mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:57:44 +00:00
Kernel: List all CPUs in /proc/cpuinfo
This commit is contained in:
parent
fb41d89384
commit
d98edb3171
12 changed files with 229 additions and 64 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Arch/i386/CPU.h>
|
||||
#include <Kernel/Arch/i386/ProcessorInfo.h>
|
||||
#include <Kernel/Arch/i386/ISRStubs.h>
|
||||
#include <Kernel/Interrupts/APIC.h>
|
||||
#include <Kernel/Interrupts/GenericInterruptHandler.h>
|
||||
|
@ -795,6 +796,22 @@ u32 read_dr6()
|
|||
|
||||
FPUState Processor::s_clean_fpu_state;
|
||||
|
||||
static Vector<Processor*>* s_processors;
|
||||
|
||||
Vector<Processor*>& Processor::processors()
|
||||
{
|
||||
ASSERT(s_processors);
|
||||
return *s_processors;
|
||||
}
|
||||
|
||||
Processor& Processor::by_id(u32 cpu)
|
||||
{
|
||||
auto& procs = processors();
|
||||
ASSERT(procs[cpu] != nullptr);
|
||||
ASSERT(procs.size() > cpu);
|
||||
return *procs[cpu];
|
||||
}
|
||||
|
||||
void Processor::initialize(u32 cpu)
|
||||
{
|
||||
m_self = this;
|
||||
|
@ -817,6 +834,14 @@ void Processor::initialize(u32 cpu)
|
|||
: "=m"(s_clean_fpu_state));
|
||||
}
|
||||
|
||||
m_info = new ProcessorInfo(*this);
|
||||
|
||||
if (!s_processors)
|
||||
s_processors = new Vector<Processor*>();
|
||||
if (cpu >= s_processors->size())
|
||||
s_processors->resize(cpu + 1);
|
||||
(*s_processors)[cpu] = this;
|
||||
|
||||
klog() << "CPU #" << cpu << " using Processor at " << VirtualAddress(FlatPtr(this));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue