diff --git a/Cargo.lock b/Cargo.lock index a3029e11..bef26da6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bootloader" -version = "0.2.0-alpha-005" +version = "0.2.0-beta" dependencies = [ "fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "os_bootinfo 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 78da3ffc..87288568 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ cargo-features = ["publish-lockfile"] [package] name = "bootloader" -version = "0.2.0-alpha-005" +version = "0.2.0-beta" authors = ["Philipp Oppermann "] license = "MIT/Apache-2.0" description = "An experimental pure-Rust x86 bootloader." diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 00000000..360fb649 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,27 @@ +#![no_std] + +extern crate os_bootinfo; + +pub mod bootinfo { + pub use os_bootinfo::*; +} + +/// Defines the entry point function. +/// +/// The function must have the signature `fn(&'static BootInfo) -> !`. +/// +/// This macro just creates a function named `_start`, which the linker will use as the entry +/// point. The advantage of using this macro instead of providing an own `_start` function is +/// that the macro ensures that the function and argument types are correct. +#[macro_export] +macro_rules! entry_point { + ($path:path) => { + #[export_name = "_start"] + pub extern "C" fn __impl_start(boot_info: &'static $crate::bootinfo::BootInfo) -> ! { + // validate the signature of the program entry point + let f: fn(&'static $crate::bootinfo::BootInfo) -> ! = $path; + + f(boot_info) + } + }; +} diff --git a/src/second_stage.s b/src/second_stage.s index 7e31ea75..730380f8 100644 --- a/src/second_stage.s +++ b/src/second_stage.s @@ -81,13 +81,7 @@ check_cpu: call check_cpuid call check_long_mode -disable_irqs: - mov al, 0xFF # Out 0xFF to 0xA1 and 0x21 to disable all IRQs. - out 0xA1, al - out 0x21, al - - nop - nop + cli # disable interrupts lidt zero_idt # Load a zero length IDT so that any NMI causes a triple fault.