Author: cgutman Date: Sat May 8 23:53:57 2010 New Revision: 47136
URL: http://svn.reactos.org/svn/reactos?rev=47136&view=rev Log: [USBDRIVER] - Fix an off-by-one error in the probing code - Scan all PCI buses instead of just the first two - Fix a horrible bug that resulted in reinitializing EHCI controllers as UHCI controllers which caused a crash on VirtualBox (with _MULTI_UHCI) - Implement support for multiple EHCI controllers and enable support for multiple UHCI controllers (greatly increases compatibility with real hardware because the first controller detected is often internal)
Modified: trunk/reactos/drivers/usb/nt4compat/usbdriver/ehci.c trunk/reactos/drivers/usb/nt4compat/usbdriver/uhci.c trunk/reactos/drivers/usb/nt4compat/usbdriver/usbdriver.rbuild
Modified: trunk/reactos/drivers/usb/nt4compat/usbdriver/ehci.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/nt4compat/usbdr... ============================================================================== --- trunk/reactos/drivers/usb/nt4compat/usbdriver/ehci.c [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/nt4compat/usbdriver/ehci.c [iso-8859-1] Sat May 8 23:53:57 2010 @@ -3461,18 +3461,19 @@ PDEVICE_OBJECT pdev; BYTE buffer[sizeof(PCI_COMMON_CONFIG)]; PEHCI_DEVICE_EXTENSION pdev_ext; + LONG count = 0;
slot_num.u.AsULONG = 0; pci_config = (PPCI_COMMON_CONFIG) buffer; pdev = NULL;
- //scan the bus to find ehci controller - for(bus = 0; bus < 3; bus++) /* enum bus0-bus2 */ - { - for(i = 0; i < PCI_MAX_DEVICES; i++) + //scan the PCI buses to find ehci controller + for (bus = 0; bus <= PCI_MAX_BRIDGE_NUMBER; bus++) //Yes, it should be <= + { + for(i = 0; i <= PCI_MAX_DEVICES; i++) { slot_num.u.bits.DeviceNumber = i; - for(j = 0; j < PCI_MAX_FUNCTIONS; j++) + for(j = 0; j <= PCI_MAX_FUNCTION; j++) { slot_num.u.bits.FunctionNumber = j;
@@ -3490,9 +3491,12 @@ { //well, we find our usb host controller( EHCI ), create device pdev = ehci_alloc(drvr_obj, reg_path, ((bus << 8) | (i << 3) | j), dev_mgr); - - if (!pdev) - continue; + if (pdev) +#ifdef _MULTI_EHCI + count++; +#else + goto LBL_LOOPOUT; +#endif } }
@@ -3500,6 +3504,11 @@ break; } } + +#ifndef _MULTI_EHCI +LBL_LOOPOUT: +#endif + DbgPrint("Found %d EHCI controllers\n", count);
if (pdev) {
Modified: trunk/reactos/drivers/usb/nt4compat/usbdriver/uhci.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/nt4compat/usbdr... ============================================================================== --- trunk/reactos/drivers/usb/nt4compat/usbdriver/uhci.c [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/nt4compat/usbdriver/uhci.c [iso-8859-1] Sat May 8 23:53:57 2010 @@ -626,13 +626,13 @@ count = 0; pdev = NULL;
- //scan the bus to find uhci controller - for(bus = 0; bus < 3; bus++) /* enum bus0-bus2 */ - { - for(i = 0; i < PCI_MAX_DEVICES; i++) + //scan the PCI buses to find uhci controller + for (bus = 0; bus <= PCI_MAX_BRIDGE_NUMBER; bus++) + { + for(i = 0; i <= PCI_MAX_DEVICES; i++) { slot_num.u.bits.DeviceNumber = i; - for(j = 0; j < PCI_MAX_FUNCTIONS; j++) + for(j = 0; j <= PCI_MAX_FUNCTION; j++) { slot_num.u.bits.FunctionNumber = j;
@@ -645,18 +645,15 @@ if (ret == 2) /*no device on the slot */ break;
- if (pci_config->BaseClass == 0x0c && pci_config->SubClass == 0x03) + if (pci_config->BaseClass == 0x0c && pci_config->SubClass == 0x03 && + pci_config->ProgIf == 0x00) { // well, we find our usb host controller, create device -#ifdef _MULTI_UHCI - { - pdev = uhci_alloc(drvr_obj, reg_path, ((bus << 8) | (i << 3) | j), dev_mgr); - if (pdev) - count++; - } -#else pdev = uhci_alloc(drvr_obj, reg_path, ((bus << 8) | (i << 3) | j), dev_mgr); if (pdev) +#ifdef _MULTI_UHCI + count++; +#else goto LBL_LOOPOUT; #endif } @@ -669,6 +666,8 @@ #ifndef _MULTI_UHCI LBL_LOOPOUT: #endif + DbgPrint("Found %d UHCI controllers\n", count); + if (pdev) { pdev_ext = pdev->DeviceExtension;
Modified: trunk/reactos/drivers/usb/nt4compat/usbdriver/usbdriver.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/nt4compat/usbdr... ============================================================================== --- trunk/reactos/drivers/usb/nt4compat/usbdriver/usbdriver.rbuild [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/nt4compat/usbdriver/usbdriver.rbuild [iso-8859-1] Sat May 8 23:53:57 2010 @@ -2,6 +2,8 @@ <!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd"> <module name="usbdriver" type="kernelmodedriver" installbase="system32/drivers" installname="usbdriver.sys"> <define name="INCLUDE_EHCI" /> + <define name="_MULTI_UHCI" /> + <define name="_MULTI_EHCI" /> <define name="_X86" /> <include base="usbdriver">.</include> <library>ntoskrnl</library>