~/bend-docscommunity

aml_name.bend checks

raw source on the hub · import bend-osdev-acpi@0.1.0.0/aml_name.bend as Aml_name

bend-osdev-acpi, aml_name.bend: AML name strings (ACPI 6.5, sections 20.2.2, Name Objects Encoding, and 5.3, ACPI Namespace):

NameSeg := <LeadNameChar NameChar NameChar NameChar> LeadNameChar := 'A'-'Z' | '_' NameChar := DigitChar | LeadNameChar (DigitChar: '0'-'9') NameString := <RootChar NamePath> | <PrefixPath NamePath> RootChar := '\' (0x5C) PrefixPath := Nothing | <'^' PrefixPath> ('^' is 0x5E) NamePath := NameSeg | DualNamePath | MultiNamePath | NullName DualNamePath := DualNamePrefix NameSeg NameSeg (DualNamePrefix: 0x2E) MultiNamePath := MultiNamePrefix SegCount NameSeg(SegCount) (MultiNamePrefix: 0x2F; SegCount: a byte, 1 to 255) NullName := 0x00

A name is AmlName{root, up, segs}: rooted at '\', or up some number of parents, then its segments (4 bytes each, as Octets). The encoder writes the shortest NamePath (a NameSeg for one segment, DualNamePath for two, MultiNamePath for three or more); the decoder reads every form, and refuses a SegCount of 0.

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

Types

type AmlName source · line 25 · raw

Data

type AmlNameL source · line 29 · raw

Data

a name read from a list of bytes: the name and what follows

type AmlNameParsed source · line 33 · raw

Data

a name read from Octets

type AmlLeadKind source · line 53 · raw

Data

type AmlSegL source · line 210 · raw

Data

type AmlSegsL source · line 213 · raw

Data

Definitions

def AmlName.root source · line 36 · raw

@n:AmlName -> Bool

def AmlName.up source · line 41 · raw

@n:AmlName -> Nat

def AmlName.segs source · line 46 · raw

@n:AmlName -> List<&2, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>

def nm.alpha source · line 62 · raw

@+c:U32 -> Bool

def nm.cls.c source · line 65 · raw

@seg:Bool -> AmlLeadKind

def nm.cls.b source · line 72 · raw

@z:Bool -> @+c:U32 -> AmlLeadKind

def nm.cls.a source · line 79 · raw

@m:Bool -> @+c:U32 -> AmlLeadKind

def nm.cls.n9 source · line 86 · raw

@d:Bool -> @+c:U32 -> AmlLeadKind

def nm.cls.n8 source · line 93 · raw

@p:Bool -> @+c:U32 -> AmlLeadKind

def nm.cls.r source · line 100 · raw

@r:Bool -> @+c:U32 -> AmlLeadKind

def AmlLead.classify source · line 108 · raw

@+c:U32 -> AmlLeadKind

the kind of name element a byte begins

def AmlLead.is_seg source · line 111 · raw

@k:AmlLeadKind -> Bool

def AmlName.name_char source · line 119 · raw

@+c:U32 -> Bool

a NameChar: a LeadNameChar or a digit

def nm.seg_ok4 source · line 122 · raw

@+c0:U32 -> @+c1:U32 -> @+c2:U32 -> @+c3:U32 -> Bool

def nm.seg_ok.list source · line 125 · raw

@xs:List<&2, U32> -> Bool

def AmlName.seg_ok source · line 133 · raw

@s:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Bool

a NameSeg: four bytes, a LeadNameChar then three NameChars

def AmlName.segs_ok source · line 136 · raw

@ss:List<&2, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets> -> Bool

def nm.root_up_ok source · line 143 · raw

@root:Bool -> @up:Nat -> Bool

def nm.len source · line 150 · raw

@ss:List<&2, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets> -> Nat

def AmlName.valid source · line 155 · raw

@n:AmlName -> Bool

the names a NameString can hold: not both rooted and going up, every segment a NameSeg, at most 255 segments

def nm.carets source · line 162 · raw

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

def nm.prefix source · line 169 · raw

@root:Bool -> @up:Nat -> List<&2, U32>

def nm.segs.list source · line 176 · raw

@ss:List<&2, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets> -> List<&2, U32>

def nm.path source · line 183 · raw

@ss:List<&2, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets> -> List<&2, U32>

def nm.enc source · line 194 · raw

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

def AmlName.encode source · line 201 · raw

@n:AmlName -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

the name as a NameString (AmlName.valid names read back: LAWS.bend, namestring_round_trip)

def AmlName.size source · line 205 · raw

@n:AmlName -> Nat

its size in bytes

def nm.seg.pick source · line 216 · raw

@ok:Bool -> @c0:U32 -> @c1:U32 -> @c2:U32 -> @c3:U32 -> @t:List<&2, U32> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlSegL>

def nm.seg source · line 223 · raw

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

def nm.cons source · line 230 · raw

@s:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> @r:Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlSegsL> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlSegsL>

def nm.segs.go source · line 238 · raw

@p:Nat -> @r:Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlSegL> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlSegsL>

the segment in r, then p more

def nm.segs source · line 254 · raw

@n:Nat -> @xs:List<&2, U32> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlSegsL>

n segments

def nm.multi.k source · line 261 · raw

@zero:Bool -> @n:Nat -> @r:List<&2, U32> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlSegsL>

def nm.multi source · line 268 · raw

@t:List<&2, U32> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlSegsL>

def nm.path.k source · line 276 · raw

@k:AmlLeadKind -> @c:U32 -> @t:List<&2, U32> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlSegsL>

def nm.dpath source · line 289 · raw

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

def nm.named source · line 296 · raw

@root:Bool -> @up:Nat -> @r:Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlSegsL> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlNameL>

def nm.up1 source · line 303 · raw

@r:Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlNameL> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlNameL>

def nm.head_kind source · line 310 · raw

@xs:List<&2, U32> -> AmlLeadKind

def nm.ups source · line 318 · raw

@xs:List<&2, U32> -> @k:AmlLeadKind -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlNameL>

parent prefixes, then a path; k is the kind of the first byte

def nm.dec.k source · line 329 · raw

@k:AmlLeadKind -> @c:U32 -> @t:List<&2, U32> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlNameL>

def nm.dec source · line 337 · raw

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

the NameString at the front of a list of bytes

def nm.pub source · line 344 · raw

@r:Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlNameL> -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlNameParsed>

def AmlName.decode source · line 352 · raw

@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x29fa0aa629b7afe02bc50bfd713bc39b/error.AcpiError, AmlNameParsed>

the NameString at the front of o, and what follows it

def nm.show.segs source · line 357 · raw

@ss:List<&2, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets> -> @first:Bool -> String

def nm.show.pre source · line 368 · raw

@root:Bool -> @up:Nat -> String

def AmlName.show source · line 375 · raw

@n:AmlName -> String

def AmlName.seg source · line 382 · raw

@s:String -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

a segment from text: its first four characters, padded with '_' as ASL does ("_SB" is "_SB_")

def nm.text.segs source · line 386 · raw

@ps:List<&2, String> -> List<&2, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>

def nm.text.split.pick source · line 393 · raw

@e:Bool -> @+s:String -> List<&2, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>

def nm.text.split source · line 400 · raw

@+s:String -> List<&2, 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets>

def nm.text.ups source · line 404 · raw

@s:String -> @isc:Bool -> @n:Nat -> AmlName

leading carets, counted; isc: s starts with one

def nm.text.root source · line 415 · raw

@r:Bool -> @+s:String -> AmlName

def AmlName.of_text source · line 424 · raw

@+s:String -> AmlName

a name from its text: "\_SB.PCI0" (in Bend source), "^^_STA", "LNKA"; segments are separated by '.', each padded to four characters with '_'