UHCI driver doesnt send interrupts

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
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

UHCI driver doesnt send interrupts

Post by Klakap »

Good day!

Now I am working on UHCI driver and I have my source code on this:
https://github.com/Klaykap/LightningOS/ ... usb_uhci.c

I am working on bochs with command:

Code: Select all

usb_uhci: enabled=1, port1=mouse, port2=keypad
On my code I didnt call uhci() but uhci_reset(0), because I know that I have only one uhci port on uhci_base[0].

My code right found that usb have two ports, and reset it, but interrupts isn't send after moving mouse. Please what I am doing wrong?
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: UHCI driver doesnt send interrupts

Post by BenLunt »

Klakap wrote:Good day!

Now I am working on UHCI driver and I have my source code on this:
https://github.com/Klaykap/LightningOS/ ... usb_uhci.c

I am working on bochs with command:

Code: Select all

usb_uhci: enabled=1, port1=mouse, port2=keypad
On my code I didnt call uhci() but uhci_reset(0), because I know that I have only one uhci port on uhci_base[0].

My code right found that usb have two ports, and reset it, but interrupts isn't send after moving mouse. Please what I am doing wrong?
Please be a little more specific.

With USB, an interrupt is not generated each time the mouse is moved. You are to request an interrupt packet at a specific timing. These packets can have the IOC bit set, which will fire an interrupt at the end of the frame, but this does not mean that the mouse was moved.

Your code needs to see if the interrupt pipe actually sent something and if it did, you have to check to see if there is a difference with the last packet you received.

A USB mouse (HID device) does not use hardware interrupts to indicate movement. USB HID devices use an interrupt pipe to get information about the device.

Ben
- http://www.fysnet.net/the_universal_serial_bus.htm
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: UHCI driver doesnt send interrupts

Post by Klakap »

Thank! I wasn't know this. But I have problem with sending package bacause I am not know how to start. Wiki and lowlevel contains a lot of useful informations, but I didnt see any "if you are bigginer, try to send this packet at first". Please how should seem a simple setup packet GET_DESCRIPTOR? I dont want code, I want only how it should look. I think then I'll understand how to process information from wiki and lowlevel.
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: UHCI driver doesnt send interrupts

Post by Klakap »

I try this:

Code: Select all

uhci_stop(port_offset);

uhci_mem[0].next=0xDEAD0001;
uhci_mem[0].status=0x18800000;
uhci_mem[0].header=0x00E0002D; //setup packet
uhci_mem[0].address=(uint32_t)uhci_packet;
uhci_mem[0].reserved=0;

uhci_packet[0]=0x01000680;
uhci_packet[1]=0x00120000;

write_uhci_frame_num(port_offset, 0);
uhci_run(port_offset);
now I wait and check for values in uhci_mem[0] but nothing happend. Please where can be error?
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: UHCI driver doesnt send interrupts

Post by BenLunt »

Klakap wrote:now I wait and check for values in uhci_mem[0] but nothing happend. Please where can be error?
It could be many things. You need to check all of the following:
- Are you using physical addresses? You must have all memory access, physical addresses.
- Are these addresses below the 4gig address space?
- Is the Run bit set in the command register?
- Have you reset the device and waited the allotted time for it to recover?
- Have you powered the port?
- Have you checked the status byte? Does it change from 0x80 to another value?
- If it is still 0x80, then the controller's stack hasn't found it. Check the Frame Pointers, QUEUE and TD pointers.
There are many things you need to check.

Are you running your code via an emulator? If so, how about Bochs? Set the Debug flag for the UHCI and look at the log file.

Ben
- http://www.fysnet.net/the_universal_serial_bus.htm
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: UHCI driver doesnt send interrupts

Post by Klakap »

Oh, I solve the problem! I forgot for base thing - frame pointer :oops: . Now all work fine. Thank for a help.
Post Reply