]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Code Scrub for ConPlatform.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 7 Nov 2008 07:18:15 +0000 (07:18 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 7 Nov 2008 07:18:15 +0000 (07:18 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6425 6f19259b-4bc3-4df7-8a09-765794883524

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

index 5deff627c69c7a9e2c8e3eaf594912323bd9391d..9d28b20009923713ee4d7a5759443bb5ef79ccc1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   UEFI Component Name(2) protocol implementation for ConPlatform driver.\r
 \r
-Copyright (c) 2006, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
 All rights reserved. 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
@@ -56,7 +56,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConPlatformDriverNameTab
 \r
   @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
   @param  Language[in]          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language. This is the\r
                                 language of the driver name that the caller is\r
@@ -65,7 +64,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConPlatformDriverNameTab
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified\r
                                 in RFC 3066 or ISO 639-2 language code format.\r
-\r
   @param  DriverName[out]       A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 driver specified by This in the language\r
@@ -74,11 +72,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConPlatformDriverNameTab
   @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
                                 This and the language specified by Language was\r
                                 returned in DriverName.\r
-\r
   @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
   @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
   @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
                                 the language specified by Language.\r
 \r
@@ -115,12 +110,10 @@ ConPlatformComponentNameGetDriverName (
 \r
   @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
   @param  ControllerHandle[in]  The handle of a controller that the driver\r
                                 specified by This is managing.  This handle\r
                                 specifies the controller whose name is to be\r
                                 returned.\r
-\r
   @param  ChildHandle[in]       The handle of the child controller to retrieve\r
                                 the name of.  This is an optional parameter that\r
                                 may be NULL.  It will be NULL for device\r
@@ -129,7 +122,6 @@ ConPlatformComponentNameGetDriverName (
                                 controller.  It will not be NULL for a bus\r
                                 driver that wishes to retrieve the name of a\r
                                 child controller.\r
-\r
   @param  Language[in]          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language.  This is the\r
                                 language of the driver name that the caller is\r
@@ -138,7 +130,6 @@ ConPlatformComponentNameGetDriverName (
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified in\r
                                 RFC 3066 or ISO 639-2 language code format.\r
-\r
   @param  ControllerName[out]   A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 controller specified by ControllerHandle and\r
@@ -150,20 +141,14 @@ ConPlatformComponentNameGetDriverName (
                                 the language specified by Language for the\r
                                 driver specified by This was returned in\r
                                 DriverName.\r
-\r
   @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
                                 EFI_HANDLE.\r
-\r
   @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
   @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
   @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
                                 managing the controller specified by\r
                                 ControllerHandle and ChildHandle.\r
-\r
   @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
                                 the language specified by Language.\r
 \r
index e8db9ad3db52da28b52e1a9bba96e292fb366542..f2f7d4caecf96064ee1732938b770a0930530d3a 100644 (file)
@@ -35,13 +35,15 @@ EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding = {
 };\r
 \r
 /**\r
-  The user Entry Point for module ConPlatform. The user code starts with this function.\r
+  Entrypoint of this module.\r
+\r
+  This function is the entrypoint of this module. It installs Driver Binding\r
+  Protocols together with Component Name Protocols.\r
 \r
   @param  ImageHandle       The firmware allocated handle for the EFI image.\r
   @param  SystemTable       A pointer to the EFI System Table.\r
 \r
   @retval EFI_SUCCESS       The entry point is executed successfully.\r
-  @retval other             Some error occurs when executing this entry point.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -53,9 +55,6 @@ InitializeConPlatform(
 {\r
   EFI_STATUS              Status;\r
 \r
-  //\r
-  // Install driver model protocol(s).\r
-  //\r
   Status = EfiLibInstallDriverBindingComponentName2 (\r
              ImageHandle,\r
              SystemTable,\r
@@ -76,13 +75,12 @@ InitializeConPlatform(
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-\r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 \r
 /**\r
-  Test to see if EFI Text In Protocol could be supported on the ControllerHandle. \r
+  Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle. \r
 \r
   @param  This                Protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
@@ -98,20 +96,19 @@ EFIAPI
 ConPlatformTextInDriverBindingSupported (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  OPTIONAL\r
   )\r
 {\r
   return ConPlatformDriverBindingSupported (\r
-          This,\r
-          ControllerHandle,\r
-          RemainingDevicePath,\r
-          &gEfiSimpleTextInProtocolGuid\r
-          );\r
+           This,\r
+           ControllerHandle,\r
+           &gEfiSimpleTextInProtocolGuid\r
+           );\r
 }\r
 \r
 \r
 /**\r
-  Test to see if EFI Text Out Protocol could be supported on the ControllerHandle. \r
+  Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle. \r
 \r
   @param  This                Protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
@@ -127,25 +124,22 @@ EFIAPI
 ConPlatformTextOutDriverBindingSupported (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  OPTIONAL\r
   )\r
 {\r
   return ConPlatformDriverBindingSupported (\r
-          This,\r
-          ControllerHandle,\r
-          RemainingDevicePath,\r
-          &gEfiSimpleTextOutProtocolGuid\r
-          );\r
+           This,\r
+           ControllerHandle,\r
+           &gEfiSimpleTextOutProtocolGuid\r
+           );\r
 }\r
 \r
 \r
 /**\r
-  Test to see if the specified Protocol could be supported on the ControllerHandle. \r
+  Test to see if the specified protocol is supported on ControllerHandle. \r
 \r
   @param  This                Protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
-                              device to start.\r
   @param  ProtocolGuid        The specfic protocol.\r
 \r
   @retval EFI_SUCCESS         This driver supports this device.\r
@@ -156,7 +150,6 @@ EFI_STATUS
 ConPlatformDriverBindingSupported (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath,\r
   IN  EFI_GUID                     *ProtocolGuid\r
   )\r
 {\r
@@ -194,17 +187,19 @@ ConPlatformDriverBindingSupported (
   }\r
 \r
   gBS->CloseProtocol (\r
-        ControllerHandle,\r
-        ProtocolGuid,\r
-        This->DriverBindingHandle,\r
-        ControllerHandle\r
-        );\r
+         ControllerHandle,\r
+         ProtocolGuid,\r
+         This->DriverBindingHandle,\r
+         ControllerHandle\r
+         );\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
-  Start this driver on ControllerHandle by opening Simple Text In protocol,\r
+  Start this driver on the device for console input.\r
+\r
+  Start this driver on ControllerHandle by opening Simple Text Input Protocol,\r
   reading Device Path, and installing Console In Devcice GUID on ControllerHandle.\r
 \r
   If this devcie is not one hot-plug devce, append its device path into the \r
@@ -228,8 +223,8 @@ ConPlatformTextInDriverBindingStart (
   IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
   )\r
 {\r
-  EFI_STATUS                  Status;\r
-  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;\r
+  EFI_STATUS                     Status;\r
+  EFI_DEVICE_PATH_PROTOCOL       *DevicePath;\r
   EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r
 \r
   //\r
@@ -247,7 +242,7 @@ ConPlatformTextInDriverBindingStart (
     return Status;\r
   }\r
   //\r
-  // Open the Simple Input Protocol BY_DRIVER\r
+  // Open the Simple Text Input Protocol BY_DRIVER\r
   //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
@@ -268,14 +263,15 @@ ConPlatformTextInDriverBindingStart (
   //\r
   if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
     gBS->InstallMultipleProtocolInterfaces (\r
-          &ControllerHandle,\r
-          &gEfiConsoleInDeviceGuid,\r
-          NULL,\r
-          NULL\r
-          );\r
+           &ControllerHandle,\r
+           &gEfiConsoleInDeviceGuid,\r
+           NULL,\r
+           NULL\r
+           );\r
   } else {\r
     //\r
-    // Append the device path to the ConInDev environment variable\r
+    // If it is not a hot-plug device, append the device path to the\r
+    // ConInDev environment variable\r
     //\r
     ConPlatformUpdateDeviceVariable (\r
       L"ConInDev",\r
@@ -284,29 +280,29 @@ ConPlatformTextInDriverBindingStart (
       );\r
 \r
     //\r
-    // If the device path is an instance in the ConIn environment variable,\r
+    // If the device path is successfully added to the ConIn environment variable,\r
     // then install EfiConsoleInDeviceGuid onto ControllerHandle\r
     //\r
     Status = ConPlatformUpdateDeviceVariable (\r
-              L"ConIn",\r
-              DevicePath,\r
-              CHECK\r
-              );\r
+               L"ConIn",\r
+               DevicePath,\r
+               CHECK\r
+               );\r
 \r
     if (!EFI_ERROR (Status)) {\r
       gBS->InstallMultipleProtocolInterfaces (\r
-            &ControllerHandle,\r
-            &gEfiConsoleInDeviceGuid,\r
-            NULL,\r
-            NULL\r
-            );\r
+             &ControllerHandle,\r
+             &gEfiConsoleInDeviceGuid,\r
+             NULL,\r
+             NULL\r
+             );\r
     } else {\r
       gBS->CloseProtocol (\r
-            ControllerHandle,\r
-            &gEfiSimpleTextInProtocolGuid,\r
-            This->DriverBindingHandle,\r
-            ControllerHandle\r
-            );\r
+             ControllerHandle,\r
+             &gEfiSimpleTextInProtocolGuid,\r
+             This->DriverBindingHandle,\r
+             ControllerHandle\r
+             );\r
     }\r
   }\r
 \r
@@ -314,7 +310,9 @@ ConPlatformTextInDriverBindingStart (
 }\r
 \r
 /**\r
-  Start this driver on ControllerHandle by opening Simple Text Out protocol,\r
+  Start this driver on the device for console output and stardard error output.\r
+\r
+  Start this driver on ControllerHandle by opening Simple Text Output Protocol,\r
   reading Device Path, and installing Console Out Devcic GUID, Standard Error\r
   Device GUID on ControllerHandle.\r
 \r
@@ -339,10 +337,10 @@ ConPlatformTextOutDriverBindingStart (
   IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath\r
   )\r
 {\r
-  EFI_STATUS                    Status;\r
-  EFI_DEVICE_PATH_PROTOCOL      *DevicePath;\r
+  EFI_STATUS                       Status;\r
+  EFI_DEVICE_PATH_PROTOCOL         *DevicePath;\r
   EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *TextOut;\r
-  BOOLEAN                       NeedClose;\r
+  BOOLEAN                          NeedClose;\r
 \r
   NeedClose = TRUE;\r
 \r
@@ -382,14 +380,15 @@ ConPlatformTextOutDriverBindingStart (
   //\r
   if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
     gBS->InstallMultipleProtocolInterfaces (\r
-          &ControllerHandle,\r
-          &gEfiConsoleOutDeviceGuid,\r
-          NULL,\r
-          NULL\r
-          );\r
+           &ControllerHandle,\r
+           &gEfiConsoleOutDeviceGuid,\r
+           NULL,\r
+           NULL\r
+           );\r
   } else {\r
     //\r
-    // Append the device path to the ConOutDev environment variable\r
+    // If it is not a hot-plug device, first append the device path to the\r
+    // ConOutDev environment variable\r
     //\r
     ConPlatformUpdateDeviceVariable (\r
       L"ConOutDev",\r
@@ -397,7 +396,7 @@ ConPlatformTextOutDriverBindingStart (
       APPEND\r
       );\r
     //\r
-    // Append the device path to the StdErrDev environment variable\r
+    // Then append the device path to the StdErrDev environment variable\r
     //\r
     ConPlatformUpdateDeviceVariable (\r
       L"ErrOutDev",\r
@@ -406,14 +405,14 @@ ConPlatformTextOutDriverBindingStart (
       );\r
 \r
     //\r
-    // If the device path is an instance in the ConOut environment variable,\r
+    // If the device path is successfully added to the ConOut environment variable,\r
     // then install EfiConsoleOutDeviceGuid onto ControllerHandle\r
     //\r
     Status = ConPlatformUpdateDeviceVariable (\r
-              L"ConOut",\r
-              DevicePath,\r
-              CHECK\r
-              );\r
+               L"ConOut",\r
+               DevicePath,\r
+               CHECK\r
+               );\r
 \r
     if (!EFI_ERROR (Status)) {\r
       NeedClose = FALSE;\r
@@ -425,31 +424,31 @@ ConPlatformTextOutDriverBindingStart (
                       );\r
     }\r
     //\r
-    // If the device path is an instance in the StdErr environment variable,\r
+    // If the device path is successfully added to the StdErr environment variable,\r
     // then install EfiStandardErrorDeviceGuid onto ControllerHandle\r
     //\r
     Status = ConPlatformUpdateDeviceVariable (\r
-              L"ErrOut",\r
-              DevicePath,\r
-              CHECK\r
-              );\r
+               L"ErrOut",\r
+               DevicePath,\r
+               CHECK\r
+               );\r
     if (!EFI_ERROR (Status)) {\r
       NeedClose = FALSE;\r
       gBS->InstallMultipleProtocolInterfaces (\r
-            &ControllerHandle,\r
-            &gEfiStandardErrorDeviceGuid,\r
-            NULL,\r
-            NULL\r
-            );\r
+             &ControllerHandle,\r
+             &gEfiStandardErrorDeviceGuid,\r
+             NULL,\r
+             NULL\r
+             );\r
     }\r
 \r
     if (NeedClose) {\r
       gBS->CloseProtocol (\r
-            ControllerHandle,\r
-            &gEfiSimpleTextOutProtocolGuid,\r
-            This->DriverBindingHandle,\r
-            ControllerHandle\r
-            );\r
+             ControllerHandle,\r
+             &gEfiSimpleTextOutProtocolGuid,\r
+             This->DriverBindingHandle,\r
+             ControllerHandle\r
+             );\r
     }\r
   }\r
 \r
@@ -458,7 +457,7 @@ ConPlatformTextOutDriverBindingStart (
 \r
 /**\r
   Stop this driver on ControllerHandle by removing Console In Devcice GUID \r
-  and closing the Simple Text In protocol on ControllerHandle.\r
+  and closing the Simple Text Input protocol on ControllerHandle.\r
 \r
   @param  This              Protocol instance pointer.\r
   @param  ControllerHandle  Handle of device to stop driver on\r
@@ -483,8 +482,7 @@ ConPlatformTextInDriverBindingStop (
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
 \r
   //\r
-  // hot plug device is not included into the console associated variables,\r
-  // so no need to check variable for those hot plug devices.\r
+  // If it is not a hot-plug device, first delete it from the ConInDev variable.\r
   //\r
   if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
     //\r
@@ -519,7 +517,7 @@ ConPlatformTextInDriverBindingStop (
     );\r
 \r
   //\r
-  // Close the Simple Input Protocol\r
+  // Close the Simple Text Input Protocol\r
   //\r
   gBS->CloseProtocol (\r
         ControllerHandle,\r
@@ -534,7 +532,7 @@ ConPlatformTextInDriverBindingStop (
 \r
 /**\r
   Stop this driver on ControllerHandle by removing Console Out Devcice GUID \r
-  and closing the Simple Text Out protocol on ControllerHandle.\r
+  and closing the Simple Text Output protocol on ControllerHandle.\r
 \r
   @param  This              Protocol instance pointer.\r
   @param  ControllerHandle  Handle of device to stop driver on\r
@@ -559,8 +557,7 @@ ConPlatformTextOutDriverBindingStop (
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
 \r
   //\r
-  // hot plug device is not included into the console associated variables,\r
-  // so no need to check variable for those hot plug devices.\r
+  // If it is not a hot-plug device, first delete it from the ConOutDev and StdErrDev variable.\r
   //\r
   if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
     //\r
@@ -626,8 +623,6 @@ ConPlatformTextOutDriverBindingStop (
   @param Handle          Handle of device to uninstall protocol on.\r
   @param ProtocolGuid    The specified protocol need to be uninstalled.\r
 \r
-  @return None.\r
-\r
 **/\r
 VOID\r
 ConPlatformUnInstallProtocol (\r
@@ -649,19 +644,22 @@ ConPlatformUnInstallProtocol (
 \r
   if (!EFI_ERROR (Status)) {\r
     gBS->UninstallMultipleProtocolInterfaces (\r
-          Handle,\r
-          ProtocolGuid,\r
-          NULL,\r
-          NULL\r
-          );\r
+           Handle,\r
+           ProtocolGuid,\r
+           NULL,\r
+           NULL\r
+           );\r
   }\r
 \r
   return ;\r
 }\r
 \r
 /**\r
-  Read the EFI variable (Name) and return a dynamically allocated\r
-  buffer, and the size of the buffer. On failure return NULL.\r
+  Get the necessary size of buffer and read the variabe.\r
+\r
+  First get the necessary size of buffer. Then read the\r
+  EFI variable (Name) and return a dynamically allocated\r
+  buffer. On failure return NULL.\r
 \r
   @param  Name             String part of EFI variable name\r
 \r
@@ -683,7 +681,7 @@ ConPlatformGetVariable (
   Buffer      = NULL;\r
 \r
   //\r
-  // Test to see if the variable exists.  If it doesn't, reuturn NULL.\r
+  // Test to see if the variable exists.  If it doesn't, return NULL.\r
   //\r
   Status = gRT->GetVariable (\r
                   Name,\r
@@ -727,7 +725,6 @@ ConPlatformGetVariable (
   Function compares a device path data structure to that of all the nodes of a\r
   second device path instance.\r
 \r
-\r
   @param Multi           A pointer to a multi-instance device path data structure.\r
   @param Single          A pointer to a single-instance device path data structure.\r
   @param NewDevicePath   If Delete is TRUE, this parameter must not be null, and it\r
@@ -737,8 +734,11 @@ ConPlatformGetVariable (
                          If FALSE, the routine just check whether Single matches\r
                          with any instance in Multi.\r
 \r
-  @retval EFI_SUCCESS    If the Single is contained within Multi.\r
-  @retval EFI_NOT_FOUND  If the Single is not contained within Multi.\r
+  @retval EFI_SUCCESS           If the Single is contained within Multi.\r
+  @retval EFI_NOT_FOUND         If the Single is not contained within Multi.\r
+  @retval EFI_INVALID_PARAMETER Multi is NULL.\r
+  @retval EFI_INVALID_PARAMETER Single is NULL.\r
+  @retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -759,14 +759,16 @@ ConPlatformMatchDevicePaths (
   // The passed in DevicePath should not be NULL\r
   //\r
   if ((Multi == NULL) || (Single == NULL)) {\r
-    return EFI_NOT_FOUND;\r
+    return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   //\r
   // If performing Delete operation, the NewDevicePath must not be NULL.\r
   //\r
   if (Delete) {\r
-    ASSERT (NewDevicePath != NULL);\r
+    if (NewDevicePath == NULL) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
   }\r
 \r
   TempDevicePath1 = NULL;\r
@@ -789,7 +791,8 @@ ConPlatformMatchDevicePaths (
     } else {\r
       if (Delete) {\r
         //\r
-        // Append the mis-matched devcie path into remaining device path.\r
+        // If the node of Multi does not match Single, then added it back to the result.\r
+        // That is, the node matching Single will be dropped and deleted from result.\r
         //\r
         TempDevicePath2 = AppendDevicePathInstance (\r
                             TempDevicePath1,\r
@@ -808,7 +811,7 @@ ConPlatformMatchDevicePaths (
 \r
   if (Delete) {\r
     //\r
-    // Return the remaining device path data structure\r
+    // Return the new device path data structure with specified node deleted.\r
     //\r
     *NewDevicePath = TempDevicePath1;\r
     return EFI_SUCCESS;\r
@@ -823,7 +826,7 @@ ConPlatformMatchDevicePaths (
   @param  VariableName    Console environment variables, ConOutDev, ConInDev\r
                           StdErrDev, ConIn or ConOut.\r
   @param  DevicePath      Console devcie's device path.\r
-  @param  Operation       Variable operations, such as APPEND or DELETE.\r
+  @param  Operation       Variable operations, including APPEND, CHECK and DELETE.\r
 \r
   @retval EFI_SUCCESS           Variable operates successfully.\r
   @retval EFI_OUT_OF_RESOURCES  If variable cannot be appended.\r
@@ -856,15 +859,17 @@ ConPlatformUpdateDeviceVariable (
     // Match specified DevicePath in Console Variable.\r
     // \r
     Status = ConPlatformMatchDevicePaths (\r
-              VariableDevicePath,\r
-              DevicePath,\r
-              NULL,\r
-              FALSE\r
-              );\r
+               VariableDevicePath,\r
+               DevicePath,\r
+               NULL,\r
+               FALSE\r
+               );\r
 \r
     if ((Operation == CHECK) || (!EFI_ERROR (Status))) {\r
       //\r
-      // The device path is already in the variable\r
+      // Branch here includes 2 cases:\r
+      // 1. Operation is CHECK, simply return Status.\r
+      // 2. Operation is APPEND, and device path already exists in variable, also return.\r
       //\r
       if (VariableDevicePath != NULL) {\r
         FreePool (VariableDevicePath);\r
@@ -873,8 +878,7 @@ ConPlatformUpdateDeviceVariable (
       return Status;\r
     }\r
     //\r
-    // The device path is not in variable. Append DevicePath to the\r
-    // environment variable that is a multi-instance device path.\r
+    // We reach here to append a device path that does not exist in variable.\r
     //\r
     Status = EFI_SUCCESS;\r
     NewVariableDevicePath = AppendDevicePathInstance (\r
@@ -887,15 +891,15 @@ ConPlatformUpdateDeviceVariable (
 \r
   } else {\r
     //\r
-    // Remove DevicePath from the environment variable that\r
+    // We reach here to remove DevicePath from the environment variable that\r
     // is a multi-instance device path.\r
     //\r
     Status = ConPlatformMatchDevicePaths (\r
-              VariableDevicePath,\r
-              DevicePath,\r
-              &NewVariableDevicePath,\r
-              TRUE\r
-              );\r
+               VariableDevicePath,\r
+               DevicePath,\r
+               &NewVariableDevicePath,\r
+               TRUE\r
+               );\r
   }\r
 \r
   if (VariableDevicePath != NULL) {\r
@@ -925,7 +929,7 @@ ConPlatformUpdateDeviceVariable (
 }\r
 \r
 /**\r
-  Check if the device is one hot-plug supported.\r
+  Check if the device supports hot-plug.\r
 \r
   @param  DriverBindingHandle   Protocol instance pointer.\r
   @param  ControllerHandle      Handle of device to check.\r
index 529c03da0c91cf4afcb642da5fad313632246803..7f8cad2304d0042d76cadf88a73881fcfaddfb3e 100644 (file)
@@ -54,12 +54,10 @@ typedef enum {
 } CONPLATFORM_VAR_OPERATION;\r
 \r
 /**\r
-  Test to see if specific Protocol could be supported on the ControllerHandle. \r
+  Test to see if specific protocol could be supported on the ControllerHandle. \r
 \r
   @param  This                Protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
-  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
-                              device to start.\r
   @param  ProtocolGuid        The specfic protocol.\r
 \r
   @retval EFI_SUCCESS         This driver supports this device\r
@@ -70,20 +68,19 @@ EFI_STATUS
 ConPlatformDriverBindingSupported (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN  EFI_HANDLE                   ControllerHandle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath,\r
   IN  EFI_GUID                     *ProtocolGuid\r
   );\r
 \r
 /**\r
-  Test to see if EFI Text In Protocol could be supported on the ControllerHandle. \r
+  Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle. \r
 \r
   @param  This                Protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
   @param  RemainingDevicePath Optional parameter use to pick a specific child\r
                               device to start.\r
 \r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval other               This driver does not support this device\r
+  @retval EFI_SUCCESS         This driver supports this device.\r
+  @retval other               This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -91,19 +88,19 @@ EFIAPI
 ConPlatformTextInDriverBindingSupported (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN  EFI_HANDLE                   Handle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  OPTIONAL\r
   );\r
 \r
 /**\r
-  Test to see if EFI Text Out Protocol could be supported on the ControllerHandle. \r
+  Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle. \r
 \r
   @param  This                Protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
   @param  RemainingDevicePath Optional parameter use to pick a specific child\r
                               device to start.\r
 \r
-  @retval EFI_SUCCESS         This driver supports this device\r
-  @retval other               This driver does not support this device\r
+  @retval EFI_SUCCESS         This driver supports this device.\r
+  @retval other               This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -111,11 +108,13 @@ EFIAPI
 ConPlatformTextOutDriverBindingSupported (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN  EFI_HANDLE                   Handle,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath  OPTIONAL\r
   );\r
 \r
 /**\r
-  Start this driver on ControllerHandle by opening Simple Text In protocol,\r
+  Start this driver on the device for console input.\r
+\r
+  Start this driver on ControllerHandle by opening Simple Text Input Protocol,\r
   reading Device Path, and installing Console In Devcice GUID on ControllerHandle.\r
 \r
   If this devcie is not one hot-plug devce, append its device path into the \r
@@ -128,7 +127,7 @@ ConPlatformTextOutDriverBindingSupported (
 \r
   @retval EFI_SUCCESS          This driver is added to ControllerHandle\r
   @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle\r
-  @retval other                This driver does not support this device\r
+  @retval other                This driver does not support this device.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -140,8 +139,10 @@ ConPlatformTextInDriverBindingStart (
   );\r
 \r
 /**\r
-  Start this driver on ControllerHandle by opening Simple Text Out protocol,\r
-  reading Device Path, and installing Console Out Devcice GUID, Standard Error\r
+  Start this driver on the device for console output and stardard error output.\r
+\r
+  Start this driver on ControllerHandle by opening Simple Text Output Protocol,\r
+  reading Device Path, and installing Console Out Devcic GUID, Standard Error\r
   Device GUID on ControllerHandle.\r
 \r
   If this devcie is not one hot-plug devce, append its device path into the \r
@@ -167,7 +168,7 @@ ConPlatformTextOutDriverBindingStart (
 \r
 /**\r
   Stop this driver on ControllerHandle by removing Console In Devcice GUID \r
-  and closing the Simple Text In protocol on ControllerHandle.\r
+  and closing the Simple Text Input protocol on ControllerHandle.\r
 \r
   @param  This              Protocol instance pointer.\r
   @param  ControllerHandle  Handle of device to stop driver on\r
@@ -190,7 +191,7 @@ ConPlatformTextInDriverBindingStop (
 \r
 /**\r
   Stop this driver on ControllerHandle by removing Console Out Devcice GUID \r
-  and closing the Simple Text Out protocol on ControllerHandle.\r
+  and closing the Simple Text Output protocol on ControllerHandle.\r
 \r
   @param  This              Protocol instance pointer.\r
   @param  ControllerHandle  Handle of device to stop driver on\r
@@ -218,8 +219,6 @@ ConPlatformTextOutDriverBindingStop (
   @param Handle          Handle of device to uninstall protocol on.\r
   @param ProtocolGuid    The specified protocol need to be uninstalled.\r
 \r
-  @return None.\r
-\r
 **/\r
 VOID\r
 ConPlatformUnInstallProtocol (\r
@@ -258,15 +257,18 @@ ConPlatformGetVariable (
                          If FALSE, the routine just check whether Single matches\r
                          with any instance in Multi.\r
 \r
-  @retval EFI_SUCCESS    If the Single is contained within Multi.\r
-  @retval EFI_NOT_FOUND  If the Single is not contained within Multi.\r
+  @retval EFI_SUCCESS           If the Single is contained within Multi.\r
+  @retval EFI_NOT_FOUND         If the Single is not contained within Multi.\r
+  @retval EFI_INVALID_PARAMETER Multi is NULL.\r
+  @retval EFI_INVALID_PARAMETER Single is NULL.\r
+  @retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.\r
 \r
 **/\r
 EFI_STATUS\r
 ConPlatformMatchDevicePaths (\r
   IN  EFI_DEVICE_PATH_PROTOCOL  *Multi,\r
   IN  EFI_DEVICE_PATH_PROTOCOL  *Single,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath OPTIONAL,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath OPTIONAL,\r
   IN  BOOLEAN                   Delete\r
   );\r
 \r
@@ -276,7 +278,7 @@ ConPlatformMatchDevicePaths (
   @param  VariableName    Console environment variables, ConOutDev, ConInDev\r
                           StdErrDev, ConIn or ConOut.\r
   @param  DevicePath      Console devcie's device path.\r
-  @param  Operation       Variable operations, such as APPEND or DELETE.\r
+  @param  Operation       Variable operations, including APPEND, CHECK and DELETE.\r
 \r
   @retval EFI_SUCCESS           Variable operates successfully.\r
   @retval EFI_OUT_OF_RESOURCES  If variable cannot be appended.\r
@@ -291,7 +293,7 @@ ConPlatformUpdateDeviceVariable (
   );\r
 \r
 /**\r
-  Check if the device is one hot-plug supported.\r
+  Check if the device supports hot-plug.\r
 \r
   @param  DriverBindingHandle   Protocol instance pointer.\r
   @param  ControllerHandle      Handle of device to check.\r
@@ -321,7 +323,6 @@ IsHotPlugDevice (
 \r
   @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
   @param  Language[in]          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language. This is the\r
                                 language of the driver name that the caller is\r
@@ -330,7 +331,6 @@ IsHotPlugDevice (
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified\r
                                 in RFC 3066 or ISO 639-2 language code format.\r
-\r
   @param  DriverName[out]       A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 driver specified by This in the language\r
@@ -339,11 +339,8 @@ IsHotPlugDevice (
   @retval EFI_SUCCESS           The Unicode string for the Driver specified by\r
                                 This and the language specified by Language was\r
                                 returned in DriverName.\r
-\r
   @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
   @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
-\r
   @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
                                 the language specified by Language.\r
 \r
@@ -372,12 +369,10 @@ ConPlatformComponentNameGetDriverName (
 \r
   @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
-\r
   @param  ControllerHandle[in]  The handle of a controller that the driver\r
                                 specified by This is managing.  This handle\r
                                 specifies the controller whose name is to be\r
                                 returned.\r
-\r
   @param  ChildHandle[in]       The handle of the child controller to retrieve\r
                                 the name of.  This is an optional parameter that\r
                                 may be NULL.  It will be NULL for device\r
@@ -386,7 +381,6 @@ ConPlatformComponentNameGetDriverName (
                                 controller.  It will not be NULL for a bus\r
                                 driver that wishes to retrieve the name of a\r
                                 child controller.\r
-\r
   @param  Language[in]          A pointer to a Null-terminated ASCII string\r
                                 array indicating the language.  This is the\r
                                 language of the driver name that the caller is\r
@@ -395,7 +389,6 @@ ConPlatformComponentNameGetDriverName (
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified in\r
                                 RFC 3066 or ISO 639-2 language code format.\r
-\r
   @param  ControllerName[out]   A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 controller specified by ControllerHandle and\r
@@ -407,20 +400,14 @@ ConPlatformComponentNameGetDriverName (
                                 the language specified by Language for the\r
                                 driver specified by This was returned in\r
                                 DriverName.\r
-\r
   @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
-\r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
                                 EFI_HANDLE.\r
-\r
   @retval EFI_INVALID_PARAMETER Language is NULL.\r
-\r
   @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
-\r
   @retval EFI_UNSUPPORTED       The driver specified by This is not currently\r
                                 managing the controller specified by\r
                                 ControllerHandle and ChildHandle.\r
-\r
   @retval EFI_UNSUPPORTED       The driver specified by This does not support\r
                                 the language specified by Language.\r
 \r
index a3e60f099a6f561905dacc36643cb0accef01568..0f9298003384ffee4f09d0b4774089cc0f6bdb24 100644 (file)
@@ -1,8 +1,7 @@
 #/** @file\r
-# Console Platfrom Driver\r
+# Console Platfrom DXE Driver, install Console protocols and updates environment variables.\r
 #\r
-# Console Platfrom DXE Driver, install Console protocols\r
-# Copyright (c) 2006 - 2007, Intel Corporation\r
+# Copyright (c) 2006 - 2008, Intel Corporation\r
 #\r
 #  All rights reserved. This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r