changeset 157:2fc7ed85e76c

rollback (rm sys_* files)
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 14 Jan 2020 16:01:49 +0900
parents 8b473f13fd9f
children d0a708a29ec7
files src/CMakeLists.txt src/file_read.cbc src/impl/FileRead.h src/impl/PipeRead.cbc src/impl/PipeRead.h src/impl/SysOpenImpl.h src/interface/SysCall.dg src/interface/SysOpen.h src/interface/SysRead.h src/interface/file.dg src/sys_open_impl.cbc src/sys_pipe_read.cbc
diffstat 12 files changed, 9 insertions(+), 266 deletions(-) [+]
line wrap: on
line diff
--- a/src/CMakeLists.txt	Thu Dec 19 17:09:38 2019 +0900
+++ b/src/CMakeLists.txt	Tue Jan 14 16:01:49 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_read.cbc	Thu Dec 19 17:09:38 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/impl/FileRead.h	Thu Dec 19 17:09:38 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	Thu Dec 19 17:09:38 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	Thu Dec 19 17:09:38 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	Thu Dec 19 17:09:38 2019 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-typedef struct SysOpenImpl <Type, Isa> impl SysOpen {
-
-} SysOpenImpl;
--- a/src/interface/SysCall.dg	Thu Dec 19 17:09:38 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	Thu Dec 19 17:09:38 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	Thu Dec 19 17:09:38 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	Thu Dec 19 17:09:38 2019 +0900
+++ b/src/interface/file.dg	Tue Jan 14 16:01:49 2020 +0900
@@ -1,9 +1,14 @@
 typedef struct file <Impl> {
-    enum { FD_NONE, FD_PIPE, FD_INODE } type;
+    union Data* file;
     int          ref;   // reference count
     char         readable;
     char         writable;
-    struct pipe  *pipe;
-    struct inode *ip;
     unsigned int off;
+    struct stat* st;
+    char* addr;
+    int n;
+    __code dup(Impl* file, __code next(...));
+    __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(...));
 } file;
--- a/src/sys_open_impl.cbc	Thu Dec 19 17:09:38 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	Thu Dec 19 17:09:38 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,...);
-}
-
-