Skip to content
Snippets Groups Projects
Commit e415242a authored by Avi Kivity's avatar Avi Kivity
Browse files

apic clockevents: per-cpu setup

The apic needs to be programmed on each cpu that is brought up.
parent 3d8b87be
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ class apic_clock_events : public clock_event_driver {
public:
explicit apic_clock_events();
~apic_clock_events();
virtual void setup_on_cpu();
virtual void set(u64 time);
private:
unsigned _vector;
......@@ -17,15 +18,19 @@ private:
apic_clock_events::apic_clock_events()
: _vector(idt.register_handler([this] { _callback->fired(); }))
{
processor::apic->write(apicreg::TMDCR, 0xb); // divide by 1
processor::apic->write(apicreg::TMICT, 0);
processor::apic->write(apicreg::LVTT, _vector); // one-shot
}
apic_clock_events::~apic_clock_events()
{
}
void apic_clock_events::setup_on_cpu()
{
processor::apic->write(apicreg::TMDCR, 0xb); // divide by 1
processor::apic->write(apicreg::TMICT, 0);
processor::apic->write(apicreg::LVTT, _vector); // one-shot
}
void apic_clock_events::set(u64 time)
{
u64 now = clock::get()->time();
......
......@@ -64,6 +64,7 @@ void cpu::handle_incoming_wakeups()
void cpu::init_on_cpu()
{
arch.init_on_cpu();
clock_event->setup_on_cpu();
}
void schedule(bool yield)
......
......@@ -13,6 +13,7 @@ public:
class clock_event_driver {
public:
virtual ~clock_event_driver();
virtual void setup_on_cpu() = 0;
// set() is cpu-local: each processor has its own timer
virtual void set(u64 time) = 0;
void set_callback(clock_event_callback* callback);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment