27.10.2015 Views

Advanced Configuration and Power Interface Specification

ACPI_6.0

ACPI_6.0

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ACPI Software Programming Model<br />

/* Create the GenericSerialBus data buffer */<br />

Name(BUFF, Buffer(34){})<br />

// Create GenericSerialBus data buffer as BUFF<br />

CreateByteField(BUFF, 0x00, STAT) // STAT = Status (Byte)<br />

CreateByteField(BUFF, 0x01, LEN) // LEN = Length (Byte)<br />

CreateWordField(BUFF, 0x02, DATW) // DATW = Data (Word – Bytes 2 & 3)<br />

CreateField(BUFF, 0x10, 256, DBUF) // DBUF = Data (Block – Bytes 2-33)<br />

/* Read the battery temperature */<br />

Store(BTMP, BUFF)<br />

If(LEqual(STAT, 0x00))<br />

{<br />

}<br />

// Invoke Read Word transaction<br />

// Successful?<br />

// DATW = Battery temperature in 1/10 th degrees Kelvin<br />

/* Read the battery manufacturer name */<br />

Store(MFGN, BUFF)<br />

// Invoke Read Blocktransaction<br />

If(LEqual(STAT, 0x00))<br />

// Successful?<br />

{<br />

// LEN = Length of the manufacturer name<br />

// DBUF = Manufacturer name (as a counted string)<br />

}<br />

Notice the use of the CreateField primitives to access the data buffer’s sub-elements (Status,<br />

Length, <strong>and</strong> Data), where Data (bytes 2-33) is ‘typecast’ as both word (DATW) <strong>and</strong> block (DBUF)<br />

data.<br />

The example above demonstrates the use of the Store() operator to invoke a Read Block transaction<br />

to obtain the name of the battery manufacturer. Evaluation of the source oper<strong>and</strong> (MFGN) results in<br />

a 34-byte buffer that gets copied by Store() to the destination buffer (BUFF).<br />

Capturing the results of a write operation, for example to check the status code, requires an<br />

additional Store() operator, as shown below.<br />

Store(Store(BUFF, MFGN), BUFF)<br />

If(LEqual(STAT, 0x00)) {…}<br />

// Invoke Write Block transaction<br />

// Transaction successful?<br />

Note that the outer Store() copies the results of the Write Block transaction back into BUFF. This is<br />

the nature of BufferAcc’s bi-directionality. It should be noted that storing (or parsing) the result of a<br />

GenericSerialBus Write transaction is not required although useful for ascertaining the outcome of a<br />

transaction.<br />

GenericSerialBus Process Call protocols require similar semantics due to the fact that only<br />

destination oper<strong>and</strong>s are passed bi-directionally. These transactions require the use of the double-<br />

Store() semantics to properly capture the return results.<br />

5.5.2.4.5.3 Using the GenericSerialBus Protocols<br />

This section provides information <strong>and</strong> examples on how each of the GenericSerialBus protocols can<br />

be used to access GenericSerialBus devices from AML.<br />

5.5.2.4.5.3.1 Read/Write Quick (AttribQuick)<br />

The GenericSerialBus Read/Write Quick protocol (AttribQuick) is typically used to control simple<br />

devices using a device-specific binary comm<strong>and</strong> (for example, ON <strong>and</strong> OFF). Comm<strong>and</strong> values are<br />

not used by this protocol <strong>and</strong> thus only a single element (at offset 0) can be specified in the field<br />

definition. This protocol transfers no data.<br />

Version 6.0 233

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!