From 0a41cf2fc087add4eda869708a9861cc6d4e9ffd Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 19 Jul 2018 11:09:33 +0200 Subject: [PATCH 1/5] Add a lib.rs that re-exports os_bootinfo --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/lib.rs diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 00000000..e25b78ff --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,3 @@ +#![no_std] + +pub extern crate os_bootinfo as bootinfo; From 15f8699a026aae896c062bff2398e0b9ce791c78 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 19 Jul 2018 11:09:43 +0200 Subject: [PATCH 2/5] Add an entry_point macro --- src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e25b78ff..709fbe9a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,23 @@ #![no_std] pub extern crate os_bootinfo as 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) + } + }; +} From c84207e56e253308ffba8ffad9259196a4455e68 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 19 Jul 2018 11:13:48 +0200 Subject: [PATCH 3/5] Disable interrupts instead of masking --- src/second_stage.s | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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. From 4a453c5f4ba29f76876027f647650409138a171e Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 19 Jul 2018 11:10:15 +0200 Subject: [PATCH 4/5] Bump version to 0.2.0-beta --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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." From 4bb45a4024d9d254fc1469dde7dd873d70fa0243 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 19 Jul 2018 23:30:20 +0200 Subject: [PATCH 5/5] Hide os_bootinfo using own bootinfo module This allows us to merge the os_bootinfo crate into the bootloader without breakage (in case we want to do that someday). It also hides the os_bootinfo crate as an implementation detail. --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 709fbe9a..360fb649 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,10 @@ #![no_std] -pub extern crate os_bootinfo as bootinfo; +extern crate os_bootinfo; + +pub mod bootinfo { + pub use os_bootinfo::*; +} /// Defines the entry point function. ///