Skip to content

Commit

Permalink
refactor: remove arch-specific get_fdt
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Oct 15, 2024
1 parent 391ec3d commit 11fe529
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
8 changes: 0 additions & 8 deletions src/arch/x86_64/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use core::num::NonZeroU64;
use core::ptr;
use core::sync::atomic::{AtomicPtr, AtomicU32, Ordering};

use fdt::Fdt;
use hermit_entry::boot_info::{BootInfo, PlatformInfo, RawBootInfo};
use hermit_sync::InterruptSpinMutex;
use x86::controlregs::{cr0, cr0_write, cr4, Cr0};
Expand Down Expand Up @@ -82,13 +81,6 @@ pub fn get_mbinfo() -> Option<NonZeroU64> {
}
}

pub fn get_fdt() -> Option<Fdt<'static>> {
boot_info().hardware_info.device_tree.map(|fdt| {
let ptr = ptr::with_exposed_provenance(fdt.get().try_into().unwrap());
unsafe { Fdt::from_ptr(ptr).unwrap() }
})
}

#[cfg(feature = "smp")]
pub fn get_possible_cpus() -> u32 {
use core::cmp;
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/mm/physicalmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use free_list::{AllocError, FreeList, PageLayout, PageRange};
use hermit_sync::InterruptTicketMutex;
use multiboot::information::{MemoryType, Multiboot};

use crate::arch::x86_64::kernel::{get_fdt, get_limit, get_mbinfo};
use crate::arch::x86_64::kernel::{get_limit, get_mbinfo};
use crate::arch::x86_64::mm::paging::{BasePageSize, PageSize};
use crate::arch::x86_64::mm::{MultibootMemory, PhysAddr, VirtAddr};
use crate::{env, mm};
Expand All @@ -18,7 +18,7 @@ const KVM_32BIT_GAP_SIZE: usize = 768 << 20;
const KVM_32BIT_GAP_START: usize = KVM_32BIT_MAX_MEM_SIZE - KVM_32BIT_GAP_SIZE;

fn detect_from_fdt() -> Result<(), ()> {
let fdt = get_fdt().ok_or(())?;
let fdt = env::fdt().ok_or(())?;

let mems = fdt.find_all_nodes("/memory");
let all_regions = mems.map(|m| m.reg().unwrap().next().unwrap());
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ fn boot_processor_main() -> ! {
info!("Welcome to Hermit {}", env!("CARGO_PKG_VERSION"));
info!("Kernel starts at {:p}", env::get_base_address());

#[cfg(target_arch = "x86_64")]
if let Some(fdt) = kernel::get_fdt() {
if let Some(fdt) = env::fdt() {
info!("FDT:\n{fdt:#?}");
}

Expand Down

0 comments on commit 11fe529

Please sign in to comment.