Split acpica-rs into a separate library
Some checks failed
Build / build (push) Failing after 2m53s

This commit is contained in:
Mathieu Strypsteen 2024-10-31 17:40:23 +01:00
parent ebef5eb97b
commit 4ca93ada92
12 changed files with 31 additions and 24 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
*.a
*.o
kernel/src/sys/acpica-bindings.rs
lib/acpica-rs/src/acpica-bindings.rs
img
target

9
Cargo.lock generated
View file

@ -2,6 +2,13 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "acpica-rs"
version = "0.0.1"
dependencies = [
"bindgen",
]
[[package]]
name = "aho-corasick"
version = "1.1.3"
@ -145,7 +152,7 @@ dependencies = [
name = "kernel"
version = "0.0.1"
dependencies = [
"bindgen",
"acpica-rs",
"bitfield",
"bitvec",
"buddy_system_allocator",

View file

@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["lib/kernel-common", "loader", "kernel"]
members = ["lib/acpica-rs", "lib/kernel-common", "loader", "kernel"]
[profile.release]
lto = true

View file

@ -2,15 +2,13 @@
name = "kernel"
version = "0.0.1"
edition = "2021"
license = "Unlicense AND BSD-3-Clause-acpica"
license = "Unlicense"
[dependencies]
acpica-rs = {path = "../lib/acpica-rs"}
bitfield = "0.17.0"
bitvec = {version = "1.0.1", default-features = false, features = ["alloc", "atomic"]}
buddy_system_allocator = "0.11.0"
kernel-common = {path = "../lib/kernel-common"}
log = "0.4.22"
spin = "0.9.8"
[build-dependencies]
bindgen = "0.70.1"

View file

@ -12,6 +12,7 @@ use core::{
sync::atomic::{AtomicU64, Ordering},
};
use acpica_rs::AcpiInitializeTables;
use buddy_system_allocator::LockedHeap;
use cpu::{gdt::setup_gdt, idt::setup_idt, paging::setup_paging};
use kernel_common::{
@ -21,7 +22,7 @@ use kernel_common::{
paging::{KERNEL_HEAP_INITIAL_SIZE, KERNEL_HEAP_START},
};
use log::{error, info};
use sys::{acpica::AcpiInitializeTables, acpica_osl::AE_OK, hpet::setup_hpet, lapic::setup_lapic_timer, madt::parse_madt, pic::disable_pic};
use sys::{acpica_osl::AE_OK, hpet::setup_hpet, lapic::setup_lapic_timer, madt::parse_madt, pic::disable_pic};
mod cpu;
mod misc;

View file

@ -5,6 +5,7 @@ use core::{
sync::atomic::Ordering,
};
use acpica_rs::{ACPI_PHYSICAL_ADDRESS, ACPI_PREDEFINED_NAMES, ACPI_SIZE, ACPI_STATUS, ACPI_STRING, ACPI_TABLE_HEADER, UINT32, UINT64};
use kernel_common::log::log_raw;
use crate::{
@ -13,8 +14,6 @@ use crate::{
RSDP_ADDRESS,
};
use super::acpica::{ACPI_PHYSICAL_ADDRESS, ACPI_PREDEFINED_NAMES, ACPI_SIZE, ACPI_STATUS, ACPI_STRING, ACPI_TABLE_HEADER, UINT32, UINT64};
pub const AE_OK: ACPI_STATUS = 0;
#[no_mangle]

View file

@ -3,18 +3,13 @@ use core::{
sync::atomic::{AtomicBool, AtomicPtr, AtomicU64, Ordering},
};
use acpica_rs::{acpi_table_header, acpi_table_hpet, AcpiGetTable};
use kernel_common::instructions::pause;
use log::warn;
use crate::{
cpu::paging::map_physical,
sys::{
acpica::{acpi_table_header, AcpiGetTable},
acpica_osl::AE_OK,
},
};
use crate::{cpu::paging::map_physical, sys::acpica_osl::AE_OK};
use super::{acpica::acpi_table_hpet, ioapic::register_isa_irq_handler};
use super::ioapic::register_isa_irq_handler;
const REGISTER_CAPABILITIES: usize = 0;
const REGISTER_CONFIG: usize = 2;

View file

@ -1,11 +1,11 @@
use core::mem::size_of;
use acpica_rs::{acpi_madt_interrupt_override, acpi_madt_io_apic, acpi_madt_local_apic_override, acpi_subtable_header, acpi_table_header, acpi_table_madt, AcpiGetTable};
use kernel_common::instructions::sti;
use crate::sys::acpica_osl::AE_OK;
use super::{
acpica::{acpi_madt_interrupt_override, acpi_madt_io_apic, acpi_madt_local_apic_override, acpi_subtable_header, acpi_table_header, acpi_table_madt, AcpiGetTable},
ioapic::{set_irq_override, setup_ioapic},
lapic::setup_lapic,
};

View file

@ -1,4 +1,3 @@
pub mod acpica;
pub mod acpica_osl;
pub mod hpet;
mod ioapic;

8
lib/acpica-rs/Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "acpica-rs"
version = "0.0.1"
edition = "2021"
license = "BSD-3-Clause-acpica"
[build-dependencies]
bindgen = "0.70.1"

View file

@ -5,10 +5,10 @@ fn main() {
println!("cargo::rustc-link-lib=acpica");
let bindings = Builder::default()
.use_core()
.clang_arg("-I../lib/acpica-build")
.header("../lib/acpica-build/acpica.h")
.clang_arg("-I../acpica-build")
.header("../acpica-build/acpica.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate()
.unwrap();
bindings.write_to_file("src/sys/acpica-bindings.rs").unwrap();
bindings.write_to_file("src/acpica-bindings.rs").unwrap();
}

View file

@ -1,3 +1,3 @@
#![no_std]
#![allow(warnings)]
#![allow(unsafe_op_in_unsafe_fn)]
include!("acpica-bindings.rs");