/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS Kernel * FILE: ntoskrnl/kd/kdmain.c * PURPOSE: Kernel Debugger Initialization * * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) */ #include #define NDEBUG #include /* VARIABLES ***************************************************************/ VOID NTAPI PspDumpThreads(BOOLEAN SystemThreads); extern ANSI_STRING KdpLogFileName; /* PUBLIC FUNCTIONS *********************************************************/ static PCHAR NTAPI KdpGetDebugMode(PCHAR Currentp2) { PCHAR p1, p2 = Currentp2; ULONG Value; /* Check for Screen Debugging */ if (!_strnicmp(p2, "SCREEN", 6)) { /* Enable It */ p2 += 6; KdpDebugMode.Screen = TRUE; } /* Check for Serial Debugging */ else if (!_strnicmp(p2, "COM", 3)) { /* Gheck for a valid Serial Port */ p2 += 3; if (*p2 != ':') { Value = (ULONG)atol(p2); if (Value > 0 && Value < 5) { /* Valid port found, enable Serial Debugging */ KdpDebugMode.Serial = TRUE; /* Set the port to use */ SerialPortNumber = Value; } } else { Value = strtoul(p2 + 1, NULL, 0); if (Value) { KdpDebugMode.Serial = TRUE; SerialPortInfo.Address = UlongToPtr(Value); SerialPortNumber = 0; } } } /* Check for Debug Log Debugging */ else if (!_strnicmp(p2, "FILE", 4)) { /* Enable It */ p2 += 4; KdpDebugMode.File = TRUE; if (*p2 == ':') { p2++; p1 = p2; while (*p2 != '\0' && *p2 != ' ') p2++; KdpLogFileName.MaximumLength = KdpLogFileName.Length = p2 - p1; KdpLogFileName.Buffer = p1; } } return p2; } NTSTATUS NTAPI KdDebuggerInitialize0( IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) { ULONG i; PCHAR CommandLine, Port = NULL; if (LoaderBlock) { /* Check if we have a command line */ CommandLine = LoaderBlock->LoadOptions; if (CommandLine) { /* Upcase it */ _strupr(CommandLine); #ifdef KDBG /* Get the KDBG Settings */ KdbpGetCommandLineSettings(CommandLine); #endif /* Get the port */ Port = strstr(CommandLine, "DEBUGPORT"); } } /* Check if we got the /DEBUGPORT parameter(s) */ while (Port) { /* Move past the actual string, to reach the port*/ Port += sizeof("DEBUGPORT") - 1; /* Now get past any spaces and skip the equal sign */ while (*Port == ' ') Port++; Port++; /* Get the debug mode and wrapper */ Port = KdpGetDebugMode(Port); Port = strstr(Port, "DEBUGPORT"); } /* Use serial port then */ if (KdpDebugMode.Value == 0) KdpDebugMode.Serial = TRUE; /* Call Providers at Phase 0 */ for (i = 0; i < KdMax; i++) { InitRoutines[i](&DispatchTable[i], 0); } return STATUS_SUCCESS; } NTSTATUS NTAPI KdDebuggerInitialize1( IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) { PLIST_ENTRY CurrentEntry; PKD_DISPATCH_TABLE CurrentTable; /* Call the registered handlers */ CurrentEntry = KdProviders.Flink; while (CurrentEntry != &KdProviders) { /* Get the current table */ CurrentTable = CONTAINING_RECORD(CurrentEntry, KD_DISPATCH_TABLE, KdProvidersList); /* Call it */ CurrentTable->KdpInitRoutine(CurrentTable, 1); /* Next Table */ CurrentEntry = CurrentEntry->Flink; } NtGlobalFlag |= FLG_STOP_ON_EXCEPTION; return STATUS_SUCCESS; } /* EOF */