(Sorry if my post seems like I am rambling on a bit. I have found if I write in a way that asks questions as well as giving statements, I find that I can usually answer my own questions)
A while back, a fellow reader contacted me and pointed out a few errors with my work. I have been using Bochs, Qemu, and VirtualBox for some time and have had quite a bit of success. However, with the contact (thank you ThatOSDev), I decided to purchase a couple, maybe not quite so recent, but recent enough expendable desktop and laptop to actually test my work.
Wouldn't you know it, I had quite a few bugs and errors that only manifested on real hardware. My ACPI had a bug that didn't let one of the desktops work. My xHCI currently has an issue on one of the laptops, but works in all emulators and other physical machines I have tested with.
Anyway, one of the issues I am having, the laptop, a Dell Latitude 7490, has a touchpad that my code doesn't seem to be receiving interrupts when "movement" is found on the touchpad.
Here is my understanding along with a few remarks:
- The touchpad, whether it is emulated via USB or not, should show up as a standard PS2 Mouse at bootup.
- I believe this particular touchpad is a AlpsAlpine touch pad and is IC2, not USB.
- I wrote some code a few years back that I thought I would try. Since it is/was written for real mode in a Legacy BIOS environment, I modified the laptop's setup to boot in Legacy mode and booted to FreeDOS via a USB thumb drive. The first time I tried the code, it didn't work. After a little trial and error, I found that the PS2 didn't like the KEY_CMD_TEST_MP command (0xA9). Once I "removed" that code, the code ran just as expected. I got interrupts and the touchpad operated just like a normal mouse. (Please note I am not using any BIOS services. It is all hardware)
- To this point, the touchpad works in the BIOS/UEFI setup, in a FreeDOS environment using the code in the last bullet, and in Win10 booted via UEFI. Therefore, it isn't a faulty touchpad.
- However, the exact same code, now in my project, booted via UEFI in a 64-bit environment, doesn't produce interrupts (before you assume my interrupt mechanism is at fault, please continue reading).
- All of the commands that are written are accepted, I get an ACK back from all of them.
- Depending on the sequence and/or addition/subtraction of certain commands, I can get one to two interrupts during initialization and nothing more.
- I checked my interrupt mechanism. Same results with Legacy PIC or the APIC/IOAPIC.
- Just for fun, I placed a KEY_CMD_EN_SECOND command (A8 = enable mouse port) in the interrupt routine and I get a single additional interrupt, which means as long as the command is in the IRQ, I receive back to back interrupts, but not because the mouse moved. I believe it is because of the A8 command triggering the interrupt. Anyway, this proves that my interrupt mechanism is working just fine.
- I checked to make sure that the machine didn't have PS2 Multiplexing capability, to make sure that wasn't in the way.
- I found a comment in the Linux source code that a RESET command (0xFF) is mandatory for certain Dell Latitude laptops, which is one of the first things I do. :-)
- Not that it really matters, but just as a point, my code works in Qemu and Bochs just fine, though it is an emulated mouse, not a touchpad.
I tried many different combinations, down to the point of simply enabling IRQ 12, doing no PS2 initialization at all, hoping the UEFI had set the PS2 and all I had to do was accept interrupts. This didn't work either.
I am wondering if anyone has seen or had this or a similar issue? Again, the code I refer to works just fine in a Legacy BIOS FreeDOS environment, but the exact same code doesn't work in my UEFI 64-bit environment.
This tells me one of a few things:
- There is some SMM code that is probably disabling/manipulating the touchpad as I try to initialize it.
- The Legacy BIOS does or doesn't do something the that UEFI does or doesn't do.
- The UEFI has set the PS2 Mouse/Touchpad to an unknown state. However, shouldn't the reset command fix that?
- The UEFI might turn off PS2 emulation and doesn't turn it back on before ExitBootServices is called. However, all commands sent and bytes read are as expected, I just don't get any interrupts when "movement" is made.
I am at a loss and am hoping that someone here has seen or have actually had similar issues and can shine some light on the subject. Maybe I am missing something simple and just can't seem to find it.
Anyway, thanks for reading this far. It has been quite a while since I have actually asked for help, so please understand I do appreciate all of those who regularly post replies to this forum.
Thank you,
Ben
