- Silence TCPIP.
[reactos.git] / reactos / ntoskrnl / kd / kdinit.c
index 7a1d1f5..4e5aa0a 100644 (file)
@@ -3,7 +3,7 @@
  * PROJECT:         ReactOS Kernel
  * FILE:            ntoskrnl/kd/kdinit.c
  * PURPOSE:         Kernel Debugger Initializtion
- * 
+ *
  * PROGRAMMERS:     Alex Ionescu (alex@relsoft.net)
  */
 
 #define NDEBUG
 #include <internal/debug.h>
 
+#if defined (ALLOC_PRAGMA)
+#pragma alloc_text(INIT, KdInitSystem)
+#endif
+
+
+/* Make bochs debug output in the very early boot phase available */
+//#define AUTO_ENABLE_BOCHS
+
 /* VARIABLES ***************************************************************/
 
 KD_PORT_INFORMATION PortInfo = {DEFAULT_DEBUG_PORT, DEFAULT_DEBUG_BAUD_RATE, 0};
 ULONG KdpPortIrq;
+#ifdef AUTO_ENABLE_BOCHS
+KDP_DEBUG_MODE KdpDebugMode = {{{.Bochs=TRUE}}};;
+PKDP_INIT_ROUTINE WrapperInitRoutine = KdpBochsInit;
+KD_DISPATCH_TABLE WrapperTable = {.KdpInitRoutine = KdpBochsInit, .KdpPrintRoutine = KdpBochsDebugPrint};
+#else
 KDP_DEBUG_MODE KdpDebugMode;
-LIST_ENTRY KdProviders;
 PKDP_INIT_ROUTINE WrapperInitRoutine;
-KD_DISPATCH_TABLE DispatchTable[KdMax];
 KD_DISPATCH_TABLE WrapperTable;
+#endif
+BOOLEAN KdpEarlyBreak = FALSE;
+LIST_ENTRY KdProviders = {&KdProviders, &KdProviders};
+KD_DISPATCH_TABLE DispatchTable[KdMax];
 
 PKDP_INIT_ROUTINE InitRoutines[KdMax] = {KdpScreenInit,
                                          KdpSerialInit,
@@ -33,8 +48,7 @@ KdpGetWrapperDebugMode(PCHAR Currentp2,
                        PLOADER_PARAMETER_BLOCK LoaderBlock)
 {
     PCHAR p2 = Currentp2;
-    
-#ifdef DBG
+
     /* Check for BOCHS Debugging */
     if (!_strnicmp(p2, "BOCHS", 5))
     {
@@ -50,7 +64,7 @@ KdpGetWrapperDebugMode(PCHAR Currentp2,
         /* Enable it */
         p2 += 3;
         KdpDebugMode.Gdb = TRUE;
-                
+
         /* Enable Debugging */
         KdDebuggerEnabled = TRUE;
         WrapperInitRoutine = KdpGdbStubInit;
@@ -62,11 +76,10 @@ KdpGetWrapperDebugMode(PCHAR Currentp2,
         /* Enable it */
         p2 += 4;
         KdpDebugMode.Pice = TRUE;
-        
+
         /* Enable Debugging */
         KdDebuggerEnabled = TRUE;
     }
-#endif
 
 #ifdef KDBG
     /* Get the KDBG Settings and enable it */
@@ -76,14 +89,14 @@ KdpGetWrapperDebugMode(PCHAR Currentp2,
 #endif
     return p2;
 }
-    
+
 PCHAR
 STDCALL
 KdpGetDebugMode(PCHAR Currentp2)
 {
     PCHAR p2 = Currentp2;
     ULONG Value;
-            
+
     /* Check for Screen Debugging */
     if (!_strnicmp(p2, "SCREEN", 6))
     {
@@ -101,7 +114,7 @@ KdpGetDebugMode(PCHAR Currentp2)
         {
             /* Valid port found, enable Serial Debugging */
             KdpDebugMode.Serial = TRUE;
-            
+
             /* Set the port to use */
             SerialPortInfo.ComPort = Value;
             KdpPort = Value;
@@ -124,23 +137,23 @@ KdpCallInitRoutine(ULONG BootPhase)
 {
     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, 
+        CurrentTable = CONTAINING_RECORD(CurrentEntry,
+                                         KD_DISPATCH_TABLE,
                                          KdProvidersList);
-                                       
+
         /* Call it */
         CurrentTable->KdpInitRoutine(CurrentTable, BootPhase);
-        
+
         /* Next Table */
         CurrentEntry = CurrentEntry->Flink;
     }
-    
+
     /* Call the Wrapper Init Routine */
     if (WrapperInitRoutine)
         WrapperTable.KdpInitRoutine(&WrapperTable, BootPhase);
@@ -158,16 +171,14 @@ KdInitSystem(ULONG BootPhase,
     /* Set Default Port Options */
     if (BootPhase == 0)
     {
-        /* Initialize the Provider List */
-        InitializeListHead(&KdProviders);
-        
+
         /* Parse the Command Line */
         p1 = (PCHAR)LoaderBlock->CommandLine;
         while (p1 && (p2 = strchr(p1, '/')))
         {
             /* Move past the slash */
             p2++;
-        
+
             /* Identify the Debug Type being Used */
             if (!_strnicmp(p2, "DEBUGPORT=", 10))
             {
@@ -175,6 +186,12 @@ KdInitSystem(ULONG BootPhase,
                 p2 = KdpGetDebugMode(p2);
                 p2 = KdpGetWrapperDebugMode(p2, LoaderBlock);
             }
+            /* Check for early breakpoint */
+            else if (!_strnicmp(p2, "BREAK", 5))
+            {
+                p2 += 5;
+                KdpEarlyBreak = TRUE;
+            }
             /* Check for Kernel Debugging Enable */
             else if (!_strnicmp(p2, "DEBUG", 5))
             {
@@ -190,7 +207,7 @@ KdInitSystem(ULONG BootPhase,
                 p2 += 7;
                 KdDebuggerEnabled = FALSE;
             }
-            /* Check for Kernel Debugging Bypass unless STOP Error */  
+            /* Check for Kernel Debugging Bypass unless STOP Error */
             else if (!_strnicmp(p2, "CRASHDEBUG", 10))
             {
                 /* Disable Debugging */
@@ -203,7 +220,7 @@ KdInitSystem(ULONG BootPhase,
                 /* Get the Baud Rate */
                 p2 += 9;
                 Value = (ULONG)atol(p2);
-                
+
                 /* Check if it's valid and Set it */
                 if (0 < Value) PortInfo.BaudRate = SerialPortInfo.BaudRate = Value;
             }
@@ -213,21 +230,21 @@ KdInitSystem(ULONG BootPhase,
                 /* Get the IRQ */
                 p2 += 3;
                 Value = (ULONG)atol(p2);
-                
+
                 /* Check if it's valid and set it */
                 if (0 < Value) KdpPortIrq = Value;
             }
-        
+
             /* Move to next */
             p1 = p2;
-        }        
+        }
+
         /* Call Providers at Phase 0 */
         for (i = 0; i < KdMax; i++)
         {
             InitRoutines[i](&DispatchTable[i], 0);
         }
-       
+
         /* Call Wrapper at Phase 0 */
         if (WrapperInitRoutine) WrapperInitRoutine(&WrapperTable, 0);