Skip to content

Rewrite acpi crate and entire AML interpreter #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 101 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
50ea695
`acpi`: remove redundant import
IsaacWoods Jun 26, 2024
e2811fa
`aml`: fix fuzz target
IsaacWoods Jun 26, 2024
598ad9c
`aml`: don't panic if AML tries to create a giant `Buffer`
IsaacWoods Jun 26, 2024
b337022
Remove unmaintained changelog
IsaacWoods Sep 7, 2024
691252b
Remove old `rsdp` crate
IsaacWoods Sep 7, 2024
1849d79
Move `aml_tester` and `acpi_dumper` into tools subdirectory
IsaacWoods Sep 7, 2024
44ab415
Improve layout of AML test runner output
IsaacWoods Sep 7, 2024
0553142
Reverse `reset` option to `combined` in AML tester
IsaacWoods Sep 7, 2024
6a6daf8
Fix crates compiled on CI
IsaacWoods Sep 7, 2024
041f5ea
Add doc comment for `Namespace::get_level_for_path`
IsaacWoods Nov 8, 2024
3577b5a
`acpi`: remove lifetime from `ManagedSlice`
IsaacWoods Jan 18, 2025
65f08e2
`acpi`: make `wakeup_aps` unsafe
IsaacWoods Jan 18, 2025
e495007
`acpi`: break out HPET fields
IsaacWoods Jan 18, 2025
0308864
`acpi`: make all table fields public
IsaacWoods Jan 18, 2025
33057d7
Clean-up a few straggling bits
IsaacWoods Jan 30, 2025
04bbfa7
Start complete rewrite of AML interpreter
IsaacWoods Feb 6, 2025
c6de62f
`aml`: support `DefPackage` + strings + refactor block handling
IsaacWoods Feb 7, 2025
708dd48
`aml`: stub out support for `DefOpRegion`, `DefField`, `DefThermalZon…
IsaacWoods Feb 7, 2025
4ae5c06
`aml`: fix parsing of `NameString`s
IsaacWoods Feb 7, 2025
2dd835f
`aml`: handle `DefBuffer`
IsaacWoods Feb 7, 2025
fa332ba
`aml`: fix handling of package creation
IsaacWoods Feb 9, 2025
3944926
`aml`: support method calls by eliding lifetimes to AML streams
IsaacWoods Feb 9, 2025
a1bcccc
`aml`: support `DefIfElse`
IsaacWoods Feb 9, 2025
7c9931b
`aml`: support creation of buffer field objects
IsaacWoods Feb 9, 2025
b77079b
`aml`: general parsing cleanup + little bits
IsaacWoods Feb 9, 2025
dea87c4
`aml`: nicer `Display` impl for `Namespace`
IsaacWoods Feb 10, 2025
33b41f6
`aml`: support `DefIncrement`, `DefDecrement`
IsaacWoods Feb 12, 2025
a56959e
`aml`: support `DefObjectType`
IsaacWoods Feb 12, 2025
db0362f
`aml`: support reads from and writes to buffer fields
IsaacWoods Feb 12, 2025
6d629b0
`aml_tester`: allow running a single test instead of a directory of them
IsaacWoods Feb 15, 2025
5185140
`aml`: fix package parsing (again)
IsaacWoods Feb 15, 2025
4ceaa01
`aml`: handle legacy `DefProcessor` operations
IsaacWoods Feb 15, 2025
b8749ce
`aml`: fix branching calculations for `DefIfElse`
IsaacWoods Feb 16, 2025
5d4a75d
`aml`: stub out `DefMutex` and `DefEvent` support
IsaacWoods Feb 16, 2025
763bc74
`aml`: binary maths
IsaacWoods Feb 16, 2025
782e26b
`aml`: handle `DefFindSetLeftBit` and `DefFindSetRightBit`
IsaacWoods Feb 17, 2025
97861f8
`aml`: support executing method objects
IsaacWoods Feb 17, 2025
3f616f5
`aml`: general cleanup
IsaacWoods Feb 18, 2025
d45879d
`aml`: support `DefBreakpoint` + some logical operations
IsaacWoods Feb 18, 2025
4e13b65
`aml`: introduce 'transparent' reference types + handle undefined pac…
IsaacWoods Feb 18, 2025
462f92e
`aml`: re-add old resource descriptor and `_PRT` parsing
IsaacWoods Feb 18, 2025
b8cb18f
`aml`: implement `DefSizeOf`
IsaacWoods Feb 18, 2025
41edbac
`aml`: monomorphise over `Handler` type
IsaacWoods Feb 18, 2025
62330d0
`aml`: implement `DefTimer`, `DefFatal`, `Debug`, and `Revision`
IsaacWoods Feb 19, 2025
86b47eb
`aml`: implement `DefToBCD` and `DefFromBCD`
IsaacWoods Feb 19, 2025
fe877bd
`aml`: support parsing of bank and index fields
IsaacWoods Feb 20, 2025
4c24b08
`aml`: implement `DefIndex`
IsaacWoods Feb 22, 2025
8378db4
`aml`: better type mismatch errors + `DefNot` support
IsaacWoods Feb 22, 2025
9795a38
`aml`: support aliases
IsaacWoods Mar 5, 2025
aee45b3
`aml`: implement `DefWhile`,`DefBreak`,`DefContinue`
IsaacWoods Mar 5, 2025
7442604
`aml`: implement `DefRefOf`, `DefCondRefOf`
IsaacWoods Mar 5, 2025
eb47b1c
`aml`: implement `DefMid`
IsaacWoods Mar 5, 2025
d38ca73
`aml`: fix handling of `DefContinue`
IsaacWoods Mar 5, 2025
55989b3
`aml`: handle strings and buffers in logical ops
IsaacWoods Mar 5, 2025
b6b78ca
`aml`: lay groundwork for field reads + support system memory + IO reads
IsaacWoods Mar 9, 2025
77d446e
`aml`: support PCI config space field reads
IsaacWoods Mar 10, 2025
df5778a
`aml`: implement `DefConcat` and `DefConcatRes`
IsaacWoods Mar 10, 2025
5ef7860
`aml`: fix behaviour of binary ops
IsaacWoods Mar 13, 2025
bb3107a
`aml`: make `InvalidOperationOnObject` error more useful
IsaacWoods Mar 13, 2025
b8e382d
`aml`: initial implementation of mutexes, `DefAcquire`, `DefRelease`
IsaacWoods Mar 13, 2025
b5bb2a5
`aml`: initial implementation of field writing
IsaacWoods Mar 13, 2025
6331744
`acpi`: don't gate `allocator_api` on a feature
IsaacWoods Mar 13, 2025
184ddbf
`acpi`: include revision of AML tables in `AmlTable`
IsaacWoods Mar 13, 2025
15b608d
`acpi`: rewrite most of the library
IsaacWoods Mar 24, 2025
c3efed1
`aml`: implement `DerefOf`
IsaacWoods Mar 24, 2025
12f8a33
`aml`: handle transparent references in return values
IsaacWoods Mar 24, 2025
e2158d6
`aml`: resolve fields at the top-level if required
IsaacWoods Mar 24, 2025
37afb69
`aml`: don't fail on `DefDataRegion` ops
IsaacWoods Mar 25, 2025
2561e5a
`aml`: handle stores to locals/args
IsaacWoods Mar 25, 2025
de76c39
`aml`: improve interpreter docs + few bits and bobs
IsaacWoods Mar 25, 2025
9cf6293
`aml`: start process for initializing namespace - `_STA` and `_INI` o…
IsaacWoods Mar 25, 2025
b266a6a
`aml`: commit some comments/other bits in prep of merging crates
IsaacWoods Mar 25, 2025
3e73ac4
Merge `acpi` and `aml` crates into one top-level crate
IsaacWoods Mar 25, 2025
fe31c72
Add `Interpreter::new_from_tables` helper method
IsaacWoods Mar 25, 2025
35ccb3b
AML: respect the table revision in `DefFindSetLeftBit`
IsaacWoods Mar 28, 2025
88fd134
Fix CI
IsaacWoods Mar 30, 2025
3956699
Make error enums `non_exhaustive`
IsaacWoods Apr 2, 2025
4ce1dad
AML: implement `ToString`, `ToBuffer`, `ToDecimalString`, `ToHexStrin…
IsaacWoods Apr 2, 2025
abb054b
AML: attempt implicit integer conversion on stores
IsaacWoods Apr 2, 2025
6e81489
AML: fix handling of `If` ops at the end of blocks
IsaacWoods Apr 2, 2025
4d66363
Add `ToInteger` test case from uACPI
IsaacWoods Apr 2, 2025
ccde4c7
AML: support `DefVarPackage`
IsaacWoods Apr 3, 2025
a880918
AML: improve safety of mutable object handling
IsaacWoods Apr 4, 2025
22867c6
AML: add rudimentary operation tracing for debugging
IsaacWoods Apr 7, 2025
cf43067
AML: fix bug in `ToHexString`, add test for `To*` opcodes from uACPI
IsaacWoods Apr 7, 2025
91e0c0f
AML: fix bug in string comparisons with strings of less than 4 bytes
IsaacWoods Apr 7, 2025
e986ac7
AML: don't error on name collisions
IsaacWoods Apr 7, 2025
beb2950
AML: allow use of `Local`/`Arg` transparent references in `OpRegion`s
IsaacWoods Apr 7, 2025
cbceb73
AML: allow transparent references to be used in more places
IsaacWoods Apr 10, 2025
1998a26
AML: prepare for correct store result handling
IsaacWoods Apr 10, 2025
4fff735
Rename `PlatformInfo` to `AcpiPlatform`, bring `wake_aps` under it
IsaacWoods Apr 10, 2025
387ddbb
`aml`: specify default `Global` allocator for `PciConfigRegions`
IsaacWoods Jun 28, 2025
aa02318
`aml`: rename `invoke_method` to `evaluate`
IsaacWoods Jun 29, 2025
e28f13d
`aml`: fix handling of names within package definitions
IsaacWoods Jun 29, 2025
697702d
Fix some warnings
IsaacWoods Jun 29, 2025
17a86ae
`aml`: fix spelling of `AmlError::MutexAcquireTimeout`
IsaacWoods Jun 29, 2025
3fe6282
AML: implement support for native methods in the AML namespace
IsaacWoods Jul 2, 2025
425cd54
AML: define `_OS`, `_OSI`, and `_REV` predefined objects
IsaacWoods Jul 5, 2025
ed550f6
Rename `AcpiHandler` to `RegionMapper`, improve docs
IsaacWoods Jul 7, 2025
44c0a12
AML: add predefined global lock mutex object to the namespace
IsaacWoods Jul 8, 2025
fb7e47b
Allow non-standard access sizes in Generic Address Structures
IsaacWoods Jul 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge acpi and aml crates into one top-level crate
  • Loading branch information
IsaacWoods committed Mar 25, 2025
commit 3e73ac480ef6cc61a5844c7c12c23cb8aa16112e
26 changes: 25 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
[workspace]
members = ["acpi", "aml", "tools/aml_tester", "tools/acpi_dumper"]
members = ["tools/aml_tester", "tools/acpi_dumper"]
resolver = "2"

[package]
name = "acpi"
version = "5.1.0"
authors = ["Isaac Woods"]
repository = "https://github.com/rust-osdev/acpi"
description = "A pure-Rust library for interacting with ACPI"
categories = ["hardware-support", "no-std"]
readme = "../README.md"
license = "MIT/Apache-2.0"
edition = "2024"

[dependencies]
bit_field = "0.10.2"
bitflags = "2.5.0"
log = "0.4.20"
spinning_top = "0.3.0"
pci_types = { version = "0.10.0", public = true, optional = true }
byteorder = { version = "1.5.0", default-features = false }

[features]
default = ["alloc", "aml"]
alloc = []
aml = ["alloc", "pci_types"]
19 changes: 0 additions & 19 deletions acpi/Cargo.toml

This file was deleted.

17 changes: 0 additions & 17 deletions aml/Cargo.toml

This file was deleted.

File renamed without changes.
20 changes: 16 additions & 4 deletions aml/src/lib.rs → src/aml/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
#![no_std]
#![feature(let_chains, inherent_str_constructors)]

extern crate alloc;
/*
* TODO:
* - Field reads supporting custom handlers
* - Run `_REG` on supported op region handlers
* - Sort out situation with `gain_mut` omg - thinking we should have a weird mutex thingy and
* gain a 'token' to give us access to objects. Objects themselves should probs be in like an
* `UnsafeCell` or something.
* - Count operations performed and time
* - Do stores properly :(
* - Load and LoadTable
* - Entire Event subsystem and opcodes for them
*
* - Method recursion depth?
* - Loop timeouts
* - Fuzz the shit out of it I guess?
*/

pub mod namespace;
pub mod object;
Expand Down
2 changes: 1 addition & 1 deletion aml/src/namespace.rs → src/aml/namespace.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{AmlError, object::Object};
use crate::aml::{AmlError, object::Object};
use alloc::{
collections::btree_map::BTreeMap,
string::{String, ToString},
Expand Down
2 changes: 1 addition & 1 deletion aml/src/object.rs → src/aml/object.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{AmlError, Handle, Operation, op_region::OpRegion};
use crate::aml::{AmlError, Handle, Operation, op_region::OpRegion};
use alloc::{borrow::Cow, string::String, sync::Arc, vec::Vec};
use bit_field::BitField;

Expand Down
2 changes: 1 addition & 1 deletion aml/src/op_region.rs → src/aml/op_region.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{AmlError, namespace::AmlName};
use crate::aml::{AmlError, namespace::AmlName};

#[derive(Clone, Debug)]
pub struct OpRegion {
Expand Down
4 changes: 2 additions & 2 deletions aml/src/pci_routing.rs → src/aml/pci_routing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{
use crate::aml::{
AmlError,
Handler,
Interpreter,
Expand All @@ -11,7 +11,7 @@ use alloc::{vec, vec::Vec};
use bit_field::BitField;
use core::str::FromStr;

pub use crate::resource::IrqDescriptor;
pub use crate::aml::resource::IrqDescriptor;

#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Pin {
Expand Down
2 changes: 1 addition & 1 deletion aml/src/resource.rs → src/aml/resource.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{AmlError, Operation, object::Object};
use crate::aml::{AmlError, Operation, object::Object};
use alloc::{sync::Arc, vec::Vec};
use bit_field::BitField;
use byteorder::{ByteOrder, LittleEndian};
Expand Down
File renamed without changes.
9 changes: 8 additions & 1 deletion acpi/src/lib.rs → src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
//! tables, and interact with the tables using their raw structures. All other functionality is
//! behind an `alloc` feature (enabled by default) and requires an allocator.
//!
//! With an allocator, this crate also provides higher-level interfaces to the static tables, as
//! well as a dynamic interpreter for AML - the bytecode format encoded in the DSDT and SSDT
//! tables.
//!
//! ### Usage
//! To use the library, you will need to provide an implementation of the [`AcpiHandler`] trait,
//! which allows the library to make requests such as mapping a particular region of physical
Expand All @@ -28,7 +32,7 @@
//! interfaces, such as [`PlatformInfo`], [`PciConfigRegions`], or [`HpetInfo`].

#![no_std]
#![feature(allocator_api)]
#![feature(allocator_api, let_chains, inherent_str_constructors)]

#[cfg_attr(test, macro_use)]
#[cfg(test)]
Expand All @@ -38,7 +42,10 @@ extern crate std;
extern crate alloc;

pub mod address;
#[cfg(feature = "aml")]
pub mod aml;
pub mod handler;
#[cfg(feature = "alloc")]
pub mod platform;
pub mod rsdp;
pub mod sdt;
Expand Down
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.
2 changes: 1 addition & 1 deletion tools/aml_tester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Isaac Woods"]
edition = "2018"

[dependencies]
aml = { path = "../../aml" }
acpi = { path = "../.." }
clap = "4"
termion = "1"
log = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions tools/aml_tester/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* - For failing tests, print out a nice summary of the errors for each file
*/

use aml::{namespace::AmlName, AmlError, Handle, Interpreter};
use acpi::aml::{namespace::AmlName, AmlError, Handle, Interpreter};
use clap::{Arg, ArgAction, ArgGroup};
use pci_types::PciAddress;
use std::{
Expand Down Expand Up @@ -324,7 +324,7 @@ impl log::Log for Logger {

struct Handler;

impl aml::Handler for Handler {
impl acpi::aml::Handler for Handler {
fn read_u8(&self, address: usize) -> u8 {
println!("read_u8 {address:#x}");
0
Expand Down