Crate acpi

Source
Expand description

A library for parsing ACPI tables. This crate can be used by bootloaders and kernels for architectures that support ACPI. This crate is not feature-complete, but can parse lots of the more common tables. Parsing the ACPI tables is required for correctly setting up the APICs, HPET, and provides useful information about power management and many other platform capabilities.

This crate is designed to find and parse the static tables ACPI provides. It should be used in conjunction with the aml crate, which is the (much less complete) AML parser used to parse the DSDT and SSDTs. These crates are separate because some kernels may want to detect the static tables, but delay AML parsing to a later stage.

This crate can be used in three configurations, depending on the environment it’s being used from:

  • Without allocator support - this can be achieved by disabling the allocator_api and alloc features. The core parts of the library will still be usable, but with generally reduced functionality and ease-of-use.
  • With a custom allocator - by disabling just the alloc feature, you can use the new_in functions to access increased functionality with your own allocator. This allows acpi to be integrated more closely with environments that already provide a custom allocator, for example to gracefully handle allocation errors.
  • With the globally-set allocator - the alloc feature provides new functions that simply use the global allocator. This is the easiest option, and the one the majority of users will want. It is the default configuration of the crate.

§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 memory into the virtual address space.

You then need to construct an instance of AcpiTables, which can be done in a few ways depending on how much information you have:

AcpiTables stores the addresses of all of the tables detected on a platform. The SDTs are parsed by this library, or can be accessed directly with from_sdt, while the DSDT and any SSDTs should be parsed with aml.

To gather information out of the static tables, a few of the types you should take a look at are:

  • PlatformInfo parses the FADT and MADT to create a nice view of the processor topology and interrupt controllers on x86_64, and the interrupt controllers on other platforms. AcpiTables::platform_info is a convenience method for constructing a PlatformInfo.
  • HpetInfo parses the HPET table and tells you how to configure the High Precision Event Timer.
  • PciConfigRegions parses the MCFG and tells you how PCIe configuration space is mapped into physical memory.

Re-exports§

pub use crate::platform::interrupt::InterruptModel;
pub use crate::platform::PlatformInfo;
pub use crate::mcfg::PciConfigRegions;
pub use fadt::PowerProfile;
pub use handler::AcpiHandler;
pub use handler::PhysicalMapping;
pub use hpet::HpetInfo;
pub use madt::MadtError;

Modules§

address
ACPI defines a Generic Address Structure (GAS), which provides a versatile way to describe register locations in a wide range of address spaces.
bgrt
fadt
handler
hpet
madt
mcfg
platform
rsdp
sdt
spcr

Structs§

AcpiTables
Type capable of enumerating the existing ACPI tables on the system.
AmlTable
ManagedSlice
Thin wrapper around a regular slice, taking a reference to an allocator for automatic deallocation when the slice is dropped out of scope.
Sdt
SdtHeaderIterator
SsdtIterator
Iterator that steps through all of the tables, and returns only the SSDTs as AmlTables.

Enums§

AcpiError
Error type used by functions that return an AcpiResult<T>.

Traits§

AcpiTable
All types representing ACPI tables should implement this trait.

Type Aliases§

AcpiResult
Result type used by error-returning functions.