diff options
-rw-r--r-- | src/kernel/syscall/actions/sys_read.c | 5 | ||||
-rw-r--r-- | src/kernel/syscall/actions/sys_write.c | 10 | ||||
-rw-r--r-- | src/kernel/syscall/syscall.c | 4 | ||||
-rw-r--r-- | src/kernel/syscall/syscall.h | 4 | ||||
-rw-r--r-- | src/userspace/main.c | 5 | ||||
-rw-r--r-- | src/userspace/syscall.h | 9 |
6 files changed, 33 insertions, 4 deletions
diff --git a/src/kernel/syscall/actions/sys_read.c b/src/kernel/syscall/actions/sys_read.c index 673d2d9..f04f3ef 100644 --- a/src/kernel/syscall/actions/sys_read.c +++ b/src/kernel/syscall/actions/sys_read.c @@ -13,4 +13,9 @@ uint32_t sys_read(char *buf) } memcpy(buf, keyboard_buffer, strlen(keyboard_buffer)); return strlen(buf); +} + +uint32_t sys_readc() +{ + return getch(); }
\ No newline at end of file diff --git a/src/kernel/syscall/actions/sys_write.c b/src/kernel/syscall/actions/sys_write.c index f159335..554ac5f 100644 --- a/src/kernel/syscall/actions/sys_write.c +++ b/src/kernel/syscall/actions/sys_write.c @@ -7,4 +7,14 @@ uint32_t sys_write(char *buf) { printf(buf); return strlen((const char *) buf); +} + +uint32_t sys_writec(char ch) +{ + serial_write_hex(ch); + serial_write("\n"); + serial_put(ch); + serial_write("\n\n"); + writec(ch); + return 0; }
\ No newline at end of file diff --git a/src/kernel/syscall/syscall.c b/src/kernel/syscall/syscall.c index eb44c87..89b70eb 100644 --- a/src/kernel/syscall/syscall.c +++ b/src/kernel/syscall/syscall.c @@ -7,7 +7,9 @@ typedef uint32_t (*syscall_func)(unsigned int, ...); uint32_t (*syscalls[])() = { [1] = sys_write, - [2] = sys_read + [2] = sys_read, + [3] = (uint32_t (*)()) sys_writec, + [4] = sys_readc }; void syscall_handler(struct regs *r) diff --git a/src/kernel/syscall/syscall.h b/src/kernel/syscall/syscall.h index f441cf1..046d702 100644 --- a/src/kernel/syscall/syscall.h +++ b/src/kernel/syscall/syscall.h @@ -7,6 +7,10 @@ void syscalls_install(); uint32_t sys_write(char *buf); +uint32_t sys_writec(char ch); + uint32_t sys_read(char *buf); +uint32_t sys_readc(); + #endif
\ No newline at end of file diff --git a/src/userspace/main.c b/src/userspace/main.c index 1e68496..64077eb 100644 --- a/src/userspace/main.c +++ b/src/userspace/main.c @@ -6,8 +6,7 @@ void user_main() syscall_write(hello); while (1) { - char buffer[20] = {'\0'}; - syscall_read(buffer); - syscall_write(buffer); + char ch = (char) syscall_readc(); + syscall_writec(ch); }; }
\ No newline at end of file diff --git a/src/userspace/syscall.h b/src/userspace/syscall.h index d5d8920..4ddd9d2 100644 --- a/src/userspace/syscall.h +++ b/src/userspace/syscall.h @@ -66,6 +66,11 @@ DECL_SYSCALL1(write, char *); DECL_SYSCALL1(read, char *); +DECL_SYSCALL1(writec, char); + +DECL_SYSCALL0(readc); + + /** * DEFINITIONS */ @@ -73,4 +78,8 @@ DEFN_SYSCALL1(write, 1, char *); DEFN_SYSCALL1(read, 2, char *); +DEFN_SYSCALL1(writec, 3, char); + +DEFN_SYSCALL0(readc, 4); + #endif |