MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / DoStartupScript

Function DoStartupScript

ShellPkg/Application/Shell/Shell.c:1194–1334  ·  view source on GitHub ↗

Handles all interaction with the default startup script. this will check that the correct command line parameters were passed, handle the delay, and then start running the script. @param ImagePath the path to the image for shell. first place to look for the startup script @param FilePath the path to the file for shell. second place to look for the startup

Source from the content-addressed store, hash-verified

1192 @retval EFI_SUCCESS the variable is initialized.
1193**/
1194EFI_STATUS
1195DoStartupScript(
1196 IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,
1197 IN EFI_DEVICE_PATH_PROTOCOL *FilePath
1198 )
1199{
1200 EFI_STATUS Status;
1201 EFI_STATUS CalleeStatus;
1202 UINTN Delay;
1203 EFI_INPUT_KEY Key;
1204 SHELL_FILE_HANDLE FileHandle;
1205 EFI_DEVICE_PATH_PROTOCOL *NewPath;
1206 EFI_DEVICE_PATH_PROTOCOL *NamePath;
1207 CHAR16 *FileStringPath;
1208 CHAR16 *TempSpot;
1209 UINTN NewSize;
1210 CONST CHAR16 *MapName;
1211
1212 Key.UnicodeChar = CHAR_NULL;
1213 Key.ScanCode = 0;
1214 FileHandle = NULL;
1215
1216 if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.Startup && ShellInfoObject.ShellInitSettings.FileName != NULL) {
1217 //
1218 // launch something else instead
1219 //
1220 NewSize = StrSize(ShellInfoObject.ShellInitSettings.FileName);
1221 if (ShellInfoObject.ShellInitSettings.FileOptions != NULL) {
1222 NewSize += StrSize(ShellInfoObject.ShellInitSettings.FileOptions) + sizeof(CHAR16);
1223 }
1224 FileStringPath = AllocateZeroPool(NewSize);
1225 if (FileStringPath == NULL) {
1226 return (EFI_OUT_OF_RESOURCES);
1227 }
1228 StrCpyS(FileStringPath, NewSize/sizeof(CHAR16), ShellInfoObject.ShellInitSettings.FileName);
1229 if (ShellInfoObject.ShellInitSettings.FileOptions != NULL) {
1230 StrnCatS(FileStringPath, NewSize/sizeof(CHAR16), L" ", NewSize/sizeof(CHAR16) - StrLen(FileStringPath) -1);
1231 StrnCatS(FileStringPath, NewSize/sizeof(CHAR16), ShellInfoObject.ShellInitSettings.FileOptions, NewSize/sizeof(CHAR16) - StrLen(FileStringPath) -1);
1232 }
1233 Status = RunShellCommand(FileStringPath, &CalleeStatus);
1234 if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit == TRUE) {
1235 ShellCommandRegisterExit(gEfiShellProtocol->BatchIsActive(), (UINT64)CalleeStatus);
1236 }
1237 FreePool(FileStringPath);
1238 return (Status);
1239
1240 }
1241
1242 //
1243 // for shell level 0 we do no scripts
1244 // Without the Startup bit overriding we allow for nostartup to prevent scripts
1245 //
1246 if ( (PcdGet8(PcdShellSupportLevel) < 1)
1247 || (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoStartup && !ShellInfoObject.ShellInitSettings.BitUnion.Bits.Startup)
1248 ){
1249 return (EFI_SUCCESS);
1250 }
1251

Callers 1

UefiMainFunction · 0.85

Calls 15

StrnCatSFunction · 0.85
RunShellCommandFunction · 0.85
ShellCommandRegisterExitFunction · 0.85
ShellPrintHiiExFunction · 0.85
StrStrFunction · 0.85
PathRemoveLastItemFunction · 0.85
AppendDevicePathNodeFunction · 0.85
RunScriptFileFunction · 0.85
ShellCloseFileFunction · 0.85
StallMethod · 0.80
StrSizeFunction · 0.50

Tested by

no test coverage detected