Skip to content

Commit fdd0bdd

Browse files
committed
rust64_start: Read kernel boot params from %rsi
This works because Option<&T> has the same FFI layout as *const T except that a null pointer is None. Signed-off-by: Joe Richey <joerichey@google.com>
1 parent 15959e1 commit fdd0bdd

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/asm/ram64.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ ram64_start:
1111
# Setup the stack (at the end of our RAM region)
1212
movq $ram_max, %rsp
1313

14+
# BootParams are in %rsi, the second paramter of the System V ABI.
1415
jmp rust64_start

src/main.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,16 @@ fn boot_from_device(device: &mut block::VirtioBlockDevice) -> bool {
153153
true
154154
}
155155

156-
#[cfg_attr(not(test), no_mangle)]
157-
pub extern "C" fn rust64_start() -> ! {
158-
log!("\nStarting..");
156+
#[no_mangle]
157+
pub extern "C" fn rust64_start(_rdi: *const (), rsi: Option<&boot::Params>) -> ! {
158+
if let Some(boot_params) = rsi {
159+
log!("\nBooting via Linux Boot Protocol");
160+
run(boot_params)
161+
}
162+
panic!("Unable to determine boot protocol")
163+
}
164+
165+
fn run(info: &dyn boot::Info) -> ! {
159166
enable_sse();
160167
paging::setup();
161168

0 commit comments

Comments
 (0)