help PCI configuration

  1. I am a newcomer, so please sorry for my simple question

  2. Our computer:NT4.0
    NT4.0 DDK
    DEFAULT INSTALLATION

  3. I copy a sourcecode from Dekker’s book to implement the PCI
    enumeration.

The headfile is “ntddk.h”, it reference the HalGet… function,
I used the vc++6.0 to compile, the result is miserable which told me
there are 95 errors in ntddk.h.

would you like tell me where are my errors.
Thanks a lot


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi

You might not have set the proper environment variables for the DDK. The
installation of the DDK sets the shortcuts for the proper environments in
Windows Start Menu like Free Build Environment or Checked Build environment.
From there you have to build the project. You have to build outside the
DeveloperStudio.

Jojan T. Antony,
Device Driver Group,
Network Systems and Technologies (P) Ltd.,
A-3 Periyar, Technopark,
Kariyavattom, Thiruvananthapuram
alt.email:xxxxx@eth.net
Ph:91-471-527441

-----Original Message-----
From: xxxxx@arl.nus.edu.sg [mailto:xxxxx@arl.nus.edu.sg]
Sent: Friday, January 05, 2001 8:08 AM
To: NT Developers Interest List
Subject: [ntdev] help PCI configuration

  1. I am a newcomer, so please sorry for my simple question

  2. Our computer:NT4.0
    NT4.0 DDK
    DEFAULT INSTALLATION

  3. I copy a sourcecode from Dekker’s book to implement the PCI
    enumeration.

The headfile is “ntddk.h”, it reference the HalGet… function,
I used the vc++6.0 to compile, the result is miserable which told me
there are 95 errors in ntddk.h.

would you like tell me where are my errors.
Thanks a lot


You are currently subscribed to ntdev as: xxxxx@nestec.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi, friend, Thanks very much for your reply, However I still in mess.

1.The follow is attached sourcecode:

  1. yes I followed your advice and checked the setting of vc6.0 vompiler.

IN THE /TOOLS/OPTIONS/directorses

I have added the c:\nt4ddk\nt4.ddk\ddk\inc
and c:\nt4ddk\nt4.ddk\ddk\lib

However I have not modified any settings of NT4.0DDK
because my installation is very smooth.

So if I should change some settings to make sure I can successfully
compile.

  1. I have stupid questions In my case if I first compile using vc compiler,
    then to use build command, so the compile errors are doesn’t matter?

Please NOTE: I treat our program as application program
because there isn’t driverentry subroutine.

Thanks very much in advance.

best regards
yours sincerely
/* THIS FUNCTION IS CALLED BY THE DRIVER TO FIND THE NEXT
PCI device and initialize the adapter’s configuration*/
/*

#include <ntddk.h>

BOOLEAN pciUtilIteratePCI(IN BOOLEAN First,
IN unsigned int pciVendorId,
IN unsigned int pciDeviceId,
IN OUT PCI_SLOT_NUMBER *returnSlotData,
IN OUT PCI_COMMON_CONFIG *returnPciData,
IN OUT unsigned int *returnBusNumber)

{ PUCHAR ioSpace;
ULONG i,j;
ULONG irq;
ULONG portBase
ULONG retryCount;
PCI_SLOT_NUMBER slotData;
PCI_COMMON_CONFIG pciData;
UCHAR statusByte;
BOOLEAN preConfig=FALSE;
BOOLEAN Found = FALSE;
unsigned int busNumber=1;

kdPrint((“pciUtil:FindPCI\n”));

/ITERATE OVER ALL PCI SLOTS/

slotData.u.AsULONG=0;

for(busNumber=First?0:*returnBusNumber;
busNumber<256; busNumber++)
{

for(slotData.u.bits.DeviceNumber=First?0:returnSlotData->u.bits.DeviceNumber;
slotData.u.bits.DeviceNumber<pci_max_devices-1> slotData.u.bits.DeviceNumber++)

{//Device enumeration

for(slotData.u.bits.FunctionNumber=First?0:(returnSlotData->u.bits.FunctionNumber++);
slotData.u.bits.FunctionNumber<pci_max_function-1> slotData.u.bits.FunctionNumber++)

{/function enumeration/
kdPrint((“pciUtil: FindPCI- call HalGetBusData DeviceNumber=%x,”
“function=%x, busNumber=%x %x”,
slotData.u.bits.DeviceNumber, slotData.u.bits.FunctionNumber,
busNumber,slotData.u.AsULONG));
if(HalGetBusData(PCIConfiguration,busNumber,
slotData.u.AsULONG,&pciData,sizeof(PCI_COMMON_CONFIG)))
{/FUNCTION EXISTS/
if(((0xFFFF==pciVendorId) || (pciData.VendorID==pciVendorId))
&&((0xFFFF==pciDeviceID)||(pciData.DeviceID==pciDeviceId))
)
{
*returnSlotData=slotData;
*returnPciData=pciData;
*returnBusNumber=busNumber;
Found=TRUE;
break;
}else
{
kdPrint(“\n incorrect\n”);
}
}
else
{
kdPrint(" HalGetBusData failed \n");
}
}
if(Found)
{
break;
}
}

if(!Found)
{
return(FALSE);
}

return(TRUE)
}

main()
{
IN BOOLEAN First;
IN unsigned int pciVendorId;
IN unsigned int pciDeviceId;
IN OUT PCI_SLOT_NUMBER *returnSlotData;
IN OUT PCI_COMMON_CONFIG *returnPciData;
IN OUT unsigned int *returnBusNumber;
BOOLEAN Last;

First=FALSE;
pciVendorId=103C;
pciDeviceId=102A;
returnSlotData=NULL;
returnPciData=NULL;
returnBusNumber=NULL;

Last=pciUtilIteratePCI( First,pciVendorId,
pciDeviceId,returnSlotData,returnPciData,
returnBusNumber);

return(Last);
}


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</pci_max_function-1></pci_max_devices-1></ntddk.h>

Hmmm… (its sometimes very hard to figure out where to start on problems
like these.)

Your source code is for an application, however the example in the Dekker
book is for a Device Driver. These (applications and device drivers) are
very different types of executable objects. For example: applications
execute in user space, device drivers execute in kernel space. The DDK has
numerous samples of device drivers, and even a few applications that
communicate with device drivers. You need to write a device driver that
examines the PCI configuration on behalf of an application (that you will
also have to create,) that communicates with your device driver and reports
the results to a user.

You will need to re-read the dekker book and the NT DDK until you are clear
on the difference between a device driver and an application.

Mark Roddy
xxxxx@hollistech.com
www.hollistech.com
WindowsNT Windows 2000 Consulting Services

-----Original Message-----
From: xxxxx@arl.nus.edu.sg [mailto:xxxxx@arl.nus.edu.sg]
Sent: Thursday, January 04, 2001 10:58 PM
To: NT Developers Interest List
Subject: [ntdev] RE: help PCI configuration

Hi, friend, Thanks very much for your reply, However I still in mess.

1.The follow is attached sourcecode:

  1. yes I followed your advice and checked the setting of
    vc6.0 vompiler.

IN THE /TOOLS/OPTIONS/directorses

I have added the c:\nt4ddk\nt4.ddk\ddk\inc
and c:\nt4ddk\nt4.ddk\ddk\lib

However I have not modified any settings of NT4.0DDK
because my installation is very smooth.

So if I should change some settings to make sure I can successfully
compile.

  1. I have stupid questions In my case if I first compile
    using vc compiler,
    then to use build command, so the compile errors are doesn’t matter?

Please NOTE: I treat our program as application program
because there isn’t driverentry subroutine.

Thanks very much in advance.

best regards
yours sincerely
/* THIS FUNCTION IS CALLED BY THE DRIVER TO FIND THE NEXT
PCI device and initialize the adapter’s configuration*/
/*

#include <ntddk.h>
>
>
>
> BOOLEAN pciUtilIteratePCI(IN BOOLEAN First,
> IN unsigned int pciVendorId,
> IN unsigned int pciDeviceId,
> IN OUT PCI_SLOT_NUMBER *returnSlotData,
> IN OUT PCI_COMMON_CONFIG *returnPciData,
> IN OUT unsigned int *returnBusNumber)
>
> { PUCHAR ioSpace;
> ULONG i,j;
> ULONG irq;
> ULONG portBase
> ULONG retryCount;
> PCI_SLOT_NUMBER slotData;
> PCI_COMMON_CONFIG pciData;
> UCHAR statusByte;
> BOOLEAN preConfig=FALSE;
> BOOLEAN Found = FALSE;
> unsigned int busNumber=1;
>
> kdPrint((“pciUtil:FindPCI\n”));
>
> /ITERATE OVER ALL PCI SLOTS/
>
> slotData.u.AsULONG=0;
>
> for(busNumber=First?0:*returnBusNumber;
> busNumber<256; busNumber++)
> {
>
> for(slotData.u.bits.DeviceNumber=First?0:returnSlotData->u.bit
> s.DeviceNumber;
> slotData.u.bits.DeviceNumber<pci_max_devices-1>> slotData.u.bits.DeviceNumber++)
>
> {//Device enumeration
>
>
> for(slotData.u.bits.FunctionNumber=First?0:(returnSlotData->u.
> bits.FunctionNumber++);
> slotData.u.bits.FunctionNumber<pci_max_function-1>> slotData.u.bits.FunctionNumber++)
>
> {/function enumeration/
> kdPrint((“pciUtil: FindPCI- call HalGetBusData
> DeviceNumber=%x,”
> “function=%x, busNumber=%x %x”,
> slotData.u.bits.DeviceNumber,
> slotData.u.bits.FunctionNumber,
> busNumber,slotData.u.AsULONG));
> if(HalGetBusData(PCIConfiguration,busNumber,
>
> slotData.u.AsULONG,&pciData,sizeof(PCI_COMMON_CONFIG)))
> {/FUNCTION EXISTS/
> if(((0xFFFF==pciVendorId) ||
> (pciData.VendorID==pciVendorId))
>
> &&((0xFFFF==pciDeviceID)||(pciData.DeviceID==pciDeviceId))
> )
> {
> *returnSlotData=slotData;
> *returnPciData=pciData;
> *returnBusNumber=busNumber;
> Found=TRUE;
> break;
> }else
> {
> kdPrint(“\n incorrect\n”);
> }
> }
> else
> {
> kdPrint(" HalGetBusData failed \n");
> }
> }
> if(Found)
> {
> break;
> }
> }
>
> if(!Found)
> {
> return(FALSE);
> }
>
> return(TRUE)
> }
>
> main()
> {
> IN BOOLEAN First;
> IN unsigned int pciVendorId;
> IN unsigned int pciDeviceId;
> IN OUT PCI_SLOT_NUMBER *returnSlotData;
> IN OUT PCI_COMMON_CONFIG *returnPciData;
> IN OUT unsigned int *returnBusNumber;
> BOOLEAN Last;
>
> First=FALSE;
> pciVendorId=103C;
> pciDeviceId=102A;
> returnSlotData=NULL;
> returnPciData=NULL;
> returnBusNumber=NULL;
>
> Last=pciUtilIteratePCI( First,pciVendorId,
> pciDeviceId,returnSlotData,returnPciData,
> returnBusNumber);
>
> return(Last);
> }
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@stratus.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</pci_max_function-1></pci_max_devices-1></ntddk.h>