]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Clean up gEfiHotPlugDeviceGuid in ConPlatformDxe.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 23 Feb 2009 02:12:01 +0000 (02:12 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 23 Feb 2009 02:12:01 +0000 (02:12 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7559 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.h
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf

index f3aa4a4fb3041c4b480befca1a036f594f6e98bd..0cb07a2971aa2a5f505c3495bc28e339739c2221 100644 (file)
@@ -261,7 +261,7 @@ ConPlatformTextInDriverBindingStart (
   // gEfiConsoleInDeviceGuid to the device handle directly.\r
   // The policy is, make hot plug device plug in and play immediately.\r
   //\r
-  if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
+  if (IsHotPlugDevice (DevicePath)) {\r
     gBS->InstallMultipleProtocolInterfaces (\r
            &ControllerHandle,\r
            &gEfiConsoleInDeviceGuid,\r
@@ -378,7 +378,7 @@ ConPlatformTextOutDriverBindingStart (
   // and install gEfiConsoleOutDeviceGuid to the device handle directly.\r
   // The policy is, make hot plug device plug in and play immediately.\r
   //\r
-  if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
+  if (IsHotPlugDevice (DevicePath)) {\r
     gBS->InstallMultipleProtocolInterfaces (\r
            &ControllerHandle,\r
            &gEfiConsoleOutDeviceGuid,\r
@@ -481,32 +481,36 @@ ConPlatformTextInDriverBindingStop (
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
 \r
+  //\r
+  // Get the Device Path Protocol firstly\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &DevicePath,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
   //\r
   // If it is not a hot-plug device, first delete it from the ConInDev variable.\r
   //\r
-  if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
+  if (!IsHotPlugDevice (DevicePath)) {\r
+   //\r
+    // Remove DevicePath from ConInDev\r
     //\r
-    // Get the Device Path Protocol so the environment variables can be updated\r
-    //\r
-    Status = gBS->OpenProtocol (\r
-                    ControllerHandle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    (VOID **) &DevicePath,\r
-                    This->DriverBindingHandle,\r
-                    ControllerHandle,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Remove DevicePath from ConInDev\r
-      //\r
-      ConPlatformUpdateDeviceVariable (\r
-        L"ConInDev",\r
-        DevicePath,\r
-        DELETE\r
-        );\r
-    }\r
+    ConPlatformUpdateDeviceVariable (\r
+      L"ConInDev",\r
+      DevicePath,\r
+      DELETE\r
+      );\r
   }\r
+\r
   //\r
   // Uninstall the Console Device GUIDs from Controller Handle\r
   //\r
@@ -556,37 +560,41 @@ ConPlatformTextOutDriverBindingStop (
   EFI_STATUS                Status;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
 \r
+  //\r
+  // Get the Device Path Protocol firstly\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ControllerHandle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &DevicePath,\r
+                  This->DriverBindingHandle,\r
+                  ControllerHandle,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
   //\r
   // If it is not a hot-plug device, first delete it from the ConOutDev and ErrOutDev variable.\r
   //\r
-  if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
+  if (!IsHotPlugDevice (DevicePath)) {\r
     //\r
-    // Get the Device Path Protocol so the environment variables can be updated\r
+    // Remove DevicePath from ConOutDev, and ErrOutDev\r
     //\r
-    Status = gBS->OpenProtocol (\r
-                    ControllerHandle,\r
-                    &gEfiDevicePathProtocolGuid,\r
-                    (VOID **) &DevicePath,\r
-                    This->DriverBindingHandle,\r
-                    ControllerHandle,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Remove DevicePath from ConOutDev, and ErrOutDev\r
-      //\r
-      ConPlatformUpdateDeviceVariable (\r
-        L"ConOutDev",\r
-        DevicePath,\r
-        DELETE\r
-        );\r
-      ConPlatformUpdateDeviceVariable (\r
-        L"ErrOutDev",\r
-        DevicePath,\r
-        DELETE\r
-        );\r
-    }\r
+    ConPlatformUpdateDeviceVariable (\r
+      L"ConOutDev",\r
+      DevicePath,\r
+      DELETE\r
+      );\r
+    ConPlatformUpdateDeviceVariable (\r
+      L"ErrOutDev",\r
+      DevicePath,\r
+      DELETE\r
+      );\r
   }\r
\r
   //\r
   // Uninstall the Console Device GUIDs from Controller Handle\r
   //\r
@@ -929,10 +937,12 @@ ConPlatformUpdateDeviceVariable (
 }\r
 \r
 /**\r
-  Check if the device supports hot-plug.\r
+  Check if the device supports hot-plug through its device path.\r
+\r
+  This function could be updated to check more types of Hot Plug devices.\r
+  Currently, it checks USB and PCCard device.\r
 \r
-  @param  DriverBindingHandle   Protocol instance pointer.\r
-  @param  ControllerHandle      Handle of device to check.\r
+  @param  DevicePath            Pointer to device's device path.\r
 \r
   @retval TRUE                  The devcie is a hot-plug device\r
   @retval FALSE                 The devcie is not a hot-plug device.\r
@@ -940,26 +950,28 @@ ConPlatformUpdateDeviceVariable (
 **/\r
 BOOLEAN\r
 IsHotPlugDevice (\r
-  EFI_HANDLE    DriverBindingHandle,\r
-  EFI_HANDLE    ControllerHandle\r
+  IN  EFI_DEVICE_PATH_PROTOCOL    *DevicePath\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
-\r
   //\r
-  // HotPlugDeviceGuid indicates ControllerHandle stands for a hot plug device.\r
-  //\r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiHotPlugDeviceGuid,\r
-                  NULL,\r
-                  DriverBindingHandle,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return FALSE;\r
+  // Check device whether is hot plug device or not throught Device Path\r
+  // \r
+  if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&\r
+      (DevicePathSubType (DevicePath) == MSG_USB_DP ||\r
+       DevicePathSubType (DevicePath) == MSG_USB_CLASS_DP ||\r
+       DevicePathSubType (DevicePath) == MSG_USB_WWID_DP)) {\r
+    //\r
+    // If Device is USB device\r
+    //\r
+    return TRUE;\r
+  }\r
+  if ((DevicePathType (DevicePath) == HARDWARE_DEVICE_PATH) &&\r
+      (DevicePathSubType (DevicePath) == HW_PCCARD_DP)) {\r
+    //\r
+    // If Device is PCCard\r
+    //\r
+    return TRUE;\r
   }\r
 \r
-  return TRUE;\r
+  return FALSE;\r
 }\r
index f7883dce6cb14f92961010a15ddcc806872360cb..d0fa03af5bf6d4ebeb4ba12f861b1a042a49ed7b 100644 (file)
@@ -293,10 +293,12 @@ ConPlatformUpdateDeviceVariable (
   );\r
 \r
 /**\r
-  Check if the device supports hot-plug.\r
+  Check if the device supports hot-plug through its device path.\r
 \r
-  @param  DriverBindingHandle   Protocol instance pointer.\r
-  @param  ControllerHandle      Handle of device to check.\r
+  This function could be updated to check more types of Hot Plug devices.\r
+  Currently, it checks USB and PCCard device.\r
+\r
+  @param  DevicePath            Pointer to device's device path.\r
 \r
   @retval TRUE                  The devcie is a hot-plug device\r
   @retval FALSE                 The devcie is not a hot-plug device.\r
@@ -304,8 +306,7 @@ ConPlatformUpdateDeviceVariable (
 **/\r
 BOOLEAN\r
 IsHotPlugDevice (\r
-  EFI_HANDLE    DriverBindingHandle,\r
-  EFI_HANDLE    ControllerHandle\r
+  IN  EFI_DEVICE_PATH_PROTOCOL    *DevicePath\r
   );\r
 \r
 //\r
index a96a6330a0d926a95c1a2331ea538efb42467b4b..892d051a1a1f16255eca860a47f8913eb7731632 100644 (file)
@@ -87,5 +87,4 @@
   gEfiDevicePathProtocolGuid                    ## TO_START\r
   gEfiSimpleTextInProtocolGuid                  ## TO_START\r
   gEfiSimpleTextOutProtocolGuid                 ## TO_START\r
-  gEfiHotPlugDeviceGuid                         ## SOMETIMES_CONSUMES (Used to check if it's a hot-plug device)\r
   
\ No newline at end of file