Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 25971ce)
raw | patch | inline | side by side (parent: 25971ce)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Mon, 26 Jan 2026 14:33:12 +0000 (22:33 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Mon, 26 Jan 2026 14:33:12 +0000 (22:33 +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
if (r.ecx & (1 << 21)) {
printk("x2apic supported\n");
} else {
- panic("x2apic not supported\n");
+ printk("x2apic not supported\n");
}
} else {
panic("local apic not supported\n");
diff --git a/kernel/apic.c b/kernel/apic.c
--- a/kernel/apic.c
+++ b/kernel/apic.c
void apic_write64_lapic(uint32_t offset, uint64_t value) {
assert(offset < PAGE_SIZE);
+ assert((offset % 8) == 0);
+#if 1
uint8_t* base = (uint8_t*)fixid_to_vaddr(FIX_LAPIC_BASE);
*(volatile uint64_t*)(base + offset) = value;
+#else
+ // 在bochs上得用下面这段代码,否则会提示
+ // PANIC
+ // Device: [APIC0 ]
+ // Message: APIC write at unaligned address 0x0000fee00304
+ uint8_t* base = (uint8_t*)fixid_to_vaddr(FIX_LAPIC_BASE);
+ *(volatile uint32_t*)(base + offset) = (uint32_t)value;
+#endif
}
uint32_t apic_get_lapic_id() {
x2apic = true;
printk("x2apic supported\n");
} else {
- // panic("x2apic not supported\n");
+ printk("x2apic not supported\n");
}
} else {
panic("local apic not supported\n");