mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
Kernel: Pull apart CPU.h
This does not add any functional changes
This commit is contained in:
parent
37253ebcae
commit
7ca3d413f7
Notes:
sideshowbarker
2024-07-18 11:36:37 +09:00
Author: https://github.com/Hendiadyoin1
Commit: 7ca3d413f7
Pull-request: https://github.com/SerenityOS/serenity/pull/8192
Reviewed-by: https://github.com/gunnarbeutner
86 changed files with 3866 additions and 3493 deletions
49
Kernel/Arch/x86/common/ASM_wrapper.cpp
Normal file
49
Kernel/Arch/x86/common/ASM_wrapper.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Types.h>
|
||||
|
||||
#include <Kernel/Arch/x86/ASM_wrapper.h>
|
||||
#include <Kernel/Arch/x86/CPU.h>
|
||||
#include <Kernel/Arch/x86/Processor.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
#define XCR_XFEATURE_ENABLED_MASK 0
|
||||
|
||||
UNMAP_AFTER_INIT u64 read_xcr0()
|
||||
{
|
||||
u32 eax, edx;
|
||||
asm volatile("xgetbv"
|
||||
: "=a"(eax), "=d"(edx)
|
||||
: "c"(XCR_XFEATURE_ENABLED_MASK));
|
||||
return eax + ((u64)edx << 32);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void write_xcr0(u64 value)
|
||||
{
|
||||
u32 eax = value;
|
||||
u32 edx = value >> 32;
|
||||
asm volatile("xsetbv" ::"a"(eax), "d"(edx), "c"(XCR_XFEATURE_ENABLED_MASK));
|
||||
}
|
||||
|
||||
void stac()
|
||||
{
|
||||
if (!Processor::current().has_feature(CPUFeature::SMAP))
|
||||
return;
|
||||
asm volatile("stac" ::
|
||||
: "cc");
|
||||
}
|
||||
|
||||
void clac()
|
||||
{
|
||||
if (!Processor::current().has_feature(CPUFeature::SMAP))
|
||||
return;
|
||||
asm volatile("clac" ::
|
||||
: "cc");
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue