阅读:2084回复:11
关于PCI卡的问题(在线等待)
我有一块PCI卡,采用以下方法找到设备识别号及供应商代码后,请教各位高手下一步该怎样可以获得它的基址寄存器里的内容。
tmp =0x80000000L|(bus<<16)|(device<<11)|(func<<8)); outpw(0xcf8),tmp); tmp =inpw(0xcfc); 谢谢! |
|
沙发#
发布于:2003-01-09 17:01
windriver is of great help .
|
|
板凳#
发布于:2003-01-09 21:43
希望用普通应用程序实现。不用驱动程序实现。
|
|
地板#
发布于:2003-01-09 21:50
pci相关中断。
|
|
|
地下室#
发布于:2003-01-10 09:21
能否用普通IO指令实现,如果可以的话请问怎样实现?谢谢
|
|
5楼#
发布于:2003-01-10 09:43
No score no answer.
|
|
6楼#
发布于:2003-01-10 11:32
问题解决后马上给分
|
|
7楼#
发布于:2003-07-18 05:07
if you just need to check and verify something you can use device manager\'s properties to find the bar base address of your pci card.
if you need to do it in program you need to do it in driver. otherwise, you can\'t access the physical address from your application program. |
|
8楼#
发布于:2003-07-18 13:38
这样试试看,应该可以得到PCI设备的6个MEM/IO地址,一般第一个地址就是这个PCI设备
的baseio地址。 for (reg=4; reg<=9; reg++) { tmp =0x80000000L|(bus<<16)|(device<<11)|(func<<8) | reg<<2); outpw(0xcf8),tmp); tmp =inpw(0xcfc); } btw, 下面这两个结构可能会用得到。 typedef union { struct _bit { DWORD DoubleZero:2; // Always be zero DWORD RegAddress:6; // Specify IO address(0xC000-0xCFFF), DWORD alignment; DWORD Function :3; // Function ID 0-7 DWORD Device :5; // Device ID 0-31 DWORD Bus :8; // Bus ID 0-255 DWORD Reserved :7; // Reserved, be zero DWORD Enable :1; // 0: normal I/O; 1: Enable config operation. } bit; DWORD dword; } PCI_CONFIG_ADR; // end of union PCI_CONFIG_ADR : union size = 2 bytes typedef struct { WORD wVendorID; WORD wDeviceID; WORD wCommand; WORD wStatus; BYTE byRevisionID; BYTE byProgrammingIF; BYTE bySubClass; BYTE byBaseClass; BYTE byCacheLineSize; BYTE byLatencyTimer; BYTE byHeaderType; BYTE byBIST; DWORD dwBaseAddress[MAX_ADDRESS_REGISTER]; //[PCI_TYPE0_ADDRESSES]; DWORD dwCardbusCISPointer; WORD wSubsystemVendorID; WORD wSubsystemID; DWORD dwROMBaseAddress; DWORD dwReserved2[2]; BYTE byInterruptLine; BYTE byInterruptPin; BYTE byMinimumGrant; BYTE byMaximumLatency; BYTE DeviceSpecific[0xC0]; } PCI_DEVICE_REG; // end of struct PCI_MY_DEVICE_REG : Total size = 256 bytes |
|
9楼#
发布于:2003-07-24 17:54
偶一个查PCI总线上所有设备的程序系这么做滴...
for(i=0; i<5; i++) { for(j=0; j<32; j++) { bus = i; device = j; iobase = 0x80000000 + bus * 0x10000+ (device * 8 ) * 0x100; ioa0 = iobase + 0; _outpd(0xcf8, ioa0); iod = _inpd(0xcfc); if (iod != 0xffffffff) { printf(\"\\nBus# = %x\\n\", bus); printf(\"Device # = %x\\n\", device); printf(\"ID# = %lx\\n\", iod); for (io=0; io<=5; io++) { ioa0 = iobase + 0x10 + io*4; _outpd(0xcf8, ioa0); iod = _inpd(0xcfc); printf(\"Base%d = 0x%lx\\n\", io, iod); } ioa0 = iobase + 0x3c; _outpd(0xcf8, ioa0); iod = _inpd(0xcfc); printf(\"IRQ# = 0x%x\\n\", iod & 0xff); getch(); } } } 希望对你有帮助。 |
|
|
10楼#
发布于:2003-07-24 17:55
怎么偶一帖上来所有的空格都不见了? :(
|
|
|
11楼#
发布于:2003-07-26 02:32
how to compile and run these two functions with win2k?
// _outpd(0xcf8, ioa0); iod = _inpd(0xcfc); // these two functions are the keys to get pci devices info. as what i know so far, win2k is not allowed application to do direct I/O port R/W. if this is true how can you do the port I/O in user mode program? you need a kernel mode driver to talk to that port. [编辑 - 7/26/03 by hong] |
|