主要讲讲OSPM用来配置设备的对象(objects),一般有三种对象:
1. 设备识别对象,将平台设备与PnP ID 关联
2. 设备配置对象,用来声明配置硬件资源和特性
3. 设备插入和移除对象,来提供动态插入或者移除设备的机制
一.设备识别对象
Object | Description |
_ADR | Object that evaluates to a device’s address on its parent bus. |
_CID | Object that evaluates to a device’s Plug and Play-compatible ID list. |
_CLS | Object that evaluates to a package of coded device-class information. |
_DDN | Object that associates a logical software name (for example, COM1) with a device. |
_HID | Object that evaluates to a device’s Plug and Play hardware ID. |
_HRV | Object that evaluates to an integer hardware revision number. |
_MLS | Object that provides a human readable description of a device in multiple languages. |
_PLD | Object that provides physical location description information. |
_SUB | Object that evaluates to a device’s Plug and Play subsystem ID. |
_SUN | Object that evaluates to the slot-unique ID number for a slot. |
_STR | Object that contains a Unicode identifier for a device. Can also be used for thermal zones. |
_UID | Object that specifies a device’s unique persistent ID, or a control method that generates it. |
常用的一般如下,他们一般用name来执行,有的也可以用method实现
_ADR: 赋值设备在其父线上的地址。 Name(_ADR,0x00140000)
_DDN: 关联一个设备的逻辑软件名称,如串口的COM1/COM2。 Name (_DDN, "COM1")
_HID: 赋值一个设备的PnP ID。 Name(_HID, EISAID("PNP0501"))
_PLD: 提供物理位置的描述信息,如USB port。 Method(_PLD) { Return (GPLD(0,11)) }
_UID: 陈述一个设备的唯一ID,或者用method产生一个唯一ID。Name(_UID, 1)
_CLS: 赋值设备PCI定义的class、subclass code
Name(_CLS, Package (3)
{
0x01, // Base Class (01h == Mass Storage)
0x06, // Sub-Class (06h == SATA)
0x01, // Programming Interface (01h == AHCI)
})
二. 设备配置对象
在ACPI 枚举设备时,OSPM可以用设备配置对象来配置硬件资源,它们可以用name提供当下或者可能的资源需求信息,也能用method来配置信息。
_CCA | Cache Coherency Attribute – specifies whether a device and its descendants support hardware managed cache coherency. |
_CDM | Object that specifies a clock domain for a processor. |
_CRS | Object that specifies a device’s current resource settings, or a control method that generates such an object. |
_DIS | Control method that disables a device. |
_DMA | Object that specifies a device’s current resources for DMA transactions. |
_DSD | Object that evaluates to device specific information |
_FIX | Object used to provide correlation between the fixed-hardware register blocks defined in the FADT and the devices that implement these fixed-hardware registers. |
_GSB | Object that provides the Global System Interrupt Base for a hot-plugged I/O APIC device. |
_HMA | Object that provides updated HMAT structures. |
_HPP | Object that specifies the cache-line size, latency timer, SERR enable, and PERR enable values to be used when configuring a PCI device inserted into a hot-plug slot or initial configuration of a PCI device at system boot. |
_HPX | Object that provides device parameters when configuring a PCI device inserted into a hot-plug slot or initial configuration of a PCI device at system boot. Supersedes _HPP. |
_MAT | Object that evaluates to a buffer of Interrupt Controller Structures. |
_OSC | An object OSPM evaluates to convey specific software support / capabilities to the platform al lowing the platform to configure itself appropriately. |
_PRS | An object that specifies a device’s possible resource settings, or a control method that generates such an object. |
_PRT | Object that specifies the PCI interrupt routing table. |
_PXM | Object that specifies a proximity domain for a device. |
_SLI | Object that provides updated distance information for a system locality. |
_SRS | Control method that sets a device’s setting |
常用的几个如下:
_CRS: 描述当下分配到设备的系统资源,其数据为一串字节流,格式要满足Resource Data Types for ACPI (参见ACPI 6.4)
Name(_CRS, ResourceTemplate()
{
IO(Decode16, 0x20, 0x20, 0, 0x2)
IO(Decode16, 0xA0, 0xA0, 0, 0x2) IRQ(Edge, ActiveHigh, Exclusive ){2}
IRQNoFlags(){2}
})
或者用method 方法:
Method(_CRS,0, Serialized)
{
Name(BFFR, ResourceTemplate()
{
IO(Decode16,0x62,0x62,0,1) // DIN/DOUT
IO(Decode16,0x66,0x66,0,1) // CMD/STS
})
Return(BFFR)
}
_DIS: 采用method禁用设备,当禁用后,设备不会decode任何硬件资源,有时候系统里右键点击设备,可以看到禁用设备就是调用此对象;同时,method_STA bit1 需要清掉。
Method(_DIS, 0) {^^SIO1.DCNT(0, 0)}
_PRS: 用一连串字节流来描述设备可能用到的资源,其格式同_CRS Name(_PRS, ResourceTemplate(){
StartDependentFn(0, 0) {
IRQNoFlags(){12}
}
EndDependentFn()
})
_SRS:采用method 来修改设备资源
三. 设备插入和移除对象
Object | Description |
_EDL | Object that evaluates to a package of namespace references of device objects that depend on the device containing _EDL. |
_EJD | Object that evaluates to the name of a device object on which a device depends. Whenever the named device is ejected, the dependent device must receive an ejection notification. |
_EJx | Control method that ejects a device. |
_LCK | Control method that locks or unlocks a device. |
_OST | Control method invoked by OSPM to convey processing status to the platform. |
_RMV | Object that indicates that the given device is removable. |
_STA | Control method that returns a device’s status. |
最常用的就是_STA,来返回设备状态:enabled, disabled, or removed,返回值定义如下:
• Bit [0] - Set if the device is present.
• Bit [1] - Set if the device is enabled and decoding its resources.
• Bit [2] - Set if the device should be shown in the UI.
• Bit [3] - Set if the device is functioning properly (cleared if device failed its diagnostics).
• Bit [4] - Set if the battery is present.
• Bits [31:5] - Reserved (must be cleared)