amlalloc, amldrop, amlenum, amleval, amlexit, amlfree, amlinit, amlint, amllen, amlload, amlmapio, amlmicrodelay, amlnew, amltag, amltake, amlunmapio, amlval, amlwalk – ACPI interprter


#include <u.h>
#include <aml.h>
enum {
MemSpace    = 0,
IoSpace          = 1,
PcicfgSpace      = 2,
EbctlSpace       = 3,
SmbusSpace       = 4,
CmosSpace = 5,
PcibarSpace      = 6,
IpmiSpace = 7,
typedef struct Amlio Amlio;
struct Amlio {
int    space;
uvlong      off;
uvlong      len;
void*       name;
uchar*      a;
void *aux;
int    (*read)(Amlio *io, void *data, int len, int off);
int    (*write)(Amlio *io, void *data, int len, int off);
int       amltag(void *p)
void*     amlval(void *p)
uvlong    amlint(void *p)
int       amllen(void *p)
void      amlnew(char type, int size)
void      amltake(void *p)
void      amldrop(void *p)
void      amlinit(void)
void      amlexit(void)
int       amlload(uchar *data, int len)
void*     amlwalk(void *dot, char *name)
int       amleval(void *dot, char *fmt, ...)
void      amlenum(void *dot, char *seg,
int (*proc)(void *, void *), void *arg)
void*     amlalloc(usize)
void      amlfree(void*)
void      amlmicrodelay(int µs)
int       amlmapio(Amlio *io)
void      amlunmapio(Amlio *io)


Aml implements an interpreter for the ACPI Machine Language. ACPI is supposed to supplant older configuration and power management methods such as MP tables and APM. AML is used by 386 and AMD64 platform BIOS for things that are not part of the ACPI fixed description tables, such as interrupts. The aml interpreter usually runs in the kernel at boot time to parse interrupts, and other non–fixed configuration.
Aml provides access to the following AML object types.
L         L     L    –         –     –    LFB       L     L.    tag        type name    b         uchar*     buffer    s         char* string    n         char* undefined    name    i         uvlong*     integer    p         void**      package    r         void* region    f         void* field u         void* bufferfield N         void* name R         void* reference
amlload(data, len)
Start the interperter with the given AML code. For userspace, the kernel provides #P/acpitbls.
Terminate the interperter and free its resources
Provided by the caller. Allocate and clear nbytes.
Provided by the caller. Free memory allocated with amlalloc.
Return the “tag” of the given AML object.
Evaluate one level of indirection on AML object p.
Return the value of the integer pointed to by p. P may have tag i or s. Objects of tag s are converted with strtoull (see atof(2)).
Return the number of elements in p.
amlnew(type, size)
Create a new aml object of the given size and type.
Exclude object from garbage collection.
Include previously excluded object in garbage collection.
amlwalk(dot, name)
Walk the aml heirarchy to name from the current position, dot.
amleval(dot, name)
Evaluate the method name from the corrent position, IR dot.
amlenum(dot, seg, procfn, arg)
Call function procfn(arg) for each matching object under dot.
Delay for the given number of microseconds.
Map the given region, and set function pointers for reading and writing.
Discard the previously mapped region.



A 32–bit little–endian machine is assumed.