The Pedigree Project 0.1
x86_common/Processor.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef KERNEL_PROCESSOR_X86_COMMON_PROCESSOR_H
21#define KERNEL_PROCESSOR_X86_COMMON_PROCESSOR_H
22#include "pedigree/kernel/processor/Processor.h"
23
24#include <config.h>
25
28 public:
32 static uint64_t readMachineSpecificRegister(uint32_t index);
36 static void writeMachineSpecificRegister(uint32_t index, uint64_t value);
44 static void cpuid(uint32_t inEax, uint32_t inEcx, uint32_t& eax, uint32_t& ebx, uint32_t& ecx,
45 uint32_t& edx);
46
47 static physical_uintptr_t readCr3();
48};
49
50#if X86_COMMON && !X64
51#if MULTIPROCESSOR
52EXPORTED_PUBLIC NEVER_INLINE __attribute__((cold))
53ProcessorInformation* currentProcessorInformationFromApic(
54 const Vector<ProcessorInformation*>& processors, size_t* processorIndex = nullptr);
55#endif
56
57inline ProcessorInformation& ProcessorBase::information() {
58#if MULTIPROCESSOR
59 if (m_Initialised < 2)
61
64
65 if (auto* information = currentProcessorInformationFromApic(m_ProcessorInformation))
66 return *information;
67#endif
68
70}
71#endif
72
73#endif
static ProcessorInformation & information()
static size_t m_Initialised
Definition Processor.h:483
static Vector< ProcessorInformation * > m_ProcessorInformation
Definition Processor.h:512
static ProcessorInformation m_SafeBspProcessorInformation
Definition Processor.h:516
static size_t index()
A vector / dynamic array.
Definition Vector.h:33
Iterator begin()
Definition Vector.h:162
static void cpuid(uint32_t inEax, uint32_t inEcx, uint32_t &eax, uint32_t &ebx, uint32_t &ecx, uint32_t &edx)
static void writeMachineSpecificRegister(uint32_t index, uint64_t value)
static uint64_t readMachineSpecificRegister(uint32_t index)
size_t count() const
Definition Vector.h:270