~/bend-docscommunity

src/x86/acpi.bend checks

raw source on the hub · import 0x2324e729258ea5021b37b97947af4c3f/src/x86/acpi.bend as Acpi

4 imports
import Base
import ../lib/u64.bend as U
import ../lib/bytes.bend as B
import ./layout.bend as X

Definitions

def Acpi.sleep_port source · line 19 · raw

U32

def Acpi.status_port source · line 22 · raw

U32

def Acpi.reset_port source · line 25 · raw

U32

def Acpi.reset_value source · line 28 · raw

U32

def Acpi.s5 source · line 31 · raw

U32

def Acpi.sum source · line 34 · raw

@bs:List<&2, U32> -> U32

def Acpi.fix source · line 42 · raw

@+bs:List<&2, U32> -> U32

The byte that makes bs sum to 0.

def Acpi.str source · line 45 · raw

@s:String -> List<&2, U32>

def Acpi.set source · line 49 · raw

@+bs:List<&2, U32> -> @+off:Nat -> @v:U32 -> List<&2, U32>

bs with byte off set to v (bs is long enough).

def Acpi.table source · line 53 · raw

@sig:String -> @rev:U32 -> @+body:List<&2, U32> -> List<&2, U32>

A table: header (checksum at byte 9 fixed last) then the body.

def Acpi.gas_io source · line 61 · raw

@+port:U32 -> List<&2, U32>

A generic address structure for an 8-bit IO port.

def Acpi.rsdp source · line 66 · raw

@+xsdt:U32 -> List<&2, U32>

The RSDP (revision 2, 36 bytes): its first 20 bytes sum to 0, and so do all 36.

def Acpi.ptrs source · line 72 · raw

@ps:List<&2, U32> -> List<&2, U32>

def Acpi.xsdt source · line 79 · raw

@ps:List<&2, U32> -> List<&2, U32>

def Acpi.fadt source · line 88 · raw

@+dsdt:U32 -> List<&2, U32>

The FADT (revision 6, 276 bytes): DSDT and X_DSDT, CENTURY 50 (the CMOS century register), IAPC_BOOT_ARCH "no VGA" (4) and "MSI not supported" (8), flags WBINVD (1), no fixed power (16) and sleep (32) buttons, RESET_REG_SUP (1024), HW_REDUCED_ACPI (1 << 20); the reset register and value; the sleep control and status registers.

def Acpi.lapics source · line 99 · raw

@n:Nat -> @+i:U32 -> List<&2, U32>

MADT entries: a local APIC per vCPU (enabled), the IOAPIC (id ncpus, GSI base 0), the overrides (ISA IRQ 0 to GSI 2; SCI 9 and each virtio ISA line level-triggered, active-high: flags 13), LINT1 as NMI on every CPU.

def Acpi.iso source · line 106 · raw

@+irq:U32 -> @+gsi:U32 -> @+flags:U32 -> List<&2, U32>

def Acpi.level_isos source · line 109 · raw

@gs:List<&2, U32> -> List<&2, U32>

def Acpi.madt source · line 116 · raw

@+cpus:U32 -> List<&2, U32>

def Aml.pkg source · line 125 · raw

@+n:U32 -> List<&2, U32>

AML. A package length counts its own bytes: one when the whole is under 64, two under 4096, three under 2^20.

def Aml.wrap source · line 131 · raw

@+op:List<&2, U32> -> @+body:List<&2, U32> -> List<&2, U32>

op, then the package length, then body.

def Aml.name source · line 135 · raw

@seg:String -> @+data:List<&2, U32> -> List<&2, U32>

Name(seg, data).

def Aml.byte source · line 138 · raw

@+v:U32 -> List<&2, U32>

def Aml.string source · line 141 · raw

@s:String -> List<&2, U32>

def Aml.buffer source · line 144 · raw

@+bs:List<&2, U32> -> List<&2, U32>

def Aml.s5 source · line 148 · raw

List<&2, U32>

Name(_S5_, Package(2) {5, 0}).

def Aml.hex source · line 151 · raw

@+d:U32 -> U32

def Aml.seg source · line 155 · raw

@+n:U32 -> String

The device V0nn of slot n (n < 256, two hex digits).

def Aml.crs source · line 160 · raw

@+base:U32 -> @+gsi:U32 -> List<&2, U32>

Memory32Fixed(ReadWrite, base, 512), Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive) {gsi}, the end tag.

def Aml.virtio source · line 166 · raw

@+n:U32 -> List<&2, U32>

Device (V0nn) { _HID "LNRO0005" (virtio-mmio), _UID n, _CRS }.

def Aml.virtios source · line 170 · raw

@k:Nat -> @+n:U32 -> List<&2, U32>

def Aml.isa_crs source · line 179 · raw

@+port:U32 -> @+len:U32 -> @+gsi:U32 -> List<&2, U32>

IO(Decode16, port, port, 1, len), Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {gsi}, the end tag: an ISA device.

def Aml.isa source · line 187 · raw

@name:String -> @hid:String -> @+port:U32 -> @+len:U32 -> @+gsi:U32 -> List<&2, U32>

Device (name) { _HID hid, _UID 0, _CRS }: the legacy devices, described so that hardware-reduced ACPI (no legacy PIC: Linux maps no ISA interrupt by itself) routes their lines.

def Aml.legacy source · line 193 · raw

List<&2, U32>

COM1 (PNP0501: 1016, 8 ports, GSI 4) and the CMOS clock (PNP0B00: 112, 2 ports, GSI 8).

def Acpi.dsdt source · line 198 · raw

@+nslots:U32 -> List<&2, U32>

The DSDT: \_S5 and Scope (\_SB_) { COM1, the clock, the first nslots virtio devices }.

def Acpi.len source · line 202 · raw

@bs:List<&2, U32> -> U32

def Acpi.pad16 source · line 205 · raw

@+bs:List<&2, U32> -> List<&2, U32>

def Acpi.tables source · line 210 · raw

@+base:U32 -> @+cpus:U32 -> @+nslots:U32 -> List<&2, U32>

Every table, laid out from base (16-byte aligned): RSDP, XSDT, FADT, MADT, DSDT, each padded to 16 bytes. The RSDP is at base.