Skip to content

Commit

Permalink
RHEL-69072: clang-format for pvpanic folder
Browse files Browse the repository at this point in the history
Signed-off-by: Vitalii Chulak <[email protected]>
  • Loading branch information
Jedoku committed Dec 16, 2024
1 parent a01c696 commit b352f2b
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
matrix:
path:
- check: '.'
exclude: './ivshmem|./NetKVM|./pciserial|./pvpanic|./viocrypt|./viofs|./viogpu|./vioinput|./viomem|./viorng|./vioscsi|./vioserial|./viosock|./viostor|./VirtIO'
exclude: './ivshmem|./NetKVM|./pciserial|./viocrypt|./viofs|./viogpu|./vioinput|./viomem|./viorng|./vioscsi|./vioserial|./viosock|./viostor|./VirtIO'
- check: 'VirtIO'
exclude: ''

Expand Down
42 changes: 21 additions & 21 deletions pvpanic/pvpanic/bugcheck.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
#include "pvpanic.h"
#include "bugcheck.tmh"

static KBUGCHECK_CALLBACK_RECORD CallbackRecord;
static KBUGCHECK_CALLBACK_RECORD CallbackRecord;
static KBUGCHECK_REASON_CALLBACK_RECORD DumpCallbackRecord;

KBUGCHECK_CALLBACK_ROUTINE PVPanicOnBugCheck;
KBUGCHECK_CALLBACK_ROUTINE PVPanicOnBugCheck;
KBUGCHECK_REASON_CALLBACK_ROUTINE PVPanicOnDumpBugCheck;

VOID PVPanicOnBugCheck(IN PVOID Buffer, IN ULONG Length)
{
//Trigger the PVPANIC_PANICKED event if the crash dump isn't enabled,
// Trigger the PVPANIC_PANICKED event if the crash dump isn't enabled,
if ((Buffer != NULL) && (Length == sizeof(PVOID)) && !bEmitCrashLoadedEvent)
{
if (BusType & PVPANIC_PCI)
Expand All @@ -48,16 +48,15 @@ VOID PVPanicOnBugCheck(IN PVOID Buffer, IN ULONG Length)
}
}

VOID PVPanicOnDumpBugCheck(
KBUGCHECK_CALLBACK_REASON Reason,
PKBUGCHECK_REASON_CALLBACK_RECORD Record,
PVOID Data,
ULONG Length)
VOID PVPanicOnDumpBugCheck(KBUGCHECK_CALLBACK_REASON Reason,
PKBUGCHECK_REASON_CALLBACK_RECORD Record,
PVOID Data,
ULONG Length)
{
UNREFERENCED_PARAMETER(Data);
UNREFERENCED_PARAMETER(Length);

//Trigger the PVPANIC_CRASHLOADED event before the crash dump.
// Trigger the PVPANIC_CRASHLOADED event before the crash dump.
if ((PvPanicPortOrMemAddress != NULL) && (Reason == KbCallbackDumpIo) && !bEmitCrashLoadedEvent)
{
if (BusType & PVPANIC_PCI)
Expand All @@ -67,7 +66,7 @@ VOID PVPanicOnDumpBugCheck(

bEmitCrashLoadedEvent = TRUE;
}
//Deregister BugCheckReasonCallback after PVPANIC_CRASHLOADED is triggered.
// Deregister BugCheckReasonCallback after PVPANIC_CRASHLOADED is triggered.
if (bEmitCrashLoadedEvent)
KeDeregisterBugCheckReasonCallback(Record);
}
Expand All @@ -81,23 +80,26 @@ VOID PVPanicRegisterBugCheckCallback(IN PVOID PortAddress, PUCHAR Component)

if (SupportedFeature & PVPANIC_PANICKED)
{
bBugCheck = KeRegisterBugCheckCallback(&CallbackRecord, PVPanicOnBugCheck,
(PVOID)PortAddress, sizeof(PVOID), Component);
bBugCheck = KeRegisterBugCheckCallback(&CallbackRecord,
PVPanicOnBugCheck,
(PVOID)PortAddress,
sizeof(PVOID),
Component);
if (!bBugCheck)
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER,
"Failed to register bug check callback function.");
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER, "Failed to register bug check callback function.");
}
}

if (SupportedFeature & PVPANIC_CRASHLOADED)
{
bBugCheck = KeRegisterBugCheckReasonCallback(&DumpCallbackRecord,
PVPanicOnDumpBugCheck, KbCallbackDumpIo, Component);
PVPanicOnDumpBugCheck,
KbCallbackDumpIo,
Component);
if (!bBugCheck)
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER,
"Failed to register bug check reason callback function.");
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER, "Failed to register bug check reason callback function.");
}
}
}
Expand All @@ -111,8 +113,7 @@ VOID PVPanicDeregisterBugCheckCallback()
bBugCheck = KeDeregisterBugCheckCallback(&CallbackRecord);
if (!bBugCheck)
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER,
"Failed to unregister bug check callback function.");
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER, "Failed to unregister bug check callback function.");
}
}

Expand All @@ -121,8 +122,7 @@ VOID PVPanicDeregisterBugCheckCallback()
bBugCheck = KeDeregisterBugCheckReasonCallback(&DumpCallbackRecord);
if (!bBugCheck)
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER,
"Failed to unregister bug check reason callback function.");
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER, "Failed to unregister bug check reason callback function.");
}
}
}
169 changes: 85 additions & 84 deletions pvpanic/pvpanic/power.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@
#pragma alloc_text(PAGE, PVPanicEvtDeviceD0Exit)
#endif

NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device,
NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device,
IN WDFCMRESLIST Resources,
IN WDFCMRESLIST ResourcesTranslated)
{
PDEVICE_CONTEXT context = GetDeviceContext(Device);
PDEVICE_CONTEXT context = GetDeviceContext(Device);
PCM_PARTIAL_RESOURCE_DESCRIPTOR desc;
ULONG i;
ULONG i;

UNREFERENCED_PARAMETER(Resources);

TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER, "--> %!FUNC! Device: %p",
Device);
TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER, "--> %!FUNC! Device: %p", Device);

PAGED_CODE();
bEmitCrashLoadedEvent = FALSE;
Expand All @@ -62,74 +61,75 @@ NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device,
switch (desc->Type)
{
case CmResourceTypePort:
{
TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER,
"I/O mapped CSR: (%lx) Length: (%lu)",
desc->u.Port.Start.LowPart, desc->u.Port.Length);
{
TraceEvents(TRACE_LEVEL_VERBOSE,
DBG_POWER,
"I/O mapped CSR: (%lx) Length: (%lu)",
desc->u.Port.Start.LowPart,
desc->u.Port.Length);

context->MappedPort = !(desc->Flags & CM_RESOURCE_PORT_IO);
context->IoRange = desc->u.Port.Length;
context->MappedPort = !(desc->Flags & CM_RESOURCE_PORT_IO);
context->IoRange = desc->u.Port.Length;

if (context->MappedPort)
{
if (context->MappedPort)
{
#if defined(NTDDI_WINTHRESHOLD) && (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
context->IoBaseAddress = MmMapIoSpaceEx(desc->u.Port.Start,
desc->u.Port.Length, PAGE_READWRITE | PAGE_NOCACHE);
context->IoBaseAddress = MmMapIoSpaceEx(desc->u.Port.Start,
desc->u.Port.Length,
PAGE_READWRITE | PAGE_NOCACHE);
#else
context->IoBaseAddress = MmMapIoSpace(desc->u.Port.Start,
desc->u.Port.Length, MmNonCached);
context->IoBaseAddress = MmMapIoSpace(desc->u.Port.Start, desc->u.Port.Length, MmNonCached);
#endif
}
else
{
context->IoBaseAddress = (PVOID)(ULONG_PTR)desc->u.Port.Start.QuadPart;
}
if (BusType & PVPANIC_PCI)
{
TraceEvents(TRACE_LEVEL_ERROR,
DBG_POWER,
"The coexistence of ISA and PCI pvpanic device is not supported, so "
"the ISA pvpanic driver fails to be loaded because the PCI pvpanic "
"driver has been loaded");
return STATUS_DEVICE_CONFIGURATION_ERROR;
}
else
PvPanicPortOrMemAddress = (PUCHAR)context->IoBaseAddress;

break;
}
else
{
context->IoBaseAddress =
(PVOID)(ULONG_PTR)desc->u.Port.Start.QuadPart;
}
if (BusType & PVPANIC_PCI)
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER,
"The coexistence of ISA and PCI pvpanic device is not supported, so "
"the ISA pvpanic driver fails to be loaded because the PCI pvpanic "
"driver has been loaded");
return STATUS_DEVICE_CONFIGURATION_ERROR;
}
else
PvPanicPortOrMemAddress = (PUCHAR)context->IoBaseAddress;

break;
}

case CmResourceTypeMemory:
{
TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER,
"Memory mapped CSR: (%lx) Length: (%lu)",
desc->u.Memory.Start.LowPart, desc->u.Memory.Length);
{
TraceEvents(TRACE_LEVEL_VERBOSE,
DBG_POWER,
"Memory mapped CSR: (%lx) Length: (%lu)",
desc->u.Memory.Start.LowPart,
desc->u.Memory.Length);

context->MemRange = desc->u.Memory.Length;
context->MemRange = desc->u.Memory.Length;
#if defined(NTDDI_WINTHRESHOLD) && (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
context->MemBaseAddress = MmMapIoSpaceEx(
desc->u.Memory.Start,
desc->u.Memory.Length,
PAGE_READWRITE | PAGE_NOCACHE);
context->MemBaseAddress = MmMapIoSpaceEx(desc->u.Memory.Start,
desc->u.Memory.Length,
PAGE_READWRITE | PAGE_NOCACHE);
#else
context->MemBaseAddress = MmMapIoSpace(
desc->u.Memory.Start,
desc->u.Memory.Length,
MmNonCached);
context->MemBaseAddress = MmMapIoSpace(desc->u.Memory.Start, desc->u.Memory.Length, MmNonCached);
#endif
if (BusType & PVPANIC_ISA)
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER,
"The coexistence of ISA and PCI pvpanic device is not supported, so "
"the PCI pvpanic driver fails to be loaded because the ISA pvpanic "
"driver has been loaded");
return STATUS_DEVICE_CONFIGURATION_ERROR;
if (BusType & PVPANIC_ISA)
{
TraceEvents(TRACE_LEVEL_ERROR,
DBG_POWER,
"The coexistence of ISA and PCI pvpanic device is not supported, so "
"the PCI pvpanic driver fails to be loaded because the ISA pvpanic "
"driver has been loaded");
return STATUS_DEVICE_CONFIGURATION_ERROR;
}
else
PvPanicPortOrMemAddress = (PUCHAR)context->MemBaseAddress;

break;
}
else
PvPanicPortOrMemAddress = (PUCHAR)context->MemBaseAddress;

break;
}
default:
break;
}
Expand All @@ -145,31 +145,37 @@ NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device,
{
BusType |= PVPANIC_ISA;
SupportedFeature = READ_PORT_UCHAR((PUCHAR)(context->IoBaseAddress));
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER,
"read feature from IoBaseAddress 0x%p SupportedFeature 0x%x \n",
context->IoBaseAddress, SupportedFeature);
TraceEvents(TRACE_LEVEL_INFORMATION,
DBG_POWER,
"read feature from IoBaseAddress 0x%p SupportedFeature 0x%x \n",
context->IoBaseAddress,
SupportedFeature);
}
else if (context->MemBaseAddress)
{
BusType |= PVPANIC_PCI;
SupportedFeature = *(PUCHAR)(context->MemBaseAddress);
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER,
"read feature 0x%p *MemBaseAddress 0x%x SupportedFeature 0x%x \n",
context->MemBaseAddress, *(PUSHORT)(context->MemBaseAddress), SupportedFeature);
TraceEvents(TRACE_LEVEL_INFORMATION,
DBG_POWER,
"read feature 0x%p *MemBaseAddress 0x%x SupportedFeature 0x%x \n",
context->MemBaseAddress,
*(PUSHORT)(context->MemBaseAddress),
SupportedFeature);
}
if (SupportedFeature & (PVPANIC_PANICKED | PVPANIC_CRASHLOADED))
{
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER,
"PVPANIC_PANICKED notification feature %s supported.",
(SupportedFeature & PVPANIC_PANICKED) ? "is" : "is not");
TraceEvents(TRACE_LEVEL_INFORMATION, DBG_POWER,
"PVPANIC_CRASHLOADED notification feature %s supported.",
(SupportedFeature & PVPANIC_CRASHLOADED) ? "is" : "is not");
TraceEvents(TRACE_LEVEL_INFORMATION,
DBG_POWER,
"PVPANIC_PANICKED notification feature %s supported.",
(SupportedFeature & PVPANIC_PANICKED) ? "is" : "is not");
TraceEvents(TRACE_LEVEL_INFORMATION,
DBG_POWER,
"PVPANIC_CRASHLOADED notification feature %s supported.",
(SupportedFeature & PVPANIC_CRASHLOADED) ? "is" : "is not");
}
else
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER,
"Panic notification feature is not supported.");
TraceEvents(TRACE_LEVEL_ERROR, DBG_POWER, "Panic notification feature is not supported.");
return STATUS_DEVICE_CONFIGURATION_ERROR;
}

Expand All @@ -178,8 +184,7 @@ NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device,
return STATUS_SUCCESS;
}

NTSTATUS PVPanicEvtDeviceReleaseHardware(IN WDFDEVICE Device,
IN WDFCMRESLIST ResourcesTranslated)
NTSTATUS PVPanicEvtDeviceReleaseHardware(IN WDFDEVICE Device, IN WDFCMRESLIST ResourcesTranslated)
{
PDEVICE_CONTEXT context = GetDeviceContext(Device);

Expand All @@ -205,15 +210,13 @@ NTSTATUS PVPanicEvtDeviceReleaseHardware(IN WDFDEVICE Device,
return STATUS_SUCCESS;
}

NTSTATUS PVPanicEvtDeviceD0Entry(IN WDFDEVICE Device,
IN WDF_POWER_DEVICE_STATE PreviousState)
NTSTATUS PVPanicEvtDeviceD0Entry(IN WDFDEVICE Device, IN WDF_POWER_DEVICE_STATE PreviousState)
{
PDEVICE_CONTEXT context = GetDeviceContext(Device);

UNREFERENCED_PARAMETER(PreviousState);

TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER, "--> %!FUNC! Device: %p",
Device);
TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER, "--> %!FUNC! Device: %p", Device);

PAGED_CODE();

Expand All @@ -227,14 +230,12 @@ NTSTATUS PVPanicEvtDeviceD0Entry(IN WDFDEVICE Device,
return STATUS_SUCCESS;
}

NTSTATUS PVPanicEvtDeviceD0Exit(IN WDFDEVICE Device,
IN WDF_POWER_DEVICE_STATE TargetState)
NTSTATUS PVPanicEvtDeviceD0Exit(IN WDFDEVICE Device, IN WDF_POWER_DEVICE_STATE TargetState)
{
UNREFERENCED_PARAMETER(Device);
UNREFERENCED_PARAMETER(TargetState);

TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER, "--> %!FUNC! Device: %p",
Device);
TraceEvents(TRACE_LEVEL_VERBOSE, DBG_POWER, "--> %!FUNC! Device: %p", Device);

PAGED_CODE();

Expand Down
Loading

0 comments on commit b352f2b

Please sign in to comment.