mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
** WIP ** Ensure proper port parameter overriding retrieval in case the debugger gets enabled not at boot, but later at runtime
This commit is contained in:
parent
4753dbe661
commit
47dd86037d
9 changed files with 356 additions and 228 deletions
|
@ -148,41 +148,43 @@ KdpPortInitialize(IN ULONG ComPortNumber,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Phase 0 initialization. Invoked by KdInitSystem() when the debugger
|
||||
* is enabled: at boot initialization, at resuming from hibernation,
|
||||
* during a BSOD, or when the debugger is re-enabled via KdEnableDebugger().
|
||||
*
|
||||
* @param[in] LoaderBlock
|
||||
* Optional pointer to the Loader Parameter Block (can be NULL).
|
||||
*
|
||||
* @return STATUS_SUCCESS or an error status.
|
||||
* Loads port parameters from the Loader Parameter Block, if available.
|
||||
**/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
KdDebuggerInitialize0(
|
||||
static NTSTATUS
|
||||
KdpRetrieveParameters(
|
||||
_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PCHAR CommandLine, PortString, BaudString, IrqString;
|
||||
static BOOLEAN AreParamsRetrieved = FALSE;
|
||||
PSTR CommandLine, PortString, BaudString, IrqString;
|
||||
ULONG Value;
|
||||
|
||||
/* Check if we have a LoaderBlock */
|
||||
if (LoaderBlock)
|
||||
{
|
||||
/* Get the Command Line */
|
||||
KDDBGPRINT("%s(%p)\n", __FUNCTION__, LoaderBlock);
|
||||
|
||||
/* Load parameters only once if they haven't been already */
|
||||
if (AreParamsRetrieved)
|
||||
return STATUS_SUCCESS;
|
||||
AreParamsRetrieved = TRUE;
|
||||
|
||||
/* Check if we have a loader block, and if not, attempt to use the
|
||||
* system one. If it's unavailable (post phase-1 init), just return. */
|
||||
if (!LoaderBlock)
|
||||
LoaderBlock = KeLoaderBlock;
|
||||
if (!LoaderBlock)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
/* Check if we have a command line */
|
||||
CommandLine = LoaderBlock->LoadOptions;
|
||||
if (!CommandLine)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
/* Upcase it */
|
||||
_strupr(CommandLine);
|
||||
|
||||
/* Get the port and baud rate */
|
||||
PortString = strstr(CommandLine, "DEBUGPORT");
|
||||
BaudString = strstr(CommandLine, "BAUDRATE");
|
||||
IrqString = strstr(CommandLine, "IRQ");
|
||||
|
||||
/* Check if we got the /DEBUGPORT parameter */
|
||||
PortString = strstr(CommandLine, "DEBUGPORT");
|
||||
if (PortString)
|
||||
{
|
||||
/* Move past the actual string, to reach the port*/
|
||||
|
@ -211,6 +213,7 @@ KdDebuggerInitialize0(
|
|||
}
|
||||
|
||||
/* Check if we got a baud rate */
|
||||
BaudString = strstr(CommandLine, "BAUDRATE");
|
||||
if (BaudString)
|
||||
{
|
||||
/* Move past the actual string, to reach the rate */
|
||||
|
@ -229,6 +232,7 @@ KdDebuggerInitialize0(
|
|||
}
|
||||
|
||||
/* Check Serial Port Settings [IRQ] */
|
||||
IrqString = strstr(CommandLine, "IRQ");
|
||||
if (IrqString)
|
||||
{
|
||||
/* Move past the actual string, to reach the rate */
|
||||
|
@ -245,8 +249,40 @@ KdDebuggerInitialize0(
|
|||
if (Value) ComPortIrq = Value;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Phase 0 initialization. Invoked by KdInitSystem() when the debugger
|
||||
* is enabled: at boot initialization, at resuming from hibernation,
|
||||
* during a BSOD, or when the debugger is re-enabled via KdEnableDebugger().
|
||||
*
|
||||
* @param[in] LoaderBlock
|
||||
* Optional pointer to the Loader Parameter Block (can be NULL).
|
||||
*
|
||||
* @return STATUS_SUCCESS or an error status.
|
||||
**/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
KdDebuggerInitialize0(
|
||||
_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
#ifdef KDDEBUG
|
||||
CpInitialize(&KdDebugComPort, UlongToPtr(BaseArray[/*ComPort*/4]), /*DEFAULT_BAUD_RATE*/115200);
|
||||
#endif
|
||||
KDDBGPRINT("KdDebuggerInitialize0\n");
|
||||
|
||||
/* Capture the parameters if this is the first invocation */
|
||||
Status = KdpRetrieveParameters(LoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status; // Or, keep using the default parameters?
|
||||
|
||||
#if 0
|
||||
#ifdef KDDEBUG
|
||||
/*
|
||||
* Try to find a free COM port and use it as the KD debugging port.
|
||||
|
@ -269,9 +305,10 @@ KdDebuggerInitialize0(
|
|||
if (ComPort != 0)
|
||||
CpInitialize(&KdDebugComPort, UlongToPtr(BaseArray[ComPort]), DEFAULT_BAUD_RATE);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
KDDBGPRINT("KdDebuggerInitialize0\n");
|
||||
//KDDBGPRINT("KdDebuggerInitialize0\n");
|
||||
|
||||
/* Initialize the port */
|
||||
Status = KdpPortInitialize(ComPortNumber, ComPortBaudRate);
|
||||
|
@ -299,6 +336,21 @@ NTAPI
|
|||
KdDebuggerInitialize1(
|
||||
_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
#ifdef KDDEBUG
|
||||
CpInitialize(&KdDebugComPort, UlongToPtr(BaseArray[/*ComPort*/4]), /*DEFAULT_BAUD_RATE*/115200);
|
||||
#endif
|
||||
KDDBGPRINT("KdDebuggerInitialize1\n");
|
||||
|
||||
/* Capture the parameters if KdDebuggerInitialize0() wasn't invoked already */
|
||||
Status = KdpRetrieveParameters(LoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status; // Or, keep using the default parameters?
|
||||
|
||||
// TODO: If we already have a MMIO COM port,
|
||||
// map it in memory and update KdComPortInUse.
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <ntifs.h>
|
||||
#include <windbgkd.h>
|
||||
|
||||
// #define KDDEBUG /* uncomment to enable debugging this dll */
|
||||
#define KDDEBUG /* uncomment to enable debugging this dll */
|
||||
|
||||
#ifndef KDDEBUG
|
||||
#define KDDBGPRINT(...)
|
||||
|
|
|
@ -141,40 +141,41 @@ KdpPortInitialize(IN ULONG ComPortNumber,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Phase 0 initialization. Invoked by KdInitSystem() when the debugger
|
||||
* is enabled: at boot initialization, at resuming from hibernation,
|
||||
* during a BSOD, or when the debugger is re-enabled via KdEnableDebugger().
|
||||
*
|
||||
* @param[in] LoaderBlock
|
||||
* Optional pointer to the Loader Parameter Block (can be NULL).
|
||||
*
|
||||
* @return STATUS_SUCCESS or an error status.
|
||||
* Loads port parameters from the Loader Parameter Block, if available.
|
||||
**/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
KdDebuggerInitialize0(
|
||||
static NTSTATUS
|
||||
KdpRetrieveParameters(
|
||||
_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||
{
|
||||
PCHAR CommandLine, PortString, BaudString, IrqString;
|
||||
static BOOLEAN AreParamsRetrieved = FALSE;
|
||||
PSTR CommandLine, PortString, BaudString, IrqString;
|
||||
ULONG Value;
|
||||
|
||||
/* Check if we have a LoaderBlock */
|
||||
if (LoaderBlock)
|
||||
{
|
||||
/* Get the Command Line */
|
||||
/* Load parameters only once if they haven't been already */
|
||||
if (AreParamsRetrieved)
|
||||
return STATUS_SUCCESS;
|
||||
AreParamsRetrieved = TRUE;
|
||||
|
||||
/* Check if we have a loader block, and if not, attempt to use the
|
||||
* system one. If it's unavailable (post phase-1 init), just return. */
|
||||
if (!LoaderBlock)
|
||||
LoaderBlock = KeLoaderBlock;
|
||||
if (!LoaderBlock)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
/* Check if we have a command line */
|
||||
CommandLine = LoaderBlock->LoadOptions;
|
||||
if (!CommandLine)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
/* Upcase it */
|
||||
_strupr(CommandLine);
|
||||
|
||||
/* Get the port and baud rate */
|
||||
PortString = strstr(CommandLine, "DEBUGPORT");
|
||||
BaudString = strstr(CommandLine, "BAUDRATE");
|
||||
IrqString = strstr(CommandLine, "IRQ");
|
||||
|
||||
/* Check if we got the /DEBUGPORT parameter */
|
||||
PortString = strstr(CommandLine, "DEBUGPORT");
|
||||
if (PortString)
|
||||
{
|
||||
/* Move past the actual string, to reach the port*/
|
||||
|
@ -203,6 +204,7 @@ KdDebuggerInitialize0(
|
|||
}
|
||||
|
||||
/* Check if we got a baud rate */
|
||||
BaudString = strstr(CommandLine, "BAUDRATE");
|
||||
if (BaudString)
|
||||
{
|
||||
/* Move past the actual string, to reach the rate */
|
||||
|
@ -221,6 +223,7 @@ KdDebuggerInitialize0(
|
|||
}
|
||||
|
||||
/* Check Serial Port Settings [IRQ] */
|
||||
IrqString = strstr(CommandLine, "IRQ");
|
||||
if (IrqString)
|
||||
{
|
||||
/* Move past the actual string, to reach the rate */
|
||||
|
@ -237,8 +240,34 @@ KdDebuggerInitialize0(
|
|||
if (Value) ComPortIrq = Value;
|
||||
}
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Phase 0 initialization. Invoked by KdInitSystem() when the debugger
|
||||
* is enabled: at boot initialization, at resuming from hibernation,
|
||||
* during a BSOD, or when the debugger is re-enabled via KdEnableDebugger().
|
||||
*
|
||||
* @param[in] LoaderBlock
|
||||
* Optional pointer to the Loader Parameter Block (can be NULL).
|
||||
*
|
||||
* @return STATUS_SUCCESS or an error status.
|
||||
**/
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
KdDebuggerInitialize0(
|
||||
_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Capture the parameters if this is the first invocation */
|
||||
Status = KdpRetrieveParameters(LoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status; // Or, keep using the default parameters?
|
||||
|
||||
#ifdef KDDEBUG
|
||||
/*
|
||||
* Try to find a free COM port and use it as the KD debugging port.
|
||||
|
@ -282,6 +311,16 @@ NTAPI
|
|||
KdDebuggerInitialize1(
|
||||
_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Capture the parameters if KdDebuggerInitialize0() wasn't invoked already */
|
||||
Status = KdpRetrieveParameters(LoaderBlock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status; // Or, keep using the default parameters?
|
||||
|
||||
// TODO: If we already have a MMIO COM port,
|
||||
// map it in memory and update KdComPortInUse.
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ typedef
|
|||
NTSTATUS
|
||||
(NTAPI *PKDP_INIT_ROUTINE)(
|
||||
_In_ struct _KD_DISPATCH_TABLE *DispatchTable,
|
||||
_In_ ULONG BootPhase);
|
||||
_In_ ULONG InitPhase);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
|
@ -55,19 +55,19 @@ NTSTATUS
|
|||
NTAPI
|
||||
KdpScreenInit(
|
||||
_In_ struct _KD_DISPATCH_TABLE *DispatchTable,
|
||||
_In_ ULONG BootPhase);
|
||||
_In_ ULONG InitPhase);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
KdpSerialInit(
|
||||
_In_ struct _KD_DISPATCH_TABLE *DispatchTable,
|
||||
_In_ ULONG BootPhase);
|
||||
_In_ ULONG InitPhase);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
KdpDebugLogInit(
|
||||
_In_ struct _KD_DISPATCH_TABLE *DispatchTable,
|
||||
_In_ ULONG BootPhase);
|
||||
_In_ ULONG InitPhase);
|
||||
|
||||
#ifdef KDBG
|
||||
#define KdpKdbgInit KdbInitialize
|
||||
|
|
|
@ -57,6 +57,8 @@ PKDP_INIT_ROUTINE InitRoutines[KdMax] =
|
|||
#endif
|
||||
};
|
||||
|
||||
extern void KdDbgPortPrintf(PCSTR Format, ...);
|
||||
|
||||
/* LOCKING FUNCTIONS *********************************************************/
|
||||
|
||||
KIRQL
|
||||
|
@ -196,23 +198,27 @@ NTSTATUS
|
|||
NTAPI
|
||||
KdpDebugLogInit(
|
||||
_In_ PKD_DISPATCH_TABLE DispatchTable,
|
||||
_In_ ULONG BootPhase)
|
||||
_In_ ULONG InitPhase)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
if (!KdpDebugMode.File)
|
||||
return STATUS_PORT_DISCONNECTED;
|
||||
|
||||
if (BootPhase == 0)
|
||||
KdDbgPortPrintf("%s(%d)\n", __FUNCTION__, InitPhase);
|
||||
|
||||
if (InitPhase == 0)
|
||||
{
|
||||
/////// ENABLING PORT ///////
|
||||
/* Write out the functions that we support for now */
|
||||
DispatchTable->KdpPrintRoutine = KdpPrintToLogFile;
|
||||
/////////////////////////////
|
||||
|
||||
/* Register for BootPhase 1 initialization and as a Provider */
|
||||
/* Register for InitPhase 1 initialization and as a Provider */
|
||||
DispatchTable->KdpInitRoutine = KdpDebugLogInit;
|
||||
InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
|
||||
}
|
||||
else if (BootPhase == 1)
|
||||
else if (InitPhase == 1)
|
||||
{
|
||||
/* Allocate a buffer for debug log */
|
||||
KdpDebugBuffer = ExAllocatePoolZero(NonPagedPool,
|
||||
|
@ -229,13 +235,13 @@ KdpDebugLogInit(
|
|||
/* Initialize spinlock */
|
||||
KeInitializeSpinLock(&KdpDebugLogSpinLock);
|
||||
|
||||
/* Register for later BootPhase 2 reinitialization */
|
||||
/* Register for later InitPhase 2 reinitialization */
|
||||
DispatchTable->KdpInitRoutine = KdpDebugLogInit;
|
||||
|
||||
/* Announce ourselves */
|
||||
HalDisplayString(" File log debugging enabled\r\n");
|
||||
}
|
||||
else if (BootPhase >= 2)
|
||||
else if (InitPhase >= 2)
|
||||
{
|
||||
UNICODE_STRING FileName;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
|
@ -323,6 +329,7 @@ KdpDebugLogInit(
|
|||
|
||||
KeInitializeEvent(&KdpLoggerThreadEvent, SynchronizationEvent, TRUE);
|
||||
|
||||
/////// ENABLING PORT ///////
|
||||
/* Create the logger thread */
|
||||
Status = PsCreateSystemThread(&ThreadHandle,
|
||||
THREAD_ALL_ACCESS,
|
||||
|
@ -345,6 +352,7 @@ KdpDebugLogInit(
|
|||
sizeof(Priority));
|
||||
|
||||
ZwClose(ThreadHandle);
|
||||
/////////////////////////////
|
||||
return Status;
|
||||
|
||||
Failure:
|
||||
|
@ -391,13 +399,16 @@ NTSTATUS
|
|||
NTAPI
|
||||
KdpSerialInit(
|
||||
_In_ PKD_DISPATCH_TABLE DispatchTable,
|
||||
_In_ ULONG BootPhase)
|
||||
_In_ ULONG InitPhase)
|
||||
{
|
||||
if (!KdpDebugMode.Serial)
|
||||
return STATUS_PORT_DISCONNECTED;
|
||||
|
||||
if (BootPhase == 0)
|
||||
KdDbgPortPrintf("%s(%d)\n", __FUNCTION__, InitPhase);
|
||||
|
||||
if (InitPhase == 0)
|
||||
{
|
||||
/////// ENABLING PORT ///////
|
||||
/* Write out the functions that we support for now */
|
||||
DispatchTable->KdpPrintRoutine = KdpSerialPrint;
|
||||
|
||||
|
@ -408,15 +419,16 @@ KdpSerialInit(
|
|||
return STATUS_DEVICE_DOES_NOT_EXIST;
|
||||
}
|
||||
KdComPortInUse = SerialPortInfo.Address;
|
||||
/////////////////////////////
|
||||
|
||||
/* Initialize spinlock */
|
||||
KeInitializeSpinLock(&KdpSerialSpinLock);
|
||||
|
||||
/* Register for BootPhase 1 initialization and as a Provider */
|
||||
/* Register for InitPhase 1 initialization and as a Provider */
|
||||
DispatchTable->KdpInitRoutine = KdpSerialInit;
|
||||
InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
|
||||
}
|
||||
else if (BootPhase == 1)
|
||||
else if (InitPhase == 1)
|
||||
{
|
||||
/* Announce ourselves */
|
||||
HalDisplayString(" Serial debugging enabled\r\n");
|
||||
|
@ -514,24 +526,30 @@ NTSTATUS
|
|||
NTAPI
|
||||
KdpScreenInit(
|
||||
_In_ PKD_DISPATCH_TABLE DispatchTable,
|
||||
_In_ ULONG BootPhase)
|
||||
_In_ ULONG InitPhase)
|
||||
{
|
||||
if (!KdpDebugMode.Screen)
|
||||
return STATUS_PORT_DISCONNECTED;
|
||||
|
||||
if (BootPhase == 0)
|
||||
KdDbgPortPrintf("%s(%d)\n", __FUNCTION__, InitPhase);
|
||||
|
||||
if (InitPhase == 0)
|
||||
{
|
||||
/////// ENABLING PORT ///////
|
||||
/* Write out the functions that we support for now */
|
||||
DispatchTable->KdpPrintRoutine = KdpScreenPrint;
|
||||
/////////////////////////////
|
||||
|
||||
/* Register for BootPhase 1 initialization and as a Provider */
|
||||
/* Register for InitPhase 1 initialization and as a Provider */
|
||||
DispatchTable->KdpInitRoutine = KdpScreenInit;
|
||||
InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
|
||||
}
|
||||
else if (BootPhase == 1)
|
||||
else if (InitPhase == 1)
|
||||
{
|
||||
/////// ENABLING PORT ///////
|
||||
/* Take control of the display */
|
||||
KdpScreenAcquire();
|
||||
/////////////////////////////
|
||||
|
||||
/* Announce ourselves */
|
||||
HalDisplayString(" Screen debugging enabled\r\n");
|
||||
|
|
|
@ -117,30 +117,36 @@ NTAPI
|
|||
KdDebuggerInitialize0(
|
||||
_In_opt_ PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||
{
|
||||
PCHAR CommandLine, Port = NULL;
|
||||
// static BOOLEAN AreParamsRetrieved = FALSE;
|
||||
ULONG i;
|
||||
BOOLEAN Success = FALSE;
|
||||
|
||||
KdDbgPortPrintf("%s(0x%p)\n", __FUNCTION__, LoaderBlock);
|
||||
|
||||
if (LoaderBlock)
|
||||
{
|
||||
/* Check if we have a loader block, and if not, attempt to use the
|
||||
* system one. If it's unavailable (post phase-1 init), just return. */
|
||||
if (!LoaderBlock)
|
||||
LoaderBlock = KeLoaderBlock;
|
||||
// if (!LoaderBlock)
|
||||
// return STATUS_SUCCESS;
|
||||
|
||||
/* Check if we have a command line */
|
||||
CommandLine = LoaderBlock->LoadOptions;
|
||||
if (CommandLine)
|
||||
if (LoaderBlock && LoaderBlock->LoadOptions)
|
||||
{
|
||||
PSTR CommandLine, Port = NULL;
|
||||
|
||||
CommandLine = LoaderBlock->LoadOptions;
|
||||
// if (!CommandLine)
|
||||
// return STATUS_SUCCESS;
|
||||
|
||||
/* Upcase it */
|
||||
_strupr(CommandLine);
|
||||
|
||||
/* Get terminal settings */
|
||||
KdpGetTerminalSettings(CommandLine);
|
||||
|
||||
/* Get the port */
|
||||
Port = strstr(CommandLine, "DEBUGPORT");
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we got the /DEBUGPORT parameter(s) */
|
||||
Port = strstr(CommandLine, "DEBUGPORT");
|
||||
while (Port)
|
||||
{
|
||||
/* Move past the actual string, to reach the port*/
|
||||
|
@ -154,6 +160,7 @@ KdDbgPortPrintf("%s(0x%p)\n", __FUNCTION__, LoaderBlock);
|
|||
Port = KdpGetDebugMode(Port);
|
||||
Port = strstr(Port, "DEBUGPORT");
|
||||
}
|
||||
}
|
||||
|
||||
/* Use serial port then */
|
||||
if (KdpDebugMode.Value == 0)
|
||||
|
@ -188,13 +195,13 @@ KdpDriverReinit(
|
|||
PLIST_ENTRY CurrentEntry;
|
||||
PKD_DISPATCH_TABLE CurrentTable;
|
||||
PKDP_INIT_ROUTINE KdpInitRoutine;
|
||||
ULONG BootPhase = (Count + 1); // Do BootPhase >= 2
|
||||
ULONG InitPhase = (Count + 1); // Do InitPhase >= 2
|
||||
BOOLEAN ScheduleReinit = FALSE;
|
||||
|
||||
ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
|
||||
|
||||
DPRINT("*** KD %sREINITIALIZATION - Phase %d ***\n",
|
||||
Context ? "" : "BOOT ", BootPhase);
|
||||
Context ? "" : "BOOT ", InitPhase);
|
||||
|
||||
/* Call the registered providers */
|
||||
for (CurrentEntry = KdProviders.Flink;
|
||||
|
@ -213,7 +220,7 @@ KdpDriverReinit(
|
|||
/* Get the initialization routine and reset it */
|
||||
KdpInitRoutine = CurrentTable->KdpInitRoutine;
|
||||
CurrentTable->KdpInitRoutine = NULL;
|
||||
CurrentTable->InitStatus = KdpInitRoutine(CurrentTable, BootPhase);
|
||||
CurrentTable->InitStatus = KdpInitRoutine(CurrentTable, InitPhase);
|
||||
DPRINT("KdpInitRoutine(%p) returned 0x%08lx\n",
|
||||
CurrentTable, CurrentTable->InitStatus);
|
||||
|
||||
|
@ -340,6 +347,12 @@ KdDebuggerInitialize1(
|
|||
|
||||
KdDbgPortPrintf("%s(0x%p)\n", __FUNCTION__, LoaderBlock);
|
||||
|
||||
//
|
||||
// TODO: If Init phase 0 wasn't invoked (because the debugger started
|
||||
// in a disabled state), we need to invoke it there right now, but
|
||||
// without enabling the corresponding debug ports.
|
||||
//
|
||||
|
||||
/* Make space for the displayed providers' signons */
|
||||
HalDisplayString("\r\n");
|
||||
|
||||
|
@ -449,7 +462,7 @@ KdDbgPortPrintf("%s(0x%p)\n", __FUNCTION__, LoaderBlock);
|
|||
* Once the KdpDriverEntry() driver entrypoint is called, we register
|
||||
* KdpDriverReinit() for re-initialization with the I/O Manager, in order
|
||||
* to provide more initialization points. KdpDriverReinit() calls the KD
|
||||
* providers at BootPhase >= 2, and schedules further reinitializations
|
||||
* providers at InitPhase >= 2, and schedules further reinitializations
|
||||
* (at most 3 more) if any of the providers request so.
|
||||
**/
|
||||
orgHalInitPnpDriver =
|
||||
|
|
|
@ -97,7 +97,7 @@ NTSTATUS
|
|||
NTAPI
|
||||
KdbInitialize(
|
||||
_In_ PKD_DISPATCH_TABLE DispatchTable,
|
||||
_In_ ULONG BootPhase);
|
||||
_In_ ULONG InitPhase);
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
|
@ -188,7 +188,7 @@ KdbSymProcessSymbols(
|
|||
|
||||
BOOLEAN
|
||||
KdbSymInit(
|
||||
_In_ ULONG BootPhase);
|
||||
_In_ ULONG InitPhase);
|
||||
|
||||
/* from kdb.c */
|
||||
|
||||
|
|
|
@ -3537,13 +3537,15 @@ KdbDebugPrint(
|
|||
* debug strings before they will be wiped over by next writes. */
|
||||
}
|
||||
|
||||
extern void KdDbgPortPrintf(PCSTR Format, ...);
|
||||
|
||||
/**
|
||||
* @brief Initializes the KDBG debugger.
|
||||
*
|
||||
* @param[in] DispatchTable
|
||||
* Pointer to the KD dispatch table.
|
||||
*
|
||||
* @param[in] BootPhase
|
||||
* @param[in] InitPhase
|
||||
* Phase of initialization.
|
||||
*
|
||||
* @return A status value.
|
||||
|
@ -3553,15 +3555,19 @@ NTSTATUS
|
|||
NTAPI
|
||||
KdbInitialize(
|
||||
_In_ PKD_DISPATCH_TABLE DispatchTable,
|
||||
_In_ ULONG BootPhase)
|
||||
_In_ ULONG InitPhase)
|
||||
{
|
||||
/* Saves the different symbol-loading status across boot phases */
|
||||
static ULONG LoadSymbols = 0;
|
||||
|
||||
if (BootPhase == 0)
|
||||
KdDbgPortPrintf("%s(%d)\n", __FUNCTION__, InitPhase);
|
||||
|
||||
if (InitPhase == 0)
|
||||
{
|
||||
/////// ENABLING PORT ///////
|
||||
/* Write out the functions that we support for now */
|
||||
DispatchTable->KdpPrintRoutine = KdbDebugPrint;
|
||||
/////////////////////////////
|
||||
|
||||
/* Check if we have a command line */
|
||||
if (KeLoaderBlock && KeLoaderBlock->LoadOptions)
|
||||
|
@ -3570,13 +3576,13 @@ KdbInitialize(
|
|||
KdbpGetCommandLineSettings(KeLoaderBlock->LoadOptions);
|
||||
}
|
||||
|
||||
/* Register for BootPhase 1 initialization and as a Provider */
|
||||
/* Register for InitPhase 1 initialization and as a Provider */
|
||||
DispatchTable->KdpInitRoutine = KdbInitialize;
|
||||
InsertTailList(&KdProviders, &DispatchTable->KdProvidersList);
|
||||
}
|
||||
else if (BootPhase == 1)
|
||||
else if (InitPhase == 1)
|
||||
{
|
||||
/* Register for later BootPhase 2 reinitialization */
|
||||
/* Register for later InitPhase 2 reinitialization */
|
||||
DispatchTable->KdpInitRoutine = KdbInitialize;
|
||||
|
||||
/* Initialize Dmesg support */
|
||||
|
@ -3594,14 +3600,14 @@ KdbInitialize(
|
|||
KeInitializeSpinLock(&KdpDmesgLogSpinLock);
|
||||
}
|
||||
|
||||
/* Initialize symbols support in BootPhase 0 and 1 */
|
||||
if (BootPhase <= 1)
|
||||
/* Initialize symbols support in InitPhase 0 and 1 */
|
||||
if (InitPhase <= 1)
|
||||
{
|
||||
LoadSymbols <<= 1;
|
||||
LoadSymbols |= KdbSymInit(BootPhase);
|
||||
LoadSymbols |= KdbSymInit(InitPhase);
|
||||
}
|
||||
|
||||
if (BootPhase == 1)
|
||||
if (InitPhase == 1)
|
||||
{
|
||||
/* Announce ourselves */
|
||||
CHAR buffer[60];
|
||||
|
@ -3613,7 +3619,7 @@ KdbInitialize(
|
|||
HalDisplayString(buffer);
|
||||
}
|
||||
|
||||
if (BootPhase >= 2)
|
||||
if (InitPhase >= 2)
|
||||
{
|
||||
/* I/O is now set up for disk access: load the KDBinit file */
|
||||
NTSTATUS Status = KdbpCliInit();
|
||||
|
|
|
@ -333,23 +333,23 @@ KdbSymProcessSymbols(
|
|||
/**
|
||||
* @brief Initializes the KDB symbols implementation.
|
||||
*
|
||||
* @param[in] BootPhase
|
||||
* @param[in] InitPhase
|
||||
* Phase of initialization.
|
||||
*
|
||||
* @return
|
||||
* TRUE if symbols are to be loaded at this given BootPhase; FALSE if not.
|
||||
* TRUE if symbols are to be loaded at this given InitPhase; FALSE if not.
|
||||
**/
|
||||
BOOLEAN
|
||||
KdbSymInit(
|
||||
_In_ ULONG BootPhase)
|
||||
_In_ ULONG InitPhase)
|
||||
{
|
||||
#if 1 // FIXME: This is a workaround HACK!!
|
||||
static BOOLEAN OrigLoadSymbols = FALSE;
|
||||
#endif
|
||||
|
||||
DPRINT("KdbSymInit() BootPhase=%d\n", BootPhase);
|
||||
DPRINT("KdbSymInit() InitPhase=%d\n", InitPhase);
|
||||
|
||||
if (BootPhase == 0)
|
||||
if (InitPhase == 0)
|
||||
{
|
||||
PSTR CommandLine;
|
||||
SHORT Found = FALSE;
|
||||
|
@ -405,13 +405,13 @@ KdbSymInit(
|
|||
}
|
||||
|
||||
#if 1 // FIXME: This is a workaround HACK!!
|
||||
// Save the actual value of LoadSymbols but disable it for BootPhase 0.
|
||||
// Save the actual value of LoadSymbols but disable it for InitPhase 0.
|
||||
OrigLoadSymbols = LoadSymbols;
|
||||
LoadSymbols = FALSE;
|
||||
return OrigLoadSymbols;
|
||||
#endif
|
||||
}
|
||||
else if (BootPhase == 1)
|
||||
else if (InitPhase == 1)
|
||||
{
|
||||
HANDLE Thread;
|
||||
NTSTATUS Status;
|
||||
|
|
Loading…
Reference in a new issue