Thanks very much for lending me your code, it was very useful, but I still got problems.
I've been over and over Adam Chapweske's PS/2 Mouse Interface document and I've even followed the initialisation procedure to the letter. My mouse driver works in that I get all the correct responses from the controller. All the communication I do with the controller is fine. The problem seems to be that I cannot get the controller to assert a mouse interrupt. As I said before, the keyboard part of my code works fine.
I've studied how you wrote your driver very hard and I can't see any real differences. I notice you start up in real-mode and then jump to protected mode where you do your mouse initialisation.
1) You enable mouse/keyboard interrupts on the controller.
2) You enable the mouse interface on the controller.
3) You enable mouse data reporting.
I've also looked at your isrs and I'm doing exactly the same for the mouse (int 44)
1) disable ints
2) push all
3) handling the mouse (calling a C extern)
4) end of int to master and slave pics
5) pop all
6) enable ints
7) iret
This works fine for my keyboard, but doesn't get called at all for the mouse. The mouse controller does seem to be doing something however, since if I move the mouse, it just fills the 8042 output buffer and I'm no longer able to read from the keyboard.
Would my gdt have anything to do with it? The actual routines work, but this is how I'm setting up:
void gdt_init() {
// Null descriptor
gdt_null_segment(0);
// GDT_CODE_SELECTOR 0x08
gdt_code_segment(1, kRead, kRing0, k4K, k32Bit, kPresent, 0, 0xfffff);
// GDT_DATA_SELECTOR 0x10
gdt_data_segment(2, kWrite, kRing0, k4K, k32Bit, kPresent, 0, 0xfffff);
gdt_load();
asm("mov $0x10, %ax");
asm("mov %ax, %ds");
asm("mov %ax, %ss");
asm("mov %ax, %es");
asm("mov %ax, %fs");
asm("mov %ax, %gs");
}
code selector is 0x08, data selector 0x10. As above ds, ss, es, fs, gs are 0x10 and cs is 0x08 (checked with disas).
I'm setting up my isrs like so:
byte options = IDT_RING_0 | IDT_INT_GATE | IDT_PRESENT | IDT_BITS_32;
idt_load_entry(32 + PIC_KEYBOARD, (dword) isr_keyboard, IDT_CODE_SELECTOR, options);
idt_load_entry(32 + PIC_MOUSE, (dword) isr_mouse, IDT_CODE_SELECTOR, options);
PIC_KEYBOARD is 0x01
PIC_MOUSE is 0x0c
IDT_CODE_SELECTOR is 0x08.
After this I program the PIC to enable the corresponding ints.
I've also remapped the PIC properly as far as I can tell:
Here's my PIC code:
#include "include\type.h"
#include "include\pic.h"
#include "include\io.h"
#include "include\console.h"
void pic_init() {
asm("cli");
outb(PIC_MASTER_PORT_A, 0x11); // ICW 1
outb(PIC_SLAVE_PORT_A, 0x11); // 7 | 6 | 5 | 4 | 3 | 2 | 1 |
// 0 | 0 | 0 | 1 |Trig|M/S|ICW4|
// Master Slave Configuration
// IC4 needed
outb(PIC_MASTER_PORT_B, 0x20); // ICW 2
outb(PIC_SLAVE_PORT_B, 0x28); // INT 32-39 mapped to IRQ 0 to IRQ 7
// INT 40-47 mapped to IRQ 8 to IRQ 15
outb(PIC_MASTER_PORT_B, 0x04); // ICW 3
outb(PIC_SLAVE_PORT_B, 0x02); // IR 2 of master is connected to slave pic
// IRQ on master this slave is connected to
outb(PIC_MASTER_PORT_B, 0x01); // ICW 4
outb(PIC_SLAVE_PORT_B, 0x01); // Master, Fully Nested Mode
// Slave, Fully Nested Mode
outb(PIC_MASTER_PORT_B, 0xff); // All interrupts except IRQ 0 are disabled
outb(PIC_SLAVE_PORT_B, 0xff);
asm("sti");
}
void pic_enable_irq(byte irq) {
byte status;
if(irq <

{
status = inb(PIC_MASTER_PORT_B);
status &= ~(1 << irq);
outb(PIC_MASTER_PORT_B, status);
} else {
irq -= 8;
status = inb(PIC_SLAVE_PORT_B);
status &= ~(1 << irq);
outb(PIC_SLAVE_PORT_B, status);
}
}
void pic_disable_irq(byte irq) {
byte status;
if(irq <

{
status = inb(PIC_MASTER_PORT_B);
status |= 1 << irq;
outb(PIC_MASTER_PORT_B, status);
} else {
irq -= 8;
status = inb(PIC_SLAVE_PORT_B);
status |= 1 << irq;
outb(PIC_SLAVE_PORT_B, status);
}
}
I can't think of much else that could be wrong and its driving me nuts. If you can think of anything then do let me know

In the mean time however I would like your permission to hack at your kernel code, and start from scratch to get my mouse and keyboard to work. You've managed to do it in a few lines so I must be missing something.
Kind regards, and thanks for your help.
Nathan Hunt
[email protected]