[CMAKE]
[reactos.git] / drivers / bus / pcix / pcivrify.c
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 #define NDEBUG
13 #include <debug.h>
14
15 /* GLOBALS ********************************************************************/
16
17 BOOLEAN PciVerifierRegistered;
18 PVOID PciVerifierNotificationHandle;
19
20 PCI_VERIFIER_DATA PciVerifierFailureTable[PCI_VERIFIER_CODES] =
21 {
22 {
23 1,
24 VFFAILURE_FAIL_LOGO,
25 0,
26 "The BIOS has reprogrammed the bus numbers of an active PCI device "
27 "(!devstack %DevObj) during a dock or undock!"
28 },
29 {
30 2,
31 VFFAILURE_FAIL_LOGO,
32 0,
33 "A device in the system did not update it's PMCSR register in the spec "
34 "mandated time (!devstack %DevObj, Power state D%Ulong)"
35 },
36 {
37 3,
38 VFFAILURE_FAIL_LOGO,
39 0,
40 "A driver controlling a PCI device has tried to access OS controlled "
41 "configuration space registers (!devstack %DevObj, Offset 0x%Ulong1, "
42 "Length 0x%Ulong2)"
43 },
44 {
45 4,
46 VFFAILURE_FAIL_UNDER_DEBUGGER,
47 0,
48 "A driver controlling a PCI device has tried to read or write from an "
49 "invalid space using IRP_MN_READ/WRITE_CONFIG or via BUS_INTERFACE_STANDARD."
50 " NB: These functions take WhichSpace parameters of the form PCI_WHICHSPACE_*"
51 " and not a BUS_DATA_TYPE (!devstack %DevObj, WhichSpace 0x%Ulong1)"
52 },
53 };
54
55 /* FUNCTIONS ******************************************************************/
56
57 PPCI_VERIFIER_DATA
58 NTAPI
59 PciVerifierRetrieveFailureData(IN ULONG FailureCode)
60 {
61 PPCI_VERIFIER_DATA VerifierData;
62
63 /* Scan the verifier failure table for this code */
64 VerifierData = PciVerifierFailureTable;
65 while (VerifierData->FailureCode != FailureCode)
66 {
67 /* Keep searching */
68 ++VerifierData;
69 ASSERT(VerifierData < &PciVerifierFailureTable[PCI_VERIFIER_CODES]);
70 }
71
72 /* Return the entry for this code */
73 return VerifierData;
74 }
75
76 NTSTATUS
77 NTAPI
78 PciVerifierProfileChangeCallback(IN PVOID NotificationStructure,
79 IN PVOID Context)
80 {
81 /* This function is not yet implemented */
82 UNIMPLEMENTED;
83 while (TRUE);
84 return STATUS_SUCCESS;
85 }
86
87 VOID
88 NTAPI
89 PciVerifierInit(IN PDRIVER_OBJECT DriverObject)
90 {
91 NTSTATUS Status;
92
93 /* Check if the kernel driver verifier is enabled */
94 if (VfIsVerificationEnabled(VFOBJTYPE_SYSTEM_BIOS, NULL))
95 {
96 /* Register a notification for changes, to keep track of the PCI tree */
97 Status = IoRegisterPlugPlayNotification(EventCategoryHardwareProfileChange,
98 0,
99 NULL,
100 DriverObject,
101 PciVerifierProfileChangeCallback,
102 NULL,
103 &PciVerifierNotificationHandle);
104 if (NT_SUCCESS(Status)) PciVerifierRegistered = TRUE;
105 }
106 }
107
108 /* EOF */