1 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARM_MM_H
2 #define __NTOSKRNL_INCLUDE_INTERNAL_ARM_MM_H
5 // Number of bits corresponding to the area that a PDE entry represents (1MB)
8 #define PDE_SIZE (1 << PDE_SHIFT)
12 // FIXFIX: This is all wrong now!!!
17 // Number of bits corresponding to the area that a coarse page table entry represents (4KB)
20 //#define PAGE_SIZE (1 << PTE_SHIFT) // FIXME: This conflicts with ndk/arm/mmtypes.h which does #define PAGE_SIZE 0x1000 -- use PTE_SIZE here instead?
23 // Number of bits corresponding to the area that a coarse page table occupies (1KB)
26 #define CPT_SIZE (1 << CPT_SHIFT)
31 // FIXFIX: This is all wrong now!!!
33 typedef union _ARM_PTE
100 ULONG BaseAddress
:20;
109 ULONG BaseAddress
:22;
113 } ARM_PTE
, *PARM_PTE
;
115 typedef struct _ARM_TRANSLATION_TABLE
118 } ARM_TRANSLATION_TABLE
, *PARM_TRANSLATION_TABLE
;
120 typedef struct _ARM_COARSE_PAGE_TABLE
124 } ARM_COARSE_PAGE_TABLE
, *PARM_COARSE_PAGE_TABLE
;
126 typedef enum _ARM_L1_PTE_TYPE
134 typedef enum _ARM_L2_PTE_TYPE
141 typedef enum _ARM_PTE_ACCESS
149 typedef enum _ARM_DOMAIN
159 // FIXFIX: This is all wrong now!!!
163 // Take 0x80812345 and extract:
164 // PTE_BASE[0x808][0x12]
166 #define MiGetPteAddress(x) \
167 (PMMPTE)(PTE_BASE + \
168 (((ULONG)(x) >> 20) << 12) + \
169 ((((ULONG)(x) >> 12) & 0xFF) << 2))
171 #define MiGetPdeAddress(x) \
172 (PMMPDE_HARDWARE)(PDE_BASE + \
173 (((ULONG)(x) >> 20) << 2))
175 #define MiGetPdeOffset(x) (((ULONG)(x)) >> 22)
177 #define PTE_BASE 0xC0000000
178 #define PTE_TOP 0xC03FFFFF
179 #define PDE_BASE 0xC1000000
180 #define HYPER_SPACE 0xC1100000
181 #define HYPER_SPACE_END 0xC07FFFFF
184 PULONG
MmGetPageDirectory(VOID
);
188 // FIXME: THESE ARE WRONG ATM.
190 #define MiAddressToPde(x) \
191 ((PMMPTE)(((((ULONG)(x)) >> 22) << 2) + PDE_BASE))
192 #define MiAddressToPte(x) \
193 ((PMMPTE)(((((ULONG)(x)) >> 12) << 2) + PTE_BASE))
194 #define MiAddressToPteOffset(x) \
195 ((((ULONG)(x)) << 10) >> 22)
198 // Convert a PTE into a corresponding address
200 #define MiPteToAddress(PTE) ((PVOID)((ULONG)(PTE) << 10))
202 #define ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (1024 * PAGE_SIZE))
203 #define ADDR_TO_PDE_OFFSET(v) ((((ULONG)(v)) / (1024 * PAGE_SIZE)))
204 #define ADDR_TO_PTE_OFFSET(v) ((((ULONG)(v)) % (1024 * PAGE_SIZE)) / PAGE_SIZE)
206 #define MI_MAKE_LOCAL_PAGE(x) ((x)->u.Hard.NonGlobal = 1)
207 #define MI_MAKE_DIRTY_PAGE(x)
208 #define MI_MAKE_OWNER_PAGE(x) ((x)->u.Hard.Access = 1) // FIXFIX
209 #define MI_MAKE_WRITE_PAGE(x) ((x)->u.Hard.ExtendedAccess = 1) // FIXFIX
210 #define MI_PAGE_DISABLE_CACHE(x) ((x)->u.Hard.Cached = 0)
211 #define MI_PAGE_WRITE_THROUGH(x) ((x)->u.Hard.Buffered = 0)
212 #define MI_PAGE_WRITE_COMBINED(x) ((x)->u.Hard.Buffered = 1)
213 #define MI_IS_PAGE_WRITEABLE(x) ((x)->u.Hard.ExtendedAccess == 0)
214 #define MI_IS_PAGE_COPY_ON_WRITE(x)FALSE
215 #define MI_IS_PAGE_DIRTY(x) TRUE
217 /* Easy accessing PFN in PTE */
218 #define PFN_FROM_PTE(v) ((v)->u.Hard.PageFrameNumber)