Bochs, PIT ch.2

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
summersong
Member
Member
Posts: 32
Joined: Sat Mar 26, 2011 5:26 am
Location: Moscow

Bochs, PIT ch.2

Post 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?
User avatar
summersong
Member
Member
Posts: 32
Joined: Sat Mar 26, 2011 5:26 am
Location: Moscow

Re: Bochs, PIT ch.2

Post 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.
Post Reply