Some ACPI work

This commit is contained in:
River 2025-02-24 09:53:36 -05:00
parent 7fe3ba7912
commit d780a72358
Signed by: shibedrill
GPG Key ID: 5FE0CB25945EFAA2
7 changed files with 64 additions and 30 deletions

18
Cargo.lock generated
View File

@ -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"

View File

@ -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"] }

1
src/arch/x86_64/acpi.rs Normal file
View File

@ -0,0 +1 @@
// TODO: Implement per-arch memory handlers for ACPI memory map regions

View File

@ -1,2 +1,3 @@
pub mod acpi;
pub mod asm;
pub mod display;

View File

@ -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();

View File

@ -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();
}
}
}

View File

@ -33,6 +33,16 @@ pub struct Process {
semaphor_wait: Option<u32>,
}
#[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,