Skip to content

Commit 3e73ac4

Browse files
committed
Merge acpi and aml crates into one top-level crate
1 parent b266a6a commit 3e73ac4

25 files changed

+58
-51
lines changed

Cargo.toml

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
11
[workspace]
2-
members = ["acpi", "aml", "tools/aml_tester", "tools/acpi_dumper"]
2+
members = ["tools/aml_tester", "tools/acpi_dumper"]
33
resolver = "2"
4+
5+
[package]
6+
name = "acpi"
7+
version = "5.1.0"
8+
authors = ["Isaac Woods"]
9+
repository = "https://github.com/rust-osdev/acpi"
10+
description = "A pure-Rust library for interacting with ACPI"
11+
categories = ["hardware-support", "no-std"]
12+
readme = "../README.md"
13+
license = "MIT/Apache-2.0"
14+
edition = "2024"
15+
16+
[dependencies]
17+
bit_field = "0.10.2"
18+
bitflags = "2.5.0"
19+
log = "0.4.20"
20+
spinning_top = "0.3.0"
21+
pci_types = { version = "0.10.0", public = true, optional = true }
22+
byteorder = { version = "1.5.0", default-features = false }
23+
24+
[features]
25+
default = ["alloc", "aml"]
26+
alloc = []
27+
aml = ["alloc", "pci_types"]

acpi/Cargo.toml

-19
This file was deleted.

aml/Cargo.toml

-17
This file was deleted.
File renamed without changes.

aml/src/lib.rs renamed to src/aml/mod.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
#![no_std]
2-
#![feature(let_chains, inherent_str_constructors)]
3-
4-
extern crate alloc;
1+
/*
2+
* TODO:
3+
* - Field reads supporting custom handlers
4+
* - Run `_REG` on supported op region handlers
5+
* - Sort out situation with `gain_mut` omg - thinking we should have a weird mutex thingy and
6+
* gain a 'token' to give us access to objects. Objects themselves should probs be in like an
7+
* `UnsafeCell` or something.
8+
* - Count operations performed and time
9+
* - Do stores properly :(
10+
* - Load and LoadTable
11+
* - Entire Event subsystem and opcodes for them
12+
*
13+
* - Method recursion depth?
14+
* - Loop timeouts
15+
* - Fuzz the shit out of it I guess?
16+
*/
517

618
pub mod namespace;
719
pub mod object;

aml/src/namespace.rs renamed to src/aml/namespace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{AmlError, object::Object};
1+
use crate::aml::{AmlError, object::Object};
22
use alloc::{
33
collections::btree_map::BTreeMap,
44
string::{String, ToString},

aml/src/object.rs renamed to src/aml/object.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{AmlError, Handle, Operation, op_region::OpRegion};
1+
use crate::aml::{AmlError, Handle, Operation, op_region::OpRegion};
22
use alloc::{borrow::Cow, string::String, sync::Arc, vec::Vec};
33
use bit_field::BitField;
44

aml/src/op_region.rs renamed to src/aml/op_region.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{AmlError, namespace::AmlName};
1+
use crate::aml::{AmlError, namespace::AmlName};
22

33
#[derive(Clone, Debug)]
44
pub struct OpRegion {

aml/src/pci_routing.rs renamed to src/aml/pci_routing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{
1+
use crate::aml::{
22
AmlError,
33
Handler,
44
Interpreter,
@@ -11,7 +11,7 @@ use alloc::{vec, vec::Vec};
1111
use bit_field::BitField;
1212
use core::str::FromStr;
1313

14-
pub use crate::resource::IrqDescriptor;
14+
pub use crate::aml::resource::IrqDescriptor;
1515

1616
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
1717
pub enum Pin {

aml/src/resource.rs renamed to src/aml/resource.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{AmlError, Operation, object::Object};
1+
use crate::aml::{AmlError, Operation, object::Object};
22
use alloc::{sync::Arc, vec::Vec};
33
use bit_field::BitField;
44
use byteorder::{ByteOrder, LittleEndian};
File renamed without changes.

acpi/src/lib.rs renamed to src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
//! tables, and interact with the tables using their raw structures. All other functionality is
1010
//! behind an `alloc` feature (enabled by default) and requires an allocator.
1111
//!
12+
//! With an allocator, this crate also provides higher-level interfaces to the static tables, as
13+
//! well as a dynamic interpreter for AML - the bytecode format encoded in the DSDT and SSDT
14+
//! tables.
15+
//!
1216
//! ### Usage
1317
//! To use the library, you will need to provide an implementation of the [`AcpiHandler`] trait,
1418
//! which allows the library to make requests such as mapping a particular region of physical
@@ -28,7 +32,7 @@
2832
//! interfaces, such as [`PlatformInfo`], [`PciConfigRegions`], or [`HpetInfo`].
2933
3034
#![no_std]
31-
#![feature(allocator_api)]
35+
#![feature(allocator_api, let_chains, inherent_str_constructors)]
3236

3337
#[cfg_attr(test, macro_use)]
3438
#[cfg(test)]
@@ -38,7 +42,10 @@ extern crate std;
3842
extern crate alloc;
3943

4044
pub mod address;
45+
#[cfg(feature = "aml")]
46+
pub mod aml;
4147
pub mod handler;
48+
#[cfg(feature = "alloc")]
4249
pub mod platform;
4350
pub mod rsdp;
4451
pub mod sdt;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tools/aml_tester/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Isaac Woods"]
55
edition = "2018"
66

77
[dependencies]
8-
aml = { path = "../../aml" }
8+
acpi = { path = "../.." }
99
clap = "4"
1010
termion = "1"
1111
log = "0.4"

tools/aml_tester/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* - For failing tests, print out a nice summary of the errors for each file
1010
*/
1111

12-
use aml::{namespace::AmlName, AmlError, Handle, Interpreter};
12+
use acpi::aml::{namespace::AmlName, AmlError, Handle, Interpreter};
1313
use clap::{Arg, ArgAction, ArgGroup};
1414
use pci_types::PciAddress;
1515
use std::{
@@ -324,7 +324,7 @@ impl log::Log for Logger {
324324

325325
struct Handler;
326326

327-
impl aml::Handler for Handler {
327+
impl acpi::aml::Handler for Handler {
328328
fn read_u8(&self, address: usize) -> u8 {
329329
println!("read_u8 {address:#x}");
330330
0

0 commit comments

Comments
 (0)