5.5.2.4.5. 声明 GeneralPurposeIO 操作区域
对于 GeneralPurposeIO 操作区域,OperationRegion 术语的语法(来自 OperationRegion(声明操作区域) 节)如下所述:
OperationRegion (
RegionName, // NameString
RegionSpace, // RegionSpaceKeyword
Offset, // TermArg=>Integer
Length // TermArg=>Integer
)
其中:
RegionName 指定此 GeneralPurposeIO 区域的名称(例如“GPI1”)。
RegionSpace 必须设置为 GeneralPurposeIO(操作区域类型值 0x08)。
GeneralPurposeIO RegionSpace 的偏移量被忽略。
长度是操作区域中包含的GPIOIO引脚的最大数量,四舍五入到下一个字节。
GeneralPurposeIO OpRegions 必须在正在访问的GPIO控制器设备的范围内声明。
5.5.2.4.5.1. 声明 GeneralPurposeIO 字段
与其他区域一样,GeneralPurposeIO 操作区域只能通过 Field 术语访问。每个字段元素表示 OpRegion 声明中声明的长度位的子集。 OpRegion 内通过给定字段名称访问的引脚由连接描述符定义。连接描述符后面定义的字段位总数必须等于描述符中列出的引脚数。
字段术语的语法(来自 Field(声明字段对象))如下所述:
Field(
RegionName, // NameString=>OperationRegion
AccessType, // AccessTypeKeyword
LockRule, // LockRuleKeyword
UpdateRule // UpdateRuleKeyword - ignored
) {FieldUnitList}
其中:
RegionName 指定先前声明的操作区域名称。
AccessType 必须设置为 ByteAcc。
LockRule 指示访问该操作区域是否需要获取全局锁以进行同步。请注意,在 HW 缩减版 ACPI 平台上,该字段必须设置为 NoLock。
UpdateRule 不适用于 GeneralPurposeIO 操作区域,因为始终需要 Preserve。所有 GeneralPurposeIO 字段定义都会忽略此字段。
以下ASL代码显示了OperationRegion、Field 和Offset 术语在GeneralPurposeIO 空间中的使用。
Device(DEVA) //An Arbitrary Device Scope
{
// Other required stuff for this device
Name (GMOD, ResourceTemplate ()
//An existing GPIO Connection (to be used later)
{
//2 Outputs that define the Power mode of the device
GpioIo (Exclusive, PullDown, , , , "\\_SB.GPI2") {10, 12}
})
} //End DEVA
Device (GPI2) //The OpRegion declaration, and the \_REG method,
//must be in the controller's namespace scope
{
//Other required stuff for the GPIO controller
OperationRegion(GPO2, GeneralPurposeIO, 0, 1)
// Note: length of 1 means region is less than 1 byte (8 pins) long
Method(_REG,2)
{
// Track availability of GeneralPurposeIO space
}
}
Device (DEVB) //Access some GPIO Pins from this device scope
//to change the device's power mode
{
//.. Other required stuff for this device
Name(_DEP, Package() {"\\_SB.GPI2"}) //OpRegion Dependency hint for OSPM
Field(\_SB.GPI2.GPO2, ByteAcc, NoLock, Preserve)
{
Connection (GMOD), // Re-Use an existing connection (defined elsewhere)
MODE, 2, // Power Mode
Connection (GpioIo(Exclusive, PullUp, , , , "\\_SB.GPI2") {7}),
STAT, 1, // e.g. Status signal from the device
Connection (GpioIo (Exclusive, PullUp, , , , "\\_SB.GPI2") {9}),
RSET, 1 // e.g. Reset signal to the device
}
Method(_PS3)
{
If (1) // Make sure GeneralPurposeIO OpRegion is available
{
MODE = 0x03 //Set both MODE bits. Power Mode 3
}
}
} //End DEVB