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 *.a
*.o *.o
kernel/src/sys/acpica-bindings.rs lib/acpica-rs/src/acpica-bindings.rs
img img
target target

9
Cargo.lock generated
View file

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

View file

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

View file

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

View file

@ -12,6 +12,7 @@ use core::{
sync::atomic::{AtomicU64, Ordering}, sync::atomic::{AtomicU64, Ordering},
}; };
use acpica_rs::AcpiInitializeTables;
use buddy_system_allocator::LockedHeap; use buddy_system_allocator::LockedHeap;
use cpu::{gdt::setup_gdt, idt::setup_idt, paging::setup_paging}; use cpu::{gdt::setup_gdt, idt::setup_idt, paging::setup_paging};
use kernel_common::{ use kernel_common::{
@ -21,7 +22,7 @@ use kernel_common::{
paging::{KERNEL_HEAP_INITIAL_SIZE, KERNEL_HEAP_START}, paging::{KERNEL_HEAP_INITIAL_SIZE, KERNEL_HEAP_START},
}; };
use log::{error, info}; 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 cpu;
mod misc; mod misc;

View file

@ -5,6 +5,7 @@ use core::{
sync::atomic::Ordering, 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 kernel_common::log::log_raw;
use crate::{ use crate::{
@ -13,8 +14,6 @@ use crate::{
RSDP_ADDRESS, 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; pub const AE_OK: ACPI_STATUS = 0;
#[no_mangle] #[no_mangle]

View file

@ -3,18 +3,13 @@ use core::{
sync::atomic::{AtomicBool, AtomicPtr, AtomicU64, Ordering}, sync::atomic::{AtomicBool, AtomicPtr, AtomicU64, Ordering},
}; };
use acpica_rs::{acpi_table_header, acpi_table_hpet, AcpiGetTable};
use kernel_common::instructions::pause; use kernel_common::instructions::pause;
use log::warn; use log::warn;
use crate::{ use crate::{cpu::paging::map_physical, sys::acpica_osl::AE_OK};
cpu::paging::map_physical,
sys::{
acpica::{acpi_table_header, AcpiGetTable},
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_CAPABILITIES: usize = 0;
const REGISTER_CONFIG: usize = 2; const REGISTER_CONFIG: usize = 2;

View file

@ -1,11 +1,11 @@
use core::mem::size_of; 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 kernel_common::instructions::sti;
use crate::sys::acpica_osl::AE_OK; use crate::sys::acpica_osl::AE_OK;
use super::{ 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}, ioapic::{set_irq_override, setup_ioapic},
lapic::setup_lapic, lapic::setup_lapic,
}; };

View file

@ -1,4 +1,3 @@
pub mod acpica;
pub mod acpica_osl; pub mod acpica_osl;
pub mod hpet; pub mod hpet;
mod ioapic; 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"); println!("cargo::rustc-link-lib=acpica");
let bindings = Builder::default() let bindings = Builder::default()
.use_core() .use_core()
.clang_arg("-I../lib/acpica-build") .clang_arg("-I../acpica-build")
.header("../lib/acpica-build/acpica.h") .header("../acpica-build/acpica.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate() .generate()
.unwrap(); .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(warnings)]
#![allow(unsafe_op_in_unsafe_fn)]
include!("acpica-bindings.rs"); include!("acpica-bindings.rs");