Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:
- uses: r7kamura/[email protected]
- name: Run api tests
run: cargo test -p bootloader_api
- name: Run bootloader common tests
if: runner.os == 'Linux'
run: cargo test -p bootloader-x86_64-common
- name: Run integration tests
run: cargo test -- --test-threads 1

Expand Down
20 changes: 20 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ members = [
"tests/test_kernels/lto",
"tests/test_kernels/ramdisk",
"tests/test_kernels/min_stack",
"tests/test_kernels/lower_memory_free",
"tests/test_kernels/write_usable_memory",
]
exclude = ["examples/basic", "examples/test_framework"]

Expand Down Expand Up @@ -67,6 +69,8 @@ test_kernel_pie = { path = "tests/test_kernels/pie", artifact = "bin", target =
test_kernel_ramdisk = { path = "tests/test_kernels/ramdisk", artifact = "bin", target = "x86_64-unknown-none" }
test_kernel_config_file = { path = "tests/test_kernels/config_file", artifact = "bin", target = "x86_64-unknown-none" }
test_kernel_min_stack = { path = "tests/test_kernels/min_stack", artifact = "bin", target = "x86_64-unknown-none" }
test_kernel_lower_memory_free = { path = "tests/test_kernels/lower_memory_free", artifact = "bin", target = "x86_64-unknown-none" }
test_kernel_write_usable_memory = { path = "tests/test_kernels/write_usable_memory", artifact = "bin", target = "x86_64-unknown-none" }

[profile.dev]
panic = "abort"
Expand Down
1 change: 1 addition & 0 deletions bios/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod racy_cell;
#[cfg_attr(feature = "debug", derive(Debug))]
#[repr(C)]
pub struct BiosInfo {
pub stage_3: Region,
pub stage_4: Region,
pub kernel: Region,
pub ramdisk: Region,
Expand Down
4 changes: 4 additions & 0 deletions bios/stage-2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ fn start(disk_number: u16, partition_table_start: *const u8) -> ! {
vesa_mode.enable().unwrap();

let mut info = BiosInfo {
stage_3: Region {
start: STAGE_3_DST as u64,
len: stage_3_len,
},
stage_4: Region {
start: stage_4_dst as u64,
len: stage_4_len,
Expand Down
14 changes: 12 additions & 2 deletions bios/stage-4/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use crate::memory_descriptor::MemoryRegion;
use bootloader_api::info::{FrameBufferInfo, PixelFormat};
use bootloader_boot_config::{BootConfig, LevelFilter};
use bootloader_x86_64_bios_common::{BiosFramebufferInfo, BiosInfo, E820MemoryRegion};
use bootloader_x86_64_bios_common::{BiosFramebufferInfo, BiosInfo, E820MemoryRegion, Region};
use bootloader_x86_64_common::legacy_memory_region::UsedMemorySlice;
use bootloader_x86_64_common::RawFrameBufferInfo;
use bootloader_x86_64_common::{
legacy_memory_region::LegacyFrameAllocator, load_and_switch_to_kernel, Kernel, PageTables,
Expand Down Expand Up @@ -55,9 +56,10 @@ pub extern "C" fn _start(info: &mut BiosInfo) -> ! {
};
let kernel_size = info.kernel.len;
let next_free_frame = PhysFrame::containing_address(PhysAddr::new(info.last_used_addr)) + 1;
let mut frame_allocator = LegacyFrameAllocator::new_starting_at(
let mut frame_allocator = LegacyFrameAllocator::new_with_used_slices(
next_free_frame,
memory_map.iter().copied().map(MemoryRegion),
used_memory_slices(info),
);

// We identity-mapped all memory, so the offset between physical and virtual addresses is 0
Expand Down Expand Up @@ -216,6 +218,14 @@ fn init_logger(
framebuffer_info
}

fn used_memory_slices(info: &BiosInfo) -> impl Iterator<Item = UsedMemorySlice> + Clone {
// skip kernel and ramdisk because they are handled individually by the
// uefi/bios common code
[info.stage_3, info.stage_4, info.config_file]
.into_iter()
.map(|region| UsedMemorySlice::new_from_len(region.start, region.len))
}

/// Creates page table abstraction types for both the bootloader and kernel page tables.
fn create_page_tables(frame_allocator: &mut impl FrameAllocator<Size4KiB>) -> PageTables {
// We identity-mapped all memory, so the offset between physical and virtual addresses is 0
Expand Down
Loading