Updates to the host controller drivers USBUHCD.SYS,USBOHCD.SYS,USBEHCD.SYS

1.) the base of these driver updates is the latest IBM sources.
    Unfortunately these do not reflect versions 10.162 of the IBM provided drivers. The DDK sources seem
    to got stuck in stage "work in progress"

2.) I worked on a couple of things:
    a) changed the "scan+assign" logic to no longer use the Resource Manager to find out what host controller
       driver instance is serving what USB device
    b) for USBUHCD.SYS, I changed the logic how to disable "legacy support" (a USB keyboard/mouse being emulated
       as a PS/2 keyboard/mouse) when the USB host controller driver USBUHCD.SYS takes over
    c) I added PCI Power Management (PCI PM) code to all host controller drivers. Fact is, that all newer USB
       host controllers support this feature. This becomes important if you boot into Windows (XP, 7 whatever)
       and subsequently boot into OS/2: on shutdown, Windows uses PCI PM to power down the USB host controllers.
       You need to use PCI PM to properly wake them up on OS/2 bootup.
    d) some extensive clean up of the code to only use the OEMHLP$ driver (built into the kernel, or, if ACPI.PSD
       is in use, the replacement that is built into ACPI.PSD) for all PCI config space related accesses.
    e) other clean up on the code
    f) Potentially fixed a bug in USBOHCD.SYS: it seemingly tried to set a bit in the wrong register (looked like typo)
       Host Controller Reset routine (in particular: turning off USB legacy support in the host controller) is affected.
    g) kicked out a bunch of superfluous CLI. At one point it also looked like interrupts were erroneously being disabled
       and left disabled for too long time
    h) I had hosed the /V display. I fixed it. Hope it's now back to working.
    i) USBEHCD.SYS: merged in the latest changes from Gregg Young (thanks Gregg Young !)
    j) USBEHCD.SYS: fixed a potential NULL pointer problem when reading from a highspeed bulk input pipe (thanks Rdiger Ihle !)
    k) USBEHCD.SYS: increasing to maximum read speed (thanks Robert Lalla !). Currently it's static, I hope I can make that
       configurable via command line parameters in due time
    l) USBEHCD.SYS: did a couple of changes to the Suspend and Resume code. Fixed Suspended flag, reset this flag on resume.
       If you had Suspend/Resume working and now it becomes broken, please report back.
    m) USBUHCD.SYS,USBOHCD.SYS: fixed a bug that I accidentally introduced when checking for PCI PM support
    n) USBUHCD.SYS: completely reworked the "UHCIResetHost" routine, it now more or less follows this (german):
       http://www.lowlevel.eu/wiki/Universal_Host_Controller_Interface
       That should hopefully fix the problems with using a PS/2 mouse (instead of or along with a USB mouse)
    o) USBOHCD.SYS: kicked out some nonsense code from OHCIInit that attempted to disable legacy support,
       for OHCI (USBOHCD.SYS) it does NOT work the same way as for UHCI (USBUHCD.SYS) but the code attempted to do
       it the same way !
    p) USBOHCD.SYS: added a context hook to handle start of frame instead of 
       handling it directly from within the interrupt handler (thanks Rdiger Ihle !)	
    q) USBEHCD.SYS: fixed a bug I accidentally introduced when doing k)
    r) USBOHCD.SYS: an attempt to properly deal with USB legacy support, it was not completely implemented
    s) USBOHCD.SYS, USBUHCD.SYS: a couple of minor changes
    t) USBEHCD.SYS: make k) configurable (/S:n where n=1,2,4,8,16,32,64, run with /V to see this info)
    u) USBOHCD.SYS: enable passthrough for real PS/2 mouse/keyboard. Should now allow peaceful coexistence
                    of PS/2 mouse and/or keyboard with USB mouse and/or keyboard
    v) USBUHCD.SYS, USBOHCD.SYS: an attempt to properly switch from legacy USB on boot and switch back to legacy USB
                    on shutdown. However I believe it needs more (to switch back to legacy USB on shutdown).
                    This is relevant so that you can continue to use your USB mouse/keyboard after OS/2 has shutdown.
    w) USBUHCD.SYS: a new attempt to properly bring the system out of legacy USB. It seems to take a very long time
                    on INTEL chipsets if USB legacy support is enabled in BIOS.
    x) USBUHCD.SYS, USBOHCD.SYS, USBEHCD.SYS: rewrote the routines to check if a USB host controller has the necessary
                    resources (IRQ, memory or I/O base address). That will prevent the drivers to load if for example
                    no IRQ was properly assigned to this device (which is absolutely necessary for the device to properly
                    operate). Should prevent hangs on systems that do not properly assign all necessary operational resources.


There are still some improvements to be made but hopefully these drivers fix some of the problems you might have
experienced with the IBM provided drivers (host controllers and therefore some USB ports being unusuable, hangs on
bootup, etc.).

Make sure you back up your existing drivers ! These drivers come without any warranty whatsoever. If they don't work
for you, revert back to your backed up drivers.

Please test and report results in the appropriate newsgroups or to:
lars.erdmann@arcor.de

I'd be especially interested in reports on older systems (also without ACPI.PSD) and on systems using ACPI.PSD
in APIC mode (/APIC) and/or multi-core (/SMP). These drivers SHOULD work on the latter systems (one user reported
success for /APIC and /SMP) but YMMV. As time permits, I will try and solve the problems.

Please provide as much info as you can:
1.) Did it work with the IBM supplied 10.162 drivers ? Also try combinations of IBM drivers and these drivers
2.) Kernel version: run "bldlevel OS2KRNL" from the root directory
3.) how many CPUs / CPU cores ?
4.) ACPI.PSD ? What switches ?
5.) What type of USB ? UHCI ? OHCI ? EHCI ? Output of "pci.exe" is very helpful:
    http://hobbes.nmsu.edu/download/pub/os2/util/misc/pci104vka.zip
    If you have eCS 2.0, you can instead use:
    \ecs\install\DETECTEI\pciscan.exe
6.) USB relevant parts in Config.sys, in particular, order and number of driver instances: USBD.SYS and USB(I|O|E)HCD.SYS
7.) if trap or hang: describe as good as you can: when exactly does it hang ? Can you check by hitting
    Alt-F2 when boot blob in upper left corner shows up and note down last driver that loaded successfully ?
    What driver / daemon program would load after the last successfully loaded driver ?
    If trap in USB(I|O|E)HCD.SYS: note down trap screen, CS:IP, SS:BP and AX,BX,CX,DX,ES,DS are especially important

Lars Erdmann

