Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHEL-69072: clang-format for pvpanic folder #1222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
38 changes: 19 additions & 19 deletions pvpanic/pvpanic/bugcheck.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ 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.");
}
}
}
111 changes: 54 additions & 57 deletions pvpanic/pvpanic/power.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device,

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,10 +61,11 @@ 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;
Expand All @@ -74,62 +74,58 @@ NTSTATUS PVPanicEvtDevicePrepareHardware(IN WDFDEVICE Device,
{
#if defined(NTDDI_WINTHRESHOLD) && (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
context->IoBaseAddress = MmMapIoSpaceEx(desc->u.Port.Start,
desc->u.Port.Length, PAGE_READWRITE | PAGE_NOCACHE);
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;
context->IoBaseAddress = (PVOID)(ULONG_PTR)desc->u.Port.Start.QuadPart;
}
if (BusType & PVPANIC_PCI)
{
Jedoku marked this conversation as resolved.
Show resolved Hide resolved
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");
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;
#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");
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;
}
default:
break;
}
Expand All @@ -145,31 +141,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 +180,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 +206,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 +226,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
25 changes: 8 additions & 17 deletions pvpanic/pvpanic/pvpanic.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
#pragma alloc_text(PAGE, PVPanicEvtDriverContextCleanup)
#endif

NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
{
NTSTATUS status;
WDF_DRIVER_CONFIG config;
Expand All @@ -55,13 +54,11 @@ NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,

WDF_DRIVER_CONFIG_INIT(&config, PVPanicEvtDeviceAdd);

status = WdfDriverCreate(DriverObject, RegistryPath, &attributes,
&config, WDF_NO_HANDLE);
status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, WDF_NO_HANDLE);

if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT,
"WdfDriverCreate failed: %!STATUS!", status);
TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfDriverCreate failed: %!STATUS!", status);
WPP_CLEANUP(DriverObject);
}
else
Expand All @@ -75,8 +72,7 @@ NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,
return status;
}

NTSTATUS PVPanicEvtDeviceAdd(IN WDFDRIVER Driver,
IN PWDFDEVICE_INIT DeviceInit)
NTSTATUS PVPanicEvtDeviceAdd(IN WDFDRIVER Driver, IN PWDFDEVICE_INIT DeviceInit)
{
NTSTATUS status;
WDFDEVICE device;
Expand All @@ -102,17 +98,14 @@ NTSTATUS PVPanicEvtDeviceAdd(IN WDFDRIVER Driver,

WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT);

WDF_FILEOBJECT_CONFIG_INIT(&fileConfig, PVPanicEvtDeviceFileCreate,
WDF_NO_EVENT_CALLBACK, WDF_NO_EVENT_CALLBACK);
WDF_FILEOBJECT_CONFIG_INIT(&fileConfig, PVPanicEvtDeviceFileCreate, WDF_NO_EVENT_CALLBACK, WDF_NO_EVENT_CALLBACK);

WdfDeviceInitSetFileObjectConfig(DeviceInit, &fileConfig,
WDF_NO_OBJECT_ATTRIBUTES);
WdfDeviceInitSetFileObjectConfig(DeviceInit, &fileConfig, WDF_NO_OBJECT_ATTRIBUTES);

status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
if (!NT_SUCCESS(status))
{
TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT,
"WdfDeviceCreate failed: %!STATUS!", status);
TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT, "WdfDeviceCreate failed: %!STATUS!", status);
return status;
}

Expand All @@ -137,9 +130,7 @@ VOID PVPanicEvtDriverContextCleanup(IN WDFOBJECT DriverObject)
WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)DriverObject));
}

VOID PVPanicEvtDeviceFileCreate(IN WDFDEVICE Device,
IN WDFREQUEST Request,
IN WDFFILEOBJECT FileObject)
VOID PVPanicEvtDeviceFileCreate(IN WDFDEVICE Device, IN WDFREQUEST Request, IN WDFFILEOBJECT FileObject)
{
UNREFERENCED_PARAMETER(Device);
UNREFERENCED_PARAMETER(FileObject);
Expand Down
Loading