mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:37:47 +00:00
Kernel: Pull apart CPU.h
This does not add any functional changes
This commit is contained in:
parent
37253ebcae
commit
7ca3d413f7
86 changed files with 3866 additions and 3493 deletions
46
Kernel/Arch/x86/MSR.h
Normal file
46
Kernel/Arch/x86/MSR.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue