ReactOS 0.4.17-dev-1190-g4c812f4
pci.h File Reference
#include <ntifs.h>
#include <wdmguid.h>
#include <wchar.h>
#include <acpiioct.h>
#include <drivers/pci/pci.h>
#include <drivers/acpi/acpi.h>
#include <ndk/halfuncs.h>
#include <ndk/rtlfuncs.h>
#include <ndk/vffuncs.h>
#include <arbiter.h>
#include <cmreslist.h>
Include dependency graph for pci.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _PCI_HACK_ENTRY
 
struct  _PCI_RESIZABLE_BAR_STATE
 
struct  _PCI_POWER_STATE
 
struct  _PCI_LOCK
 
struct  _PCI_FDO_EXTENSION
 
struct  _PCI_FUNCTION_RESOURCES
 
struct  _PCI_DEBUGGING_DEVICE
 
union  _PCI_HEADER_TYPE_DEPENDENT
 
struct  _PCI_PDO_EXTENSION
 
struct  _PCI_MN_DISPATCH_TABLE
 
struct  _PCI_MJ_DISPATCH_TABLE
 
struct  _PCI_INTERFACE
 
struct  PCI_SECONDARY_EXTENSION
 
struct  PCI_ARBITER_INSTANCE
 
struct  _PCI_VERIFIER_DATA
 
struct  _PCI_ID_BUFFER
 
struct  _PCI_CONFIGURATOR
 
struct  _PCI_CONFIGURATOR_CONTEXT
 
struct  _PCI_IPI_CONTEXT
 
struct  _PCI_LEGACY_DEVICE
 

Macros

#define PCI_POOL_TAG   'BicP'
 
#define TAG_PCI_ROUTING   'RicP'
 
#define TAG_PCI_PRESERVED   'PicP'
 
#define PCI_IS_ROOT_FDO(x)   ((x)->BusRootFdoExtension == x)
 
#define ASSERT_FDO(x)   ASSERT((x)->ExtensionType == PciFdoExtensionType);
 
#define ASSERT_PDO(x)   ASSERT((x)->ExtensionType == PciPdoExtensionType);
 
#define PCI_HACK_ENTRY_SIZE   sizeof(L"VVVVdddd") - sizeof(UNICODE_NULL)
 
#define PCI_HACK_ENTRY_REV_SIZE   sizeof(L"VVVVddddRR") - sizeof(UNICODE_NULL)
 
#define PCI_HACK_ENTRY_SUBSYS_SIZE   sizeof(L"VVVVddddssssIIII") - sizeof(UNICODE_NULL)
 
#define PCI_HACK_ENTRY_FULL_SIZE   sizeof(L"VVVVddddssssIIIIRR") - sizeof(UNICODE_NULL)
 
#define PCI_HACK_HAS_REVISION_INFO   0x01
 
#define PCI_HACK_HAS_SUBSYSTEM_INFO   0x02
 
#define PCI_INTERFACE_PDO   0x01
 
#define PCI_INTERFACE_FDO   0x02
 
#define PCI_INTERFACE_ROOT   0x04
 
#define PCI_SKIP_DEVICE_ENUMERATION   0x01
 
#define PCI_SKIP_RESOURCE_ENUMERATION   0x02
 
#define PCI_HACK_FIXUP_BEFORE_CONFIGURATION   0x00
 
#define PCI_HACK_FIXUP_AFTER_CONFIGURATION   0x01
 
#define PCI_HACK_FIXUP_BEFORE_UPDATE   0x03
 
#define PCI_LEGACY_CONFIG_LENGTH   0x100
 
#define PCI_INTERRUPT_LINE_UNKNOWN   0xFF
 
#define PCI_RBAR_EXTENDED_CAP_ID   0x0015
 
#define PCI_RBAR_MAX_ENTRIES   6
 
#define PCI_RBAR_ENTRY_CAPABILITY(n)   (0x04 + ((n) * 8))
 
#define PCI_RBAR_ENTRY_CONTROL(n)   (0x08 + ((n) * 8))
 
#define PCI_RBAR_CAPABILITY_SIZES_SHIFT   4
 
#define PCI_RBAR_CONTROL_BAR_INDEX_MASK   0x00000007
 
#define PCI_RBAR_CONTROL_COUNT_MASK   0x000000E0
 
#define PCI_RBAR_CONTROL_COUNT_SHIFT   5
 
#define PCI_RBAR_CONTROL_SIZE_MASK   (0x3F << 8)
 
#define PCI_RBAR_CONTROL_SIZE_SHIFT   8
 
#define ARBITER_INTERFACE_VERSION   0
 
#define MAX_DEBUGGING_DEVICES_SUPPORTED   0x04
 
#define PCI_VERIFIER_CODES   0x04
 
#define MAX_ANSI_STRINGS   0x08
 

Typedefs

typedef enum _PCI_SIGNATURE PCI_SIGNATURE
 
typedef enum _PCI_SIGNATURE * PPCI_SIGNATURE
 
typedef enum _PCI_DEVICE_TYPES PCI_DEVICE_TYPES
 
typedef enum _PCI_STATE PCI_STATE
 
typedef enum _PCI_DISPATCH_STYLE PCI_DISPATCH_STYLE
 
typedef struct _PCI_HACK_ENTRY PCI_HACK_ENTRY
 
typedef struct _PCI_HACK_ENTRY * PPCI_HACK_ENTRY
 
typedef struct _PCI_RESIZABLE_BAR_STATE PCI_RESIZABLE_BAR_STATE
 
typedef struct _PCI_RESIZABLE_BAR_STATE * PPCI_RESIZABLE_BAR_STATE
 
typedef struct _PCI_POWER_STATE PCI_POWER_STATE
 
typedef struct _PCI_POWER_STATE * PPCI_POWER_STATE
 
typedef struct _PCI_LOCK PCI_LOCK
 
typedef struct _PCI_LOCK * PPCI_LOCK
 
typedef struct _PCI_FDO_EXTENSION PCI_FDO_EXTENSION
 
typedef struct _PCI_FDO_EXTENSION * PPCI_FDO_EXTENSION
 
typedef struct _PCI_FUNCTION_RESOURCES PCI_FUNCTION_RESOURCES
 
typedef struct _PCI_FUNCTION_RESOURCES * PPCI_FUNCTION_RESOURCES
 
typedef struct _PCI_DEBUGGING_DEVICE PCI_DEBUGGING_DEVICE
 
typedef struct _PCI_DEBUGGING_DEVICE * PPCI_DEBUGGING_DEVICE
 
typedef union _PCI_HEADER_TYPE_DEPENDENT PCI_HEADER_TYPE_DEPENDENT
 
typedef union _PCI_HEADER_TYPE_DEPENDENT * PPCI_HEADER_TYPE_DEPENDENT
 
typedef struct _PCI_PDO_EXTENSION PCI_PDO_EXTENSION
 
typedef struct _PCI_PDO_EXTENSION * PPCI_PDO_EXTENSION
 
typedef NTSTATUS(NTAPI * PCI_DISPATCH_FUNCTION) (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PVOID DeviceExtension)
 
typedef struct _PCI_MN_DISPATCH_TABLE PCI_MN_DISPATCH_TABLE
 
typedef struct _PCI_MN_DISPATCH_TABLE * PPCI_MN_DISPATCH_TABLE
 
typedef struct _PCI_MJ_DISPATCH_TABLE PCI_MJ_DISPATCH_TABLE
 
typedef struct _PCI_MJ_DISPATCH_TABLE * PPCI_MJ_DISPATCH_TABLE
 
typedef NTSTATUS(NTAPI * PCI_INTERFACE_CONSTRUCTOR) (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
typedef NTSTATUS(NTAPI * PCI_INTERFACE_INITIALIZER) (IN PVOID Instance)
 
typedef struct _PCI_INTERFACE PCI_INTERFACE
 
typedef struct _PCI_INTERFACE * PPCI_INTERFACE
 
typedef struct PCI_SECONDARY_EXTENSION PCI_SECONDARY_EXTENSION
 
typedef struct PCI_SECONDARY_EXTENSION * PPCI_SECONDARY_EXTENSION
 
typedef struct PCI_ARBITER_INSTANCE PCI_ARBITER_INSTANCE
 
typedef struct PCI_ARBITER_INSTANCE * PPCI_ARBITER_INSTANCE
 
typedef struct _PCI_VERIFIER_DATA PCI_VERIFIER_DATA
 
typedef struct _PCI_VERIFIER_DATA * PPCI_VERIFIER_DATA
 
typedef struct _PCI_ID_BUFFER PCI_ID_BUFFER
 
typedef struct _PCI_ID_BUFFER * PPCI_ID_BUFFER
 
typedef VOID(NTAPI * PCI_CONFIGURATOR_INITIALIZE) (IN struct _PCI_CONFIGURATOR_CONTEXT *Context)
 
typedef VOID(NTAPI * PCI_CONFIGURATOR_RESTORE_CURRENT) (IN struct _PCI_CONFIGURATOR_CONTEXT *Context)
 
typedef VOID(NTAPI * PCI_CONFIGURATOR_SAVE_LIMITS) (IN struct _PCI_CONFIGURATOR_CONTEXT *Context)
 
typedef VOID(NTAPI * PCI_CONFIGURATOR_SAVE_CURRENT_SETTINGS) (IN struct _PCI_CONFIGURATOR_CONTEXT *Context)
 
typedef NTSTATUS(NTAPI * PCI_CONFIGURATOR_CHANGE_RESOURCE_SETTINGS) (_In_ PPCI_PDO_EXTENSION PdoExtension, _Inout_ PPCI_COMMON_HEADER PciData)
 
typedef VOID(NTAPI * PCI_CONFIGURATOR_GET_ADDITIONAL_RESOURCE_DESCRIPTORS) (IN struct _PCI_CONFIGURATOR_CONTEXT *Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
 
typedef VOID(NTAPI * PCI_CONFIGURATOR_RESET_DEVICE) (IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)
 
typedef struct _PCI_CONFIGURATOR PCI_CONFIGURATOR
 
typedef struct _PCI_CONFIGURATOR * PPCI_CONFIGURATOR
 
typedef struct _PCI_CONFIGURATOR_CONTEXT PCI_CONFIGURATOR_CONTEXT
 
typedef struct _PCI_CONFIGURATOR_CONTEXT * PPCI_CONFIGURATOR_CONTEXT
 
typedef VOID(NTAPI * PCI_IPI_FUNCTION) (IN PVOID Reserved, IN PVOID Context)
 
typedef struct _PCI_IPI_CONTEXT PCI_IPI_CONTEXT
 
typedef struct _PCI_IPI_CONTEXT * PPCI_IPI_CONTEXT
 
typedef struct _PCI_LEGACY_DEVICE PCI_LEGACY_DEVICE
 
typedef struct _PCI_LEGACY_DEVICE * PPCI_LEGACY_DEVICE
 

Enumerations

enum  _PCI_SIGNATURE {
  PciPdoExtensionType = 'icP0' , PciFdoExtensionType = 'icP1' , PciArb_Io = 'icP2' , PciArb_Memory = 'icP3' ,
  PciArb_Interrupt = 'icP4' , PciArb_BusNumber = 'icP5' , PciTrans_Interrupt = 'icP6' , PciInterface_BusHandler = 'icP7' ,
  PciInterface_IntRouteHandler = 'icP8' , PciInterface_PciCb = 'icP9' , PciInterface_LegacyDeviceDetection = 'icP:' , PciInterface_PmeHandler = 'icP;' ,
  PciInterface_DevicePresent = 'icP<' , PciInterface_NativeIde = 'icP=' , PciInterface_AgpTarget = 'icP>' , PciInterface_Location = 'icP?'
}
 
enum  _PCI_DEVICE_TYPES {
  PciTypeInvalid , PciTypeHostBridge , PciTypePciBridge , PciTypeCardbusBridge ,
  PciTypeDevice
}
 
enum  _PCI_STATE {
  PciNotStarted , PciStarted , PciDeleted , PciStopped ,
  PciSurpriseRemoved , PciSynchronizedOperation , PciMaxObjectState
}
 
enum  _PCI_DISPATCH_STYLE { IRP_COMPLETE , IRP_DOWNWARD , IRP_UPWARD , IRP_DISPATCH }
 

Functions

NTSTATUS NTAPI PciDispatchIrp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI PciIrpNotSupported (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPassIrpFromFdoToPdo (IN PPCI_FDO_EXTENSION DeviceExtension, IN PIRP Irp)
 
NTSTATUS NTAPI PciCallDownIrpStack (IN PPCI_FDO_EXTENSION DeviceExtension, IN PIRP Irp)
 
NTSTATUS NTAPI PciIrpInvalidDeviceRequest (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoWaitWake (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoSetPowerState (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryPower (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciSetPowerManagedDevicePowerState (IN PPCI_PDO_EXTENSION DeviceExtension, IN DEVICE_POWER_STATE DeviceState, IN BOOLEAN IrpSet)
 
NTSTATUS NTAPI PciAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS NTAPI PciFdoIrpStartDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpCancelRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpCancelStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryDeviceRelations (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryInterface (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryCapabilities (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpDeviceUsageNotification (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpSurpriseRemoval (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciFdoIrpQueryLegacyBusInformation (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoCreate (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_SLOT_NUMBER Slot, OUT PDEVICE_OBJECT *PdoDeviceObject)
 
NTSTATUS NTAPI PciPdoWaitWake (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoSetPowerState (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryPower (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpStartDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpCancelRemoveDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpCancelStopDevice (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryDeviceRelations (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryInterface (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryCapabilities (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryResources (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryResourceRequirements (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryDeviceText (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpReadConfig (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpWriteConfig (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryId (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryDeviceState (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryBusInformation (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpDeviceUsageNotification (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpSurpriseRemoval (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciPdoIrpQueryLegacyBusInformation (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension)
 
VOID NTAPI PciHookHal (VOID)
 
VOID NTAPI PciRestoreHalHooks (VOID)
 Gives the HAL back the routines PciHookHal replaced.
 
VOID NTAPI PciVerifierInit (IN PDRIVER_OBJECT DriverObject)
 
VOID NTAPI PciVerifierRelease (VOID)
 Drops the hardware profile notification taken by PciVerifierInit.
 
PPCI_VERIFIER_DATA NTAPI PciVerifierRetrieveFailureData (IN ULONG FailureCode)
 
BOOLEAN NTAPI PciStringToUSHORT (IN PWCHAR String, OUT PUSHORT Value)
 
BOOLEAN NTAPI PciIsDatacenter (VOID)
 
NTSTATUS NTAPI PciBuildDefaultExclusionLists (VOID)
 
BOOLEAN NTAPI PciUnicodeStringStrStr (IN PUNICODE_STRING InputString, IN PCUNICODE_STRING EqualString, IN BOOLEAN CaseInSensitive)
 
BOOLEAN NTAPI PciOpenKey (IN PWCHAR KeyName, IN HANDLE RootKey, IN ACCESS_MASK DesiredAccess, OUT PHANDLE KeyHandle, OUT PNTSTATUS KeyStatus)
 
NTSTATUS NTAPI PciGetRegistryValue (IN PWCHAR ValueName, IN PWCHAR KeyName, IN HANDLE RootHandle, IN ULONG Type, OUT PVOID *OutputBuffer, OUT PULONG OutputLength)
 
PPCI_FDO_EXTENSION NTAPI PciFindParentPciFdoExtension (IN PDEVICE_OBJECT DeviceObject, IN PKEVENT Lock)
 
VOID NTAPI PciInsertEntryAtTail (IN PSINGLE_LIST_ENTRY ListHead, IN PPCI_FDO_EXTENSION DeviceExtension, IN PKEVENT Lock)
 
NTSTATUS NTAPI PciGetDeviceProperty (IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, OUT PVOID *OutputBuffer)
 
NTSTATUS NTAPI PciSendIoctl (IN PDEVICE_OBJECT DeviceObject, IN ULONG IoControlCode, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength)
 
VOID NTAPI PcipLinkSecondaryExtension (IN PSINGLE_LIST_ENTRY List, IN PVOID Lock, IN PPCI_SECONDARY_EXTENSION SecondaryExtension, IN PCI_SIGNATURE ExtensionType, IN PVOID Destructor)
 
PPCI_SECONDARY_EXTENSION NTAPI PciFindNextSecondaryExtension (IN PSINGLE_LIST_ENTRY ListHead, IN PCI_SIGNATURE ExtensionType)
 
ULONGLONG NTAPI PciGetHackFlags (IN USHORT VendorId, IN USHORT DeviceId, IN USHORT SubVendorId, IN USHORT SubSystemId, IN UCHAR RevisionId)
 
PPCI_PDO_EXTENSION NTAPI PciFindPdoByFunction (IN PPCI_FDO_EXTENSION DeviceExtension, IN ULONG FunctionNumber, IN PPCI_COMMON_HEADER PciData)
 
BOOLEAN NTAPI PciIsCriticalDeviceClass (IN UCHAR BaseClass, IN UCHAR SubClass)
 
BOOLEAN NTAPI PciIsDeviceOnDebugPath (IN PPCI_PDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciGetBiosConfig (IN PPCI_PDO_EXTENSION DeviceExtension, OUT PPCI_COMMON_HEADER PciData)
 
NTSTATUS NTAPI PciSaveBiosConfig (IN PPCI_PDO_EXTENSION DeviceExtension, OUT PPCI_COMMON_HEADER PciData)
 
UCHAR NTAPI PciReadDeviceCapability (IN PPCI_PDO_EXTENSION DeviceExtension, IN UCHAR Offset, IN ULONG CapabilityId, OUT PPCI_CAPABILITIES_HEADER Buffer, IN ULONG Length)
 
BOOLEAN NTAPI PciCanDisableDecodes (IN PPCI_PDO_EXTENSION DeviceExtension, IN PPCI_COMMON_HEADER Config, IN ULONGLONG HackFlags, IN BOOLEAN ForPowerDown)
 
PCI_DEVICE_TYPES NTAPI PciClassifyDeviceType (IN PPCI_PDO_EXTENSION PdoExtension)
 
ULONG_PTR NTAPI PciExecuteCriticalSystemRoutine (IN ULONG_PTR IpiContext)
 
BOOLEAN NTAPI PciCreateIoDescriptorFromBarLimit (_Out_ PIO_RESOURCE_DESCRIPTOR ResourceDescriptor, _In_ ULONG Bar, _In_ ULONG NextBar, _In_ BOOLEAN Rom)
 Builds the requirement of a BAR from the value it reads back after all ones were written to it.
 
BOOLEAN NTAPI PciIsSlotPresentInParentMethod (IN PPCI_PDO_EXTENSION PdoExtension, IN ULONG Method)
 
VOID NTAPI PciDecodeEnable (IN PPCI_PDO_EXTENSION PdoExtension, IN BOOLEAN Enable, OUT PUSHORT Command)
 
NTSTATUS NTAPI PciQueryBusInformation (IN PPCI_PDO_EXTENSION PdoExtension, OUT PPNP_BUS_INFORMATION *Buffer)
 
NTSTATUS NTAPI PciQueryCapabilities (IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_CAPABILITIES DeviceCapability)
 
NTSTATUS NTAPI PciGetConfigHandlers (IN PPCI_FDO_EXTENSION FdoExtension)
 
VOID NTAPI PciInitializeEcam (_In_ PPCI_FDO_EXTENSION FdoExtension)
 Maps the bus an FDO decodes into the ECAM window and verifies the window the first time a bus with devices on it is seen.
 
VOID NTAPI PciReleaseEcam (VOID)
 Unmaps every bus mapped through the ECAM window.
 
ULONG NTAPI PciReadDeviceExtendedCapability (_In_ PPCI_PDO_EXTENSION DeviceExtension, _In_ ULONG CapabilityId, _Out_writes_bytes_(Length) PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Buffer, _In_ ULONG Length)
 Finds an extended capability and reads it into the caller's buffer.
 
VOID NTAPI PciGetExpressCapabilities (_Inout_ PPCI_PDO_EXTENSION PdoExtension)
 Records the Express capability of a new function and whether its extended configuration space can be reached.
 
VOID NTAPI PciGetResizableBarCapability (_Inout_ PPCI_PDO_EXTENSION PdoExtension)
 Records which BARs of a new function can be resized and the sizes each of them supports.
 
ULONG NTAPI PciAddResizableBarRequirements (_In_ PPCI_PDO_EXTENSION PdoExtension, _In_ ULONG BarIndex, _In_ PIO_RESOURCE_DESCRIPTOR Limit, _Out_writes_opt_(2) PIO_RESOURCE_DESCRIPTOR Descriptors)
 Writes the requirements for the sizes a resizable BAR can grow to. They go ahead of the default requirement, which the caller then lists as the alternative. The largest size is preferred, and the smallest supported size follows it when that is also bigger than the default.
 
VOID NTAPI PciApplyResizableBarSizes (_In_ PPCI_PDO_EXTENSION PdoExtension)
 Sets every resizable BAR to the length it was assigned. The memory decode has to be off, since the size field changes what the BAR decodes. Critical devices call this from the IPI that updates their hardware.
 
BOOLEAN NTAPI PciEcamReadWriteConfig (_In_ ULONG Bus, _In_ PCI_SLOT_NUMBER Slot, _Inout_updates_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length, _In_ BOOLEAN Read)
 Performs a configuration space access through the ECAM window.
 
VOID NTAPI PciReadSlotConfig (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
VOID NTAPI PciWriteDeviceConfig (IN PPCI_PDO_EXTENSION DeviceExtension, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
VOID NTAPI PciReadDeviceConfig (IN PPCI_PDO_EXTENSION DeviceExtension, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
UCHAR NTAPI PciGetAdjustedInterruptLine (IN PPCI_PDO_EXTENSION PdoExtension)
 
NTSTATUS NTAPI PciUpdateDeviceUsage (_Inout_ PPCI_POWER_STATE PowerState, _In_ PIO_STACK_LOCATION IoStackLocation)
 Counts a paging, hibernation or dump file arriving on or leaving a device.
 
NTSTATUS NTAPI PciSendDeviceUsageToParent (_In_ PPCI_FDO_EXTENSION ParentFdoExtension, _In_ PIO_STACK_LOCATION IoStackLocation)
 Sends a device usage notification to the top of the stack of a parent bus.
 
VOID NTAPI PciInitializeState (IN PPCI_FDO_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI PciBeginStateTransition (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
 
NTSTATUS NTAPI PciCancelStateTransition (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
 
VOID NTAPI PciCommitStateTransition (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
 
NTSTATUS NTAPI PciInitializeArbiters (IN PPCI_FDO_EXTENSION FdoExtension)
 
NTSTATUS NTAPI PciInitializeArbiterRanges (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCM_RESOURCE_LIST Resources)
 
BOOLEAN NTAPI PciDebugIrpDispatchDisplay (IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension, IN USHORT MaxMinor)
 
VOID NTAPI PciDebugDumpCommonConfig (IN PPCI_COMMON_HEADER PciData)
 
VOID NTAPI PciDebugDumpQueryCapabilities (IN PDEVICE_CAPABILITIES DeviceCaps)
 
VOID NTAPI PciDebugPrintIoResReqList (IN PIO_RESOURCE_REQUIREMENTS_LIST Requirements)
 
VOID NTAPI PciDebugPrintCmResList (IN PCM_RESOURCE_LIST ResourceList)
 
VOID NTAPI PciDebugPrintPartialResource (IN PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialResource)
 
NTSTATUS NTAPI PciQueryInterface (IN PPCI_FDO_EXTENSION DeviceExtension, IN CONST GUID *InterfaceType, IN ULONG Size, IN ULONG Version, IN PVOID InterfaceData, IN PINTERFACE Interface, IN BOOLEAN LastChance)
 
NTSTATUS NTAPI PciPmeInterfaceInitializer (IN PVOID Instance)
 
NTSTATUS NTAPI routeintrf_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI arbusno_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI arbusno_UnpackRequirement (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _Out_ PULONGLONG Minimum, _Out_ PULONGLONG Maximum, _Out_ PULONGLONG Length, _Out_ PULONGLONG Alignment)
 
NTSTATUS NTAPI arbusno_PackResource (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONGLONG Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource)
 
NTSTATUS NTAPI arbusno_UnpackResource (_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource, _Out_ PULONGLONG Start, _Out_ PULONGLONG Length)
 
INT32 NTAPI arbusno_ScoreRequirement (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor)
 
NTSTATUS NTAPI agpintrf_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI tranirq_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI busintrf_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI armem_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI ario_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI locintrf_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI pcicbintrf_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI lddintrf_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI devpresent_Initializer (IN PVOID Instance)
 
NTSTATUS NTAPI agpintrf_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI arbusno_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI tranirq_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI armem_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI busintrf_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
ULONG NTAPI PciBusInterface_GetBusData (_In_ PVOID Context, _In_ ULONG WhichSpace, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
 
ULONG NTAPI PciBusInterface_SetBusData (_In_ PVOID Context, _In_ ULONG WhichSpace, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
 
NTSTATUS NTAPI ario_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
VOID NTAPI ario_ApplyBrokenVideoHack (IN PPCI_FDO_EXTENSION FdoExtension)
 
NTSTATUS NTAPI ario_UnpackRequirement (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _Out_ PULONGLONG Minimum, _Out_ PULONGLONG Maximum, _Out_ PULONGLONG Length, _Out_ PULONGLONG Alignment)
 
NTSTATUS NTAPI ario_PackResource (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONGLONG Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource)
 
NTSTATUS NTAPI ario_UnpackResource (_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource, _Out_ PULONGLONG Start, _Out_ PULONGLONG Length)
 
INT32 NTAPI ario_ScoreRequirement (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor)
 
NTSTATUS NTAPI armem_UnpackRequirement (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _Out_ PULONGLONG Minimum, _Out_ PULONGLONG Maximum, _Out_ PULONGLONG Length, _Out_ PULONGLONG Alignment)
 
NTSTATUS NTAPI armem_PackResource (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONGLONG Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource)
 
NTSTATUS NTAPI armem_UnpackResource (_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource, _Out_ PULONGLONG Start, _Out_ PULONGLONG Length)
 
INT32 NTAPI armem_ScoreRequirement (_In_ PIO_RESOURCE_DESCRIPTOR Descriptor)
 
VOID NTAPI PciArbiter_Reference (_In_ PVOID Context)
 
VOID NTAPI PciArbiter_Dereference (_In_ PVOID Context)
 
NTSTATUS NTAPI PciArbiterConstructor (_In_ PPCI_FDO_EXTENSION FdoExtension, _In_ PCI_SIGNATURE ArbiterType, _Out_ PARBITER_INTERFACE Interface)
 
NTSTATUS NTAPI PciArbiter_PreprocessEntry (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE State)
 Sets the range attributes of one arbitration entry before the engine looks for a placement for it.
 
BOOLEAN NTAPI PciArbiter_FindSuitableRange (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE State)
 Searches for a placement, remembering on the range whether it came from a fixed alternative.
 
BOOLEAN NTAPI PciArbiter_OverrideConflict (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE State)
 Lets a fixed requirement overlap ranges its own device was given by other fixed requirements.
 
NTSTATUS NTAPI pcicbintrf_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI lddintrf_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI locintrf_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI PciPmeInterfaceConstructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI routeintrf_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI devpresent_Constructor (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)
 
NTSTATUS NTAPI PciQueryDeviceRelations (IN PPCI_FDO_EXTENSION DeviceExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
 
NTSTATUS NTAPI PciQueryResources (IN PPCI_PDO_EXTENSION PdoExtension, OUT PCM_RESOURCE_LIST *Buffer)
 
NTSTATUS NTAPI PciQueryTargetDeviceRelations (IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
 
NTSTATUS NTAPI PciQueryEjectionRelations (IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
 
NTSTATUS NTAPI PciQueryRequirements (IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *RequirementsList)
 
BOOLEAN NTAPI PciComputeNewCurrentSettings (IN PPCI_PDO_EXTENSION PdoExtension, IN PCM_RESOURCE_LIST ResourceList)
 
NTSTATUS NTAPI PciSetResources (IN PPCI_PDO_EXTENSION PdoExtension, IN BOOLEAN DoReset, IN BOOLEAN SomethingSomethingDarkSide)
 
BOOLEAN NTAPI PciIsRequirementDescriptor (_In_ PIO_RESOURCE_DESCRIPTOR Limit)
 Tells whether a discovered limit asks the arbiter for a range.
 
BOOLEAN NTAPI PcipIsSameDevice (_In_ PPCI_PDO_EXTENSION DeviceExtension, _In_ PPCI_COMMON_HEADER PciData)
 
NTSTATUS NTAPI PciBuildRequirementsList (IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData, OUT PIO_RESOURCE_REQUIREMENTS_LIST *Buffer)
 
PWCHAR NTAPI PciGetDeviceDescriptionMessage (IN UCHAR BaseClass, IN UCHAR SubClass)
 
NTSTATUS NTAPI PciQueryDeviceText (IN PPCI_PDO_EXTENSION PdoExtension, IN DEVICE_TEXT_TYPE QueryType, IN ULONG Locale, OUT PWCHAR *Buffer)
 
NTSTATUS NTAPI PciQueryId (IN PPCI_PDO_EXTENSION DeviceExtension, IN BUS_QUERY_ID_TYPE QueryType, OUT PWCHAR *Buffer)
 
VOID NTAPI Cardbus_MassageHeaderForLimitsDetermination (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Cardbus_SaveCurrentSettings (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Cardbus_SaveLimits (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Cardbus_RestoreCurrent (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Cardbus_GetAdditionalResourceDescriptors (IN PPCI_CONFIGURATOR_CONTEXT Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
 
VOID NTAPI Cardbus_ResetDevice (IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)
 
NTSTATUS NTAPI Cardbus_ChangeResourceSettings (_In_ PPCI_PDO_EXTENSION PdoExtension, _Inout_ PPCI_COMMON_HEADER PciData)
 
VOID NTAPI Device_MassageHeaderForLimitsDetermination (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Device_SaveCurrentSettings (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Device_SaveLimits (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Device_RestoreCurrent (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI Device_GetAdditionalResourceDescriptors (IN PPCI_CONFIGURATOR_CONTEXT Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
 
VOID NTAPI Device_ResetDevice (IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)
 
NTSTATUS NTAPI Device_ChangeResourceSettings (_In_ PPCI_PDO_EXTENSION PdoExtension, _Inout_ PPCI_COMMON_HEADER PciData)
 Puts the ranges assigned to a function into its BARs and ROM BAR.
 
VOID NTAPI PPBridge_MassageHeaderForLimitsDetermination (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI PPBridge_SaveCurrentSettings (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI PPBridge_SaveLimits (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI PPBridge_RestoreCurrent (IN PPCI_CONFIGURATOR_CONTEXT Context)
 
VOID NTAPI PPBridge_GetAdditionalResourceDescriptors (IN PPCI_CONFIGURATOR_CONTEXT Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
 
VOID NTAPI PPBridge_ResetDevice (IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)
 
NTSTATUS NTAPI PPBridge_ChangeResourceSettings (_In_ PPCI_PDO_EXTENSION PdoExtension, _Inout_ PPCI_COMMON_HEADER PciData)
 
BOOLEAN NTAPI PciAreBusNumbersConfigured (IN PPCI_PDO_EXTENSION PdoExtension)
 
NTSTATUS NTAPI PciCacheLegacyDeviceRouting (IN PDEVICE_OBJECT DeviceObject, IN ULONG BusNumber, IN ULONG SlotNumber, IN UCHAR InterruptLine, IN UCHAR InterruptPin, IN UCHAR BaseClass, IN UCHAR SubClass, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PPCI_PDO_EXTENSION PdoExtension, OUT PDEVICE_OBJECT *pFoundDeviceObject)
 
VOID NTAPI PciFreeLegacyDeviceCache (VOID)
 Frees the routing cached for slots claimed by legacy drivers.
 

Variables

DRIVER_DISPATCH PciDispatchIrp
 
DRIVER_ADD_DEVICE PciAddDevice
 
KIPI_BROADCAST_WORKER PciExecuteCriticalSystemRoutine
 
SINGLE_LIST_ENTRY PciFdoExtensionListHead
 
KEVENT PciGlobalLock
 
PPCI_INTERFACE PciInterfaces []
 
BOOLEAN PciEcamVerified
 
PCI_INTERFACE ArbiterInterfaceBusNumber
 
PCI_INTERFACE ArbiterInterfaceMemory
 
PCI_INTERFACE ArbiterInterfaceIo
 
PCI_INTERFACE BusHandlerInterface
 
PCI_INTERFACE PciRoutingInterface
 
PCI_INTERFACE PciCardbusPrivateInterface
 
PCI_INTERFACE PciLegacyDeviceDetectionInterface
 
PCI_INTERFACE PciPmeInterface
 
PCI_INTERFACE PciDevicePresentInterface
 
PCI_INTERFACE PciLocationInterface
 
PCI_INTERFACE AgpTargetInterface
 
PCI_INTERFACE TranslatorInterfaceInterrupt
 
PDRIVER_OBJECT PciDriverObject
 
PWATCHDOG_TABLE WdTable
 
PPCI_HACK_ENTRY PciHackTable
 
BOOLEAN PciAssignBusNumbers
 
BOOLEAN PciEnableNativeModeATA
 
PPCI_IRQ_ROUTING_TABLE PciIrqRoutingTable
 
BOOLEAN PciRunningDatacenter
 
PIO_RESOURCE_REQUIREMENTS_LIST PciZeroIoResourceRequirements
 
RTL_RANGE_LIST PciIsaBitExclusionList
 
RTL_RANGE_LIST PciVgaAndIsaBitExclusionList
 
PCI_DEBUGGING_DEVICE PciDebuggingDevices [MAX_DEBUGGING_DEVICES_SUPPORTED]
 
ULONG PciDebugPortsCount
 

Macro Definition Documentation

◆ ARBITER_INTERFACE_VERSION

#define ARBITER_INTERFACE_VERSION   0

Definition at line 111 of file pci.h.

◆ ASSERT_FDO

#define ASSERT_FDO (   x)    ASSERT((x)->ExtensionType == PciFdoExtensionType);

Definition at line 47 of file pci.h.

◆ ASSERT_PDO

#define ASSERT_PDO (   x)    ASSERT((x)->ExtensionType == PciPdoExtensionType);

Definition at line 48 of file pci.h.

◆ MAX_ANSI_STRINGS

#define MAX_ANSI_STRINGS   0x08

Definition at line 126 of file pci.h.

◆ MAX_DEBUGGING_DEVICES_SUPPORTED

#define MAX_DEBUGGING_DEVICES_SUPPORTED   0x04

Definition at line 116 of file pci.h.

◆ PCI_HACK_ENTRY_FULL_SIZE

#define PCI_HACK_ENTRY_FULL_SIZE   sizeof(L"VVVVddddssssIIIIRR") - sizeof(UNICODE_NULL)

Definition at line 56 of file pci.h.

◆ PCI_HACK_ENTRY_REV_SIZE

#define PCI_HACK_ENTRY_REV_SIZE   sizeof(L"VVVVddddRR") - sizeof(UNICODE_NULL)

Definition at line 54 of file pci.h.

◆ PCI_HACK_ENTRY_SIZE

#define PCI_HACK_ENTRY_SIZE   sizeof(L"VVVVdddd") - sizeof(UNICODE_NULL)

Definition at line 53 of file pci.h.

◆ PCI_HACK_ENTRY_SUBSYS_SIZE

#define PCI_HACK_ENTRY_SUBSYS_SIZE   sizeof(L"VVVVddddssssIIII") - sizeof(UNICODE_NULL)

Definition at line 55 of file pci.h.

◆ PCI_HACK_FIXUP_AFTER_CONFIGURATION

#define PCI_HACK_FIXUP_AFTER_CONFIGURATION   0x01

Definition at line 81 of file pci.h.

◆ PCI_HACK_FIXUP_BEFORE_CONFIGURATION

#define PCI_HACK_FIXUP_BEFORE_CONFIGURATION   0x00

Definition at line 80 of file pci.h.

◆ PCI_HACK_FIXUP_BEFORE_UPDATE

#define PCI_HACK_FIXUP_BEFORE_UPDATE   0x03

Definition at line 82 of file pci.h.

◆ PCI_HACK_HAS_REVISION_INFO

#define PCI_HACK_HAS_REVISION_INFO   0x01

Definition at line 61 of file pci.h.

◆ PCI_HACK_HAS_SUBSYSTEM_INFO

#define PCI_HACK_HAS_SUBSYSTEM_INFO   0x02

Definition at line 62 of file pci.h.

◆ PCI_INTERFACE_FDO

#define PCI_INTERFACE_FDO   0x02

Definition at line 68 of file pci.h.

◆ PCI_INTERFACE_PDO

#define PCI_INTERFACE_PDO   0x01

Definition at line 67 of file pci.h.

◆ PCI_INTERFACE_ROOT

#define PCI_INTERFACE_ROOT   0x04

Definition at line 69 of file pci.h.

◆ PCI_INTERRUPT_LINE_UNKNOWN

#define PCI_INTERRUPT_LINE_UNKNOWN   0xFF

Definition at line 92 of file pci.h.

◆ PCI_IS_ROOT_FDO

#define PCI_IS_ROOT_FDO (   x)    ((x)->BusRootFdoExtension == x)

Definition at line 42 of file pci.h.

◆ PCI_LEGACY_CONFIG_LENGTH

#define PCI_LEGACY_CONFIG_LENGTH   0x100

Definition at line 87 of file pci.h.

◆ PCI_POOL_TAG

#define PCI_POOL_TAG   'BicP'

Definition at line 27 of file pci.h.

◆ PCI_RBAR_CAPABILITY_SIZES_SHIFT

#define PCI_RBAR_CAPABILITY_SIZES_SHIFT   4

Definition at line 101 of file pci.h.

◆ PCI_RBAR_CONTROL_BAR_INDEX_MASK

#define PCI_RBAR_CONTROL_BAR_INDEX_MASK   0x00000007

Definition at line 102 of file pci.h.

◆ PCI_RBAR_CONTROL_COUNT_MASK

#define PCI_RBAR_CONTROL_COUNT_MASK   0x000000E0

Definition at line 103 of file pci.h.

◆ PCI_RBAR_CONTROL_COUNT_SHIFT

#define PCI_RBAR_CONTROL_COUNT_SHIFT   5

Definition at line 104 of file pci.h.

◆ PCI_RBAR_CONTROL_SIZE_MASK

#define PCI_RBAR_CONTROL_SIZE_MASK   (0x3F << 8)

Definition at line 105 of file pci.h.

◆ PCI_RBAR_CONTROL_SIZE_SHIFT

#define PCI_RBAR_CONTROL_SIZE_SHIFT   8

Definition at line 106 of file pci.h.

◆ PCI_RBAR_ENTRY_CAPABILITY

#define PCI_RBAR_ENTRY_CAPABILITY (   n)    (0x04 + ((n) * 8))

Definition at line 99 of file pci.h.

◆ PCI_RBAR_ENTRY_CONTROL

#define PCI_RBAR_ENTRY_CONTROL (   n)    (0x08 + ((n) * 8))

Definition at line 100 of file pci.h.

◆ PCI_RBAR_EXTENDED_CAP_ID

#define PCI_RBAR_EXTENDED_CAP_ID   0x0015

Definition at line 97 of file pci.h.

◆ PCI_RBAR_MAX_ENTRIES

#define PCI_RBAR_MAX_ENTRIES   6

Definition at line 98 of file pci.h.

◆ PCI_SKIP_DEVICE_ENUMERATION

#define PCI_SKIP_DEVICE_ENUMERATION   0x01

Definition at line 74 of file pci.h.

◆ PCI_SKIP_RESOURCE_ENUMERATION

#define PCI_SKIP_RESOURCE_ENUMERATION   0x02

Definition at line 75 of file pci.h.

◆ PCI_VERIFIER_CODES

#define PCI_VERIFIER_CODES   0x04

Definition at line 121 of file pci.h.

◆ TAG_PCI_PRESERVED

#define TAG_PCI_PRESERVED   'PicP'

Definition at line 37 of file pci.h.

◆ TAG_PCI_ROUTING

#define TAG_PCI_ROUTING   'RicP'

Definition at line 32 of file pci.h.

Typedef Documentation

◆ PCI_ARBITER_INSTANCE

◆ PCI_CONFIGURATOR

◆ PCI_CONFIGURATOR_CHANGE_RESOURCE_SETTINGS

typedef NTSTATUS(NTAPI * PCI_CONFIGURATOR_CHANGE_RESOURCE_SETTINGS) (_In_ PPCI_PDO_EXTENSION PdoExtension, _Inout_ PPCI_COMMON_HEADER PciData)

Definition at line 520 of file pci.h.

◆ PCI_CONFIGURATOR_CONTEXT

◆ PCI_CONFIGURATOR_GET_ADDITIONAL_RESOURCE_DESCRIPTORS

typedef VOID(NTAPI * PCI_CONFIGURATOR_GET_ADDITIONAL_RESOURCE_DESCRIPTORS) (IN struct _PCI_CONFIGURATOR_CONTEXT *Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)

Definition at line 524 of file pci.h.

◆ PCI_CONFIGURATOR_INITIALIZE

typedef VOID(NTAPI * PCI_CONFIGURATOR_INITIALIZE) (IN struct _PCI_CONFIGURATOR_CONTEXT *Context)

Definition at line 504 of file pci.h.

◆ PCI_CONFIGURATOR_RESET_DEVICE

typedef VOID(NTAPI * PCI_CONFIGURATOR_RESET_DEVICE) (IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)

Definition at line 530 of file pci.h.

◆ PCI_CONFIGURATOR_RESTORE_CURRENT

typedef VOID(NTAPI * PCI_CONFIGURATOR_RESTORE_CURRENT) (IN struct _PCI_CONFIGURATOR_CONTEXT *Context)

Definition at line 508 of file pci.h.

◆ PCI_CONFIGURATOR_SAVE_CURRENT_SETTINGS

typedef VOID(NTAPI * PCI_CONFIGURATOR_SAVE_CURRENT_SETTINGS) (IN struct _PCI_CONFIGURATOR_CONTEXT *Context)

Definition at line 516 of file pci.h.

◆ PCI_CONFIGURATOR_SAVE_LIMITS

typedef VOID(NTAPI * PCI_CONFIGURATOR_SAVE_LIMITS) (IN struct _PCI_CONFIGURATOR_CONTEXT *Context)

Definition at line 512 of file pci.h.

◆ PCI_DEBUGGING_DEVICE

◆ PCI_DEVICE_TYPES

◆ PCI_DISPATCH_FUNCTION

typedef NTSTATUS(NTAPI * PCI_DISPATCH_FUNCTION) (IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PVOID DeviceExtension)

Definition at line 390 of file pci.h.

◆ PCI_DISPATCH_STYLE

◆ PCI_FDO_EXTENSION

◆ PCI_FUNCTION_RESOURCES

◆ PCI_HACK_ENTRY

◆ PCI_HEADER_TYPE_DEPENDENT

◆ PCI_ID_BUFFER

◆ PCI_INTERFACE

◆ PCI_INTERFACE_CONSTRUCTOR

typedef NTSTATUS(NTAPI * PCI_INTERFACE_CONSTRUCTOR) (IN PVOID DeviceExtension, IN PVOID Instance, IN PVOID InterfaceData, IN USHORT Version, IN USHORT Size, IN PINTERFACE Interface)

Definition at line 424 of file pci.h.

◆ PCI_INTERFACE_INITIALIZER

typedef NTSTATUS(NTAPI * PCI_INTERFACE_INITIALIZER) (IN PVOID Instance)

Definition at line 433 of file pci.h.

◆ PCI_IPI_CONTEXT

◆ PCI_IPI_FUNCTION

typedef VOID(NTAPI * PCI_IPI_FUNCTION) (IN PVOID Reserved, IN PVOID Context)

Definition at line 566 of file pci.h.

◆ PCI_LEGACY_DEVICE

◆ PCI_LOCK

◆ PCI_MJ_DISPATCH_TABLE

◆ PCI_MN_DISPATCH_TABLE

◆ PCI_PDO_EXTENSION

◆ PCI_POWER_STATE

◆ PCI_RESIZABLE_BAR_STATE

◆ PCI_SECONDARY_EXTENSION

◆ PCI_SIGNATURE

◆ PCI_STATE

◆ PCI_VERIFIER_DATA

◆ PPCI_ARBITER_INSTANCE

◆ PPCI_CONFIGURATOR

◆ PPCI_CONFIGURATOR_CONTEXT

◆ PPCI_DEBUGGING_DEVICE

◆ PPCI_FDO_EXTENSION

◆ PPCI_FUNCTION_RESOURCES

◆ PPCI_HACK_ENTRY

◆ PPCI_HEADER_TYPE_DEPENDENT

◆ PPCI_ID_BUFFER

◆ PPCI_INTERFACE

◆ PPCI_IPI_CONTEXT

◆ PPCI_LEGACY_DEVICE

◆ PPCI_LOCK

◆ PPCI_MJ_DISPATCH_TABLE

◆ PPCI_MN_DISPATCH_TABLE

◆ PPCI_PDO_EXTENSION

◆ PPCI_POWER_STATE

◆ PPCI_RESIZABLE_BAR_STATE

◆ PPCI_SECONDARY_EXTENSION

◆ PPCI_SIGNATURE

◆ PPCI_VERIFIER_DATA

Enumeration Type Documentation

◆ _PCI_DEVICE_TYPES

Enumerator
PciTypeInvalid 
PciTypeHostBridge 
PciTypePciBridge 
PciTypeCardbusBridge 
PciTypeDevice 

Definition at line 154 of file pci.h.

155{
@ PciTypeHostBridge
Definition: pci.h:157
@ PciTypeDevice
Definition: pci.h:160
@ PciTypePciBridge
Definition: pci.h:158
@ PciTypeInvalid
Definition: pci.h:156
@ PciTypeCardbusBridge
Definition: pci.h:159
enum _PCI_DEVICE_TYPES PCI_DEVICE_TYPES

◆ _PCI_DISPATCH_STYLE

Enumerator
IRP_COMPLETE 
IRP_DOWNWARD 
IRP_UPWARD 
IRP_DISPATCH 

Definition at line 180 of file pci.h.

181{
enum _PCI_DISPATCH_STYLE PCI_DISPATCH_STYLE
@ IRP_UPWARD
Definition: pci.h:184
@ IRP_COMPLETE
Definition: pci.h:182
@ IRP_DISPATCH
Definition: pci.h:185
@ IRP_DOWNWARD
Definition: pci.h:183

◆ _PCI_SIGNATURE

Enumerator
PciPdoExtensionType 
PciFdoExtensionType 
PciArb_Io 
PciArb_Memory 
PciArb_Interrupt 
PciArb_BusNumber 
PciTrans_Interrupt 
PciInterface_BusHandler 
PciInterface_IntRouteHandler 
PciInterface_PciCb 
PciInterface_LegacyDeviceDetection 
PciInterface_PmeHandler 
PciInterface_DevicePresent 
PciInterface_NativeIde 
PciInterface_AgpTarget 
PciInterface_Location 

Definition at line 131 of file pci.h.

132{
133 PciPdoExtensionType = 'icP0',
134 PciFdoExtensionType = 'icP1',
135 PciArb_Io = 'icP2',
136 PciArb_Memory = 'icP3',
137 PciArb_Interrupt = 'icP4',
138 PciArb_BusNumber = 'icP5',
139 PciTrans_Interrupt = 'icP6',
142 PciInterface_PciCb = 'icP9',
146 PciInterface_NativeIde = 'icP=',
147 PciInterface_AgpTarget = 'icP>',
148 PciInterface_Location = 'icP?'
enum _PCI_SIGNATURE PCI_SIGNATURE
enum _PCI_SIGNATURE * PPCI_SIGNATURE
@ PciInterface_NativeIde
Definition: pci.h:146
@ PciFdoExtensionType
Definition: pci.h:134
@ PciPdoExtensionType
Definition: pci.h:133
@ PciInterface_PciCb
Definition: pci.h:142
@ PciInterface_IntRouteHandler
Definition: pci.h:141
@ PciArb_BusNumber
Definition: pci.h:138
@ PciInterface_Location
Definition: pci.h:148
@ PciArb_Io
Definition: pci.h:135
@ PciInterface_DevicePresent
Definition: pci.h:145
@ PciArb_Interrupt
Definition: pci.h:137
@ PciInterface_BusHandler
Definition: pci.h:140
@ PciTrans_Interrupt
Definition: pci.h:139
@ PciInterface_LegacyDeviceDetection
Definition: pci.h:143
@ PciArb_Memory
Definition: pci.h:136
@ PciInterface_AgpTarget
Definition: pci.h:147
@ PciInterface_PmeHandler
Definition: pci.h:144

◆ _PCI_STATE

Enumerator
PciNotStarted 
PciStarted 
PciDeleted 
PciStopped 
PciSurpriseRemoved 
PciSynchronizedOperation 
PciMaxObjectState 

Definition at line 166 of file pci.h.

167{
175} PCI_STATE;
enum _PCI_STATE PCI_STATE
@ PciMaxObjectState
Definition: pci.h:174
@ PciSurpriseRemoved
Definition: pci.h:172
@ PciDeleted
Definition: pci.h:170
@ PciStarted
Definition: pci.h:169
@ PciSynchronizedOperation
Definition: pci.h:173
@ PciStopped
Definition: pci.h:171
@ PciNotStarted
Definition: pci.h:168

Function Documentation

◆ agpintrf_Constructor()

NTSTATUS NTAPI agpintrf_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 117 of file agpintrf.c.

123{
128
130 UNREFERENCED_PARAMETER(InterfaceData);
132 PAGED_CODE();
133
134 /* Only AGP bridges are supported (which are PCI-to-PCI Bridge Devices) */
135 if ((PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) ||
137 {
138 /* Fail any other PDO */
140 }
141
142 /* Without its own target capability the bridge relies on a host bridge beside it */
144 if (!PdoExtension->TargetAgpCapabilityId)
145 {
146 if (!PCI_IS_ROOT_FDO(PdoExtension->ParentFdoExtension))
148
149 Status = agpintrf_FindHostBridge(PdoExtension->ParentFdoExtension, &Target);
150 if (!NT_SUCCESS(Status))
151 return Status;
152 }
153
155 AgpInterface->Size = sizeof(*AgpInterface);
156 AgpInterface->Version = Version;
157 AgpInterface->Context = Target;
162 AgpInterface->CapabilityID = Target->TargetAgpCapabilityId;
163
164 return STATUS_SUCCESS;
165}
#define PAGED_CODE()
static VOID NTAPI agpintrf_Dereference(_In_ PVOID Context)
Definition: agpintrf.c:50
static NTSTATUS NTAPI agpintrf_FindHostBridge(_In_ PPCI_FDO_EXTENSION FdoExtension, _Out_ PPCI_PDO_EXTENSION *HostBridge)
Finds the one host bridge on a root bus that has an AGP capability.
Definition: agpintrf.c:65
static VOID NTAPI agpintrf_Reference(_In_ PVOID Context)
Definition: agpintrf.c:38
LONG NTSTATUS
Definition: precomp.h:26
ULONG NTAPI PciBusInterface_GetBusData(IN PVOID Context, IN ULONG WhichSpace, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: busintrf.c:92
ULONG NTAPI PciBusInterface_SetBusData(IN PVOID Context, IN ULONG WhichSpace, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: busintrf.c:112
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
struct _PCI_PDO_EXTENSION * PPCI_PDO_EXTENSION
#define PCI_IS_ROOT_FDO(x)
Definition: pci.h:42
@ PdoExtension
Definition: precomp.h:61
Status
Definition: gdiplustypes.h:24
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define STATUS_SUCCESS
Definition: shellext.h:65
PINTERFACE_REFERENCE InterfaceReference
Definition: iotypes.h:4536
PGET_SET_DEVICE_DATA GetBusData
Definition: iotypes.h:4539
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: iotypes.h:4537
PGET_SET_DEVICE_DATA SetBusData
Definition: iotypes.h:4538
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481
#define PCI_SUBCLASS_BR_PCI_TO_PCI
Definition: iotypes.h:4181
struct _AGP_TARGET_BUS_INTERFACE_STANDARD * PAGP_TARGET_BUS_INTERFACE_STANDARD
#define PCI_CLASS_BRIDGE_DEV
Definition: iotypes.h:4124

◆ agpintrf_Initializer()

NTSTATUS NTAPI agpintrf_Initializer ( IN PVOID  Instance)

Definition at line 107 of file agpintrf.c.

108{
110 /* PnP Interfaces don't get Initialized */
111 ASSERTMSG("PCI agpintrf_Initializer, unexpected call.\n", FALSE);
112 return STATUS_UNSUCCESSFUL;
113}
#define FALSE
Definition: types.h:117
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

◆ arbusno_Constructor()

NTSTATUS NTAPI arbusno_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 144 of file ar_busno.c.

150{
152 PAGED_CODE();
153
154 UNREFERENCED_PARAMETER(PciInterface);
157
158 /* This one only arbitrates bus numbers */
159 if ((ULONG_PTR)InterfaceData != CmResourceTypeBusNumber)
160 {
162 }
163
164 /* Hand out the instance that was built for this bus */
168}
NTSTATUS NTAPI PciArbiterConstructor(_In_ PPCI_FDO_EXTENSION FdoExtension, _In_ PCI_SIGNATURE ArbiterType, _Out_ PARBITER_INTERFACE Interface)
Definition: arb_comn.c:200
struct _PCI_FDO_EXTENSION * PPCI_FDO_EXTENSION
@ FdoExtension
Definition: precomp.h:60
#define STATUS_INVALID_PARAMETER_5
Definition: ntstatus.h:573
#define CmResourceTypeBusNumber
Definition: restypes.h:109
uint32_t ULONG_PTR
Definition: typedefs.h:65

◆ arbusno_Initializer()

NTSTATUS NTAPI arbusno_Initializer ( IN PVOID  Instance)

Definition at line 110 of file ar_busno.c.

111{
115
116 PAGED_CODE();
117
118 RtlZeroMemory(&Arbiter->CommonInstance, sizeof(Arbiter->CommonInstance));
119
120 FdoExtension = Arbiter->BusFdoExtension;
121
127
129 FdoExtension->FunctionalDeviceObject,
131 Arbiter->InstanceName,
132 L"Pci",
133 NULL);
134 if (!NT_SUCCESS(Status))
135 {
136 DPRINT1("PCIX - arbusno_Initializer: init arbiter return %X\n", Status);
137 }
138
139 return Status;
140}
NTSTATUS NTAPI arbusno_PackResource(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONGLONG Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource)
Definition: ar_busno.c:54
INT32 NTAPI arbusno_ScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor)
Definition: ar_busno.c:85
NTSTATUS NTAPI arbusno_UnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _Out_ PULONGLONG Minimum, _Out_ PULONGLONG Maximum, _Out_ PULONGLONG Length, _Out_ PULONGLONG Alignment)
Definition: ar_busno.c:35
NTSTATUS NTAPI arbusno_UnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource, _Out_ PULONGLONG Start, _Out_ PULONGLONG Length)
Definition: ar_busno.c:71
NTSTATUS NTAPI PciArbiter_PreprocessEntry(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE State)
Sets the range attributes of one arbitration entry before the engine looks for a placement for it.
Definition: arb_comn.c:51
NTSTATUS NTAPI ArbiterLibInitializeInstance(_Inout_ PARBITER_INSTANCE Arbiter, _In_ PDEVICE_OBJECT BusDeviceObject, _In_ CM_RESOURCE_TYPE ResourceType, _In_ PCWSTR ArbiterName, _In_ PCWSTR OrderName, _In_ PARB_TRANSLATE_ORDERING TranslateOrderingFunction)
Definition: arbiter.c:69
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define L(x)
Definition: resources.c:13
PPCI_FDO_EXTENSION BusFdoExtension
Definition: pci.h:470
WCHAR InstanceName[24]
Definition: pci.h:471
ARBITER_INSTANCE CommonInstance
Definition: pci.h:472
PARB_UNPACK_RESOURCE UnpackResource
Definition: arbiter.h:312
PARB_SCORE_REQUIREMENT ScoreRequirement
Definition: arbiter.h:313
PARB_UNPACK_REQUIREMENT UnpackRequirement
Definition: arbiter.h:310
PARB_PREPROCESS_ENTRY PreprocessEntry
Definition: arbiter.h:323
PARB_PACK_RESOURCE PackResource
Definition: arbiter.h:311
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

◆ arbusno_PackResource()

NTSTATUS NTAPI arbusno_PackResource ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_In_ ULONGLONG  Start,
_Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Resource 
)

Definition at line 54 of file ar_busno.c.

57{
58 /* Turn the run of bus numbers the engine settled on into a resource */
60
62 Resource->Flags = Descriptor->Flags;
63 Resource->ShareDisposition = Descriptor->ShareDisposition;
64 Resource->u.BusNumber.Start = (ULONG)Start;
65 Resource->u.BusNumber.Length = Descriptor->u.BusNumber.Length;
66 return STATUS_SUCCESS;
67}
static _Out_opt_ PULONGLONG Start
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by arbusno_Initializer().

◆ arbusno_ScoreRequirement()

INT32 NTAPI arbusno_ScoreRequirement ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor)

Definition at line 85 of file ar_busno.c.

86{
87 ULONGLONG Minimum, Maximum, Length, Alignment;
88
89 /* A requirement this arbiter cannot read is treated as unsatisfiable */
91 &Minimum,
92 &Maximum,
93 &Length,
94 &Alignment)) ||
95 (Maximum < Minimum))
96 {
97 return -1;
98 }
99
100 /*
101 * The score is how many places the run could go, so that the engine places
102 * the most constrained requirements first.
103 */
104 if ((Maximum - Minimum) >= MAXLONG) return MAXLONG;
105 return (INT32)(Maximum - Minimum + 1);
106}
union Alignment_ Alignment
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
int32_t INT32
Definition: typedefs.h:58
uint64_t ULONGLONG
Definition: typedefs.h:67
#define MAXLONG
Definition: umtypes.h:116

Referenced by arbusno_Initializer().

◆ arbusno_UnpackRequirement()

NTSTATUS NTAPI arbusno_UnpackRequirement ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_Out_ PULONGLONG  Minimum,
_Out_ PULONGLONG  Maximum,
_Out_ PULONGLONG  Length,
_Out_ PULONGLONG  Alignment 
)

Definition at line 35 of file ar_busno.c.

40{
41 /* This arbiter is only ever handed bus number descriptors */
43
44 /* Bus numbers are counted, not addressed, so they are always unit-aligned */
45 *Minimum = Descriptor->u.BusNumber.MinBusNumber;
46 *Maximum = Descriptor->u.BusNumber.MaxBusNumber;
47 *Length = Descriptor->u.BusNumber.Length;
48 *Alignment = 1;
49 return STATUS_SUCCESS;
50}

Referenced by arbusno_Initializer(), and arbusno_ScoreRequirement().

◆ arbusno_UnpackResource()

NTSTATUS NTAPI arbusno_UnpackResource ( _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Resource,
_Out_ PULONGLONG  Start,
_Out_ PULONGLONG  Length 
)

Definition at line 71 of file ar_busno.c.

74{
75 /* Read a previously packed run of bus numbers back out */
77
78 *Start = Resource->u.BusNumber.Start;
79 *Length = Resource->u.BusNumber.Length;
80 return STATUS_SUCCESS;
81}

Referenced by arbusno_Initializer().

◆ ario_ApplyBrokenVideoHack()

VOID NTAPI ario_ApplyBrokenVideoHack ( IN PPCI_FDO_EXTENSION  FdoExtension)

Definition at line 184 of file ar_memio.c.

185{
186 PPCI_ARBITER_INSTANCE PciArbiter;
187 PARBITER_INSTANCE CommonInstance;
189
190 /* Only valid for root FDOs who are being applied the hack for the first time */
191 ASSERT(!FdoExtension->BrokenVideoHackApplied);
193
194 /* Find the I/O arbiter */
196 SecondaryExtension.Next,
197 PciArb_Io);
198 ASSERT(PciArbiter);
199 if (!PciArbiter) return;
200
201 /* Get the Arb instance */
202 CommonInstance = &PciArbiter->CommonInstance;
203
204 /* Free the two lists, enabling full VGA access */
207
208 /* Build the ordering for broken video PCI access */
210 L"Pci",
211 L"BrokenVideo",
212 NULL);
214 if (!NT_SUCCESS(Status))
215 {
216 DPRINT1("PCIX - ario_ApplyBrokenVideoHack: ordering failed %X\n", Status);
217 }
218
219 /* Now the hack has been applied */
220 FdoExtension->BrokenVideoHackApplied = TRUE;
221}
NTSTATUS NTAPI ArbiterLibDefaultAssignmentOrdering(_Inout_ PARBITER_INSTANCE Arbiter, _In_ PCWSTR AllocationOrderName, _In_ PCWSTR ReservedResourcesName, _In_opt_ PARB_TRANSLATE_ORDERING TranslateOrderingFunction)
Builds the arbiter's allocation ordering from the registry policy, most-preferred window first.
Definition: ordering.c:571
VOID NTAPI ArbiterLibFreeOrderingList(_Inout_ PARBITER_ORDERING_LIST OrderingList)
Definition: ordering.c:60
#define TRUE
Definition: types.h:120
PPCI_SECONDARY_EXTENSION NTAPI PciFindNextSecondaryExtension(IN PSINGLE_LIST_ENTRY ListHead, IN PCI_SIGNATURE ExtensionType)
Definition: utils.c:584
#define ASSERT(a)
Definition: mode.c:44
ARBITER_ORDERING_LIST ReservedList
Definition: arbiter.h:305
ARBITER_ORDERING_LIST OrderingList
Definition: arbiter.h:304
void * PVOID
Definition: typedefs.h:50

Referenced by PciApplyHacks().

◆ ario_Constructor()

NTSTATUS NTAPI ario_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 156 of file ar_memio.c.

162{
164 PAGED_CODE();
165
166 UNREFERENCED_PARAMETER(PciInterface);
169
170 /* This one only arbitrates I/O ports */
171 if ((ULONG_PTR)InterfaceData != CmResourceTypePort)
172 {
174 }
175
176 /* Hand out the instance that was built for this bus */
178 PciArb_Io,
180}
#define CmResourceTypePort
Definition: restypes.h:104

◆ ario_Initializer()

NTSTATUS NTAPI ario_Initializer ( IN PVOID  Instance)

Definition at line 119 of file ar_memio.c.

120{
124 PAGED_CODE();
125
126 /* Start from a clean engine instance */
127 RtlZeroMemory(&Arbiter->CommonInstance, sizeof(Arbiter->CommonInstance));
128 FdoExtension = Arbiter->BusFdoExtension;
129
130 /* Teach the engine how to read and write I/O port descriptors */
138
139 /* The rest of the engine, and the PCI assignment ordering, is generic */
141 FdoExtension->FunctionalDeviceObject,
143 Arbiter->InstanceName,
144 L"Pci",
145 NULL);
146 if (!NT_SUCCESS(Status))
147 {
148 DPRINT1("PCIX - ario_Initializer: init arbiter returned %X\n", Status);
149 }
150
151 return Status;
152}
NTSTATUS NTAPI ario_PackResource(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONGLONG Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource)
Definition: ar_memio.c:67
INT32 NTAPI ario_ScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor)
Definition: ar_memio.c:98
NTSTATUS NTAPI ario_UnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _Out_ PULONGLONG Minimum, _Out_ PULONGLONG Maximum, _Out_ PULONGLONG Length, _Out_ PULONGLONG Alignment)
Definition: ar_memio.c:48
NTSTATUS NTAPI ario_UnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource, _Out_ PULONGLONG Start, _Out_ PULONGLONG Length)
Definition: ar_memio.c:84
BOOLEAN NTAPI PciArbiter_FindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE State)
Searches for a placement, remembering on the range whether it came from a fixed alternative.
Definition: arb_comn.c:97
BOOLEAN NTAPI PciArbiter_OverrideConflict(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE State)
Lets a fixed requirement overlap ranges its own device was given by other fixed requirements.
Definition: arb_comn.c:136
PARB_OVERRIDE_CONFLICT OverrideConflict
Definition: arbiter.h:329
PARB_FIND_SUITABLE_RANGE FindSuitableRange
Definition: arbiter.h:326

◆ ario_PackResource()

NTSTATUS NTAPI ario_PackResource ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_In_ ULONGLONG  Start,
_Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Resource 
)

Definition at line 67 of file ar_memio.c.

70{
71 /* Turn the placement the engine settled on back into an I/O port resource */
73
75 Resource->Flags = Descriptor->Flags;
76 Resource->ShareDisposition = Descriptor->ShareDisposition;
77 Resource->u.Port.Start.QuadPart = (LONGLONG)Start;
78 Resource->u.Port.Length = Descriptor->u.Port.Length;
79 return STATUS_SUCCESS;
80}
int64_t LONGLONG
Definition: typedefs.h:68

Referenced by ario_Initializer().

◆ ario_ScoreRequirement()

INT32 NTAPI ario_ScoreRequirement ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor)

Definition at line 98 of file ar_memio.c.

99{
100 ULONGLONG Minimum, Maximum, Length, Alignment;
101
102 /* A requirement this arbiter cannot read is treated as unsatisfiable */
104 &Minimum,
105 &Maximum,
106 &Length,
107 &Alignment)) ||
108 (Maximum < Minimum))
109 {
110 return -1;
111 }
112
113 if ((Maximum - Minimum) >= MAXLONG) return MAXLONG;
114 return (INT32)(Maximum - Minimum + 1);
115}

Referenced by ario_Initializer().

◆ ario_UnpackRequirement()

NTSTATUS NTAPI ario_UnpackRequirement ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_Out_ PULONGLONG  Minimum,
_Out_ PULONGLONG  Maximum,
_Out_ PULONGLONG  Length,
_Out_ PULONGLONG  Alignment 
)

Definition at line 48 of file ar_memio.c.

53{
54 /* This arbiter is only ever handed I/O port descriptors */
56
57 /* An alignment of zero would place the range nowhere, so make it one byte */
58 *Minimum = (ULONGLONG)Descriptor->u.Port.MinimumAddress.QuadPart;
59 *Maximum = (ULONGLONG)Descriptor->u.Port.MaximumAddress.QuadPart;
60 *Length = Descriptor->u.Port.Length;
61 *Alignment = Descriptor->u.Port.Alignment ? Descriptor->u.Port.Alignment : 1;
62 return STATUS_SUCCESS;
63}

Referenced by ario_Initializer(), and ario_ScoreRequirement().

◆ ario_UnpackResource()

NTSTATUS NTAPI ario_UnpackResource ( _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Resource,
_Out_ PULONGLONG  Start,
_Out_ PULONGLONG  Length 
)

Definition at line 84 of file ar_memio.c.

87{
88 /* Read a previously packed I/O port resource back out */
90
91 *Start = (ULONGLONG)Resource->u.Port.Start.QuadPart;
92 *Length = Resource->u.Port.Length;
93 return STATUS_SUCCESS;
94}

Referenced by ario_Initializer().

◆ armem_Constructor()

NTSTATUS NTAPI armem_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 345 of file ar_memio.c.

351{
353 PAGED_CODE();
354
355 UNREFERENCED_PARAMETER(PciInterface);
358
359 /* This one only arbitrates device memory */
360 if ((ULONG_PTR)InterfaceData != CmResourceTypeMemory)
361 {
363 }
364
365 /* Hand out the instance that was built for this bus */
369}
#define CmResourceTypeMemory
Definition: restypes.h:106

◆ armem_Initializer()

NTSTATUS NTAPI armem_Initializer ( IN PVOID  Instance)

Definition at line 308 of file ar_memio.c.

309{
313 PAGED_CODE();
314
315 /* Start from a clean engine instance */
316 RtlZeroMemory(&Arbiter->CommonInstance, sizeof(Arbiter->CommonInstance));
317 FdoExtension = Arbiter->BusFdoExtension;
318
319 /* Teach the engine how to read and write memory descriptors */
327
328 /* The rest of the engine, and the PCI assignment ordering, is generic */
330 FdoExtension->FunctionalDeviceObject,
332 Arbiter->InstanceName,
333 L"Pci",
334 NULL);
335 if (!NT_SUCCESS(Status))
336 {
337 DPRINT1("PCIX - armem_Initializer: init arbiter returned %X\n", Status);
338 }
339
340 return Status;
341}
NTSTATUS NTAPI armem_UnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource, _Out_ PULONGLONG Start, _Out_ PULONGLONG Length)
Definition: ar_memio.c:270
INT32 NTAPI armem_ScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor)
Definition: ar_memio.c:287
NTSTATUS NTAPI armem_PackResource(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONGLONG Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource)
Definition: ar_memio.c:248
NTSTATUS NTAPI armem_UnpackRequirement(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _Out_ PULONGLONG Minimum, _Out_ PULONGLONG Maximum, _Out_ PULONGLONG Length, _Out_ PULONGLONG Alignment)
Definition: ar_memio.c:225

◆ armem_PackResource()

NTSTATUS NTAPI armem_PackResource ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_In_ ULONGLONG  Start,
_Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Resource 
)

Definition at line 248 of file ar_memio.c.

251{
252 /* Turn the placement the engine settled on back into a memory resource */
253 if ((Descriptor->Type != CmResourceTypeMemory) &&
255 {
257 }
258
259 /* The flags say how a large length is scaled, so both come across unchanged */
260 Resource->Type = Descriptor->Type;
261 Resource->Flags = Descriptor->Flags;
262 Resource->ShareDisposition = Descriptor->ShareDisposition;
263 Resource->u.Memory.Start.QuadPart = (LONGLONG)Start;
264 Resource->u.Memory.Length = Descriptor->u.Memory.Length;
265 return STATUS_SUCCESS;
266}
#define CmResourceTypeMemoryLarge
Definition: cmtypes.h:231

Referenced by armem_Initializer().

◆ armem_ScoreRequirement()

INT32 NTAPI armem_ScoreRequirement ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor)

Definition at line 287 of file ar_memio.c.

288{
289 ULONGLONG Minimum, Maximum, Length, Alignment;
290
291 /* A requirement this arbiter cannot read is treated as unsatisfiable */
293 &Minimum,
294 &Maximum,
295 &Length,
296 &Alignment)) ||
297 (Maximum < Minimum))
298 {
299 return -1;
300 }
301
302 if ((Maximum - Minimum) >= MAXLONG) return MAXLONG;
303 return (INT32)(Maximum - Minimum + 1);
304}

Referenced by armem_Initializer().

◆ armem_UnpackRequirement()

NTSTATUS NTAPI armem_UnpackRequirement ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_Out_ PULONGLONG  Minimum,
_Out_ PULONGLONG  Maximum,
_Out_ PULONGLONG  Length,
_Out_ PULONGLONG  Alignment 
)

Definition at line 225 of file ar_memio.c.

230{
231 /* This arbiter is only ever handed device memory descriptors, large ones included */
232 if ((Descriptor->Type != CmResourceTypeMemory) &&
234 {
236 }
237
238 /* An alignment of zero would place the range nowhere, so make it one byte */
240 if (!*Alignment)
241 *Alignment = 1;
242
243 return STATUS_SUCCESS;
244}
ULONGLONG NTAPI RtlIoDecodeMemIoResource(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _Out_opt_ PULONGLONG Alignment, _Out_opt_ PULONGLONG MinimumAddress, _Out_opt_ PULONGLONG MaximumAddress)
Definition: memres.c:79

Referenced by armem_Initializer(), and armem_ScoreRequirement().

◆ armem_UnpackResource()

NTSTATUS NTAPI armem_UnpackResource ( _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Resource,
_Out_ PULONGLONG  Start,
_Out_ PULONGLONG  Length 
)

Definition at line 270 of file ar_memio.c.

273{
274 /* Read a previously packed memory resource back out */
275 if ((Resource->Type != CmResourceTypeMemory) &&
277 {
279 }
280
282 return STATUS_SUCCESS;
283}
ULONGLONG NTAPI RtlCmDecodeMemIoResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _Out_opt_ PULONGLONG Start)
Definition: memres.c:58

Referenced by armem_Initializer().

◆ busintrf_Constructor()

NTSTATUS NTAPI busintrf_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 142 of file busintrf.c.

148{
149 PBUS_INTERFACE_STANDARD BusInterface;
151
153 UNREFERENCED_PARAMETER(InterfaceData);
155 PAGED_CODE();
156
157 if (Size < sizeof(BUS_INTERFACE_STANDARD))
158 {
159 return STATUS_UNSUCCESSFUL;
160 }
161
162 BusInterface = (PBUS_INTERFACE_STANDARD)Interface;
163 PdoExtension = (PPCI_PDO_EXTENSION)DeviceExtension;
164
165 BusInterface->Size = sizeof(*BusInterface);
166 BusInterface->Version = 1;
167 BusInterface->Context = PdoExtension;
170
175
176 return STATUS_SUCCESS;
177}
VOID NTAPI PciBusInterface_Dereference(IN PVOID Context)
Definition: busintrf.c:44
VOID NTAPI PciBusInterface_Reference(IN PVOID Context)
Definition: busintrf.c:35
PDMA_ADAPTER NTAPI PciBusInterface_GetDmaAdapter(IN PVOID Context, IN PDEVICE_DESCRIPTION DeviceDescriptor, OUT PULONG NumberOfMapRegisters)
Definition: busintrf.c:73
BOOLEAN NTAPI PciBusInterface_TranslateBusAddress(IN PVOID Context, IN PHYSICAL_ADDRESS BusAddress, IN ULONG Length, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: busintrf.c:53
PGET_SET_DEVICE_DATA SetBusData
Definition: iotypes.h:915
PINTERFACE_REFERENCE InterfaceReference
Definition: iotypes.h:911
PTRANSLATE_BUS_ADDRESS TranslateBusAddress
Definition: iotypes.h:913
PGET_SET_DEVICE_DATA GetBusData
Definition: iotypes.h:916
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: iotypes.h:912
PGET_DMA_ADAPTER GetDmaAdapter
Definition: iotypes.h:914
struct _BUS_INTERFACE_STANDARD * PBUS_INTERFACE_STANDARD

◆ busintrf_Initializer()

NTSTATUS NTAPI busintrf_Initializer ( IN PVOID  Instance)

Definition at line 132 of file busintrf.c.

133{
135 /* PnP Interfaces don't get Initialized */
136 ASSERTMSG("PCI busintrf_Initializer, unexpected call.\n", FALSE);
137 return STATUS_UNSUCCESSFUL;
138}

◆ Cardbus_ChangeResourceSettings()

NTSTATUS NTAPI Cardbus_ChangeResourceSettings ( _In_ PPCI_PDO_EXTENSION  PdoExtension,
_Inout_ PPCI_COMMON_HEADER  PciData 
)

Definition at line 149 of file cardbus.c.

152{
154 ULONG Bar, BarMask;
155
156 /* The socket register BAR gets its assigned address, or zero when it was given none */
157 Resources = PdoExtension->Resources;
158 if ((Resources) && (Resources->Limit[0].Type != CmResourceTypeNull))
159 {
160 Bar = PciData->u.type2.SocketRegistersBaseAddress;
162 {
164 }
165 else
166 {
168 }
169
170 Bar &= ~BarMask;
171 if (Resources->Current[0].Type != CmResourceTypeNull)
172 Bar |= Resources->Current[0].u.Generic.Start.LowPart & BarMask;
173
174 PciData->u.type2.SocketRegistersBaseAddress = Bar;
175 }
176
177 /* The windows stay as read, only what a power loss would wipe is written again */
178 PciData->u.type2.PrimaryBus = PdoExtension->Dependent.type1.PrimaryBus;
179 PciData->u.type2.SecondaryBus = PdoExtension->Dependent.type1.SecondaryBus;
180 PciData->u.type2.SubordinateBus = PdoExtension->Dependent.type1.SubordinateBus;
181
182 if (PdoExtension->Dependent.type1.VgaBitSet)
183 PciData->u.type2.BridgeControl |= PCI_ENABLE_BRIDGE_VGA;
184
185 return STATUS_SUCCESS;
186}
void Bar(void)
Definition: terminate.cpp:70
#define CmResourceTypeNull
Definition: restypes.h:103
#define PCI_ENABLE_BRIDGE_VGA
Definition: pci.h:63
#define PCI_ADDRESS_IO_ADDRESS_MASK
Definition: iotypes.h:4249
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4246
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK
Definition: iotypes.h:4250

◆ Cardbus_GetAdditionalResourceDescriptors()

VOID NTAPI Cardbus_GetAdditionalResourceDescriptors ( IN PPCI_CONFIGURATOR_CONTEXT  Context,
IN PPCI_COMMON_HEADER  PciData,
IN PIO_RESOURCE_DESCRIPTOR  IoDescriptor 
)

Definition at line 128 of file cardbus.c.

131{
132 /* The VGA enable is the same bit as on a PCI-to-PCI bridge */
134}
VOID NTAPI PPBridge_GetAdditionalResourceDescriptors(IN PPCI_CONFIGURATOR_CONTEXT Context, IN PPCI_COMMON_HEADER PciData, IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
Definition: ppbridge.c:657
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81

◆ Cardbus_MassageHeaderForLimitsDetermination()

VOID NTAPI Cardbus_MassageHeaderForLimitsDetermination ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 102 of file cardbus.c.

103{
104 PPCI_COMMON_HEADER Current, PciData;
105
106 Current = Context->Current;
107 PciData = Context->PciData;
108
109 /* Only the socket register BAR is sized, the windows keep what the firmware wrote */
110 PciData->u.type2.SocketRegistersBaseAddress = 0xFFFFFFFF;
111
112 /* Writing the error bits back would clear them, so keep them out of the probe */
113 Context->SecondaryStatus = Current->u.type2.SecondaryStatus;
114 Current->u.type2.SecondaryStatus = 0;
115 PciData->u.type2.SecondaryStatus = 0;
116}

◆ Cardbus_ResetDevice()

VOID NTAPI Cardbus_ResetDevice ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN PPCI_COMMON_HEADER  PciData 
)

Definition at line 138 of file cardbus.c.

140{
142 UNREFERENCED_PARAMETER(PciData);
143
144 /* The socket reset bit belongs to the socket driver, so it goes back as it was read */
145}

◆ Cardbus_RestoreCurrent()

VOID NTAPI Cardbus_RestoreCurrent ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 120 of file cardbus.c.

121{
122 /* Put back the secondary status that was held out of the probe */
123 Context->Current->u.type2.SecondaryStatus = Context->SecondaryStatus;
124}

◆ Cardbus_SaveCurrentSettings()

VOID NTAPI Cardbus_SaveCurrentSettings ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 39 of file cardbus.c.

40{
42 PPCI_COMMON_HEADER Current;
46
47 PdoExtension = Context->PdoExtension;
48 Current = Context->Current;
49 Limit = &PdoExtension->Resources->Limit[0];
50 Partial = &PdoExtension->Resources->Current[0];
51
52 /* Only the socket register BAR is tracked, the four windows are left to the socket driver */
53 Partial->Type = Limit->Type;
54 if (Limit->Type != CmResourceTypeNull)
55 {
56 Address = Current->u.type2.SocketRegistersBaseAddress;
57 if (Limit->Type == CmResourceTypePort)
58 {
60 }
61 else
62 {
64 }
65
66 Partial->Flags = Limit->Flags;
67 Partial->ShareDisposition = Limit->ShareDisposition;
68 Partial->u.Generic.Start.QuadPart = Address;
69 Partial->u.Generic.Length = Limit->u.Generic.Length;
70
71 /* A BAR the firmware never placed decodes nothing yet */
72 if (!Address)
73 Partial->Type = CmResourceTypeNull;
74 }
75
76 /* Remember the bus numbers so they survive the function losing power */
77 PdoExtension->Dependent.type1.PrimaryBus = Current->u.type2.PrimaryBus;
78 PdoExtension->Dependent.type1.SecondaryBus = Current->u.type2.SecondaryBus;
79 PdoExtension->Dependent.type1.SubordinateBus = Current->u.type2.SubordinateBus;
80
81 /* A bridge that forwards VGA also claims the legacy video ranges */
82 if (Current->u.type2.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
83 {
84 PdoExtension->Dependent.type1.VgaBitSet = TRUE;
85 PdoExtension->AdditionalResourceCount = 4;
86 }
87}
static WCHAR Address[46]
Definition: ping.c:68
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@495 Generic
_In_ LONG _In_ LONG Limit
Definition: kefuncs.h:304

◆ Cardbus_SaveLimits()

VOID NTAPI Cardbus_SaveLimits ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 91 of file cardbus.c.

92{
93 /* The socket register BAR is 32-bit only, so it never takes a high half from the next field */
94 PciCreateIoDescriptorFromBarLimit(&Context->PdoExtension->Resources->Limit[0],
95 Context->PciData->u.type2.SocketRegistersBaseAddress,
96 0,
97 FALSE);
98}
BOOLEAN NTAPI PciCreateIoDescriptorFromBarLimit(_Out_ PIO_RESOURCE_DESCRIPTOR ResourceDescriptor, _In_ ULONG Bar, _In_ ULONG NextBar, _In_ BOOLEAN Rom)
Builds the requirement of a BAR from the value it reads back after all ones were written to it.
Definition: utils.c:1252

◆ Device_ChangeResourceSettings()

NTSTATUS NTAPI Device_ChangeResourceSettings ( _In_ PPCI_PDO_EXTENSION  PdoExtension,
_Inout_ PPCI_COMMON_HEADER  PciData 
)

Puts the ranges assigned to a function into its BARs and ROM BAR.

Parameters
[in]PdoExtensionThe PDO extension of the function.
[in,out]PciDataThe header that will be written to the function.
Returns
STATUS_INVALID_PARAMETER if a BAR would decode an address nobody assigned to it.

Definition at line 308 of file device.c.

311{
315 PULONG BarArray;
316 ULONG Bar, BarMask, i;
317 USHORT Decode;
318 BOOLEAN IsVga, HasUpperHalf;
319
320 Resources = PdoExtension->Resources;
321 if (!Resources)
322 return STATUS_SUCCESS;
323
324 /* VGA decodes are forced on at start, so a BAR it was not given may stay empty */
325 IsVga = ((PdoExtension->BaseClass == PCI_CLASS_PRE_20) &&
326 (PdoExtension->SubClass == PCI_SUBCLASS_PRE_20_VGA)) ||
327 ((PdoExtension->BaseClass == PCI_CLASS_DISPLAY_CTLR) &&
329
330 BarArray = PciData->u.type0.BaseAddresses;
331 for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
332 {
333 Limit = &Resources->Limit[i];
334 CmDescriptor = &Resources->Current[i];
335
336 if (CmDescriptor->Type == CmResourceTypeNull)
337 {
338 /* A requested BAR left without a range must not decode while its space is on */
339 Decode = (Limit->Type == CmResourceTypePort) ? PCI_ENABLE_IO_SPACE :
342 (PdoExtension->CommandEnables & Decode) &&
343 !IsVga)
344 {
345 DPRINT1("PCIX - pdox %p BAR %lu has no range but its decode stays on\n",
347 i);
349 }
350
351 BarArray[i] = 0;
352 continue;
353 }
354
355 /* The limit says what the BAR decodes, its read-only low bits say how wide it is */
356 Bar = BarArray[i];
357 HasUpperHalf = FALSE;
358 if (Limit->Type == CmResourceTypePort)
359 {
361 }
363 {
364 BarMask = 0xFFFF0;
365 }
366 else
367 {
369 HasUpperHalf = ((Bar & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_64BIT) &&
370 ((i + 1) < PCI_TYPE0_ADDRESSES);
371 }
372
373 if (!HasUpperHalf && CmDescriptor->u.Generic.Start.HighPart)
374 {
375 DPRINT1("PCIX - pdox %p BAR %lu cannot hold address %I64x\n",
377 i,
378 CmDescriptor->u.Generic.Start.QuadPart);
380 }
381
382 BarArray[i] = (Bar & ~BarMask) | (CmDescriptor->u.Generic.Start.LowPart & BarMask);
383 if (HasUpperHalf)
384 {
385 i++;
386 BarArray[i] = CmDescriptor->u.Generic.Start.HighPart;
387 }
388 }
389
390 /* The ROM decodes only while its enable bit is set, and reads zero when it has no range */
391 CmDescriptor = &Resources->Current[PCI_TYPE0_ADDRESSES];
392 if (CmDescriptor->Type == CmResourceTypeNull)
393 {
394 PciData->u.type0.ROMBaseAddress = 0;
395 }
396 else
397 {
398 Bar = PciData->u.type0.ROMBaseAddress & ~PCI_ADDRESS_ROM_ADDRESS_MASK;
399 PciData->u.type0.ROMBaseAddress = Bar |
400 (CmDescriptor->u.Generic.Start.LowPart &
403 }
404
405 return STATUS_SUCCESS;
406}
unsigned char BOOLEAN
Definition: actypes.h:127
BOOLEAN NTAPI PciIsRequirementDescriptor(_In_ PIO_RESOURCE_DESCRIPTOR Limit)
Tells whether a discovered limit asks the arbiter for a range.
Definition: enum.c:671
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
unsigned short USHORT
Definition: pedump.c:61
uint32_t * PULONG
Definition: typedefs.h:59
#define PCI_TYPE_64BIT
Definition: iotypes.h:4255
#define PCI_TYPE0_ADDRESSES
Definition: iotypes.h:3515
#define PCI_ENABLE_IO_SPACE
Definition: iotypes.h:3631
#define PCI_ENABLE_MEMORY_SPACE
Definition: iotypes.h:3632
#define PCI_TYPE_20BIT
Definition: iotypes.h:4254
#define PCI_ADDRESS_ROM_ADDRESS_MASK
Definition: iotypes.h:4251
#define PCI_CLASS_PRE_20
Definition: iotypes.h:4118
#define PCI_ROMADDRESS_ENABLED
Definition: iotypes.h:4257
#define PCI_SUBCLASS_VID_VGA_CTLR
Definition: iotypes.h:4160
#define PCI_ADDRESS_MEMORY_TYPE_MASK
Definition: iotypes.h:4247
#define PCI_SUBCLASS_PRE_20_VGA
Definition: iotypes.h:4140
#define PCI_CLASS_DISPLAY_CTLR
Definition: iotypes.h:4121

◆ Device_GetAdditionalResourceDescriptors()

VOID NTAPI Device_GetAdditionalResourceDescriptors ( IN PPCI_CONFIGURATOR_CONTEXT  Context,
IN PPCI_COMMON_HEADER  PciData,
IN PIO_RESOURCE_DESCRIPTOR  IoDescriptor 
)

Definition at line 271 of file device.c.

274{
276 UNREFERENCED_PARAMETER(PciData);
277 UNREFERENCED_PARAMETER(IoDescriptor);
278
279 /* A device decodes nothing beyond its BARs, only bridges add ranges here */
280}

◆ Device_MassageHeaderForLimitsDetermination()

VOID NTAPI Device_MassageHeaderForLimitsDetermination ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 230 of file device.c.

231{
232 PPCI_COMMON_HEADER PciData;
234 PULONG BarArray;
235 ULONG i = 0;
236
237 /* Get pointers from context data */
238 PdoExtension = Context->PdoExtension;
239 PciData = Context->PciData;
240
241 /* Get the array of BARs */
242 BarArray = PciData->u.type0.BaseAddresses;
243
244 /* Check for IDE controllers that are not in native mode */
245 if ((PdoExtension->BaseClass == PCI_CLASS_MASS_STORAGE_CTLR) &&
247 (PdoExtension->ProgIf & 5) != 5)
248 {
249 /* These controllers only use legacy resources */
250 i = 4;
251 }
252
253 /* Set all the bits on, which will allow us to recover the limit data */
254 for (i = 0; i < PCI_TYPE0_ADDRESSES; i++) BarArray[i] = 0xFFFFFFFF;
255
256 /* Do the same for the PCI ROM BAR */
257 PciData->u.type0.ROMBaseAddress = PCI_ADDRESS_ROM_ADDRESS_MASK;
258}
#define PCI_CLASS_MASS_STORAGE_CTLR
Definition: iotypes.h:4119
#define PCI_SUBCLASS_MSC_IDE_CTLR
Definition: iotypes.h:4144

◆ Device_ResetDevice()

VOID NTAPI Device_ResetDevice ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN PPCI_COMMON_HEADER  PciData 
)

Definition at line 284 of file device.c.

286{
288 UNREFERENCED_PARAMETER(PciData);
289
290 /* Nothing to undo, the caller writes the whole header back */
291}

◆ Device_RestoreCurrent()

VOID NTAPI Device_RestoreCurrent ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 262 of file device.c.

263{
265 /* Nothing to do for devices */
266 return;
267}

◆ Device_SaveCurrentSettings()

VOID NTAPI Device_SaveCurrentSettings ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 20 of file device.c.

21{
22 PPCI_COMMON_HEADER PciData;
23 PIO_RESOURCE_DESCRIPTOR IoDescriptor;
26 PULONG BarArray;
27 ULONG Bar, BarMask, i;
28
29 /* Get variables from context */
30 PciData = Context->Current;
31 Resources = Context->PdoExtension->Resources;
32
33 /* Loop all the PCI BARs */
34 BarArray = PciData->u.type0.BaseAddresses;
35 for (i = 0; i <= PCI_TYPE0_ADDRESSES; i++)
36 {
37 /* Get the resource descriptor and limit descriptor for this BAR */
38 CmDescriptor = &Resources->Current[i];
39 IoDescriptor = &Resources->Limit[i];
40
41 /* Build the resource descriptor based on the limit descriptor */
42 CmDescriptor->Type = IoDescriptor->Type;
43 if (CmDescriptor->Type == CmResourceTypeNull) continue;
44 CmDescriptor->Flags = IoDescriptor->Flags;
45 CmDescriptor->ShareDisposition = IoDescriptor->ShareDisposition;
46 CmDescriptor->u.Generic.Start.HighPart = 0;
47 CmDescriptor->u.Generic.Length = IoDescriptor->u.Generic.Length;
48
49 /* Check if we're handling PCI BARs, or the ROM BAR */
51 {
52 /* Read the actual BAR value */
53 Bar = BarArray[i];
54
55 /* Check if this is an I/O BAR */
57 {
58 /* Use the right mask to get the I/O port base address */
59 ASSERT(CmDescriptor->Type == CmResourceTypePort);
61 }
62 else
63 {
64 /* It's a RAM BAR, use the right mask to get the base address */
65 ASSERT((CmDescriptor->Type == CmResourceTypeMemory) ||
66 (CmDescriptor->Type == CmResourceTypeMemoryLarge));
68
69 /* Check if it's a 64-bit BAR, the last BAR has no register for a high half */
71 ((i + 1) < PCI_TYPE0_ADDRESSES))
72 {
73 /* The next BAR value is actually the high 32-bits */
74 CmDescriptor->u.Memory.Start.HighPart = BarArray[i + 1];
75 }
77 {
78 /* Legacy BAR, don't read more than 20 bits of the address */
79 BarMask = 0xFFFF0;
80 }
81 }
82 }
83 else
84 {
85 /* Actually a ROM BAR, so read the correct register */
86 Bar = PciData->u.type0.ROMBaseAddress;
87
88 /* Apply the correct mask for ROM BARs */
90
91 /* Make sure it's enabled */
93 {
94 /* If it isn't, then a descriptor won't be built for it */
95 CmDescriptor->Type = CmResourceTypeNull;
96 continue;
97 }
98 }
99
100 /* Now we have the right mask, read the actual address from the BAR */
101 Bar &= BarMask;
102 CmDescriptor->u.Memory.Start.LowPart = Bar;
103
104 /* And check for invalid BAR addresses */
105 if (!(CmDescriptor->u.Memory.Start.HighPart | Bar))
106 {
107 /* Skip these descriptors */
108 CmDescriptor->Type = CmResourceTypeNull;
109 DPRINT1("PCIX - Invalid BAR\n");
110 }
111 }
112
113 /* Also save the sub-IDs that came directly from the PCI header */
114 Context->PdoExtension->SubsystemVendorId = PciData->u.type0.SubVendorID;
115 Context->PdoExtension->SubsystemId = PciData->u.type0.SubSystemID;
116}
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@499 Memory
struct _IO_RESOURCE_DESCRIPTOR::@2498::@2503 Generic
union _IO_RESOURCE_DESCRIPTOR::@2498 u

◆ Device_SaveLimits()

VOID NTAPI Device_SaveLimits ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 120 of file device.c.

121{
122 PPCI_COMMON_HEADER Current, PciData;
124 PULONG BarArray;
126 ULONG i;
127
128 /* Get pointers from the context */
129 PdoExtension = Context->PdoExtension;
130 Current = Context->Current;
131 PciData = Context->PciData;
132
133 /* And get the array of bARs */
134 BarArray = PciData->u.type0.BaseAddresses;
135
136 /* First, check for IDE controllers that are not in native mode */
137 if ((PdoExtension->BaseClass == PCI_CLASS_MASS_STORAGE_CTLR) &&
139 (PdoExtension->ProgIf & 5) != 5)
140 {
141 /* They should not be using any non-legacy resources */
142 BarArray[0] = 0;
143 BarArray[1] = 0;
144 BarArray[2] = 0;
145 BarArray[3] = 0;
146 }
147 else if ((PdoExtension->VendorId == 0x5333) &&
148 ((PdoExtension->DeviceId == 0x88F0) ||
149 (PdoExtension->DeviceId == 0x8880)))
150 {
151 /*
152 * The problem is caused by the S3 Vision 968/868 video controller which
153 * is used on the Diamond Stealth 64 Video 3000 series, Number Nine 9FX
154 * motion 771, and other popular video cards, all containing a memory bug.
155 * The 968/868 claims to require 32 MB of memory, but it actually decodes
156 * 64 MB of memory.
157 */
158 for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
159 {
160 /* Find its 32MB RAM BAR */
161 if (BarArray[i] == 0xFE000000)
162 {
163 /* Increase it to 64MB to make sure nobody touches the buffer */
164 BarArray[i] = 0xFC000000;
165 DPRINT1("PCIX - Adjusted broken S3 requirement from 32MB to 64MB\n");
166 }
167 }
168 }
169
170 /* Check for Cirrus Logic GD5430/5440 cards */
171 if ((PdoExtension->VendorId == 0x1013) && (PdoExtension->DeviceId == 0xA0))
172 {
173 /* Check for the I/O port requirement */
174 if (BarArray[1] == 0xFC01)
175 {
176 /* Check for completely bogus BAR */
177 if (Current->u.type0.BaseAddresses[1] == 1)
178 {
179 /* Ignore it */
180 BarArray[1] = 0;
181 DPRINT1("PCIX - Ignored Cirrus GD54xx broken IO requirement (400 ports)\n");
182 }
183 else
184 {
185 /* Otherwise, this BAR seems okay */
186 DPRINT1("PCIX - Cirrus GD54xx 400 port IO requirement has a valid setting (%08x)\n",
187 Current->u.type0.BaseAddresses[1]);
188 }
189 }
190 else if (BarArray[1])
191 {
192 /* Strange, the I/O BAR was not found as expected (or at all) */
193 DPRINT1("PCIX - Warning Cirrus Adapter 101300a0 has unexpected resource requirement (%08x)\n",
194 BarArray[1]);
195 }
196 }
197
198 /* Finally, process all the limit descriptors */
199 Limit = PdoExtension->Resources->Limit;
200 for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
201 {
202 /* And build them based on the BARs, the last one has no BAR after it for a high half */
203 ULONG NextBar = ((i + 1) < PCI_TYPE0_ADDRESSES) ? BarArray[i + 1] : 0;
204
205 if (!PciCreateIoDescriptorFromBarLimit(&Limit[i], BarArray[i], NextBar, FALSE))
206 continue;
207
208 /* A 64-bit BAR in the last slot has nowhere to put its high half, so it stays below 4GB */
209 if ((i + 1) == PCI_TYPE0_ADDRESSES)
210 {
211 DPRINT1("PCIX - 64-bit BAR %lu has no upper register, decoding it as 32-bit\n", i);
212 continue;
213 }
214
215 /* The high half of a 64-bit BAR is not a BAR of its own */
216 i++;
217 Limit[i].Type = CmResourceTypeNull;
218 }
219
220 /* Create the last descriptor based on the ROM address */
221 PciCreateIoDescriptorFromBarLimit(&Limit[i], PciData->u.type0.ROMBaseAddress, 0, TRUE);
222
223 /* A ROM the firmware left disabled is not given a window */
224 if (!(Current->u.type0.ROMBaseAddress & PCI_ROMADDRESS_ENABLED))
225 Limit[i].Type = CmResourceTypeNull;
226}

◆ devpresent_Constructor()

NTSTATUS NTAPI devpresent_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 270 of file devhere.c.

276{
278 BOOLEAN HasEx;
279 PAGED_CODE();
280
282 UNREFERENCED_PARAMETER(InterfaceData);
284
285 /* Callers built before IsDevicePresentEx existed pass the shorter size */
286 HasEx = (Size >= sizeof(*PresentInterface));
287
289 if (HasEx)
291
292 PresentInterface->InterfaceReference = devpresent_Reference;
294 PresentInterface->Context = DeviceExtension;
296 PresentInterface->Size = (USHORT)(HasEx ? sizeof(*PresentInterface) :
297 FIELD_OFFSET(PCI_DEVICE_PRESENT_INTERFACE, IsDevicePresentEx));
298
299 return STATUS_SUCCESS;
300}
static BOOLEAN NTAPI devpresent_IsDevicePresent(_In_ USHORT VendorID, _In_ USHORT DeviceID, _In_ UCHAR RevisionID, _In_ USHORT SubVendorID, _In_ USHORT SubSystemID, _In_ ULONG Flags)
Definition: devhere.c:182
static VOID NTAPI devpresent_Dereference(_In_ PVOID Context)
Definition: devhere.c:57
static BOOLEAN NTAPI devpresent_IsDevicePresentEx(_In_ PVOID Context, _In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
Definition: devhere.c:232
static VOID NTAPI devpresent_Reference(_In_ PVOID Context)
Definition: devhere.c:46
PINTERFACE_REFERENCE InterfaceReference
Definition: iotypes.h:923
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: iotypes.h:924
PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx
Definition: iotypes.h:926
PPCI_IS_DEVICE_PRESENT IsDevicePresent
Definition: iotypes.h:925
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define PCI_DEVICE_PRESENT_INTERFACE_VERSION
Definition: iotypes.h:863
struct _PCI_DEVICE_PRESENT_INTERFACE * PPCI_DEVICE_PRESENT_INTERFACE

◆ devpresent_Initializer()

NTSTATUS NTAPI devpresent_Initializer ( IN PVOID  Instance)

Definition at line 35 of file devhere.c.

36{
38 /* PnP Interfaces don't get Initialized */
39 ASSERTMSG("PCI devpresent_Initializer, unexpected call.\n", FALSE);
41}

◆ lddintrf_Constructor()

NTSTATUS NTAPI lddintrf_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 45 of file lddintrf.c.

51{
52 UNREFERENCED_PARAMETER(DeviceExtension);
54 UNREFERENCED_PARAMETER(InterfaceData);
58
59 /* Not provided, so the query fails and the caller goes without it */
61}

◆ lddintrf_Initializer()

NTSTATUS NTAPI lddintrf_Initializer ( IN PVOID  Instance)

Definition at line 35 of file lddintrf.c.

36{
38 /* PnP Interfaces don't get Initialized */
39 ASSERTMSG("PCI lddintrf_Initializer, unexpected call.\n", FALSE);
41}

◆ locintrf_Constructor()

NTSTATUS NTAPI locintrf_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 116 of file locintrf.c.

122{
124 PAGED_CODE();
125
127 UNREFERENCED_PARAMETER(InterfaceData);
130
131 LocationInterface->Size = sizeof(*LocationInterface);
132 LocationInterface->Version = PNP_LOCATION_INTERFACE_VERSION;
133 LocationInterface->Context = DeviceExtension;
134 LocationInterface->InterfaceReference = locintrf_Reference;
135 LocationInterface->InterfaceDereference = locintrf_Dereference;
137 return STATUS_SUCCESS;
138}
static VOID NTAPI locintrf_Dereference(_In_ PVOID Context)
Definition: locintrf.c:56
static NTSTATUS NTAPI locintrf_GetLocationString(_In_ PVOID Context, _Outptr_ PZZWSTR *LocationStrings)
Returns "PCI(DDFF)" for a device or "PCIROOT(B)" for a root bus as a multi-sz. The caller frees the b...
Definition: locintrf.c:69
static VOID NTAPI locintrf_Reference(_In_ PVOID Context)
Definition: locintrf.c:46
PGET_LOCATION_STRING GetLocationString
Definition: iotypes.h:4559
PINTERFACE_REFERENCE InterfaceReference
Definition: iotypes.h:4557
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: iotypes.h:4558
struct _PNP_LOCATION_INTERFACE * PPNP_LOCATION_INTERFACE
#define PNP_LOCATION_INTERFACE_VERSION
Definition: iotypes.h:5536

◆ locintrf_Initializer()

NTSTATUS NTAPI locintrf_Initializer ( IN PVOID  Instance)

Definition at line 35 of file locintrf.c.

36{
38 /* PnP Interfaces don't get Initialized */
39 ASSERTMSG("PCI locintrf_Initializer, unexpected call.\n", FALSE);
41}

◆ PciAddDevice()

NTSTATUS NTAPI PciAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 707 of file fdo.c.

709{
711 PDEVICE_OBJECT AttachedTo;
713 PPCI_FDO_EXTENSION ParentExtension;
722 PAGED_CODE();
723 DPRINT1("PCIX - AddDevice (a new bus). PDO: %p (Driver: %wZ)\n",
724 PhysicalDeviceObject, &PhysicalDeviceObject->DriverObject->DriverName);
725
726 /* Zero out variables so failure path knows what to do */
727 AttachedTo = NULL;
731
732 do
733 {
734 /* Check if there's already a device extension for this bus */
737 if (ParentExtension)
738 {
739 /* Make sure we find a real PDO */
742
743 /* Make sure it's a PCI-to-PCI bridge */
744 if ((PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) ||
746 {
747 /* This should never happen */
748 DPRINT1("PCIX - PciAddDevice for Non-Root/Non-PCI-PCI bridge,\n"
749 " Class %02x, SubClass %02x, will not add.\n",
750 PdoExtension->BaseClass,
751 PdoExtension->SubClass);
752 ASSERT((PdoExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
754
755 /* Enter the failure path */
757 break;
758 }
759
760 /* Subordinate bus on the bridge */
761 DPRINT1("PCIX - AddDevice (new bus is child of bus 0x%x).\n",
762 ParentExtension->BaseBus);
763
764 /* Make sure PCI bus numbers are configured */
766 {
767 /* This is a critical failure */
768 DPRINT1("PCIX - Bus numbers not configured for bridge (0x%x.0x%x.0x%x)\n",
769 ParentExtension->BaseBus,
770 PdoExtension->Slot.u.bits.DeviceNumber,
771 PdoExtension->Slot.u.bits.FunctionNumber);
772
773 /* Enter the failure path */
775 break;
776 }
777 }
778
779 /* Create the FDO for the bus */
781 sizeof(PCI_FDO_EXTENSION),
782 NULL,
784 0,
785 0,
786 &DeviceObject);
787 if (!NT_SUCCESS(Status)) break;
788
789 /* Initialize the extension for the FDO */
790 FdoExtension = DeviceObject->DeviceExtension;
794
795 /* Attach to the root PDO */
799 ASSERT(AttachedTo != NULL);
800 if (!AttachedTo) break;
801 FdoExtension->AttachedDeviceObject = AttachedTo;
802
803 /* Check if this is a child bus, or the root */
804 if (ParentExtension)
805 {
806 /* The child inherits root data */
807 FdoExtension->BaseBus = PdoExtension->Dependent.type1.SecondaryBus;
808 FdoExtension->BusRootFdoExtension = ParentExtension->BusRootFdoExtension;
809 PdoExtension->BridgeFdoExtension = FdoExtension;
810 FdoExtension->ParentFdoExtension = ParentExtension;
811 }
812 else
813 {
814 /* Query the boot configuration */
817 (PVOID*)&Descriptor);
818 if (!NT_SUCCESS(Status))
819 {
820 /* No configuration has been set */
822 }
823
824 /* The firmware reports the bus numbers this root decodes in its boot config */
825 if (Descriptor &&
827 &FdoExtension->BaseBus,
828 &FdoExtension->MaxSubordinateBus))
829 {
830 DPRINT1("PCIX - Root bus range 0x%x to 0x%x.\n",
831 FdoExtension->BaseBus,
832 FdoExtension->MaxSubordinateBus);
833 }
834 else
835 {
836 /* Default configuration isn't the normal path on Windows */
838 {
839 /* If a second bus is found and there's still no data, crash */
840 KeBugCheckEx(PCI_BUS_DRIVER_INTERNAL,
841 0xDEAD0010u,
843 0,
844 0);
845 }
846
847 /* Warn that a default configuration will be used, and set bus 0 */
848 DPRINT1("PCIX - Will use default configuration.\n");
850 FdoExtension->BaseBus = 0;
851 FdoExtension->MaxSubordinateBus = 0xFF;
852 }
853
854 if (Descriptor)
856
857 /* This is the root bus */
858 FdoExtension->BusRootFdoExtension = FdoExtension;
859 }
860
861 /* Get the HAL or ACPI Bus Handler Callbacks for Configuration Access */
863 if (!NT_SUCCESS(Status)) break;
864
865 /* Map this bus for extended configuration space access */
867
868 /* Initialize all the supported PCI arbiters */
870 if (!NT_SUCCESS(Status)) break;
871
872 /* This is a real FDO, insert it into the list */
873 FdoExtension->Fake = FALSE;
877
878 /* Open the device registry key so that we can query the errata flags */
882 &KeyHandle),
883
884 /* Open the value that contains errata flags for this bus instance */
885 RtlInitUnicodeString(&ValueName, L"HackFlags");
886 Status = ZwQueryValueKey(KeyHandle,
887 &ValueName,
889 ValueInfo,
890 sizeof(Buffer),
891 &ResultLength);
893 if (NT_SUCCESS(Status))
894 {
895 /* Make sure the data is of expected type and size */
896 if ((ValueInfo->Type == REG_DWORD) &&
897 (ValueInfo->DataLength == sizeof(ULONG)))
898 {
899 /* Read the flags for this bus */
900 FdoExtension->BusHackFlags = *(PULONG)&ValueInfo->Data;
901 }
902 }
903
904 /* Query ACPI for PCI HotPlug Support */
906
907 /* The Bus FDO is now initialized */
908 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
909 return STATUS_SUCCESS;
910 } while (FALSE);
911
912 /* This is the failure path */
914
915 /* Check if the FDO extension exists */
916 if (FdoExtension) DPRINT1("PCIX - Should destroy secondaries\n");
917
918 /* Delete device objects */
919 if (AttachedTo) IoDetachDevice(AttachedTo);
921 return Status;
922}
NTSTATUS NTAPI PciInitializeArbiters(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: arb_comn.c:242
DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx(IN ULONG BugCheckCode, IN ULONG_PTR BugCheckParameter1, IN ULONG_PTR BugCheckParameter2, IN ULONG_PTR BugCheckParameter3, IN ULONG_PTR BugCheckParameter4)
Definition: debug.c:485
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
static BOOLEAN NTAPI PciGetRootBusRange(_In_ PCM_RESOURCE_LIST BootConfig, _Out_ PUCHAR FirstBus, _Out_ PUCHAR LastBus)
Finds the bus number range a root bus decodes in its boot configuration.
Definition: fdo.c:82
VOID NTAPI PciInitializeFdoExtensionCommonFields(PPCI_FDO_EXTENSION FdoExtension, IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: fdo.c:682
BOOLEAN PciBreakOnDefault
Definition: fdo.c:19
SINGLE_LIST_ENTRY PciFdoExtensionListHead
Definition: fdo.c:18
VOID NTAPI PciGetHotPlugParameters(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: fdo.c:593
Definition: bufpool.h:45
KEVENT PciGlobalLock
Definition: init.c:20
VOID NTAPI PciInsertEntryAtTail(IN PSINGLE_LIST_ENTRY ListHead, IN PPCI_FDO_EXTENSION DeviceExtension, IN PKEVENT Lock)
Definition: utils.c:400
BOOLEAN NTAPI PciAreBusNumbersConfigured(IN PPCI_PDO_EXTENSION PdoExtension)
Definition: busno.c:20
VOID NTAPI PciInitializeEcam(_In_ PPCI_FDO_EXTENSION FdoExtension)
Maps the bus an FDO decodes into the ECAM window and verifies the window the first time a bus with de...
Definition: ecam.c:336
PPCI_FDO_EXTENSION NTAPI PciFindParentPciFdoExtension(IN PDEVICE_OBJECT DeviceObject, IN PKEVENT Lock)
Definition: utils.c:340
NTSTATUS NTAPI PciGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, OUT PVOID *OutputBuffer)
Definition: utils.c:475
#define ASSERT_PDO(x)
Definition: pci.h:48
NTSTATUS NTAPI PciGetConfigHandlers(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: config.c:266
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValuePartialInformation
Definition: nt_native.h:1185
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:973
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1038
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1306
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1261
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:1621
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:87
#define REG_DWORD
Definition: sdbapi.c:615
PVOID DeviceExtension
Definition: env_spec_w32.h:418
BOOLEAN BaseBus
Definition: pci.h:260
struct _PCI_FDO_EXTENSION * BusRootFdoExtension
Definition: pci.h:254
unsigned char UCHAR
Definition: typedefs.h:53
_In_ PGUID _In_ ULONG _Out_ PULONG ResultLength
Definition: ucxcontroller.h:83
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2793
@ DevicePropertyBootConfiguration
Definition: iotypes.h:1198

◆ PciAddResizableBarRequirements()

ULONG NTAPI PciAddResizableBarRequirements ( _In_ PPCI_PDO_EXTENSION  PdoExtension,
_In_ ULONG  BarIndex,
_In_ PIO_RESOURCE_DESCRIPTOR  Limit,
_Out_writes_opt_(2) PIO_RESOURCE_DESCRIPTOR  Descriptors 
)

Writes the requirements for the sizes a resizable BAR can grow to. They go ahead of the default requirement, which the caller then lists as the alternative. The largest size is preferred, and the smallest supported size follows it when that is also bigger than the default.

Parameters
[in]PdoExtensionThe PDO extension of the function.
[in]BarIndexThe BAR the default requirement describes.
[in]LimitThe default requirement of the BAR.
[out]DescriptorsReceives up to two descriptors, or NULL to only count them.
Returns
The number of descriptors written, which is 0 when the BAR cannot grow.

Definition at line 142 of file rbar.c.

147{
148 IO_RESOURCE_DESCRIPTOR Resized[2];
149 ULONGLONG Largest, Smallest;
150 ULONG SizeMask, Count;
151 PAGED_CODE();
152
153 /* Only a memory BAR asking for less than 4GB is offered other sizes */
154 if ((BarIndex >= PCI_RBAR_MAX_ENTRIES) || (Limit->Type != CmResourceTypeMemory))
155 return 0;
156
157 SizeMask = PdoExtension->ResizableBarState.SizeMask[BarIndex];
158 if (!SizeMask)
159 return 0;
160
161 /* Built even when only counting, so a size that cannot be described is never counted */
163 if ((Largest <= Limit->u.Memory.Length) ||
165 {
166 return 0;
167 }
168 Count = 1;
169
171 if ((Smallest > Limit->u.Memory.Length) &&
172 (Smallest < Largest) &&
174 {
175 Count++;
176 }
177
178 if (Descriptors)
179 RtlCopyMemory(Descriptors, Resized, Count * sizeof(IO_RESOURCE_DESCRIPTOR));
180
181 return Count;
182}
#define PCI_RBAR_MAX_ENTRIES
Definition: pci.h:98
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 * u
Definition: glfuncs.h:240
int Count
Definition: noreturn.cpp:7
static BOOLEAN NTAPI PciFillResizedBarRequirement(_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PIO_RESOURCE_DESCRIPTOR Limit, _In_ ULONGLONG Length, _In_ UCHAR Option)
Definition: rbar.c:97
#define PCI_RBAR_SIZE_TO_LENGTH(Bit)
Definition: rbar.c:17
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
NTSYSAPI CCHAR WINAPI RtlFindMostSignificantBit(ULONGLONG)
Definition: bitmap.c:211
NTSYSAPI CCHAR WINAPI RtlFindLeastSignificantBit(ULONGLONG)
Definition: bitmap.c:235
#define IO_RESOURCE_ALTERNATIVE
#define IO_RESOURCE_PREFERRED

Referenced by PciBuildRequirementsList().

◆ PciApplyResizableBarSizes()

VOID NTAPI PciApplyResizableBarSizes ( _In_ PPCI_PDO_EXTENSION  PdoExtension)

Sets every resizable BAR to the length it was assigned. The memory decode has to be off, since the size field changes what the BAR decodes. Critical devices call this from the IPI that updates their hardware.

Parameters
[in]PdoExtensionThe PDO extension of the function whose resources are being set.

Definition at line 229 of file rbar.c.

231{
234 ULONG BarIndex;
235
236 if (!PdoExtension->ResizableBarState.CapabilityPtr || !PdoExtension->Resources)
237 return;
238
239 /* A function whose decodes could not be turned off keeps the sizes it has */
241 &Command,
243 sizeof(Command));
245 {
246 DPRINT("PCIX - Memory decode of %p is still on, not resizing BARs\n", PdoExtension);
247 return;
248 }
249
250 for (BarIndex = 0; BarIndex < PCI_RBAR_MAX_ENTRIES; BarIndex++)
251 {
252 if (!PdoExtension->ResizableBarState.SizeMask[BarIndex])
253 continue;
254
255 Current = &PdoExtension->Resources->Current[BarIndex];
256 if ((Current->Type != CmResourceTypeMemory) &&
257 (Current->Type != CmResourceTypeMemoryLarge))
258 {
259 continue;
260 }
261
263 BarIndex,
265 }
266}
VOID NTAPI PciReadDeviceConfig(IN PPCI_PDO_EXTENSION DeviceExtension, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: config.c:149
static VOID NTAPI PciSelectResizableBarSize(_In_ PPCI_PDO_EXTENSION PdoExtension, _In_ ULONG BarIndex, _In_ ULONGLONG Length)
Definition: rbar.c:187
#define DPRINT
Definition: sndvol32.h:73
Definition: shell.h:41

Referenced by PcipUpdateHardware().

◆ PciArbiter_Dereference()

VOID NTAPI PciArbiter_Dereference ( _In_ PVOID  Context)

Definition at line 191 of file arb_comn.c.

192{
194
196}
struct _ARBITER_INSTANCE * PARBITER_INSTANCE
Definition: arbiter.h:110
#define InterlockedDecrement
Definition: armddk.h:52
ULONG ReferenceCount
Definition: arbiter.h:306
int32_t * PLONG
Definition: typedefs.h:58

Referenced by PciArbiterConstructor().

◆ PciArbiter_FindSuitableRange()

BOOLEAN NTAPI PciArbiter_FindSuitableRange ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  State 
)

Searches for a placement, remembering on the range whether it came from a fixed alternative.

Parameters
[in]ArbiterThe arbiter instance placing the entry.
[in,out]StateThe allocation state of the entry.
Returns
TRUE if a placement was found, FALSE otherwise.

Definition at line 97 of file arb_comn.c.

100{
101 PAGED_CODE();
102
103 State->RangeAttributes &= (UCHAR)~PCI_RANGE_FIXED_PLACEMENT;
104 if (State->CurrentAlternative &&
105 (State->CurrentAlternative->Flags & ARBITER_ALTERNATIVE_FLAG_FIXED))
106 {
107 State->RangeAttributes |= PCI_RANGE_FIXED_PLACEMENT;
108 }
109
110 return ArbiterLibFindSuitableRange(Arbiter, State);
111}
#define PCI_RANGE_FIXED_PLACEMENT
Definition: arb_comn.c:19
BOOLEAN NTAPI ArbiterLibFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Finds a free range of the current candidate window in the arbiter's tentative allocation list.
Definition: range.c:717
#define ARBITER_ALTERNATIVE_FLAG_FIXED
Definition: arbiter.h:32

Referenced by ario_Initializer(), and armem_Initializer().

◆ PciArbiter_OverrideConflict()

BOOLEAN NTAPI PciArbiter_OverrideConflict ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  State 
)

Lets a fixed requirement overlap ranges its own device was given by other fixed requirements.

Parameters
[in]ArbiterThe arbiter instance placing the entry.
[in,out]StateThe allocation state of the entry. On success Start and End receive the requested window.
Returns
TRUE if every conflicting range is a fixed placement of the same device, FALSE otherwise.
Remarks
A resized BAR that landed on top of another BAR's firmware address is a movable placement, so the fixed BAR fails and the resized one has to back off to another alternative.

Definition at line 136 of file arb_comn.c.

139{
141 PRTL_RANGE Range;
142 BOOLEAN Overridden = FALSE;
143
144 PAGED_CODE();
145
146 if (!State->Entry ||
147 !State->CurrentAlternative ||
148 !(State->CurrentAlternative->Flags & ARBITER_ALTERNATIVE_FLAG_FIXED))
149 {
150 return FALSE;
151 }
152
153 if (!NT_SUCCESS(RtlGetFirstRange(Arbiter->PossibleAllocation, &Iterator, &Range)))
154 return FALSE;
155
156 while (Range)
157 {
158 if ((Range->Start <= State->CurrentMaximum) &&
159 (Range->End >= State->CurrentMinimum) &&
160 !(Range->Attributes & State->RangeAvailableAttributes))
161 {
162 if ((Range->Owner != State->Entry->PhysicalDeviceObject) ||
164 {
165 return FALSE;
166 }
167
168 Overridden = TRUE;
169 State->Start = State->CurrentMinimum;
170 State->End = State->CurrentMaximum;
171 }
172
173 if (!NT_SUCCESS(RtlGetNextRange(&Iterator, &Range, TRUE)))
174 break;
175 }
176
177 return Overridden;
178}
NTSYSAPI NTSTATUS NTAPI RtlGetNextRange(_Inout_ PRTL_RANGE_LIST_ITERATOR Iterator, _Outptr_ PRTL_RANGE *Range, _In_ BOOLEAN MoveForwards)
NTSYSAPI NTSTATUS NTAPI RtlGetFirstRange(_In_ PRTL_RANGE_LIST RangeList, _Out_ PRTL_RANGE_LIST_ITERATOR Iterator, _Outptr_ PRTL_RANGE *Range)
ULONGLONG End
Definition: rtltypes.h:1517
ULONGLONG Start
Definition: rtltypes.h:1516
UCHAR Attributes
Definition: rtltypes.h:1520
PVOID Owner
Definition: rtltypes.h:1519
_In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR Iterator
Definition: wdfchildlist.h:656

Referenced by ario_Initializer(), and armem_Initializer().

◆ PciArbiter_PreprocessEntry()

NTSTATUS NTAPI PciArbiter_PreprocessEntry ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  State 
)

Sets the range attributes of one arbitration entry before the engine looks for a placement for it.

Parameters
[in]ArbiterThe arbiter instance placing the entry.
[in,out]StateThe allocation state of the entry.
Returns
STATUS_SUCCESS.
Remarks
Boot configs and legacy claims treat boot reservations as free. Positive decode ports ignore ISA alias ranges.

Definition at line 51 of file arb_comn.c.

54{
56
58
59 PAGED_CODE();
60
61 if (!State->Entry)
62 return STATUS_SUCCESS;
63
64 if ((State->Entry->Flags & ARBITER_FLAG_BOOT_CONFIG) ||
65 (State->Entry->RequestSource == ArbiterRequestLegacyReported) ||
66 (State->Entry->RequestSource == ArbiterRequestLegacyAssigned))
67 {
68 State->RangeAvailableAttributes |= ARBITER_RANGE_BOOT_ALLOCATED;
69 }
70
71 /* CurrentAlternative is not set yet, use the first alternative */
72 Descriptor = State->Alternatives ? State->Alternatives->Descriptor : NULL;
73 if (Descriptor &&
74 (Descriptor->Type == CmResourceTypePort) &&
76 State->RangeAvailableAttributes |= ARBITER_RANGE_PORT_ALIAS;
77
78 return STATUS_SUCCESS;
79}
#define ARBITER_RANGE_PORT_ALIAS
Definition: arbiter.h:55
#define ARBITER_RANGE_BOOT_ALLOCATED
Definition: arbiter.h:53
#define CM_RESOURCE_PORT_POSITIVE_DECODE
Definition: cmtypes.h:113
@ ArbiterRequestLegacyAssigned
Definition: iotypes.h:4632
@ ArbiterRequestLegacyReported
Definition: iotypes.h:4630
#define ARBITER_FLAG_BOOT_CONFIG
Definition: iotypes.h:4644

Referenced by arbusno_Initializer(), ario_Initializer(), and armem_Initializer().

◆ PciArbiter_Reference()

VOID NTAPI PciArbiter_Reference ( _In_ PVOID  Context)

Definition at line 182 of file arb_comn.c.

183{
185
187}
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by PciArbiterConstructor().

◆ PciArbiterConstructor()

NTSTATUS NTAPI PciArbiterConstructor ( _In_ PPCI_FDO_EXTENSION  FdoExtension,
_In_ PCI_SIGNATURE  ArbiterType,
_Out_ PARBITER_INTERFACE  Interface 
)

Definition at line 200 of file arb_comn.c.

203{
204 PPCI_ARBITER_INSTANCE Arbiter;
205 PAGED_CODE();
206
207 if (!FdoExtension->ArbitersInitialized) return STATUS_NOT_SUPPORTED;
208
209 /* Find the instance this bus built for the requested resource type */
211 SecondaryExtension.Next,
212 ArbiterType);
213 if (!Arbiter)
214 {
215 DPRINT1("PCIX - FDO ext 0x%p has no %s arbiter to hand out.\n",
217 PciArbiterNames[ArbiterType - PciArb_Io]);
219 }
220
221 Interface->Size = sizeof(ARBITER_INTERFACE);
223 Interface->Context = &Arbiter->CommonInstance;
224 Interface->InterfaceReference = PciArbiter_Reference;
225 Interface->InterfaceDereference = PciArbiter_Dereference;
226 Interface->ArbiterHandler = ArbiterLibHandler;
227 Interface->Flags = 0;
228 return STATUS_SUCCESS;
229}
VOID NTAPI PciArbiter_Reference(_In_ PVOID Context)
Definition: arb_comn.c:182
PCHAR PciArbiterNames[]
Definition: arb_comn.c:21
VOID NTAPI PciArbiter_Dereference(_In_ PVOID Context)
Definition: arb_comn.c:191
NTSTATUS NTAPI ArbiterLibHandler(_In_ PVOID Context, _In_ ARBITER_ACTION Action, _Inout_ PARBITER_PARAMETERS Parameters)
The single ARBITER_ACTION dispatcher every exported ARBITER_INTERFACE points its ArbiterHandler at; C...
Definition: handler.c:164
#define ARBITER_INTERFACE_VERSION
Definition: pci.h:111
struct _ARBITER_INTERFACE ARBITER_INTERFACE

Referenced by arbusno_Constructor(), ario_Constructor(), and armem_Constructor().

◆ PciAreBusNumbersConfigured()

BOOLEAN NTAPI PciAreBusNumbersConfigured ( IN PPCI_PDO_EXTENSION  PdoExtension)

Definition at line 20 of file busno.c.

21{
22 UCHAR PrimaryBus, BaseBus, SecondaryBus, SubordinateBus;
23
24 PAGED_CODE();
25
26 /* Get all relevant bus number details */
27 PrimaryBus = PdoExtension->Dependent.type1.PrimaryBus;
28 BaseBus = PdoExtension->ParentFdoExtension->BaseBus;
29 SecondaryBus = PdoExtension->Dependent.type1.SecondaryBus;
30 SubordinateBus = PdoExtension->Dependent.type1.SubordinateBus;
31
32 /* The primary bus should be the base bus of the parent */
33 if ((PrimaryBus != BaseBus) || (SecondaryBus <= PrimaryBus)) return FALSE;
34
35 /* The subordinate should be a higher bus number than the secondary */
36 return SubordinateBus >= SecondaryBus;
37}

Referenced by PciAddDevice(), and PciProcessBus().

◆ PciBeginStateTransition()

NTSTATUS NTAPI PciBeginStateTransition ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCI_STATE  NewState 
)

Definition at line 97 of file state.c.

99{
102 DPRINT1("PCIX - Request to begin transition of Extension %p to %s ->",
103 DeviceExtension,
104 PciTransitionText[NewState]);
105
106 /* Assert the device isn't already in a pending transition */
107 ASSERT(DeviceExtension->TentativeNextState == DeviceExtension->DeviceState);
108
109 /* Assert this is a valid state */
110 CurrentState = DeviceExtension->DeviceState;
112 ASSERT(NewState < PciMaxObjectState);
113
114 /* Lookup if this state transition is valid */
117 {
118 /* Invalid transition (logical fault) */
119 DPRINT1("ERROR\nPCIX - Error trying to enter state \"%s\" "
120 "from state \"%s\"\n",
121 PciTransitionText[NewState],
124 }
126 {
127 /* Invalid transition (illegal request) */
128 DPRINT1("ERROR\nPCIX - Illegal request to try to enter state \"%s\" "
129 "from state \"%s\", rejecting",
130 PciTransitionText[NewState],
132 }
133
134 /* New state must be different from current, unless request is at fault */
135 ASSERT((NewState != DeviceExtension->DeviceState) || (!NT_SUCCESS(Status)));
136
137 /* Enter the new state if successful, and return state status */
138 if (NT_SUCCESS(Status)) DeviceExtension->TentativeNextState = NewState;
139 DbgPrint("%x\n", Status);
140 return Status;
141}
PCHAR PciTransitionText[PciMaxObjectState+1]
Definition: state.c:18
NTSTATUS PnpStateTransitionArray[PciMaxObjectState *PciMaxObjectState]
Definition: state.c:39
#define DbgPrint
Definition: hal.h:12
#define STATUS_FAIL_CHECK
Definition: ntstatus.h:807
NTSYSAPI void WINAPI DbgBreakPoint(void)
_Out_opt_ PBOOLEAN CurrentState
Definition: zwfuncs.h:393

Referenced by PciFdoIrpQueryRemoveDevice(), PciFdoIrpQueryStopDevice(), PciFdoIrpRemoveDevice(), PciFdoIrpStartDevice(), PciFdoIrpSurpriseRemoval(), PciPdoIrpQueryRemoveDevice(), PciPdoIrpQueryStopDevice(), PciPdoIrpRemoveDevice(), PciPdoIrpStartDevice(), PciPdoIrpSurpriseRemoval(), and PciQueryDeviceRelations().

◆ PciBuildDefaultExclusionLists()

NTSTATUS NTAPI PciBuildDefaultExclusionLists ( VOID  )

Definition at line 276 of file utils.c.

277{
278 ULONG Start;
282
283 /* Initialize the range lists */
286
287 /* Loop x86 I/O ranges */
288 for (Start = 0x100; Start <= 0xFEFF; Start += 0x400)
289 {
290 /* Add the ISA I/O ranges */
292 Start,
293 Start + 0x2FF,
294 0,
296 NULL,
297 NULL);
298 if (!NT_SUCCESS(Status)) break;
299
300 /* Add the ISA I/O ranges */
302 Start,
303 Start + 0x2AF,
304 0,
306 NULL,
307 NULL);
308 if (!NT_SUCCESS(Status)) break;
309
310 /* Add the VGA I/O range for Monochrome Video */
312 Start + 0x2BC,
313 Start + 0x2BF,
314 0,
316 NULL,
317 NULL);
318 if (!NT_SUCCESS(Status)) break;
319
320 /* Add the VGA I/O range for certain CGA adapters */
322 Start + 0x2E0,
323 Start + 0x2FF,
324 0,
326 NULL,
327 NULL);
328 if (!NT_SUCCESS(Status)) break;
329
330 /* Success, ranges added done */
331 };
332
335 return Status;
336}
RTL_RANGE_LIST PciVgaAndIsaBitExclusionList
Definition: utils.c:22
RTL_RANGE_LIST PciIsaBitExclusionList
Definition: utils.c:21
NTSYSAPI NTSTATUS NTAPI RtlAddRange(_Inout_ PRTL_RANGE_LIST RangeList, _In_ ULONGLONG Start, _In_ ULONGLONG End, _In_ UCHAR Attributes, _In_ ULONG Flags, _In_opt_ PVOID UserData, _In_opt_ PVOID Owner)
NTSYSAPI VOID NTAPI RtlInitializeRangeList(_Out_ PRTL_RANGE_LIST RangeList)
NTSYSAPI VOID NTAPI RtlFreeRangeList(_In_ PRTL_RANGE_LIST RangeList)
#define RTL_RANGE_LIST_ADD_IF_CONFLICT
Definition: rtltypes.h:81

Referenced by DriverEntry().

◆ PciBuildRequirementsList()

NTSTATUS NTAPI PciBuildRequirementsList ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN PPCI_COMMON_HEADER  PciData,
OUT PIO_RESOURCE_REQUIREMENTS_LIST *  Buffer 
)

Definition at line 756 of file enum.c.

759{
763 ULONG Count, i;
764 BOOLEAN HaveInterrupt;
765
766 PAGED_CODE();
767
768 /* Count the BAR limits that resource discovery found for this function */
769 Count = 0;
770 if (PdoExtension->Resources)
771 {
772 for (i = 0; i < (PCI_TYPE0_ADDRESSES + 1); i++)
773 {
774 if (!PciIsRequirementDescriptor(&PdoExtension->Resources->Limit[i]))
775 continue;
776
777 /* A resizable BAR also asks for the larger sizes it can decode */
778 Count++;
780 i,
781 &PdoExtension->Resources->Limit[i],
782 NULL);
783
784 /* And a BAR that already decodes a range also asks to keep it */
786 }
787 }
788
789 /* A device with an interrupt pin also needs a line routed to it */
790 HaveInterrupt = (PdoExtension->InterruptPin) &&
792 if (HaveInterrupt)
793 Count++;
794
795 /* And a bridge with legacy decodes enabled needs those ranges locked down */
796 Count += PdoExtension->AdditionalResourceCount;
797
798 /* Check if the function turned out to need nothing after all */
799 if (!Count)
800 {
801 /* There aren't, so use the zero descriptor */
803
804 /* Does it actually exist yet? */
806 {
807 /* Allocate it, and use it for future use */
811 }
812
814 DPRINT1("PCIX - build resource reqs - early out, 0 resources\n");
815 return STATUS_SUCCESS;
816 }
817
819 PdoExtension->ParentFdoExtension->BaseBus,
820 PdoExtension->Slot.u.AsULONG);
821 if (!RequirementsList)
823
824 Descriptor = RequirementsList->List[0].Descriptors;
825
826 /* Emit the requirements of each BAR that decoded something during discovery */
827 if (PdoExtension->Resources)
828 {
829 Limit = PdoExtension->Resources->Limit;
830 for (i = 0; i < (PCI_TYPE0_ADDRESSES + 1); i++)
831 {
832 /* Skip unimplemented BARs and bridge windows, neither asks for a range */
834 continue;
835
836 /* Larger resizable sizes, then the current placement, then the default size */
840 PciData->Command,
841 i,
842 Descriptor);
843
844 /* A BAR decodes for one function only, so it cannot be shared */
845 *Descriptor = Limit[i];
846 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
847 Descriptor++;
848
849 /* The first choice for the BAR is preferred and every later one is its alternative */
850 First->Option |= IO_RESOURCE_PREFERRED;
851 for (Next = First + 1; Next < Descriptor; Next++)
852 Next->Option |= IO_RESOURCE_ALTERNATIVE;
853 }
854 }
855
856 if (HaveInterrupt)
857 {
859 Descriptor->ShareDisposition = CmResourceShareShared;
861 Descriptor->u.Interrupt.MinimumVector = 0;
862 Descriptor->u.Interrupt.MaximumVector = MAXULONG;
863 Descriptor++;
864 }
865
866 /* And finally any extra ranges this kind of function decodes on the side */
867 if (PdoExtension->AdditionalResourceCount)
868 {
869 RtlZeroMemory(&Context, sizeof(Context));
870 Context.PdoExtension = PdoExtension;
871 Context.Current = PciData;
872 PciConfigurators[PdoExtension->HeaderType].
873 GetAdditionalResourceDescriptors(&Context, PciData, Descriptor);
874 }
875
877 return STATUS_SUCCESS;
878}
WCHAR First[]
Definition: FormatMessage.c:11
static ULONG NTAPI PciAddCurrentPlacementRequirement(_In_ PPCI_PDO_EXTENSION PdoExtension, _In_ USHORT Command, _In_ ULONG BarIndex, _Out_opt_ PIO_RESOURCE_DESCRIPTOR Descriptor)
Writes a fixed requirement for the range a BAR is decoding now.
Definition: enum.c:702
PIO_RESOURCE_REQUIREMENTS_LIST PciZeroIoResourceRequirements
Definition: enum.c:18
PIO_RESOURCE_REQUIREMENTS_LIST NTAPI PciAllocateIoRequirementsList(IN ULONG Count, IN ULONG BusNumber, IN ULONG SlotNumber)
Definition: enum.c:326
PCI_CONFIGURATOR PciConfigurators[]
Definition: enum.c:20
ULONG NTAPI PciAddResizableBarRequirements(_In_ PPCI_PDO_EXTENSION PdoExtension, _In_ ULONG BarIndex, _In_ PIO_RESOURCE_DESCRIPTOR Limit, _Out_writes_opt_(2) PIO_RESOURCE_DESCRIPTOR Descriptors)
Writes the requirements for the sizes a resizable BAR can grow to. They go ahead of the default requi...
Definition: rbar.c:142
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
Definition: restypes.h:116
#define CmResourceTypeInterrupt
Definition: restypes.h:105
#define PCI_HACK_NO_ENUM_AT_ALL
Definition: pci.h:14
STDMETHOD() Next(THIS_ ULONG celt, IAssociationElement *pElement, ULONG *pceltFetched) PURE
#define MAXULONG
Definition: typedefs.h:251
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFIORESREQLIST RequirementsList
Definition: wdfresource.h:65
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241
@ CmResourceShareShared
Definition: cmtypes.h:243

Referenced by PciAssignAndProgramLegacy(), and PciQueryRequirements().

◆ PciBusInterface_GetBusData()

ULONG NTAPI PciBusInterface_GetBusData ( _In_ PVOID  Context,
_In_ ULONG  WhichSpace,
_Out_writes_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Offset,
_In_ ULONG  Length 
)

◆ PciBusInterface_SetBusData()

ULONG NTAPI PciBusInterface_SetBusData ( _In_ PVOID  Context,
_In_ ULONG  WhichSpace,
_In_reads_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Offset,
_In_ ULONG  Length 
)

◆ PciCacheLegacyDeviceRouting()

NTSTATUS NTAPI PciCacheLegacyDeviceRouting ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN UCHAR  InterruptLine,
IN UCHAR  InterruptPin,
IN UCHAR  BaseClass,
IN UCHAR  SubClass,
IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PPCI_PDO_EXTENSION  PdoExtension,
OUT PDEVICE_OBJECT *  pFoundDeviceObject 
)

Definition at line 266 of file routintf.c.

276{
278 PPCI_LEGACY_DEVICE LegacyDevice;
279 PDEVICE_OBJECT FoundDeviceObject;
280 PAGED_CODE();
281
282 /* Scan current registered devices */
283 LegacyDevice = PciLegacyDeviceHead;
285 while (LegacyDevice)
286 {
287 /* Find a match */
288 if ((BusNumber == LegacyDevice->BusNumber) &&
289 (SlotNumber == LegacyDevice->SlotNumber))
290 {
291 /* We already know about this routing */
292 break;
293 }
294
295 /* We know about device already, but for a different location */
296 if (LegacyDevice->DeviceObject == DeviceObject)
297 {
298 /* Free the existing structure, move to the next one */
299 *Link = LegacyDevice->Next;
300 ExFreePoolWithTag(LegacyDevice, 0);
301 LegacyDevice = *Link;
302 }
303 else
304 {
305 /* Keep going */
306 Link = &LegacyDevice->Next;
307 LegacyDevice = LegacyDevice->Next;
308 }
309 }
310
311 /* Did we find a match? */
312 if (!LegacyDevice)
313 {
314 /* Allocate a new cache structure */
315 LegacyDevice = ExAllocatePoolWithTag(PagedPool,
316 sizeof(PCI_LEGACY_DEVICE),
318 if (!LegacyDevice) return STATUS_INSUFFICIENT_RESOURCES;
319
320 /* Save all the data in it */
321 RtlZeroMemory(LegacyDevice, sizeof(PCI_LEGACY_DEVICE));
322 LegacyDevice->BusNumber = BusNumber;
323 LegacyDevice->SlotNumber = SlotNumber;
324 LegacyDevice->InterruptLine = InterruptLine;
325 LegacyDevice->InterruptPin = InterruptPin;
326 LegacyDevice->BaseClass = BaseClass;
327 LegacyDevice->SubClass = SubClass;
329 LegacyDevice->DeviceObject = DeviceObject;
330 LegacyDevice->PdoExtension = PdoExtension;
331
332 /* Link it in the list */
333 LegacyDevice->Next = PciLegacyDeviceHead;
334 PciLegacyDeviceHead = LegacyDevice;
335 }
336
337 /* Check if we found, or created, a matching caching structure */
338 FoundDeviceObject = LegacyDevice->DeviceObject;
339 if (FoundDeviceObject == DeviceObject)
340 {
341 /* Return the device object and success */
342 if (pFoundDeviceObject) *pFoundDeviceObject = DeviceObject;
343 return STATUS_SUCCESS;
344 }
345
346 /* Otherwise, this is a new device object for this location */
347 LegacyDevice->DeviceObject = DeviceObject;
348 if (pFoundDeviceObject) *pFoundDeviceObject = FoundDeviceObject;
349 return STATUS_SUCCESS;
350}
#define TAG_PCI_ROUTING
Definition: pci.h:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
_In_ ULONG BusNumber
Definition: pciidex.h:65
PPCI_LEGACY_DEVICE PciLegacyDeviceHead
Definition: routintf.c:18
UCHAR InterruptPin
Definition: pci.h:593
UCHAR SubClass
Definition: pci.h:595
UCHAR BaseClass
Definition: pci.h:594
PPCI_PDO_EXTENSION PdoExtension
Definition: pci.h:598
UCHAR InterruptLine
Definition: pci.h:592
PDEVICE_OBJECT PhysicalDeviceObject
Definition: pci.h:596
PDEVICE_OBJECT DeviceObject
Definition: pci.h:589
struct _PCI_LEGACY_DEVICE * Next
Definition: pci.h:588
ULONG BusNumber
Definition: pci.h:590
ULONG SlotNumber
Definition: pci.h:591
static int Link(const char **args)
Definition: vfdcmd.c:2414
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:68

Referenced by PciAssignSlotResources().

◆ PciCallDownIrpStack()

NTSTATUS NTAPI PciCallDownIrpStack ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PIRP  Irp 
)

Definition at line 39 of file dispatch.c.

41{
44 PAGED_CODE();
45 DPRINT("PCIX - PciCallDownIrpStack ...\n");
46 ASSERT_FDO(DeviceExtension);
47
48 /* Initialize the wait event */
50
51 /* Setup a completion routine */
54
55 /* Call the attached device */
56 Status = IoCallDriver(DeviceExtension->AttachedDeviceObject, Irp);
58 {
59 /* Wait for it to complete the request, and get its status */
61 Status = Irp->IoStatus.Status;
62 }
63
64 /* Return that status back to the caller */
65 return Status;
66}
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
IO_COMPLETION_ROUTINE PciSetEventCompletion
Definition: dispatch.c:18
#define ASSERT_FDO(x)
Definition: pci.h:47
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
_In_ PIRP Irp
Definition: kse.h:79
#define KernelMode
Definition: asm.h:38
@ SynchronizationEvent
#define IoCopyCurrentIrpStackLocationToNext(Irp)
Definition: ntifs_ex.h:413
#define IoCallDriver
Definition: irp.c:1257
#define STATUS_PENDING
Definition: telnetd.h:14
@ Executive
Definition: ketypes.h:467

Referenced by PciDispatchIrp(), and PciFdoIrpQueryInterface().

◆ PciCancelStateTransition()

NTSTATUS NTAPI PciCancelStateTransition ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCI_STATE  NewState 
)

Definition at line 145 of file state.c.

147{
149 DPRINT1("PCIX - Request to cancel transition of Extension %p to %s ->",
150 DeviceExtension,
151 PciTransitionText[StateNotEntered]);
152
153 /* The next state can't be the state the device is already in */
154 if (DeviceExtension->TentativeNextState == DeviceExtension->DeviceState)
155 {
156 /* It's too late since the state was already committed */
157 ASSERT(StateNotEntered < PciMaxObjectState);
158 ASSERT(PnpStateCancelArray[StateNotEntered] != STATUS_FAIL_CHECK);
159
160 /* Return failure */
162 DbgPrint("%x\n", Status);
163 }
164 else
165 {
166 /* The device hasn't yet entered the state, so it's still possible to cancel */
167 ASSERT(DeviceExtension->TentativeNextState == StateNotEntered);
168 DeviceExtension->TentativeNextState = DeviceExtension->DeviceState;
169
170 /* Return success */
172 DbgPrint("%x\n", Status);
173 }
174
175 /* Return the cancel state */
176 return Status;
177}
NTSTATUS PnpStateCancelArray[PciMaxObjectState]
Definition: state.c:29
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178

Referenced by PciFdoIrpCancelRemoveDevice(), PciFdoIrpCancelStopDevice(), PciFdoIrpStartDevice(), PciPdoIrpCancelRemoveDevice(), PciPdoIrpCancelStopDevice(), PciPdoIrpStartDevice(), and PciQueryDeviceRelations().

◆ PciCanDisableDecodes()

BOOLEAN NTAPI PciCanDisableDecodes ( IN PPCI_PDO_EXTENSION  DeviceExtension,
IN PPCI_COMMON_HEADER  Config,
IN ULONGLONG  HackFlags,
IN BOOLEAN  ForPowerDown 
)

Definition at line 1027 of file utils.c.

1031{
1032 UCHAR BaseClass, SubClass;
1033 BOOLEAN IsVga, KeepPower = FALSE;
1034
1035 /* Is there a device extension or should the PCI header be used? */
1036 if (DeviceExtension)
1037 {
1038 /* Never disable decodes for a debug PCI Device */
1039 if (DeviceExtension->OnDebugPath) return FALSE;
1040
1041 /* Hack flags will be obtained from the extension, not the caller */
1042 ASSERT(HackFlags == 0);
1043
1044 /* Get hacks and classification from the device extension */
1045 HackFlags = DeviceExtension->HackFlags;
1046 SubClass = DeviceExtension->SubClass;
1047 BaseClass = DeviceExtension->BaseClass;
1048 KeepPower = DeviceExtension->DisablePowerDown;
1049 }
1050 else
1051 {
1052 /* There must be a PCI header, go read the classification information */
1053 ASSERT(Config != NULL);
1054 BaseClass = Config->BaseClass;
1055 SubClass = Config->SubClass;
1056 }
1057
1058 /* Check for hack flags that prevent disabling the decodes */
1063 {
1064 /* Don't do it */
1065 return FALSE;
1066 }
1067
1068 if (ForPowerDown)
1069 {
1070 /* IDE controllers, legacy bridges and flagged functions may stop but not power down */
1071 if (KeepPower || (HackFlags & PCI_HACK_NEVER_POWER_DOWN))
1072 return FALSE;
1073 }
1075 {
1076 /* Flagged functions may power down, but keep decoding while stopped or removed */
1077 return FALSE;
1078 }
1079
1080 /* VGA adapters keep decoding unless they are being powered down */
1081 if (((BaseClass == PCI_CLASS_DISPLAY_CTLR) && (SubClass == PCI_SUBCLASS_VID_VGA_CTLR)) ||
1082 ((BaseClass == PCI_CLASS_PRE_20) && (SubClass == PCI_SUBCLASS_PRE_20_VGA)))
1083 {
1084 return ForPowerDown;
1085 }
1086
1087 if (BaseClass == PCI_CLASS_BRIDGE_DEV)
1088 {
1089 /* Check for legacy bridges */
1090 if ((SubClass == PCI_SUBCLASS_BR_ISA) ||
1091 (SubClass == PCI_SUBCLASS_BR_EISA) ||
1092 (SubClass == PCI_SUBCLASS_BR_MCA) ||
1093 (SubClass == PCI_SUBCLASS_BR_HOST) ||
1094 (SubClass == PCI_SUBCLASS_BR_OTHER))
1095 {
1096 /* Never disable these */
1097 return FALSE;
1098 }
1099 else if ((SubClass == PCI_SUBCLASS_BR_PCI_TO_PCI) ||
1100 (SubClass == PCI_SUBCLASS_BR_CARDBUS))
1101 {
1102 /* This is a supported bridge, but does it have a VGA card? */
1103 if (!DeviceExtension)
1104 {
1105 /* Read the bridge control flag from the PCI header */
1106 IsVga = Config->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA;
1107 }
1108 else
1109 {
1110 /* Read the cached flag in the device extension */
1111 IsVga = DeviceExtension->Dependent.type1.VgaBitSet;
1112 }
1113
1114 /* A bridge forwarding VGA follows the same rule as the adapter behind it */
1115 if (IsVga)
1116 return ForPowerDown;
1117 }
1118 }
1119
1120 /* Nothing else has to keep decoding */
1121 return TRUE;
1122}
_In_ ULONG_PTR HackFlags
Definition: cdrom.h:983
#define PCI_HACK_PRESERVE_COMMAND
Definition: pci.h:25
#define PCI_HACK_CB_SHARE_CMD_BITS
Definition: pci.h:27
#define PCI_HACK_NEVER_DISCONNECT
Definition: pci.h:17
#define PCI_HACK_DONT_DISABLE
Definition: pci.h:18
#define PCI_HACK_NEVER_POWER_DOWN
Definition: pci.h:41
#define PCI_HACK_KEEP_DECODES_ON_STOP
Definition: pci.h:12
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
#define PCI_SUBCLASS_BR_OTHER
Definition: iotypes.h:4186
#define PCI_SUBCLASS_BR_EISA
Definition: iotypes.h:4179
#define PCI_SUBCLASS_BR_HOST
Definition: iotypes.h:4177
#define PCI_SUBCLASS_BR_MCA
Definition: iotypes.h:4180
#define PCI_SUBCLASS_BR_ISA
Definition: iotypes.h:4178
#define PCI_SUBCLASS_BR_CARDBUS
Definition: iotypes.h:4184

Referenced by PciDecodeEnable(), PciPdoCanPowerDown(), PciPdoCanTurnOff(), PciPdoTurnOff(), and PciSetPowerManagedDevicePowerState().

◆ pcicbintrf_Constructor()

NTSTATUS NTAPI pcicbintrf_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 200 of file cardbus.c.

206{
207 UNREFERENCED_PARAMETER(DeviceExtension);
209 UNREFERENCED_PARAMETER(InterfaceData);
213
214 /* Not provided, so the query fails and the socket driver goes without it */
216}

◆ pcicbintrf_Initializer()

NTSTATUS NTAPI pcicbintrf_Initializer ( IN PVOID  Instance)

Definition at line 190 of file cardbus.c.

191{
193 /* PnP Interfaces don't get Initialized */
194 ASSERTMSG("PCI pcicbintrf_Initializer, unexpected call.\n", FALSE);
195 return STATUS_UNSUCCESSFUL;
196}

◆ PciClassifyDeviceType()

PCI_DEVICE_TYPES NTAPI PciClassifyDeviceType ( IN PPCI_PDO_EXTENSION  PdoExtension)

Definition at line 1126 of file utils.c.

1127{
1128 ASSERT(PdoExtension->ExtensionType == PciPdoExtensionType);
1129
1130 /* Differentiate between devices and bridges */
1131 if (PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) return PciTypeDevice;
1132
1133 /* The PCI Bus driver handles only CardBus and PCI bridges (plus host) */
1134 if (PdoExtension->SubClass == PCI_SUBCLASS_BR_HOST) return PciTypeHostBridge;
1137
1138 /* Any other kind of bridge is treated like a device */
1139 return PciTypeDevice;
1140}

Referenced by PciProcessBus().

◆ PciCommitStateTransition()

VOID NTAPI PciCommitStateTransition ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCI_STATE  NewState 
)

Definition at line 181 of file state.c.

183{
184 DPRINT1("PCIX - Commit transition of Extension %p to %s\n",
185 DeviceExtension, PciTransitionText[NewState]);
186
187 /* Make sure this is a valid commit */
188 ASSERT(NewState != PciSynchronizedOperation);
189 ASSERT(DeviceExtension->TentativeNextState == NewState);
190
191 /* Enter the new state */
192 DeviceExtension->DeviceState = NewState;
193}

Referenced by PciFdoIrpRemoveDevice(), PciFdoIrpStartDevice(), PciFdoIrpStopDevice(), PciFdoIrpSurpriseRemoval(), PciPdoIrpRemoveDevice(), PciPdoIrpStartDevice(), PciPdoIrpStopDevice(), and PciPdoIrpSurpriseRemoval().

◆ PciComputeNewCurrentSettings()

BOOLEAN NTAPI PciComputeNewCurrentSettings ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN PCM_RESOURCE_LIST  ResourceList 
)

Definition at line 55 of file enum.c.

57{
58 PCM_PARTIAL_RESOURCE_DESCRIPTOR Partial, InterruptResource;
59 PCM_PARTIAL_RESOURCE_DESCRIPTOR CurrentDescriptor;
60 CM_PARTIAL_RESOURCE_DESCRIPTOR ResourceArray[7];
61 ULONG BarIndex;
63 BOOLEAN RangeChange;
64 ULONG DrainPartial;
65 ULONG i, j;
66 PPCI_FUNCTION_RESOURCES PciResources;
67 PAGED_CODE();
68
69 /* Make sure we have either no resources, or at least one */
70 ASSERT((ResourceList == NULL) || (ResourceList->Count == 1));
71
72 /* Initialize no partial, interrupt descriptor, or range change */
73 Partial = NULL;
74 InterruptResource = NULL;
75 RangeChange = FALSE;
76 BarIndex = 0;
77
78 /* The limits say which BARs this function implements, so the walk below
79 * can tell which BAR each assigned descriptor belongs to */
80 PciResources = PdoExtension->Resources;
81
82 /* Check if there's not actually any resources */
83 if (!(ResourceList) || !(ResourceList->Count))
84 {
85 /* Then just return the hardware update state */
86 return PdoExtension->UpdateHardware;
87 }
88
89 /* Print the new specified resource list */
91
92 /* Zero all fields, an unassigned entry still gets copied into the current settings */
93 RtlZeroMemory(ResourceArray, sizeof(ResourceArray));
94
95 /* Loop the full resource descriptor */
96 FullList = ResourceList->List;
97 for (i = 0; i < ResourceList->Count; i++)
98 {
99 /* Initialize loop variables */
100 DrainPartial = 0;
101
102 /* Loop the partial descriptors */
103 Partial = FullList->PartialResourceList.PartialDescriptors;
104 for (j = 0; j < FullList->PartialResourceList.Count; j++)
105 {
106 /* Check if we were supposed to drain a partial due to device data */
107 if (DrainPartial)
108 {
109 DrainPartial--;
110 Partial = CmiGetNextPartialDescriptor(Partial);
111 continue;
112 }
113
114 /* Check what kind of descriptor this was */
115 switch (Partial->Type)
116 {
117 /* Base BAR resources */
121 {
122 /*
123 * Skip legacy/shared resources (e.g., VGA ports 0x3B0-0x3DF, memory 0xA0000).
124 * should not be placed in the ResourceArray.
125 */
127 {
128 break;
129 }
130
131 /*
132 * The assigned descriptors come back in the order the
133 * requirements list asked for them, so walking the limits
134 * in that same order says which BAR this one satisfies.
135 */
136 if (PciResources)
137 {
138 while ((BarIndex < RTL_NUMBER_OF(ResourceArray)) &&
139 !PciIsRequirementDescriptor(&PciResources->Limit[BarIndex]))
140 {
141 BarIndex++;
142 }
143
144 if (BarIndex < RTL_NUMBER_OF(ResourceArray))
145 ResourceArray[BarIndex++] = *Partial;
146 }
147 break;
148 }
149 /* Interrupt resource */
151
152 /* Make sure it's the only PCI interrupt */
153 ASSERT(InterruptResource == NULL);
154 InterruptResource = Partial;
155
156 /* A message grant packs its message count into the level and
157 * has no line to report, it gets programmed at start instead */
159 break;
160
161 /* Make sure it's a compatible line-based interrupt */
162 ASSERT(Partial->u.Interrupt.Level == Partial->u.Interrupt.Vector);
163
164 /* Only 255 interrupts on x86/x64 hardware */
165 if (Partial->u.Interrupt.Level < 256)
166 {
167 /* Use the passed interrupt line */
168 PdoExtension->AdjustedInterruptLine = Partial->u.Interrupt.Level;
169 }
170 else
171 {
172 /* Invalid vector, so ignore it */
173 PdoExtension->AdjustedInterruptLine = 0;
174 }
175
176 break;
177
178 /* Check for specific device data */
180
181 /* Check what kind of data this was */
182 switch (Partial->u.DevicePrivate.Data[0])
183 {
184 /* Not used in the driver yet */
185 case 1:
186 case 2:
187 DPRINT1("PCIX - ignoring device-private data type %u\n",
188 Partial->u.DevicePrivate.Data[0]);
189 break;
190
191 /* A drain request */
192 case 3:
193 DrainPartial = Partial->u.DevicePrivate.Data[1];
194 break;
195 }
196 break;
197 }
198
199 /* Move to the next descriptor */
200 Partial = CmiGetNextPartialDescriptor(Partial);
201 }
202
203 /* We should be starting a new list now */
204 FullList = (PVOID)Partial;
205 }
206
207 /* A function with no discovered resources has nothing to update */
208 if (!PciResources) return FALSE;
209
210 /* Loop all the PCI function resources */
211 for (i = 0; i < RTL_NUMBER_OF(ResourceArray); i++)
212 {
213 /* A bridge window is never asked for, so it keeps the range the firmware gave it */
214 if (!PciIsRequirementDescriptor(&PciResources->Limit[i]))
215 continue;
216
217 /* Get the current function resource descriptor, and the new one */
218 CurrentDescriptor = &PciResources->Current[i];
219 Partial = &ResourceArray[i];
220
221 /* Check if this new descriptor is different than the old one */
222 if ((Partial->Type != CurrentDescriptor->Type) ||
223 ((Partial->Type != CmResourceTypeNull) &&
224 ((Partial->u.Generic.Start.QuadPart !=
225 CurrentDescriptor->u.Generic.Start.QuadPart) ||
226 (RtlCmDecodeMemIoResource(Partial, NULL) !=
227 RtlCmDecodeMemIoResource(CurrentDescriptor, NULL)))))
228 {
229 /* Record a change */
230 RangeChange = TRUE;
231
232 /* Was there a range before? */
233 if (CurrentDescriptor->Type != CmResourceTypeNull)
234 {
235 /* Print it */
236 DbgPrint(" Old range-\n");
237 PciDebugPrintPartialResource(CurrentDescriptor);
238 }
239 else
240 {
241 /* There was no range */
242 DbgPrint(" Previously unset range\n");
243 }
244
245 /* Print new one */
246 DbgPrint(" changed to\n");
248
249 /* Update to new range */
250 CurrentDescriptor->Type = Partial->Type;
251 CurrentDescriptor->Flags = Partial->Flags;
252 CurrentDescriptor->u.Generic.Start = Partial->u.Generic.Start;
253 CurrentDescriptor->u.Generic.Length = Partial->u.Generic.Length;
254 }
255 }
256
257 /* Either the hardware was updated, or a resource range changed */
258 return ((RangeChange) || (PdoExtension->UpdateHardware));
259}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
FORCEINLINE PCM_PARTIAL_RESOURCE_DESCRIPTOR CmiGetNextPartialDescriptor(_In_ const CM_PARTIAL_RESOURCE_DESCRIPTOR *PartialDescriptor)
Definition: cmreslist.h:31
VOID NTAPI PciDebugPrintPartialResource(IN PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialResource)
Definition: debug.c:349
VOID NTAPI PciDebugPrintCmResList(IN PCM_RESOURCE_LIST PartialList)
Definition: debug.c:365
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 GLint GLint j
Definition: glfuncs.h:250
#define CM_RESOURCE_INTERRUPT_MESSAGE
Definition: restypes.h:118
#define CmResourceTypeDevicePrivate
Definition: restypes.h:112
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: restypes.h:145
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@501 DevicePrivate
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@497 Interrupt
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: restypes.h:100
IO_RESOURCE_DESCRIPTOR Limit[7]
Definition: pci.h:287
CM_PARTIAL_RESOURCE_DESCRIPTOR Current[7]
Definition: pci.h:288
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
@ CmResourceShareDriverExclusive
Definition: cmtypes.h:242

Referenced by PciAssignAndProgramLegacy(), and PciPdoIrpStartDevice().

◆ PciCreateIoDescriptorFromBarLimit()

BOOLEAN NTAPI PciCreateIoDescriptorFromBarLimit ( _Out_ PIO_RESOURCE_DESCRIPTOR  ResourceDescriptor,
_In_ ULONG  Bar,
_In_ ULONG  NextBar,
_In_ BOOLEAN  Rom 
)

Builds the requirement of a BAR from the value it reads back after all ones were written to it.

Parameters
[out]ResourceDescriptorReceives the requirement, or a null descriptor when the BAR is not implemented.
[in]BarThe probed BAR.
[in]NextBarThe probed BAR after it, which holds the high half of a 64-bit BAR. 0 when there is none.
[in]RomTRUE when Bar is an expansion ROM BAR.
Returns
TRUE when the BAR is 64-bit, so the BAR after it is not a BAR of its own.

Definition at line 1252 of file utils.c.

1257{
1258 ULONGLONG AddressBits, Length, Alignment;
1260 UCHAR Type;
1261 BOOLEAN Is64BitBar = FALSE;
1262
1263 /* Check if the BAR is nor I/O nor memory */
1264 if (!(Bar & ~PCI_ADDRESS_IO_SPACE))
1265 {
1266 /* Fail this descriptor */
1267 ResourceDescriptor->Type = CmResourceTypeNull;
1268 return FALSE;
1269 }
1270
1271 /* Set default flag */
1272 ResourceDescriptor->Flags = 0;
1273
1274 /* Check for ROM AddressBits */
1275 if (Rom)
1276 {
1277 /* Clean up the BAR to get just the address */
1279 if (!Bar)
1280 {
1281 /* Invalid ar, fail this descriptor */
1282 ResourceDescriptor->Type = CmResourceTypeNull;
1283 return FALSE;
1284 }
1285
1286 /* ROM Addresses are always read only */
1287 ResourceDescriptor->Flags = CM_RESOURCE_MEMORY_READ_ONLY;
1288 }
1289
1290 /* Check what kind of BAR this is */
1292 {
1293 /* Set this as an I/O Port descriptor */
1295 ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO;
1296 AddressBits = Bar & PCI_ADDRESS_IO_ADDRESS_MASK;
1297 }
1298 else
1299 {
1300 /* Set this as a memory descriptor */
1302 AddressBits = Bar & PCI_ADDRESS_MEMORY_ADDRESS_MASK;
1303
1304 /* A 64-bit BAR takes the high half of its address from the next BAR */
1306 {
1307 AddressBits |= (ULONGLONG)NextBar << 32;
1308 Is64BitBar = TRUE;
1309 }
1310
1311 /* Check if the BAR is listed as prefetchable memory */
1313 {
1314 /* Mark the descriptor in the same way */
1315 ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE;
1316 }
1317 }
1318
1319 /* The probe leaves only the bits the BAR implements, so the lowest one is its length */
1320 Length = AddressBits & (~AddressBits + 1);
1321
1322 /* A BAR that implements no address bits is not there */
1323 if (!Length)
1324 {
1325 ResourceDescriptor->Type = CmResourceTypeNull;
1326 return FALSE;
1327 }
1328
1329 /* A legacy memory BAR can only be placed below 1MB */
1330 if ((Type == CmResourceTypeMemory) &&
1332 {
1333 AddressBits &= 0xFFFFF;
1334 }
1335
1336 /* A BAR aligns to its own length and decodes nothing above the bits it implements */
1337 Alignment = Length;
1338 MinimumAddress = 0;
1339 MaximumAddress = AddressBits | (Length - 1);
1340
1341 /* A length of 4GB or more takes the large memory form */
1342 if (!NT_SUCCESS(RtlIoEncodeMemIoResource(ResourceDescriptor,
1343 Type,
1344 Length,
1345 Alignment,
1348 {
1349 /* Fail this descriptor */
1350 ResourceDescriptor->Type = CmResourceTypeNull;
1351 }
1352
1353 /* Return if this is a 64-bit BAR, so the loop code knows to skip the next one */
1354 return Is64BitBar;
1355}
static _Out_opt_ PULONGLONG _Out_opt_ PULONGLONG MinimumAddress
static _Out_opt_ PULONGLONG _Out_opt_ PULONGLONG _Out_opt_ PULONGLONG MaximumAddress
Type
Definition: Type.h:7
#define CM_RESOURCE_MEMORY_PREFETCHABLE
Definition: cmtypes.h:125
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CM_RESOURCE_MEMORY_READ_ONLY
Definition: cmtypes.h:122
#define PCI_ADDRESS_MEMORY_PREFETCHABLE
Definition: iotypes.h:4248
NTSYSAPI NTSTATUS NTAPI RtlIoEncodeMemIoResource(_In_ struct _IO_RESOURCE_DESCRIPTOR *Descriptor, _In_ UCHAR Type, _In_ ULONGLONG Length, _In_ ULONGLONG Alignment, _In_ ULONGLONG MinimumAddress, _In_ ULONGLONG MaximumAddress)

Referenced by Cardbus_SaveLimits(), Device_SaveLimits(), and PPBridge_SaveLimits().

◆ PciDebugDumpCommonConfig()

VOID NTAPI PciDebugDumpCommonConfig ( IN PPCI_COMMON_HEADER  PciData)

Definition at line 207 of file debug.c.

208{
209 USHORT i;
210
211 /* Loop the PCI header */
212 for (i = 0; i < PCI_COMMON_HDR_LENGTH; i += 4)
213 {
214 /* Dump each DWORD and its offset */
215 DPRINT1(" %02x - %08x\n", i, *(PULONG)((ULONG_PTR)PciData + i));
216 }
217}
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3609

Referenced by PcipGetFunctionLimits(), and PciScanBus().

◆ PciDebugDumpQueryCapabilities()

VOID NTAPI PciDebugDumpQueryCapabilities ( IN PDEVICE_CAPABILITIES  DeviceCaps)

Definition at line 221 of file debug.c.

222{
223 ULONG i;
224
225 /* Dump the capabilities */
226 DPRINT1("PCIX - Capabilities\n Lock:%u, Eject:%u, Remove:%u, Dock:%u, UniqueId:%u\n",
227 DeviceCaps->LockSupported,
228 DeviceCaps->EjectSupported,
229 DeviceCaps->Removable,
230 DeviceCaps->DockDevice,
231 DeviceCaps->UniqueID);
232 DbgPrint(" SilentInstall:%u, RawOk:%u, SurpriseOk:%u\n",
233 DeviceCaps->SilentInstall,
234 DeviceCaps->RawDeviceOK,
235 DeviceCaps->SurpriseRemovalOK);
236 DbgPrint(" Address %08x, UINumber %08x, Latencies D1 %u, D2 %u, D3 %u\n",
237 DeviceCaps->Address,
238 DeviceCaps->UINumber,
239 DeviceCaps->D1Latency,
240 DeviceCaps->D2Latency,
241 DeviceCaps->D3Latency);
242
243 /* Dump and convert the wake levels */
244 DbgPrint(" System Wake: %s, Device Wake: %s\n DeviceState[PowerState] [",
245 SystemPowerStates[min(DeviceCaps->SystemWake, PowerSystemMaximum)],
246 DevicePowerStates[min(DeviceCaps->DeviceWake, PowerDeviceMaximum)]);
247
248 /* Dump and convert the power state mappings */
250 DbgPrint(" %s", DevicePowerStates[DeviceCaps->DeviceState[i]]);
251
252 /* Finish the dump */
253 DbgPrint(" ]\n");
254}
PCHAR SystemPowerStates[]
Definition: debug.c:53
PCHAR DevicePowerStates[]
Definition: debug.c:64
#define min(a, b)
Definition: monoChain.cc:55
@ PowerSystemMaximum
Definition: ntpoapi.h:42
@ PowerSystemWorking
Definition: ntpoapi.h:36
@ PowerDeviceMaximum
Definition: ntpoapi.h:53

Referenced by PciFdoIrpQueryCapabilities(), and PciQueryCapabilities().

◆ PciDebugIrpDispatchDisplay()

BOOLEAN NTAPI PciDebugIrpDispatchDisplay ( IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension,
IN USHORT  MaxMinor 
)

Definition at line 124 of file debug.c.

127{
128 PPCI_PDO_EXTENSION PdoDeviceExtension;
129 ULONG BreakMask;
130 //ULONG DebugLevel = 0;
131 PCHAR IrpString;
132
133 /* Only two functions are recognized */
135 {
136 case IRP_MJ_POWER:
137
138 /* Get the string and the correct break mask for the extension */
139 BreakMask = (DeviceExtension->ExtensionType == PciPdoExtensionType) ?
142 break;
143
144 case IRP_MJ_PNP:
145
146 /* Get the string and the correct break mask for the extension */
147 BreakMask = (DeviceExtension->ExtensionType == PciFdoExtensionType) ?
150 break;
151
152 default:
153
154 /* Other functions are not decoded */
155 BreakMask = FALSE;
156 IrpString = "";
157 break;
158 }
159
160 /* Check if this is a PDO */
161 if (DeviceExtension->ExtensionType == PciPdoExtensionType)
162 {
163 /* Choose the correct debug level based on which function this is */
165 {
166 //DebugLevel = 0x500;
167 }
169 {
170 //DebugLevel = 0x200;
171 }
172
173 /* For a PDO, print out the bus, device, and function number */
174 PdoDeviceExtension = (PVOID)DeviceExtension;
175 DPRINT1("PCIX - PDO(b=0x%x, d=0x%x, f=0x%x)<-%s\n",
176 PdoDeviceExtension->ParentFdoExtension->BaseBus,
177 PdoDeviceExtension->Slot.u.bits.DeviceNumber,
178 PdoDeviceExtension->Slot.u.bits.FunctionNumber,
179 IrpString);
180 }
181 else if (DeviceExtension->ExtensionType == PciFdoExtensionType)
182 {
183 /* Choose the correct debug level based on which function this is */
185 {
186 //DebugLevel = 0x400;
187 }
189 {
190 //DebugLevel = 0x100;
191 }
192
193 /* For an FDO, just dump the extension pointer and IRP string */
194 DPRINT1("PCIX - FDO(%p)<-%s\n", DeviceExtension, IrpString);
195 }
196
197 /* If the function is illegal for this extension, complain */
198 if (IoStackLocation->MinorFunction > MaxMinor)
199 DPRINT1("PCIX - Unknown IRP, minor = 0x%x\n", IoStackLocation->MinorFunction);
200
201 /* Return whether or not the debugger should be broken into for this IRP */
202 return ((1 << IoStackLocation->MinorFunction) & BreakMask);
203}
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
ULONG PciBreakOnFdoPnpIrp
Definition: debug.c:74
ULONG PciBreakOnPdoPowerIrp
Definition: debug.c:73
PCHAR NTAPI PciDebugPnpIrpTypeToText(IN USHORT MinorFunction)
Definition: debug.c:80
ULONG PciBreakOnPdoPnpIrp
Definition: debug.c:74
PCHAR NTAPI PciDebugPoIrpTypeToText(IN USHORT MinorFunction)
Definition: debug.c:102
ULONG PciBreakOnFdoPowerIrp
Definition: debug.c:73
PCI_SLOT_NUMBER Slot
Definition: pci.h:332
PPCI_FDO_EXTENSION ParentFdoExtension
Definition: pci.h:334
struct _PCI_SLOT_NUMBER::@5064::@5065 bits
union _PCI_SLOT_NUMBER::@5064 u
char * PCHAR
Definition: typedefs.h:51
_In_ PIO_STACK_LOCATION IoStackLocation
Definition: usbdlib.h:292
#define IRP_MJ_POWER

Referenced by PciDispatchIrp().

◆ PciDebugPrintCmResList()

VOID NTAPI PciDebugPrintCmResList ( IN PCM_RESOURCE_LIST  ResourceList)

Definition at line 365 of file debug.c.

366{
367 PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptor;
368 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
369 ULONG Count, i, ListCount;
370
371 /* Make sure there's something to dump */
372 if (!PartialList) return;
373
374 /* Get the full list count */
375 ListCount = PartialList->Count;
376 FullDescriptor = PartialList->List;
377 DPRINT1(" CM_RESOURCE_LIST (PCI Bus Driver) (List Count = %u)\n", PartialList->Count);
378
379 /* Loop full list */
380 for (i = 0; i < ListCount; i++)
381 {
382 /* Loop full descriptor */
383 DPRINT1(" InterfaceType %d\n", FullDescriptor->InterfaceType);
384 DPRINT1(" BusNumber 0x%x\n", FullDescriptor->BusNumber);
385
386 /* Get partial count and loop partials */
387 Count = FullDescriptor->PartialResourceList.Count;
388 for (PartialDescriptor = FullDescriptor->PartialResourceList.PartialDescriptors;
389 Count;
390 PartialDescriptor = CmiGetNextPartialDescriptor(PartialDescriptor))
391 {
392 /* Print each partial */
393 PciDebugPrintPartialResource(PartialDescriptor);
394 Count--;
395 }
396
397 /* Go to the next full descriptor */
398 FullDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)PartialDescriptor;
399 }
400
401 /* Done printing data */
402 DPRINT1("\n");
403}
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
INTERFACE_TYPE InterfaceType
Definition: restypes.h:143

Referenced by PciComputeNewCurrentSettings().

◆ PciDebugPrintIoResReqList()

VOID NTAPI PciDebugPrintIoResReqList ( IN PIO_RESOURCE_REQUIREMENTS_LIST  Requirements)

Definition at line 303 of file debug.c.

304{
305 ULONG AlternativeLists;
307 ULONG Count;
309
310 /* Make sure there's a list */
311 if (!Requirements) return;
312
313 /* Grab the main list and the alternates as well */
314 AlternativeLists = Requirements->AlternativeLists;
315 List = Requirements->List;
316
317 /* Print out the initial header*/
318 DPRINT1(" IO_RESOURCE_REQUIREMENTS_LIST (PCI Bus Driver)\n");
319 DPRINT1(" InterfaceType %d\n", Requirements->InterfaceType);
320 DPRINT1(" BusNumber 0x%x\n", Requirements->BusNumber);
321 DPRINT1(" SlotNumber %d (0x%x), (d/f = 0x%x/0x%x)\n",
322 Requirements->SlotNumber,
323 Requirements->SlotNumber,
324 ((PCI_SLOT_NUMBER*)&Requirements->SlotNumber)->u.bits.DeviceNumber,
325 ((PCI_SLOT_NUMBER*)&Requirements->SlotNumber)->u.bits.FunctionNumber);
326 DPRINT1(" AlternativeLists %u\n", AlternativeLists);
327
328 /* Scan alternative lists */
329 while (AlternativeLists--)
330 {
331 /* Get the descriptor array, and the count of descriptors */
332 Descriptor = List->Descriptors;
333 Count = List->Count;
334
335 /* Print out each descriptor */
336 DPRINT1("\n List[%u].Count = %u\n", AlternativeLists, Count);
338
339 /* Should've reached a new list now */
341 }
342
343 /* Terminate the dump */
344 DPRINT1("\n");
345}
VOID NTAPI PciDebugPrintIoResource(IN PIO_RESOURCE_DESCRIPTOR Descriptor)
Definition: debug.c:280
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
struct _IO_RESOURCE_LIST * PIO_RESOURCE_LIST

Referenced by PciQueryRequirements().

◆ PciDebugPrintPartialResource()

VOID NTAPI PciDebugPrintPartialResource ( IN PCM_PARTIAL_RESOURCE_DESCRIPTOR  PartialResource)

Definition at line 349 of file debug.c.

350{
351 /* Dump all the data in the partial */
352 DPRINT1(" Partial Resource Descriptor @0x%p\n", PartialResource);
353 DPRINT1(" Type = %u (%s)\n", PartialResource->Type, PciDebugCmResourceTypeToText(PartialResource->Type));
354 DPRINT1(" ShareDisposition = %u\n", PartialResource->ShareDisposition);
355 DPRINT1(" Flags = 0x%04X\n", PartialResource->Flags);
356 DPRINT1(" Data[%d] = %08x %08x %08x\n",
357 0,
358 PartialResource->u.Generic.Start.LowPart,
359 PartialResource->u.Generic.Start.HighPart,
360 PartialResource->u.Generic.Length);
361}
PCHAR NTAPI PciDebugCmResourceTypeToText(IN UCHAR Type)
Definition: debug.c:258

Referenced by PciComputeNewCurrentSettings(), and PciDebugPrintCmResList().

◆ PciDecodeEnable()

VOID NTAPI PciDecodeEnable ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN BOOLEAN  Enable,
OUT PUSHORT  Command 
)

Definition at line 1359 of file utils.c.

1362{
1363 USHORT CommandValue;
1364
1365 /*
1366 * If decodes are being disabled, make sure it's allowed, and in both cases,
1367 * make sure that a hackflag isn't preventing touching the decodes at all.
1368 */
1369 if (((Enable) || (PciCanDisableDecodes(PdoExtension, 0, 0, 0))) &&
1371 {
1372 /* Did the caller already have a command word? */
1373 if (Command)
1374 {
1375 /* Use the caller's */
1376 CommandValue = *Command;
1377 }
1378 else
1379 {
1380 /* Otherwise, read the current command */
1382 &CommandValue,
1384 sizeof(USHORT));
1385 }
1386
1387 /* Turn off decodes by default */
1388 CommandValue &= ~(PCI_ENABLE_IO_SPACE |
1391
1392 /* If requested, enable the decodes that were enabled at init time */
1393 if (Enable) CommandValue |= PdoExtension->CommandEnables &
1397
1398 /* Update the command word */
1400 &CommandValue,
1402 sizeof(USHORT));
1403 }
1404}
VOID NTAPI PciWriteDeviceConfig(IN PPCI_PDO_EXTENSION DeviceExtension, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: config.c:133
BOOLEAN NTAPI PciCanDisableDecodes(IN PPCI_PDO_EXTENSION DeviceExtension, IN PPCI_COMMON_HEADER Config, IN ULONGLONG HackFlags, IN BOOLEAN ForPowerDown)
Definition: utils.c:1027
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
#define PCI_ENABLE_BUS_MASTER
Definition: iotypes.h:3633

Referenced by PciApplyHacks(), PciConfigureIdeController(), PciPdoTurnOff(), and PcipUpdateHardware().

◆ PciDispatchIrp()

NTSTATUS NTAPI PciDispatchIrp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 99 of file dispatch.c.

101{
102 PPCI_FDO_EXTENSION DeviceExtension;
104 PPCI_MJ_DISPATCH_TABLE IrpDispatchTable;
105 BOOLEAN PassToPdo;
107 PPCI_MN_DISPATCH_TABLE TableArray = NULL, Table;
108 USHORT MaxMinor;
109 PCI_DISPATCH_STYLE DispatchStyle = 0;
110 PCI_DISPATCH_FUNCTION DispatchFunction = NULL;
111 DPRINT("PCIX - Dispatch IRP\n");
112
113 /* Get the extension and I/O stack location for this IRP */
114 DeviceExtension = (PPCI_FDO_EXTENSION)DeviceObject->DeviceExtension;
116 ASSERT((DeviceExtension->ExtensionType == PciPdoExtensionType) ||
117 (DeviceExtension->ExtensionType == PciFdoExtensionType));
118
119 /* Deleted extensions don't respond to IRPs */
120 if (DeviceExtension->DeviceState == PciDeleted)
121 {
122 /* Fail this IRP */
124 PassToPdo = FALSE;
125 }
126 else
127 {
128 /* Otherwise, get the dispatch table for the extension */
129 IrpDispatchTable = DeviceExtension->IrpDispatchTable;
130
131 /* And choose which function table to use */
133 {
134 case IRP_MJ_POWER:
135
136 /* Power Manager IRPs */
137 TableArray = IrpDispatchTable->PowerIrpDispatchTable;
138 MaxMinor = IrpDispatchTable->PowerIrpMaximumMinorFunction;
139 break;
140
141 case IRP_MJ_PNP:
142
143 /* Plug-and-Play Manager IRPs */
144 TableArray = IrpDispatchTable->PnpIrpDispatchTable;
145 MaxMinor = IrpDispatchTable->PnpIrpMaximumMinorFunction;
146 break;
147
149
150 /* WMI IRPs */
151 DispatchFunction = IrpDispatchTable->SystemControlIrpDispatchFunction;
152 DispatchStyle = IrpDispatchTable->SystemControlIrpDispatchStyle;
153 MaxMinor = 0xFFFF;
154 break;
155
156 default:
157
158 /* Unrecognized IRPs */
159 DispatchFunction = IrpDispatchTable->OtherIrpDispatchFunction;
160 DispatchStyle = IrpDispatchTable->OtherIrpDispatchStyle;
161 MaxMinor = 0xFFFF;
162 break;
163 }
164
165 /* Only deal with recognized IRPs */
166 if (MaxMinor != 0xFFFF)
167 {
168 /* Make sure the function is recognized */
169 if (IoStackLocation->MinorFunction > MaxMinor)
170 {
171 /* Pick the terminator, which should return unrecognized */
172 Table = &TableArray[MaxMinor + 1];
173 }
174 else
175 {
176 /* Pick the appropriate table for this function */
177 Table = &TableArray[IoStackLocation->MinorFunction];
178 }
179
180 /* From that table, get the function code and dispatch style */
181 DispatchStyle = Table->DispatchStyle;
182 DispatchFunction = Table->DispatchFunction;
183 }
184
185 /* Print out debugging information, and see if we should break */
187 DeviceExtension,
188 MaxMinor))
189 {
190 /* The developer/user wants us to break for this IRP, do it */
192 }
193
194 /* Check if this IRP should be sent up the stack first */
195 if (DispatchStyle == IRP_UPWARD)
196 {
197 /* Do it now before handling it ourselves */
198 PciCallDownIrpStack(DeviceExtension, Irp);
199 }
200
201 /* Call the our driver's handler for this IRP and deal with the IRP */
202 Status = DispatchFunction(Irp, IoStackLocation, DeviceExtension);
203 switch (DispatchStyle)
204 {
205 /* Complete IRPs are completely immediately by our driver */
206 case IRP_COMPLETE:
207 PassToPdo = FALSE;
208 break;
209
210 /* Downward IRPs are send to the attached FDO */
211 case IRP_DOWNWARD:
212 PassToPdo = TRUE;
213 break;
214
215 /* Upward IRPs are completed immediately by our driver */
216 case IRP_UPWARD:
217 PassToPdo = FALSE;
218 break;
219
220 /* Dispatch IRPs are immediately returned */
221 case IRP_DISPATCH:
222 return Status;
223
224 /* There aren't any other dispatch styles! */
225 default:
226 ASSERT(FALSE);
227 return Status;
228 }
229 }
230
231 /* Pending IRPs are returned immediately */
232 if (Status == STATUS_PENDING) return Status;
233
234 /* Handled IRPs return their status in the status block */
235 if (Status != STATUS_NOT_SUPPORTED) Irp->IoStatus.Status = Status;
236
237 /* Successful, or unhandled IRPs that are "DOWNWARD" are sent to the PDO */
238 if ((PassToPdo) && ((NT_SUCCESS(Status)) || (Status == STATUS_NOT_SUPPORTED)))
239 {
240 /* Let the PDO deal with it */
241 Status = PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
242 }
243 else
244 {
245 /* Otherwise, the IRP is returned with its status */
246 Status = Irp->IoStatus.Status;
247
248 /* Power IRPs need to notify the Power Manager that the next IRP can go */
250
251 /* And now this IRP can be completed */
253 }
254
255 /* And the status returned back to the caller */
256 return Status;
257}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
BOOLEAN NTAPI PciDebugIrpDispatchDisplay(IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension, IN USHORT MaxMinor)
Definition: debug.c:124
NTSTATUS NTAPI PciCallDownIrpStack(IN PPCI_FDO_EXTENSION DeviceExtension, IN PIRP Irp)
Definition: dispatch.c:39
NTSTATUS NTAPI PciPassIrpFromFdoToPdo(IN PPCI_FDO_EXTENSION DeviceExtension, IN PIRP Irp)
Definition: dispatch.c:70
NTSTATUS(NTAPI * PCI_DISPATCH_FUNCTION)(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PVOID DeviceExtension)
Definition: pci.h:390
ASMGENDATA Table[]
Definition: genincdata.c:61
#define IoCompleteRequest
Definition: irp.c:1272
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758
BOOLEAN DeviceState
Definition: pci.h:246
ULONG ExtensionType
Definition: pci.h:244
struct _PCI_MJ_DISPATCH_TABLE * IrpDispatchTable
Definition: pci.h:245
ULONG PnpIrpMaximumMinorFunction
Definition: pci.h:410
PCI_DISPATCH_FUNCTION SystemControlIrpDispatchFunction
Definition: pci.h:415
PPCI_MN_DISPATCH_TABLE PowerIrpDispatchTable
Definition: pci.h:413
PCI_DISPATCH_STYLE OtherIrpDispatchStyle
Definition: pci.h:416
PCI_DISPATCH_FUNCTION OtherIrpDispatchFunction
Definition: pci.h:417
ULONG PowerIrpMaximumMinorFunction
Definition: pci.h:412
PPCI_MN_DISPATCH_TABLE PnpIrpDispatchTable
Definition: pci.h:411
PCI_DISPATCH_STYLE SystemControlIrpDispatchStyle
Definition: pci.h:414
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MJ_SYSTEM_CONTROL

◆ PciEcamReadWriteConfig()

BOOLEAN NTAPI PciEcamReadWriteConfig ( _In_ ULONG  Bus,
_In_ PCI_SLOT_NUMBER  Slot,
_Inout_updates_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Offset,
_In_ ULONG  Length,
_In_ BOOLEAN  Read 
)

Performs a configuration space access through the ECAM window.

Returns
FALSE if the window cannot serve the access, in which case the caller falls back to the legacy mechanism.

Definition at line 401 of file ecam.c.

408{
410
411 if (!PciEcamVerified) return FALSE;
412
415 {
416 return FALSE;
417 }
418
419 Function = PciEcamFunctionBase(Bus, Slot);
420 if (!Function) return FALSE;
421
423 return TRUE;
424}
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
BOOLEAN PciEcamVerified
Definition: ecam.c:20
static VOID NTAPI PciEcamTransfer(_In_ PUCHAR Function, _Inout_updates_bytes_(Length) PUCHAR Buffer, _In_ ULONG Offset, _In_ ULONG Length, _In_ BOOLEAN Read)
Definition: ecam.c:226
static PUCHAR NTAPI PciEcamFunctionBase(_In_ ULONG Bus, _In_ PCI_SLOT_NUMBER Slot)
Definition: ecam.c:203
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ BOOLEAN Read
Definition: strmini.h:479
unsigned char * PUCHAR
Definition: typedefs.h:53
#define PCI_EXTENDED_CONFIG_LENGTH
Definition: iotypes.h:3611

Referenced by PciReadWriteConfigSpace().

◆ PciExecuteCriticalSystemRoutine()

ULONG_PTR NTAPI PciExecuteCriticalSystemRoutine ( IN ULONG_PTR  IpiContext)

Definition at line 1144 of file utils.c.

1145{
1147
1148 /* Check if the IPI is already running */
1149 if (!InterlockedDecrement(&Context->RunCount))
1150 {
1151 /* Nope, this is the first instance, so execute the IPI function */
1152 Context->Function(Context->DeviceExtension, Context->Context);
1153
1154 /* Notify anyone that was spinning that they can stop now */
1155 Context->Barrier = 0;
1156 }
1157 else
1158 {
1159 /* Spin until it has finished running */
1160 while (Context->Barrier);
1161 }
1162
1163 /* Done */
1164 return 0;
1165}
struct _PCI_IPI_CONTEXT * PPCI_IPI_CONTEXT
PCI_IPI_FUNCTION Function
Definition: pci.h:579

◆ PciFdoIrpCancelRemoveDevice()

NTSTATUS NTAPI PciFdoIrpCancelRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 322 of file fdo.c.

325{
326 PAGED_CODE();
327
330
331 /* The remove is off, so the bus stays where it was */
332 PciCancelStateTransition(DeviceExtension, PciDeleted);
333 return STATUS_SUCCESS;
334}
NTSTATUS NTAPI PciCancelStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:145

◆ PciFdoIrpCancelStopDevice()

NTSTATUS NTAPI PciFdoIrpCancelStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 382 of file fdo.c.

385{
386 PAGED_CODE();
387
390
391 /* The stop is off, so the bus keeps its windows */
392 PciCancelStateTransition(DeviceExtension, PciStopped);
393 return STATUS_SUCCESS;
394}

◆ PciFdoIrpDeviceUsageNotification()

NTSTATUS NTAPI PciFdoIrpDeviceUsageNotification ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 527 of file fdo.c.

530{
531 PAGED_CODE();
532
533 /* A failure from below stands, but a lower driver that ignored it does not count */
534 if (!NT_SUCCESS(Irp->IoStatus.Status) &&
535 (Irp->IoStatus.Status != STATUS_NOT_SUPPORTED))
536 {
537 return Irp->IoStatus.Status;
538 }
539
540 return PciUpdateDeviceUsage(&DeviceExtension->PowerState, IoStackLocation);
541}
NTSTATUS NTAPI PciUpdateDeviceUsage(_Inout_ PPCI_POWER_STATE PowerState, _In_ PIO_STACK_LOCATION IoStackLocation)
Counts a paging, hibernation or dump file arriving on or leaving a device.
Definition: usage.c:35

◆ PciFdoIrpQueryCapabilities()

NTSTATUS NTAPI PciFdoIrpQueryCapabilities ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 500 of file fdo.c.

503{
505 PAGED_CODE();
506 ASSERT_FDO(DeviceExtension);
507
509
510 /* Get the capabilities */
512
513 /* Inherit wake levels and power mappings from the higher-up capabilities */
514 DeviceExtension->PowerState.SystemWakeLevel = Capabilities->SystemWake;
515 DeviceExtension->PowerState.DeviceWakeLevel = Capabilities->DeviceWake;
516 RtlCopyMemory(DeviceExtension->PowerState.SystemStateMapping,
517 Capabilities->DeviceState,
518 sizeof(DeviceExtension->PowerState.SystemStateMapping));
519
520 /* Dump the capabilities and return success */
522 return STATUS_SUCCESS;
523}
VOID NTAPI PciDebugDumpQueryCapabilities(IN PDEVICE_CAPABILITIES DeviceCaps)
Definition: debug.c:221
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
struct _IO_STACK_LOCATION::@5020::@5047 DeviceCapabilities
union _IO_STACK_LOCATION::@1814 Parameters
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965

◆ PciFdoIrpQueryDeviceRelations()

NTSTATUS NTAPI PciFdoIrpQueryDeviceRelations ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 398 of file fdo.c.

401{
403 PAGED_CODE();
404
405 /* Are bus relations being queried? */
407 {
408 /* The FDO is a bus, so only bus relations can be obtained */
410 }
411 else
412 {
413 /* Scan the PCI bus and build the device relations for the caller */
414 Status = PciQueryDeviceRelations(DeviceExtension,
416 &Irp->IoStatus.Information);
417 }
418
419 /* Return the enumeration status back */
420 return Status;
421}
NTSTATUS NTAPI PciQueryDeviceRelations(IN PPCI_FDO_EXTENSION DeviceExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: enum.c:2366
struct _IO_STACK_LOCATION::@5020::@5045 QueryDeviceRelations
@ BusRelations
Definition: iotypes.h:2154

◆ PciFdoIrpQueryInterface()

NTSTATUS NTAPI PciFdoIrpQueryInterface ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 425 of file fdo.c.

428{
430 PAGED_CODE();
431 ASSERT(DeviceExtension->ExtensionType == PciFdoExtensionType);
432
433 /* Deleted extensions don't respond to IRPs */
434 if (DeviceExtension->DeviceState == PciDeleted)
435 {
436 /* Hand it back to try to deal with it */
437 return PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
438 }
439
440 /* Query our driver for this interface */
441 Status = PciQueryInterface(DeviceExtension,
445 Size,
447 Version,
451 Interface,
452 FALSE);
453 if (NT_SUCCESS(Status))
454 {
455 /* We found it, let the PDO handle it */
456 Irp->IoStatus.Status = Status;
457 return PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
458 }
459 else if (Status == STATUS_NOT_SUPPORTED)
460 {
461 /* Otherwise, we can't handle it, let someone else down the stack try */
462 Status = PciCallDownIrpStack(DeviceExtension, Irp);
464 {
465 /* They can't either, try a last-resort interface lookup */
466 Status = PciQueryInterface(DeviceExtension,
470 Size,
472 Version,
476 Interface,
477 TRUE);
478 }
479 }
480
481 /* Has anyone claimed this interface yet? */
483 {
484 /* No, return the original IRP status */
485 Status = Irp->IoStatus.Status;
486 }
487 else
488 {
489 /* Yes, set the new IRP status */
490 Irp->IoStatus.Status = Status;
491 }
492
493 /* Complete this IRP */
495 return Status;
496}
NTSTATUS NTAPI PciQueryInterface(IN PPCI_FDO_EXTENSION DeviceExtension, IN CONST GUID *InterfaceType, IN ULONG Size, IN ULONG Version, IN PVOID InterfaceData, IN PINTERFACE Interface, IN BOOLEAN LastChance)
Definition: intrface.c:45
struct _IO_STACK_LOCATION::@5020::@5046 QueryInterface
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT _In_opt_ PVOID InterfaceSpecificData
Definition: wdffdo.h:472

◆ PciFdoIrpQueryLegacyBusInformation()

NTSTATUS NTAPI PciFdoIrpQueryLegacyBusInformation ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 567 of file fdo.c.

570{
572 PAGED_CODE();
573
575
576 /* The PnP manager frees this once it has recorded the bus */
578 sizeof(*BusInformation),
580 if (!BusInformation)
582
583 BusInformation->BusTypeGuid = GUID_BUS_TYPE_PCI;
584 BusInformation->LegacyBusType = PCIBus;
585 BusInformation->BusNumber = DeviceExtension->BaseBus;
586
587 Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
588 return STATUS_SUCCESS;
589}
#define PCI_POOL_TAG
Definition: pci.h:27
#define ULONG_PTR
Definition: config.h:101
@ PCIBus
Definition: restypes.h:127
_In_ WDFDEVICE _In_ PPNP_BUS_INFORMATION BusInformation
Definition: wdfdevice.h:3921

◆ PciFdoIrpQueryPower()

NTSTATUS NTAPI PciFdoIrpQueryPower ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 351 of file power.c.

354{
357 UNREFERENCED_PARAMETER(DeviceExtension);
358
359 /* Refusing states that would break an armed wake is not implemented yet */
360 DPRINT1("PCIX - Wake-aware power queries are not implemented, accepting the state\n");
361 return STATUS_SUCCESS;
362}

◆ PciFdoIrpQueryRemoveDevice()

NTSTATUS NTAPI PciFdoIrpQueryRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 236 of file fdo.c.

239{
240 PAGED_CODE();
241
244
245 /* Paging, hibernation and dump files behind this bus cannot lose their path */
246 if (DeviceExtension->PowerState.Paging ||
247 DeviceExtension->PowerState.Hibernate ||
248 DeviceExtension->PowerState.CrashDump)
249 {
250 return STATUS_DEVICE_BUSY;
251 }
252
253 /* The remove that follows commits this */
254 return PciBeginStateTransition(DeviceExtension, PciDeleted);
255}
NTSTATUS NTAPI PciBeginStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:97
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129

◆ PciFdoIrpQueryStopDevice()

NTSTATUS NTAPI PciFdoIrpQueryStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 356 of file fdo.c.

359{
360 PAGED_CODE();
361
364
365 /* Paging, hibernation and dump files behind this bus cannot lose their path */
366 if (DeviceExtension->PowerState.Paging ||
367 DeviceExtension->PowerState.Hibernate ||
368 DeviceExtension->PowerState.CrashDump)
369 {
370 return STATUS_DEVICE_BUSY;
371 }
372
373 /* Root bus ranges are fixed, and children would sit outside new bridge windows */
374 if (PCI_IS_ROOT_FDO(DeviceExtension) || DeviceExtension->ChildPdoList)
375 return STATUS_UNSUCCESSFUL;
376
377 return PciBeginStateTransition(DeviceExtension, PciStopped);
378}

◆ PciFdoIrpRemoveDevice()

NTSTATUS NTAPI PciFdoIrpRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 259 of file fdo.c.

262{
264 PPCI_PDO_EXTENSION BridgeExtension;
267 PAGED_CODE();
268
270
271 /* A remove with no query before it, such as after a failed start, begins the deletion here */
272 if (DeviceExtension->TentativeNextState != PciDeleted)
273 PciBeginStateTransition(DeviceExtension, PciDeleted);
274
275 PciCommitStateTransition(DeviceExtension, PciDeleted);
276
277 /* Unlink the bus first so no lookup can reach it while it comes apart */
280
281 for (Entry = &PciFdoExtensionListHead; Entry->Next; Entry = Entry->Next)
282 {
283 if (Entry->Next == &DeviceExtension->List)
284 {
285 Entry->Next = DeviceExtension->List.Next;
286 break;
287 }
288 }
289
290 if (!PCI_IS_ROOT_FDO(DeviceExtension))
291 {
292 BridgeExtension = DeviceExtension->PhysicalDeviceObject->DeviceExtension;
293 ASSERT_PDO(BridgeExtension);
294
295 if (BridgeExtension->BridgeFdoExtension == DeviceExtension)
296 BridgeExtension->BridgeFdoExtension = NULL;
297 }
298
301
302 PciDeleteBusChildren(DeviceExtension);
303 PciFreeBusSecondaryExtensions(DeviceExtension);
304
305 if (DeviceExtension->PreservedConfig)
306 ExFreePoolWithTag(DeviceExtension->PreservedConfig, TAG_PCI_PRESERVED);
307
308 /* The lower drivers see the remove before this device leaves the stack */
309 DeviceObject = DeviceExtension->FunctionalDeviceObject;
310 AttachedDeviceObject = DeviceExtension->AttachedDeviceObject;
311
312 Irp->IoStatus.Status = STATUS_SUCCESS;
313 Status = PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
314
317 return Status;
318}
static VOID NTAPI PciFreeBusSecondaryExtensions(_Inout_ PPCI_FDO_EXTENSION FdoExtension)
Destroys the arbiter instances a bus being removed still holds.
Definition: fdo.c:168
static VOID NTAPI PciDeleteBusChildren(_Inout_ PPCI_FDO_EXTENSION FdoExtension)
Deletes the PDOs of a bus being removed. Each one already had its own remove.
Definition: fdo.c:130
#define TAG_PCI_PRESERVED
Definition: pci.h:37
VOID NTAPI PciCommitStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:181
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
Entry
Definition: section.c:5216
PCI_FDO_EXTENSION * BridgeFdoExtension
Definition: pci.h:372
PDEVICE_OBJECT PhysicalDeviceObject
Definition: pci.h:333
Definition: ntbasedef.h:640
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT AttachedDeviceObject
Definition: wdfminiport.h:70

◆ PciFdoIrpStartDevice()

NTSTATUS NTAPI PciFdoIrpStartDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 202 of file fdo.c.

205{
208 PAGED_CODE();
209
210 /* The device stack must be starting the FDO in a success path */
211 if (!NT_SUCCESS(Irp->IoStatus.Status)) return STATUS_NOT_SUPPORTED;
212
213 /* Attempt to switch the state machine to the started state */
214 Status = PciBeginStateTransition(DeviceExtension, PciStarted);
215 if (!NT_SUCCESS(Status)) return Status;
216
217 /* Only a root bus seeds its arbiters from these, a bus behind a bridge uses its windows */
218 Resources = IoStackLocation->Parameters.StartDevice.AllocatedResources;
219
220 /* Initialize the arbiter for this FDO */
221 Status = PciInitializeArbiterRanges(DeviceExtension, Resources);
222 if (!NT_SUCCESS(Status))
223 {
224 /* Cancel the transition if this failed */
225 PciCancelStateTransition(DeviceExtension, PciStarted);
226 return Status;
227 }
228
229 /* Commit the transition to the started state */
230 PciCommitStateTransition(DeviceExtension, PciStarted);
231 return STATUS_SUCCESS;
232}
NTSTATUS NTAPI PciInitializeArbiterRanges(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCM_RESOURCE_LIST Resources)
Definition: arb_comn.c:447
struct _IO_STACK_LOCATION::@5020::@5057 StartDevice

◆ PciFdoIrpStopDevice()

NTSTATUS NTAPI PciFdoIrpStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 338 of file fdo.c.

341{
342 PAGED_CODE();
343
346
347 PciCommitStateTransition(DeviceExtension, PciStopped);
348
349 /* The next start seeds the arbiters again from the windows it is given */
350 DeviceExtension->ArbitersInitialized = FALSE;
351 return STATUS_SUCCESS;
352}

◆ PciFdoIrpSurpriseRemoval()

NTSTATUS NTAPI PciFdoIrpSurpriseRemoval ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 545 of file fdo.c.

548{
549 PAGED_CODE();
550
553
554 /* Only the remove that follows is left, and it commits the deletion */
556 {
558 PciBeginStateTransition(DeviceExtension, PciDeleted);
559 }
560
561 /* Failing this would keep it from reaching the PDO below */
562 return STATUS_SUCCESS;
563}

◆ PciFdoSetPowerState()

NTSTATUS NTAPI PciFdoSetPowerState ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 318 of file power.c.

321{
323
324 /* Bridge hardware is handled by the PDO below, so only the state is kept */
326 {
327 DeviceExtension->PowerState.CurrentDeviceState = State.DeviceState;
328 return STATUS_SUCCESS;
329 }
330
331 DeviceExtension->PowerState.CurrentSystemState = State.SystemState;
332 if (DeviceExtension->DeviceState != PciStarted)
333 return STATUS_SUCCESS;
334
335 /* The bus owns its power policy and follows up with a device state request */
336 Irp->IoStatus.Status = STATUS_SUCCESS;
341 DeviceExtension,
342 TRUE,
343 TRUE,
344 TRUE);
345 PoCallDriver(DeviceExtension->AttachedDeviceObject, Irp);
346 return STATUS_PENDING;
347}
_Check_return_ _In_ ULONG _In_ DEVICE_POWER_STATE DevicePowerState
Definition: dispmprt.h:1274
static IO_COMPLETION_ROUTINE PciFdoSystemPowerCompletion
Definition: power.c:243
IoMarkIrpPending(Irp)
struct _IO_STACK_LOCATION::@5020::@5056 Power

◆ PciFdoWaitWake()

NTSTATUS NTAPI PciFdoWaitWake ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 305 of file power.c.

308{
310
311 /* Arming the bus for its children's wake requests is not implemented yet */
312 DPRINT1("PCIX - Bus wake arming is not implemented, passing wait-wake down\n");
313 return PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
314}

◆ PciFindNextSecondaryExtension()

PPCI_SECONDARY_EXTENSION NTAPI PciFindNextSecondaryExtension ( IN PSINGLE_LIST_ENTRY  ListHead,
IN PCI_SIGNATURE  ExtensionType 
)

Definition at line 584 of file utils.c.

586{
587 PSINGLE_LIST_ENTRY NextEntry;
589
590 /* Scan the list */
591 for (NextEntry = ListHead; NextEntry; NextEntry = NextEntry->Next)
592 {
593 /* Grab each extension and check if it's the one requested */
595 if (Extension->ExtensionType == ExtensionType) return Extension;
596 }
597
598 /* Nothing was found */
599 return NULL;
600}
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:641
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by ario_ApplyBrokenVideoHack(), PciArbiterConstructor(), and PciInitializeArbiterRanges().

◆ PciFindParentPciFdoExtension()

PPCI_FDO_EXTENSION NTAPI PciFindParentPciFdoExtension ( IN PDEVICE_OBJECT  DeviceObject,
IN PKEVENT  Lock 
)

Definition at line 340 of file utils.c.

342{
343 PPCI_FDO_EXTENSION DeviceExtension;
344 PPCI_PDO_EXTENSION SearchExtension, FoundExtension;
345
346 /* Assume we'll find nothing */
347 SearchExtension = DeviceObject->DeviceExtension;
348 FoundExtension = NULL;
349
350 /* Check if a lock was specified */
351 if (Lock)
352 {
353 /* Wait for the lock to be released */
356 }
357
358 /* Now search for the extension */
360 while (DeviceExtension)
361 {
362 /* Acquire this device's lock */
364 KeWaitForSingleObject(&DeviceExtension->ChildListLock,
365 Executive,
367 FALSE,
368 NULL);
369
370 /* Scan all children PDO, stop when no more PDOs, or found it */
371 for (FoundExtension = DeviceExtension->ChildPdoList;
372 ((FoundExtension) && (FoundExtension != SearchExtension));
373 FoundExtension = FoundExtension->Next);
374
375 /* Release this device's lock */
376 KeSetEvent(&DeviceExtension->ChildListLock, IO_NO_INCREMENT, FALSE);
378
379 /* If we found it, break out */
380 if (FoundExtension) break;
381
382 /* Move to the next device */
383 DeviceExtension = (PPCI_FDO_EXTENSION)DeviceExtension->List.Next;
384 }
385
386 /* Check if we had acquired a lock previously */
387 if (Lock)
388 {
389 /* Release it */
392 }
393
394 /* Return which extension was found, if any */
395 return DeviceExtension;
396}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
SINGLE_LIST_ENTRY List
Definition: pci.h:243
struct _PCI_PDO_EXTENSION * ChildPdoList
Definition: pci.h:253
KEVENT ChildListLock
Definition: pci.h:252
PVOID Next
Definition: pci.h:325
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127

Referenced by PciAddDevice().

◆ PciFindPdoByFunction()

PPCI_PDO_EXTENSION NTAPI PciFindPdoByFunction ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN ULONG  FunctionNumber,
IN PPCI_COMMON_HEADER  PciData 
)

Definition at line 695 of file utils.c.

698{
699 KIRQL Irql;
701
702 /* Get the current IRQL when this call was made */
704
705 /* Is this a low-IRQL call? */
706 if (Irql < DISPATCH_LEVEL)
707 {
708 /* Acquire this device's lock */
710 KeWaitForSingleObject(&DeviceExtension->ChildListLock,
711 Executive,
713 FALSE,
714 NULL);
715 }
716
717 /* Loop every child PDO */
718 for (PdoExtension = DeviceExtension->ChildPdoList;
721 {
722 /* Find only enumerated PDOs */
723 if (!PdoExtension->ReportedMissing)
724 {
725 /* Same slot, and the IDs match as the device's hack flags allow */
726 if ((FunctionNumber == PdoExtension->Slot.u.AsULONG) &&
727 (PcipIsSameDevice(PdoExtension, PciData)))
728 {
729 /* This is considered to be the same PDO */
730 break;
731 }
732 }
733 }
734
735 /* Was this a low-IRQL call? */
736 if (Irql < DISPATCH_LEVEL)
737 {
738 /* Release this device's lock */
739 KeSetEvent(&DeviceExtension->ChildListLock, IO_NO_INCREMENT, FALSE);
741 }
742
743 /* If the search found something, this is non-NULL, otherwise it's NULL */
744 return PdoExtension;
745}
_Out_ PKIRQL Irql
Definition: csq.h:179
BOOLEAN NTAPI PcipIsSameDevice(IN PPCI_PDO_EXTENSION DeviceExtension, IN PPCI_COMMON_HEADER PciData)
Definition: enum.c:1333
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696

Referenced by PciScanBus().

◆ PciFreeLegacyDeviceCache()

VOID NTAPI PciFreeLegacyDeviceCache ( VOID  )

Frees the routing cached for slots claimed by legacy drivers.

Definition at line 357 of file routintf.c.

358{
359 PPCI_LEGACY_DEVICE LegacyDevice;
360 PAGED_CODE();
361
362 while (PciLegacyDeviceHead)
363 {
364 LegacyDevice = PciLegacyDeviceHead;
365 PciLegacyDeviceHead = LegacyDevice->Next;
366 ExFreePoolWithTag(LegacyDevice, TAG_PCI_ROUTING);
367 }
368}

Referenced by PciDriverUnload().

◆ PciGetAdjustedInterruptLine()

UCHAR NTAPI PciGetAdjustedInterruptLine ( IN PPCI_PDO_EXTENSION  PdoExtension)

Definition at line 24 of file config.c.

25{
26 UCHAR InterruptLine = 0, PciInterruptLine;
28
29 /* Does the device have an interrupt pin? */
30 if (PdoExtension->InterruptPin)
31 {
32 /* Find the associated line on the parent bus */
34 PdoExtension->ParentFdoExtension->BaseBus,
35 PdoExtension->Slot.u.AsULONG,
36 &PciInterruptLine,
38 u.type0.InterruptLine),
39 sizeof(UCHAR));
40 if (Length) InterruptLine = PciInterruptLine;
41 }
42
43 /* Either keep the original interrupt line, or the one on the master bus */
44 return InterruptLine ? PdoExtension->RawInterruptLine : InterruptLine;
45}
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
@ PCIConfiguration
Definition: miniport.h:93

Referenced by PciScanBus().

◆ PciGetBiosConfig()

NTSTATUS NTAPI PciGetBiosConfig ( IN PPCI_PDO_EXTENSION  DeviceExtension,
OUT PPCI_COMMON_HEADER  PciData 
)

Definition at line 840 of file utils.c.

842{
845 UNICODE_STRING KeyName, KeyValue;
846 WCHAR Buffer[32];
848 PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PVOID)DataBuffer;
851 PAGED_CODE();
852
853 /* Open the PCI key */
854 Status = IoOpenDeviceRegistryKey(DeviceExtension->ParentFdoExtension->
856 TRUE,
858 &KeyHandle);
859 if (!NT_SUCCESS(Status)) return Status;
860
861 /* Create a volatile BIOS configuration key */
862 RtlInitUnicodeString(&KeyName, L"BiosConfig");
864 &KeyName,
866 KeyHandle,
867 NULL);
868 Status = ZwCreateKey(&SubKeyHandle,
869 KEY_READ,
871 0,
872 NULL,
874 NULL);
876 if (!NT_SUCCESS(Status)) return Status;
877
878 /* Create the key value based on the device and function number */
880 L"DEV_%02x&FUN_%02x",
881 DeviceExtension->Slot.u.bits.DeviceNumber,
882 DeviceExtension->Slot.u.bits.FunctionNumber);
883 RtlInitUnicodeString(&KeyValue, Buffer);
884
885 /* Query the value information (PCI BIOS configuration header) */
886 Status = ZwQueryValueKey(SubKeyHandle,
887 &KeyValue,
889 PartialInfo,
890 sizeof(DataBuffer),
891 &ResultLength);
893 if (!NT_SUCCESS(Status)) return Status;
894
895 /* If any information was returned, go ahead and copy its data */
896 ASSERT(PartialInfo->DataLength == PCI_COMMON_HDR_LENGTH);
897 RtlCopyMemory(PciData, PartialInfo->Data, PCI_COMMON_HDR_LENGTH);
898 return Status;
899}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define _swprintf(buf, format,...)
Definition: sprintf.c:56
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING _Out_ PNDIS_HANDLE SubKeyHandle
Definition: ndis.h:4726
#define KEY_READ
Definition: nt_native.h:1026
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1063
short WCHAR
Definition: pedump.c:58
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2705

Referenced by PciGetBiosBusRange(), PciScanBus(), PPBridge_SaveCurrentSettings(), and routeintrf_UpdateInterruptLine().

◆ PciGetConfigHandlers()

NTSTATUS NTAPI PciGetConfigHandlers ( IN PPCI_FDO_EXTENSION  FdoExtension)

Definition at line 266 of file config.c.

267{
268 PPCI_BUS_INTERFACE_STANDARD PciInterface;
269 PBUS_HANDLER BusHandler;
271
272 ASSERT(FdoExtension->BusHandler == NULL);
273
274 /* Check if this is the FDO for the root bus */
276 {
277 /* Query the PCI Bus Interface that ACPI exposes */
278 ASSERT(FdoExtension->PciBusInterface == NULL);
280 if (!NT_SUCCESS(Status))
281 {
282 /* No ACPI, so Bus Numbers should be maintained by BIOS */
284 }
285 else
286 {
287 /* ACPI detected, PCI Bus Driver will reconfigure bus numbers*/
289
290 /* The driver below owns _OSC and reports what the firmware granted */
291 PciInterface = FdoExtension->PciBusInterface;
293 RootBusCapability)) &&
294 PciInterface->RootBusCapability)
295 {
296 PciInterface->RootBusCapability(PciInterface->Context,
297 &FdoExtension->RootBusHardwareCapability);
298
299 DPRINT1("PCIX - Root bus interface %d, _OSC support 0x%08lx, granted 0x%08lx\n",
300 FdoExtension->RootBusHardwareCapability.SecondaryInterface,
301 FdoExtension->RootBusHardwareCapability.OscFeatureSupport.u.AsULONG,
302 FdoExtension->RootBusHardwareCapability.OscControlGranted.u.AsULONG);
303 }
304 }
305 }
306 else
307 {
308 /* Check if the root bus already has the interface set up */
309 if (FdoExtension->BusRootFdoExtension->PciBusInterface)
310 {
311 /* Nothing for this FDO to do */
312 return STATUS_SUCCESS;
313 }
314
315 /* Fail into case below so we can query the HAL interface */
317 }
318
319 /* If the ACPI PCI Bus Interface couldn't be obtained, try the HAL */
320 if (!NT_SUCCESS(Status))
321 {
322 /* Bus number assignment should be static */
325
326 /* Call the HAL to obtain the bus handler for PCI */
327 BusHandler = HalReferenceHandlerForBus(PCIBus, FdoExtension->BaseBus);
328 FdoExtension->BusHandler = BusHandler;
329
330 /* Fail if the HAL does not have a PCI Bus Handler for this bus */
331 if (!BusHandler) return STATUS_INVALID_DEVICE_REQUEST;
332 }
333
334 /* Appropriate interface was obtained */
335 return STATUS_SUCCESS;
336}
NTSTATUS NTAPI PciQueryForPciBusInterface(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: config.c:177
BOOLEAN PciAssignBusNumbers
Definition: config.c:18
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:684
PCI_ROOT_BUS_CAPABILITY RootBusCapability
Definition: iotypes.h:5348
#define HalReferenceHandlerForBus
Definition: haltypes.h:307

Referenced by PciAddDevice().

◆ PciGetDeviceDescriptionMessage()

PWCHAR NTAPI PciGetDeviceDescriptionMessage ( IN UCHAR  BaseClass,
IN UCHAR  SubClass 
)

Definition at line 105 of file id.c.

107{
110
111 /* The message identifier in the table is encoded based on the PCI class */
112 Identifier = (BaseClass << 8) | SubClass;
113
114 /* Go grab the description message for this device */
116 if (!Message)
117 {
118 /* It wasn't found, allocate a buffer for a generic description */
119 Message = ExAllocatePoolWithTag(PagedPool, sizeof(L"PCI Device"), 'bicP');
120 if (Message) RtlCopyMemory(Message, L"PCI Device", sizeof(L"PCI Device"));
121 }
122
123 /* Return the description message */
124 return Message;
125}
@ Identifier
Definition: asmpp.cpp:103
static const WCHAR Message[]
Definition: register.c:74
PWCHAR NTAPI PciGetDescriptionMessage(IN ULONG Identifier, OUT PULONG Length)
Definition: id.c:21
uint16_t * PWCHAR
Definition: typedefs.h:56

Referenced by PciQueryDeviceText(), and PciScanBus().

◆ PciGetDeviceProperty()

NTSTATUS NTAPI PciGetDeviceProperty ( IN PDEVICE_OBJECT  DeviceObject,
IN DEVICE_REGISTRY_PROPERTY  DeviceProperty,
OUT PVOID *  OutputBuffer 
)

Definition at line 475 of file utils.c.

478{
482 do
483 {
484 /* Query the requested property size */
487 0,
488 NULL,
489 &BufferLength);
491 {
492 /* Call should've failed with buffer too small! */
493 DPRINT1("PCIX - Unexpected status from GetDeviceProperty, saw %08X, expected %08X.\n",
494 Status,
497 ASSERTMSG("PCI Successfully did the impossible!\n", FALSE);
498 break;
499 }
500
501 /* Allocate the required buffer */
503 if (!Buffer)
504 {
505 /* No memory, fail the request */
506 DPRINT1("PCIX - Failed to allocate DeviceProperty buffer (%u bytes).\n", BufferLength);
508 break;
509 }
510
511 /* Do the actual property query call */
515 Buffer,
516 &ResultLength);
517 if (!NT_SUCCESS(Status)) break;
518
519 /* Return the buffer to the caller */
522 return STATUS_SUCCESS;
523 } while (FALSE);
524
525 /* Failure path */
526 return STATUS_UNSUCCESSFUL;
527}
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1382
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY DeviceProperty
Definition: wdfdevice.h:3775
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863

Referenced by PciAddDevice().

◆ PciGetExpressCapabilities()

VOID NTAPI PciGetExpressCapabilities ( _Inout_ PPCI_PDO_EXTENSION  PdoExtension)

Records the Express capability of a new function and whether its extended configuration space can be reached.

Parameters
[in,out]PdoExtensionThe PDO extension of the function being enumerated.

Definition at line 99 of file express.c.

101{
103 PPCI_FDO_EXTENSION ParentFdo;
104 PPCI_PDO_EXTENSION ParentBridge;
106 PAGED_CODE();
107
108 PdoExtension->ExpressCapabilityPtr = 0;
109 PdoExtension->ExpressDeviceType = 0;
110 PdoExtension->IsExtendedConfigReachable = FALSE;
111
112 if (!PdoExtension->CapabilitiesPtr)
113 return;
114
115 if (PdoExtension->HackFlags & PCI_HACK_NO_EXPRESS_CAP)
116 return;
117
118 /* Only the capabilities register is needed */
120 PdoExtension->CapabilitiesPtr,
122 &Express.Header,
124 ExpressCapabilities));
125 if (!Offset)
126 return;
127
128 PdoExtension->ExpressCapabilityPtr = Offset;
129 PdoExtension->ExpressDeviceType = (UCHAR)Express.ExpressCapabilities.DeviceType;
130
131 /* Every bridge between the root and this function has to pass extended config cycles */
132 ParentFdo = PdoExtension->ParentFdoExtension;
133 if (PCI_IS_ROOT_FDO(ParentFdo))
134 {
135 PdoExtension->IsExtendedConfigReachable = PciEcamVerified;
136 }
137 else
138 {
139 ParentBridge = (PPCI_PDO_EXTENSION)ParentFdo->PhysicalDeviceObject->DeviceExtension;
140 ASSERT_PDO(ParentBridge);
141 PdoExtension->IsExtendedConfigReachable = ParentBridge->IsExtendedConfigReachable;
142 }
143
144 DPRINT1("PCIX - Express capability at 0x%x, port type %u, version %u\n",
145 PdoExtension->ExpressCapabilityPtr,
146 PdoExtension->ExpressDeviceType,
148}
BOOLEAN PciEcamVerified
Definition: ecam.c:20
UCHAR NTAPI PciReadDeviceCapability(IN PPCI_PDO_EXTENSION DeviceExtension, IN UCHAR Offset, IN ULONG CapabilityId, OUT PPCI_CAPABILITIES_HEADER Buffer, IN ULONG Length)
Definition: utils.c:958
if(dx< 0)
Definition: linetemp.h:194
#define PCI_HACK_NO_EXPRESS_CAP
Definition: pci.h:30
PCI_CAPABILITIES_HEADER Header
Definition: iotypes.h:5141
PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities
Definition: iotypes.h:5142
PDEVICE_OBJECT PhysicalDeviceObject
Definition: pci.h:249
BOOLEAN IsExtendedConfigReachable
Definition: pci.h:382
#define PCI_CAPABILITY_ID_PCI_EXPRESS
Definition: iotypes.h:3677

Referenced by PciGetEnhancedCapabilities().

◆ PciGetHackFlags()

ULONGLONG NTAPI PciGetHackFlags ( IN USHORT  VendorId,
IN USHORT  DeviceId,
IN USHORT  SubVendorId,
IN USHORT  SubSystemId,
IN UCHAR  RevisionId 
)

Definition at line 604 of file utils.c.

609{
610 PPCI_HACK_ENTRY HackEntry;
612 ULONG LastWeight, MatchWeight;
613 ULONG EntryFlags;
614
615 /* ReactOS SetupLDR Hack */
616 if (!PciHackTable) return 0;
617
618 /* Initialize the variables before looping */
619 LastWeight = 0;
620 HackFlags = 0;
622
623 /* Scan the hack table */
624 for (HackEntry = PciHackTable;
625 HackEntry->VendorID != PCI_INVALID_VENDORID;
626 ++HackEntry)
627 {
628 /* Check if there's an entry for this device */
629 if ((HackEntry->DeviceID == DeviceId) &&
630 (HackEntry->VendorID == VendorId))
631 {
632 /* This is a basic match */
633 EntryFlags = HackEntry->Flags;
634 MatchWeight = 1;
635
636 /* Does the entry have revision information? */
637 if (EntryFlags & PCI_HACK_HAS_REVISION_INFO)
638 {
639 /* Check if the revision matches, if so, this is a better match */
640 if (HackEntry->RevisionID != RevisionId) continue;
641 MatchWeight = 3;
642 }
643
644 /* Does the netry have subsystem information? */
645 if (EntryFlags & PCI_HACK_HAS_SUBSYSTEM_INFO)
646 {
647 /* Check if it matches, if so, this is the best possible match */
648 if ((HackEntry->SubVendorID != SubVendorId) ||
649 (HackEntry->SubSystemID != SubSystemId))
650 {
651 continue;
652 }
653 MatchWeight += 4;
654 }
655
656 /* Is this the best match yet? */
657 if (MatchWeight > LastWeight)
658 {
659 /* This is the best match for now, use this as the hack flags */
660 HackFlags = HackEntry->HackFlags;
661 LastWeight = MatchWeight;
662 }
663 }
664 }
665
666 /* Return the best match */
667 return HackFlags;
668}
PPCI_HACK_ENTRY PciHackTable
Definition: init.c:28
#define PCI_HACK_HAS_REVISION_INFO
Definition: pci.h:61
#define PCI_HACK_HAS_SUBSYSTEM_INFO
Definition: pci.h:62
Definition: pci.h:192
ULONGLONG HackFlags
Definition: pci.h:197
USHORT SubSystemID
Definition: pci.h:196
USHORT VendorID
Definition: pci.h:193
USHORT RevisionID
Definition: pci.h:198
USHORT DeviceID
Definition: pci.h:194
UCHAR Flags
Definition: pci.h:199
USHORT SubVendorID
Definition: pci.h:195
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3616

Referenced by PciScanBus().

◆ PciGetRegistryValue()

NTSTATUS NTAPI PciGetRegistryValue ( IN PWCHAR  ValueName,
IN PWCHAR  KeyName,
IN HANDLE  RootHandle,
IN ULONG  Type,
OUT PVOID *  OutputBuffer,
OUT PULONG  OutputLength 
)

Definition at line 193 of file utils.c.

199{
202 ULONG NeededLength, ActualLength;
203 UNICODE_STRING ValueString;
206
207 /* So we know what to free at the end of the body */
208 PartialInfo = NULL;
209 KeyHandle = NULL;
210 do
211 {
212 /* Open the key by name, rooted off the handle passed */
214 RootHandle,
216 &KeyHandle,
217 &Status);
218 if (!Result) break;
219
220 /* Query for the size that's needed for the value that was passed in */
221 RtlInitUnicodeString(&ValueString, ValueName);
222 Status = ZwQueryValueKey(KeyHandle,
223 &ValueString,
225 NULL,
226 0,
227 &NeededLength);
229 if (Status != STATUS_BUFFER_TOO_SMALL) break;
230
231 /* Allocate an appropriate buffer for the size that was returned */
232 ASSERT(NeededLength != 0);
234 PartialInfo = ExAllocatePoolWithTag(PagedPool,
235 NeededLength,
237 if (!PartialInfo) break;
238
239 /* Query the actual value information now that the size is known */
240 Status = ZwQueryValueKey(KeyHandle,
241 &ValueString,
243 PartialInfo,
244 NeededLength,
245 &ActualLength);
246 if (!NT_SUCCESS(Status)) break;
247
248 /* Make sure it's of the type that the caller expects */
250 if (PartialInfo->Type != Type) break;
251
252 ASSERT(NeededLength == ActualLength);
253 NeededLength = PartialInfo->DataLength;
254
255 /* Allocate a buffer to hold the data and return it to the caller */
258 NeededLength,
260 if (!*OutputBuffer) break;
261
262 /* Copy the data into the buffer and return its length to the caller */
263 RtlCopyMemory(*OutputBuffer, PartialInfo->Data, NeededLength);
264 if (OutputLength) *OutputLength = NeededLength;
266 } while (0);
267
268 /* Close any opened keys and free temporary allocations */
270 if (PartialInfo) ExFreePoolWithTag(PartialInfo, 0);
271 return Status;
272}
BOOLEAN NTAPI PciOpenKey(IN PWCHAR KeyName, IN HANDLE RootKey, IN ACCESS_MASK DesiredAccess, OUT PHANDLE KeyHandle, OUT PNTSTATUS KeyStatus)
Definition: utils.c:166
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by DriverEntry(), PciAcpiFindRsdt(), PciGetDebugPorts(), PciGetIrqRoutingTableFromRegistry(), and PciIsDatacenter().

◆ PciGetResizableBarCapability()

VOID NTAPI PciGetResizableBarCapability ( _Inout_ PPCI_PDO_EXTENSION  PdoExtension)

Records which BARs of a new function can be resized and the sizes each of them supports.

Parameters
[in,out]PdoExtensionThe PDO extension of the function being enumerated.

Definition at line 31 of file rbar.c.

33{
34 PPCI_RESIZABLE_BAR_STATE State = &PdoExtension->ResizableBarState;
36 ULONG Offset, Entry, EntryCount, Control, SizeMask, BarIndex;
37
38 PAGED_CODE();
39
40 RtlZeroMemory(State, sizeof(*State));
41
42 /* Bridges keep their windows after the first two BARs, so only endpoints are resized */
43 if (PdoExtension->HeaderType != PCI_DEVICE_TYPE)
44 return;
45
48 &Header,
49 sizeof(Header));
50 if (!Offset)
51 return;
52
53 /* Only the first control register holds the number of entries */
55 &Control,
57 sizeof(Control));
59 if (EntryCount > PCI_RBAR_MAX_ENTRIES)
60 EntryCount = PCI_RBAR_MAX_ENTRIES;
61
62 State->CapabilityPtr = (USHORT)Offset;
63
64 for (Entry = 0; Entry < EntryCount; Entry++)
65 {
67 &SizeMask,
69 sizeof(SizeMask));
71 &Control,
73 sizeof(Control));
74
77
78 /* Skip entries with no sizes, a BAR that cannot exist, or a BAR already seen */
79 if (!SizeMask ||
80 (BarIndex >= PCI_RBAR_MAX_ENTRIES) ||
81 State->SizeMask[BarIndex])
82 {
83 continue;
84 }
85
86 State->SizeMask[BarIndex] = SizeMask;
87 State->EntryIndex[BarIndex] = (UCHAR)Entry;
88
89 DPRINT1("PCIX - BAR %lu of %p is resizable, sizes 0x%08lx\n",
90 BarIndex, PdoExtension, SizeMask);
91 }
92}
Definition: Header.h:9
#define PCI_RBAR_CONTROL_BAR_INDEX_MASK
Definition: pci.h:102
#define PCI_RBAR_ENTRY_CONTROL(n)
Definition: pci.h:100
#define PCI_RBAR_CAPABILITY_SIZES_SHIFT
Definition: pci.h:101
#define PCI_RBAR_ENTRY_CAPABILITY(n)
Definition: pci.h:99
#define PCI_RBAR_CONTROL_COUNT_SHIFT
Definition: pci.h:104
#define PCI_RBAR_CONTROL_COUNT_MASK
Definition: pci.h:103
#define PCI_RBAR_EXTENDED_CAP_ID
Definition: pci.h:97
ULONG NTAPI PciReadDeviceExtendedCapability(_In_ PPCI_PDO_EXTENSION DeviceExtension, _In_ ULONG CapabilityId, _Out_writes_bytes_(Length) PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Buffer, _In_ ULONG Length)
Finds an extended capability and reads it into the caller's buffer.
Definition: express.c:39
_In_ WDF_WMI_PROVIDER_CONTROL Control
Definition: wdfwmi.h:166
#define PCI_DEVICE_TYPE
Definition: iotypes.h:3620

Referenced by PciGetEnhancedCapabilities().

◆ PciHookHal()

VOID NTAPI PciHookHal ( VOID  )

Definition at line 319 of file hookhal.c.

320{
321 /* Save the old HAL routines */
326
327 /* Take over the HAL's Bus Handler functions */
330}
pHalTranslateBusAddress PcipSavedTranslateBusAddress
Definition: hookhal.c:18
NTSTATUS NTAPI PciAssignSlotResources(_In_ PUNICODE_STRING RegistryPath, _In_opt_ PUNICODE_STRING DriverClassName, _In_ PDRIVER_OBJECT DriverObject, _In_opt_ PDEVICE_OBJECT DeviceObject, _In_ INTERFACE_TYPE BusType, _In_ ULONG BusNumber, _In_ ULONG SlotNumber, _Inout_ PCM_RESOURCE_LIST *AllocatedResources)
Assigns resources to a function claimed by a driver outside of PnP.
Definition: hookhal.c:232
pHalAssignSlotResources PcipSavedAssignSlotResources
Definition: hookhal.c:19
BOOLEAN NTAPI PciTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: hookhal.c:25
#define HalPciTranslateBusAddress
Definition: halfuncs.h:41
#define HalPciAssignSlotResources
Definition: halfuncs.h:42

Referenced by DriverEntry().

◆ PciInitializeArbiterRanges()

NTSTATUS NTAPI PciInitializeArbiterRanges ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCM_RESOURCE_LIST  Resources 
)

Definition at line 447 of file arb_comn.c.

449{
452 PCM_RESOURCE_LIST Ranges;
453 PCI_SIGNATURE ArbiterType;
455
456 /* Arbiters should not already be initialized */
457 if (DeviceExtension->ArbitersInitialized)
458 {
459 /* Duplicated start request, fail initialization */
460 DPRINT1("PCIX - Warning hot start FDOx %p, resource ranges not checked.\n", DeviceExtension);
462 }
463
464 /* A root bus decodes the ranges it was started with */
465 Ranges = Resources;
466
467 /* Check for non-root FDO */
468 if (!PCI_IS_ROOT_FDO(DeviceExtension))
469 {
470 /* Grab the PDO */
471 PdoExtension = (PPCI_PDO_EXTENSION)DeviceExtension->PhysicalDeviceObject->DeviceExtension;
473
474 /* Check if this is a subtractive bus */
475 if (PdoExtension->Dependent.type1.SubtractiveDecode)
476 {
477 /* There is nothing to do regarding arbitration of resources */
478 DPRINT1("PCIX - Skipping arbiter initialization for subtractive bridge FDOX %p\n", DeviceExtension);
479 return STATUS_SUCCESS;
480 }
481
482 /* The start resources hold the bridge's own BARs, the bus only gets what it forwards */
484 if (!Ranges)
486 }
487
488 /* Loop the arbiters that hand out the ranges a bus decodes */
489 for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_Memory; ArbiterType++)
490 {
491 /* Find an arbiter of this type */
492 Instance = (PVOID)PciFindNextSecondaryExtension(DeviceExtension->
493 SecondaryExtension.Next,
494 ArbiterType);
495 if (Instance)
496 {
497 /* The decoded ranges bound what the arbiter may hand out */
498 Status = Instance->CommonInstance.StartArbiter(&Instance->CommonInstance,
499 Ranges);
500 if (!NT_SUCCESS(Status))
501 {
502 DPRINT1("PCIX - FDO ext 0x%p %s arbiter failed to start: %X\n",
503 DeviceExtension,
504 PciArbiterNames[ArbiterType - PciArb_Io],
505 Status);
506 goto Exit;
507 }
508
509 /* An empty seed leaves everything open, but a bridge without the range forwards none */
510 if (!PCI_IS_ROOT_FDO(DeviceExtension) &&
511 !PciHasRangeOfType(Ranges, (UCHAR)Instance->CommonInstance.ResourceType))
512 {
513 ArbiterLibReserveRange(&Instance->CommonInstance,
514 0,
516 NULL,
517 FALSE);
518 }
519 }
520 else
521 {
522 /* The arbiter was not found, this is an error! */
523 DPRINT1("PCIX - FDO ext 0x%p %s arbiter (REQUIRED) is missing.\n",
524 DeviceExtension,
525 PciArbiterNames[ArbiterType - PciArb_Io]);
526 }
527 }
528
529 /* Arbiters are now initialized */
530 DeviceExtension->ArbitersInitialized = TRUE;
532
533Exit:
534 if (Ranges != Resources)
536
537 return Status;
538}
static PCM_RESOURCE_LIST NTAPI PciCollectForwardedRanges(_In_ PPCI_PDO_EXTENSION BridgeExtension)
Builds a resource list of the ranges a PCI-to-PCI bridge forwards to its secondary bus.
Definition: arb_comn.c:343
static BOOLEAN NTAPI PciHasRangeOfType(_In_ PCM_RESOURCE_LIST RangeList, _In_ UCHAR Type)
Tells whether a resource list holds any range of one resource type.
Definition: arb_comn.c:423
#define ARBITER_MAXIMUM_ADDRESS
Definition: arbiter.h:13
VOID NTAPI ArbiterLibReserveRange(_In_ PARBITER_INSTANCE Arbiter, _In_ ULONGLONG Start, _In_ ULONGLONG End, _In_opt_ PVOID Owner, _In_ BOOLEAN Shared)
Commits a single [Start, End] range into the arbiter as an ordinary allocation owned by Owner.
Definition: handler.c:533
static void Exit(void)
Definition: sock.c:1330

Referenced by PciFdoIrpStartDevice().

◆ PciInitializeArbiters()

NTSTATUS NTAPI PciInitializeArbiters ( IN PPCI_FDO_EXTENSION  FdoExtension)

Definition at line 242 of file arb_comn.c.

243{
244 PPCI_INTERFACE CurrentInterface, *Interfaces;
246 PPCI_ARBITER_INSTANCE ArbiterInterface;
248 PCI_SIGNATURE ArbiterType;
250
251 /* A bus that ends up needing no arbiter at all is not a failure */
253
254 /* A subtractive bus has no arbiters of its own, requests fall through to the parent's */
256 {
257 /* Get the PDO extension */
258 PdoExtension = FdoExtension->PhysicalDeviceObject->DeviceExtension;
260
261 if (PdoExtension->Dependent.type1.SubtractiveDecode)
262 {
263 DPRINT1("PCIX - Not creating arbiters for subtractive bus 0x%x\n",
264 FdoExtension->BaseBus);
265 return STATUS_SUCCESS;
266 }
267 }
268
269 /* Loop all the arbiters */
270 for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_BusNumber; ArbiterType++)
271 {
272 /* Query all the registered arbiter interfaces */
273 Interfaces = PciInterfaces;
274 while (*Interfaces)
275 {
276 /* Find the one that matches the arbiter currently being setup */
277 CurrentInterface = *Interfaces;
278 if (CurrentInterface->Signature == ArbiterType) break;
279 Interfaces++;
280 }
281
282 /* Check if the required arbiter was not found in the list */
283 if (!*Interfaces)
284 {
285 /* Skip this arbiter and try the next one */
286 DPRINT1("PCIX - FDO ext 0x%p no %s arbiter.\n",
288 PciArbiterNames[ArbiterType - PciArb_Io]);
289 continue;
290 }
291
292 /* An arbiter was found, allocate an instance for it */
294 ArbiterInterface = ExAllocatePoolWithTag(PagedPool,
295 sizeof(PCI_ARBITER_INSTANCE),
297 if (!ArbiterInterface) break;
298
299 /* Setup the instance */
300 ArbiterInterface->BusFdoExtension = FdoExtension;
301 ArbiterInterface->Interface = CurrentInterface;
302 _swprintf(ArbiterInterface->InstanceName,
303 L"PCI %S (b=%02x)",
304 PciArbiterNames[ArbiterType - PciArb_Io],
305 FdoExtension->BaseBus);
306
307 /* Call the interface initializer for it */
308 Status = CurrentInterface->Initializer(ArbiterInterface);
309 if (!NT_SUCCESS(Status)) break;
310
311 /* Link it with this FDO */
312 PcipLinkSecondaryExtension(&FdoExtension->SecondaryExtension,
313 &FdoExtension->SecondaryExtLock,
314 &ArbiterInterface->Header,
315 ArbiterType,
317
318 /* This arbiter is now initialized, move to the next one */
319 DPRINT1("PCIX - FDO ext 0x%p %S arbiter initialized (context 0x%p).\n",
321 L"ARBITER HEADER MISSING", //ArbiterInterface->CommonInstance.Name,
322 ArbiterInterface);
324 }
325
326 /* Return to caller */
327 return Status;
328}
VOID NTAPI PciArbiterDestructor(IN PPCI_ARBITER_INSTANCE Arbiter)
Definition: arb_comn.c:233
VOID NTAPI PcipLinkSecondaryExtension(IN PSINGLE_LIST_ENTRY List, IN PVOID Lock, IN PPCI_SECONDARY_EXTENSION SecondaryExtension, IN PCI_SIGNATURE ExtensionType, IN PVOID Destructor)
Definition: utils.c:459
PPCI_INTERFACE PciInterfaces[]
Definition: intrface.c:18
PCI_SECONDARY_EXTENSION Header
Definition: pci.h:468
PPCI_INTERFACE Interface
Definition: pci.h:469
PCI_SIGNATURE Signature
Definition: pci.h:448
PCI_INTERFACE_INITIALIZER Initializer
Definition: pci.h:450

Referenced by PciAddDevice().

◆ PciInitializeEcam()

VOID NTAPI PciInitializeEcam ( _In_ PPCI_FDO_EXTENSION  FdoExtension)

Maps the bus an FDO decodes into the ECAM window and verifies the window the first time a bus with devices on it is seen.

Parameters
[in]FdoExtensionThe FDO extension of the bus being started.

Definition at line 336 of file ecam.c.

338{
340 PAGED_CODE();
341
343 {
345
347 if (!NT_SUCCESS(Status))
348 {
349 DPRINT1("PCIX - No ECAM window available (0x%lx)\n", Status);
350 return;
351 }
352
353#if defined(_M_IX86) || defined(_M_AMD64)
354 PciEcamSkipK8Northbridge = PciEcamIsAmdK8();
355#endif
356 DPRINT1("PCIX - ECAM window at 0x%I64x for 0x%lx buses\n",
359 }
360
361 if (!PciEcamMapBus(FdoExtension->BaseBus) || PciEcamVerified) return;
362
363 /* An empty bus proves nothing, so leave it to the next one */
366 {
368 }
369 else if (NT_SUCCESS(Status))
370 {
372 DPRINT1("PCIX - ECAM verified on bus 0x%lx\n", FdoExtension->BaseBus);
373 }
374}
static BOOLEAN PciEcamSkipK8Northbridge
Definition: ecam.c:23
static VOID NTAPI PciEcamDiscardWindow(VOID)
Definition: ecam.c:184
static ULONG PciEcamWindowBuses
Definition: ecam.c:25
static PUCHAR NTAPI PciEcamMapBus(_In_ ULONG Bus)
Definition: ecam.c:162
static NTSTATUS NTAPI PciEcamQueryWindow(VOID)
Definition: ecam.c:74
static ULONGLONG PciEcamWindowStart
Definition: ecam.c:24
static NTSTATUS NTAPI PciEcamVerifyBus(_In_ PPCI_FDO_EXTENSION FdoExtension)
Definition: ecam.c:287
static BOOLEAN PciEcamWindowQueried
Definition: ecam.c:22
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:713

Referenced by PciAddDevice().

◆ PciInitializeState()

VOID NTAPI PciInitializeState ( IN PPCI_FDO_EXTENSION  DeviceExtension)

Definition at line 88 of file state.c.

89{
90 /* Set the initial state */
91 DeviceExtension->DeviceState = PciNotStarted;
92 DeviceExtension->TentativeNextState = PciNotStarted;
93}

Referenced by PciInitializeFdoExtensionCommonFields(), and PciPdoCreate().

◆ PciInsertEntryAtTail()

VOID NTAPI PciInsertEntryAtTail ( IN PSINGLE_LIST_ENTRY  ListHead,
IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PKEVENT  Lock 
)

Definition at line 400 of file utils.c.

403{
404 PSINGLE_LIST_ENTRY NextEntry;
405 PAGED_CODE();
406
407 /* Check if a lock was specified */
408 if (Lock)
409 {
410 /* Wait for the lock to be released */
413 }
414
415 /* Loop the list until we get to the end, then insert this entry there */
416 for (NextEntry = ListHead; NextEntry->Next; NextEntry = NextEntry->Next);
417 NextEntry->Next = &DeviceExtension->List;
418
419 /* Check if we had acquired a lock previously */
420 if (Lock)
421 {
422 /* Release it */
425 }
426}

Referenced by PciAddDevice(), and PciPdoCreate().

◆ PciIrpInvalidDeviceRequest()

NTSTATUS NTAPI PciIrpInvalidDeviceRequest ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 277 of file dispatch.c.

280{
283 UNREFERENCED_PARAMETER(DeviceExtension);
284
285 /* Not supported */
287}

◆ PciIrpNotSupported()

NTSTATUS NTAPI PciIrpNotSupported ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_FDO_EXTENSION  DeviceExtension 
)

Definition at line 261 of file dispatch.c.

264{
267 UNREFERENCED_PARAMETER(DeviceExtension);
268
269 /* Not supported */
270 DPRINT1("PCIX - Received unsupported IRP!\n");
271 //DbgBreakPoint();
273}

◆ PciIsCriticalDeviceClass()

BOOLEAN NTAPI PciIsCriticalDeviceClass ( IN UCHAR  BaseClass,
IN UCHAR  SubClass 
)

Definition at line 672 of file utils.c.

674{
675 /* Check for system or bridge devices */
676 if (BaseClass == PCI_CLASS_BASE_SYSTEM_DEV)
677 {
678 /* Interrupt controllers are critical */
679 return SubClass == PCI_SUBCLASS_SYS_INTERRUPT_CTLR;
680 }
681 else if (BaseClass == PCI_CLASS_BRIDGE_DEV)
682 {
683 /* ISA Bridges are critical */
684 return SubClass == PCI_SUBCLASS_BR_ISA;
685 }
686 else
687 {
688 /* All display controllers are critical */
689 return BaseClass == PCI_CLASS_DISPLAY_CTLR;
690 }
691}
#define PCI_SUBCLASS_SYS_INTERRUPT_CTLR
Definition: iotypes.h:4194
#define PCI_CLASS_BASE_SYSTEM_DEV
Definition: iotypes.h:4126

Referenced by PciScanBus().

◆ PciIsDatacenter()

BOOLEAN NTAPI PciIsDatacenter ( VOID  )

Definition at line 132 of file utils.c.

133{
135 PVOID Value;
138
139 /* Assume this isn't Datacenter */
140 Result = FALSE;
141
142 /* First, try opening the setup key */
144 L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\setupdd",
145 0,
147 &Value,
148 &ResultLength);
149 if (!NT_SUCCESS(Status))
150 {
151 /* This is not an in-progress Setup boot, so query the suite version */
153 }
154 else
155 {
156 /* This scenario shouldn't happen yet, since SetupDD isn't used */
157 UNIMPLEMENTED_FATAL("ReactOS doesn't use SetupDD for its installation program. Therefore this scenario must not happen!\n");
158 }
159
160 /* Return if this is Datacenter or not */
161 return Result;
162}
BOOLEAN NTAPI PciIsSuiteVersion(IN USHORT SuiteMask)
Definition: utils.c:115
NTSTATUS NTAPI PciGetRegistryValue(IN PWCHAR ValueName, IN PWCHAR KeyName, IN HANDLE RootHandle, IN ULONG Type, OUT PVOID *OutputBuffer, OUT PULONG OutputLength)
Definition: utils.c:193
#define REG_BINARY
Definition: nt_native.h:1499
#define VER_SUITE_DATACENTER
#define UNIMPLEMENTED_FATAL(...)
Definition: debug.h:244
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by DriverEntry().

◆ PciIsDeviceOnDebugPath()

BOOLEAN NTAPI PciIsDeviceOnDebugPath ( IN PPCI_PDO_EXTENSION  DeviceExtension)

Referenced by PciScanBus().

◆ PciIsRequirementDescriptor()

BOOLEAN NTAPI PciIsRequirementDescriptor ( _In_ PIO_RESOURCE_DESCRIPTOR  Limit)

Tells whether a discovered limit asks the arbiter for a range.

Parameters
[in]LimitThe limit of one BAR or bridge window.
Returns
TRUE when the limit has a type and a length. A bridge window has no length of its own.

Definition at line 671 of file enum.c.

673{
674 if (Limit->Type == CmResourceTypeNull)
675 return FALSE;
676
677 return (Limit->u.Generic.Length != 0);
678}

Referenced by Device_ChangeResourceSettings(), PciBuildRequirementsList(), and PciComputeNewCurrentSettings().

◆ PciIsSlotPresentInParentMethod()

BOOLEAN NTAPI PciIsSlotPresentInParentMethod ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN ULONG  Method 
)

Definition at line 1169 of file utils.c.

1171{
1172 BOOLEAN FoundSlot;
1176 ULONG i, Length;
1178 PAGED_CODE();
1179
1180 /* Assume slot is not part of the parent method */
1181 FoundSlot = FALSE;
1182
1183 /* Allocate a 2KB buffer for the method return parameters */
1184 Length = sizeof(ACPI_EVAL_OUTPUT_BUFFER) + 2048;
1186 if (OutputBuffer)
1187 {
1188 /* Clear out the output buffer */
1190
1191 /* Initialize the input buffer with the method requested */
1192 InputBuffer.Signature = 0;
1193 *(PULONG)InputBuffer.MethodName = Method;
1195
1196 /* Send it to the ACPI driver */
1197 Status = PciSendIoctl(PdoExtension->ParentFdoExtension->PhysicalDeviceObject,
1199 &InputBuffer,
1200 sizeof(ACPI_EVAL_INPUT_BUFFER),
1202 Length);
1203 if (NT_SUCCESS(Status))
1204 {
1205 /* Scan all output arguments */
1206 for (i = 0; i < OutputBuffer->Count; i++)
1207 {
1208 /* Make sure it's an integer */
1209 Argument = &OutputBuffer->Argument[i];
1210 if (Argument->Type != ACPI_METHOD_ARGUMENT_INTEGER) continue;
1211
1212 /* Check if the argument matches this PCI slot structure */
1213 if (Argument->Argument == ((PdoExtension->Slot.u.bits.DeviceNumber) |
1214 ((PdoExtension->Slot.u.bits.FunctionNumber) << 16)))
1215 {
1216 /* This slot has been found, return it */
1217 FoundSlot = TRUE;
1218 break;
1219 }
1220 }
1221 }
1222
1223 /* Finished with the buffer, free it */
1225 }
1226
1227 /* Return if the slot was found */
1228 return FoundSlot;
1229}
ACPI_METHOD_ARGUMENT UNALIGNED * PACPI_METHOD_ARGUMENT
Definition: acpiioct.h:80
struct _ACPI_EVAL_OUTPUT_BUFFER ACPI_EVAL_OUTPUT_BUFFER
#define ACPI_METHOD_ARGUMENT_INTEGER
Definition: acpiioct.h:30
#define ACPI_EVAL_INPUT_BUFFER_SIGNATURE
Definition: acpiioct.h:12
#define IOCTL_ACPI_EVAL_METHOD
Definition: acpiioct.h:194
ACPI_EVAL_OUTPUT_BUFFER UNALIGNED * PACPI_EVAL_OUTPUT_BUFFER
Definition: acpiioct.h:99
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG _In_ PVOID Argument
Definition: dispmprt.h:1288
NTSTATUS NTAPI PciSendIoctl(IN PDEVICE_OBJECT DeviceObject, IN ULONG IoControlCode, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength)
Definition: utils.c:531
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953

Referenced by PciApplyHacks(), and PciBridgeIsPositiveDecode().

◆ PciOpenKey()

BOOLEAN NTAPI PciOpenKey ( IN PWCHAR  KeyName,
IN HANDLE  RootKey,
IN ACCESS_MASK  DesiredAccess,
OUT PHANDLE  KeyHandle,
OUT PNTSTATUS  KeyStatus 
)

Definition at line 166 of file utils.c.

171{
174 UNICODE_STRING KeyString;
175 PAGED_CODE();
176
177 /* Initialize the object attributes */
178 RtlInitUnicodeString(&KeyString, KeyName);
180 &KeyString,
182 RootKey,
183 NULL);
184
185 /* Open the key, returning a boolean, and the status, if requested */
187 if (KeyStatus) *KeyStatus = Status;
188 return NT_SUCCESS(Status);
189}
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static PMEMKEY RootKey
Definition: registry.c:55
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2664

Referenced by DriverEntry(), PciAcpiFindRsdt(), PciEcamQueryWindow(), PciGetIrqRoutingTableFromRegistry(), and PciGetRegistryValue().

◆ PciPassIrpFromFdoToPdo()

NTSTATUS NTAPI PciPassIrpFromFdoToPdo ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PIRP  Irp 
)

Definition at line 70 of file dispatch.c.

72{
75 DPRINT("PCIX - PassIrp ...\n");
76
77 /* Get the stack location to check which function this is */
80 {
81 /* Power IRPs are special since we have to notify the Power Manager */
84 Status = PoCallDriver(DeviceExtension->AttachedDeviceObject, Irp);
85 }
86 else
87 {
88 /* For a normal IRP, just call the next driver in the stack */
90 Status = IoCallDriver(DeviceExtension->AttachedDeviceObject, Irp);
91 }
92
93 /* Return the status back to the caller */
94 return Status;
95}
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

Referenced by PciDispatchIrp(), PciFdoIrpQueryInterface(), PciFdoIrpRemoveDevice(), and PciFdoWaitWake().

◆ PciPdoCreate()

NTSTATUS NTAPI PciPdoCreate ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCI_SLOT_NUMBER  Slot,
OUT PDEVICE_OBJECT *  PdoDeviceObject 
)

Definition at line 1022 of file pdo.c.

1025{
1026 WCHAR DeviceName[32];
1027 UNICODE_STRING DeviceString;
1031 ULONG SequenceNumber;
1032 PAGED_CODE();
1033
1034 /* Pick an atomically unique sequence number for this device */
1035 SequenceNumber = InterlockedIncrement(&PciPdoSequenceNumber);
1036
1037 /* Create the standard PCI device name for a PDO */
1038 _swprintf(DeviceName, L"\\Device\\NTPNP_PCI%04d", SequenceNumber);
1039 RtlInitUnicodeString(&DeviceString, DeviceName);
1040
1041 /* Create the actual device now */
1042 Status = IoCreateDevice(DeviceExtension->FunctionalDeviceObject->DriverObject,
1043 sizeof(PCI_PDO_EXTENSION),
1044 &DeviceString,
1046 0,
1047 0,
1048 &DeviceObject);
1050
1051 /* Get the extension for it */
1052 PdoExtension = (PPCI_PDO_EXTENSION)DeviceObject->DeviceExtension;
1053 DPRINT1("PCIX - New PDO (b=0x%x, d=0x%x, f=0x%x) @ %p, ext @ %p\n",
1054 DeviceExtension->BaseBus,
1055 Slot.u.bits.DeviceNumber,
1056 Slot.u.bits.FunctionNumber,
1058 DeviceObject->DeviceExtension);
1059
1060 /* Configure the extension */
1061 PdoExtension->ExtensionType = PciPdoExtensionType;
1062 PdoExtension->IrpDispatchTable = &PciPdoDispatchTable;
1063 PdoExtension->PhysicalDeviceObject = DeviceObject;
1064 PdoExtension->Slot = Slot;
1065 PdoExtension->PowerState.CurrentSystemState = PowerSystemWorking;
1066 PdoExtension->PowerState.CurrentDeviceState = PowerDeviceD0;
1067 PdoExtension->ParentFdoExtension = DeviceExtension;
1068
1069 /* Initialize the lock for arbiters and other interfaces */
1071
1072 /* Initialize the state machine */
1074
1075 /* Add the PDO to the parent's list */
1076 PdoExtension->Next = NULL;
1077 PciInsertEntryAtTail((PSINGLE_LIST_ENTRY)&DeviceExtension->ChildPdoList,
1079 &DeviceExtension->ChildListLock);
1080
1081 /* And finally return it to the caller */
1083 return STATUS_SUCCESS;
1084}
PCI_MJ_DISPATCH_TABLE PciPdoDispatchTable
Definition: pdo.c:63
LONG PciPdoSequenceNumber
Definition: pdo.c:18
VOID NTAPI PciInitializeState(IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: state.c:88
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT _In_ PUSB_PORT_PATH _Out_ PUSB_CD_ERROR_INFORMATION _In_ USHORT _In_ PDEVICE_OBJECT PdoDeviceObject
Definition: hubbusif.h:95
@ PowerDeviceD0
Definition: ntpoapi.h:49
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281

Referenced by PciScanBus().

◆ PciPdoIrpCancelRemoveDevice()

NTSTATUS NTAPI PciPdoIrpCancelRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 597 of file pdo.c.

600{
601 PAGED_CODE();
602
605
606 /* The remove is off, so the device stays where it was */
608 return STATUS_SUCCESS;
609}

◆ PciPdoIrpCancelStopDevice()

NTSTATUS NTAPI PciPdoIrpCancelStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 655 of file pdo.c.

658{
659 PAGED_CODE();
660
663
664 /* The stop is off, so the device keeps what it has */
665 PciCancelStateTransition((PVOID)DeviceExtension, PciStopped);
666 return STATUS_SUCCESS;
667}

◆ PciPdoIrpDeviceUsageNotification()

NTSTATUS NTAPI PciPdoIrpDeviceUsageNotification ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 956 of file pdo.c.

959{
961 PAGED_CODE();
962
964
965 /* Every bus up to the root has to hold on to the path, so it goes up first */
966 Status = PciSendDeviceUsageToParent(DeviceExtension->ParentFdoExtension,
968 if (!NT_SUCCESS(Status))
969 return Status;
970
971 return PciUpdateDeviceUsage(&DeviceExtension->PowerState, IoStackLocation);
972}
NTSTATUS NTAPI PciSendDeviceUsageToParent(_In_ PPCI_FDO_EXTENSION ParentFdoExtension, _In_ PIO_STACK_LOCATION IoStackLocation)
Sends a device usage notification to the top of the stack of a parent bus.
Definition: usage.c:94

◆ PciPdoIrpQueryBusInformation()

NTSTATUS NTAPI PciPdoIrpQueryBusInformation ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 809 of file pdo.c.

812{
813 PAGED_CODE();
814
816
817 /* Call the worker function */
818 return PciQueryBusInformation(DeviceExtension,
820 IoStatus.Information);
821}
NTSTATUS NTAPI PciQueryBusInformation(IN PPCI_PDO_EXTENSION PdoExtension, OUT PPNP_BUS_INFORMATION *Buffer)
Definition: utils.c:1408
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159

◆ PciPdoIrpQueryCapabilities()

NTSTATUS NTAPI PciPdoIrpQueryCapabilities ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 731 of file pdo.c.

734{
735 PAGED_CODE();
736
738
739 /* Call the worker function */
740 return PciQueryCapabilities(DeviceExtension,
742 Parameters.DeviceCapabilities.Capabilities);
743}
_In_ HANDLE _In_ CONST PDXGKMDT_OPM_GET_INFO_PARAMETERS Parameters
Definition: dispmprt.h:321
NTSTATUS NTAPI PciQueryCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_CAPABILITIES DeviceCapability)
Definition: utils.c:1820

◆ PciPdoIrpQueryDeviceRelations()

NTSTATUS NTAPI PciPdoIrpQueryDeviceRelations ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 697 of file pdo.c.

700{
702 PAGED_CODE();
703
704 /* Are ejection relations being queried? */
706 {
707 /* Call the worker function */
708 Status = PciQueryEjectionRelations(DeviceExtension,
710 IoStatus.Information);
711 }
713 {
714 /* The only other relation supported is the target device relation */
715 Status = PciQueryTargetDeviceRelations(DeviceExtension,
717 IoStatus.Information);
718 }
719 else
720 {
721 /* All other relations are unsupported */
723 }
724
725 /* Return either the result of the worker function, or unsupported status */
726 return Status;
727}
NTSTATUS NTAPI PciQueryEjectionRelations(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: enum.c:614
NTSTATUS NTAPI PciQueryTargetDeviceRelations(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: enum.c:552
@ EjectionRelations
Definition: iotypes.h:2155
@ TargetDeviceRelation
Definition: iotypes.h:2158

◆ PciPdoIrpQueryDeviceState()

NTSTATUS NTAPI PciPdoIrpQueryDeviceState ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 930 of file pdo.c.

933{
935 PAGED_CODE();
936
938
939 /* Whatever the rest of the stack decided about this device still holds */
940 State = (PNP_DEVICE_STATE)Irp->IoStatus.Information;
941
942 /* Host bridges, and anything a query remove would refuse, must not be offered for disabling */
943 if (((DeviceExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
944 (DeviceExtension->SubClass == PCI_SUBCLASS_BR_HOST)) ||
945 (!NT_SUCCESS(PciPdoValidateRelease(DeviceExtension))))
946 {
948 }
949
950 Irp->IoStatus.Information = State;
951 return STATUS_SUCCESS;
952}
static NTSTATUS NTAPI PciPdoValidateRelease(_In_ PPCI_PDO_EXTENSION DeviceExtension)
Checks the uses of a function that keep it from being stopped or removed.
Definition: pdo.c:268
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:1006
ULONG PNP_DEVICE_STATE
Definition: iotypes.h:997

◆ PciPdoIrpQueryDeviceText()

NTSTATUS NTAPI PciPdoIrpQueryDeviceText ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 778 of file pdo.c.

781{
782 PAGED_CODE();
783
784 /* Call the worker function */
785 return PciQueryDeviceText(DeviceExtension,
787 Parameters.QueryDeviceText.DeviceTextType,
790 (PWCHAR*)&Irp->IoStatus.Information);
791}
NTSTATUS NTAPI PciQueryDeviceText(IN PPCI_PDO_EXTENSION PdoExtension, IN DEVICE_TEXT_TYPE QueryType, IN ULONG Locale, OUT PWCHAR *Buffer)
Definition: id.c:422
struct _IO_STACK_LOCATION::@5020::@5052 QueryDeviceText

◆ PciPdoIrpQueryId()

NTSTATUS NTAPI PciPdoIrpQueryId ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 795 of file pdo.c.

798{
799 PAGED_CODE();
800
801 /* Call the worker function */
802 return PciQueryId(DeviceExtension,
804 (PWCHAR*)&Irp->IoStatus.Information);
805}
NTSTATUS NTAPI PciQueryId(IN PPCI_PDO_EXTENSION DeviceExtension, IN BUS_QUERY_ID_TYPE QueryType, OUT PWCHAR *Buffer)
Definition: id.c:217
struct _IO_STACK_LOCATION::@5020::@5051 QueryId

◆ PciPdoIrpQueryInterface()

NTSTATUS NTAPI PciPdoIrpQueryInterface ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 671 of file pdo.c.

674{
676 PAGED_CODE();
677
679
680 /* Query the interface from the PCI driver */
682 (PPCI_FDO_EXTENSION)DeviceExtension,
686 IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData,
688 FALSE);
689
690 /* TODO: There's more to this story, but NOT TODAY! */
691
692 return Status;
693}

◆ PciPdoIrpQueryLegacyBusInformation()

NTSTATUS NTAPI PciPdoIrpQueryLegacyBusInformation ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 1006 of file pdo.c.

1009{
1010 PAGED_CODE();
1011
1014 UNREFERENCED_PARAMETER(DeviceExtension);
1015
1016 /* A bridge's FDO answers above this, so keep its bus number and buffer intact */
1017 return STATUS_NOT_SUPPORTED;
1018}

◆ PciPdoIrpQueryPower()

NTSTATUS NTAPI PciPdoIrpQueryPower ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 144 of file pdo.c.

147{
150 UNREFERENCED_PARAMETER(DeviceExtension);
151
152 /* Every device state is accepted when set, so none is refused here */
153 return STATUS_SUCCESS;
154}

◆ PciPdoIrpQueryRemoveDevice()

NTSTATUS NTAPI PciPdoIrpQueryRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 534 of file pdo.c.

537{
539 PAGED_CODE();
540
543
544 if (DeviceExtension->HackFlags & PCI_HACK_FAIL_QUERY_REMOVE)
545 return STATUS_DEVICE_BUSY;
546
547 Status = PciPdoValidateRelease(DeviceExtension);
548 if (!NT_SUCCESS(Status))
549 return Status;
550
551 /* A function that was never started has no state to leave */
552 if (DeviceExtension->DeviceState == PciNotStarted)
553 return STATUS_SUCCESS;
554
555 return PciBeginStateTransition((PVOID)DeviceExtension, PciNotStarted);
556}
#define PCI_HACK_FAIL_QUERY_REMOVE
Definition: pci.h:47

◆ PciPdoIrpQueryResourceRequirements()

NTSTATUS NTAPI PciPdoIrpQueryResourceRequirements ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 762 of file pdo.c.

765{
766 PAGED_CODE();
767
769
770 /* Call the worker function */
771 return PciQueryRequirements(DeviceExtension,
773 IoStatus.Information);
774}
NTSTATUS NTAPI PciQueryRequirements(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *RequirementsList)
Definition: enum.c:882

◆ PciPdoIrpQueryResources()

NTSTATUS NTAPI PciPdoIrpQueryResources ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 747 of file pdo.c.

750{
751 PAGED_CODE();
752
754
755 /* Call the worker function */
756 return PciQueryResources(DeviceExtension,
757 (PCM_RESOURCE_LIST*)&Irp->IoStatus.Information);
758}
NTSTATUS NTAPI PciQueryResources(IN PPCI_PDO_EXTENSION PdoExtension, OUT PCM_RESOURCE_LIST *Buffer)
Definition: enum.c:389

◆ PciPdoIrpQueryStopDevice()

NTSTATUS NTAPI PciPdoIrpQueryStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 632 of file pdo.c.

635{
637 PAGED_CODE();
638
641
642 Status = PciPdoValidateRelease(DeviceExtension);
643 if (!NT_SUCCESS(Status))
644 return Status;
645
646 /* New resources are useless if the old ranges keep decoding */
647 if (!PciPdoCanTurnOff(DeviceExtension))
649
650 return PciBeginStateTransition((PVOID)DeviceExtension, PciStopped);
651}
static BOOLEAN NTAPI PciPdoCanTurnOff(_In_ PPCI_PDO_EXTENSION DeviceExtension)
Checks whether a function may stop decoding for as long as it is stopped or removed.
Definition: pdo.c:300

◆ PciPdoIrpReadConfig()

NTSTATUS NTAPI PciPdoIrpReadConfig ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 908 of file pdo.c.

911{
912 PAGED_CODE();
913
914 return PciPdoReadWriteConfig(Irp, IoStackLocation, DeviceExtension, TRUE);
915}
static NTSTATUS NTAPI PciPdoReadWriteConfig(_Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IoStackLocation, _In_ PPCI_PDO_EXTENSION DeviceExtension, _In_ BOOLEAN Read)
Serves a driver's read or write of its own function's configuration space.
Definition: pdo.c:836

◆ PciPdoIrpRemoveDevice()

NTSTATUS NTAPI PciPdoIrpRemoveDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 560 of file pdo.c.

563{
564 PAGED_CODE();
565
568
569 if (PciPdoIsPresent(DeviceExtension))
570 PciPdoTurnOff(DeviceExtension, TRUE);
571
572 /* A remove without a query still has to take a started function out of that state */
573 if ((DeviceExtension->DeviceState == PciStarted) &&
574 (DeviceExtension->TentativeNextState == PciStarted))
575 {
577 }
578
579 if ((DeviceExtension->DeviceState != PciNotStarted) &&
580 (DeviceExtension->TentativeNextState == PciNotStarted))
581 {
583 }
584
585 /* A function that left the bus will not come back through this PDO */
586 if ((DeviceExtension->ReportedMissing) &&
588 {
589 PciCommitStateTransition((PVOID)DeviceExtension, PciDeleted);
590 }
591
592 return STATUS_SUCCESS;
593}
static VOID NTAPI PciPdoTurnOff(_Inout_ PPCI_PDO_EXTENSION DeviceExtension, _In_ BOOLEAN PowerDown)
Stops a function from decoding, mastering and raising interrupts, and optionally moves it to D3.
Definition: pdo.c:353
static BOOLEAN NTAPI PciPdoIsPresent(_Inout_ PPCI_PDO_EXTENSION DeviceExtension)
Reads the identity back from the slot to learn whether the function is still there.
Definition: pdo.c:320

◆ PciPdoIrpStartDevice()

NTSTATUS NTAPI PciPdoIrpStartDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 158 of file pdo.c.

161{
163 BOOLEAN Changed, DoReset;
165 PAGED_CODE();
166
168
169 DoReset = FALSE;
170
171 /* Begin entering the start phase */
172 Status = PciBeginStateTransition((PVOID)DeviceExtension, PciStarted);
173 if (!NT_SUCCESS(Status)) return Status;
174
175 /* Check if this is a VGA device */
176 if (((DeviceExtension->BaseClass == PCI_CLASS_PRE_20) &&
177 (DeviceExtension->SubClass == PCI_SUBCLASS_PRE_20_VGA)) ||
178 ((DeviceExtension->BaseClass == PCI_CLASS_DISPLAY_CTLR) &&
179 (DeviceExtension->SubClass == PCI_SUBCLASS_VID_VGA_CTLR)))
180 {
181 /* Always force it on */
182 DeviceExtension->CommandEnables |= (PCI_ENABLE_IO_SPACE |
184 }
185
186 /* Check if native IDE is enabled and it owns the I/O ports */
187 if (DeviceExtension->IoSpaceUnderNativeIdeControl)
188 {
189 /* Then don't allow I/O access */
190 DeviceExtension->CommandEnables &= ~PCI_ENABLE_IO_SPACE;
191 }
192
193 /* Always enable bus mastering */
194 DeviceExtension->CommandEnables |= PCI_ENABLE_BUS_MASTER;
195
196 /* Check if the OS assigned resources differ from the PCI configuration */
197 Changed = PciComputeNewCurrentSettings(DeviceExtension,
199 StartDevice.AllocatedResources);
200 if (Changed)
201 {
202 /* Remember this for later */
203 DeviceExtension->MovedDevice = TRUE;
204 }
205 else
206 {
207 /* All good */
208 DPRINT1("PCIX - START not changing resource settings.\n");
209 }
210
211 /* Check if the device was sleeping */
212 if (DeviceExtension->PowerState.CurrentDeviceState != PowerDeviceD0)
213 {
214 /* Power it up */
217 FALSE);
218 if (!NT_SUCCESS(Status))
219 {
220 /* Powerup fail, fail the request */
221 PciCancelStateTransition((PVOID)DeviceExtension, PciStarted);
223 }
224
225 /* Tell the power manager that the device is powered up */
226 PowerState.DeviceState = PowerDeviceD0;
227 PoSetPowerState(DeviceExtension->PhysicalDeviceObject,
229 PowerState);
230
231 /* Update internal state */
232 DeviceExtension->PowerState.CurrentDeviceState = PowerDeviceD0;
233
234 /* This device's resources and decodes will need to be reset */
235 DoReset = TRUE;
236 }
237
238 /* Update resource information now that the device is powered up and active */
239 Status = PciSetResources(DeviceExtension, DoReset, TRUE);
240 if (!NT_SUCCESS(Status))
241 {
242 /* That failed, so cancel the transition */
243 PciCancelStateTransition((PVOID)DeviceExtension, PciStarted);
244 }
245 else
246 {
247 /* Fully commit, as the device is now started up and ready to go */
248 PciCommitStateTransition((PVOID)DeviceExtension, PciStarted);
249 }
250
251 /* Return the result of the start request */
252 return Status;
253}
NTSTATUS NTAPI PciSetResources(IN PPCI_PDO_EXTENSION PdoExtension, IN BOOLEAN DoReset, IN BOOLEAN SomethingSomethingDarkSide)
Definition: enum.c:2490
BOOLEAN NTAPI PciComputeNewCurrentSettings(IN PPCI_PDO_EXTENSION PdoExtension, IN PCM_RESOURCE_LIST ResourceList)
Definition: enum.c:55
NTSTATUS NTAPI PciSetPowerManagedDevicePowerState(IN PPCI_PDO_EXTENSION DeviceExtension, IN DEVICE_POWER_STATE DeviceState, IN BOOLEAN IrpSet)
Definition: power.c:123
static BOOL StartDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DevInfoData OPTIONAL, IN BOOL bEnable, IN DWORD HardwareProfile OPTIONAL, OUT BOOL *bNeedReboot OPTIONAL)
Definition: wizard.c:173
POWER_STATE NTAPI PoSetPowerState(IN PDEVICE_OBJECT DeviceObject, IN POWER_STATE_TYPE Type, IN POWER_STATE State)
Definition: power.c:729
#define STATUS_DEVICE_POWER_FAILURE
Definition: ntstatus.h:488
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3040

◆ PciPdoIrpStopDevice()

NTSTATUS NTAPI PciPdoIrpStopDevice ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 613 of file pdo.c.

616{
617 PAGED_CODE();
618
621
622 /* The device is losing its resources, so it must stop using them first */
623 PciPdoTurnOff(DeviceExtension, FALSE);
624
625 /* The query stop that has to come first already began the transition */
626 PciCommitStateTransition((PVOID)DeviceExtension, PciStopped);
627 return STATUS_SUCCESS;
628}

◆ PciPdoIrpSurpriseRemoval()

NTSTATUS NTAPI PciPdoIrpSurpriseRemoval ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 976 of file pdo.c.

979{
980 PAGED_CODE();
981
984
985 /* This also comes after a failed start, with the function still in its slot */
986 if (PciPdoIsPresent(DeviceExtension))
987 PciPdoTurnOff(DeviceExtension, TRUE);
988
989 if (DeviceExtension->ReportedMissing)
990 {
991 /* The slot is empty, so only the remove is left to come */
994 }
995 else if (DeviceExtension->DeviceState != PciNotStarted)
996 {
997 /* The remove that follows commits this */
999 }
1000
1001 return STATUS_SUCCESS;
1002}

◆ PciPdoIrpWriteConfig()

NTSTATUS NTAPI PciPdoIrpWriteConfig ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 919 of file pdo.c.

922{
923 PAGED_CODE();
924
925 return PciPdoReadWriteConfig(Irp, IoStackLocation, DeviceExtension, FALSE);
926}

◆ PciPdoSetPowerState()

NTSTATUS NTAPI PciPdoSetPowerState ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 104 of file pdo.c.

107{
110
111 /* The function driver follows a system state with a device state request of its own */
113 {
114 DeviceExtension->PowerState.CurrentSystemState = State.SystemState;
115 return STATUS_SUCCESS;
116 }
117
118 if ((State.DeviceState < PowerDeviceD0) || (State.DeviceState > PowerDeviceD3))
120
121 if (State.DeviceState == DeviceExtension->PowerState.CurrentDeviceState)
122 return STATUS_SUCCESS;
123
124 /* Configuration cycles cannot reach a function on a bus that is not running */
125 if (DeviceExtension->ParentFdoExtension->DeviceState != PciStarted)
127
129 return PciPdoEnterDevicePowerState(DeviceExtension, State.DeviceState);
130
131 /* D0 may be sent at DISPATCH_LEVEL, and reprogramming the function needs PASSIVE_LEVEL */
132 WorkItem = IoAllocateWorkItem(DeviceExtension->PhysicalDeviceObject);
133 if (!WorkItem)
135
136 Irp->Tail.Overlay.DriverContext[0] = WorkItem;
139 return STATUS_PENDING;
140}
static IO_WORKITEM_ROUTINE PciPdoDevicePowerWorker
Definition: pdo.c:84
static NTSTATUS NTAPI PciPdoEnterDevicePowerState(_Inout_ PPCI_PDO_EXTENSION DeviceExtension, _In_ DEVICE_POWER_STATE DeviceState)
Moves a function to a device power state and reports it to the power manager.
Definition: pdo.c:451
_In_opt_ PVOID _In_ PUCXHUB_WORKITEM WorkItem
Definition: hubucx.h:227
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
@ PowerDeviceD3
Definition: ntpoapi.h:52
@ DelayedWorkQueue
Definition: extypes.h:190
_In_ SYSTEM_POWER_STATE SystemPowerState
Definition: iotypes.h:7535

◆ PciPdoWaitWake()

NTSTATUS NTAPI PciPdoWaitWake ( IN PIRP  Irp,
IN PIO_STACK_LOCATION  IoStackLocation,
IN PPCI_PDO_EXTENSION  DeviceExtension 
)

Definition at line 88 of file pdo.c.

91{
93 UNREFERENCED_PARAMETER(DeviceExtension);
94
95 /* PME is never armed, so the function cannot wake the system */
96 Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
100}

◆ PcipIsSameDevice()

BOOLEAN NTAPI PcipIsSameDevice ( _In_ PPCI_PDO_EXTENSION  DeviceExtension,
_In_ PPCI_COMMON_HEADER  PciData 
)

◆ PcipLinkSecondaryExtension()

VOID NTAPI PcipLinkSecondaryExtension ( IN PSINGLE_LIST_ENTRY  List,
IN PVOID  Lock,
IN PPCI_SECONDARY_EXTENSION  SecondaryExtension,
IN PCI_SIGNATURE  ExtensionType,
IN PVOID  Destructor 
)

Definition at line 459 of file utils.c.

464{
465 PAGED_CODE();
466
467 /* Setup the extension data, and insert it into the primary's list */
468 SecondaryExtension->ExtensionType = ExtensionType;
469 SecondaryExtension->Destructor = Destructor;
470 PciInsertEntryAtHead(List, &SecondaryExtension->List, Lock);
471}
VOID NTAPI PciInsertEntryAtHead(IN PSINGLE_LIST_ENTRY ListHead, IN PSINGLE_LIST_ENTRY Entry, IN PKEVENT Lock)
Definition: utils.c:430

Referenced by PciInitializeArbiters().

◆ PciPmeInterfaceConstructor()

NTSTATUS NTAPI PciPmeInterfaceConstructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 74 of file pmeintf.c.

80{
81 PPCI_PME_INTERFACE PmeInterface;
82
84 UNREFERENCED_PARAMETER(InterfaceData);
86
87 PAGED_CODE();
88
89 if (Size < sizeof(PCI_PME_INTERFACE))
90 {
92 }
93
94 PmeInterface = (PPCI_PME_INTERFACE)Interface;
95 PmeInterface->Size = sizeof(*PmeInterface);
96 PmeInterface->Version = PCI_PME_INTRF_STANDARD_VER;
97 PmeInterface->Context = DeviceExtension;
101
102 return STATUS_SUCCESS;
103}
VOID NTAPI PciPmeInterface_Dereference(IN PVOID Context)
Definition: pmeintf.c:54
VOID NTAPI PciPmeInterface_Reference(IN PVOID Context)
Definition: pmeintf.c:45
VOID NTAPI PciPmeInterface_UpdateEnable(IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN Enable)
Definition: pmeintf.c:63
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: iotypes.h:5588
PINTERFACE_REFERENCE InterfaceReference
Definition: iotypes.h:5587
PPME_SET_PME_ENABLE UpdateEnable
Definition: iotypes.h:5591
struct _PCI_PME_INTERFACE * PPCI_PME_INTERFACE
#define PCI_PME_INTRF_STANDARD_VER
Definition: iotypes.h:5535

◆ PciPmeInterfaceInitializer()

NTSTATUS NTAPI PciPmeInterfaceInitializer ( IN PVOID  Instance)

Definition at line 35 of file pmeintf.c.

36{
38 /* PnP Interfaces don't get Initialized */
39 ASSERTMSG("PCI PciPmeInterfaceInitializer, unexpected call.\n", FALSE);
41}

◆ PciQueryBusInformation()

NTSTATUS NTAPI PciQueryBusInformation ( IN PPCI_PDO_EXTENSION  PdoExtension,
OUT PPNP_BUS_INFORMATION *  Buffer 
)

Definition at line 1408 of file utils.c.

1410{
1411 PPNP_BUS_INFORMATION BusInfo;
1412
1413 /* Allocate a structure for the bus information */
1415 sizeof(PNP_BUS_INFORMATION),
1416 'BicP');
1417 if (!BusInfo) return STATUS_INSUFFICIENT_RESOURCES;
1418
1419 /* Write the correct GUID and bus type identifier, and fill the bus number */
1420 BusInfo->BusTypeGuid = GUID_BUS_TYPE_PCI;
1421 BusInfo->LegacyBusType = PCIBus;
1422 BusInfo->BusNumber = PdoExtension->ParentFdoExtension->BaseBus;
1423
1424 *Buffer = BusInfo;
1425
1426 return STATUS_SUCCESS;
1427}
INTERFACE_TYPE LegacyBusType
Definition: cmtypes.h:366

Referenced by PciPdoIrpQueryBusInformation().

◆ PciQueryCapabilities()

NTSTATUS NTAPI PciQueryCapabilities ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN OUT PDEVICE_CAPABILITIES  DeviceCapability 
)

Definition at line 1820 of file utils.c.

1822{
1824
1825 /* A PDO ID is never unique, and its address is its function and device */
1826 DeviceCapability->UniqueID = FALSE;
1827 DeviceCapability->Address = PdoExtension->Slot.u.bits.FunctionNumber |
1828 (PdoExtension->Slot.u.bits.DeviceNumber << 16);
1829
1830 /* Check for host bridges */
1831 if ((PdoExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
1832 (PdoExtension->SubClass == PCI_SUBCLASS_BR_HOST))
1833 {
1834 /* Raw device opens to a host bridge are acceptable */
1835 DeviceCapability->RawDeviceOK = TRUE;
1836 }
1837 else
1838 {
1839 /* Otherwise, other PDOs cannot be directly opened */
1840 DeviceCapability->RawDeviceOK = FALSE;
1841 }
1842
1843 /* PCI PDOs are pretty fixed things */
1844 DeviceCapability->LockSupported = FALSE;
1845 DeviceCapability->EjectSupported = FALSE;
1846 DeviceCapability->Removable = FALSE;
1847 DeviceCapability->DockDevice = FALSE;
1848
1849 /* The slot number is stored as a device property, go query it */
1850 PciDetermineSlotNumber(PdoExtension, &DeviceCapability->UINumber);
1851
1852 /* Finally, query and power capabilities and convert them for PnP usage */
1853 Status = PciQueryPowerCapabilities(PdoExtension, DeviceCapability);
1854
1855 /* Dump the capabilities if it all worked, and return the status */
1856 if (NT_SUCCESS(Status)) PciDebugDumpQueryCapabilities(DeviceCapability);
1857 return Status;
1858}
NTSTATUS NTAPI PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, IN PDEVICE_CAPABILITIES DeviceCapability)
Definition: utils.c:1570
NTSTATUS NTAPI PciDetermineSlotNumber(IN PPCI_PDO_EXTENSION PdoExtension, OUT PULONG SlotNumber)
Definition: utils.c:1431

Referenced by PciPdoIrpQueryCapabilities().

◆ PciQueryDeviceRelations()

NTSTATUS NTAPI PciQueryDeviceRelations ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN OUT PDEVICE_RELATIONS *  pDeviceRelations 
)

Definition at line 2366 of file enum.c.

2368{
2371 ULONG PdoCount = 0;
2372 PDEVICE_RELATIONS DeviceRelations, NewRelations;
2373 SIZE_T Size;
2374 PDEVICE_OBJECT DeviceObject, *ObjectArray;
2375 PAGED_CODE();
2376
2377 /* Make sure the FDO is started */
2378 ASSERT(DeviceExtension->DeviceState == PciStarted);
2379
2380 /* Synchronize while we enumerate the bus */
2382 if (!NT_SUCCESS(Status)) return Status;
2383
2384 /* Scan all children PDO */
2385 for (PdoExtension = DeviceExtension->ChildPdoList;
2387 PdoExtension = PdoExtension->Next)
2388 {
2389 /* Invalidate them */
2390 PdoExtension->NotPresent = TRUE;
2391 }
2392
2393 /* Scan the PCI Bus */
2394 Status = PciScanBus(DeviceExtension);
2396
2397 /* Enumerate all children PDO again */
2398 for (PdoExtension = DeviceExtension->ChildPdoList;
2400 PdoExtension = PdoExtension->Next)
2401 {
2402 /* Check for PDOs that are still invalidated */
2403 if (PdoExtension->NotPresent)
2404 {
2405 /* This means this PDO existed before, but not anymore */
2406 PdoExtension->ReportedMissing = TRUE;
2407 DPRINT1("PCIX - Old device (pdox) %p not found on rescan.\n",
2408 PdoExtension);
2409 }
2410 else
2411 {
2412 /* Increase count of detected PDOs */
2413 PdoCount++;
2414 }
2415 }
2416
2417 /* Read the current relations and add the newly discovered relations */
2418 DeviceRelations = *pDeviceRelations;
2419 Size = FIELD_OFFSET(DEVICE_RELATIONS, Objects) +
2420 PdoCount * sizeof(PDEVICE_OBJECT);
2421 if (DeviceRelations) Size += sizeof(PDEVICE_OBJECT) * DeviceRelations->Count;
2422
2423 /* Allocate the device relations */
2424 NewRelations = (PDEVICE_RELATIONS)ExAllocatePoolWithTag(0, Size, 'BicP');
2425 if (!NewRelations)
2426 {
2427 /* Out of space, cancel the operation */
2430 }
2431
2432 /* Check if there were any older relations */
2433 NewRelations->Count = 0;
2434 if (DeviceRelations)
2435 {
2436 /* Copy the old relations into the new buffer, then free the old one */
2437 RtlCopyMemory(NewRelations,
2438 DeviceRelations,
2439 FIELD_OFFSET(DEVICE_RELATIONS, Objects) +
2440 DeviceRelations->Count * sizeof(PDEVICE_OBJECT));
2441 ExFreePoolWithTag(DeviceRelations, 0);
2442 }
2443
2444 /* Print out that we're ready to dump relations */
2445 DPRINT("PCIX - QueryDeviceRelations/BusRelations FDOx %p (bus 0x%02x)\n",
2446 DeviceExtension,
2447 DeviceExtension->BaseBus);
2448
2449 /* Loop the current PDO children and the device relation object array */
2450 PdoExtension = DeviceExtension->ChildPdoList;
2451 ObjectArray = &NewRelations->Objects[NewRelations->Count];
2452 while (PdoExtension)
2453 {
2454 /* Dump this relation */
2455 DPRINT(" QDR PDO %p (x %p)%s\n",
2456 PdoExtension->PhysicalDeviceObject,
2458 PdoExtension->NotPresent ?
2459 "<Omitted, device flaged not present>" : "");
2460
2461 /* Is this PDO present? */
2462 if (!PdoExtension->NotPresent)
2463 {
2464 /* Reference it and add it to the array */
2465 DeviceObject = PdoExtension->PhysicalDeviceObject;
2467 *ObjectArray++ = DeviceObject;
2468 }
2469
2470 /* Go to the next PDO */
2471 PdoExtension = PdoExtension->Next;
2472 }
2473
2474 /* Terminate dumping the relations */
2475 DPRINT(" QDR Total PDO count = %u (%u already in list)\n",
2476 NewRelations->Count + PdoCount,
2477 NewRelations->Count);
2478
2479 /* Return the final count and the new buffer */
2480 NewRelations->Count += PdoCount;
2481 *pDeviceRelations = NewRelations;
2482
2483 /* Let later rescans and PnP state changes begin their own transitions */
2485 return STATUS_SUCCESS;
2486}
NTSTATUS NTAPI PciScanBus(IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: enum.c:1879
struct _DEVICE_OBJECT * PDEVICE_OBJECT
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2165
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by PciFdoIrpQueryDeviceRelations().

◆ PciQueryDeviceText()

NTSTATUS NTAPI PciQueryDeviceText ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN DEVICE_TEXT_TYPE  QueryType,
IN ULONG  Locale,
OUT PWCHAR *  Buffer 
)

Definition at line 422 of file id.c.

426{
427 PWCHAR MessageBuffer, LocationBuffer;
430
432
433 /* Check what the caller is requesting */
434 switch (QueryType)
435 {
437
438 /* Get the message from the resource section */
439 MessageBuffer = PciGetDeviceDescriptionMessage(PdoExtension->BaseClass,
440 PdoExtension->SubClass);
441
442 /* Return it to the caller, and select proper status code */
443 *Buffer = MessageBuffer;
444 Status = MessageBuffer ? STATUS_SUCCESS : STATUS_NOT_SUPPORTED;
445 break;
446
448
449 /* Get the message from the resource section */
450 MessageBuffer = PciGetDescriptionMessage(0x10000, &Length);
451 if (!MessageBuffer)
452 {
453 /* It should be there, but fail if it wasn't found for some reason */
455 break;
456 }
457
458 /* Add space for a null-terminator, and allocate the buffer */
459 Length += 2 * sizeof(UNICODE_NULL);
460 LocationBuffer = ExAllocatePoolWithTag(PagedPool,
461 Length * sizeof(WCHAR),
462 'BicP');
463 *Buffer = LocationBuffer;
464
465 /* Check if the allocation succeeded */
466 if (LocationBuffer)
467 {
468 /* Build the location string based on bus, function, and device */
469 _swprintf(LocationBuffer,
470 MessageBuffer,
471 PdoExtension->ParentFdoExtension->BaseBus,
472 PdoExtension->Slot.u.bits.FunctionNumber,
473 PdoExtension->Slot.u.bits.DeviceNumber);
474 }
475
476 /* Free the original string from the resource section */
477 ExFreePoolWithTag(MessageBuffer, 0);
478
479 /* Select the correct status */
481 break;
482
483 default:
484
485 /* Anything else is unsupported */
487 break;
488 }
489
490 /* Return whether or not a device text string was indeed found */
491 return Status;
492}
PWCHAR NTAPI PciGetDeviceDescriptionMessage(IN UCHAR BaseClass, IN UCHAR SubClass)
Definition: id.c:105
#define UNICODE_NULL
_Must_inspect_result_ _In_ KTMOBJECT_TYPE QueryType
Definition: nttmapi.h:404
@ DeviceTextLocationInformation
Definition: iotypes.h:2961
@ DeviceTextDescription
Definition: iotypes.h:2960

Referenced by PciPdoIrpQueryDeviceText().

◆ PciQueryEjectionRelations()

NTSTATUS NTAPI PciQueryEjectionRelations ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN OUT PDEVICE_RELATIONS *  pDeviceRelations 
)

Definition at line 614 of file enum.c.

616{
617 PPCI_FDO_EXTENSION FdoExtension = PdoExtension->ParentFdoExtension;
618 PDEVICE_RELATIONS OldRelations = *pDeviceRelations;
619 PDEVICE_RELATIONS NewRelations = NULL;
620 ULONG OldCount = OldRelations ? OldRelations->Count : 0;
621 ULONG FunctionCount;
622 PAGED_CODE();
623
626
627 /* The other functions of the same device leave the machine with this one */
628 FunctionCount = PciGatherOtherFunctions(PdoExtension, NULL);
629 if (FunctionCount)
630 {
631 NewRelations = ExAllocatePoolWithTag(NonPagedPool,
633 (OldCount + FunctionCount) * sizeof(*NewRelations->Objects),
635 }
636
637 /* Without memory the list from above is kept as it is */
638 if (NewRelations)
639 {
640 if (OldRelations)
641 {
642 RtlCopyMemory(NewRelations->Objects,
643 OldRelations->Objects,
644 OldCount * sizeof(*OldRelations->Objects));
645 ExFreePoolWithTag(OldRelations, 0);
646 }
647
648 NewRelations->Count = OldCount +
649 PciGatherOtherFunctions(PdoExtension, &NewRelations->Objects[OldCount]);
650 ASSERT(NewRelations->Count == OldCount + FunctionCount);
651 *pDeviceRelations = NewRelations;
652 }
653
654 KeSetEvent(&FdoExtension->ChildListLock, IO_NO_INCREMENT, FALSE);
656 return STATUS_SUCCESS;
657}
#define NonPagedPool
Definition: env_spec_w32.h:307

Referenced by PciPdoIrpQueryDeviceRelations().

◆ PciQueryId()

NTSTATUS NTAPI PciQueryId ( IN PPCI_PDO_EXTENSION  DeviceExtension,
IN BUS_QUERY_ID_TYPE  QueryType,
OUT PWCHAR *  Buffer 
)

Definition at line 217 of file id.c.

220{
221 ULONG SubsysId;
222 CHAR VendorString[22];
224 PPCI_FDO_EXTENSION ParentExtension;
226 ULONG i, Size;
228 PANSI_STRING NextString;
230 PCI_ID_BUFFER IdBuffer;
231 PAGED_CODE();
232
233 /* Assume failure */
235 *Buffer = NULL;
236
237 /* Start with the genric vendor string, which is the vendor ID + device ID */
238 sprintf(VendorString,
239 "PCI\\VEN_%04X&DEV_%04X",
240 DeviceExtension->VendorId,
241 DeviceExtension->DeviceId);
242
243 /* Initialize the PCI ID Buffer */
244 PciInitIdBuffer(&IdBuffer);
245
246 /* Build the subsystem ID as shown in PCI ID Strings */
247 SubsysId = DeviceExtension->SubsystemVendorId | (DeviceExtension->SubsystemId << 16);
248
249 /* Check what the caller is requesting */
250 switch (QueryType)
251 {
252 case BusQueryDeviceID:
253
254 /* A single ID, the vendor string + the revision ID */
255 PciIdPrintf(&IdBuffer,
256 "%s&SUBSYS_%08X&REV_%02X",
257 VendorString,
258 SubsysId,
259 DeviceExtension->RevisionId);
260 break;
261
263
264 /* First the vendor string + the subsystem ID + the revision ID */
265 PciIdPrintf(&IdBuffer,
266 "%s&SUBSYS_%08X&REV_%02X",
267 VendorString,
268 SubsysId,
269 DeviceExtension->RevisionId);
270
271 /* Next, without the revision */
272 PciIdPrintf(&IdBuffer,
273 "%s&SUBSYS_%08X",
274 VendorString,
275 SubsysId);
276
277 /* Next, the vendor string + the base class + sub class + progif */
278 PciIdPrintf(&IdBuffer,
279 "%s&CC_%02X%02X%02X",
280 VendorString,
281 DeviceExtension->BaseClass,
282 DeviceExtension->SubClass,
283 DeviceExtension->ProgIf);
284
285 /* Next, without the progif */
286 PciIdPrintf(&IdBuffer,
287 "%s&CC_%02X%02X",
288 VendorString,
289 DeviceExtension->BaseClass,
290 DeviceExtension->SubClass);
291
292 /* And finally, a terminator */
293 PciIdPrintf(&IdBuffer, "\0");
294 break;
295
297
298 /* First, the vendor + revision ID only */
299 PciIdPrintf(&IdBuffer,
300 "%s&REV_%02X",
301 VendorString,
302 DeviceExtension->RevisionId);
303
304 /* Next, the vendor string alone */
305 PciIdPrintf(&IdBuffer, "%s", VendorString);
306
307 /* Next, the vendor ID + the base class + the sub class + progif */
308 PciIdPrintf(&IdBuffer,
309 "PCI\\VEN_%04X&CC_%02X%02X%02X",
310 DeviceExtension->VendorId,
311 DeviceExtension->BaseClass,
312 DeviceExtension->SubClass,
313 DeviceExtension->ProgIf);
314
315 /* Now without the progif */
316 PciIdPrintf(&IdBuffer,
317 "PCI\\VEN_%04X&CC_%02X%02X",
318 DeviceExtension->VendorId,
319 DeviceExtension->BaseClass,
320 DeviceExtension->SubClass);
321
322 /* And then just the vendor ID itself */
323 PciIdPrintf(&IdBuffer,
324 "PCI\\VEN_%04X",
325 DeviceExtension->VendorId);
326
327 /* Then the base class + subclass + progif, without any vendor */
328 PciIdPrintf(&IdBuffer,
329 "PCI\\CC_%02X%02X%02X",
330 DeviceExtension->BaseClass,
331 DeviceExtension->SubClass,
332 DeviceExtension->ProgIf);
333
334 /* Next, without the progif */
335 PciIdPrintf(&IdBuffer,
336 "PCI\\CC_%02X%02X",
337 DeviceExtension->BaseClass,
338 DeviceExtension->SubClass);
339
340 /* And finally, a terminator */
341 PciIdPrintf(&IdBuffer, "\0");
342 break;
343
345
346 /* Start with a terminator */
347 PciIdPrintf(&IdBuffer, "\0");
348
349 /* And then encode the device and function number */
350 PciIdPrintfAppend(&IdBuffer,
351 "%02X",
352 (DeviceExtension->Slot.u.bits.DeviceNumber << 3) |
353 DeviceExtension->Slot.u.bits.FunctionNumber);
354
355 /* Loop every parent until the root */
356 ParentExtension = DeviceExtension->ParentFdoExtension;
357 while (!PCI_IS_ROOT_FDO(ParentExtension))
358 {
359 /* Two more digits and their terminator have to fit */
360 if ((IdBuffer.CharBuffer + 2) >
361 (IdBuffer.BufferData + sizeof(IdBuffer.BufferData)))
362 {
363 DPRINT1("PCIX - Bridge chain too deep for an instance ID\n");
365 }
366
367 /* And encode the parent's device and function number as well */
369 PciIdPrintfAppend(&IdBuffer,
370 "%02X",
371 (PdoExtension->Slot.u.bits.DeviceNumber << 3) |
372 PdoExtension->Slot.u.bits.FunctionNumber);
373
374 /* Move up to the next bridge */
375 ParentExtension = PdoExtension->ParentFdoExtension;
376 }
377 break;
378
379 default:
380
381 /* Unknown query type */
382 DPRINT1("PCIX - PciQueryId expected ID type = %d\n", QueryType);
384 }
385
386 /* Something should've been generated if this has been reached */
387 ASSERT(IdBuffer.Count > 0);
388
389 /* Allocate the final string buffer to hold the ID */
392
393 /* Build the UNICODE_STRING structure for it */
394 DPRINT("PCIX - PciQueryId(%d)\n", QueryType);
397
398 /* Loop every ID in the buffer */
399 for (i = 0; i < IdBuffer.Count; i++)
400 {
401 /* Select the ANSI_STRING for the ID */
402 NextString = &IdBuffer.Strings[i];
403 DPRINT(" <- \"%s\"\n", NextString->Buffer);
404
405 /* Convert it to a UNICODE_STRING */
408
409 /* Add it into the final destination buffer */
410 Size = IdBuffer.StringSize[i];
412 DestinationString.Buffer += (Size / sizeof(WCHAR));
413 }
414
415 /* Return the buffer to the caller and return status (should be success) */
417 return Status;
418}
ULONG __cdecl PciIdPrintfAppend(IN PPCI_ID_BUFFER IdBuffer, IN PCCH Format,...)
Definition: id.c:176
VOID NTAPI PciInitIdBuffer(IN PPCI_ID_BUFFER IdBuffer)
Definition: id.c:129
ULONG __cdecl PciIdPrintf(IN PPCI_ID_BUFFER IdBuffer, IN PCCH Format,...)
Definition: id.c:139
WCHAR StringBuffer[156]
Definition: ldrinit.c:41
#define sprintf
Definition: sprintf.c:45
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1956
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
char CHAR
Definition: pedump.c:57
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
struct _PCI_FDO_EXTENSION * ParentFdoExtension
Definition: pci.h:255
ULONG Count
Definition: pci.h:491
ULONG StringSize[MAX_ANSI_STRINGS]
Definition: pci.h:493
CHAR BufferData[256]
Definition: pci.h:496
ANSI_STRING Strings[MAX_ANSI_STRINGS]
Definition: pci.h:492
ULONG TotalLength
Definition: pci.h:494
PCHAR CharBuffer
Definition: pci.h:495
void * Buffer
Definition: sprintf.c:453
unsigned short MaximumLength
Definition: sprintf.c:452
@ BusQueryCompatibleIDs
Definition: iotypes.h:2953
@ BusQueryInstanceID
Definition: iotypes.h:2954
@ BusQueryDeviceID
Definition: iotypes.h:2951
@ BusQueryHardwareIDs
Definition: iotypes.h:2952

Referenced by PciPdoIrpQueryId().

◆ PciQueryInterface()

NTSTATUS NTAPI PciQueryInterface ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN CONST GUID *  InterfaceType,
IN ULONG  Size,
IN ULONG  Version,
IN PVOID  InterfaceData,
IN PINTERFACE  Interface,
IN BOOLEAN  LastChance 
)

Definition at line 45 of file intrface.c.

52{
56 PPCI_INTERFACE PciInterface;
58 DPRINT("PCIX - PciQueryInterface TYPE = %wZ\n", &GuidString);
60 DPRINT(" Size = %u, Version = %u, InterfaceData = %p, LastChance = %s\n",
61 Size,
62 Version,
63 InterfaceData,
64 LastChance ? "TRUE" : "FALSE");
65
66 /* Loop all the available interfaces */
70 {
71 /* Get the current interface */
72 PciInterface = *InterfaceList;
73
74 /* For debugging, construct the GUID string */
76
77 /* Check if this is an FDO or PDO */
78 if (DeviceExtension->ExtensionType == PciFdoExtensionType)
79 {
80 /* Check if the interface is for FDOs */
81 if (!(PciInterface->Flags & PCI_INTERFACE_FDO))
82 {
83 /* This interface is not for FDOs, skip it */
84 DPRINT("PCIX - PciQueryInterface guid = %wZ not for FDOs\n",
85 &GuidString);
87 continue;
88 }
89
90 /* Check if the interface is for root FDO only */
91 if ((PciInterface->Flags & PCI_INTERFACE_ROOT) &&
92 (!PCI_IS_ROOT_FDO(DeviceExtension)))
93 {
94 /* This FDO isn't the root, skip the interface */
95 DPRINT("PCIX - PciQueryInterface guid = %wZ only for ROOT\n",
96 &GuidString);
98 continue;
99 }
100 }
101 else
102 {
103 /* This is a PDO, check if the interface is for PDOs too */
104 if (!(PciInterface->Flags & PCI_INTERFACE_PDO))
105 {
106 /* It isn't, skip it */
107 DPRINT("PCIX - PciQueryInterface guid = %wZ not for PDOs\n",
108 &GuidString);
110 continue;
111 }
112 }
113
114 /* Print the GUID for debugging, and then free the string */
115 DPRINT("PCIX - PciQueryInterface looking at guid = %wZ\n", &GuidString);
117
118 /* Check if the GUID, version, and size all match */
119 if ((IsEqualGUIDAligned(PciInterface->InterfaceType, InterfaceType)) &&
120 (Version >= PciInterface->MinVersion) &&
121 (Version <= PciInterface->MaxVersion) &&
122 (Size >= PciInterface->MinSize))
123 {
124 /* Call the interface's constructor */
125 Status = PciInterface->Constructor(DeviceExtension,
126 PciInterface,
127 InterfaceData,
128 Version,
129 Size,
130 Interface);
131 if (!NT_SUCCESS(Status))
132 {
133 /* This interface was not initialized correctly, skip it */
134 DPRINT("PCIX - PciQueryInterface constructor %p returned %08lx\n",
135 PciInterface->Constructor, Status);
136 continue;
137 }
138
139 /* Reference the interface and return success, all is good */
140 Interface->InterfaceReference(Interface->Context);
141 DPRINT("PCIX - PciQueryInterface returning SUCCESS\n");
142 return Status;
143 }
144 }
145
146 /* No match is not an error, the FDO path still asks the lower drivers */
147 DPRINT("PCIX - PciQueryInterface found no matching interface\n");
149}
#define PCI_INTERFACE_PDO
Definition: pci.h:67
#define PCI_INTERFACE_FDO
Definition: pci.h:68
#define PCI_INTERFACE_ROOT
Definition: pci.h:69
PPCI_INTERFACE PciInterfacesLastResort[]
Definition: intrface.c:35
static PWSTR GuidString
Definition: apphelp.c:93
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
USHORT MinSize
Definition: pci.h:443
USHORT Flags
Definition: pci.h:446
PCI_INTERFACE_CONSTRUCTOR Constructor
Definition: pci.h:449
USHORT MinVersion
Definition: pci.h:444
CONST GUID * InterfaceType
Definition: pci.h:442
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:208
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)

Referenced by PciFdoIrpQueryInterface(), and PciPdoIrpQueryInterface().

◆ PciQueryRequirements()

NTSTATUS NTAPI PciQueryRequirements ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *  RequirementsList 
)

Definition at line 882 of file enum.c.

884{
886 PCI_COMMON_HEADER PciHeader;
887 PAGED_CODE();
888
889 /* Build even without a BAR or a pin, bridge legacy decodes need ranges too */
892 if (!NT_SUCCESS(Status))
893 return Status;
894
895 /* Is this a Compaq PCI Hotplug Controller (r17) on a PAE system ? */
896 if ((PciHeader.VendorID == 0xE11) &&
897 (PciHeader.DeviceID == 0xA0F7) &&
898 (PciHeader.RevisionID == 17) &&
900 {
901 /* No fixup is applied for this controller under PAE */
902 DPRINT1("PCIX - Compaq hotplug controller PDO ext 0x%p has an unhandled PAE quirk\n",
904 }
905
906 /* The shared zero list must never reach PnP, which frees what it is given */
908 {
910 DPRINT("PCIX - Returning NULL requirements list\n");
911 }
912 else
913 {
915 }
916
917 /* This call always succeeds (but maybe with no requirements) */
918 return STATUS_SUCCESS;
919}
VOID NTAPI PciDebugPrintIoResReqList(IN PIO_RESOURCE_REQUIREMENTS_LIST Requirements)
Definition: debug.c:303
NTSTATUS NTAPI PciBuildRequirementsList(IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData, OUT PIO_RESOURCE_REQUIREMENTS_LIST *Buffer)
Definition: enum.c:756
BOOLEAN NTAPI ExIsProcessorFeaturePresent(IN ULONG ProcessorFeature)
Definition: sysinfo.c:363
#define PF_PAE_ENABLED
Definition: ketypes.h:185

Referenced by PciPdoIrpQueryResourceRequirements().

◆ PciQueryResources()

NTSTATUS NTAPI PciQueryResources ( IN PPCI_PDO_EXTENSION  PdoExtension,
OUT PCM_RESOURCE_LIST *  Buffer 
)

Definition at line 389 of file enum.c.

391{
392 PPCI_FUNCTION_RESOURCES PciResources;
393 BOOLEAN HaveVga, HaveMemSpace, HaveIoSpace;
394 USHORT BridgeControl, PciCommand;
395 ULONG Count, i;
396 PCM_PARTIAL_RESOURCE_DESCRIPTOR Partial, Resource, LastResource;
398 UCHAR InterruptLine;
399 PAGED_CODE();
400
401 /* Assume failure */
402 Count = 0;
403 HaveVga = FALSE;
404 *Buffer = NULL;
405
406 /* Make sure there's some resources to query */
407 PciResources = PdoExtension->Resources;
408 if (!PciResources) return STATUS_SUCCESS;
409
410 /* Read the decodes */
412 &PciCommand,
414 sizeof(USHORT));
415
416 /* Check which ones are turned on */
417 HaveIoSpace = PciCommand & PCI_ENABLE_IO_SPACE;
418 HaveMemSpace = PciCommand & PCI_ENABLE_MEMORY_SPACE;
419
420 /* Loop maximum possible descriptors */
421 for (i = 0; i < 7; i++)
422 {
423 /* Check if the decode for this descriptor is actually turned on */
424 Partial = &PciResources->Current[i];
425 if ((HaveMemSpace &&
426 ((Partial->Type == CmResourceTypeMemory) ||
427 (Partial->Type == CmResourceTypeMemoryLarge))) ||
428 (HaveIoSpace && (Partial->Type == CmResourceTypePort)))
429 {
430 /* One more fully active descriptor */
431 Count++;
432 }
433 }
434
435 /* If there's an interrupt pin associated, check at least one decode is on */
436 if ((PdoExtension->InterruptPin) && ((HaveMemSpace) || (HaveIoSpace)))
437 {
438 /* Read the interrupt line for the pin, add a descriptor if it's valid */
439 InterruptLine = PdoExtension->AdjustedInterruptLine;
440 if ((InterruptLine) && (InterruptLine != PCI_INTERRUPT_LINE_UNKNOWN))
441 Count++;
442 }
443
444 /* Check for a PCI-to-PCI or CardBus bridge, both keep the VGA enable at the same place */
445 if ((PdoExtension->HeaderType == PCI_BRIDGE_TYPE) ||
446 (PdoExtension->HeaderType == PCI_CARDBUS_BRIDGE_TYPE))
447 {
448 /* Read bridge settings, check if VGA is present */
450 &BridgeControl,
451 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.BridgeControl),
452 sizeof(USHORT));
453 if (BridgeControl & PCI_ENABLE_BRIDGE_VGA)
454 {
455 /* Remember for later */
456 HaveVga = TRUE;
457
458 /* One memory descriptor for 0xA0000, plus the two I/O port ranges */
459 if (HaveMemSpace) Count++;
460 if (HaveIoSpace) Count += 2;
461 }
462 }
463
464 /* If there's no descriptors in use, there's no resources, so return */
465 if (!Count) return STATUS_SUCCESS;
466
467 /* Allocate a resource list to hold the resources */
469 PdoExtension->ParentFdoExtension->BaseBus);
471
472 /* This is where the descriptors will be copied into */
473 Resource = ResourceList->List[0].PartialResourceList.PartialDescriptors;
474 LastResource = Resource + Count + 1;
475
476 /* Loop maximum possible descriptors */
477 for (i = 0; i < 7; i++)
478 {
479 /* Check if the decode for this descriptor is actually turned on */
480 Partial = &PciResources->Current[i];
481 if ((HaveMemSpace &&
482 ((Partial->Type == CmResourceTypeMemory) ||
483 (Partial->Type == CmResourceTypeMemoryLarge))) ||
484 (HaveIoSpace && (Partial->Type == CmResourceTypePort)))
485 {
486 /* Copy the descriptor into the resource list */
487 *Resource++ = *Partial;
488 }
489 }
490
491 /* Check if earlier the code detected this was a PCI bridge with VGA on it */
492 if (HaveVga)
493 {
494 /* Are the memory decodes enabled? */
495 if (HaveMemSpace)
496 {
497 /* Build a memory descriptor for a 128KB framebuffer at 0xA0000 */
499 Resource->u.Generic.Start.HighPart = 0;
501 Resource->u.Generic.Start.LowPart = 0xA0000;
502 Resource->u.Generic.Length = 0x20000;
503 Resource++;
504 }
505
506 /* Are the I/O decodes enabled? */
507 if (HaveIoSpace)
508 {
509 /* Build an I/O descriptor for the graphic ports at 0x3B0 */
512 Resource->u.Port.Start.QuadPart = 0x3B0u;
513 Resource->u.Port.Length = 0xC;
514 Resource++;
515
516 /* Build an I/O descriptor for the graphic ports at 0x3C0 */
519 Resource->u.Port.Start.QuadPart = 0x3C0u;
520 Resource->u.Port.Length = 0x20;
521 Resource++;
522 }
523 }
524
525 /* If there's an interrupt pin associated, check at least one decode is on */
526 if ((PdoExtension->InterruptPin) && ((HaveMemSpace) || (HaveIoSpace)))
527 {
528 /* Read the interrupt line for the pin, check if it's valid */
529 InterruptLine = PdoExtension->AdjustedInterruptLine;
530 if ((InterruptLine) && (InterruptLine != PCI_INTERRUPT_LINE_UNKNOWN))
531 {
532 /* Make sure there's still space */
533 ASSERT(Resource < LastResource);
534
535 /* Add the interrupt descriptor */
538 Resource->ShareDisposition = CmResourceShareShared;
539 Resource->u.Interrupt.Affinity = -1;
540 Resource->u.Interrupt.Level = InterruptLine;
541 Resource->u.Interrupt.Vector = InterruptLine;
542 }
543 }
544
545 /* Return the resource list */
547 return STATUS_SUCCESS;
548}
PCM_RESOURCE_LIST NTAPI PciAllocateCmResourceList(IN ULONG Count, IN ULONG BusNumber)
Definition: enum.c:359
#define PCI_INTERRUPT_LINE_UNKNOWN
Definition: pci.h:92
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:121
#define CM_RESOURCE_PORT_10_BIT_DECODE
Definition: cmtypes.h:110
#define PCI_BRIDGE_TYPE
Definition: iotypes.h:3621
#define PCI_CARDBUS_BRIDGE_TYPE
Definition: iotypes.h:3622

Referenced by PciPdoIrpQueryResources().

◆ PciQueryTargetDeviceRelations()

NTSTATUS NTAPI PciQueryTargetDeviceRelations ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN OUT PDEVICE_RELATIONS *  pDeviceRelations 
)

Definition at line 552 of file enum.c.

554{
555 PDEVICE_RELATIONS DeviceRelations;
556 PAGED_CODE();
557
558 /* If there were existing relations, free them */
559 if (*pDeviceRelations) ExFreePoolWithTag(*pDeviceRelations, 0);
560
561 /* Allocate a new structure for the relations */
562 DeviceRelations = ExAllocatePoolWithTag(NonPagedPool,
563 sizeof(DEVICE_RELATIONS),
564 'BicP');
565 if (!DeviceRelations) return STATUS_INSUFFICIENT_RESOURCES;
566
567 /* Only one relation: the PDO */
568 DeviceRelations->Count = 1;
569 DeviceRelations->Objects[0] = PdoExtension->PhysicalDeviceObject;
570 ObReferenceObject(DeviceRelations->Objects[0]);
571
572 /* Return the new relations */
573 *pDeviceRelations = DeviceRelations;
574 return STATUS_SUCCESS;
575}

Referenced by PciPdoIrpQueryDeviceRelations().

◆ PciReadDeviceCapability()

UCHAR NTAPI PciReadDeviceCapability ( IN PPCI_PDO_EXTENSION  DeviceExtension,
IN UCHAR  Offset,
IN ULONG  CapabilityId,
OUT PPCI_CAPABILITIES_HEADER  Buffer,
IN ULONG  Length 
)

Definition at line 958 of file utils.c.

963{
964 ULONG CapabilityCount = 0;
965
966 /* If the device has no capabilility list, fail */
967 if (!Offset) return 0;
968
969 /* Validate a PDO with capabilities, a valid buffer, and a valid length */
970 ASSERT(DeviceExtension->ExtensionType == PciPdoExtensionType);
971 ASSERT(DeviceExtension->CapabilitiesPtr != 0);
972 ASSERT(Buffer);
974
975 /* Loop all capabilities */
976 while (Offset)
977 {
978 /* Make sure the pointer is spec-aligned and spec-sized */
979 ASSERT((Offset >= PCI_COMMON_HDR_LENGTH) && ((Offset & 0x3) == 0));
980
981 /* Read the capability header */
982 PciReadDeviceConfig(DeviceExtension,
983 Buffer,
984 Offset,
986
987 /* Check if this is the capability being looked up */
988 if ((Buffer->CapabilityID == CapabilityId) || !(CapabilityId))
989 {
990 /* Check if was at a valid offset and length */
991 if ((Offset) && (Length > sizeof(PCI_CAPABILITIES_HEADER)))
992 {
993 /* Sanity check */
994 ASSERT(Length <= (sizeof(PCI_COMMON_CONFIG) - Offset));
995
996 /* Now read the whole capability data into the buffer */
997 PciReadDeviceConfig(DeviceExtension,
1002 }
1003
1004 /* Return the offset where the capability was found */
1005 return Offset;
1006 }
1007
1008 /* Try the next capability instead */
1009 CapabilityCount++;
1010 Offset = Buffer->Next;
1011
1012 /* There can't be more than 48 capabilities (256 bytes max) */
1013 if (CapabilityCount > 48)
1014 {
1015 /* Fail, since this is basically a broken PCI device */
1016 DPRINT1("PCIX - Device %p capabilities list is broken.\n", DeviceExtension);
1017 return 0;
1018 }
1019 }
1020
1021 /* Capability wasn't found, fail */
1022 return 0;
1023}

Referenced by PciGetEnhancedCapabilities(), PciGetExpressCapabilities(), PciScanBus(), and PciSetPowerManagedDevicePowerState().

◆ PciReadDeviceConfig()

VOID NTAPI PciReadDeviceConfig ( IN PPCI_PDO_EXTENSION  DeviceExtension,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 149 of file config.c.

153{
154 /* Call the generic worker function */
155 PciReadWriteConfigSpace(DeviceExtension->ParentFdoExtension,
156 DeviceExtension->Slot,
157 Buffer,
158 Offset,
159 Length,
160 TRUE);
161}
VOID NTAPI PciReadWriteConfigSpace(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_SLOT_NUMBER Slot, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length, IN BOOLEAN Read)
Definition: config.c:49

Referenced by PciApplyHacks(), PciApplyResizableBarSizes(), PciAssignSlotResources(), PciConfigureIdeController(), PciDecodeEnable(), PciGetResizableBarCapability(), PciPdoIsPresent(), PciPdoReadWriteConfig(), PciPdoTurnOff(), PcipGetFunctionLimits(), PciQueryRequirements(), PciQueryResources(), PciReadDeviceCapability(), PciReadDeviceExtendedCapability(), PciScanBus(), PciSelectResizableBarSize(), PciSetResources(), PciStallForPowerChange(), PciVerifierCheckBridgeBusNumbers(), and PciWriteLimitsAndRestoreCurrent().

◆ PciReadDeviceExtendedCapability()

ULONG NTAPI PciReadDeviceExtendedCapability ( _In_ PPCI_PDO_EXTENSION  DeviceExtension,
_In_ ULONG  CapabilityId,
_Out_writes_bytes_(Length) PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER  Buffer,
_In_ ULONG  Length 
)

Finds an extended capability and reads it into the caller's buffer.

Returns
The offset of the capability, or 0 if it was not found.

Definition at line 39 of file express.c.

44{
46 ULONG Offset, EntriesLeft;
47
48 ASSERT(DeviceExtension->ExtensionType == PciPdoExtensionType);
50
51 if (!DeviceExtension->IsExtendedConfigReachable)
52 return 0;
53
54 /* More entries than aligned offsets means the list loops */
56
58 {
60 return 0;
61
62 if (EntriesLeft == 0)
63 {
64 DPRINT1("PCIX - Device %p extended capabilities list is broken\n",
65 DeviceExtension);
66 return 0;
67 }
68 EntriesLeft--;
69
70 PciReadDeviceConfig(DeviceExtension, &Header, Offset, sizeof(Header));
71
72 /* A function that does not decode extended space reads back all ones */
73 if (Header.CapabilityID == 0xFFFF)
74 return 0;
75
76 if (Header.CapabilityID != CapabilityId)
77 continue;
78
80 return 0;
81
82 PciReadDeviceConfig(DeviceExtension, Buffer, Offset, Length);
83 return Offset;
84 }
85
86 return 0;
87}
#define PCI_LEGACY_CONFIG_LENGTH
Definition: pci.h:87
static BOOLEAN NTAPI PciIsExtendedCapabilityOffsetValid(_In_ ULONG Offset)
Definition: express.c:20

Referenced by PciGetResizableBarCapability().

◆ PciReadSlotConfig()

VOID NTAPI PciReadSlotConfig ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCI_SLOT_NUMBER  Slot,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 165 of file config.c.

170{
171 /* Call the generic worker function */
172 PciReadWriteConfigSpace(DeviceExtension, Slot, Buffer, Offset, Length, TRUE);
173}

Referenced by PciEcamVerifyBus(), and PciScanBus().

◆ PciReleaseEcam()

VOID NTAPI PciReleaseEcam ( VOID  )

Unmaps every bus mapped through the ECAM window.

Definition at line 381 of file ecam.c.

382{
383 PAGED_CODE();
384
385 /* Config access falls back to the legacy mechanism before the mappings go away */
389}

Referenced by PciDriverUnload().

◆ PciRestoreHalHooks()

VOID NTAPI PciRestoreHalHooks ( VOID  )

Gives the HAL back the routines PciHookHal replaced.

Definition at line 337 of file hookhal.c.

Referenced by PciDriverUnload().

◆ PciSaveBiosConfig()

NTSTATUS NTAPI PciSaveBiosConfig ( IN PPCI_PDO_EXTENSION  DeviceExtension,
OUT PPCI_COMMON_HEADER  PciData 
)

◆ PciSendDeviceUsageToParent()

NTSTATUS NTAPI PciSendDeviceUsageToParent ( _In_ PPCI_FDO_EXTENSION  ParentFdoExtension,
_In_ PIO_STACK_LOCATION  IoStackLocation 
)

Sends a device usage notification to the top of the stack of a parent bus.

Parameters
[in]ParentFdoExtensionThe FDO extension of the bus the function is on.
[in]IoStackLocationThe stack location of the notification the function received.
Returns
The status the parent stack completed the notification with.

Definition at line 94 of file usage.c.

97{
98 PDEVICE_OBJECT TopDevice;
99 PIO_STACK_LOCATION NextStack;
103 PIRP Irp;
104
105 PAGED_CODE();
106
107 TopDevice = IoGetAttachedDeviceReference(ParentFdoExtension->PhysicalDeviceObject);
108
111 TopDevice,
112 NULL,
113 0,
114 NULL,
115 &Event,
116 &IoStatus);
117 if (!Irp)
118 {
119 ObDereferenceObject(TopDevice);
121 }
122
123 /* A PnP IRP nobody handles must come back as not supported */
124 Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
125 Irp->IoStatus.Information = 0;
126
127 NextStack = IoGetNextIrpStackLocation(Irp);
130
131 Status = IoCallDriver(TopDevice, Irp);
132 if (Status == STATUS_PENDING)
133 {
135 Status = IoStatus.Status;
136 }
137
138 ObDereferenceObject(TopDevice);
139 return Status;
140}
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1416
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1101
struct _IO_STACK_LOCATION::@5020::@5053 UsageNotification
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2702
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by PciPdoIrpDeviceUsageNotification().

◆ PciSendIoctl()

NTSTATUS NTAPI PciSendIoctl ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  IoControlCode,
IN PVOID  InputBuffer,
IN ULONG  InputBufferLength,
IN PVOID  OutputBuffer,
IN ULONG  OutputBufferLength 
)

Definition at line 531 of file utils.c.

537{
538 PIRP Irp;
542 PDEVICE_OBJECT AttachedDevice;
543 PAGED_CODE();
544
545 /* Initialize the pending IRP event */
547
548 /* Get a reference to the root PDO (ACPI) */
550 if (!AttachedDevice) return STATUS_INVALID_PARAMETER;
551
552 /* Build the requested IOCTL IRP */
554 AttachedDevice,
559 0,
560 &Event,
563
564 /* Send the IOCTL to the driver */
565 Status = IoCallDriver(AttachedDevice, Irp);
566 if (Status == STATUS_PENDING)
567 {
568 /* Wait for a response */
570 Executive,
572 FALSE,
573 NULL);
574 Status = Irp->IoStatus.Status;
575 }
576
577 /* Take away the reference we took and return the result to the caller */
578 ObDereferenceObject(AttachedDevice);
579 return Status;
580}
_In_ PIO_STATUS_BLOCK IoStatusBlock
Definition: dispmprt.h:608
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:913
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
_In_ PGUID _In_ ULONG OutputBufferLength
Definition: ucxcontroller.h:81
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength

Referenced by PciGetHotPlugParameters(), and PciIsSlotPresentInParentMethod().

◆ PciSetPowerManagedDevicePowerState()

NTSTATUS NTAPI PciSetPowerManagedDevicePowerState ( IN PPCI_PDO_EXTENSION  DeviceExtension,
IN DEVICE_POWER_STATE  DeviceState,
IN BOOLEAN  IrpSet 
)

Definition at line 123 of file power.c.

126{
128 PCI_PM_CAPABILITY PmCaps;
129 ULONG CapsOffset;
130
131 /* Assume success */
133
134 /* Check if this device can support low power states */
135 if (!(PciCanDisableDecodes(DeviceExtension, NULL, 0, TRUE)) &&
137 {
138 /* Simply return success, ignoring this request */
139 DPRINT1("PCIX - Cannot disable decodes on this device, ignoring PM request...\n");
140 return Status;
141 }
142
143 /* Does the device support power management at all? */
144 if (!(DeviceExtension->HackFlags & PCI_HACK_NO_PM_CAPS))
145 {
146 /* Get the PM capabilities register */
147 CapsOffset = PciReadDeviceCapability(DeviceExtension,
148 DeviceExtension->CapabilitiesPtr,
150 &PmCaps.Header,
151 sizeof(PCI_PM_CAPABILITY));
152 ASSERT(CapsOffset);
154
155 /* Check if the device is being powered up */
157 {
158 /* Set full power state */
159 PmCaps.PMCSR.ControlStatus.PowerState = 0;
160
161 /* Check if the device supports Cold-D3 poweroff */
162 if (PmCaps.PMC.Capabilities.Support.PMED3Cold)
163 {
164 /* If there was a pending PME, clear it */
165 PmCaps.PMCSR.ControlStatus.PMEStatus = 1;
166 }
167 }
168 else
169 {
170 /* Otherwise, just set the new power state, converting from NT */
172 }
173
174 /* Write the new power state in the PMCSR */
175 PciWriteDeviceConfig(DeviceExtension,
176 &PmCaps.PMCSR,
177 CapsOffset + FIELD_OFFSET(PCI_PM_CAPABILITY, PMCSR),
178 sizeof(PCI_PMCSR));
179
180 /* Now wait for the change to "stick" based on the spec-mandated time */
181 Status = PciStallForPowerChange(DeviceExtension, DeviceState, CapsOffset);
182 if (!NT_SUCCESS(Status)) return Status;
183 }
184 else
185 {
186 /* Nothing to do! */
187 DPRINT1("PCIX - No PM on this device, ignoring request\n");
188 }
189
190 /* Check if new resources have to be assigned */
191 if (IrpSet)
192 {
193 /* Check if the new device state is lower (higher power) than now */
194 if (DeviceState < DeviceExtension->PowerState.CurrentDeviceState)
195 {
196 /* Leaving D3 may reset the function, so write its configuration again */
197 Status = PciSetResources(DeviceExtension, FALSE, FALSE);
198 }
199 }
200
201 /* Return the power state change status */
202 return Status;
203}
BOOLEAN NTAPI PciCanDisableDecodes(IN PPCI_PDO_EXTENSION DeviceExtension, IN PPCI_COMMON_HEADER Config, IN ULONGLONG HackFlags, IN BOOLEAN ForPowerDown)
Definition: utils.c:1027
NTSTATUS NTAPI PciStallForPowerChange(IN PPCI_PDO_EXTENSION PdoExtension, IN DEVICE_POWER_STATE PowerState, IN ULONG_PTR CapOffset)
Definition: power.c:45
@ PowerDeviceUnspecified
Definition: ntpoapi.h:48
#define PCI_HACK_NO_PM_CAPS
Definition: pci.h:40
USHORT PowerState
Definition: iotypes.h:3704
USHORT PMEStatus
Definition: iotypes.h:3709
struct _PCI_PMC::_PM_SUPPORT Support
PCI_CAPABILITIES_HEADER Header
Definition: iotypes.h:3719
PCI_PMCSR ControlStatus
Definition: iotypes.h:3725
union _PCI_PM_CAPABILITY::@5067 PMCSR
PCI_PMC Capabilities
Definition: iotypes.h:3721
union _PCI_PM_CAPABILITY::@5066 PMC
_In_ WDFDEVICE _Out_ PWDF_DEVICE_STATE DeviceState
Definition: wdfdevice.h:2005
#define PCI_CAPABILITY_ID_POWER_MANAGEMENT
Definition: iotypes.h:3662

Referenced by PciPdoEnterDevicePowerState(), PciPdoIrpStartDevice(), PciPdoTurnOff(), and PciScanBus().

◆ PciSetResources()

NTSTATUS NTAPI PciSetResources ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN BOOLEAN  DoReset,
IN BOOLEAN  SomethingSomethingDarkSide 
)

Definition at line 2490 of file enum.c.

2493{
2495 UCHAR NewCacheLineSize, NewLatencyTimer, CacheLineReadBack;
2496 PCI_COMMON_HEADER PciData;
2498 PPCI_CONFIGURATOR Configurator;
2500
2501 UNREFERENCED_PARAMETER(SomethingSomethingDarkSide);
2502
2503 /* Get the FDO and read the configuration data */
2504 FdoExtension = PdoExtension->ParentFdoExtension;
2506
2507 /* Make sure this is still the same device */
2508 if (!PcipIsSameDevice(PdoExtension, &PciData))
2509 {
2510 /* Fail */
2511 ASSERTMSG("PCI Set resources - not same device.\n", FALSE);
2513 }
2514
2515 /* Nothing to set for a host bridge */
2516 if ((PdoExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
2517 (PdoExtension->SubClass == PCI_SUBCLASS_BR_HOST))
2518 {
2519 /* Fake success */
2520 return STATUS_SUCCESS;
2521 }
2522
2523 /* Check if an IDE controller is being reset */
2524 if ((DoReset) &&
2525 (PdoExtension->BaseClass == PCI_CLASS_MASS_STORAGE_CTLR) &&
2527 {
2528 /* Turn off native mode */
2530 ASSERT(Native == PdoExtension->IDEInNativeMode);
2531 }
2532
2533 /* Check for update of a hotplug device, or first configuration of one */
2534 if ((PdoExtension->NeedsHotPlugConfiguration) &&
2535 (FdoExtension->HotPlugParameters.Acquired))
2536 {
2537 /* The firmware never configured this device, so use what _HPP asks for */
2538 PdoExtension->SavedLatencyTimer = FdoExtension->HotPlugParameters.LatencyTimer;
2539 PdoExtension->SavedCacheLineSize = FdoExtension->HotPlugParameters.CacheLineSize;
2540
2541 PdoExtension->CommandEnables &= ~(PCI_ENABLE_PARITY | PCI_ENABLE_SERR);
2542 if (FdoExtension->HotPlugParameters.EnablePERR)
2543 {
2544 PdoExtension->CommandEnables |= PCI_ENABLE_PARITY;
2545 }
2546
2547 if (FdoExtension->HotPlugParameters.EnableSERR)
2548 {
2549 PdoExtension->CommandEnables |= PCI_ENABLE_SERR;
2550 }
2551
2552 /* Only turn on memory write and invalidate if the device keeps the cache line size */
2554 &PdoExtension->SavedCacheLineSize,
2555 FIELD_OFFSET(PCI_COMMON_HEADER, CacheLineSize),
2556 sizeof(PdoExtension->SavedCacheLineSize));
2558 &CacheLineReadBack,
2559 FIELD_OFFSET(PCI_COMMON_HEADER, CacheLineSize),
2560 sizeof(CacheLineReadBack));
2561 if ((CacheLineReadBack != 0) &&
2562 (CacheLineReadBack == PdoExtension->SavedCacheLineSize))
2563 {
2565 }
2566 else
2567 {
2568 DPRINT1("PCIX - pdox %p cache line size %02x rejected, MWI stays off\n",
2569 PdoExtension, PdoExtension->SavedCacheLineSize);
2570 }
2571 }
2572
2573 /* Locate the correct resource configurator for this type of device */
2574 Configurator = &PciConfigurators[PdoExtension->HeaderType];
2575
2576 /* Apply the settings change, nothing reaches the hardware if it is refused */
2577 Status = Configurator->ChangeResourceSettings(PdoExtension, &PciData);
2578 if (!NT_SUCCESS(Status))
2579 return Status;
2580
2581 /* Assume no update needed */
2582 PdoExtension->UpdateHardware = FALSE;
2583
2584 /* Check if a reset is needed */
2585 if (DoReset)
2586 {
2587 /* Reset resources */
2588 Configurator->ResetDevice(PdoExtension, &PciData);
2589 PciData.u.type0.InterruptLine = PdoExtension->RawInterruptLine;
2590 }
2591
2592 /* Check if the latency timer changed */
2593 NewLatencyTimer = PdoExtension->SavedLatencyTimer;
2594 if (PciData.LatencyTimer != NewLatencyTimer)
2595 {
2596 /* Debug notification */
2597 DPRINT1("PCIX - pdox %p changing latency from %02x to %02x.\n",
2599 PciData.LatencyTimer,
2600 NewLatencyTimer);
2601 }
2602
2603 /* Check if the cache line changed */
2604 NewCacheLineSize = PdoExtension->SavedCacheLineSize;
2605 if (PciData.CacheLineSize != NewCacheLineSize)
2606 {
2607 /* Debug notification */
2608 DPRINT1("PCIX - pdox %p changing cache line size from %02x to %02x.\n",
2610 PciData.CacheLineSize,
2611 NewCacheLineSize);
2612 }
2613
2614 /* Inherit data from PDO extension */
2615 PciData.LatencyTimer = PdoExtension->SavedLatencyTimer;
2616 PciData.CacheLineSize = PdoExtension->SavedCacheLineSize;
2617 PciData.u.type0.InterruptLine = PdoExtension->RawInterruptLine;
2618
2619 /* Apply any resource hacks required */
2621 &PciData,
2622 PdoExtension->Slot,
2624 PdoExtension);
2625
2626 /* Check if I/O space was disabled by administrator or driver */
2627 if (PdoExtension->IoSpaceNotRequired)
2628 {
2629 /* Don't turn on the decode */
2630 PdoExtension->CommandEnables &= ~PCI_ENABLE_IO_SPACE;
2631 }
2632
2633 /* Update the device with the new settings */
2635
2636 /* Update complete */
2637 PdoExtension->RawInterruptLine = PciData.u.type0.InterruptLine;
2638 PdoExtension->NeedsHotPlugConfiguration = FALSE;
2639 return STATUS_SUCCESS;
2640}
BOOLEAN NTAPI PciConfigureIdeController(IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData, IN BOOLEAN Initial)
Definition: enum.c:941
VOID NTAPI PciUpdateHardware(IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)
Definition: enum.c:300
VOID NTAPI PciApplyHacks(IN PPCI_FDO_EXTENSION DeviceExtension, IN PPCI_COMMON_HEADER PciData, IN PCI_SLOT_NUMBER SlotNumber, IN ULONG OperationType, PPCI_PDO_EXTENSION PdoExtension)
Definition: enum.c:1081
#define PCI_HACK_FIXUP_BEFORE_UPDATE
Definition: pci.h:82
unsigned int Native
Definition: fpcontrol.c:84
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:522
PCI_CONFIGURATOR_CHANGE_RESOURCE_SETTINGS ChangeResourceSettings
Definition: pci.h:544
PCI_CONFIGURATOR_RESET_DEVICE ResetDevice
Definition: pci.h:546
#define PCI_ENABLE_WRITE_AND_INVALIDATE
Definition: iotypes.h:3635
#define PCI_ENABLE_PARITY
Definition: iotypes.h:3637
#define PCI_ENABLE_SERR
Definition: iotypes.h:3639

Referenced by PciAssignAndProgramLegacy(), PciPdoIrpStartDevice(), and PciSetPowerManagedDevicePowerState().

◆ PciStringToUSHORT()

BOOLEAN NTAPI PciStringToUSHORT ( IN PWCHAR  String,
OUT PUSHORT  Value 
)

Definition at line 62 of file utils.c.

64{
67 WCHAR Char;
68
69 /* Initialize everything to zero */
70 Short = 0;
71 Length = 0;
72 while (TRUE)
73 {
74 /* Get the character and set the high byte based on the previous one */
75 Char = *String++;
76 High = 16 * Short;
77
78 /* Check for numbers */
79 if ( Char >= '0' && Char <= '9' )
80 {
81 /* Convert them to a byte */
82 Low = Char - '0';
83 }
84 else if ( Char >= 'A' && Char <= 'F' )
85 {
86 /* Convert upper-case hex letters into a byte */
87 Low = Char - '7';
88 }
89 else if ( Char >= 'a' && Char <= 'f' )
90 {
91 /* Convert lower-case hex letters into a byte */
92 Low = Char - 'W';
93 }
94 else
95 {
96 /* Invalid string, fail the conversion */
97 return FALSE;
98 }
99
100 /* Combine the high and low byte */
101 Short = High | Low;
102
103 /* If 4 letters have been reached, the 16-bit integer should exist */
104 if (++Length >= 4)
105 {
106 /* Return it to the caller */
107 *Value = Short;
108 return TRUE;
109 }
110 }
111}
short Short
Definition: ftraster.c:309
@ High
Definition: strmini.h:378
@ Low
Definition: strmini.h:380
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2439

Referenced by PciBuildHackTable().

◆ PciUnicodeStringStrStr()

BOOLEAN NTAPI PciUnicodeStringStrStr ( IN PUNICODE_STRING  InputString,
IN PCUNICODE_STRING  EqualString,
IN BOOLEAN  CaseInSensitive 
)

Definition at line 28 of file utils.c.

31{
32 UNICODE_STRING PartialString;
33 LONG EqualChars, TotalChars;
34
35 /* Build a partial string with the smaller substring */
36 PartialString.Length = EqualString->Length;
37 PartialString.MaximumLength = InputString->MaximumLength;
38 PartialString.Buffer = InputString->Buffer;
39
40 /* Check how many characters that need comparing */
41 EqualChars = 0;
42 TotalChars = (InputString->Length - EqualString->Length) / sizeof(WCHAR);
43
44 /* If the substring is bigger, just fail immediately */
45 if (TotalChars < 0) return FALSE;
46
47 /* Keep checking each character */
48 while (!RtlEqualUnicodeString(EqualString, &PartialString, CaseInSensitive))
49 {
50 /* Continue checking until all the required characters are equal */
51 PartialString.Buffer++;
52 PartialString.MaximumLength -= sizeof(WCHAR);
53 if (++EqualChars > TotalChars) return FALSE;
54 }
55
56 /* The string is equal */
57 return TRUE;
58}
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2437
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
long LONG
Definition: pedump.c:60
USHORT MaximumLength
Definition: env_spec_w32.h:370

Referenced by DriverEntry().

◆ PciUpdateDeviceUsage()

NTSTATUS NTAPI PciUpdateDeviceUsage ( _Inout_ PPCI_POWER_STATE  PowerState,
_In_ PIO_STACK_LOCATION  IoStackLocation 
)

Counts a paging, hibernation or dump file arriving on or leaving a device.

Parameters
[in,out]PowerStateThe power state of the extension that holds the counts.
[in]IoStackLocationThe stack location of the device usage notification.
Returns
STATUS_SUCCESS for a usage the driver accepts, STATUS_NOT_SUPPORTED otherwise.

Definition at line 35 of file usage.c.

38{
40
41 PAGED_CODE();
42
44 {
46 Count = &PowerState->Paging;
47 break;
48
50 Count = &PowerState->Hibernate;
51 break;
52
54 Count = &PowerState->CrashDump;
55 break;
56
57 /* Accepted, but nothing is held back for the boot device */
59 return STATUS_SUCCESS;
60
61 default:
63 }
64
65 /* Several files can share a device, so these are counts and not flags */
67 {
69 }
70 else
71 {
72 ASSERT(*Count > 0);
74 }
75
76 return STATUS_SUCCESS;
77}
@ DeviceUsageTypeHibernation
Definition: iotypes.h:1171
@ DeviceUsageTypeBoot
Definition: iotypes.h:1173
@ DeviceUsageTypeDumpFile
Definition: iotypes.h:1172
@ DeviceUsageTypePaging
Definition: iotypes.h:1170

Referenced by PciFdoIrpDeviceUsageNotification(), and PciPdoIrpDeviceUsageNotification().

◆ PciVerifierInit()

VOID NTAPI PciVerifierInit ( IN PDRIVER_OBJECT  DriverObject)

Definition at line 182 of file pcivrify.c.

183{
185
186 /* Check if the kernel driver verifier is enabled */
188 {
189 /* Register a notification for changes, to keep track of the PCI tree */
191 0,
192 NULL,
195 NULL,
198 }
199}
BOOLEAN NTAPI VfIsVerificationEnabled(IN VF_OBJECT_TYPE VfObjectType, IN PVOID Object OPTIONAL)
Definition: driver.c:22
DRIVER_NOTIFICATION_CALLBACK_ROUTINE PciVerifierProfileChangeCallback
Definition: pcivrify.c:161
PVOID PciVerifierNotificationHandle
Definition: pcivrify.c:19
BOOLEAN PciVerifierRegistered
Definition: pcivrify.c:18
NTSTATUS NTAPI IoRegisterPlugPlayNotification(_In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory, _In_ ULONG EventCategoryFlags, _In_opt_ PVOID EventCategoryData, _In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, _Inout_opt_ PVOID Context, _Out_ PVOID *NotificationEntry)
Definition: pnpnotify.c:346
@ VFOBJTYPE_SYSTEM_BIOS
Definition: vftypes.h:44
@ EventCategoryHardwareProfileChange
Definition: iotypes.h:1225

Referenced by DriverEntry().

◆ PciVerifierRelease()

VOID NTAPI PciVerifierRelease ( VOID  )

Drops the hardware profile notification taken by PciVerifierInit.

Definition at line 206 of file pcivrify.c.

207{
208 PAGED_CODE();
209
211 {
215 }
216}
NTSTATUS NTAPI IoUnregisterPlugPlayNotification(_In_ PVOID NotificationEntry)
Definition: pnpnotify.c:480

Referenced by PciDriverUnload().

◆ PciVerifierRetrieveFailureData()

PPCI_VERIFIER_DATA NTAPI PciVerifierRetrieveFailureData ( IN ULONG  FailureCode)

Definition at line 60 of file pcivrify.c.

61{
62 PPCI_VERIFIER_DATA VerifierData;
63
64 /* Scan the verifier failure table for this code */
65 VerifierData = PciVerifierFailureTable;
66 while (VerifierData->FailureCode != FailureCode)
67 {
68 /* Keep searching */
69 ++VerifierData;
71 }
72
73 /* Return the entry for this code */
74 return VerifierData;
75}
#define PCI_VERIFIER_CODES
Definition: pci.h:121
PCI_VERIFIER_DATA PciVerifierFailureTable[PCI_VERIFIER_CODES]
Definition: pcivrify.c:21
ULONG FailureCode
Definition: pci.h:480

Referenced by PciStallForPowerChange(), and PciVerifierCheckBridgeBusNumbers().

◆ PciWriteDeviceConfig()

VOID NTAPI PciWriteDeviceConfig ( IN PPCI_PDO_EXTENSION  DeviceExtension,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 133 of file config.c.

137{
138 /* Call the generic worker function */
139 PciReadWriteConfigSpace(DeviceExtension->ParentFdoExtension,
140 DeviceExtension->Slot,
141 Buffer,
142 Offset,
143 Length,
144 FALSE);
145}

Referenced by PciApplyHacks(), PciConfigureIdeController(), PciDecodeEnable(), PciPdoReadWriteConfig(), PcipUpdateHardware(), PciScanBus(), PciSelectResizableBarSize(), PciSetPowerManagedDevicePowerState(), PciSetResources(), PciWriteLimitsAndRestoreCurrent(), and routeintrf_UpdateInterruptLine().

◆ PPBridge_ChangeResourceSettings()

NTSTATUS NTAPI PPBridge_ChangeResourceSettings ( _In_ PPCI_PDO_EXTENSION  PdoExtension,
_Inout_ PPCI_COMMON_HEADER  PciData 
)

Definition at line 831 of file ppbridge.c.

834{
835 //BOOLEAN IoActive;
836 PPCI_COMMON_CONFIG SavedConfig;
837 PPCI_FUNCTION_RESOURCES PciResources;
840 PULONG BarArray;
841 ULONG Bar, BarMask, i;
842
843 /* Check if I/O Decodes are enabled */
844 //IoActive = (PciData->u.type1.IOBase & 0xF) == 1;
845
846 /* Close every window, only the ones with a range to forward get opened again */
847 PciData->u.type1.MemoryBase = 0xFFFF;
848 PciData->u.type1.PrefetchBase = 0xFFFF;
849 PciData->u.type1.IOBase = 0xFF;
850 PciData->u.type1.IOLimit = 0;
851 PciData->u.type1.MemoryLimit = 0;
852 PciData->u.type1.PrefetchLimit = 0;
853 PciData->u.type1.PrefetchBaseUpper32 = 0;
854 PciData->u.type1.PrefetchLimitUpper32 = 0;
855 PciData->u.type1.IOBaseUpper16 = 0;
856 PciData->u.type1.IOLimitUpper16 = 0;
857
858 /* Only the bridges PPBridge_SaveCurrentSettings kept a header for have windows to restore */
859 SavedConfig = NULL;
860 if ((PdoExtension->Dependent.type1.SubtractiveDecode) &&
861 (((PdoExtension->VendorId == 0x8086) &&
862 ((PdoExtension->DeviceId == 0x2418) ||
863 (PdoExtension->DeviceId == 0x2428) ||
864 (PdoExtension->DeviceId == 0x244E) ||
865 (PdoExtension->DeviceId == 0x2448))) ||
867 {
868 SavedConfig = PdoExtension->ParentFdoExtension->PreservedConfig;
869 }
870
871 /* A subtractive bridge has no window limits, so the loop below leaves these alone */
872 if (SavedConfig)
873 PciBridgeRestoreOpenWindows(PciData, (PPCI_COMMON_HEADER)SavedConfig);
874
875 /* Write back the BARs, windows and ROM with the ranges assigned to them */
876 PciResources = PdoExtension->Resources;
877 if (PciResources)
878 {
879 BarArray = PciData->u.type1.BaseAddresses;
880 for (i = 0; i < 6; i++)
881 {
882 /* Nothing to write for what the bridge does not implement */
883 if (PciResources->Limit[i].Type == CmResourceTypeNull)
884 continue;
885
886 CmDescriptor = &PciResources->Current[i];
887 Address.QuadPart = 0;
888 if (CmDescriptor->Type != CmResourceTypeNull)
889 Address = CmDescriptor->u.Generic.Start;
890
892 {
893 /* Keep the type bits the BAR reports */
894 Bar = BarArray[i];
897 else
899
900 BarArray[i] = (Bar & ~BarMask) | (Address.LowPart & BarMask);
901
902 /* A 64-bit BAR takes the high half of the address in the next BAR */
903 if (!(Bar & PCI_ADDRESS_IO_SPACE) &&
905 ((i + 1) < PCI_TYPE1_ADDRESSES))
906 {
907 i++;
908 BarArray[i] = Address.HighPart;
909 }
910 }
911 else if (i < 5)
912 {
913 PciBridgeOpenWindow(PciData, i, CmDescriptor);
914 }
915 else
916 {
917 /* The ROM decodes only while its enable bit is set */
918 Bar = PciData->u.type1.ROMBaseAddress &
920 if (CmDescriptor->Type != CmResourceTypeNull)
921 {
924 }
925
926 PciData->u.type1.ROMBaseAddress = Bar;
927 }
928 }
929 }
930
931 /* Copy the bus number data */
932 PciData->u.type1.PrimaryBus = PdoExtension->Dependent.type1.PrimaryBus;
933 PciData->u.type1.SecondaryBus = PdoExtension->Dependent.type1.SecondaryBus;
934 PciData->u.type1.SubordinateBus = PdoExtension->Dependent.type1.SubordinateBus;
935
936 /* Copy the decode flags */
937 if (PdoExtension->Dependent.type1.IsaBitSet)
938 {
939 PciData->u.type1.BridgeControl |= PCI_ENABLE_BRIDGE_ISA;
940 }
941
942 if (PdoExtension->Dependent.type1.VgaBitSet)
943 {
944 PciData->u.type1.BridgeControl |= PCI_ENABLE_BRIDGE_VGA;
945 }
946
947 return STATUS_SUCCESS;
948}
static VOID NTAPI PciBridgeRestoreOpenWindows(_Inout_ PPCI_COMMON_HEADER PciData, _In_ PPCI_COMMON_HEADER SavedHeader)
Copies back the windows that were open in a bridge header saved before enumeration.
Definition: ppbridge.c:793
static VOID NTAPI PciBridgeOpenWindow(_Inout_ PPCI_COMMON_HEADER PciData, _In_ ULONG Index, _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Window)
Opens one forwarding window of a bridge over the range assigned to it.
Definition: ppbridge.c:727
#define PCI_ENABLE_BRIDGE_ISA
Definition: pci.h:62
#define PCI_HACK_BROKEN_SUBTRACTIVE_DECODE
Definition: pci.h:50
#define PCI_TYPE1_ADDRESSES
Definition: iotypes.h:3516

◆ PPBridge_GetAdditionalResourceDescriptors()

VOID NTAPI PPBridge_GetAdditionalResourceDescriptors ( IN PPCI_CONFIGURATOR_CONTEXT  Context,
IN PPCI_COMMON_HEADER  PciData,
IN PIO_RESOURCE_DESCRIPTOR  IoDescriptor 
)

Definition at line 657 of file ppbridge.c.

660{
661
663
664 /* Does this bridge have VGA decodes on it? */
665 if (PciData->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
666 {
667 /* Build a private descriptor with 3 entries */
668 IoDescriptor->Type = CmResourceTypeDevicePrivate;
669 IoDescriptor->u.DevicePrivate.Data[0] = 3;
670 IoDescriptor->u.DevicePrivate.Data[1] = 3;
671
672 /* First, the VGA range at 0xA0000 */
673 IoDescriptor[1].Type = CmResourceTypeMemory;
674 IoDescriptor[1].Flags = CM_RESOURCE_MEMORY_READ_WRITE;
675 IoDescriptor[1].u.Port.Length = 0x20000;
676 IoDescriptor[1].u.Port.Alignment = 1;
677 IoDescriptor[1].u.Port.MinimumAddress.QuadPart = 0xA0000;
678 IoDescriptor[1].u.Port.MaximumAddress.QuadPart = 0xBFFFF;
679
680 /* Then, the VGA registers at 0x3B0 */
681 IoDescriptor[2].Type = CmResourceTypePort;
682 IoDescriptor[2].Flags = CM_RESOURCE_PORT_POSITIVE_DECODE |
684 IoDescriptor[2].u.Port.Length = 12;
685 IoDescriptor[2].u.Port.Alignment = 1;
686 IoDescriptor[2].u.Port.MinimumAddress.QuadPart = 0x3B0;
687 IoDescriptor[2].u.Port.MaximumAddress.QuadPart = 0x3BB;
688
689 /* And finally the VGA registers at 0x3C0 */
690 IoDescriptor[3].Type = CmResourceTypePort;
691 IoDescriptor[3].Flags = CM_RESOURCE_PORT_POSITIVE_DECODE |
693 IoDescriptor[3].u.Port.Length = 32;
694 IoDescriptor[3].u.Port.Alignment = 1;
695 IoDescriptor[3].u.Port.MinimumAddress.QuadPart = 0x3C0;
696 IoDescriptor[3].u.Port.MaximumAddress.QuadPart = 0x3DF;
697 }
698}

Referenced by Cardbus_GetAdditionalResourceDescriptors().

◆ PPBridge_MassageHeaderForLimitsDetermination()

VOID NTAPI PPBridge_MassageHeaderForLimitsDetermination ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 611 of file ppbridge.c.

612{
613 PPCI_COMMON_HEADER PciData, Current;
614
615 /* Get pointers from context */
616 PciData = Context->PciData;
617 Current = Context->Current;
618
619 /*
620 * Write FFh everywhere so that the PCI bridge ignores what it can't handle.
621 * Based on the bits that were ignored (still 0), this is how we can tell
622 * what the limit is.
623 */
624 RtlFillMemory(PciData->u.type1.BaseAddresses,
625 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.CapabilitiesPtr) -
626 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.BaseAddresses),
627 0xFF);
628
629 /* Copy the saved settings from the current context into the PCI header */
630 PciData->u.type1.PrimaryBus = Current->u.type1.PrimaryBus;
631 PciData->u.type1.SecondaryBus = Current->u.type1.SecondaryBus;
632 PciData->u.type1.SubordinateBus = Current->u.type1.SubordinateBus;
633 PciData->u.type1.SecondaryLatency = Current->u.type1.SecondaryLatency;
634
635 /* No I/O limit or base. The bottom base bit specifies that FIXME */
636 PciData->u.type1.IOBaseUpper16 = 0xFFFE;
637 PciData->u.type1.IOLimitUpper16 = 0xFFFF;
638
639 /* Save secondary status before it gets cleared */
640 Context->SecondaryStatus = Current->u.type1.SecondaryStatus;
641
642 /* Clear secondary status */
643 Current->u.type1.SecondaryStatus = 0;
644 PciData->u.type1.SecondaryStatus = 0;
645}
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:603

◆ PPBridge_ResetDevice()

VOID NTAPI PPBridge_ResetDevice ( IN PPCI_PDO_EXTENSION  PdoExtension,
IN PPCI_COMMON_HEADER  PciData 
)

Definition at line 702 of file ppbridge.c.

704{
706
707 /* Never write the header back with the secondary bus held in reset */
708 PciData->u.type1.BridgeControl &= ~PCI_ASSERT_BRIDGE_RESET;
709}

◆ PPBridge_RestoreCurrent()

VOID NTAPI PPBridge_RestoreCurrent ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 649 of file ppbridge.c.

650{
651 /* Copy back the secondary status register */
652 Context->Current->u.type1.SecondaryStatus = Context->SecondaryStatus;
653}

◆ PPBridge_SaveCurrentSettings()

VOID NTAPI PPBridge_SaveCurrentSettings ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 227 of file ppbridge.c.

228{
231 PIO_RESOURCE_DESCRIPTOR IoDescriptor;
234 PPCI_COMMON_HEADER Current;
235 PPCI_COMMON_CONFIG SavedConfig;
236 ULONG i, Bar, BarMask;
237 PULONG BarArray;
239 BOOLEAN HaveIoLimit, CheckAlignment;
241
242 /* Get the pointers from the extension */
243 PdoExtension = Context->PdoExtension;
244 Resources = PdoExtension->Resources;
245 Current = Context->Current;
246
247 /* Check if decodes are disabled */
249 {
250 /* Well, we're going to need them from somewhere, use the registry data */
252 if (NT_SUCCESS(Status)) Current = &BiosData;
253 }
254
255 /* Scan all current and limit descriptors for each BAR needed */
256 BarArray = Current->u.type1.BaseAddresses;
257 for (i = 0; i < 6; i++)
258 {
259 /* Get the current resource descriptor, and the limit requirement */
260 CmDescriptor = &Resources->Current[i];
261 IoDescriptor = &Resources->Limit[i];
262
263 /* Copy descriptor data, skipping null descriptors */
264 CmDescriptor->Type = IoDescriptor->Type;
265 if (CmDescriptor->Type == CmResourceTypeNull) continue;
266 CmDescriptor->Flags = IoDescriptor->Flags;
267 CmDescriptor->ShareDisposition = IoDescriptor->ShareDisposition;
268
269 /* Initialize the high-parts to zero, since most stuff is 32-bit only */
270 Base.QuadPart = Limit.QuadPart = Length.QuadPart = 0;
271
272 /* Check if we're handling PCI BARs, or the ROM BAR */
273 if ((i < PCI_TYPE1_ADDRESSES) || (i == 5))
274 {
275 /* Is this the ROM BAR? */
276 if (i == 5)
277 {
278 /* Read the correct bar, with the appropriate mask */
279 Bar = Current->u.type1.ROMBaseAddress;
281
282 /* Decode the base address, and write down the length */
283 Base.LowPart = Bar & BarMask;
284 DPRINT1("PCIX - ROM BAR Base: %lx\n", Base.LowPart);
285 CmDescriptor->u.Memory.Length = IoDescriptor->u.Memory.Length;
286 }
287 else
288 {
289 /* Otherwise, get the BAR from the array */
290 Bar = BarArray[i];
291
292 /* Is this an I/O BAR? */
294 {
295 /* Set the correct mask */
296 ASSERT(CmDescriptor->Type == CmResourceTypePort);
298 }
299 else
300 {
301 /* This is a memory BAR, set the correct base */
302 ASSERT((CmDescriptor->Type == CmResourceTypeMemory) ||
303 (CmDescriptor->Type == CmResourceTypeMemoryLarge));
305
306 /* IS this a 64-bit BAR? */
308 {
309 /* Read the next 32-bits as well, ie, the next BAR */
310 Base.HighPart = BarArray[i + 1];
311 }
312 }
313
314 /* Decode the base address, and write down the length */
315 Base.LowPart = Bar & BarMask;
316 DPRINT1("PCIX - BAR Base: %lx\n", Base.LowPart);
317 CmDescriptor->u.Generic.Length = IoDescriptor->u.Generic.Length;
318 }
319 }
320 else
321 {
322 /* Reset loop conditions */
323 HaveIoLimit = FALSE;
325
326 /* Check which descriptor is being parsed */
327 if (i == 2)
328 {
329 /* I/O Port Requirements */
330 Base.LowPart = PciBridgeIoBase(Current);
331 Limit.LowPart = PciBridgeIoLimit(Current);
332 DPRINT1("PCIX - Bridge I/O Base and Limit: %lx %lx\n",
333 Base.LowPart, Limit.LowPart);
334
335 /* Do we have any I/O Port data? */
336 if (!(Base.LowPart) && (Current->u.type1.IOLimit))
337 {
338 /* There's a limit */
339 HaveIoLimit = TRUE;
340 }
341 }
342 else if (i == 3)
343 {
344 /* Memory requirements */
345 Base.LowPart = PciBridgeMemoryBase(Current);
346 Limit.LowPart = PciBridgeMemoryLimit(Current);
347
348 /* These should always be there, so check their alignment */
349 DPRINT1("PCIX - Bridge MEM Base and Limit: %lx %lx\n",
350 Base.LowPart, Limit.LowPart);
352 }
353 else if (i == 4)
354 {
355 /* This should only be present for prefetch memory */
359
360 /* If it's there, check the alignment */
361 DPRINT1("PCIX - Bridge Prefetch MEM Base and Limit: %I64x %I64x\n", Base, Limit);
363 }
364
365 /* Check for invalid base address */
366 if (Base.QuadPart >= Limit.QuadPart)
367 {
368 /* Assume the descriptor is bogus */
369 CmDescriptor->Type = CmResourceTypeNull;
370 IoDescriptor->Type = CmResourceTypeNull;
371 continue;
372 }
373
374 /* Check if there's no memory, and no I/O port either */
375 if (!(Base.QuadPart) && !(HaveIoLimit))
376 {
377 /* This seems like a bogus requirement, ignore it */
378 CmDescriptor->Type = CmResourceTypeNull;
379 continue;
380 }
381
382 /* The window spans its base through its limit */
383 Length.QuadPart = Limit.QuadPart - Base.QuadPart + 1;
384
385 /* Junk in the upper prefetch limit would give a window no descriptor can hold */
387 (Limit.HighPart > Base.HighPart) &&
388 (Limit.LowPart > Base.LowPart))
389 {
390 DPRINT1("PCIX - Bridge prefetch limit %I64x has junk in its upper half\n",
391 Limit.QuadPart);
392 Limit.HighPart = Base.HighPart;
393 Length.QuadPart = Limit.QuadPart - Base.QuadPart + 1;
394 }
395
396 /* A prefetchable window of 4GB or more takes the large memory form */
397 Status = RtlCmEncodeMemIoResource(CmDescriptor,
398 CmDescriptor->Type,
399 Length.QuadPart,
400 Base.QuadPart);
401 if (!NT_SUCCESS(Status))
402 {
403 CmDescriptor->Type = CmResourceTypeNull;
404 continue;
405 }
406
407 /* Check if alignment should be set */
408 if (CheckAlignment)
409 {
410 /* Compute the required alignment for this length, 2GB at most */
411 if (Length.HighPart)
412 {
413 IoDescriptor->u.Memory.Alignment = 0x80000000;
414 }
415 else
416 {
417 IoDescriptor->u.Memory.Alignment =
419 }
420 }
421 }
422
423 /* Now set the base address */
424 CmDescriptor->u.Generic.Start = Base;
425 }
426
427 /* Save PCI settings into the PDO extension for easy access later */
428 PdoExtension->Dependent.type1.PrimaryBus = Current->u.type1.PrimaryBus;
429 PdoExtension->Dependent.type1.SecondaryBus = Current->u.type1.SecondaryBus;
430 PdoExtension->Dependent.type1.SubordinateBus = Current->u.type1.SubordinateBus;
431
432 /* Check for subtractive decode bridges */
433 if (PdoExtension->Dependent.type1.SubtractiveDecode)
434 {
435 /* Check if legacy VGA decodes are enabled */
436 DPRINT1("PCIX - Subtractive decode bridge\n");
437 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
438 {
439 /* Save this setting for later */
440 DPRINT1("PCIX - VGA Bridge\n");
441 PdoExtension->Dependent.type1.VgaBitSet = TRUE;
442 }
443
444 /* Legacy ISA decoding is not compatible with subtractive decode */
445 ASSERT(PdoExtension->Dependent.type1.IsaBitSet == FALSE);
446 }
447 else
448 {
449 /* Check if legacy VGA decodes are enabled */
450 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
451 {
452 /* Save this setting for later */
453 DPRINT1("PCIX - VGA Bridge\n");
454 PdoExtension->Dependent.type1.VgaBitSet = TRUE;
455
456 /* And on positive decode, we'll also need extra resources locked */
457 PdoExtension->AdditionalResourceCount = 4;
458 }
459
460 /* Check if legacy ISA decoding is enabled */
461 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_ISA)
462 {
463 /* Save this setting for later */
464 DPRINT1("PCIX - ISA Bridge\n");
465 PdoExtension->Dependent.type1.IsaBitSet = TRUE;
466 }
467 }
468
469 /*
470 * Check for Intel ICH PCI-to-PCI (i82801) bridges (used on the i810,
471 * i820, i840, i845 Chipsets) that have subtractive decode broken.
472 */
473 if (((PdoExtension->VendorId == 0x8086) &&
474 ((PdoExtension->DeviceId == 0x2418) ||
475 (PdoExtension->DeviceId == 0x2428) ||
476 (PdoExtension->DeviceId == 0x244E) ||
477 (PdoExtension->DeviceId == 0x2448))) ||
479 {
480 /* Check if subtractive decode is actually enabled */
481 if (PdoExtension->Dependent.type1.SubtractiveDecode)
482 {
483 /* We're going to need a copy of the configuration for later use */
484 DPRINT1("PCIX - apply config save hack to ICH subtractive decode\n");
486 PdoExtension->ParentFdoExtension->PreservedConfig = SavedConfig;
487 if (SavedConfig) RtlCopyMemory(SavedConfig, Current, PCI_COMMON_HDR_LENGTH);
488 }
489 }
490}
VOID CheckAlignment()
NTSTATUS NTAPI PciGetBiosConfig(IN PPCI_PDO_EXTENSION DeviceExtension, OUT PPCI_COMMON_HEADER PciData)
Definition: utils.c:840
#define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN
Definition: cmtypes.h:139
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2486
PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryBase(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:94
ULONG NTAPI PciBridgeMemoryWorstCaseAlignment(IN ULONG Length)
Definition: ppbridge.c:150
PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryLimit(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:122
ULONG NTAPI PciBridgeIoBase(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:20
ULONG NTAPI PciBridgeMemoryLimit(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:84
ULONG NTAPI PciBridgeIoLimit(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:47
ULONG NTAPI PciBridgeMemoryBase(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:74
struct _IO_RESOURCE_DESCRIPTOR::@2498::@2500 Memory
PBIOS_DATA BiosData
Definition: bios.c:42
NTSYSAPI NTSTATUS NTAPI RtlCmEncodeMemIoResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Type, _In_ ULONGLONG Length, _In_ ULONGLONG Start)
Definition: memres.c:116

◆ PPBridge_SaveLimits()

VOID NTAPI PPBridge_SaveLimits ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 494 of file ppbridge.c.

495{
497 PULONG BarArray;
498 PHYSICAL_ADDRESS MemoryLimit;
499 ULONG i;
502
503 /* Get the pointers from the context */
504 Working = Context->PciData;
505 PdoExtension = Context->PdoExtension;
506
507 /* Scan the BARs into the limit descriptors */
508 BarArray = Working->u.type1.BaseAddresses;
509 Limit = PdoExtension->Resources->Limit;
510
511 /* First of all, loop all the BARs */
512 for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
513 {
514 /* Create a descriptor for their limits, the second BAR has no BAR after it */
515 ULONG NextBar = ((i + 1) < PCI_TYPE1_ADDRESSES) ? BarArray[i + 1] : 0;
516
517 if (PciCreateIoDescriptorFromBarLimit(&Limit[i], BarArray[i], NextBar, FALSE))
518 {
519 /* This was a 64-bit descriptor, make sure there's space */
521
522 /* Skip the next descriptor since this one is double sized */
523 i++;
524 Limit[i].Type = CmResourceTypeNull;
525 }
526 }
527
528 /* Check if this is a subtractive decode bridge */
530 {
531 /* This bridge is subtractive */
532 PdoExtension->Dependent.type1.SubtractiveDecode = TRUE;
533
534 /* Subtractive bridges cannot use legacy ISA or VGA functionality */
535 PdoExtension->Dependent.type1.IsaBitSet = FALSE;
536 PdoExtension->Dependent.type1.VgaBitSet = FALSE;
537 }
538
539 /* For normal decode bridges, we'll need to find the bridge limits too */
540 if (!PdoExtension->Dependent.type1.SubtractiveDecode)
541 {
542 /* Loop the descriptors that are left, to store the bridge limits */
543 for (i = PCI_TYPE1_ADDRESSES; i < 5; i++)
544 {
545 /* No 64-bit memory addresses, and set the address to 0 to begin */
546 MemoryLimit.HighPart = 0;
547 (&Limit[i])->u.Port.MinimumAddress.QuadPart = 0;
548
549 /* Are we getting the I/O limit? */
550 if (i == 2)
551 {
552 /* There should be one, get it */
553 ASSERT(Working->u.type1.IOLimit != 0);
554 ASSERT((Working->u.type1.IOLimit & 0x0E) == 0);
555 MemoryLimit.LowPart = PciBridgeIoLimit(Working);
556
557 /* Build a descriptor for this limit */
561 (&Limit[i])->u.Port.Alignment = 0x1000;
562 (&Limit[i])->u.Port.MinimumAddress.QuadPart = 0;
563 (&Limit[i])->u.Port.MaximumAddress = MemoryLimit;
564 (&Limit[i])->u.Port.Length = 0;
565 }
566 else if (i == 3)
567 {
568 /* There should be a valid memory limit, get it */
569 ASSERT((Working->u.type1.MemoryLimit & 0xF) == 0);
570 MemoryLimit.LowPart = PciBridgeMemoryLimit(Working);
571
572 /* Build the descriptor for it */
575 (&Limit[i])->u.Memory.Alignment = 0x100000;
576 (&Limit[i])->u.Memory.MinimumAddress.QuadPart = 0;
577 (&Limit[i])->u.Memory.MaximumAddress = MemoryLimit;
578 (&Limit[i])->u.Memory.Length = 0;
579 }
580 else if (Working->u.type1.PrefetchLimit)
581 {
582 /* Get the prefetch memory limit, if there is one */
584
585 /* Write out the descriptor for it */
588 (&Limit[i])->u.Memory.Alignment = 0x100000;
589 (&Limit[i])->u.Memory.MinimumAddress.QuadPart = 0;
590 (&Limit[i])->u.Memory.MaximumAddress = MemoryLimit;
591 (&Limit[i])->u.Memory.Length = 0;
592 }
593 else
594 {
595 /* Blank descriptor */
597 }
598 }
599 }
600
601 /* Does the ROM have its own BAR? */
602 if (Working->u.type1.ROMBaseAddress & PCI_ROMADDRESS_ENABLED)
603 {
604 /* Build a limit for it as well */
605 PciCreateIoDescriptorFromBarLimit(&Limit[i], Working->u.type1.ROMBaseAddress, 0, TRUE);
606 }
607}
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
@ Working
Definition: fbtusb.h:82
#define CM_RESOURCE_PORT_WINDOW_DECODE
Definition: cmtypes.h:115
BOOLEAN NTAPI PciBridgeIsSubtractiveDecode(IN PPCI_CONFIGURATOR_CONTEXT Context)
Definition: ppbridge.c:175
ULONG LowPart
Definition: typedefs.h:106

◆ routeintrf_Constructor()

NTSTATUS NTAPI routeintrf_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 236 of file routintf.c.

242{
244 PAGED_CODE();
245
247 UNREFERENCED_PARAMETER(InterfaceData);
249
250 /* Only version 1 is supported */
252
253 RouteInterface->Size = sizeof(*RouteInterface);
255 RouteInterface->Context = DeviceExtension;
261 return STATUS_SUCCESS;
262}
#define STATUS_NOINTERFACE
Definition: ntstatus.h:937
static VOID NTAPI routeintrf_UpdateInterruptLine(_In_ PDEVICE_OBJECT Pdo, _In_ UCHAR LineRegister)
Programs the IRQ chosen for a device into its interrupt line register. The saved BIOS copy is updated...
Definition: routintf.c:200
static NTSTATUS NTAPI routeintrf_GetInterruptRouting(_In_ PDEVICE_OBJECT Pdo, _Out_ ULONG *Bus, _Out_ ULONG *PciSlot, _Out_ UCHAR *InterruptLine, _Out_ UCHAR *InterruptPin, _Out_ UCHAR *ClassCode, _Out_ UCHAR *SubClassCode, _Out_ PDEVICE_OBJECT *ParentPdo, _Out_ ROUTING_TOKEN *RoutingToken, _Out_ UCHAR *Flags)
Describes where a device's interrupt pin is wired. ParentPdo is the PDO of the bridge above the devic...
Definition: routintf.c:116
static NTSTATUS NTAPI routeintrf_SetInterruptRoutingToken(_In_ PDEVICE_OBJECT Pdo, _In_ PROUTING_TOKEN RoutingToken)
Definition: routintf.c:166
static VOID NTAPI routeintrf_Dereference(_In_ PVOID Context)
Definition: routintf.c:103
static VOID NTAPI routeintrf_Reference(_In_ PVOID Context)
Definition: routintf.c:93
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: iotypes.h:5517
PGET_INTERRUPT_ROUTING GetInterruptRouting
Definition: iotypes.h:5518
PUPDATE_INTERRUPT_LINE UpdateInterruptLine
Definition: iotypes.h:5520
PINTERFACE_REFERENCE InterfaceReference
Definition: iotypes.h:5516
PSET_INTERRUPT_ROUTING_TOKEN SetInterruptRoutingToken
Definition: iotypes.h:5519
struct _INT_ROUTE_INTERFACE_STANDARD * PINT_ROUTE_INTERFACE_STANDARD
#define PCI_INT_ROUTE_INTRF_STANDARD_VER
Definition: iotypes.h:5473

◆ routeintrf_Initializer()

NTSTATUS NTAPI routeintrf_Initializer ( IN PVOID  Instance)

Definition at line 37 of file routintf.c.

38{
40 /* PnP Interfaces don't get Initialized */
41 ASSERTMSG("PCI routeintrf_Initializer, unexpected call.\n", FALSE);
43}

◆ tranirq_Constructor()

NTSTATUS NTAPI tranirq_Constructor ( IN PVOID  DeviceExtension,
IN PVOID  Instance,
IN PVOID  InterfaceData,
IN USHORT  Version,
IN USHORT  Size,
IN PINTERFACE  Interface 
)

Definition at line 45 of file tr_irq.c.

51{
53 ULONG BaseBus, ParentBus;
54 INTERFACE_TYPE ParentInterface;
56
60
61 /* Make sure it's the right resource type */
62 if ((ULONG_PTR)InterfaceData != CmResourceTypeInterrupt)
63 {
64 /* Fail this invalid request */
65 DPRINT1("PCIX - IRQ trans constructor doesn't like %p in InterfaceSpecificData\n",
66 InterfaceData);
68 }
69
70 /* Get the bus, and use this as the interface-specific data */
71 BaseBus = FdoExtension->BaseBus;
72 InterfaceData = UlongToPtr(BaseBus);
73
74 /* Check if this is the root bus */
76 {
77 /* It is, so there is no parent, and it's connected on the system bus */
78 ParentBus = 0;
79 ParentInterface = Internal;
80 DPRINT1(" Is root FDO\n");
81 }
82 else
83 {
84 /* It's not, so the translator is rooted on the bus the bridge sits on */
85 PPCI_PDO_EXTENSION PdoExtension = FdoExtension->PhysicalDeviceObject->DeviceExtension;
87 ParentBus = PdoExtension->ParentFdoExtension->BaseBus;
88 ParentInterface = PCIBus;
89 DPRINT1(" Is bridge FDO, parent bus %x, secondary bus %x\n",
90 ParentBus, BaseBus);
91 }
92
93 /* Now call the legacy HAL interface to get the correct translator */
94 return HalGetInterruptTranslator(ParentInterface,
95 ParentBus,
96 PCIBus,
98 0,
100 (PULONG)&InterfaceData);
101}
#define UlongToPtr(u)
Definition: config.h:106
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:571
@ Internal
Definition: restypes.h:122
enum _INTERFACE_TYPE INTERFACE_TYPE
#define HalGetInterruptTranslator
Definition: haltypes.h:313

◆ tranirq_Initializer()

NTSTATUS NTAPI tranirq_Initializer ( IN PVOID  Instance)

Definition at line 35 of file tr_irq.c.

36{
38 /* PnP Interfaces don't get Initialized */
39 ASSERTMSG("PCI tranirq_Initializer, unexpected call.\n", FALSE);
41}

Variable Documentation

◆ AgpTargetInterface

PCI_INTERFACE AgpTargetInterface
extern

Definition at line 20 of file agpintrf.c.

◆ ArbiterInterfaceBusNumber

PCI_INTERFACE ArbiterInterfaceBusNumber
extern

Definition at line 18 of file ar_busno.c.

◆ ArbiterInterfaceIo

PCI_INTERFACE ArbiterInterfaceIo
extern

Definition at line 31 of file ar_memio.c.

◆ ArbiterInterfaceMemory

PCI_INTERFACE ArbiterInterfaceMemory
extern

Definition at line 18 of file ar_memio.c.

◆ BusHandlerInterface

PCI_INTERFACE BusHandlerInterface
extern

Definition at line 18 of file busintrf.c.

◆ PciAddDevice

DRIVER_ADD_DEVICE PciAddDevice

Definition at line 683 of file pci.h.

◆ PciAssignBusNumbers

BOOLEAN PciAssignBusNumbers
extern

Definition at line 18 of file config.c.

Referenced by PciGetConfigHandlers(), PciProcessBus(), and PciReadWriteConfigSpace().

◆ PciCardbusPrivateInterface

PCI_INTERFACE PciCardbusPrivateInterface
extern

Definition at line 18 of file cardbus.c.

◆ PciDebuggingDevices

Definition at line 18 of file utils.c.

Referenced by PciGetDebugPorts(), and PciIsDeviceOnDebugPath().

◆ PciDebugPortsCount

ULONG PciDebugPortsCount
extern

Definition at line 19 of file utils.c.

Referenced by PciGetDebugPorts(), and PciIsDeviceOnDebugPath().

◆ PciDevicePresentInterface

PCI_INTERFACE PciDevicePresentInterface
extern

Definition at line 18 of file devhere.c.

Referenced by PdoQueryInterface(), and VideoPortCheckForDeviceExistence().

◆ PciDispatchIrp

DRIVER_DISPATCH PciDispatchIrp

Definition at line 605 of file pci.h.

Referenced by DriverEntry().

◆ PciDriverObject

PDRIVER_OBJECT PciDriverObject
extern

Definition at line 19 of file init.c.

Referenced by DriverEntry(), PciGetDescriptionMessage(), and routeintrf_FindDevice().

◆ PciEcamVerified

BOOLEAN PciEcamVerified
extern

◆ PciEnableNativeModeATA

BOOLEAN PciEnableNativeModeATA
extern

Definition at line 24 of file init.c.

Referenced by DriverEntry(), and PciApplyHacks().

◆ PciExecuteCriticalSystemRoutine

KIPI_BROADCAST_WORKER PciExecuteCriticalSystemRoutine

Definition at line 1204 of file pci.h.

Referenced by PcipGetFunctionLimits(), and PciUpdateHardware().

◆ PciFdoExtensionListHead

◆ PciGlobalLock

◆ PciHackTable

PPCI_HACK_ENTRY PciHackTable
extern

Definition at line 28 of file init.c.

Referenced by PciBuildHackTable(), PciDriverUnload(), and PciGetHackFlags().

◆ PciInterfaces

PPCI_INTERFACE PciInterfaces[]
extern

Definition at line 18 of file intrface.c.

Referenced by PciInitializeArbiters(), and PciQueryInterface().

◆ PciIrqRoutingTable

PPCI_IRQ_ROUTING_TABLE PciIrqRoutingTable
extern

Definition at line 26 of file init.c.

Referenced by DriverEntry(), PciDetermineSlotNumber(), and PciDriverUnload().

◆ PciIsaBitExclusionList

RTL_RANGE_LIST PciIsaBitExclusionList
extern

Definition at line 21 of file utils.c.

Referenced by PciBuildDefaultExclusionLists(), and PciDriverUnload().

◆ PciLegacyDeviceDetectionInterface

PCI_INTERFACE PciLegacyDeviceDetectionInterface
extern

Definition at line 18 of file lddintrf.c.

◆ PciLocationInterface

PCI_INTERFACE PciLocationInterface
extern

Definition at line 18 of file locintrf.c.

◆ PciPmeInterface

PCI_INTERFACE PciPmeInterface
extern

Definition at line 18 of file pmeintf.c.

◆ PciRoutingInterface

PCI_INTERFACE PciRoutingInterface
extern

Definition at line 20 of file routintf.c.

◆ PciRunningDatacenter

BOOLEAN PciRunningDatacenter
extern

Definition at line 18 of file init.c.

Referenced by DriverEntry().

◆ PciVgaAndIsaBitExclusionList

RTL_RANGE_LIST PciVgaAndIsaBitExclusionList
extern

Definition at line 22 of file utils.c.

Referenced by PciBuildDefaultExclusionLists(), and PciDriverUnload().

◆ PciZeroIoResourceRequirements

PIO_RESOURCE_REQUIREMENTS_LIST PciZeroIoResourceRequirements
extern

◆ TranslatorInterfaceInterrupt

PCI_INTERFACE TranslatorInterfaceInterrupt
extern

Definition at line 18 of file tr_irq.c.

◆ WdTable

PWATCHDOG_TABLE WdTable
extern

Definition at line 27 of file init.c.

Referenced by PciDriverUnload(), and PciScanBus().