ReactOS  0.4.15-dev-1150-g593bcce
pdo.c File Reference
#include "pci.h"
#include <initguid.h>
#include <wdmguid.h>
#include <debug.h>
Include dependency graph for pdo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define DBGPRINT(...)
 
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK_64   0xfffffffffffffff0ull
 
#define PCI_ADDRESS_IO_ADDRESS_MASK_64   0xfffffffffffffffcull
 

Functions

static NTSTATUS PdoQueryDeviceText (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static NTSTATUS PdoQueryId (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static NTSTATUS PdoQueryBusInformation (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static NTSTATUS PdoQueryCapabilities (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static BOOLEAN PdoReadPciBar (PPDO_DEVICE_EXTENSION DeviceExtension, ULONG Offset, PULONG OriginalValue, PULONG NewValue)
 
static BOOLEAN PdoGetRangeLength (PPDO_DEVICE_EXTENSION DeviceExtension, UCHAR Bar, PULONGLONG Base, PULONGLONG Length, PULONG Flags, PUCHAR NextBar, PULONGLONG MaximumAddress)
 
static NTSTATUS PdoQueryResourceRequirements (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static NTSTATUS PdoQueryResources (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static VOID NTAPI InterfaceReference (IN PVOID Context)
 
static VOID NTAPI InterfaceDereference (IN PVOID Context)
 
static BOOLEAN NTAPI InterfaceBusTranslateBusAddress (IN PVOID Context, IN PHYSICAL_ADDRESS BusAddress, IN ULONG Length, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 
static PDMA_ADAPTER NTAPI InterfaceBusGetDmaAdapter (IN PVOID Context, IN PDEVICE_DESCRIPTION DeviceDescription, OUT PULONG NumberOfMapRegisters)
 
static ULONG NTAPI InterfaceBusSetBusData (IN PVOID Context, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
static ULONG NTAPI InterfaceBusGetBusData (IN PVOID Context, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
static BOOLEAN NTAPI InterfacePciDevicePresent (IN USHORT VendorID, IN USHORT DeviceID, IN UCHAR RevisionID, IN USHORT SubVendorID, IN USHORT SubSystemID, IN ULONG Flags)
 
static BOOLEAN CheckPciDevice (IN PPCI_COMMON_CONFIG PciConfig, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
 
static BOOLEAN NTAPI InterfacePciDevicePresentEx (IN PVOID Context, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
 
static NTSTATUS PdoQueryInterface (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static NTSTATUS PdoStartDevice (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static NTSTATUS PdoReadConfig (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static NTSTATUS PdoWriteConfig (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
static NTSTATUS PdoQueryDeviceRelations (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
NTSTATUS PdoPnpControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS PdoPowerControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 

Variables

static TRANSLATE_BUS_ADDRESS InterfaceBusTranslateBusAddress
 
static GET_DMA_ADAPTER InterfaceBusGetDmaAdapter
 
static GET_SET_DEVICE_DATA InterfaceBusSetBusData
 
static GET_SET_DEVICE_DATA InterfaceBusGetBusData
 

Macro Definition Documentation

◆ DBGPRINT

#define DBGPRINT (   ...)

Definition at line 21 of file pdo.c.

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file pdo.c.

◆ PCI_ADDRESS_IO_ADDRESS_MASK_64

#define PCI_ADDRESS_IO_ADDRESS_MASK_64   0xfffffffffffffffcull

Definition at line 25 of file pdo.c.

◆ PCI_ADDRESS_MEMORY_ADDRESS_MASK_64

#define PCI_ADDRESS_MEMORY_ADDRESS_MASK_64   0xfffffffffffffff0ull

Definition at line 24 of file pdo.c.

Function Documentation

◆ CheckPciDevice()

static BOOLEAN CheckPciDevice ( IN PPCI_COMMON_CONFIG  PciConfig,
IN PPCI_DEVICE_PRESENCE_PARAMETERS  Parameters 
)
static

Definition at line 1147 of file pdo.c.

1150 {
1151  if ((Parameters->Flags & PCI_USE_VENDEV_IDS) &&
1152  (PciConfig->VendorID != Parameters->VendorID ||
1153  PciConfig->DeviceID != Parameters->DeviceID))
1154  {
1155  return FALSE;
1156  }
1157 
1159  (PciConfig->BaseClass != Parameters->BaseClass ||
1160  PciConfig->SubClass != Parameters->SubClass))
1161  {
1162  return FALSE;
1163  }
1164 
1165  if ((Parameters->Flags & PCI_USE_PROGIF) &&
1166  PciConfig->ProgIf != Parameters->ProgIf)
1167  {
1168  return FALSE;
1169  }
1170 
1172  (PciConfig->u.type0.SubVendorID != Parameters->SubVendorID ||
1173  PciConfig->u.type0.SubSystemID != Parameters->SubSystemID))
1174  {
1175  return FALSE;
1176  }
1177 
1178  if ((Parameters->Flags & PCI_USE_REVISION) &&
1179  PciConfig->RevisionID != Parameters->RevisionID)
1180  {
1181  return FALSE;
1182  }
1183 
1184  return TRUE;
1185 }
#define TRUE
Definition: types.h:120
#define PCI_USE_PROGIF
Definition: iotypes.h:853
#define PCI_USE_REVISION
Definition: iotypes.h:850
#define FALSE
Definition: types.h:117
#define PCI_USE_VENDEV_IDS
Definition: iotypes.h:851
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:887
#define PCI_USE_CLASS_SUBCLASS
Definition: iotypes.h:852
#define PCI_USE_SUBSYSTEM_IDS
Definition: iotypes.h:849

Referenced by InterfacePciDevicePresentEx().

◆ InterfaceBusGetBusData()

static ULONG NTAPI InterfaceBusGetBusData ( IN PVOID  Context,
IN ULONG  DataType,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)
static

Definition at line 1060 of file pdo.c.

1066 {
1067  PPDO_DEVICE_EXTENSION DeviceExtension;
1068  ULONG Size;
1069 
1070  DPRINT("InterfaceBusGetBusData(%p 0x%lx %p 0x%lx 0x%lx) called\n",
1072 
1074  {
1075  DPRINT("Unknown DataType %lu\n", DataType);
1076  return 0;
1077  }
1078 
1079  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
1080 
1081  /* Get PCI configuration space */
1083  DeviceExtension->PciDevice->BusNumber,
1084  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
1085  Buffer,
1086  Offset,
1087  Length);
1088  return Size;
1089 }
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PPCI_DEVICE PciDevice
Definition: pci.h:60
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
ULONG BusNumber
Definition: pci.h:16
union _PCI_SLOT_NUMBER::@3763 u
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3623
ULONG NTAPI HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:73
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
PCI_SLOT_NUMBER SlotNumber
Definition: pci.h:18
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG DataType
Definition: iotypes.h:803

◆ InterfaceBusGetDmaAdapter()

static PDMA_ADAPTER NTAPI InterfaceBusGetDmaAdapter ( IN PVOID  Context,
IN PDEVICE_DESCRIPTION  DeviceDescription,
OUT PULONG  NumberOfMapRegisters 
)
static

Definition at line 1009 of file pdo.c.

1013 {
1014  DPRINT("InterfaceBusGetDmaAdapter(%p %p %p)\n",
1017 }
_Out_ PULONG NumberOfMapRegisters
Definition: halfuncs.h:209
void DPRINT(...)
Definition: polytest.cpp:61
_Must_inspect_result_ _In_ PDEVICE_DESCRIPTION DeviceDescription
Definition: iofuncs.h:1015
PADAPTER_OBJECT NTAPI HalGetAdapter(IN PDEVICE_DESCRIPTION DeviceDescription, OUT PULONG NumberOfMapRegisters)
Definition: dma.c:22

◆ InterfaceBusSetBusData()

static ULONG NTAPI InterfaceBusSetBusData ( IN PVOID  Context,
IN ULONG  DataType,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)
static

Definition at line 1024 of file pdo.c.

1030 {
1031  PPDO_DEVICE_EXTENSION DeviceExtension;
1032  ULONG Size;
1033 
1034  DPRINT("InterfaceBusSetBusData(%p 0x%lx %p 0x%lx 0x%lx)\n",
1036 
1038  {
1039  DPRINT("Unknown DataType %lu\n", DataType);
1040  return 0;
1041  }
1042 
1043  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
1044 
1045  /* Get PCI configuration space */
1047  DeviceExtension->PciDevice->BusNumber,
1048  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
1049  Buffer,
1050  Offset,
1051  Length);
1052  return Size;
1053 }
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PPCI_DEVICE PciDevice
Definition: pci.h:60
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
ULONG BusNumber
Definition: pci.h:16
union _PCI_SLOT_NUMBER::@3763 u
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3623
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
PCI_SLOT_NUMBER SlotNumber
Definition: pci.h:18
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
_In_ ULONG DataType
Definition: iotypes.h:803
ULONG NTAPI HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:123

◆ InterfaceBusTranslateBusAddress()

static BOOLEAN NTAPI InterfaceBusTranslateBusAddress ( IN PVOID  Context,
IN PHYSICAL_ADDRESS  BusAddress,
IN ULONG  Length,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress 
)
static

Definition at line 983 of file pdo.c.

989 {
990  PPDO_DEVICE_EXTENSION DeviceExtension;
991 
992  DPRINT("InterfaceBusTranslateBusAddress(%p %p 0x%lx %p %p)\n",
994 
995  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
996 
998  DeviceExtension->PciDevice->BusNumber,
999  BusAddress,
1000  AddressSpace,
1002 }
_In_ ULONG _In_ PHYSICAL_ADDRESS BusAddress
Definition: iofuncs.h:2268
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PPCI_DEVICE PciDevice
Definition: pci.h:60
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2268
ULONG BusNumber
Definition: pci.h:16
void DPRINT(...)
Definition: polytest.cpp:61
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bus.c:140
struct tagContext Context
Definition: acpixf.h:1034

◆ InterfaceDereference()

static VOID NTAPI InterfaceDereference ( IN PVOID  Context)
static

Definition at line 967 of file pdo.c.

969 {
970  PPDO_DEVICE_EXTENSION DeviceExtension;
971 
972  DPRINT("InterfaceDereference(%p)\n", Context);
973 
974  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
975  InterlockedDecrement(&DeviceExtension->References);
976 }
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
void DPRINT(...)
Definition: polytest.cpp:61
#define InterlockedDecrement
Definition: armddk.h:52
struct tagContext Context
Definition: acpixf.h:1034

Referenced by PdoQueryInterface().

◆ InterfacePciDevicePresent()

static BOOLEAN NTAPI InterfacePciDevicePresent ( IN USHORT  VendorID,
IN USHORT  DeviceID,
IN UCHAR  RevisionID,
IN USHORT  SubVendorID,
IN USHORT  SubSystemID,
IN ULONG  Flags 
)
static

Definition at line 1093 of file pdo.c.

1100 {
1101  PFDO_DEVICE_EXTENSION FdoDeviceExtension;
1102  PPCI_DEVICE PciDevice;
1103  PLIST_ENTRY CurrentBus, CurrentEntry;
1104  KIRQL OldIrql;
1105  BOOLEAN Found = FALSE;
1106 
1108  CurrentBus = DriverExtension->BusListHead.Flink;
1109  while (!Found && CurrentBus != &DriverExtension->BusListHead)
1110  {
1111  FdoDeviceExtension = CONTAINING_RECORD(CurrentBus, FDO_DEVICE_EXTENSION, ListEntry);
1112 
1113  KeAcquireSpinLockAtDpcLevel(&FdoDeviceExtension->DeviceListLock);
1114  CurrentEntry = FdoDeviceExtension->DeviceListHead.Flink;
1115  while (!Found && CurrentEntry != &FdoDeviceExtension->DeviceListHead)
1116  {
1117  PciDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
1118  if (PciDevice->PciConfig.VendorID == VendorID &&
1119  PciDevice->PciConfig.DeviceID == DeviceID)
1120  {
1121  if (!(Flags & PCI_USE_SUBSYSTEM_IDS) ||
1122  (PciDevice->PciConfig.u.type0.SubVendorID == SubVendorID &&
1123  PciDevice->PciConfig.u.type0.SubSystemID == SubSystemID))
1124  {
1125  if (!(Flags & PCI_USE_REVISION) ||
1126  PciDevice->PciConfig.RevisionID == RevisionID)
1127  {
1128  DPRINT("Found the PCI device\n");
1129  Found = TRUE;
1130  }
1131  }
1132  }
1133 
1134  CurrentEntry = CurrentEntry->Flink;
1135  }
1136 
1137  KeReleaseSpinLockFromDpcLevel(&FdoDeviceExtension->DeviceListLock);
1138  CurrentBus = CurrentBus->Flink;
1139  }
1141 
1142  return Found;
1143 }
#define TRUE
Definition: types.h:120
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
_In_ USHORT DeviceID
Definition: iotypes.h:875
Definition: pci.h:9
KSPIN_LOCK DeviceListLock
Definition: pci.h:93
#define PCI_USE_REVISION
Definition: iotypes.h:850
_In_ USHORT _In_ UCHAR RevisionID
Definition: iotypes.h:875
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
return Found
Definition: dirsup.c:1270
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
_In_ USHORT _In_ UCHAR _In_ USHORT SubVendorID
Definition: iotypes.h:875
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
KSPIN_LOCK BusListLock
Definition: pci.h:105
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
LIST_ENTRY BusListHead
Definition: pci.h:103
Definition: typedefs.h:119
_In_ USHORT _In_ UCHAR _In_ USHORT _In_ USHORT SubSystemID
Definition: iotypes.h:875
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
LIST_ENTRY DeviceListHead
Definition: pci.h:89
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
PCI_COMMON_CONFIG PciConfig
Definition: pci.h:20
#define PCI_USE_SUBSYSTEM_IDS
Definition: iotypes.h:849

Referenced by PdoQueryInterface().

◆ InterfacePciDevicePresentEx()

static BOOLEAN NTAPI InterfacePciDevicePresentEx ( IN PVOID  Context,
IN PPCI_DEVICE_PRESENCE_PARAMETERS  Parameters 
)
static

Definition at line 1189 of file pdo.c.

1192 {
1193  PPDO_DEVICE_EXTENSION DeviceExtension;
1194  PFDO_DEVICE_EXTENSION MyFdoDeviceExtension;
1195  PFDO_DEVICE_EXTENSION FdoDeviceExtension;
1196  PPCI_DEVICE PciDevice;
1197  PLIST_ENTRY CurrentBus, CurrentEntry;
1198  KIRQL OldIrql;
1199  BOOLEAN Found = FALSE;
1200 
1201  DPRINT("InterfacePciDevicePresentEx(%p %p) called\n",
1202  Context, Parameters);
1203 
1205  return FALSE;
1206 
1207  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
1208  MyFdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceExtension->Fdo->DeviceExtension;
1209 
1211  {
1212  return CheckPciDevice(&DeviceExtension->PciDevice->PciConfig, Parameters);
1213  }
1214 
1216  CurrentBus = DriverExtension->BusListHead.Flink;
1217  while (!Found && CurrentBus != &DriverExtension->BusListHead)
1218  {
1219  FdoDeviceExtension = CONTAINING_RECORD(CurrentBus, FDO_DEVICE_EXTENSION, ListEntry);
1220  if (!(Parameters->Flags & PCI_USE_LOCAL_BUS) || FdoDeviceExtension == MyFdoDeviceExtension)
1221  {
1222  KeAcquireSpinLockAtDpcLevel(&FdoDeviceExtension->DeviceListLock);
1223  CurrentEntry = FdoDeviceExtension->DeviceListHead.Flink;
1224  while (!Found && CurrentEntry != &FdoDeviceExtension->DeviceListHead)
1225  {
1226  PciDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
1227 
1228  if (CheckPciDevice(&PciDevice->PciConfig, Parameters))
1229  {
1230  DPRINT("Found the PCI device\n");
1231  Found = TRUE;
1232  }
1233 
1234  CurrentEntry = CurrentEntry->Flink;
1235  }
1236 
1237  KeReleaseSpinLockFromDpcLevel(&FdoDeviceExtension->DeviceListLock);
1238  }
1239  CurrentBus = CurrentBus->Flink;
1240  }
1242 
1243  return Found;
1244 }
#define TRUE
Definition: types.h:120
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
static BOOLEAN CheckPciDevice(IN PPCI_COMMON_CONFIG PciConfig, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
Definition: pdo.c:1147
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PDEVICE_OBJECT Fdo
Definition: pci.h:58
PPCI_DEVICE PciDevice
Definition: pci.h:60
Definition: pci.h:9
KSPIN_LOCK DeviceListLock
Definition: pci.h:93
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
return Found
Definition: dirsup.c:1270
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define PCI_USE_LOCAL_DEVICE
Definition: iotypes.h:855
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
KSPIN_LOCK BusListLock
Definition: pci.h:105
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:887
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
LIST_ENTRY BusListHead
Definition: pci.h:103
Definition: typedefs.h:119
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
LIST_ENTRY DeviceListHead
Definition: pci.h:89
#define PCI_USE_LOCAL_BUS
Definition: iotypes.h:854
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
struct tagContext Context
Definition: acpixf.h:1034
PCI_COMMON_CONFIG PciConfig
Definition: pci.h:20

Referenced by PdoQueryInterface().

◆ InterfaceReference()

static VOID NTAPI InterfaceReference ( IN PVOID  Context)
static

Definition at line 954 of file pdo.c.

956 {
957  PPDO_DEVICE_EXTENSION DeviceExtension;
958 
959  DPRINT("InterfaceReference(%p)\n", Context);
960 
961  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
962  InterlockedIncrement(&DeviceExtension->References);
963 }
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
void DPRINT(...)
Definition: polytest.cpp:61
#define InterlockedIncrement
Definition: armddk.h:53
struct tagContext Context
Definition: acpixf.h:1034

Referenced by PdoQueryInterface().

◆ PdoGetRangeLength()

static BOOLEAN PdoGetRangeLength ( PPDO_DEVICE_EXTENSION  DeviceExtension,
UCHAR  Bar,
PULONGLONG  Base,
PULONGLONG  Length,
PULONG  Flags,
PUCHAR  NextBar,
PULONGLONG  MaximumAddress 
)
static

Definition at line 263 of file pdo.c.

270 {
271  union {
272  struct {
273  ULONG Bar0;
274  ULONG Bar1;
275  } Bars;
276  ULONGLONG Bar;
277  } OriginalValue;
278  union {
279  struct {
280  ULONG Bar0;
281  ULONG Bar1;
282  } Bars;
283  ULONGLONG Bar;
284  } NewValue;
285  ULONG Offset;
286 
287  /* Compute the offset of this BAR in PCI config space */
288  Offset = 0x10 + Bar * 4;
289 
290  /* Assume this is a 32-bit BAR until we find wrong */
291  *NextBar = Bar + 1;
292 
293  /* Initialize BAR values to zero */
294  OriginalValue.Bar = 0ULL;
295  NewValue.Bar = 0ULL;
296 
297  /* Read the first BAR */
298  if (!PdoReadPciBar(DeviceExtension, Offset,
299  &OriginalValue.Bars.Bar0,
300  &NewValue.Bars.Bar0))
301  {
302  return FALSE;
303  }
304 
305  /* Check if this is a memory BAR */
306  if (!(OriginalValue.Bars.Bar0 & PCI_ADDRESS_IO_SPACE))
307  {
308  /* Write the maximum address if the caller asked for it */
309  if (MaximumAddress != NULL)
310  {
311  if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_32BIT)
312  {
313  *MaximumAddress = 0x00000000FFFFFFFFULL;
314  }
315  else if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_20BIT)
316  {
317  *MaximumAddress = 0x00000000000FFFFFULL;
318  }
319  else if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_64BIT)
320  {
321  *MaximumAddress = 0xFFFFFFFFFFFFFFFFULL;
322  }
323  }
324 
325  /* Check if this is a 64-bit BAR */
326  if ((OriginalValue.Bars.Bar0 & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_64BIT)
327  {
328  /* We've now consumed the next BAR too */
329  *NextBar = Bar + 2;
330 
331  /* Read the next BAR */
332  if (!PdoReadPciBar(DeviceExtension, Offset + 4,
333  &OriginalValue.Bars.Bar1,
334  &NewValue.Bars.Bar1))
335  {
336  return FALSE;
337  }
338  }
339  }
340  else
341  {
342  /* Write the maximum I/O port address */
343  if (MaximumAddress != NULL)
344  {
345  *MaximumAddress = 0x00000000FFFFFFFFULL;
346  }
347  }
348 
349  if (NewValue.Bar == 0)
350  {
351  DPRINT("Unused address register\n");
352  *Base = 0;
353  *Length = 0;
354  *Flags = 0;
355  return TRUE;
356  }
357 
358  *Base = ((OriginalValue.Bar & PCI_ADDRESS_IO_SPACE)
359  ? (OriginalValue.Bar & PCI_ADDRESS_IO_ADDRESS_MASK_64)
360  : (OriginalValue.Bar & PCI_ADDRESS_MEMORY_ADDRESS_MASK_64));
361 
362  *Length = ~((NewValue.Bar & PCI_ADDRESS_IO_SPACE)
363  ? (NewValue.Bar & PCI_ADDRESS_IO_ADDRESS_MASK_64)
364  : (NewValue.Bar & PCI_ADDRESS_MEMORY_ADDRESS_MASK_64)) + 1;
365 
366  *Flags = (NewValue.Bar & PCI_ADDRESS_IO_SPACE)
367  ? (NewValue.Bar & ~PCI_ADDRESS_IO_ADDRESS_MASK_64)
368  : (NewValue.Bar & ~PCI_ADDRESS_MEMORY_ADDRESS_MASK_64);
369 
370  return TRUE;
371 }
#define PCI_TYPE_20BIT
Definition: iotypes.h:4217
#define TRUE
Definition: types.h:120
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK_64
Definition: pdo.c:24
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2373
#define PCI_ADDRESS_MEMORY_TYPE_MASK
Definition: iotypes.h:4210
#define PCI_TYPE_32BIT
Definition: iotypes.h:4216
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define PCI_ADDRESS_IO_ADDRESS_MASK_64
Definition: pdo.c:25
void DPRINT(...)
Definition: polytest.cpp:61
#define ULL(a, b)
Definition: format_msg.c:27
uint64_t ULONGLONG
Definition: typedefs.h:67
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define PCI_TYPE_64BIT
Definition: iotypes.h:4218
unsigned int ULONG
Definition: retypes.h:1
static BOOLEAN PdoReadPciBar(PPDO_DEVICE_EXTENSION DeviceExtension, ULONG Offset, PULONG OriginalValue, PULONG NewValue)
Definition: pdo.c:198
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4209

Referenced by PdoQueryResourceRequirements(), and PdoQueryResources().

◆ PdoPnpControl()

NTSTATUS PdoPnpControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 1500 of file pdo.c.

1511 {
1513  NTSTATUS Status;
1514 
1515  DPRINT("Called\n");
1516 
1517  Status = Irp->IoStatus.Status;
1518 
1520 
1521  switch (IrpSp->MinorFunction)
1522  {
1524  DPRINT("Unimplemented IRP_MN_DEVICE_USAGE_NOTIFICATION received\n");
1525  break;
1526 
1527  case IRP_MN_EJECT:
1528  DPRINT("Unimplemented IRP_MN_EJECT received\n");
1529  break;
1530 
1533  break;
1534 
1537  break;
1538 
1541  break;
1542 
1544  DPRINT("IRP_MN_QUERY_DEVICE_TEXT received\n");
1546  break;
1547 
1548  case IRP_MN_QUERY_ID:
1549  DPRINT("IRP_MN_QUERY_ID received\n");
1551  break;
1552 
1554  DPRINT("Unimplemented IRP_MN_QUERY_ID received\n");
1555  break;
1556 
1558  DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS received\n");
1560  break;
1561 
1563  DPRINT("IRP_MN_QUERY_RESOURCES received\n");
1565  break;
1566 
1567  case IRP_MN_SET_LOCK:
1568  DPRINT("Unimplemented IRP_MN_SET_LOCK received\n");
1569  break;
1570 
1571  case IRP_MN_START_DEVICE:
1573  break;
1574 
1577  case IRP_MN_STOP_DEVICE:
1580  case IRP_MN_REMOVE_DEVICE:
1583  break;
1584 
1586  DPRINT("IRP_MN_QUERY_INTERFACE received\n");
1588  break;
1589 
1590  case IRP_MN_READ_CONFIG:
1591  DPRINT("IRP_MN_READ_CONFIG received\n");
1593  break;
1594 
1595  case IRP_MN_WRITE_CONFIG:
1596  DPRINT("IRP_MN_WRITE_CONFIG received\n");
1598  break;
1599 
1601  DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS received\n");
1602  /* Nothing to do */
1603  Irp->IoStatus.Status = Status;
1604  break;
1605 
1606  default:
1607  DPRINT1("Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
1608  break;
1609  }
1610 
1611  if (Status != STATUS_PENDING)
1612  {
1613  Irp->IoStatus.Status = Status;
1615  }
1616 
1617  DPRINT("Leaving. Status 0x%X\n", Status);
1618 
1619  return Status;
1620 }
#define IRP_MN_CANCEL_REMOVE_DEVICE
static NTSTATUS PdoQueryResources(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:700
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_ID
static NTSTATUS PdoQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:1469
_In_ PIRP Irp
Definition: csq.h:116
static NTSTATUS PdoQueryId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:74
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
static NTSTATUS PdoQueryInterface(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:1248
#define IRP_MN_WRITE_CONFIG
LONG NTSTATUS
Definition: precomp.h:26
static NTSTATUS PdoQueryDeviceText(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:30
#define IRP_MN_EJECT
static NTSTATUS PdoQueryBusInformation(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:141
#define IRP_MN_QUERY_REMOVE_DEVICE
static NTSTATUS PdoQueryCapabilities(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:169
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
static NTSTATUS PdoWriteConfig(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:1440
#define IRP_MN_READ_CONFIG
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_INTERFACE
#define IRP_MN_QUERY_BUS_INFORMATION
Status
Definition: gdiplustypes.h:24
static NTSTATUS PdoReadConfig(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:1411
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define DPRINT1
Definition: precomp.h:8
#define IRP_MN_SET_LOCK
#define IO_NO_INCREMENT
Definition: iotypes.h:581
static NTSTATUS PdoStartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:1318
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
static NTSTATUS PdoQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:375
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_QUERY_CAPABILITIES

Referenced by PciPnpControl().

◆ PdoPowerControl()

NTSTATUS PdoPowerControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 1623 of file pdo.c.

1634 {
1636  NTSTATUS Status = Irp->IoStatus.Status;
1637 
1638  DPRINT("Called\n");
1639 
1641 
1642  switch (IrpSp->MinorFunction)
1643  {
1644  case IRP_MN_QUERY_POWER:
1645  case IRP_MN_SET_POWER:
1647  break;
1648  }
1649 
1651  Irp->IoStatus.Status = Status;
1653 
1654  DPRINT("Leaving. Status 0x%X\n", Status);
1655 
1656  return Status;
1657 }
#define IRP_MN_QUERY_POWER
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
#define IRP_MN_SET_POWER
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:737
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define IO_NO_INCREMENT
Definition: iotypes.h:581
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by PciPowerControl().

◆ PdoQueryBusInformation()

static NTSTATUS PdoQueryBusInformation ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 141 of file pdo.c.

145 {
146  PPDO_DEVICE_EXTENSION DeviceExtension;
147  PPNP_BUS_INFORMATION BusInformation;
148 
150  DPRINT("Called\n");
151 
152  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
153  BusInformation = ExAllocatePoolWithTag(PagedPool, sizeof(PNP_BUS_INFORMATION), TAG_PCI);
154  Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
155  if (BusInformation != NULL)
156  {
157  BusInformation->BusTypeGuid = GUID_BUS_TYPE_PCI;
158  BusInformation->LegacyBusType = PCIBus;
159  BusInformation->BusNumber = DeviceExtension->PciDevice->BusNumber;
160 
161  return STATUS_SUCCESS;
162  }
163 
165 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PPCI_DEVICE PciDevice
Definition: pci.h:60
ULONG BusNumber
Definition: pci.h:16
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define TAG_PCI
Definition: pci.h:7
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define ULONG_PTR
Definition: config.h:101
return STATUS_SUCCESS
Definition: btrfs.c:3014
INTERFACE_TYPE LegacyBusType
Definition: cmtypes.h:365

Referenced by PdoPnpControl().

◆ PdoQueryCapabilities()

static NTSTATUS PdoQueryCapabilities ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 169 of file pdo.c.

173 {
174  PPDO_DEVICE_EXTENSION DeviceExtension;
176  ULONG DeviceNumber, FunctionNumber;
177 
179  DPRINT("Called\n");
180 
181  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
182  DeviceCapabilities = IrpSp->Parameters.DeviceCapabilities.Capabilities;
183 
184  if (DeviceCapabilities->Version != 1)
185  return STATUS_UNSUCCESSFUL;
186 
187  DeviceNumber = DeviceExtension->PciDevice->SlotNumber.u.bits.DeviceNumber;
188  FunctionNumber = DeviceExtension->PciDevice->SlotNumber.u.bits.FunctionNumber;
189 
190  DeviceCapabilities->UniqueID = FALSE;
191  DeviceCapabilities->Address = ((DeviceNumber << 16) & 0xFFFF0000) + (FunctionNumber & 0xFFFF);
192  DeviceCapabilities->UINumber = MAXULONG; /* FIXME */
193 
194  return STATUS_SUCCESS;
195 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
struct _PCI_SLOT_NUMBER::@3763::@3764 bits
PPCI_DEVICE PciDevice
Definition: pci.h:60
#define FALSE
Definition: types.h:117
union _PCI_SLOT_NUMBER::@3763 u
#define DeviceCapabilities
Definition: wingdi.h:4448
void DPRINT(...)
Definition: polytest.cpp:61
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
* PDEVICE_CAPABILITIES
Definition: iotypes.h:948
#define MAXULONG
Definition: typedefs.h:251
PCI_SLOT_NUMBER SlotNumber
Definition: pci.h:18
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
unsigned int ULONG
Definition: retypes.h:1
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by PdoPnpControl().

◆ PdoQueryDeviceRelations()

static NTSTATUS PdoQueryDeviceRelations ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 1469 of file pdo.c.

1473 {
1474  PDEVICE_RELATIONS DeviceRelations;
1475 
1476  /* We only support TargetDeviceRelation for child PDOs */
1477  if (IrpSp->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
1478  return Irp->IoStatus.Status;
1479 
1480  /* We can do this because we only return 1 PDO for TargetDeviceRelation */
1481  DeviceRelations = ExAllocatePoolWithTag(PagedPool, sizeof(*DeviceRelations), TAG_PCI);
1482  if (!DeviceRelations)
1484 
1485  DeviceRelations->Count = 1;
1486  DeviceRelations->Objects[0] = DeviceObject;
1487 
1488  /* The PnP manager will remove this when it is done with the PDO */
1490 
1491  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
1492 
1493  return STATUS_SUCCESS;
1494 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2143
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define TAG_PCI
Definition: pci.h:7
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define ObReferenceObject
Definition: obfuncs.h:204
#define ULONG_PTR
Definition: config.h:101
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by PdoPnpControl().

◆ PdoQueryDeviceText()

static NTSTATUS PdoQueryDeviceText ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 30 of file pdo.c.

34 {
35  PPDO_DEVICE_EXTENSION DeviceExtension;
38 
39  DPRINT("Called\n");
40 
41  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
42 
43  switch (IrpSp->Parameters.QueryDeviceText.DeviceTextType)
44  {
47  &DeviceExtension->DeviceDescription,
48  &String);
49 
50  DPRINT("DeviceTextDescription\n");
51  Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
52  break;
53 
56  &DeviceExtension->DeviceLocation,
57  &String);
58 
59  DPRINT("DeviceTextLocationInformation\n");
60  Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
61  break;
62 
63  default:
64  Irp->IoStatus.Information = 0;
66  break;
67  }
68 
69  return Status;
70 }
NTSTATUS PciDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: pci.c:670
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
static WCHAR String[]
Definition: stringtable.c:55
void DPRINT(...)
Definition: polytest.cpp:61
switch(r->id)
Definition: btrfs.c:2980
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: isapnp.h:82
UNICODE_STRING DeviceLocation
Definition: pci.h:72
UNICODE_STRING DeviceDescription
Definition: pci.h:70
Status
Definition: gdiplustypes.h:24
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define ULONG_PTR
Definition: config.h:101
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107

Referenced by PdoPnpControl().

◆ PdoQueryId()

static NTSTATUS PdoQueryId ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 74 of file pdo.c.

78 {
79  PPDO_DEVICE_EXTENSION DeviceExtension;
82 
83  DPRINT("Called\n");
84 
85  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
86 
87 // Irp->IoStatus.Information = 0;
88 
90 
92 
93  switch (IrpSp->Parameters.QueryId.IdType)
94  {
95  case BusQueryDeviceID:
97  &DeviceExtension->DeviceID,
98  &String);
99 
100  DPRINT("DeviceID: %S\n", String.Buffer);
101 
102  Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
103  break;
104 
105  case BusQueryHardwareIDs:
107  &DeviceExtension->HardwareIDs,
108  &String);
109 
110  Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
111  break;
112 
115  &DeviceExtension->CompatibleIDs,
116  &String);
117 
118  Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
119  break;
120 
121  case BusQueryInstanceID:
123  &DeviceExtension->InstanceID,
124  &String);
125 
126  DPRINT("InstanceID: %S\n", String.Buffer);
127 
128  Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
129  break;
130 
132  default:
134  }
135 
136  return Status;
137 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
NTSTATUS PciDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: pci.c:670
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
static WCHAR String[]
Definition: stringtable.c:55
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: isapnp.h:82
UNICODE_STRING HardwareIDs
Definition: pci.h:66
Status
Definition: gdiplustypes.h:24
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
UNICODE_STRING InstanceID
Definition: pci.h:64
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ULONG_PTR
Definition: config.h:101
UNICODE_STRING DeviceID
Definition: pci.h:62
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
UNICODE_STRING CompatibleIDs
Definition: pci.h:68

Referenced by PdoPnpControl().

◆ PdoQueryInterface()

static NTSTATUS PdoQueryInterface ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 1248 of file pdo.c.

1252 {
1253  NTSTATUS Status;
1254 
1256 
1257  if (RtlCompareMemory(IrpSp->Parameters.QueryInterface.InterfaceType,
1258  &GUID_BUS_INTERFACE_STANDARD, sizeof(GUID)) == sizeof(GUID))
1259  {
1260  /* BUS_INTERFACE_STANDARD */
1261  if (IrpSp->Parameters.QueryInterface.Version < 1)
1263  else if (IrpSp->Parameters.QueryInterface.Size < sizeof(BUS_INTERFACE_STANDARD))
1265  else
1266  {
1267  PBUS_INTERFACE_STANDARD BusInterface;
1268  BusInterface = (PBUS_INTERFACE_STANDARD)IrpSp->Parameters.QueryInterface.Interface;
1269  BusInterface->Size = sizeof(BUS_INTERFACE_STANDARD);
1270  BusInterface->Version = 1;
1272  BusInterface->GetDmaAdapter = InterfaceBusGetDmaAdapter;
1273  BusInterface->SetBusData = InterfaceBusSetBusData;
1274  BusInterface->GetBusData = InterfaceBusGetBusData;
1276  }
1277  }
1278  else if (RtlCompareMemory(IrpSp->Parameters.QueryInterface.InterfaceType,
1279  &GUID_PCI_DEVICE_PRESENT_INTERFACE, sizeof(GUID)) == sizeof(GUID))
1280  {
1281  /* PCI_DEVICE_PRESENT_INTERFACE */
1282  if (IrpSp->Parameters.QueryInterface.Version < 1)
1286  else
1287  {
1291  PciDevicePresentInterface->Version = 1;
1295  }
1296  }
1297  else
1298  {
1299  /* Not a supported interface */
1300  return STATUS_NOT_SUPPORTED;
1301  }
1302 
1303  if (NT_SUCCESS(Status))
1304  {
1305  /* Add a reference for the returned interface */
1308  Interface->Context = DeviceObject;
1309  Interface->InterfaceReference = InterfaceReference;
1310  Interface->InterfaceDereference = InterfaceDereference;
1311  Interface->InterfaceReference(Interface->Context);
1312  }
1313 
1314  return Status;
1315 }
PGET_DMA_ADAPTER GetDmaAdapter
Definition: iotypes.h:897
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
struct _BUS_INTERFACE_STANDARD * PBUS_INTERFACE_STANDARD
LONG NTSTATUS
Definition: precomp.h:26
static BOOLEAN NTAPI InterfacePciDevicePresentEx(IN PVOID Context, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
Definition: pdo.c:1189
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
static GET_SET_DEVICE_DATA InterfaceBusSetBusData
Definition: pdo.c:1019
static TRANSLATE_BUS_ADDRESS InterfaceBusTranslateBusAddress
Definition: pdo.c:978
static BOOLEAN NTAPI InterfacePciDevicePresent(IN USHORT VendorID, IN USHORT DeviceID, IN UCHAR RevisionID, IN USHORT SubVendorID, IN USHORT SubSystemID, IN ULONG Flags)
Definition: pdo.c:1093
PTRANSLATE_BUS_ADDRESS TranslateBusAddress
Definition: iotypes.h:896
struct _INTERFACE * PINTERFACE
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PGET_SET_DEVICE_DATA GetBusData
Definition: iotypes.h:899
Status
Definition: gdiplustypes.h:24
static GET_SET_DEVICE_DATA InterfaceBusGetBusData
Definition: pdo.c:1055
PGET_SET_DEVICE_DATA SetBusData
Definition: iotypes.h:898
struct _GUID GUID
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
struct _PCI_DEVICE_PRESENT_INTERFACE * PPCI_DEVICE_PRESENT_INTERFACE
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
static GET_DMA_ADAPTER InterfaceBusGetDmaAdapter
Definition: pdo.c:1004
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
static VOID NTAPI InterfaceDereference(IN PVOID Context)
Definition: pdo.c:967
PCI_INTERFACE PciDevicePresentInterface
Definition: devhere.c:18
static VOID NTAPI InterfaceReference(IN PVOID Context)
Definition: pdo.c:954
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465

Referenced by PdoPnpControl().

◆ PdoQueryResourceRequirements()

static NTSTATUS PdoQueryResourceRequirements ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 375 of file pdo.c.

379 {
380  PPDO_DEVICE_EXTENSION DeviceExtension;
381  PCI_COMMON_CONFIG PciConfig;
384  ULONG Size;
385  ULONG ResCount = 0;
386  ULONG ListSize;
387  UCHAR Bar;
388  ULONGLONG Base;
390  ULONG Flags;
391  ULONGLONG MaximumAddress;
392 
394  DPRINT("PdoQueryResourceRequirements() called\n");
395 
396  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
397 
398  /* Get PCI configuration space */
400  DeviceExtension->PciDevice->BusNumber,
401  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
402  &PciConfig,
404  DPRINT("Size %lu\n", Size);
406  {
407  Irp->IoStatus.Information = 0;
408  return STATUS_UNSUCCESSFUL;
409  }
410 
411  DPRINT("Command register: 0x%04hx\n", PciConfig.Command);
412 
413  /* Count required resource descriptors */
414  ResCount = 0;
415  if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
416  {
417  for (Bar = 0; Bar < PCI_TYPE0_ADDRESSES;)
418  {
419  if (!PdoGetRangeLength(DeviceExtension,
420  Bar,
421  &Base,
422  &Length,
423  &Flags,
424  &Bar,
425  NULL))
426  break;
427 
428  if (Length != 0)
429  ResCount += 2;
430  }
431 
432  /* FIXME: Check ROM address */
433 
434  if (PciConfig.u.type0.InterruptPin != 0)
435  ResCount++;
436  }
437  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
438  {
439  for (Bar = 0; Bar < PCI_TYPE1_ADDRESSES;)
440  {
441  if (!PdoGetRangeLength(DeviceExtension,
442  Bar,
443  &Base,
444  &Length,
445  &Flags,
446  &Bar,
447  NULL))
448  break;
449 
450  if (Length != 0)
451  ResCount += 2;
452  }
453 
454  if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
455  ResCount++;
456  }
457  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
458  {
459  /* FIXME: Count Cardbus bridge resources */
460  }
461  else
462  {
463  DPRINT1("Unsupported header type %d\n", PCI_CONFIGURATION_TYPE(&PciConfig));
464  }
465 
466  if (ResCount == 0)
467  {
468  Irp->IoStatus.Information = 0;
469  return STATUS_SUCCESS;
470  }
471 
472  /* Calculate the resource list size */
473  ListSize = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List[0].Descriptors) +
474  ResCount * sizeof(IO_RESOURCE_DESCRIPTOR);
475 
476  DPRINT("ListSize %lu (0x%lx)\n", ListSize, ListSize);
477 
478  /* Allocate the resource requirements list */
480  ListSize,
481  TAG_PCI);
482  if (ResourceList == NULL)
483  {
484  Irp->IoStatus.Information = 0;
486  }
487 
488  RtlZeroMemory(ResourceList, ListSize);
489  ResourceList->ListSize = ListSize;
490  ResourceList->InterfaceType = PCIBus;
491  ResourceList->BusNumber = DeviceExtension->PciDevice->BusNumber;
492  ResourceList->SlotNumber = DeviceExtension->PciDevice->SlotNumber.u.AsULONG;
493  ResourceList->AlternativeLists = 1;
494 
495  ResourceList->List[0].Version = 1;
496  ResourceList->List[0].Revision = 1;
497  ResourceList->List[0].Count = ResCount;
498 
499  Descriptor = &ResourceList->List[0].Descriptors[0];
500  if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
501  {
502  for (Bar = 0; Bar < PCI_TYPE0_ADDRESSES;)
503  {
504  if (!PdoGetRangeLength(DeviceExtension,
505  Bar,
506  &Base,
507  &Length,
508  &Flags,
509  &Bar,
510  &MaximumAddress))
511  {
512  DPRINT1("PdoGetRangeLength() failed\n");
513  break;
514  }
515 
516  if (Length == 0)
517  {
518  DPRINT("Unused address register\n");
519  continue;
520  }
521 
522  /* Set preferred descriptor */
525  {
527  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
531 
532  Descriptor->u.Port.Length = Length;
533  Descriptor->u.Port.Alignment = 1;
534  Descriptor->u.Port.MinimumAddress.QuadPart = Base;
535  Descriptor->u.Port.MaximumAddress.QuadPart = Base + Length - 1;
536  }
537  else
538  {
540  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
543 
544  Descriptor->u.Memory.Length = Length;
545  Descriptor->u.Memory.Alignment = 1;
546  Descriptor->u.Memory.MinimumAddress.QuadPart = Base;
547  Descriptor->u.Memory.MaximumAddress.QuadPart = Base + Length - 1;
548  }
549  Descriptor++;
550 
551  /* Set alternative descriptor */
554  {
556  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
560 
561  Descriptor->u.Port.Length = Length;
562  Descriptor->u.Port.Alignment = Length;
563  Descriptor->u.Port.MinimumAddress.QuadPart = 0;
564  Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress;
565  }
566  else
567  {
569  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
572 
573  Descriptor->u.Memory.Length = Length;
574  Descriptor->u.Memory.Alignment = Length;
575  Descriptor->u.Port.MinimumAddress.QuadPart = 0;
576  Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress;
577  }
578  Descriptor++;
579  }
580 
581  /* FIXME: Check ROM address */
582 
583  if (PciConfig.u.type0.InterruptPin != 0)
584  {
585  Descriptor->Option = 0; /* Required */
587  Descriptor->ShareDisposition = CmResourceShareShared;
589 
590  Descriptor->u.Interrupt.MinimumVector = 0;
591  Descriptor->u.Interrupt.MaximumVector = 0xFF;
592  }
593  }
594  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
595  {
596  for (Bar = 0; Bar < PCI_TYPE1_ADDRESSES;)
597  {
598  if (!PdoGetRangeLength(DeviceExtension,
599  Bar,
600  &Base,
601  &Length,
602  &Flags,
603  &Bar,
604  &MaximumAddress))
605  {
606  DPRINT1("PdoGetRangeLength() failed\n");
607  break;
608  }
609 
610  if (Length == 0)
611  {
612  DPRINT("Unused address register\n");
613  continue;
614  }
615 
616  /* Set preferred descriptor */
619  {
621  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
625 
626  Descriptor->u.Port.Length = Length;
627  Descriptor->u.Port.Alignment = 1;
628  Descriptor->u.Port.MinimumAddress.QuadPart = Base;
629  Descriptor->u.Port.MaximumAddress.QuadPart = Base + Length - 1;
630  }
631  else
632  {
634  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
637 
638  Descriptor->u.Memory.Length = Length;
639  Descriptor->u.Memory.Alignment = 1;
640  Descriptor->u.Memory.MinimumAddress.QuadPart = Base;
641  Descriptor->u.Memory.MaximumAddress.QuadPart = Base + Length - 1;
642  }
643  Descriptor++;
644 
645  /* Set alternative descriptor */
648  {
650  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
654 
655  Descriptor->u.Port.Length = Length;
656  Descriptor->u.Port.Alignment = Length;
657  Descriptor->u.Port.MinimumAddress.QuadPart = 0;
658  Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress;
659  }
660  else
661  {
663  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
666 
667  Descriptor->u.Memory.Length = Length;
668  Descriptor->u.Memory.Alignment = Length;
669  Descriptor->u.Port.MinimumAddress.QuadPart = 0;
670  Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress;
671  }
672  Descriptor++;
673  }
674 
675  if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
676  {
677  Descriptor->Option = 0; /* Required */
679  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
680 
681  ResourceList->BusNumber =
682  Descriptor->u.BusNumber.MinBusNumber =
683  Descriptor->u.BusNumber.MaxBusNumber = DeviceExtension->PciDevice->PciConfig.u.type1.SecondaryBus;
684  Descriptor->u.BusNumber.Length = 1;
685  Descriptor->u.BusNumber.Reserved = 0;
686  }
687  }
688  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
689  {
690  /* FIXME: Add Cardbus bridge resources */
691  }
692 
693  Irp->IoStatus.Information = (ULONG_PTR)ResourceList;
694 
695  return STATUS_SUCCESS;
696 }
#define PCI_TYPE0_ADDRESSES
Definition: iotypes.h:3479
#define CM_RESOURCE_MEMORY_PREFETCHABLE
Definition: cmtypes.h:123
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IO_RESOURCE_PREFERRED
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2373
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PPCI_DEVICE PciDevice
Definition: pci.h:60
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:120
#define CmResourceTypePort
Definition: hwresource.cpp:123
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
ULONG BusNumber
Definition: pci.h:16
union _PCI_SLOT_NUMBER::@3763 u
smooth NULL
Definition: ftsmooth.c:416
#define CM_RESOURCE_PORT_16_BIT_DECODE
Definition: cmtypes.h:112
void DPRINT(...)
Definition: polytest.cpp:61
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
static BOOLEAN PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension, UCHAR Bar, PULONGLONG Base, PULONGLONG Length, PULONG Flags, PUCHAR NextBar, PULONGLONG MaximumAddress)
Definition: pdo.c:263
LIST_ENTRY List
Definition: psmgr.c:57
#define CM_RESOURCE_PORT_POSITIVE_DECODE
Definition: cmtypes.h:113
uint64_t ULONGLONG
Definition: typedefs.h:67
#define PCI_DEVICE_TYPE
Definition: iotypes.h:3584
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: cdrom.h:932
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define IO_RESOURCE_ALTERNATIVE
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
#define TAG_PCI
Definition: pci.h:7
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
PCI_SLOT_NUMBER SlotNumber
Definition: pci.h:18
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
Definition: cmtypes.h:143
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
#define PCI_ADDRESS_MEMORY_PREFETCHABLE
Definition: iotypes.h:4211
#define PCI_CONFIGURATION_TYPE(PciData)
Definition: iotypes.h:3588
unsigned int ULONG
Definition: retypes.h:1
NTHALAPI ULONG NTAPI HalGetBusData(BUS_DATA_TYPE, ULONG, ULONG, PVOID, ULONG)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128
#define PCI_CLASS_BRIDGE_DEV
Definition: iotypes.h:4088
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define PCI_TYPE1_ADDRESSES
Definition: iotypes.h:3480
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4209
PCI_COMMON_CONFIG PciConfig
Definition: pci.h:20
#define PCI_CARDBUS_BRIDGE_TYPE
Definition: iotypes.h:3586
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3573
#define PCI_BRIDGE_TYPE
Definition: iotypes.h:3585

Referenced by PdoPnpControl().

◆ PdoQueryResources()

static NTSTATUS PdoQueryResources ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 700 of file pdo.c.

704 {
705  PPDO_DEVICE_EXTENSION DeviceExtension;
706  PCI_COMMON_CONFIG PciConfig;
708  PCM_PARTIAL_RESOURCE_LIST PartialList;
710  ULONG Size;
711  ULONG ResCount = 0;
712  ULONG ListSize;
713  UCHAR Bar;
714  ULONGLONG Base;
716  ULONG Flags;
717 
718  DPRINT("PdoQueryResources() called\n");
719 
721  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
722 
723  /* Get PCI configuration space */
725  DeviceExtension->PciDevice->BusNumber,
726  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
727  &PciConfig,
729  DPRINT("Size %lu\n", Size);
731  {
732  Irp->IoStatus.Information = 0;
733  return STATUS_UNSUCCESSFUL;
734  }
735 
736  DPRINT("Command register: 0x%04hx\n", PciConfig.Command);
737 
738  /* Count required resource descriptors */
739  ResCount = 0;
740  if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
741  {
742  for (Bar = 0; Bar < PCI_TYPE0_ADDRESSES;)
743  {
744  if (!PdoGetRangeLength(DeviceExtension,
745  Bar,
746  &Base,
747  &Length,
748  &Flags,
749  &Bar,
750  NULL))
751  break;
752 
753  if (Length)
754  ResCount++;
755  }
756 
757  if ((PciConfig.u.type0.InterruptPin != 0) &&
758  (PciConfig.u.type0.InterruptLine != 0) &&
759  (PciConfig.u.type0.InterruptLine != 0xFF))
760  ResCount++;
761  }
762  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
763  {
764  for (Bar = 0; Bar < PCI_TYPE1_ADDRESSES;)
765  {
766  if (!PdoGetRangeLength(DeviceExtension,
767  Bar,
768  &Base,
769  &Length,
770  &Flags,
771  &Bar,
772  NULL))
773  break;
774 
775  if (Length != 0)
776  ResCount++;
777  }
778 
779  if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
780  ResCount++;
781  }
782  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
783  {
784  /* FIXME: Count Cardbus bridge resources */
785  }
786  else
787  {
788  DPRINT1("Unsupported header type %d\n", PCI_CONFIGURATION_TYPE(&PciConfig));
789  }
790 
791  if (ResCount == 0)
792  {
793  Irp->IoStatus.Information = 0;
794  return STATUS_SUCCESS;
795  }
796 
797  /* Calculate the resource list size */
798  ListSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors) +
799  ResCount * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
800 
801  /* Allocate the resource list */
803  ListSize,
804  TAG_PCI);
805  if (ResourceList == NULL)
807 
808  RtlZeroMemory(ResourceList, ListSize);
809  ResourceList->Count = 1;
810  ResourceList->List[0].InterfaceType = PCIBus;
811  ResourceList->List[0].BusNumber = DeviceExtension->PciDevice->BusNumber;
812 
813  PartialList = &ResourceList->List[0].PartialResourceList;
814  PartialList->Version = 1;
815  PartialList->Revision = 1;
816  PartialList->Count = ResCount;
817 
818  Descriptor = &PartialList->PartialDescriptors[0];
819  if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
820  {
821  for (Bar = 0; Bar < PCI_TYPE0_ADDRESSES;)
822  {
823  if (!PdoGetRangeLength(DeviceExtension,
824  Bar,
825  &Base,
826  &Length,
827  &Flags,
828  &Bar,
829  NULL))
830  break;
831 
832  if (Length == 0)
833  {
834  DPRINT("Unused address register\n");
835  continue;
836  }
837 
839  {
841  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
845  Descriptor->u.Port.Start.QuadPart = (ULONGLONG)Base;
846  Descriptor->u.Port.Length = Length;
847 
848  /* Enable IO space access */
849  DeviceExtension->PciDevice->EnableIoSpace = TRUE;
850  }
851  else
852  {
854  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
857  Descriptor->u.Memory.Start.QuadPart = (ULONGLONG)Base;
858  Descriptor->u.Memory.Length = Length;
859 
860  /* Enable memory space access */
861  DeviceExtension->PciDevice->EnableMemorySpace = TRUE;
862  }
863 
864  Descriptor++;
865  }
866 
867  /* Add interrupt resource */
868  if ((PciConfig.u.type0.InterruptPin != 0) &&
869  (PciConfig.u.type0.InterruptLine != 0) &&
870  (PciConfig.u.type0.InterruptLine != 0xFF))
871  {
873  Descriptor->ShareDisposition = CmResourceShareShared;
875  Descriptor->u.Interrupt.Level = PciConfig.u.type0.InterruptLine;
876  Descriptor->u.Interrupt.Vector = PciConfig.u.type0.InterruptLine;
877  Descriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
878  }
879 
880  /* Allow bus master mode */
881  DeviceExtension->PciDevice->EnableBusMaster = TRUE;
882  }
883  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
884  {
885  for (Bar = 0; Bar < PCI_TYPE1_ADDRESSES;)
886  {
887  if (!PdoGetRangeLength(DeviceExtension,
888  Bar,
889  &Base,
890  &Length,
891  &Flags,
892  &Bar,
893  NULL))
894  break;
895 
896  if (Length == 0)
897  {
898  DPRINT("Unused address register\n");
899  continue;
900  }
901 
903  {
905  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
909  Descriptor->u.Port.Start.QuadPart = (ULONGLONG)Base;
910  Descriptor->u.Port.Length = Length;
911 
912  /* Enable IO space access */
913  DeviceExtension->PciDevice->EnableIoSpace = TRUE;
914  }
915  else
916  {
918  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
921  Descriptor->u.Memory.Start.QuadPart = (ULONGLONG)Base;
922  Descriptor->u.Memory.Length = Length;
923 
924  /* Enable memory space access */
925  DeviceExtension->PciDevice->EnableMemorySpace = TRUE;
926  }
927 
928  Descriptor++;
929  }
930 
931  if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
932  {
934  Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
935 
936  ResourceList->List[0].BusNumber =
937  Descriptor->u.BusNumber.Start = DeviceExtension->PciDevice->PciConfig.u.type1.SecondaryBus;
938  Descriptor->u.BusNumber.Length = 1;
939  Descriptor->u.BusNumber.Reserved = 0;
940  }
941  }
942  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
943  {
944  /* FIXME: Add Cardbus bridge resources */
945  }
946 
947  Irp->IoStatus.Information = (ULONG_PTR)ResourceList;
948 
949  return STATUS_SUCCESS;
950 }
#define PCI_TYPE0_ADDRESSES
Definition: iotypes.h:3479
BOOLEAN EnableMemorySpace
Definition: pci.h:22
#define CM_RESOURCE_MEMORY_PREFETCHABLE
Definition: cmtypes.h:123
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2373
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
PPCI_DEVICE PciDevice
Definition: pci.h:60
const MUI_LANGUAGE_RESOURCE ResourceList[]
Definition: muilanguages.h:414
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:120
#define CmResourceTypePort
Definition: hwresource.cpp:123
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
ULONG BusNumber
Definition: pci.h:16
union _PCI_SLOT_NUMBER::@3763 u
smooth NULL
Definition: ftsmooth.c:416
#define CM_RESOURCE_PORT_16_BIT_DECODE
Definition: cmtypes.h:112
BOOLEAN EnableBusMaster
Definition: pci.h:26
void DPRINT(...)
Definition: polytest.cpp:61
static BOOLEAN PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension, UCHAR Bar, PULONGLONG Base, PULONGLONG Length, PULONG Flags, PUCHAR NextBar, PULONGLONG MaximumAddress)
Definition: pdo.c:263
LIST_ENTRY List
Definition: psmgr.c:57
#define CM_RESOURCE_PORT_POSITIVE_DECODE
Definition: cmtypes.h:113
uint64_t ULONGLONG
Definition: typedefs.h:67
#define PCI_DEVICE_TYPE
Definition: iotypes.h:3584
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: cdrom.h:932
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
#define TAG_PCI
Definition: pci.h:7
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
BOOLEAN EnableIoSpace
Definition: pci.h:24
PCI_SLOT_NUMBER SlotNumber
Definition: pci.h:18
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
Definition: cmtypes.h:143
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define DPRINT1
Definition: precomp.h:8
#define PCI_ADDRESS_MEMORY_PREFETCHABLE
Definition: iotypes.h:4211
#define PCI_CONFIGURATION_TYPE(PciData)
Definition: iotypes.h:3588
unsigned int ULONG
Definition: retypes.h:1
NTHALAPI ULONG NTAPI HalGetBusData(BUS_DATA_TYPE, ULONG, ULONG, PVOID, ULONG)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
#define CmResourceTypeBusNumber
Definition: hwresource.cpp:128
#define PCI_CLASS_BRIDGE_DEV
Definition: iotypes.h:4088
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define PCI_TYPE1_ADDRESSES
Definition: iotypes.h:3480
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4209
PCI_COMMON_CONFIG PciConfig
Definition: pci.h:20
#define PCI_CARDBUS_BRIDGE_TYPE
Definition: iotypes.h:3586
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3573
#define PCI_BRIDGE_TYPE
Definition: iotypes.h:3585

Referenced by PdoPnpControl().

◆ PdoReadConfig()

static NTSTATUS PdoReadConfig ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 1411 of file pdo.c.

1415 {
1416  ULONG Size;
1417 
1418  DPRINT("PdoReadConfig() called\n");
1419 
1421  IrpSp->Parameters.ReadWriteConfig.WhichSpace,
1422  IrpSp->Parameters.ReadWriteConfig.Buffer,
1423  IrpSp->Parameters.ReadWriteConfig.Offset,
1424  IrpSp->Parameters.ReadWriteConfig.Length);
1425 
1426  if (Size != IrpSp->Parameters.ReadWriteConfig.Length)
1427  {
1428  DPRINT1("Size %lu Length %lu\n", Size, IrpSp->Parameters.ReadWriteConfig.Length);
1429  Irp->IoStatus.Information = 0;
1430  return STATUS_UNSUCCESSFUL;
1431  }
1432 
1433  Irp->IoStatus.Information = Size;
1434 
1435  return STATUS_SUCCESS;
1436 }
_In_ PIRP Irp
Definition: csq.h:116
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static GET_SET_DEVICE_DATA InterfaceBusGetBusData
Definition: pdo.c:1055
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by PdoPnpControl().

◆ PdoReadPciBar()

static BOOLEAN PdoReadPciBar ( PPDO_DEVICE_EXTENSION  DeviceExtension,
ULONG  Offset,
PULONG  OriginalValue,
PULONG  NewValue 
)
static

Definition at line 198 of file pdo.c.

202 {
203  ULONG Size;
204  ULONG AllOnes;
205 
206  /* Read the original value */
208  DeviceExtension->PciDevice->BusNumber,
209  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
210  OriginalValue,
211  Offset,
212  sizeof(ULONG));
213  if (Size != sizeof(ULONG))
214  {
215  DPRINT1("Wrong size %lu\n", Size);
216  return FALSE;
217  }
218 
219  /* Write all ones to determine which bits are held to zero */
220  AllOnes = MAXULONG;
222  DeviceExtension->PciDevice->BusNumber,
223  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
224  &AllOnes,
225  Offset,
226  sizeof(ULONG));
227  if (Size != sizeof(ULONG))
228  {
229  DPRINT1("Wrong size %lu\n", Size);
230  return FALSE;
231  }
232 
233  /* Get the range length */
235  DeviceExtension->PciDevice->BusNumber,
236  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
237  NewValue,
238  Offset,
239  sizeof(ULONG));
240  if (Size != sizeof(ULONG))
241  {
242  DPRINT1("Wrong size %lu\n", Size);
243  return FALSE;
244  }
245 
246  /* Restore original value */
248  DeviceExtension->PciDevice->BusNumber,
249  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
250  OriginalValue,
251  Offset,
252  sizeof(ULONG));
253  if (Size != sizeof(ULONG))
254  {
255  DPRINT1("Wrong size %lu\n", Size);
256  return FALSE;
257  }
258 
259  return TRUE;
260 }
#define TRUE
Definition: types.h:120
PPCI_DEVICE PciDevice
Definition: pci.h:60
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define FALSE
Definition: types.h:117
ULONG BusNumber
Definition: pci.h:16
union _PCI_SLOT_NUMBER::@3763 u
ULONG NTAPI HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:73
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define MAXULONG
Definition: typedefs.h:251
PCI_SLOT_NUMBER SlotNumber
Definition: pci.h:18
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
ULONG NTAPI HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:123

Referenced by PdoGetRangeLength().

◆ PdoStartDevice()

static NTSTATUS PdoStartDevice ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 1318 of file pdo.c.

1322 {
1323  PCM_RESOURCE_LIST RawResList = IrpSp->Parameters.StartDevice.AllocatedResources;
1324  PCM_FULL_RESOURCE_DESCRIPTOR RawFullDesc;
1325  PCM_PARTIAL_RESOURCE_DESCRIPTOR RawPartialDesc;
1326  ULONG i, ii;
1327  PPDO_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1328  UCHAR Irq;
1329  USHORT Command;
1330 
1332 
1333  if (!RawResList)
1334  return STATUS_SUCCESS;
1335 
1336  /* TODO: Assign the other resources we get to the card */
1337 
1338  RawFullDesc = &RawResList->List[0];
1339  for (i = 0; i < RawResList->Count; i++, RawFullDesc = CmiGetNextResourceDescriptor(RawFullDesc))
1340  {
1341  for (ii = 0; ii < RawFullDesc->PartialResourceList.Count; ii++)
1342  {
1343  /* Partial resource descriptors can be of variable size (CmResourceTypeDeviceSpecific),
1344  but only one is allowed and it must be the last one in the list! */
1345  RawPartialDesc = &RawFullDesc->PartialResourceList.PartialDescriptors[ii];
1346 
1347  if (RawPartialDesc->Type == CmResourceTypeInterrupt)
1348  {
1349  DPRINT("Assigning IRQ %u to PCI device 0x%x on bus 0x%x\n",
1350  RawPartialDesc->u.Interrupt.Vector,
1351  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
1352  DeviceExtension->PciDevice->BusNumber);
1353 
1354  Irq = (UCHAR)RawPartialDesc->u.Interrupt.Vector;
1356  DeviceExtension->PciDevice->BusNumber,
1357  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
1358  &Irq,
1359  0x3c /* PCI_INTERRUPT_LINE */,
1360  sizeof(UCHAR));
1361  }
1362  }
1363  }
1364 
1365  Command = 0;
1366 
1367  DBGPRINT("pci!PdoStartDevice: Enabling command flags for PCI device 0x%x on bus 0x%x: ",
1368  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
1369  DeviceExtension->PciDevice->BusNumber);
1370  if (DeviceExtension->PciDevice->EnableBusMaster)
1371  {
1373  DBGPRINT("[Bus master] ");
1374  }
1375 
1376  if (DeviceExtension->PciDevice->EnableMemorySpace)
1377  {
1379  DBGPRINT("[Memory space enable] ");
1380  }
1381 
1382  if (DeviceExtension->PciDevice->EnableIoSpace)
1383  {
1385  DBGPRINT("[I/O space enable] ");
1386  }
1387 
1388  if (Command != 0)
1389  {
1390  DBGPRINT("\n");
1391 
1392  /* OR with the previous value */
1393  Command |= DeviceExtension->PciDevice->PciConfig.Command;
1394 
1396  DeviceExtension->PciDevice->BusNumber,
1397  DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
1398  &Command,
1400  sizeof(USHORT));
1401  }
1402  else
1403  {
1404  DBGPRINT("None\n");
1405  }
1406 
1407  return STATUS_SUCCESS;
1408 }
BOOLEAN EnableMemorySpace
Definition: pci.h:22
#define DBGPRINT(...)
Definition: pdo.c:21
#define PCI_ENABLE_IO_SPACE
Definition: iotypes.h:3595
CM_FULL_RESOURCE_DESCRIPTOR List[1]
Definition: hwresource.cpp:165
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
PPCI_DEVICE PciDevice
Definition: pci.h:60
Definition: shell.h:41
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG BusNumber
Definition: pci.h:16
union _PCI_SLOT_NUMBER::@3763 u
BOOLEAN EnableBusMaster
Definition: pci.h:26
void DPRINT(...)
Definition: polytest.cpp:61
struct Command Command
#define PCI_ENABLE_BUS_MASTER
Definition: iotypes.h:3597
FORCEINLINE PCM_FULL_RESOURCE_DESCRIPTOR CmiGetNextResourceDescriptor(_In_ const CM_FULL_RESOURCE_DESCRIPTOR *ResourceDescriptor)
Definition: cmreslist.h:54
unsigned char UCHAR
Definition: xmlstorage.h:181
BOOLEAN EnableIoSpace
Definition: pci.h:24
PCI_SLOT_NUMBER SlotNumber
Definition: pci.h:18
unsigned short USHORT
Definition: pedump.c:61
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384::@387 Interrupt
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define PCI_ENABLE_MEMORY_SPACE
Definition: iotypes.h:3596
unsigned int ULONG
Definition: retypes.h:1
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384 u
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
ULONG NTAPI HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:123
return STATUS_SUCCESS
Definition: btrfs.c:3014
PCI_COMMON_CONFIG PciConfig
Definition: pci.h:20

Referenced by PdoPnpControl().

◆ PdoWriteConfig()

static NTSTATUS PdoWriteConfig ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)
static

Definition at line 1440 of file pdo.c.

1444 {
1445  ULONG Size;
1446 
1447  DPRINT1("PdoWriteConfig() called\n");
1448 
1449  /* Get PCI configuration space */
1451  IrpSp->Parameters.ReadWriteConfig.WhichSpace,
1452  IrpSp->Parameters.ReadWriteConfig.Buffer,
1453  IrpSp->Parameters.ReadWriteConfig.Offset,
1454  IrpSp->Parameters.ReadWriteConfig.Length);
1455 
1456  if (Size != IrpSp->Parameters.ReadWriteConfig.Length)
1457  {
1458  DPRINT1("Size %lu Length %lu\n", Size, IrpSp->Parameters.ReadWriteConfig.Length);
1459  Irp->IoStatus.Information = 0;
1460  return STATUS_UNSUCCESSFUL;
1461  }
1462 
1463  Irp->IoStatus.Information = Size;
1464 
1465  return STATUS_SUCCESS;
1466 }
_In_ PIRP Irp
Definition: csq.h:116
static GET_SET_DEVICE_DATA InterfaceBusSetBusData
Definition: pdo.c:1019
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
_In_ PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:2464
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by PdoPnpControl().

Variable Documentation

◆ InterfaceBusGetBusData

GET_SET_DEVICE_DATA InterfaceBusGetBusData
static

Definition at line 1055 of file pdo.c.

Referenced by PdoQueryInterface(), and PdoReadConfig().

◆ InterfaceBusGetDmaAdapter

GET_DMA_ADAPTER InterfaceBusGetDmaAdapter
static

Definition at line 1004 of file pdo.c.

Referenced by PdoQueryInterface().

◆ InterfaceBusSetBusData

GET_SET_DEVICE_DATA InterfaceBusSetBusData
static

Definition at line 1019 of file pdo.c.

Referenced by PdoQueryInterface(), and PdoWriteConfig().

◆ InterfaceBusTranslateBusAddress

TRANSLATE_BUS_ADDRESS InterfaceBusTranslateBusAddress
static

Definition at line 978 of file pdo.c.

Referenced by PdoQueryInterface().