Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove arch-specific get_fdt #1430

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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
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::{PlatformInfo, RawBootInfo};
use hermit_sync::InterruptSpinMutex;
use x86::controlregs::{cr0, cr0_write, cr4, Cr0};
Expand Down Expand Up @@ -68,13 +67,6 @@ pub fn get_mbinfo() -> Option<NonZeroU64> {
}
}

pub fn get_fdt() -> Option<Fdt<'static>> {
env::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 @@ -196,8 +196,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