]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Code scrub.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 15 Jul 2008 08:16:24 +0000 (08:16 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 15 Jul 2008 08:16:24 +0000 (08:16 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5471 6f19259b-4bc3-4df7-8a09-765794883524

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

index 56bdd11693926ffdc7360f1a929173b196acaf4d..c2540795cd403581031512cb97fca00e833d21a7 100644 (file)
@@ -37,8 +37,8 @@ EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding = {
 /**\r
   The user Entry Point for module ConPlatform. The user code starts with this function.\r
 \r
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.\r
-  @param[in] SystemTable    A pointer to the EFI System Table.\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
@@ -89,8 +89,8 @@ InitializeConPlatform(
   @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
@@ -118,8 +118,8 @@ ConPlatformTextInDriverBindingSupported (
   @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
@@ -140,7 +140,7 @@ ConPlatformTextOutDriverBindingSupported (
 \r
 \r
 /**\r
-  Test to see if specific Protocol could be supported on the ControllerHandle. \r
+  Test to see if the specified Protocol could be supported on the ControllerHandle. \r
 \r
   @param  This                Protocol instance pointer.\r
   @param  ControllerHandle    Handle of device to test.\r
@@ -148,8 +148,8 @@ ConPlatformTextOutDriverBindingSupported (
                               device to start.\r
   @param  ProtocolGuid        The specfic protocol.\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
@@ -164,8 +164,8 @@ ConPlatformDriverBindingSupported (
   VOID        *Interface;\r
 \r
   //\r
-  // Test to see if this is a physical device by checking to see if\r
-  // it has a Device Path Protocol\r
+  // Test to see if this is a physical device by checking if\r
+  // it has a Device Path Protocol.\r
   //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
@@ -179,7 +179,7 @@ ConPlatformDriverBindingSupported (
     return Status;\r
   }\r
   //\r
-  // Test to see if this device supports the specific Protocol\r
+  // Test to see if this device supports the specified Protocol.\r
   //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
@@ -620,11 +620,11 @@ ConPlatformTextOutDriverBindingStop (
 \r
 \r
 /**\r
-  Unstall the specific protocol.\r
+  Uninstall the specified protocol.\r
 \r
   @param This            Protocol instance pointer.\r
-  @param Handle          Handle of device to unstall protocol on.\r
-  @param ProtocolGuid    The specific protocol need to be uninstalled.\r
+  @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
@@ -663,12 +663,11 @@ ConPlatformUnInstallProtocol (
   Read the EFI variable (Name) and return a dynamically allocated\r
   buffer, and the size of the buffer. On failure return NULL.\r
 \r
-\r
   @param  Name             String part of EFI variable name\r
 \r
   @return Dynamically allocated memory that contains a copy of the EFI variable.\r
-          Caller is repsoncible freeing the buffer.\r
-          NULL - Variable was not read\r
+          Caller is repsoncible freeing the buffer. Return NULL means Variable \r
+          was not read.\r
 \r
 **/\r
 VOID *\r
@@ -684,7 +683,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, reuturn NULL.\r
   //\r
   Status = gRT->GetVariable (\r
                   Name,\r
@@ -714,6 +713,9 @@ ConPlatformGetVariable (
                     );\r
     if (EFI_ERROR (Status)) {\r
       FreePool (Buffer);\r
+      //\r
+      // To make sure Buffer is NULL if any error occurs.\r
+      //\r
       Buffer = NULL;\r
     }\r
   }\r
@@ -735,20 +737,21 @@ ConPlatformGetVariable (
                          If FALSE, the routine just check whether Single matches\r
                          with any instance in Multi.\r
 \r
-  @return The function returns EFI_SUCCESS if the Single is contained within Multi.\r
-          Otherwise, EFI_NOT_FOUND is returned.\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
 \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
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath1;\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath2;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePathInst;\r
   UINTN                     Size;\r
 \r
@@ -758,29 +761,42 @@ ConPlatformMatchDevicePaths (
   if ((Multi == NULL) || (Single == NULL)) {\r
     return EFI_NOT_FOUND;\r
   }\r
+\r
   //\r
-  // if performing Delete operation, the NewDevicePath must not be NULL.\r
+  // If performing Delete operation, the NewDevicePath must not be NULL.\r
   //\r
-  TempDevicePath  = NULL;\r
+  if (Delete) {\r
+    ASSERT (NewDevicePath != NULL);\r
+  }\r
+\r
+  TempDevicePath1 = NULL;\r
 \r
   DevicePath      = Multi;\r
   DevicePathInst  = GetNextDevicePathInstance (&DevicePath, &Size);\r
 \r
   //\r
-  // search for the match of 'Single' in 'Multi'\r
+  // Search for the match of 'Single' in 'Multi'\r
   //\r
   while (DevicePathInst != NULL) {\r
     if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
       if (!Delete) {\r
+        //\r
+        // If Delete is FALSE, return EFI_SUCCESS if Single is found in Multi.\r
+        //\r
         FreePool (DevicePathInst);\r
         return EFI_SUCCESS;\r
       }\r
     } else {\r
       if (Delete) {\r
-        TempDevicePath = AppendDevicePathInstance (\r
-                            NULL,\r
+        //\r
+        // Append the mis-matched devcie path into remaining device path.\r
+        //\r
+        TempDevicePath2 = AppendDevicePathInstance (\r
+                            TempDevicePath1,\r
                             DevicePathInst\r
                             );\r
+        SafeFreePool (TempDevicePath1);\r
+        TempDevicePath1 = TempDevicePath2;\r
       }\r
     }\r
 \r
@@ -789,7 +805,10 @@ ConPlatformMatchDevicePaths (
   }\r
 \r
   if (Delete) {\r
-    *NewDevicePath = TempDevicePath;\r
+    //\r
+    // Return the remaining device path data structure\r
+    //\r
+    *NewDevicePath = TempDevicePath1;\r
     return EFI_SUCCESS;\r
   }\r
 \r
@@ -797,7 +816,7 @@ ConPlatformMatchDevicePaths (
 }\r
 \r
 /**\r
-  Update console devicein console environment variables. \r
+  Update console environment variables. \r
 \r
   @param  VariableName    Console environment variables, ConOutDev, ConInDev\r
                           StdErrDev, ConIn or ConOut.\r
@@ -831,7 +850,9 @@ ConPlatformUpdateDeviceVariable (
   VariableDevicePath = ConPlatformGetVariable (VariableName);\r
 \r
   if (Operation != DELETE) {\r
-\r
+    //\r
+    // Match specified DevicePath in Console Variable.\r
+    // \r
     Status = ConPlatformMatchDevicePaths (\r
               VariableDevicePath,\r
               DevicePath,\r
@@ -884,6 +905,9 @@ ConPlatformUpdateDeviceVariable (
   }\r
 \r
   if (NewVariableDevicePath != NULL) {\r
+    //\r
+    // Update Console Environment Variable.\r
+    //\r
     Status = gRT->SetVariable (\r
                     VariableName,\r
                     &gEfiGlobalVariableGuid,\r
index 1ec31a170b7dd21eb24e7a8345a8885c3bb8f328..eccb18b3ff28f426f9ba7eaba3cc17f3622db1bd 100644 (file)
@@ -15,14 +15,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _CON_PLATFORM_H_\r
 #define _CON_PLATFORM_H_\r
 \r
-#include <Uefi.h>\r
+#include <PiDxe.h>\r
+\r
 #include <Protocol/SimpleTextOut.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/SimpleTextIn.h>\r
+\r
 #include <Guid/GlobalVariable.h>\r
 #include <Guid/ConsoleInDevice.h>\r
 #include <Guid/StandardErrorDevice.h>\r
 #include <Guid/ConsoleOutDevice.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/SimpleTextIn.h>\r
 #include <Guid/HotPlugDevice.h>\r
 \r
 #include <Library/DebugLib.h>\r
@@ -210,11 +212,11 @@ ConPlatformTextOutDriverBindingStop (
   );\r
 \r
 /**\r
-  Unstall the specific protocol.\r
+  Uninstall the specified protocol.\r
 \r
   @param This            Protocol instance pointer.\r
-  @param Handle          Handle of device to unstall protocol on.\r
-  @param ProtocolGuid    The specific protocol need to be uninstalled.\r
+  @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
@@ -230,12 +232,11 @@ ConPlatformUnInstallProtocol (
   Read the EFI variable (Name) and return a dynamically allocated\r
   buffer, and the size of the buffer. On failure return NULL.\r
 \r
-\r
   @param  Name             String part of EFI variable name\r
 \r
   @return Dynamically allocated memory that contains a copy of the EFI variable.\r
-          Caller is repsoncible freeing the buffer.\r
-          NULL - Variable was not read\r
+          Caller is repsoncible freeing the buffer. Return NULL means Variable \r
+          was not read.\r
 \r
 **/\r
 VOID *\r
@@ -257,8 +258,8 @@ ConPlatformGetVariable (
                          If FALSE, the routine just check whether Single matches\r
                          with any instance in Multi.\r
 \r
-  @return The function returns EFI_SUCCESS if the Single is contained within Multi.\r
-          Otherwise, EFI_NOT_FOUND is returned.\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
 \r
 **/\r
 EFI_STATUS\r
@@ -270,7 +271,7 @@ ConPlatformMatchDevicePaths (
   );\r
 \r
 /**\r
-  Update console devicein console environment variables. \r
+  Update console environment variables.\r
 \r
   @param  VariableName    Console environment variables, ConOutDev, ConInDev\r
                           StdErrDev, ConIn or ConOut.\r