X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FBus%2FUsb%2FUsbBusDxe%2FUsbEnumer.c;h=a6dc1c0c29d52f5d1d7c29d7bfc9068a917e5b4c;hp=4c2e5ffa6501af2e0079ced2a2f5ae35532b5a0b;hb=cd5ebaa06dca3e6ef3c464081e6defe00d358c69;hpb=17d6c2e782dd6453fc0cb909d58860b2d6004aba diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c index 4c2e5ffa65..a6dc1c0c29 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c @@ -2,8 +2,8 @@ Usb bus enumeration support. -Copyright (c) 2007 - 2008, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -109,6 +109,7 @@ UsbCreateInterface ( UsbIf->Signature = USB_INTERFACE_SIGNATURE; UsbIf->Device = Device; UsbIf->IfDesc = IfDesc; + ASSERT (IfDesc->ActiveIndex < USB_MAX_INTERFACE_SETTING); UsbIf->IfSetting = IfDesc->Settings[IfDesc->ActiveIndex]; CopyMem ( @@ -279,7 +280,7 @@ UsbConnectDriver ( // if (UsbBusIsWantedUsbIO (UsbIf->Device->Bus, UsbIf)) { OldTpl = UsbGetCurrentTpl (); - DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d\n", (UINT32)OldTpl)); + DEBUG ((EFI_D_INFO, "UsbConnectDriver: TPL before connect is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle)); gBS->RestoreTPL (TPL_CALLBACK); @@ -325,6 +326,7 @@ UsbSelectSetting ( Setting = NULL; for (Index = 0; Index < IfDesc->NumOfSetting; Index++) { + ASSERT (Index < USB_MAX_INTERFACE_SETTING); Setting = IfDesc->Settings[Index]; if (Setting->Desc.AlternateSetting == Alternate) { @@ -338,6 +340,7 @@ UsbSelectSetting ( IfDesc->ActiveIndex = Index; + ASSERT (Setting != NULL); DEBUG ((EFI_D_INFO, "UsbSelectSetting: setting %d selected for interface %d\n", Alternate, Setting->Desc.InterfaceNumber)); @@ -420,6 +423,7 @@ UsbSelectConfig ( return EFI_OUT_OF_RESOURCES; } + ASSERT (Index < USB_MAX_INTERFACE); Device->Interfaces[Index] = UsbIf; // @@ -452,6 +456,7 @@ UsbDisconnectDriver ( ) { EFI_TPL OldTpl; + EFI_STATUS Status; // // Release the hub if it's a hub controller, otherwise @@ -469,14 +474,14 @@ UsbDisconnectDriver ( // or disconnect at CALLBACK. // OldTpl = UsbGetCurrentTpl (); - DEBUG ((EFI_D_INFO, "UsbDisconnectDriver: old TPL is %d\n", (UINT32)OldTpl)); + DEBUG ((EFI_D_INFO, "UsbDisconnectDriver: old TPL is %d, %p\n", (UINT32)OldTpl, UsbIf->Handle)); gBS->RestoreTPL (TPL_CALLBACK); - gBS->DisconnectController (UsbIf->Handle, NULL, NULL); + Status = gBS->DisconnectController (UsbIf->Handle, NULL, NULL); UsbIf->IsManaged = FALSE; - DEBUG (( EFI_D_INFO, "UsbDisconnectDriver: TPL after disconnect is %d\n", (UINT32)UsbGetCurrentTpl())); + DEBUG (( EFI_D_INFO, "UsbDisconnectDriver: TPL after disconnect is %d, %d\n", (UINT32)UsbGetCurrentTpl(), Status)); ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK); gBS->RaiseTPL (OldTpl); @@ -501,7 +506,8 @@ UsbRemoveConfig ( // // Remove each interface of the device // - for (Index = 0; Index < Device->NumOfInterface; Index++) { + for (Index = 0; Index < Device->NumOfInterface; Index++) { + ASSERT (Index < USB_MAX_INTERFACE); UsbIf = Device->Interfaces[Index]; if (UsbIf == NULL) { @@ -561,6 +567,7 @@ UsbRemoveDevice ( DEBUG (( EFI_D_INFO, "UsbRemoveDevice: device %d removed\n", Device->Address)); + ASSERT (Device->Address < USB_MAX_DEVICES); Bus->Devices[Device->Address] = NULL; UsbFreeDevice (Device); @@ -845,8 +852,8 @@ UsbEnumeratePort ( return EFI_SUCCESS; } - DEBUG (( EFI_D_INFO, "UsbEnumeratePort: port %d state - %x, change - %x\n", - Port, PortState.PortStatus, PortState.PortChangeStatus)); + DEBUG (( EFI_D_INFO, "UsbEnumeratePort: port %d state - %x, change - %x on %p\n", + Port, PortState.PortStatus, PortState.PortChangeStatus, HubIf)); // // This driver only process two kinds of events now: over current and @@ -900,7 +907,7 @@ UsbEnumeratePort ( Child = UsbFindChild (HubIf, Port); if (Child != NULL) { - DEBUG (( EFI_D_INFO, "UsbEnumeratePort: device at port %d removed from system\n", Port)); + DEBUG (( EFI_D_INFO, "UsbEnumeratePort: device at port %d removed from root hub %p\n", Port, HubIf)); UsbRemoveDevice (Child); }