diff options
Diffstat (limited to 'src/kernel/arch')
-rw-r--r-- | src/kernel/arch/amd64/boot.c | 70 | ||||
-rw-r--r-- | src/kernel/arch/generic.h | 2 |
2 files changed, 41 insertions, 31 deletions
diff --git a/src/kernel/arch/amd64/boot.c b/src/kernel/arch/amd64/boot.c index a03c21d..e92b040 100644 --- a/src/kernel/arch/amd64/boot.c +++ b/src/kernel/arch/amd64/boot.c @@ -1,3 +1,4 @@ +#include <kernel/arch/amd64/3rdparty/multiboot2.h> #include <kernel/arch/amd64/boot.h> #include <kernel/arch/amd64/driver/fsroot.h> #include <kernel/arch/amd64/driver/pata.h> @@ -6,12 +7,11 @@ #include <kernel/arch/amd64/driver/video.h> #include <kernel/arch/amd64/interrupts/idt.h> #include <kernel/arch/amd64/interrupts/irq.h> -#include <kernel/arch/amd64/3rdparty/multiboot2.h> #include <kernel/arch/amd64/tty/tty.h> #include <kernel/arch/generic.h> -#include <kernel/main.h> #include <kernel/mem/alloc.h> #include <kernel/panic.h> +#include <kernel/proc.h> static void *mbi_tag(void *mbi, uint32_t type) { struct multiboot_tag *tag; @@ -27,8 +27,10 @@ static void *mbi_tag(void *mbi, uint32_t type) { } void kmain_early(void *mbi) { - struct kmain_info info; struct fb_info vid; + struct { + void *addr; size_t len; + } init; tty_init(); kprintf("idt..."); @@ -36,44 +38,50 @@ void kmain_early(void *mbi) { kprintf("irq..."); irq_init(); - struct multiboot_tag_basic_meminfo *meminfo; - meminfo = mbi_tag(mbi, MULTIBOOT_TAG_TYPE_BASIC_MEMINFO); - info.memtop = (void*)(long)(meminfo->mem_upper * 1024); - - struct multiboot_tag_framebuffer *framebuf; - framebuf = mbi_tag(mbi, MULTIBOOT_TAG_TYPE_FRAMEBUFFER); - vid.b = (void*)framebuf->common.framebuffer_addr; - vid.pitch = framebuf->common.framebuffer_pitch; - vid.width = framebuf->common.framebuffer_width; - vid.height = framebuf->common.framebuffer_height; - vid.bpp = framebuf->common.framebuffer_bpp; - vid.size = vid.pitch * vid.height; - // TODO framebuffer doesn't need to be part of kmain_info - info.fb.at = vid.b; - info.fb.size = vid.size; + { + kprintf("mem...\n"); + struct multiboot_tag_basic_meminfo *meminfo; + meminfo = mbi_tag(mbi, MULTIBOOT_TAG_TYPE_BASIC_MEMINFO); + mem_init((void*)(long)(meminfo->mem_upper * 1024)); + } - struct multiboot_tag_module *init; - init = mbi_tag(mbi, MULTIBOOT_TAG_TYPE_MODULE); - info.init.at = (void*)(long)init->mod_start; - info.init.size = init->mod_end - init->mod_start; + { + struct multiboot_tag_framebuffer *framebuf; + framebuf = mbi_tag(mbi, MULTIBOOT_TAG_TYPE_FRAMEBUFFER); + vid.b = (void*)framebuf->common.framebuffer_addr; + vid.pitch = framebuf->common.framebuffer_pitch; + vid.width = framebuf->common.framebuffer_width; + vid.height = framebuf->common.framebuffer_height; + vid.bpp = framebuf->common.framebuffer_bpp; + vid.size = vid.pitch * vid.height; + mem_reserve(vid.b, vid.size); + kprintf("framebuffer at 0x%x, %ux%u bpp %u\n", vid.b, vid.width, vid.height, vid.bpp); + } - kprintf("mem...\n"); - mem_init(&info); + { + struct multiboot_tag_module *mod; + mod = mbi_tag(mbi, MULTIBOOT_TAG_TYPE_MODULE); + init.addr = (void*)(long)mod->mod_start; + init.len = mod->mod_end - mod->mod_start; + mem_reserve(init.addr, init.len); + } kprintf("rootfs...\n"); vfs_root_init(); ps2_init(); serial_init(); + video_init(vid); kprintf("ata...\n"); pata_init(); - kprintf("kernel %8x -> %8x\n", 0, &_bss_end); - kprintf("init %8x -> %8x\n", info.init.at, info.init.at + info.init.size); - kprintf("video %8x -> %8x\n", vid.b, vid.b + vid.size); - kprintf("limit %8x\n", info.memtop); - kprintf("framebuffer at 0x%x, %ux%u bpp %u\n", vid.b, vid.width, vid.height, vid.bpp); - video_init(vid); + kprintf("running init...\n"); + process_seed(init.addr, init.len); + process_switch_any(); +} - kmain(info); +void shutdown(void) { + kprintf("shutting off\n"); + mem_debugprint(); + cpu_shutdown(); } diff --git a/src/kernel/arch/generic.h b/src/kernel/arch/generic.h index 0b7b2f2..b213962 100644 --- a/src/kernel/arch/generic.h +++ b/src/kernel/arch/generic.h @@ -20,6 +20,8 @@ __attribute__((noreturn)) void cpu_halt(void); __attribute__((noreturn)) void cpu_shutdown(void); +__attribute__((noreturn)) +void shutdown(void); /** on x86: waits for an IRQ */ void cpu_pause(void); |