[SeaBIOS] Add support for legacy USB keyboard/mouse (PS/2 emulation for USB?)

Adam Rutkowski a_rutkowski at outlook.com
Sat Apr 16 11:19:15 CEST 2016


On 16.04.2016 at 03:03, Kevin O'Connor wrote:
> On Sat, Apr 16, 2016 at 01:26:43AM +0200, Adam Rutkowski wrote:
>> Hello,
>>
>> I think this is the right place to write about this. From a few days
>> I'm fighting with not USB-aware OS-es in QEMU (like Windows 98, IBM
>> OS/2, MS-DOS etc.). When I assign real USB keyboard and mouse to VM,
>> keyboard partially works in DOS (keys like Alt aren't working), but
>> mouse doesn't work at all.
> In my quick tests on freedos, both the usb keyboard alt key and usb
> mouse work.  That said, I don't doubt old DOS device drivers and old
> OSes (eg, win98) would attempt to directly access the ps2 hardware and
> thus not benefit from the SeaBIOS USB drivers.
I also tested FreeDOS both in QEMU standard emulation and with VGA 
passthrough. In standard SDL window, both keyboard and mouse are 
emulated properly and everything works fine, but not when passing real 
graphics card to KVM. In this mode, I need to forward my real keyboard 
and mouse to guest (because QEMU is running in with -nographic) and then 
the weird things happen. Keyboard works, but only when program doesn't 
take control over it. Alt key sometimes works, sometimes not. Numeric 
keypad doesn't work at all (Numlock LED is on and can't be turned off). 
Mouse doesn't work anywhere. I tried FreeDOS edit and the block cursor 
doesn't move. Additionally, after launching FreeDOS Shell (dosshell.exe) 
keyboard stops working.
>
>> After starting, let's say Windows 98
>> Setup, keyboard stops working too. From my experience these
>> peripherals works only in newer OSes like Windows 2000+ or Linux,
>> because they initialize their own USB HID driver. I'm not using
>> QEMU's emulated USB HID devices, because I utilize VGA passthrough,
>> so I need direct access from guest machine.
>>
>> Summarizing: is it possible to add full support for USB keyboard and
>> mouse in SeaBIOS?
> Unfortunately, emulating a ps2 keyboard/mouse in SeaBIOS is very
> difficult, and I don't think it's practical.
>
> However, it should be easy to have QEMU emulate a ps2 keyboard/mouse.
> It should also be possible to do that emulation even if the VGA is in
> passthrough.
>
> -Kevin
This is my command I'm using to run FreeDOS in PCI/VGA passthrough mode 
using vfio:
qemu-system-x86_64 -nographic -hda /mnt/freedos.qcow2 -vga none 
-enable-kvm -m 512 -cpu host -localtime -smp 4 -device 
vfio-pci,host=01:00.0,x-vga=on -device vfio-pci,host=01:00.1 -netdev 
user,id=net0 -device rtl8139,netdev=net0 -usb -device 
usb-host,vendorid=0x09da,productid=0x9090 -device 
usb-host,vendorid=0x046d,productid=0xc31b

I was looking for other methods to use keys and mouse, but I couldn't 
find anything other than USB host-to-guest.

Adam



More information about the SeaBIOS mailing list