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 SerialBus buf as BUFF<br />

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

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

CreateWordField(BUFF, 0x03, DATW) // DATW = Data (Word - Bytes 2 & 3, or 16 bits)<br />

CreateField(BUFF, 16, 256, DBUF) // DBUF = Data (Bytes 2-33)<br />

CreateField(BUFF, 16, 32, DATD) // DATD = Data (DWord)<br />

// Read block of data from the device using comm<strong>and</strong> value 0<br />

Store(TFK1, BUFF)<br />

If(LNotEqual(STAT, 0x00)) {<br />

Return(0)<br />

}<br />

// Read block of data from the device using comm<strong>and</strong> value 1<br />

Store(TFK2, BUFF)<br />

If(LNotEqual(STAT, 0x00)) {<br />

Return(0)<br />

}<br />

In this example, two field elements (TFK1, <strong>and</strong> TFK2) are defined to represent the virtual registers<br />

for comm<strong>and</strong> values 0 <strong>and</strong> 1. Access to any of the field elements will cause a GenericSerialBus<br />

transaction to occur to the device.<br />

Writing blocks of data requires similar semantics, such as in the following example.<br />

Store(16, LEN) // In bits, so 4 bytes<br />

Store(Store(BUFF, TFK1), BUFF) // Invoke Write Block transaction<br />

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

// Transaction successful?<br />

This accessor is not viable for some SPBs because the bus may not support the appropriate<br />

functionality. In cases that variable length buffers are desired but the bus does not support block<br />

accessors, refer to the SerialBytes protocol.<br />

5.5.2.4.5.3.6 Word Process Call (AttribProcessCall)<br />

The GenericSerialBus Process Call protocol (AttribProcessCall) transfers 2 bytes of data bidirectionally<br />

(performs a Write Word followed by a Read Word as an atomic transaction). This<br />

protocol uses a comm<strong>and</strong> value to reference up to 256 word-sized virtual registers.<br />

The following ASL code illustrates how a device supporting the Process Call protocol should be<br />

accessed:<br />

OperationRegion(TOP1, GenericSerialBus, 0x00, 0x100) // GenericSerialBus device at slave address<br />

0x42<br />

Field(TOP1, BufferAcc, NoLock, Preserve)<br />

{<br />

}<br />

Connection(I2CSerialBus(0x5a,,100000,,"\_SB.I2C",,,,RawDataBuffer(){1,6}))<br />

AccessAs(BufferAcc, AttribProcessCall) // Use the GenericSerialBus Process Call protocol<br />

FLD0, 8, // Virtual register at comm<strong>and</strong> value 0.<br />

FLD1, 8, // Virtual register at comm<strong>and</strong> value 1.<br />

FLD2, 8 // Virtual register at comm<strong>and</strong> value 2.<br />

// Create the GenericSerialBus data buffer<br />

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

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

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

CreateWordField(BUFF, 0x02, DATA) // DATA = Data (Word)<br />

Version 6.0 237

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

Saved successfully!

Ooh no, something went wrong!