⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 patpge.c

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 C
字号:
/*
* PROJECT:         ReactOS Kernel
* LICENSE:         GPL - See COPYING in the top level directory
* FILE:            ntoskrnl/ke/i386/patpge.c
* PURPOSE:         Support for PAT and PGE (Large Pages)
* PROGRAMMERS:     Alex Ionescu (alex.ionescu@reactos.org)
*/

/* INCLUDES ******************************************************************/

#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>

/* GLOBALS *******************************************************************/

ULONG Ke386GlobalPagesEnabled;

/* FUNCTIONS *****************************************************************/

ULONG_PTR
NTAPI
Ki386EnableGlobalPage(IN volatile ULONG_PTR Context)
{
    volatile PLONG Count = (PLONG)Context;
    ULONG Cr4, Cr3;

    /* Disable interrupts */
    _disable();

    /* Decrease CPU Count and loop until it's reached 0 */
    do {InterlockedDecrement(Count);} while (!*Count);

    /* Now check if this is the Boot CPU */
    if (!KeGetPcr()->Number)
    {
        /* It is.FIXME: Patch KeFlushCurrentTb */
    }

    /* Now get CR4 and make sure PGE is masked out */
    Cr4 = __readcr4();
    __writecr4(Cr4 & ~CR4_PGE);

    /* Flush the TLB */
    Cr3 = __readcr3();
    __writecr3(Cr3);

    /* Now enable PGE */
    __writecr4(Cr4 | CR4_PGE);
    Ke386GlobalPagesEnabled = TRUE;

    /* Restore interrupts */
    _enable();
    return 0;
}

VOID
NTAPI
KiInitializePAT(VOID)
{
    /* FIXME: Support this */
    DPRINT1("Advanced Memory features detected but not yet taken advantage of.\n");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -