76 lines
1.5 KiB
C
76 lines
1.5 KiB
C
#include <mango/arg.h>
|
|
#include <mango/clock.h>
|
|
#include <mango/cpu.h>
|
|
#include <mango/init.h>
|
|
#include <mango/input.h>
|
|
#include <mango/libc/stdio.h>
|
|
#include <mango/machine/init.h>
|
|
#include <mango/object.h>
|
|
#include <mango/panic.h>
|
|
#include <mango/printk.h>
|
|
#include <mango/sched.h>
|
|
#include <mango/test.h>
|
|
#include <stdint.h>
|
|
|
|
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();
|
|
}
|