From: acevest Date: Thu, 8 Jan 2026 01:48:31 +0000 (+0800) Subject: 把8254的时钟中断路由到AP,把HPET#0的时钟中断路由到BSP X-Git-Url: http://repos.zhaoyanbai.com/Mou_128.png?a=commitdiff_plain;h=3ce97a427128dd0998e75a24748c6882eabee653;p=kernel.git 把8254的时钟中断路由到AP,把HPET#0的时钟中断路由到BSP --- diff --git a/kernel/ap.c b/kernel/ap.c index 0312377..fd05c06 100644 --- a/kernel/ap.c +++ b/kernel/ap.c @@ -128,7 +128,7 @@ void ap_kernel_entry() { lapic_svr |= (1 << 8); // 启用LAPIC lapic_svr &= ~(1 << 12); // 禁用EOI广播 lapic->write(LAPIC_SVR, lapic_svr); - +#if 0 // 先显示地屏蔽时钟中断 lapic->write(LAPIC_LVT_TIMER, LAPIC_LVT_MASKED); @@ -148,7 +148,7 @@ void ap_kernel_entry() { // lapic->write(LAPIC_LVT_TIMER, LAPIC_TIMER_MODE_PERIODIC | clkvec); - +#endif asm("sti;"); while (1) { diff --git a/kernel/apic.c b/kernel/apic.c index 8f3045e..5600206 100644 --- a/kernel/apic.c +++ b/kernel/apic.c @@ -343,7 +343,8 @@ void ioapic_init() { #if 1 // 把8253的中断通过IOAPIC转发到CPU0的0号中断 // 8253/8254连在i8259的0号引脚,但连在IO APIC的2号引脚上 - ioapic_rte_write(IOAPIC_RTE(2), 0x20 + 0 | (dst_cpuid << 56)); + // ioapic_rte_write(IOAPIC_RTE(2), 0x20 + 0 | (dst_cpuid << 56)); + ioapic_rte_write(IOAPIC_RTE(2), 0x20 + 0 | (1ULL << 56)); // 把键盘中断通过IOAPIC转发到CPU0的1号中断 ioapic_rte_write(IOAPIC_RTE(1), 0x20 + 1 | (dst_cpuid << 56)); irq_set_chip(0x00, &ioapic_chip); @@ -396,7 +397,7 @@ void ioapic_init() { printk("HPET enabled: %s\n", (GEN_CONF & (1 << 0)) == 0 ? "no" : "yes"); printk("HPET legacy replacement: %s\n", (GEN_CONF & (1 << 1)) == 0 ? "no" : "yes"); - uint32_t cpu_irq_vec = 64; + uint32_t cpu_irq_vec = 0; uint32_t ioapic_irq = 23; // TIM0_CONF @@ -451,8 +452,8 @@ void ioapic_init() { printk("TIM0_CONF: 0x%08x%08x\n", (uint32_t)(TIM0_CONF >> 32), (uint32_t)TIM0_CONF); - uint64_t x = freq_mhz * 1000000ULL; - x >>= 1; + // uint64_t x = freq_mhz * 1000000ULL; + uint64_t x = freq_mhz * 10000ULL; *(volatile uint32_t*)(hpet_base + 0x108 + 0x04) = (uint32_t)(x >> 32); *(volatile uint32_t*)(hpet_base + 0x108 + 0x00) = (uint32_t)(x & 0xFFFFFFFF); // *(volatile uint64_t*)(hpet_base + 0x108) = x;