1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 06:25:01 +00:00
serenity/Kernel/Arch/x86/MSR.h
Hendiadyoin1 7ca3d413f7 Kernel: Pull apart CPU.h
This does not add any functional changes
2021-06-24 00:38:23 +02:00

46 lines
751 B
C++

/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <Kernel/Arch/x86/CPUID.h>
namespace Kernel {
class MSR {
uint32_t m_msr;
public:
static bool have()
{
CPUID id(1);
return (id.edx() & (1 << 5)) != 0;
}
MSR(const MSR&) = delete;
MSR& operator=(const MSR&) = delete;
MSR(uint32_t msr)
: m_msr(msr)
{
}
void get(u32& low, u32& high)
{
asm volatile("rdmsr"
: "=a"(low), "=d"(high)
: "c"(m_msr));
}
void set(u32 low, u32 high)
{
asm volatile("wrmsr" ::"a"(low), "d"(high), "c"(m_msr));
}
};
}