kernel: implementing mapping and execution of bsp executable
This commit is contained in:
44
init/main.c
44
init/main.c
@@ -1,6 +1,8 @@
|
||||
#include <mango/arg.h>
|
||||
#include <mango/bsp.h>
|
||||
#include <mango/clock.h>
|
||||
#include <mango/cpu.h>
|
||||
#include <mango/handle.h>
|
||||
#include <mango/init.h>
|
||||
#include <mango/input.h>
|
||||
#include <mango/libc/stdio.h>
|
||||
@@ -10,6 +12,7 @@
|
||||
#include <mango/printk.h>
|
||||
#include <mango/sched.h>
|
||||
#include <mango/test.h>
|
||||
#include <mango/vm-object.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern unsigned long get_rflags(void);
|
||||
@@ -23,14 +26,16 @@ void print_kernel_banner(void)
|
||||
|
||||
static void hang(void)
|
||||
{
|
||||
struct task *self = current_task();
|
||||
struct thread *thread = current_thread();
|
||||
// struct task *self = current_task();
|
||||
// struct thread *thread = current_thread();
|
||||
|
||||
while (1) {
|
||||
#if 0
|
||||
printk("[cpu %u, task %u, thread %u]: tick",
|
||||
this_cpu(),
|
||||
self->t_id,
|
||||
thread->tr_id);
|
||||
#endif
|
||||
milli_sleep(2000);
|
||||
}
|
||||
}
|
||||
@@ -67,9 +72,40 @@ void kernel_init(uintptr_t arg)
|
||||
{
|
||||
ml_init(arg);
|
||||
|
||||
printk("kernel_init() running on processor %u", this_cpu());
|
||||
struct boot_module bsp_image = {0};
|
||||
bsp_get_location(&bsp_image);
|
||||
|
||||
create_kernel_thread(background_thread);
|
||||
tracek("kernel_init() running on processor %u", this_cpu());
|
||||
|
||||
if (!bsp_image.mod_base) {
|
||||
printk("FATAL: no bsp image specified");
|
||||
hang();
|
||||
}
|
||||
|
||||
tracek("bsp image at [0x%llx-0x%llx]",
|
||||
bsp_image.mod_base,
|
||||
bsp_image.mod_base + bsp_image.mod_size);
|
||||
|
||||
struct bsp bsp;
|
||||
kern_status_t status = bsp_load(&bsp, &bsp_image);
|
||||
if (status != KERN_OK) {
|
||||
printk("FATAL: bsp image is corrupt/invalid");
|
||||
hang();
|
||||
}
|
||||
|
||||
tracek("bsp image loaded. text=[%06llx-%06llx], data=[%06llx-%06llx], "
|
||||
"entry=%06llx, vmo=%p",
|
||||
bsp.bsp_trailer.bsp_text_vaddr,
|
||||
bsp.bsp_trailer.bsp_text_size + bsp.bsp_trailer.bsp_text_vaddr,
|
||||
bsp.bsp_trailer.bsp_data_vaddr,
|
||||
bsp.bsp_trailer.bsp_data_size + bsp.bsp_trailer.bsp_data_vaddr,
|
||||
bsp.bsp_trailer.bsp_exec_entry,
|
||||
bsp.bsp_vmo);
|
||||
|
||||
struct task *bootstrap_task = task_create(kernel_task(), "bootstrap");
|
||||
tracek("created bootstrap task (pid=%u)", bootstrap_task->t_id);
|
||||
|
||||
bsp_launch_async(&bsp, bootstrap_task);
|
||||
|
||||
hang();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user