diff --git a/kernel/init.c b/kernel/init.c index 2ee97f57..640029a3 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -25,6 +25,9 @@ #include #include #include +#ifdef CONFIG_VGA +#include +#endif #ifdef CONFIG_LWIP #include #include @@ -44,6 +47,9 @@ static volatile int done = 0; int lowlevel_init(void) { +#ifdef CONFIG_VGA + vga_init(); +#endif return 0; } diff --git a/kernel/main.c b/kernel/main.c index 5f8a01b4..a67e2bde 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -77,9 +77,10 @@ static void list_root(void) { int main(void) { + lowlevel_init(); + kprintf("This is MetalSVM %s Build %u, %u\n", METALSVM_VERSION, &__BUILD_DATE, &__BUILD_TIME); - lowlevel_init(); system_init(); irq_init(); timer_init(); diff --git a/libkern/stdio.c b/libkern/stdio.c index db4eb40a..451e85f6 100644 --- a/libkern/stdio.c +++ b/libkern/stdio.c @@ -28,35 +28,19 @@ #include #endif +#define NO_EARLY_PRINT 0 +#define VGA_EARLY_PRINT 1 + +#ifdef CONFIG_VGA +static uint32_t early_print = VGA_EARLY_PRINT; +#else +static uint32_t early_print = NO_EARLY_PRINT; +#endif static atomic_int32_t kmsg_counter = ATOMIC_INIT(0); static unsigned char kmessages[KMSG_SIZE] = {[0 ... KMSG_SIZE-1] = 0x00}; -#ifdef CONFIG_VGA -static sem_t sem_output = SEM_INIT(0); - -static int STDCALL output_task(void* arg) -{ - uint32_t rpos = 0; - - do { - sem_wait(&sem_output); - vga_putchar((int) kmessages[rpos]); - rpos = (rpos + 1) % KMSG_SIZE; - } while(1); - - return 0; -} -#endif - int koutput_init(void) { -#ifdef CONFIG_VGA - tid_t id; - - vga_init(); - create_kernel_task(&id, output_task, NULL); -#endif - return 0; } @@ -67,7 +51,8 @@ int kputchar(int c) pos = atomic_int32_inc(&kmsg_counter); kmessages[pos % KMSG_SIZE] = (unsigned char) c; #ifdef CONFIG_VGA - sem_post(&sem_output); + if (early_print == VGA_EARLY_PRINT) + vga_putchar(c); #endif return 1; @@ -82,7 +67,8 @@ int kputs(const char *str) pos = atomic_int32_inc(&kmsg_counter); kmessages[pos % KMSG_SIZE] = str[i]; #ifdef CONFIG_VGA - sem_post(&sem_output); + if (early_print == VGA_EARLY_PRINT) + vga_putchar(str[i]); #endif }