diff --git a/kern/arch/mips/syscall/syscall.c b/kern/arch/mips/syscall/syscall.c index b42d9c0..8b25ec5 100644 --- a/kern/arch/mips/syscall/syscall.c +++ b/kern/arch/mips/syscall/syscall.c @@ -110,6 +110,10 @@ void syscall(struct trapframe *tf) { thread_exit(); break; + case SYS_printchar: + err = sys_printchar((char)tf->tf_a0); + break; + /* Add stuff here */ default: diff --git a/kern/conf/conf.kern b/kern/conf/conf.kern index ad58977..dd1db07 100644 --- a/kern/conf/conf.kern +++ b/kern/conf/conf.kern @@ -379,6 +379,7 @@ file vfs/devnull.c file syscall/loadelf.c file syscall/runprogram.c file syscall/time_syscalls.c +file syscall/printchar.c # # Startup and initialization diff --git a/kern/include/kern/syscall.h b/kern/include/kern/syscall.h index 53a2b45..64cb40f 100644 --- a/kern/include/kern/syscall.h +++ b/kern/include/kern/syscall.h @@ -94,6 +94,7 @@ // #define SYS_getpriority 38 // #define SYS_setpriority 39 // (process groups, sessions, and job control) +#define SYS_printchar 41 // #define SYS_getpgid 40 // #define SYS_setpgid 41 // #define SYS_getsid 42 diff --git a/kern/include/syscall.h b/kern/include/syscall.h index 6cd517b..1098a55 100644 --- a/kern/include/syscall.h +++ b/kern/include/syscall.h @@ -57,4 +57,6 @@ __DEAD void enter_new_process(int argc, userptr_t argv, userptr_t env, int sys_reboot(int code); int sys___time(userptr_t user_seconds, userptr_t user_nanoseconds); +int sys_printchar(char c); + #endif /* _SYSCALL_H_ */ diff --git a/kern/syscall/printchar.c b/kern/syscall/printchar.c new file mode 100644 index 0000000..f7f9b83 --- /dev/null +++ b/kern/syscall/printchar.c @@ -0,0 +1,7 @@ +#include +#include +#include +int sys_printchar(char c) { + kprintf("%c", c); + return 0; +} diff --git a/userland/include/unistd.h b/userland/include/unistd.h index 9739344..2d05a92 100644 --- a/userland/include/unistd.h +++ b/userland/include/unistd.h @@ -156,4 +156,6 @@ int execvp(const char *prog, char *const *args); /* calls execv */ char *getcwd(char *buf, size_t buflen); /* calls __getcwd */ time_t time(time_t *seconds); /* calls __time */ +int printchar(char c); + #endif /* _UNISTD_H_ */ diff --git a/userland/testbin/Makefile b/userland/testbin/Makefile index 647f229..14f7f02 100644 --- a/userland/testbin/Makefile +++ b/userland/testbin/Makefile @@ -8,7 +8,7 @@ TOP=../.. SUBDIRS=add argtest badcall bigexec bigfile bigfork bigseek bloat conman \ crash ctest dirconc dirseek dirtest f_test factorial farm faulter \ filetest forkbomb forktest frack hash hog huge \ - malloctest matmult multiexec palin parallelvm poisondisk psort \ + malloctest matmult multiexec palin parallelvm poisondisk printchartest psort \ randcall redirect rmdirtest rmtest \ sbrktest schedpong sort sparsefile tail tictac triplehuge \ triplemat triplesort usemtest zero diff --git a/userland/testbin/printchartest/Makefile b/userland/testbin/printchartest/Makefile new file mode 100644 index 0000000..3294115 --- /dev/null +++ b/userland/testbin/printchartest/Makefile @@ -0,0 +1,11 @@ +# Makefile for printchartest + +TOP=../../.. +.include "$(TOP)/mk/os161.config.mk" + +PROG=printchartest +SRCS=printchartest.c +BINDIR=/testbin + +.include "$(TOP)/mk/os161.prog.mk" + diff --git a/userland/testbin/printchartest/printchartest.c b/userland/testbin/printchartest/printchartest.c new file mode 100644 index 0000000..5c3f007 --- /dev/null +++ b/userland/testbin/printchartest/printchartest.c @@ -0,0 +1,17 @@ +#include + +extern int printchar(char c); + +int main() { + + printchar('C'); + printchar('S'); + printchar('E'); + printchar('4'); + printchar('0'); + printchar('0'); + printchar('1'); + printchar('\n'); + + return 0; +}