Author: dgorbachev
Date: Wed Jun 3 02:14:46 2009
New Revision: 41264
URL:
http://svn.reactos.org/svn/reactos?rev=41264&view=rev
Log:
Do not crash on software breakpoint in kdb.
Modified:
trunk/reactos/ntoskrnl/kd/i386/kdmemsup.c
Modified: trunk/reactos/ntoskrnl/kd/i386/kdmemsup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/i386/kdmemsup.…
==============================================================================
--- trunk/reactos/ntoskrnl/kd/i386/kdmemsup.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/kd/i386/kdmemsup.c [iso-8859-1] Wed Jun 3 02:14:46 2009
@@ -15,16 +15,24 @@
#define PAGE_TABLE_MASK 0x3ff
#define BIG_PAGE_SIZE (1<<22)
#define CR4_PAGE_SIZE_BIT 0x10
-#define PDE_PRESENT_BIT 1
-#define PDE_W_BIT 2
+#define PDE_PRESENT_BIT 0x01
+#define PDE_W_BIT 0x02
+#define PDE_PWT_BIT 0x08
+#define PDE_PCD_BIT 0x10
+#define PDE_ACCESSED_BIT 0x20
+#define PDE_DIRTY_BIT 0x40
#define PDE_PS_BIT 0x80
+#define MI_KDBG_TMP_PAGE_1 (HYPER_SPACE + 0x400000 - PAGE_SIZE)
+#define MI_KDBG_TMP_PAGE_0 (MI_KDBG_TMP_PAGE_1 - PAGE_SIZE)
+
/* VARIABLES ***************************************************************/
+static BOOLEAN KdpPhysAccess = FALSE;
+
+#if 0
extern ULONG MmGlobalKernelPageDirectory[1024];
-static BOOLEAN KdpPhysAccess = FALSE;
ULONG_PTR IdentityMapAddrHigh, IdentityMapAddrLow;
-extern PFN_TYPE NTAPI MmAllocEarlyPage();
ULONGLONG
FASTCALL
@@ -66,7 +74,6 @@
return Result;
}
-
VOID
NTAPI
KdpPhysWrite(ULONG_PTR Addr, LONG Len, ULONGLONG Value)
@@ -103,6 +110,91 @@
__writecr3(OldCR3);
__invlpg((PVOID)Addr);
}
+
+#else
+
+static
+ULONG_PTR
+KdpPhysMap(ULONG_PTR PhysAddr, LONG Len)
+{
+ MMPTE TempPte;
+ PMMPTE PointerPte;
+ ULONG_PTR VirtAddr;
+
+ TempPte.u.Long = PDE_PRESENT_BIT | PDE_W_BIT | PDE_PWT_BIT |
+ PDE_PCD_BIT | PDE_ACCESSED_BIT | PDE_DIRTY_BIT;
+
+ if ((PhysAddr & (PAGE_SIZE - 1)) + Len > PAGE_SIZE)
+ {
+ TempPte.u.Hard.PageFrameNumber = (PhysAddr >> PAGE_SHIFT) + 1;
+ PointerPte = MiAddressToPte(MI_KDBG_TMP_PAGE_1);
+ *PointerPte = TempPte;
+ VirtAddr = (ULONG_PTR)PointerPte << 10;
+ __invlpg((PVOID)VirtAddr);
+ }
+
+ TempPte.u.Hard.PageFrameNumber = PhysAddr >> PAGE_SHIFT;
+ PointerPte = MiAddressToPte(MI_KDBG_TMP_PAGE_0);
+ *PointerPte = TempPte;
+ VirtAddr = (ULONG_PTR)PointerPte << 10;
+ __invlpg((PVOID)VirtAddr);
+
+ return VirtAddr + (PhysAddr & (PAGE_SIZE - 1));
+}
+
+static
+ULONGLONG
+KdpPhysRead(ULONG_PTR PhysAddr, LONG Len)
+{
+ ULONG_PTR Addr;
+ ULONGLONG Result = 0;
+
+ Addr = KdpPhysMap(PhysAddr, Len);
+
+ switch (Len)
+ {
+ case 8:
+ Result = *((PULONGLONG)Addr);
+ break;
+ case 4:
+ Result = *((PULONG)Addr);
+ break;
+ case 2:
+ Result = *((PUSHORT)Addr);
+ break;
+ case 1:
+ Result = *((PUCHAR)Addr);
+ break;
+ }
+
+ return Result;
+}
+
+static
+VOID
+KdpPhysWrite(ULONG_PTR PhysAddr, LONG Len, ULONGLONG Value)
+{
+ ULONG_PTR Addr;
+
+ Addr = KdpPhysMap(PhysAddr, Len);
+
+ switch (Len)
+ {
+ case 8:
+ *((PULONGLONG)Addr) = Value;
+ break;
+ case 4:
+ *((PULONG)Addr) = Value;
+ break;
+ case 2:
+ *((PUSHORT)Addr) = Value;
+ break;
+ case 1:
+ *((PUCHAR)Addr) = Value;
+ break;
+ }
+}
+#endif
BOOLEAN
NTAPI
@@ -199,6 +291,7 @@
return TRUE;
}
+#if 0
VOID
NTAPI
KdpEnableSafeMem()
@@ -245,3 +338,13 @@
KdpPhysAccess = TRUE;
}
+
+#else
+
+VOID
+NTAPI
+KdpEnableSafeMem(VOID)
+{
+ KdpPhysAccess = TRUE;
+}
+#endif