#include <Library/SortLib.h>\r
#include <Library/BaseLib.h>\r
\r
-#define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)\r
-\r
//\r
// globals...\r
//\r
{\r
EFI_STATUS Status;\r
\r
- //\r
- // UEFI 2.0 shell interfaces (used preferentially)\r
- //\r
- Status = gBS->OpenProtocol(\r
- ImageHandle,\r
- &gEfiShellProtocolGuid,\r
- (VOID **)&gEfiShellProtocol,\r
- ImageHandle,\r
- NULL,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if (EFI_ERROR(Status)) {\r
+ if (gEfiShellProtocol == NULL) {\r
//\r
- // Search for the shell protocol\r
+ // UEFI 2.0 shell interfaces (used preferentially)\r
//\r
- Status = gBS->LocateProtocol(\r
+ Status = gBS->OpenProtocol (\r
+ ImageHandle,\r
&gEfiShellProtocolGuid,\r
+ (VOID **)&gEfiShellProtocol,\r
+ ImageHandle,\r
NULL,\r
- (VOID **)&gEfiShellProtocol\r
- );\r
- if (EFI_ERROR(Status)) {\r
- gEfiShellProtocol = NULL;\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Search for the shell protocol\r
+ //\r
+ Status = gBS->LocateProtocol (\r
+ &gEfiShellProtocolGuid,\r
+ NULL,\r
+ (VOID **)&gEfiShellProtocol\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ gEfiShellProtocol = NULL;\r
+ }\r
}\r
}\r
- Status = gBS->OpenProtocol(\r
- ImageHandle,\r
- &gEfiShellParametersProtocolGuid,\r
- (VOID **)&gEfiShellParametersProtocol,\r
- ImageHandle,\r
- NULL,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if (EFI_ERROR(Status)) {\r
- gEfiShellParametersProtocol = NULL;\r
+\r
+ if (gEfiShellParametersProtocol == NULL) {\r
+ Status = gBS->OpenProtocol (\r
+ ImageHandle,\r
+ &gEfiShellParametersProtocolGuid,\r
+ (VOID **)&gEfiShellParametersProtocol,\r
+ ImageHandle,\r
+ NULL,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ gEfiShellParametersProtocol = NULL;\r
+ }\r
}\r
\r
- if (gEfiShellParametersProtocol == NULL || gEfiShellProtocol == NULL) {\r
+ if (gEfiShellProtocol == NULL) {\r
//\r
// Moved to seperate function due to complexity\r
//\r
}\r
\r
//\r
- // only success getting 2 of either the old or new, but no 1/2 and 1/2\r
+ // Getting either EDK Shell's ShellEnvironment2 and ShellInterface protocol\r
+ // or UEFI Shell's Shell protocol.\r
+ // When ShellLib is linked to a driver producing DynamicCommand protocol,\r
+ // ShellParameters protocol is set by DynamicCommand.Handler().\r
//\r
- if ((mEfiShellEnvironment2 != NULL && mEfiShellInterface != NULL) ||\r
- (gEfiShellProtocol != NULL && gEfiShellParametersProtocol != NULL) ) {\r
+ if ((mEfiShellEnvironment2 != NULL && mEfiShellInterface != NULL) ||\r
+ (gEfiShellProtocol != NULL)\r
+ ) {\r
if (gEfiShellProtocol != NULL) {\r
FileFunctionMap.GetFileInfo = gEfiShellProtocol->GetFileInfo;\r
FileFunctionMap.SetFileInfo = gEfiShellProtocol->SetFileInfo;\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
+ EFI_STATUS Status;\r
+\r
if (mEfiShellEnvironment2 != NULL) {\r
- gBS->CloseProtocol(mEfiShellEnvironment2Handle==NULL?ImageHandle:mEfiShellEnvironment2Handle,\r
+ Status = gBS->CloseProtocol(mEfiShellEnvironment2Handle==NULL?ImageHandle:mEfiShellEnvironment2Handle,\r
&gEfiShellEnvironment2Guid,\r
ImageHandle,\r
NULL);\r
- mEfiShellEnvironment2 = NULL;\r
+ if (!EFI_ERROR (Status)) {\r
+ mEfiShellEnvironment2 = NULL;\r
+ mEfiShellEnvironment2Handle = NULL;\r
+ }\r
}\r
if (mEfiShellInterface != NULL) {\r
- gBS->CloseProtocol(ImageHandle,\r
+ Status = gBS->CloseProtocol(ImageHandle,\r
&gEfiShellInterfaceGuid,\r
ImageHandle,\r
NULL);\r
- mEfiShellInterface = NULL;\r
+ if (!EFI_ERROR (Status)) {\r
+ mEfiShellInterface = NULL;\r
+ }\r
}\r
if (gEfiShellProtocol != NULL) {\r
- gBS->CloseProtocol(ImageHandle,\r
+ Status = gBS->CloseProtocol(ImageHandle,\r
&gEfiShellProtocolGuid,\r
ImageHandle,\r
NULL);\r
- gEfiShellProtocol = NULL;\r
+ if (!EFI_ERROR (Status)) {\r
+ gEfiShellProtocol = NULL;\r
+ }\r
}\r
if (gEfiShellParametersProtocol != NULL) {\r
- gBS->CloseProtocol(ImageHandle,\r
+ Status = gBS->CloseProtocol(ImageHandle,\r
&gEfiShellParametersProtocolGuid,\r
ImageHandle,\r
NULL);\r
- gEfiShellParametersProtocol = NULL;\r
+ if (!EFI_ERROR (Status)) {\r
+ gEfiShellParametersProtocol = NULL;\r
+ }\r
}\r
- mEfiShellEnvironment2Handle = NULL;\r
\r
return (EFI_SUCCESS);\r
}\r
EFI_STATUS\r
EFIAPI\r
ShellInitialize (\r
+ VOID\r
)\r
{\r
EFI_STATUS Status;\r
// Create the directory to create the file in\r
//\r
FileNameCopy = AllocateCopyPool (StrSize (FileName), FileName);\r
- if (FileName == NULL) {\r
+ if (FileNameCopy == NULL) {\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
PathCleanUpDirectories (FileNameCopy);\r
// update the attribute\r
//\r
if (ResumeLocation != NULL) {\r
- if (*(ResumeLocation-1) == L'^') {\r
+ if ((ResumeLocation != mPostReplaceFormat2) && (*(ResumeLocation-1) == L'^')) {\r
//\r
// Move cursor back 1 position to overwrite the ^\r
//\r
gST->ConOut->SetAttribute(gST->ConOut, EFI_TEXT_ATTR(EFI_WHITE, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)));\r
break;\r
case (L'B'):\r
- gST->ConOut->SetAttribute(gST->ConOut, EFI_TEXT_ATTR(EFI_BLUE, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)));\r
+ gST->ConOut->SetAttribute(gST->ConOut, EFI_TEXT_ATTR(EFI_LIGHTBLUE, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)));\r
break;\r
case (L'V'):\r
- gST->ConOut->SetAttribute(gST->ConOut, EFI_TEXT_ATTR(EFI_GREEN, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)));\r
+ gST->ConOut->SetAttribute(gST->ConOut, EFI_TEXT_ATTR(EFI_LIGHTGREEN, ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)));\r
break;\r
default:\r
//\r