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