Skip to contentSkip to conversation

ps/2 mouse handler interrupt

Qemu-devel Andry 1 participant 1 message Nov 7, 2004

lore
Share & tools
lore

Andry

author
#0 lore raw

Hello all,

I'm trying to write a basic mouse interrupt handler for a simple kernel, but got stuck somewhere... Please, if anyone can tell me where I went wrong?

This code is intended to run at the start of a kernel when we're still in real mode. The mouse type i'm trying to handle is the ps/2 mouse.

Here's what I understand so far:

1) mouse events are reported to interrupt_vector_table entry number 0x000C (COM1).

2) data bytes from mouse can be read at io port 0x03f8

3) each mouse event generates 3 interrupts, so giving us 3 bytes with the following structure:

Data packet format

	D7	D6	D5	D4	D3	D2	D1	D0

1. XV XV YS XS 1 0 R L

2. X7 X6 X5 X4 X3 X2 X1 X0

3. Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0

L Left button state (1 = pressed down)

R Right button state (1 = pressed down)

X0-X7 Movement in X direction

Y0-Y7 Movement in Y direction

XS,YS Movement data sign bits (1 = negative)

XV,YV Movement data overflow bits (1 = overflow has occured)

(from http://www.hut.fi/~then/mytexts/mouse.html)

The code I've written looks like this:

...

;init mouse

mov ax, 0

int 0x33

;replace mouse interrupt handler

push word 0

pop ds

cli

mov [4 * MOUSE_INTERRUPT], word mouseHandler

mov [4 * MOUSE_INTERRUPT + 2], cs

sti

jmp $

...

mouseHandler:

call printSomething

...

mov dx, 0x03f8

in al, dx ;get one mouse data byte

...

The problem is that printSomething doesn't get called. So, am I using the wrong interrupt_vector_table entry?

Also pls let me know if anything else is wrong with above code... i'm relatively new to x86 assembly language.

Thanks,

Andre