19#define DBGPRINT(...) DbgPrint(__VA_ARGS__)
24#define PCI_ADDRESS_MEMORY_ADDRESS_MASK_64 0xfffffffffffffff0ull
25#define PCI_ADDRESS_IO_ADDRESS_MASK_64 0xfffffffffffffffcull
50 DPRINT(
"DeviceTextDescription\n");
59 DPRINT(
"DeviceTextLocationInformation\n");
64 Irp->IoStatus.Information = 0;
295 OriginalValue.Bar = 0
ULL;
300 &OriginalValue.Bars.Bar0,
301 &NewValue.Bars.Bar0))
310 if (MaximumAddress !=
NULL)
314 *MaximumAddress = 0x00000000FFFFFFFFULL;
318 *MaximumAddress = 0x00000000000FFFFFULL;
322 *MaximumAddress = 0xFFFFFFFFFFFFFFFFULL;
334 &OriginalValue.Bars.Bar1,
335 &NewValue.Bars.Bar1))
344 if (MaximumAddress !=
NULL)
346 *MaximumAddress = 0x00000000FFFFFFFFULL;
350 if (NewValue.Bar == 0)
352 DPRINT(
"Unused address register\n");
370 : (NewValue.Bar & ~PCI_ADDRESS_MEMORY_ADDRESS_MASK_64);
396 DPRINT(
"PdoQueryResourceRequirements() called\n");
409 Irp->IoStatus.Information = 0;
413 DPRINT(
"Command register: 0x%04hx\n", PciConfig.Command);
436 if (PciConfig.u.type0.InterruptPin != 0)
470 Irp->IoStatus.Information = 0;
478 DPRINT(
"ListSize %lu (0x%lx)\n", ListSize, ListSize);
486 Irp->IoStatus.Information = 0;
514 DPRINT1(
"PdoGetRangeLength() failed\n");
520 DPRINT(
"Unused address register\n");
565 Descriptor->u.Port.MinimumAddress.QuadPart = 0;
566 Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress;
577 Descriptor->u.Port.MinimumAddress.QuadPart = 0;
578 Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress;
585 if (PciConfig.u.type0.InterruptPin != 0)
608 DPRINT1(
"PdoGetRangeLength() failed\n");
614 DPRINT(
"Unused address register\n");
659 Descriptor->u.Port.MinimumAddress.QuadPart = 0;
660 Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress;
671 Descriptor->u.Port.MinimumAddress.QuadPart = 0;
672 Descriptor->u.Port.MaximumAddress.QuadPart = MaximumAddress;
720 DPRINT(
"PdoQueryResources() called\n");
734 Irp->IoStatus.Information = 0;
738 DPRINT(
"Command register: 0x%04hx\n", PciConfig.Command);
759 if ((PciConfig.u.type0.InterruptPin != 0) &&
760 (PciConfig.u.type0.InterruptLine != 0) &&
761 (PciConfig.u.type0.InterruptLine != 0xFF))
795 Irp->IoStatus.Information = 0;
815 PartialList = &
ResourceList->List[0].PartialResourceList;
818 PartialList->
Count = ResCount;
836 DPRINT(
"Unused address register\n");
870 if ((PciConfig.u.type0.InterruptPin != 0) &&
871 (PciConfig.u.type0.InterruptLine != 0) &&
872 (PciConfig.u.type0.InterruptLine != 0xFF))
877 Descriptor->u.Interrupt.Level = PciConfig.u.type0.InterruptLine;
878 Descriptor->u.Interrupt.Vector = PciConfig.u.type0.InterruptLine;
879 Descriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
900 DPRINT(
"Unused address register\n");
994 DPRINT(
"InterfaceBusTranslateBusAddress(%p %p 0x%lx %p %p)\n",
1016 DPRINT(
"InterfaceBusGetDmaAdapter(%p %p %p)\n",
1036 DPRINT(
"InterfaceBusSetBusData(%p 0x%lx %p 0x%lx 0x%lx)\n",
1072 DPRINT(
"InterfaceBusGetBusData(%p 0x%lx %p 0x%lx 0x%lx) called\n",
1120 if (PciDevice->
PciConfig.VendorID == VendorID &&
1130 DPRINT(
"Found the PCI device\n");
1136 CurrentEntry = CurrentEntry->
Flink;
1140 CurrentBus = CurrentBus->
Flink;
1154 (PciConfig->VendorID !=
Parameters->VendorID ||
1155 PciConfig->DeviceID !=
Parameters->DeviceID))
1161 (PciConfig->BaseClass !=
Parameters->BaseClass ||
1162 PciConfig->SubClass !=
Parameters->SubClass))
1174 (PciConfig->u.type0.SubVendorID !=
Parameters->SubVendorID ||
1175 PciConfig->u.type0.SubSystemID !=
Parameters->SubSystemID))
1181 PciConfig->RevisionID !=
Parameters->RevisionID)
1203 DPRINT(
"InterfacePciDevicePresentEx(%p %p) called\n",
1232 DPRINT(
"Found the PCI device\n");
1236 CurrentEntry = CurrentEntry->
Flink;
1241 CurrentBus = CurrentBus->
Flink;
1260 &GUID_BUS_INTERFACE_STANDARD,
sizeof(
GUID)) ==
sizeof(
GUID))
1281 &GUID_PCI_DEVICE_PRESENT_INTERFACE,
sizeof(
GUID)) ==
sizeof(
GUID))
1340 RawFullDesc = &RawResList->
List[0];
1351 DPRINT(
"Assigning IRQ %u to PCI device 0x%x on bus 0x%x\n",
1369 DBGPRINT(
"pci!PdoStartDevice: Enabling command flags for PCI device 0x%x on bus 0x%x: ",
1381 DBGPRINT(
"[Memory space enable] ");
1420 DPRINT(
"PdoReadConfig() called\n");
1431 Irp->IoStatus.Information = 0;
1435 Irp->IoStatus.Information =
Size;
1449 DPRINT1(
"PdoWriteConfig() called\n");
1461 Irp->IoStatus.Information = 0;
1465 Irp->IoStatus.Information =
Size;
1480 return Irp->IoStatus.Status;
1484 if (!DeviceRelations)
1487 DeviceRelations->
Count = 1;
1493 Irp->IoStatus.Information = (
ULONG_PTR)DeviceRelations;
1526 DPRINT(
"Unimplemented IRP_MN_DEVICE_USAGE_NOTIFICATION received\n");
1530 DPRINT(
"Unimplemented IRP_MN_EJECT received\n");
1546 DPRINT(
"IRP_MN_QUERY_DEVICE_TEXT received\n");
1551 DPRINT(
"IRP_MN_QUERY_ID received\n");
1556 DPRINT(
"Unimplemented IRP_MN_QUERY_ID received\n");
1560 DPRINT(
"IRP_MN_QUERY_RESOURCE_REQUIREMENTS received\n");
1565 DPRINT(
"IRP_MN_QUERY_RESOURCES received\n");
1570 DPRINT(
"Unimplemented IRP_MN_SET_LOCK received\n");
1588 DPRINT(
"IRP_MN_QUERY_INTERFACE received\n");
1593 DPRINT(
"IRP_MN_READ_CONFIG received\n");
1598 DPRINT(
"IRP_MN_WRITE_CONFIG received\n");
1603 DPRINT(
"IRP_MN_FILTER_RESOURCE_REQUIREMENTS received\n");
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define InterlockedIncrement
#define InterlockedDecrement
static VOID NTAPI InterfaceReference(IN PVOID Context)
static NTSTATUS PdoReadConfig(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS PdoPnpControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
static GET_SET_DEVICE_DATA InterfaceBusGetBusData
static NTSTATUS PdoWriteConfig(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 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 NTSTATUS PdoQueryBusInformation(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS PdoPowerControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
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)
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK_64
static NTSTATUS PdoQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
static GET_SET_DEVICE_DATA InterfaceBusSetBusData
#define PCI_ADDRESS_IO_ADDRESS_MASK_64
static NTSTATUS PdoQueryDeviceText(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 PdoQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
static TRANSLATE_BUS_ADDRESS InterfaceBusTranslateBusAddress
static VOID NTAPI InterfaceDereference(IN PVOID Context)
static NTSTATUS PdoQueryInterface(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
static GET_DMA_ADAPTER InterfaceBusGetDmaAdapter
static NTSTATUS PdoQueryId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, PIO_STACK_LOCATION IrpSp)
static BOOLEAN PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension, UCHAR Bar, PULONGLONG Base, PULONGLONG Length, PULONG Flags, PUCHAR NextBar, PULONGLONG MaximumAddress)
static BOOLEAN NTAPI InterfacePciDevicePresentEx(IN PVOID Context, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
_In_ PCHAR _In_ ULONG DeviceNumber
FORCEINLINE PCM_FULL_RESOURCE_DESCRIPTOR CmiGetNextResourceDescriptor(_In_ const CM_FULL_RESOURCE_DESCRIPTOR *ResourceDescriptor)
#define STATUS_NOT_SUPPORTED
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
_In_ PIO_STACK_LOCATION IrpSp
NTHALAPI ULONG NTAPI HalGetBusData(BUS_DATA_TYPE, ULONG, ULONG, PVOID, ULONG)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define RtlCompareMemory(s1, s2, l)
#define KeReleaseSpinLock(sl, irql)
#define KeAcquireSpinLock(sl, irql)
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
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
ULONG NTAPI HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
BOOLEAN NTAPI HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
ULONG NTAPI HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
PADAPTER_OBJECT NTAPI HalGetAdapter(IN PDEVICE_DESCRIPTION DeviceDescription, OUT PULONG NumberOfMapRegisters)
#define CmResourceTypeMemory
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
#define CmResourceTypePort
#define CmResourceTypeBusNumber
#define CmResourceTypeInterrupt
PCI_INTERFACE PciDevicePresentInterface
#define CM_RESOURCE_PORT_POSITIVE_DECODE
#define CM_RESOURCE_MEMORY_PREFETCHABLE
#define CM_RESOURCE_PORT_IO
#define CM_RESOURCE_PORT_16_BIT_DECODE
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
#define CM_RESOURCE_MEMORY_READ_WRITE
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
#define UNREFERENCED_PARAMETER(P)
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define IRP_MN_SURPRISE_REMOVAL
#define IoCompleteRequest
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
PPCI_DRIVER_EXTENSION DriverExtension
NTSTATUS PciDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
struct _INTERFACE * PINTERFACE
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
#define STATUS_BUFFER_TOO_SMALL
PGET_SET_DEVICE_DATA SetBusData
PTRANSLATE_BUS_ADDRESS TranslateBusAddress
PGET_SET_DEVICE_DATA GetBusData
PGET_DMA_ADAPTER GetDmaAdapter
CM_PARTIAL_RESOURCE_LIST PartialResourceList
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@391 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@391::@394 Interrupt
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
CM_FULL_RESOURCE_DESCRIPTOR List[1]
PDEVICE_OBJECT Objects[1]
LIST_ENTRY DeviceListHead
KSPIN_LOCK DeviceListLock
struct _IO_STACK_LOCATION::@3978::@4007 ReadWriteConfig
union _IO_STACK_LOCATION::@1579 Parameters
struct _IO_STACK_LOCATION::@3978::@4015 StartDevice
struct _IO_STACK_LOCATION::@3978::@4003 QueryDeviceRelations
struct _IO_STACK_LOCATION::@3978::@4004 QueryInterface
struct _IO_STACK_LOCATION::@3978::@4010 QueryDeviceText
struct _IO_STACK_LOCATION::@3978::@4005 DeviceCapabilities
struct _IO_STACK_LOCATION::@3978::@4009 QueryId
struct _LIST_ENTRY * Flink
PCI_SLOT_NUMBER SlotNumber
BOOLEAN EnableMemorySpace
PCI_COMMON_CONFIG PciConfig
union _PCI_SLOT_NUMBER::@4022 u
struct _PCI_SLOT_NUMBER::@4022::@4023 bits
UNICODE_STRING DeviceDescription
UNICODE_STRING CompatibleIDs
UNICODE_STRING InstanceID
UNICODE_STRING HardwareIDs
UNICODE_STRING DeviceLocation
#define FIELD_OFFSET(t, f)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
_In_ WDFDEVICE _In_ PPNP_BUS_INFORMATION BusInformation
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceID
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
_Must_inspect_result_ _In_ WDFCMRESLIST List
#define DeviceCapabilities
_Must_inspect_result_ _In_ ULONG Flags
@ CmResourceShareDeviceExclusive
_Out_ PULONG NumberOfMapRegisters
_In_ ULONG _In_ PHYSICAL_ADDRESS BusAddress
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define PCI_WHICHSPACE_CONFIG
#define PCI_ENABLE_BUS_MASTER
#define IRP_MN_QUERY_INTERFACE
#define PCI_TYPE0_ADDRESSES
#define IRP_MN_START_DEVICE
#define PCI_USE_VENDEV_IDS
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
#define IRP_MN_READ_CONFIG
#define PCI_ENABLE_IO_SPACE
#define IRP_MN_WRITE_CONFIG
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IO_RESOURCE_ALTERNATIVE
#define PCI_ADDRESS_IO_SPACE
#define PCI_CONFIGURATION_TYPE(PciData)
#define IRP_MN_REMOVE_DEVICE
#define PCI_USE_CLASS_SUBCLASS
#define PCI_ENABLE_MEMORY_SPACE
#define PCI_TYPE1_ADDRESSES
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
struct _PCI_DEVICE_PRESENT_INTERFACE * PPCI_DEVICE_PRESENT_INTERFACE
#define IRP_MN_QUERY_DEVICE_RELATIONS
struct _BUS_INTERFACE_STANDARD * PBUS_INTERFACE_STANDARD
#define IO_RESOURCE_PREFERRED
#define PCI_COMMON_HDR_LENGTH
#define IRP_MN_QUERY_STOP_DEVICE
#define PCI_CLASS_BRIDGE_DEV
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_CAPABILITIES
#define IRP_MN_QUERY_RESOURCES
_In_ USHORT _In_ UCHAR _In_ USHORT _In_ USHORT SubSystemID
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define PCI_USE_LOCAL_DEVICE
#define PCI_ADDRESS_MEMORY_PREFETCHABLE
#define IRP_MN_STOP_DEVICE
@ DeviceTextLocationInformation
_In_ USHORT _In_ UCHAR RevisionID
#define PCI_ADDRESS_MEMORY_TYPE_MASK
@ BusQueryDeviceSerialNumber
#define PCI_USE_LOCAL_BUS
#define PCI_USE_SUBSYSTEM_IDS
_In_ USHORT _In_ UCHAR _In_ USHORT SubVendorID
#define IRP_MN_QUERY_POWER
#define PCI_CARDBUS_BRIDGE_TYPE
#define IRP_MN_QUERY_BUS_INFORMATION
#define IRP_MN_QUERY_REMOVE_DEVICE
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
#define ObReferenceObject