Mercurial > hg > Members > menikon > CbC_xv6
changeset 92:bc5bcfd2f6d6
rename CbCFile to CbCSysFile
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 19 Oct 2019 16:44:24 +0900 |
parents | b5ddf6fb0a6d |
children | 7d0ec88cdd22 |
files | src/context.h src/file.cbc src/interface/CbCFile.h src/interface/CbCSysFile.h src/syscall.cbc src/sysfile.cbc |
diffstat | 6 files changed, 46 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/context.h Fri Oct 18 20:39:36 2019 +0900 +++ b/src/context.h Sat Oct 19 16:44:24 2019 +0900 @@ -226,13 +226,15 @@ struct CUDAWorker { } CUDAWorker; #endif - struct CbCFile { + struct CbCSysFile { struct file *f; int n; char *p; + struct UInteger* num; enum Code next; enum Code read; - } CbCFile; + enum Code cbc_file_ret; + } CbCSysFile; struct Main { enum Code code; enum Code next; @@ -357,6 +359,9 @@ struct Integer { int value; } Integer; + struct UInteger { + unsigned int value; + } UInteger; struct SortArray { struct Integer *array; //Array arrayじゃできない? int loopCounter;
--- a/src/file.cbc Fri Oct 18 20:39:36 2019 +0900 +++ b/src/file.cbc Sat Oct 19 16:44:24 2019 +0900 @@ -135,7 +135,7 @@ } __code cbc_fileread_stub(struct Context* cbc_context) { - struct CbCFile* cbc_file = &cbc_context->data[D_CbCFile]->CbCFile; + struct CbCSysFile* cbc_file = &cbc_context->data[D_CbCSysFile]->CbCSysFile; enum Code next = cbc_context->next; goto cbc_fileread(cbc_file->f, cbc_file->p, cbc_file->n, cbc_context->code[next]); }
--- a/src/interface/CbCFile.h Fri Oct 18 20:39:36 2019 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -typedef struct CbCFile<Type, Impl>{ - struct CbCFile* cbc_file; - __code file_read(__code next(...)); - __code next(...); -} CbCFile;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/interface/CbCSysFile.h Sat Oct 19 16:44:24 2019 +0900 @@ -0,0 +1,10 @@ +typedef struct CbCSysFile<Type, Impl>{ + struct CbCSysFile* cbc_file; + struct UInteger* num; + int n; + char *p; + struct file *f; + __code file_read(__code next(...)); + __code cbc_ret(Impl* cbc_sys_file, UInteger* num); + __code next(...); +} CbCSysFile;
--- a/src/syscall.cbc Fri Oct 18 20:39:36 2019 +0900 +++ b/src/syscall.cbc Sat Oct 19 16:44:24 2019 +0900 @@ -144,7 +144,7 @@ }; static enum Code cbccodes[] = { - [SYS_cbc_read] = C_start_code, + [SYS_cbc_read] = C_start_code, }; __ncode cbc_trap_return(){
--- a/src/sysfile.cbc Fri Oct 18 20:39:36 2019 +0900 +++ b/src/sysfile.cbc Sat Oct 19 16:44:24 2019 +0900 @@ -14,9 +14,31 @@ #include "file.h" #include "fcntl.h" -#interface "CbCFile.h" +#include "arm.h" +#interface "CbCSysFile.h" + +extern int SYS_exec; +#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; + return cbc_file; +} -#define __ncode __code +__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. @@ -89,18 +111,13 @@ goto cbc_fileread(f, p, n, next); } -struct CbCFile* initial_cbc_file(struct Context* cbc_context) { - struct CbCFile* cbc_file = new CbCFile(); - cbc_file->read = C_cbc_fileread; - return cbc_file; -} __code file_read(struct file *f, char *p, int n, __code next(...)){ goto cbc_fileread(f, p, n, next); } __code file_read_stub(struct Context* cbc_context, __code next(...)){ - struct CbCFile* cbc_file = initial_cbc_file(cbc_context); + struct CbCSysfile* cbc_file = create_cbc_sys_file(cbc_context); struct file *f; int n; char *p; @@ -339,6 +356,8 @@ iupdate(ip); if(type == T_DIR){ // Create . and .. entries. + dp->nlink++; // for ".." + iupdate(dp); // No ip->nlink++ for ".": avoid cyclic ref count. if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) {