?? pciconfig.cpp
字號(hào):
// 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設(shè)備,16到23位表示總線號(hào),第11到15位代表了插槽號(hào)
}
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -