Mercurial > hg > Members > menikon > CbC_xv6
changeset 113:ef44d384ad9d
rollback rev 52
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 02 Dec 2019 11:17:04 +0900 |
parents | b9df8ea87b42 |
children | f3ebb813d0bf |
files | src/file.cbc src/file.h src/interface/SysRead.h src/pipe.cbc src/sysfile.cbc |
diffstat | 5 files changed, 22 insertions(+), 102 deletions(-) [+] |
line wrap: on
line diff
--- a/src/file.cbc Thu Nov 28 16:58:04 2019 +0900 +++ b/src/file.cbc Mon Dec 02 11:17:04 2019 +0900 @@ -11,10 +11,7 @@ #include "proc.h" #define __ncode __code - -#interface "SysRead.h" - - +# struct devsw devsw[NDEV]; struct cbc_devsw cbc_devsw[NDEV]; @@ -28,17 +25,6 @@ initlock(&ftable.lock, "ftable"); } -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; -} - // Allocate a file structure. struct file* filealloc (void) { @@ -127,16 +113,14 @@ goto next(r); } - -// Skip: generate_context -__code cbc_fileread(struct file *f, char *addr, int n, __code next(int ret, ...)) +__ncode cbc_fileread (struct file *f, char *addr, int n, __code (*next)(int ret)) { if (f->readable == 0) { goto next(-1); } if (f->type == FD_PIPE) { - piperead(f->pipe, addr, n); + goto cbc_piperead(f->pipe, addr, n, next); goto next(-1); } @@ -238,11 +222,3 @@ panic("filewrite"); } -__code readFileRead(__code next(...)) { - - goto next(...); -} - -__code nextFileRead(...) { - -}
--- a/src/file.h Thu Nov 28 16:58:04 2019 +0900 +++ b/src/file.h Mon Dec 02 11:17:04 2019 +0900 @@ -1,14 +1,3 @@ -struct file { - enum { FD_NONE, FD_PIPE, FD_INODE } type; - int ref; // reference count - char readable; - char writable; - struct pipe *pipe; - struct inode *ip; - uint off; -}; - - // in-memory copy of an inode struct inode { uint dev; // Device number
--- a/src/interface/SysRead.h Thu Nov 28 16:58:04 2019 +0900 +++ b/src/interface/SysRead.h Mon Dec 02 11:17:04 2019 +0900 @@ -1,9 +1,9 @@ typedef struct SysRead<Type, Impl>{ union Data* sys_read; struct UInteger* num; - int n; + struct Integer* n; struct String *p; - __code read(__code next(...)); + __code read(Type* sys_read, __code next(...)); //__code ret(Impl* cbc_sys_file, UInteger* num); __code next(...); } SysRead;
--- a/src/pipe.cbc Thu Nov 28 16:58:04 2019 +0900 +++ b/src/pipe.cbc Mon Dec 02 11:17:04 2019 +0900 @@ -20,14 +20,6 @@ int writeopen; // write fd is still open }; -struct PipeRead* create_pipe_read(struct Context* context) { - struct SysRead* sys_read = new SysRead(); - struct PipeRead* pipe_read = new PipeRead(); - sys_read->sys_read = (union Data*)pipe_read; - sys_red->read = C_cbc_piperead; - return sys_read; -} - int pipealloc(struct file **f0, struct file **f1) { struct pipe *p; @@ -152,30 +144,30 @@ goto cbc_wakeup(&p->nwrite, cbc_piperead3); //DOC: piperead-wakeup } -__ncode cbc_piperead1(struct PipeRead* pipe_read){ - struct pipe *p = pipe_read->pipe; +__ncode cbc_piperead1(){ + struct pipe *p = proc->cbc_arg.cbc_console_arg.p; __code(*next)(int ret) = proc->cbc_arg.cbc_console_arg.next; - if (pipe->nread == pipe->nwrite && pipe->writeopen){ + if (p->nread == p->nwrite && p->writeopen){ if(proc->killed){ - release(&pipe->lock); + release(&p->lock); goto next(-1); } - //pipe_read->pipe = p; - goto cbc_sleep(&pipe->nread, &pipe->lock, cbc_piperead1); + proc->cbc_arg.cbc_console_arg.p = p; + goto cbc_sleep(&p->nread, &p->lock, cbc_piperead1); } int i = 0; - pipe_read->i->value = i; - //pipe_read->pipe = p; + proc->cbc_arg.cbc_console_arg.i = i; + proc->cbc_arg.cbc_console_arg.p = p; goto cbc_piperead2(); } -__ncode cbc_piperead(struct PipeRead* pipe_read, struct pipe *p, char *addr, int n, __code (*next)(int ret)) +__ncode cbc_piperead(struct pipe *p, char *addr, int n, __code (*next)(int ret)) { acquire(&p->lock); - //proc->cbc_arg.cbc_console_arg.n = n; - //proc->cbc_arg.cbc_console_arg.p = p; - //proc->cbc_arg.cbc_console_arg.addr = addr; - //proc->cbc_arg.cbc_console_arg.next = next; + proc->cbc_arg.cbc_console_arg.n = n; + proc->cbc_arg.cbc_console_arg.p = p; + proc->cbc_arg.cbc_console_arg.addr = addr; + proc->cbc_arg.cbc_console_arg.next = next; goto cbc_piperead1(); }
--- a/src/sysfile.cbc Thu Nov 28 16:58:04 2019 +0900 +++ b/src/sysfile.cbc Mon Dec 02 11:17:04 2019 +0900 @@ -14,33 +14,8 @@ #include "file.h" #include "fcntl.h" -#include "arm.h" -#include "syscall.h" -#interface "CbCSysFile.h" - #define __ncode __code -struct CbCSysFile* create_cbc_sys_file(struct Context* cbc_context) { - struct CbCSysFile* cbc_file = new CbCSysFile(); - cbc_file->read = C_cbc_fileread; - cbc_file->cbc_file_ret = C_cbc_file_ret; - return cbc_file; -} - -__code cbc_file_trap_return(){ - return; -} - -__code cbc_file_ret(struct CbCSysFile* cbc_sys_file, struct UInteger* ret){ - int num = cbc_sys_file->num->value; - uint return_value = ret->value; - //int num = proc->cbc_arg.cbc_console_arg.num; - if (num != SYS_exec) { - proc->tf->r0 = return_value; - } - goto cbc_file_trap_return(); -} - // Fetch the nth word-sized system call argument as a file descriptor // and return both the descriptor and the corresponding struct file. static int argfd(int n, int *pfd, struct file **pf) @@ -101,27 +76,15 @@ return fd; } -__code cbc_read(struct CbCSysFile* cbc_file){ - //struct CbCSysFile* cbc_file = create_cbc_sys_file(cbc_context); - goto cbc_fileread(); -} - -__code cbc_read_stub(struct Context* cbc_context){ +__ncode cbc_read(__code (*next)(int ret)){ struct file *f; int n; char *p; - - CbCSysFile* cbc_sys_file = (CbCSysFile*)Gearef(cbc_context,CbCSysFile); + if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) { - //__code cbc_file_ret(struct CbCSysFile* cbc_sys_file, struct UInteger* ret){ - UInteger* ret = (UInteger*)Gearef(cbc_context,UInteger); - ret->value = -1; - goto cbc_file_ret(cbc_context, cbc_sys_file, ret); + goto next(-1); } - cbc_sys_file->f = f; - cbc_sys_file->n = n; - cbc_sys_file->p = p; - goto cbc_read(cbc_context,cbc_sys_file); + goto cbc_fileread(f, p, n, next); } int sys_read(void)