ReactOS 0.4.17-dev-1190-g4c812f4
pcivrify.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for pcivrify.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

PPCI_VERIFIER_DATA NTAPI PciVerifierRetrieveFailureData (IN ULONG FailureCode)
 
static VOID NTAPI PciVerifierCheckBridgeBusNumbers (_In_ PPCI_PDO_EXTENSION PdoExtension)
 Reports a bridge whose bus numbers differ from the ones this driver tracks.
 
static VOID NTAPI PciVerifierCheckAllBridges (VOID)
 Checks every active bridge after firmware had the chance to reprogram it.
 
NTSTATUS NTAPI PciVerifierProfileChangeCallback (IN PVOID NotificationStructure, IN PVOID Context)
 
VOID NTAPI PciVerifierInit (IN PDRIVER_OBJECT DriverObject)
 
VOID NTAPI PciVerifierRelease (VOID)
 Drops the hardware profile notification taken by PciVerifierInit.
 

Variables

BOOLEAN PciVerifierRegistered
 
PVOID PciVerifierNotificationHandle
 
PCI_VERIFIER_DATA PciVerifierFailureTable [PCI_VERIFIER_CODES]
 
DRIVER_NOTIFICATION_CALLBACK_ROUTINE PciVerifierProfileChangeCallback
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file pcivrify.c.

Function Documentation

◆ PciVerifierCheckAllBridges()

static VOID NTAPI PciVerifierCheckAllBridges ( VOID  )
static

Checks every active bridge after firmware had the chance to reprogram it.

Definition at line 119 of file pcivrify.c.

120{
123 PAGED_CODE();
124
127
131 {
133
134 for (PdoExtension = FdoExtension->ChildPdoList;
137 {
138 if ((PdoExtension->HeaderType != PCI_BRIDGE_TYPE) &&
139 (PdoExtension->HeaderType != PCI_CARDBUS_BRIDGE_TYPE))
140 {
141 continue;
142 }
143
144 /* A bridge that is gone or powered off may have lost its settings legitimately */
145 if (PdoExtension->NotPresent ||
146 (PdoExtension->PowerState.CurrentDeviceState == PowerDeviceD3))
147 {
148 continue;
149 }
150
152 }
153
154 KeSetEvent(&FdoExtension->ChildListLock, IO_NO_INCREMENT, FALSE);
155 }
156
159}
#define PAGED_CODE()
SINGLE_LIST_ENTRY PciFdoExtensionListHead
Definition: fdo.c:18
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
KEVENT PciGlobalLock
Definition: init.c:20
@ PdoExtension
Definition: precomp.h:61
@ FdoExtension
Definition: precomp.h:60
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#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
#define KernelMode
Definition: asm.h:38
@ PowerDeviceD3
Definition: ntpoapi.h:52
static VOID NTAPI PciVerifierCheckBridgeBusNumbers(_In_ PPCI_PDO_EXTENSION PdoExtension)
Reports a bridge whose bus numbers differ from the ones this driver tracks.
Definition: pcivrify.c:83
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:641
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define PCI_BRIDGE_TYPE
Definition: iotypes.h:3621
#define PCI_CARDBUS_BRIDGE_TYPE
Definition: iotypes.h:3622
@ Executive
Definition: ketypes.h:467

Referenced by PciVerifierProfileChangeCallback().

◆ PciVerifierCheckBridgeBusNumbers()

static VOID NTAPI PciVerifierCheckBridgeBusNumbers ( _In_ PPCI_PDO_EXTENSION  PdoExtension)
static

Reports a bridge whose bus numbers differ from the ones this driver tracks.

Definition at line 83 of file pcivrify.c.

85{
86 PPCI_VERIFIER_DATA VerifierData;
87 UCHAR BusNumbers[3];
88
89 /* Type 1 and type 2 headers keep the bus numbers at the same offset */
91 BusNumbers,
92 FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.PrimaryBus),
93 sizeof(BusNumbers));
94
95 if ((BusNumbers[0] == PdoExtension->Dependent.type1.PrimaryBus) &&
96 (BusNumbers[1] == PdoExtension->Dependent.type1.SecondaryBus) &&
97 (BusNumbers[2] == PdoExtension->Dependent.type1.SubordinateBus))
98 {
99 return;
100 }
101
102 VerifierData = PciVerifierRetrieveFailureData(1);
103 ASSERT(VerifierData);
104 VfFailSystemBIOS(PCI_VERIFIER_DETECTED_VIOLATION,
105 1,
106 VerifierData->FailureClass,
107 &VerifierData->AssertionControl,
108 VerifierData->DebuggerMessageText,
109 "%DevObj",
110 PdoExtension->PhysicalDeviceObject);
111}
VOID NTAPI PciReadDeviceConfig(IN PPCI_PDO_EXTENSION DeviceExtension, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: config.c:149
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
#define ASSERT(a)
Definition: mode.c:44
VOID __cdecl VfFailSystemBIOS(IN ULONG BugCheckMajorCode, IN ULONG BugCheckMinorCode, IN VF_FAILURE_CLASS FailureClass, IN OUT PULONG AssertionControl, IN PSTR DebuggerMessageText, IN PSTR ParameterFormatString,...)
Definition: driver.c:51
PPCI_VERIFIER_DATA NTAPI PciVerifierRetrieveFailureData(IN ULONG FailureCode)
Definition: pcivrify.c:60
VF_FAILURE_CLASS FailureClass
Definition: pci.h:481
PCHAR DebuggerMessageText
Definition: pci.h:483
ULONG AssertionControl
Definition: pci.h:482
unsigned char UCHAR
Definition: typedefs.h:53
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by PciVerifierCheckAllBridges().

◆ PciVerifierInit()

VOID NTAPI PciVerifierInit ( IN PDRIVER_OBJECT  DriverObject)

Definition at line 182 of file pcivrify.c.

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

Referenced by DriverEntry().

◆ PciVerifierProfileChangeCallback()

NTSTATUS NTAPI PciVerifierProfileChangeCallback ( IN PVOID  NotificationStructure,
IN PVOID  Context 
)

Definition at line 165 of file pcivrify.c.

167{
169
171 PAGED_CODE();
172
173 /* A dock or undock is finished, so firmware is done touching the buses */
174 if (IsEqualGUIDAligned(&Notification->Event, &GUID_HWPROFILE_CHANGE_COMPLETE))
176
177 return STATUS_SUCCESS;
178}
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
static VOID NTAPI PciVerifierCheckAllBridges(VOID)
Checks every active bridge after firmware had the chance to reprogram it.
Definition: pcivrify.c:119
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
Definition: wdfcontrol.h:115
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1206

◆ PciVerifierRelease()

VOID NTAPI PciVerifierRelease ( VOID  )

Drops the hardware profile notification taken by PciVerifierInit.

Definition at line 206 of file pcivrify.c.

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

Referenced by PciDriverUnload().

◆ PciVerifierRetrieveFailureData()

PPCI_VERIFIER_DATA NTAPI PciVerifierRetrieveFailureData ( IN ULONG  FailureCode)

Definition at line 60 of file pcivrify.c.

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

Referenced by PciStallForPowerChange(), and PciVerifierCheckBridgeBusNumbers().

Variable Documentation

◆ PciVerifierFailureTable

PCI_VERIFIER_DATA PciVerifierFailureTable[PCI_VERIFIER_CODES]

Definition at line 21 of file pcivrify.c.

Referenced by PciVerifierRetrieveFailureData().

◆ PciVerifierNotificationHandle

PVOID PciVerifierNotificationHandle

Definition at line 19 of file pcivrify.c.

Referenced by PciVerifierInit(), and PciVerifierRelease().

◆ PciVerifierProfileChangeCallback

DRIVER_NOTIFICATION_CALLBACK_ROUTINE PciVerifierProfileChangeCallback

Definition at line 161 of file pcivrify.c.

Referenced by PciVerifierInit().

◆ PciVerifierRegistered

BOOLEAN PciVerifierRegistered

Definition at line 18 of file pcivrify.c.

Referenced by PciVerifierInit(), and PciVerifierRelease().