Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (22 months ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c
r85718 r99404 29 29 #include "UefiShellLevel2CommandsLib.h" 30 30 31 CONST CHAR16 mFileName[]= L"ShellCommands";32 EFI_HII_HANDLE gShellLevel2HiiHandle = NULL;31 CONST CHAR16 mFileName[] = L"ShellCommands"; 32 EFI_HII_HANDLE gShellLevel2HiiHandle = NULL; 33 33 34 34 /** … … 37 37 @retval The filename. 38 38 **/ 39 CONST CHAR16 *39 CONST CHAR16 * 40 40 EFIAPI 41 41 ShellCommandGetManFileNameLevel2 ( … … 67 67 // if shell level is less than 2 do nothing 68 68 // 69 if (PcdGet8 (PcdShellSupportLevel) < 2) {69 if (PcdGet8 (PcdShellSupportLevel) < 2) { 70 70 return (EFI_SUCCESS); 71 71 } … … 79 79 // install our shell command handlers that are always installed 80 80 // 81 ShellCommandRegisterCommandName (L"attrib", ShellCommandRunAttrib , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_ATTRIB));82 ShellCommandRegisterCommandName (L"cd", ShellCommandRunCd , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_CD));83 ShellCommandRegisterCommandName (L"cp", ShellCommandRunCp , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_CP));84 ShellCommandRegisterCommandName (L"load", ShellCommandRunLoad , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_LOAD));85 ShellCommandRegisterCommandName (L"map", ShellCommandRunMap , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_MAP));86 ShellCommandRegisterCommandName (L"mkdir", ShellCommandRunMkDir , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_MKDIR));87 ShellCommandRegisterCommandName (L"mv", ShellCommandRunMv , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_MV));88 ShellCommandRegisterCommandName (L"parse", ShellCommandRunParse , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_PARSE));89 ShellCommandRegisterCommandName (L"reset", ShellCommandRunReset , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_RESET));90 ShellCommandRegisterCommandName (L"set", ShellCommandRunSet , ShellCommandGetManFileNameLevel2, 2, L"",FALSE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_SET));91 ShellCommandRegisterCommandName (L"ls", ShellCommandRunLs , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_LS));92 ShellCommandRegisterCommandName (L"rm", ShellCommandRunRm , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_RM));93 ShellCommandRegisterCommandName (L"vol", ShellCommandRunVol , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_VOL));81 ShellCommandRegisterCommandName (L"attrib", ShellCommandRunAttrib, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_ATTRIB)); 82 ShellCommandRegisterCommandName (L"cd", ShellCommandRunCd, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_CD)); 83 ShellCommandRegisterCommandName (L"cp", ShellCommandRunCp, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_CP)); 84 ShellCommandRegisterCommandName (L"load", ShellCommandRunLoad, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_LOAD)); 85 ShellCommandRegisterCommandName (L"map", ShellCommandRunMap, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_MAP)); 86 ShellCommandRegisterCommandName (L"mkdir", ShellCommandRunMkDir, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_MKDIR)); 87 ShellCommandRegisterCommandName (L"mv", ShellCommandRunMv, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_MV)); 88 ShellCommandRegisterCommandName (L"parse", ShellCommandRunParse, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_PARSE)); 89 ShellCommandRegisterCommandName (L"reset", ShellCommandRunReset, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_RESET)); 90 ShellCommandRegisterCommandName (L"set", ShellCommandRunSet, ShellCommandGetManFileNameLevel2, 2, L"", FALSE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_SET)); 91 ShellCommandRegisterCommandName (L"ls", ShellCommandRunLs, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_LS)); 92 ShellCommandRegisterCommandName (L"rm", ShellCommandRunRm, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_RM)); 93 ShellCommandRegisterCommandName (L"vol", ShellCommandRunVol, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_VOL)); 94 94 95 95 // 96 96 // support for permanent (built in) aliases 97 97 // 98 ShellCommandRegisterAlias (L"rm", L"del");99 ShellCommandRegisterAlias (L"ls", L"dir");100 ShellCommandRegisterAlias (L"cp", L"copy");101 ShellCommandRegisterAlias (L"mkdir", L"md");102 ShellCommandRegisterAlias (L"cd ..", L"cd..");103 ShellCommandRegisterAlias (L"cd \\", L"cd\\");104 ShellCommandRegisterAlias (L"mv", L"ren");105 ShellCommandRegisterAlias (L"mv", L"move");106 ShellCommandRegisterAlias (L"map", L"mount");98 ShellCommandRegisterAlias (L"rm", L"del"); 99 ShellCommandRegisterAlias (L"ls", L"dir"); 100 ShellCommandRegisterAlias (L"cp", L"copy"); 101 ShellCommandRegisterAlias (L"mkdir", L"md"); 102 ShellCommandRegisterAlias (L"cd ..", L"cd.."); 103 ShellCommandRegisterAlias (L"cd \\", L"cd\\"); 104 ShellCommandRegisterAlias (L"mv", L"ren"); 105 ShellCommandRegisterAlias (L"mv", L"move"); 106 ShellCommandRegisterAlias (L"map", L"mount"); 107 107 // 108 108 // These are installed in level 2 or 3... 109 109 // 110 if ( PcdGet8(PcdShellSupportLevel) == 2 || PcdGet8(PcdShellSupportLevel) == 3) {111 ShellCommandRegisterCommandName (L"date", ShellCommandRunDate , ShellCommandGetManFileNameLevel2, PcdGet8(PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_DATE));112 ShellCommandRegisterCommandName (L"time", ShellCommandRunTime , ShellCommandGetManFileNameLevel2, PcdGet8(PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIME));113 ShellCommandRegisterCommandName (L"timezone", ShellCommandRunTimeZone, ShellCommandGetManFileNameLevel2, PcdGet8(PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIMEZONE));110 if ((PcdGet8 (PcdShellSupportLevel) == 2) || (PcdGet8 (PcdShellSupportLevel) == 3)) { 111 ShellCommandRegisterCommandName (L"date", ShellCommandRunDate, ShellCommandGetManFileNameLevel2, PcdGet8 (PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_DATE)); 112 ShellCommandRegisterCommandName (L"time", ShellCommandRunTime, ShellCommandGetManFileNameLevel2, PcdGet8 (PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_TIME)); 113 ShellCommandRegisterCommandName (L"timezone", ShellCommandRunTimeZone, ShellCommandGetManFileNameLevel2, PcdGet8 (PcdShellSupportLevel), L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_TIMEZONE)); 114 114 } else { 115 DEBUG_CODE_BEGIN ();115 DEBUG_CODE_BEGIN (); 116 116 // 117 117 // we want to be able to test these so install them under a different name in debug mode... 118 118 // 119 ShellCommandRegisterCommandName (L"l2date", ShellCommandRunDate , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_DATE));120 ShellCommandRegisterCommandName (L"l2time", ShellCommandRunTime , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIME));121 ShellCommandRegisterCommandName (L"l2timezone", ShellCommandRunTimeZone, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_TIMEZONE));122 DEBUG_CODE_END ();119 ShellCommandRegisterCommandName (L"l2date", ShellCommandRunDate, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_DATE)); 120 ShellCommandRegisterCommandName (L"l2time", ShellCommandRunTime, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_TIME)); 121 ShellCommandRegisterCommandName (L"l2timezone", ShellCommandRunTimeZone, ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN (STR_GET_HELP_TIMEZONE)); 122 DEBUG_CODE_END (); 123 123 } 124 124 … … 142 142 { 143 143 if (gShellLevel2HiiHandle != NULL) { 144 HiiRemovePackages(gShellLevel2HiiHandle); 145 } 144 HiiRemovePackages (gShellLevel2HiiHandle); 145 } 146 146 147 return (EFI_SUCCESS); 147 148 } … … 163 164 @retval other An allocated pointer to a fuly qualified path. 164 165 **/ 165 CHAR16 *166 GetFullyQualifiedPath (167 IN CONST CHAR16 *Path166 CHAR16 * 167 GetFullyQualifiedPath ( 168 IN CONST CHAR16 *Path 168 169 ) 169 170 { … … 172 173 CONST CHAR16 *CurDir; 173 174 174 PathToReturn 175 Size 176 177 ASSERT ((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL));175 PathToReturn = NULL; 176 Size = 0; 177 178 ASSERT ((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL)); 178 179 // 179 180 // convert a local path to an absolute path 180 181 // 181 if (StrStr (Path, L":") == NULL) {182 CurDir = gEfiShellProtocol->GetCurDir (NULL);183 StrnCatGrow (&PathToReturn, &Size, CurDir, 0);184 StrnCatGrow (&PathToReturn, &Size, L"\\", 0);182 if (StrStr (Path, L":") == NULL) { 183 CurDir = gEfiShellProtocol->GetCurDir (NULL); 184 StrnCatGrow (&PathToReturn, &Size, CurDir, 0); 185 StrnCatGrow (&PathToReturn, &Size, L"\\", 0); 185 186 if (*Path == L'\\') { 186 187 Path++; 187 188 } 188 189 } 189 StrnCatGrow(&PathToReturn, &Size, Path, 0); 190 191 PathCleanUpDirectories(PathToReturn); 190 191 StrnCatGrow (&PathToReturn, &Size, Path, 0); 192 193 PathCleanUpDirectories (PathToReturn); 192 194 193 195 if (PathToReturn == NULL) { … … 195 197 } 196 198 197 while (PathToReturn[StrLen (PathToReturn)-1] == L'*') {198 PathToReturn[StrLen (PathToReturn)-1] = CHAR_NULL;199 while (PathToReturn[StrLen (PathToReturn)-1] == L'*') { 200 PathToReturn[StrLen (PathToReturn)-1] = CHAR_NULL; 199 201 } 200 202 … … 211 213 EFI_STATUS 212 214 VerifyIntermediateDirectories ( 213 IN CONST CHAR16 *Path214 ) 215 { 216 EFI_STATUS Status;217 CHAR16 *PathCopy;218 CHAR16 *TempSpot;219 SHELL_FILE_HANDLE 220 221 ASSERT (Path != NULL);222 223 Status 224 PathCopy 225 PathCopy = StrnCatGrow(&PathCopy, NULL, Path, 0);226 FileHandle 215 IN CONST CHAR16 *Path 216 ) 217 { 218 EFI_STATUS Status; 219 CHAR16 *PathCopy; 220 CHAR16 *TempSpot; 221 SHELL_FILE_HANDLE FileHandle; 222 223 ASSERT (Path != NULL); 224 225 Status = EFI_SUCCESS; 226 PathCopy = NULL; 227 PathCopy = StrnCatGrow (&PathCopy, NULL, Path, 0); 228 FileHandle = NULL; 227 229 228 230 if (PathCopy == NULL) { … … 230 232 } 231 233 232 for (TempSpot = &PathCopy[StrLen (PathCopy)-1] ; *TempSpot != CHAR_NULL && *TempSpot != L'\\' ; TempSpot = &PathCopy[StrLen(PathCopy)-1]){234 for (TempSpot = &PathCopy[StrLen (PathCopy)-1]; *TempSpot != CHAR_NULL && *TempSpot != L'\\'; TempSpot = &PathCopy[StrLen (PathCopy)-1]) { 233 235 *TempSpot = CHAR_NULL; 234 236 } 237 235 238 if (*TempSpot == L'\\') { 236 239 *TempSpot = CHAR_NULL; 237 240 } 238 241 239 if ( PathCopy != NULL && *PathCopy != CHAR_NULL) {240 Status = VerifyIntermediateDirectories (PathCopy);241 242 if (PathCopy[StrLen (PathCopy)-1] != L':') {243 if (!EFI_ERROR (Status)) {244 Status = ShellOpenFileByName (PathCopy, &FileHandle, EFI_FILE_MODE_READ, 0);242 if ((PathCopy != NULL) && (*PathCopy != CHAR_NULL)) { 243 Status = VerifyIntermediateDirectories (PathCopy); 244 245 if (PathCopy[StrLen (PathCopy)-1] != L':') { 246 if (!EFI_ERROR (Status)) { 247 Status = ShellOpenFileByName (PathCopy, &FileHandle, EFI_FILE_MODE_READ, 0); 245 248 if (FileHandle != NULL) { 246 ShellCloseFile (&FileHandle);249 ShellCloseFile (&FileHandle); 247 250 } 248 251 } … … 250 253 } 251 254 252 SHELL_FREE_NON_NULL (PathCopy);255 SHELL_FREE_NON_NULL (PathCopy); 253 256 254 257 return (Status); … … 267 270 **/ 268 271 INTN 269 StrniCmp (270 IN CONST CHAR16 *Source,271 IN CONST CHAR16 *Target,272 IN CONST UINTN Count273 ) 274 { 275 CHAR16 276 CHAR16 277 UINTN 278 UINTN 279 INTN 272 StrniCmp ( 273 IN CONST CHAR16 *Source, 274 IN CONST CHAR16 *Target, 275 IN CONST UINTN Count 276 ) 277 { 278 CHAR16 *SourceCopy; 279 CHAR16 *TargetCopy; 280 UINTN SourceLength; 281 UINTN TargetLength; 282 INTN Result; 280 283 281 284 if (Count == 0) { … … 287 290 SourceLength = MIN (SourceLength, Count); 288 291 TargetLength = MIN (TargetLength, Count); 289 SourceCopy = AllocateCopyPool ((SourceLength + 1) * sizeof (CHAR16), Source);292 SourceCopy = AllocateCopyPool ((SourceLength + 1) * sizeof (CHAR16), Source); 290 293 if (SourceCopy == NULL) { 291 294 return -1; 292 295 } 296 293 297 TargetCopy = AllocateCopyPool ((TargetLength + 1) * sizeof (CHAR16), Target); 294 298 if (TargetCopy == NULL) { … … 299 303 SourceCopy[SourceLength] = L'\0'; 300 304 TargetCopy[TargetLength] = L'\0'; 301 Result = gUnicodeCollation->StriColl (gUnicodeCollation, SourceCopy, TargetCopy);305 Result = gUnicodeCollation->StriColl (gUnicodeCollation, SourceCopy, TargetCopy); 302 306 FreePool (SourceCopy); 303 307 FreePool (TargetCopy); 304 308 return Result; 305 309 } 306 307 310 308 311 /** … … 318 321 EFI_STATUS 319 322 ShellLevel2StripQuotes ( 320 IN CONST CHAR16 321 OUT CHAR16 322 ) 323 { 324 CHAR16 325 326 if ( OriginalString == NULL || CleanString == NULL) {323 IN CONST CHAR16 *OriginalString, 324 OUT CHAR16 **CleanString 325 ) 326 { 327 CHAR16 *Walker; 328 329 if ((OriginalString == NULL) || (CleanString == NULL)) { 327 330 return EFI_INVALID_PARAMETER; 328 331 } … … 333 336 } 334 337 335 for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL 338 for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL; Walker++) { 336 339 if (*Walker == L'\"') { 337 CopyMem (Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));340 CopyMem (Walker, Walker+1, StrSize (Walker) - sizeof (Walker[0])); 338 341 } 339 342 } … … 341 344 return EFI_SUCCESS; 342 345 } 343 344
Note:
See TracChangeset
for help on using the changeset viewer.