[USB-BRINGUP-TRUNK]
[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 INIT_FUNCTION
20 Ki386EnableGlobalPage(IN volatile ULONG_PTR Context)
21 {
22 volatile PLONG Count = (PLONG)Context;
23 ULONG Cr4, Cr3;
24
25 /* Disable interrupts */
26 _disable();
27
28 /* Decrease CPU Count and loop until it's reached 0 */
29 do {InterlockedDecrement(Count);} while (!*Count);
30
31 /* Now check if this is the Boot CPU */
32 if (!KeGetPcr()->Number)
33 {
34 /* It is.FIXME: Patch KeFlushCurrentTb */
35 }
36
37 /* Now get CR4 and make sure PGE is masked out */
38 Cr4 = __readcr4();
39 __writecr4(Cr4 & ~CR4_PGE);
40
41 /* Flush the TLB */
42 Cr3 = __readcr3();
43 __writecr3(Cr3);
44
45 /* Now enable PGE */
46 DPRINT("Global page support detected but not yet taken advantage of\n");
47 //__writecr4(Cr4 | CR4_PGE);
48
49 /* Restore interrupts */
50 _enable();
51 return 0;
52 }
53
54 VOID
55 NTAPI
56 INIT_FUNCTION
57 KiInitializePAT(VOID)
58 {
59 /* FIXME: Support this */
60 DPRINT("PAT support detected but not yet taken advantage of\n");
61 }