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
andalloc
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 thenew_in
functions to access increased functionality with your own allocator. This allowsacpi
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 providesnew
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:
- Use
AcpiTables::from_rsdp
if you have the physical address of the RSDP - Use
AcpiTables::from_rsdt
if you have the physical address of the RSDT/XSDT - Use
AcpiTables::search_for_rsdp_bios
if you don’t have the address of either, but you know you are running on BIOS, not UEFI - Use
AcpiTables::from_tables_direct
if you are using the library in an unusual setting, such as in usermode, and have a custom method to enumerate and access the tables.
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 onx86_64
, and the interrupt controllers on other platforms.AcpiTables::platform_info
is a convenience method for constructing aPlatformInfo
.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§
- ACPI defines a Generic Address Structure (GAS), which provides a versatile way to describe register locations in a wide range of address spaces.
Structs§
- Type capable of enumerating the existing ACPI tables on the system.
- Thin wrapper around a regular slice, taking a reference to an allocator for automatic deallocation when the slice is dropped out of scope.
- Iterator that steps through all of the tables, and returns only the SSDTs as
AmlTable
s.
Enums§
- Error type used by functions that return an
AcpiResult<T>
.
Traits§
- All types representing ACPI tables should implement this trait.
Type Aliases§
- Result type used by error-returning functions.