OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:06 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Mouse PS2 USB emulation on real hardware
PostPosted: Wed Jan 12, 2022 3:21 pm 
Offline
Member
Member

Joined: Tue Aug 31, 2021 7:25 am
Posts: 67
So I followed the steps in the mouse forum post to initialise the mouse and enable IRQs but my question is how do I get those interrupts/irqs from USB mice? Emulators work fine however testing it on my machine yields no input. I do see it says I must receive such data streams from the "USB bus" but is there any general guidance towards specifically getting that work for USB mice? I'd rather avoid writing a full fledged USB driver until I really have to. Thanks.


Top
 Profile  
 
 Post subject: Re: Mouse PS2 USB emulation on real hardware
PostPosted: Wed Jan 12, 2022 4:18 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
YDeeps1 wrote:
So I followed the steps in the mouse forum post to initialise the mouse and enable IRQs but my question is how do I get those interrupts/irqs from USB mice? Emulators work fine however testing it on my machine yields no input. I do see it says I must receive such data streams from the "USB bus" but is there any general guidance towards specifically getting that work for USB mice? I'd rather avoid writing a full fledged USB driver until I really have to. Thanks.

Well, it depends. Are you still in real-mode? If so, getting mouse movements from a USB mouse is emulated and programmed just like getting mouse movements from a PS2 mouse, as long as the hardware emulates the mouse. Most, if not all modern machines do this.

If you have moved to protected mode, you probably don't want to hear it, but you will have to write a (mostly) <quote>full fledged USB driver until I really have to.</quote>

What hardware do you have, which of the four controllers do you wish to use, and how much effort do you wish to put into USB? Depending on your answer, I have different recommendations.

If you don't want to put much effort into USB, stick with the xHCI controller and forget about the other three. If you wish to learn about USB, I would start with UHCI (and possibly OHCI), skip EHCI altogether, and then go to xHCI.

I have written a book that describes all four controllers and one of the chapters is specifically for USB mice.

Whether you read my book or not, I try to help with every USB question on this forum. After reading other documentation, the wiki for this site for instance, and other resources, start building your base, and when you have a question, feel free to ask.

Ben
- http://www.fysnet.net/the_universal_serial_bus.htm


Top
 Profile  
 
 Post subject: Re: Mouse PS2 USB emulation on real hardware
PostPosted: Wed Jan 12, 2022 4:23 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
YDeeps1 wrote:
the mouse forum post

Which forum post?

Does the emulated PS/2 controller act like a mouse is attached when you initialize it? Does it act like a mouse is attached when you poll for input without using IRQ12?

Have you checked the firmware settings to make sure USB legacy support is enabled? There may be a separate option for mouse support.

Does your firmware support mouse emulation? (I don't know how you would check this!)


Top
 Profile  
 
 Post subject: Re: Mouse PS2 USB emulation on real hardware
PostPosted: Thu Jan 13, 2022 1:53 pm 
Offline
Member
Member

Joined: Tue Aug 31, 2021 7:25 am
Posts: 67
Octocontrabass wrote:
YDeeps1 wrote:
the mouse forum post

Which forum post?

Does the emulated PS/2 controller act like a mouse is attached when you initialize it? Does it act like a mouse is attached when you poll for input without using IRQ12?

Have you checked the firmware settings to make sure USB legacy support is enabled? There may be a separate option for mouse support.

Does your firmware support mouse emulation? (I don't know how you would check this!)


Quote:
Which forum post?

https://wiki.osdev.org/Mouse_Input

Quote:
Does the emulated PS/2 controller act like a mouse is attached when you initialize it? Does it act like a mouse is attached when you poll for input without using IRQ12?

I tried polling it for input but that too returned nothing. Looks like there is no emulation going on with the mouse.

Quote:
Have you checked the firmware settings to make sure USB legacy support is enabled? There may be a separate option for mouse support.

Checked the BIOS and there is a "USB legacy" option which is turned on but does not mention the mouse.

Quote:
Does your firmware support mouse emulation? (I don't know how you would check this!)

Your guess is as good as mine :lol: but from the information here it does not look like it.


Top
 Profile  
 
 Post subject: Re: Mouse PS2 USB emulation on real hardware
PostPosted: Thu Jan 13, 2022 2:02 pm 
Offline
Member
Member

Joined: Tue Aug 31, 2021 7:25 am
Posts: 67
BenLunt wrote:
YDeeps1 wrote:
So I followed the steps in the mouse forum post to initialise the mouse and enable IRQs but my question is how do I get those interrupts/irqs from USB mice? Emulators work fine however testing it on my machine yields no input. I do see it says I must receive such data streams from the "USB bus" but is there any general guidance towards specifically getting that work for USB mice? I'd rather avoid writing a full fledged USB driver until I really have to. Thanks.

Well, it depends. Are you still in real-mode? If so, getting mouse movements from a USB mouse is emulated and programmed just like getting mouse movements from a PS2 mouse, as long as the hardware emulates the mouse. Most, if not all modern machines do this.

If you have moved to protected mode, you probably don't want to hear it, but you will have to write a (mostly) <quote>full fledged USB driver until I really have to.</quote>

What hardware do you have, which of the four controllers do you wish to use, and how much effort do you wish to put into USB? Depending on your answer, I have different recommendations.

If you don't want to put much effort into USB, stick with the xHCI controller and forget about the other three. If you wish to learn about USB, I would start with UHCI (and possibly OHCI), skip EHCI altogether, and then go to xHCI.

I have written a book that describes all four controllers and one of the chapters is specifically for USB mice.

Whether you read my book or not, I try to help with every USB question on this forum. After reading other documentation, the wiki for this site for instance, and other resources, start building your base, and when you have a question, feel free to ask.

Ben
- http://www.fysnet.net/the_universal_serial_bus.htm


I am in fact in protected mode.

Quote:
What hardware do you have, which of the four controllers do you wish to use, and how much effort do you wish to put into USB?

Haha I haven't even begun with USB barebone basics since I wasn't expecting I'd mess with the USB quite early (well not so early) so I don't know (still would like to exhaust all other available options).
But if I had to pick an approach I'd go with the most basic since I don't think I'll be making use of the USB outside of this instance.


Top
 Profile  
 
 Post subject: Re: Mouse PS2 USB emulation on real hardware
PostPosted: Thu Jan 13, 2022 6:16 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
YDeeps1 wrote:
Haha I haven't even begun with USB barebone basics since I wasn't expecting I'd mess with the USB quite early (well not so early) so I don't know (still would like to exhaust all other available options).
But if I had to pick an approach I'd go with the most basic since I don't think I'll be making use of the USB outside of this instance.

Depending on the BIOS, and more importantly, the System Management Firmware, the PS2 emulation may or may not continue to work after the move to protected mode. It is assumed that if your software is capable of protected mode code, it is capable of loading a USB driver. :-)

Good luck,
Ben


Top
 Profile  
 
 Post subject: Re: Mouse PS2 USB emulation on real hardware
PostPosted: Fri Jan 14, 2022 11:42 am 
Offline
Member
Member

Joined: Tue Aug 31, 2021 7:25 am
Posts: 67
BenLunt wrote:
YDeeps1 wrote:
Haha I haven't even begun with USB barebone basics since I wasn't expecting I'd mess with the USB quite early (well not so early) so I don't know (still would like to exhaust all other available options).
But if I had to pick an approach I'd go with the most basic since I don't think I'll be making use of the USB outside of this instance.

Depending on the BIOS, and more importantly, the System Management Firmware, the PS2 emulation may or may not continue to work after the move to protected mode. It is assumed that if your software is capable of protected mode code, it is capable of loading a USB driver. :-)

Good luck,
Ben

I'll give it a shot. Do you mind giving me a vague list of steps in getting this to work? From my little USB knowledge I believe I need to first establish a connection with a version both the host and device support and then somehow get an interrupt transfer in place in order to receive data from the mouse in real time.


Top
 Profile  
 
 Post subject: Re: Mouse PS2 USB emulation on real hardware
PostPosted: Fri Jan 14, 2022 1:06 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
YDeeps1 wrote:
I'll give it a shot. Do you mind giving me a vague list of steps in getting this to work? From my little USB knowledge I believe I need to first establish a connection with a version both the host and device support and then somehow get an interrupt transfer in place in order to receive data from the mouse in real time.

Hi,

I am sorry to say, there is no vague list of steps to get USB working. You must setup the controller, create a periodic stack, send and then receive descriptor requests, initialize the mouse, etc, before you can even think of receiving mouse packets.

On top of that, a mouse movement will not trigger an interrupt as you think it will. i.e.: it won't fire an interrupt to the PIC on every movement like you expect the PS2 would. Your stack contains a flag that will tell the controller to generate an interrupt at the end of the frame. This frame could have had 100 or more packets from various devices, some not at all related to the mouse. Your code then has to determine which packet has been received and which has yet to be received.

All of that doesn't even mention enumerating the PCI(e) to find the USB controller(s).

I am sorry, but there is no vague list of steps to take. You step in to USB and you better be ready to swim. :-)

So, to answer your question, you either need to build a USB driver or forget about the USB mouse. One or the other.

Sorry,
Ben


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 77 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group