1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:17:35 +00:00

Kernel: Hide the implementation detail that MSRs use two registers

When retrieving and setting x86 MSRs two registers are required. The
existing setter and getter for the MSR class made this implementation
detail visible to the caller. This changes the setter and getter to
use u64 instead.
This commit is contained in:
Gunnar Beutner 2021-07-03 00:25:41 +02:00 committed by Andreas Kling
parent a09e6171a6
commit 04a912f68f
3 changed files with 10 additions and 9 deletions

View file

@ -30,15 +30,19 @@ public:
{
}
void get(u32& low, u32& high)
[[nodiscard]] u64 get()
{
u32 low, high;
asm volatile("rdmsr"
: "=a"(low), "=d"(high)
: "c"(m_msr));
return ((u64)high << 32) | low;
}
void set(u32 low, u32 high)
void set(u64 value)
{
u32 low = value & 0xffffffff;
u32 high = value >> 32;
asm volatile("wrmsr" ::"a"(low), "d"(high), "c"(m_msr));
}
};