ReactOS 0.4.17-dev-1190-g4c812f4
hypermap.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
#include <mm/ARM3/miarm.h>
Include dependency graph for hypermap.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define MODULE_INVOLVED_IN_ARM3
 

Functions

PVOID NTAPI MiMapPageInHyperSpace (IN PEPROCESS Process, IN PFN_NUMBER Page, IN PKIRQL OldIrql)
 
VOID NTAPI MiUnmapPageInHyperSpace (IN PEPROCESS Process, IN PVOID Address, IN KIRQL OldIrql)
 
PVOID NTAPI MiMapPagesInZeroSpace (IN PMMPFN Pfn1, IN PFN_NUMBER NumberOfPages)
 
VOID NTAPI MiUnmapPagesInZeroSpace (IN PVOID VirtualAddress, IN PFN_NUMBER NumberOfPages)
 

Variables

PMMPTE MmFirstReservedMappingPte
 
PMMPTE MmLastReservedMappingPte
 
PMMPTE MiFirstReservedZeroingPte
 
MMPTE HyperTemplatePte
 

Macro Definition Documentation

◆ MODULE_INVOLVED_IN_ARM3

#define MODULE_INVOLVED_IN_ARM3

Definition at line 15 of file hypermap.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file hypermap.c.

Function Documentation

◆ MiMapPageInHyperSpace()

PVOID NTAPI MiMapPageInHyperSpace ( IN PEPROCESS  Process,
IN PFN_NUMBER  Page,
IN PKIRQL  OldIrql 
)

Definition at line 28 of file hypermap.c.

31{
33 PMMPTE PointerPte;
35
36 //
37 // Never accept page 0 or non-physical pages
38 //
39 ASSERT(Page != 0);
41
42 //
43 // Build the PTE
44 //
47
48 //
49 // Pick the first hyperspace PTE
50 //
51 PointerPte = MmFirstReservedMappingPte;
52
53 //
54 // Acquire the hyperlock
55 //
57 KeAcquireSpinLock(&Process->HyperSpaceLock, OldIrql);
58
59 //
60 // Now get the first free PTE
61 //
62 Offset = PFN_FROM_PTE(PointerPte);
63 if (!Offset)
64 {
65 //
66 // Reset the PTEs
67 //
70 }
71
72 //
73 // Prepare the next PTE
74 //
75 PointerPte->u.Hard.PageFrameNumber = Offset - 1;
76
77 //
78 // Write the current PTE
79 //
80 PointerPte += Offset;
81 MI_WRITE_VALID_PTE(PointerPte, TempPte);
82
83 //
84 // Return the address
85 //
86 return MiPteToAddress(PointerPte);
87}
ULONG_PTR PFN_NUMBER
HARDWARE_PTE_ARMV6 TempPte
Definition: winldr.c:76
#define NULL
Definition: types.h:112
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
PMMPTE MmFirstReservedMappingPte
Definition: hypermap.c:20
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:967
#define ASSERT(a)
Definition: mode.c:44
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
FORCEINLINE VOID KeFlushProcessTb(VOID)
Definition: ke.h:282
#define MI_HYPERSPACE_PTES
Definition: mm.h:83
#define PFN_FROM_PTE(v)
Definition: mm.h:94
#define MiPteToAddress(_Pte)
Definition: mm.h:131
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:1042
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1287
MMPTE ValidKernelPteLocal
Definition: init.c:33
ULONG PageFrameNumber
Definition: mmtypes.h:109
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
union _MMPTE::@2788 u
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by MiCopyFromUserPage(), MiReadFilePage(), and MiZeroPhysicalPage().

◆ MiMapPagesInZeroSpace()

PVOID NTAPI MiMapPagesInZeroSpace ( IN PMMPFN  Pfn1,
IN PFN_NUMBER  NumberOfPages 
)

Definition at line 111 of file hypermap.c.

113{
115 PMMPTE PointerPte;
116 PFN_NUMBER Offset, PageFrameIndex;
117
118 //
119 // Sanity checks
120 //
122 ASSERT(NumberOfPages != 0);
123 ASSERT(NumberOfPages <= MI_ZERO_PTES);
124
125 //
126 // Pick the first zeroing PTE
127 //
128 PointerPte = MiFirstReservedZeroingPte;
129
130 //
131 // Now get the first free PTE
132 //
133 Offset = PFN_FROM_PTE(PointerPte);
134 if (NumberOfPages > Offset)
135 {
136 //
137 // Reset the PTEs
138 //
140 PointerPte->u.Hard.PageFrameNumber = Offset;
142 }
143
144 //
145 // Prepare the next PTE
146 //
147 PointerPte->u.Hard.PageFrameNumber = Offset - NumberOfPages;
148
149 /* Choose the correct PTE to use, and which template */
150 PointerPte += (Offset + 1);
152
153 /* Disable caching */
155
156 /* Make sure the list isn't empty and loop it */
157 ASSERT(Pfn1 != (PVOID)LIST_HEAD);
158 while (Pfn1 != (PVOID)LIST_HEAD)
159 {
160 /* Get the page index for this PFN */
161 PageFrameIndex = MiGetPfnEntryIndex(Pfn1);
162
163 //
164 // Write the PFN
165 //
166 TempPte.u.Hard.PageFrameNumber = PageFrameIndex;
167
168 //
169 // Set the correct PTE to write to, and set its new value
170 //
171 PointerPte--;
172 MI_WRITE_VALID_PTE(PointerPte, TempPte);
173
174 /* Move to the next PFN */
175 Pfn1 = (PMMPFN)Pfn1->u1.Flink;
176 }
177
178 //
179 // Return the address
180 //
181 return MiPteToAddress(PointerPte);
182}
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
PMMPTE MiFirstReservedZeroingPte
Definition: hypermap.c:21
#define MI_ZERO_PTES
Definition: mm.h:84
#define MI_MAKE_PTE_NON_CACHED(Pte)
Definition: mm.h:88
FORCEINLINE PFN_NUMBER MiGetPfnEntryIndex(IN PMMPFN Pfn1)
Definition: mm.h:1062
struct _MMPFN * PMMPFN
MMPTE ValidKernelPte
Definition: init.c:29
#define LIST_HEAD(name, type)
Definition: queue.h:167

Referenced by MmZeroPageThread().

◆ MiUnmapPageInHyperSpace()

VOID NTAPI MiUnmapPageInHyperSpace ( IN PEPROCESS  Process,
IN PVOID  Address,
IN KIRQL  OldIrql 
)

Definition at line 91 of file hypermap.c.

94{
96
97 //
98 // Blow away the mapping
99 //
100 MiAddressToPte(Address)->u.Long = 0;
101
102 //
103 // Release the hyperlock
104 //
106 KeReleaseSpinLock(&Process->HyperSpaceLock, OldIrql);
107}
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define MiAddressToPte(x)
Definition: mm.h:144
static WCHAR Address[46]
Definition: ping.c:68

Referenced by MiCopyFromUserPage(), MiReadFilePage(), and MiZeroPhysicalPage().

◆ MiUnmapPagesInZeroSpace()

VOID NTAPI MiUnmapPagesInZeroSpace ( IN PVOID  VirtualAddress,
IN PFN_NUMBER  NumberOfPages 
)

Definition at line 186 of file hypermap.c.

188{
189 PMMPTE PointerPte;
190
191 //
192 // Sanity checks
193 //
195 ASSERT (NumberOfPages != 0);
196 ASSERT(NumberOfPages <= MI_ZERO_PTES);
197
198 //
199 // Get the first PTE for the mapped zero VA
200 //
201 PointerPte = MiAddressToPte(VirtualAddress);
202
203 //
204 // Blow away the mapped zero PTEs
205 //
206 RtlZeroMemory(PointerPte, NumberOfPages * sizeof(MMPTE));
207}
_In_ ULONG _In_ MEMORY_CACHING_TYPE _Out_ PPHYSICAL_ADDRESS _Out_ PVOID * VirtualAddress
Definition: dispmprt.h:716
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by MmZeroPageThread().

Variable Documentation

◆ HyperTemplatePte

MMPTE HyperTemplatePte

Definition at line 22 of file hypermap.c.

Referenced by MiInitializePageTable().

◆ MiFirstReservedZeroingPte

PMMPTE MiFirstReservedZeroingPte

Definition at line 21 of file hypermap.c.

Referenced by MiBuildSystemPteSpace(), MiInitMachineDependent(), and MiMapPagesInZeroSpace().

◆ MmFirstReservedMappingPte

PMMPTE MmFirstReservedMappingPte

Definition at line 20 of file hypermap.c.

Referenced by MiInitializePageTable(), MiInitMachineDependent(), and MiMapPageInHyperSpace().

◆ MmLastReservedMappingPte

PMMPTE MmLastReservedMappingPte

Definition at line 20 of file hypermap.c.

Referenced by MiInitializePageTable(), and MiInitMachineDependent().