VirtualBox

Ignore:
Timestamp:
Apr 14, 2023 3:17:44 PM (22 months ago)
Author:
vboxsync
Message:

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.c

    r85718 r99404  
    2929#include "UefiShellLevel2CommandsLib.h"
    3030
    31 CONST CHAR16 mFileName[] = L"ShellCommands";
    32 EFI_HII_HANDLE gShellLevel2HiiHandle = NULL;
     31CONST CHAR16    mFileName[]          = L"ShellCommands";
     32EFI_HII_HANDLE  gShellLevel2HiiHandle = NULL;
    3333
    3434/**
     
    3737  @retval The filename.
    3838**/
    39 CONST CHAR16*
     39CONST CHAR16 *
    4040EFIAPI
    4141ShellCommandGetManFileNameLevel2 (
     
    6767  // if shell level is less than 2 do nothing
    6868  //
    69   if (PcdGet8(PcdShellSupportLevel) < 2) {
     69  if (PcdGet8 (PcdShellSupportLevel) < 2) {
    7070    return (EFI_SUCCESS);
    7171  }
     
    7979  // install our shell command handlers that are always installed
    8080  //
    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));
    9494
    9595  //
    9696  // support for permanent (built in) aliases
    9797  //
    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");
    107107  //
    108108  // These are installed in level 2 or 3...
    109109  //
    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));
    114114  } else {
    115     DEBUG_CODE_BEGIN();
     115    DEBUG_CODE_BEGIN ();
    116116    //
    117117    // we want to be able to test these so install them under a different name in debug mode...
    118118    //
    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 ();
    123123  }
    124124
     
    142142{
    143143  if (gShellLevel2HiiHandle != NULL) {
    144     HiiRemovePackages(gShellLevel2HiiHandle);
    145   }
     144    HiiRemovePackages (gShellLevel2HiiHandle);
     145  }
     146
    146147  return (EFI_SUCCESS);
    147148}
     
    163164  @retval other           An allocated pointer to a fuly qualified path.
    164165**/
    165 CHAR16*
    166 GetFullyQualifiedPath(
    167   IN CONST CHAR16* Path
     166CHAR16 *
     167GetFullyQualifiedPath (
     168  IN CONST CHAR16  *Path
    168169  )
    169170{
     
    172173  CONST CHAR16  *CurDir;
    173174
    174   PathToReturn  = NULL;
    175   Size          = 0;
    176 
    177   ASSERT((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL));
     175  PathToReturn = NULL;
     176  Size         = 0;
     177
     178  ASSERT ((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL));
    178179  //
    179180  // convert a local path to an absolute path
    180181  //
    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);
    185186    if (*Path == L'\\') {
    186187      Path++;
    187188    }
    188189  }
    189   StrnCatGrow(&PathToReturn, &Size, Path, 0);
    190 
    191   PathCleanUpDirectories(PathToReturn);
     190
     191  StrnCatGrow (&PathToReturn, &Size, Path, 0);
     192
     193  PathCleanUpDirectories (PathToReturn);
    192194
    193195  if (PathToReturn == NULL) {
     
    195197  }
    196198
    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;
    199201  }
    200202
     
    211213EFI_STATUS
    212214VerifyIntermediateDirectories (
    213   IN CONST CHAR16 *Path
    214   )
    215 {
    216   EFI_STATUS      Status;
    217   CHAR16          *PathCopy;
    218   CHAR16          *TempSpot;
    219   SHELL_FILE_HANDLE          FileHandle;
    220 
    221   ASSERT(Path != NULL);
    222 
    223   Status      = EFI_SUCCESS;
    224   PathCopy    = NULL;
    225   PathCopy    = StrnCatGrow(&PathCopy, NULL, Path, 0);
    226   FileHandle  = NULL;
     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;
    227229
    228230  if (PathCopy == NULL) {
     
    230232  }
    231233
    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]) {
    233235    *TempSpot = CHAR_NULL;
    234236  }
     237
    235238  if (*TempSpot == L'\\') {
    236239    *TempSpot = CHAR_NULL;
    237240  }
    238241
    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);
    245248        if (FileHandle != NULL) {
    246           ShellCloseFile(&FileHandle);
     249          ShellCloseFile (&FileHandle);
    247250        }
    248251      }
     
    250253  }
    251254
    252   SHELL_FREE_NON_NULL(PathCopy);
     255  SHELL_FREE_NON_NULL (PathCopy);
    253256
    254257  return (Status);
     
    267270**/
    268271INTN
    269 StrniCmp(
    270   IN CONST CHAR16 *Source,
    271   IN CONST CHAR16 *Target,
    272   IN CONST UINTN  Count
    273   )
    274 {
    275   CHAR16                    *SourceCopy;
    276   CHAR16                    *TargetCopy;
    277   UINTN                     SourceLength;
    278   UINTN                     TargetLength;
    279   INTN                      Result;
     272StrniCmp (
     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;
    280283
    281284  if (Count == 0) {
     
    287290  SourceLength = MIN (SourceLength, Count);
    288291  TargetLength = MIN (TargetLength, Count);
    289   SourceCopy = AllocateCopyPool ((SourceLength + 1) * sizeof (CHAR16), Source);
     292  SourceCopy   = AllocateCopyPool ((SourceLength + 1) * sizeof (CHAR16), Source);
    290293  if (SourceCopy == NULL) {
    291294    return -1;
    292295  }
     296
    293297  TargetCopy = AllocateCopyPool ((TargetLength + 1) * sizeof (CHAR16), Target);
    294298  if (TargetCopy == NULL) {
     
    299303  SourceCopy[SourceLength] = L'\0';
    300304  TargetCopy[TargetLength] = L'\0';
    301   Result = gUnicodeCollation->StriColl (gUnicodeCollation, SourceCopy, TargetCopy);
     305  Result                   = gUnicodeCollation->StriColl (gUnicodeCollation, SourceCopy, TargetCopy);
    302306  FreePool (SourceCopy);
    303307  FreePool (TargetCopy);
    304308  return Result;
    305309}
    306 
    307310
    308311/**
     
    318321EFI_STATUS
    319322ShellLevel2StripQuotes (
    320   IN  CONST CHAR16     *OriginalString,
    321   OUT CHAR16           **CleanString
    322   )
    323 {
    324   CHAR16            *Walker;
    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)) {
    327330    return EFI_INVALID_PARAMETER;
    328331  }
     
    333336  }
    334337
    335   for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {
     338  for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL; Walker++) {
    336339    if (*Walker == L'\"') {
    337       CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));
     340      CopyMem (Walker, Walker+1, StrSize (Walker) - sizeof (Walker[0]));
    338341    }
    339342  }
     
    341344  return EFI_SUCCESS;
    342345}
    343 
    344 
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette