📄 pciconfig.cpp
字号:
// PCIConfig.h: interface for the PCIConfig class.
// PCI配置空间读取1.0本代码由桃源村编写 2004.6.12
// 功能:读取查询PCI配置寄存器只适合X86体系下的win98/nt/2000/xp
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "PCIConfig.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
PCIConfig::PCIConfig()
{
}
PCIConfig::~PCIConfig()
{
}
UINT PCIConfig::GetPCIConfig(DWORD VendorID, DWORD DeviceID)
{
DWORD DeviceVendor=(DeviceID<<16)+VendorID;
DWORD INPCIC=0;
DWORD PCIbuf[16];
memset(PCIbuf,0,64);
DWORD * pPCIbufpos=PCIbuf;
DWORD PCIConfBaseAddr=0x80000000;
UINT i=0;
for(;;)
{
SetPortVal(0xcf8,PCIConfBaseAddr,4);
GetPortVal(0xcfc,&INPCIC,4);
if(INPCIC==DeviceVendor)
{
pPCIbufpos=PCIbuf;
for(i=0;i<16;i++,pPCIbufpos++)
{
SetPortVal(0xcf8,PCIConfBaseAddr+4*i,4);
GetPortVal(0xcfc,pPCIbufpos,4);
}
PCIConf.VendorID=PCIbuf[0]&0xffff;
PCIConf.DeviceID=((PCIbuf[0]&0x0000ffff)>>16);
PCIConf.Command=PCIbuf[1]&0xffff;
PCIConf.Status=((PCIbuf[1]&0x0000ffff)>>16);
PCIConf.RevisionID=PCIbuf[2]&0xff;
PCIConf.ClassCode=((PCIbuf[2]&0xffffff00)>>8);
PCIConf.CacheLineSize=PCIbuf[3]&0xff;
PCIConf.LatencyTimer=((PCIbuf[3]&0xff00)>>8);
PCIConf.HeaderType=((PCIbuf[3]&0xff0000)>>16);
PCIConf.BIST=((PCIbuf[3]&0xff000000)>>24);
PCIConf.BaseAddressRegister[0]=PCIbuf[4];
PCIConf.BaseAddressRegister[1]=PCIbuf[5];
PCIConf.BaseAddressRegister[2]=PCIbuf[6];
PCIConf.BaseAddressRegister[3]=PCIbuf[7];
PCIConf.BaseAddressRegister[4]=PCIbuf[8];
PCIConf.BaseAddressRegister[5]=PCIbuf[9];
PCIConf.CardbusCISPointer=PCIbuf[10];
PCIConf.SubsystemVendorID=PCIbuf[11]&0xffff;
PCIConf.SubsystemID=((PCIbuf[11]&0xffff0000)>>16);
PCIConf.ExpansionROMBaseAddress=PCIbuf[12];
PCIConf.CapabllltlesPolnter=PCIbuf[13]&0xff;
PCIConf.Reserved0=((PCIbuf[13]&0xffffff00)>>8);
PCIConf.Reserved1=PCIbuf[14];
PCIConf.InterruptLine=PCIbuf[15]&0xff;
PCIConf.InterruptPin=((PCIbuf[15]&0xff00)>>8);
PCIConf.Min_Gnt=((PCIbuf[15]&0xff0000)>>16);
PCIConf.Max_Lat=((PCIbuf[15]&0xff000000)>>24);
return 1;
}
if(PCIConfBaseAddr>=0x80ffffff)
{
return 0;
}
PCIConfBaseAddr=PCIConfBaseAddr+0x800;//枚举PCI设备,16到23位表示总线号,第11到15位代表了插槽号
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -