aml(2): tabelize by function, move hardware linkage on separate page

This commit is contained in:
cinap_lenrek 2013-11-10 18:58:00 +01:00
parent e14e6dfdbe
commit eb060fbfb1

View file

@ -33,7 +33,8 @@ int amldebug;
.SH DESCRIPTION .SH DESCRIPTION
The aml library implements an interpreter for the ACPI machine language The aml library implements an interpreter for the ACPI machine language
byte code. byte code.
.PP .TP
\f5amlinit() \f5amlexit()
The interpreter runtime state is initialized by calling The interpreter runtime state is initialized by calling
.I amlinit .I amlinit
and frees all the resources when and frees all the resources when
@ -43,14 +44,16 @@ The runtime state consists of objects organized in a global
namespace. The name object referred to by namespace. The name object referred to by
.I amlroot .I amlroot
is the root of that namespace. is the root of that namespace.
.PP .TP
.BI amlload( data , len )
.I Amlload .I Amlload
populates the namespace with objects parsed from the populates the namespace with objects parsed from the
definition block of definition block of
.I len .I len
byte size read from byte size read from
.IR data . .IR data .
.PP .TP
.BI amltag( p )
Objects are dynamically allocated and typed and are passed as Objects are dynamically allocated and typed and are passed as
.B void* .B void*
pointers. The type tag of an object can be determined with the pointers. The type tag of an object can be determined with the
@ -71,20 +74,18 @@ underlying type:
* R void* reference * R void* reference
*/ */
.EE .EE
.PP .TP
Name objects (like .BI amlwalk( dot , name )
.IR amlroot ) .I Amlwalk
can be traversed with the takes a path string (relative to
.I amlenum .IR dot )
and in
.I amlwalk .I name
functions. The
.I amlwalk
function
takes a path string (relative or absolute)
and returns the final name object of the walk; or and returns the final name object of the walk; or
.B nil .B nil
if not found. if not found.
.TP
\f5amlenum(\fIdot\f5,\fIseg\f5,\fIproc\f5,\fIarg\f5)
.I Amlenum .I Amlenum
recursively enumerates all child name objects of recursively enumerates all child name objects of
.I dot .I dot
@ -102,25 +103,29 @@ When
.I proc .I proc
returns zero, enumeration will continue recursively down returns zero, enumeration will continue recursively down
for the current dot. for the current dot.
.PP .TP
.BI amlval( p )
.I Amlval .I Amlval
returns the value of a name, reference or field object. returns the value of a name, reference or field object.
Calling Calling
.I amlval .I amlval
on any other object yields the same object. on any other object yields the same object.
.PP .TP
.BI amllen( p )
.I Amllen .I Amllen
is defined for variable length objects like buffers, strings and packages. is defined for variable length objects like buffers, strings and packages.
For strings, the number of characters (not including the terminating null byte) For strings, the number of characters (not including the terminating null byte)
is returned. For buffers, the size of the buffer in bytes is returned. is returned. For buffers, the size of the buffer in bytes is returned.
For packages (arrays), the number of elements is returned. For any other For packages (arrays), the number of elements is returned. For any other
object types, the return value is undefined. object types, the return value is undefined.
.PP .TP
.BI amlint( p )
.I Amlint .I Amlint
returns the integer value of an object. For strings, the string is interpreted returns the integer value of an object. For strings, the string is interpreted
as an hexadecimal number. For buffers and buffer fields, the binary value is returned. as an hexadecimal number. For buffers and buffer fields, the binary value is returned.
Integers just return their value. Any other object types yield zero. Integers just return their value. Any other object types yield zero.
.PP .TP
.BI amlnew( tag , len )
Integer, buffer, string and package objects can be created with the Integer, buffer, string and package objects can be created with the
.I amlnew .I amlnew
function. The function. The
@ -130,7 +135,8 @@ specific definition of the
parameter is the same as in parameter is the same as in
.I amllen .I amllen
(see above). (see above).
.PP .TP
\f5amleval(\fIdot\f5,\fIfmt\f5,\fI...\f5)
.I Amleval .I Amleval
evaluates the name object evaluates the name object
.IR dot . .IR dot .
@ -168,7 +174,8 @@ The last variable argument is a pointer to the result
object location. When the last parameter is object location. When the last parameter is
.B nil .B nil
the result is discarded. the result is discarded.
.PP .TP
\f5amltake(\fIp\f5) \f5amldrop(\fIp\f5)
Objects returned by Objects returned by
.IR amlval , .IR amlval ,
.I amleval .I amleval
@ -182,45 +189,28 @@ To remark an object for collection,
needs be called. needs be called.
Objects stay valid as long as they are reachable from Objects stay valid as long as they are reachable from
.IR amlroot . .IR amlroot .
.PP .bp
.EX
extern void* amlalloc(int);
extern void amlfree(void*);
.EE
.PP
.I Amlalloc
and
.I amlfree
can be optionally defined to control dynamic memory allocation
providing a way to limit or pool the memory allocated by acpi.
If not provided, the library will use the functions
defined in
.IR malloc (2)
for dynamic allocation.
.PP .PP
The aml library can be linked into userspace programs and The aml library can be linked into userspace programs and
and the kernel which have different means of hardware access. and the kernel which have different means of hardware access
and memory constraints.
.PP .PP
.EX The
extern void amldelay(int);
.EE
.PP
.I Amldelay
is called by the interpreter with the number of microseconds it
needs to wait.
.PP
.EX
extern int amlmapio(Amlio *io);
extern void amlunmapio(Amlio *io);
.EE
.PP
The interpreter calls
.I amlmapio
with a
.I Amlio .I Amlio
data structure that needs be filled out. data structure defines access to a hardware space.
.PP
.EX .EX
enum {
MemSpace = 0x00,
IoSpace = 0x01,
PcicfgSpace = 0x02,
EbctlSpace = 0x03,
SmbusSpace = 0x04,
CmosSpace = 0x05,
PcibarSpace = 0x06,
IpmiSpace = 0x07,
};
typedef struct Amlio Amlio; typedef struct Amlio Amlio;
struct Amlio struct Amlio
{ {
@ -234,8 +224,8 @@ struct Amlio
int (*read)(Amlio *io, void *data, int len, int off); int (*read)(Amlio *io, void *data, int len, int off);
int (*write)(Amlio *io, void *data, int len, int off); int (*write)(Amlio *io, void *data, int len, int off);
}; };
.EE .EE
.PP
The The
members members
.IR space , .IR space ,
@ -260,19 +250,31 @@ pointer can be used freely by the map function to attach its own
resources to the I/O region and allows it to free these resources resources to the I/O region and allows it to free these resources
on on
.IR amlunmapio . .IR amlunmapio .
.PP .TP
The following region types are defined by ACPI: \f5amlmapio(\fIio\f5) \f5amlunmapio(\fIio\f5)
.EX The interpreter calls
enum { .I amlmapio
MemSpace = 0x00, with a
IoSpace = 0x01, .I Amlio
PcicfgSpace = 0x02, data structure that is to be filled out. When finished, the
EbctlSpace = 0x03, interpreter calls
SmbusSpace = 0x04, .I amlunmapio
CmosSpace = 0x05, with the same data structure to allow freeing resources.
PcibarSpace = 0x06, .TP
IpmiSpace = 0x07, .BI amldelay( µs )
}; .I Amldelay
.EE is called by the interpreter with the number of microseconds
to sleep.
.TP
\f5amlalloc(\fIn\f5) \f5amlfree(\fIp\f5)
.I Amlalloc
and
.I amlfree
can be optionally defined to control dynamic memory allocation
providing a way to limit or pool the memory allocated by acpi.
If not provided, the library will use the functions
defined in
.IR malloc (2)
for dynamic allocation.
.SH SOURCE .SH SOURCE
.B /sys/src/libaml .B /sys/src/libaml