interrupts..interrupts..and more interrupts

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
AltCtrlDel
Member
Member
Posts: 25
Joined: Sat Jun 25, 2005 11:00 pm

interrupts..interrupts..and more interrupts

Post by AltCtrlDel »

i have some problem that needs your help.
my mouse driver works fine for the normal motion of the mouse .. however when the user moves the mouse quite fast the mouse just sticks to the borders of the screen .. perhaps because it cannot handle succesive interrupts correctly

here is my mouse driver,
it simply receives three successive interrupts from the mouse and read three successive bytes,
*mouse_cycle: is the counter that determines which one of the three interrupts is the current one
*_kernelMouseDriverData: is the mouse data sent by the mouse, it is public but accessed only from the _mouse_events proc
*_mouse_event: a C function that notifies the tasks that a mouse event has occured and it draws the cursor
if more clarifications are required just tell me

Code: Select all

[color=blue]
_kernelMouseDriverData	db 0,0,0   ;; the data sent by the mouse
mouse_cycle		db 0       ;; which byte is the current one
_int2C_handler:
	cli
	push eax
	push ebx
	
	;; mouse_byte[mouse_cycle] = inportb(0x60)
	xor eax,eax
	in al,60h					

	;;read mouse byte
	xor ebx,ebx			
	mov bl,[mouse_cycle]
	mov [byte ptr ebx+offset _kernelMouseDriverData],al
	
	;; mouse_cycle = (mouse_cycle==2) ? (0) : mouse_cycle+1) 
	cmp [mouse_cycle],02
	je int2c_handler_lastbyte
	
	inc [mouse_cycle]			;less than 2
	jmp int2c_handler_end
	
	int2c_handler_lastbyte:	;equals 2
	mov [mouse_cycle],0
	
	call _mouse_events	;;let the events fire
	
	int2c_handler_end:
	;; Issue an end-of-interrupt (EOI) to the slave PIC
	mov AL, 00100000b
	out 0A0h, AL
	;; Issue an end-of-interrupt (EOI) to the master PIC
	mov AL, 00100000b
	out 20h, AL
		
	pop ebx
	pop eax
	iretd[/color]
AltCtrlDel
Member
Member
Posts: 25
Joined: Sat Jun 25, 2005 11:00 pm

Re: interrupts..interrupts..and more interrupts

Post by AltCtrlDel »

well..i think i have got it!!!

accessing data from the kernel using [mouse_cycle] requires the DS register to be set to the selector of the kernel's data segment..
the clash is solved by adding the following wrapper to the interrupt handler:

push ds
mov ax,kernel_ds_selector
mov ds,ax
..
..
pop ds


thank you for the help that u didn't enough time to provide ;) !!!
Post Reply