; FilePath = (FILEPATH_DEVICE_PATH*)NextDevicePathNode (&FilePath->Header)\r
){\r
//\r
- // all the rest should be file path nodes\r
+ // If any node is not a file path node, then the conversion can not be completed\r
//\r
if ((DevicePathType(&FilePath->Header) != MEDIA_DEVICE_PATH) ||\r
(DevicePathSubType(&FilePath->Header) != MEDIA_FILEPATH_DP)) {\r
FreePool(PathForReturn);\r
- PathForReturn = NULL;\r
- ASSERT(FALSE);\r
- } else {\r
- //\r
- // append the path part onto the filepath.\r
- //\r
- ASSERT((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));\r
-\r
- AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePath), FilePath);\r
- ASSERT (AlignedNode != NULL);\r
-\r
- // File Path Device Path Nodes 'can optionally add a "\" separator to\r
- // the beginning and/or the end of the Path Name string.'\r
- // (UEFI Spec 2.4 section 9.3.6.4).\r
- // If necessary, add a "\", but otherwise don't\r
- // (This is specified in the above section, and also implied by the\r
- // UEFI Shell spec section 3.7)\r
- if ((PathSize != 0) &&\r
- (PathForReturn != NULL) &&\r
- (PathForReturn[PathSize - 1] != L'\\') &&\r
- (AlignedNode->PathName[0] != L'\\')) {\r
- PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, L"\\", 1);\r
- }\r
+ return NULL;\r
+ }\r
\r
- PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, AlignedNode->PathName, 0);\r
- FreePool(AlignedNode);\r
+ //\r
+ // append the path part onto the filepath.\r
+ //\r
+ ASSERT((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));\r
+\r
+ AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePath), FilePath);\r
+ ASSERT (AlignedNode != NULL);\r
+\r
+ // File Path Device Path Nodes 'can optionally add a "\" separator to\r
+ // the beginning and/or the end of the Path Name string.'\r
+ // (UEFI Spec 2.4 section 9.3.6.4).\r
+ // If necessary, add a "\", but otherwise don't\r
+ // (This is specified in the above section, and also implied by the\r
+ // UEFI Shell spec section 3.7)\r
+ if ((PathSize != 0) &&\r
+ (PathForReturn != NULL) &&\r
+ (PathForReturn[PathSize - 1] != L'\\') &&\r
+ (AlignedNode->PathName[0] != L'\\')) {\r
+ PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, L"\\", 1);\r
}\r
+\r
+ PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, AlignedNode->PathName, 0);\r
+ FreePool(AlignedNode);\r
} // for loop of remaining nodes\r
}\r
if (PathForReturn != NULL) {\r
ShellParamsProtocol.StdIn = ShellInfoObject.NewShellParametersProtocol->StdIn;\r
ShellParamsProtocol.StdOut = ShellInfoObject.NewShellParametersProtocol->StdOut;\r
ShellParamsProtocol.StdErr = ShellInfoObject.NewShellParametersProtocol->StdErr;\r
- Status = UpdateArgcArgv(&ShellParamsProtocol, NewCmdLine, NULL, NULL);\r
+ Status = UpdateArgcArgv(&ShellParamsProtocol, NewCmdLine, Efi_Application, NULL, NULL);\r
ASSERT_EFI_ERROR(Status);\r
//\r
// Replace Argv[0] with the full path of the binary we're executing:\r
CHAR16 *Temp;\r
EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
UINTN Size;\r
+ EFI_STATUS CalleeStatusCode;\r
\r
+ CalleeStatusCode = EFI_SUCCESS;\r
+ \r
if ((PcdGet8(PcdShellSupportLevel) < 1)) {\r
return (EFI_UNSUPPORTED);\r
}\r
\r
- DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, ShellInfoObject.FileDevPath);\r
+ if (Environment != NULL) {\r
+ // If Environment isn't null, load a new image of the shell with its own\r
+ // environment\r
+ DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, ShellInfoObject.FileDevPath);\r
+ \r
+ DEBUG_CODE_BEGIN();\r
+ Temp = ConvertDevicePathToText(ShellInfoObject.FileDevPath, TRUE, TRUE);\r
+ FreePool(Temp);\r
+ Temp = ConvertDevicePathToText(ShellInfoObject.ImageDevPath, TRUE, TRUE);\r
+ FreePool(Temp);\r
+ Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);\r
+ FreePool(Temp);\r
+ DEBUG_CODE_END();\r
+\r
+ Temp = NULL;\r
+ Size = 0;\r
+ ASSERT((Temp == NULL && Size == 0) || (Temp != NULL));\r
+ StrnCatGrow(&Temp, &Size, L"Shell.efi -_exit ", 0);\r
+ StrnCatGrow(&Temp, &Size, CommandLine, 0);\r
\r
- DEBUG_CODE_BEGIN();\r
- Temp = ConvertDevicePathToText(ShellInfoObject.FileDevPath, TRUE, TRUE);\r
- FreePool(Temp);\r
- Temp = ConvertDevicePathToText(ShellInfoObject.ImageDevPath, TRUE, TRUE);\r
- FreePool(Temp);\r
- Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);\r
- FreePool(Temp);\r
- DEBUG_CODE_END();\r
+ Status = InternalShellExecuteDevicePath(\r
+ ParentImageHandle,\r
+ DevPath,\r
+ Temp,\r
+ (CONST CHAR16**)Environment,\r
+ StatusCode);\r
\r
- Temp = NULL;\r
- Size = 0;\r
- ASSERT((Temp == NULL && Size == 0) || (Temp != NULL));\r
- StrnCatGrow(&Temp, &Size, L"Shell.efi -_exit ", 0);\r
- StrnCatGrow(&Temp, &Size, CommandLine, 0);\r
+ //\r
+ // de-allocate and return\r
+ //\r
+ FreePool(DevPath);\r
+ FreePool(Temp);\r
+ } else {\r
+ // If Environment is NULL, we are free to use and mutate the current shell\r
+ // environment. This is much faster as uses much less memory.\r
\r
- Status = InternalShellExecuteDevicePath(\r
- ParentImageHandle,\r
- DevPath,\r
- Temp,\r
- (CONST CHAR16**)Environment,\r
- StatusCode);\r
+ if (CommandLine == NULL) {\r
+ CommandLine = L"";\r
+ }\r
+\r
+ Status = RunShellCommand (CommandLine, &CalleeStatusCode);\r
+\r
+ // Pass up the command's exit code if the caller wants it\r
+ if (StatusCode != NULL) {\r
+ *StatusCode = (EFI_STATUS) CalleeStatusCode;\r
+ }\r
+ }\r
\r
- //\r
- // de-allocate and return\r
- //\r
- FreePool(DevPath);\r
- FreePool(Temp);\r
return(Status);\r
}\r
\r