Author: ros-arm-bringup
Date: Tue Jun 23 13:23:16 2009
New Revision: 41577
URL: http://svn.reactos.org/svn/reactos?rev=41577&view=rev
Log:
- Jesus Christ man, learn some C, will you?
- Fix boot.
- The lack of colorful poetry is brought to you by cogent human beings on the West Coast whom you should be thankful haven't gone to bed yet.
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/init.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/init.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/init.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/init.c [iso-8859-1] Tue Jun 23 13:23:16 2009
@@ -121,7 +121,7 @@
//
// This both odious and heinous
//
- extern PULONG MmGlobalKernelPageDirectory;
+ extern ULONG MmGlobalKernelPageDirectory[1024];
MmGlobalKernelPageDirectory[Pde] = ((PULONG)PAGEDIRECTORY_MAP)[Pde];
Pde++;
}
Author: ros-arm-bringup
Date: Tue Jun 23 13:11:01 2009
New Revision: 41576
URL: http://svn.reactos.org/svn/reactos?rev=41576&view=rev
Log:
- So it turns out bad things can happen if you play behind Mm's back.
- The lovely poetry is brought to you by 7AM coding marathons...
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/init.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/init.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/init.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/init.c [iso-8859-1] Tue Jun 23 13:11:01 2009
@@ -103,6 +103,29 @@
ULONG MmNumberOfSystemPtes;
/* PRIVATE FUNCTIONS **********************************************************/
+
+//
+// In Bavaria, this is probably a hate crime
+//
+VOID
+FASTCALL
+MiSyncARM3WithROS(IN PVOID AddressStart,
+ IN PVOID AddressEnd)
+{
+ //
+ // Puerile piece of junk-grade carbonized horseshit puss sold to the lowest bidder
+ //
+ ULONG Pde = ADDR_TO_PDE_OFFSET(AddressStart);
+ while (Pde < ADDR_TO_PDE_OFFSET(AddressEnd))
+ {
+ //
+ // This both odious and heinous
+ //
+ extern PULONG MmGlobalKernelPageDirectory;
+ MmGlobalKernelPageDirectory[Pde] = ((PULONG)PAGEDIRECTORY_MAP)[Pde];
+ Pde++;
+ }
+}
NTSTATUS
NTAPI
@@ -490,6 +513,13 @@
// Set the counter to maximum to boot with
//
MiFirstReservedZeroingPte->u.Hard.PageFrameNumber = MI_ZERO_PTES - 1;
+
+ //
+ // Sync us up with ReactOS Mm
+ //
+ MiSyncARM3WithROS(MmNonPagedSystemStart, (PVOID)((ULONG_PTR)MmNonPagedPoolEnd - 1));
+ MiSyncARM3WithROS(MmNonPagedPoolStart, (PVOID)((ULONG_PTR)MmNonPagedPoolStart + MmSizeOfNonPagedPoolInBytes - 1));
+ MiSyncARM3WithROS((PVOID)HYPER_SPACE, (PVOID)(HYPER_SPACE + PAGE_SIZE - 1));
}
//
Author: ros-arm-bringup
Date: Tue Jun 23 11:49:39 2009
New Revision: 41575
URL: http://svn.reactos.org/svn/reactos?rev=41575&view=rev
Log:
- Move ARM Pool to 0xB0000000 to avoid clashing with existing ReactOS address space components (shouldn't happen if things work right, but better safe than sorry).
- Implement System PTE allocator (MiReserveAlignedSystemPtes and MiReserveSystemPtes). Very simple yet functional, no optimizes for now.
- Allocate 32 zeoring PTEs from the System PTE pool.
- Not used yet, only the allocation is made to test the current framework.
- Tested on VirtualBox, QEMU and VMWare with RAM sizes from 128MB to 1536MB with no problems.
Modified:
trunk/reactos/ntoskrnl/include/internal/mm.h
trunk/reactos/ntoskrnl/mm/ARM3/init.c
trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
trunk/reactos/ntoskrnl/mm/ARM3/syspte.c
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Tue Jun 23 11:49:39 2009
@@ -64,6 +64,7 @@
#define HYPER_SPACE (0xC0400000)
#define MI_HYPERSPACE_PTES (256 - 1)
+#define MI_ZERO_PTES (32)
#define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
#define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
MI_HYPERSPACE_PTES * PAGE_SIZE)
Modified: trunk/reactos/ntoskrnl/mm/ARM3/init.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/init.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/init.c [iso-8859-1] Tue Jun 23 11:49:39 2009
@@ -52,7 +52,7 @@
// immediately follows the PFN database, typically sharing the same PDE. It is
// a very small resource (32MB on a 1GB system), and capped at 128MB.
//
-// Right now, we call this the "ARM Pool" and it begins at 0xA0000000 since we
+// Right now, we call this the "ARM Pool" and it begins at 0xB0000000 since we
// don't want to interefere with the ReactOS memory manager PFN database (yet).
//
// The expansion nonpaged pool, on the other hand, can grow much bigger (400MB
@@ -288,7 +288,7 @@
DPRINT1("System PTE VA starts at: %p\n", MmNonPagedSystemStart);
DPRINT1("NP Expansion VA begins at: %p and ends at: %p\n",
MmNonPagedPoolStart, MmNonPagedPoolEnd);
- MmNonPagedPoolStart = (PVOID)0xA0000000;
+ MmNonPagedPoolStart = (PVOID)0xB0000000;
//
// Now we actually need to get these many physical pages. Nonpaged pool
@@ -477,6 +477,19 @@
MmFirstReservedMappingPte = MiAddressToPte(MI_MAPPING_RANGE_START);
MmLastReservedMappingPte = MiAddressToPte(MI_MAPPING_RANGE_END);
MmFirstReservedMappingPte->u.Hard.PageFrameNumber = MI_HYPERSPACE_PTES;
+
+ //
+ // Reserve system PTEs for zeroing PTEs and clear them
+ //
+ MiFirstReservedZeroingPte = MiReserveSystemPtes(MI_ZERO_PTES,
+ SystemPteSpace);
+ DPRINT1("ZERO PTEs are at: %p\n", MiFirstReservedZeroingPte);
+ RtlZeroMemory(MiFirstReservedZeroingPte, MI_ZERO_PTES * sizeof(MMPTE));
+
+ //
+ // Set the counter to maximum to boot with
+ //
+ MiFirstReservedZeroingPte->u.Hard.PageFrameNumber = MI_ZERO_PTES - 1;
}
//
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Tue Jun 23 11:49:39 2009
@@ -27,6 +27,7 @@
extern PVOID MmNonPagedPoolStart;
extern PVOID MmNonPagedPoolExpansionStart;
extern PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte;
+extern PMMPTE MiFirstReservedZeroingPte;
VOID
NTAPI
@@ -42,4 +43,11 @@
IN MMSYSTEM_PTE_POOL_TYPE PoolType
);
+PMMPTE
+NTAPI
+MiReserveSystemPtes(
+ IN ULONG NumberOfPtes,
+ IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType
+);
+
/* EOF */
Modified: trunk/reactos/ntoskrnl/mm/ARM3/syspte.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/syspte.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/syspte.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/syspte.c [iso-8859-1] Tue Jun 23 11:49:39 2009
@@ -27,6 +27,137 @@
/* PRIVATE FUNCTIONS **********************************************************/
+PMMPTE
+NTAPI
+MiReserveAlignedSystemPtes(IN ULONG NumberOfPtes,
+ IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType,
+ IN ULONG Alignment)
+{
+ PMMPTE PointerPte, NextPte, PreviousPte;
+ ULONG_PTR ClusterSize;
+
+ //
+ // Sanity check
+ //
+ ASSERT(Alignment <= PAGE_SIZE);
+
+ //
+ // Get the first free cluster and make sure we have PTEs available
+ //
+ PointerPte = &MmFirstFreeSystemPte[SystemPtePoolType];
+ if (PointerPte->u.List.NextEntry == -1) return NULL;
+
+ //
+ // Now move to the first free system PTE cluster
+ //
+ PreviousPte = PointerPte;
+ PointerPte = MmSystemPteBase + PointerPte->u.List.NextEntry;
+
+ //
+ // Loop each cluster
+ //
+ while (TRUE)
+ {
+ //
+ // Check if we're done to only one PTE left
+ //
+ if (!PointerPte->u.List.OneEntry)
+ {
+ //
+ // Keep track of the next cluster in case we have to relink
+ //
+ NextPte = PointerPte + 1;
+
+ //
+ // Can this cluster satisfy the request?
+ //
+ ClusterSize = (ULONG_PTR)NextPte->u.List.NextEntry;
+ if (NumberOfPtes < ClusterSize)
+ {
+ //
+ // It can, and it will leave just one PTE left
+ //
+ if ((ClusterSize - NumberOfPtes) == 1)
+ {
+ //
+ // This cluster becomes a single system PTE entry
+ //
+ PointerPte->u.List.OneEntry = 1;
+ }
+ else
+ {
+ //
+ // Otherwise, the next cluster aborbs what's left
+ //
+ NextPte->u.List.NextEntry = ClusterSize - NumberOfPtes;
+ }
+
+ //
+ // Decrement the free count and move to the next starting PTE
+ //
+ MmTotalFreeSystemPtes[SystemPtePoolType] -= NumberOfPtes;
+ PointerPte += (ClusterSize - NumberOfPtes);
+ break;
+ }
+
+ //
+ // Did we find exactly what you wanted?
+ //
+ if (NumberOfPtes == ClusterSize)
+ {
+ //
+ // Yes, fixup the cluster and decrease free system PTE count
+ //
+ PreviousPte->u.List.NextEntry = PointerPte->u.List.NextEntry;
+ MmTotalFreeSystemPtes[SystemPtePoolType] -= NumberOfPtes;
+ break;
+ }
+ }
+ else if (NumberOfPtes == 1)
+ {
+ //
+ // We have one PTE in this cluster, and it's all you want
+ //
+ PreviousPte->u.List.NextEntry = PointerPte->u.List.NextEntry;
+ MmTotalFreeSystemPtes[SystemPtePoolType]--;
+ break;
+ }
+
+ //
+ // We couldn't find what you wanted -- is this the last cluster?
+ //
+ if (PointerPte->u.List.NextEntry == -1) return NULL;
+
+ //
+ // Go to the next cluster
+ //
+ PreviousPte = PointerPte;
+ PointerPte = MmSystemPteBase + PointerPte->u.List.NextEntry;
+ ASSERT(PointerPte > PreviousPte);
+ }
+
+ //
+ // Flush the TLB and return the first PTE
+ //
+ KeFlushProcessTb();
+ return PointerPte;
+}
+
+PMMPTE
+NTAPI
+MiReserveSystemPtes(IN ULONG NumberOfPtes,
+ IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
+{
+ PMMPTE PointerPte;
+
+ //
+ // Use the extended function
+ //
+ PointerPte = MiReserveAlignedSystemPtes(NumberOfPtes, SystemPtePoolType, 0);
+ ASSERT(PointerPte != NULL);
+ return PointerPte;
+}
+
VOID
NTAPI
MiInitializeSystemPtes(IN PMMPTE StartingPte,
Author: ros-arm-bringup
Date: Tue Jun 23 10:32:11 2009
New Revision: 41572
URL: http://svn.reactos.org/svn/reactos?rev=41572&view=rev
Log:
- Do not zero out MC_SYSTEM pages if they are "early pages" either. This could cause issues on certain systems where mapping the PFN database required "early pages", and they were zeroed before hyperspace was ready.
- Add a new flag to MmGetContigousPages to specify if these pages should be zeroed or not. Allows the nonpaged pool pages not to get automatically zeroed when allocated (the NP pool allocator can do this by itself later). This allows initial nonpaged pool to be allocated before hyperspace is ready.
Modified:
trunk/reactos/ntoskrnl/include/internal/mm.h
trunk/reactos/ntoskrnl/mm/cont.c
trunk/reactos/ntoskrnl/mm/freelist.c
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Tue Jun 23 10:32:11 2009
@@ -1125,7 +1125,8 @@
ULONG NumberOfBytes,
PHYSICAL_ADDRESS LowestAcceptableAddress,
PHYSICAL_ADDRESS HighestAcceptableAddress,
- PHYSICAL_ADDRESS BoundaryAddressMultiple
+ PHYSICAL_ADDRESS BoundaryAddressMultiple,
+ BOOLEAN ZeroPages
);
NTSTATUS
Modified: trunk/reactos/ntoskrnl/mm/cont.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/cont.c?rev=415…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/cont.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/cont.c [iso-8859-1] Tue Jun 23 10:32:11 2009
@@ -103,7 +103,8 @@
PBase = MmGetContinuousPages(NumberOfBytes,
LowestAcceptableAddress,
HighestAcceptableAddress,
- BoundaryAddressMultiple);
+ BoundaryAddressMultiple,
+ TRUE);
if (PBase == 0)
{
MmLockAddressSpace(MmGetKernelAddressSpace());
Modified: trunk/reactos/ntoskrnl/mm/freelist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] Tue Jun 23 10:32:11 2009
@@ -138,7 +138,8 @@
MmGetContinuousPages(ULONG NumberOfBytes,
PHYSICAL_ADDRESS LowestAcceptableAddress,
PHYSICAL_ADDRESS HighestAcceptableAddress,
- PHYSICAL_ADDRESS BoundaryAddressMultiple)
+ PHYSICAL_ADDRESS BoundaryAddressMultiple,
+ BOOLEAN ZeroPages)
{
ULONG NrPages;
ULONG i, j;
@@ -222,7 +223,7 @@
{
if (MiGetPfnEntry(i)->Flags.Zero == 0)
{
- MiZeroPage(i);
+ if (ZeroPages) MiZeroPage(i);
}
else
{
@@ -727,7 +728,7 @@
/* Allocate an early page -- we'll account for it later */
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
PfnOffset = MmAllocEarlyPage();
- MiZeroPage(PfnOffset);
+ if (Consumer != MC_SYSTEM) MiZeroPage(PfnOffset);
return PfnOffset;
}