comparison src/sysfile.cbc @ 93:7d0ec88cdd22

fix read interface
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sat, 19 Oct 2019 18:44:57 +0900
parents bc5bcfd2f6d6
children
comparison
equal deleted inserted replaced
92:bc5bcfd2f6d6 93:7d0ec88cdd22
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" 17 #include "arm.h"
18 #include "syscall.h"
18 #interface "CbCSysFile.h" 19 #interface "CbCSysFile.h"
19 20
20 extern int SYS_exec;
21 #define __ncode __code 21 #define __ncode __code
22 22
23 struct CbCSysFile* create_cbc_sys_file(struct Context* cbc_context) { 23 struct CbCSysFile* create_cbc_sys_file(struct Context* cbc_context) {
24 struct CbCSysFile* cbc_file = new CbCSysFile(); 24 struct CbCSysFile* cbc_file = new CbCSysFile();
25 cbc_file->read = C_cbc_fileread; 25 cbc_file->read = C_cbc_fileread;
26 cbc_file->cbc_file_ret = C_cbc_file_ret;
26 return cbc_file; 27 return cbc_file;
27 } 28 }
28 29
29 __code cbc_file_trap_return(){ 30 __code cbc_file_trap_return(){
30 return; 31 return;
98 filedup(f); 99 filedup(f);
99 100
100 return fd; 101 return fd;
101 } 102 }
102 103
103 __ncode cbc_read(__code (*next)(int ret)){ 104 __code cbc_read(struct CbCSysFile* cbc_file){
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){
104 struct file *f; 110 struct file *f;
105 int n; 111 int n;
106 char *p; 112 char *p;
107 113
114 CbCSysFile* cbc_sys_file = (CbCSysFile*)Gearef(cbc_context,CbCSysFile);
108 if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) { 115 if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) {
109 goto next(-1); 116 //__code cbc_file_ret(struct CbCSysFile* cbc_sys_file, struct UInteger* ret){
110 } 117 UInteger* ret = (UInteger*)Gearef(cbc_context,UInteger);
111 goto cbc_fileread(f, p, n, next); 118 ret->value = -1;
112 } 119 goto cbc_file_ret(cbc_context, cbc_sys_file, ret);
113 120 }
114 121 cbc_sys_file->f = f;
115 __code file_read(struct file *f, char *p, int n, __code next(...)){ 122 cbc_sys_file->n = n;
116 goto cbc_fileread(f, p, n, next); 123 cbc_sys_file->p = p;
117 } 124 goto cbc_read(cbc_context,cbc_sys_file);
118
119 __code file_read_stub(struct Context* cbc_context, __code next(...)){
120 struct CbCSysfile* cbc_file = create_cbc_sys_file(cbc_context);
121 struct file *f;
122 int n;
123 char *p;
124 if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) {
125 goto next(-1);
126 }
127 goto file_read(cbc_context,f, p, n, next);
128 } 125 }
129 126
130 int sys_read(void) 127 int sys_read(void)
131 { 128 {
132 struct file *f; 129 struct file *f;