Fix kernel entrypoint

This commit is contained in:
Mathieu Strypsteen 2024-06-30 19:14:39 +02:00
parent 37f8c7d1ae
commit 2d42ee3202
2 changed files with 22 additions and 8 deletions

View file

@ -1,22 +1,31 @@
#![no_std]
#![no_main]
use core::{arch::asm, panic::PanicInfo};
use core::{
arch::{asm, global_asm},
panic::PanicInfo,
};
use gdt::setup_gdt;
use log::{error, info};
mod gdt;
static mut STACK: [u8; 8 * 1024] = [0; 8 * 1024];
global_asm!(
"
.global _start
_start:
mov $stack, %rsp
call main
.section .bss
.align 16
.skip 0x2000
stack:
",
options(att_syntax)
);
#[no_mangle]
fn _start() -> ! {
unsafe {
asm!("mov rsp, {}", in(reg) STACK.as_ptr().add(STACK.len()));
}
main();
}
fn main() -> ! {
com_logger::init();
info!("Starting kernel...");

5
qemu.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
# shellcheck disable=SC2068
set -e
./build.sh
qemu-system-x86_64 -M q35 -m 256M -L /usr/share/OVMF -bios OVMF_CODE.fd -drive file=img/os.img,format=raw $@