[CMAKE]
[reactos.git] / ntoskrnl / ke / i386 / patpge.c
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/ke/i386/patpge.c
5 * PURPOSE: Support for PAT and PGE (Large Pages)
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14
15 /* FUNCTIONS *****************************************************************/
16
17 ULONG_PTR
18 NTAPI
19 Ki386EnableGlobalPage(IN volatile ULONG_PTR Context)
20 {
21 volatile PLONG Count = (PLONG)Context;
22 ULONG Cr4, Cr3;
23
24 /* Disable interrupts */
25 _disable();
26
27 /* Decrease CPU Count and loop until it's reached 0 */
28 do {InterlockedDecrement(Count);} while (!*Count);
29
30 /* Now check if this is the Boot CPU */
31 if (!KeGetPcr()->Number)
32 {
33 /* It is.FIXME: Patch KeFlushCurrentTb */
34 }
35
36 /* Now get CR4 and make sure PGE is masked out */
37 Cr4 = __readcr4();
38 __writecr4(Cr4 & ~CR4_PGE);
39
40 /* Flush the TLB */
41 Cr3 = __readcr3();
42 __writecr3(Cr3);
43
44 /* Now enable PGE */
45 DPRINT1("Global page support detected but not yet taken advantage of\n");
46 //__writecr4(Cr4 | CR4_PGE);
47
48 /* Restore interrupts */
49 _enable();
50 return 0;
51 }
52
53 VOID
54 NTAPI
55 KiInitializePAT(VOID)
56 {
57 /* FIXME: Support this */
58 DPRINT1("PAT support detected but not yet taken advantage of\n");
59 }