Day 4 of debugging a previously functional PS/2 Mouse Driver

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
t3hn3rd
Posts: 7
Joined: Sat May 20, 2017 6:29 am
Libera.chat IRC: t3hn3rd

Day 4 of debugging a previously functional PS/2 Mouse Driver

Post by t3hn3rd »

Hi all,

I've been spending the last few days banging my head against the wall with regard to my PS/2 mouse implementation.

For a bit of context, I recently built a test system out of old hardware (Gigabyte Board with an old AMD Vishera 8350) + PiKVM (Raspberry Pi acting as a Keyboard/Video/Mouse over the network) for testing my OS on real hardware. Previously, I've mainly been using VirtualBox/QEmu/Bochs for testing, occasionally testing on an old laptop or my main rig.

The mouse driver has worked fine up until now when tested in virtualized environments or on real hardware. However, with the new test rig, initializing the mouse causes a triple fault when switching to Data Reporting mode (outb(0x60, 0xF4);). Port 60/64 emulation is enabled in the BIOS/SMM, but as soon as the call to enable Data Reporting mode is called the system triple faults and as such, resets.

The PIC is rebased to 32, and as such, I'd expect IRQ 44 (32 + 12) to be the PS/2 mouse Data Reporting.

NB: The keyboard seems to be fully functional.

I have enabled debug output through RS232 serial, and this is what I've tried so far:
- Traced the code using lots of verbose output & infinite loops - this traced to outb(0x60, 0xF4), everything before this runs fine.
- Disabling the PS/2 mouse driver - System boots without issue.
- Commenting out the mouse_write(0xF4)/outb(0x60, 0xF4) - System boots without issue.
- Checking to see if IRQ44 is called at all by writing out to serial - Interrupt doesn't seem to be called before the triple fault.
- Disabling the PCI driver (it was mentioned by doug16k on the IRC that touching/clearing the BARs of the USB to check sizes can mess up PS/2 emulation) - Disabling the PCI initialization didn't seem to solve the issue.
- Checking that other interrupts are functioning correctly - The PIT at IRQ32 seems to be firing correctly.

Does anyone have any tips/pointers? I feel like I must be missing something, but I can't for the life of me work out what.

Source for reference (apologies, I haven't renewed the certificate on the web svn viewer):
- Mouse Driver: https://svn.spexeah.com/!/#Asuro/view/h ... /mouse.pas
- PIC Init/Rebase: https://svn.spexeah.com/!/#Asuro/view/head/src/irq.pas
- ISR Manager: https://svn.spexeah.com/!/#Asuro/view/h ... anager.pas

If there's any more information I can provide, or you would prefer the source in disassembled ASM format as opposed to Pascal, please ask - any help would be massively appreciated.

Regards,

t3hn3rd
Octocontrabass
Member
Member
Posts: 5572
Joined: Mon Mar 25, 2013 7:01 pm

Re: Day 4 of debugging a previously functional PS/2 Mouse Dr

Post by Octocontrabass »

You've checked your exception handlers and you're sure it's triple faulting while in SMM, right?

Have you tried it without the Pi-KVM?

Do other users of the SMM USB stack have the same issue? (For example, DOS with a PS/2 mouse driver.)
t3hn3rd
Posts: 7
Joined: Sat May 20, 2017 6:29 am
Libera.chat IRC: t3hn3rd

Re: Day 4 of debugging a previously functional PS/2 Mouse Dr

Post by t3hn3rd »

Octocontrabass wrote:You've checked your exception handlers and you're sure it's triple faulting while in SMM, right?
I have checked, and it doesn't seem to run any instructions after the outb, data report interrupt code doesn't seem to be run either.
Octocontrabass wrote:Have you tried it without the Pi-KVM?
I've tried it with a standard USB mouse and have the same issue.
Octocontrabass wrote:Do other users of the SMM USB stack have the same issue? (For example, DOS with a PS/2 mouse driver.)
I haven't tried that yet, very good idea - I'll download DOS + PS/2 Mouse Driver and give this a go. I have every faith that it's my code as opposed to an SMM issue though :P

Regards,

t3hn3rd
Post Reply