Feature API, firmware type
This commit is contained in:
parent
ed139f9d0f
commit
d279e193ab
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -67,6 +67,26 @@ version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
|
||||
|
||||
[[package]]
|
||||
name = "enumflags2"
|
||||
version = "0.7.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef"
|
||||
dependencies = [
|
||||
"enumflags2_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "enumflags2_derive"
|
||||
version = "0.7.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fdt"
|
||||
version = "0.2.0-alpha1"
|
||||
@ -83,7 +103,7 @@ name = "gila"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"acpi",
|
||||
"bitflags",
|
||||
"enumflags2",
|
||||
"fdt",
|
||||
"flagset",
|
||||
"intbits",
|
||||
|
@ -5,7 +5,7 @@ edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
acpi = { version = "5.2.0", optional = true }
|
||||
bitflags = "2.9.1"
|
||||
enumflags2 = "0.7.12"
|
||||
fdt = { git = "https://github.com/repnop/fdt", version = "0.2.0-alpha1", optional = true }
|
||||
flagset = "0.4.7"
|
||||
intbits = "0.2.0"
|
||||
|
@ -20,6 +20,7 @@ lazy_static! {
|
||||
// crate::interrupt::double_fault(&format!("{info:#?}"));
|
||||
//}
|
||||
|
||||
#[allow(dead_code)]
|
||||
extern "x86-interrupt" fn page_fault(info: InterruptStackFrame, errcode: PageFaultErrorCode) {
|
||||
if errcode.contains(PageFaultErrorCode::USER_MODE) {
|
||||
// Fault occurred in usermode. Non fatal.
|
||||
|
@ -24,4 +24,8 @@ pub static MP_REQUEST: MpRequest = limine::request::MpRequest::new();
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static FRAMEBUFFER_REQUEST: FramebufferRequest = limine::request::FramebufferRequest::new();
|
||||
pub static FRAMEBUFFER_REQUEST: FramebufferRequest = limine::request::FramebufferRequest::new();
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
pub static FIRMWARE_TYPE_REQUEST: FirmwareTypeRequest = limine::request::FirmwareTypeRequest::new();
|
||||
|
@ -1,15 +1,38 @@
|
||||
// Copyright (c) 2025 shibedrill
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use enumflags2::{BitFlags, bitflags};
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use crate::format;
|
||||
use crate::log::LogLevel;
|
||||
use crate::memory::alloc::string::String;
|
||||
|
||||
// TODO: Add API to query available features
|
||||
pub static ACPI_ENABLED: bool = if cfg!(feature = "acpi") { true } else { false };
|
||||
pub static DTB_ENABLED: bool = if cfg!(feature = "dtb") { true } else { false };
|
||||
pub static COMPRESSION_ENABLED: bool = if cfg!(feature = "compression") { true } else { false };
|
||||
pub static UEFI_ENABLED: bool = if cfg!(feature = "uefi") { true } else { false };
|
||||
#[bitflags]
|
||||
#[repr(u8)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Features {
|
||||
Acpi,
|
||||
Dtb,
|
||||
Compression,
|
||||
Uefi,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
#[derive(Debug)]
|
||||
pub static ref FEATURE_FLAGS: BitFlags<Features> = {
|
||||
let mut temp_flags = BitFlags::<Features>::empty();
|
||||
#[cfg(feature = "acpi")]
|
||||
temp_flags.insert(Features::Acpi);
|
||||
#[cfg(feature = "dtb")]
|
||||
temp_flags.insert(Features::Dtb);
|
||||
#[cfg(feature = "compression")]
|
||||
temp_flags.insert(Features::Compression);
|
||||
#[cfg(feature = "uefi")]
|
||||
temp_flags.insert(Features::Uefi);
|
||||
temp_flags
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub static INITRAMFS_DEFAULT_PATH: &str = if cfg!(feature = "compression") {
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
// TODO: Implement per-arch memory handlers for ACPI memory map regions
|
||||
|
||||
use limine::{request::RsdpRequest, response::RsdpResponse};
|
||||
use lazy_static::lazy_static;
|
||||
use limine::{request::RsdpRequest, response::RsdpResponse};
|
||||
|
||||
use crate::{format, log_info, log_warning, log::*};
|
||||
use crate::{format, log::*, log_info, log_warning};
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
@ -23,4 +23,4 @@ lazy_static! {
|
||||
None
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
|
||||
use fdt::*;
|
||||
use lazy_static::lazy_static;
|
||||
use limine::{request::DeviceTreeBlobRequest, response::DeviceTreeBlobResponse};
|
||||
use fdt::*;
|
||||
|
||||
use crate::{format, log_trace, log_info, log_warning, log::*};
|
||||
use crate::{format, log::*, log_info, log_trace, log_warning};
|
||||
|
||||
#[used]
|
||||
#[unsafe(link_section = ".requests")]
|
||||
@ -32,4 +31,4 @@ pub fn device_tree_parsed() -> Option<Fdt<'static>> {
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,13 +13,17 @@ use crate::{format, log_error};
|
||||
pub fn init_statics() {
|
||||
let dtb = {
|
||||
#[cfg(feature = "dtb")]
|
||||
{ devtree::DTB.is_some() }
|
||||
{
|
||||
devtree::DTB.is_some()
|
||||
}
|
||||
#[cfg(not(feature = "dtb"))]
|
||||
false
|
||||
};
|
||||
let rdsp = {
|
||||
#[cfg(feature = "acpi")]
|
||||
{ acpi::RSDP.is_some() }
|
||||
{
|
||||
acpi::RSDP.is_some()
|
||||
}
|
||||
#[cfg(not(feature = "acpi"))]
|
||||
false
|
||||
};
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2025 shibedrill
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn double_fault(info: &str) -> ! {
|
||||
panic!("Double fault: {}", info);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ use arch::x86_64::serial::Serialport;
|
||||
|
||||
use boot::{modules::*, params, *};
|
||||
use constants::*;
|
||||
use limine::firmware_type::FirmwareType;
|
||||
use log::*;
|
||||
use memory::alloc::{format, string::*, vec};
|
||||
use memory::{HHDM_RESPONSE, MEMMAP_REQUEST};
|
||||
@ -69,6 +70,21 @@ unsafe extern "C" fn main() -> ! {
|
||||
String::from_utf8_lossy(EXECUTABLE_FILE_RESPONSE.file().path().to_bytes())
|
||||
);
|
||||
log_info!("Boot: Booting gila version {}", kernel_version_string());
|
||||
log_info!("Boot: Enabled features: {}", FEATURE_FLAGS.to_string());
|
||||
|
||||
match boot::FIRMWARE_TYPE_REQUEST.get_response() {
|
||||
Some(resp) => log_info!(
|
||||
"Boot: Firmware type: {}",
|
||||
match resp.firmware_type() {
|
||||
FirmwareType::SBI => "SBI",
|
||||
FirmwareType::UEFI_32 => "UEFI (32-bit)",
|
||||
FirmwareType::UEFI_64 => "UEFI (64-bit)",
|
||||
FirmwareType::X86_BIOS => "x86 BIOS",
|
||||
_ => "Unknown",
|
||||
}
|
||||
),
|
||||
None => log_warning!("Boot: Firmware type: No response"),
|
||||
}
|
||||
|
||||
log_info!("Boot: Trans rights!");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user