I try to calibrate APIC timer by using PIT ch.2.
Code: Select all
; in real mode
cli
in al,70h ; turn off interrupts and NMI
or al,80h
out 70h,al
mov al,-1 ; no interrupts at all
out 21h,al
out 0a1h,al
; ...
; in long mode, after turn APIC on
sti ; need to calibrate APIC timer
mov dx,61h
in al,dx
and al,0fdh ; turn off sound of speaker
or al,1 ; connect speaker to PIT ch.2
out dx,al
mov al,10110000b ; ch.2 (10), r/w LSB/MSB (11), one-shot (000), binary (0)
out 43h,al
mov al,9bh ; LSB; 1193180/100 Hz = 11931 = 2e9bh
out 40h,al
mov al,2eh ; MSB
out 40h,al
@@:
in al,dx
and al,20h
jz @b