From e3ef4823b3a05227e8906edb7b48db6e91645a95 Mon Sep 17 00:00:00 2001 From: Mathieu Strypsteen Date: Mon, 30 Dec 2024 21:56:10 +0100 Subject: [PATCH] Implement more ACPICA functions --- Cargo.toml | 1 + kernel/src/sys/acpica_osl.rs | 25 +++++++++++++++++-------- kernel/src/sys/sync.rs | 1 - 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ef17229..1a83185 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,4 +6,5 @@ members = ["lib/acpica-rs", "lib/kernel-common", "loader", "kernel", "init"] lto = true [profile.dev] +opt-level = 3 panic = "abort" diff --git a/kernel/src/sys/acpica_osl.rs b/kernel/src/sys/acpica_osl.rs index 229f436..65f00dc 100644 --- a/kernel/src/sys/acpica_osl.rs +++ b/kernel/src/sys/acpica_osl.rs @@ -8,6 +8,7 @@ use core::{ use acpica_rs::{ACPI_IO_ADDRESS, ACPI_OSD_HANDLER, ACPI_PHYSICAL_ADDRESS, ACPI_PREDEFINED_NAMES, ACPI_SIZE, ACPI_STATUS, ACPI_STRING, ACPI_TABLE_HEADER, UINT16, UINT32, UINT64, UINT8}; use alloc::{boxed::Box, sync::Arc}; use kernel_common::{ + instructions::pause, ioports::{inb, inl, inw, outb, outl, outw}, log::log_raw, }; @@ -60,12 +61,17 @@ extern "C" fn AcpiOsCreateSemaphore(max: UINT32, initial: UINT32, out: *mut *mut AE_OK } #[no_mangle] -extern "C" fn AcpiOsDeleteLock() { - unimplemented!(); +extern "C" fn AcpiOsDeleteLock(handle: *mut c_void) { + unsafe { + drop(Box::from_raw(handle)); + } } #[no_mangle] -extern "C" fn AcpiOsDeleteSemaphore() { - unimplemented!(); +extern "C" fn AcpiOsDeleteSemaphore(handle: *mut c_void) -> ACPI_STATUS { + unsafe { + Arc::from_raw(handle as *const RawSemaphore); + } + AE_OK } #[no_mangle] extern "C" fn AcpiOsEnterSleep(_sleep_state: UINT8, _reg_a_val: UINT32, _reg_b_val: UINT32) -> ACPI_STATUS { @@ -166,16 +172,19 @@ extern "C" fn AcpiOsReleaseLock(handle: *mut c_void, _cpu_flags: ACPI_SIZE) { spinlock.raw_unlock(); } #[no_mangle] -extern "C" fn AcpiOsStall() { - unimplemented!(); +extern "C" fn AcpiOsStall(us: UINT32) { + let end_time = get_current_time() + us as usize; + while get_current_time() < end_time { + pause(); + } } #[no_mangle] extern "C" fn AcpiOsRemoveInterruptHandler() { unimplemented!(); } #[no_mangle] -extern "C" fn AcpiOsSignal() { - unimplemented!(); +extern "C" fn AcpiOsSignal(_func: UINT32, _info: *mut c_void) -> ACPI_STATUS { + panic!("Received ACPI signal"); } #[no_mangle] extern "C" fn AcpiOsSignalSemaphore(handle: *mut c_void, units: UINT32) -> ACPI_STATUS { diff --git a/kernel/src/sys/sync.rs b/kernel/src/sys/sync.rs index e5928f1..4ae4ed0 100644 --- a/kernel/src/sys/sync.rs +++ b/kernel/src/sys/sync.rs @@ -69,7 +69,6 @@ impl RawSpinlock { let early_lock = self.early_lock.swap(false, Ordering::SeqCst); if interrupts_setup && !early_lock { lapic_id = self.lapic_id.load(Ordering::SeqCst); - debug_assert_eq!(lapic_id, get_current_lapic_id()); } self.locked.store(false, Ordering::SeqCst); if interrupts_setup && !early_lock {