Author: ros-arm-bringup
Date: Tue Jun 23 11:32:43 2009
New Revision: 41574
URL:
http://svn.reactos.org/svn/reactos?rev=41574&view=rev
Log:
- Move hypermap.c into ARM3 since it will be changed to use System PTEs for zero PTEs to
solve the current race conditions that had to be fixed/hacked around in the current
implementation.
- DO NOT MAP HYPERSPACE PTEs as GLOBAL! They are now mapped as local, which might fix some
really strange bugs that could've occured in the past.
- Use MiPteToAddress instead of manually doing the bitmagic when mapping a page into
hyperspace.
Added:
trunk/reactos/ntoskrnl/mm/ARM3/hypermap.c
- copied, changed from r41573, trunk/reactos/ntoskrnl/mm/hypermap.c
Removed:
trunk/reactos/ntoskrnl/mm/hypermap.c
Modified:
trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild
Copied: trunk/reactos/ntoskrnl/mm/ARM3/hypermap.c (from r41573,
trunk/reactos/ntoskrnl/mm/hypermap.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/hypermap.…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/hypermap.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/hypermap.c [iso-8859-1] Tue Jun 23 11:32:43 2009
@@ -1,7 +1,7 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: BSD - See COPYING.ARM in the top level directory
- * FILE: ntoskrnl/mm/hypermap.c
+ * FILE: ntoskrnl/mm/ARM3/hypermap.c
* PURPOSE: Hyperspace Mapping Functionality
* PROGRAMMERS: ReactOS Portable Systems Group
*/
@@ -15,6 +15,7 @@
/* GLOBALS ********************************************************************/
PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte;
+PMMPTE MiFirstReservedZeroingPte;
MMPTE HyperTemplatePte;
PEPROCESS HyperProcess;
KIRQL HyperIrql;
@@ -30,43 +31,60 @@
MMPTE TempPte;
PMMPTE PointerPte;
PFN_NUMBER Offset;
- PVOID Address;
- /* Never accept page 0 */
+ //
+ // Never accept page 0
+ //
ASSERT(Page != 0);
- /* Build the PTE */
+ //
+ // Build the PTE
+ //
TempPte = HyperTemplatePte;
TempPte.u.Hard.PageFrameNumber = Page;
+ TempPte.u.Hard.Global = 0; // Hyperspace is local!
- /* Pick the first hyperspace PTE */
+ //
+ // Pick the first hyperspace PTE
+ //
PointerPte = MmFirstReservedMappingPte;
- /* Acquire the hyperlock */
+ //
+ // Acquire the hyperlock
+ //
ASSERT(Process == PsGetCurrentProcess());
KeAcquireSpinLock(&Process->HyperSpaceLock, OldIrql);
- /* Now get the first free PTE */
+ //
+ // Now get the first free PTE
+ //
Offset = PFN_FROM_PTE(PointerPte);
if (!Offset)
{
- /* Reset the PTEs */
+ //
+ // Reset the PTEs
+ //
Offset = MI_HYPERSPACE_PTES;
KeFlushProcessTb();
}
- /* Prepare the next PTE */
+ //
+ // Prepare the next PTE
+ //
PointerPte->u.Hard.PageFrameNumber = Offset - 1;
- /* Write the current PTE */
+ //
+ // Write the current PTE
+ //
PointerPte += Offset;
ASSERT(PointerPte->u.Hard.Valid == 0);
ASSERT(TempPte.u.Hard.Valid == 1);
*PointerPte = TempPte;
- /* Return the address */
- Address = (PVOID)((ULONG_PTR)PointerPte << 10);
- return Address;
+ //
+ // Return the address
+ //
+ return MiPteToAddress(PointerPte);
}
VOID
@@ -77,10 +95,14 @@
{
ASSERT(Process == PsGetCurrentProcess());
- /* Blow away the mapping */
+ //
+ // Blow away the mapping
+ //
MiAddressToPte(Address)->u.Long = 0;
- /* Release the hyperlock */
+ //
+ // Release the hyperlock
+ //
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
KeReleaseSpinLock(&Process->HyperSpaceLock, OldIrql);
}
@@ -93,24 +115,36 @@
PMMPTE PointerPte;
PVOID Address;
- /* Never accept page 0 */
+ //
+ // Never accept page 0
+ //
ASSERT(Page != 0);
- /* Build the PTE */
+ //
+ // Build the PTE
+ //
TempPte = HyperTemplatePte;
TempPte.u.Hard.PageFrameNumber = Page;
- /* Get the Zero PTE and its address */
+ //
+ // Get the Zero PTE and its address
+ //
PointerPte = MiAddressToPte(MI_ZERO_PTE);
Address = (PVOID)((ULONG_PTR)PointerPte << 10);
- /* Invalidate the old address */
+ //
+ // Invalidate the old address
+ //
__invlpg(Address);
- /* Write the current PTE */
+ //
+ // Write the current PTE
+ //
TempPte.u.Hard.PageFrameNumber = Page;
*PointerPte = TempPte;
- /* Return the address */
+ //
+ // Return the address
+ //
return Address;
}
Removed: trunk/reactos/ntoskrnl/mm/hypermap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/hypermap.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/hypermap.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/hypermap.c (removed)
@@ -1,116 +1,0 @@
-/*
- * PROJECT: ReactOS Kernel
- * LICENSE: BSD - See COPYING.ARM in the top level directory
- * FILE: ntoskrnl/mm/hypermap.c
- * PURPOSE: Hyperspace Mapping Functionality
- * PROGRAMMERS: ReactOS Portable Systems Group
- */
-
-/* INCLUDES *******************************************************************/
-
-#include <ntoskrnl.h>
-#define NDEBUG
-#include <debug.h>
-
-/* GLOBALS ********************************************************************/
-
-PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte;
-MMPTE HyperTemplatePte;
-PEPROCESS HyperProcess;
-KIRQL HyperIrql;
-
-/* PRIVATE FUNCTIONS **********************************************************/
-
-PVOID
-NTAPI
-MiMapPageInHyperSpace(IN PEPROCESS Process,
- IN PFN_NUMBER Page,
- IN PKIRQL OldIrql)
-{
- MMPTE TempPte;
- PMMPTE PointerPte;
- PFN_NUMBER Offset;
- PVOID Address;
-
- /* Never accept page 0 */
- ASSERT(Page != 0);
-
- /* Build the PTE */
- TempPte = HyperTemplatePte;
- TempPte.u.Hard.PageFrameNumber = Page;
-
- /* Pick the first hyperspace PTE */
- PointerPte = MmFirstReservedMappingPte;
-
- /* Acquire the hyperlock */
- ASSERT(Process == PsGetCurrentProcess());
- KeAcquireSpinLock(&Process->HyperSpaceLock, OldIrql);
-
- /* Now get the first free PTE */
- Offset = PFN_FROM_PTE(PointerPte);
- if (!Offset)
- {
- /* Reset the PTEs */
- Offset = MI_HYPERSPACE_PTES;
- KeFlushProcessTb();
- }
-
- /* Prepare the next PTE */
- PointerPte->u.Hard.PageFrameNumber = Offset - 1;
-
- /* Write the current PTE */
- PointerPte += Offset;
- ASSERT(PointerPte->u.Hard.Valid == 0);
- ASSERT(TempPte.u.Hard.Valid == 1);
- *PointerPte = TempPte;
-
- /* Return the address */
- Address = (PVOID)((ULONG_PTR)PointerPte << 10);
- return Address;
-}
-
-VOID
-NTAPI
-MiUnmapPageInHyperSpace(IN PEPROCESS Process,
- IN PVOID Address,
- IN KIRQL OldIrql)
-{
- ASSERT(Process == PsGetCurrentProcess());
-
- /* Blow away the mapping */
- MiAddressToPte(Address)->u.Long = 0;
-
- /* Release the hyperlock */
- ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
- KeReleaseSpinLock(&Process->HyperSpaceLock, OldIrql);
-}
-
-PVOID
-NTAPI
-MiMapPageToZeroInHyperSpace(IN PFN_NUMBER Page)
-{
- MMPTE TempPte;
- PMMPTE PointerPte;
- PVOID Address;
-
- /* Never accept page 0 */
- ASSERT(Page != 0);
-
- /* Build the PTE */
- TempPte = HyperTemplatePte;
- TempPte.u.Hard.PageFrameNumber = Page;
-
- /* Get the Zero PTE and its address */
- PointerPte = MiAddressToPte(MI_ZERO_PTE);
- Address = (PVOID)((ULONG_PTR)PointerPte << 10);
-
- /* Invalidate the old address */
- __invlpg(Address);
-
- /* Write the current PTE */
- TempPte.u.Hard.PageFrameNumber = Page;
- *PointerPte = TempPte;
-
- /* Return the address */
- return Address;
-}
Modified: trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl-generic.…
==============================================================================
--- trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] Tue Jun 23 11:32:43 2009
@@ -360,6 +360,7 @@
</directory>
</if>
<directory name="ARM3">
+ <file>hypermap.c</file>
<file>init.c</file>
<file>pool.c</file>
<file>syspte.c</file>
@@ -370,7 +371,6 @@
<file>dbgpool.c</file>
<file>drvlck.c</file>
<file>freelist.c</file>
- <file>hypermap.c</file>
<file>iospace.c</file>
<file>kmap.c</file>
<file>marea.c</file>