ReactOS 0.4.17-dev-1190-g4c812f4
pcivrify.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS PCI Bus Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/bus/pci/pcivrify.c
5 * PURPOSE: PCI Driver Verifier Support
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include <pci.h>
12
13#define NDEBUG
14#include <debug.h>
15
16/* GLOBALS ********************************************************************/
17
20
22{
23 {
24 1,
26 0,
27 "The BIOS has reprogrammed the bus numbers of an active PCI device "
28 "(!devstack %DevObj) during a dock or undock!"
29 },
30 {
31 2,
33 0,
34 "A device in the system did not update it's PMCSR register in the spec "
35 "mandated time (!devstack %DevObj, Power state D%Ulong)"
36 },
37 {
38 3,
40 0,
41 "A driver controlling a PCI device has tried to access OS controlled "
42 "configuration space registers (!devstack %DevObj, Offset 0x%Ulong1, "
43 "Length 0x%Ulong2)"
44 },
45 {
46 4,
48 0,
49 "A driver controlling a PCI device has tried to read or write from an "
50 "invalid space using IRP_MN_READ/WRITE_CONFIG or via BUS_INTERFACE_STANDARD."
51 " NB: These functions take WhichSpace parameters of the form PCI_WHICHSPACE_*"
52 " and not a BUS_DATA_TYPE (!devstack %DevObj, WhichSpace 0x%Ulong1)"
53 },
54};
55
56/* FUNCTIONS ******************************************************************/
57
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}
76
80static
81VOID
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}
112
116static
117VOID
118NTAPI
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}
160
161DRIVER_NOTIFICATION_CALLBACK_ROUTINE PciVerifierProfileChangeCallback;
162
164NTAPI
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}
179
180VOID
181NTAPI
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}
200
204VOID
205NTAPI
207{
208 PAGED_CODE();
209
211 {
215 }
216}
217
218/* EOF */
#define PAGED_CODE()
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
SINGLE_LIST_ENTRY PciFdoExtensionListHead
Definition: fdo.c:18
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
KEVENT PciGlobalLock
Definition: init.c:20
#define PCI_VERIFIER_CODES
Definition: pci.h:121
VOID NTAPI PciReadDeviceConfig(IN PPCI_PDO_EXTENSION DeviceExtension, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: config.c:149
@ 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
Status
Definition: gdiplustypes.h:24
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 KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
#define ASSERT(a)
Definition: mode.c:44
#define KernelMode
Definition: asm.h:38
#define _In_
Definition: no_sal2.h:158
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
BOOLEAN NTAPI VfIsVerificationEnabled(IN VF_OBJECT_TYPE VfObjectType, IN PVOID Object OPTIONAL)
Definition: driver.c:22
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
@ 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
VOID NTAPI PciVerifierInit(IN PDRIVER_OBJECT DriverObject)
Definition: pcivrify.c:182
DRIVER_NOTIFICATION_CALLBACK_ROUTINE PciVerifierProfileChangeCallback
Definition: pcivrify.c:161
PPCI_VERIFIER_DATA NTAPI PciVerifierRetrieveFailureData(IN ULONG FailureCode)
Definition: pcivrify.c:60
PCI_VERIFIER_DATA PciVerifierFailureTable[PCI_VERIFIER_CODES]
Definition: pcivrify.c:21
PVOID PciVerifierNotificationHandle
Definition: pcivrify.c:19
BOOLEAN PciVerifierRegistered
Definition: pcivrify.c:18
static VOID NTAPI PciVerifierCheckAllBridges(VOID)
Checks every active bridge after firmware had the chance to reprogram it.
Definition: pcivrify.c:119
VOID NTAPI PciVerifierRelease(VOID)
Drops the hardware profile notification taken by PciVerifierInit.
Definition: pcivrify.c:206
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
NTSTATUS NTAPI IoUnregisterPlugPlayNotification(_In_ PVOID NotificationEntry)
Definition: pnpnotify.c:480
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG FailureCode
Definition: pci.h:480
VF_FAILURE_CLASS FailureClass
Definition: pci.h:481
PCHAR DebuggerMessageText
Definition: pci.h:483
ULONG AssertionControl
Definition: pci.h:482
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:641
unsigned char UCHAR
Definition: typedefs.h:53
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
@ VFFAILURE_FAIL_LOGO
Definition: vftypes.h:33
@ VFFAILURE_FAIL_UNDER_DEBUGGER
Definition: vftypes.h:34
@ VFOBJTYPE_SYSTEM_BIOS
Definition: vftypes.h:44
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
Definition: wdfcontrol.h:115
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1206
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define PCI_BRIDGE_TYPE
Definition: iotypes.h:3621
@ EventCategoryHardwareProfileChange
Definition: iotypes.h:1225
#define PCI_CARDBUS_BRIDGE_TYPE
Definition: iotypes.h:3622
@ Executive
Definition: ketypes.h:467