~/bend-docscommunity

aml_pkglength.bend checks

raw source on the hub · import bend-osdev-acpi@0.1.1.0/aml_pkglength.bend as Aml_pkglength

bend-osdev-acpi, aml_pkglength.bend: PkgLength, the length that opens every AML package (ACPI 6.5, section 20.2.4, Package Length Encoding):

PkgLength := PkgLeadByte | <PkgLeadByte ByteData> | <PkgLeadByte ByteData ByteData> | <PkgLeadByte ByteData ByteData ByteData>

Bits 7-6 of PkgLeadByte count the ByteData that follow. With none, bits 5-0 are the length (0 to 63). Otherwise bits 3-0 are its least significant four bits, each following byte the next eight, and bits 5-4 must be zero. So a PkgLength holds up to 2^28 - 1. The value counts the PkgLength's own bytes and the package that follows.

The decoder reads bits by pattern and builds the value by joining bits, so that its round trip with the encoder computes for a value whose bits are unknown (LAWS.bend: pkglength_round_trip).

3 imports
import Base
import bend-osdev-bytes@0.1.1.0/bytes.bend as B
import ./error.bend as E

Types

type AmlPkgL source · line 23 · raw

Data

the value, its size in bytes (1 to 4) and what follows (list layer)

type AmlPkgLen source · line 27 · raw

Data

the value and what follows

Definitions

def pk.enc.pick source · line 32 · raw

@s1:Bool -> @s2:Bool -> @s3:Bool -> @+v:U32 -> List<&2, U32>

def pk.enc source · line 47 · raw

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

def pk.v2 source · line 52 · raw

@l0:Bool -> @l1:Bool -> @l2:Bool -> @l3:Bool -> @a:U32 -> U32

def pk.v3 source · line 57 · raw

@l0:Bool -> @l1:Bool -> @l2:Bool -> @l3:Bool -> @a:U32 -> @b:U32 -> U32

def pk.v4 source · line 62 · raw

@l0:Bool -> @l1:Bool -> @l2:Bool -> @l3:Bool -> @a:U32 -> @b:U32 -> @c:U32 -> U32

def pk.d2 source · line 67 · raw

@l0:Bool -> @l1:Bool -> @l2:Bool -> @l3:Bool -> @t:List<&2, U32> -> Result<&2, &2, 0x62173b4e9e82dde7465c7018262f0baa/error.AcpiError, AmlPkgL>

def pk.d3 source · line 74 · raw

@l0:Bool -> @l1:Bool -> @l2:Bool -> @l3:Bool -> @t:List<&2, U32> -> Result<&2, &2, 0x62173b4e9e82dde7465c7018262f0baa/error.AcpiError, AmlPkgL>

def pk.d4 source · line 81 · raw

@l0:Bool -> @l1:Bool -> @l2:Bool -> @l3:Bool -> @t:List<&2, U32> -> Result<&2, &2, 0x62173b4e9e82dde7465c7018262f0baa/error.AcpiError, AmlPkgL>

def pk.multi source · line 89 · raw

@l4:Bool -> @l5:Bool -> @n:Nat -> @l0:Bool -> @l1:Bool -> @l2:Bool -> @l3:Bool -> @t:List<&2, U32> -> Result<&2, &2, 0x62173b4e9e82dde7465c7018262f0baa/error.AcpiError, AmlPkgL>

bits 5-4 must be zero in the multi-byte forms; n: how many bytes follow

def pk.lead source · line 102 · raw

@l7:Bool -> @l6:Bool -> @l0:Bool -> @l1:Bool -> @l2:Bool -> @l3:Bool -> @l4:Bool -> @l5:Bool -> @t:List<&2, U32> -> Result<&2, &2, 0x62173b4e9e82dde7465c7018262f0baa/error.AcpiError, AmlPkgL>

def pk.dec source · line 118 · raw

@xs:List<&2, U32> -> Result<&2, &2, 0x62173b4e9e82dde7465c7018262f0baa/error.AcpiError, AmlPkgL>

the PkgLength at the front of a list of bytes

def AmlPkgLength.fits source · line 128 · raw

@v:U32 -> Bool

the values a PkgLength holds: below 2^28

def AmlPkgLength.encode source · line 132 · raw

@+v:U32 -> 0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets

v in the shortest form (the low 28 bits of v)

def pk.pub source · line 135 · raw

@r:Result<&2, &2, 0x62173b4e9e82dde7465c7018262f0baa/error.AcpiError, AmlPkgL> -> Result<&2, &2, 0x62173b4e9e82dde7465c7018262f0baa/error.AcpiError, AmlPkgLen>

def AmlPkgLength.decode source · line 145 · raw

@o:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> Result<&2, &2, 0x62173b4e9e82dde7465c7018262f0baa/error.AcpiError, AmlPkgLen>

the PkgLength at the front of o, and what follows it; AcpiAmlTruncated if o ends inside it, AcpiAmlBadPkgLength if bits 5-4 are set in a multi-byte form

def pk.size.pick source · line 148 · raw

@a:Bool -> @b:Bool -> @c:Bool -> Nat

def AmlPkgLength.size_for source · line 165 · raw

@+n:Nat -> Nat

the size of the PkgLength that covers a package whose contents (after the PkgLength) are n bytes

def AmlPkgLength.wrap source · line 169 · raw

@+body:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> 0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets

a package: the PkgLength covering it, then its contents