ReactOS 0.4.17-dev-934-g091855f
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_POWER_STATE
 
struct  _PCI_LOCK
 
struct  _PCI_FDO_EXTENSION
 
struct  _PCI_FUNCTION_RESOURCES
 
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 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 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_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 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 VOID(NTAPI * PCI_CONFIGURATOR_CHANGE_RESOURCE_SETTINGS) (IN PPCI_PDO_EXTENSION PdoExtension, IN 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 PciVerifierInit (IN PDRIVER_OBJECT DriverObject)
 
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.
 
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.
 
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)
 
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)
 
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 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)
 
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)
 
VOID NTAPI Cardbus_ChangeResourceSettings (IN PPCI_PDO_EXTENSION PdoExtension, IN 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)
 
VOID NTAPI Device_ChangeResourceSettings (IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)
 
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)
 
VOID NTAPI PPBridge_ChangeResourceSettings (IN PPCI_PDO_EXTENSION PdoExtension, IN 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)
 

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
 
NTSYSAPI BOOLEAN InitSafeBootMode
 

Macro Definition Documentation

◆ ARBITER_INTERFACE_VERSION

#define ARBITER_INTERFACE_VERSION   0

Definition at line 82 of file pci.h.

◆ ASSERT_FDO

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

Definition at line 37 of file pci.h.

◆ ASSERT_PDO

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

Definition at line 38 of file pci.h.

◆ MAX_ANSI_STRINGS

#define MAX_ANSI_STRINGS   0x08

Definition at line 97 of file pci.h.

◆ MAX_DEBUGGING_DEVICES_SUPPORTED

#define MAX_DEBUGGING_DEVICES_SUPPORTED   0x04

Definition at line 87 of file pci.h.

◆ PCI_HACK_ENTRY_FULL_SIZE

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

Definition at line 46 of file pci.h.

◆ PCI_HACK_ENTRY_REV_SIZE

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

Definition at line 44 of file pci.h.

◆ PCI_HACK_ENTRY_SIZE

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

Definition at line 43 of file pci.h.

◆ PCI_HACK_ENTRY_SUBSYS_SIZE

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

Definition at line 45 of file pci.h.

◆ PCI_HACK_FIXUP_AFTER_CONFIGURATION

#define PCI_HACK_FIXUP_AFTER_CONFIGURATION   0x01

Definition at line 71 of file pci.h.

◆ PCI_HACK_FIXUP_BEFORE_CONFIGURATION

#define PCI_HACK_FIXUP_BEFORE_CONFIGURATION   0x00

Definition at line 70 of file pci.h.

◆ PCI_HACK_FIXUP_BEFORE_UPDATE

#define PCI_HACK_FIXUP_BEFORE_UPDATE   0x03

Definition at line 72 of file pci.h.

◆ PCI_HACK_HAS_REVISION_INFO

#define PCI_HACK_HAS_REVISION_INFO   0x01

Definition at line 51 of file pci.h.

◆ PCI_HACK_HAS_SUBSYSTEM_INFO

#define PCI_HACK_HAS_SUBSYSTEM_INFO   0x02

Definition at line 52 of file pci.h.

◆ PCI_INTERFACE_FDO

#define PCI_INTERFACE_FDO   0x02

Definition at line 58 of file pci.h.

◆ PCI_INTERFACE_PDO

#define PCI_INTERFACE_PDO   0x01

Definition at line 57 of file pci.h.

◆ PCI_INTERFACE_ROOT

#define PCI_INTERFACE_ROOT   0x04

Definition at line 59 of file pci.h.

◆ PCI_IS_ROOT_FDO

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

Definition at line 32 of file pci.h.

◆ PCI_LEGACY_CONFIG_LENGTH

#define PCI_LEGACY_CONFIG_LENGTH   0x100

Definition at line 77 of file pci.h.

◆ PCI_POOL_TAG

#define PCI_POOL_TAG   'BicP'

Definition at line 27 of file pci.h.

◆ PCI_SKIP_DEVICE_ENUMERATION

#define PCI_SKIP_DEVICE_ENUMERATION   0x01

Definition at line 64 of file pci.h.

◆ PCI_SKIP_RESOURCE_ENUMERATION

#define PCI_SKIP_RESOURCE_ENUMERATION   0x02

Definition at line 65 of file pci.h.

◆ PCI_VERIFIER_CODES

#define PCI_VERIFIER_CODES   0x04

Definition at line 92 of file pci.h.

Typedef Documentation

◆ PCI_ARBITER_INSTANCE

◆ PCI_CONFIGURATOR

◆ PCI_CONFIGURATOR_CHANGE_RESOURCE_SETTINGS

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

Definition at line 469 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 474 of file pci.h.

◆ PCI_CONFIGURATOR_INITIALIZE

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

Definition at line 453 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 480 of file pci.h.

◆ PCI_CONFIGURATOR_RESTORE_CURRENT

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

Definition at line 457 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 465 of file pci.h.

◆ PCI_CONFIGURATOR_SAVE_LIMITS

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

Definition at line 461 of file pci.h.

◆ 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 339 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 373 of file pci.h.

◆ PCI_INTERFACE_INITIALIZER

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

Definition at line 382 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 516 of file pci.h.

◆ PCI_LEGACY_DEVICE

◆ PCI_LOCK

◆ PCI_MJ_DISPATCH_TABLE

◆ PCI_MN_DISPATCH_TABLE

◆ PCI_PDO_EXTENSION

◆ PCI_POWER_STATE

◆ PCI_SECONDARY_EXTENSION

◆ PCI_SIGNATURE

◆ PCI_STATE

◆ PCI_VERIFIER_DATA

◆ PPCI_ARBITER_INSTANCE

◆ PPCI_CONFIGURATOR

◆ PPCI_CONFIGURATOR_CONTEXT

◆ 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_SECONDARY_EXTENSION

◆ PPCI_SIGNATURE

◆ PPCI_VERIFIER_DATA

Enumeration Type Documentation

◆ _PCI_DEVICE_TYPES

Enumerator
PciTypeInvalid 
PciTypeHostBridge 
PciTypePciBridge 
PciTypeCardbusBridge 
PciTypeDevice 

Definition at line 125 of file pci.h.

126{
@ PciTypeHostBridge
Definition: pci.h:128
@ PciTypeDevice
Definition: pci.h:131
@ PciTypePciBridge
Definition: pci.h:129
@ PciTypeInvalid
Definition: pci.h:127
@ PciTypeCardbusBridge
Definition: pci.h:130
enum _PCI_DEVICE_TYPES PCI_DEVICE_TYPES

◆ _PCI_DISPATCH_STYLE

Enumerator
IRP_COMPLETE 
IRP_DOWNWARD 
IRP_UPWARD 
IRP_DISPATCH 

Definition at line 151 of file pci.h.

152{
enum _PCI_DISPATCH_STYLE PCI_DISPATCH_STYLE
@ IRP_UPWARD
Definition: pci.h:155
@ IRP_COMPLETE
Definition: pci.h:153
@ IRP_DISPATCH
Definition: pci.h:156
@ IRP_DOWNWARD
Definition: pci.h:154

◆ _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 102 of file pci.h.

103{
104 PciPdoExtensionType = 'icP0',
105 PciFdoExtensionType = 'icP1',
106 PciArb_Io = 'icP2',
107 PciArb_Memory = 'icP3',
108 PciArb_Interrupt = 'icP4',
109 PciArb_BusNumber = 'icP5',
110 PciTrans_Interrupt = 'icP6',
113 PciInterface_PciCb = 'icP9',
117 PciInterface_NativeIde = 'icP=',
118 PciInterface_AgpTarget = 'icP>',
119 PciInterface_Location = 'icP?'
enum _PCI_SIGNATURE PCI_SIGNATURE
enum _PCI_SIGNATURE * PPCI_SIGNATURE
@ PciInterface_NativeIde
Definition: pci.h:117
@ PciFdoExtensionType
Definition: pci.h:105
@ PciPdoExtensionType
Definition: pci.h:104
@ PciInterface_PciCb
Definition: pci.h:113
@ PciInterface_IntRouteHandler
Definition: pci.h:112
@ PciArb_BusNumber
Definition: pci.h:109
@ PciInterface_Location
Definition: pci.h:119
@ PciArb_Io
Definition: pci.h:106
@ PciInterface_DevicePresent
Definition: pci.h:116
@ PciArb_Interrupt
Definition: pci.h:108
@ PciInterface_BusHandler
Definition: pci.h:111
@ PciTrans_Interrupt
Definition: pci.h:110
@ PciInterface_LegacyDeviceDetection
Definition: pci.h:114
@ PciArb_Memory
Definition: pci.h:107
@ PciInterface_AgpTarget
Definition: pci.h:118
@ PciInterface_PmeHandler
Definition: pci.h:115

◆ _PCI_STATE

Enumerator
PciNotStarted 
PciStarted 
PciDeleted 
PciStopped 
PciSurpriseRemoved 
PciSynchronizedOperation 
PciMaxObjectState 

Definition at line 137 of file pci.h.

138{
146} PCI_STATE;
enum _PCI_STATE PCI_STATE
@ PciMaxObjectState
Definition: pci.h:145
@ PciSurpriseRemoved
Definition: pci.h:143
@ PciDeleted
Definition: pci.h:141
@ PciStarted
Definition: pci.h:140
@ PciSynchronizedOperation
Definition: pci.h:144
@ PciStopped
Definition: pci.h:142
@ PciNotStarted
Definition: pci.h:139

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 47 of file agpintrf.c.

53{
55
57 UNREFERENCED_PARAMETER(InterfaceData);
61
62 /* Only AGP bridges are supported (which are PCI-to-PCI Bridge Devices) */
63 if ((PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) ||
65 {
66 /* Fail any other PDO */
68 }
69
70 /* Not yet implemented */
73}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
struct _PCI_PDO_EXTENSION * PPCI_PDO_EXTENSION
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
@ PdoExtension
Definition: precomp.h:49
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
_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 Interface
Definition: wdffdo.h:465
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_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:4168
#define PCI_CLASS_BRIDGE_DEV
Definition: iotypes.h:4111

◆ agpintrf_Initializer()

NTSTATUS NTAPI agpintrf_Initializer ( IN PVOID  Instance)

Definition at line 37 of file agpintrf.c.

38{
40 /* PnP Interfaces don't get Initialized */
41 ASSERTMSG("PCI agpintrf_Initializer, unexpected call.\n", FALSE);
43}
#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 143 of file ar_busno.c.

149{
151 PAGED_CODE();
152
153 UNREFERENCED_PARAMETER(PciInterface);
156
157 /* This one only arbitrates bus numbers */
158 if ((ULONG_PTR)InterfaceData != CmResourceTypeBusNumber)
159 {
161 }
162
163 /* Hand out the instance that was built for this bus */
167}
#define PAGED_CODE()
NTSTATUS NTAPI PciArbiterConstructor(_In_ PPCI_FDO_EXTENSION FdoExtension, _In_ PCI_SIGNATURE ArbiterType, _Out_ PARBITER_INTERFACE Interface)
Definition: arb_comn.c:48
struct _PCI_FDO_EXTENSION * PPCI_FDO_EXTENSION
@ FdoExtension
Definition: precomp.h:48
#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
126
128 FdoExtension->FunctionalDeviceObject,
130 Arbiter->InstanceName,
131 L"Pci",
132 NULL);
133 if (!NT_SUCCESS(Status))
134 {
135 DPRINT1("arbusno_Initializer: init arbiter return %X\n", Status);
136 }
137
138 return Status;
139}
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 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
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define L(x)
Definition: resources.c:13
Status
Definition: gdiplustypes.h:24
PPCI_FDO_EXTENSION BusFdoExtension
Definition: pci.h:419
WCHAR InstanceName[24]
Definition: pci.h:420
ARBITER_INSTANCE CommonInstance
Definition: pci.h:421
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_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
#define STATUS_SUCCESS
Definition: shellext.h:65
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 181 of file ar_memio.c.

182{
183 PPCI_ARBITER_INSTANCE PciArbiter;
184 PARBITER_INSTANCE CommonInstance;
186
187 /* Only valid for root FDOs who are being applied the hack for the first time */
188 ASSERT(!FdoExtension->BrokenVideoHackApplied);
190
191 /* Find the I/O arbiter */
193 SecondaryExtension.Next,
194 PciArb_Io);
195 ASSERT(PciArbiter);
196 if (!PciArbiter) return;
197
198 /* Get the Arb instance */
199 CommonInstance = &PciArbiter->CommonInstance;
200
201 /* Free the two lists, enabling full VGA access */
204
205 /* Build the ordering for broken video PCI access */
207 L"Pci",
208 L"BrokenVideo",
209 NULL);
211 if (!NT_SUCCESS(Status))
212 {
213 DPRINT1("ario_ApplyBrokenVideoHack: ordering failed %X\n", Status);
214 }
215
216 /* Now the hack has been applied */
217 FdoExtension->BrokenVideoHackApplied = TRUE;
218}
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:583
#define PCI_IS_ROOT_FDO(x)
Definition: pci.h:32
#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 153 of file ar_memio.c.

159{
161 PAGED_CODE();
162
163 UNREFERENCED_PARAMETER(PciInterface);
166
167 /* This one only arbitrates I/O ports */
168 if ((ULONG_PTR)InterfaceData != CmResourceTypePort)
169 {
171 }
172
173 /* Hand out the instance that was built for this bus */
175 PciArb_Io,
177}
#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 */
135
136 /* The rest of the engine, and the PCI assignment ordering, is generic */
138 FdoExtension->FunctionalDeviceObject,
140 Arbiter->InstanceName,
141 L"Pci",
142 NULL);
143 if (!NT_SUCCESS(Status))
144 {
145 DPRINT1("ario_Initializer: init arbiter returned %X\n", Status);
146 }
147
148 return Status;
149}
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

◆ 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 339 of file ar_memio.c.

345{
347 PAGED_CODE();
348
349 UNREFERENCED_PARAMETER(PciInterface);
352
353 /* This one only arbitrates device memory */
354 if ((ULONG_PTR)InterfaceData != CmResourceTypeMemory)
355 {
357 }
358
359 /* Hand out the instance that was built for this bus */
363}
#define CmResourceTypeMemory
Definition: restypes.h:106

◆ armem_Initializer()

NTSTATUS NTAPI armem_Initializer ( IN PVOID  Instance)

Definition at line 305 of file ar_memio.c.

306{
310 PAGED_CODE();
311
312 /* Start from a clean engine instance */
313 RtlZeroMemory(&Arbiter->CommonInstance, sizeof(Arbiter->CommonInstance));
314 FdoExtension = Arbiter->BusFdoExtension;
315
316 /* Teach the engine how to read and write memory descriptors */
321
322 /* The rest of the engine, and the PCI assignment ordering, is generic */
324 FdoExtension->FunctionalDeviceObject,
326 Arbiter->InstanceName,
327 L"Pci",
328 NULL);
329 if (!NT_SUCCESS(Status))
330 {
331 DPRINT1("armem_Initializer: init arbiter returned %X\n", Status);
332 }
333
334 return Status;
335}
NTSTATUS NTAPI armem_UnpackResource(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource, _Out_ PULONGLONG Start, _Out_ PULONGLONG Length)
Definition: ar_memio.c:267
INT32 NTAPI armem_ScoreRequirement(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor)
Definition: ar_memio.c:284
NTSTATUS NTAPI armem_PackResource(_In_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONGLONG Start, _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Resource)
Definition: ar_memio.c:245
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:222

◆ armem_PackResource()

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

Definition at line 245 of file ar_memio.c.

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

Referenced by armem_Initializer().

◆ armem_ScoreRequirement()

INT32 NTAPI armem_ScoreRequirement ( _In_ PIO_RESOURCE_DESCRIPTOR  Descriptor)

Definition at line 284 of file ar_memio.c.

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

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 222 of file ar_memio.c.

227{
228 /* This arbiter is only ever handed device memory descriptors, large ones included */
229 if ((Descriptor->Type != CmResourceTypeMemory) &&
231 {
233 }
234
235 /* An alignment of zero would place the range nowhere, so make it one byte */
237 if (!*Alignment)
238 *Alignment = 1;
239
240 return STATUS_SUCCESS;
241}
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 267 of file ar_memio.c.

270{
271 /* Read a previously packed memory resource back out */
272 if ((Resource->Type != CmResourceTypeMemory) &&
274 {
276 }
277
279 return STATUS_SUCCESS;
280}
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
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
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()

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

Definition at line 89 of file cardbus.c.

◆ Cardbus_GetAdditionalResourceDescriptors()

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

Definition at line 67 of file cardbus.c.

70{
73 UNREFERENCED_PARAMETER(IoDescriptor);
75}
_In_ PVOID Context
Definition: storport.h:2269

◆ Cardbus_MassageHeaderForLimitsDetermination()

VOID NTAPI Cardbus_MassageHeaderForLimitsDetermination ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 51 of file cardbus.c.

◆ Cardbus_ResetDevice()

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

Definition at line 79 of file cardbus.c.

◆ Cardbus_RestoreCurrent()

VOID NTAPI Cardbus_RestoreCurrent ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 59 of file cardbus.c.

◆ Cardbus_SaveCurrentSettings()

VOID NTAPI Cardbus_SaveCurrentSettings ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 35 of file cardbus.c.

◆ Cardbus_SaveLimits()

VOID NTAPI Cardbus_SaveLimits ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 43 of file cardbus.c.

◆ Device_ChangeResourceSettings()

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

Definition at line 284 of file device.c.

286{
289 PULONG BarArray;
290 ULONG Bar, BarMask, i;
291
292 Resources = PdoExtension->Resources;
293 if (!Resources)
294 return;
295
296 /* Write each BAR back with the address that was arbitrated for it */
297 BarArray = PciData->u.type0.BaseAddresses;
298 for (i = 0; i <= PCI_TYPE0_ADDRESSES; i++)
299 {
300 CmDescriptor = &Resources->Current[i];
301
303 {
304 /* A BAR the function does not implement reads back as zero */
305 Bar = BarArray[i];
306 if (!(Bar & ~PCI_ADDRESS_IO_SPACE)) continue;
307
308 /* Work out which bits of this BAR are the address */
310 {
312 }
313 else
314 {
316
317 /* A legacy BAR only decodes the low 20 bits of the address */
319 {
320 BarMask = 0xFFFF0;
321 }
322 }
323
324 BarArray[i] = (Bar & ~BarMask) |
325 (CmDescriptor->u.Memory.Start.LowPart & BarMask);
326
327 /* A 64-bit BAR keeps the high half of its address in the next one */
328 if (!(Bar & PCI_ADDRESS_IO_SPACE) &&
330 {
332 BarArray[i + 1] = CmDescriptor->u.Memory.Start.HighPart;
333 i++;
334 }
335 }
336 else
337 {
338 /* The ROM BAR decodes only while its enable bit is set */
339 Bar = PciData->u.type0.ROMBaseAddress;
340 if (CmDescriptor->Type == CmResourceTypeNull)
341 {
342 PciData->u.type0.ROMBaseAddress = Bar & ~PCI_ROMADDRESS_ENABLED;
343 }
344 else
345 {
346 PciData->u.type0.ROMBaseAddress =
347 (Bar & ~PCI_ADDRESS_ROM_ADDRESS_MASK) |
348 (CmDescriptor->u.Memory.Start.LowPart &
351 }
352 }
353 }
354}
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
void Bar(void)
Definition: terminate.cpp:70
#define CmResourceTypeNull
Definition: restypes.h:103
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@486 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@486::@491 Memory
uint32_t * PULONG
Definition: typedefs.h:59
#define PCI_TYPE_64BIT
Definition: iotypes.h:4242
#define PCI_ADDRESS_IO_ADDRESS_MASK
Definition: iotypes.h:4236
#define PCI_TYPE0_ADDRESSES
Definition: iotypes.h:3502
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4233
#define PCI_TYPE_20BIT
Definition: iotypes.h:4241
#define PCI_ADDRESS_ROM_ADDRESS_MASK
Definition: iotypes.h:4238
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK
Definition: iotypes.h:4237
#define PCI_ROMADDRESS_ENABLED
Definition: iotypes.h:4244
#define PCI_ADDRESS_MEMORY_TYPE_MASK
Definition: iotypes.h:4234

◆ Device_GetAdditionalResourceDescriptors()

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

Definition at line 260 of file device.c.

263{
265 UNREFERENCED_PARAMETER(PciData);
266 UNREFERENCED_PARAMETER(IoDescriptor);
267 /* Not yet implemented */
269}

◆ Device_MassageHeaderForLimitsDetermination()

VOID NTAPI Device_MassageHeaderForLimitsDetermination ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 219 of file device.c.

220{
221 PPCI_COMMON_HEADER PciData;
223 PULONG BarArray;
224 ULONG i = 0;
225
226 /* Get pointers from context data */
227 PdoExtension = Context->PdoExtension;
228 PciData = Context->PciData;
229
230 /* Get the array of BARs */
231 BarArray = PciData->u.type0.BaseAddresses;
232
233 /* Check for IDE controllers that are not in native mode */
234 if ((PdoExtension->BaseClass == PCI_CLASS_MASS_STORAGE_CTLR) &&
236 (PdoExtension->ProgIf & 5) != 5)
237 {
238 /* These controllers only use legacy resources */
239 i = 4;
240 }
241
242 /* Set all the bits on, which will allow us to recover the limit data */
243 for (i = 0; i < PCI_TYPE0_ADDRESSES; i++) BarArray[i] = 0xFFFFFFFF;
244
245 /* Do the same for the PCI ROM BAR */
246 PciData->u.type0.ROMBaseAddress = PCI_ADDRESS_ROM_ADDRESS_MASK;
247}
#define PCI_CLASS_MASS_STORAGE_CTLR
Definition: iotypes.h:4106
#define PCI_SUBCLASS_MSC_IDE_CTLR
Definition: iotypes.h:4131

◆ Device_ResetDevice()

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

Definition at line 273 of file device.c.

275{
277 UNREFERENCED_PARAMETER(PciData);
278 /* Not yet implemented */
280}

◆ Device_RestoreCurrent()

VOID NTAPI Device_RestoreCurrent ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 251 of file device.c.

252{
254 /* Nothing to do for devices */
255 return;
256}

◆ 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 */
71 {
72 /* The next BAR value is actually the high 32-bits */
73 CmDescriptor->u.Memory.Start.HighPart = BarArray[i + 1];
74 }
76 {
77 /* Legacy BAR, don't read more than 20 bits of the address */
78 BarMask = 0xFFFF0;
79 }
80 }
81 }
82 else
83 {
84 /* Actually a ROM BAR, so read the correct register */
85 Bar = PciData->u.type0.ROMBaseAddress;
86
87 /* Apply the correct mask for ROM BARs */
89
90 /* Make sure it's enabled */
92 {
93 /* If it isn't, then a descriptor won't be built for it */
94 CmDescriptor->Type = CmResourceTypeNull;
95 continue;
96 }
97 }
98
99 /* Now we have the right mask, read the actual address from the BAR */
100 Bar &= BarMask;
101 CmDescriptor->u.Memory.Start.LowPart = Bar;
102
103 /* And check for invalid BAR addresses */
104 if (!(CmDescriptor->u.Memory.Start.HighPart | Bar))
105 {
106 /* Skip these descriptors */
107 CmDescriptor->Type = CmResourceTypeNull;
108 DPRINT1("Invalid BAR\n");
109 }
110 }
111
112 /* Also save the sub-IDs that came directly from the PCI header */
113 Context->PdoExtension->SubsystemVendorId = PciData->u.type0.SubVendorID;
114 Context->PdoExtension->SubsystemId = PciData->u.type0.SubSystemID;
115}
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@486::@487 Generic
struct _IO_RESOURCE_DESCRIPTOR::@2481::@2486 Generic
union _IO_RESOURCE_DESCRIPTOR::@2481 u

◆ Device_SaveLimits()

VOID NTAPI Device_SaveLimits ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 119 of file device.c.

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

◆ 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 45 of file devhere.c.

◆ 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.

◆ 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 45 of file locintrf.c.

◆ 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 458 of file fdo.c.

460{
462 PDEVICE_OBJECT AttachedTo;
464 PPCI_FDO_EXTENSION ParentExtension;
473 PAGED_CODE();
474 DPRINT1("PCI - AddDevice (a new bus). PDO: %p (Driver: %wZ)\n",
475 PhysicalDeviceObject, &PhysicalDeviceObject->DriverObject->DriverName);
476
477 /* Zero out variables so failure path knows what to do */
478 AttachedTo = NULL;
482
483 do
484 {
485 /* Check if there's already a device extension for this bus */
488 if (ParentExtension)
489 {
490 /* Make sure we find a real PDO */
493
494 /* Make sure it's a PCI-to-PCI bridge */
495 if ((PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) ||
497 {
498 /* This should never happen */
499 DPRINT1("PCI - PciAddDevice for Non-Root/Non-PCI-PCI bridge,\n"
500 " Class %02x, SubClass %02x, will not add.\n",
501 PdoExtension->BaseClass,
502 PdoExtension->SubClass);
503 ASSERT((PdoExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
505
506 /* Enter the failure path */
508 break;
509 }
510
511 /* Subordinate bus on the bridge */
512 DPRINT1("PCI - AddDevice (new bus is child of bus 0x%x).\n",
513 ParentExtension->BaseBus);
514
515 /* Make sure PCI bus numbers are configured */
517 {
518 /* This is a critical failure */
519 DPRINT1("PCI - Bus numbers not configured for bridge (0x%x.0x%x.0x%x)\n",
520 ParentExtension->BaseBus,
521 PdoExtension->Slot.u.bits.DeviceNumber,
522 PdoExtension->Slot.u.bits.FunctionNumber);
523
524 /* Enter the failure path */
526 break;
527 }
528 }
529
530 /* Create the FDO for the bus */
532 sizeof(PCI_FDO_EXTENSION),
533 NULL,
535 0,
536 0,
537 &DeviceObject);
538 if (!NT_SUCCESS(Status)) break;
539
540 /* Initialize the extension for the FDO */
541 FdoExtension = DeviceObject->DeviceExtension;
545
546 /* Attach to the root PDO */
550 ASSERT(AttachedTo != NULL);
551 if (!AttachedTo) break;
552 FdoExtension->AttachedDeviceObject = AttachedTo;
553
554 /* Check if this is a child bus, or the root */
555 if (ParentExtension)
556 {
557 /* The child inherits root data */
558 FdoExtension->BaseBus = PdoExtension->Dependent.type1.SecondaryBus;
559 FdoExtension->BusRootFdoExtension = ParentExtension->BusRootFdoExtension;
560 PdoExtension->BridgeFdoExtension = FdoExtension;
561 FdoExtension->ParentFdoExtension = ParentExtension;
562 }
563 else
564 {
565 /* Query the boot configuration */
568 (PVOID*)&Descriptor);
569 if (!NT_SUCCESS(Status))
570 {
571 /* No configuration has been set */
573 }
574 else
575 {
576 /* Root PDO in ReactOS does not assign boot resources */
577 UNIMPLEMENTED_DBGBREAK("Encountered during setup\n");
579 }
580
581 if (Descriptor)
582 {
583 /* Root PDO in ReactOS does not assign boot resources */
585 }
586 else
587 {
588 /* Default configuration isn't the normal path on Windows */
590 {
591 /* If a second bus is found and there's still no data, crash */
592 KeBugCheckEx(PCI_BUS_DRIVER_INTERNAL,
593 0xDEAD0010u,
595 0,
596 0);
597 }
598
599 /* Warn that a default configuration will be used, and set bus 0 */
600 DPRINT1("PCI Will use default configuration.\n");
602 FdoExtension->BaseBus = 0;
603 }
604
605 /* This is the root bus */
606 FdoExtension->BusRootFdoExtension = FdoExtension;
607 }
608
609 /* Get the HAL or ACPI Bus Handler Callbacks for Configuration Access */
611 if (!NT_SUCCESS(Status)) break;
612
613 /* Map this bus for extended configuration space access */
615
616 /* Initialize all the supported PCI arbiters */
618 if (!NT_SUCCESS(Status)) break;
619
620 /* This is a real FDO, insert it into the list */
621 FdoExtension->Fake = FALSE;
625
626 /* Open the device registry key so that we can query the errata flags */
630 &KeyHandle),
631
632 /* Open the value that contains errata flags for this bus instance */
633 RtlInitUnicodeString(&ValueName, L"HackFlags");
634 Status = ZwQueryValueKey(KeyHandle,
635 &ValueName,
637 ValueInfo,
638 sizeof(Buffer),
639 &ResultLength);
641 if (NT_SUCCESS(Status))
642 {
643 /* Make sure the data is of expected type and size */
644 if ((ValueInfo->Type == REG_DWORD) &&
645 (ValueInfo->DataLength == sizeof(ULONG)))
646 {
647 /* Read the flags for this bus */
648 FdoExtension->BusHackFlags = *(PULONG)&ValueInfo->Data;
649 }
650 }
651
652 /* Query ACPI for PCI HotPlug Support */
654
655 /* The Bus FDO is now initialized */
656 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
657 return STATUS_SUCCESS;
658 } while (FALSE);
659
660 /* This is the failure path */
662
663 /* Check if the FDO extension exists */
664 if (FdoExtension) DPRINT1("Should destroy secondaries\n");
665
666 /* Delete device objects */
667 if (AttachedTo) IoDetachDevice(AttachedTo);
669 return Status;
670}
NTSTATUS NTAPI PciInitializeArbiters(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: arb_comn.c:90
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
VOID NTAPI PciInitializeFdoExtensionCommonFields(PPCI_FDO_EXTENSION FdoExtension, IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
Definition: fdo.c:433
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:379
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:399
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:339
NTSTATUS NTAPI PciGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, OUT PVOID *OutputBuffer)
Definition: utils.c:474
#define ASSERT_PDO(x)
Definition: pci.h:38
NTSTATUS NTAPI PciGetConfigHandlers(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: config.c:266
_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:971
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:1036
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1304
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1259
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:221
struct _PCI_FDO_EXTENSION * BusRootFdoExtension
Definition: pci.h:215
unsigned char UCHAR
Definition: typedefs.h:53
#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_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3782
_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:2786
@ DevicePropertyBootConfiguration
Definition: iotypes.h:1198

◆ PciArbiter_Dereference()

VOID NTAPI PciArbiter_Dereference ( _In_ PVOID  Context)

Definition at line 39 of file arb_comn.c.

40{
42
44}
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_Reference()

VOID NTAPI PciArbiter_Reference ( _In_ PVOID  Context)

Definition at line 30 of file arb_comn.c.

31{
33
35}
#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 48 of file arb_comn.c.

51{
53 PAGED_CODE();
54
55 if (!FdoExtension->ArbitersInitialized) return STATUS_NOT_SUPPORTED;
56
57 /* Find the instance this bus built for the requested resource type */
59 SecondaryExtension.Next,
60 ArbiterType);
61 if (!Arbiter)
62 {
63 DPRINT1("PCI - FDO ext 0x%p has no %s arbiter to hand out.\n",
65 PciArbiterNames[ArbiterType - PciArb_Io]);
67 }
68
69 Interface->Size = sizeof(ARBITER_INTERFACE);
71 Interface->Context = &Arbiter->CommonInstance;
72 Interface->InterfaceReference = PciArbiter_Reference;
73 Interface->InterfaceDereference = PciArbiter_Dereference;
74 Interface->ArbiterHandler = ArbiterLibHandler;
75 Interface->Flags = 0;
76 return STATUS_SUCCESS;
77}
VOID NTAPI PciArbiter_Reference(_In_ PVOID Context)
Definition: arb_comn.c:30
PCHAR PciArbiterNames[]
Definition: arb_comn.c:18
VOID NTAPI PciArbiter_Dereference(_In_ PVOID Context)
Definition: arb_comn.c:39
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:82
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().

◆ PciBeginStateTransition()

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

Definition at line 97 of file state.c.

99{
102 DPRINT1("PCI 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\nPCI: Error trying to enter state \"%s\" "
120 "from state \"%s\"\n",
121 PciTransitionText[NewState],
124 }
126 {
127 /* Invalid transition (illegal request) */
128 DPRINT1("ERROR\nPCI: 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 PciFdoIrpStartDevice(), PciPdoIrpStartDevice(), and PciQueryDeviceRelations().

◆ PciBuildDefaultExclusionLists()

NTSTATUS NTAPI PciBuildDefaultExclusionLists ( VOID  )

Definition at line 275 of file utils.c.

276{
277 ULONG Start;
281
282 /* Initialize the range lists */
285
286 /* Loop x86 I/O ranges */
287 for (Start = 0x100; Start <= 0xFEFF; Start += 0x400)
288 {
289 /* Add the ISA I/O ranges */
291 Start,
292 Start + 0x2FF,
293 0,
295 NULL,
296 NULL);
297 if (!NT_SUCCESS(Status)) break;
298
299 /* Add the ISA I/O ranges */
301 Start,
302 Start + 0x2AF,
303 0,
305 NULL,
306 NULL);
307 if (!NT_SUCCESS(Status)) break;
308
309 /* Add the VGA I/O range for Monochrome Video */
311 Start + 0x2BC,
312 Start + 0x2BF,
313 0,
315 NULL,
316 NULL);
317 if (!NT_SUCCESS(Status)) break;
318
319 /* Add the VGA I/O range for certain CGA adapters */
321 Start + 0x2E0,
322 Start + 0x2FF,
323 0,
325 NULL,
326 NULL);
327 if (!NT_SUCCESS(Status)) break;
328
329 /* Success, ranges added done */
330 };
331
334 return Status;
335}
RTL_RANGE_LIST PciVgaAndIsaBitExclusionList
Definition: utils.c:21
RTL_RANGE_LIST PciIsaBitExclusionList
Definition: utils.c:20
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 572 of file enum.c.

575{
579 ULONG Count, i;
580 BOOLEAN HaveInterrupt;
581
582 PAGED_CODE();
583
584 /* Count the BAR limits that resource discovery found for this function */
585 Count = 0;
586 if (PdoExtension->Resources)
587 {
588 for (i = 0; i < (PCI_TYPE0_ADDRESSES + 1); i++)
589 {
590 if (PdoExtension->Resources->Limit[i].Type != CmResourceTypeNull)
591 Count++;
592 }
593 }
594
595 /* A device with an interrupt pin also needs a line routed to it */
596 HaveInterrupt = (PdoExtension->InterruptPin) &&
598 if (HaveInterrupt)
599 Count++;
600
601 /* And a bridge with legacy decodes enabled needs those ranges locked down */
602 Count += PdoExtension->AdditionalResourceCount;
603
604 /* Check if the function turned out to need nothing after all */
605 if (!Count)
606 {
607 /* There aren't, so use the zero descriptor */
609
610 /* Does it actually exist yet? */
612 {
613 /* Allocate it, and use it for future use */
617 }
618
620 DPRINT1("PCI - build resource reqs - early out, 0 resources\n");
621 return STATUS_SUCCESS;
622 }
623
625 PdoExtension->ParentFdoExtension->BaseBus,
626 PdoExtension->Slot.u.AsULONG);
627 if (!RequirementsList)
629
630 Descriptor = RequirementsList->List[0].Descriptors;
631
632 /* Emit one descriptor per BAR that decoded something during discovery */
633 if (PdoExtension->Resources)
634 {
635 Limit = PdoExtension->Resources->Limit;
636 for (i = 0; i < (PCI_TYPE0_ADDRESSES + 1); i++)
637 {
638 /* Skip the BARs this function does not implement */
640 continue;
641
642 /* A BAR decodes for one function only, so it cannot be shared */
643 *Descriptor = Limit[i];
644 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
645 Descriptor++;
646 }
647 }
648
649 if (HaveInterrupt)
650 {
652 Descriptor->ShareDisposition = CmResourceShareShared;
654 Descriptor->u.Interrupt.MinimumVector = 0;
655 Descriptor->u.Interrupt.MaximumVector = MAXULONG;
656 Descriptor++;
657 }
658
659 /* And finally any extra ranges this kind of function decodes on the side */
660 if (PdoExtension->AdditionalResourceCount)
661 {
662 RtlZeroMemory(&Context, sizeof(Context));
663 Context.PdoExtension = PdoExtension;
664 Context.Current = PciData;
665 PciConfigurators[PdoExtension->HeaderType].
666 GetAdditionalResourceDescriptors(&Context, PciData, Descriptor);
667 }
668
670 return STATUS_SUCCESS;
671}
Type
Definition: Type.h:7
unsigned char BOOLEAN
Definition: actypes.h:127
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:308
PCI_CONFIGURATOR PciConfigurators[]
Definition: enum.c:20
int Count
Definition: noreturn.cpp:7
#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
#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 PciAssignSlotResources(), and PciQueryRequirements().

◆ 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 70 of file routintf.c.

80{
82 PPCI_LEGACY_DEVICE LegacyDevice;
83 PDEVICE_OBJECT FoundDeviceObject;
84 PAGED_CODE();
85
86 /* Scan current registered devices */
87 LegacyDevice = PciLegacyDeviceHead;
89 while (LegacyDevice)
90 {
91 /* Find a match */
92 if ((BusNumber == LegacyDevice->BusNumber) &&
93 (SlotNumber == LegacyDevice->SlotNumber))
94 {
95 /* We already know about this routing */
96 break;
97 }
98
99 /* We know about device already, but for a different location */
100 if (LegacyDevice->DeviceObject == DeviceObject)
101 {
102 /* Free the existing structure, move to the next one */
103 *Link = LegacyDevice->Next;
104 ExFreePoolWithTag(LegacyDevice, 0);
105 LegacyDevice = *Link;
106 }
107 else
108 {
109 /* Keep going */
110 Link = &LegacyDevice->Next;
111 LegacyDevice = LegacyDevice->Next;
112 }
113 }
114
115 /* Did we find a match? */
116 if (!LegacyDevice)
117 {
118 /* Allocate a new cache structure */
119 LegacyDevice = ExAllocatePoolWithTag(PagedPool,
120 sizeof(PCI_LEGACY_DEVICE),
121 'PciR');
122 if (!LegacyDevice) return STATUS_INSUFFICIENT_RESOURCES;
123
124 /* Save all the data in it */
125 RtlZeroMemory(LegacyDevice, sizeof(PCI_LEGACY_DEVICE));
126 LegacyDevice->BusNumber = BusNumber;
127 LegacyDevice->SlotNumber = SlotNumber;
128 LegacyDevice->InterruptLine = InterruptLine;
129 LegacyDevice->InterruptPin = InterruptPin;
130 LegacyDevice->BaseClass = BaseClass;
131 LegacyDevice->SubClass = SubClass;
133 LegacyDevice->DeviceObject = DeviceObject;
134 LegacyDevice->PdoExtension = PdoExtension;
135
136 /* Link it in the list */
137 LegacyDevice->Next = PciLegacyDeviceHead;
138 PciLegacyDeviceHead = LegacyDevice;
139 }
140
141 /* Check if we found, or created, a matching caching structure */
142 FoundDeviceObject = LegacyDevice->DeviceObject;
143 if (FoundDeviceObject == DeviceObject)
144 {
145 /* Return the device object and success */
146 if (pFoundDeviceObject) *pFoundDeviceObject = DeviceObject;
147 return STATUS_SUCCESS;
148 }
149
150 /* Otherwise, this is a new device object for this location */
151 LegacyDevice->DeviceObject = DeviceObject;
152 if (pFoundDeviceObject) *pFoundDeviceObject = FoundDeviceObject;
153 return STATUS_SUCCESS;
154}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ ULONG BusNumber
Definition: pciidex.h:65
PPCI_LEGACY_DEVICE PciLegacyDeviceHead
Definition: routintf.c:18
UCHAR InterruptPin
Definition: pci.h:543
UCHAR SubClass
Definition: pci.h:545
UCHAR BaseClass
Definition: pci.h:544
PPCI_PDO_EXTENSION PdoExtension
Definition: pci.h:548
UCHAR InterruptLine
Definition: pci.h:542
PDEVICE_OBJECT PhysicalDeviceObject
Definition: pci.h:546
PDEVICE_OBJECT DeviceObject
Definition: pci.h:539
struct _PCI_LEGACY_DEVICE * Next
Definition: pci.h:538
ULONG BusNumber
Definition: pci.h:540
ULONG SlotNumber
Definition: pci.h:541
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 DPRINT1("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}
_In_ PIRP Irp
Definition: csq.h:116
_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:37
#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
#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("PCI 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 PciFdoIrpStartDevice(), 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 954 of file utils.c.

958{
959 UCHAR BaseClass, SubClass;
960 BOOLEAN IsVga, KeepPower = FALSE;
961
962 /* Is there a device extension or should the PCI header be used? */
963 if (DeviceExtension)
964 {
965 /* Never disable decodes for a debug PCI Device */
966 if (DeviceExtension->OnDebugPath) return FALSE;
967
968 /* Hack flags will be obtained from the extension, not the caller */
969 ASSERT(HackFlags == 0);
970
971 /* Get hacks and classification from the device extension */
972 HackFlags = DeviceExtension->HackFlags;
973 SubClass = DeviceExtension->SubClass;
974 BaseClass = DeviceExtension->BaseClass;
975 KeepPower = DeviceExtension->DisablePowerDown;
976 }
977 else
978 {
979 /* There must be a PCI header, go read the classification information */
980 ASSERT(Config != NULL);
981 BaseClass = Config->BaseClass;
982 SubClass = Config->SubClass;
983 }
984
985 /* Check for hack flags that prevent disabling the decodes */
990 {
991 /* Don't do it */
992 return FALSE;
993 }
994
995 if (ForPowerDown)
996 {
997 /* IDE controllers, legacy bridges and flagged functions may stop but not power down */
998 if (KeepPower || (HackFlags & PCI_HACK_NEVER_POWER_DOWN))
999 return FALSE;
1000 }
1002 {
1003 /* Flagged functions may power down, but keep decoding while stopped or removed */
1004 return FALSE;
1005 }
1006
1007 /* VGA adapters keep decoding unless they are being powered down */
1008 if (((BaseClass == PCI_CLASS_DISPLAY_CTLR) && (SubClass == PCI_SUBCLASS_VID_VGA_CTLR)) ||
1009 ((BaseClass == PCI_CLASS_PRE_20) && (SubClass == PCI_SUBCLASS_PRE_20_VGA)))
1010 {
1011 return ForPowerDown;
1012 }
1013
1014 if (BaseClass == PCI_CLASS_BRIDGE_DEV)
1015 {
1016 /* Check for legacy bridges */
1017 if ((SubClass == PCI_SUBCLASS_BR_ISA) ||
1018 (SubClass == PCI_SUBCLASS_BR_EISA) ||
1019 (SubClass == PCI_SUBCLASS_BR_MCA) ||
1020 (SubClass == PCI_SUBCLASS_BR_HOST) ||
1021 (SubClass == PCI_SUBCLASS_BR_OTHER))
1022 {
1023 /* Never disable these */
1024 return FALSE;
1025 }
1026 else if ((SubClass == PCI_SUBCLASS_BR_PCI_TO_PCI) ||
1027 (SubClass == PCI_SUBCLASS_BR_CARDBUS))
1028 {
1029 /* This is a supported bridge, but does it have a VGA card? */
1030 if (!DeviceExtension)
1031 {
1032 /* Read the bridge control flag from the PCI header */
1033 IsVga = Config->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA;
1034 }
1035 else
1036 {
1037 /* Read the cached flag in the device extension */
1038 IsVga = DeviceExtension->Dependent.type1.VgaBitSet;
1039 }
1040
1041 /* A bridge forwarding VGA follows the same rule as the adapter behind it */
1042 if (IsVga)
1043 return ForPowerDown;
1044 }
1045 }
1046
1047 /* Nothing else has to keep decoding */
1048 return TRUE;
1049}
_In_ ULONG_PTR HackFlags
Definition: cdrom.h:983
#define PCI_HACK_PRESERVE_COMMAND
Definition: pci.h:25
#define PCI_ENABLE_BRIDGE_VGA
Definition: pci.h:63
#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_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476
#define PCI_SUBCLASS_BR_OTHER
Definition: iotypes.h:4173
#define PCI_SUBCLASS_BR_EISA
Definition: iotypes.h:4166
#define PCI_SUBCLASS_BR_HOST
Definition: iotypes.h:4164
#define PCI_SUBCLASS_BR_MCA
Definition: iotypes.h:4167
#define PCI_SUBCLASS_BR_ISA
Definition: iotypes.h:4165
#define PCI_SUBCLASS_BR_CARDBUS
Definition: iotypes.h:4171
#define PCI_CLASS_PRE_20
Definition: iotypes.h:4105
#define PCI_SUBCLASS_VID_VGA_CTLR
Definition: iotypes.h:4147
#define PCI_SUBCLASS_PRE_20_VGA
Definition: iotypes.h:4127
#define PCI_CLASS_DISPLAY_CTLR
Definition: iotypes.h:4108

Referenced by PciDecodeEnable(), 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 109 of file cardbus.c.

115{
116 UNREFERENCED_PARAMETER(DeviceExtension);
118 UNREFERENCED_PARAMETER(InterfaceData);
122
123 /* Not yet implemented */
126}

◆ pcicbintrf_Initializer()

NTSTATUS NTAPI pcicbintrf_Initializer ( IN PVOID  Instance)

Definition at line 99 of file cardbus.c.

100{
102 /* PnP Interfaces don't get Initialized */
103 ASSERTMSG("PCI pcicbintrf_Initializer, unexpected call.\n", FALSE);
104 return STATUS_UNSUCCESSFUL;
105}

◆ PciClassifyDeviceType()

PCI_DEVICE_TYPES NTAPI PciClassifyDeviceType ( IN PPCI_PDO_EXTENSION  PdoExtension)

Definition at line 1053 of file utils.c.

1054{
1055 ASSERT(PdoExtension->ExtensionType == PciPdoExtensionType);
1056
1057 /* Differentiate between devices and bridges */
1058 if (PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) return PciTypeDevice;
1059
1060 /* The PCI Bus driver handles only CardBus and PCI bridges (plus host) */
1061 if (PdoExtension->SubClass == PCI_SUBCLASS_BR_HOST) return PciTypeHostBridge;
1064
1065 /* Any other kind of bridge is treated like a device */
1066 return PciTypeDevice;
1067}

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("PCI 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 PciFdoIrpStartDevice(), and PciPdoIrpStartDevice().

◆ 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 /* Clear the temporary resource array */
93 for (i = 0; i < 7; i++) ResourceArray[i].Type = CmResourceTypeNull;
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 (PciResources->Limit[BarIndex].Type == CmResourceTypeNull))
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 a compatible (and the only) PCI interrupt */
153 ASSERT(InterruptResource == NULL);
154 ASSERT(Partial->u.Interrupt.Level == Partial->u.Interrupt.Vector);
155 InterruptResource = Partial;
156
157 /* Only 255 interrupts on x86/x64 hardware */
158 if (Partial->u.Interrupt.Level < 256)
159 {
160 /* Use the passed interrupt line */
161 PdoExtension->AdjustedInterruptLine = Partial->u.Interrupt.Level;
162 }
163 else
164 {
165 /* Invalid vector, so ignore it */
166 PdoExtension->AdjustedInterruptLine = 0;
167 }
168
169 break;
170
171 /* Check for specific device data */
173
174 /* Check what kind of data this was */
175 switch (Partial->u.DevicePrivate.Data[0])
176 {
177 /* Not used in the driver yet */
178 case 1:
180 break;
181
182 /* Not used in the driver yet */
183 case 2:
185 break;
186
187 /* A drain request */
188 case 3:
189 DrainPartial = Partial->u.DevicePrivate.Data[1];
190 break;
191 }
192 break;
193 }
194
195 /* Move to the next descriptor */
196 Partial = CmiGetNextPartialDescriptor(Partial);
197 }
198
199 /* We should be starting a new list now */
200 FullList = (PVOID)Partial;
201 }
202
203 /* A function with no discovered resources has nothing to update */
204 if (!PciResources) return FALSE;
205
206 /* Loop all the PCI function resources */
207 for (i = 0; i < RTL_NUMBER_OF(ResourceArray); i++)
208 {
209 /* Get the current function resource descriptor, and the new one */
210 CurrentDescriptor = &PciResources->Current[i];
211 Partial = &ResourceArray[i];
212
213 /* Check if this new descriptor is different than the old one */
214 if ((Partial->Type != CurrentDescriptor->Type) ||
215 ((Partial->Type != CmResourceTypeNull) &&
216 ((Partial->u.Generic.Start.QuadPart !=
217 CurrentDescriptor->u.Generic.Start.QuadPart) ||
218 (RtlCmDecodeMemIoResource(Partial, NULL) !=
219 RtlCmDecodeMemIoResource(CurrentDescriptor, NULL)))))
220 {
221 /* Record a change */
222 RangeChange = TRUE;
223
224 /* Was there a range before? */
225 if (CurrentDescriptor->Type != CmResourceTypeNull)
226 {
227 /* Print it */
228 DbgPrint(" Old range-\n");
229 PciDebugPrintPartialResource(CurrentDescriptor);
230 }
231 else
232 {
233 /* There was no range */
234 DbgPrint(" Previously unset range\n");
235 }
236
237 /* Print new one */
238 DbgPrint(" changed to\n");
240
241 /* Update to new range */
242 CurrentDescriptor->Type = Partial->Type;
243 CurrentDescriptor->Flags = Partial->Flags;
244 CurrentDescriptor->u.Generic.Start = Partial->u.Generic.Start;
245 CurrentDescriptor->u.Generic.Length = Partial->u.Generic.Length;
246 }
247 }
248
249 /* Either the hardware was updated, or a resource range changed */
250 return ((RangeChange) || (PdoExtension->UpdateHardware));
251}
#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 CmResourceTypeDevicePrivate
Definition: restypes.h:112
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: restypes.h:145
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@486::@489 Interrupt
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@486::@493 DevicePrivate
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: restypes.h:100
IO_RESOURCE_DESCRIPTOR Limit[7]
Definition: pci.h:247
CM_PARTIAL_RESOURCE_DESCRIPTOR Current[7]
Definition: pci.h:248
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
@ CmResourceShareDriverExclusive
Definition: cmtypes.h:242

Referenced by PciAssignSlotResources(), 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 1179 of file utils.c.

1184{
1185 ULONGLONG AddressBits, Length, Alignment;
1187 UCHAR Type;
1188 BOOLEAN Is64BitBar = FALSE;
1189
1190 /* Check if the BAR is nor I/O nor memory */
1191 if (!(Bar & ~PCI_ADDRESS_IO_SPACE))
1192 {
1193 /* Fail this descriptor */
1194 ResourceDescriptor->Type = CmResourceTypeNull;
1195 return FALSE;
1196 }
1197
1198 /* Set default flag */
1199 ResourceDescriptor->Flags = 0;
1200
1201 /* Check for ROM AddressBits */
1202 if (Rom)
1203 {
1204 /* Clean up the BAR to get just the address */
1206 if (!Bar)
1207 {
1208 /* Invalid ar, fail this descriptor */
1209 ResourceDescriptor->Type = CmResourceTypeNull;
1210 return FALSE;
1211 }
1212
1213 /* ROM Addresses are always read only */
1214 ResourceDescriptor->Flags = CM_RESOURCE_MEMORY_READ_ONLY;
1215 }
1216
1217 /* Check what kind of BAR this is */
1219 {
1220 /* Set this as an I/O Port descriptor */
1222 ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO;
1223 AddressBits = Bar & PCI_ADDRESS_IO_ADDRESS_MASK;
1224 }
1225 else
1226 {
1227 /* Set this as a memory descriptor */
1229 AddressBits = Bar & PCI_ADDRESS_MEMORY_ADDRESS_MASK;
1230
1231 /* A 64-bit BAR takes the high half of its address from the next BAR */
1233 {
1234 AddressBits |= (ULONGLONG)NextBar << 32;
1235 Is64BitBar = TRUE;
1236 }
1237
1238 /* Check if the BAR is listed as prefetchable memory */
1240 {
1241 /* Mark the descriptor in the same way */
1242 ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE;
1243 }
1244 }
1245
1246 /* The probe leaves only the bits the BAR implements, so the lowest one is its length */
1247 Length = AddressBits & (~AddressBits + 1);
1248
1249 /* A BAR that implements no address bits is not there */
1250 if (!Length)
1251 {
1252 ResourceDescriptor->Type = CmResourceTypeNull;
1253 return FALSE;
1254 }
1255
1256 /* A legacy memory BAR can only be placed below 1MB */
1257 if ((Type == CmResourceTypeMemory) &&
1259 {
1260 AddressBits &= 0xFFFFF;
1261 }
1262
1263 /* A BAR aligns to its own length and decodes nothing above the bits it implements */
1264 Alignment = Length;
1265 MinimumAddress = 0;
1266 MaximumAddress = AddressBits | (Length - 1);
1267
1268 /* A length of 4GB or more takes the large memory form */
1269 if (!NT_SUCCESS(RtlIoEncodeMemIoResource(ResourceDescriptor,
1270 Type,
1271 Length,
1272 Alignment,
1275 {
1276 /* Fail this descriptor */
1277 ResourceDescriptor->Type = CmResourceTypeNull;
1278 }
1279
1280 /* Return if this is a 64-bit BAR, so the loop code knows to skip the next one */
1281 return Is64BitBar;
1282}
static _Out_opt_ PULONGLONG _Out_opt_ PULONGLONG MinimumAddress
static _Out_opt_ PULONGLONG _Out_opt_ PULONGLONG _Out_opt_ PULONGLONG MaximumAddress
#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:4235
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 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}
unsigned short USHORT
Definition: pedump.c:61
#define PCI_COMMON_HDR_LENGTH
Definition: iotypes.h:3596

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("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("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("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("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:283
PPCI_FDO_EXTENSION ParentFdoExtension
Definition: pci.h:285
union _PCI_SLOT_NUMBER::@4969 u
struct _PCI_SLOT_NUMBER::@4969::@4970 bits
char * PCHAR
Definition: typedefs.h:51
_In_ PIO_STACK_LOCATION IoStackLocation
Definition: usbdlib.h:265
#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 1286 of file utils.c.

1289{
1290 USHORT CommandValue;
1291
1292 /*
1293 * If decodes are being disabled, make sure it's allowed, and in both cases,
1294 * make sure that a hackflag isn't preventing touching the decodes at all.
1295 */
1296 if (((Enable) || (PciCanDisableDecodes(PdoExtension, 0, 0, 0))) &&
1298 {
1299 /* Did the caller already have a command word? */
1300 if (Command)
1301 {
1302 /* Use the caller's */
1303 CommandValue = *Command;
1304 }
1305 else
1306 {
1307 /* Otherwise, read the current command */
1309 &Command,
1311 sizeof(USHORT));
1312 }
1313
1314 /* Turn off decodes by default */
1315 CommandValue &= ~(PCI_ENABLE_IO_SPACE |
1318
1319 /* If requested, enable the decodes that were enabled at init time */
1320 if (Enable) CommandValue |= PdoExtension->CommandEnables &
1324
1325 /* Update the command word */
1327 &CommandValue,
1329 sizeof(USHORT));
1330 }
1331}
VOID NTAPI PciWriteDeviceConfig(IN PPCI_PDO_EXTENSION DeviceExtension, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: config.c:133
VOID NTAPI PciReadDeviceConfig(IN PPCI_PDO_EXTENSION DeviceExtension, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: config.c:149
BOOLEAN NTAPI PciCanDisableDecodes(IN PPCI_PDO_EXTENSION DeviceExtension, IN PPCI_COMMON_HEADER Config, IN ULONGLONG HackFlags, IN BOOLEAN ForPowerDown)
Definition: utils.c:954
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
Definition: shell.h:41
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define PCI_ENABLE_BUS_MASTER
Definition: iotypes.h:3620
#define PCI_ENABLE_IO_SPACE
Definition: iotypes.h:3618
#define PCI_ENABLE_MEMORY_SPACE
Definition: iotypes.h:3619

Referenced by PciApplyHacks(), PciConfigureIdeController(), 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 DPRINT1("PCI: 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:339
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:207
ULONG ExtensionType
Definition: pci.h:205
struct _PCI_MJ_DISPATCH_TABLE * IrpDispatchTable
Definition: pci.h:206
ULONG PnpIrpMaximumMinorFunction
Definition: pci.h:359
PCI_DISPATCH_FUNCTION SystemControlIrpDispatchFunction
Definition: pci.h:364
PPCI_MN_DISPATCH_TABLE PowerIrpDispatchTable
Definition: pci.h:362
PCI_DISPATCH_STYLE OtherIrpDispatchStyle
Definition: pci.h:365
PCI_DISPATCH_FUNCTION OtherIrpDispatchFunction
Definition: pci.h:366
ULONG PowerIrpMaximumMinorFunction
Definition: pci.h:361
PPCI_MN_DISPATCH_TABLE PnpIrpDispatchTable
Definition: pci.h:360
PCI_DISPATCH_STYLE SystemControlIrpDispatchStyle
Definition: pci.h:363
#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 386 of file ecam.c.

393{
395
396 if (!PciEcamVerified) return FALSE;
397
400 {
401 return FALSE;
402 }
403
404 Function = PciEcamFunctionBase(Bus, Slot);
405 if (!Function) return FALSE;
406
408 return TRUE;
409}
_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:3598

Referenced by PciReadWriteConfigSpace().

◆ PciExecuteCriticalSystemRoutine()

ULONG_PTR NTAPI PciExecuteCriticalSystemRoutine ( IN ULONG_PTR  IpiContext)

Definition at line 1071 of file utils.c.

1072{
1074
1075 /* Check if the IPI is already running */
1076 if (!InterlockedDecrement(&Context->RunCount))
1077 {
1078 /* Nope, this is the first instance, so execute the IPI function */
1079 Context->Function(Context->DeviceExtension, Context->Context);
1080
1081 /* Notify anyone that was spinning that they can stop now */
1082 Context->Barrier = 0;
1083 }
1084 else
1085 {
1086 /* Spin until it has finished running */
1087 while (Context->Barrier);
1088 }
1089
1090 /* Done */
1091 return 0;
1092}
struct _PCI_IPI_CONTEXT * PPCI_IPI_CONTEXT
PCI_IPI_FUNCTION Function
Definition: pci.h:529

◆ PciFdoIrpCancelRemoveDevice()

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

Definition at line 152 of file fdo.c.

◆ PciFdoIrpCancelStopDevice()

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

Definition at line 194 of file fdo.c.

◆ PciFdoIrpDeviceUsageNotification()

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

Definition at line 337 of file fdo.c.

◆ PciFdoIrpQueryCapabilities()

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

Definition at line 310 of file fdo.c.

313{
315 PAGED_CODE();
316 ASSERT_FDO(DeviceExtension);
317
319
320 /* Get the capabilities */
322
323 /* Inherit wake levels and power mappings from the higher-up capabilities */
324 DeviceExtension->PowerState.SystemWakeLevel = Capabilities->SystemWake;
325 DeviceExtension->PowerState.DeviceWakeLevel = Capabilities->DeviceWake;
326 RtlCopyMemory(DeviceExtension->PowerState.SystemStateMapping,
327 Capabilities->DeviceState,
328 sizeof(DeviceExtension->PowerState.SystemStateMapping));
329
330 /* Dump the capabilities and return success */
332 return STATUS_SUCCESS;
333}
VOID NTAPI PciDebugDumpQueryCapabilities(IN PDEVICE_CAPABILITIES DeviceCaps)
Definition: debug.c:221
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
union _IO_STACK_LOCATION::@1803 Parameters
struct _IO_STACK_LOCATION::@4925::@4952 DeviceCapabilities
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
* 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 208 of file fdo.c.

211{
213 PAGED_CODE();
214
215 /* Are bus relations being queried? */
217 {
218 /* The FDO is a bus, so only bus relations can be obtained */
220 }
221 else
222 {
223 /* Scan the PCI bus and build the device relations for the caller */
224 Status = PciQueryDeviceRelations(DeviceExtension,
226 &Irp->IoStatus.Information);
227 }
228
229 /* Return the enumeration status back */
230 return Status;
231}
NTSTATUS NTAPI PciQueryDeviceRelations(IN PPCI_FDO_EXTENSION DeviceExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: enum.c:2134
struct _IO_STACK_LOCATION::@4925::@4950 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 235 of file fdo.c.

238{
240 PAGED_CODE();
241 ASSERT(DeviceExtension->ExtensionType == PciFdoExtensionType);
242
243 /* Deleted extensions don't respond to IRPs */
244 if (DeviceExtension->DeviceState == PciDeleted)
245 {
246 /* Hand it back to try to deal with it */
247 return PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
248 }
249
250 /* Query our driver for this interface */
251 Status = PciQueryInterface(DeviceExtension,
255 Size,
257 Version,
261 Interface,
262 FALSE);
263 if (NT_SUCCESS(Status))
264 {
265 /* We found it, let the PDO handle it */
266 Irp->IoStatus.Status = Status;
267 return PciPassIrpFromFdoToPdo(DeviceExtension, Irp);
268 }
269 else if (Status == STATUS_NOT_SUPPORTED)
270 {
271 /* Otherwise, we can't handle it, let someone else down the stack try */
272 Status = PciCallDownIrpStack(DeviceExtension, Irp);
274 {
275 /* They can't either, try a last-resort interface lookup */
276 Status = PciQueryInterface(DeviceExtension,
280 Size,
282 Version,
286 Interface,
287 TRUE);
288 }
289 }
290
291 /* Has anyone claimed this interface yet? */
293 {
294 /* No, return the original IRP status */
295 Status = Irp->IoStatus.Status;
296 }
297 else
298 {
299 /* Yes, set the new IRP status */
300 Irp->IoStatus.Status = Status;
301 }
302
303 /* Complete this IRP */
305 return Status;
306}
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::@4925::@4951 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 365 of file fdo.c.

◆ PciFdoIrpQueryPower()

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

Definition at line 236 of file power.c.

239{
242 UNREFERENCED_PARAMETER(DeviceExtension);
243
245 while (TRUE);
247}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15

◆ PciFdoIrpQueryRemoveDevice()

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

Definition at line 124 of file fdo.c.

◆ PciFdoIrpQueryStopDevice()

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

Definition at line 180 of file fdo.c.

◆ PciFdoIrpRemoveDevice()

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

Definition at line 138 of file fdo.c.

◆ PciFdoIrpStartDevice()

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

Definition at line 76 of file fdo.c.

79{
82 PAGED_CODE();
83
84 /* The device stack must be starting the FDO in a success path */
85 if (!NT_SUCCESS(Irp->IoStatus.Status)) return STATUS_NOT_SUPPORTED;
86
87 /* Attempt to switch the state machine to the started state */
88 Status = PciBeginStateTransition(DeviceExtension, PciStarted);
89 if (!NT_SUCCESS(Status)) return Status;
90
91 /* Check for any boot-provided resources */
92 Resources = IoStackLocation->Parameters.StartDevice.AllocatedResources;
93 if ((Resources) && !(PCI_IS_ROOT_FDO(DeviceExtension)))
94 {
95 /* These resources would only be for non-root FDOs, unhandled for now */
96 ASSERT(Resources->Count == 1);
98 }
99
100 /* Initialize the arbiter for this FDO */
101 Status = PciInitializeArbiterRanges(DeviceExtension, Resources);
102 if (!NT_SUCCESS(Status))
103 {
104 /* Cancel the transition if this failed */
105 PciCancelStateTransition(DeviceExtension, PciStarted);
106 return Status;
107 }
108
109 /* Again, check for boot-provided resources for non-root FDO */
110 if ((Resources) && !(PCI_IS_ROOT_FDO(DeviceExtension)))
111 {
112 /* Unhandled for now */
113 ASSERT(Resources->Count == 1);
115 }
116
117 /* Commit the transition to the started state */
118 PciCommitStateTransition(DeviceExtension, PciStarted);
119 return STATUS_SUCCESS;
120}
NTSTATUS NTAPI PciInitializeArbiterRanges(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCM_RESOURCE_LIST Resources)
Definition: arb_comn.c:181
NTSTATUS NTAPI PciCancelStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:145
NTSTATUS NTAPI PciBeginStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:97
VOID NTAPI PciCommitStateTransition(IN PPCI_FDO_EXTENSION DeviceExtension, IN PCI_STATE NewState)
Definition: state.c:181
struct _IO_STACK_LOCATION::@4925::@4962 StartDevice

◆ PciFdoIrpStopDevice()

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

Definition at line 166 of file fdo.c.

◆ PciFdoIrpSurpriseRemoval()

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

Definition at line 351 of file fdo.c.

◆ PciFdoSetPowerState()

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

Definition at line 221 of file power.c.

224{
227 UNREFERENCED_PARAMETER(DeviceExtension);
228
230 while (TRUE);
232}

◆ PciFdoWaitWake()

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

Definition at line 206 of file power.c.

209{
212 UNREFERENCED_PARAMETER(DeviceExtension);
213
215 while (TRUE);
217}

◆ PciFindNextSecondaryExtension()

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

Definition at line 583 of file utils.c.

585{
586 PSINGLE_LIST_ENTRY NextEntry;
588
589 /* Scan the list */
590 for (NextEntry = ListHead; NextEntry; NextEntry = NextEntry->Next)
591 {
592 /* Grab each extension and check if it's the one requested */
594 if (Extension->ExtensionType == ExtensionType) return Extension;
595 }
596
597 /* Nothing was found */
598 return NULL;
599}
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
Definition: ntbasedef.h:640
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 339 of file utils.c.

341{
342 PPCI_FDO_EXTENSION DeviceExtension;
343 PPCI_PDO_EXTENSION SearchExtension, FoundExtension;
344
345 /* Assume we'll find nothing */
346 SearchExtension = DeviceObject->DeviceExtension;
347 FoundExtension = NULL;
348
349 /* Check if a lock was specified */
350 if (Lock)
351 {
352 /* Wait for the lock to be released */
355 }
356
357 /* Now search for the extension */
359 while (DeviceExtension)
360 {
361 /* Acquire this device's lock */
363 KeWaitForSingleObject(&DeviceExtension->ChildListLock,
364 Executive,
366 FALSE,
367 NULL);
368
369 /* Scan all children PDO, stop when no more PDOs, or found it */
370 for (FoundExtension = DeviceExtension->ChildPdoList;
371 ((FoundExtension) && (FoundExtension != SearchExtension));
372 FoundExtension = FoundExtension->Next);
373
374 /* Release this device's lock */
375 KeSetEvent(&DeviceExtension->ChildListLock, IO_NO_INCREMENT, FALSE);
377
378 /* If we found it, break out */
379 if (FoundExtension) break;
380
381 /* Move to the next device */
382 DeviceExtension = (PPCI_FDO_EXTENSION)DeviceExtension->List.Next;
383 }
384
385 /* Check if we had acquired a lock previously */
386 if (Lock)
387 {
388 /* Release it */
391 }
392
393 /* Return which extension was found, if any */
394 return DeviceExtension;
395}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
#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
SINGLE_LIST_ENTRY List
Definition: pci.h:204
struct _PCI_PDO_EXTENSION * ChildPdoList
Definition: pci.h:214
KEVENT ChildListLock
Definition: pci.h:213
PVOID Next
Definition: pci.h:276
_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 694 of file utils.c.

697{
698 KIRQL Irql;
700
701 /* Get the current IRQL when this call was made */
703
704 /* Is this a low-IRQL call? */
705 if (Irql < DISPATCH_LEVEL)
706 {
707 /* Acquire this device's lock */
709 KeWaitForSingleObject(&DeviceExtension->ChildListLock,
710 Executive,
712 FALSE,
713 NULL);
714 }
715
716 /* Loop every child PDO */
717 for (PdoExtension = DeviceExtension->ChildPdoList;
720 {
721 /* Find only enumerated PDOs */
722 if (!PdoExtension->ReportedMissing)
723 {
724 /* Check if the function number and header data matches */
725 if ((FunctionNumber == PdoExtension->Slot.u.AsULONG) &&
726 (PdoExtension->VendorId == PciData->VendorID) &&
727 (PdoExtension->DeviceId == PciData->DeviceID) &&
728 (PdoExtension->RevisionId == PciData->RevisionID))
729 {
730 /* This is considered to be the same PDO */
731 break;
732 }
733 }
734 }
735
736 /* Was this a low-IRQL call? */
737 if (Irql < DISPATCH_LEVEL)
738 {
739 /* Release this device's lock */
740 KeSetEvent(&DeviceExtension->ChildListLock, IO_NO_INCREMENT, FALSE);
742 }
743
744 /* If the search found something, this is non-NULL, otherwise it's NULL */
745 return PdoExtension;
746}
_Out_ PKIRQL Irql
Definition: csq.h:179
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().

◆ 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}
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
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 767 of file utils.c.

769{
772 UNICODE_STRING KeyName, KeyValue;
773 WCHAR Buffer[32];
775 PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PVOID)DataBuffer;
778 PAGED_CODE();
779
780 /* Open the PCI key */
781 Status = IoOpenDeviceRegistryKey(DeviceExtension->ParentFdoExtension->
783 TRUE,
785 &KeyHandle);
786 if (!NT_SUCCESS(Status)) return Status;
787
788 /* Create a volatile BIOS configuration key */
789 RtlInitUnicodeString(&KeyName, L"BiosConfig");
791 &KeyName,
793 KeyHandle,
794 NULL);
795 Status = ZwCreateKey(&SubKeyHandle,
796 KEY_READ,
798 0,
799 NULL,
801 NULL);
803 if (!NT_SUCCESS(Status)) return Status;
804
805 /* Create the key value based on the device and function number */
807 L"DEV_%02x&FUN_%02x",
808 DeviceExtension->Slot.u.bits.DeviceNumber,
809 DeviceExtension->Slot.u.bits.FunctionNumber);
810 RtlInitUnicodeString(&KeyValue, Buffer);
811
812 /* Query the value information (PCI BIOS configuration header) */
813 Status = ZwQueryValueKey(SubKeyHandle,
814 &KeyValue,
816 PartialInfo,
817 sizeof(DataBuffer),
818 &ResultLength);
820 if (!NT_SUCCESS(Status)) return Status;
821
822 /* If any information was returned, go ahead and copy its data */
823 ASSERT(PartialInfo->DataLength == PCI_COMMON_HDR_LENGTH);
824 RtlCopyMemory(PciData, PartialInfo->Data, PCI_COMMON_HDR_LENGTH);
825 return Status;
826}
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 PciScanBus(), and PPBridge_SaveCurrentSettings().

◆ PciGetConfigHandlers()

NTSTATUS NTAPI PciGetConfigHandlers ( IN PPCI_FDO_EXTENSION  FdoExtension)

Definition at line 266 of file config.c.

267{
268 PBUS_HANDLER BusHandler;
270 ASSERT(FdoExtension->BusHandler == NULL);
271
272 /* Check if this is the FDO for the root bus */
274 {
275 /* Query the PCI Bus Interface that ACPI exposes */
276 ASSERT(FdoExtension->PciBusInterface == NULL);
278 if (!NT_SUCCESS(Status))
279 {
280 /* No ACPI, so Bus Numbers should be maintained by BIOS */
282 }
283 else
284 {
285 /* ACPI detected, PCI Bus Driver will reconfigure bus numbers*/
287 }
288 }
289 else
290 {
291 /* Check if the root bus already has the interface set up */
292 if (FdoExtension->BusRootFdoExtension->PciBusInterface)
293 {
294 /* Nothing for this FDO to do */
295 return STATUS_SUCCESS;
296 }
297
298 /* Fail into case below so we can query the HAL interface */
300 }
301
302 /* If the ACPI PCI Bus Interface couldn't be obtained, try the HAL */
303 if (!NT_SUCCESS(Status))
304 {
305 /* Bus number assignment should be static */
308
309 /* Call the HAL to obtain the bus handler for PCI */
310 BusHandler = HalReferenceHandlerForBus(PCIBus, FdoExtension->BaseBus);
311 FdoExtension->BusHandler = BusHandler;
312
313 /* Fail if the HAL does not have a PCI Bus Handler for this bus */
314 if (!BusHandler) return STATUS_INVALID_DEVICE_REQUEST;
315 }
316
317 /* Appropriate interface was obtained */
318 return STATUS_SUCCESS;
319}
NTSTATUS NTAPI PciQueryForPciBusInterface(IN PPCI_FDO_EXTENSION FdoExtension)
Definition: config.c:177
BOOLEAN PciAssignBusNumbers
Definition: config.c:18
@ PCIBus
Definition: restypes.h:127
#define HalReferenceHandlerForBus
Definition: haltypes.h:307

Referenced by PciAddDevice().

◆ PciGetDeviceDescriptionMessage()

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

Definition at line 88 of file id.c.

90{
93
94 /* The message identifier in the table is encoded based on the PCI class */
95 Identifier = (BaseClass << 8) | SubClass;
96
97 /* Go grab the description message for this device */
99 if (!Message)
100 {
101 /* It wasn't found, allocate a buffer for a generic description */
102 Message = ExAllocatePoolWithTag(PagedPool, sizeof(L"PCI Device"), 'bicP');
103 if (Message) RtlCopyMemory(Message, L"PCI Device", sizeof(L"PCI Device"));
104 }
105
106 /* Return the description message */
107 return Message;
108}
@ Identifier
Definition: asmpp.cpp:95
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 474 of file utils.c.

477{
481 do
482 {
483 /* Query the requested property size */
486 0,
487 NULL,
488 &BufferLength);
490 {
491 /* Call should've failed with buffer too small! */
492 DPRINT1("PCI - Unexpected status from GetDeviceProperty, saw %08X, expected %08X.\n",
493 Status,
496 ASSERTMSG("PCI Successfully did the impossible!\n", FALSE);
497 break;
498 }
499
500 /* Allocate the required buffer */
502 if (!Buffer)
503 {
504 /* No memory, fail the request */
505 DPRINT1("PCI - Failed to allocate DeviceProperty buffer (%u bytes).\n", BufferLength);
507 break;
508 }
509
510 /* Do the actual property query call */
514 Buffer,
515 &ResultLength);
516 if (!NT_SUCCESS(Status)) break;
517
518 /* Return the buffer to the caller */
521 return STATUS_SUCCESS;
522 } while (FALSE);
523
524 /* Failure path */
525 return STATUS_UNSUCCESSFUL;
526}
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("PCI - 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:885
if(dx< 0)
Definition: linetemp.h:194
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:684
#define PCI_HACK_NO_EXPRESS_CAP
Definition: pci.h:30
PCI_CAPABILITIES_HEADER Header
Definition: iotypes.h:5128
PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities
Definition: iotypes.h:5129
PDEVICE_OBJECT PhysicalDeviceObject
Definition: pci.h:210
BOOLEAN IsExtendedConfigReachable
Definition: pci.h:333
#define PCI_CAPABILITY_ID_PCI_EXPRESS
Definition: iotypes.h:3664

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 603 of file utils.c.

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

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 192 of file utils.c.

198{
201 ULONG NeededLength, ActualLength;
202 UNICODE_STRING ValueString;
205
206 /* So we know what to free at the end of the body */
207 PartialInfo = NULL;
208 KeyHandle = NULL;
209 do
210 {
211 /* Open the key by name, rooted off the handle passed */
213 RootHandle,
215 &KeyHandle,
216 &Status);
217 if (!Result) break;
218
219 /* Query for the size that's needed for the value that was passed in */
220 RtlInitUnicodeString(&ValueString, ValueName);
221 Status = ZwQueryValueKey(KeyHandle,
222 &ValueString,
224 NULL,
225 0,
226 &NeededLength);
228 if (Status != STATUS_BUFFER_TOO_SMALL) break;
229
230 /* Allocate an appropriate buffer for the size that was returned */
231 ASSERT(NeededLength != 0);
233 PartialInfo = ExAllocatePoolWithTag(PagedPool,
234 NeededLength,
236 if (!PartialInfo) break;
237
238 /* Query the actual value information now that the size is known */
239 Status = ZwQueryValueKey(KeyHandle,
240 &ValueString,
242 PartialInfo,
243 NeededLength,
244 &ActualLength);
245 if (!NT_SUCCESS(Status)) break;
246
247 /* Make sure it's of the type that the caller expects */
249 if (PartialInfo->Type != Type) break;
250
251 ASSERT(NeededLength == ActualLength);
252 NeededLength = PartialInfo->DataLength;
253
254 /* Allocate a buffer to hold the data and return it to the caller */
257 NeededLength,
259 if (!*OutputBuffer) break;
260
261 /* Copy the data into the buffer and return its length to the caller */
262 RtlCopyMemory(*OutputBuffer, PartialInfo->Data, NeededLength);
263 if (OutputLength) *OutputLength = NeededLength;
265 } while (0);
266
267 /* Close any opened keys and free temporary allocations */
269 if (PartialInfo) ExFreePoolWithTag(PartialInfo, 0);
270 return Status;
271}
#define PCI_POOL_TAG
Definition: pci.h:27
BOOLEAN NTAPI PciOpenKey(IN PWCHAR KeyName, IN HANDLE RootKey, IN ACCESS_MASK DesiredAccess, OUT PHANDLE KeyHandle, OUT PNTSTATUS KeyStatus)
Definition: utils.c:165
#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(), PciGetIrqRoutingTableFromRegistry(), and PciIsDatacenter().

◆ PciHookHal()

VOID NTAPI PciHookHal ( VOID  )

Definition at line 248 of file hookhal.c.

249{
250 /* Save the old HAL routines */
255
256 /* Take over the HAL's Bus Handler functions */
257// HalPciAssignSlotResources = PciAssignSlotResources;
259}
pHalTranslateBusAddress PcipSavedTranslateBusAddress
Definition: hookhal.c:18
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 181 of file arb_comn.c.

183{
186 PCI_SIGNATURE ArbiterType;
188
189 /* Arbiters should not already be initialized */
190 if (DeviceExtension->ArbitersInitialized)
191 {
192 /* Duplicated start request, fail initialization */
193 DPRINT1("PCI Warning hot start FDOx %p, resource ranges not checked.\n", DeviceExtension);
195 }
196
197 /* Check for non-root FDO */
198 if (!PCI_IS_ROOT_FDO(DeviceExtension))
199 {
200 /* Grab the PDO */
201 PdoExtension = (PPCI_PDO_EXTENSION)DeviceExtension->PhysicalDeviceObject->DeviceExtension;
203
204 /* Check if this is a subtractive bus */
205 if (PdoExtension->Dependent.type1.SubtractiveDecode)
206 {
207 /* There is nothing to do regarding arbitration of resources */
208 DPRINT1("PCI Skipping arbiter initialization for subtractive bridge FDOX %p\n", DeviceExtension);
209 return STATUS_SUCCESS;
210 }
211 }
212
213 /* Loop the arbiters that hand out the ranges a bus decodes */
214 for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_Memory; ArbiterType++)
215 {
216 /* Find an arbiter of this type */
217 Instance = (PVOID)PciFindNextSecondaryExtension(DeviceExtension->
218 SecondaryExtension.Next,
219 ArbiterType);
220 if (Instance)
221 {
222 /*
223 * Hand it the resources this bus was started with. They describe
224 * the windows the bus actually decodes, which is what bounds the
225 * addresses it may hand out to the devices behind it.
226 */
227 Status = Instance->CommonInstance.StartArbiter(&Instance->CommonInstance,
228 Resources);
229 if (!NT_SUCCESS(Status))
230 {
231 DPRINT1("PCI - FDO ext 0x%p %s arbiter failed to start: %X\n",
232 DeviceExtension,
233 PciArbiterNames[ArbiterType - PciArb_Io],
234 Status);
235 return Status;
236 }
237 }
238 else
239 {
240 /* The arbiter was not found, this is an error! */
241 DPRINT1("PCI - FDO ext 0x%p %s arbiter (REQUIRED) is missing.\n",
242 DeviceExtension,
243 PciArbiterNames[ArbiterType - PciArb_Io]);
244 }
245 }
246
247 /* Arbiters are now initialized */
248 DeviceExtension->ArbitersInitialized = TRUE;
249 return STATUS_SUCCESS;
250}

Referenced by PciFdoIrpStartDevice().

◆ PciInitializeArbiters()

NTSTATUS NTAPI PciInitializeArbiters ( IN PPCI_FDO_EXTENSION  FdoExtension)

Definition at line 90 of file arb_comn.c.

91{
92 PPCI_INTERFACE CurrentInterface, *Interfaces;
94 PPCI_ARBITER_INSTANCE ArbiterInterface;
96 PCI_SIGNATURE ArbiterType;
98
99 /* A bus that ends up needing no arbiter at all is not a failure */
101
102 /* Loop all the arbiters */
103 for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_BusNumber; ArbiterType++)
104 {
105 /* Check if this is the extension for the Root PCI Bus */
107 {
108 /* Get the PDO extension */
109 PdoExtension = FdoExtension->PhysicalDeviceObject->DeviceExtension;
111
112 /* Skip this bus if it does subtractive decode */
113 if (PdoExtension->Dependent.type1.SubtractiveDecode)
114 {
115 DPRINT1("PCI Not creating arbiters for subtractive bus %u\n",
116 PdoExtension->Dependent.type1.SubtractiveDecode);
117 continue;
118 }
119 }
120
121 /* Query all the registered arbiter interfaces */
122 Interfaces = PciInterfaces;
123 while (*Interfaces)
124 {
125 /* Find the one that matches the arbiter currently being setup */
126 CurrentInterface = *Interfaces;
127 if (CurrentInterface->Signature == ArbiterType) break;
128 Interfaces++;
129 }
130
131 /* Check if the required arbiter was not found in the list */
132 if (!*Interfaces)
133 {
134 /* Skip this arbiter and try the next one */
135 DPRINT1("PCI - FDO ext 0x%p no %s arbiter.\n",
137 PciArbiterNames[ArbiterType - PciArb_Io]);
138 continue;
139 }
140
141 /* An arbiter was found, allocate an instance for it */
143 ArbiterInterface = ExAllocatePoolWithTag(PagedPool,
144 sizeof(PCI_ARBITER_INSTANCE),
146 if (!ArbiterInterface) break;
147
148 /* Setup the instance */
149 ArbiterInterface->BusFdoExtension = FdoExtension;
150 ArbiterInterface->Interface = CurrentInterface;
151 _swprintf(ArbiterInterface->InstanceName,
152 L"PCI %S (b=%02x)",
153 PciArbiterNames[ArbiterType - PciArb_Io],
154 FdoExtension->BaseBus);
155
156 /* Call the interface initializer for it */
157 Status = CurrentInterface->Initializer(ArbiterInterface);
158 if (!NT_SUCCESS(Status)) break;
159
160 /* Link it with this FDO */
161 PcipLinkSecondaryExtension(&FdoExtension->SecondaryExtension,
162 &FdoExtension->SecondaryExtLock,
163 &ArbiterInterface->Header,
164 ArbiterType,
166
167 /* This arbiter is now initialized, move to the next one */
168 DPRINT1("PCI - FDO ext 0x%p %S arbiter initialized (context 0x%p).\n",
170 L"ARBITER HEADER MISSING", //ArbiterInterface->CommonInstance.Name,
171 ArbiterInterface);
173 }
174
175 /* Return to caller */
176 return Status;
177}
VOID NTAPI PciArbiterDestructor(IN PPCI_ARBITER_INSTANCE Arbiter)
Definition: arb_comn.c:81
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:458
PPCI_INTERFACE PciInterfaces[]
Definition: intrface.c:18
PCI_SECONDARY_EXTENSION Header
Definition: pci.h:417
PPCI_INTERFACE Interface
Definition: pci.h:418
PCI_SIGNATURE Signature
Definition: pci.h:397
PCI_INTERFACE_INITIALIZER Initializer
Definition: pci.h:399

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("PCI: 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("PCI: 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("PCI: 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 399 of file utils.c.

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

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("WARNING: PCI received unsupported IRP!\n");
271 //DbgBreakPoint();
273}

◆ PciIsCriticalDeviceClass()

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

Definition at line 671 of file utils.c.

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

Referenced by PciScanBus().

◆ PciIsDatacenter()

BOOLEAN NTAPI PciIsDatacenter ( VOID  )

Definition at line 131 of file utils.c.

132{
134 PVOID Value;
137
138 /* Assume this isn't Datacenter */
139 Result = FALSE;
140
141 /* First, try opening the setup key */
143 L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\setupdd",
144 0,
146 &Value,
147 &ResultLength);
148 if (!NT_SUCCESS(Status))
149 {
150 /* This is not an in-progress Setup boot, so query the suite version */
152 }
153 else
154 {
155 /* This scenario shouldn't happen yet, since SetupDD isn't used */
156 UNIMPLEMENTED_FATAL("ReactOS doesn't use SetupDD for its installation program. Therefore this scenario must not happen!\n");
157 }
158
159 /* Return if this is Datacenter or not */
160 return Result;
161}
BOOLEAN NTAPI PciIsSuiteVersion(IN USHORT SuiteMask)
Definition: utils.c:114
NTSTATUS NTAPI PciGetRegistryValue(IN PWCHAR ValueName, IN PWCHAR KeyName, IN HANDLE RootHandle, IN ULONG Type, OUT PVOID *OutputBuffer, OUT PULONG OutputLength)
Definition: utils.c:192
#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)

Definition at line 750 of file utils.c.

751{
752 PAGED_CODE();
753
754 UNREFERENCED_PARAMETER(DeviceExtension);
755
756 /* Check for too many, or no, debug ports */
758 if (!PciDebugPortsCount) return FALSE;
759
760 /* eVb has not been able to test such devices yet */
762 return FALSE;
763}
#define MAX_DEBUGGING_DEVICES_SUPPORTED
Definition: pci.h:87
ULONG PciDebugPortsCount
Definition: utils.c:18

Referenced by PciScanBus().

◆ PciIsSlotPresentInParentMethod()

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

Definition at line 1096 of file utils.c.

1098{
1099 BOOLEAN FoundSlot;
1103 ULONG i, Length;
1105 PAGED_CODE();
1106
1107 /* Assume slot is not part of the parent method */
1108 FoundSlot = FALSE;
1109
1110 /* Allocate a 2KB buffer for the method return parameters */
1111 Length = sizeof(ACPI_EVAL_OUTPUT_BUFFER) + 2048;
1113 if (OutputBuffer)
1114 {
1115 /* Clear out the output buffer */
1117
1118 /* Initialize the input buffer with the method requested */
1119 InputBuffer.Signature = 0;
1120 *(PULONG)InputBuffer.MethodName = Method;
1122
1123 /* Send it to the ACPI driver */
1124 Status = PciSendIoctl(PdoExtension->ParentFdoExtension->PhysicalDeviceObject,
1126 &InputBuffer,
1127 sizeof(ACPI_EVAL_INPUT_BUFFER),
1129 Length);
1130 if (NT_SUCCESS(Status))
1131 {
1132 /* Scan all output arguments */
1133 for (i = 0; i < OutputBuffer->Count; i++)
1134 {
1135 /* Make sure it's an integer */
1136 Argument = &OutputBuffer->Argument[i];
1137 if (Argument->Type != ACPI_METHOD_ARGUMENT_INTEGER) continue;
1138
1139 /* Check if the argument matches this PCI slot structure */
1140 if (Argument->Argument == ((PdoExtension->Slot.u.bits.DeviceNumber) |
1141 ((PdoExtension->Slot.u.bits.FunctionNumber) << 16)))
1142 {
1143 /* This slot has been found, return it */
1144 FoundSlot = TRUE;
1145 break;
1146 }
1147 }
1148 }
1149
1150 /* Finished with the buffer, free it */
1152 }
1153
1154 /* Return if the slot was found */
1155 return FoundSlot;
1156}
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:530
_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 165 of file utils.c.

170{
173 UNICODE_STRING KeyString;
174 PAGED_CODE();
175
176 /* Initialize the object attributes */
177 RtlInitUnicodeString(&KeyString, KeyName);
179 &KeyString,
181 RootKey,
182 NULL);
183
184 /* Open the key, returning a boolean, and the status, if requested */
186 if (KeyStatus) *KeyStatus = Status;
187 return NT_SUCCESS(Status);
188}
#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 DPRINT1("Pci 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(), and PciFdoIrpQueryInterface().

◆ PciPdoCreate()

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

Definition at line 542 of file pdo.c.

545{
546 WCHAR DeviceName[32];
547 UNICODE_STRING DeviceString;
551 ULONG SequenceNumber;
552 PAGED_CODE();
553
554 /* Pick an atomically unique sequence number for this device */
556
557 /* Create the standard PCI device name for a PDO */
558 _swprintf(DeviceName, L"\\Device\\NTPNP_PCI%04d", SequenceNumber);
559 RtlInitUnicodeString(&DeviceString, DeviceName);
560
561 /* Create the actual device now */
562 Status = IoCreateDevice(DeviceExtension->FunctionalDeviceObject->DriverObject,
563 sizeof(PCI_PDO_EXTENSION),
564 &DeviceString,
566 0,
567 0,
568 &DeviceObject);
570
571 /* Get the extension for it */
572 PdoExtension = (PPCI_PDO_EXTENSION)DeviceObject->DeviceExtension;
573 DPRINT1("PCI: New PDO (b=0x%x, d=0x%x, f=0x%x) @ %p, ext @ %p\n",
574 DeviceExtension->BaseBus,
575 Slot.u.bits.DeviceNumber,
576 Slot.u.bits.FunctionNumber,
578 DeviceObject->DeviceExtension);
579
580 /* Configure the extension */
581 PdoExtension->ExtensionType = PciPdoExtensionType;
582 PdoExtension->IrpDispatchTable = &PciPdoDispatchTable;
583 PdoExtension->PhysicalDeviceObject = DeviceObject;
584 PdoExtension->Slot = Slot;
585 PdoExtension->PowerState.CurrentSystemState = PowerSystemWorking;
586 PdoExtension->PowerState.CurrentDeviceState = PowerDeviceD0;
587 PdoExtension->ParentFdoExtension = DeviceExtension;
588
589 /* Initialize the lock for arbiters and other interfaces */
591
592 /* Initialize the state machine */
594
595 /* Add the PDO to the parent's list */
596 PdoExtension->Next = NULL;
597 PciInsertEntryAtTail((PSINGLE_LIST_ENTRY)&DeviceExtension->ChildPdoList,
599 &DeviceExtension->ChildListLock);
600
601 /* And finally return it to the caller */
603 return STATUS_SUCCESS;
604}
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 248 of file pdo.c.

◆ PciPdoIrpCancelStopDevice()

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

Definition at line 290 of file pdo.c.

◆ PciPdoIrpDeviceUsageNotification()

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

Definition at line 500 of file pdo.c.

◆ PciPdoIrpQueryBusInformation()

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

Definition at line 442 of file pdo.c.

445{
446 PAGED_CODE();
447
449
450 /* Call the worker function */
451 return PciQueryBusInformation(DeviceExtension,
453 IoStatus.Information);
454}
NTSTATUS NTAPI PciQueryBusInformation(IN PPCI_PDO_EXTENSION PdoExtension, OUT PPNP_BUS_INFORMATION *Buffer)
Definition: utils.c:1335
__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 364 of file pdo.c.

367{
368 PAGED_CODE();
369
371
372 /* Call the worker function */
373 return PciQueryCapabilities(DeviceExtension,
375 Parameters.DeviceCapabilities.Capabilities);
376}
_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:1747

◆ PciPdoIrpQueryDeviceRelations()

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

Definition at line 330 of file pdo.c.

333{
335 PAGED_CODE();
336
337 /* Are ejection relations being queried? */
339 {
340 /* Call the worker function */
341 Status = PciQueryEjectionRelations(DeviceExtension,
343 IoStatus.Information);
344 }
346 {
347 /* The only other relation supported is the target device relation */
348 Status = PciQueryTargetDeviceRelations(DeviceExtension,
350 IoStatus.Information);
351 }
352 else
353 {
354 /* All other relations are unsupported */
356 }
357
358 /* Return either the result of the worker function, or unsupported status */
359 return Status;
360}
NTSTATUS NTAPI PciQueryEjectionRelations(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: enum.c:559
NTSTATUS NTAPI PciQueryTargetDeviceRelations(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PDEVICE_RELATIONS *pDeviceRelations)
Definition: enum.c:532
@ 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 486 of file pdo.c.

◆ PciPdoIrpQueryDeviceText()

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

Definition at line 411 of file pdo.c.

414{
415 PAGED_CODE();
416
417 /* Call the worker function */
418 return PciQueryDeviceText(DeviceExtension,
420 Parameters.QueryDeviceText.DeviceTextType,
423 (PWCHAR*)&Irp->IoStatus.Information);
424}
NTSTATUS NTAPI PciQueryDeviceText(IN PPCI_PDO_EXTENSION PdoExtension, IN DEVICE_TEXT_TYPE QueryType, IN ULONG Locale, OUT PWCHAR *Buffer)
Definition: id.c:394
struct _IO_STACK_LOCATION::@4925::@4957 QueryDeviceText

◆ PciPdoIrpQueryId()

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

Definition at line 428 of file pdo.c.

431{
432 PAGED_CODE();
433
434 /* Call the worker function */
435 return PciQueryId(DeviceExtension,
437 (PWCHAR*)&Irp->IoStatus.Information);
438}
NTSTATUS NTAPI PciQueryId(IN PPCI_PDO_EXTENSION DeviceExtension, IN BUS_QUERY_ID_TYPE QueryType, OUT PWCHAR *Buffer)
Definition: id.c:200
struct _IO_STACK_LOCATION::@4925::@4956 QueryId

◆ PciPdoIrpQueryInterface()

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

Definition at line 304 of file pdo.c.

307{
309 PAGED_CODE();
310
312
313 /* Query the interface from the PCI driver */
315 (PPCI_FDO_EXTENSION)DeviceExtension,
319 IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData,
321 FALSE);
322
323 /* TODO: There's more to this story, but NOT TODAY! */
324
325 return Status;
326}

◆ PciPdoIrpQueryLegacyBusInformation()

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

Definition at line 528 of file pdo.c.

◆ PciPdoIrpQueryPower()

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

Definition at line 107 of file pdo.c.

◆ PciPdoIrpQueryRemoveDevice()

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

Definition at line 220 of file pdo.c.

◆ PciPdoIrpQueryResourceRequirements()

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

Definition at line 395 of file pdo.c.

398{
399 PAGED_CODE();
400
402
403 /* Call the worker function */
404 return PciQueryRequirements(DeviceExtension,
406 IoStatus.Information);
407}
NTSTATUS NTAPI PciQueryRequirements(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *RequirementsList)
Definition: enum.c:675

◆ PciPdoIrpQueryResources()

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

Definition at line 380 of file pdo.c.

383{
384 PAGED_CODE();
385
387
388 /* Call the worker function */
389 return PciQueryResources(DeviceExtension,
390 (PCM_RESOURCE_LIST*)&Irp->IoStatus.Information);
391}
NTSTATUS NTAPI PciQueryResources(IN PPCI_PDO_EXTENSION PdoExtension, OUT PCM_RESOURCE_LIST *Buffer)
Definition: enum.c:371

◆ PciPdoIrpQueryStopDevice()

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

Definition at line 276 of file pdo.c.

◆ PciPdoIrpReadConfig()

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

Definition at line 458 of file pdo.c.

◆ PciPdoIrpRemoveDevice()

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

Definition at line 234 of file pdo.c.

◆ PciPdoIrpStartDevice()

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

Definition at line 121 of file pdo.c.

124{
126 BOOLEAN Changed, DoReset;
128 PAGED_CODE();
129
131
132 DoReset = FALSE;
133
134 /* Begin entering the start phase */
135 Status = PciBeginStateTransition((PVOID)DeviceExtension, PciStarted);
136 if (!NT_SUCCESS(Status)) return Status;
137
138 /* Check if this is a VGA device */
139 if (((DeviceExtension->BaseClass == PCI_CLASS_PRE_20) &&
140 (DeviceExtension->SubClass == PCI_SUBCLASS_PRE_20_VGA)) ||
141 ((DeviceExtension->BaseClass == PCI_CLASS_DISPLAY_CTLR) &&
142 (DeviceExtension->SubClass == PCI_SUBCLASS_VID_VGA_CTLR)))
143 {
144 /* Always force it on */
145 DeviceExtension->CommandEnables |= (PCI_ENABLE_IO_SPACE |
147 }
148
149 /* Check if native IDE is enabled and it owns the I/O ports */
150 if (DeviceExtension->IoSpaceUnderNativeIdeControl)
151 {
152 /* Then don't allow I/O access */
153 DeviceExtension->CommandEnables &= ~PCI_ENABLE_IO_SPACE;
154 }
155
156 /* Always enable bus mastering */
157 DeviceExtension->CommandEnables |= PCI_ENABLE_BUS_MASTER;
158
159 /* Check if the OS assigned resources differ from the PCI configuration */
160 Changed = PciComputeNewCurrentSettings(DeviceExtension,
162 StartDevice.AllocatedResources);
163 if (Changed)
164 {
165 /* Remember this for later */
166 DeviceExtension->MovedDevice = TRUE;
167 }
168 else
169 {
170 /* All good */
171 DPRINT1("PCI - START not changing resource settings.\n");
172 }
173
174 /* Check if the device was sleeping */
175 if (DeviceExtension->PowerState.CurrentDeviceState != PowerDeviceD0)
176 {
177 /* Power it up */
180 FALSE);
181 if (!NT_SUCCESS(Status))
182 {
183 /* Powerup fail, fail the request */
184 PciCancelStateTransition((PVOID)DeviceExtension, PciStarted);
186 }
187
188 /* Tell the power manager that the device is powered up */
189 PowerState.DeviceState = PowerDeviceD0;
190 PoSetPowerState(DeviceExtension->PhysicalDeviceObject,
192 PowerState);
193
194 /* Update internal state */
195 DeviceExtension->PowerState.CurrentDeviceState = PowerDeviceD0;
196
197 /* This device's resources and decodes will need to be reset */
198 DoReset = TRUE;
199 }
200
201 /* Update resource information now that the device is powered up and active */
202 Status = PciSetResources(DeviceExtension, DoReset, TRUE);
203 if (!NT_SUCCESS(Status))
204 {
205 /* That failed, so cancel the transition */
206 PciCancelStateTransition((PVOID)DeviceExtension, PciStarted);
207 }
208 else
209 {
210 /* Fully commit, as the device is now started up and ready to go */
211 PciCommitStateTransition((PVOID)DeviceExtension, PciStarted);
212 }
213
214 /* Return the result of the start request */
215 return Status;
216}
_Check_return_ _In_ ULONG _In_ DEVICE_POWER_STATE DevicePowerState
Definition: dispmprt.h:1274
NTSTATUS NTAPI PciSetResources(IN PPCI_PDO_EXTENSION PdoExtension, IN BOOLEAN DoReset, IN BOOLEAN SomethingSomethingDarkSide)
Definition: enum.c:2255
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:121
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 262 of file pdo.c.

◆ PciPdoIrpSurpriseRemoval()

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

Definition at line 514 of file pdo.c.

◆ PciPdoIrpWriteConfig()

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

Definition at line 472 of file pdo.c.

◆ PciPdoSetPowerState()

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

Definition at line 93 of file pdo.c.

◆ PciPdoWaitWake()

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

Definition at line 79 of file pdo.c.

◆ 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 458 of file utils.c.

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

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:5575
PINTERFACE_REFERENCE InterfaceReference
Definition: iotypes.h:5574
PPME_SET_PME_ENABLE UpdateEnable
Definition: iotypes.h:5578
struct _PCI_PME_INTERFACE * PPCI_PME_INTERFACE
#define PCI_PME_INTRF_STANDARD_VER
Definition: iotypes.h:5522

◆ 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 1335 of file utils.c.

1337{
1338 PPNP_BUS_INFORMATION BusInfo;
1339
1340 /* Allocate a structure for the bus information */
1342 sizeof(PNP_BUS_INFORMATION),
1343 'BicP');
1344 if (!BusInfo) return STATUS_INSUFFICIENT_RESOURCES;
1345
1346 /* Write the correct GUID and bus type identifier, and fill the bus number */
1347 BusInfo->BusTypeGuid = GUID_BUS_TYPE_PCI;
1348 BusInfo->LegacyBusType = PCIBus;
1349 BusInfo->BusNumber = PdoExtension->ParentFdoExtension->BaseBus;
1350
1351 *Buffer = BusInfo;
1352
1353 return STATUS_SUCCESS;
1354}
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 1747 of file utils.c.

1749{
1751
1752 /* A PDO ID is never unique, and its address is its function and device */
1753 DeviceCapability->UniqueID = FALSE;
1754 DeviceCapability->Address = PdoExtension->Slot.u.bits.FunctionNumber |
1755 (PdoExtension->Slot.u.bits.DeviceNumber << 16);
1756
1757 /* Check for host bridges */
1758 if ((PdoExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
1759 (PdoExtension->SubClass == PCI_SUBCLASS_BR_HOST))
1760 {
1761 /* Raw device opens to a host bridge are acceptable */
1762 DeviceCapability->RawDeviceOK = TRUE;
1763 }
1764 else
1765 {
1766 /* Otherwise, other PDOs cannot be directly opened */
1767 DeviceCapability->RawDeviceOK = FALSE;
1768 }
1769
1770 /* PCI PDOs are pretty fixed things */
1771 DeviceCapability->LockSupported = FALSE;
1772 DeviceCapability->EjectSupported = FALSE;
1773 DeviceCapability->Removable = FALSE;
1774 DeviceCapability->DockDevice = FALSE;
1775
1776 /* The slot number is stored as a device property, go query it */
1777 PciDetermineSlotNumber(PdoExtension, &DeviceCapability->UINumber);
1778
1779 /* Finally, query and power capabilities and convert them for PnP usage */
1780 Status = PciQueryPowerCapabilities(PdoExtension, DeviceCapability);
1781
1782 /* Dump the capabilities if it all worked, and return the status */
1783 if (NT_SUCCESS(Status)) PciDebugDumpQueryCapabilities(DeviceCapability);
1784 return Status;
1785}
NTSTATUS NTAPI PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, IN PDEVICE_CAPABILITIES DeviceCapability)
Definition: utils.c:1497
NTSTATUS NTAPI PciDetermineSlotNumber(IN PPCI_PDO_EXTENSION PdoExtension, OUT PULONG SlotNumber)
Definition: utils.c:1358

Referenced by PciPdoIrpQueryCapabilities().

◆ PciQueryDeviceRelations()

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

Definition at line 2134 of file enum.c.

2136{
2139 ULONG PdoCount = 0;
2140 PDEVICE_RELATIONS DeviceRelations, NewRelations;
2141 SIZE_T Size;
2142 PDEVICE_OBJECT DeviceObject, *ObjectArray;
2143 PAGED_CODE();
2144
2145 /* Make sure the FDO is started */
2146 ASSERT(DeviceExtension->DeviceState == PciStarted);
2147
2148 /* Synchronize while we enumerate the bus */
2150 if (!NT_SUCCESS(Status)) return Status;
2151
2152 /* Scan all children PDO */
2153 for (PdoExtension = DeviceExtension->ChildPdoList;
2155 PdoExtension = PdoExtension->Next)
2156 {
2157 /* Invalidate them */
2158 PdoExtension->NotPresent = TRUE;
2159 }
2160
2161 /* Scan the PCI Bus */
2162 Status = PciScanBus(DeviceExtension);
2164
2165 /* Enumerate all children PDO again */
2166 for (PdoExtension = DeviceExtension->ChildPdoList;
2168 PdoExtension = PdoExtension->Next)
2169 {
2170 /* Check for PDOs that are still invalidated */
2171 if (PdoExtension->NotPresent)
2172 {
2173 /* This means this PDO existed before, but not anymore */
2174 PdoExtension->ReportedMissing = TRUE;
2175 DPRINT1("PCI - Old device (pdox) %p not found on rescan.\n",
2176 PdoExtension);
2177 }
2178 else
2179 {
2180 /* Increase count of detected PDOs */
2181 PdoCount++;
2182 }
2183 }
2184
2185 /* Read the current relations and add the newly discovered relations */
2186 DeviceRelations = *pDeviceRelations;
2187 Size = FIELD_OFFSET(DEVICE_RELATIONS, Objects) +
2188 PdoCount * sizeof(PDEVICE_OBJECT);
2189 if (DeviceRelations) Size += sizeof(PDEVICE_OBJECT) * DeviceRelations->Count;
2190
2191 /* Allocate the device relations */
2192 NewRelations = (PDEVICE_RELATIONS)ExAllocatePoolWithTag(0, Size, 'BicP');
2193 if (!NewRelations)
2194 {
2195 /* Out of space, cancel the operation */
2198 }
2199
2200 /* Check if there were any older relations */
2201 NewRelations->Count = 0;
2202 if (DeviceRelations)
2203 {
2204 /* Copy the old relations into the new buffer, then free the old one */
2205 RtlCopyMemory(NewRelations,
2206 DeviceRelations,
2207 FIELD_OFFSET(DEVICE_RELATIONS, Objects) +
2208 DeviceRelations->Count * sizeof(PDEVICE_OBJECT));
2209 ExFreePoolWithTag(DeviceRelations, 0);
2210 }
2211
2212 /* Print out that we're ready to dump relations */
2213 DPRINT1("PCI QueryDeviceRelations/BusRelations FDOx %p (bus 0x%02x)\n",
2214 DeviceExtension,
2215 DeviceExtension->BaseBus);
2216
2217 /* Loop the current PDO children and the device relation object array */
2218 PdoExtension = DeviceExtension->ChildPdoList;
2219 ObjectArray = &NewRelations->Objects[NewRelations->Count];
2220 while (PdoExtension)
2221 {
2222 /* Dump this relation */
2223 DPRINT1(" QDR PDO %p (x %p)%s\n",
2224 PdoExtension->PhysicalDeviceObject,
2226 PdoExtension->NotPresent ?
2227 "<Omitted, device flaged not present>" : "");
2228
2229 /* Is this PDO present? */
2230 if (!PdoExtension->NotPresent)
2231 {
2232 /* Reference it and add it to the array */
2233 DeviceObject = PdoExtension->PhysicalDeviceObject;
2235 *ObjectArray++ = DeviceObject;
2236 }
2237
2238 /* Go to the next PDO */
2239 PdoExtension = PdoExtension->Next;
2240 }
2241
2242 /* Terminate dumping the relations */
2243 DPRINT1(" QDR Total PDO count = %u (%u already in list)\n",
2244 NewRelations->Count + PdoCount,
2245 NewRelations->Count);
2246
2247 /* Return the final count and the new buffer */
2248 NewRelations->Count += PdoCount;
2249 *pDeviceRelations = NewRelations;
2250 return STATUS_SUCCESS;
2251}
NTSTATUS NTAPI PciScanBus(IN PPCI_FDO_EXTENSION DeviceExtension)
Definition: enum.c:1666
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 394 of file id.c.

398{
399 PWCHAR MessageBuffer, LocationBuffer;
402
404
405 /* Check what the caller is requesting */
406 switch (QueryType)
407 {
409
410 /* Get the message from the resource section */
411 MessageBuffer = PciGetDeviceDescriptionMessage(PdoExtension->BaseClass,
412 PdoExtension->SubClass);
413
414 /* Return it to the caller, and select proper status code */
415 *Buffer = MessageBuffer;
416 Status = MessageBuffer ? STATUS_SUCCESS : STATUS_NOT_SUPPORTED;
417 break;
418
420
421 /* Get the message from the resource section */
422 MessageBuffer = PciGetDescriptionMessage(0x10000, &Length);
423 if (!MessageBuffer)
424 {
425 /* It should be there, but fail if it wasn't found for some reason */
427 break;
428 }
429
430 /* Add space for a null-terminator, and allocate the buffer */
431 Length += 2 * sizeof(UNICODE_NULL);
432 LocationBuffer = ExAllocatePoolWithTag(PagedPool,
433 Length * sizeof(WCHAR),
434 'BicP');
435 *Buffer = LocationBuffer;
436
437 /* Check if the allocation succeeded */
438 if (LocationBuffer)
439 {
440 /* Build the location string based on bus, function, and device */
441 _swprintf(LocationBuffer,
442 MessageBuffer,
443 PdoExtension->ParentFdoExtension->BaseBus,
444 PdoExtension->Slot.u.bits.FunctionNumber,
445 PdoExtension->Slot.u.bits.DeviceNumber);
446 }
447
448 /* Free the original string from the resource section */
449 ExFreePoolWithTag(MessageBuffer, 0);
450
451 /* Select the correct status */
453 break;
454
455 default:
456
457 /* Anything else is unsupported */
459 break;
460 }
461
462 /* Return whether or not a device text string was indeed found */
463 return Status;
464}
PWCHAR NTAPI PciGetDeviceDescriptionMessage(IN UCHAR BaseClass, IN UCHAR SubClass)
Definition: id.c:88
#define UNICODE_NULL
_Must_inspect_result_ _In_ KTMOBJECT_TYPE QueryType
Definition: nttmapi.h:404
@ DeviceTextLocationInformation
Definition: iotypes.h:2948
@ DeviceTextDescription
Definition: iotypes.h:2947

Referenced by PciPdoIrpQueryDeviceText().

◆ PciQueryEjectionRelations()

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

Definition at line 559 of file enum.c.

561{
563 UNREFERENCED_PARAMETER(pDeviceRelations);
564
565 /* Not yet implemented */
568}

Referenced by PciPdoIrpQueryDeviceRelations().

◆ PciQueryId()

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

Definition at line 200 of file id.c.

203{
204 ULONG SubsysId;
205 CHAR VendorString[22];
207 PPCI_FDO_EXTENSION ParentExtension;
209 ULONG i, Size;
211 PANSI_STRING NextString;
213 PCI_ID_BUFFER IdBuffer;
214 PAGED_CODE();
215
216 /* Assume failure */
218 *Buffer = NULL;
219
220 /* Start with the genric vendor string, which is the vendor ID + device ID */
221 sprintf(VendorString,
222 "PCI\\VEN_%04X&DEV_%04X",
223 DeviceExtension->VendorId,
224 DeviceExtension->DeviceId);
225
226 /* Initialize the PCI ID Buffer */
227 PciInitIdBuffer(&IdBuffer);
228
229 /* Build the subsystem ID as shown in PCI ID Strings */
230 SubsysId = DeviceExtension->SubsystemVendorId | (DeviceExtension->SubsystemId << 16);
231
232 /* Check what the caller is requesting */
233 switch (QueryType)
234 {
235 case BusQueryDeviceID:
236
237 /* A single ID, the vendor string + the revision ID */
238 PciIdPrintf(&IdBuffer,
239 "%s&SUBSYS_%08X&REV_%02X",
240 VendorString,
241 SubsysId,
242 DeviceExtension->RevisionId);
243 break;
244
246
247 /* First the vendor string + the subsystem ID + the revision ID */
248 PciIdPrintf(&IdBuffer,
249 "%s&SUBSYS_%08X&REV_%02X",
250 VendorString,
251 SubsysId,
252 DeviceExtension->RevisionId);
253
254 /* Next, without the revision */
255 PciIdPrintf(&IdBuffer,
256 "%s&SUBSYS_%08X",
257 VendorString,
258 SubsysId);
259
260 /* Next, the vendor string + the base class + sub class + progif */
261 PciIdPrintf(&IdBuffer,
262 "%s&CC_%02X%02X%02X",
263 VendorString,
264 DeviceExtension->BaseClass,
265 DeviceExtension->SubClass,
266 DeviceExtension->ProgIf);
267
268 /* Next, without the progif */
269 PciIdPrintf(&IdBuffer,
270 "%s&CC_%02X%02X",
271 VendorString,
272 DeviceExtension->BaseClass,
273 DeviceExtension->SubClass);
274
275 /* And finally, a terminator */
276 PciIdPrintf(&IdBuffer, "\0");
277 break;
278
280
281 /* First, the vendor + revision ID only */
282 PciIdPrintf(&IdBuffer,
283 "%s&REV_%02X",
284 VendorString,
285 DeviceExtension->RevisionId);
286
287 /* Next, the vendor string alone */
288 PciIdPrintf(&IdBuffer, "%s", VendorString);
289
290 /* Next, the vendor ID + the base class + the sub class + progif */
291 PciIdPrintf(&IdBuffer,
292 "PCI\\VEN_%04X&CC_%02X%02X%02X",
293 DeviceExtension->VendorId,
294 DeviceExtension->BaseClass,
295 DeviceExtension->SubClass,
296 DeviceExtension->ProgIf);
297
298 /* Now without the progif */
299 PciIdPrintf(&IdBuffer,
300 "PCI\\VEN_%04X&CC_%02X%02X",
301 DeviceExtension->VendorId,
302 DeviceExtension->BaseClass,
303 DeviceExtension->SubClass);
304
305 /* And then just the vendor ID itself */
306 PciIdPrintf(&IdBuffer,
307 "PCI\\VEN_%04X",
308 DeviceExtension->VendorId);
309
310 /* Then the base class + subclass + progif, without any vendor */
311 PciIdPrintf(&IdBuffer,
312 "PCI\\CC_%02X%02X%02X",
313 DeviceExtension->BaseClass,
314 DeviceExtension->SubClass,
315 DeviceExtension->ProgIf);
316
317 /* Next, without the progif */
318 PciIdPrintf(&IdBuffer,
319 "PCI\\CC_%02X%02X",
320 DeviceExtension->BaseClass,
321 DeviceExtension->SubClass);
322
323 /* And finally, a terminator */
324 PciIdPrintf(&IdBuffer, "\0");
325 break;
326
328
329 /* Start with a terminator */
330 PciIdPrintf(&IdBuffer, "\0");
331
332 /* And then encode the device and function number */
333 PciIdPrintfAppend(&IdBuffer,
334 "%02X",
335 (DeviceExtension->Slot.u.bits.DeviceNumber << 3) |
336 DeviceExtension->Slot.u.bits.FunctionNumber);
337
338 /* Loop every parent until the root */
339 ParentExtension = DeviceExtension->ParentFdoExtension;
340 while (!PCI_IS_ROOT_FDO(ParentExtension))
341 {
342 /* And encode the parent's device and function number as well */
344 PciIdPrintfAppend(&IdBuffer,
345 "%02X",
346 (PdoExtension->Slot.u.bits.DeviceNumber << 3) |
347 PdoExtension->Slot.u.bits.FunctionNumber);
348 }
349 break;
350
351 default:
352
353 /* Unknown query type */
354 DPRINT1("PciQueryId expected ID type = %d\n", QueryType);
356 }
357
358 /* Something should've been generated if this has been reached */
359 ASSERT(IdBuffer.Count > 0);
360
361 /* Allocate the final string buffer to hold the ID */
364
365 /* Build the UNICODE_STRING structure for it */
366 DPRINT1("PciQueryId(%d)\n", QueryType);
369
370 /* Loop every ID in the buffer */
371 for (i = 0; i < IdBuffer.Count; i++)
372 {
373 /* Select the ANSI_STRING for the ID */
374 NextString = &IdBuffer.Strings[i];
375 DPRINT1(" <- \"%s\"\n", NextString->Buffer);
376
377 /* Convert it to a UNICODE_STRING */
380
381 /* Add it into the final destination buffer */
382 Size = IdBuffer.StringSize[i];
384 DestinationString.Buffer += (Size / sizeof(WCHAR));
385 }
386
387 /* Return the buffer to the caller and return status (should be success) */
389 return Status;
390}
ULONG __cdecl PciIdPrintfAppend(IN PPCI_ID_BUFFER IdBuffer, IN PCCH Format,...)
Definition: id.c:159
VOID NTAPI PciInitIdBuffer(IN PPCI_ID_BUFFER IdBuffer)
Definition: id.c:112
ULONG __cdecl PciIdPrintf(IN PPCI_ID_BUFFER IdBuffer, IN PCCH Format,...)
Definition: id.c:122
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
struct _PCI_FDO_EXTENSION * ParentFdoExtension
Definition: pci.h:216
ULONG Count
Definition: pci.h:440
ULONG StringSize[MAX_ANSI_STRINGS]
Definition: pci.h:442
ANSI_STRING Strings[MAX_ANSI_STRINGS]
Definition: pci.h:441
ULONG TotalLength
Definition: pci.h:443
void * Buffer
Definition: sprintf.c:453
unsigned short MaximumLength
Definition: sprintf.c:452
@ BusQueryCompatibleIDs
Definition: iotypes.h:2940
@ BusQueryInstanceID
Definition: iotypes.h:2941
@ BusQueryDeviceID
Definition: iotypes.h:2938
@ BusQueryHardwareIDs
Definition: iotypes.h:2939

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 DPRINT1("PCI - PciQueryInterface TYPE = %wZ\n", &GuidString);
60 DPRINT1(" 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 DPRINT1("PCI - PciQueryInterface: guid = %wZ only 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 DPRINT1("PCI - 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 DPRINT1("PCI - PciQueryInterface: guid = %wZ only for PDOs\n",
108 &GuidString);
110 continue;
111 }
112 }
113
114 /* Print the GUID for debugging, and then free the string */
115 DPRINT1("PCI - 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 DPRINT1("PCI - PciQueryInterface - Constructor %p = %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 DPRINT1("PCI - PciQueryInterface returning SUCCESS\n");
142 return Status;
143 }
144 }
145
146 /* An interface of this type, and for this device, could not be found */
147 DPRINT1("PCI - PciQueryInterface FAILED TO FIND INTERFACE\n");
149}
#define PCI_INTERFACE_PDO
Definition: pci.h:57
#define PCI_INTERFACE_FDO
Definition: pci.h:58
#define PCI_INTERFACE_ROOT
Definition: pci.h:59
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:392
USHORT Flags
Definition: pci.h:395
PCI_INTERFACE_CONSTRUCTOR Constructor
Definition: pci.h:398
USHORT MinVersion
Definition: pci.h:393
CONST GUID * InterfaceType
Definition: pci.h:391
_In_ PUSBD_INTERFACE_LIST_ENTRY InterfaceList
Definition: usbdlib.h:181
#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 675 of file enum.c.

677{
679 PCI_COMMON_HEADER PciHeader;
680 PAGED_CODE();
681
682 /* Check if the PDO has any resources, or at least an interrupt pin */
683 if ((PdoExtension->Resources) || (PdoExtension->InterruptPin))
684 {
685 /* Read the current PCI header */
687
688 /* Use it to build a list of requirements */
690 if (!NT_SUCCESS(Status)) return Status;
691
692 /* Is this a Compaq PCI Hotplug Controller (r17) on a PAE system ? */
693 if ((PciHeader.VendorID == 0xE11) &&
694 (PciHeader.DeviceID == 0xA0F7) &&
695 (PciHeader.RevisionID == 17) &&
697 {
698 /* Have not tested this on eVb's machine yet */
700 }
701
702 /* Check if the requirements are actually the zero list */
704 {
705 /* A simple NULL will suffice for the PnP Manager */
707 DPRINT1("Returning NULL requirements list\n");
708 }
709 else
710 {
711 /* Otherwise, print out the requirements list */
713 }
714 }
715 else
716 {
717 /* There aren't any resources, so simply return NULL */
718 DPRINT1("PciQueryRequirements returning NULL requirements list\n");
720 }
721
722 /* This call always succeeds (but maybe with no requirements) */
723 return STATUS_SUCCESS;
724}
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:572
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 371 of file enum.c.

373{
374 PPCI_FUNCTION_RESOURCES PciResources;
375 BOOLEAN HaveVga, HaveMemSpace, HaveIoSpace;
376 USHORT BridgeControl, PciCommand;
377 ULONG Count, i;
378 PCM_PARTIAL_RESOURCE_DESCRIPTOR Partial, Resource, LastResource;
380 UCHAR InterruptLine;
381 PAGED_CODE();
382
383 /* Assume failure */
384 Count = 0;
385 HaveVga = FALSE;
386 *Buffer = NULL;
387
388 /* Make sure there's some resources to query */
389 PciResources = PdoExtension->Resources;
390 if (!PciResources) return STATUS_SUCCESS;
391
392 /* Read the decodes */
394 &PciCommand,
396 sizeof(USHORT));
397
398 /* Check which ones are turned on */
399 HaveIoSpace = PciCommand & PCI_ENABLE_IO_SPACE;
400 HaveMemSpace = PciCommand & PCI_ENABLE_MEMORY_SPACE;
401
402 /* Loop maximum possible descriptors */
403 for (i = 0; i < 7; i++)
404 {
405 /* Check if the decode for this descriptor is actually turned on */
406 Partial = &PciResources->Current[i];
407 if ((HaveMemSpace &&
408 ((Partial->Type == CmResourceTypeMemory) ||
409 (Partial->Type == CmResourceTypeMemoryLarge))) ||
410 (HaveIoSpace && (Partial->Type == CmResourceTypePort)))
411 {
412 /* One more fully active descriptor */
413 Count++;
414 }
415 }
416
417 /* If there's an interrupt pin associated, check at least one decode is on */
418 if ((PdoExtension->InterruptPin) && ((HaveMemSpace) || (HaveIoSpace)))
419 {
420 /* Read the interrupt line for the pin, add a descriptor if it's valid */
421 InterruptLine = PdoExtension->AdjustedInterruptLine;
422 if ((InterruptLine) && (InterruptLine != -1)) Count++;
423 }
424
425 /* Check for PCI bridge */
426 if (PdoExtension->HeaderType == PCI_BRIDGE_TYPE)
427 {
428 /* Read bridge settings, check if VGA is present */
430 &BridgeControl,
431 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.BridgeControl),
432 sizeof(USHORT));
433 if (BridgeControl & PCI_ENABLE_BRIDGE_VGA)
434 {
435 /* Remember for later */
436 HaveVga = TRUE;
437
438 /* One memory descriptor for 0xA0000, plus the two I/O port ranges */
439 if (HaveMemSpace) Count++;
440 if (HaveIoSpace) Count += 2;
441 }
442 }
443
444 /* If there's no descriptors in use, there's no resources, so return */
445 if (!Count) return STATUS_SUCCESS;
446
447 /* Allocate a resource list to hold the resources */
449 PdoExtension->ParentFdoExtension->BaseBus);
451
452 /* This is where the descriptors will be copied into */
453 Resource = ResourceList->List[0].PartialResourceList.PartialDescriptors;
454 LastResource = Resource + Count + 1;
455
456 /* Loop maximum possible descriptors */
457 for (i = 0; i < 7; i++)
458 {
459 /* Check if the decode for this descriptor is actually turned on */
460 Partial = &PciResources->Current[i];
461 if ((HaveMemSpace &&
462 ((Partial->Type == CmResourceTypeMemory) ||
463 (Partial->Type == CmResourceTypeMemoryLarge))) ||
464 (HaveIoSpace && (Partial->Type == CmResourceTypePort)))
465 {
466 /* Copy the descriptor into the resource list */
467 *Resource++ = *Partial;
468 }
469 }
470
471 /* Check if earlier the code detected this was a PCI bridge with VGA on it */
472 if (HaveVga)
473 {
474 /* Are the memory decodes enabled? */
475 if (HaveMemSpace)
476 {
477 /* Build a memory descriptor for a 128KB framebuffer at 0xA0000 */
479 Resource->u.Generic.Start.HighPart = 0;
481 Resource->u.Generic.Start.LowPart = 0xA0000;
482 Resource->u.Generic.Length = 0x20000;
483 Resource++;
484 }
485
486 /* Are the I/O decodes enabled? */
487 if (HaveIoSpace)
488 {
489 /* Build an I/O descriptor for the graphic ports at 0x3B0 */
492 Resource->u.Port.Start.QuadPart = 0x3B0u;
493 Resource->u.Port.Length = 0xC;
494 Resource++;
495
496 /* Build an I/O descriptor for the graphic ports at 0x3C0 */
499 Resource->u.Port.Start.QuadPart = 0x3C0u;
500 Resource->u.Port.Length = 0x20;
501 Resource++;
502 }
503 }
504
505 /* If there's an interrupt pin associated, check at least one decode is on */
506 if ((PdoExtension->InterruptPin) && ((HaveMemSpace) || (HaveIoSpace)))
507 {
508 /* Read the interrupt line for the pin, check if it's valid */
509 InterruptLine = PdoExtension->AdjustedInterruptLine;
510 if ((InterruptLine) && (InterruptLine != -1))
511 {
512 /* Make sure there's still space */
513 ASSERT(Resource < LastResource);
514
515 /* Add the interrupt descriptor */
518 Resource->ShareDisposition = CmResourceShareShared;
519 Resource->u.Interrupt.Affinity = -1;
520 Resource->u.Interrupt.Level = InterruptLine;
521 Resource->u.Interrupt.Vector = InterruptLine;
522 }
523 }
524
525 /* Return the resource list */
527 return STATUS_SUCCESS;
528}
PCM_RESOURCE_LIST NTAPI PciAllocateCmResourceList(IN ULONG Count, IN ULONG BusNumber)
Definition: enum.c:341
#define CM_RESOURCE_PORT_POSITIVE_DECODE
Definition: cmtypes.h:113
#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:3608

Referenced by PciPdoIrpQueryResources().

◆ PciQueryTargetDeviceRelations()

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

Definition at line 532 of file enum.c.

534{
535 PDEVICE_RELATIONS DeviceRelations;
536 PAGED_CODE();
537
538 /* If there were existing relations, free them */
539 if (*pDeviceRelations) ExFreePoolWithTag(*pDeviceRelations, 0);
540
541 /* Allocate a new structure for the relations */
542 DeviceRelations = ExAllocatePoolWithTag(NonPagedPool,
543 sizeof(DEVICE_RELATIONS),
544 'BicP');
545 if (!DeviceRelations) return STATUS_INSUFFICIENT_RESOURCES;
546
547 /* Only one relation: the PDO */
548 DeviceRelations->Count = 1;
549 DeviceRelations->Objects[0] = PdoExtension->PhysicalDeviceObject;
550 ObReferenceObject(DeviceRelations->Objects[0]);
551
552 /* Return the new relations */
553 *pDeviceRelations = DeviceRelations;
554 return STATUS_SUCCESS;
555}
#define NonPagedPool
Definition: env_spec_w32.h:307

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 885 of file utils.c.

890{
891 ULONG CapabilityCount = 0;
892
893 /* If the device has no capabilility list, fail */
894 if (!Offset) return 0;
895
896 /* Validate a PDO with capabilities, a valid buffer, and a valid length */
897 ASSERT(DeviceExtension->ExtensionType == PciPdoExtensionType);
898 ASSERT(DeviceExtension->CapabilitiesPtr != 0);
899 ASSERT(Buffer);
901
902 /* Loop all capabilities */
903 while (Offset)
904 {
905 /* Make sure the pointer is spec-aligned and spec-sized */
906 ASSERT((Offset >= PCI_COMMON_HDR_LENGTH) && ((Offset & 0x3) == 0));
907
908 /* Read the capability header */
909 PciReadDeviceConfig(DeviceExtension,
910 Buffer,
911 Offset,
913
914 /* Check if this is the capability being looked up */
915 if ((Buffer->CapabilityID == CapabilityId) || !(CapabilityId))
916 {
917 /* Check if was at a valid offset and length */
918 if ((Offset) && (Length > sizeof(PCI_CAPABILITIES_HEADER)))
919 {
920 /* Sanity check */
921 ASSERT(Length <= (sizeof(PCI_COMMON_CONFIG) - Offset));
922
923 /* Now read the whole capability data into the buffer */
924 PciReadDeviceConfig(DeviceExtension,
929 }
930
931 /* Return the offset where the capability was found */
932 return Offset;
933 }
934
935 /* Try the next capability instead */
936 CapabilityCount++;
937 Offset = Buffer->Next;
938
939 /* There can't be more than 48 capabilities (256 bytes max) */
940 if (CapabilityCount > 48)
941 {
942 /* Fail, since this is basically a broken PCI device */
943 DPRINT1("PCI device %p capabilities list is broken.\n", DeviceExtension);
944 return 0;
945 }
946 }
947
948 /* Capability wasn't found, fail */
949 return 0;
950}

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(), PciAssignSlotResources(), PciConfigureIdeController(), PciDecodeEnable(), PcipGetFunctionLimits(), PciQueryRequirements(), PciQueryResources(), PciReadDeviceCapability(), PciReadDeviceExtendedCapability(), PciScanBus(), PciSetResources(), PciStallForPowerChange(), 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("PCI 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}
Definition: Header.h:9
#define PCI_LEGACY_CONFIG_LENGTH
Definition: pci.h:77
static BOOLEAN NTAPI PciIsExtendedCapabilityOffsetValid(_In_ ULONG Offset)
Definition: express.c:20

◆ 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().

◆ PciSaveBiosConfig()

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

Referenced by PciScanBus().

◆ 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 530 of file utils.c.

536{
537 PIRP Irp;
541 PDEVICE_OBJECT AttachedDevice;
542 PAGED_CODE();
543
544 /* Initialize the pending IRP event */
546
547 /* Get a reference to the root PDO (ACPI) */
549 if (!AttachedDevice) return STATUS_INVALID_PARAMETER;
550
551 /* Build the requested IOCTL IRP */
553 AttachedDevice,
558 0,
559 &Event,
562
563 /* Send the IOCTL to the driver */
564 Status = IoCallDriver(AttachedDevice, Irp);
565 if (Status == STATUS_PENDING)
566 {
567 /* Wait for a response */
569 Executive,
571 FALSE,
572 NULL);
573 Status = Irp->IoStatus.Status;
574 }
575
576 /* Take away the reference we took and return the result to the caller */
577 ObDereferenceObject(AttachedDevice);
578 return Status;
579}
_In_ PIO_STATUS_BLOCK IoStatusBlock
Definition: dispmprt.h:608
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1414
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
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
#define ObDereferenceObject
Definition: obfuncs.h:203

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 121 of file power.c.

124{
126 PCI_PM_CAPABILITY PmCaps;
127 ULONG CapsOffset;
128
129 /* Assume success */
131
132 /* Check if this device can support low power states */
133 if (!(PciCanDisableDecodes(DeviceExtension, NULL, 0, TRUE)) &&
135 {
136 /* Simply return success, ignoring this request */
137 DPRINT1("Cannot disable decodes on this device, ignoring PM request...\n");
138 return Status;
139 }
140
141 /* Does the device support power management at all? */
142 if (!(DeviceExtension->HackFlags & PCI_HACK_NO_PM_CAPS))
143 {
144 /* Get the PM capabilities register */
145 CapsOffset = PciReadDeviceCapability(DeviceExtension,
146 DeviceExtension->CapabilitiesPtr,
148 &PmCaps.Header,
149 sizeof(PCI_PM_CAPABILITY));
150 ASSERT(CapsOffset);
152
153 /* Check if the device is being powered up */
155 {
156 /* Set full power state */
157 PmCaps.PMCSR.ControlStatus.PowerState = 0;
158
159 /* Check if the device supports Cold-D3 poweroff */
160 if (PmCaps.PMC.Capabilities.Support.PMED3Cold)
161 {
162 /* If there was a pending PME, clear it */
163 PmCaps.PMCSR.ControlStatus.PMEStatus = 1;
164 }
165 }
166 else
167 {
168 /* Otherwise, just set the new power state, converting from NT */
170 }
171
172 /* Write the new power state in the PMCSR */
173 PciWriteDeviceConfig(DeviceExtension,
174 &PmCaps.PMCSR,
175 CapsOffset + FIELD_OFFSET(PCI_PM_CAPABILITY, PMCSR),
176 sizeof(PCI_PMCSR));
177
178 /* Now wait for the change to "stick" based on the spec-mandated time */
179 Status = PciStallForPowerChange(DeviceExtension, DeviceState, CapsOffset);
180 if (!NT_SUCCESS(Status)) return Status;
181 }
182 else
183 {
184 /* Nothing to do! */
185 DPRINT1("No PM on this device, ignoring request\n");
186 }
187
188 /* Check if new resources have to be assigned */
189 if (IrpSet)
190 {
191 /* Check if the new device state is lower (higher power) than now */
192 if (DeviceState < DeviceExtension->PowerState.CurrentDeviceState)
193 {
194 /* We would normally re-assign resources after powerup */
197 }
198 }
199
200 /* Return the power state change status */
201 return Status;
202}
BOOLEAN NTAPI PciCanDisableDecodes(IN PPCI_PDO_EXTENSION DeviceExtension, IN PPCI_COMMON_HEADER Config, IN ULONGLONG HackFlags, IN BOOLEAN ForPowerDown)
Definition: utils.c:954
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:3691
USHORT PMEStatus
Definition: iotypes.h:3696
struct _PCI_PMC::_PM_SUPPORT Support
union _PCI_PM_CAPABILITY::@4972 PMCSR
PCI_CAPABILITIES_HEADER Header
Definition: iotypes.h:3706
PCI_PMCSR ControlStatus
Definition: iotypes.h:3712
union _PCI_PM_CAPABILITY::@4971 PMC
PCI_PMC Capabilities
Definition: iotypes.h:3708
_In_ WDFDEVICE _Out_ PWDF_DEVICE_STATE DeviceState
Definition: wdfdevice.h:2005
#define PCI_CAPABILITY_ID_POWER_MANAGEMENT
Definition: iotypes.h:3649

Referenced by PciPdoIrpStartDevice(), and PciScanBus().

◆ PciSetResources()

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

Definition at line 2255 of file enum.c.

2258{
2260 UCHAR NewCacheLineSize, NewLatencyTimer;
2261 PCI_COMMON_HEADER PciData;
2263 PPCI_CONFIGURATOR Configurator;
2264
2265 UNREFERENCED_PARAMETER(SomethingSomethingDarkSide);
2266
2267 /* Get the FDO and read the configuration data */
2268 FdoExtension = PdoExtension->ParentFdoExtension;
2270
2271 /* Make sure this is still the same device */
2272 if (!PcipIsSameDevice(PdoExtension, &PciData))
2273 {
2274 /* Fail */
2275 ASSERTMSG("PCI Set resources - not same device.\n", FALSE);
2277 }
2278
2279 /* Nothing to set for a host bridge */
2280 if ((PdoExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) &&
2281 (PdoExtension->SubClass == PCI_SUBCLASS_BR_HOST))
2282 {
2283 /* Fake success */
2284 return STATUS_SUCCESS;
2285 }
2286
2287 /* Check if an IDE controller is being reset */
2288 if ((DoReset) &&
2289 (PdoExtension->BaseClass == PCI_CLASS_MASS_STORAGE_CTLR) &&
2291 {
2292 /* Turn off native mode */
2294 ASSERT(Native == PdoExtension->IDEInNativeMode);
2295 }
2296
2297 /* Check for update of a hotplug device, or first configuration of one */
2298 if ((PdoExtension->NeedsHotPlugConfiguration) &&
2299 (FdoExtension->HotPlugParameters.Acquired))
2300 {
2301 /* Don't have hotplug devices to test with yet, QEMU 0.14 should */
2303 }
2304
2305 /* Locate the correct resource configurator for this type of device */
2306 Configurator = &PciConfigurators[PdoExtension->HeaderType];
2307
2308 /* Apply the settings change */
2309 Configurator->ChangeResourceSettings(PdoExtension, &PciData);
2310
2311 /* Assume no update needed */
2312 PdoExtension->UpdateHardware = FALSE;
2313
2314 /* Check if a reset is needed */
2315 if (DoReset)
2316 {
2317 /* Reset resources */
2318 Configurator->ResetDevice(PdoExtension, &PciData);
2319 PciData.u.type0.InterruptLine = PdoExtension->RawInterruptLine;
2320 }
2321
2322 /* Check if the latency timer changed */
2323 NewLatencyTimer = PdoExtension->SavedLatencyTimer;
2324 if (PciData.LatencyTimer != NewLatencyTimer)
2325 {
2326 /* Debug notification */
2327 DPRINT1("PCI (pdox %p) changing latency from %02x to %02x.\n",
2329 PciData.LatencyTimer,
2330 NewLatencyTimer);
2331 }
2332
2333 /* Check if the cache line changed */
2334 NewCacheLineSize = PdoExtension->SavedCacheLineSize;
2335 if (PciData.CacheLineSize != NewCacheLineSize)
2336 {
2337 /* Debug notification */
2338 DPRINT1("PCI (pdox %p) changing cache line size from %02x to %02x.\n",
2340 PciData.CacheLineSize,
2341 NewCacheLineSize);
2342 }
2343
2344 /* Inherit data from PDO extension */
2345 PciData.LatencyTimer = PdoExtension->SavedLatencyTimer;
2346 PciData.CacheLineSize = PdoExtension->SavedCacheLineSize;
2347 PciData.u.type0.InterruptLine = PdoExtension->RawInterruptLine;
2348
2349 /* Apply any resource hacks required */
2351 &PciData,
2352 PdoExtension->Slot,
2354 PdoExtension);
2355
2356 /* Check if I/O space was disabled by administrator or driver */
2357 if (PdoExtension->IoSpaceNotRequired)
2358 {
2359 /* Don't turn on the decode */
2360 PdoExtension->CommandEnables &= ~PCI_ENABLE_IO_SPACE;
2361 }
2362
2363 /* Update the device with the new settings */
2365
2366 /* Update complete */
2367 PdoExtension->RawInterruptLine = PciData.u.type0.InterruptLine;
2368 PdoExtension->NeedsHotPlugConfiguration = FALSE;
2369 return STATUS_SUCCESS;
2370}
BOOLEAN NTAPI PcipIsSameDevice(IN PPCI_PDO_EXTENSION DeviceExtension, IN PPCI_COMMON_HEADER PciData)
Definition: enum.c:1155
BOOLEAN NTAPI PciConfigureIdeController(IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData, IN BOOLEAN Initial)
Definition: enum.c:746
VOID NTAPI PciUpdateHardware(IN PPCI_PDO_EXTENSION PdoExtension, IN PPCI_COMMON_HEADER PciData)
Definition: enum.c:282
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:886
#define PCI_HACK_FIXUP_BEFORE_UPDATE
Definition: pci.h:72
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:494
PCI_CONFIGURATOR_RESET_DEVICE ResetDevice
Definition: pci.h:496

Referenced by PciAssignSlotResources(), and PciPdoIrpStartDevice().

◆ PciStringToUSHORT()

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

Definition at line 61 of file utils.c.

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

30{
31 UNICODE_STRING PartialString;
32 LONG EqualChars, TotalChars;
33
34 /* Build a partial string with the smaller substring */
35 PartialString.Length = EqualString->Length;
36 PartialString.MaximumLength = InputString->MaximumLength;
37 PartialString.Buffer = InputString->Buffer;
38
39 /* Check how many characters that need comparing */
40 EqualChars = 0;
41 TotalChars = (InputString->Length - EqualString->Length) / sizeof(WCHAR);
42
43 /* If the substring is bigger, just fail immediately */
44 if (TotalChars < 0) return FALSE;
45
46 /* Keep checking each character */
47 while (!RtlEqualUnicodeString(EqualString, &PartialString, CaseInSensitive))
48 {
49 /* Continue checking until all the required characters are equal */
50 PartialString.Buffer++;
51 PartialString.MaximumLength -= sizeof(WCHAR);
52 if (++EqualChars > TotalChars) return FALSE;
53 }
54
55 /* The string is equal */
56 return TRUE;
57}
_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().

◆ PciVerifierInit()

VOID NTAPI PciVerifierInit ( IN PDRIVER_OBJECT  DriverObject)

Definition at line 94 of file pcivrify.c.

95{
97
98 /* Check if the kernel driver verifier is enabled */
100 {
101 /* Register a notification for changes, to keep track of the PCI tree */
103 0,
104 NULL,
107 NULL,
110 }
111}
BOOLEAN NTAPI VfIsVerificationEnabled(IN VF_OBJECT_TYPE VfObjectType, IN PVOID Object OPTIONAL)
Definition: driver.c:22
DRIVER_NOTIFICATION_CALLBACK_ROUTINE PciVerifierProfileChangeCallback
Definition: pcivrify.c:77
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().

◆ 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:92
PCI_VERIFIER_DATA PciVerifierFailureTable[PCI_VERIFIER_CODES]
Definition: pcivrify.c:21
ULONG FailureCode
Definition: pci.h:429

Referenced by PciStallForPowerChange().

◆ 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(), PcipUpdateHardware(), PciScanBus(), PciSetPowerManagedDevicePowerState(), and PciWriteLimitsAndRestoreCurrent().

◆ PPBridge_ChangeResourceSettings()

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

Definition at line 684 of file ppbridge.c.

686{
687 //BOOLEAN IoActive;
689 PPCI_FUNCTION_RESOURCES PciResources;
690 ULONG i;
691
692 /* Check if I/O Decodes are enabled */
693 //IoActive = (PciData->u.type1.IOBase & 0xF) == 1;
694
695 /*
696 * Check for Intel ICH PCI-to-PCI (i82801) bridges (used on the i810,
697 * i820, i840, i845 Chipsets) that don't have subtractive decode broken.
698 * If they do have broken subtractive support, or if they are not ICH bridges,
699 * then check if the bridge supports subtractive decode at all.
700 */
701 if ((((PdoExtension->VendorId == 0x8086) &&
702 ((PdoExtension->DeviceId == 0x2418) ||
703 (PdoExtension->DeviceId == 0x2428) ||
704 (PdoExtension->DeviceId == 0x244E) ||
705 (PdoExtension->DeviceId == 0x2448))) &&
707 (PdoExtension->Dependent.type1.SubtractiveDecode == FALSE))) ||
708 (PdoExtension->Dependent.type1.SubtractiveDecode == FALSE))
709 {
710 /* No resources are needed on a subtractive decode bridge */
711 PciData->u.type1.MemoryBase = 0xFFFF;
712 PciData->u.type1.PrefetchBase = 0xFFFF;
713 PciData->u.type1.IOBase = 0xFF;
714 PciData->u.type1.IOLimit = 0;
715 PciData->u.type1.MemoryLimit = 0;
716 PciData->u.type1.PrefetchLimit = 0;
717 PciData->u.type1.PrefetchBaseUpper32 = 0;
718 PciData->u.type1.PrefetchLimitUpper32 = 0;
719 PciData->u.type1.IOBaseUpper16 = 0;
720 PciData->u.type1.IOLimitUpper16 = 0;
721 }
722 else
723 {
724 /*
725 * Otherwise, get the FDO to read the old PCI configuration header that
726 * had been saved by the hack in PPBridge_SaveCurrentSettings.
727 */
728 FdoExtension = PdoExtension->ParentFdoExtension;
729 ASSERT(PdoExtension->Resources == NULL);
730
731 /* Read the PCI header data and use that here */
732 PciData->u.type1.IOBase = FdoExtension->PreservedConfig->u.type1.IOBase;
733 PciData->u.type1.IOLimit = FdoExtension->PreservedConfig->u.type1.IOLimit;
734 PciData->u.type1.MemoryBase = FdoExtension->PreservedConfig->u.type1.MemoryBase;
735 PciData->u.type1.MemoryLimit = FdoExtension->PreservedConfig->u.type1.MemoryLimit;
736 PciData->u.type1.PrefetchBase = FdoExtension->PreservedConfig->u.type1.PrefetchBase;
737 PciData->u.type1.PrefetchLimit = FdoExtension->PreservedConfig->u.type1.PrefetchLimit;
738 PciData->u.type1.PrefetchBaseUpper32 = FdoExtension->PreservedConfig->u.type1.PrefetchBaseUpper32;
739 PciData->u.type1.PrefetchLimitUpper32 = FdoExtension->PreservedConfig->u.type1.PrefetchLimitUpper32;
740 PciData->u.type1.IOBaseUpper16 = FdoExtension->PreservedConfig->u.type1.IOBaseUpper16;
741 PciData->u.type1.IOLimitUpper16 = FdoExtension->PreservedConfig->u.type1.IOLimitUpper16;
742 }
743
744 /* Loop bus resources */
745 PciResources = PdoExtension->Resources;
746 if (PciResources)
747 {
748 /* Loop each resource type (the BARs, ROM BAR and Prefetch) */
749 for (i = 0; i < 6; i++)
750 {
752 }
753 }
754
755 /* Copy the bus number data */
756 PciData->u.type1.PrimaryBus = PdoExtension->Dependent.type1.PrimaryBus;
757 PciData->u.type1.SecondaryBus = PdoExtension->Dependent.type1.SecondaryBus;
758 PciData->u.type1.SubordinateBus = PdoExtension->Dependent.type1.SubordinateBus;
759
760 /* Copy the decode flags */
761 if (PdoExtension->Dependent.type1.IsaBitSet)
762 {
763 PciData->u.type1.BridgeControl |= PCI_ENABLE_BRIDGE_ISA;
764 }
765
766 if (PdoExtension->Dependent.type1.VgaBitSet)
767 {
768 PciData->u.type1.BridgeControl |= PCI_ENABLE_BRIDGE_VGA;
769 }
770}
#define PCI_ENABLE_BRIDGE_ISA
Definition: pci.h:62
#define PCI_HACK_BROKEN_SUBTRACTIVE_DECODE
Definition: pci.h:50

◆ PPBridge_GetAdditionalResourceDescriptors()

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

Definition at line 629 of file ppbridge.c.

632{
633
635
636 /* Does this bridge have VGA decodes on it? */
637 if (PciData->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
638 {
639 /* Build a private descriptor with 3 entries */
640 IoDescriptor->Type = CmResourceTypeDevicePrivate;
641 IoDescriptor->u.DevicePrivate.Data[0] = 3;
642 IoDescriptor->u.DevicePrivate.Data[1] = 3;
643
644 /* First, the VGA range at 0xA0000 */
645 IoDescriptor[1].Type = CmResourceTypeMemory;
646 IoDescriptor[1].Flags = CM_RESOURCE_MEMORY_READ_WRITE;
647 IoDescriptor[1].u.Port.Length = 0x20000;
648 IoDescriptor[1].u.Port.Alignment = 1;
649 IoDescriptor[1].u.Port.MinimumAddress.QuadPart = 0xA0000;
650 IoDescriptor[1].u.Port.MaximumAddress.QuadPart = 0xBFFFF;
651
652 /* Then, the VGA registers at 0x3B0 */
653 IoDescriptor[2].Type = CmResourceTypePort;
654 IoDescriptor[2].Flags = CM_RESOURCE_PORT_POSITIVE_DECODE |
656 IoDescriptor[2].u.Port.Length = 12;
657 IoDescriptor[2].u.Port.Alignment = 1;
658 IoDescriptor[2].u.Port.MinimumAddress.QuadPart = 0x3B0;
659 IoDescriptor[2].u.Port.MaximumAddress.QuadPart = 0x3BB;
660
661 /* And finally the VGA registers at 0x3C0 */
662 IoDescriptor[3].Type = CmResourceTypePort;
663 IoDescriptor[3].Flags = CM_RESOURCE_PORT_POSITIVE_DECODE |
665 IoDescriptor[3].u.Port.Length = 32;
666 IoDescriptor[3].u.Port.Alignment = 1;
667 IoDescriptor[3].u.Port.MinimumAddress.QuadPart = 0x3C0;
668 IoDescriptor[3].u.Port.MaximumAddress.QuadPart = 0x3DF;
669 }
670}

◆ PPBridge_MassageHeaderForLimitsDetermination()

VOID NTAPI PPBridge_MassageHeaderForLimitsDetermination ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 583 of file ppbridge.c.

584{
585 PPCI_COMMON_HEADER PciData, Current;
586
587 /* Get pointers from context */
588 PciData = Context->PciData;
589 Current = Context->Current;
590
591 /*
592 * Write FFh everywhere so that the PCI bridge ignores what it can't handle.
593 * Based on the bits that were ignored (still 0), this is how we can tell
594 * what the limit is.
595 */
596 RtlFillMemory(PciData->u.type1.BaseAddresses,
597 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.CapabilitiesPtr) -
598 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.BaseAddresses),
599 0xFF);
600
601 /* Copy the saved settings from the current context into the PCI header */
602 PciData->u.type1.PrimaryBus = Current->u.type1.PrimaryBus;
603 PciData->u.type1.SecondaryBus = Current->u.type1.SecondaryBus;
604 PciData->u.type1.SubordinateBus = Current->u.type1.SubordinateBus;
605 PciData->u.type1.SecondaryLatency = Current->u.type1.SecondaryLatency;
606
607 /* No I/O limit or base. The bottom base bit specifies that FIXME */
608 PciData->u.type1.IOBaseUpper16 = 0xFFFE;
609 PciData->u.type1.IOLimitUpper16 = 0xFFFF;
610
611 /* Save secondary status before it gets cleared */
612 Context->SecondaryStatus = Current->u.type1.SecondaryStatus;
613
614 /* Clear secondary status */
615 Current->u.type1.SecondaryStatus = 0;
616 PciData->u.type1.SecondaryStatus = 0;
617}
#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 674 of file ppbridge.c.

◆ PPBridge_RestoreCurrent()

VOID NTAPI PPBridge_RestoreCurrent ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 621 of file ppbridge.c.

622{
623 /* Copy back the secondary status register */
624 Context->Current->u.type1.SecondaryStatus = Context->SecondaryStatus;
625}

◆ PPBridge_SaveCurrentSettings()

VOID NTAPI PPBridge_SaveCurrentSettings ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 225 of file ppbridge.c.

226{
229 PIO_RESOURCE_DESCRIPTOR IoDescriptor;
232 PPCI_COMMON_HEADER Current;
233 PPCI_COMMON_CONFIG SavedConfig;
234 ULONG i, Bar, BarMask;
235 PULONG BarArray;
237 BOOLEAN HaveIoLimit, CheckAlignment;
239
240 /* Get the pointers from the extension */
241 PdoExtension = Context->PdoExtension;
242 Resources = PdoExtension->Resources;
243 Current = Context->Current;
244
245 /* Check if decodes are disabled */
247 {
248 /* Well, we're going to need them from somewhere, use the registry data */
250 if (NT_SUCCESS(Status)) Current = &BiosData;
251 }
252
253 /* Scan all current and limit descriptors for each BAR needed */
254 BarArray = Current->u.type1.BaseAddresses;
255 for (i = 0; i < 6; i++)
256 {
257 /* Get the current resource descriptor, and the limit requirement */
258 CmDescriptor = &Resources->Current[i];
259 IoDescriptor = &Resources->Limit[i];
260
261 /* Copy descriptor data, skipping null descriptors */
262 CmDescriptor->Type = IoDescriptor->Type;
263 if (CmDescriptor->Type == CmResourceTypeNull) continue;
264 CmDescriptor->Flags = IoDescriptor->Flags;
265 CmDescriptor->ShareDisposition = IoDescriptor->ShareDisposition;
266
267 /* Initialize the high-parts to zero, since most stuff is 32-bit only */
268 Base.QuadPart = Limit.QuadPart = Length.QuadPart = 0;
269
270 /* Check if we're handling PCI BARs, or the ROM BAR */
271 if ((i < PCI_TYPE1_ADDRESSES) || (i == 5))
272 {
273 /* Is this the ROM BAR? */
274 if (i == 5)
275 {
276 /* Read the correct bar, with the appropriate mask */
277 Bar = Current->u.type1.ROMBaseAddress;
279
280 /* Decode the base address, and write down the length */
281 Base.LowPart = Bar & BarMask;
282 DPRINT1("ROM BAR Base: %lx\n", Base.LowPart);
283 CmDescriptor->u.Memory.Length = IoDescriptor->u.Memory.Length;
284 }
285 else
286 {
287 /* Otherwise, get the BAR from the array */
288 Bar = BarArray[i];
289
290 /* Is this an I/O BAR? */
292 {
293 /* Set the correct mask */
294 ASSERT(CmDescriptor->Type == CmResourceTypePort);
296 }
297 else
298 {
299 /* This is a memory BAR, set the correct base */
300 ASSERT((CmDescriptor->Type == CmResourceTypeMemory) ||
301 (CmDescriptor->Type == CmResourceTypeMemoryLarge));
303
304 /* IS this a 64-bit BAR? */
306 {
307 /* Read the next 32-bits as well, ie, the next BAR */
308 Base.HighPart = BarArray[i + 1];
309 }
310 }
311
312 /* Decode the base address, and write down the length */
313 Base.LowPart = Bar & BarMask;
314 DPRINT1("BAR Base: %lx\n", Base.LowPart);
315 CmDescriptor->u.Generic.Length = IoDescriptor->u.Generic.Length;
316 }
317 }
318 else
319 {
320 /* Reset loop conditions */
321 HaveIoLimit = FALSE;
323
324 /* Check which descriptor is being parsed */
325 if (i == 2)
326 {
327 /* I/O Port Requirements */
328 Base.LowPart = PciBridgeIoBase(Current);
329 Limit.LowPart = PciBridgeIoLimit(Current);
330 DPRINT1("Bridge I/O Base and Limit: %lx %lx\n",
331 Base.LowPart, Limit.LowPart);
332
333 /* Do we have any I/O Port data? */
334 if (!(Base.LowPart) && (Current->u.type1.IOLimit))
335 {
336 /* There's a limit */
337 HaveIoLimit = TRUE;
338 }
339 }
340 else if (i == 3)
341 {
342 /* Memory requirements */
343 Base.LowPart = PciBridgeMemoryBase(Current);
344 Limit.LowPart = PciBridgeMemoryLimit(Current);
345
346 /* These should always be there, so check their alignment */
347 DPRINT1("Bridge MEM Base and Limit: %lx %lx\n",
348 Base.LowPart, Limit.LowPart);
350 }
351 else if (i == 4)
352 {
353 /* This should only be present for prefetch memory */
357
358 /* If it's there, check the alignment */
359 DPRINT1("Bridge Prefetch MEM Base and Limit: %I64x %I64x\n", Base, Limit);
361 }
362
363 /* Check for invalid base address */
364 if (Base.QuadPart >= Limit.QuadPart)
365 {
366 /* Assume the descriptor is bogus */
367 CmDescriptor->Type = CmResourceTypeNull;
368 IoDescriptor->Type = CmResourceTypeNull;
369 continue;
370 }
371
372 /* Check if there's no memory, and no I/O port either */
373 if (!(Base.LowPart) && !(HaveIoLimit))
374 {
375 /* This seems like a bogus requirement, ignore it */
376 CmDescriptor->Type = CmResourceTypeNull;
377 continue;
378 }
379
380 /* Set the length to be the limit - the base; should always be 32-bit */
381 Length.QuadPart = Limit.LowPart - Base.LowPart + 1;
382 ASSERT(Length.HighPart == 0);
383 CmDescriptor->u.Generic.Length = Length.LowPart;
384
385 /* Check if alignment should be set */
386 if (CheckAlignment)
387 {
388 /* Compute the required alignment for this length */
389 ASSERT(CmDescriptor->u.Memory.Length > 0);
390 IoDescriptor->u.Memory.Alignment =
391 PciBridgeMemoryWorstCaseAlignment(CmDescriptor->u.Memory.Length);
392 }
393 }
394
395 /* Now set the base address */
396 CmDescriptor->u.Generic.Start.LowPart = Base.LowPart;
397 }
398
399 /* Save PCI settings into the PDO extension for easy access later */
400 PdoExtension->Dependent.type1.PrimaryBus = Current->u.type1.PrimaryBus;
401 PdoExtension->Dependent.type1.SecondaryBus = Current->u.type1.SecondaryBus;
402 PdoExtension->Dependent.type1.SubordinateBus = Current->u.type1.SubordinateBus;
403
404 /* Check for subtractive decode bridges */
405 if (PdoExtension->Dependent.type1.SubtractiveDecode)
406 {
407 /* Check if legacy VGA decodes are enabled */
408 DPRINT1("Subtractive decode bridge\n");
409 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
410 {
411 /* Save this setting for later */
412 DPRINT1("VGA Bridge\n");
413 PdoExtension->Dependent.type1.VgaBitSet = TRUE;
414 }
415
416 /* Legacy ISA decoding is not compatible with subtractive decode */
417 ASSERT(PdoExtension->Dependent.type1.IsaBitSet == FALSE);
418 }
419 else
420 {
421 /* Check if legacy VGA decodes are enabled */
422 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_VGA)
423 {
424 /* Save this setting for later */
425 DPRINT1("VGA Bridge\n");
426 PdoExtension->Dependent.type1.VgaBitSet = TRUE;
427
428 /* And on positive decode, we'll also need extra resources locked */
429 PdoExtension->AdditionalResourceCount = 4;
430 }
431
432 /* Check if legacy ISA decoding is enabled */
433 if (Current->u.type1.BridgeControl & PCI_ENABLE_BRIDGE_ISA)
434 {
435 /* Save this setting for later */
436 DPRINT1("ISA Bridge\n");
437 PdoExtension->Dependent.type1.IsaBitSet = TRUE;
438 }
439 }
440
441 /*
442 * Check for Intel ICH PCI-to-PCI (i82801) bridges (used on the i810,
443 * i820, i840, i845 Chipsets) that have subtractive decode broken.
444 */
445 if (((PdoExtension->VendorId == 0x8086) &&
446 ((PdoExtension->DeviceId == 0x2418) ||
447 (PdoExtension->DeviceId == 0x2428) ||
448 (PdoExtension->DeviceId == 0x244E) ||
449 (PdoExtension->DeviceId == 0x2448))) ||
451 {
452 /* Check if subtractive decode is actually enabled */
453 if (PdoExtension->Dependent.type1.SubtractiveDecode)
454 {
455 /* We're going to need a copy of the configuration for later use */
456 DPRINT1("apply config save hack to ICH subtractive decode\n");
457 SavedConfig = ExAllocatePoolWithTag(0, PCI_COMMON_HDR_LENGTH, 'PciP');
458 PdoExtension->ParentFdoExtension->PreservedConfig = SavedConfig;
459 if (SavedConfig) RtlCopyMemory(SavedConfig, Current, PCI_COMMON_HDR_LENGTH);
460 }
461 }
462}
VOID CheckAlignment()
NTSTATUS NTAPI PciGetBiosConfig(IN PPCI_PDO_EXTENSION DeviceExtension, OUT PPCI_COMMON_HEADER PciData)
Definition: utils.c:767
_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:148
PHYSICAL_ADDRESS NTAPI PciBridgePrefetchMemoryLimit(IN PPCI_COMMON_HEADER PciData)
Definition: ppbridge.c:121
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::@2481::@2483 Memory
PBIOS_DATA BiosData
Definition: bios.c:42
#define PCI_TYPE1_ADDRESSES
Definition: iotypes.h:3503

◆ PPBridge_SaveLimits()

VOID NTAPI PPBridge_SaveLimits ( IN PPCI_CONFIGURATOR_CONTEXT  Context)

Definition at line 466 of file ppbridge.c.

467{
469 PULONG BarArray;
470 PHYSICAL_ADDRESS MemoryLimit;
471 ULONG i;
474
475 /* Get the pointers from the context */
476 Working = Context->PciData;
477 PdoExtension = Context->PdoExtension;
478
479 /* Scan the BARs into the limit descriptors */
480 BarArray = Working->u.type1.BaseAddresses;
481 Limit = PdoExtension->Resources->Limit;
482
483 /* First of all, loop all the BARs */
484 for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
485 {
486 /* Create a descriptor for their limits, the second BAR has no BAR after it */
487 ULONG NextBar = ((i + 1) < PCI_TYPE1_ADDRESSES) ? BarArray[i + 1] : 0;
488
489 if (PciCreateIoDescriptorFromBarLimit(&Limit[i], BarArray[i], NextBar, FALSE))
490 {
491 /* This was a 64-bit descriptor, make sure there's space */
493
494 /* Skip the next descriptor since this one is double sized */
495 i++;
496 Limit[i].Type = CmResourceTypeNull;
497 }
498 }
499
500 /* Check if this is a subtractive decode bridge */
502 {
503 /* This bridge is subtractive */
504 PdoExtension->Dependent.type1.SubtractiveDecode = TRUE;
505
506 /* Subtractive bridges cannot use legacy ISA or VGA functionality */
507 PdoExtension->Dependent.type1.IsaBitSet = FALSE;
508 PdoExtension->Dependent.type1.VgaBitSet = FALSE;
509 }
510
511 /* For normal decode bridges, we'll need to find the bridge limits too */
512 if (!PdoExtension->Dependent.type1.SubtractiveDecode)
513 {
514 /* Loop the descriptors that are left, to store the bridge limits */
515 for (i = PCI_TYPE1_ADDRESSES; i < 5; i++)
516 {
517 /* No 64-bit memory addresses, and set the address to 0 to begin */
518 MemoryLimit.HighPart = 0;
519 (&Limit[i])->u.Port.MinimumAddress.QuadPart = 0;
520
521 /* Are we getting the I/O limit? */
522 if (i == 2)
523 {
524 /* There should be one, get it */
525 ASSERT(Working->u.type1.IOLimit != 0);
526 ASSERT((Working->u.type1.IOLimit & 0x0E) == 0);
527 MemoryLimit.LowPart = PciBridgeIoLimit(Working);
528
529 /* Build a descriptor for this limit */
533 (&Limit[i])->u.Port.Alignment = 0x1000;
534 (&Limit[i])->u.Port.MinimumAddress.QuadPart = 0;
535 (&Limit[i])->u.Port.MaximumAddress = MemoryLimit;
536 (&Limit[i])->u.Port.Length = 0;
537 }
538 else if (i == 3)
539 {
540 /* There should be a valid memory limit, get it */
541 ASSERT((Working->u.type1.MemoryLimit & 0xF) == 0);
542 MemoryLimit.LowPart = PciBridgeMemoryLimit(Working);
543
544 /* Build the descriptor for it */
547 (&Limit[i])->u.Memory.Alignment = 0x100000;
548 (&Limit[i])->u.Memory.MinimumAddress.QuadPart = 0;
549 (&Limit[i])->u.Memory.MaximumAddress = MemoryLimit;
550 (&Limit[i])->u.Memory.Length = 0;
551 }
552 else if (Working->u.type1.PrefetchLimit)
553 {
554 /* Get the prefetch memory limit, if there is one */
556
557 /* Write out the descriptor for it */
560 (&Limit[i])->u.Memory.Alignment = 0x100000;
561 (&Limit[i])->u.Memory.MinimumAddress.QuadPart = 0;
562 (&Limit[i])->u.Memory.MaximumAddress = MemoryLimit;
563 (&Limit[i])->u.Memory.Length = 0;
564 }
565 else
566 {
567 /* Blank descriptor */
569 }
570 }
571 }
572
573 /* Does the ROM have its own BAR? */
574 if (Working->u.type1.ROMBaseAddress & PCI_ROMADDRESS_ENABLED)
575 {
576 /* Build a limit for it as well */
577 PciCreateIoDescriptorFromBarLimit(&Limit[i], Working->u.type1.ROMBaseAddress, 0, TRUE);
578 }
579}
_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:173
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 47 of file routintf.c.

53{
54 UNREFERENCED_PARAMETER(DeviceExtension);
56 UNREFERENCED_PARAMETER(InterfaceData);
59
60 /* Only version 1 is supported */
62
63 /* Not yet implemented */
66}
#define STATUS_NOINTERFACE
Definition: ntstatus.h:937
#define PCI_INT_ROUTE_INTRF_STANDARD_VER
Definition: iotypes.h:5460

◆ 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("PCI - 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.

◆ InitSafeBootMode

NTSYSAPI BOOLEAN InitSafeBootMode
extern

Definition at line 71 of file init.c.

Referenced by AtaCtrlSetTransferMode(), and PciApplyHacks().

◆ PciAddDevice

DRIVER_ADD_DEVICE PciAddDevice

Definition at line 633 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.

◆ 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 555 of file pci.h.

Referenced by DriverEntry().

◆ PciDriverObject

PDRIVER_OBJECT PciDriverObject
extern

Definition at line 19 of file init.c.

Referenced by DriverEntry(), and PciGetDescriptionMessage().

◆ PciEcamVerified

BOOLEAN PciEcamVerified
extern

Definition at line 20 of file ecam.c.

Referenced by PciEcamReadWriteConfig(), PciGetExpressCapabilities(), and PciInitializeEcam().

◆ 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 1146 of file pci.h.

Referenced by PcipGetFunctionLimits(), and PciUpdateHardware().

◆ PciFdoExtensionListHead

SINGLE_LIST_ENTRY PciFdoExtensionListHead
extern

Definition at line 18 of file fdo.c.

Referenced by PciAddDevice(), PciFindParentPciFdoExtension(), and PciFindPdoByLocation().

◆ PciGlobalLock

KEVENT PciGlobalLock
extern

Definition at line 20 of file init.c.

Referenced by DriverEntry(), PciAddDevice(), PciAssignSlotResources(), and PciFindPdoByLocation().

◆ PciHackTable

PPCI_HACK_ENTRY PciHackTable
extern

Definition at line 28 of file init.c.

Referenced by PciBuildHackTable(), 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(), and PciDetermineSlotNumber().

◆ 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().

◆ 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 PciScanBus().