Clarification needed for the PCI_COMMON_CONFIG structure

The struct I have for PCI_COMMON_CONFIG inside of wdm.h does not match up with what Microsoft shows on their documentation for PCI_COMMON_CONFIG.
https://msdn.microsoft.com/en-us/library/windows/hardware/ff537455(v=vs.85).aspx

This is what is present inside that header on my system.

typedef struct _PCI_COMMON_CONFIG {
PCI_COMMON_HEADER DUMMYSTRUCTNAME;
UCHAR DeviceSpecific[192];
} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;

Directly above this, there’s a struct called PCI_COMMON_HEADER, which DOES contain the fields that are present in the documentation for PCI_COMMON_CONFIG, along with two additional structs inside of the union.

#define PCI_TYPE0_ADDRESSES 6
#define PCI_TYPE1_ADDRESSES 2
#define PCI_TYPE2_ADDRESSES 5

typedef struct _PCI_COMMON_HEADER {
USHORT VendorID; // (ro)
USHORT DeviceID; // (ro)
USHORT Command; // Device control
USHORT Status;
UCHAR RevisionID; // (ro)
UCHAR ProgIf; // (ro)
UCHAR SubClass; // (ro)
UCHAR BaseClass; // (ro)
UCHAR CacheLineSize; // (ro+)
UCHAR LatencyTimer; // (ro+)
UCHAR HeaderType; // (ro)
UCHAR BIST; // Built in self test

union {
struct _PCI_HEADER_TYPE_0 {
ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
ULONG CIS;
USHORT SubVendorID;
USHORT SubSystemID;
ULONG ROMBaseAddress;
UCHAR CapabilitiesPtr;
UCHAR Reserved1[3];
ULONG Reserved2;
UCHAR InterruptLine; //
UCHAR InterruptPin; // (ro)
UCHAR MinimumGrant; // (ro)
UCHAR MaximumLatency; // (ro)
} type0;

//
// PCI to PCI Bridge
//

struct _PCI_HEADER_TYPE_1 {
ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
UCHAR PrimaryBus;
UCHAR SecondaryBus;
UCHAR SubordinateBus;
UCHAR SecondaryLatency;
UCHAR IOBase;
UCHAR IOLimit;
USHORT SecondaryStatus;
USHORT MemoryBase;
USHORT MemoryLimit;
USHORT PrefetchBase;
USHORT PrefetchLimit;
ULONG PrefetchBaseUpper32;
ULONG PrefetchLimitUpper32;
USHORT IOBaseUpper16;
USHORT IOLimitUpper16;
UCHAR CapabilitiesPtr;
UCHAR Reserved1[3];
ULONG ROMBaseAddress;
UCHAR InterruptLine;
UCHAR InterruptPin;
USHORT BridgeControl;
} type1;

//
// PCI to CARDBUS Bridge
//

struct _PCI_HEADER_TYPE_2 {
ULONG SocketRegistersBaseAddress;
UCHAR CapabilitiesPtr;
UCHAR Reserved;
USHORT SecondaryStatus;
UCHAR PrimaryBus;
UCHAR SecondaryBus;
UCHAR SubordinateBus;
UCHAR SecondaryLatency;
struct {
ULONG Base;
ULONG Limit;
} Range[PCI_TYPE2_ADDRESSES-1];
UCHAR InterruptLine;
UCHAR InterruptPin;
USHORT BridgeControl;
} type2;

} u;

} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER

The only reference that I see of PCI_COMMON_HEADER is in a Microsoft document titled “Accessing PCI Device Configuration Space”, but the struct they have for PCI_COMMON_HEADER is listed as:

typedef struct {
ULONG Reserved[HEADERSIZE];
} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;

I noticed this while going through the pcidrv example project and saw that I couldn’t access the fields that project was accessing. Do I use the PCI_COMMON_HEADER struct instead? or is this actually going to be some sort of a problem? I’m running WDK 8.1.

Do you have _MSC_EXTENSIONS defined in your project? If you look you will
see DUMMYSTRUCTNAME is defined as nothing if _MSC_EXTENSIONS is defined and
NONAMELESSUNION is not defined. PCIDRV assumes this.

Don Burn
Windows Driver Consulting
Website: http://www.windrvr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Wednesday, July 20, 2016 1:11 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Clarification needed for the PCI_COMMON_CONFIG structure

The struct I have for PCI_COMMON_CONFIG inside of wdm.h does not match up
with what Microsoft shows on their documentation for PCI_COMMON_CONFIG.
https://msdn.microsoft.com/en-us/library/windows/hardware/ff537455(v=vs.85).
aspx

This is what is present inside that header on my system.

typedef struct _PCI_COMMON_CONFIG {
PCI_COMMON_HEADER DUMMYSTRUCTNAME;
UCHAR DeviceSpecific[192];
} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;

Directly above this, there’s a struct called PCI_COMMON_HEADER, which DOES
contain the fields that are present in the documentation for
PCI_COMMON_CONFIG, along with two additional structs inside of the union.

#define PCI_TYPE0_ADDRESSES 6
#define PCI_TYPE1_ADDRESSES 2
#define PCI_TYPE2_ADDRESSES 5

typedef struct _PCI_COMMON_HEADER {
USHORT VendorID; // (ro)
USHORT DeviceID; // (ro)
USHORT Command; // Device control
USHORT Status;
UCHAR RevisionID; // (ro)
UCHAR ProgIf; // (ro)
UCHAR SubClass; // (ro)
UCHAR BaseClass; // (ro)
UCHAR CacheLineSize; // (ro+)
UCHAR LatencyTimer; // (ro+)
UCHAR HeaderType; // (ro)
UCHAR BIST; // Built in self test

union {
struct _PCI_HEADER_TYPE_0 {
ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
ULONG CIS;
USHORT SubVendorID;
USHORT SubSystemID;
ULONG ROMBaseAddress;
UCHAR CapabilitiesPtr;
UCHAR Reserved1[3];
ULONG Reserved2;
UCHAR InterruptLine; //
UCHAR InterruptPin; // (ro)
UCHAR MinimumGrant; // (ro)
UCHAR MaximumLatency; // (ro)
} type0;

//
// PCI to PCI Bridge
//

struct _PCI_HEADER_TYPE_1 {
ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
UCHAR PrimaryBus;
UCHAR SecondaryBus;
UCHAR SubordinateBus;
UCHAR SecondaryLatency;
UCHAR IOBase;
UCHAR IOLimit;
USHORT SecondaryStatus;
USHORT MemoryBase;
USHORT MemoryLimit;
USHORT PrefetchBase;
USHORT PrefetchLimit;
ULONG PrefetchBaseUpper32;
ULONG PrefetchLimitUpper32;
USHORT IOBaseUpper16;
USHORT IOLimitUpper16;
UCHAR CapabilitiesPtr;
UCHAR Reserved1[3];
ULONG ROMBaseAddress;
UCHAR InterruptLine;
UCHAR InterruptPin;
USHORT BridgeControl;
} type1;

//
// PCI to CARDBUS Bridge
//

struct _PCI_HEADER_TYPE_2 {
ULONG SocketRegistersBaseAddress;
UCHAR CapabilitiesPtr;
UCHAR Reserved;
USHORT SecondaryStatus;
UCHAR PrimaryBus;
UCHAR SecondaryBus;
UCHAR SubordinateBus;
UCHAR SecondaryLatency;
struct {
ULONG Base;
ULONG Limit;
} Range[PCI_TYPE2_ADDRESSES-1];
UCHAR InterruptLine;
UCHAR InterruptPin;
USHORT BridgeControl;
} type2;

} u;

} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER

The only reference that I see of PCI_COMMON_HEADER is in a Microsoft
document titled “Accessing PCI Device Configuration Space”, but the struct
they have for PCI_COMMON_HEADER is listed as:

typedef struct {
ULONG Reserved[HEADERSIZE];
} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;

I noticed this while going through the pcidrv example project and saw that I
couldn’t access the fields that project was accessing. Do I use the
PCI_COMMON_HEADER struct instead? or is this actually going to be some sort
of a problem? I’m running WDK 8.1.


NTDEV is sponsored by OSR

Visit the list online at:
http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software
drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at
http:</http:></http:></http:>

Ah, OK. Thanks, didn’t realize that.

On Wed, Jul 20, 2016 at 10:19 AM, Don Burn wrote:

> Do you have _MSC_EXTENSIONS defined in your project? If you look you will
> see DUMMYSTRUCTNAME is defined as nothing if _MSC_EXTENSIONS is defined and
> NONAMELESSUNION is not defined. PCIDRV assumes this.
>
>
> Don Burn
> Windows Driver Consulting
> Website: http://www.windrvr.com
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of
> xxxxx@gmail.com
> Sent: Wednesday, July 20, 2016 1:11 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Clarification needed for the PCI_COMMON_CONFIG structure
>
> The struct I have for PCI_COMMON_CONFIG inside of wdm.h does not match up
> with what Microsoft shows on their documentation for PCI_COMMON_CONFIG.
> https://msdn.microsoft.com/en-us/library/windows/hardware/ff537455(v=vs.85)
> .
> aspx
>
>
>
> This is what is present inside that header on my system.
>
> typedef struct _PCI_COMMON_CONFIG {
> PCI_COMMON_HEADER DUMMYSTRUCTNAME;
> UCHAR DeviceSpecific[192];
> } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
>
>
> Directly above this, there’s a struct called PCI_COMMON_HEADER, which DOES
> contain the fields that are present in the documentation for
> PCI_COMMON_CONFIG, along with two additional structs inside of the union.
>
>
> #define PCI_TYPE0_ADDRESSES 6
> #define PCI_TYPE1_ADDRESSES 2
> #define PCI_TYPE2_ADDRESSES 5
>
> typedef struct _PCI_COMMON_HEADER {
> USHORT VendorID; // (ro)
> USHORT DeviceID; // (ro)
> USHORT Command; // Device control
> USHORT Status;
> UCHAR RevisionID; // (ro)
> UCHAR ProgIf; // (ro)
> UCHAR SubClass; // (ro)
> UCHAR BaseClass; // (ro)
> UCHAR CacheLineSize; // (ro+)
> UCHAR LatencyTimer; // (ro+)
> UCHAR HeaderType; // (ro)
> UCHAR BIST; // Built in self test
>
> union {
> struct _PCI_HEADER_TYPE_0 {
> ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
> ULONG CIS;
> USHORT SubVendorID;
> USHORT SubSystemID;
> ULONG ROMBaseAddress;
> UCHAR CapabilitiesPtr;
> UCHAR Reserved1[3];
> ULONG Reserved2;
> UCHAR InterruptLine; //
> UCHAR InterruptPin; // (ro)
> UCHAR MinimumGrant; // (ro)
> UCHAR MaximumLatency; // (ro)
> } type0;
>
>
>
> //
> // PCI to PCI Bridge
> //
>
> struct _PCI_HEADER_TYPE_1 {
> ULONG BaseAddresses[PCI_TYPE1_ADDRESSES];
> UCHAR PrimaryBus;
> UCHAR SecondaryBus;
> UCHAR SubordinateBus;
> UCHAR SecondaryLatency;
> UCHAR IOBase;
> UCHAR IOLimit;
> USHORT SecondaryStatus;
> USHORT MemoryBase;
> USHORT MemoryLimit;
> USHORT PrefetchBase;
> USHORT PrefetchLimit;
> ULONG PrefetchBaseUpper32;
> ULONG PrefetchLimitUpper32;
> USHORT IOBaseUpper16;
> USHORT IOLimitUpper16;
> UCHAR CapabilitiesPtr;
> UCHAR Reserved1[3];
> ULONG ROMBaseAddress;
> UCHAR InterruptLine;
> UCHAR InterruptPin;
> USHORT BridgeControl;
> } type1;
>
> //
> // PCI to CARDBUS Bridge
> //
>
> struct _PCI_HEADER_TYPE_2 {
> ULONG SocketRegistersBaseAddress;
> UCHAR CapabilitiesPtr;
> UCHAR Reserved;
> USHORT SecondaryStatus;
> UCHAR PrimaryBus;
> UCHAR SecondaryBus;
> UCHAR SubordinateBus;
> UCHAR SecondaryLatency;
> struct {
> ULONG Base;
> ULONG Limit;
> } Range[PCI_TYPE2_ADDRESSES-1];
> UCHAR InterruptLine;
> UCHAR InterruptPin;
> USHORT BridgeControl;
> } type2;
>
>
>
> } u;
>
> } PCI_COMMON_HEADER, *PPCI_COMMON_HEADER
>
>
> The only reference that I see of PCI_COMMON_HEADER is in a Microsoft
> document titled “Accessing PCI Device Configuration Space”, but the struct
> they have for PCI_COMMON_HEADER is listed as:
>
> typedef struct {
> ULONG Reserved[HEADERSIZE];
> } PCI_COMMON_HEADER, *PPCI_COMMON_HEADER;
>
>
> I noticed this while going through the pcidrv example project and saw that
> I
> couldn’t access the fields that project was accessing. Do I use the
> PCI_COMMON_HEADER struct instead? or is this actually going to be some sort
> of a problem? I’m running WDK 8.1.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at:
> http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software
> drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at
> http:
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: <
> http://www.osronline.com/showlists.cfm?list=ntdev&gt;
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:></http:></http:>