Mercurial > hg > Members > menikon > CbC_xv6
changeset 29:a672d603ccb2
fix
author | mir3636 |
---|---|
date | Fri, 18 Jan 2019 10:04:37 +0900 |
parents | 68de775c3a29 |
children | 6a7ab1d7001c |
files | src/console.c src/file.h src/syscall.c src/syscall.h |
diffstat | 4 files changed, 34 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/src/console.c Fri Jan 18 09:40:22 2019 +0900 +++ b/src/console.c Fri Jan 18 10:04:37 2019 +0900 @@ -215,33 +215,6 @@ release(&input.lock); } -__code cbc_consoleread (struct inode *ip, char *dst, int n, __code(*next)(int ret)) -{ - uint target; - - iunlock(ip); - - target = n; - acquire(&input.lock); - - while (n > 0) { - while (input.r == input.w) { - if (proc->killed) { - release(&input.lock); - ilock(ip); - goto next(-1); - } - - proc->cbc_arg.cbc_console_arg.n = n; - proc->cbc_arg.cbc_console_arg.target = target; - proc->cbc_arg.cbc_console_arg.dst = dst; - proc->cbc_arg.cbc_console_arg.ip = ip; - proc->cbc_arg.cbc_console_arg.next = next; - goto cbc_sleep(&input.r, &input.lock, cbc_consoleread1); - } - } -} - __code cbc_consoleread1 (__code(*next)(int ret)) { int cont = 1; @@ -283,6 +256,33 @@ goto next(target - n); } +__code cbc_consoleread (struct inode *ip, char *dst, int n, __code(*next)(int ret)) +{ + uint target; + + iunlock(ip); + + target = n; + acquire(&input.lock); + + while (n > 0) { + while (input.r == input.w) { + if (proc->killed) { + release(&input.lock); + ilock(ip); + goto next(-1); + } + + proc->cbc_arg.cbc_console_arg.n = n; + proc->cbc_arg.cbc_console_arg.target = target; + proc->cbc_arg.cbc_console_arg.dst = dst; + proc->cbc_arg.cbc_console_arg.ip = ip; + proc->cbc_arg.cbc_console_arg.next = next; + goto cbc_sleep(&input.r, &input.lock, cbc_consoleread1); + } + } +} + int consoleread (struct inode *ip, char *dst, int n) { uint target;
--- a/src/file.h Fri Jan 18 09:40:22 2019 +0900 +++ b/src/file.h Fri Jan 18 10:04:37 2019 +0900 @@ -34,8 +34,8 @@ }; struct cbc_devsw { - int (*read) (struct inode*, char*, int, __code (*)(int)); - //int (*write)(struct inode*, char*, int, __code (*)(int)); + __code (*read) (struct inode*, char*, int, __code (*)(int)); + //__code (*write)(struct inode*, char*, int, __code (*)(int)); }; extern struct devsw devsw[];
--- a/src/syscall.c Fri Jan 18 09:40:22 2019 +0900 +++ b/src/syscall.c Fri Jan 18 10:04:37 2019 +0900 @@ -115,6 +115,8 @@ extern int sys_write(void); extern int sys_uptime(void); +extern __code cbc_read(__code(*)(int)); + static int (*syscalls[])(void) = { [SYS_fork] =sys_fork, [SYS_exit] =sys_exit, @@ -139,7 +141,7 @@ [SYS_close] =sys_close, }; -static __code (*cbccodes[])(void) = { +static __code (*cbccodes[])(__code (*)(int)) = { [SYS_cbc_read] = cbc_read, };