| | | jpzsj 初級用戶
積分 43 發(fā)帖 26 注冊 2005-10-7 狀態(tài) 離線 | | 2006-7-12 01:33 | | | firstsail 高級用戶
積分 603 發(fā)帖 264 注冊 2005-7-27 來自 廣東深圳 狀態(tài) 離線 | 『第 9 樓』:
舉一個例子(在Win98中執(zhí)行): 研華的PCI-1713是一塊32通道的、PCI總線的AD卡,PCI總線卡的基地址是由操作系統(tǒng)分配的,在一臺計算中,可以插入多塊相同的PCI卡。故不同的計算機硬件配置會導(dǎo)致PCI卡基地址是不定的。我的系統(tǒng)插有兩塊相同的PCI-1713卡。為了獲得PCI-1713的基地址,程序是這樣的
//研華的PCI-1713的供應(yīng)商代碼 #define VENDOR_ADVANTECH 0x13FEL
//研華的PCI-1713卡的設(shè)備代碼 #define DEVICE_ADVANTECH_PCI1713 0x1713L
//函數(shù)功能:掃描指定格式字的PCI卡,返回多個相同格式字PCI卡的基地址。 //入口參數(shù):dwFormat ----低16位為供應(yīng)商代碼,高16位為設(shè)備代碼 //出口參數(shù):pnBase1 ------ 符合指定格式字的第一塊PCI卡 //出口參數(shù):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為設(shè)備號 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); //判斷供應(yīng)商代碼和設(shè)備代碼是否相同 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的基地址。 //函數(shù)功能:掃描研華PCI-1713的基地址 //出口參數(shù):pnBase1 ------ 第一塊PCI-1713卡的基地址 //出口參數(shù):pnBase2 ------ 第二塊PCI-1713卡的基地址 //返 回 值:找到為真,否則FALSE
BOOL ScanAdvantech_PCI1713(int* pnBase1, int* pnBase2) { return(::ScanPCI_IO(((DEVICE_ADVANTECH_PCI1713 << 16) | VENDOR_ADVANTECH), pnBase1, pnBase2));
}
| | 2006-7-12 12:14 | | | ITU 中級用戶
積分 201 發(fā)帖 79 注冊 2006-3-22 狀態(tài) 離線 | 『第 10 樓』:
fire314:
Quote: | Originally posted by fire314 at 2005-12-27 13:15: .model small,c
.386
.data message1 db '---------------------------------------------------',13,10 db 'Index Bus. Dev. func. DeviceI ... | | 這個程序在一些電腦上執(zhí)行會出現(xiàn)許多重復(fù)的設(shè)備? 能不能修正一下這個程序?
我剛才試過的一臺電腦,有一個板載網(wǎng)卡(接口不通),另裝有一個PCI網(wǎng)卡,都是8139的。
測試結(jié)果如下:
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
它里面多出了許多個網(wǎng)卡的項,而實際上只有兩個網(wǎng)卡才對。 我又用了其它的測試工具進行測試,結(jié)果都沒問題。所以我覺得應(yīng)該是這個程序的問題了,因為這個編譯之后只有1.5K,比起同類軟件小了許多,所以強烈希望能修正這個程序問題。謝謝!
另附其它工具在同一臺電腦上的測試結(jié)果: 如下:
1、用PCILIST.EXE 測試的結(jié)果是: =============================================== PC/AT PCI device list [ PCIlist ] 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 [0]:[ 0] PCI--HOST Intel -- Yes No No Yes No No - - - - [0]:[ 1] GFX bridge Intel -- Yes No Yes Yes No Yes - - - - [0]:[29]:[0] USB Intel 12 [A] Yes No Yes No No No - - - - [0]:[29]:[1] USB Intel 3 [B] Yes No Yes No No No - - - - [0]:[29]:[2] USB Intel 11 [C] Yes No Yes No No No - - - - [0]:[29]:[3] USB Intel 12 [A] Yes No Yes No No No - - - - [0]:[29]:[7] USB 2.0 Intel 5 [D] Yes No No Yes No No - - - - [0]:[30] LPC bridge Intel -- Yes No Yes Yes No Yes - - - - [0]:[31]:[0] PCI--ISA Intel -- Yes No Yes Yes No No - - - - [0]:[31]:[1] IDE ctrl. Intel -- [A] Yes No Yes Yes No No - - - - [0]:[31]:[2] IDE ctrl. Intel 11 [A] Yes No Yes No No No - - - - [0]:[31]:[3] SM bus Intel 10 [B] No No Yes No No No - - - - [0]:[31]:[5] MM-AUDIO Intel 10 [B] Yes No Yes Yes No No - - - - [1]:[ 0] VGA-VIDEO ATI ** Yes No Yes Yes No No - - - 8 [2]:[ 1] IEEE1394 Texas Ins 10 [A] Yes No No Yes No No - - - 8 [2]:[ 2] EtherNet RealTEK 11 [A] Yes No Yes Yes No No - - - - [2]:[ 9] EtherNet RealTEK 10 [A] Yes No Yes Yes No No - - - - ===============================================
2、用PCISCAN.EXE 測試的結(jié)果是: ===============================================
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 測試的結(jié)果是: =============================================== PCI BIOS version 2.10, highest bus number is 2. bus.device(.function) [vendor:model] classcode(/iface) vendor class [details]
BusDevf vend:type class vendor description... ----------------------------------------------------------------------------- 00.00 8086:2570 0600 Intel CPU host bridge 00.01 8086:2571 0604 Intel PCI bridge [00->01] 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 [D3] 00.1e 8086:244e 0604 Intel PCI bridge [00->02] 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 [D3] 01.00 1002:5159 0300 ATI VGA graphics [D1,D3] 02.01 104c:8024 0c00/10 TI FireWire IEEE1394 [D1,D3] 02.02 10ec:8139 0200 Realtek LAN / Ethernet [D1,D3] 02.09 10ec:8139 0200 Realtek LAN / Ethernet [D1,D3]
PCI Scan done.
===============================================
[
| | |