China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-24 06:00
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » [Help] Is there a programming method for searching PCI devices under DOS? View 3,475 Replies 9
Original Poster Posted 2003-12-04 00:00 ·  中国 浙江 杭州 华数宽带
初级用户
Credits 120
Posts 5
Joined 2003-09-22 00:00
22-year member
UID 10157
Gender Male
Status Offline
Floor 2 Posted 2003-12-05 00:00 ·  中国 辽宁 沈阳 中移铁通
初级用户
Credits 207
Posts 26
Joined 2003-09-01 00:00
22-year member
UID 9292
Gender Male
Status Offline
Use the pcibios interrupt.
Floor 3 Posted 2003-12-13 00:00 ·  中国 天津 南开区 电信
高级用户
★★
Credits 924
Posts 243
Joined 2003-07-09 00:00
22-year member
UID 6612
Gender Male
Status Offline
Program directly to the ports and registers.
You can refer to the book <>
Floor 4 Posted 2003-12-19 00:00 ·  中国 广东 深圳 南山区 电信
初级用户
★★
鹰击长空
Credits 271
Posts 61
Joined 2003-08-20 00:00
22-year member
UID 8964
Gender Male
Status Offline
Assembly is enough.
适合的,就是最好的!
DOS,永远的初恋情人。
Floor 5 Posted 2005-10-07 21:59 ·  中国 上海 松江区 电信
新手上路
Credits 13
Posts 6
Joined 2005-10-06 13:48
20-year member
UID 43162
Gender Male
Status Offline
I wrote a program that can find all PCI devices.
Floor 6 Posted 2005-10-10 14:48 ·  中国 台湾 桃园市 中华电信
新手上路
Credits 13
Posts 6
Joined 2005-10-06 13:48
20-year member
UID 43162
Gender Male
Status Offline
The interrupt number for PCI BIOS is 0X1A. You can use it to access all PCI DEVICEs, but you need to know the DEVICE NUMBER, FUNCTION NUMBER, and VERNDOR ID. Use a FOR loop and search these addresses starting from 0.
Floor 7 Posted 2005-12-27 13:15 ·  中国 江苏 苏州 联通
新手上路
Credits 2
Posts 1
Joined 2005-12-27 09:11
20-year member
UID 47946
Status Offline
Floor 8 Posted 2006-07-12 01:33 ·  中国 云南 红河哈尼族彝族自治州 个旧市 电信
初级用户
Credits 43
Posts 26
Joined 2005-10-07 11:08
20-year member
UID 43188
Status Offline
Give us an executable file.
Floor 9 Posted 2006-07-12 12:14 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
20-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
Here is an example (run under Win98):
Advantech's PCI-1713 is a 32-channel PCI-bus AD card. The base address of a PCI bus card is assigned by the operating system, and multiple identical PCI cards can be inserted into one computer. Therefore, different computer hardware specs will cause the base address of the PCI card to vary. My system has two identical PCI-1713 cards installed. In order to obtain the base address of the PCI-1713, the program is as follows

//Advantech PCI-1713 vendor code
#define VENDOR_ADVANTECH 0x13FEL

//Advantech PCI-1713 card device code
#define DEVICE_ADVANTECH_PCI1713 0x1713L


//Function: scan for PCI cards matching the specified format word, and return the base addresses of multiple PCI cards with the same format word.
//Input parameter: dwFormat ---- the low 16 bits are the vendor code, the high 16 bits are the device code
//Output parameter: pnBase1 ------ the first PCI card matching the specified format word
//Output parameter: pnBase2 ------ the second PCI card matching the specified format word
//Return value: true if found, otherwise FALSE
BOOL ScanPCI_IO(DWORD dwFormat, int* pnBase1, int* pnBase2)
{
if (pnBase1 != NULL) *pnBase1 = NULL;
if (pnBase2 != NULL) *pnBase2 = NULL;

//i is the bus number
for (char i = 0; i < 5; i++)
{
//j is the device number
for(char j=0; j < 32; j++)
{
DWORD dwPCI = 0x80000000Lu + i * 0x10000Lu + (j * 8) * 0x100Lu;

//the 0th double word
DWORD dwPCI_Vendor = dwPCI | (0x0 * sizeof(DWORD));
::_outpd(0xcf8, dwPCI_Vendor);
DWORD dwDeviceAndVendor = ::_inpd(0xcfc);
//check whether the vendor code and device code are the same
if (dwDeviceAndVendor != dwFormat)
{
continue;
}

//analyze each base address
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, the address must be valid
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);
}

//Get the base address of the Advantech PCI-1713.
//Function: scan for the base address of the Advantech PCI-1713
//Output parameter: pnBase1 ------ base address of the first PCI-1713 card
//Output parameter: pnBase2 ------ base address of the second PCI-1713 card
//Return value: true if found, otherwise FALSE

BOOL ScanAdvantech_PCI1713(int* pnBase1, int* pnBase2)
{
return(::ScanPCI_IO(((DEVICE_ADVANTECH_PCI1713
<< 16) | VENDOR_ADVANTECH), pnBase1, pnBase2));

}
Floor 10 Posted 2009-12-02 03:15 ·  中国 广东 广州 联通
中级用户
★★
Credits 209
Posts 82
Joined 2006-03-22 00:18
20-year member
UID 52554
Status Offline
fire314:

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 ...



When this program runs on some computers, it shows a lot of duplicate devices. Can this program be fixed?

I just tested a computer with one onboard network card (interface not connected), plus one additional PCI network card installed. Both are 8139s.

The test result is as follows:

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

There are far too many network card entries in it, but in fact there should only be two network cards.
I also tested with other testing tools, and their results were all fine. So I think this should be a problem with this program. Because after compiling it is only 1.5K, much smaller than similar software, I very strongly hope this program issue can be fixed. Thanks!



Also attaching the test results from other tools on the same computer:

As follows:


1. The result tested with PCILIST.EXE is:
===============================================
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. The result tested with PCISCAN.EXE is:
===============================================

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. The result tested with PCISLEEP.EXE is:
===============================================
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 ]
Forum Jump: