Debug HPET init
This commit is contained in:
@@ -19,7 +19,25 @@ static T0_COMPARATOR_OFFSET: usize = 0x108;
|
||||
static PER_INT_CAP: u64 = 0x10;
|
||||
|
||||
pub unsafe fn init(hpet: &mut Hpet) -> bool {
|
||||
// Disable HPET
|
||||
{
|
||||
let mut config_word = hpet.base_address.read_u64(GENERAL_CONFIG_OFFSET);
|
||||
log::info!("HPET config old: {:#x}", config_word);
|
||||
config_word &= !ENABLE_CNF;
|
||||
log::info!("HPET config new: {:#x}", config_word);
|
||||
hpet.base_address.write_u64(GENERAL_CONFIG_OFFSET, config_word);
|
||||
}
|
||||
|
||||
let capability = hpet.base_address.read_u64(CAPABILITY_OFFSET);
|
||||
{
|
||||
log::info!("HPET caps: {:#x}", capability);
|
||||
log::info!("HPET caps clock period: {}", (capability >> 32) as u32);
|
||||
log::info!("HPET caps ID: {:#x}", (capability >> 16) as u16);
|
||||
log::info!("HPET caps LEG_RT_CAP: {}", capability & (1 << 15) == (1 << 15));
|
||||
log::info!("HPET caps COUNT_SIZE_CAP: {}", capability & (1 << 13) == (1 << 13));
|
||||
log::info!("HPET caps timers: {}", (capability >> 8) as u8 & 0x1F);
|
||||
log::info!("HPET caps revision: {}", capability as u8);
|
||||
}
|
||||
if capability & LEG_RT_CAP == 0 {
|
||||
log::warn!("HPET missing capability LEG_RT_CAP");
|
||||
return false;
|
||||
@@ -31,6 +49,11 @@ pub unsafe fn init(hpet: &mut Hpet) -> bool {
|
||||
let clk_periods_per_kernel_tick: u64 = desired_fs_period / counter_clk_period_fs;
|
||||
|
||||
let t0_capabilities = hpet.base_address.read_u64(T0_CONFIG_CAPABILITY_OFFSET);
|
||||
{
|
||||
log::info!("HPET T0 caps: {:#x}", t0_capabilities);
|
||||
log::info!("HPET T0 caps interrupt routing: {:#x}", (t0_capabilities >> 32) as u32);
|
||||
log::info!("HPET T0 caps flags: {:#x}", t0_capabilities as u16);
|
||||
}
|
||||
if t0_capabilities & PER_INT_CAP == 0 {
|
||||
log::warn!("HPET T0 missing capability PER_INT_CAP");
|
||||
return false;
|
||||
@@ -38,14 +61,19 @@ pub unsafe fn init(hpet: &mut Hpet) -> bool {
|
||||
|
||||
let t0_config_word: u64 = TN_VAL_SET_CNF | TN_TYPE_CNF | TN_INT_ENB_CNF;
|
||||
hpet.base_address.write_u64(T0_CONFIG_CAPABILITY_OFFSET, t0_config_word);
|
||||
hpet.base_address.write_u64(T0_COMPARATOR_OFFSET, clk_periods_per_kernel_tick);
|
||||
// set accumulator value
|
||||
hpet.base_address.write_u64(T0_COMPARATOR_OFFSET, clk_periods_per_kernel_tick);
|
||||
// set interval
|
||||
hpet.base_address.write_u64(T0_COMPARATOR_OFFSET, clk_periods_per_kernel_tick);
|
||||
|
||||
let enable_word: u64 = hpet.base_address.read_u64(GENERAL_CONFIG_OFFSET) | LEG_RT_CNF | ENABLE_CNF;
|
||||
hpet.base_address.write_u64(GENERAL_CONFIG_OFFSET, enable_word);
|
||||
// Enable interrupts from the HPET
|
||||
{
|
||||
let mut config_word: u64 = hpet.base_address.read_u64(GENERAL_CONFIG_OFFSET);
|
||||
log::info!("HPET config old: {:#x}", config_word);
|
||||
config_word |= LEG_RT_CNF | ENABLE_CNF;
|
||||
log::info!("HPET config new: {:#x}", config_word);
|
||||
hpet.base_address.write_u64(GENERAL_CONFIG_OFFSET, config_word);
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@ unsafe fn init_hpet() -> bool {
|
||||
|
||||
pub unsafe fn init_noncore() {
|
||||
if init_hpet() {
|
||||
println!("HPET used as system timer");
|
||||
log::info!("HPET used as system timer");
|
||||
} else {
|
||||
pit::init();
|
||||
println!("PIT used as system timer");
|
||||
log::info!("PIT used as system timer");
|
||||
}
|
||||
|
||||
rtc::init();
|
||||
|
||||
Reference in New Issue
Block a user