20#include "pedigree/kernel/process/InfoBlock.h"
21#include "pedigree/kernel/process/PerProcessorScheduler.h"
22#include "pedigree/kernel/process/Process.h"
23#include "pedigree/kernel/process/Thread.h"
24#include "pedigree/kernel/processor/Processor.h"
25#include "pedigree/kernel/processor/VirtualAddressSpace.h"
26#include "pedigree/kernel/processor/state.h"
27#include "pedigree/kernel/processor/types.h"
28#include "pedigree/kernel/processor/x64/tss.h"
29#include "pedigree/kernel/processor/x86_common/ProcessorInformation.h"
30#include "pedigree/kernel/utilities/new"
65 return reinterpret_cast<void*
>(
m_Tss);
76uintptr_t X86CommonProcessorInformation::getKernelStack()
const {
79void X86CommonProcessorInformation::setKernelStack(uintptr_t stack) {
82 pedigree_materialize_user_entry();
86 m_KernelGsAnchor.kernelStack = stack;
91void X86CommonProcessorInformation::activateKernelGsAnchor(
size_t processorIndex) {
92 m_KernelGsAnchor.processorIndex = processorIndex;
93 const uintptr_t entry =
reinterpret_cast<uintptr_t
>(&m_KernelGsAnchor);
94 uint32_t eax = entry, edx = entry >> 32;
96 asm volatile(
"wrmsr" ::
"a"(eax),
"d"(edx),
"c"(0xc0000101) :
"memory");
100void X86CommonProcessorInformation::setCurrentThread(
Thread* pThread) {
101 if (m_RcuState.active()) {
102 panic(
"Context switch inside an RCU read section.");
110 Processor::setUserGsBase(pThread->getUserGsBase());
112 InfoBlockManager::instance().setPid(pThread->
getParent()->
getId());
131 : m_ProcessorId(processorId),
135 m_LocalApicId(apicId),
137 m_Scheduler(nullptr),
139 m_DeviceHardIrqDepth(0),
141 m_TscClockAnchorNanoseconds(0),
142 m_TscClockAnchorInitialised(false) {}
148void X86CommonProcessorInformation::setIds(
ProcessorId processorId, uint8_t apicId) {
Process * getParent() const
static EXPORTED_PUBLIC VirtualAddressSpace & getKernelAddressSpace()
void EXPORTED_PUBLIC panic(const char *msg) NORETURN