Implement more ACPICA functions
All checks were successful
Build / build (push) Successful in 2m41s

This commit is contained in:
Mathieu Strypsteen 2024-12-30 21:56:10 +01:00
parent 52c31ccc61
commit e3ef4823b3
3 changed files with 18 additions and 9 deletions

View file

@ -6,4 +6,5 @@ members = ["lib/acpica-rs", "lib/kernel-common", "loader", "kernel", "init"]
lto = true lto = true
[profile.dev] [profile.dev]
opt-level = 3
panic = "abort" panic = "abort"

View file

@ -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 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 alloc::{boxed::Box, sync::Arc};
use kernel_common::{ use kernel_common::{
instructions::pause,
ioports::{inb, inl, inw, outb, outl, outw}, ioports::{inb, inl, inw, outb, outl, outw},
log::log_raw, log::log_raw,
}; };
@ -60,12 +61,17 @@ extern "C" fn AcpiOsCreateSemaphore(max: UINT32, initial: UINT32, out: *mut *mut
AE_OK AE_OK
} }
#[no_mangle] #[no_mangle]
extern "C" fn AcpiOsDeleteLock() { extern "C" fn AcpiOsDeleteLock(handle: *mut c_void) {
unimplemented!(); unsafe {
drop(Box::from_raw(handle));
}
} }
#[no_mangle] #[no_mangle]
extern "C" fn AcpiOsDeleteSemaphore() { extern "C" fn AcpiOsDeleteSemaphore(handle: *mut c_void) -> ACPI_STATUS {
unimplemented!(); unsafe {
Arc::from_raw(handle as *const RawSemaphore);
}
AE_OK
} }
#[no_mangle] #[no_mangle]
extern "C" fn AcpiOsEnterSleep(_sleep_state: UINT8, _reg_a_val: UINT32, _reg_b_val: UINT32) -> ACPI_STATUS { 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(); spinlock.raw_unlock();
} }
#[no_mangle] #[no_mangle]
extern "C" fn AcpiOsStall() { extern "C" fn AcpiOsStall(us: UINT32) {
unimplemented!(); let end_time = get_current_time() + us as usize;
while get_current_time() < end_time {
pause();
}
} }
#[no_mangle] #[no_mangle]
extern "C" fn AcpiOsRemoveInterruptHandler() { extern "C" fn AcpiOsRemoveInterruptHandler() {
unimplemented!(); unimplemented!();
} }
#[no_mangle] #[no_mangle]
extern "C" fn AcpiOsSignal() { extern "C" fn AcpiOsSignal(_func: UINT32, _info: *mut c_void) -> ACPI_STATUS {
unimplemented!(); panic!("Received ACPI signal");
} }
#[no_mangle] #[no_mangle]
extern "C" fn AcpiOsSignalSemaphore(handle: *mut c_void, units: UINT32) -> ACPI_STATUS { extern "C" fn AcpiOsSignalSemaphore(handle: *mut c_void, units: UINT32) -> ACPI_STATUS {

View file

@ -69,7 +69,6 @@ impl RawSpinlock {
let early_lock = self.early_lock.swap(false, Ordering::SeqCst); let early_lock = self.early_lock.swap(false, Ordering::SeqCst);
if interrupts_setup && !early_lock { if interrupts_setup && !early_lock {
lapic_id = self.lapic_id.load(Ordering::SeqCst); lapic_id = self.lapic_id.load(Ordering::SeqCst);
debug_assert_eq!(lapic_id, get_current_lapic_id());
} }
self.locked.store(false, Ordering::SeqCst); self.locked.store(false, Ordering::SeqCst);
if interrupts_setup && !early_lock { if interrupts_setup && !early_lock {