/**\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
@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
@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
\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
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
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
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
\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
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
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
);\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
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
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
}\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
}\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
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
}\r
\r
if (NewVariableDevicePath != NULL) {\r
+ //\r
+ // Update Console Environment Variable.\r
+ //\r
Status = gRT->SetVariable (\r
VariableName,\r
&gEfiGlobalVariableGuid,\r
#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
);\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
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
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
);\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