Skip to content

Commit

Permalink
limine: update to 2024 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Feb 21, 2025
1 parent 47e8655 commit 6b8eed3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion oro-bootloader-limine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "oro-bootloader-limine"
version.workspace = true
description = "Oro operating system Limine bootloader support"
publish = false
edition = "2021"
edition = "2024"
authors = [
"Josh Junon (https//github.com/qix-)"
]
Expand Down
10 changes: 7 additions & 3 deletions oro-bootloader-limine/bin/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#[inline(never)]
#[panic_handler]
unsafe fn panic(info: &::core::panic::PanicInfo<'_>) -> ! {
::oro_bootloader_limine::panic(info)
// SAFETY: This is the architecture-specific entry function, the
// SAFETY: only allowed place to call this function.
unsafe { ::oro_bootloader_limine::panic(info) }
}

/// Main entry point for the Limine bootloader stage
Expand All @@ -18,7 +20,9 @@ unsafe fn panic(info: &::core::panic::PanicInfo<'_>) -> ! {
/// by the Limine bootloader.
#[inline(never)]
#[cold]
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn _start() -> ! {
::oro_bootloader_limine::init()
// SAFETY: This is the architecture-specific entry function, the
// SAFETY: only allowed place to call this function.
unsafe { ::oro_bootloader_limine::init() }
}
15 changes: 11 additions & 4 deletions oro-bootloader-limine/bin/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#[inline(never)]
#[panic_handler]
unsafe fn panic(info: &::core::panic::PanicInfo<'_>) -> ! {
::oro_bootloader_limine::panic(info)
// SAFETY: This is the architecture-specific entry function, the
// SAFETY: only allowed place to call this function.
unsafe { ::oro_bootloader_limine::panic(info) }
}

/// Main entry point for the Limine bootloader stage
Expand All @@ -18,8 +20,13 @@ unsafe fn panic(info: &::core::panic::PanicInfo<'_>) -> ! {
/// by the Limine bootloader.
#[inline(never)]
#[cold]
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn _start() -> ! {
::core::arch::asm!("cli");
::oro_bootloader_limine::init()
// SAFETY: Inline assembly is required to disable interrupts.
unsafe {
::core::arch::asm!("cli");
}
// SAFETY: This is the architecture-specific entry function, the
// SAFETY: only allowed place to call this function.
unsafe { ::oro_bootloader_limine::init() }
}
15 changes: 10 additions & 5 deletions oro-bootloader-limine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ pub unsafe fn init() -> ! {
let hhdm_offset = hhdm_response.offset();

(|| {
Err({
// SAFETY: The call to bootstrap is inherently unsafe; we call it
// SAFETY: once here, from only the bootstrap processor.
Err(unsafe {
let bs = oro_boot::OroBootstrapper::bootstrap(
hhdm_offset,
KERNEL_STACK_PAGES,
Expand Down Expand Up @@ -297,9 +299,12 @@ pub unsafe fn panic(info: &::core::panic::PanicInfo<'_>) -> ! {

dbg_err!("panic: {:?}", info);
loop {
#[cfg(target_arch = "x86_64")]
asm!("hlt");
#[cfg(target_arch = "aarch64")]
asm!("wfi");
// SAFETY: Inline assembly is required to halt the CPU.
unsafe {
#[cfg(target_arch = "x86_64")]
asm!("hlt");
#[cfg(target_arch = "aarch64")]
asm!("wfi");
}
}
}

0 comments on commit 6b8eed3

Please sign in to comment.