I am trying to get the local APIC to signal timer interrupts. It seems to work fine in Bochs and QEMU. I have not tried it on real hardware. However in VirtualBox (Version 4.2.16) it does not work. What I do so far is:
1) ensure that APIC is enabled reading its MSR. In VirtualBox I got 0xfee00900. (much like QEMU and Bochs).
2) OR in 0x1ff to LAPIC spurious interrupt register. So I enable it and set vector to 255.
3) Set TPR to 0 to unmask interrupts.
4) Send EOI to flush any pending interrupt
5) Set up timer: vector 0x20, periodic mode, clock divisor to 128, initial count to 0xf00.
I tried to debug it in the standard VirtualBox debugger, even tough I am
not familiar with it:
Code: Select all
VBoxDbg> info apic
Local APIC at fee00900:
LAPIC ID : 00000000
APIC ID = 00
APIC VER : 00050014
version = 14
lvts = 6
TPR : 00000000
task pri = 0/0
PPR : 00000020
cpu pri = 2/0
LDR : 00000000
log id = 00
DFR : 0fffffff
SVR : 000001ff
focus = check on
lapic = ENABLED
vector = ff
ISR : 0000000000000001000000000000000000000000000000000000000000000000
highest = 20
IRR : 0000000000000001000000000000000000000000000000000000000000000000
highest = 20
VBoxDbg> info apic timer
Local APIC timer:
Initial count : 0000f000
Current count : 0000f000
Divide config : 0000000a
divider = 128
VBoxDbg> info apic lvt
LVT Timer : 00020020
mode = periodic
mask = 0
status = idle
vector = 20
LVT LINT0 : 00000700
mask = 0
trigger = edge
rem irr = 0
polarty = 0
status = idle
delivry = ExtINT
vector = 00
LVT LINT1 : 00000400
mask = 0
trigger = edge
rem irr = 0
polarty = 0
status = idle
delivry = NMI
vector = 00
VBoxDbg>
LAPIC is mapped in with caching disabled, as recommended. For now I configured VirtualBox and the other emulators to run with one CPU core only. I have not tried to enable other cores.
I cannot get interrupts from I/O APIC either (although they do work in Bochs and QEMU).
If deemed useful, I shall upload source tarball or compiled binary.
Thank you for any help.
P.S.:
After having found a working floppy disk drive, I managed to try my program out on my own real PC. It works fine as in QEMU and Bochs. Also ISA IRQs are working: I have got response after keyboard input. I have an Intel Core 2 Duo E8400 3.00GHz. Only one I/O APIC with 23 entries. After parsing MP table, my program recognized 7 PCI buses and a single ISA bus and got the pin assignment entry right.