def AcpiMcfg.of_sdt

bend-osdev-acpi@0.1.1.0 · mcfg.bend:45

import bend-osdev-acpi@0.1.1.0/mcfg.bend as Mcfg
import Base
import bend-osdev-bytes@0.1.1.0/bytes.bend as B
import bend-osdev-acpi@0.1.1.0/error.bend as E
import bend-osdev-acpi@0.1.1.0/header.bend as H

45# a checked table as an MCFG: the body is 8 reserved bytes and a whole
46# number of 16-byte structures (AcpiBadSize otherwise)
47def AcpiMcfg.of_sdt(t: H.AcpiSdt) -> Result<&2, &2, E.AcpiError, AcpiMcfg>:
48  match t:
49    case H.AcpiSdt{h, +body}:
50      +n = B.Octets.len(body)
51      mcfg.body(Bool.and(Nat.is_le(8n, n), Nat.is_eq(Nat.mod(Nat.sub(n, 8n), 16n), 0n)), h, body)

Uses (11)

Used by (3)