You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
I'm trying to find a way to enumerate PCI devices in a PC. I'm looking for the vendor ID and the device ID strings of the PCI devices (in particular the network card). Any ideas ? Would int 1A with ax=B401 do the trick ?
Rob,
try the following. INT &h1a with ah=&hb1 is used to access the PCI system.
Paul.
Code:
%FORCE32bit=&h66
cls
PCIpresent%=0
LastPCIbus%=0
PCIrev%=0
PCImechanism%=0
'get PCI system data
!mov ax,&hb101
!int &h1a
!jnc zz
!and ah,&hff
!jnz xit
zz:
!db %FORCE32bit
!cmp dx,&h20494350
!jnz xit
!mov PCImechanism%,al
!mov PCIrev%,bx
!mov LastPCIbus%,cl
!mov ax,-1
!mov PCIpresent%,ax
xit:
If PCIpresent% then
print "last bus number = ";LastPCIbus%
print "PCI revision number = ";hex$(PCIrev%\256);".";hex$(PCIrev% and 255)
if bit(PCImechanism%,0) then print "Configuration mechanism #1 supported"
if bit(PCImechanism%,1) then print "Configuration mechanism #2 supported"
if bit(PCImechanism%,4) then print "Special cycle supported via configuration mechanism #1"
if bit(PCImechanism%,5) then print "Special cycle supported via configuration mechanism #2"
else
print "PCI system not present"
end if
for bus%=0 to LastPCIbus%
for func%=0 to 255
flag%=0
'get vendor ID
!mov ax,&hb109 ;read PCI headre
!mov bh,bus% ;on this bus
!mov bl,func% ;for this device
!mov di,0 ;location 0 = vendor ID
!int &h1a
!jc fail
!and ah,&hff
!jnz fail
!mov config%,cx
!inc flag%
fail:
if flag% and config%<>&hffff then
print "bus ";bus%;" device number ";func%\8;" function ";func% and 7;"vendor ID=";hex$(config%);
flag%=0
'get device ID
!mov ax,&hb109
!mov bh,bus%
!mov bl,func%
!mov di,2 ;location 2 = device ID
!int &h1a
!jc fail2
!and ah,&hff
!jnz fail2
!mov config%,cx
!inc flag%
fail2:
if flag% then print " device ID ="hex$(config%) else print
end if
next
next
There is a nice program written by Ralph Brown (yes, from the marvellous interrupt list)
that obtains LOTS of information from PCI devices... and the great thing is, the source
is included (a single C++ file)!
I modified the PB code so it now also looks up vendors and
device descriptions. I posted it on my website today.
The url is http://www.gvii.net/tburcham/PCI.zip. The file
contains the PB3.5 source and the freeware vendor database.
Here's the modified code:
'***** PCI.bas for PBDos 3.5 *****
defint A-Z
%FORCE32bit=&h66
cls
screen 0
color 1,7
for n = 1 to 25
? string$(80," ")
next n
? string$(80,"*")
color 4
? " This retrieves and displays information about PCI devices"
? "installed in the system it's run on."
? "From demo code modified by Tony Burcham: [email protected]"
? "I saw no indication of a copyright and my part is public domain"
? "as is 'PCIDEVS.TXT' according to its author."
? "For updates visit: <A HREF="http://members.hyperlink.net.au/~chart"" TARGET=_blank>http://members.hyperlink.net.au/~chart"</A>
? "Press any key to skip the 3-second delay between devices."
?
'get PCI system data
!mov ax,&hb101
!int &h1a
!jnc zz
!and ah,&hff
!jnz xit
zz:
!db %FORCE32bit
!cmp dx,&h20494350
!jnz xit
!mov PCImechanism%,al
!mov PCIrev%,bx
!mov LastPCIbus%,cl
!mov ax,-1
!mov PCIpresent%,ax
xit:
If PCIpresent% then
color 15
print "last bus number = ";LastPCIbus%
print "PCI revision number = ";hex$(PCIrev%\256);".";hex$(PCIrev% and 255)
if bit(PCImechanism%,0) then print "Configuration mechanism #1 supported"
if bit(PCImechanism%,1) then print "Configuration mechanism #2 supported"
if bit(PCImechanism%,4) then print "Special cycle supported via configuration mechanism #1"
if bit(PCImechanism%,5) then print "Special cycle supported via configuration mechanism #2"
else
color 4
print "PCI system not present"
end if
for bus%=0 to LastPCIbus%
for func%=0 to 255
flag%=0
'get vendor ID
!mov ax,&hb109 ;read PCI header
!mov bh,bus% ;on this bus
!mov bl,func% ;for this device
!mov di,0 ;location 0 = vendor ID
!int &h1a
!jc fail
!and ah,&hff
!jnz fail
!mov config%,cx
!inc flag%
fail:
if flag% and config%<>&hffff then
color 15
print "bus";bus%;" device number";func%\8;" function";func% and 7;" vendor ID =";hex$(config%)
V$ = Vendor$(config%)
flag%=0
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment