rust-osdev/bootloader

APIC init failed on UEFI, but work on BIOS

xuanplus opened this issue · 3 comments

I have added ioapic to my code, and keyboard is working.

When I select boot with UEFI, there is a panic on 0x200FEE0320 or something like this, I forget it.

So an error happens when I init Timer IRQ.

Forgive my bad grammar.

What should I do for this?

The page fault happens when your kernel tries to access the local APIC at 0xfee0_0000. This currently fails because the physical memory mapping only covers all the memory regions we get from UEFI and if the system doesn't have a lot of memory, the mapping won't cover 0xfee0_0000. Passing -m 4G to QEMU forces the physical memory mapping to be large enough to cover the local APIC and makes the access succeed.

I'd be okay with making the physical memory mapping always cover at least the first 4 GiB of physical memory. Feel free to open a PR if you want to, otherwise I'd also be happy to implement this.

Thanks for your help!

Althought it maybe temporary, it works perfectly.

By the way, I'm true noob in os programming, so open the pr please, and I can learn more from it.

I'd be okay with making the physical memory mapping always cover at least the first 4 GiB of physical memory. Feel free to open a PR if you want to, otherwise I'd also be happy to implement this.

Sounds like a good idea!