mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[kernel] Add fake clock source if there's no HPET
If there's no HPET (or if HPET is left uninitialized for debugging) default to a fake incrementing counter clock.
This commit is contained in:
@@ -313,6 +313,13 @@ device_manager::probe_pci()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint64_t
|
||||||
|
fake_clock_source(void*)
|
||||||
|
{
|
||||||
|
static uint64_t value = 0;
|
||||||
|
return value++;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
device_manager::init_drivers()
|
device_manager::init_drivers()
|
||||||
{
|
{
|
||||||
@@ -331,18 +338,20 @@ device_manager::init_drivers()
|
|||||||
ahcid.register_device(&device);
|
ahcid.register_device(&device);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
clock *master_clock = nullptr;
|
||||||
if (m_hpets.count() > 0) {
|
if (m_hpets.count() > 0) {
|
||||||
hpet &h = m_hpets[0];
|
hpet &h = m_hpets[0];
|
||||||
h.enable();
|
h.enable();
|
||||||
|
|
||||||
// becomes the singleton
|
// becomes the singleton
|
||||||
clock *master_clock = new clock(h.rate(), hpet_clock_source, &h);
|
master_clock = new clock(h.rate(), hpet_clock_source, &h);
|
||||||
kassert(master_clock, "Failed to allocate master clock");
|
|
||||||
log::info(logs::clock, "Created master clock using HPET 0: Rate %d", h.rate());
|
log::info(logs::clock, "Created master clock using HPET 0: Rate %d", h.rate());
|
||||||
} else {
|
} else {
|
||||||
//TODO: APIC clock?
|
//TODO: Other clocks, APIC clock?
|
||||||
kassert(0, "No HPET master clock");
|
master_clock = new clock(5000, fake_clock_source, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kassert(master_clock, "Failed to allocate master clock");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
Reference in New Issue
Block a user