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