阅读:1322回复:3
s5933驱动测试程序
请问编写s5933的驱动测试程序时,怎么在测试程序中得到pci的配置信息及操作寄存器的控制及状态信息?有谁有现成的测试程序,能否提供,本人愿意出高分?
|
|
沙发#
发布于:2002-12-01 21:04
这个网站的资料区就有许多现成的资料,拉下来运行就OK
|
|
|
板凳#
发布于:2002-12-02 13:12
弟兄,在什么地方,说清楚些。文件名
|
|
地板#
发布于:2002-12-02 14:26
搜一下就可以了,下面是截取的获取pci信息的代码,只不过2k下需要另外写个驱动操作端口
#include \"stdio.h\" #include \"windows.h\" DWORD DWORD_In(WORD io_Port) { DWORD val; _asm { mov dx,io_Port in eax,dx mov val,eax } return val; } DWORD DWORD_Out(WORD io_Port,DWORD val) { _asm { mov dx,io_Port mov eax,val out dx,eax } return 0; } int main() { DWORD io_CF8; // port 0xcf8 DWORD io_CFC; // port 0xcfc int i; io_CF8=0x80000000; //because the first bit is enable/disable for(;;) //so must be 1,so from 0x800000000 { DWORD_Out(0xcf8,io_CF8); io_CFC=DWORD_In(0xcfc); if (io_CFC!=0xffffffff) //if =0xffffffff,then is a invalid { //bus number and device number printf(\"\\nPCI device has found,the pci config address=%lx\\n\",io_CF8); printf(\"its Bus Numer is %lx \\n\",(io_CF8&0x00ff0000)/0x10000); printf(\"its Device Number is %lx \\n\",(io_CF8&0x0000f800)/0x800); printf(\"its Functin Number is %lx \\n\",(io_CF8&0x700)/0x100); printf(\"this device\'s deviceID and vendorID=%lx\\n\",io_CFC); for (i=0 ;i<=15;i++) { DWORD_Out(0xcf8,io_CF8+4*i); //read DWORD switch (i) { case 0: printf(\"Device Number and Vendor Number =%lx\"); break; case 1: printf(\"Status and Command =\"); break; case 2: printf(\"Class Code and Revision ID=\"); break; case 3: printf(\"Bist and Header Type and Latency Timer and Cacne Line Size=\"); break; case 4: //PCI Configration has 6 base address case 5: //register case 6: case 7: case 8: case 9: printf(\"Base Address Register=\"); break; case 10: case 11: case 13: case 14: printf(\"Reserved =\"); break; case 12: printf(\"Expansion ROM Base Address=\"); break; case 15: //attention:the interrupt IRQ= this result&0xff printf(\"Max_Lat Min_Gnt Interrupt Pin Interrupt line=\"); break; } printf(\"%lx\\n\",DWORD_In(0xcfc)); } } io_CF8+=0x800; if (io_CF8>=0x80FFFF00) break; } return 0; } |
|
|