2 * PROJECT: ReactOS PCI Bus Driver
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/bus/pci/debug.c
5 * PURPOSE: Debug Helpers
6 * PROGRAMMERS: ReactOS Portable Systems Group
9 /* INCLUDES *******************************************************************/
15 /* GLOBALS ********************************************************************/
20 "QUERY_REMOVE_DEVICE",
22 "CANCEL_REMOVE_DEVICE",
26 "QUERY_DEVICE_RELATIONS",
30 "QUERY_RESOURCE_REQUIREMENTS",
32 "FILTER_RESOURCE_REQUIREMENTS",
33 "** UNKNOWN PNP IRP Minor Code **",
39 "QUERY_PNP_DEVICE_STATE",
40 "QUERY_BUS_INFORMATION",
41 "DEVICE_USAGE_NOTIFICATION"
52 ULONG PciBreakOnPdoPowerIrp
, PciBreakOnFdoPowerIrp
;
53 ULONG PciBreakOnPdoPnpIrp
, PciBreakOnFdoPnpIrp
;
55 /* FUNCTIONS ******************************************************************/
59 PciDebugPnpIrpTypeToText(IN USHORT MinorFunction
)
63 /* Catch invalid code */
64 if (MinorFunction
>= IRP_MN_SURPRISE_REMOVAL
)
66 /* New version of Windows? Or driver bug */
67 Text
= "** UNKNOWN PNP IRP Minor Code **";
71 /* Get the right text for it */
72 Text
= PnpCodes
[MinorFunction
];
75 /* Return the symbolic name for the IRP */
81 PciDebugPoIrpTypeToText(IN USHORT MinorFunction
)
85 /* Catch invalid code */
86 if (MinorFunction
>= IRP_MN_QUERY_POWER
)
88 /* New version of Windows? Or driver bug */
89 Text
= "** UNKNOWN PO IRP Minor Code **";
93 /* Get the right text for it */
94 Text
= PoCodes
[MinorFunction
];
97 /* Return the symbolic name for the IRP */
103 PciDebugIrpDispatchDisplay(IN PIO_STACK_LOCATION IoStackLocation
,
104 IN PPCI_FDO_EXTENSION DeviceExtension
,
107 //PPCI_PDO_EXTENSION PdoDeviceExtension;
108 ULONG BreakMask
, DebugLevel
= 0;
111 /* Only two functions are recognized */
112 switch (IoStackLocation
->MajorFunction
)
116 /* Get the string and the correct break mask for the extension */
117 BreakMask
= (DeviceExtension
->ExtensionType
== PciPdoExtensionType
) ?
118 PciBreakOnPdoPowerIrp
: PciBreakOnFdoPowerIrp
;
119 IrpString
= PciDebugPoIrpTypeToText(IoStackLocation
->MinorFunction
);
124 /* Get the string and the correct break mask for the extension */
125 BreakMask
= (DeviceExtension
->ExtensionType
== PciFdoExtensionType
) ?
126 PciBreakOnPdoPnpIrp
: PciBreakOnFdoPnpIrp
;
127 IrpString
= PciDebugPnpIrpTypeToText(IoStackLocation
->MinorFunction
);
132 /* Other functions are not decoded */
138 /* Check if this is a PDO */
139 if (DeviceExtension
->ExtensionType
== PciPdoExtensionType
)
141 /* Choose the correct debug level based on which function this is */
142 if (IoStackLocation
->MajorFunction
== IRP_MJ_POWER
)
146 else if (IoStackLocation
->MajorFunction
== IRP_MJ_PNP
)
150 #if 0 // after commit PDO support
151 /* For a PDO, print out the bus, device, and function number */
152 PdoDeviceExtension
= (PVOID
)DeviceExtension
;
153 DPRINT1("PDO(b=0x%x, d=0x%x, f=0x%x)<-%s\n",
154 PdoDeviceExtension
->ParentFdoExtension
->BaseBus
,
155 PdoDeviceExtension
->Slot
.u
.bits
.DeviceNumber
,
156 PdoDeviceExtension
->Slot
.u
.bits
.FunctionNumber
,
160 else if (DeviceExtension
->ExtensionType
== PciFdoExtensionType
)
162 /* Choose the correct debug level based on which function this is */
163 if (IoStackLocation
->MajorFunction
== IRP_MJ_POWER
)
167 else if (IoStackLocation
->MajorFunction
== IRP_MJ_PNP
)
172 /* For an FDO, just dump the extension pointer and IRP string */
173 DPRINT1("FDO(%x)<-%s\n", DeviceExtension
, IrpString
);
176 /* If the function is illegal for this extension, complain */
177 if (IoStackLocation
->MinorFunction
> MaxMinor
)
178 DPRINT1("Unknown IRP, minor = 0x%x\n", IoStackLocation
->MinorFunction
);
180 /* Return whether or not the debugger should be broken into for this IRP */
181 return ((1 << IoStackLocation
->MinorFunction
) & BreakMask
);