acpi.bend checks
raw source on the hub · import bend-osdev-acpi@0.1.2.0/acpi.bend as Acpi
bend-osdev-acpi: the ACPI tables of a machine, found and read through physical memory (ACPI 6.5, section 5.2: the RSDP leads to the RSDT or XSDT, which lists every other table but the DSDT and the FACS, which the FADT points to).
Physical memory is read through a template argument, so any memory works (a mapped window in a kernel, a firmware image, a test image):
~M: Data, ~read: M -> W64 -> Nat -> Result<&2, &2, AcpiError, Octets>
read(m, address, n) answers the n bytes at a physical address, or AcpiNotMapped. AcpiMemImage is an in-memory default. Tables are read one at a time: a header's first 8 bytes for its length, then the table.
10 imports
import Base import bend-osdev-word64@0.1.1.1/word64.bend as W import bend-osdev-bytes@0.1.1.1/bytes.bend as B import ./error.bend as E import ./header.bend as H import ./rsdp.bend as P import ./rsdt.bend as S import ./fadt.bend as F import ./facs.bend as FS import ./registry.bend as R
Types
type AcpiMemRegion source · line 27 · raw
Data
AcpiMemRegion@base:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @bytes:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> AcpiMemRegion
type AcpiMemImage source · line 30 · raw
Data
AcpiMemImage@regions:List<&2, AcpiMemRegion> -> AcpiMemImage
type AcpiLoadOptions source · line 92 · raw
Data
AcpiLoadOptions@prefer_xsdt:Bool -> @registry:0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiRegistry -> AcpiLoadOptions
use the XSDT when the RSDP has one (ACPI 6.5, 5.2.5.3: OSPM uses the XSDT if present); False reads the RSDT
type AcpiLoaded source · line 104 · raw
@-X:Data -> Data
a table, by the address it was read from; a table that fails to read does not stop the others
AcpiLoaded@-X:Data -> @address:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @table:Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiTable<X>> -> AcpiLoaded<X>
type AcpiTableSet source · line 107 · raw
@-X:Data -> Data
AcpiTableSet@-X:Data -> @rsdp:0x437a65a35fd0c02411bea19819f9b33f/rsdp.AcpiRsdp -> @root:0x437a65a35fd0c02411bea19819f9b33f/rsdt.AcpiSdtList -> @tables:List<&2, AcpiLoaded<X>> -> @facs:Maybe<&2, Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x437a65a35fd0c02411bea19819f9b33f/facs.AcpiFacs>> -> AcpiTableSet<X>
Definitions
def mem.slice source · line 33 · raw
@inside:Bool -> @+off:Nat -> @+n:Nat -> @+o:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> Maybe<&2, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>
def mem.near source · line 42 · raw
@near:Bool -> @+off:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+n:Nat -> @+o:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> Maybe<&2, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>
the offset into the region is computed only once it is known to be small (a Nat holds at most 2^48 - 1 at run time)
def mem.above source · line 50 · raw
@above:Bool -> @+base:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+n:Nat -> @+o:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> Maybe<&2, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>
def mem.try source · line 58 · raw
@r:AcpiMemRegion -> @+addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+n:Nat -> Maybe<&2, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>
def mem.find source · line 63 · raw
@rs:List<&2, AcpiMemRegion> -> @+addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+n:Nat -> Maybe<&2, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>
def mem.done source · line 70 · raw
@m:Maybe<&2, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets> -> @+addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>
def mem.read source · line 78 · raw
@m:AcpiMemImage -> @+addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+n:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>
n bytes at a physical address, from the first region holding all of them
def AcpiMemImage.read source · line 84 · raw
@m:AcpiMemImage -> @addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @n:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>
(plain parameters, so that it fits the template type ~read)
def AcpiMemImage.of_list source · line 87 · raw
@rs:List<&2, AcpiMemRegion> -> AcpiMemImage
def AcpiLoadOptions.default source · line 97 · raw
AcpiLoadOptions
def ld.rsdp.pick source · line 122 · raw
@v1:Bool -> Nat
def ld.rsdp.len source · line 129 · raw
@+head:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> Nat
def ld.root.parse source · line 138 · raw
@xsdt:Bool -> @+o:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x437a65a35fd0c02411bea19819f9b33f/rsdt.AcpiSdtList>
def ld.nz.pick source · line 170 · raw
@z:Bool -> @+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> Maybe<&2, 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64>
def ld.nz source · line 177 · raw
@+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> Maybe<&2, 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64>
def ld.list source · line 180 · raw
@m:Maybe<&2, 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64> -> List<&2, 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64>
def ld.use_x source · line 208 · raw
@prefer:Bool -> @+r:0x437a65a35fd0c02411bea19819f9b33f/rsdp.AcpiRsdp -> Bool
def ld.root_addr source · line 215 · raw
@x:Bool -> @+r:0x437a65a35fd0c02411bea19819f9b33f/rsdp.AcpiRsdp -> 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64
def ld.opts source · line 227 · raw
@o:AcpiLoadOptions -> Bool
def ld.reg source · line 232 · raw
@o:AcpiLoadOptions -> 0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiRegistry
Templates
template ld.whole source · line 114 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @+m:M -> @+addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+head:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>
the table at a physical address: its length from its header, then all of its bytes
template AcpiTables.read_table source · line 117 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @+m:M -> @+addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>
template AcpiTables.read_rsdp source · line 132 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @+m:M -> @+addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x437a65a35fd0c02411bea19819f9b33f/rsdp.AcpiRsdp>
template ld.root source · line 145 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @+m:M -> @+xsdt:Bool -> @+addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x437a65a35fd0c02411bea19819f9b33f/rsdt.AcpiSdtList>
template ld.one source · line 150 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @-X:Data -> @-ext:(@_:U32 -> @_:0x437a65a35fd0c02411bea19819f9b33f/header.AcpiSdt -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, X>) -> @+m:M -> @+reg:0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiRegistry -> @+addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> AcpiLoaded<X>
template ld.all source · line 153 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @-X:Data -> @-ext:(@_:U32 -> @_:0x437a65a35fd0c02411bea19819f9b33f/header.AcpiSdt -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, X>) -> @as:List<&2, 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64> -> @+m:M -> @+reg:0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiRegistry -> List<&2, AcpiLoaded<X>>
template ld.fadt source · line 161 · raw
@-X:Data -> @ts:List<&2, AcpiLoaded<X>> -> Maybe<&2, 0x437a65a35fd0c02411bea19819f9b33f/fadt.AcpiFadt>
the FADT among the tables read
template ld.dsdt source · line 187 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @-X:Data -> @-ext:(@_:U32 -> @_:0x437a65a35fd0c02411bea19819f9b33f/header.AcpiSdt -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, X>) -> @f:Maybe<&2, 0x437a65a35fd0c02411bea19819f9b33f/fadt.AcpiFadt> -> @+m:M -> @+reg:0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiRegistry -> List<&2, AcpiLoaded<X>>
template ld.facs.at source · line 194 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @+m:M -> @a:Maybe<&2, 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64> -> Maybe<&2, Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x437a65a35fd0c02411bea19819f9b33f/facs.AcpiFacs>>
template ld.facs source · line 201 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @f:Maybe<&2, 0x437a65a35fd0c02411bea19819f9b33f/fadt.AcpiFadt> -> @+m:M -> Maybe<&2, Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x437a65a35fd0c02411bea19819f9b33f/facs.AcpiFacs>>
template ld.finish source · line 222 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @-X:Data -> @-ext:(@_:U32 -> @_:0x437a65a35fd0c02411bea19819f9b33f/header.AcpiSdt -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, X>) -> @+m:M -> @+reg:0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiRegistry -> @rsdp:0x437a65a35fd0c02411bea19819f9b33f/rsdp.AcpiRsdp -> @+root:0x437a65a35fd0c02411bea19819f9b33f/rsdt.AcpiSdtList -> AcpiTableSet<X>
template AcpiTables.load_with source · line 240 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @-X:Data -> @-ext:(@_:U32 -> @_:0x437a65a35fd0c02411bea19819f9b33f/header.AcpiSdt -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, X>) -> @+opts:AcpiLoadOptions -> @+m:M -> @+rsdp_addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, AcpiTableSet<X>>
every table of the machine whose RSDP is at rsdp_addr: the RSDP, the RSDT or XSDT (Fail if either cannot be read), then each table it lists, the DSDT (from the FADT) and the FACS, each read and parsed on its own
template AcpiTables.load source · line 247 · raw
@-M:Data -> @-read:(@_:M -> @_:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @_:Nat -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets>) -> @+m:M -> @+rsdp_addr:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, AcpiTableSet<0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiNoExt>>
template AcpiTableSet.tables source · line 252 · raw
@-X:Data -> @s:AcpiTableSet<X> -> List<&2, AcpiLoaded<X>>
template ld.find.pick source · line 257 · raw
@-X:Data -> @hit:Bool -> @t:0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiTable<X> -> @rest:Maybe<&2, 0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiTable<X>> -> Maybe<&2, 0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiTable<X>>
template ld.find source · line 264 · raw
@-X:Data -> @ts:List<&2, AcpiLoaded<X>> -> @+name:String -> Maybe<&2, 0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiTable<X>>
template AcpiTableSet.find source · line 275 · raw
@-X:Data -> @s:AcpiTableSet<X> -> @+name:String -> Maybe<&2, 0x437a65a35fd0c02411bea19819f9b33f/registry.AcpiTable<X>>
the first table read whose parser's name (R.AcpiTable.name: the signature) is name