From fffa6d99ae14b1b233fd79012d4af4cfcd5d647a Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Thu, 24 Mar 2011 20:18:14 -0500 Subject: [PATCH] One task runs the clock, one task runs the shell. --- kernel/core/vga.c | 26 ++++++++++++++++++++++++-- kernel/include/system.h | 3 +++ kernel/main.c | 29 ++++++----------------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/kernel/core/vga.c b/kernel/core/vga.c index 77877ee5..07b607ce 100644 --- a/kernel/core/vga.c +++ b/kernel/core/vga.c @@ -5,7 +5,8 @@ */ unsigned short * textmemptr; int attrib = 0x0F; -int csr_x = 0, csr_y = 0; +int csr_x = 0, csr_y = 0, use_serial = 1; +int old_x = 0, old_y = 0, old_s = 1; /* * scroll @@ -31,6 +32,25 @@ scroll() { } } +void +set_serial(int on) { + use_serial = on; +} + +void +store_csr() { + old_x = csr_x; + old_y = csr_y; + old_s = use_serial; +} + +void +restore_csr() { + csr_x = old_x; + csr_y = old_y; + use_serial = old_s; +} + /* * move_csr * Update the hardware cursor @@ -144,7 +164,9 @@ writech( *where = c | att; csr_x++; } - serial_send(c); + if (use_serial) { + serial_send(c); + } if (csr_x >= 80) { csr_x = 0; diff --git a/kernel/include/system.h b/kernel/include/system.h index bd22d85c..014a0d7f 100644 --- a/kernel/include/system.h +++ b/kernel/include/system.h @@ -41,6 +41,9 @@ extern void placech(unsigned char c, int x, int y, int attr); extern void writechf(unsigned char c); extern void writech(unsigned char c); extern void place_csr(uint32_t x, uint32_t y); +extern void store_csr(); +extern void restore_csr(); +extern void set_serial(int); /* GDT */ extern void gdt_install(); diff --git a/kernel/main.c b/kernel/main.c index 47a9cae6..673b501e 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -133,17 +133,10 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag, uintptr_t esp) } __asm__ __volatile__ ("sti"); - start_shell(); - /* * Aw man... */ fork(); - fork(); - fork(); - fork(); - - uint32_t i = getpid() * 10000; if (getpid() == 0) { while (1) { @@ -161,25 +154,15 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag, uintptr_t esp) uint16_t seconds = from_bcd(values[0]); __asm__ __volatile__ ("cli"); - place_csr(0,0); - settextcolor(10,0); - kprintf("%d:%d:%d", hours, minutes, seconds); + store_csr(); + place_csr(70,0); + set_serial(0); + kprintf("[%d:%d:%d]", hours, minutes, seconds); + restore_csr(); __asm__ __volatile__ ("sti"); } } else { - - while (1) { - ++i; - __asm__ __volatile__ ("cli"); - if (getpid() % 2 == 0) { - place_csr(0, getpid() / 2); - } else { - place_csr(30, getpid()/ 2); - } - settextcolor(getpid() + 1, 0); - kprintf("%d:%d", getpid(), i); - __asm__ __volatile__ ("sti"); - } + start_shell(); } return 0;