Merge with 13841:13843. Blight's rewrite adds a bug with ENTER in qemu, waiting on his fix.
Modified: branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_cli.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/iomgr.c
Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/kthread.c

Modified: branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_cli.c
--- branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_cli.c	2005-03-06 00:20:32 UTC (rev 13843)
+++ branches/alex_devel_branch/reactos/ntoskrnl/dbg/kdb_cli.c	2005-03-06 00:50:48 UTC (rev 13844)
@@ -873,7 +873,8 @@
    PEPROCESS Process = NULL;
    PULONG Esp;
    PULONG Ebp;
-   ULONG Eip, ul;
+   ULONG Eip;
+   ULONG ul = 0;
    PCHAR State, pend, str1, str2;
    STATIC CONST PCHAR ThreadStateToString[THREAD_STATE_MAX] =
                                           { "Initialized", "Ready", "Running",
@@ -1224,14 +1225,15 @@
       }
       KdbpPrint("IDT Base: 0x%08x  Limit: 0x%04x\n", Reg.Base, Reg.Limit);
       KdbpPrint("  Idx  Type        Seg. Sel.  Offset      DPL\n");
-      for ( ; (i + sizeof(SegDesc) - 1) <= Reg.Limit; i += 8)
+      for (i = 0; (i + sizeof(SegDesc) - 1) <= Reg.Limit; i += 8)
       {
          if (!NT_SUCCESS(KdbpSafeReadMemory(SegDesc, (PVOID)(Reg.Base + i), sizeof(SegDesc))))
          {
             KdbpPrint("Couldn't access memory at 0x%08x!\n", Reg.Base + i);
             return TRUE;
          }
-         
+
+         Dpl = ((SegDesc[1] >> 13) & 3);
          if ((SegDesc[1] & 0x1f00) == 0x0500)        /* Task gate */
             SegType = "TASKGATE";
          else if ((SegDesc[1] & 0x1fe0) == 0x0e00)   /* 32 bit Interrupt gate */
@@ -1242,6 +1244,8 @@
             SegType = "TRAPGATE32";
          else if ((SegDesc[1] & 0x1fe0) == 0x0700)   /* 16 bit Trap gate */
             SegType = "TRAPGATE16";
+         else
+            SegType = "UNKNOWN";
 
          if ((SegDesc[1] & (1 << 15)) == 0) /* not present */
          {
@@ -1432,7 +1436,7 @@
              "  InterruptMode:             0x%08x\n",
              Pcr->Tib.ExceptionList, Pcr->Tib.StackBase, Pcr->Tib.StackLimit,
              Pcr->Tib.SubSystemTib, Pcr->Tib.FiberData, Pcr->Tib.ArbitraryUserPointer,
-             Pcr->Tib.Self, Pcr->Self, Pcr->PCRCB, Pcr->Irql, Pcr->IRR, Pcr->IrrActive,
+             Pcr->Tib.Self, Pcr->Self, Pcr->Prcb, Pcr->Irql, Pcr->IRR, Pcr->IrrActive,
              Pcr->IDR, Pcr->KdVersionBlock, Pcr->IDT, Pcr->GDT, Pcr->TSS,
              Pcr->MajorVersion, Pcr->MinorVersion, Pcr->SetMember, Pcr->StallScaleFactor,
              Pcr->DebugActive, Pcr->ProcessorNumber, Pcr->L2CacheAssociativity,
@@ -1673,7 +1677,7 @@
    STATIC CHAR Buffer[4096];
    STATIC BOOLEAN TerminalInitialized = FALSE;
    STATIC BOOLEAN TerminalReportsSize = TRUE;
-   CHAR c;
+   CHAR c = '\0';
    PCHAR p;
    INT Length;
    INT i;

Modified: branches/alex_devel_branch/reactos/ntoskrnl/io/iomgr.c
--- branches/alex_devel_branch/reactos/ntoskrnl/io/iomgr.c	2005-03-06 00:20:32 UTC (rev 13843)
+++ branches/alex_devel_branch/reactos/ntoskrnl/io/iomgr.c	2005-03-06 00:50:48 UTC (rev 13844)
@@ -11,7 +11,7 @@
 /* INCLUDES ****************************************************************/
 
 #include <ntoskrnl.h>
-#include <internal/kdb.h>
+#include "../dbg/kdb.h"
 #define NDEBUG
 #include <internal/debug.h>
 

Modified: branches/alex_devel_branch/reactos/ntoskrnl/ke/kthread.c
--- branches/alex_devel_branch/reactos/ntoskrnl/ke/kthread.c	2005-03-06 00:20:32 UTC (rev 13843)
+++ branches/alex_devel_branch/reactos/ntoskrnl/ke/kthread.c	2005-03-06 00:50:48 UTC (rev 13844)
@@ -251,7 +251,7 @@
     Thread->ApcStatePointer[AttachedApcEnvironment] = &Thread->SavedApcState;
     Thread->ApcStateIndex = OriginalApcEnvironment;
     Thread->ApcQueueable = TRUE;
-    RtlZeroMemory(&Thread->SavedApcState, 0, sizeof(KAPC_STATE));
+    RtlZeroMemory(&Thread->SavedApcState, sizeof(KAPC_STATE));
     KeInitializeSpinLock(&Thread->ApcQueueLock);
     
     /* Setup Wait Fields */
@@ -263,8 +263,8 @@
     Thread->WaitListEntry.Blink = NULL;
     Thread->WaitTime = 0;
     Thread->WaitBlockList = NULL;
-    RtlZeroMemory(Thread->WaitBlock, 0, sizeof(KWAIT_BLOCK) * 4);
-    RtlZeroMemory(&Thread->Timer, 0, sizeof(KTIMER));
+    RtlZeroMemory(Thread->WaitBlock, sizeof(KWAIT_BLOCK) * 4);
+    RtlZeroMemory(&Thread->Timer, sizeof(KTIMER));
     KeInitializeTimer(&Thread->Timer);
     
     /* Setup scheduler Fields */