Problem with timer/counter3

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
hrm
Posts: 7
Joined: Tue Feb 19, 2013 4:14 am

Problem with timer/counter3

Post 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.
hrm
Posts: 7
Joined: Tue Feb 19, 2013 4:14 am

Problem with timer/counter3

Post by hrm »

Image
User avatar
xenos
Member
Member
Posts: 1118
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Problem with timer/counter3

Post 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?
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
hrm
Posts: 7
Joined: Tue Feb 19, 2013 4:14 am

Re: Problem with timer/counter3

Post 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
Last edited by hrm on Mon Jul 22, 2013 6:42 am, edited 1 time in total.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Problem with timer/counter3

Post by Combuster »

EXT = 1
You forgot to read the FAQ
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: Problem with timer/counter3

Post 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?
User avatar
xenos
Member
Member
Posts: 1118
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Problem with timer/counter3

Post by xenos »

And did you properly remap the PIC?
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
hrm
Posts: 7
Joined: Tue Feb 19, 2013 4:14 am

Re: Problem with timer/counter3

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