Documenting the IRIX USB Subsystem
#1
Documenting the IRIX USB Subsystem
I'm making it a point to gather useful info on this. 

As everyone knows, IRIX's USB implementation is lacking. Very lacking. It only supports HID and USB Audio. On top of that, the O2, Octane, Onyx2/Origin2000 are not able to utilize USB at all due to the usb stack not getting compiled for/not supporting their kernels. 

So here's what I've been able to uncover:

1. If you plug in a USB stick or an unknown controller sometimes IRIX can "see" it as an unknown device in its hardware graph. 
2. It appears, from my guesstimate, that the reason it's only supported on Chimera systems is that the usb modules simply don't get compiled/linked into the IRIX sysgen kernel when certain IP platforms are selected. This is reinforced by the PLATFORM restriction symbols I see scattered around the development artifacts left behind out there. 
3. The USB header files included with IRIX don't specify additional classes beyond those already supported.

PymbleSoftware documented this years ago and I just have been sitting on the bits that he dug up. Part of what I'm doing, along with another dev, is documenting some parts of the IRIX kernel that aren't well documented. 

As people know, Rackable "SGI" appears in 2011 to have mass-shredded hundreds of programming manuals, internal documentation, engineering blueprints and engineer's notes by order of Eng Lim Goh (their CTO at the time) as that's what the SGI employees I went after were able to tell me when I contacted them about it. So we have really, no choice but to try and uncover/document these things ourselves. 

I can't make promises I will be able to uncover everything, but the devs of IRIX left us a ton of breadcrumbs around.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,240
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
02-25-2021, 05:58 PM
#2
RE: Documenting the IRIX USB Subsystem
This is pretty awesome
I tried contacting pymbal but it was a no go. If something was to be done about implementing usb it sure would be easier for newbs to get on board for lower end hardware. The hardest thing for me to get a hold of locally was a ps2 mouse surprisingly. Quite a few keyboards but no mice. Plus I just kind of love the idea of backporting usb mass storage.

did you find any driver developing booklets: Document Number 007-0911-210 : http://www.irix7.com/techpubs/007-0911-210.pdf. Not sure if its relevant but in here: There are books referencing developing for the kernel module: https://irix7.com/techpubs.html huge amount of technical documentation in there I haven't had time to read any of that but it seems pretty comprehensive.

In my o2 my pci card, the firewire part is recognized as dm10 and then the usb ehci and uhci are recognized in the unknown pci tree I was planning on reworking pymbals driver to see what happened with uhci (probably nothing) but just for fun.
mamed
Octane

Trade Count: (0)
Posts: 112
Threads: 29
Joined: Jan 2021
Location: Canada
Find Reply
03-08-2021, 03:27 PM
#3
RE: Documenting the IRIX USB Subsystem
That's an achievement I tried to do with my kernel modules.

In fact the easiest part is to detect the PCI card. AFAIK, to detect new USB devices connect/unconnect/ is also very easy. We just read some PCI registers in the corresponding interfaceUHCI or EHCI depending on the device type we are connecting (Mouse, Keyboards and other low speedies will be taken by the UHCI controller. Hi speed devices will be taken by the EHCI controllers. The VIA8212 has 1 controller for UHCI and 2 for EHCI).

The funny part comes here: USB device enumeration, which we use to know which kind of device is connected, if it's a mouse, a keyboard, a game controller, or whatever, and with that, we get the device type. Fo this, once the new device is detected, we need to do some data exchange with the device. For this, we setup some data structures -a linked list- in the machine's DMA. The DMA chunk must be aligned to... 32k? don't remeber very well, all is in the UHCI/EHCI standard doc. In these linked lists, some data about the transfers is stored and of course, data from the devices are stored there by the UHCI/EHCI interface. If we accomplish this with the controllers UHCI/EHCI/xHCI, we are almost done with the hardest part of a decent USB stack and from here all will just go like a ride in the park.
bsdero
O2

Trade Count: (0)
Posts: 6
Threads: 2
Joined: Jul 2018
Find Reply
03-08-2021, 06:28 PM
#4
RE: Documenting the IRIX USB Subsystem
(03-08-2021, 06:28 PM)bsdero Wrote:  That's an achievement I tried to do with my kernel modules.

In fact the easiest part is to detect the PCI card. AFAIK, to detect new USB devices connect/unconnect/ is also very easy. We just read some PCI registers in the corresponding interfaceUHCI or EHCI depending on the device type we are connecting (Mouse, Keyboards and other low speedies will be taken by the UHCI controller. Hi speed devices will be taken by the EHCI controllers. The VIA8212 has 1 controller for UHCI and 2 for EHCI).

The funny part comes here: USB device enumeration, which we use to know which kind of device is connected, if it's a mouse, a keyboard, a game controller, or whatever, and with that, we get the device type. Fo this, once the new device is detected, we need to do some data exchange with the device. For this, we setup some data structures -a linked list- in the machine's DMA. The DMA chunk must be aligned to... 32k? don't remeber very well, all is in the UHCI/EHCI standard doc. In these linked lists, some data about the transfers is stored and of course, data from the devices are stored there by the UHCI/EHCI interface. If we accomplish this with the controllers UHCI/EHCI/xHCI, we are almost done with the hardest part of a decent USB stack and from here all will just go like a ride in the park.
So I just got the built and loaded partly! All I needed to do was edit:cpuboard=cputype I guess my cpu type wasn't in the table anyway I changed cputype to ip32 and it built. Now for a reason I am not sure of when loaded it loves to kernel panic when uhci is loaded. So I deleted usbuhci.o before loading it and after a few usb bus errors and panics it loaded and showed up in /hw as /hw/usb. When I do hinv tho nothing has changed probably because of not loading the usbuhci.o Also my usb2.0 controller doesn't seem to get loaded I had to put my ohci controller in ehci. Anyway after It loaded I plugged in a couple usb devices and they would light up for a second. since there is no enumeration or anything I assume its turing off after a handshake attempt?
mamed
Octane

Trade Count: (0)
Posts: 112
Threads: 29
Joined: Jan 2021
Location: Canada
Find Reply
03-17-2021, 03:27 PM
#5
RE: Documenting the IRIX USB Subsystem
The reason the kernel panics is likely because you have an O2 which doesn't have USB support at all. The Octane, O2, Onyx2, Origin 2000 weren't built with USB support in mind.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,240
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
03-17-2021, 05:43 PM
#6
RE: Documenting the IRIX USB Subsystem
(03-17-2021, 05:43 PM)Raion Wrote:  The reason the kernel panics is likely because you have an O2 which doesn't have USB support at all. The Octane, O2, Onyx2, Origin 2000 weren't built with USB support in mind.
not sure, Bsdhero said he used it on a fuel and an o2. I'm attempting to shoehorn my card into his code, which is a firewire usb card with 3 usb ports. Its not a VT6212L. sm092503-01 asy90145-sun rev 04 pmd031114-01 made by smart penang, I think they are commonly in g4s according to another forum. Anyway his build seems to be very specific to CPU and mine wasn't on the list so base r5ks are in there even lower end hardware is in there! I just changed board type to ip32 without changing anything else. When I compile I get the pictured error. but it does build anyway: /Desktop/usbirix/build.sh[97]: cflags+= -n32 -D_Pagesz= 4096: not found /Desktop/usbirix/build.sh[159]: cflags+= -dip32 -dr400 -dr10000 -ditriton -duse_PCI_PIO -c99: not found Maybe this is causing kernel panics? The kernel panics are bad address or a pci error. Ive been reviewing the diag info  little bit and that helped me to get ehci working.
I have another o2 with a cpu which is on the list the base r5000 180mhz so I may buy a VT6212L on ebay and try that as they are absolutely dirt cheap and it might be easier than shoehorning my own card in as it may have different coding needs and I haven't found a datasheet or source code yet for my card. Ill have to ask bsdhero more about the driver and how it works normally when a usb device is plugged in. But I think putting my ohci controller in ehci and actually getting it to load properly every time even though it doesn't show in hinv and even light up a usb device is definitelly proof of concept.


Attached Files Image(s)
   
(This post was last modified: 03-18-2021, 05:14 PM by mamed.)
mamed
Octane

Trade Count: (0)
Posts: 112
Threads: 29
Joined: Jan 2021
Location: Canada
Find Reply
03-18-2021, 05:13 PM
#7
RE: Documenting the IRIX USB Subsystem
I'm just telling you that these systems were not designed for USB so it's entirely possible there are bugs from that.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,240
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
03-18-2021, 06:31 PM
#8
RE: Documenting the IRIX USB Subsystem
(03-17-2021, 05:43 PM)Raion Wrote:  The reason the kernel panics is likely because you have an O2 which doesn't have USB support at all. The Octane, O2, Onyx2, Origin 2000 weren't built with USB support in mind.

Even if there is not support for USB at all, we have support for PCI.  As Irix kernel has not an API for USB developers -and if it has, is not documented at all-, a complete USB stack and its API for kernel modules must be written from scratch and not only the hw layer.

Hi, 1.-Please use GNU make. Check if it's on your path. Make sure the build script is using it. 2.-The drivers were written for PCI cards with USB ports.  Is your firewire card a PCI card?
(This post was last modified: 03-22-2021, 12:01 AM by Raion.)
bsdero
O2

Trade Count: (0)
Posts: 6
Threads: 2
Joined: Jul 2018
Find Reply
03-21-2021, 07:08 PM
#9
RE: Documenting the IRIX USB Subsystem
(03-21-2021, 07:08 PM)bsdero Wrote:  Even if there is not support for USB at all, we have support for PCI.  As Irix kernel has not an API for USB developers -and if it has, is not documented at all-, a complete USB stack and its API for kernel modules must be written from scratch and not only the hw layer.

Hi, 1.-Please use GNU make. Check if it's on your path. Make sure the build script is using it. 2.-The drivers were written for PCI cards with USB ports.  Is your firewire card a PCI card?
I need to check back on this thread more, gnu and all that good stuff is in my path, This is a 3 port usb pci card with 1 firewire port. So yep it has usb support and separate controllers.
 The modules now build correctly without errors  after changing the cflags in the build script, to be CFLAGS=$CFLAGS instead of CFLAGS+= on the flags that couldn't be found.  Now I no longer need to change my processor board type manually in the script and it autodetects. Now the modules work as long as I only use my EHCI controller no kernel panics anymore. However if I enter my uhci controller device id and vendor id into the uhci.c I still get kernel panics Ill have to do some more diagnosis to figure out why but it seems to be due to the hcd driver for some reason at least for now because without the uhci controller the hcd driver appears to function normally.  
Yes it will be a lot of work but how awesome would it be to have usb on a computer from 1997. That's news article worthy.
(This post was last modified: 03-24-2021, 10:56 PM by mamed.)
mamed
Octane

Trade Count: (0)
Posts: 112
Threads: 29
Joined: Jan 2021
Location: Canada
Find Reply
03-24-2021, 10:54 PM
#10
RE: Documenting the IRIX USB Subsystem
(03-24-2021, 10:54 PM)mamed Wrote:  However if I enter my uhci controller device id and vendor id into the uhci.c I still get kernel panics Ill have to do some more diagnosis to figure out why but it seems to be due to the hcd driver for some reason at least for now because without the uhci controller the hcd driver appears to function normally.  
Yes it will be a lot of work but how awesome would it be to have usb on a computer from 1997. That's news article worthy.
Does the Firewire/USB card actually have a UHCI controller? My experience is that they used OHCI controllers.

Personaliris O2 Indigo2 R10000/IMPACT Indigo2 R10000/IMPACT Indigo2 Indy   (past: 4D70GT)
robespierre
refector peritus

Trade Count: (0)
Posts: 640
Threads: 3
Joined: Nov 2020
Location: Massholium
Find Reply
03-24-2021, 11:57 PM


Forum Jump:


Users browsing this thread: 1 Guest(s)