Page 1 of 1

Problem with timer/counter3

Posted: Sun Jul 21, 2013 7:18 am
by hrm
Hi guys...
I wrote a beep function for my simple 64-bits OS and works well. but as I call it , "Double Fault Exception" occur.
this is my beep function code:

Code: Select all

;	AX : Frequency
;	BX : Lentgh
Beep:
	push	rbx
	push	rax
	mov		al,0xff
	out		0x21,al		; Disable IRQ0
	mov		al,PIT_M_SW|PIT_RWF|PIT_T2
	out		0x43,al
	pop		rax
	mov		bx,ax
	mov		eax,PIT_BF/2
	mov		edx,eax
	and		edx,0xFFFF0000
	shr		edx,16
	div		bx
	push	ax
	out		0x42,al
	mov		al,ah
	out		0x42,al
	xor		rax,rax
	in		al,0x61
	or		al,3
	out		0x61,al
	pop		ax
	pop		rbx
	mul		bx
	xor		ebx,ebx
	and		eax,0xFFFF
	mov		ebx,eax
	and		edx,0xFFFF
	shl		edx,16
	or		ebx,edx
_b0:
	in		al,0x61
	and		al,1<<5
	jz		_b0
	dec		ebx
	jnz		_b0
	in		al,0x61
	and		al,0xFE
	out		0x61,al

	xor		al,al
	out		0x21,al		; Enable IRQ0
ret
Where is my problem?
thanks in advance.

Problem with timer/counter3

Posted: Sun Jul 21, 2013 7:27 am
by hrm
Image

Re: Problem with timer/counter3

Posted: Sun Jul 21, 2013 7:31 am
by xenos
hrm wrote:Where is my problem?
Insufficient debugging skills.

At which instruction does the double fault occur? What is causing the double fault? Which exception is raised before the double fault? What does the Bochs log tell you about these things?

Re: Problem with timer/counter3

Posted: Mon Jul 22, 2013 6:40 am
by hrm
Thank you for your attention.
I don't know what is causing it...
This is Bochs log , but I can't understand anything :cry:

Code: Select all

00179620622d[CPU0 ] long mode activated
00179620623d[CPU0 ] page walk for address 0x0000000000002b5f
00179620623d[CPU0 ] page walk for address 0x00000000000027a4
00179620623d[CPU0 ] page walk for address 0x000000000002fff8
00179620644d[CPU0 ] page walk for address 0x00000000000b8000
00179627559d[CPU0 ] inhibit interrupts mask = 1
00189515185d[CPU0 ] interrupt(): vector = 08, TYPE = 0, EXT = 1 // #DF Occured
00189515185d[CPU0 ] page walk for address 0x0000000000045080
00189515185d[CPU0 ] interrupt(long mode): INTERRUPT TO SAME PRIVILEGE
00189515185d[CPU0 ] page walk for address 0x000000000000102b // Print Message
00189515190d[CPU0 ] page walk for address 0x0000000000002d77
00189515200d[CPU0 ] page walk for address 0x0000000000002d16
00189515893d[CPU0 ] page walk for address 0x0000000000002e26
00189515893d[CPU0 ] page walk for address 0x0000000000002d16
00189515905d[CPU0 ] page walk for address 0x0000000000002e26
00189515905d[CPU0 ] page walk for address 0x0000000000002d16
00189515917d[CPU0 ] page walk for address 0x0000000000002d77
00189515917d[CPU0 ] page walk for address 0x0000000000002d16
00189515962d[CPU0 ] LONG MODE IRET

Re: Problem with timer/counter3

Posted: Mon Jul 22, 2013 6:42 am
by Combuster
EXT = 1
You forgot to read the FAQ

Re: Problem with timer/counter3

Posted: Mon Jul 22, 2013 6:53 am
by Casm

Code: Select all

   xor      al,al
   out      0x21,al      ; Enable IRQ0
Have you got handlers for all the interrupts you are enabling there?

Re: Problem with timer/counter3

Posted: Mon Jul 22, 2013 7:43 am
by xenos
And did you properly remap the PIC?

Re: Problem with timer/counter3

Posted: Mon Jul 22, 2013 8:14 am
by hrm

Code: Select all

And did you properly remap the PIC?
Thanks a lot , I did it. but my problem was too more simple!

Code: Select all

Code:
   xor      al,al
   out      0x21,al      ; Enable IRQ0


Have you got handlers for all the interrupts you are enabling there?
Yeah! I had removed some of the ISR's yesterday. but I had forgotten it! My problem solved. Really thank you... =D> [-o<