diff --git a/Cargo.lock b/Cargo.lock index 53ca6a2..b2e4b4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,17 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "acpi" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e42f25ac5fa51f4188d14baf8f387a97dcd8639644b2f3df948bf5f6dd7d6fa" +dependencies = [ + "bit_field", + "bitflags 2.8.0", + "log", +] + [[package]] name = "autocfg" version = "1.4.0" @@ -63,6 +74,7 @@ checksum = "875488b8711a968268c7cf5d139578713097ca4635a76044e8fe8eedf831d07e" name = "gila" version = "0.2.2" dependencies = [ + "acpi", "flagset", "limine", "once_cell", @@ -90,6 +102,12 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "log" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" + [[package]] name = "num-traits" version = "0.2.19" diff --git a/Cargo.toml b/Cargo.toml index 5d4a831..dffd4d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.2.2" edition = "2024" [dependencies] +acpi = "5.1.0" flagset = "0.4.6" limine = "0.3.1" once_cell = { version = "1.20.3", default-features = false, features = ["alloc", "critical-section"] } diff --git a/src/arch/x86_64/acpi.rs b/src/arch/x86_64/acpi.rs new file mode 100644 index 0000000..89000b7 --- /dev/null +++ b/src/arch/x86_64/acpi.rs @@ -0,0 +1 @@ +// TODO: Implement per-arch memory handlers for ACPI memory map regions diff --git a/src/arch/x86_64/mod.rs b/src/arch/x86_64/mod.rs index 0bc4595..5103e0f 100644 --- a/src/arch/x86_64/mod.rs +++ b/src/arch/x86_64/mod.rs @@ -1,2 +1,3 @@ +pub mod acpi; pub mod asm; pub mod display; diff --git a/src/boot.rs b/src/boot.rs index f8c0e85..4d60a91 100644 --- a/src/boot.rs +++ b/src/boot.rs @@ -18,3 +18,6 @@ pub static SMP_REQUEST: SmpRequest = limine::request::SmpRequest::new(); #[used] #[unsafe(link_section = ".requests")] pub static FILE_REQUEST: KernelFileRequest = limine::request::KernelFileRequest::new(); +#[used] +#[unsafe(link_section = ".requests")] +pub static RSDP_REQUEST: RsdpRequest = limine::request::RsdpRequest::new(); diff --git a/src/main.rs b/src/main.rs index 5fa87b3..76e2b46 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,12 +12,14 @@ mod params; mod process; mod resources; -use crate::arch::current::*; +use crate::arch::current; use crate::boot::*; use crate::log::*; -use crate::memory::alloc::*; +use crate::memory::alloc::{self, format, string::String, vec}; use crate::params::*; +use acpi::{AcpiResult, AcpiTable}; + #[unsafe(no_mangle)] unsafe extern "C" fn main() -> ! { // Assert supported bootloader version @@ -47,54 +49,52 @@ unsafe extern "C" fn main() -> ! { if log_device_list.contains(&"serial") { // Append serial console to log subs } - log(LogLevel::Info, "Configured kernel logging devices.") - } - - { - let kernel_cmdline_string = - string::String::from_utf8_lossy(kernel_file_response.file().cmdline()); - log( - LogLevel::Info, - &format!("Kernel cmdline: {}", kernel_cmdline_string), - ); - drop(kernel_cmdline_string); - } - - { - let kernel_path = string::String::from_utf8_lossy(kernel_file_response.file().path()); - log( - LogLevel::Info, - &format!("Kernel file path: {}", kernel_path), - ); - drop(kernel_path); + log(LogLevel::Info, "Boot: Configured kernel logging devices.") } + log( + LogLevel::Info, + &format!( + "Boot: Kernel cmdline: {}", + String::from_utf8_lossy(kernel_file_response.file().cmdline()) + ), + ); + log( + LogLevel::Info, + &format!( + "Boot: Kernel file path: {}", + String::from_utf8_lossy(kernel_file_response.file().path()) + ), + ); } - - log(LogLevel::Info, "Log devices configured. Booting `gila`."); - log(LogLevel::Info, "Trans Rights!"); + log( + LogLevel::Info, + "Boot: Log devices configured. Booting `gila`.", + ); + log(LogLevel::Info, "Boot: Trans Rights!"); let _smp_response = SMP_REQUEST.get_response(); - match _smp_response { None => log( LogLevel::Error, - "SMP response not received. Multiprocessing is disabled.", + "SMP: bootloader response not received. Multiprocessing is disabled.", ), Some(resp) => { log( LogLevel::Info, - "SMP response received. Multiprocessing enabled.", + "SMP: bootloader response received. Multiprocessing enabled.", ); log( LogLevel::Info, - &format!("{} CPUs found.", resp.cpus().len()), + &format!("SMP: {} CPUs found.", resp.cpus().len()), ); } } + let _rsdp_response = RSDP_REQUEST.get_response(); + loop { unsafe { - asm::halt(); + arch::current::asm::halt(); } } } diff --git a/src/process.rs b/src/process.rs index 182203d..edd7ff6 100644 --- a/src/process.rs +++ b/src/process.rs @@ -33,6 +33,16 @@ pub struct Process { semaphor_wait: Option, } +#[allow(dead_code)] +pub unsafe fn context_switch() -> ! { + #[allow(unused_unsafe)] + unsafe { + loop { + crate::arch::current::asm::halt(); + } + } +} + #[allow(dead_code)] pub enum ProcessState { Running,