aml_term.bend checks
raw source on the hub · import bend-osdev-acpi@0.1.2.0/aml_term.bend as Aml_term
bend-osdev-acpi, aml_term.bend: building AML (ACPI 6.5, chapter 20, AML Specification): terms and their encoding, with a constructor for each ASL operator this package uses (chapter 19 names them), so that a definition block can be written in Bend:
AmlT.scope("\\_SB", [AmlT.device("PCI0", [ AmlT.name("_HID", AmlT.eisaid("PNP0A03")), AmlT.method("_STA", 0n, False{}, [AmlT.ret(AmlT.int32(15))])])])
A term is a number, a string, raw bytes, an opcode with operands, or a package (an opcode, then a PkgLength covering a head and a body), which is enough for every encoding in chapter 20: the constructors below fill them in. Operands are lists, so that encoding is one structural recursion.
5 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 ./aml_pkglength.bend as K import ./aml_name.bend as N
Types
type AmlTerm source · line 21 · raw
Data
AmlTInt@v:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> AmlTerm
an integer, in its shortest encoding: ZeroOp, OneOp, OnesOp (all 64 bits set), or the Byte, Word, DWord or QWord prefix
AmlTStr@s:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> AmlTerm
a String (AsciiCharList, then the NUL the encoder adds)
AmlTRaw@bytes:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> AmlTerm
bytes as they are: a NameString, Local0, Debug, ...
AmlTOp@code:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> @args:List<&2, AmlTerm> -> AmlTerm
an opcode (or a NameString, for a method call) followed by operands
AmlTPkg@code:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> @head:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> @body:List<&2, AmlTerm> -> AmlTerm
an opcode, then a PkgLength covering head and body
type AmlFieldElem source · line 35 · raw
Data
Field elements (20.2.5.2, FieldList)
AmlFNamed@seg:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> @bits:U32 -> AmlFieldElem
NamedField: a NameSeg and its width in bits
AmlFReserved@bits:U32 -> AmlFieldElem
ReservedField (ASL Offset): bits skipped
AmlFAccess@access_type:U32 -> @attrib:U32 -> AmlFieldElem
AccessField: access type and attribute from here on
Definitions
def tm.b source · line 45 · raw
@xs:List<&2, U32> -> 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets
def tm.int.pick source · line 48 · raw
@z:Bool -> @o:Bool -> @m:Bool -> @b8:Bool -> @b16:Bool -> @b32:Bool -> @+v:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets
def tm.int source · line 75 · raw
@+v:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets
def tm.str source · line 80 · raw
@+s:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets
def AmlT.encode source · line 85 · raw
@ts:List<&2, AmlTerm> -> 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets
a term list; every term's operands and body are sublists, so this is one structural recursion
def AmlT.encode1 source · line 102 · raw
@t:AmlTerm -> 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets
def tm.field.enc source · line 105 · raw
@es:List<&2, AmlFieldElem> -> 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets
def AmlT.int source · line 118 · raw
@v:0xea9c6e6209a3ac3fb21596f70f09f650/word64.W64 -> AmlTerm
def AmlT.int32 source · line 121 · raw
@v:U32 -> AmlTerm
def AmlT.zero source · line 124 · raw
AmlTerm
def AmlT.one source · line 127 · raw
AmlTerm
def AmlT.ones source · line 130 · raw
AmlTerm
def AmlT.str source · line 133 · raw
@s:String -> AmlTerm
def AmlT.revision source · line 136 · raw
AmlTerm
def AmlT.buffer source · line 140 · raw
@size:AmlTerm -> @bytes:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> AmlTerm
a Buffer of size bytes (a term), initialised from bytes
def AmlT.buf source · line 144 · raw
@+bytes:0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets -> AmlTerm
a Buffer holding exactly these bytes
def AmlT.package source · line 147 · raw
@+elems:List<&2, AmlTerm> -> AmlTerm
def AmlT.var_package source · line 150 · raw
@count:AmlTerm -> @elems:List<&2, AmlTerm> -> AmlTerm
def tm.hex.pick source · line 155 · raw
@digit:Bool -> @upper:Bool -> @+c:U32 -> U32
EISAID("PNP0A03") (chapter 19, EISAID): three letters of five bits each and four hex digits, stored most significant byte first, as a DWord
def tm.hex source · line 166 · raw
@+c:U32 -> U32
def tm.eisa source · line 169 · raw
@xs:List<&2, U32> -> U32
def AmlT.eisaid_value source · line 178 · raw
@s:String -> U32
def AmlT.eisaid source · line 181 · raw
@s:String -> AmlTerm
def tm.name source · line 186 · raw
@s:String -> 0x15cc157649e26d54c7c549cb80d4a2a9/bytes.Octets
def AmlT.nm source · line 191 · raw
@s:String -> AmlTerm
a name as a term (its value, a reference to it in a package, or a call of a method that takes no arguments)
def AmlT.call source · line 194 · raw
@s:String -> @args:List<&2, AmlTerm> -> AmlTerm
def AmlT.local source · line 197 · raw
@i:U32 -> AmlTerm
def AmlT.arg source · line 200 · raw
@i:U32 -> AmlTerm
def AmlT.debug source · line 203 · raw
AmlTerm
def AmlT.none source · line 207 · raw
AmlTerm
NullName, the Target that discards a result
def AmlT.name source · line 212 · raw
@s:String -> @v:AmlTerm -> AmlTerm
def AmlT.scope source · line 215 · raw
@s:String -> @body:List<&2, AmlTerm> -> AmlTerm
def AmlT.device source · line 218 · raw
@s:String -> @body:List<&2, AmlTerm> -> AmlTerm
def tm.bit source · line 221 · raw
@b:Bool -> @v:U32 -> U32
def AmlT.method source · line 229 · raw
@s:String -> @nargs:Nat -> @ser:Bool -> @body:List<&2, AmlTerm> -> AmlTerm
a method of nargs arguments (0 to 7), serialized or not, sync level 0
def AmlT.processor source · line 232 · raw
@s:String -> @id:U32 -> @pblk:U32 -> @plen:U32 -> @body:List<&2, AmlTerm> -> AmlTerm
def AmlT.power_resource source · line 235 · raw
@s:String -> @level:U32 -> @order:U32 -> @body:List<&2, AmlTerm> -> AmlTerm
def AmlT.thermal_zone source · line 238 · raw
@s:String -> @body:List<&2, AmlTerm> -> AmlTerm
def AmlT.region source · line 243 · raw
@s:String -> @space:U32 -> @off:AmlTerm -> @len:AmlTerm -> AmlTerm
OperationRegion(name, space, offset, length): space 0 SystemMemory, 1 SystemIO, 2 PCI_Config, 3 EmbeddedControl, ...
def AmlT.field_flags source · line 249 · raw
@access:U32 -> @lock:Bool -> @update:U32 -> U32
FieldFlags (20.2.5.2): access type 0 AnyAcc, 1 ByteAcc, 2 WordAcc, 3 DWordAcc, 4 QWordAcc, 5 BufferAcc; lock; update rule 0 Preserve, 1 WriteAsOnes, 2 WriteAsZeros
def AmlT.field source · line 252 · raw
@region:String -> @flags:U32 -> @es:List<&2, AmlFieldElem> -> AmlTerm
def AmlT.index_field source · line 255 · raw
@index:String -> @data:String -> @flags:U32 -> @es:List<&2, AmlFieldElem> -> AmlTerm
def AmlT.fnamed source · line 258 · raw
@s:String -> @bits:U32 -> AmlFieldElem
def AmlT.mutex source · line 261 · raw
@s:String -> @sync:U32 -> AmlTerm
def AmlT.event source · line 264 · raw
@s:String -> AmlTerm
def AmlT.alias source · line 267 · raw
@src:String -> @dst:String -> AmlTerm
def AmlT.external source · line 270 · raw
@s:String -> @kind:U32 -> @nargs:U32 -> AmlTerm
def AmlT.create_field source · line 275 · raw
@op:U32 -> @src:AmlTerm -> @index:AmlTerm -> @s:String -> AmlTerm
CreateBitField, CreateByteField, CreateWordField, CreateDWordField, CreateQWordField (op 141, 140, 139, 138, 143): a field of a buffer
def AmlT.create_dword_field source · line 278 · raw
@src:AmlTerm -> @index:AmlTerm -> @s:String -> AmlTerm
def AmlT.if_ source · line 283 · raw
@pred:AmlTerm -> @body:List<&2, AmlTerm> -> AmlTerm
def AmlT.if_else source · line 286 · raw
@pred:AmlTerm -> @body:List<&2, AmlTerm> -> @els:List<&2, AmlTerm> -> AmlTerm
def AmlT.while_ source · line 289 · raw
@pred:AmlTerm -> @body:List<&2, AmlTerm> -> AmlTerm
def AmlT.ret source · line 292 · raw
@v:AmlTerm -> AmlTerm
def AmlT.brk source · line 295 · raw
AmlTerm
def AmlT.cont source · line 298 · raw
AmlTerm
def AmlT.noop source · line 301 · raw
AmlTerm
def AmlT.notify source · line 304 · raw
@obj:AmlTerm -> @v:AmlTerm -> AmlTerm
def AmlT.sleep source · line 307 · raw
@ms:AmlTerm -> AmlTerm
def AmlT.stall source · line 310 · raw
@us:AmlTerm -> AmlTerm
def AmlT.acquire source · line 313 · raw
@m:AmlTerm -> @timeout:U32 -> AmlTerm
def AmlT.release source · line 316 · raw
@m:AmlTerm -> AmlTerm
def AmlT.op source · line 322 · raw
@op:U32 -> @args:List<&2, AmlTerm> -> AmlTerm
def AmlT.store source · line 325 · raw
@v:AmlTerm -> @target:AmlTerm -> AmlTerm
def AmlT.copy_object source · line 328 · raw
@v:AmlTerm -> @target:AmlTerm -> AmlTerm
def AmlT.add source · line 331 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.subtract source · line 334 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.multiply source · line 337 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.divide source · line 341 · raw
@a:AmlTerm -> @b:AmlTerm -> @rem:AmlTerm -> @quo:AmlTerm -> AmlTerm
Divide(dividend, divisor, remainder target, quotient target)
def AmlT.mod source · line 344 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.shift_left source · line 347 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.shift_right source · line 350 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.and source · line 353 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.nand source · line 356 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.or source · line 359 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.nor source · line 362 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.xor source · line 365 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.not source · line 368 · raw
@a:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.find_set_left_bit source · line 371 · raw
@a:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.find_set_right_bit source · line 374 · raw
@a:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.increment source · line 377 · raw
@t:AmlTerm -> AmlTerm
def AmlT.decrement source · line 380 · raw
@t:AmlTerm -> AmlTerm
def AmlT.concat source · line 383 · raw
@a:AmlTerm -> @b:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.land source · line 386 · raw
@a:AmlTerm -> @b:AmlTerm -> AmlTerm
def AmlT.lor source · line 389 · raw
@a:AmlTerm -> @b:AmlTerm -> AmlTerm
def AmlT.lnot source · line 392 · raw
@a:AmlTerm -> AmlTerm
def AmlT.lequal source · line 395 · raw
@a:AmlTerm -> @b:AmlTerm -> AmlTerm
def AmlT.lgreater source · line 398 · raw
@a:AmlTerm -> @b:AmlTerm -> AmlTerm
def AmlT.lless source · line 401 · raw
@a:AmlTerm -> @b:AmlTerm -> AmlTerm
def AmlT.lnot_equal source · line 405 · raw
@a:AmlTerm -> @b:AmlTerm -> AmlTerm
LNotEqual, LLessEqual, LGreaterEqual: LNot of LEqual, LGreater, LLess
def AmlT.lless_equal source · line 408 · raw
@a:AmlTerm -> @b:AmlTerm -> AmlTerm
def AmlT.lgreater_equal source · line 411 · raw
@a:AmlTerm -> @b:AmlTerm -> AmlTerm
def AmlT.ref_of source · line 416 · raw
@a:AmlTerm -> AmlTerm
def AmlT.deref_of source · line 419 · raw
@a:AmlTerm -> AmlTerm
def AmlT.index source · line 422 · raw
@a:AmlTerm -> @i:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.cond_ref_of source · line 425 · raw
@a:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.size_of source · line 428 · raw
@a:AmlTerm -> AmlTerm
def AmlT.object_type source · line 431 · raw
@a:AmlTerm -> AmlTerm
def AmlT.to_integer source · line 436 · raw
@a:AmlTerm -> @t:AmlTerm -> AmlTerm
def AmlT.to_buffer source · line 439 · raw
@a:AmlTerm -> @t:AmlTerm -> AmlTerm