PCIReadConfig function requires a BusNumber parameter.
How to obtain BusNumber, if I know the vendor_id and device_id?
Thanx...
Posted on 2002-06-24 05:34:31 by Vaxon
If you do not know the Bus number of the device that you are trying to talk to then you will need to enum. the PCI bus by hand , checking each devices VID/DID until you find the one that you are looking for (this is the only way that I know how to do it).

Here is a very old (and incomplete) section of code that I had been working on (which may be of service to you, just don't take it as written in stone; I have not done anything with it since I started to play with it):

EnumPciBus PROC USES ecx edx esi
local moreBuses:BYTE
local busNumber:DWORD
local deviceNumber:DWORD
local functionNumber:DWORD

mov moreBuses, TRUE
mov busNumber, 0
mov deviceNumber, 0
mov functionNumber, 0

lea edx, slotNumber

.IF moreBuses == TRUE ; should be .WHILE

.IF deviceNumber < PCI_MAX_DEVICES

.IF functionNumber < PCI_MAX_FUNCTION
; assume edx: PTR PCI_SLOT_NUMBER
mov (PCI_SLOT_NUMBER PTR ).u.bits.Reserved, 0
mov eax, deviceNumber
mov (PCI_SLOT_NUMBER PTR ).u.bits.DeviceNumber, eax
mov eax, functionNumber
mov (PCI_SLOT_NUMBER PTR).u.bits.FunctionNumber, eax

mov edx, (PCI_SLOT_NUMBER PTR ).u.AsULONG
; assume edx: NOTHING

lea esi, configInfo
invoke HalGetBusData, PCIConfiguration, busNumber, edx, ADDR configInfo, 40h
; assume edx: NOTHING
inc functionNumber
.ENDIF

inc deviceNumber
.ENDIF

inc busNumber
.ENDIF
ret
EnumPciBus ENDP
Posted on 2002-06-24 16:17:01 by madprgmr
Thank you, Madprgmr.
I just started to think that no one was gonna help me....
But this HalGetBusData function... What module is it in?
I can't find any description of it anywhere. Even in win98ddk.:confused:
Please, help
Posted on 2002-06-25 01:53:11 by Vaxon
HalGetBusData is obsolete
have a look here for more info
Posted on 2002-06-25 05:53:28 by Allanon
Ok, this function is obsolete, but it says it's exported.
But where?
In what module or dll?
Still Can't get it.
What do I have to link to make
invoke HalGetBusData, ....
work.
Well, Microsoft says i have to use IRP instead of this function.
What the hell is that supposed to mean?
Can't understand how to use it.
Please, HELP!!!
:stupid: :confused: :stupid:
Posted on 2002-06-25 08:15:03 by Vaxon
HalGetBusData is for winnt.. you cant find it inside 98ddk.
for 98 i use
VxDCall _PCI_Read_Config,x,y,0

_PCI_Get_Version EQU 000430000H
_PCI_Read_Config EQU 000430001H
_PCI_Write_Config EQU 000430002H
_PCI_Lock_Unlock EQU 000430004H
Posted on 2002-06-25 10:52:26 by kamilh
For information on the non-obsolete method (I told you that this driver code was dated :) ) check out the Windows XP ddk document under the following section:

Kernel-Mode Driver Architecture
- Input/Output Techniques
- Accessing Device Configuration Space

if you do not have the WinXp ddk then check out the following link:

Accessing Device Configuration Space
Posted on 2002-06-25 13:32:11 by madprgmr
Thank you guys, but I still can't get how to obtain the bus number if I know vendor_id and device_id.
Do I have to call PCIReadConfig, x, y, 0, increasing x by 1 each time and verify the number returned with my dev_id and ven_id untill it returns some error code of wrong bus number?
But what the error code should be then? Or is there any way to get the total number of buses available? :confused:
Posted on 2002-06-26 02:37:19 by Vaxon