Skip to content

Commit

Permalink
Bootloader: clean up warnings and prints
Browse files Browse the repository at this point in the history
  • Loading branch information
corigan01 committed Jan 6, 2025
1 parent b9438af commit 8d32680
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 3 additions & 6 deletions bootloader/stage-64bit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ use elf::{
Elf,
tables::{ArchKind, SegmentKind},
};
use lldebug::{debug_ready, hexdump::HexPrint, log, logln, make_debug};
use lldebug::{debug_ready, log, logln, make_debug};
use mem::phys::{PhysMemoryEntry, PhysMemoryKind, PhysMemoryMap};
use serial::{Serial, baud::SerialBaud};
use util::{
align_to,
bytes::HumanBytes,
consts::{MIB, PAGE_2M, PAGE_4K},
consts::{MIB, PAGE_2M},
};

mod paging;
Expand Down Expand Up @@ -74,7 +74,7 @@ fn main(stage_to_stage: &Stage32toStage64) {

logln!("Kernel Size : {}", HumanBytes::from(kernel_exe_len));
let page_info = build_memory_map(stage_to_stage, kernel_exe_len);
let mut virt_info = paging::build_page_tables(page_info);
let virt_info = paging::build_page_tables(page_info);

log!("Loading new page tables...");
unsafe { paging::load_page_tables() };
Expand Down Expand Up @@ -105,9 +105,6 @@ fn main(stage_to_stage: &Stage32toStage64) {
.unwrap();
logln!(") -- OK");

let kernel_exe_slice = virt_info.exe_slice();
logln!("{}", (&kernel_exe_slice[..1024]).hexdump());

unsafe {
let mm = &mut *MEMORY_MAP.get();
let s2k = &mut *KERNEL_INFO.get();
Expand Down
10 changes: 5 additions & 5 deletions bootloader/stage-64bit/src/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ pub struct KernelVirtInfo {
pub exe_start_virt: u64,
pub exe_end_virt: u64,
pub stack_start_virt: u64,
pub stack_end_virt: u64,
pub _stack_end_virt: u64,
}

impl KernelVirtInfo {
pub fn exe_slice(&mut self) -> &'static mut [u8] {
pub fn _exe_slice(&mut self) -> &'static mut [u8] {
unsafe {
core::slice::from_raw_parts_mut(
self.exe_start_virt as *mut u8,
Expand All @@ -74,11 +74,11 @@ impl KernelVirtInfo {
}
}

pub fn stack_slice(&mut self) -> &'static mut [u8] {
pub fn _stack_slice(&mut self) -> &'static mut [u8] {
unsafe {
core::slice::from_raw_parts_mut(
self.stack_start_virt as *mut u8,
(self.stack_end_virt - self.stack_start_virt) as usize,
(self._stack_end_virt - self.stack_start_virt) as usize,
)
}
}
Expand Down Expand Up @@ -176,7 +176,7 @@ pub fn build_page_tables(c: PageTableConfig) -> KernelVirtInfo {
exe_start_virt: c.kernel_virt,
exe_end_virt: c.kernel_virt + (exe_pages * PAGE_2M) as u64,
stack_start_virt: c.kernel_virt + ((exe_pages + 1) * PAGE_2M) as u64,
stack_end_virt: c.kernel_virt + ((exe_pages + stack_pages + 1) * PAGE_2M) as u64,
_stack_end_virt: c.kernel_virt + ((exe_pages + stack_pages + 1) * PAGE_2M) as u64,
}
}

Expand Down

0 comments on commit 8d32680

Please sign in to comment.