From 5f63ea8f8a090c382bdadd83ad803d7c5c1610ff Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 14 Oct 2024 11:38:03 +0300 Subject: [PATCH] Kernel: Add CPUID check for 1 GiB page support --- kernel/include/kernel/CPUID.h | 1 + kernel/kernel/CPUID.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/kernel/include/kernel/CPUID.h b/kernel/include/kernel/CPUID.h index ac12e2e8..e4aef13a 100644 --- a/kernel/include/kernel/CPUID.h +++ b/kernel/include/kernel/CPUID.h @@ -80,5 +80,6 @@ namespace CPUID bool has_nxe(); bool has_pge(); bool has_pat(); + bool has_1gib_pages(); } diff --git a/kernel/kernel/CPUID.cpp b/kernel/kernel/CPUID.cpp index 046aeee6..57b1a138 100644 --- a/kernel/kernel/CPUID.cpp +++ b/kernel/kernel/CPUID.cpp @@ -64,6 +64,16 @@ namespace CPUID return edx & CPUID::EDX_PAT; } + bool has_1gib_pages() + { + uint32_t buffer[4] {}; + get_cpuid(0x80000000, buffer); + if (buffer[0] < 0x80000001) + return false; + get_cpuid(0x80000001, buffer); + return buffer[3] & (1 << 26); + } + const char* feature_string_ecx(uint32_t feat) { switch (feat)