redesign of the IO interface
=> do not create an additional task to dump kernel messages
This commit is contained in:
parent
ec5c78fbb3
commit
80377e4ff3
3 changed files with 20 additions and 27 deletions
|
@ -25,6 +25,9 @@
|
|||
#include <metalsvm/tasks.h>
|
||||
#include <metalsvm/errno.h>
|
||||
#include <metalsvm/init.h>
|
||||
#ifdef CONFIG_VGA
|
||||
#include <asm/vga.h>
|
||||
#endif
|
||||
#ifdef CONFIG_LWIP
|
||||
#include <lwip/init.h>
|
||||
#include <lwip/sys.h>
|
||||
|
@ -44,6 +47,9 @@ static volatile int done = 0;
|
|||
|
||||
int lowlevel_init(void)
|
||||
{
|
||||
#ifdef CONFIG_VGA
|
||||
vga_init();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -28,35 +28,19 @@
|
|||
#include <asm/vga.h>
|
||||
#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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue