From 8e933fac9fd068343bb602f13175c8d70a6c5768 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Wed, 1 Aug 2018 02:27:57 +1000 Subject: Defined EOF as -1 in stdio.h. Implemented the sprintf() library function in lib/stdio.c which uses the vsprintf() function. Implemented a very primative controlling TTY for each process. This is achieved by a switch in the sys_puts system call which uses the 'ctty' element of the process' task structure to determine an appropriate I/O channel. A negative ctty value doesn't equate to any I/O channel effectively disabling the process' output. Added the sys_ctty system call which allows a process to set it's own ctty value. Removed the sys_rsputs system call. Output to serial is now performed by the process first setting it's ctty value to 1, then invoking sys_puts. --- kernel/serial.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'kernel/serial.c') diff --git a/kernel/serial.c b/kernel/serial.c index 7f23298..86bbd87 100644 --- a/kernel/serial.c +++ b/kernel/serial.c @@ -15,10 +15,20 @@ #define RSMODEMS (RSBASE + 6) #define RSSCRATCH (RSBASE + 7) -static int rsputs(char *s) { +#define rswait()\ + while((inb(RSLINES) & 0x20) == 0); + +int rsputs(char *s) { while(*s) { - while((inb(RSLINES) & 0x20) == 0); - outb(RSDATA, *s++); + rswait(); + if(*s == '\n') { + outb(RSDATA, '\n'); + rswait(); + outb(RSDATA, '\r'); + s++; + } else { + outb(RSDATA, *s++); + } } return 0; @@ -46,7 +56,3 @@ void serial_init(void) { rsputs("[kernel] Serial monitor initialized!\n\r"); printk("[rs] Serial port COM0 initialized!\n"); } - -int sys_rsputs(char *s) { - return rsputs(s); -} -- cgit v1.3