pci卡设计心得
2006-04-08 11:38:57 来源:WEB开发网下面提供了vxd中查询pci卡的代码,这个代码是参考清华bbs驱动版精华区huyuguang大虾的大作,他提供了更详细的代码
有兴趣可以参考。
BOOL findpci(DWORD DeviceVendor,PCIINF *pciinf)//我的卡的DeviceVendor=0x905210b5
{
DWORD io_cf8;
DWORD io_cfc;
int i;
DWORD buf[16];
io_cf8=0x80000000;
for(;;)
{
DWORD_OUT(0xcf8,io_cf8);//向0xcf8输出双字 io_cf8
io_cfc=DWORD_IN(0xcfc); //从0xcfc读入双字
if(io_cfc==DeviceVendor)//find pci9052
{
for(i=0;i<16;i++)
{
DWORD_OUT(0xcf8,io_cf8+4*i);
buf[i]=DWORD_IN(0xcfc);
}
pciinf->VendorID=(WORD)(buf[0]&0xffff);
pciinf->DeviceID=(WORD)((buf[0]&0xffff0000)/0x10000);
pciinf->Command=(WORD)(buf[1]&0xffff);
pciinf->Status=(WORD)((buf[1]&0xffff0000)/0x10000);
pciinf->RevisionID=(UCHAR)(buf[2]&0xff);
pciinf->CacheLineSize=(UCHAR)(buf[3]&0xff);
pciinf->LatencyTimer=(UCHAR)((buf[3]&0xff00)/0x100);
pciinf->HeaderType=(UCHAR)((buf[3]&0xff0000)/0x10000);
pciinf->BIST=(UCHAR)((buf[3]&0xff000000)/0x1000000);
pciinf->BaseAddresses[0]=buf[4];
pciinf->BaseAddresses[1]=buf[5];
pciinf->BaseAddresses[2]=buf[6];
pciinf->BaseAddresses[3]=buf[7];
pciinf->BaseAddresses[4]=buf[8];
pciinf->BaseAddresses[5]=buf[9];
pciinf->SubsystemVendorID=(USHORT)(buf[11]&0xffff);
pciinf->SubsystemID=(USHORT)((buf[12]&0xffff0000)/0x10000);
pciinf->InterruptLine=(UCHAR)(buf[15]&0xff);
pciinf->InterruptPin=(UCHAR)((buf[15]&0xff00)/0x100);
pciinf->MinimumGrant=(UCHAR)((buf[15]&0xff0000)/0x10000);
pciinf->MaximumLatency=(UCHAR)((buf[15]&0xff000000)/0x1000000);
break;
}
else
io_cf8+=0x800;
if(io_cf8>=0x80ffff00)
return 1;
}
return 0;
}
以上都是我这次制作卡的一些心得,还有很多不清楚的地方,写出来只是想让感兴趣的pci门外汉了解一下,但愿能有所帮助。肯定有很多错误,希望各位大虾指正,但求不会误人子弟。pci大虾见笑了。
更多精彩
赞助商链接