- add macro for a static initialization of a semaphore

- create a special process which reads the kernel messages from a buffer and dump them on the screen



git-svn-id: http://svn.lfbs.rwth-aachen.de/svn/scc/trunk/MetalSVM@51 315a16e6-25f9-4109-90ae-ca3045a26c18
This commit is contained in:
stefan 2010-08-09 15:43:45 +00:00
parent ffd61e14b0
commit 311b32aef8
3 changed files with 30 additions and 9 deletions

View file

@ -35,6 +35,8 @@ typedef struct {
spinlock_t lock;
} sem_t;
#define SEM_INIT(v) {v, {[0 ... MAX_TASKS-1] = MAX_TASKS}, 0, SPINLOCK_INIT};
inline static int sem_init(sem_t* s, unsigned int v) {
unsigned int i;

View file

@ -192,13 +192,13 @@ int main(void)
system_init();
irq_init();
koutput_init();
timer_init();
#ifdef CONFIG_KEYBOARD
keyboard_init();
#endif
mmu_init();
multitasking_init();
koutput_init();
irq_enable();

View file

@ -20,20 +20,41 @@
#include <metalsvm/stdio.h>
#include <metalsvm/string.h>
#include <metalsvm/stdarg.h>
#include <metalsvm/tasks.h>
#include <metalsvm/semaphore.h>
#include <asm/atomic.h>
#ifdef CONFIG_VGA
#include <asm/vga.h>
#endif
static atomic_int32_t kmsg_counter = ATOMIC_INIT(0);
static unsigned char kmessages[KMSG_SIZE];
static unsigned char kmessages[KMSG_SIZE] = {[0 ... KMSG_SIZE-1] = 0};
#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
memset(kmessages, 0, sizeof(unsigned char)*KMSG_SIZE);
return 0;
}
@ -45,10 +66,9 @@ int kputchar(int c)
pos = atomic_int32_inc(&kmsg_counter);
kmessages[pos % KMSG_SIZE] = c;
#ifdef CONFIG_VGA
ret = vga_putchar(c);
#endif
sem_post(&sem_output);
#endif
return ret;
}
@ -61,11 +81,10 @@ int kputs(const char *str)
for(i=0; str[i] != '\0'; i++) {
pos = atomic_int32_inc(&kmsg_counter);
kmessages[pos % KMSG_SIZE] = str[i];
}
#ifdef CONFIG_VGA
i = vga_puts(str);
sem_post(&sem_output);
#endif
}
return i;
}