[BOOT:LIB] Add conditional debug printing
Added DebugPrint() and DebugPrintf() macros, which are aliases of ConsolePrint() and ConsolePrintf() if _DEBUG is defined. Otherwise, they do not generate any code.
This commit is contained in:
parent
4dbb5235e3
commit
76b01cfb00
@ -34,6 +34,17 @@ ConsolePrintf (
|
|||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Enable/disable debug printing.
|
||||||
|
//
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define DebugPrint(String) ConsolePrint(String)
|
||||||
|
#define DebugPrintf(Format, ...) ConsolePrintf(Format, __VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define DebugPrint(String)
|
||||||
|
#define DebugPrintf(Format, ...)
|
||||||
|
#endif
|
||||||
|
|
||||||
ULONG
|
ULONG
|
||||||
BlGetBootOptionSize (
|
BlGetBootOptionSize (
|
||||||
IN PBOOT_APPLICATION_OPTION Option
|
IN PBOOT_APPLICATION_OPTION Option
|
||||||
|
@ -81,16 +81,25 @@ Return Value:
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Initialize firmware library.
|
// Initialize firmware library.
|
||||||
|
// It is important to do this early so that
|
||||||
|
// ConsolePrint() and DebugPrint() can be used.
|
||||||
//
|
//
|
||||||
Status = BlpFwInitialize(0, FirmwareData);
|
Status = BlpFwInitialize(0, FirmwareData);
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Print image information.
|
||||||
|
//
|
||||||
|
ConsolePrintf(L"Image base: %x %x\r\n", (ULONG)((ULONG_PTR)InputParameters->ImageBase >> 32), (ULONG)((ULONG_PTR)InputParameters->ImageBase));
|
||||||
|
ConsolePrintf(L"Image size: %x\r\n", InputParameters->ImageSize);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check application entry signature.
|
// Check application entry signature.
|
||||||
//
|
//
|
||||||
if (ApplicationEntry->Signature != BOOT_INPUT_APPLICATION_ENTRY_SIGNATURE) {
|
if (ApplicationEntry->Signature != BOOT_INPUT_APPLICATION_ENTRY_SIGNATURE) {
|
||||||
|
DebugPrint(L"Application entry signature is invalid\r\n");
|
||||||
return STATUS_INVALID_PARAMETER_9;
|
return STATUS_INVALID_PARAMETER_9;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,53 +113,51 @@ Return Value:
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Print debug information.
|
// Print debug information.
|
||||||
|
// TODO: Remove this once the project is more stable?
|
||||||
//
|
//
|
||||||
|
#ifdef _DEBUG
|
||||||
ConsolePrintf(L"Image base: %x %x\r\n", (ULONG)((ULONG_PTR)InputParameters->ImageBase >> 32), (ULONG)((ULONG_PTR)InputParameters->ImageBase));
|
DebugPrint(L"Boot device type: ");
|
||||||
ConsolePrintf(L"Image size: %x\r\n", InputParameters->ImageSize);
|
|
||||||
|
|
||||||
ConsolePrint(L"Boot device type: ");
|
|
||||||
switch (BlpBootDevice->Type) {
|
switch (BlpBootDevice->Type) {
|
||||||
case BOOT_DEVICE_TYPE_PARTITION:
|
case BOOT_DEVICE_TYPE_PARTITION:
|
||||||
ConsolePrint(L"partition\r\n");
|
DebugPrint(L"partition\r\n");
|
||||||
BlockDevice = &BlpBootDevice->Partition.Parent;
|
BlockDevice = &BlpBootDevice->Partition.Parent;
|
||||||
break;
|
break;
|
||||||
case BOOT_DEVICE_TYPE_PARTITION_EX:
|
case BOOT_DEVICE_TYPE_PARTITION_EX:
|
||||||
ConsolePrint(L"partition\r\n");
|
DebugPrint(L"partition\r\n");
|
||||||
BlockDevice = &BlpBootDevice->PartitionEx.Parent;
|
BlockDevice = &BlpBootDevice->PartitionEx.Parent;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ConsolePrint(L"generic block device\r\n");
|
DebugPrint(L"generic block device\r\n");
|
||||||
BlockDevice = &BlpBootDevice->Block;
|
BlockDevice = &BlpBootDevice->Block;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsolePrint(L"Boot device parent type: ");
|
DebugPrint(L"Boot device parent type: ");
|
||||||
switch (BlockDevice->Type) {
|
switch (BlockDevice->Type) {
|
||||||
case BOOT_BLOCK_DEVICE_TYPE_HARDDRIVE:
|
case BOOT_BLOCK_DEVICE_TYPE_HARDDRIVE:
|
||||||
ConsolePrint(L"hard drive\r\n");
|
DebugPrint(L"hard drive\r\n");
|
||||||
break;
|
break;
|
||||||
case BOOT_BLOCK_DEVICE_TYPE_CDROM:
|
case BOOT_BLOCK_DEVICE_TYPE_CDROM:
|
||||||
ConsolePrint(L"CD-ROM\r\n");
|
DebugPrint(L"CD-ROM\r\n");
|
||||||
break;
|
break;
|
||||||
case BOOT_BLOCK_DEVICE_TYPE_RAMDISK:
|
case BOOT_BLOCK_DEVICE_TYPE_RAMDISK:
|
||||||
ConsolePrint(L"RAM disk\r\n");
|
DebugPrint(L"RAM disk\r\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ConsolePrint(L"generic block device\r\n");
|
DebugPrint(L"generic block device\r\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Option = &ApplicationEntry->Options;
|
Option = &ApplicationEntry->Options;
|
||||||
for (ULONG Index = 0; !Option->IsInvalid; Index++) {
|
for (ULONG Index = 0; !Option->IsInvalid; Index++) {
|
||||||
ConsolePrintf(L"Boot entry option %x: ", Index);
|
DebugPrintf(L"Boot entry option %x: ", Index);
|
||||||
|
|
||||||
if (Option->Type == BCDE_DATA_TYPE_APPLICATION_PATH) {
|
if (Option->Type == BCDE_DATA_TYPE_APPLICATION_PATH) {
|
||||||
ConsolePrint(L"application path \"");
|
DebugPrint(L"application path \"");
|
||||||
ConsolePrint((PWSTR)((PUCHAR)Option + Option->DataOffset));
|
DebugPrint((PWSTR)((PUCHAR)Option + Option->DataOffset));
|
||||||
ConsolePrint(L"\"\r\n");
|
DebugPrint(L"\"\r\n");
|
||||||
} else {
|
} else {
|
||||||
ConsolePrintf(L"type %x, data size %x\r\n", Option->Type, Option->DataSize);
|
DebugPrintf(L"type %x, data size %x\r\n", Option->Type, Option->DataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Option->NextOptionOffset == 0) {
|
if (Option->NextOptionOffset == 0) {
|
||||||
@ -159,6 +166,7 @@ Return Value:
|
|||||||
|
|
||||||
Option = (PBOOT_APPLICATION_OPTION)((PUCHAR)Option + Option->NextOptionOffset);
|
Option = (PBOOT_APPLICATION_OPTION)((PUCHAR)Option + Option->NextOptionOffset);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user