Skip to content

Kernel loading #505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ofluffydev opened this issue Apr 6, 2025 · 2 comments
Open

Kernel loading #505

ofluffydev opened this issue Apr 6, 2025 · 2 comments

Comments

@ofluffydev
Copy link

I see in the UEFI folder it does in fact use the uefi-rs crate which is nice. I cannot for the love of everything load a kernel in elf64 format... Normally, I'd ask this in the discussions tab which is currently off, so I will try to ask here. I've spent all day playing with numerous elf crates and even trying to parse it myself with no luck. No matter what happens, it just hangs after trying to jump to the kernel. So, how/where does this implementation handle jumping into a kernel?

@Freax13
Copy link
Member

Freax13 commented Apr 6, 2025

If you're having trouble using this crate, please read the usage section or take a look at some of our test kernels.

Most of the code responsible for loading the elf file can be found here.
The code that jumps to the kernel is here:

unsafe fn context_switch(addresses: Addresses) -> ! {
unsafe {
asm!(
r#"
xor rbp, rbp
mov cr3, {}
mov rsp, {}
push 0
jmp {}
"#,
in(reg) addresses.page_table.start_address().as_u64(),
in(reg) addresses.stack_top.as_u64(),
in(reg) addresses.entry_point.as_u64(),
in("rdi") addresses.boot_info as *const _ as usize,
);
}
unreachable!();
}

@ofluffydev
Copy link
Author

ofluffydev commented Apr 6, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants