forked from Bananymous/banan-os
Kernel: Save BSB id
This commit is contained in:
parent
58aca68726
commit
f84df175ce
|
@ -31,11 +31,12 @@ namespace Kernel
|
|||
asm volatile("movw %%gs, %0" : "=rm"(id));
|
||||
return id;
|
||||
}
|
||||
|
||||
static Processor& get(ProcessorID);
|
||||
|
||||
static Processor& current() { return get(current_id()); }
|
||||
|
||||
static ProcessorID bsb_id() { return s_bsb_id; }
|
||||
static bool current_is_bsb() { return current_id() == bsb_id(); }
|
||||
|
||||
static void set_interrupt_state(InterruptState state)
|
||||
{
|
||||
if (state == InterruptState::Enabled)
|
||||
|
@ -73,6 +74,8 @@ namespace Kernel
|
|||
~Processor();
|
||||
|
||||
private:
|
||||
static ProcessorID s_bsb_id;
|
||||
|
||||
void* m_stack { nullptr };
|
||||
static constexpr size_t m_stack_size { 4096 };
|
||||
|
||||
|
|
|
@ -4,10 +4,16 @@
|
|||
namespace Kernel
|
||||
{
|
||||
|
||||
ProcessorID Processor::s_bsb_id { PROCESSOR_NONE };
|
||||
|
||||
static BAN::Vector<Processor> s_processors;
|
||||
|
||||
Processor& Processor::create(ProcessorID id)
|
||||
{
|
||||
// bsb is the first processor
|
||||
if (s_bsb_id == PROCESSOR_NONE)
|
||||
s_bsb_id = id;
|
||||
|
||||
while (s_processors.size() <= id)
|
||||
MUST(s_processors.emplace_back());
|
||||
auto& processor = s_processors[id];
|
||||
|
|
Loading…
Reference in New Issue