Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9ab827a)
raw | patch | inline | side by side (parent: 9ab827a)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Thu, 8 Jan 2026 01:48:31 +0000 (09:48 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Thu, 8 Jan 2026 01:48:31 +0000 (09:48 +0800) |
| kernel/ap.c | patch | blob | history | |
| kernel/apic.c | patch | blob | history |
diff --git a/kernel/ap.c b/kernel/ap.c
--- a/kernel/ap.c
+++ b/kernel/ap.c
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);
//
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
--- a/kernel/apic.c
+++ b/kernel/apic.c
#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);
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
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;