52 lines
1.4 KiB
Rust
52 lines
1.4 KiB
Rust
// Copyright (c) 2025 shibedrill
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
use fdt::*;
|
|
use lazy_static::lazy_static;
|
|
use limine::response::{DeviceTreeBlobResponse, RsdpResponse};
|
|
|
|
use crate::boot::{DTB_REQUEST, RSDP_REQUEST};
|
|
use crate::log::{LOGGER, LogLevel};
|
|
use crate::{format, log_info, log_trace, log_warning};
|
|
|
|
lazy_static! {
|
|
pub static ref DTB: Option<&'static DeviceTreeBlobResponse> = match DTB_REQUEST.get_response() {
|
|
Some(resp) => {
|
|
log_info!("Device: Got DTB pointer");
|
|
Some(resp)
|
|
}
|
|
None => {
|
|
log_warning!("Device: Did not get DTB pointer");
|
|
None
|
|
}
|
|
};
|
|
pub static ref RSDP: Option<&'static RsdpResponse> = match RSDP_REQUEST.get_response() {
|
|
Some(resp) => {
|
|
log_info!("Device: Got RSDP pointer");
|
|
Some(resp)
|
|
}
|
|
None => {
|
|
log_warning!("Device: Did not get RSDP pointer, ACPI unavailable");
|
|
None
|
|
}
|
|
};
|
|
}
|
|
|
|
// Just to check
|
|
pub fn init_statics() {
|
|
let _ = DTB.is_some();
|
|
let _ = RSDP.is_some();
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn device_tree_parsed() -> Option<Fdt<'static>> {
|
|
if let Some(ok_dtb) = *DTB
|
|
&& let Ok(ok_parsed_dt) = unsafe { fdt::Fdt::from_ptr(ok_dtb.dtb_ptr() as *const u8) }
|
|
{
|
|
log_trace!("Device: Parsed device tree");
|
|
Some(ok_parsed_dt)
|
|
} else {
|
|
None
|
|
}
|
|
}
|