~/bend-docscommunity

aml_host.bend checks

raw source on the hub · import bend-osdev-acpi@0.1.2.0/aml_host.bend as Aml_host

bend-osdev-acpi, aml_host.bend: how AML reaches hardware. Operation regions (ACPI 6.5, chapter 19, OperationRegion; 5.5.2.4, Access to Operation Regions) are read and written through a host, a template argument of the interpreter:

~H: Data, ~io: H -> AmlHostOp -> Result<&2, &2, AcpiError, AmlHostAns<H>>

io(h, AmlHRead{a}) answers the value read and the host after the read (a read may have effects); io(h, AmlHWrite{a, v}) answers the host after the write (and v). An access names its address space (0 SystemMemory, 1 SystemIO, 2 PCI_Config, 3 EmbeddedControl, 4 SMBus, 5 SystemCMOS, 6 PciBarTarget, 7 IPMI, 8 GeneralPurposeIO, 9 GenericSerialBus, 10 PCC, 0x80 and up OEM), its address and its width in bits (8, 16, 32 or 64).

A PCI_Config address is laid out as in a Generic Address Structure (5.2.3.2: offset in bits 0-15, function in 16-31, device in 32-47), with the bus in bits 48-55 and the low byte of the segment in bits 56-63 (AmlPci.address); the interpreter takes the device and function from the region's device's _ADR, the bus from _BBN and the segment from _SEG of the nearest enclosing device that has them (6.1.1, 6.5.5, 6.5.6).

AmlMemHost, the default, is pure memory: one byte map per address space, zero where nothing was written, and a log of every access.

4 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

Types

type AmlAccess source · line 29 · raw

Data

type AmlHostOp source · line 32 · raw

Data

type AmlHostAns source · line 36 · raw

@-H:Data -> Data

type AmlMemHost source · line 44 · raw

Data

Definitions

def AmlPci.address source · line 39 · raw

@seg:U32 -> @bus:U32 -> @dev:U32 -> @fun:U32 -> @off:U32 -> 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64

def AmlMemHost.new source · line 47 · raw

AmlMemHost

def hst.key source · line 50 · raw

@+space:U32 -> @+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> String

def hst.snd source · line 53 · raw

@r:Pair(Map<&2, U32>, U32) -> U32

def hst.byte source · line 57 · raw

@+m:Map<&2, U32> -> @+space:U32 -> @+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> U32

def hst.rd source · line 61 · raw

@n:Nat -> @+m:Map<&2, U32> -> @+space:U32 -> @+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+sh:Nat -> @acc:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> 0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64

n bytes from address a, little-endian, into acc from bit sh

def hst.wr source · line 68 · raw

@n:Nat -> @m:Map<&2, U32> -> @+space:U32 -> @+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @+v:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> Map<&2, U32>

def hst.go source · line 75 · raw

@h:AmlMemHost -> @op:AmlHostOp -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, AmlHostAns<AmlMemHost>>

def AmlMemHost.io source · line 84 · raw

@h:AmlMemHost -> @op:AmlHostOp -> Result<&2, &2, 0x437a65a35fd0c02411bea19819f9b33f/error.AcpiError, AmlHostAns<AmlMemHost>>

the host interface for AmlMemHost (plain parameters, so that it fits the template type ~io)

def hst.load source · line 87 · raw

@xs:List<&2, U32> -> @m:Map<&2, U32> -> @+space:U32 -> @+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> Map<&2, U32>

def AmlMemHost.poke source · line 95 · raw

@h:AmlMemHost -> @+space:U32 -> @+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> @o:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> AmlMemHost

the host with bytes o at address a of a space (no access logged)

def AmlMemHost.peek source · line 101 · raw

@h:AmlMemHost -> @+space:U32 -> @+a:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> U32

the byte at an address of a space

def hst.rev source · line 106 · raw

@xs:List<&2, AmlHostOp> -> @acc:List<&2, AmlHostOp> -> List<&2, AmlHostOp>

def AmlMemHost.log source · line 114 · raw

@h:AmlMemHost -> List<&2, AmlHostOp>

every access so far, oldest first

def AmlHostOp.show source · line 119 · raw

@op:AmlHostOp -> String

def hst.show source · line 126 · raw

@xs:List<&2, AmlHostOp> -> @first:Bool -> String

def AmlMemHost.show_log source · line 138 · raw

@h:AmlMemHost -> String

the log as text, oldest first, "; " between accesses