KPciConfiguration, KPciSlot类:
一、Overview
KPciSlot类和KPciConfiguration类用于在驱动开发过程中协助支持基于PCI总线的设备。KDevice的派生类可以包含KPciConfiguration类的一个实例来存取设备配置空间的内容。为了满足这些需要,驱动编写人员需要提供PCI vendor ID和device ID给它的构造函数。这个类使用系统服务来确定设备所在的总线序号和插槽序号。KPciConfiguration的成员函数可以使驱动程序完成读写PCI配置空间中各个域的读写。
KPciSlot类是KPciConfiguration类的一个基类,并且不被用于其他的地方。它的大多数成员函数对于WDM都是禁用的。然而,这个类的实例是KPciConfiguration::Enumerate()的一个参数。这个类的目的是要封装一个特别的PCI设备驻留在系统中的位置的信息。特别的,它为一个PCI设备保存总线序号,插槽序号和功能序号。KPciSlot类中的成员函数有助于列举系统中所有的PCI设备。
二、Member Functions of KPciConfiguration
1、KPciConfiguration - Constructor (4 forms)构造函数四种形式
2、Initialize - Initialization when default constructor used当用默认的不带参数的构造函数时,这个函数完成初始化任务
3、Invalidate - Removes the object from an initialized state从一个初始化了的状态删除对象资源
4、IsValid - Test if the object is initialized测试这个对象是否已经初始化成功
5、ReadHeader - Read PCI configuration header读PCI配置空间的头信息
6、WriteHeader - Write PCI configuration header写PCI配置空间的头信息
7、ReadDeviceSpecificConfig - Read device specific area of PCI configuration space读PCI配置空间中关于设备的具体区域
8、WriteDeviceSpecificConfig - Write device specific area of PCI configuration space写PCI配置空间中关于设备的具体区域
9、ReadCommandRegister - Read the PCI command register读PCI命令寄存器
10、WriteCommandRegister - Write the PCI command register写PCI命令寄存器
11、Control - Access the PCI control register读写PCI的控制寄存器
12、ReadStatusRegister - Read the PCI status register读PCI的状态寄存器
13、ReadBaseAddress - Read one of the base address registers from the PCI configuration space (two forms)从PCI配置空间中读一个基地址寄存器(两种形式)
14、WriteBaseAddress - Write one of the base address registers in the PCI configuration space (two forms)从PCI配置空间中写一个基地址寄存器(两种形式)
15、ReadInterrupt - Read the interrupt register读中断寄存器
16、WriteInterrupt - Write the interrupt register写中断寄存器
17、Enumerate - Static member to enumerate all PCI devices静态函数,用于列举所有PCI设备。
三、Member Functions of KPciSlot
1、KPciSlot - Constructor构造函数
2、Initialize - Initialize the object初始化对象的函数
3、Invalidate - Removes the object from an initialized state从一个初始化了的状态删除对象
4、Slot - Accessor to retrieve the slot vector获取插槽向量
5、Bus - Accessor to retrieve the bus number获取总线序号
6、Device - Accessor to retrieve the device number获取设备序号
7、Function - Accessor to retrieve the function number获取功能序号
8、Increment - Advance to the next function前进到下一个功能
9、IncrementDevice - Advance to the next device前进到下一个设备
10、MarkInvalid - Mark the object as invalid把对象标记为不合法
11、IsValid - Test the validity of the object测试对象的合法性
四、Example
这段示例代码显示了KPciConfiguration对象在KDevice派生类中的典型用法:
class SuperFastCard : public KDevice
{
public:
SuperFastCard(void);
protected:
KPciConfiguration m_Config;
};
SuperFastCard::SuperFastCard(void) :
KDevice(L"SuperFastCard", FILE_DEVICE_UNKNOWN),
m_Config(SFC_VENDOR_ID, SFC_DEVICE_ID)
{
if (! m_Config.IsValid() )
{
m_ConstructorStatus = STATUS_UNSUCCESSFUL;
return;
}
else
{
basePhysAddress = m_Config.ReadBaseAddress(0);
. . .
}
. . .
}
----------------
§ 译自"DriverWorks帮助文件" §
§ 李文凯 2008年03月28日 §
----------------