![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-10-31 07:19 |
共 47,815 主题排行 / 349,930 发帖 / 今日 0 篇 / 48,290 会员排行 |
| DOS开发编程 & 发展交流 (开发室) » [求助]有DOS下搜索PCI设备的编程方法吗 |
| 可打印版本 3,975 / 9 |
| 第1楼 taoweiwei | 发表于 2003-12-04 00:00 |
| 初级用户 发帖 5 积分 120 | |
|
[求助]有DOS下搜索PCI设备的编程方法吗 a.t.t.
|
|
| 第2楼 yixianwei | 发表于 2003-12-05 00:00 |
| 初级用户 发帖 26 积分 207 | |
|
采用pcibios中断。
|
|
| 第3楼 aria | 发表于 2003-12-13 00:00 |
| 高级用户 发帖 243 积分 924 | |
|
直接对端口和寄存器编程
可以参考<>这本书 |
|
| 第4楼 笑傲江湖 | 发表于 2003-12-19 00:00 |
| 初级用户 发帖 61 积分 271 | |
|
用汇编就可以的。
|
|
| 第5楼 ldy810 | 发表于 2005-10-07 21:59 |
| 新手上路 发帖 6 积分 13 | |
|
我写了一个程序,可以查找所有的PCI设备。
|
|
| 第6楼 ldy810 | 发表于 2005-10-10 14:48 |
| 新手上路 发帖 6 积分 13 | |
|
PCI BIOS的中断号是0X1A你可以用它,去访问所有的PCI DEVICE,不过你要知道DEVICE NUMBER,FUNCTION NUMBER,VERNDOR ID。你用一个FOR循环,把这些地址从0开始搜索就可以啦。
|
|
| 第7楼 fire314 | 发表于 2005-12-27 13:15 |
| 新手上路 发帖 1 积分 2 | |
|
DOs下汇编实现PCI 扫瞄 SourceCode .model small,c
.386 .data message1 db '---------------------------------------------------',13,10 db 'Index Bus. Dev. func. DeviceID VendorID DeviceType',13,10 db '---------------------------------------------------',13,10 db '$' return db 13,10,'$' moreMessage db 'press any key for more .',13,10,'$' bus db 00h dev db 00h func db 00h bcode db 00h Lindex db 00h bc00 db 'Device built before Define BC','$' bc01 db 'Mass Storage Controller','$' bc02 db 'Network Controller','$' bc03 db 'Display Controller','$' bc04 db 'Mutimedia device','$' bc05 db 'Memory Controller','$' bc06 db 'Bridge device','$' bc07 db 'Simple communication controllers','$' bc08 db 'Base system peripherals','$' bc09 db 'Input devices','$' bc0a db 'Docking stations','$' bc0b db 'Processors','$' bc0c db 'Serial bus controllers','$' bc0d db 'Wireless controller','$' bc0e db 'Intelligent I/O controllers','$' bc0f db 'Satellite communication controllers','$' bc10 db 'Encryption/Decryption controllers','$' bc11 db 'Data acquisition and signal processing controllers','$' BCTable label byte dw offset bc00 dw offset bc01 dw offset bc02 dw offset bc03 dw offset bc04 dw offset bc05 dw offset bc06 dw offset bc07 dw offset bc08 dw offset bc09 dw offset bc0a dw offset bc0b dw offset bc0c .stack .code ;-------------------------------------------------------------------- ;Display space ; ;Input : None ;Output : None ;-------------------------------------------------------------------- Disp_spc proc push dx push ax mov dl,20h mov ah,2 int 21h pop ax pop dx ret Disp_spc endp ;-------------------------------------------------------------------- ;Display the character '0'~'9' and 'A'~'F' ; ;Input : DL = Number ;Ouput : None ;-------------------------------------------------------------------- Disp_chr proc push dx push ax cmp dl,10 jns letter add dl,30h jmp down letter: add dl,37h down: mov ah,2 int 21h pop ax pop dx ret Disp_chr endp ;-------------------------------------------------------------------- ;Display the Bus number,Device number and Function number ; ;Input : EBX = Bus#, Dev#, Func# ;Output : None ;-------------------------------------------------------------------- Disp_add proc ;;;;;;Display Bus Number rol ebx,16 mov dl,bl and dl,0fh call Disp_chr call Disp_spc call Disp_spc call Disp_spc call Disp_spc ;;;;;;Display Device Number ;;;;;;Display the high 1 bit rol ebx,1 mov dl,bl and dl,1 call Disp_chr ;;;;;;Display the low 4 bits rol ebx,4 mov dl,bl and dl,0fh call Disp_chr call Disp_spc call Disp_spc call Disp_spc call Disp_spc ;;;;;;Display Function Number rol ebx,3 mov dl,bl and dl,7 call Disp_chr call Disp_spc call Disp_spc call Disp_spc call Disp_spc ret Disp_add endp ;------------------------------------ disp_sp proc push cx mov cl,4 p: rol eax,4 mov dl,al and dl,0fh call disp_chr dec cl jnz p call disp_spc call disp_spc call disp_spc call disp_spc call disp_spc pop cx ret disp_sp endp ;---------------------------------------------- disp_sd proc push cx mov cl,4 rol eax,16 p1: rol eax,4 mov dl,al and dl,0fh call disp_chr dec cl jnz p1 call disp_spc call disp_spc pop cx ret disp_sd endp ;--------------------- ;------------------------------------------------------------------- ;------------------------------------------------------------ ;Start Program Here ;------------------------------------------------------------ Begin: ;;;;;;Display the table head mov ah,9 mov dx,seg message1 mov ds,dx mov dx,offset message1 int 21h ;************************************************************ ;************************************************************ ; Add Scan PCI Code here ;loop1: loop1: and eax,00000000h and ebx,00000000h mov ah,dev mov cl,03h rol ah,cl add ah,func mov al,00h ;register num.=00h mov bx,ax mov ax,8000h add al,bus mov cl,10h rol eax,cl add eax,ebx mov ebx,eax ;save bus#,dev#,func# in ebx mov dx,0cf8h out dx,eax mov dx,0cfch in eax,dx cmp ax,0ffffh ; int 3h jz next2 display: ;;;;;;;;;Get Base ClassCode and save it in bcode memory push eax mov eax,ebx add eax,08h mov dx,0cf8h out dx,eax mov dx,0cfch in eax,dx mov cl,08h rol eax,cl mov bcode,al call Disp_spc call Disp_spc ;;;;;;;;;display the PCI Devices list index push ax mov al,Lindex mov cl,4 rol al,cl mov dl,al and dl,0fh call Disp_chr rol al,cl mov dl,al and dl,0fh call Disp_chr ;;;;;inc Lindex inc al mov Lindex,al pop ax call Disp_spc call Disp_spc ;;;;;;;;;display the bus number, device number , function number call disp_add pop eax push eax pop eax push eax call Disp_spc call disp_sp pop eax call Disp_spc call disp_sd ;;;;;;Display Base Class Code push eax mov al,bcode sal al,1 mov ah,0 mov si, offset BCTable add si, ax mov dx,word ptr ds:[si] mov ah,09h int 21h pop eax ;;;;;;change to a new line push eax mov ah,9 mov dx,seg return mov ds,dx mov dx,offset return int 21h pop eax ;;;;;;;;;;;check the cusor at the bottom of the screen next2: mov ah,func inc ah cmp ah,07h jg next3 mov func,ah jmp loop1 next3: mov func,00h mov ah,dev inc ah cmp ah,1fh jg next4 mov dev,ah jmp loop1 next4: mov func,00h mov dev,00h mov ah,bus inc ah cmp ah,0fh jg N1 ;jz or jg mov bus,ah jmp loop1 ;************************************************************ ;************************************************************ N1: mov ah,4ch int 21h end Begin |
|
| 第8楼 jpzsj | 发表于 2006-07-12 01:33 |
| 初级用户 发帖 26 积分 43 | |
|
给一个可执行的文件啊
|
|
| 第9楼 firstsail | 发表于 2006-07-12 12:14 |
| 高级用户 发帖 295 积分 668 来自 广东深圳 | |
|
举一个例子(在Win98中执行):
研华的PCI-1713是一块32通道的、PCI总线的AD卡,PCI总线卡的基地址是由操作系统分配的,在一台计算中,可以插入多块相同的PCI卡。故不同的计算机硬件配置会导致PCI卡基地址是不定的。我的系统插有两块相同的PCI-1713卡。为了获得PCI-1713的基地址,程序是这样的 //研华的PCI-1713的供应商代码 #define VENDOR_ADVANTECH 0x13FEL //研华的PCI-1713卡的设备代码 #define DEVICE_ADVANTECH_PCI1713 0x1713L //函数功能:扫描指定格式字的PCI卡,返回多个相同格式字PCI卡的基地址。 //入口参数:dwFormat ----低16位为供应商代码,高16位为设备代码 //出口参数:pnBase1 ------ 符合指定格式字的第一块PCI卡 //出口参数:pnBase2 ------ 符合指定格式字的第二块PCI卡 //返 回 值:找到为真,否则FALSE BOOL ScanPCI_IO(DWORD dwFormat, int* pnBase1, int* pnBase2) { if (pnBase1 != NULL) *pnBase1 = NULL; if (pnBase2 != NULL) *pnBase2 = NULL; //i为总线号 for (char i = 0; i < 5; i++) { //j为设备号 for(char j=0; j < 32; j++) { DWORD dwPCI = 0x80000000Lu + i * 0x10000Lu + (j * 8) * 0x100Lu; //第0个双字 DWORD dwPCI_Vendor = dwPCI | (0x0 * sizeof(DWORD)); ::_outpd(0xcf8, dwPCI_Vendor); DWORD dwDeviceAndVendor = ::_inpd(0xcfc); //判断供应商代码和设备代码是否相同 if (dwDeviceAndVendor != dwFormat) { continue; } //分析每一个基地址 for (int k = 0; k < 6; k++) { DWORD dwPCI_Base = (dwPCI | ((4 + k) * sizeof(DWORD))); ::_outpd(0xcf8, dwPCI_Base); DWORD dwBase = ::_inpd(0xcfc); BOOL bMem = !(dwBase & 0x1); dwBase &= 0xFFFFFFFEL; //I/O,必须地址有效 if (!bMem && (dwBase != 0x0 && dwBase != 0xFFFFFFFEL)) { if (pnBase1 != NULL && *pnBase1 == 0) { *pnBase1 = (int)dwBase; if (pnBase2 == NULL) { return(TRUE); } } else if (pnBase2 != NULL && *pnBase2 == 0) { *pnBase2 = (int)dwBase; return(TRUE); } } } } } return(FALSE); } //获得研华PCI-1713的基地址。 //函数功能:扫描研华PCI-1713的基地址 //出口参数:pnBase1 ------ 第一块PCI-1713卡的基地址 //出口参数:pnBase2 ------ 第二块PCI-1713卡的基地址 //返 回 值:找到为真,否则FALSE BOOL ScanAdvantech_PCI1713(int* pnBase1, int* pnBase2) { return(::ScanPCI_IO(((DEVICE_ADVANTECH_PCI1713 << 16) | VENDOR_ADVANTECH), pnBase1, pnBase2)); } |
|
| 第10楼 ITU | 发表于 2009-12-02 03:15 |
| 中级用户 发帖 82 积分 209 | |
|
fire314:
Originally posted by fire314 at 2005-12-27 13:15: 这个程序在一些电脑上执行会出现许多重复的设备? 能不能修正一下这个程序? 我刚才试过的一台电脑,有一个板载网卡(接口不通),另装有一个PCI网卡,都是8139的。 测试结果如下: Index Bus. Dev. func. Vendor:Device DeviceType ---------------------------------------------------- 00 0 00 0 8086:2570 Bridge device 01 0 01 0 8086:2571 Bridge device 02 0 1D 0 8086:24D2 Serial bus controllers 03 0 1D 1 8086:24D4 Serial bus controllers 04 0 1D 2 8086:24D7 Serial bus controllers 05 0 1D 3 8086:24DE Serial bus controllers 06 0 1D 7 8086:24DD Serial bus controllers 07 0 1E 0 8086:244E Bridge device 08 0 1F 0 8086:24D0 Bridge device 09 0 1F 1 8086:24DB Mass Storage Controller 0A 0 1F 2 8086:24D1 Mass Storage Controller 0B 0 1F 3 8086:24D3 Serial bus controllers 0C 0 1F 5 8086:24D5 Mutimedia device 0D 1 00 0 1002:5159 Display Controller 0E 1 00 1 1002:5159 Display Controller 0F 1 00 2 1002:5159 Display Controller 10 1 00 3 1002:5159 Display Controller 11 1 00 4 1002:5159 Display Controller 12 1 00 5 1002:5159 Display Controller 13 1 00 6 1002:5159 Display Controller 14 1 00 7 1002:5159 Display Controller 15 2 01 0 104C:8024 Serial bus controllers 16 2 01 1 104C:8024 Serial bus controllers 17 2 01 2 104C:8024 Serial bus controllers 18 2 01 3 104C:8024 Serial bus controllers 19 2 01 4 104C:8024 Serial bus controllers 1A 2 01 5 104C:8024 Serial bus controllers 1B 2 01 6 104C:8024 Serial bus controllers 1C 2 01 7 104C:8024 Serial bus controllers 1D 2 02 0 10EC:8139 Network Controller 1E 2 09 0 10EC:8139 Network Controller 1F 2 09 1 10EC:8139 Network Controller 20 2 09 2 10EC:8139 Network Controller 21 2 09 3 10EC:8139 Network Controller 22 2 09 4 10EC:8139 Network Controller 23 2 09 5 10EC:8139 Network Controller 24 2 09 6 10EC:8139 Network Controller 25 2 09 7 10EC:8139 Network Controller 它里面多出了许多个网卡的项,而实际上只有两个网卡才对。 我又用了其它的测试工具进行测试,结果都没问题。所以我觉得应该是这个程序的问题了,因为这个编译之后只有1.5K,比起同类软件小了许多,所以强烈希望能修正这个程序问题。谢谢! 另附其它工具在同一台电脑上的测试结果: 如下: 1、用PCILIST.EXE 测试的结果是: =============================================== PC/AT PCI device list Version 1.36 Copyright(C) 2003-09 傑傝傕 PCI BIOS Version 2.10, Last bus number(BIOS)=2, Configuration mechanism #1 Bus Dev Func Class Vendor IRQ INT B/M P/E I/O MEM MWI SER PED DPD SED CL : PCI--HOST Intel -- Yes No No Yes No No - - - - : GFX bridge Intel -- Yes No Yes Yes No Yes - - - - :: USB Intel 12 Yes No Yes No No No - - - - :: USB Intel 3 Yes No Yes No No No - - - - :: USB Intel 11 Yes No Yes No No No - - - - :: USB Intel 12 Yes No Yes No No No - - - - :: USB 2.0 Intel 5 Yes No No Yes No No - - - - : LPC bridge Intel -- Yes No Yes Yes No Yes - - - - :: PCI--ISA Intel -- Yes No Yes Yes No No - - - - :: IDE ctrl. Intel -- Yes No Yes Yes No No - - - - :: IDE ctrl. Intel 11 Yes No Yes No No No - - - - :: SM bus Intel 10 No No Yes No No No - - - - :: MM-AUDIO Intel 10 Yes No Yes Yes No No - - - - : VGA-VIDEO ATI ** Yes No Yes Yes No No - - - 8 : IEEE1394 Texas Ins 10 Yes No No Yes No No - - - 8 : EtherNet RealTEK 11 Yes No Yes Yes No No - - - - : EtherNet RealTEK 10 Yes No Yes Yes No No - - - - =============================================== 2、用PCISCAN.EXE 测试的结果是: =============================================== Bus Dev Func Slot Vend Dev. Class Name Subclass Name ---------------------------------------------------------------- 0 0 0 0 8086 2570 Bridge CPU/PCI 0 1 0 1 8086 2571 Bridge PCI/PCI 0 1D 0 1D 8086 24D2 Serial Bus USB 0 1D 1 1D 8086 24D4 Serial Bus USB 0 1E 0 1E 8086 244E Bridge PCI/PCI 0 1F 0 1F 8086 24D0 Bridge PCI/ISA 0 1F 1 1F 8086 24DB Disk IDE 1 0 0 20 1002 5159 Display VGA 2 1 0 41 104C 8024 Serial Bus Firewire 2 2 0 42 10EC 8139 Network Ethernet 2 9 0 49 10EC 8139 Network Ethernet 11 PCI devices found 3、用PCISLEEP.EXE 测试的结果是: =============================================== PCI BIOS version 2.10, highest bus number is 2. bus.device(.function) classcode(/iface) vendor class BusDevf vend:type class vendor description... ----------------------------------------------------------------------------- 00.00 8086:2570 0600 Intel CPU host bridge 00.01 8086:2571 0604 Intel PCI bridge 00.1d.0 8086:24d2 0c03 Intel USB controller 00.1d.1 8086:24d4 0c03 Intel USB controller 00.1d.2 8086:24d7 0c03 Intel USB controller 00.1d.3 8086:24de 0c03 Intel USB controller 00.1d.7 8086:24dd 0c03/20 Intel USB controller 00.1e 8086:244e 0604 Intel PCI bridge 00.1f.0 8086:24d0 0601 Intel ISA bridge 00.1f.1 8086:24db 0101/8a Intel IDE controller 00.1f.2 8086:24d1 0101/8f Intel IDE controller 00.1f.3 8086:24d3 0c05 Intel SMBus controller 00.1f.5 8086:24d5 0401 Intel audio 01.00 1002:5159 0300 ATI VGA graphics 02.01 104c:8024 0c00/10 TI FireWire IEEE1394 02.02 10ec:8139 0200 Realtek LAN / Ethernet 02.09 10ec:8139 0200 Realtek LAN / Ethernet PCI Scan done. =============================================== [ Last edited by ITU on 2009-12-2 at 03:23 ] |
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |