#include #include #include #include #include #include #include #include #include #include #include #include #include extern unsigned long get_rflags(void); extern char __pstart[], __pend[]; void print_kernel_banner(void) { printk("Mango kernel version " BUILD_ID); } static void hang(void) { struct task *self = current_task(); struct thread *thread = current_thread(); while (1) { printk("[cpu %u, task %u, thread %u]: tick", this_cpu(), self->t_id, thread->tr_id); milli_sleep(2000); } } void background_thread(void) { struct task *self = current_task(); struct thread *thread = current_thread(); printk("background_thread() running on processor %u", this_cpu()); milli_sleep(1000); while (1) { printk("[cpu %u, task %u, thread %u]: tock", this_cpu(), self->t_id, thread->tr_id); milli_sleep(2000); } } static void putchar(char c) { unsigned long flags; struct queue *consoles = get_consoles(&flags); queue_foreach(struct console, con, consoles, c_list) { console_write(con, &c, 1); } put_consoles(consoles, flags); } void kernel_init(uintptr_t arg) { ml_init(arg); printk("kernel_init() running on processor %u", this_cpu()); create_kernel_thread(background_thread); hang(); }