changeset 175:de3934dd522a

merge
author anatofuz
date Fri, 17 Jan 2020 14:37:26 +0900
parents 8c12438a9827 (diff) b948cf7a881d (current diff)
children da4c83ae7ada
files src/gearsTools/lib/Gears/Context/Template/XV6.pm
diffstat 27 files changed, 237 insertions(+), 304 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Dec 23 18:03:22 2019 +0900
+++ b/.hgignore	Fri Jan 17 14:37:26 2020 +0900
@@ -15,3 +15,6 @@
 mkfs
 
 *.orig
+.gdb_history
+
+.vscode/
--- a/src/CMakeLists.txt	Mon Dec 23 18:03:22 2019 +0900
+++ b/src/CMakeLists.txt	Fri Jan 17 14:37:26 2020 +0900
@@ -126,7 +126,7 @@
   SOURCES
 	string.c arm.c asm.S bio.c buddy.c console.cbc exec.c file.cbc fs.c log.c main.c memide.c pipe.cbc proc.cbc spinlock.cbc 
 	start.c swtch.S syscall.cbc sysfile.cbc sysproc.c trap_asm.S trap.c vm.c device/picirq.c device/timer.c device/uart.c 
-  SingleLinkedStack.cbc sys_open_impl.cbc sys_pipe_read.cbc file_read.cbc
+  SingleLinkedStack.cbc 
          entry.S 
 )
 
--- a/src/file.cbc	Mon Dec 23 18:03:22 2019 +0900
+++ b/src/file.cbc	Fri Jan 17 14:37:26 2020 +0900
@@ -11,7 +11,9 @@
 #include "proc.h"
 
 #define __ncode __code
-#
+
+// data_gear "file.dg"
+
 struct devsw devsw[NDEV];
 struct cbc_devsw cbc_devsw[NDEV];
 
--- a/src/file_read.cbc	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#include "../context.h"
-#interface "SysRead.h"
-
-// ----
-// typedef struct FileRead<Type, Isa> 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);
-}
-
--- a/src/gearsTools/lib/Gears/Context/Template/XV6.pm	Mon Dec 23 18:03:22 2019 +0900
+++ b/src/gearsTools/lib/Gears/Context/Template/XV6.pm	Fri Jan 17 14:37:26 2020 +0900
@@ -35,8 +35,7 @@
 #define calloc(a,b)  kmalloc((a)*(b))
 #define free(a)  kfree(a)
 #else
-#include "types.h"
-#include "user.h"
+extern void* malloc(unsigned int sz);
 #define calloc(a,b)  malloc((a)*(b))
 #define free(a)  free(a)
 #endif
@@ -111,9 +110,6 @@
 
 #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"
@@ -160,6 +156,7 @@
     enum Code before;
 };
 
+#include "spinlock.h"
 typedef int Int;
 #ifndef USE_CUDAWorker
 typedef unsigned long long CUdeviceptr;
@@ -174,6 +171,8 @@
 print $out "union Data {\n";
 print $out $dgs;
 print $out  <<'EOF';
+
+#ifndef CbC_XV6_CONTEXT
     struct Context Context;
 }; // union Data end       this is necessary for context generator
 typedef union Data Data;
@@ -192,6 +191,7 @@
 
 #include "c/extern.h"
 
+#define CbC_XV6_CONTEXT 1
 extern __code start_code(struct Context* cbc_context);
 extern __code exit_code(struct Context* cbc_context);
 extern __code meta(struct Context* cbc_context, enum Code next);
--- a/src/gearsTools/lib/Gears/Util.pm	Mon Dec 23 18:03:22 2019 +0900
+++ b/src/gearsTools/lib/Gears/Util.pm	Fri Jan 17 14:37:26 2020 +0900
@@ -122,19 +122,23 @@
   my $header_name = shift;
 
   my $find_path = shift // ".";
-  my $header_file = '';
+  my @header_list = ();
 
   find(
     {
       wanted => sub {
-        if ($_ =~ /\/$header_name\.h/) {
-          $header_file = $_;
+        if ($_ =~ /\/$header_name\.(h|dg)/) {
+          push(@header_list,$_);
         }
       },
       no_chdir => 1,
     },
     $find_path);
-  return $header_file;
+  my @find_headers =  grep { $_ =~ /\/$header_name\.(h|dg)/} @header_list;
+  if (@find_headers > 1) {
+      @find_headers =  grep { $_ =~ /\/$header_name\.dg/} @find_headers;
+  }
+  return shift @find_headers;
 }
 
 sub find_headers_path {
--- a/src/gearsTools/trans_impl.pl	Mon Dec 23 18:03:22 2019 +0900
+++ b/src/gearsTools/trans_impl.pl	Fri Jan 17 14:37:26 2020 +0900
@@ -75,15 +75,20 @@
 EOF
 
   for my $datum (@impl_data) {
-        if ($datum =~ /\w+ \w+\* (\w+)/) {
+        $datum =~ s|//[\s\w]+||;
+        if ($datum =~ /^\s+#/) {
+          next;
+        }
+
+        if ($datum =~ /\w+\s\w+\*\s(\w+)/) {
             print $out "    ${instance_impl}->$1 = NULL;\n";
             next;
         }
-        if ($datum =~ /\w+ \w+ (\w+)/) {
+        if ($datum =~ /\w+\s\w+\s(\w+)/) {
             print $out "    ${instance_impl}->$1 = 0;\n";
         }
 
-        if ($datum =~ /\w+(\*)? (\w+)/) {
+        if ($datum =~ /\w+(\*)?\s(\w+)/) {
             my $is_pointer = $1;
             my $var_name = $2;
             if ($1) {
@@ -95,15 +100,21 @@
   }
 
   for my $datum (@inter_data) {
-        if ($datum =~ /\w+ \w+\* (\w+)/) {
+        # remove macro, comment block
+        $datum =~ s|//[\s\w]+||;
+        if ($datum =~ /^\s+#/) {
+          next;
+        }
+
+        if ($datum =~ /\w+\s\w+\*\s(\w+)/) {
             print $out "    ${instance_inter}->$1 = NULL;\n";
             next;
         }
-        if ($datum =~ /\w+ \w+ (\w+)/) {
+        if ($datum =~ /\w+\s\w+\s(\w+)/) {
             print $out "    ${instance_inter}->$1 = 0;\n";
             next;
         }
-        if ($datum =~ /\w+(\*)? (\w+)/) {
+        if ($datum =~ /\w+(\*)?\s(\w+)/) {
             my $is_pointer = $1;
             my $var_name = $2;
             if ($1) {
@@ -165,12 +176,12 @@
 
       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";
+          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 "    goto ",shift(@cg),";\n";
         }
       }
       print $out "}\n\n";
@@ -196,12 +207,12 @@
 
     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";
+        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 "    goto ",shift(@cg),";\n";
       }
     }
     print $out "}\n\n";
--- a/src/impl/FileRead.h	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-typedef struct FileRead<Type, Isa> impl SysRead {
-  struct file* f;
-} FileRead;
--- a/src/impl/PipeRead.cbc	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-#include "../context.h"
-#interface "SysRead.h"
-
-// ----
-// typedef struct PipeRead<Type, Isa> 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;
-    //pipe_read->next = C_nextPipeRead;
-    sys_read->read = C_readPipeRead;
-    sys_read->next = C_nextPipeRead;
-    return sys_read;
-}
-
-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 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,...);
-}
-
-
--- a/src/impl/PipeRead.h	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-typedef struct PipeRead<Type, Isa> 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;
--- a/src/impl/SysOpenImpl.h	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-typedef struct SysOpenImpl <Type, Isa> impl SysOpen {
-
-} SysOpenImpl;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/impl/file_impl_pipe.cbc	Fri Jan 17 14:37:26 2020 +0900
@@ -0,0 +1,117 @@
+#include "../context.h"
+#interface "file.h"
+
+// ----
+// typedef struct pipe<Impl, Isa> impl file {
+//     #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;
+// ----
+
+file* createpipe(struct Context* cbc_context) {
+    struct file* file  = new file();
+    struct pipe* pipe = new pipe();
+    file->file = (union Data*)pipe;
+    pipe->lock = 0;
+    pipe->spinlock  = 0;
+    pipe->data  = 0;
+    pipe->nread  = 0;
+    pipe->nwrite  = 0;
+    pipe->readopen  = 0;
+    pipe->writeopen  = 0;
+    file->off = 0;
+    file->st = NULL;
+    file->addr = NULL;
+    file->n  = 0;
+    file->stat = C_statpipe;
+    file->read = C_readpipe;
+    file->write = C_writepipe;
+    file->close = C_closepipe;
+    return file;
+}
+__code statpipe(struct pipe* file, struct stat* st, __code next(...)) {
+
+    goto next(...);
+}
+
+__code readpipe(struct pipe* file, char* addr, int n, __code next(...)) {
+    acquire(&p->lock);
+    goto cbc_piperead1(file,addr,n,next);
+}
+
+__code piperead1(struct pipe* p, char* addr, int n, __code next(...)) {
+    if (p->nread == p->nwrite && p->writeopen){
+        if(proc->killed){
+            release(&p->lock);
+            goto cbc_context->error();
+        }
+        goto cbc_sleep(p,&p->nread, &p->lock, next,cbc_piperead1);
+    }
+    n = 0;
+    goto cbc_piperead2(p,n);
+}
+
+__code cbc_sleep(struct pipe* p, unit* nread, struct spinlock* lock, __code next(...), __code pread(...)){
+    if(proc == 0) {
+        goto cbc_context->panic("sleep");
+    }
+
+    if(lk == 0) {
+        goto cbc_context->panic("sleep without lk");
+    }
+
+    if(lk != &ptable.lock){  //DOC: sleeplock0
+        acquire(&ptable.lock);  //DOC: sleeplock1
+        release(lk);
+    }
+    goto cbc_sched(cbc_sleep1);
+}
+
+__code cbc_sched_stub(struct pipe* p, unit* nread, struct spinlock* lock, __code next(...), __code pread(...)){
+    proc->chan = chan;
+    proc->state = SLEEPING;
+    proc->lk = lk;
+    proc->cbc_next = next1;
+}
+
+__code writepipe(struct pipe* file, char* addr, int n, __code next(...)) {
+
+  goto next(...);
+}
+
+__code closepipe(struct pipe* file,int fd,__code next(...)) {
+    proc->ofile[fd] = 0;
+    goto cbc_fileclose(f,next);
+}
+
+
+__code cbc_fileclose(struct file* file, __code next(...)) {
+    struct file ff;
+    acquire(*ftable.loc)
+
+    if (f->ref < 1) {
+        goto cbc_context->kernel_error->panic("file close");
+    }
+    goto cbc_fileclose2(f,ff,next);
+}
+
+__code cbc_fileclose2(struct file* file, struct file* ff,__code next(...)) {
+    if (--f->ref > 0) {
+        release(&ftable.lock);
+        goto cbc_context->return();
+    }
+    goto cbc_fileclose3(f,ff,next);
+}
+
+__code cbc_fileclose3(struct file* file, struct file* ff,__code next(...)) {
+    if (--f->ref > 0) {
+        release(&ftable.lock);
+        goto cbc_context->return();
+    }
+    goto cbc_fileclose3(f,ff,next);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/impl/kernel_error.cbc	Fri Jan 17 14:37:26 2020 +0900
@@ -0,0 +1,26 @@
+#include "../context.h"
+#interface "ErrorGear.h"
+
+// ----
+// typedef struct KernelError <Type, Isa> impl ErrorGear {
+// } KernelError;
+// ----
+
+ErrorGear* createKernelError(struct Context* cbc_context) {
+    struct ErrorGear* error_gear  = new ErrorGear();
+    struct KernelError* kernel_error = new KernelError();
+    error_gear->error_gear = (union Data*)kernel_error;
+    error_gear->err_code  = 0;
+    error_gear->msg = NULL;
+    error_gear->error = C_errorKernelError;
+    error_gear->panic = C_panicKernelError;
+    return error_gear;
+}
+__code errorKernelError(int err_code,...) {
+
+}
+
+__code panicKernelError(char* msg) {
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/impl/kernel_error.h	Fri Jan 17 14:37:26 2020 +0900
@@ -0,0 +1,2 @@
+typedef struct KernelError <Type, Isa> impl ErrorGear {
+} KernelError;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/impl/pipe.h	Fri Jan 17 14:37:26 2020 +0900
@@ -0,0 +1,17 @@
+typedef struct pipe<Impl, Isa> impl file {
+    #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
+
+    // interface field
+    int n;
+    char* addr;
+
+    // private code gear
+    __code piperead1(Impl* pipe, char* addr, int n, __code next(...));
+    __code piperead2(Impl* pipe, char* addr, int n, __code next(...));
+} pipe;
--- a/src/inode.h	Mon Dec 23 18:03:22 2019 +0900
+++ b/src/inode.h	Fri Jan 17 14:37:26 2020 +0900
@@ -1,4 +1,4 @@
-typedef struct inode <Impl> {
+typedef struct inode <Impl, Isa> impl file {
     uint    dev;        // Device number
     uint    inum;       // Inode number
     int     ref;        // Reference count
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/interface/ErrorGear.h	Fri Jan 17 14:37:26 2020 +0900
@@ -0,0 +1,8 @@
+typedef struct ErrorGear <Type, Impl> {
+  union Data* error_gear;
+  int err_code;
+  char* msg;
+
+  __code error(int err_code,...);
+  __code panic(char* msg);
+} ErrorGear;
--- a/src/interface/SysCall.dg	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-typedef struct SysCall<Type,Impl>{
-    union Data* sys_call;
-    union Data* arg1;
-    union Data* arg2;
-    union Data* arg3;
-    union Data* context;
-    int ret;
-    __code ret(__code next(int ret, ...));
-    __code sleep(Impl* sys_call, __code next(union Data* context, ...));
-    __code exec(Impl* sys_call,union Data* arg1,union Data* arg2,union Data* aeg3,__code next(...));
-} syscall;
--- a/src/interface/SysOpen.h	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-typedef struct SysOpen<Type, Impl>{
-  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;
--- a/src/interface/SysRead.h	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-typedef struct SysRead<Type, Impl>{
-   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;
--- a/src/interface/file.dg	Mon Dec 23 18:03:22 2019 +0900
+++ b/src/interface/file.dg	Fri Jan 17 14:37:26 2020 +0900
@@ -1,9 +1,18 @@
 typedef struct file <Impl> {
-    enum { FD_NONE, FD_PIPE, FD_INODE } type;
+    union Data* file;
+    enum { FD_NONE, FD_PIPE, FD_INODE } type; //TODO: after remoe
     int          ref;   // reference count
     char         readable;
     char         writable;
-    struct pipe  *pipe;
-    struct inode *ip;
     unsigned int off;
+    struct stat* st;
+    char* addr;
+    struct pipe *pipe; //TODO : remove
+    struct inode *ip; //TODO : remove
+    int n;
+    int fd;
+    __code stat(Impl* file, struct stat* st, __code next(...));
+    __code read(Impl* file, char* addr, __code next(...));
+    __code write(Impl* file, char* addr, int n, __code next(...));
+    __code close(Impl* file,int fd, __code next(...));
 } file;
--- a/src/move_data_gears/pipe.h	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-typedef struct pipe<Impl> {
-    #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;
--- a/src/pipe.cbc	Mon Dec 23 18:03:22 2019 +0900
+++ b/src/pipe.cbc	Fri Jan 17 14:37:26 2020 +0900
@@ -10,7 +10,8 @@
 #define PIPESIZE 512
 
 #define __ncode __code
-#
+// data_gear "pipe.h"
+
 /*
 struct pipe {
     struct spinlock lock;
--- a/src/spinlock.h	Mon Dec 23 18:03:22 2019 +0900
+++ b/src/spinlock.h	Fri Jan 17 14:37:26 2020 +0900
@@ -1,4 +1,5 @@
 // Mutual exclusion lock.
+#ifndef SPINLOCK_H
 struct spinlock {
     uint        locked;     // Is the lock held?
 
@@ -8,4 +9,5 @@
     uint        pcs[10];    // The call stack (an array of program counters)
     // that locked the lock.
 };
-
+#endif // SPINLOCK_H
+#define SPINLOCK_H
--- a/src/sys_open_impl.cbc	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#include "../context.h"
-#interface "SysOpen.h"
-
-// ----
-// typedef struct SysOpenImpl <Type, Isa> 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(...) {
-
-}
--- a/src/sys_pipe_read.cbc	Mon Dec 23 18:03:22 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-#include "../context.h"
-#interface "SysRead.h"
-
-// ----
-// typedef struct PipeRead<Type, Isa> 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,...);
-}
-
-
--- a/src/sysfile.cbc	Mon Dec 23 18:03:22 2019 +0900
+++ b/src/sysfile.cbc	Fri Jan 17 14:37:26 2020 +0900
@@ -14,6 +14,8 @@
 #include "file.h"
 #include "fcntl.h"
 
+//data_gear "inode.h"
+
 #define __ncode __code
 
 // Fetch the nth word-sized system call argument as a file descriptor