Mercurial > hg > Members > menikon > CbC_xv6
comparison src/sysfile.cbc @ 113:ef44d384ad9d
rollback rev 52
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 02 Dec 2019 11:17:04 +0900 |
parents | 7d0ec88cdd22 |
children | 8c12438a9827 |
comparison
equal
deleted
inserted
replaced
112:b9df8ea87b42 | 113:ef44d384ad9d |
---|---|
12 #include "proc.h" | 12 #include "proc.h" |
13 #include "fs.h" | 13 #include "fs.h" |
14 #include "file.h" | 14 #include "file.h" |
15 #include "fcntl.h" | 15 #include "fcntl.h" |
16 | 16 |
17 #include "arm.h" | |
18 #include "syscall.h" | |
19 #interface "CbCSysFile.h" | |
20 | |
21 #define __ncode __code | 17 #define __ncode __code |
22 | |
23 struct CbCSysFile* create_cbc_sys_file(struct Context* cbc_context) { | |
24 struct CbCSysFile* cbc_file = new CbCSysFile(); | |
25 cbc_file->read = C_cbc_fileread; | |
26 cbc_file->cbc_file_ret = C_cbc_file_ret; | |
27 return cbc_file; | |
28 } | |
29 | |
30 __code cbc_file_trap_return(){ | |
31 return; | |
32 } | |
33 | |
34 __code cbc_file_ret(struct CbCSysFile* cbc_sys_file, struct UInteger* ret){ | |
35 int num = cbc_sys_file->num->value; | |
36 uint return_value = ret->value; | |
37 //int num = proc->cbc_arg.cbc_console_arg.num; | |
38 if (num != SYS_exec) { | |
39 proc->tf->r0 = return_value; | |
40 } | |
41 goto cbc_file_trap_return(); | |
42 } | |
43 | 18 |
44 // Fetch the nth word-sized system call argument as a file descriptor | 19 // Fetch the nth word-sized system call argument as a file descriptor |
45 // and return both the descriptor and the corresponding struct file. | 20 // and return both the descriptor and the corresponding struct file. |
46 static int argfd(int n, int *pfd, struct file **pf) | 21 static int argfd(int n, int *pfd, struct file **pf) |
47 { | 22 { |
99 filedup(f); | 74 filedup(f); |
100 | 75 |
101 return fd; | 76 return fd; |
102 } | 77 } |
103 | 78 |
104 __code cbc_read(struct CbCSysFile* cbc_file){ | 79 __ncode cbc_read(__code (*next)(int ret)){ |
105 //struct CbCSysFile* cbc_file = create_cbc_sys_file(cbc_context); | |
106 goto cbc_fileread(); | |
107 } | |
108 | |
109 __code cbc_read_stub(struct Context* cbc_context){ | |
110 struct file *f; | 80 struct file *f; |
111 int n; | 81 int n; |
112 char *p; | 82 char *p; |
113 | 83 |
114 CbCSysFile* cbc_sys_file = (CbCSysFile*)Gearef(cbc_context,CbCSysFile); | |
115 if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) { | 84 if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) { |
116 //__code cbc_file_ret(struct CbCSysFile* cbc_sys_file, struct UInteger* ret){ | 85 goto next(-1); |
117 UInteger* ret = (UInteger*)Gearef(cbc_context,UInteger); | 86 } |
118 ret->value = -1; | 87 goto cbc_fileread(f, p, n, next); |
119 goto cbc_file_ret(cbc_context, cbc_sys_file, ret); | |
120 } | |
121 cbc_sys_file->f = f; | |
122 cbc_sys_file->n = n; | |
123 cbc_sys_file->p = p; | |
124 goto cbc_read(cbc_context,cbc_sys_file); | |
125 } | 88 } |
126 | 89 |
127 int sys_read(void) | 90 int sys_read(void) |
128 { | 91 { |
129 struct file *f; | 92 struct file *f; |