[ros-diffs] [sginsberg] 44023: - Disable the MiCacheImageSymbols call in MmLoadSystemImage for KD too as this hack is required for rossym rather than KDBG. Fixes detection of non-boot driver images by WinDbg. - Add another hack to freeldr.c to make sure that HAL is the second entry in the Load Order list -- detect if it isn't and insert it as the second entry manually if it isn't. - KdbInitialize can now assume that the 2nd entry in the Load Order list is HAL, just like ExpLoadBootSymbols and KD does, so get the Loader Entry directly instead of searching for it. - Move KiBootTss and KiBootGdt to freeldr.c as this is where they belong -- they are not required for NTLDR/WINLDR boot style and are only used directly in freeldr.c. - Get rid of the AcpiTableDetected variable from freeldr.c. Instead, set the AcpiTable entry to something and make PoInitSystem check for that instead to preserve the old behavior. - Implement KdpGetFirstParameter and KdpGetSecondParameter for ARM too -- just retrieve R3/R4 here. Also rename those macros to clarify what parameters we are retrieving. - Add MmIsSessionAddress stub and use it from KD handle session space properly in the Memory Query API, and ASSERT that we are not trying to do a copy to/from session space in MmDbgCopyMemory as we don't handle it properly. Put this in mmdbg.c for now as we don't implement session space, and it is only called from KD right now. - Rename the 3 kdsup.c files to kdx86.c, kdx64.c and kdarm.c to differ them from each other. - Implement KdpAllowDisable -- just check if any processor breakpoints are set on any processor in the system and disallow the disable if so. The routine is now architecture dependant, so move it to the appropriate files. - Get rid of the MmFreeLdr* variables too. These have been deprecated for some time now. - The ModuleObject and ImageBaseAddress parameters of MmLoadSystemImage are not optional so don't treat them as such, and don't zero initialize them as callers shouldn't rely on this. - Set LDRP_ENTRY_NATIVE instead of LDRP_COMPAT_DATABASE_PROCESSED to mark the image as a native image. Also fix the value of LDRP_ENTRY_NATIVE. - Fix definition of LDR_DATA_TABLE_ENTRY -- the Checksum member should be in the union too. - Remove some unnecessary externs for stuff we now define globally in the kernel headers. - Rename some variables in KD to better match the logic. - Move some x86 only stuff from global ke.h and ke_x.h to the x86 dependent ke.h. Remove DR_ACTIVE_MASK as it has been deprecated/unused for a while now.

sginsberg at svn.reactos.org sginsberg at svn.reactos.org
Sun Nov 8 02:13:49 CET 2009


Author: sginsberg
Date: Sun Nov  8 02:13:49 2009
New Revision: 44023

URL: http://svn.reactos.org/svn/reactos?rev=44023&view=rev
Log:
- Disable the MiCacheImageSymbols call in MmLoadSystemImage for KD too as this hack is required for rossym rather than KDBG. Fixes detection of non-boot driver images by WinDbg.
- Add another hack to freeldr.c to make sure that HAL is the second entry in the Load Order list -- detect if it isn't and insert it as the second entry manually if it isn't.
- KdbInitialize can now assume that the 2nd entry in the Load Order list is HAL, just like ExpLoadBootSymbols and KD does, so get the Loader Entry directly instead of searching for it.
- Move KiBootTss and KiBootGdt to freeldr.c as this is where they belong -- they are not required for NTLDR/WINLDR boot style and are only used directly in freeldr.c.
- Get rid of the AcpiTableDetected variable from freeldr.c. Instead, set the AcpiTable entry to something and make PoInitSystem check for that instead to preserve the old behavior.
- Implement KdpGetFirstParameter and KdpGetSecondParameter for ARM too -- just retrieve R3/R4 here. Also rename those macros to clarify what parameters we are retrieving.
- Add MmIsSessionAddress stub and use it from KD handle session space properly in the Memory Query API, and ASSERT that we are not trying to do a copy to/from session space in MmDbgCopyMemory as we don't handle it properly. Put this in mmdbg.c for now as we don't implement session space, and it is only called from KD right now.
- Rename the 3 kdsup.c files to kdx86.c, kdx64.c and kdarm.c to differ them from each other.
- Implement KdpAllowDisable -- just check if any processor breakpoints are set on any processor in the system and disallow the disable if so. The routine is now architecture dependant, so move it to the appropriate files.
- Get rid of the MmFreeLdr* variables too. These have been deprecated for some time now.
- The ModuleObject and ImageBaseAddress parameters of MmLoadSystemImage are not optional so don't treat them as such, and don't zero initialize them as callers shouldn't rely on this.
- Set LDRP_ENTRY_NATIVE instead of LDRP_COMPAT_DATABASE_PROCESSED to mark the image as a native image. Also fix the value of LDRP_ENTRY_NATIVE.
- Fix definition of LDR_DATA_TABLE_ENTRY -- the Checksum member should be in the union too.
- Remove some unnecessary externs for stuff we now define globally in the kernel headers.
- Rename some variables in KD to better match the logic.
- Move some x86 only stuff from global ke.h and ke_x.h to the x86 dependent ke.h. Remove DR_ACTIVE_MASK as it has been deprecated/unused for a while now.

Added:
    trunk/reactos/ntoskrnl/kd64/amd64/kdx64.c
      - copied, changed from r43987, trunk/reactos/ntoskrnl/kd64/amd64/kdsup.c
    trunk/reactos/ntoskrnl/kd64/arm/kdarm.c
      - copied, changed from r43987, trunk/reactos/ntoskrnl/kd64/arm/kdsup.c
    trunk/reactos/ntoskrnl/kd64/i386/kdx86.c
      - copied, changed from r43987, trunk/reactos/ntoskrnl/kd64/i386/kdsup.c
Removed:
    trunk/reactos/ntoskrnl/kd64/amd64/kdsup.c
    trunk/reactos/ntoskrnl/kd64/arm/kdsup.c
    trunk/reactos/ntoskrnl/kd64/i386/kdsup.c
Modified:
    trunk/reactos/include/ndk/ldrtypes.h
    trunk/reactos/include/reactos/rosldr.h
    trunk/reactos/ntoskrnl/ex/init.c
    trunk/reactos/ntoskrnl/include/internal/i386/ke.h
    trunk/reactos/ntoskrnl/include/internal/kd64.h
    trunk/reactos/ntoskrnl/include/internal/ke.h
    trunk/reactos/ntoskrnl/include/internal/ke_x.h
    trunk/reactos/ntoskrnl/include/internal/mm.h
    trunk/reactos/ntoskrnl/include/internal/po.h
    trunk/reactos/ntoskrnl/kd64/kdapi.c
    trunk/reactos/ntoskrnl/kd64/kdprint.c
    trunk/reactos/ntoskrnl/kd64/kdtrap.c
    trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c
    trunk/reactos/ntoskrnl/ke/freeldr.c
    trunk/reactos/ntoskrnl/ke/i386/cpu.c
    trunk/reactos/ntoskrnl/ke/i386/exp.c
    trunk/reactos/ntoskrnl/mm/mmdbg.c
    trunk/reactos/ntoskrnl/mm/sysldr.c
    trunk/reactos/ntoskrnl/po/power.c

Modified: trunk/reactos/include/ndk/ldrtypes.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/ldrtypes.h?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/include/ndk/ldrtypes.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/ldrtypes.h [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -52,7 +52,7 @@
 #define LDRP_SYSTEM_MAPPED                      0x01000000
 #define LDRP_IMAGE_VERIFYING                    0x02000000
 #define LDRP_DRIVER_DEPENDENT_DLL               0x04000000
-#define LDRP_ENTRY_NATIVE                       0x08800000
+#define LDRP_ENTRY_NATIVE                       0x08000000
 #define LDRP_REDIRECTED                         0x10000000
 #define LDRP_NON_PAGED_DEBUG_INFO               0x20000000
 #define LDRP_MM_LOADED                          0x40000000
@@ -112,9 +112,12 @@
     union
     {
         LIST_ENTRY HashLinks;
-        PVOID SectionPointer;
+        struct
+        {
+            PVOID SectionPointer;
+            ULONG CheckSum;
+        };
     };
-    ULONG CheckSum;
     union
     {
         ULONG TimeDateStamp;

Modified: trunk/reactos/include/reactos/rosldr.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/rosldr.h?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/include/reactos/rosldr.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/rosldr.h [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -48,7 +48,4 @@
     ULONG (*FrLdrDbgPrint)(const char *Format, ...);
 } ROS_LOADER_PARAMETER_BLOCK, *PROS_LOADER_PARAMETER_BLOCK;
 
-extern BOOLEAN AcpiTableDetected;
-extern ULONG MmFreeLdrPageDirectoryStart, MmFreeLdrPageDirectoryEnd;
-
 #endif

Modified: trunk/reactos/ntoskrnl/ex/init.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -1395,7 +1395,7 @@
     InbvDisplayString(EndBuffer);
 
     /* Initialize Power Subsystem in Phase 0 */
-    if (!PoInitSystem(0, AcpiTableDetected)) KeBugCheck(INTERNAL_POWER_ERROR);
+    if (!PoInitSystem(0)) KeBugCheck(INTERNAL_POWER_ERROR);
 
     /* Check for Y2K hack */
     Y2KHackRequired = strstr(CommandLine, "YEAR");
@@ -1833,7 +1833,7 @@
 #endif
 
     /* Initialize Power Subsystem in Phase 1*/
-    if (!PoInitSystem(1, AcpiTableDetected)) KeBugCheck(INTERNAL_POWER_ERROR);
+    if (!PoInitSystem(1)) KeBugCheck(INTERNAL_POWER_ERROR);
 
     /* Initialize the Process Manager at Phase 1 */
     if (!PsInitSystem(LoaderBlock)) KeBugCheck(PROCESS1_INITIALIZATION_FAILED);

Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/i386/ke.h?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -7,6 +7,12 @@
 #include "v86m.h"
 
 extern ULONG Ke386CacheAlignment;
+
+//
+// Thread Dispatcher Header DebugActive Mask
+//
+#define DR_MASK(x)                              (1 << (x))
+#define DR_REG_MASK                             0x4F
 
 #define IMAGE_FILE_MACHINE_ARCHITECTURE IMAGE_FILE_MACHINE_I386
 
@@ -107,7 +113,180 @@
     IN PKGDTENTRY Descriptor
 );
 
+VOID
+NTAPI
+KiFlushNPXState(
+    IN FLOATING_SAVE_AREA *SaveArea
+);
+
+VOID
+NTAPI
+Ki386AdjustEsp0(
+    IN PKTRAP_FRAME TrapFrame
+);
+
+VOID
+NTAPI
+Ki386SetupAndExitToV86Mode(
+    OUT PTEB VdmTeb
+);
+
+VOID
+NTAPI
+KeI386VdmInitialize(
+    VOID
+);
+
+ULONG_PTR
+NTAPI
+Ki386EnableGlobalPage(
+    IN volatile ULONG_PTR Context
+);
+
+VOID
+NTAPI
+KiI386PentiumLockErrataFixup(
+    VOID
+);
+
+VOID
+NTAPI
+KiInitializePAT(
+    VOID
+);
+
+VOID
+NTAPI
+KiInitializeMTRR(
+    IN BOOLEAN FinalCpu
+);
+
+VOID
+NTAPI
+KiAmdK6InitializeMTRR(
+    VOID
+);
+
+VOID
+NTAPI
+KiRestoreFastSyscallReturnState(
+    VOID
+);
+
+ULONG_PTR
+NTAPI
+Ki386EnableDE(
+    IN ULONG_PTR Context
+);
+
+ULONG_PTR
+NTAPI
+Ki386EnableFxsr(
+    IN ULONG_PTR Context
+);
+
+ULONG_PTR
+NTAPI
+Ki386EnableXMMIExceptions(
+    IN ULONG_PTR Context
+);
+
+//
+// Global x86 only Kernel data
+//
+extern PVOID Ki386IopmSaveArea;
+extern ULONG KeI386EFlagsAndMaskV86;
+extern ULONG KeI386EFlagsOrMaskV86;
+extern BOOLEAN KeI386VirtualIntExtensions;
+extern KIDTENTRY KiIdt[MAXIMUM_IDTVECTOR];
+extern KDESCRIPTOR KiIdtDescriptor;
+extern ULONG Ke386GlobalPagesEnabled;
+extern BOOLEAN KiI386PentiumLockErrataPresent;
+extern ULONG KeI386NpxPresent;
+extern ULONG KeI386XMMIPresent;
+extern ULONG KeI386FxsrPresent;
+extern ULONG KiMXCsrMask;
+extern ULONG KeI386CpuType;
+extern ULONG KeI386CpuStep;
+extern UCHAR KiDebugRegisterTrapOffsets[9];
+extern UCHAR KiDebugRegisterContextOffsets[9];
+extern VOID __cdecl KiTrap2(VOID);
+extern VOID __cdecl KiTrap8(VOID);
+extern VOID __cdecl KiTrap19(VOID);
+extern VOID __cdecl KiFastCallEntry(VOID);
+
+//
+// Sanitizes a selector
+//
+FORCEINLINE
+ULONG
+Ke386SanitizeSeg(IN ULONG Cs,
+                IN KPROCESSOR_MODE Mode)
+{
+    //
+    // Check if we're in kernel-mode, and force CPL 0 if so.
+    // Otherwise, force CPL 3.
+    //
+    return ((Mode == KernelMode) ?
+            (Cs & (0xFFFF & ~RPL_MASK)) :
+            (RPL_MASK | (Cs & 0xFFFF)));
+}
+
+//
+// Sanitizes EFLAGS
+//
+FORCEINLINE
+ULONG
+Ke386SanitizeFlags(IN ULONG Eflags,
+                   IN KPROCESSOR_MODE Mode)
+{
+    //
+    // Check if we're in kernel-mode, and sanitize EFLAGS if so.
+    // Otherwise, also force interrupt mask on.
+    //
+    return ((Mode == KernelMode) ?
+            (Eflags & (EFLAGS_USER_SANITIZE | EFLAGS_INTERRUPT_MASK)) :
+            (EFLAGS_INTERRUPT_MASK | (Eflags & EFLAGS_USER_SANITIZE)));
+}
+
+//
+// Gets a DR register from a CONTEXT structure
+//
+FORCEINLINE
+PVOID
+KiDrFromContext(IN ULONG Dr,
+                IN PCONTEXT Context)
+{
+    return *(PVOID*)((ULONG_PTR)Context + KiDebugRegisterContextOffsets[Dr]);
+}
+
+//
+// Gets a DR register from a KTRAP_FRAME structure
+//
+FORCEINLINE
+PVOID*
+KiDrFromTrapFrame(IN ULONG Dr,
+                  IN PKTRAP_FRAME TrapFrame)
+{
+    return (PVOID*)((ULONG_PTR)TrapFrame + KiDebugRegisterTrapOffsets[Dr]);
+}
+
+//
+// Sanitizes a Debug Register
+//
+FORCEINLINE
+PVOID
+Ke386SanitizeDr(IN PVOID DrAddress,
+                IN KPROCESSOR_MODE Mode)
+{
+    //
+    // Check if we're in kernel-mode, and return the address directly if so.
+    // Otherwise, make sure it's not inside the kernel-mode address space.
+    // If it is, then clear the address.
+    //
+    return ((Mode == KernelMode) ? DrAddress :
+            (DrAddress <= MM_HIGHEST_USER_ADDRESS) ? DrAddress : 0);
+}
+
 #endif
 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_KE_H */
-
-/* EOF */

Modified: trunk/reactos/ntoskrnl/include/internal/kd64.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/kd64.h?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/kd64.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/kd64.h [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -179,7 +179,7 @@
 VOID
 NTAPI
 KdExitDebugger(
-    IN BOOLEAN Entered
+    IN BOOLEAN Enable
 );
 
 NTSTATUS
@@ -207,7 +207,7 @@
     IN KPROCESSOR_MODE PreviousMode,
     IN PKTRAP_FRAME TrapFrame,
     IN PKEXCEPTION_FRAME ExceptionFrame,
-    OUT PBOOLEAN Status
+    OUT PBOOLEAN Handled
 );
 
 USHORT
@@ -310,6 +310,15 @@
 VOID
 NTAPI
 KdpSuspendAllBreakPoints(
+    VOID
+);
+
+//
+// Routine to determine if it is safe to disable the debugger
+//
+NTSTATUS
+NTAPI
+KdpAllowDisable(
     VOID
 );
 

Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/ke.h?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -71,10 +71,6 @@
     IN ULONG Length
 );
 
-extern ULONG_PTR MmFreeLdrFirstKrnlPhysAddr;
-extern ULONG_PTR MmFreeLdrLastKrnlPhysAddr;
-extern ULONG_PTR MmFreeLdrLastKernelAddress;
-
 extern PVOID KeUserApcDispatcher;
 extern PVOID KeUserCallbackDispatcher;
 extern PVOID KeUserExceptionDispatcher;
@@ -82,18 +78,10 @@
 extern LARGE_INTEGER KeBootTime;
 extern ULONGLONG KeBootTimeBias;
 extern BOOLEAN ExCmosClockIsSane;
-extern ULONG KeI386NpxPresent;
-extern ULONG KeI386XMMIPresent;
-extern ULONG KeI386FxsrPresent;
-extern ULONG KiMXCsrMask;
-extern ULONG KeI386CpuType;
-extern ULONG KeI386CpuStep;
 extern ULONG KeProcessorArchitecture;
 extern ULONG KeProcessorLevel;
 extern ULONG KeProcessorRevision;
 extern ULONG KeFeatureBits;
-extern ULONG Ke386GlobalPagesEnabled;
-extern BOOLEAN KiI386PentiumLockErrataPresent;
 extern KNODE KiNode0;
 extern PKNODE KeNodeBlock[1];
 extern UCHAR KeNumberNodes;
@@ -105,17 +93,6 @@
 extern PULONG KiInterruptTemplateDispatch;
 extern PULONG KiInterruptTemplate2ndDispatch;
 extern ULONG KiUnexpectedEntrySize;
-#ifdef _M_IX86
-extern PVOID Ki386IopmSaveArea;
-extern ULONG KeI386EFlagsAndMaskV86;
-extern ULONG KeI386EFlagsOrMaskV86;
-extern BOOLEAN KeI386VirtualIntExtensions;
-extern KIDTENTRY KiIdt[];
-extern KGDTENTRY KiBootGdt[];
-extern KDESCRIPTOR KiGdtDescriptor;
-extern KDESCRIPTOR KiIdtDescriptor;
-extern KTSS KiBootTss;
-#endif
 extern UCHAR P0BootStack[];
 extern UCHAR KiDoubleFaultStack[];
 extern EX_PUSH_LOCK KernelAddressSpaceLock;
@@ -142,16 +119,10 @@
 extern PKPRCB KiProcessorBlock[];
 extern ULONG KiMask32Array[MAXIMUM_PRIORITY];
 extern ULONG KiIdleSummary;
-extern VOID __cdecl KiTrap19(VOID);
-extern VOID __cdecl KiTrap8(VOID);
-extern VOID __cdecl KiTrap2(VOID);
-extern VOID __cdecl KiFastCallEntry(VOID);
 extern PVOID KeUserApcDispatcher;
 extern PVOID KeUserCallbackDispatcher;
 extern PVOID KeUserExceptionDispatcher;
 extern PVOID KeRaiseUserExceptionDispatcher;
-extern UCHAR KiDebugRegisterTrapOffsets[9];
-extern UCHAR KiDebugRegisterContextOffsets[9];
 extern ULONG KeTimeIncrement;
 extern ULONG KeTimeAdjustment;
 extern ULONG_PTR KiBugCheckData[5];
@@ -885,38 +856,9 @@
 
 VOID
 NTAPI
-Ki386AdjustEsp0(
-    IN PKTRAP_FRAME TrapFrame
-);
-
-VOID
-NTAPI
-Ki386SetupAndExitToV86Mode(
-    OUT PTEB VdmTeb
-);
-
-VOID
-NTAPI
-KeI386VdmInitialize(
-    VOID
-);
-
-VOID
-NTAPI
 KiInitializeMachineType(
     VOID
 );
-
-//
-// We need to do major portability work
-//
-#ifdef _M_IX86
-VOID
-NTAPI
-KiFlushNPXState(
-    IN FLOATING_SAVE_AREA *SaveArea
-);
-#endif
 
 VOID
 NTAPI
@@ -969,45 +911,9 @@
     VOID
 );
 
-ULONG_PTR
-NTAPI
-Ki386EnableGlobalPage(IN volatile ULONG_PTR Context);
-
-VOID
-NTAPI
-KiInitializePAT(VOID);
-
-VOID
-NTAPI
-KiInitializeMTRR(IN BOOLEAN FinalCpu);
-
-VOID
-NTAPI
-KiAmdK6InitializeMTRR(VOID);
-
-VOID
-NTAPI
-KiRestoreFastSyscallReturnState(VOID);
-
-ULONG_PTR
-NTAPI
-Ki386EnableDE(IN ULONG_PTR Context);
-
-ULONG_PTR
-NTAPI
-Ki386EnableFxsr(IN ULONG_PTR Context);
-
-ULONG_PTR
-NTAPI
-Ki386EnableXMMIExceptions(IN ULONG_PTR Context);
-
 VOID
 NTAPI
 KiInitMachineDependent(VOID);
-
-VOID
-NTAPI
-KiI386PentiumLockErrataFixup(VOID);
 
 BOOLEAN
 NTAPI

Modified: trunk/reactos/ntoskrnl/include/internal/ke_x.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/ke_x.h?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke_x.h [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -5,88 +5,6 @@
 * PURPOSE:         Internal Inlined Functions for the Kernel
 * PROGRAMMERS:     Alex Ionescu (alex.ionescu at reactos.org)
 */
-
-//
-// Thread Dispatcher Header DebugActive Mask
-//
-#define DR_MASK(x)                              1 << x
-#define DR_ACTIVE_MASK                          0x10
-#define DR_REG_MASK                             0x4F
-
-#ifdef _M_IX86
-//
-// Sanitizes a selector
-//
-FORCEINLINE
-ULONG
-Ke386SanitizeSeg(IN ULONG Cs,
-                IN KPROCESSOR_MODE Mode)
-{
-    //
-    // Check if we're in kernel-mode, and force CPL 0 if so.
-    // Otherwise, force CPL 3.
-    //
-    return ((Mode == KernelMode) ?
-            (Cs & (0xFFFF & ~RPL_MASK)) :
-            (RPL_MASK | (Cs & 0xFFFF)));
-}
-
-//
-// Sanitizes EFLAGS
-//
-FORCEINLINE
-ULONG
-Ke386SanitizeFlags(IN ULONG Eflags,
-                   IN KPROCESSOR_MODE Mode)
-{
-    //
-    // Check if we're in kernel-mode, and sanitize EFLAGS if so.
-    // Otherwise, also force interrupt mask on.
-    //
-    return ((Mode == KernelMode) ?
-            (Eflags & (EFLAGS_USER_SANITIZE | EFLAGS_INTERRUPT_MASK)) :
-            (EFLAGS_INTERRUPT_MASK | (Eflags & EFLAGS_USER_SANITIZE)));
-}
-
-//
-// Gets a DR register from a CONTEXT structure
-//
-FORCEINLINE
-PVOID
-KiDrFromContext(IN ULONG Dr,
-                IN PCONTEXT Context)
-{
-    return *(PVOID*)((ULONG_PTR)Context + KiDebugRegisterContextOffsets[Dr]);
-}
-
-//
-// Gets a DR register from a KTRAP_FRAME structure
-//
-FORCEINLINE
-PVOID*
-KiDrFromTrapFrame(IN ULONG Dr,
-                  IN PKTRAP_FRAME TrapFrame)
-{
-    return (PVOID*)((ULONG_PTR)TrapFrame + KiDebugRegisterTrapOffsets[Dr]);
-}
-
-//
-//
-//
-FORCEINLINE
-PVOID
-Ke386SanitizeDr(IN PVOID DrAddress,
-                IN KPROCESSOR_MODE Mode)
-{
-    //
-    // Check if we're in kernel-mode, and return the address directly if so.
-    // Otherwise, make sure it's not inside the kernel-mode address space.
-    // If it is, then clear the address.
-    //
-    return ((Mode == KernelMode) ? DrAddress :
-            (DrAddress <= MM_HIGHEST_USER_ADDRESS) ? DrAddress : 0);
-}
-#endif /* _M_IX86 */
 
 #ifndef _M_ARM
 FORCEINLINE

Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/mm.h?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -511,6 +511,15 @@
     IN ULONG Flags
 );
 
+//
+// Determines if a given address is a session address
+//
+BOOLEAN
+NTAPI
+MmIsSessionAddress(
+    IN PVOID Address
+);
+
 /* marea.c *******************************************************************/
 
 NTSTATUS

Modified: trunk/reactos/ntoskrnl/include/internal/po.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/po.h?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/po.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/po.h [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -38,8 +38,7 @@
 BOOLEAN
 NTAPI
 PoInitSystem(
-    IN ULONG BootPhase,
-    IN BOOLEAN HaveAcpiTable
+    IN ULONG BootPhase
 );
 
 VOID

Removed: trunk/reactos/ntoskrnl/kd64/amd64/kdsup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/amd64/kdsup.c?rev=44022&view=auto
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/amd64/kdsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd64/amd64/kdsup.c (removed)
@@ -1,151 +1,0 @@
-/*
- * PROJECT:         ReactOS Kernel
- * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            ntoskrnl/kd64/amd64/kdsup.c
- * PURPOSE:         KD support routines for AMD64
- * PROGRAMMERS:     Timo Kreuzer (timo.kreuzer at reactos.org)
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ntoskrnl.h>
-#define NDEBUG
-#include <debug.h>
-
-#undef UNIMPLEMENTED
-#define UNIMPLEMENTED KdpDprintf("%s is unimplemented\n", __FUNCTION__)
-
-/* FUNCTIONS *****************************************************************/
-
-VOID
-NTAPI
-KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State,
-                  IN PCONTEXT Context)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-}
-
-VOID
-NTAPI
-KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange,
-                   IN PCONTEXT Context)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadMsr(IN ULONG Msr,
-              OUT PLARGE_INTEGER MsrValue)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteMsr(IN ULONG Msr,
-               IN PLARGE_INTEGER MsrValue)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadBusData(IN ULONG BusDataType,
-                  IN ULONG BusNumber,
-                  IN ULONG SlotNumber,
-                  IN ULONG Offset,
-                  IN PVOID Buffer,
-                  IN ULONG Length,
-                  OUT PULONG ActualLength)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteBusData(IN ULONG BusDataType,
-                   IN ULONG BusNumber,
-                   IN ULONG SlotNumber,
-                   IN ULONG Offset,
-                   IN PVOID Buffer,
-                   IN ULONG Length,
-                   OUT PULONG ActualLength)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadControlSpace(IN ULONG Processor,
-                       IN ULONG64 BaseAddress,
-                       IN PVOID Buffer,
-                       IN ULONG Length,
-                       OUT PULONG ActualLength)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteControlSpace(IN ULONG Processor,
-                        IN ULONG64 BaseAddress,
-                        IN PVOID Buffer,
-                        IN ULONG Length,
-                        OUT PULONG ActualLength)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadIoSpace(IN ULONG InterfaceType,
-                  IN ULONG BusNumber,
-                  IN ULONG AddressSpace,
-                  IN ULONG64 IoAddress,
-                  IN PVOID DataValue,
-                  IN ULONG DataSize,
-                  OUT PULONG ActualDataSize)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteIoSpace(IN ULONG InterfaceType,
-                   IN ULONG BusNumber,
-                   IN ULONG AddressSpace,
-                   IN ULONG64 IoAddress,
-                   IN PVOID DataValue,
-                   IN ULONG DataSize,
-                   OUT PULONG ActualDataSize)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysCheckLowMemory(IN ULONG Flags)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}

Copied: trunk/reactos/ntoskrnl/kd64/amd64/kdx64.c (from r43987, trunk/reactos/ntoskrnl/kd64/amd64/kdsup.c)
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/amd64/kdx64.c?p2=trunk/reactos/ntoskrnl/kd64/amd64/kdx64.c&p1=trunk/reactos/ntoskrnl/kd64/amd64/kdsup.c&r1=43987&r2=44023&rev=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/amd64/kdsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd64/amd64/kdx64.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -1,7 +1,7 @@
 /*
  * PROJECT:         ReactOS Kernel
  * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            ntoskrnl/kd64/amd64/kdsup.c
+ * FILE:            ntoskrnl/kd64/amd64/kdx64.c
  * PURPOSE:         KD support routines for AMD64
  * PROGRAMMERS:     Timo Kreuzer (timo.kreuzer at reactos.org)
  */
@@ -149,3 +149,12 @@
     while (TRUE);
     return STATUS_UNSUCCESSFUL;
 }
+
+NTSTATUS
+NTAPI
+KdpAllowDisable(VOID)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return STATUS_ACCESS_DENIED;
+}

Copied: trunk/reactos/ntoskrnl/kd64/arm/kdarm.c (from r43987, trunk/reactos/ntoskrnl/kd64/arm/kdsup.c)
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/arm/kdarm.c?p2=trunk/reactos/ntoskrnl/kd64/arm/kdarm.c&p1=trunk/reactos/ntoskrnl/kd64/arm/kdsup.c&r1=43987&r2=44023&rev=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/arm/kdsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd64/arm/kdarm.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -1,7 +1,7 @@
 /*
  * PROJECT:         ReactOS Kernel
  * LICENSE:         BSD - See COPYING.ARM in the top level directory
- * FILE:            ntoskrnl/kd64/arm/kdsup.c
+ * FILE:            ntoskrnl/kd64/arm/kdarm.c
  * PURPOSE:         KD support routines for ARM
  * PROGRAMMERS:     ReactOS Portable Systems Group
  */
@@ -149,3 +149,12 @@
     while (TRUE);
     return STATUS_UNSUCCESSFUL;
 }
+
+NTSTATUS
+NTAPI
+KdpAllowDisable(VOID)
+{
+    UNIMPLEMENTED;
+    while (TRUE);
+    return STATUS_ACCESS_DENIED;
+}

Removed: trunk/reactos/ntoskrnl/kd64/arm/kdsup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/arm/kdsup.c?rev=44022&view=auto
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/arm/kdsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd64/arm/kdsup.c (removed)
@@ -1,151 +1,0 @@
-/*
- * PROJECT:         ReactOS Kernel
- * LICENSE:         BSD - See COPYING.ARM in the top level directory
- * FILE:            ntoskrnl/kd64/arm/kdsup.c
- * PURPOSE:         KD support routines for ARM
- * PROGRAMMERS:     ReactOS Portable Systems Group
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ntoskrnl.h>
-#define NDEBUG
-#include <debug.h>
-
-#undef UNIMPLEMENTED
-#define UNIMPLEMENTED KdpDprintf("%s is unimplemented\n", __FUNCTION__)
-
-/* FUNCTIONS *****************************************************************/
-
-VOID
-NTAPI
-KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State,
-                  IN PCONTEXT Context)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-}
-
-VOID
-NTAPI
-KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange,
-                   IN PCONTEXT Context)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadMsr(IN ULONG Msr,
-              OUT PLARGE_INTEGER MsrValue)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteMsr(IN ULONG Msr,
-               IN PLARGE_INTEGER MsrValue)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadBusData(IN ULONG BusDataType,
-                  IN ULONG BusNumber,
-                  IN ULONG SlotNumber,
-                  IN ULONG Offset,
-                  IN PVOID Buffer,
-                  IN ULONG Length,
-                  OUT PULONG ActualLength)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteBusData(IN ULONG BusDataType,
-                   IN ULONG BusNumber,
-                   IN ULONG SlotNumber,
-                   IN ULONG Offset,
-                   IN PVOID Buffer,
-                   IN ULONG Length,
-                   OUT PULONG ActualLength)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadControlSpace(IN ULONG Processor,
-                       IN ULONG64 BaseAddress,
-                       IN PVOID Buffer,
-                       IN ULONG Length,
-                       OUT PULONG ActualLength)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteControlSpace(IN ULONG Processor,
-                        IN ULONG64 BaseAddress,
-                        IN PVOID Buffer,
-                        IN ULONG Length,
-                        OUT PULONG ActualLength)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadIoSpace(IN ULONG InterfaceType,
-                  IN ULONG BusNumber,
-                  IN ULONG AddressSpace,
-                  IN ULONG64 IoAddress,
-                  IN PVOID DataValue,
-                  IN ULONG DataSize,
-                  OUT PULONG ActualDataSize)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteIoSpace(IN ULONG InterfaceType,
-                   IN ULONG BusNumber,
-                   IN ULONG AddressSpace,
-                   IN ULONG64 IoAddress,
-                   IN PVOID DataValue,
-                   IN ULONG DataSize,
-                   OUT PULONG ActualDataSize)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysCheckLowMemory(IN ULONG Flags)
-{
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_UNSUCCESSFUL;
-}

Removed: trunk/reactos/ntoskrnl/kd64/i386/kdsup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/i386/kdsup.c?rev=44022&view=auto
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/i386/kdsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd64/i386/kdsup.c (removed)
@@ -1,423 +1,0 @@
-/*
- * PROJECT:         ReactOS Kernel
- * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            ntoskrnl/kd64/i386/kdsup.c
- * PURPOSE:         KD support routines for x86
- * PROGRAMMERS:     Alex Ionescu (alex.ionescu at reactos.org)
- *                  Stefan Ginsberg (stefan.ginsberg at reactos.org)
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ntoskrnl.h>
-#define NDEBUG
-#include <debug.h>
-
-/* FUNCTIONS *****************************************************************/
-
-VOID
-NTAPI
-KdpGetStateChange(IN PDBGKD_MANIPULATE_STATE64 State,
-                  IN PCONTEXT Context)
-{
-    PKPRCB Prcb;
-    ULONG i;
-
-    /* Check for success */
-    if (NT_SUCCESS(State->u.Continue2.ContinueStatus))
-    {
-        /* Check if we're tracing */
-        if (State->u.Continue2.ControlSet.TraceFlag)
-        {
-            /* Enable TF */
-            Context->EFlags |= EFLAGS_TF;
-        }
-        else
-        {
-            /* Remove it */
-            Context->EFlags &= ~EFLAGS_TF;
-        }
-
-        /* Loop all processors */
-        for (i = 0; i < KeNumberProcessors; i++)
-        {
-            /* Get the PRCB and update DR7 and DR6 */
-            Prcb = KiProcessorBlock[i];
-            Prcb->ProcessorState.SpecialRegisters.KernelDr7 =
-                State->u.Continue2.ControlSet.Dr7;
-            Prcb->ProcessorState.SpecialRegisters.KernelDr6 = 0;
-        }
-
-        /* Check if we have new symbol information */
-        if (State->u.Continue2.ControlSet.CurrentSymbolStart != 1)
-        {
-            /* Update it */
-            KdpCurrentSymbolStart =
-                State->u.Continue2.ControlSet.CurrentSymbolStart;
-            KdpCurrentSymbolEnd= State->u.Continue2.ControlSet.CurrentSymbolEnd;
-        }
-    }
-}
-
-VOID
-NTAPI
-KdpSetContextState(IN PDBGKD_ANY_WAIT_STATE_CHANGE WaitStateChange,
-                   IN PCONTEXT Context)
-{
-    PKPRCB Prcb = KeGetCurrentPrcb();
-
-    /* Copy i386 specific debug registers */
-    WaitStateChange->ControlReport.Dr6 = Prcb->ProcessorState.SpecialRegisters.
-                                         KernelDr6;
-    WaitStateChange->ControlReport.Dr7 = Prcb->ProcessorState.SpecialRegisters.
-                                         KernelDr7;
-
-    /* Copy i386 specific segments */
-    WaitStateChange->ControlReport.SegCs = (USHORT)Context->SegCs;
-    WaitStateChange->ControlReport.SegDs = (USHORT)Context->SegDs;
-    WaitStateChange->ControlReport.SegEs = (USHORT)Context->SegEs;
-    WaitStateChange->ControlReport.SegFs = (USHORT)Context->SegFs;
-
-    /* Copy EFlags */
-    WaitStateChange->ControlReport.EFlags = Context->EFlags;
-
-    /* Set Report Flags */
-    WaitStateChange->ControlReport.ReportFlags = REPORT_INCLUDES_SEGS;
-    if (WaitStateChange->ControlReport.SegCs == KGDT_R0_CODE)
-    {
-        WaitStateChange->ControlReport.ReportFlags |= REPORT_STANDARD_CS;
-    }
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadMsr(IN ULONG Msr,
-              OUT PLARGE_INTEGER MsrValue)
-{
-    /* Wrap this in SEH in case the MSR doesn't exist */
-    //_SEH2_TRY
-    {
-        /* Read from the MSR */
-        MsrValue->QuadPart = RDMSR(Msr);
-    }
-    //_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-    {
-        /* Invalid MSR */
-        //_SEH2_YIELD(return STATUS_NO_SUCH_DEVICE);
-    }
-    //_SEH2_END;
-
-    /* Success */
-    return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteMsr(IN ULONG Msr,
-               IN PLARGE_INTEGER MsrValue)
-{
-    /* Wrap this in SEH in case the MSR doesn't exist */
-    //_SEH2_TRY
-    {
-        /* Write to the MSR */
-        WRMSR(Msr, MsrValue->QuadPart);
-    }
-    //_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
-    {
-        /* Invalid MSR */
-        //_SEH2_YIELD(return STATUS_NO_SUCH_DEVICE);
-    }
-    //_SEH2_END;
-
-    /* Success */
-    return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadBusData(IN ULONG BusDataType,
-                  IN ULONG BusNumber,
-                  IN ULONG SlotNumber,
-                  IN ULONG Offset,
-                  IN PVOID Buffer,
-                  IN ULONG Length,
-                  OUT PULONG ActualLength)
-{
-    /* Just forward to HAL */
-    *ActualLength = HalGetBusDataByOffset(BusDataType,
-                                          BusNumber,
-                                          SlotNumber,
-                                          Buffer,
-                                          Offset,
-                                          Length);
-
-    /* Return status */
-    return *ActualLength != 0 ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteBusData(IN ULONG BusDataType,
-                   IN ULONG BusNumber,
-                   IN ULONG SlotNumber,
-                   IN ULONG Offset,
-                   IN PVOID Buffer,
-                   IN ULONG Length,
-                   OUT PULONG ActualLength)
-{
-    /* Just forward to HAL */
-    *ActualLength = HalSetBusDataByOffset(BusDataType,
-                                          BusNumber,
-                                          SlotNumber,
-                                          Buffer,
-                                          Offset,
-                                          Length);
-
-    /* Return status */
-    return *ActualLength != 0 ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadControlSpace(IN ULONG Processor,
-                       IN ULONG64 BaseAddress,
-                       IN PVOID Buffer,
-                       IN ULONG Length,
-                       OUT PULONG ActualLength)
-{
-    PVOID ControlStart;
-    ULONG RealLength;
-
-    /* Make sure that this is a valid request */
-    if ((BaseAddress < sizeof(KPROCESSOR_STATE)) &&
-        (Processor < KeNumberProcessors))
-    {
-        /* Get the actual length */
-        RealLength = sizeof(KPROCESSOR_STATE) - (ULONG_PTR)BaseAddress;
-        if (RealLength < Length) Length = RealLength;
-
-        /* Set the proper address */
-        ControlStart = (PVOID)((ULONG_PTR)BaseAddress +
-                               (ULONG_PTR)&KiProcessorBlock[Processor]->
-                                           ProcessorState);
-
-        /* Read the control state safely */
-        return KdpCopyMemoryChunks((ULONG_PTR)Buffer,
-                                   ControlStart,
-                                   Length,
-                                   0,
-                                   MMDBG_COPY_UNSAFE | MMDBG_COPY_WRITE,
-                                   ActualLength);
-    }
-    else
-    {
-        /* Invalid request */
-        *ActualLength = 0;
-        return STATUS_UNSUCCESSFUL;
-    }
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteControlSpace(IN ULONG Processor,
-                        IN ULONG64 BaseAddress,
-                        IN PVOID Buffer,
-                        IN ULONG Length,
-                        OUT PULONG ActualLength)
-{
-    PVOID ControlStart;
-
-    /* Make sure that this is a valid request */
-    if (((BaseAddress + Length) <= sizeof(KPROCESSOR_STATE)) &&
-        (Processor < KeNumberProcessors))
-    {
-        /* Set the proper address */
-        ControlStart = (PVOID)((ULONG_PTR)BaseAddress +
-                               (ULONG_PTR)&KiProcessorBlock[Processor]->
-                                           ProcessorState);
-
-        /* Write the control state safely */
-        return KdpCopyMemoryChunks((ULONG_PTR)Buffer,
-                                   ControlStart,
-                                   Length,
-                                   0,
-                                   MMDBG_COPY_UNSAFE,
-                                   ActualLength);
-    }
-    else
-    {
-        /* Invalid request */
-        *ActualLength = 0;
-        return STATUS_UNSUCCESSFUL;
-    }
-}
-
-NTSTATUS
-NTAPI
-KdpSysReadIoSpace(IN ULONG InterfaceType,
-                  IN ULONG BusNumber,
-                  IN ULONG AddressSpace,
-                  IN ULONG64 IoAddress,
-                  IN PVOID DataValue,
-                  IN ULONG DataSize,
-                  OUT PULONG ActualDataSize)
-{
-    NTSTATUS Status;
-
-    /* Verify parameters */
-    if ((InterfaceType != Isa) ||
-        (BusNumber != 0) ||
-        (AddressSpace != 1))
-    {
-        /* Fail, we don't support this */
-        *ActualDataSize = 0;
-        return STATUS_UNSUCCESSFUL;
-    }
-
-    /* Check the size */
-    switch (DataSize)
-    {
-        case sizeof(UCHAR):
-
-            /* Read 1 byte */
-            *(PUCHAR)DataValue =
-                READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)IoAddress);
-            *ActualDataSize = sizeof(UCHAR);
-            Status = STATUS_SUCCESS;
-            break;
-
-        case sizeof(USHORT):
-
-            /* Make sure the address is aligned */
-            if ((IoAddress & (sizeof(USHORT) - 1)) != 0)
-            {
-                /* It isn't, bail out */
-                *ActualDataSize = 0;
-                Status = STATUS_DATATYPE_MISALIGNMENT;
-                break;
-            }
-
-            /* Read 2 bytes */
-            *(PUSHORT)DataValue =
-                READ_PORT_USHORT((PUSHORT)(ULONG_PTR)IoAddress);
-            *ActualDataSize = sizeof(USHORT);
-            Status = STATUS_SUCCESS;
-            break;
-
-        case sizeof(ULONG):
-
-            /* Make sure the address is aligned */
-            if ((IoAddress & (sizeof(ULONG) - 1)) != 0)
-            {
-                /* It isn't, bail out */
-                *ActualDataSize = 0;
-                Status = STATUS_DATATYPE_MISALIGNMENT;
-                break;
-            }
-
-            /* Read 4 bytes */
-            *(PULONG)DataValue =
-                READ_PORT_ULONG((PULONG)(ULONG_PTR)IoAddress);
-            *ActualDataSize = sizeof(ULONG);
-            Status = STATUS_SUCCESS;
-            break;
-
-        default:
-
-            /* Invalid size, fail */
-            *ActualDataSize = 0;
-            Status = STATUS_INVALID_PARAMETER;
-    }
-
-    /* Return status */
-    return Status;
-}
-
-NTSTATUS
-NTAPI
-KdpSysWriteIoSpace(IN ULONG InterfaceType,
-                   IN ULONG BusNumber,
-                   IN ULONG AddressSpace,
-                   IN ULONG64 IoAddress,
-                   IN PVOID DataValue,
-                   IN ULONG DataSize,
-                   OUT PULONG ActualDataSize)
-{
-    NTSTATUS Status;
-
-    /* Verify parameters */
-    if ((InterfaceType != Isa) ||
-        (BusNumber != 0) ||
-        (AddressSpace != 1))
-    {
-        /* Fail, we don't support this */
-        *ActualDataSize = 0;
-        return STATUS_UNSUCCESSFUL;
-    }
-
-    /* Check the size */
-    switch (DataSize)
-    {
-        case sizeof(UCHAR):
-
-            /* Write 1 byte */
-            WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)IoAddress,
-                             *(PUCHAR)DataValue);
-            *ActualDataSize = sizeof(UCHAR);
-            Status = STATUS_SUCCESS;
-            break;
-
-        case sizeof(USHORT):
-
-            /* Make sure the address is aligned */
-            if ((IoAddress & (sizeof(USHORT) - 1)) != 0)
-            {
-                /* It isn't, bail out */
-                *ActualDataSize = 0;
-                Status = STATUS_DATATYPE_MISALIGNMENT;
-                break;
-            }
-
-            /* Write 2 bytes */
-            WRITE_PORT_USHORT((PUSHORT)(ULONG_PTR)IoAddress,
-                             *(PUSHORT)DataValue);
-            *ActualDataSize = sizeof(USHORT);
-            Status = STATUS_SUCCESS;
-            break;
-
-        case sizeof(ULONG):
-
-            /* Make sure the address is aligned */
-            if ((IoAddress & (sizeof(ULONG) - 1)) != 0)
-            {
-                /* It isn't, bail out */
-                *ActualDataSize = 0;
-                Status = STATUS_DATATYPE_MISALIGNMENT;
-                break;
-            }
-
-            /* Write 4 bytes */
-            WRITE_PORT_ULONG((PULONG)(ULONG_PTR)IoAddress,
-                             *(PULONG)DataValue);
-            *ActualDataSize = sizeof(ULONG);
-            Status = STATUS_SUCCESS;
-            break;
-
-        default:
-
-            /* Invalid size, fail */
-            *ActualDataSize = 0;
-            Status = STATUS_INVALID_PARAMETER;
-    }
-
-    /* Return status */
-    return Status;
-}
-
-NTSTATUS
-NTAPI
-KdpSysCheckLowMemory(IN ULONG Flags)
-{
-    /* Stubbed as we don't support PAE */
-    return STATUS_UNSUCCESSFUL;
-}

Copied: trunk/reactos/ntoskrnl/kd64/i386/kdx86.c (from r43987, trunk/reactos/ntoskrnl/kd64/i386/kdsup.c)
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/i386/kdx86.c?p2=trunk/reactos/ntoskrnl/kd64/i386/kdx86.c&p1=trunk/reactos/ntoskrnl/kd64/i386/kdsup.c&r1=43987&r2=44023&rev=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/i386/kdsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd64/i386/kdx86.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -1,7 +1,7 @@
 /*
  * PROJECT:         ReactOS Kernel
  * LICENSE:         GPL - See COPYING in the top level directory
- * FILE:            ntoskrnl/kd64/i386/kdsup.c
+ * FILE:            ntoskrnl/kd64/i386/kdx86.c
  * PURPOSE:         KD support routines for x86
  * PROGRAMMERS:     Alex Ionescu (alex.ionescu at reactos.org)
  *                  Stefan Ginsberg (stefan.ginsberg at reactos.org)
@@ -421,3 +421,28 @@
     /* Stubbed as we don't support PAE */
     return STATUS_UNSUCCESSFUL;
 }
+
+NTSTATUS
+NTAPI
+KdpAllowDisable(VOID)
+{
+    LONG i;
+    ULONG Dr7;
+
+    /* Loop every processor */
+    for (i = 0; i < KeNumberProcessors; i++)
+    {
+        /* Get its DR7 */
+        Dr7 =  KiProcessorBlock[i]->ProcessorState.SpecialRegisters.KernelDr7;
+
+        /* Check if any processor breakpoints are active */
+        if (Dr7 != 0)
+        {
+            /* We can't allow running without a debugger then */
+            return STATUS_ACCESS_DENIED;
+        }
+    }
+
+    /* No processor breakpoints; allow disabling the debugger */
+    return STATUS_SUCCESS;
+}

Modified: trunk/reactos/ntoskrnl/kd64/kdapi.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/kdapi.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/kdapi.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd64/kdapi.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -112,8 +112,17 @@
         }
         else
         {
-            /* FIXME: Check if it's session space */
-            Memory->AddressSpace = DBGKD_QUERY_MEMORY_KERNEL;
+            /* Check if it's session space */
+            if (MmIsSessionAddress((PVOID)(ULONG_PTR)Memory->Address))
+            {
+                /* It is */
+                Memory->AddressSpace = DBGKD_QUERY_MEMORY_SESSION;
+            }
+            else
+            {
+                /* Not session space but some other kernel memory */
+                Memory->AddressSpace = DBGKD_QUERY_MEMORY_KERNEL;
+            }
         }
 
         /* Set flags */
@@ -1642,28 +1651,12 @@
     return KeQueryPerformanceCounter(NULL);
 }
 
-NTSTATUS
-NTAPI
-KdpAllowDisable(VOID)
-{
-    /* Check if we are on MP */
-    if (KeNumberProcessors > 1)
-    {
-        /* TODO */
-        KdpDprintf("KdpAllowDisable: SMP UNHANDLED\n");
-        while (TRUE);
-    }
-
-    /* Allow disable */
-    return STATUS_SUCCESS;
-}
-
 BOOLEAN
 NTAPI
 KdEnterDebugger(IN PKTRAP_FRAME TrapFrame,
                 IN PKEXCEPTION_FRAME ExceptionFrame)
 {
-    BOOLEAN Entered;
+    BOOLEAN Enable;
 
     /* Check if we have a trap frame */
     if (TrapFrame)
@@ -1683,7 +1676,7 @@
     KeGetCurrentPrcb()->DebuggerSavedIRQL = KeGetCurrentIrql();
 
     /* Freeze all CPUs */
-    Entered = KeFreezeExecution(TrapFrame, ExceptionFrame);
+    Enable = KeFreezeExecution(TrapFrame, ExceptionFrame);
 
     /* Lock the port, save the state and set debugger entered */
     KdpPortLocked = KeTryToAcquireSpinLockAtDpcLevel(&KdpDebuggerLock);
@@ -1707,13 +1700,13 @@
     /* Make sure we acquired the port */
     if (!KdpPortLocked) KdpDprintf("Port lock was not acquired!\n");
 
-    /* Return enter state */
-    return Entered;
-}
-
-VOID
-NTAPI
-KdExitDebugger(IN BOOLEAN Entered)
+    /* Return if interrupts needs to be re-enabled */
+    return Enable;
+}
+
+VOID
+NTAPI
+KdExitDebugger(IN BOOLEAN Enable)
 {
     ULONG TimeSlip;
 
@@ -1722,7 +1715,7 @@
     if (KdpPortLocked) KdpPortUnlock();
 
     /* Unfreeze the CPUs */
-    KeThawExecution(Entered);
+    KeThawExecution(Enable);
 
     /* Compare time with the one from KdEnterDebugger */
     if (!KdTimerStop.QuadPart)
@@ -2048,7 +2041,7 @@
 NTAPI
 KdRefreshDebuggerNotPresent(VOID)
 {
-    BOOLEAN Entered, DebuggerNotPresent;
+    BOOLEAN Enable, DebuggerNotPresent;
 
     /* Check if the debugger is completely disabled */
     if (KdPitchDebugger)
@@ -2058,7 +2051,7 @@
     }
 
     /* Enter the debugger */
-    Entered = KdEnterDebugger(NULL, NULL);
+    Enable = KdEnterDebugger(NULL, NULL);
 
     /*
      * Attempt to send a string to the debugger to refresh the
@@ -2070,7 +2063,7 @@
     DebuggerNotPresent = KdDebuggerNotPresent;
 
     /* Exit the debugger and return the state */
-    KdExitDebugger(Entered);
+    KdExitDebugger(Enable);
     return DebuggerNotPresent;
 }
 

Modified: trunk/reactos/ntoskrnl/kd64/kdprint.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/kdprint.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/kdprint.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd64/kdprint.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -130,14 +130,14 @@
                  IN PKTRAP_FRAME TrapFrame,
                  IN PKEXCEPTION_FRAME ExceptionFrame)
 {
-    BOOLEAN Entered;
+    BOOLEAN Enable;
     PKPRCB Prcb = KeGetCurrentPrcb();
 
     /* Check if we need to do anything */
     if ((PreviousMode != KernelMode) || (KdDebuggerNotPresent)) return;
 
     /* Enter the debugger */
-    Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
+    Enable = KdEnterDebugger(TrapFrame, ExceptionFrame);
 
     /* Save the CPU Control State and save the context */
     KiSaveProcessorControlState(&Prcb->ProcessorState);
@@ -157,7 +157,7 @@
     KiRestoreProcessorControlState(&Prcb->ProcessorState);
 
     /* Exit the debugger and return */
-    KdExitDebugger(Entered);
+    KdExitDebugger(Enable);
 }
 
 VOID
@@ -170,14 +170,14 @@
           IN PKTRAP_FRAME TrapFrame,
           IN PKEXCEPTION_FRAME ExceptionFrame)
 {
-    BOOLEAN Entered;
+    BOOLEAN Enable;
     PKPRCB Prcb = KeGetCurrentPrcb();
 
     /* Check if we need to do anything */
     if ((PreviousMode != KernelMode) || (KdDebuggerNotPresent)) return;
 
     /* Enter the debugger */
-    Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
+    Enable = KdEnterDebugger(TrapFrame, ExceptionFrame);
 
     /* Save the CPU Control State and save the context */
     KiSaveProcessorControlState(&Prcb->ProcessorState);
@@ -198,7 +198,7 @@
     KiRestoreProcessorControlState(&Prcb->ProcessorState);
 
     /* Exit the debugger and return */
-    KdExitDebugger(Entered);
+    KdExitDebugger(Enable);
 }
 
 USHORT
@@ -212,7 +212,7 @@
           IN PKEXCEPTION_FRAME ExceptionFrame)
 {
     STRING PromptBuffer, ResponseBuffer;
-    BOOLEAN Entered, Resend;
+    BOOLEAN Enable, Resend;
 
     /* Normalize the lengths */
     PromptLength = min(PromptLength, 512);
@@ -235,7 +235,7 @@
     //KdLogDbgPrint(&PromptBuffer);
 
     /* Enter the debugger */
-    Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
+    Enable = KdEnterDebugger(TrapFrame, ExceptionFrame);
 
     /* Enter prompt loop */
     do
@@ -247,7 +247,7 @@
     } while (Resend);
 
     /* Exit the debugger */
-    KdExitDebugger(Entered);
+    KdExitDebugger(Enable);
 
     /* Return the number of characters received */
     return ResponseBuffer.Length;
@@ -262,14 +262,14 @@
          IN KPROCESSOR_MODE PreviousMode,
          IN PKTRAP_FRAME TrapFrame,
          IN PKEXCEPTION_FRAME ExceptionFrame,
-         OUT PBOOLEAN Status)
+         OUT PBOOLEAN Handled)
 {
     NTSTATUS ReturnStatus;
-    BOOLEAN Entered;
+    BOOLEAN Enable;
     STRING OutputString;
 
     /* Assume failure */
-    *Status = FALSE;
+    *Handled = FALSE;
 
     /* Validate the mask */
     if (Level < 32) Level = 1 << Level;
@@ -278,7 +278,7 @@
         !(*KdComponentTable[ComponentId] & Level)))
     {
         /* Mask validation failed */
-        *Status = TRUE;
+        *Handled = TRUE;
         return STATUS_SUCCESS;
     }
 
@@ -302,12 +302,12 @@
     if (KdDebuggerNotPresent)
     {
         /* Fail */
-        *Status = TRUE;
+        *Handled = TRUE;
         return STATUS_DEVICE_NOT_CONNECTED;
     }
 
     /* Enter the debugger */
-    Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
+    Enable = KdEnterDebugger(TrapFrame, ExceptionFrame);
 
     /* Print the string */
     if (KdpPrintString(&OutputString))
@@ -322,8 +322,8 @@
     }
 
     /* Exit the debugger and return */
-    KdExitDebugger(Entered);
-    *Status = TRUE;
+    KdExitDebugger(Enable);
+    *Handled = TRUE;
     return ReturnStatus;
 }
 

Modified: trunk/reactos/ntoskrnl/kd64/kdtrap.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/kdtrap.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/kdtrap.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd64/kdtrap.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -22,20 +22,24 @@
 //
 // EBX/EDI on x86
 //
-#define KdpGetFirstParameter(Context)  ((Context)->Ebx)
-#define KdpGetSecondParameter(Context) ((Context)->Edi)
+#define KdpGetParameterThree(Context)  ((Context)->Ebx)
+#define KdpGetParameterFour(Context)   ((Context)->Edi)
 
 #elif defined(_AMD64_)
 
 //
 // R8/R9 on AMD64
 //
-#define KdpGetFirstParameter(Context)  ((Context)->R8)
-#define KdpGetSecondParameter(Context) ((Context)->R9)
+#define KdpGetParameterThree(Context)  ((Context)->R8)
+#define KdpGetParameterFour(Context)   ((Context)->R9)
 
 #elif defined(_ARM_)
 
-#error Yo Ninjas!
+//
+// R3/R4 on ARM
+//
+#define KdpGetParameterThree(Context)  ((Context)->R3)
+#define KdpGetParameterFour(Context)   ((Context)->R4)
 
 #else
 #error Unsupported Architecture
@@ -52,7 +56,7 @@
           IN KPROCESSOR_MODE PreviousMode,
           IN BOOLEAN SecondChanceException)
 {
-    BOOLEAN Entered, Status;
+    BOOLEAN Enable, Handled;
     PKPRCB Prcb;
     NTSTATUS ExceptionCode = ExceptionRecord->ExceptionCode;
 
@@ -95,7 +99,7 @@
     }
 
     /* Enter the debugger */
-    Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
+    Enable = KdEnterDebugger(TrapFrame, ExceptionFrame);
 
     /*
      * Get the KPRCB and save the CPU Control State manually instead of
@@ -108,10 +112,10 @@
                   sizeof(CONTEXT));
 
     /* Report the new state */
-    Status = KdpReportExceptionStateChange(ExceptionRecord,
-                                           &Prcb->ProcessorState.
-                                           ContextFrame,
-                                           SecondChanceException);
+    Handled = KdpReportExceptionStateChange(ExceptionRecord,
+                                            &Prcb->ProcessorState.
+                                            ContextFrame,
+                                            SecondChanceException);
 
     /* Now restore the processor state, manually again. */
     RtlCopyMemory(ContextRecord,
@@ -120,9 +124,9 @@
     KiRestoreProcessorControlState(&Prcb->ProcessorState);
 
     /* Exit the debugger and clear the CTRL-C state */
-    KdExitDebugger(Entered);
+    KdExitDebugger(Enable);
     KdpControlCPressed = FALSE;
-    return Status;
+    return Handled;
 }
 
 BOOLEAN
@@ -136,7 +140,7 @@
 {
     BOOLEAN Unload = FALSE;
     ULONG_PTR ProgramCounter;
-    BOOLEAN Status = FALSE;
+    BOOLEAN Handled;
     NTSTATUS ReturnStatus;
     USHORT ReturnLength;
 
@@ -158,8 +162,8 @@
             case BREAKPOINT_PRINT:
 
                 /* Call the worker routine */
-                ReturnStatus = KdpPrint((ULONG)KdpGetFirstParameter(ContextRecord),
-                                        (ULONG)KdpGetSecondParameter(ContextRecord),
+                ReturnStatus = KdpPrint((ULONG)KdpGetParameterThree(ContextRecord),
+                                        (ULONG)KdpGetParameterFour(ContextRecord),
                                         (LPSTR)ExceptionRecord->
                                         ExceptionInformation[1],
                                         (USHORT)ExceptionRecord->
@@ -167,7 +171,7 @@
                                         PreviousMode,
                                         TrapFrame,
                                         ExceptionFrame,
-                                        &Status);
+                                        &Handled);
 
                 /* Update the return value for the caller */
                 KeSetContextReturnRegister(ContextRecord, ReturnStatus);
@@ -181,12 +185,12 @@
                                          ExceptionInformation[1],
                                          (USHORT)ExceptionRecord->
                                          ExceptionInformation[2],
-                                         (LPSTR)KdpGetFirstParameter(ContextRecord),
-                                         (USHORT)KdpGetSecondParameter(ContextRecord),
+                                         (LPSTR)KdpGetParameterThree(ContextRecord),
+                                         (USHORT)KdpGetParameterFour(ContextRecord),
                                          PreviousMode,
                                          TrapFrame,
                                          ExceptionFrame);
-                Status = TRUE;
+                Handled = TRUE;
 
                 /* Update the return value for the caller */
                 KeSetContextReturnRegister(ContextRecord, ReturnLength);
@@ -211,7 +215,7 @@
                           ContextRecord,
                           TrapFrame,
                           ExceptionFrame);
-                Status = TRUE;
+                Handled = TRUE;
                 break;
 
             /* DbgCommandString */
@@ -226,12 +230,13 @@
                                  ContextRecord,
                                  TrapFrame,
                                  ExceptionFrame);
-                Status = TRUE;
+                Handled = TRUE;
 
             /* Anything else, do nothing */
             default:
 
-                /* Get out */
+                /* Invalid debug service! Don't handle this! */
+                Handled = FALSE;
                 break;
         }
 
@@ -249,16 +254,16 @@
     else
     {
         /* Call the worker routine */
-        Status = KdpReport(TrapFrame,
-                           ExceptionFrame,
-                           ExceptionRecord,
-                           ContextRecord,
-                           PreviousMode,
-                           SecondChanceException);
+        Handled = KdpReport(TrapFrame,
+                            ExceptionFrame,
+                            ExceptionRecord,
+                            ContextRecord,
+                            PreviousMode,
+                            SecondChanceException);
     }
 
     /* Return TRUE or FALSE to caller */
-    return Status;
+    return Handled;
 }
 
 BOOLEAN

Modified: trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kdbg/kdb_symbols.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -529,10 +529,9 @@
         LdrEntry = CONTAINING_RECORD(PsLoadedModuleList.Flink, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
         KdbSymProcessSymbols(LdrEntry);
 
-        /* Also load them for HAL.DLL.
-           This module has no fixed position, so search for it. */
-        if(KdbpSymFindModule(NULL, L"HAL.DLL", -1, &LdrEntry))
-            KdbSymProcessSymbols(LdrEntry);
+        /* Also load them for HAL.DLL. */
+        LdrEntry = CONTAINING_RECORD(PsLoadedModuleList.Flink->Flink, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
+        KdbSymProcessSymbols(LdrEntry);
 
         KdbpSymbolsInitialized = TRUE;
     }

Modified: trunk/reactos/ntoskrnl/ke/freeldr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/freeldr.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/freeldr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/freeldr.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -9,10 +9,10 @@
 /* INCLUDES *****************************************************************/
 
 #include <ntoskrnl.h>
-//#define NDEBUG
+#define NDEBUG
 #include <debug.h>
 
-#ifdef _M_PPC
+#if defined(_PPC_)
 #include <ppcmmu/mmu.h>
 #define KERNEL_RVA(x) RVA(x,0x80800000)
 #define KERNEL_DESCRIPTOR_PAGE(x) (((ULONG_PTR)x + KernelBase) >> PAGE_SHIFT)
@@ -31,7 +31,6 @@
 
 /* FreeLDR Loader Data */
 PROS_LOADER_PARAMETER_BLOCK KeRosLoaderBlock;
-BOOLEAN AcpiTableDetected = FALSE;
 ADDRESS_RANGE KeMemoryMap[64];
 ULONG KeMemoryMapRangeCount;
 
@@ -66,8 +65,35 @@
 ULONG NumberDescriptors = 0;
 MEMORY_DESCRIPTOR MDArray[60] = { { 0, 0, 0 }, };
 
+#if defined(_X86_)
+
+/* The Boot TSS */
+KTSS KiBootTss;
+
 /* Old boot style IDT */
-KIDTENTRY KiHackIdt[256];
+KIDTENTRY KiBootIdt[256];
+
+/* The Boot GDT */
+KGDTENTRY KiBootGdt[256] =
+{
+    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}},       /* KGDT_NULL */
+    {0xffff, 0x0000, {{0x00, 0x9b, 0xcf, 0x00}}},       /* KGDT_R0_CODE */
+    {0xffff, 0x0000, {{0x00, 0x93, 0xcf, 0x00}}},       /* KGDT_R0_DATA */
+    {0xffff, 0x0000, {{0x00, 0xfb, 0xcf, 0x00}}},       /* KGDT_R3_CODE */
+    {0xffff, 0x0000, {{0x00, 0xf3, 0xcf, 0x00}}},       /* KGDT_R3_DATA*/
+    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}},       /* KGDT_TSS */
+    {0x0001, 0xf000, {{0xdf, 0x93, 0xc0, 0xff}}},       /* KGDT_R0_PCR */
+    {0x0fff, 0x0000, {{0x00, 0xf3, 0x40, 0x00}}},       /* KGDT_R3_TEB */
+    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}},       /* KGDT_UNUSED */
+    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}},       /* KGDT_LDT */
+    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}},       /* KGDT_DF_TSS */
+    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}}        /* KGDT_NMI_TSS */
+};
+
+/* GDT Descriptor */
+KDESCRIPTOR KiGdtDescriptor = {0, sizeof(KiBootGdt) - 1, (ULONG)KiBootGdt};
+
+#endif
 
 /* FUNCTIONS *****************************************************************/
 
@@ -465,7 +491,7 @@
     /* If anything failed until now, return error code */
     if (Status != STATUS_SUCCESS) return Status;
 
-#ifdef _M_IX86
+#if defined(_X86_)
     /* Set the top 16MB region as reserved */
     Status = KiRosConfigureArcDescriptor(0xFC0, 0x1000, MemorySpecialMemory);
     if (Status != STATUS_SUCCESS) return Status;
@@ -492,6 +518,7 @@
     return Status;
 }
 
+#if defined(_X86_)
 VOID
 NTAPI
 KiRosBuildReservedMemoryMap(VOID)
@@ -560,6 +587,7 @@
         }
     }
 }
+#endif
 
 VOID
 NTAPI
@@ -917,12 +945,9 @@
     WCHAR PathSetup[] = L"\\SystemRoot\\";
     CHAR DriverNameLow[256];
     ULONG Base;
-#ifdef _M_PPC
+#if defined(_PPC_)
     ULONG KernelBase = RosLoaderBlock->ModsAddr[0].ModStart;
 #endif
-
-    /* First get some kernel-loader globals */
-    AcpiTableDetected = (RosLoaderBlock->Flags & MB_FLAGS_ACPI_TABLE) ? TRUE : FALSE;
 
     /* Set the NT Loader block and initialize it */
     *NtLoaderBlock = KeLoaderBlock = LoaderBlock = &BldrLoaderBlock;
@@ -949,7 +974,7 @@
     /* Build entries for ReactOS memory ranges, which uses ARC Descriptors */
     KiRosBuildOsMemoryMap();
 
-#ifdef _M_IX86
+#if defined(_X86_)
     /* Build entries for the reserved map, which uses ARC Descriptors */
     KiRosBuildReservedMemoryMap();
 #endif
@@ -966,7 +991,7 @@
         ModStart = (PVOID)RosEntry->ModStart;
         ModSize = RosEntry->ModEnd - (ULONG_PTR)ModStart;
 
-#ifdef _M_PPC
+#if defined(_PPC_)
         ModStart -= KernelBase;
 #endif
 
@@ -1073,7 +1098,7 @@
                                       &Base);
         }
 
-#ifdef _M_PPC
+#if defined(_PPC_)
         ModStart += 0x80800000;
 #endif
 
@@ -1138,6 +1163,33 @@
         LdrEntry->Flags = LDRP_IMAGE_DLL |
                           LDRP_ENTRY_PROCESSED;
         if (RosEntry->Reserved) LdrEntry->Flags |= LDRP_ENTRY_INSERTED;
+
+        /* Check if this is HAL */
+        if (!(_stricmp(DriverName, "hal.dll")))
+        {
+            /* Check if there is a second entry already */
+            if (LoaderBlock->LoadOrderListHead.Flink->Flink !=
+                &LoaderBlock->LoadOrderListHead)
+            {
+                PLIST_ENTRY OldSecondEntry;
+
+                /* Get the second entry */
+                OldSecondEntry =
+                    LoaderBlock->LoadOrderListHead.Flink->Flink;
+
+                /* Set up our entry correctly */
+                LdrEntry->InLoadOrderLinks.Flink = OldSecondEntry;
+                LdrEntry->InLoadOrderLinks.Blink = OldSecondEntry->Blink;
+
+                /* Make the first entry (always the kernel) point to us */
+                LoaderBlock->LoadOrderListHead.Flink->Flink =
+                    &LdrEntry->InLoadOrderLinks;
+
+                /* Make the old entry point back to us and continue looping */
+                OldSecondEntry->Blink = &LdrEntry->InLoadOrderLinks;
+                continue;
+            }
+        }
 
         /* Insert it into the loader block */
         InsertTailList(&LoaderBlock->LoadOrderListHead,
@@ -1186,6 +1238,13 @@
     /* Now convert to pages */
     LoaderBlock->Extension->LoaderPagesSpanned /= PAGE_SIZE;
 
+    /* Check if FreeLdr detected a ACPI table */
+    if (RosLoaderBlock->Flags & MB_FLAGS_ACPI_TABLE)
+    {
+        /* Set the pointer to something for compatibility */
+        LoaderBlock->Extension->AcpiTable = (PVOID)1;
+    }
+
     /* Now setup the setup block if we have one */
     if (LoaderBlock->SetupLdrBlock)
     {
@@ -1266,15 +1325,15 @@
 {
     PLOADER_PARAMETER_BLOCK NtLoaderBlock;
     ULONG size, i = 0, *ent;
-#if defined(_M_IX86)
+#if defined(_X86_)
     PKTSS Tss;
     PKGDTENTRY TssEntry;
     KDESCRIPTOR IdtDescriptor;
 
     __sidt(&IdtDescriptor.Limit);
-    RtlCopyMemory(KiHackIdt, (PVOID)IdtDescriptor.Base, IdtDescriptor.Limit + 1);
-    IdtDescriptor.Base = (ULONG)&KiHackIdt;
-    IdtDescriptor.Limit = sizeof(KiHackIdt) - 1;
+    RtlCopyMemory(KiBootIdt, (PVOID)IdtDescriptor.Base, IdtDescriptor.Limit + 1);
+    IdtDescriptor.Base = (ULONG)&KiBootIdt;
+    IdtDescriptor.Limit = sizeof(KiBootIdt) - 1;
 
     /* Load the GDT and IDT */
     Ke386SetGlobalDescriptorTable(&KiGdtDescriptor.Limit);

Modified: trunk/reactos/ntoskrnl/ke/i386/cpu.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/cpu.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/cpu.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/cpu.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -14,34 +14,11 @@
 
 /* GLOBALS *******************************************************************/
 
-/* The Boot TSS */
-KTSS KiBootTss;
-
 /* The TSS to use for Double Fault Traps (INT 0x9) */
 UCHAR KiDoubleFaultTSS[KTSS_IO_MAPS];
 
 /* The TSS to use for NMI Fault Traps (INT 0x2) */
 UCHAR KiNMITSS[KTSS_IO_MAPS];
-
-/* The Boot GDT */
-KGDTENTRY KiBootGdt[256] =
-{
-    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}},       /* KGDT_NULL */
-    {0xffff, 0x0000, {{0x00, 0x9b, 0xcf, 0x00}}},       /* KGDT_R0_CODE */
-    {0xffff, 0x0000, {{0x00, 0x93, 0xcf, 0x00}}},       /* KGDT_R0_DATA */
-    {0xffff, 0x0000, {{0x00, 0xfb, 0xcf, 0x00}}},       /* KGDT_R3_CODE */
-    {0xffff, 0x0000, {{0x00, 0xf3, 0xcf, 0x00}}},       /* KGDT_R3_DATA*/
-    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}},       /* KGDT_TSS */
-    {0x0001, 0xf000, {{0xdf, 0x93, 0xc0, 0xff}}},       /* KGDT_R0_PCR */
-    {0x0fff, 0x0000, {{0x00, 0xf3, 0x40, 0x00}}},       /* KGDT_R3_TEB */
-    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}},       /* KGDT_UNUSED */
-    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}},       /* KGDT_LDT */
-    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}},       /* KGDT_DF_TSS */
-    {0x0000, 0x0000, {{0x00, 0x00, 0x00, 0x00}}}        /* KGDT_NMI_TSS */
-};
-
-/* GDT Descriptor */
-KDESCRIPTOR KiGdtDescriptor = {0, sizeof(KiBootGdt) - 1, (ULONG)KiBootGdt};
 
 /* CPU Features and Flags */
 ULONG KeI386CpuType;

Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/exp.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/exp.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/exp.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -53,7 +53,6 @@
 {
     ULONG i;
     USHORT FlippedSelector;
-    extern KIDTENTRY KiIdt[MAXIMUM_IDTVECTOR];
 
     /* Loop the IDT */
     for (i = 0; i <= MAXIMUM_IDTVECTOR; i++)

Modified: trunk/reactos/ntoskrnl/mm/mmdbg.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mmdbg.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mmdbg.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/mmdbg.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -19,6 +19,16 @@
 BOOLEAN MiDbgReadyForPhysical = FALSE;
 
 /* FUNCTIONS ******************************************************************/
+
+BOOLEAN
+NTAPI
+MmIsSessionAddress(IN PVOID Address)
+{
+    //
+    // No session space support yet
+    //
+    return FALSE;
+}
 
 PVOID
 NTAPI
@@ -217,6 +227,11 @@
                        TargetAddress);
             return STATUS_UNSUCCESSFUL;
         }
+
+        //
+        // No session space support yet
+        //
+        ASSERT(MmIsSessionAddress(TargetAddress) == FALSE);
     }
 
     //

Modified: trunk/reactos/ntoskrnl/mm/sysldr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/sysldr.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/sysldr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/sysldr.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -32,7 +32,6 @@
 KSPIN_LOCK PsLoadedModuleSpinLock;
 ULONG_PTR PsNtosImageBase;
 KMUTANT MmSystemLoadLock;
-extern ULONG NtGlobalFlag;
 
 PVOID MmUnloadedDrivers;
 PVOID MmLastUnloadedDrivers;
@@ -997,7 +996,7 @@
                 /* Now add the import name and null-terminate it */
                 RtlAppendStringToString((PSTRING)&DllName,
                                         (PSTRING)&NameString);
-                DllName.Buffer[(DllName.MaximumLength - 1) / 2] = UNICODE_NULL;
+                DllName.Buffer[(DllName.MaximumLength - 1) /  sizeof(WCHAR)] = UNICODE_NULL;
 
                 /* Load the image */
                 Status = MmLoadSystemImage(&DllName,
@@ -1220,7 +1219,7 @@
         /* Debug info */
         DPRINT("[Mm0]: Driver at: %p ending at: %p for module: %wZ\n",
                 LdrEntry->DllBase,
-                (ULONG_PTR)LdrEntry->DllBase+ LdrEntry->SizeOfImage,
+                (ULONG_PTR)LdrEntry->DllBase + LdrEntry->SizeOfImage,
                 &LdrEntry->FullDllName);
 
         /* Skip kernel and HAL */
@@ -1315,7 +1314,7 @@
                        LdrEntry->SizeOfImage);
 
         /* Update the loader entry */
-        LdrEntry->Flags |= 0x01000000;
+        LdrEntry->Flags |= LDRP_SYSTEM_MAPPED;
         LdrEntry->EntryPoint = (PVOID)((ULONG_PTR)NewImageAddress +
                                 NtHeader->OptionalHeader.AddressOfEntryPoint);
         LdrEntry->SizeOfImage = LdrEntry->SizeOfImage;
@@ -1551,9 +1550,6 @@
         if (!PsGetCurrentProcess()->ProcessInSession) return STATUS_NO_MEMORY;
     }
 
-    if (ModuleObject) *ModuleObject = NULL;
-    if (ImageBaseAddress) *ImageBaseAddress = NULL;
-
     /* Allocate a buffer we'll use for names */
     Buffer = ExAllocatePoolWithTag(NonPagedPool, MAX_PATH, TAG_LDR_WSTR);
     if (!Buffer) return STATUS_INSUFFICIENT_RESOURCES;
@@ -1644,8 +1640,8 @@
         if (!Flags)
         {
             /* It wasn't, so just return the data */
-            if (ModuleObject) *ModuleObject = LdrEntry;
-            if (ImageBaseAddress) *ImageBaseAddress = LdrEntry->DllBase;
+            *ModuleObject = LdrEntry;
+            *ImageBaseAddress = LdrEntry->DllBase;
             Status = STATUS_IMAGE_ALREADY_LOADED;
         }
         else
@@ -1818,7 +1814,7 @@
         (NtHeader->OptionalHeader.MajorImageVersion >= 5))
     {
         /* Mark this image as a native image */
-        LdrEntry->Flags |= 0x80000000;
+        LdrEntry->Flags |= LDRP_ENTRY_NATIVE;
     }
 
     /* Setup the rest of the entry */
@@ -1838,7 +1834,7 @@
     RtlCopyMemory(LdrEntry->BaseDllName.Buffer,
                   BaseName.Buffer,
                   BaseName.Length);
-    LdrEntry->BaseDllName.Buffer[BaseName.Length / 2] = UNICODE_NULL;
+    LdrEntry->BaseDllName.Buffer[BaseName.Length / sizeof(WCHAR)] = UNICODE_NULL;
 
     /* Now allocate the full name */
     LdrEntry->FullDllName.Buffer = ExAllocatePoolWithTag(PagedPool,
@@ -1861,7 +1857,7 @@
         RtlCopyMemory(LdrEntry->FullDllName.Buffer,
                       PrefixName.Buffer,
                       PrefixName.Length);
-        LdrEntry->FullDllName.Buffer[PrefixName.Length / 2] = UNICODE_NULL;
+        LdrEntry->FullDllName.Buffer[PrefixName.Length / sizeof(WCHAR)] = UNICODE_NULL;
     }
 
     /* Add the entry */
@@ -1919,11 +1915,11 @@
         PspRunLoadImageNotifyRoutines(FileName, NULL, &ImageInfo);
     }
 
-    /* Check if there's symbols */
-#ifdef KDBG
-    /* If KDBG is defined, then we always have symbols */
+#if defined(KDBG) || defined(_WINKD_)
+    /* MiCacheImageSymbols doesn't detect rossym */
     if (TRUE)
 #else
+    /* Check if there's symbols */
     if (MiCacheImageSymbols(LdrEntry->DllBase))
 #endif
     {
@@ -1960,8 +1956,8 @@
     ASSERT(Section == NULL);
 
     /* Return pointers */
-    if (ModuleObject) *ModuleObject = LdrEntry;
-    if (ImageBaseAddress) *ImageBaseAddress = LdrEntry->DllBase;
+    *ModuleObject = LdrEntry;
+    *ImageBaseAddress = LdrEntry->DllBase;
 
 Quickie:
     /* If we have a file handle, close it */
@@ -1995,7 +1991,6 @@
     ANSI_STRING AnsiRoutineName;
     NTSTATUS Status;
     PLIST_ENTRY NextEntry;
-    extern LIST_ENTRY PsLoadedModuleList;
     PLDR_DATA_TABLE_ENTRY LdrEntry;
     BOOLEAN Found = FALSE;
     UNICODE_STRING KernelName = RTL_CONSTANT_STRING(L"ntoskrnl.exe");

Modified: trunk/reactos/ntoskrnl/po/power.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/po/power.c?rev=44023&r1=44022&r2=44023&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/po/power.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/po/power.c [iso-8859-1] Sun Nov  8 02:13:49 2009
@@ -14,8 +14,6 @@
 #include <debug.h>
 
 /* GLOBALS *******************************************************************/
-
-extern ULONG ExpInitialiationPhase;
 
 typedef struct _REQUEST_POWER_ITEM
 {
@@ -126,8 +124,7 @@
 
 BOOLEAN
 NTAPI
-PoInitSystem(IN ULONG BootPhase,
-             IN BOOLEAN HaveAcpiTable)
+PoInitSystem(IN ULONG BootPhase)
 {
     PVOID NotificationEntry;
     PCHAR CommandLine;
@@ -164,8 +161,8 @@
     }
     else
     {
-        /* Otherwise check the LoaderBlock's Flag */
-        PopAcpiPresent = HaveAcpiTable;
+        /* Otherwise check if the LoaderBlock has a ACPI Table  */
+        PopAcpiPresent = KeLoaderBlock->Extension->AcpiTable != NULL ? TRUE : FALSE;
     }
 
     return TRUE;




More information about the Ros-diffs mailing list