Refine and export kernel debugger printing
This commit is contained in:
@@ -9,9 +9,6 @@
|
||||
#include <xtos.hh>
|
||||
|
||||
|
||||
/* Pointer to DbgPrint() routine */
|
||||
PKD_PRINT_ROUTINE KdPrint = nullptr;
|
||||
|
||||
/* Kernel Debugger mode */
|
||||
KD_DEBUG_MODE KD::DebugIo::DebugMode;
|
||||
|
||||
@@ -21,6 +18,9 @@ PKD_INIT_ROUTINE KD::DebugIo::IoProvidersInitRoutines[KDBG_PROVIDERS_COUNT] = {
|
||||
InitializeSerialPortProvider
|
||||
};
|
||||
|
||||
/* Pointer to DbgPrint() routine */
|
||||
PKD_PRINT_ROUTINE KD::DebugIo::KdPrint = nullptr;
|
||||
|
||||
/* List of active I/O providers */
|
||||
LIST_ENTRY KD::DebugIo::Providers;
|
||||
|
||||
|
@@ -24,29 +24,57 @@
|
||||
*/
|
||||
XTCDECL
|
||||
VOID
|
||||
KD::DebugIo::DbgPrint(PCWSTR Format, ...)
|
||||
KD::DebugIo::DbgPrint(PCWSTR Format,
|
||||
...)
|
||||
{
|
||||
VA_LIST Arguments;
|
||||
PLIST_ENTRY DispatchTableEntry;
|
||||
PKD_DISPATCH_TABLE DispatchTable;
|
||||
|
||||
/* Initialise the va_list */
|
||||
VA_START(Arguments, Format);
|
||||
|
||||
DispatchTableEntry = Providers.Flink;
|
||||
while(DispatchTableEntry != &Providers)
|
||||
{
|
||||
DispatchTable = CONTAIN_RECORD(DispatchTableEntry, KD_DISPATCH_TABLE, ListEntry);
|
||||
|
||||
RTL::WideString::FormatWideString(&DispatchTable->PrintContext, (PWCHAR)Format, Arguments);
|
||||
|
||||
DispatchTableEntry = DispatchTableEntry->Flink;
|
||||
}
|
||||
/* Call the actual debug print routine */
|
||||
DbgPrintEx(Format, Arguments);
|
||||
|
||||
/* Clean up the va_list */
|
||||
VA_END(Arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a formatted string using the configured debug output providers (va_list variant).
|
||||
*
|
||||
* @param Format
|
||||
* Supplies the format string.
|
||||
*
|
||||
* @param ...
|
||||
* Supplies the variable argument list.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
VOID
|
||||
KD::DebugIo::DbgPrintEx(PCWSTR Format,
|
||||
VA_LIST Arguments)
|
||||
{
|
||||
PLIST_ENTRY DispatchTableEntry;
|
||||
PKD_DISPATCH_TABLE DispatchTable;
|
||||
|
||||
/* Iterate over all registered debug providers */
|
||||
DispatchTableEntry = Providers.Flink;
|
||||
while(DispatchTableEntry != &Providers)
|
||||
{
|
||||
/* Get dispatch table */
|
||||
DispatchTable = CONTAIN_RECORD(DispatchTableEntry, KD_DISPATCH_TABLE, ListEntry);
|
||||
|
||||
/* Print formatted string using the provider's print context */
|
||||
RTL::WideString::FormatWideString(&DispatchTable->PrintContext, (PWCHAR)Format, Arguments);
|
||||
|
||||
/* Move to the next provider */
|
||||
DispatchTableEntry = DispatchTableEntry->Flink;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects and enables the kernel's debug ports based on the 'DEBUG' parameter passed to the kernel.
|
||||
*
|
||||
|
40
xtoskrnl/kd/exports.cc
Normal file
40
xtoskrnl/kd/exports.cc
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* PROJECT: ExectOS
|
||||
* COPYRIGHT: See COPYING.md in the top level directory
|
||||
* FILE: xtoskrnl/kd/exports.cc
|
||||
* DESCRIPTION: C-compatible API wrappers for exported kernel functions
|
||||
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
|
||||
*/
|
||||
|
||||
#include <xtos.hh>
|
||||
|
||||
|
||||
/**
|
||||
* Prints a formatted string using the configured debug output providers.
|
||||
*
|
||||
* @param Format
|
||||
* Supplies the format string.
|
||||
*
|
||||
* @param ...
|
||||
* Supplies the variable argument list.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCLINK
|
||||
XTCDECL
|
||||
VOID
|
||||
DbgPrint(PCWSTR Format,
|
||||
...)
|
||||
{
|
||||
VA_LIST Arguments;
|
||||
|
||||
/* Initialise the va_list */
|
||||
VA_START(Arguments, Format);
|
||||
|
||||
KD::DebugIo::DbgPrintEx(Format, Arguments);
|
||||
|
||||
/* Clean up the va_list */
|
||||
VA_END(Arguments);
|
||||
}
|
Reference in New Issue
Block a user