The compiler will use the following template for compiling expressions
that involve comparisons:
00 push op1
01 push op2
02 je/jg/jl true_label
03 push_0
04 jmp done_label
05 true_label:
06 push_1
07 done_label:
The jmp instruction type used for L02 depends on the AML opcode that is
compiled. To conserve space, the ACPI spec only defines opcodes for the
following comparison operations: equal, less, greater. All other
comparisons are constructed by combining one of the above opcodes with a
logical not opcode (e.g. greaterOrEqual = !(less)).
The VM opcode exploits the fact the comparison expressions always push a
0/1 value on the stack and uses bitwise operations to emulate some
additional logic opcodes:
- logic not: 0/1 (on stack) XOR 1
- logic and: 0/1 (left expr on stack) AND 0/1 (right expr on stack)
- logic or : 0/1 (left expr on stack) OR 0/1 (right expr on stack)
This commit includes the required code to process all methods defined by
an AML entity hierarchy and invoke a function for converting each method
statement into a sequence of opcodes that can be executed by our
internal VM.
The mapping of the AML opcodes to the VM opcodes is facilitated via the
opcodeMap which allows us to apply a particular compiler function when
converting each AML opcode. Currently, this map is empty so all AML
opcodes are mapped to "nop" instructions.
This commit moves the AML entity definitions into the entity package and
makes them exportable so we can reference them from other packages.
In addition, the commit adds some missing entity structs that were
previously treated as generic entities (e.g. Processor, PowerResource
and ThermalZone).
Finally, this commit cleans the definitions and adds missing struct
attributes for the various field types (Field, IndexField, BankField)
This commit updates the post-parse step so that:
- the visitor not longer recurses into method bodies. Since code inside
methods may potentially generate dynamic/scoped entities or even use
conditional invocations (if CondRefOf(X) { X(...) }), symbol resolution
will be deferred to the AML interpreter.
- parent-child relationships between entities are checked and updated if
not properly specified
Since the ACPI standard allows forward function declarations this step
is required so we can properly parse the argument list for function
invocations. Contrary to other AML entities, method invocations do not
include any sort of pkgLength information so unless we track the
expected argument count for each function, our parser will not be able
to figure out where the argument list ends.
vmm.IdentityMapRegion can be used by device drivers that want to
establish an identity mapping for a contiguous physical memory block in
order to access some hardware or table.
The hal package automatically selects the best font from the list of
available fonts based on the console dimensions and the font priorities. The font
selection can be overriden by passing the "consoleFont" boot commandline
parameter to the kernel (e.g. consoleFont=terminus8x16)