# HG changeset patch # User tobaru # Date 1576826205 -32400 # Node ID 74d9f25dcb76aff159e4c733513d6dbbca64be64 # Parent 57386e27708b5503c78cb8633942e759cb11edc6# Parent 2c63276c6b04e909e43d71bbd37697e186fc4701 merge diff -r 57386e27708b -r 74d9f25dcb76 .hgignore --- a/.hgignore Fri Dec 20 16:13:46 2019 +0900 +++ b/.hgignore Fri Dec 20 16:16:45 2019 +0900 @@ -14,3 +14,4 @@ */Makefile mkfs +*.orig diff -r 57386e27708b -r 74d9f25dcb76 connect.gdb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/connect.gdb Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,2 @@ +symbol kernel.elf +target remote tcp::1234 diff -r 57386e27708b -r 74d9f25dcb76 debug.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debug.sh Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,2 @@ +#!/bin/sh +arm-none-eabi-gdb -x connect.gdb diff -r 57386e27708b -r 74d9f25dcb76 src/CMakeLists.txt diff -r 57386e27708b -r 74d9f25dcb76 src/Makefile.osx --- a/src/Makefile.osx Fri Dec 20 16:13:46 2019 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -# specify path to QEMU, installed with MacPorts -QEMU = qemu-system-arm - -include makefile-osx.inc - -# link the libgcc.a for __aeabi_idiv. ARM has no native support for div -LIBS = $(LIBGCC) - -OBJS = \ - lib/string.o \ - \ - arm.o\ - asm.o\ - bio.o\ - buddy.o\ - console.o\ - exec.o\ - file.o\ - fs.o\ - log.o\ - main.o\ - memide.o\ - pipe.o\ - proc.o\ - spinlock.o\ - start.o\ - swtch.o\ - syscall.o\ - sysfile.o\ - sysproc.o\ - trap_asm.o\ - trap.o\ - vm.o \ - \ - device/picirq.o \ - device/timer.o \ - device/uart.o - -KERN_OBJS = $(OBJS) entry-osx.o -kernel.elf: $(addprefix build/,$(KERN_OBJS)) kernel.ld build/initcode build/fs.img - cp -f build/initcode initcode - cp -f build/fs.img fs.img - $(call LINK_BIN, kernel.ld, kernel.elf, \ - $(addprefix build/,$(KERN_OBJS)), \ - initcode fs.img) - $(OBJDUMP) -S kernel.elf > kernel.asm - $(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym - rm -f initcode fs.img - -qemu: kernel.elf - @clear - @echo "Press Ctrl-A and then X to terminate QEMU session\n" - $(QEMU) -M versatilepb -m 128 -cpu arm1176 -nographic -kernel kernel.elf - -INITCODE_OBJ = initcode.o -$(addprefix build/,$(INITCODE_OBJ)): initcode.S - $(call build-directory) - $(call AS_WITH, -nostdinc -I.) - -#initcode is linked into the kernel, it will be used to craft the first process -build/initcode: $(addprefix build/,$(INITCODE_OBJ)) - $(call LINK_INIT, -e start ) - $(call OBJCOPY_INIT) - $(OBJDUMP) -S $< > initcode.asm - -build/fs.img: - make -C tools - make -C usr - -clean: - rm -rf build - rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \ - initcode initcode.out kernel xv6.img fs.img kernel.elf memfs - make -C tools clean - make -C usr clean diff -r 57386e27708b -r 74d9f25dcb76 src/file.h --- a/src/file.h Fri Dec 20 16:13:46 2019 +0900 +++ b/src/file.h Fri Dec 20 16:16:45 2019 +0900 @@ -1,3 +1,4 @@ +/* typedef struct file { enum { FD_NONE, FD_PIPE, FD_INODE } type; int ref; // reference count @@ -7,7 +8,10 @@ struct inode *ip; uint off; } file; +*/ // in-memory copy of an inode + +/* struct inode { uint dev; // Device number uint inum; // Inode number @@ -21,9 +25,13 @@ uint size; uint addrs[NDIRECT+1]; }; +*/ + #define I_BUSY 0x1 #define I_VALID 0x2 + + // table mapping major device number to // device functions struct devsw { diff -r 57386e27708b -r 74d9f25dcb76 src/file_read.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/file_read.cbc Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,33 @@ +#include "../context.h" +#interface "SysRead.h" + +// ---- +// typedef struct FileRead impl SysRead { +// struct file* f; +// int r; +// __code cbc_fileread1(Type* file_read, struct file* f,int r,__code next(r,...)); +// __code next(...); +// } FileRead; +// ---- + +SysRead* createFileReadInstFromFile(struct Context* cbc_context, struct file* f,char* addr, int n) { + if (f->type == FD_PIPE) { + return create_piperead(cbc_context, f->pipe, addr, n, next); + } + + if (f->type == FD_INODE) { + ilock(f->ip); + return create_readi(cbc_context, f->ip, addr, f->off, n, cbc_fileread1); + } + return NULL; //Error? +} + +__code selectReadInstance(struct Context cbc_context, struct file* f, __code next(int i)) { + if (f->readable == 0) { + i = -1; + goto next(i); + } + SysRead* read = createFileReadInstFromFile(proc->cbc_context, f); + goto read->read(f,addr,n); +} + diff -r 57386e27708b -r 74d9f25dcb76 src/fs.c diff -r 57386e27708b -r 74d9f25dcb76 src/gearsTools/lib/Gears/Context.pm --- a/src/gearsTools/lib/Gears/Context.pm Fri Dec 20 16:13:46 2019 +0900 +++ b/src/gearsTools/lib/Gears/Context.pm Fri Dec 20 16:16:45 2019 +0900 @@ -30,7 +30,7 @@ for my $cbc_file (@{$self->{compile_sources}}) { open my $fh , '<', $cbc_file; while (my $line = <$fh>) { - if ($line =~ /#interface\s*"(.*)\.h"/ || $line =~ /^\/\/\s*use\s*"(.*)\.h"/) { + if ($line =~ /#interface\s*"(.*)\.h"/ || $line =~ /^\/\/\s*data_gear\s*"(.*)\.(?:h|dg)?"/) { $self->{data_gears_with_count}->{$1}->{caller}->{$cbc_file}++; $counter{interfaces}->{$1}++; next; @@ -41,15 +41,15 @@ next; } - if ($line =~ /^(\w+)(\*)+ *create(\w+)\(([^]]*)\)/) { - my $interface = $1; - my $implementation = $3; - $self->{data_gears_with_count}->{$interface}->{caller}->{$cbc_file}++; - $self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}++; - $counter{interfaces}->{$interface}++; - $counter{impl}->{$implementation}++; - next; - } + #if ($line =~ /^(\w+)(\*)+ *create(\w+)\(([^]]*)\)/) { + # my $interface = $1; + # my $implementation = $3; + # $self->{data_gears_with_count}->{$interface}->{caller}->{$cbc_file}++; + # $self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}++; + # $counter{interfaces}->{$interface}++; + # $counter{impl}->{$implementation}++; + # next; + #} if ($line =~ /Gearef\(context,\s*(\w+)\)/) { my $implementation = $1; @@ -166,6 +166,19 @@ sub tree2data_struct_str { my ($self, $dg_str) = @_; my $data_struct_str = ""; + + # 定義順で大変なのでオミット + ##もとのxv6に登録されているものはcontext.hには定義を書かない + #my $alread_defined_str = _already_defined_struct(); + #for my $str (sort keys %$dg_str) { + # if (defined $alread_defined_str->{$str}) { + # my $str_name = $alread_defined_str->{$str}; + # $data_struct_str .= "struct $str_name $str_name;\n"; + # delete $dg_str->{$str_name}; + # } + #} + + #定義されてないものはcontext.hに書くフォーマットに合わせておく for my $interface (sort keys %$dg_str) { $data_struct_str .= Gears::Util->h2context_str($dg_str->{$interface}->{elem}); next unless ($dg_str->{$interface}->{impl}); @@ -207,7 +220,7 @@ my $header_paths = Gears::Util->find_headers_path($search_bash_path); map { - if (/(\w+)\.h/) { + if (/(\w+)\.(?:h|dg)/) { my $header_file = $1; if (exists $res{$header_file}) { if ($res{$header_file} =~ /^\d+$/){ @@ -221,4 +234,31 @@ return \%res; } +sub _already_defined_struct { + my @struct_list = qw/ +__jmp_buf_tag +buf +cbc_devsw +context +cpu +devsw +dinode +dirent +elfhdr +file +inode +pipe +proc +proghdr +spinlock +stat +superblock +trapframe +/; + + my %def_hash; + map { $def_hash{$_} = $_} @struct_list; + return \%def_hash; +} + 1; diff -r 57386e27708b -r 74d9f25dcb76 src/gearsTools/lib/Gears/Context/Template/XV6.pm --- a/src/gearsTools/lib/Gears/Context/Template/XV6.pm Fri Dec 20 16:13:46 2019 +0900 +++ b/src/gearsTools/lib/Gears/Context/Template/XV6.pm Fri Dec 20 16:16:45 2019 +0900 @@ -109,8 +109,13 @@ #define GearImpl(cbc_context, intf, name) (Gearef(cbc_context, intf)->name->intf.name) +#ifndef CBC_XV6_CONTEXT +#define CBC_XV6_CONTEXT TRUE + #include "c/enumCode.h" +#include "types.h" + enum Relational { EQ, GT, @@ -120,6 +125,7 @@ #include "c/enumData.h" #define NDIRECT 12 //fs.h + struct Context { enum Code next; struct Worker* worker; @@ -169,6 +175,7 @@ struct Context Context; }; // union Data end this is necessary for context generator typedef union Data Data; +#endif EOF } @@ -176,6 +183,9 @@ sub emit_last_header { my($class, $out) = @_; print $out <<'EOF'; + + + #include "c/typedefData.h" #include "c/extern.h" diff -r 57386e27708b -r 74d9f25dcb76 src/gearsTools/trans_impl.pl --- a/src/gearsTools/trans_impl.pl Fri Dec 20 16:13:46 2019 +0900 +++ b/src/gearsTools/trans_impl.pl Fri Dec 20 16:16:45 2019 +0900 @@ -7,12 +7,13 @@ use Gears::Util; use Getopt::Std; +use File::Spec; my %opt; -getopts("w" => \%opt); +getopts("wo:" => \%opt); my $impl_file = shift or die 'require impl file'; -my $impl_ir = Gears::Util->parse_with_rewrite($impl_file); +my $impl_ir = Gears::Util->parse_with_rewrite(File::Spec->rel2abs($impl_file)); my $interface_file = Gears::Util->find_header($impl_ir->{isa},"$FindBin::Bin/.."); my $inter_ir = Gears::Util->parse_with_rewrite($interface_file); @@ -20,24 +21,26 @@ my $output_file = $impl_file; $output_file =~ s/\.h/.cbc/; -open my $fh, '>', $output_file; -my $stdout = $fh; +my $stdout = *STDOUT; -unless ($opt{w}) { - $stdout = *STDOUT; +if ($opt{w}) { + open $stdout, '>', $output_file; +} elsif ($opt{o}) { + open $stdout, '>', $opt{o}; } + emit_include_part($stdout, $inter_ir->{name}); emit_impl_header_in_comment($stdout, $impl_file); emit_constracutor($stdout,$impl_ir,$inter_ir); emit_code_gears($stdout,$impl_ir,$inter_ir); -close $fh; +close $stdout; sub emit_include_part { my ($out, $interface) = @_; print $out <<"EOF" -#include "../context.h"; -#interface "$interface.h"; +#include "../context.h" +#interface "$interface.h" EOF } @@ -79,6 +82,16 @@ if ($datum =~ /\w+ \w+ (\w+)/) { print $out " ${instance_impl}->$1 = 0;\n"; } + + if ($datum =~ /\w+(\*)? (\w+)/) { + my $is_pointer = $1; + my $var_name = $2; + if ($1) { + print $out " ${instance_impl}->$var_name = NULL;\n"; + } else { + print $out " ${instance_impl}->$var_name = 0;\n"; + } + } } for my $datum (@inter_data) { @@ -88,7 +101,23 @@ } if ($datum =~ /\w+ \w+ (\w+)/) { print $out " ${instance_inter}->$1 = 0;\n"; + next; } + if ($datum =~ /\w+(\*)? (\w+)/) { + my $is_pointer = $1; + my $var_name = $2; + if ($1) { + print $out " ${instance_inter}->$var_name = NULL;\n"; + } else { + print $out " ${instance_inter}->$var_name = 0;\n"; + } + } + } + + + for my $code (@{$impl_ir->{codes}}) { + my $code_gear = $code->{name}; + print $out " ${instance_impl}->$code_gear = C_$code_gear$impl_ir->{name};\n" } for my $code (@{$inter_ir->{codes}}) { @@ -104,6 +133,7 @@ sub emit_code_gears { my ($out, $impl_ir, $inter_ir) = @_; my $impl = $impl_ir->{name}; + my $interface_name = $inter_ir->{name}; my @inter_data = @{$inter_ir->{data}}; my $instance_inter = shift @inter_data; @@ -114,22 +144,45 @@ $instance_impl =~ s/([A-Z])/_\l$1/g; my $data_gear_types = {}; + if (defined $impl_ir->{codes}) { + for my $cg (@{$impl_ir->{codes}}) { + my $data_gears = $cg->{args}; + while ($data_gears =~ /Type\*\s*(\w+),/g) { + $data_gears =~ s/Type\*/struct $impl*/; + } + + while ($data_gears =~ /Isa\*\s*(\w+),/g) { + $data_gears =~ s/Isa\*/struct $interface_name*/; + } + print $out "__code $cg->{name}$impl("; + print $out "$data_gears) {\n\n"; + + #__code next(...), __code whenEmpty(...) + my @cg = (); + while ($data_gears =~ /__code ([\w(\.)\*\s,]+?\)),?/g) { + push(@cg, $1); + } + + if (@cg) { + if (@cg == 2) { + print $out " if (:TODO:) {\n"; + print $out " goto ",shift(@cg),";\n"; + print $out " }\n"; + print $out " goto ",shift(@cg),";\n"; + } else { + print $out " goto ",shift(@cg),";\n"; + } + } + print $out "}\n\n"; + } + } + for my $code_ir (@{$inter_ir->{codes}}) { my $data_gears = $code_ir->{args}; $data_gears =~ s/Impl/struct $impl/g; + while ($data_gears =~ /Type\*\s*(\w+),/g) { - my $target = $1; - if (exists $data_gear_types->{$target}){ - $data_gears =~ s/Type\*/$data_gear_types->{$target}/; - } else { - my $td = ""; - map { $td = $_ if ($_ =~ /$target/) } @inter_data; - if ($td =~ /(\w+)\s*([\w\*]+)\s*(\w+)/) { - my $tmp = "$1 $2"; - $data_gears =~ s/Type\*/$tmp/; - $data_gear_types->{$target} = $tmp; - } - } + $data_gears =~ s/Type\*/struct $interface_name*/; } print $out "__code $code_ir->{name}$impl("; diff -r 57386e27708b -r 74d9f25dcb76 src/gearsTools/update_context.pl --- a/src/gearsTools/update_context.pl Fri Dec 20 16:13:46 2019 +0900 +++ b/src/gearsTools/update_context.pl Fri Dec 20 16:16:45 2019 +0900 @@ -12,7 +12,7 @@ my $interface_file = shift or die "require itnerface file"; my $h2context = Gears::Util->parse_interface($interface_file); -my $context = dump_h2context($h2context); +my $context = Gears::Util->h2context_str($h2context); if ($opt{c}) { print "$context"; @@ -56,25 +56,6 @@ return (\@first_context_headers,\@last_context_headers); } -sub dump_h2context { - my $h2context = shift; - my $context = ''; - my $space = ' '; - #print "${space}struct $h2context->{name} {\n"; - $context = "${space}struct $h2context->{name} {\n"; - for my $datum (@{$h2context->{data}}) { - #print "${space}${space}$datum; \n"; - $context .= "${space}${space}$datum;\n"; - } - for my $code (@{$h2context->{codes}}) { - #print "${space}${space}enum Code $code;\n"; - $context .= "${space}${space}enum Code $code;\n"; - } - #print "${space}} $h2context->{name};\n"; - $context .= "${space}} $h2context->{name};\n"; - return $context; -} - sub context_dump { for my $line (@_) { print "$line"; diff -r 57386e27708b -r 74d9f25dcb76 src/impl/FileRead.cbc --- a/src/impl/FileRead.cbc Fri Dec 20 16:13:46 2019 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -#include "../context.h"; -#interface "SysRead.h"; - -// ---- -// typedef struct FileRead impl SysRead { -// struct file* f; -// } FileRead; -// ---- - -SysRead* createFileRead(struct Context* cbc_context) { - struct SysRead* sys_read = new SysRead(); - struct FileRead* file_read = new FileRead(); - sys_read->sys_read = (union Data*)file_read; - file_read->f = NULL; - sys_read->num = NULL; - sys_read->read = C_readFileRead; - sys_read->next = C_nextFileRead; - return sys_read; -} -__code readFileRead(__code next(...)) { - - goto next(...); -} - -__code nextFileRead(...) { - -} - diff -r 57386e27708b -r 74d9f25dcb76 src/impl/FileRead.h diff -r 57386e27708b -r 74d9f25dcb76 src/impl/PipeRead.cbc --- a/src/impl/PipeRead.cbc Fri Dec 20 16:13:46 2019 +0900 +++ b/src/impl/PipeRead.cbc Fri Dec 20 16:16:45 2019 +0900 @@ -1,11 +1,15 @@ -#include "../context.h"; -#interface "SysRead.h"; +#include "../context.h" +#interface "SysRead.h" // ---- // typedef struct PipeRead impl SysRead { -// struct CbCPipe *pipe; -// struct String *addr; -// struct Integer* i; +// struct pipe* p; +// int i; +// int n; +// __code cbc_piperead1(Type* sys_read, struct pipe* p, __code next(...)); +// __code cbc_piperead2(Type* sys_read, int i, int n, struct pipe* p, __code next(...)); +// __code cbc_piperead3(Type* sys_read, int i, struct pipe* p, __code next(...)); +// __code next(...); // } PipeRead; // ---- @@ -13,17 +17,73 @@ struct SysRead* sys_read = new SysRead(); struct PipeRead* pipe_read = new PipeRead(); sys_read->sys_read = (union Data*)pipe_read; - pipe_read->num = NULL; + pipe_read->p = NULL; + pipe_read->i = 0; + pipe_read->n = 0; + sys_read->impl = NULL; + sys_read->addr = NULL; + sys_read->n = 0; + pipe_read->cbc_piperead1 = C_cbc_piperead1PipeRead; + pipe_read->cbc_piperead2 = C_cbc_piperead2PipeRead; + pipe_read->cbc_piperead3 = C_cbc_piperead3PipeRead; + //pipe_read->next = C_nextPipeRead; sys_read->read = C_readPipeRead; sys_read->next = C_nextPipeRead; return sys_read; } -__code readPipeRead(__code next(...)) { + +SysRead* createPipeReadUseArgs(struct Context* cbc_context,struct pipe* p, char* addr, int n) { + struct SysRead* sys_read = new SysRead(); + struct PipeRead* pipe_read = new PipeRead(); + sys_read->sys_read = (union Data*)pipe_read; + + pipe_read->p = p; + pipe_read->i = 0; + pipe_read->n = n; + + sys_read->impl = (union Data*)p; + sys_read->addr = addr; + sys_read->n = n; + + pipe_read->cbc_piperead1 = C_cbc_piperead1PipeRead; + pipe_read->cbc_piperead2 = C_cbc_piperead2PipeRead; + pipe_read->cbc_piperead3 = C_cbc_piperead3PipeRead; + //pipe_read->next = C_nextPipeRead; + sys_read->read = C_readPipeRead; + sys_read->next = C_nextPipeRead; + return sys_read; +} + +__code cbc_piperead1PipeRead(struct PipeRead* sys_read, struct pipe* p, __code error(int err), __code next(int i, p,...)) { + if (p->nread == p->nwrite && p->writeopen){ + if(proc->killed){ + release(&p->lock); + goto error(-1); + } + goto cbc_sleep(&p->nread, &p->lock, cbc_piperead1); + } + goto next(i,p,...); +} + +__code cbc_piperead2PipeRead(struct PipeRead* sys_read, int i, int n, struct pipe* p,char* addr, __code next(...)) { + if (i < n && !(p->nread == p->nwrite)) { + addr[i] = p->data[p->nread++ % PIPESIZE]; + i++; + goto sys_read->cbc_piperead2(i,n,p,addr,cbc_wakeup); + } + goto cbc_wakeup(&p->nwrite, cbc_piperead3); //DOC: piperead-wakeup goto next(...); } -__code nextPipeRead(...) { - +__code cbc_piperead3PipeRead(struct PipeRead* sys_read, int i, struct pipe* p, __code next(...)) { + release(&p->lock); + goto sys_read->ret(i,...); } +__code readPipeRead(struct PipeRead* sys_read, union Data* impl, char* addr, int n, __code next(int ret,...)) { + + goto next(int ret,...); +} + + diff -r 57386e27708b -r 74d9f25dcb76 src/impl/PipeRead.h --- a/src/impl/PipeRead.h Fri Dec 20 16:13:46 2019 +0900 +++ b/src/impl/PipeRead.h Fri Dec 20 16:16:45 2019 +0900 @@ -1,5 +1,9 @@ typedef struct PipeRead impl SysRead { - struct CbCPipe *pipe; - struct String *addr; - struct Integer* i; + struct pipe* p; + int i; + int n; + __code cbc_piperead1(Type* sys_read, struct pipe* p, __code next(...)); + __code cbc_piperead2(Type* sys_read, int i, int n, struct pipe* p, __code next(...)); + __code cbc_piperead3(Type* sys_read, int i, struct pipe* p, __code next(...)); + __code next(...); } PipeRead; diff -r 57386e27708b -r 74d9f25dcb76 src/impl/SysOpenImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/impl/SysOpenImpl.h Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,3 @@ +typedef struct SysOpenImpl impl SysOpen { + +} SysOpenImpl; diff -r 57386e27708b -r 74d9f25dcb76 src/interface/SysOpen.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/interface/SysOpen.h Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,12 @@ +typedef struct SysOpen{ + union Data* sys_open; + int fd; + int omode; + char* addr; + struct file* file; + struct inode* ip; + + __code open(Impl* sys_open, int fd, int omode, char* addr, struct file* file, struct inode* ip, __code next(...)); + + __code next(...); +} SysOpen; diff -r 57386e27708b -r 74d9f25dcb76 src/interface/SysRead.h --- a/src/interface/SysRead.h Fri Dec 20 16:13:46 2019 +0900 +++ b/src/interface/SysRead.h Fri Dec 20 16:16:45 2019 +0900 @@ -1,9 +1,9 @@ typedef struct SysRead{ - union Data* sys_read; - struct UInteger* num; - struct Integer* n; - struct String *p; - __code read(Type* sys_read, __code next(...)); - //__code ret(Impl* cbc_sys_file, UInteger* num); + union Data* sys_read; + union Data* impl; + char* addr; + int n; + + __code read(Impl* sys_read, union Data* impl, char* addr, int n, __code next(int ret,...)); __code next(...); } SysRead; diff -r 57386e27708b -r 74d9f25dcb76 src/interface/file.dg --- a/src/interface/file.dg Fri Dec 20 16:13:46 2019 +0900 +++ b/src/interface/file.dg Fri Dec 20 16:16:45 2019 +0900 @@ -5,5 +5,5 @@ char writable; struct pipe *pipe; struct inode *ip; - uint off; + unsigned int off; } file; diff -r 57386e27708b -r 74d9f25dcb76 src/makefile-armclang --- a/src/makefile-armclang Fri Dec 20 16:13:46 2019 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -# specify path to QEMU, installed with MacPorts -QEMU = qemu-system-arm - -CPU = armv8 -QEMUCPU = cortex-a15 -include makefile.inc -CC = /usr/local/cbclang/bin/clang -AS = arm-linux-gnu-as -LD = arm-linux-gnu-ld -OBJCOPY = arm-linux-gnu-objcopy -OBJDUMP = arm-linux-gnu-objdump - -# CFLAGS = -march=${CPU} -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 -CFLAGS = -target ${CPU}-linux-gnueabihf -march=${CPU} -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -I ../cbclang/arm -g -O0 -LDFLAGS = --noinhibit-exec -# ASFLAGS = -march=${CPU} -ASFLAGS = -target ${CPU}-linux-gnueabihf - -LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) - -# link the libgcc.a for __aeabi_idiv. ARM has no native support for div -LIBS =/net/open/RaspberryPi/rasbian-img/usr/lib/gcc/arm-linux-gnueabihf/6/libgcc.a - - -OBJS = \ - lib/string.o \ - \ - arm.o\ - asm.o\ - bio.o\ - buddy.o\ - console.o\ - exec.o\ - file.o\ - fs.o\ - log.o\ - main.o\ - memide.o\ - pipe.o\ - proc.o\ - spinlock.o\ - start.o\ - swtch.o\ - syscall.o\ - sysfile.o\ - sysproc.o\ - trap_asm.o\ - trap.o\ - vm.o \ - \ - device/picirq.o \ - device/timer.o \ - device/uart.o - -KERN_OBJS = $(OBJS) entry-clang.o -kernel.elf: $(addprefix build/,$(KERN_OBJS)) kernel-clang.ld build/initcode build/fs.img - cp -f build/initcode initcode - cp -f build/fs.img fs.img - $(call LINK_BIN, kernel-clang.ld, kernel.elf, \ - $(addprefix build/,$(KERN_OBJS)), \ - initcode fs.img) - $(OBJDUMP) -S kernel.elf > kernel.asm - $(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym - rm -f initcode fs.img - -qemu: kernel.elf - @clear - @echo "Press Ctrl-A and then X to terminate QEMU session\n" - export QEMU_AUDIO_DRV=none ; $(QEMU) -M versatilepb -m 128 -cpu ${QEMUCPU} -nographic -soundhw hda -kernel kernel.elf - -qemu-debug : kernel.elf - @clear - @echo "Press Ctrl-A and then X to terminate QEMU session\n" - export QEMU_AUDIO_DRV=none ; $(QEMU) -M versatilepb -m 128 -cpu ${QEMUCPU} -nographic -singlestep -d exec,cpu,guest_errors -D qemu.log -kernel kernel.elf -s -S - -INITCODE_OBJ = initcode.o -$(addprefix build/,$(INITCODE_OBJ)): initcode.S - $(call build-directory) - $(call AS_WITH, -nostdinc -I.) - -#initcode is linked into the kernel, it will be used to craft the first process -build/initcode: $(addprefix build/,$(INITCODE_OBJ)) - $(call LINK_INIT, -N -e start -Ttext 0) - $(call OBJCOPY_INIT) - $(OBJDUMP) -S $< > initcode.asm - -build/fs.img: - make -C tools - make -C usr - -clean: - rm -rf build - rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \ - initcode initcode.out kernel xv6.img fs.img kernel.elf memfs - make -C tools clean - make -C usr clean diff -r 57386e27708b -r 74d9f25dcb76 src/makefile-armgcc4.8.5 --- a/src/makefile-armgcc4.8.5 Fri Dec 20 16:13:46 2019 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,96 +0,0 @@ -# specify path to QEMU, installed with MacPorts -QEMU = qemu-system-arm - -include makefile.inc - -CC = arm-linux-gnu-gcc -AS = arm-linux-gnu-as -LD = arm-linux-gnu-ld -OBJCOPY = arm-linux-gnu-objcopy -OBJDUMP = arm-linux-gnu-objdump - -CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0 - -ASFLAGS = - -LIBGCC = $(shell $(CC) -print-libgcc-file-name) - -LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \ - -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@") - -LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \ - $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@") -OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \ - -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@") - - -# link the libgcc.a for __aeabi_idiv. ARM has no native support for div -LIBS = $(LIBGCC) - -OBJS = \ - lib/string.o \ - \ - arm.o\ - asm.o\ - bio.o\ - buddy.o\ - console.o\ - exec.o\ - file.o\ - fs.o\ - log.o\ - main.o\ - memide.o\ - pipe.o\ - proc.o\ - spinlock.o\ - start.o\ - swtch.o\ - syscall.o\ - sysfile.o\ - sysproc.o\ - trap_asm.o\ - trap.o\ - vm.o \ - \ - device/picirq.o \ - device/timer.o \ - device/uart.o - -KERN_OBJS = $(OBJS) entry.o -kernel.elf: $(addprefix build/,$(KERN_OBJS)) kernel.ld build/initcode build/fs.img - cp -f build/initcode initcode - cp -f build/fs.img fs.img - $(call LINK_BIN, kernel.ld, kernel.elf, \ - $(addprefix build/,$(KERN_OBJS)), \ - initcode fs.img) - $(OBJDUMP) -S kernel.elf > kernel.asm - $(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym - rm -f initcode fs.img - -qemu: kernel.elf - @clear - @echo "Press Ctrl-A and then X to terminate QEMU session\n" - $(QEMU) -M versatilepb -m 128 -cpu arm1176 -nographic -kernel kernel.elf - -INITCODE_OBJ = initcode.o -$(addprefix build/,$(INITCODE_OBJ)): initcode.S - $(call build-directory) - $(call AS_WITH, -nostdinc -I.) - -#initcode is linked into the kernel, it will be used to craft the first process -build/initcode: $(addprefix build/,$(INITCODE_OBJ)) - $(call LINK_INIT, -N -e start -Ttext 0) - $(call OBJCOPY_INIT) - $(OBJDUMP) -S $< > initcode.asm - -build/fs.img: - make -C tools - make -C usr - -clean: - rm -rf build - rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \ - initcode initcode.out kernel xv6.img fs.img kernel.elf memfs - make -C tools clean - make -C usr clean diff -r 57386e27708b -r 74d9f25dcb76 src/makefile-armgccbc --- a/src/makefile-armgccbc Fri Dec 20 16:13:46 2019 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -# specify path to QEMU, installed with MacPorts -QEMU = qemu-system-arm - -include makefile.inc - -CC = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc -B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- -#AS = arm-linux-gnu-gcc -AS = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc -#LD = arm-linux-gnu-ld -LD = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-ld -#OBJCOPY = arm-linux-gnu-objcopy -OBJCOPY = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-objcopy -#OBJDUMP = arm-linux-gnu-objdump -OBJDUMP = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-objdump -CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0 - -ASFLAGS = - -LIBGCC = $(shell $(CC) -print-libgcc-file-name) - -LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \ - -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@") - -LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \ - $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@") -OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \ - -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@") -AS_WITH = $(call quiet-command,$(AS) $(ASFLAGS) \ - $(1) -c -o $@ $<," AS $(TARGET_DIR)$@") - -# link the libgcc.a for __aeabi_idiv. ARM has no native support for div -LIBS = $(LIBGCC) - -CMAKEDIR = CMakeFiles/kernel.dir - -OBJS = \ - $(CMAKEDIR)/lib/string.c.o \ - $(CMAKEDIR)/c/kernel-context.c.o\ - $(CMAKEDIR)/arm.c.o\ - $(CMAKEDIR)/asm.S.o\ - $(CMAKEDIR)/bio.c.o\ - $(CMAKEDIR)/buddy.c.o\ - $(CMAKEDIR)/c/console.c.o\ - $(CMAKEDIR)/exec.c.o\ - $(CMAKEDIR)/c/file.c.o\ - $(CMAKEDIR)/fs.c.o\ - $(CMAKEDIR)/log.c.o\ - $(CMAKEDIR)/main.c.o\ - $(CMAKEDIR)/memide.c.o\ - $(CMAKEDIR)/c/pipe.c.o\ - $(CMAKEDIR)/c/proc.c.o\ - $(CMAKEDIR)/c/spinlock.c.o\ - $(CMAKEDIR)/start.c.o\ - $(CMAKEDIR)/swtch.S.o\ - $(CMAKEDIR)/c/syscall.c.o\ - $(CMAKEDIR)/c/sysfile.c.o\ - $(CMAKEDIR)/sysproc.c.o\ - $(CMAKEDIR)/trap_asm.c.o\ - $(CMAKEDIR)/trap.c.o\ - $(CMAKEDIR)/vm.c.o \ - \ - $(CMAKEDIR)/device/picirq.c.o \ - $(CMAKEDIR)/device/timer.c.o \ - $(CMAKEDIR)/device/uart.c.o - -KERN_OBJS = $(OBJS) entry.S.o -kernel.elf: $(KERN_OBJS) kernel.ld build/initcode build/fs.img - cp -f build/initcode initcode - cp -f build/fs.img fs.img - $(call LINK_BIN, kernel.ld, kernel.elf, \ - $(KERN_OBJS), \ - initcode fs.img) - $(OBJDUMP) -S kernel.elf > kernel.asm - $(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym - rm -f initcode fs.img - -qemu: kernel.elf - @clear - @echo "Press Ctrl-A and then X to terminate QEMU session\n" - $(QEMU) -M versatilepb -m 128 -cpu arm1176 -nographic -kernel kernel.elf - -INITCODE_OBJ = initcode.o -$(addprefix build/,$(INITCODE_OBJ)): initcode.S - $(call build-directory) - $(call AS_WITH, -nostdinc -I.) - -#initcode is linked into the kernel, it will be used to craft the first process -build/initcode: $(addprefix build/,$(INITCODE_OBJ)) - $(call LINK_INIT, -N -e start -Ttext 0) - $(call OBJCOPY_INIT) - $(OBJDUMP) -S $< > initcode.asm - -build/fs.img: - make -C tools - make -C usr -f makfile-armgccbc - -clean: - rm -rf build - rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \ - initcode initcode.out kernel xv6.img fs.img kernel.elf memfs - make -C tools clean - make -C usr clean diff -r 57386e27708b -r 74d9f25dcb76 src/makefile-osx.inc --- a/src/makefile-osx.inc Fri Dec 20 16:13:46 2019 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -# Cross-compiling (e.g., on Mac OS X, install arm-none-eabi-gcc with MacPorts) -CROSSCOMPILE := - -CC = $(CROSSCOMPILE)/Users/one/src/cbclang-arm/build/bin/clang -AS = $(CROSSCOMPILE)as -LD = $(CROSSCOMPILE)ld -OBJCOPY = $(CROSSCOMPILE)objcopy -OBJDUMP = $(CROSSCOMPILE)objdump - -CFLAGS = -arch arm -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 \ - -Wno-macro-redefined -Wno-gnu-designator -Wno-sometimes-uninitialized -Wno-tautological-compare \ - -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include -LDFLAGS = -L. -arch armv7 -ASFLAGS = -arch arm - -LIBGCC = $(shell $(CC) -print-libgcc-file-name) - -# host compiler -HOSTCC_preferred = clang -define get_hostcc - $(if $(shell which $(HOSTCC_preferred)),$(HOSTCC_preferred),"cc") -endef -HOSTCC := $(call get_hostcc) - -# general rules -quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) - -LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \ - -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@") - -LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \ - $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@") -OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \ - -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@") - -build-directory = $(shell mkdir -p build build/device build/lib) - -build/%.o: %.c - $(call build-directory) - $(call quiet-command,$(CC) $(CFLAGS) \ - -c -o $@ $<," CC $(TARGET_DIR)$@") - -AS_WITH = $(call quiet-command,$(CC) $(ASFLAGS) \ - $(1) -c -o $@ $<," AS $(TARGET_DIR)$@") - -build/%.o: %.S - $(call build-directory) - $(call AS_WITH, ) diff -r 57386e27708b -r 74d9f25dcb76 src/makefile.inc --- a/src/makefile.inc Fri Dec 20 16:13:46 2019 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -# Cross-compiling (e.g., on Mac OS X, install arm-none-eabi-gcc with MacPorts) - -CROSSCOMPILE := arm-linux-gnu- - -CPU = armv8 -#CC = /usr/local/cbclang/bin/clang -AS = $(CROSSCOMPILE)as -LD = $(CROSSCOMPILE)ld -OBJCOPY = $(CROSSCOMPILE)objcopy -OBJDUMP = $(CROSSCOMPILE)objdump - -# CFLAGS = -march=${CPU} -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 -CFLAGS = -target ${CPU}-none-eabi -I /net/open/Linux/arm/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/ /net/open/Linux/arm/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include-fixed/ -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0 -LDFLAGS = -L. -# ASFLAGS = -march=${CPU} -ASFLAGS = -target ${CPU}-none-eabi - -#LIBGCC = $(shell $(gcc) -print-libgcc-file-name) -LIBGCC = /net/open/Linux/arm/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/libgcc.a - -# host compiler - HOSTCC_preferred = gcc -#HOSTCC_preferred = /usr/local/cbclang/bin/clang -define get_hostcc - $(if $(shell which $(HOSTCC_preferred)),$(HOSTCC_preferred),"cc") -endef -HOSTCC := $(call get_hostcc) - -# general rules -quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) - -LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \ - -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@") - -LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \ - $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@") -OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \ - -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@") - -build-directory = $(shell mkdir -p build build/device build/lib) - -build/%.o: %.c - $(call build-directory) - $(call quiet-command,$(CC) $(CFLAGS) \ - -c -o $@ $<," CC $(TARGET_DIR)$@") - -build/%.o: %.cbc - $(call build-directory) - $(call quiet-command,$(CC) $(CFLAGS) \ - -c -o $@ $<," CC $(TARGET_DIR)$@") - -AS_WITH = $(call quiet-command,$(CC) $(ASFLAGS) \ - $(1) -c -o $@ $<," AS $(TARGET_DIR)$@") - -build/%.o: %.S - $(call build-directory) - $(call AS_WITH, ) diff -r 57386e27708b -r 74d9f25dcb76 src/move_data_gears/pipe.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/move_data_gears/pipe.h Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,9 @@ +typedef struct pipe { + #define PIPESIZE 512 + struct spinlock lock; + char data[PIPESIZE]; + uint nread; // number of bytes read + uint nwrite; // number of bytes written + int readopen; // read fd is still open + int writeopen; // write fd is still open +} pipe; diff -r 57386e27708b -r 74d9f25dcb76 src/old_makefiles/Makefile.osx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/old_makefiles/Makefile.osx Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,75 @@ +# specify path to QEMU, installed with MacPorts +QEMU = qemu-system-arm + +include makefile-osx.inc + +# link the libgcc.a for __aeabi_idiv. ARM has no native support for div +LIBS = $(LIBGCC) + +OBJS = \ + lib/string.o \ + \ + arm.o\ + asm.o\ + bio.o\ + buddy.o\ + console.o\ + exec.o\ + file.o\ + fs.o\ + log.o\ + main.o\ + memide.o\ + pipe.o\ + proc.o\ + spinlock.o\ + start.o\ + swtch.o\ + syscall.o\ + sysfile.o\ + sysproc.o\ + trap_asm.o\ + trap.o\ + vm.o \ + \ + device/picirq.o \ + device/timer.o \ + device/uart.o + +KERN_OBJS = $(OBJS) entry-osx.o +kernel.elf: $(addprefix build/,$(KERN_OBJS)) kernel.ld build/initcode build/fs.img + cp -f build/initcode initcode + cp -f build/fs.img fs.img + $(call LINK_BIN, kernel.ld, kernel.elf, \ + $(addprefix build/,$(KERN_OBJS)), \ + initcode fs.img) + $(OBJDUMP) -S kernel.elf > kernel.asm + $(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym + rm -f initcode fs.img + +qemu: kernel.elf + @clear + @echo "Press Ctrl-A and then X to terminate QEMU session\n" + $(QEMU) -M versatilepb -m 128 -cpu arm1176 -nographic -kernel kernel.elf + +INITCODE_OBJ = initcode.o +$(addprefix build/,$(INITCODE_OBJ)): initcode.S + $(call build-directory) + $(call AS_WITH, -nostdinc -I.) + +#initcode is linked into the kernel, it will be used to craft the first process +build/initcode: $(addprefix build/,$(INITCODE_OBJ)) + $(call LINK_INIT, -e start ) + $(call OBJCOPY_INIT) + $(OBJDUMP) -S $< > initcode.asm + +build/fs.img: + make -C tools + make -C usr + +clean: + rm -rf build + rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \ + initcode initcode.out kernel xv6.img fs.img kernel.elf memfs + make -C tools clean + make -C usr clean diff -r 57386e27708b -r 74d9f25dcb76 src/old_makefiles/makefile-armclang --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/old_makefiles/makefile-armclang Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,96 @@ +# specify path to QEMU, installed with MacPorts +QEMU = qemu-system-arm + +CPU = armv8 +QEMUCPU = cortex-a15 +include makefile.inc +CC = /usr/local/cbclang/bin/clang +AS = arm-linux-gnu-as +LD = arm-linux-gnu-ld +OBJCOPY = arm-linux-gnu-objcopy +OBJDUMP = arm-linux-gnu-objdump + +# CFLAGS = -march=${CPU} -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 +CFLAGS = -target ${CPU}-linux-gnueabihf -march=${CPU} -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -I ../cbclang/arm -g -O0 +LDFLAGS = --noinhibit-exec +# ASFLAGS = -march=${CPU} +ASFLAGS = -target ${CPU}-linux-gnueabihf + +LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) + +# link the libgcc.a for __aeabi_idiv. ARM has no native support for div +LIBS =/net/open/RaspberryPi/rasbian-img/usr/lib/gcc/arm-linux-gnueabihf/6/libgcc.a + + +OBJS = \ + lib/string.o \ + \ + arm.o\ + asm.o\ + bio.o\ + buddy.o\ + console.o\ + exec.o\ + file.o\ + fs.o\ + log.o\ + main.o\ + memide.o\ + pipe.o\ + proc.o\ + spinlock.o\ + start.o\ + swtch.o\ + syscall.o\ + sysfile.o\ + sysproc.o\ + trap_asm.o\ + trap.o\ + vm.o \ + \ + device/picirq.o \ + device/timer.o \ + device/uart.o + +KERN_OBJS = $(OBJS) entry-clang.o +kernel.elf: $(addprefix build/,$(KERN_OBJS)) kernel-clang.ld build/initcode build/fs.img + cp -f build/initcode initcode + cp -f build/fs.img fs.img + $(call LINK_BIN, kernel-clang.ld, kernel.elf, \ + $(addprefix build/,$(KERN_OBJS)), \ + initcode fs.img) + $(OBJDUMP) -S kernel.elf > kernel.asm + $(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym + rm -f initcode fs.img + +qemu: kernel.elf + @clear + @echo "Press Ctrl-A and then X to terminate QEMU session\n" + export QEMU_AUDIO_DRV=none ; $(QEMU) -M versatilepb -m 128 -cpu ${QEMUCPU} -nographic -soundhw hda -kernel kernel.elf + +qemu-debug : kernel.elf + @clear + @echo "Press Ctrl-A and then X to terminate QEMU session\n" + export QEMU_AUDIO_DRV=none ; $(QEMU) -M versatilepb -m 128 -cpu ${QEMUCPU} -nographic -singlestep -d exec,cpu,guest_errors -D qemu.log -kernel kernel.elf -s -S + +INITCODE_OBJ = initcode.o +$(addprefix build/,$(INITCODE_OBJ)): initcode.S + $(call build-directory) + $(call AS_WITH, -nostdinc -I.) + +#initcode is linked into the kernel, it will be used to craft the first process +build/initcode: $(addprefix build/,$(INITCODE_OBJ)) + $(call LINK_INIT, -N -e start -Ttext 0) + $(call OBJCOPY_INIT) + $(OBJDUMP) -S $< > initcode.asm + +build/fs.img: + make -C tools + make -C usr + +clean: + rm -rf build + rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \ + initcode initcode.out kernel xv6.img fs.img kernel.elf memfs + make -C tools clean + make -C usr clean diff -r 57386e27708b -r 74d9f25dcb76 src/old_makefiles/makefile-armgcc4.8.5 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/old_makefiles/makefile-armgcc4.8.5 Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,96 @@ +# specify path to QEMU, installed with MacPorts +QEMU = qemu-system-arm + +include makefile.inc + +CC = arm-linux-gnu-gcc +AS = arm-linux-gnu-as +LD = arm-linux-gnu-ld +OBJCOPY = arm-linux-gnu-objcopy +OBJDUMP = arm-linux-gnu-objdump + +CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0 + +ASFLAGS = + +LIBGCC = $(shell $(CC) -print-libgcc-file-name) + +LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \ + -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@") + +LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \ + $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@") +OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \ + -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@") + + +# link the libgcc.a for __aeabi_idiv. ARM has no native support for div +LIBS = $(LIBGCC) + +OBJS = \ + lib/string.o \ + \ + arm.o\ + asm.o\ + bio.o\ + buddy.o\ + console.o\ + exec.o\ + file.o\ + fs.o\ + log.o\ + main.o\ + memide.o\ + pipe.o\ + proc.o\ + spinlock.o\ + start.o\ + swtch.o\ + syscall.o\ + sysfile.o\ + sysproc.o\ + trap_asm.o\ + trap.o\ + vm.o \ + \ + device/picirq.o \ + device/timer.o \ + device/uart.o + +KERN_OBJS = $(OBJS) entry.o +kernel.elf: $(addprefix build/,$(KERN_OBJS)) kernel.ld build/initcode build/fs.img + cp -f build/initcode initcode + cp -f build/fs.img fs.img + $(call LINK_BIN, kernel.ld, kernel.elf, \ + $(addprefix build/,$(KERN_OBJS)), \ + initcode fs.img) + $(OBJDUMP) -S kernel.elf > kernel.asm + $(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym + rm -f initcode fs.img + +qemu: kernel.elf + @clear + @echo "Press Ctrl-A and then X to terminate QEMU session\n" + $(QEMU) -M versatilepb -m 128 -cpu arm1176 -nographic -kernel kernel.elf + +INITCODE_OBJ = initcode.o +$(addprefix build/,$(INITCODE_OBJ)): initcode.S + $(call build-directory) + $(call AS_WITH, -nostdinc -I.) + +#initcode is linked into the kernel, it will be used to craft the first process +build/initcode: $(addprefix build/,$(INITCODE_OBJ)) + $(call LINK_INIT, -N -e start -Ttext 0) + $(call OBJCOPY_INIT) + $(OBJDUMP) -S $< > initcode.asm + +build/fs.img: + make -C tools + make -C usr + +clean: + rm -rf build + rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \ + initcode initcode.out kernel xv6.img fs.img kernel.elf memfs + make -C tools clean + make -C usr clean diff -r 57386e27708b -r 74d9f25dcb76 src/old_makefiles/makefile-armgccbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/old_makefiles/makefile-armgccbc Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,102 @@ +# specify path to QEMU, installed with MacPorts +QEMU = qemu-system-arm + +include makefile.inc + +CC = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc -B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- +#AS = arm-linux-gnu-gcc +AS = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc +#LD = arm-linux-gnu-ld +LD = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-ld +#OBJCOPY = arm-linux-gnu-objcopy +OBJCOPY = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-objcopy +#OBJDUMP = arm-linux-gnu-objdump +OBJDUMP = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-objdump +CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0 + +ASFLAGS = + +LIBGCC = $(shell $(CC) -print-libgcc-file-name) + +LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \ + -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@") + +LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \ + $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@") +OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \ + -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@") +AS_WITH = $(call quiet-command,$(AS) $(ASFLAGS) \ + $(1) -c -o $@ $<," AS $(TARGET_DIR)$@") + +# link the libgcc.a for __aeabi_idiv. ARM has no native support for div +LIBS = $(LIBGCC) + +CMAKEDIR = CMakeFiles/kernel.dir + +OBJS = \ + $(CMAKEDIR)/lib/string.c.o \ + $(CMAKEDIR)/c/kernel-context.c.o\ + $(CMAKEDIR)/arm.c.o\ + $(CMAKEDIR)/asm.S.o\ + $(CMAKEDIR)/bio.c.o\ + $(CMAKEDIR)/buddy.c.o\ + $(CMAKEDIR)/c/console.c.o\ + $(CMAKEDIR)/exec.c.o\ + $(CMAKEDIR)/c/file.c.o\ + $(CMAKEDIR)/fs.c.o\ + $(CMAKEDIR)/log.c.o\ + $(CMAKEDIR)/main.c.o\ + $(CMAKEDIR)/memide.c.o\ + $(CMAKEDIR)/c/pipe.c.o\ + $(CMAKEDIR)/c/proc.c.o\ + $(CMAKEDIR)/c/spinlock.c.o\ + $(CMAKEDIR)/start.c.o\ + $(CMAKEDIR)/swtch.S.o\ + $(CMAKEDIR)/c/syscall.c.o\ + $(CMAKEDIR)/c/sysfile.c.o\ + $(CMAKEDIR)/sysproc.c.o\ + $(CMAKEDIR)/trap_asm.c.o\ + $(CMAKEDIR)/trap.c.o\ + $(CMAKEDIR)/vm.c.o \ + \ + $(CMAKEDIR)/device/picirq.c.o \ + $(CMAKEDIR)/device/timer.c.o \ + $(CMAKEDIR)/device/uart.c.o + +KERN_OBJS = $(OBJS) entry.S.o +kernel.elf: $(KERN_OBJS) kernel.ld build/initcode build/fs.img + cp -f build/initcode initcode + cp -f build/fs.img fs.img + $(call LINK_BIN, kernel.ld, kernel.elf, \ + $(KERN_OBJS), \ + initcode fs.img) + $(OBJDUMP) -S kernel.elf > kernel.asm + $(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym + rm -f initcode fs.img + +qemu: kernel.elf + @clear + @echo "Press Ctrl-A and then X to terminate QEMU session\n" + $(QEMU) -M versatilepb -m 128 -cpu arm1176 -nographic -kernel kernel.elf + +INITCODE_OBJ = initcode.o +$(addprefix build/,$(INITCODE_OBJ)): initcode.S + $(call build-directory) + $(call AS_WITH, -nostdinc -I.) + +#initcode is linked into the kernel, it will be used to craft the first process +build/initcode: $(addprefix build/,$(INITCODE_OBJ)) + $(call LINK_INIT, -N -e start -Ttext 0) + $(call OBJCOPY_INIT) + $(OBJDUMP) -S $< > initcode.asm + +build/fs.img: + make -C tools + make -C usr -f makfile-armgccbc + +clean: + rm -rf build + rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \ + initcode initcode.out kernel xv6.img fs.img kernel.elf memfs + make -C tools clean + make -C usr clean diff -r 57386e27708b -r 74d9f25dcb76 src/old_makefiles/makefile-osx.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/old_makefiles/makefile-osx.inc Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,48 @@ +# Cross-compiling (e.g., on Mac OS X, install arm-none-eabi-gcc with MacPorts) +CROSSCOMPILE := + +CC = $(CROSSCOMPILE)/Users/one/src/cbclang-arm/build/bin/clang +AS = $(CROSSCOMPILE)as +LD = $(CROSSCOMPILE)ld +OBJCOPY = $(CROSSCOMPILE)objcopy +OBJDUMP = $(CROSSCOMPILE)objdump + +CFLAGS = -arch arm -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 \ + -Wno-macro-redefined -Wno-gnu-designator -Wno-sometimes-uninitialized -Wno-tautological-compare \ + -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include +LDFLAGS = -L. -arch armv7 +ASFLAGS = -arch arm + +LIBGCC = $(shell $(CC) -print-libgcc-file-name) + +# host compiler +HOSTCC_preferred = clang +define get_hostcc + $(if $(shell which $(HOSTCC_preferred)),$(HOSTCC_preferred),"cc") +endef +HOSTCC := $(call get_hostcc) + +# general rules +quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) + +LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \ + -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@") + +LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \ + $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@") +OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \ + -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@") + +build-directory = $(shell mkdir -p build build/device build/lib) + +build/%.o: %.c + $(call build-directory) + $(call quiet-command,$(CC) $(CFLAGS) \ + -c -o $@ $<," CC $(TARGET_DIR)$@") + +AS_WITH = $(call quiet-command,$(CC) $(ASFLAGS) \ + $(1) -c -o $@ $<," AS $(TARGET_DIR)$@") + +build/%.o: %.S + $(call build-directory) + $(call AS_WITH, ) diff -r 57386e27708b -r 74d9f25dcb76 src/old_makefiles/makefile.inc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/old_makefiles/makefile.inc Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,57 @@ +# Cross-compiling (e.g., on Mac OS X, install arm-none-eabi-gcc with MacPorts) + +CROSSCOMPILE := arm-linux-gnu- + +CPU = armv8 +#CC = /usr/local/cbclang/bin/clang +AS = $(CROSSCOMPILE)as +LD = $(CROSSCOMPILE)ld +OBJCOPY = $(CROSSCOMPILE)objcopy +OBJDUMP = $(CROSSCOMPILE)objdump + +# CFLAGS = -march=${CPU} -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 +CFLAGS = -target ${CPU}-none-eabi -I /net/open/Linux/arm/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/ /net/open/Linux/arm/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/include-fixed/ -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0 +LDFLAGS = -L. +# ASFLAGS = -march=${CPU} +ASFLAGS = -target ${CPU}-none-eabi + +#LIBGCC = $(shell $(gcc) -print-libgcc-file-name) +LIBGCC = /net/open/Linux/arm/gcc-arm-none-eabi-7-2017-q4-major/lib/gcc/arm-none-eabi/7.2.1/libgcc.a + +# host compiler + HOSTCC_preferred = gcc +#HOSTCC_preferred = /usr/local/cbclang/bin/clang +define get_hostcc + $(if $(shell which $(HOSTCC_preferred)),$(HOSTCC_preferred),"cc") +endef +HOSTCC := $(call get_hostcc) + +# general rules +quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) + +LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \ + -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@") + +LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \ + $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@") +OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \ + -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@") + +build-directory = $(shell mkdir -p build build/device build/lib) + +build/%.o: %.c + $(call build-directory) + $(call quiet-command,$(CC) $(CFLAGS) \ + -c -o $@ $<," CC $(TARGET_DIR)$@") + +build/%.o: %.cbc + $(call build-directory) + $(call quiet-command,$(CC) $(CFLAGS) \ + -c -o $@ $<," CC $(TARGET_DIR)$@") + +AS_WITH = $(call quiet-command,$(CC) $(ASFLAGS) \ + $(1) -c -o $@ $<," AS $(TARGET_DIR)$@") + +build/%.o: %.S + $(call build-directory) + $(call AS_WITH, ) diff -r 57386e27708b -r 74d9f25dcb76 src/pipe.cbc --- a/src/pipe.cbc Fri Dec 20 16:13:46 2019 +0900 +++ b/src/pipe.cbc Fri Dec 20 16:16:45 2019 +0900 @@ -11,6 +11,7 @@ #define __ncode __code # +/* struct pipe { struct spinlock lock; char data[PIPESIZE]; @@ -19,6 +20,7 @@ int readopen; // read fd is still open int writeopen; // write fd is still open }; +*/ int pipealloc(struct file **f0, struct file **f1) { diff -r 57386e27708b -r 74d9f25dcb76 src/plautogen/interface/Integer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/plautogen/interface/Integer.h Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,3 @@ +typedef struct Integer { + int value; +} Integer; diff -r 57386e27708b -r 74d9f25dcb76 src/proc.h --- a/src/proc.h Fri Dec 20 16:13:46 2019 +0900 +++ b/src/proc.h Fri Dec 20 16:16:45 2019 +0900 @@ -3,6 +3,7 @@ #define PROC_INCLUDE_ #include "context.h" + // Per-CPU state, now we only support one CPU struct cpu { uchar id; // index into cpus[] below @@ -20,7 +21,6 @@ extern struct cpu cpus[NCPU]; extern int ncpu; - extern struct cpu* cpu; extern struct proc* proc; diff -r 57386e27708b -r 74d9f25dcb76 src/sys_open_impl.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sys_open_impl.cbc Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,30 @@ +#include "../context.h" +#interface "SysOpen.h" + +// ---- +// typedef struct SysOpenImpl impl SysOpen { +// +// } SysOpenImpl; +// ---- + +SysOpen* createSysOpenImpl(struct Context* cbc_context) { + struct SysOpen* sys_open = new SysOpen(); + struct SysOpenImpl* sys_open_impl = new SysOpenImpl(); + sys_open->sys_open = (union Data*)sys_open_impl; + sys_open->fd = 0; + sys_open->omode = 0; + sys_open->addr = NULL; + sys_open->file = NULL; + sys_open->ip = NULL; + sys_open->open = C_openSysOpenImpl; + sys_open->next = C_nextSysOpenImpl; + return sys_open; +} +__code openSysOpenImpl(struct SysOpenImpl* sys_open, int fd, int omode, char* addr, struct file* file, struct inode* ip, __code next(...)) { + + goto next(...); +} + +__code nextSysOpenImpl(...) { + +} diff -r 57386e27708b -r 74d9f25dcb76 src/sys_pipe_read.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sys_pipe_read.cbc Fri Dec 20 16:16:45 2019 +0900 @@ -0,0 +1,63 @@ +#include "../context.h" +#interface "SysRead.h" + +// ---- +// typedef struct PipeRead impl SysRead { +// struct pipe* p; +// int i; +// int n; +// __code cbc_piperead1(Type* sys_read, struct pipe* p, __code next(...)); +// __code cbc_piperead2(Type* sys_read, int i, int n, struct pipe* p, __code next(...)); +// __code cbc_piperead3(Type* sys_read, int i, struct pipe* p, __code next(...)); +// __code next(...); +// } PipeRead; +// ---- + +SysRead* createPipeRead(struct Context* cbc_context) { + struct SysRead* sys_read = new SysRead(); + struct PipeRead* pipe_read = new PipeRead(); + sys_read->sys_read = (union Data*)pipe_read; + pipe_read->p = NULL; + pipe_read->i = 0; + pipe_read->n = 0; + sys_read->impl = NULL; + sys_read->addr = NULL; + sys_read->n = 0; + pipe_read->cbc_piperead1 = C_cbc_piperead1PipeRead; + pipe_read->cbc_piperead2 = C_cbc_piperead2PipeRead; + pipe_read->cbc_piperead3 = C_cbc_piperead3PipeRead; + sys_read->read = C_readPipeRead; + return sys_read; +} +__code cbc_piperead1PipeRead(struct PipeRead* sys_read, struct pipe* p, __code next(...)) { + if (p->nread == p->nwrite && p->writeopen){ + if(proc->killed){ + release(&p->lock); + goto err(); + } + goto cbc_sleep(&p->nread, &p->lock, cbc_piperead1); + } + goto next(sys_read,0,sys_read->n,sys_read->p,cbc_piperead2SysReadImpl); +} + +__code cbc_piperead2PipeRead(struct PipeRead* sys_read, int i, int n, struct pipe* p, __code next(...)) { + if (i < n && !(p->nread == p->nwrite)) { + addr[i] = p->data[p->nread++ % PIPESIZE]; + i ++; + goto cbc_piperead2(sys_read,i,n,p,addr); + } + goto cbc_wakeup(&p->nwrite, cbc_piperead3); //DOC: piperead-wakeup +} + +__code cbc_piperead3PipeRead(struct PipeRead* sys_read, int i, struct pipe* p, __code next(...)) { + + goto next(...); +} + + +__code readPipeRead(struct PipeRead* sys_read, union Data* impl, char* addr, int n, __code next(int ret,...)) { + + goto next(int ret,...); +} + +