27.10.2015 Views

Advanced Configuration and Power Interface Specification

ACPI_6.0

ACPI_6.0

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ACPI Software Programming Model<br />

The following ASL code illustrates how a device supporting the Read/Write N Bytes protocol<br />

should be accessed:<br />

OperationRegion(TOP1, GenericSerialBus, 0x00, 0x100)<br />

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

{<br />

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

Offset(0x0),<br />

AccessAs(BufferAcc, AttribBytes (4)),<br />

TFK1, 8, //TFK1 at comm<strong>and</strong> value 0<br />

TFK2, 8, //TFK2 at comm<strong>and</strong> value 1<br />

Connection(I2CSerialBus(0x5b,,100000,,"\_SB.I2C",,,,RawDataBuffer(){2,9}))<br />

// same connection attribute, but different vendor data passed to driver<br />

AccessAs(BufferAcc, AttribByte)<br />

TM1, 8 //TM1 at comm<strong>and</strong> value 2<br />

}<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, 0x02, DATW) // DATW = Data (Word - Bytes 2 & 3, or 16 bits)<br />

CreateField(BUFF, 16, 256, DBUF) // DBUF = Data (Bytes 2-34)<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 />

// Write block of data to the device using comm<strong>and</strong> value 1<br />

Store(Store(BUFF,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 of the length specified in the AccessAttributes.<br />

5.5.2.4.5.3.9 Raw Read/Write N Bytes (AttribRawBytes)<br />

The GenericSerialBus Raw Read/Write N Bytes protocol (AttribRawBytes) transfers variable-sized<br />

data. The actual number of bytes to read or write is specified as part of the AccessAs attribute. The<br />

initial comm<strong>and</strong> value specified in the operation region definition is ignored by Raw accesses.<br />

The following ASL code illustrates how a device supporting the Read/Write N Bytes protocol<br />

should be accessed:<br />

Version 6.0 239

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

Saved successfully!

Ooh no, something went wrong!