Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 153 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ align-address = "0.3"
allocator-api2 = { version = "0.4", default-features = false }
anstyle = { version = "1", default-features = false }
cfg-if = "1"
hermit-entry = { version = "0.10", features = ["loader"] }
hermit-entry = { version = "0.10", git = "https://github.com/fogti/hermit-entry.git", branch = "image-reader", features = ["allocator-api2", "loader"] }
lazy_static = { version = "1.5.0", features = ["spin_no_std"] }
log = "0.4"
one-shot-mutex = "0.2"
sptr = "0.3"
Expand Down
6 changes: 4 additions & 2 deletions src/arch/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use sptr::Strict;

use crate::BootInfoExt;
use crate::arch::paging::*;
use crate::os::CONSOLE;
use crate::os::{CONSOLE, ExtraBootInfo};

unsafe extern "C" {
static mut loader_end: u8;
Expand Down Expand Up @@ -110,12 +110,14 @@ pub fn find_kernel() -> &'static [u8] {
}
}

pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
pub unsafe fn boot_kernel(kernel_info: LoadedKernel, extra_info: ExtraBootInfo) -> ! {
let LoadedKernel {
load_info,
entry_point,
} = kernel_info;

assert!(extra_info.image.is_none());

let dtb = unsafe {
Fdt::from_ptr(sptr::from_exposed_addr(get_dtb_addr() as usize))
.expect(".dtb file has invalid header")
Expand Down
2 changes: 1 addition & 1 deletion src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cfg_if::cfg_if! {
} else if #[cfg(target_arch = "riscv64")] {
mod riscv64;
pub use self::riscv64::*;
} else if #[cfg(all(target_arch = "x86_64"))] {
} else if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
}
Expand Down
5 changes: 4 additions & 1 deletion src/arch/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use log::info;
use sptr::Strict;

use crate::BootInfoExt;
use crate::os::ExtraBootInfo;

fn find_kernel_linux(chosen: &FdtNode<'_, '_>) -> Option<&'static [u8]> {
let initrd_start = chosen.property("linux,initrd-start")?.as_usize()?;
Expand Down Expand Up @@ -90,7 +91,7 @@ pub unsafe fn get_memory(memory_size: u64) -> u64 {
u64::try_from(start_address).unwrap()
}

pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
pub unsafe fn boot_kernel(kernel_info: LoadedKernel, extra_info: ExtraBootInfo) -> ! {
let LoadedKernel {
load_info,
entry_point,
Expand Down Expand Up @@ -118,6 +119,8 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
DeviceTreeAddress::new(fdt_addr.try_into().unwrap())
};

assert!(extra_info.image.is_none());

let boot_info = BootInfo {
hardware_info: HardwareInfo {
phys_addr_range,
Expand Down
10 changes: 8 additions & 2 deletions src/arch/x86_64/firecracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use super::physicalmem::PhysAlloc;
use super::{KERNEL_STACK_SIZE, SERIAL_IO_PORT, paging};
use crate::BootInfoExt;
use crate::fdt::Fdt;
use crate::os::ExtraBootInfo;

unsafe extern "C" {
static mut loader_end: u8;
Expand Down Expand Up @@ -118,7 +119,7 @@ pub fn find_kernel() -> &'static [u8] {
unsafe { slice::from_raw_parts(sptr::from_exposed_addr(elf_start), elf_len) }
}

pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
pub unsafe fn boot_kernel(kernel_info: LoadedKernel, extra_info: ExtraBootInfo) -> ! {
let LoadedKernel {
load_info,
entry_point,
Expand Down Expand Up @@ -172,7 +173,12 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
write_bytes(stack, 0, KERNEL_STACK_SIZE.try_into().unwrap());
}

let mut fdt = Fdt::new("firecracker").unwrap();
let maybe_image = match extra_info.image {
None => &[],
Some(tar_image) => tar_image,
};

let mut fdt = Fdt::new("firecracker", maybe_image).unwrap();

// Load the boot_param memory-map information
let linux_e820_entries =
Expand Down
Loading
Loading