Page 1 of 1

Bochs, PIT ch.2

Posted: Wed Jan 04, 2012 10:23 am
by summersong
Sorry for my english.

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
In Qemu all OK, but in Bochs I get infinite loop. Where am I wrong?

Re: Bochs, PIT ch.2

Posted: Wed Jan 04, 2012 2:01 pm
by summersong
Solved :). Thanks to http://www.nondot.org/sabre/os/files/MiscHW/PIT.txt

Instead port 40h (ch.0) need to use 42h (ch.2). And control word must be 10110010b.