[NTOSKRNL] Add a raw implementation of !irpfind in kdbg
[reactos.git] / ntoskrnl / kd / kdinit.c
index 1f3c0ce..b5ec7f4 100644 (file)
 #define NDEBUG
 #include <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  PortNumber = DEFAULT_DEBUG_PORT;
+CPPORT PortInfo   = {0, DEFAULT_DEBUG_BAUD_RATE, 0};
 ULONG KdpPortIrq;
 #ifdef AUTO_ENABLE_BOCHS
 KDP_DEBUG_MODE KdpDebugMode = {{{.Bochs=TRUE}}};
@@ -73,7 +69,7 @@ KdpGetDebugMode(PCHAR Currentp2)
                 KdpDebugMode.Serial = TRUE;
 
                 /* Set the port to use */
-                SerialPortInfo.ComPort = Value;
+                SerialPortNumber = Value;
                 KdpPort = Value;
             }
         }
@@ -83,8 +79,8 @@ KdpGetDebugMode(PCHAR Currentp2)
             if (Value)
             {
                 KdpDebugMode.Serial = TRUE;
-                SerialPortInfo.BaseAddress = Value;
-                SerialPortInfo.ComPort = 0;
+                SerialPortInfo.Address = UlongToPtr(Value);
+                SerialPortNumber = 0;
                 KdpPort = 0;
             }
         }
@@ -122,8 +118,9 @@ KdpGetDebugMode(PCHAR Currentp2)
         KdpDebugMode.Gdb = TRUE;
 
         /* Enable Debugging */
-        KdDebuggerEnabled = TRUE;
         KdDebuggerNotPresent = FALSE;
+        KdDebuggerEnabled = TRUE;
+        SharedUserData->KdDebuggerEnabled = TRUE;
         WrapperInitRoutine = KdpGdbStubInit;
     }
 
@@ -135,8 +132,9 @@ KdpGetDebugMode(PCHAR Currentp2)
         KdpDebugMode.Pice = TRUE;
 
         /* Enable Debugging */
-        KdDebuggerEnabled = TRUE;
         KdDebuggerNotPresent = FALSE;
+        KdDebuggerEnabled = TRUE;
+        SharedUserData->KdDebuggerEnabled = TRUE;
     }
 
     return p2;
@@ -172,7 +170,6 @@ KdpCallInitRoutine(ULONG BootPhase)
 }
 
 BOOLEAN
-INIT_FUNCTION
 NTAPI
 KdInitSystem(ULONG BootPhase,
              PLOADER_PARAMETER_BLOCK LoaderBlock)
@@ -197,14 +194,17 @@ KdInitSystem(ULONG BootPhase,
         else if (strstr(CommandLine, "DEBUG"))
         {
             /* Enable the kernel debugger */
-            KdDebuggerEnabled = TRUE;
             KdDebuggerNotPresent = FALSE;
+            KdDebuggerEnabled = TRUE;
 #ifdef KDBG
             /* Get the KDBG Settings */
             KdbpGetCommandLineSettings(LoaderBlock->LoadOptions);
 #endif
         }
 
+        /* Let user-mode know our state */
+        SharedUserData->KdDebuggerEnabled = KdDebuggerEnabled;
+
         /* Get the port and baud rate */
         Port = strstr(CommandLine, "DEBUGPORT");
         BaudRate = strstr(CommandLine, "BAUDRATE");