From 75c519a70c68bb14085680aceca0979b586b1949 Mon Sep 17 00:00:00 2001 From: belliash Date: Tue, 7 Feb 2023 19:37:44 +0100 Subject: [PATCH] Use more generic name for this macro use pointer used behind it will point to kernel debugger after it gets initialized --- sdk/xtdk/xtdebug.h | 10 ++++---- xtoskrnl/ar/amd64/traps.c | 48 ++++++++++++++++++------------------ xtoskrnl/ar/i686/traps.c | 44 ++++++++++++++++----------------- xtoskrnl/includes/globals.h | 6 ++--- xtoskrnl/ke/amd64/krnlinit.c | 2 +- xtoskrnl/ke/globals.c | 6 ++--- xtoskrnl/ke/i686/krnlinit.c | 2 +- xtoskrnl/ke/krnlinit.c | 6 ++--- 8 files changed, 62 insertions(+), 62 deletions(-) diff --git a/sdk/xtdk/xtdebug.h b/sdk/xtdk/xtdebug.h index c86c7df..ae8b19a 100644 --- a/sdk/xtdk/xtdebug.h +++ b/sdk/xtdk/xtdebug.h @@ -11,19 +11,19 @@ /* Debugging macros */ -#define CHECKPOINT LdrPrint(L"Checkpoint reached at %s:%d\n", __FILE__, __LINE__); -#define DEPRECATED LdrPrint(L"Called deprecated routine '%s()' at %s:%d\n", \ +#define CHECKPOINT DebugPrint(L"Checkpoint reached at %s:%d\n", __FILE__, __LINE__); +#define DEPRECATED DebugPrint(L"Called deprecated routine '%s()' at %s:%d\n", \ __FUNCTION__, __FILE__, __LINE__); -#define UNIMPLEMENTED LdrPrint(L"Called unimplemented routine '%s()' at %s:%d\n", \ +#define UNIMPLEMENTED DebugPrint(L"Called unimplemented routine '%s()' at %s:%d\n", \ __FUNCTION__, __FILE__, __LINE__); /* XTOS platform debugging macros */ #ifdef DBG #define DEBUG 1 - #define LdrPrint(Format, ...) if(LdrDbgPrint) LdrDbgPrint(Format, __VA_ARGS__); + #define DebugPrint(Format, ...) if(KeDbgPrint) KeDbgPrint(Format, __VA_ARGS__); #else #define DEBUG 0 - #define LdrPrint(Format, ...) ((VOID)NULL) + #define DebugPrint(Format, ...) ((VOID)NULL) #endif #endif /* __XTDK_XTDEBUG_H */ diff --git a/xtoskrnl/ar/amd64/traps.c b/xtoskrnl/ar/amd64/traps.c index de1055d..d0b833f 100644 --- a/xtoskrnl/ar/amd64/traps.c +++ b/xtoskrnl/ar/amd64/traps.c @@ -13,14 +13,14 @@ XTCDECL VOID ArpHandleSystemCall32() { - LdrPrint(L"Handled 32-bit system call!\n"); + DebugPrint(L"Handled 32-bit system call!\n"); } XTCDECL VOID ArpHandleSystemCall64() { - LdrPrint(L"Handled 64-bit system call!\n"); + DebugPrint(L"Handled 64-bit system call!\n"); } /** @@ -34,7 +34,7 @@ XTCDECL VOID ArpHandleTrap00() { - LdrPrint(L"Handled Division-By-Zero Error (0x00)!\n"); + DebugPrint(L"Handled Division-By-Zero Error (0x00)!\n"); for(;;); } @@ -49,7 +49,7 @@ XTCDECL VOID ArpHandleTrap01() { - LdrPrint(L"Handled Debug exception (0x01)!\n"); + DebugPrint(L"Handled Debug exception (0x01)!\n"); for(;;); } @@ -64,7 +64,7 @@ XTCDECL VOID ArpHandleTrap02() { - LdrPrint(L"Handled Non-Maskable-Interrupt (0x02)!\n"); + DebugPrint(L"Handled Non-Maskable-Interrupt (0x02)!\n"); for(;;); } @@ -79,7 +79,7 @@ XTCDECL VOID ArpHandleTrap03() { - LdrPrint(L"Handled INT3 (0x03)!\n"); + DebugPrint(L"Handled INT3 (0x03)!\n"); for(;;); } @@ -94,7 +94,7 @@ XTCDECL VOID ArpHandleTrap04() { - LdrPrint(L"Handled Overflow exception (0x04)!\n"); + DebugPrint(L"Handled Overflow exception (0x04)!\n"); for(;;); } @@ -109,7 +109,7 @@ XTCDECL VOID ArpHandleTrap05() { - LdrPrint(L"Handled Bound-Range-Exceeded exception (0x05)!\n"); + DebugPrint(L"Handled Bound-Range-Exceeded exception (0x05)!\n"); for(;;); } @@ -124,7 +124,7 @@ XTCDECL VOID ArpHandleTrap06() { - LdrPrint(L"Handled Invalid Opcode exception (0x06)!\n"); + DebugPrint(L"Handled Invalid Opcode exception (0x06)!\n"); for(;;); } @@ -139,7 +139,7 @@ XTCDECL VOID ArpHandleTrap07() { - LdrPrint(L"Handled Device Not Available exception (0x07)!\n"); + DebugPrint(L"Handled Device Not Available exception (0x07)!\n"); for(;;); } @@ -154,7 +154,7 @@ XTCDECL VOID ArpHandleTrap08() { - LdrPrint(L"Handled Double-Fault exception (0x08)!\n"); + DebugPrint(L"Handled Double-Fault exception (0x08)!\n"); for(;;); } @@ -169,7 +169,7 @@ XTCDECL VOID ArpHandleTrap09() { - LdrPrint(L"Handled Segment-Overrun exception (0x09)!\n"); + DebugPrint(L"Handled Segment-Overrun exception (0x09)!\n"); for(;;); } @@ -184,7 +184,7 @@ XTCDECL VOID ArpHandleTrap0A() { - LdrPrint(L"Handled Invalid-TSS exception (0x0A)!\n"); + DebugPrint(L"Handled Invalid-TSS exception (0x0A)!\n"); for(;;); } @@ -199,7 +199,7 @@ XTCDECL VOID ArpHandleTrap0B() { - LdrPrint(L"Handled Segment-Not-Present exception (0x0B)!\n"); + DebugPrint(L"Handled Segment-Not-Present exception (0x0B)!\n"); for(;;); } @@ -214,7 +214,7 @@ XTCDECL VOID ArpHandleTrap0C() { - LdrPrint(L"Handled Stack-Segment-Fault exception (0x0C)!\n"); + DebugPrint(L"Handled Stack-Segment-Fault exception (0x0C)!\n"); for(;;); } @@ -229,7 +229,7 @@ XTCDECL VOID ArpHandleTrap0D() { - LdrPrint(L"Handled General-Protection-Fault (0x0D)!\n"); + DebugPrint(L"Handled General-Protection-Fault (0x0D)!\n"); for(;;); } @@ -244,7 +244,7 @@ XTCDECL VOID ArpHandleTrap0E() { - LdrPrint(L"Handled Page-Fault exception (0x0E)!\n"); + DebugPrint(L"Handled Page-Fault exception (0x0E)!\n"); for(;;); } @@ -259,7 +259,7 @@ XTCDECL VOID ArpHandleTrap10() { - LdrPrint(L"Handled x87 Floating-Point exception (0x10)!\n"); + DebugPrint(L"Handled x87 Floating-Point exception (0x10)!\n"); for(;;); } @@ -274,7 +274,7 @@ XTCDECL VOID ArpHandleTrap11() { - LdrPrint(L"Handled Alignment-Check exception (0x11)!\n"); + DebugPrint(L"Handled Alignment-Check exception (0x11)!\n"); for(;;); } @@ -289,7 +289,7 @@ XTCDECL VOID ArpHandleTrap12() { - LdrPrint(L"Handled Machine-Check exception (0x12)!\n"); + DebugPrint(L"Handled Machine-Check exception (0x12)!\n"); for(;;); } @@ -304,7 +304,7 @@ XTCDECL VOID ArpHandleTrap13() { - LdrPrint(L"Handled SIMD Floating-Point exception (0x13)!\n"); + DebugPrint(L"Handled SIMD Floating-Point exception (0x13)!\n"); for(;;); } @@ -319,7 +319,7 @@ XTCDECL VOID ArpHandleTrap2C() { - LdrPrint(L"Handled Assertion (0x2C)!\n"); + DebugPrint(L"Handled Assertion (0x2C)!\n"); for(;;); } @@ -334,7 +334,7 @@ XTCDECL VOID ArpHandleTrap2D() { - LdrPrint(L"Handled Debug-Service-Request (0x2D)!\n"); + DebugPrint(L"Handled Debug-Service-Request (0x2D)!\n"); for(;;); } @@ -349,6 +349,6 @@ XTCDECL VOID ArpHandleTrapFF() { - LdrPrint(L"Handled Unexpected-Interrupt (0xFF)!\n"); + DebugPrint(L"Handled Unexpected-Interrupt (0xFF)!\n"); for(;;); } diff --git a/xtoskrnl/ar/i686/traps.c b/xtoskrnl/ar/i686/traps.c index 1ebe39c..97e6d5a 100644 --- a/xtoskrnl/ar/i686/traps.c +++ b/xtoskrnl/ar/i686/traps.c @@ -20,7 +20,7 @@ XTCDECL VOID ArpHandleTrap00() { - LdrPrint(L"Handled Division-By-Zero Error (0x00)!\n"); + DebugPrint(L"Handled Division-By-Zero Error (0x00)!\n"); for(;;); } @@ -35,7 +35,7 @@ XTCDECL VOID ArpHandleTrap01() { - LdrPrint(L"Handled Debug exception (0x01)!\n"); + DebugPrint(L"Handled Debug exception (0x01)!\n"); for(;;); } @@ -50,7 +50,7 @@ XTCDECL VOID ArpHandleTrap02() { - LdrPrint(L"Handled Non-Maskable-Interrupt (0x02)!\n"); + DebugPrint(L"Handled Non-Maskable-Interrupt (0x02)!\n"); for(;;); } @@ -65,7 +65,7 @@ XTCDECL VOID ArpHandleTrap03() { - LdrPrint(L"Handled INT3 (0x03)!\n"); + DebugPrint(L"Handled INT3 (0x03)!\n"); for(;;); } @@ -80,7 +80,7 @@ XTCDECL VOID ArpHandleTrap04() { - LdrPrint(L"Handled Overflow exception (0x04)!\n"); + DebugPrint(L"Handled Overflow exception (0x04)!\n"); for(;;); } @@ -95,7 +95,7 @@ XTCDECL VOID ArpHandleTrap05() { - LdrPrint(L"Handled Bound-Range-Exceeded exception (0x05)!\n"); + DebugPrint(L"Handled Bound-Range-Exceeded exception (0x05)!\n"); for(;;); } @@ -110,7 +110,7 @@ XTCDECL VOID ArpHandleTrap06() { - LdrPrint(L"Handled Invalid Opcode exception (0x06)!\n"); + DebugPrint(L"Handled Invalid Opcode exception (0x06)!\n"); for(;;); } @@ -125,7 +125,7 @@ XTCDECL VOID ArpHandleTrap07() { - LdrPrint(L"Handled Device Not Available exception (0x07)!\n"); + DebugPrint(L"Handled Device Not Available exception (0x07)!\n"); for(;;); } @@ -140,7 +140,7 @@ XTCDECL VOID ArpHandleTrap08() { - LdrPrint(L"Handled Double-Fault exception (0x08)!\n"); + DebugPrint(L"Handled Double-Fault exception (0x08)!\n"); for(;;); } @@ -155,7 +155,7 @@ XTCDECL VOID ArpHandleTrap09() { - LdrPrint(L"Handled Segment-Overrun exception (0x09)!\n"); + DebugPrint(L"Handled Segment-Overrun exception (0x09)!\n"); for(;;); } @@ -170,7 +170,7 @@ XTCDECL VOID ArpHandleTrap0A() { - LdrPrint(L"Handled Invalid-TSS exception (0x0A)!\n"); + DebugPrint(L"Handled Invalid-TSS exception (0x0A)!\n"); for(;;); } @@ -185,7 +185,7 @@ XTCDECL VOID ArpHandleTrap0B() { - LdrPrint(L"Handled Segment-Not-Present exception (0x0B)!\n"); + DebugPrint(L"Handled Segment-Not-Present exception (0x0B)!\n"); for(;;); } @@ -200,7 +200,7 @@ XTCDECL VOID ArpHandleTrap0C() { - LdrPrint(L"Handled Stack-Segment-Fault exception (0x0C)!\n"); + DebugPrint(L"Handled Stack-Segment-Fault exception (0x0C)!\n"); for(;;); } @@ -215,7 +215,7 @@ XTCDECL VOID ArpHandleTrap0D() { - LdrPrint(L"Handled General-Protection-Fault (0x0D)!\n"); + DebugPrint(L"Handled General-Protection-Fault (0x0D)!\n"); for(;;); } @@ -230,7 +230,7 @@ XTCDECL VOID ArpHandleTrap0E() { - LdrPrint(L"Handled Page-Fault exception (0x0E)!\n"); + DebugPrint(L"Handled Page-Fault exception (0x0E)!\n"); for(;;); } @@ -245,7 +245,7 @@ XTCDECL VOID ArpHandleTrap10() { - LdrPrint(L"Handled x87 Floating-Point exception (0x10)!\n"); + DebugPrint(L"Handled x87 Floating-Point exception (0x10)!\n"); for(;;); } @@ -260,7 +260,7 @@ XTCDECL VOID ArpHandleTrap11() { - LdrPrint(L"Handled Alignment-Check exception (0x11)!\n"); + DebugPrint(L"Handled Alignment-Check exception (0x11)!\n"); for(;;); } @@ -275,7 +275,7 @@ XTCDECL VOID ArpHandleTrap12() { - LdrPrint(L"Handled Machine-Check exception (0x12)!\n"); + DebugPrint(L"Handled Machine-Check exception (0x12)!\n"); for(;;); } @@ -290,7 +290,7 @@ XTCDECL VOID ArpHandleTrap13() { - LdrPrint(L"Handled SIMD Floating-Point exception (0x13)!\n"); + DebugPrint(L"Handled SIMD Floating-Point exception (0x13)!\n"); for(;;); } @@ -305,7 +305,7 @@ XTCDECL VOID ArpHandleTrap2C() { - LdrPrint(L"Handled Assertion (0x2C)!\n"); + DebugPrint(L"Handled Assertion (0x2C)!\n"); for(;;); } @@ -320,7 +320,7 @@ XTCDECL VOID ArpHandleTrap2D() { - LdrPrint(L"Handled Debug-Service-Request (0x2D)!\n"); + DebugPrint(L"Handled Debug-Service-Request (0x2D)!\n"); for(;;); } @@ -335,6 +335,6 @@ XTCDECL VOID ArpHandleTrapFF() { - LdrPrint(L"Handled Unexpected-Interrupt (0xFF)!\n"); + DebugPrint(L"Handled Unexpected-Interrupt (0xFF)!\n"); for(;;); } diff --git a/xtoskrnl/includes/globals.h b/xtoskrnl/includes/globals.h index d29a741..4407ac3 100644 --- a/xtoskrnl/includes/globals.h +++ b/xtoskrnl/includes/globals.h @@ -16,10 +16,10 @@ /* FrameBuffer information */ EXTERN HAL_FRAMEBUFFER_DATA HlpFrameBufferData; +/* Pointer to boot loader provided DbgPrint() routine */ +EXTERN VOID (*KeDbgPrint)(IN PWCHAR Format, IN ...); + /* Kernel initialization block passed by boot loader */ EXTERN PKERNEL_INITIALIZATION_BLOCK KeInitializationBlock; -/* Pointer to boot loader provided DbgPrint() routine */ -EXTERN VOID (*LdrDbgPrint)(IN PWCHAR Format, IN ...); - #endif /* __XTOSKRNL_GLOBALS_H */ diff --git a/xtoskrnl/ke/amd64/krnlinit.c b/xtoskrnl/ke/amd64/krnlinit.c index 516fcb1..ad9bde4 100644 --- a/xtoskrnl/ke/amd64/krnlinit.c +++ b/xtoskrnl/ke/amd64/krnlinit.c @@ -36,7 +36,7 @@ XTAPI VOID KepStartKernel(VOID) { - LdrPrint(L"Hello from new kernel stack!\n"); + DebugPrint(L"Hello from new kernel stack!\n"); for(;;); } diff --git a/xtoskrnl/ke/globals.c b/xtoskrnl/ke/globals.c index cb81d83..2dd9bd3 100644 --- a/xtoskrnl/ke/globals.c +++ b/xtoskrnl/ke/globals.c @@ -12,8 +12,8 @@ /* FrameBuffer information */ HAL_FRAMEBUFFER_DATA HlpFrameBufferData; +/* Pointer to boot loader provided DbgPrint() routine */ +VOID (*KeDbgPrint)(IN PWCHAR Format, IN ...) = NULL; + /* Kernel initialization block passed by boot loader */ PKERNEL_INITIALIZATION_BLOCK KeInitializationBlock; - -/* Pointer to boot loader provided DbgPrint() routine */ -VOID (*LdrDbgPrint)(IN PWCHAR Format, IN ...) = NULL; diff --git a/xtoskrnl/ke/i686/krnlinit.c b/xtoskrnl/ke/i686/krnlinit.c index 9d841d8..a67fb75 100644 --- a/xtoskrnl/ke/i686/krnlinit.c +++ b/xtoskrnl/ke/i686/krnlinit.c @@ -36,7 +36,7 @@ XTAPI VOID KepStartKernel(VOID) { - LdrPrint(L"Hello from new kernel stack!\n"); + DebugPrint(L"Hello from new kernel stack!\n"); for(;;); } diff --git a/xtoskrnl/ke/krnlinit.c b/xtoskrnl/ke/krnlinit.c index 9a45273..36342a7 100644 --- a/xtoskrnl/ke/krnlinit.c +++ b/xtoskrnl/ke/krnlinit.c @@ -27,13 +27,13 @@ KeStartXtSystem(IN PKERNEL_INITIALIZATION_BLOCK Parameters) if(DEBUG && Parameters->LoaderInformation.DbgPrint) { /* Use loader's provided DbgPrint() routine for early printing to serial console */ - LdrDbgPrint = Parameters->LoaderInformation.DbgPrint; + KeDbgPrint = Parameters->LoaderInformation.DbgPrint; } /* Print some message to serial console and test kernel parameters */ - LdrPrint(L"Hello world from ExectOS kernel!\n"); - LdrPrint(L"\n\n------ Kernel parameters block ------\n" + DebugPrint(L"Hello world from ExectOS kernel!\n"); + DebugPrint(L"\n\n------ Kernel parameters block ------\n" L"Loader block size: %lu\n" L"Loader block version: %lu\n" L"EFI Revision: %lu\n",