您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ FreePool函数代码示例

51自学网 2021-06-01 20:48:45
  C++
这篇教程C++ FreePool函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中FreePool函数的典型用法代码示例。如果您正苦于以下问题:C++ FreePool函数的具体用法?C++ FreePool怎么用?C++ FreePool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了FreePool函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: FtwWrite

//.........这里部分代码省略.........  MyOffset  = (UINT8 *) Record - FtwDevice->FtwWorkSpace;  MyLength  = RECORD_SIZE (Header->PrivateDataSize);  Status = FtwDevice->FtwFvBlock->Write (                                    FtwDevice->FtwFvBlock,                                    FtwDevice->FtwWorkSpaceLba,                                    FtwDevice->FtwWorkSpaceBase + MyOffset,                                    &MyLength,                                    (UINT8 *) Record                                    );  if (EFI_ERROR (Status)) {    return EFI_ABORTED;  }  //  // Record has written to working block, then do the data.  //  //  // Allocate a memory buffer  //  MyBufferSize  = FtwDevice->SpareAreaLength;  MyBuffer      = AllocatePool (MyBufferSize);  if (MyBuffer == NULL) {    return EFI_OUT_OF_RESOURCES;  }  //  // Read all original data from target block to memory buffer  //  Ptr = MyBuffer;  for (Index = 0; Index < FtwDevice->NumberOfSpareBlock; Index += 1) {    MyLength  = FtwDevice->BlockSize;    Status    = Fvb->Read (Fvb, Lba + Index, 0, &MyLength, Ptr);    if (EFI_ERROR (Status)) {      FreePool (MyBuffer);      return EFI_ABORTED;    }    Ptr += MyLength;  }  //  // Overwrite the updating range data with  // the input buffer content  //  CopyMem (MyBuffer + Offset, Buffer, Length);  //  // Try to keep the content of spare block  // Save spare block into a spare backup memory buffer (Sparebuffer)  //  SpareBufferSize = FtwDevice->SpareAreaLength;  SpareBuffer     = AllocatePool (SpareBufferSize);  if (SpareBuffer == NULL) {    FreePool (MyBuffer);    return EFI_OUT_OF_RESOURCES;  }  Ptr = SpareBuffer;  for (Index = 0; Index < FtwDevice->NumberOfSpareBlock; Index += 1) {    MyLength = FtwDevice->BlockSize;    Status = FtwDevice->FtwBackupFvb->Read (                                        FtwDevice->FtwBackupFvb,                                        FtwDevice->FtwSpareLba + Index,                                        0,                                        &MyLength,                                        Ptr                                        );
开发者ID:etiago,项目名称:vbox,代码行数:67,


示例2: CurrentLanguageMatch

/*++  Check whether the language is supported for given HII handle  @param   HiiHandle     The HII package list handle.  @param   Offset        The offest of current lanague in the supported languages.  @param   CurrentLang   The language code.  @retval  TRUE          Supported.  @retval  FALSE         Not Supported.**/VOIDEFIAPICurrentLanguageMatch (    IN  EFI_HII_HANDLE                   HiiHandle,    OUT UINT16                           *Offset,    OUT CHAR8                            *CurrentLang){    CHAR8     *DefaultLang;    CHAR8     *BestLanguage;    CHAR8     *Languages;    CHAR8     *MatchLang;    CHAR8     *EndMatchLang;    UINTN     CompareLength;    Languages = HiiGetSupportedLanguages (HiiHandle);    if (Languages == NULL) {        return;    }    CurrentLang  = GetEfiGlobalVariable (L"PlatformLang");    DefaultLang  = (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang);    BestLanguage = GetBestLanguage (                       Languages,                       FALSE,                       (CurrentLang != NULL) ? CurrentLang : "",                       DefaultLang,                       NULL                   );    if (BestLanguage != NULL) {        //        // Find the best matching RFC 4646 language, compute the offset.        //        CompareLength = AsciiStrLen (BestLanguage);        for (MatchLang = Languages, (*Offset) = 0; MatchLang != '/0'; (*Offset)++) {            //            // Seek to the end of current match language.            //            for (EndMatchLang = MatchLang; *EndMatchLang != '/0' && *EndMatchLang != ';'; EndMatchLang++);            if ((EndMatchLang == MatchLang + CompareLength) && AsciiStrnCmp(MatchLang, BestLanguage, CompareLength) == 0) {                //                // Find the current best Language in the supported languages                //                break;            }            //            // best language match be in the supported language.            //            ASSERT (*EndMatchLang == ';');            MatchLang = EndMatchLang + 1;        }        FreePool (BestLanguage);    }    FreePool (Languages);    if (CurrentLang != NULL) {        FreePool (CurrentLang);    }    return ;}
开发者ID:hsienchieh,项目名称:uefilab,代码行数:72,


示例3: file

/**  Function to validate that moving a specific file (FileName) to a specific  location (DestPath) is valid.  This function will verify that the destination is not a subdirectory of  FullName, that the Current working Directory is not being moved, and that  the directory is not read only.  if the move is invalid this function will report the error to StdOut.  @param SourcePath [in]    The name of the file to move.  @param Cwd        [in]    The current working directory  @param DestPath   [in]    The target location to move to  @param Attribute  [in]    The Attribute of the file  @param DestAttr   [in]    The Attribute of the destination  @param FileStatus [in]    The Status of the file when opened  @retval TRUE        The move is valid  @retval FALSE       The move is not**/BOOLEANEFIAPIIsValidMove(  IN CONST CHAR16     *SourcePath,  IN CONST CHAR16     *Cwd,  IN CONST CHAR16     *DestPath,  IN CONST UINT64     Attribute,  IN CONST UINT64     DestAttr,  IN CONST EFI_STATUS FileStatus  ){  CHAR16  *DestPathCopy;  CHAR16  *DestPathWalker;  if (Cwd != NULL && StrCmp(SourcePath, Cwd) == 0) {    //    // Invalid move    //    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_CWD), gShellLevel2HiiHandle);    return (FALSE);  }  //  // invalid to move read only or move to a read only destination  //  if (((Attribute & EFI_FILE_READ_ONLY) != 0)     || (FileStatus == EFI_WRITE_PROTECTED)    || ((DestAttr & EFI_FILE_READ_ONLY) != 0)    ) {    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_RO), gShellLevel2HiiHandle, SourcePath);    return (FALSE);  }      DestPathCopy = AllocateCopyPool(StrSize(DestPath), DestPath);  if (DestPathCopy == NULL) {    return (FALSE);  }  for (DestPathWalker = DestPathCopy; *DestPathWalker == L'//'; DestPathWalker++) ;  while(DestPathWalker != NULL && DestPathWalker[StrLen(DestPathWalker)-1] == L'//') {    DestPathWalker[StrLen(DestPathWalker)-1] = CHAR_NULL;  }  ASSERT(DestPathWalker != NULL);  ASSERT(SourcePath   != NULL);  //  // If they're the same, or if source is "above" dest on file path tree  //  if ( StrCmp(DestPathWalker, SourcePath) == 0     || StrStr(DestPathWalker, SourcePath) == DestPathWalker     ) {    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);    FreePool(DestPathCopy);    return (FALSE);  }  FreePool(DestPathCopy);  return (TRUE);}
开发者ID:Teino1978-Corp,项目名称:edk2,代码行数:81,


示例4: UiSetConsoleMode

//.........这里部分代码省略.........  if (SimpleTextOut != NULL) {    MaxTextMode = SimpleTextOut->Mode->MaxMode;  }  //  // 1. If current video resolution is same with required video resolution,  //    video resolution need not be changed.  //    1.1. If current text mode is same with required text mode, text mode need not be changed.  //    1.2. If current text mode is different from required text mode, text mode need be changed.  // 2. If current video resolution is different from required video resolution, we need restart whole console drivers.  //  for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {    Status = GraphicsOutput->QueryMode (                       GraphicsOutput,                       ModeNumber,                       &SizeOfInfo,                       &Info                       );    if (!EFI_ERROR (Status)) {      if ((Info->HorizontalResolution == NewHorizontalResolution) &&          (Info->VerticalResolution == NewVerticalResolution)) {        if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&            (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {          //          // Current resolution is same with required resolution, check if text mode need be set          //          Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);          ASSERT_EFI_ERROR (Status);          if (CurrentColumn == NewColumns && CurrentRow == NewRows) {            //            // If current text mode is same with required text mode. Do nothing            //            FreePool (Info);            return EFI_SUCCESS;          } else {            //            // If current text mode is different from requried text mode.  Set new video mode            //            for (Index = 0; Index < MaxTextMode; Index++) {              Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);              if (!EFI_ERROR(Status)) {                if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {                  //                  // Required text mode is supported, set it.                  //                  Status = SimpleTextOut->SetMode (SimpleTextOut, Index);                  ASSERT_EFI_ERROR (Status);                  //                  // Update text mode PCD.                  //                  Status = PcdSet32S (PcdConOutColumn, mSetupTextModeColumn);                  ASSERT_EFI_ERROR (Status);                  Status = PcdSet32S (PcdConOutRow, mSetupTextModeRow);                  ASSERT_EFI_ERROR (Status);                  FreePool (Info);                  return EFI_SUCCESS;                }              }            }            if (Index == MaxTextMode) {              //              // If requried text mode is not supported, return error.              //              FreePool (Info);              return EFI_UNSUPPORTED;
开发者ID:jonpablo,项目名称:edk2,代码行数:67,


示例5: GroupMultipleLegacyBootOption4SameType

/**  Group the legacy boot options in the BootOption.  The routine assumes the boot options in the beginning that covers all the device   types are ordered properly and re-position the following boot options just after  the corresponding boot options with the same device type.  For example:  1. Input  = [Harddisk1 CdRom2 Efi1 Harddisk0 CdRom0 CdRom1 Harddisk2 Efi0]     Assuming [Harddisk1 CdRom2 Efi1] is ordered properly     Output = [Harddisk1 Harddisk0 Harddisk2 CdRom2 CdRom0 CdRom1 Efi1 Efi0]  2. Input  = [Efi1 Efi0 CdRom1 Harddisk0 Harddisk1 Harddisk2 CdRom0 CdRom2]     Assuming [Efi1 Efi0 CdRom1 Harddisk0] is ordered properly     Output = [Efi1 Efi0 CdRom1 CdRom0 CdRom2 Harddisk0 Harddisk1 Harddisk2]**/VOIDGroupMultipleLegacyBootOption4SameType (  VOID  ){  EFI_STATUS                   Status;  UINTN                        Index;  UINTN                        DeviceIndex;  UINTN                        DeviceTypeIndex[7];  UINTN                        *NextIndex;  UINT16                       OptionNumber;  UINT16                       *BootOrder;  UINTN                        BootOrderSize;  CHAR16                       OptionName[sizeof ("Boot####")];  EFI_BOOT_MANAGER_LOAD_OPTION BootOption;  SetMem (DeviceTypeIndex, sizeof (DeviceTypeIndex), 0xff);  GetEfiGlobalVariable2 (L"BootOrder", (VOID **) &BootOrder, &BootOrderSize);  if (BootOrder == NULL) {    return;  }  for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {    UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);    Status = EfiBootManagerVariableToLoadOption (OptionName, &BootOption);    ASSERT_EFI_ERROR (Status);    if ((DevicePathType (BootOption.FilePath) == BBS_DEVICE_PATH) &&        (DevicePathSubType (BootOption.FilePath) == BBS_BBS_DP)) {      //      // Legacy Boot Option      //      DEBUG ((EFI_D_ERROR, "[BootManagerDxe] ==== Find Legacy Boot Option  0x%x! ==== /n", Index));      ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF) < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]));      NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF];      if (*NextIndex == (UINTN) -1) {        //        // *NextIndex is the Index in BootOrder to put the next Option Number for the same type        //        *NextIndex = Index + 1;      } else {        //        // insert the current boot option before *NextIndex, causing [*Next .. Index] shift right one position        //        OptionNumber = BootOrder[Index];        CopyMem (&BootOrder[*NextIndex + 1], &BootOrder[*NextIndex], (Index - *NextIndex) * sizeof (UINT16));        BootOrder[*NextIndex] = OptionNumber;        //        // Update the DeviceTypeIndex array to reflect the right shift operation        //        for (DeviceIndex = 0; DeviceIndex < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]); DeviceIndex++) {          if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) {            DeviceTypeIndex[DeviceIndex]++;          }        }      }    }    EfiBootManagerFreeLoadOption (&BootOption);  }  gRT->SetVariable (         L"BootOrder",         &gEfiGlobalVariableGuid,         VAR_FLAG,         BootOrderSize,         BootOrder         );  FreePool (BootOrder);}
开发者ID:M1cha,项目名称:edk2,代码行数:88,


示例6: ValidateAndMoveFiles

/**  function to take a list of files to move and a destination location and do  the verification and moving of those files to that location.  This function  will report any errors to the user and continue to move the rest of the files.  @param[in] FileList           A LIST_ENTRY* based list of files to move  @param[out] Resp              pointer to response from question.  Pass back on looped calling  @param[in] DestParameter      the originally specified destination location  @retval SHELL_SUCCESS             the files were all moved.  @retval SHELL_INVALID_PARAMETER   a parameter was invalid  @retval SHELL_SECURITY_VIOLATION  a security violation ocurred  @retval SHELL_WRITE_PROTECTED     the destination was write protected  @retval SHELL_OUT_OF_RESOURCES    a memory allocation failed**/SHELL_STATUSEFIAPIValidateAndMoveFiles(  IN EFI_SHELL_FILE_INFO        *FileList,  OUT VOID                      **Resp,  IN CONST CHAR16               *DestParameter  ){  EFI_STATUS                Status;  CHAR16                    *HiiOutput;  CHAR16                    *HiiResultOk;  CHAR16                    *DestPath;  CHAR16                    *FullDestPath;  CONST CHAR16              *Cwd;  SHELL_STATUS              ShellStatus;  EFI_SHELL_FILE_INFO       *Node;  VOID                      *Response;  UINT64                    Attr;  CHAR16                    *CleanFilePathStr;  ASSERT(FileList != NULL);  ASSERT(DestParameter  != NULL);  DestPath          = NULL;  FullDestPath      = NULL;  Cwd               = ShellGetCurrentDir(NULL);  Response          = *Resp;  Attr              = 0;  CleanFilePathStr  = NULL;  Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr);  if (EFI_ERROR (Status)) {    if (Status == EFI_OUT_OF_RESOURCES) {      return SHELL_OUT_OF_RESOURCES;    } else {      return SHELL_INVALID_PARAMETER;    }  }  ASSERT (CleanFilePathStr != NULL);  //  // Get and validate the destination location  //  ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, Cwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);  FreePool (CleanFilePathStr);  if (ShellStatus != SHELL_SUCCESS) {    return (ShellStatus);  }  DestPath = PathCleanUpDirectories(DestPath);  if (DestPath == NULL) {    return (SHELL_OUT_OF_RESOURCES);  }  HiiOutput   = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_MV_OUTPUT), NULL);  HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL);  if (HiiOutput == NULL || HiiResultOk == NULL) {    SHELL_FREE_NON_NULL(DestPath);    SHELL_FREE_NON_NULL(HiiOutput);    SHELL_FREE_NON_NULL(HiiResultOk);    return (SHELL_OUT_OF_RESOURCES);  }  //  // Go through the list of files and directories to move...  //  for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)    ;  !IsNull(&FileList->Link, &Node->Link)    ;  Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)   ){    if (ShellGetExecutionBreakFlag()) {      break;    }    //    // These should never be NULL    //    ASSERT(Node->FileName != NULL);    ASSERT(Node->FullName != NULL);    ASSERT(Node->Info     != NULL);    //    // skip the directory traversing stuff...    ////.........这里部分代码省略.........
开发者ID:Teino1978-Corp,项目名称:edk2,代码行数:101,


示例7: BOpt_FindDrivers

/**  Find drivers that will be added as Driver#### variables from handles  in current system environment  All valid handles in the system except those consume SimpleFs, LoadFile  are stored in DriverMenu for future use.  @retval EFI_SUCCESS The function complets successfully.  @return Other value if failed to build the DriverMenu.**/EFI_STATUSBOpt_FindDrivers (  VOID  ){  UINTN                           NoDevicePathHandles;  EFI_HANDLE                      *DevicePathHandle;  UINTN                           Index;  EFI_STATUS                      Status;  BM_MENU_ENTRY                   *NewMenuEntry;  BM_HANDLE_CONTEXT               *NewHandleContext;  EFI_HANDLE                      CurHandle;  UINTN                           OptionNumber;  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;  EFI_LOAD_FILE_PROTOCOL          *LoadFile;  SimpleFs  = NULL;  LoadFile  = NULL;  InitializeListHead (&DriverMenu.Head);  //  // At first, get all handles that support Device Path  // protocol which is the basic requirement for  // Driver####  //  Status = gBS->LocateHandleBuffer (                  ByProtocol,                  &gEfiDevicePathProtocolGuid,                  NULL,                  &NoDevicePathHandles,                  &DevicePathHandle                  );  if (EFI_ERROR (Status)) {    return Status;  }  OptionNumber = 0;  for (Index = 0; Index < NoDevicePathHandles; Index++) {    CurHandle = DevicePathHandle[Index];    Status = gBS->HandleProtocol (                    CurHandle,                    &gEfiSimpleFileSystemProtocolGuid,                    (VOID **) &SimpleFs                    );    if (Status == EFI_SUCCESS) {      continue;    }    Status = gBS->HandleProtocol (                    CurHandle,                    &gEfiLoadFileProtocolGuid,                    (VOID **) &LoadFile                    );    if (Status == EFI_SUCCESS) {      continue;    }    NewMenuEntry = BOpt_CreateMenuEntry (BM_HANDLE_CONTEXT_SELECT);    if (NULL == NewMenuEntry) {      FreePool (DevicePathHandle);      return EFI_OUT_OF_RESOURCES;    }    NewHandleContext              = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;    NewHandleContext->Handle      = CurHandle;    NewHandleContext->DevicePath  = DevicePathFromHandle (CurHandle);    NewMenuEntry->DisplayString = UiDevicePathToStr (NewHandleContext->DevicePath);    NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle,0,NewMenuEntry->DisplayString,NULL);    NewMenuEntry->HelpString    = NULL;    NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;    NewMenuEntry->OptionNumber  = OptionNumber;    OptionNumber++;    InsertTailList (&DriverMenu.Head, &NewMenuEntry->Link);  }  if (DevicePathHandle != NULL) {    FreePool (DevicePathHandle);  }  DriverMenu.MenuNumber = OptionNumber;  return EFI_SUCCESS;}
开发者ID:ErikBjorge,项目名称:edk2,代码行数:96,


示例8: BOpt_GetDriverOptions

//.........这里部分代码省略.........    return EFI_NOT_FOUND;  }    for (Index = 0; Index < DriverOrderListSize / sizeof (UINT16); Index++) {    UnicodeSPrint (      DriverString,      sizeof (DriverString),      L"Driver%04x",      DriverOrderList[Index]      );    //    //  Get all loadoptions from the VAR    //    GetEfiGlobalVariable2 (DriverString, (VOID **) &LoadOptionFromVar, &DriverOptionSize);    if (LoadOptionFromVar == NULL) {      continue;    }    NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);    if (NULL == NewMenuEntry) {      return EFI_OUT_OF_RESOURCES;    }    NewLoadContext                      = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;    LoadOptionPtr                       = LoadOptionFromVar;    LoadOptionEnd                       = LoadOptionFromVar + DriverOptionSize;    NewMenuEntry->OptionNumber          = DriverOrderList[Index];    NewLoadContext->Deleted             = FALSE;    NewLoadContext->IsLegacy            = FALSE;    //    // LoadOption is a pointer type of UINT8    // for easy use with following LOAD_OPTION    // embedded in this struct    //    NewLoadContext->Attributes      = *(UINT32 *) LoadOptionPtr;    LoadOptionPtr += sizeof (UINT32);    NewLoadContext->FilePathListLength = *(UINT16 *) LoadOptionPtr;    LoadOptionPtr += sizeof (UINT16);    StringSize                  = StrSize ((UINT16 *) LoadOptionPtr);    NewLoadContext->Description = AllocateZeroPool (StringSize);    ASSERT (NewLoadContext->Description != NULL);    CopyMem (      NewLoadContext->Description,      (UINT16 *) LoadOptionPtr,      StringSize      );    NewMenuEntry->DisplayString = NewLoadContext->Description;    NewMenuEntry->DisplayStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);    LoadOptionPtr += StringSize;    NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);    ASSERT (NewLoadContext->FilePathList != NULL);    CopyMem (      NewLoadContext->FilePathList,      (EFI_DEVICE_PATH_PROTOCOL *) LoadOptionPtr,      NewLoadContext->FilePathListLength      );    NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);    NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);     LoadOptionPtr += NewLoadContext->FilePathListLength;    if (LoadOptionPtr < LoadOptionEnd) {      OptionalDataSize = DriverOptionSize -        sizeof (UINT32) -        sizeof (UINT16) -        StringSize -        NewLoadContext->FilePathListLength;      NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);      ASSERT (NewLoadContext->OptionalData != NULL);      CopyMem (        NewLoadContext->OptionalData,        LoadOptionPtr,        OptionalDataSize        );    }    InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);    FreePool (LoadOptionFromVar);  }  if (DriverOrderList != NULL) {    FreePool (DriverOrderList);  }  DriverOptionMenu.MenuNumber = Index;  return EFI_SUCCESS;}
开发者ID:ErikBjorge,项目名称:edk2,代码行数:101,


示例9: BOpt_DestroyMenuEntry

/**  Free up all resource allocated for a BM_MENU_ENTRY.  @param MenuEntry   A pointer to BM_MENU_ENTRY.**/VOIDBOpt_DestroyMenuEntry (  BM_MENU_ENTRY         *MenuEntry  ){  BM_LOAD_CONTEXT           *LoadContext;  BM_FILE_CONTEXT           *FileContext;  BM_CONSOLE_CONTEXT        *ConsoleContext;  BM_TERMINAL_CONTEXT       *TerminalContext;  BM_HANDLE_CONTEXT         *HandleContext;  //  //  Select by the type in Menu entry for current context type  //  switch (MenuEntry->ContextSelection) {  case BM_LOAD_CONTEXT_SELECT:    LoadContext = (BM_LOAD_CONTEXT *) MenuEntry->VariableContext;    FreePool (LoadContext->FilePathList);    if (LoadContext->OptionalData != NULL) {      FreePool (LoadContext->OptionalData);    }    FreePool (LoadContext);    break;  case BM_FILE_CONTEXT_SELECT:    FileContext = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;    if (!FileContext->IsRoot) {      FreePool (FileContext->DevicePath);    } else {      if (FileContext->FHandle != NULL) {        FileContext->FHandle->Close (FileContext->FHandle);      }    }    if (FileContext->FileName != NULL) {      FreePool (FileContext->FileName);    }    if (FileContext->Info != NULL) {      FreePool (FileContext->Info);    }    FreePool (FileContext);    break;  case BM_CONSOLE_CONTEXT_SELECT:    ConsoleContext = (BM_CONSOLE_CONTEXT *) MenuEntry->VariableContext;    FreePool (ConsoleContext->DevicePath);    FreePool (ConsoleContext);    break;  case BM_TERMINAL_CONTEXT_SELECT:    TerminalContext = (BM_TERMINAL_CONTEXT *) MenuEntry->VariableContext;    FreePool (TerminalContext->DevicePath);    FreePool (TerminalContext);    break;  case BM_HANDLE_CONTEXT_SELECT:    HandleContext = (BM_HANDLE_CONTEXT *) MenuEntry->VariableContext;    FreePool (HandleContext);    break;  default:    break;  }  FreePool (MenuEntry->DisplayString);  if (MenuEntry->HelpString != NULL) {    FreePool (MenuEntry->HelpString);  }  FreePool (MenuEntry);}
开发者ID:ErikBjorge,项目名称:edk2,代码行数:78,


示例10: BOpt_GetBootOptions

/**  Build the BootOptionMenu according to BootOrder Variable.  This Routine will access the Boot#### to get EFI_LOAD_OPTION.  @param CallbackData The BMM context data.  @return EFI_NOT_FOUND Fail to find "BootOrder" variable.  @return EFI_SUCESS    Success build boot option menu.**/EFI_STATUSBOpt_GetBootOptions (  IN  BMM_CALLBACK_DATA         *CallbackData  ){  UINTN                         Index;  UINT16                        BootString[10];  UINT8                         *LoadOptionFromVar;  UINTN                         BootOptionSize;  BOOLEAN                       BootNextFlag;  UINT16                        *BootOrderList;  UINTN                         BootOrderListSize;  UINT16                        *BootNext;  UINTN                         BootNextSize;  BM_MENU_ENTRY                 *NewMenuEntry;  BM_LOAD_CONTEXT               *NewLoadContext;  UINT8                         *LoadOptionPtr;  UINTN                         StringSize;  UINTN                         OptionalDataSize;  UINT8                         *LoadOptionEnd;  EFI_DEVICE_PATH_PROTOCOL      *DevicePath;  UINTN                         MenuCount;  UINT8                         *Ptr;  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption;  UINTN                         BootOptionCount;      MenuCount         = 0;  BootOrderListSize = 0;  BootNextSize      = 0;  BootOrderList     = NULL;  BootNext          = NULL;  LoadOptionFromVar = NULL;  BOpt_FreeMenu (&BootOptionMenu);  InitializeListHead (&BootOptionMenu.Head);  //  // Get the BootOrder from the Var  //  GetEfiGlobalVariable2 (L"BootOrder", (VOID **) &BootOrderList, &BootOrderListSize);  if (BootOrderList == NULL) {    return EFI_NOT_FOUND;  }    //  // Get the BootNext from the Var  //  GetEfiGlobalVariable2 (L"BootNext", (VOID **) &BootNext, &BootNextSize);  if (BootNext != NULL) {    if (BootNextSize != sizeof (UINT16)) {      FreePool (BootNext);      BootNext = NULL;    }  }  BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);  for (Index = 0; Index < BootOrderListSize / sizeof (UINT16); Index++) {    //    // Don't display the hidden/inactive boot option    //    if (((BootOption[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) || ((BootOption[Index].Attributes & LOAD_OPTION_ACTIVE) == 0)) {      continue;    }          UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", BootOrderList[Index]);    //    //  Get all loadoptions from the VAR    //    GetEfiGlobalVariable2 (BootString, (VOID **) &LoadOptionFromVar, &BootOptionSize);    if (LoadOptionFromVar == NULL) {      continue;    }    if (BootNext != NULL) {      BootNextFlag = (BOOLEAN) (*BootNext == BootOrderList[Index]);    } else {      BootNextFlag = FALSE;    }    NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);    ASSERT (NULL != NewMenuEntry);    NewLoadContext                      = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;    LoadOptionPtr                       = LoadOptionFromVar;    LoadOptionEnd                       = LoadOptionFromVar + BootOptionSize;    NewMenuEntry->OptionNumber          = BootOrderList[Index];    NewLoadContext->Deleted             = FALSE;    NewLoadContext->IsBootNext          = BootNextFlag;//.........这里部分代码省略.........
开发者ID:ErikBjorge,项目名称:edk2,代码行数:101,


示例11: Image

/**  Function for 'memmap' command.  @param[in] ImageHandle  Handle to the Image (NULL if Internal).  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).**/SHELL_STATUSEFIAPIShellCommandRunMemMap (  IN EFI_HANDLE        ImageHandle,  IN EFI_SYSTEM_TABLE  *SystemTable  ){  EFI_STATUS          Status;  LIST_ENTRY          *Package;  CHAR16              *ProblemParam;  SHELL_STATUS        ShellStatus;  UINTN               Size;  EFI_MEMORY_DESCRIPTOR *Buffer;  UINTN               MapKey;  UINTN               ItemSize;  UINT32              Version;  UINT8               *Walker;  UINT64              ReservedPages;  UINT64              LoadCodePages;  UINT64              LoadDataPages;  UINT64              BSCodePages;  UINT64              BSDataPages;  UINT64              RTDataPages;  UINT64              RTCodePages;  UINT64              AvailPages;  UINT64              TotalPages;  UINT64              ReservedPagesSize;  UINT64              LoadCodePagesSize;  UINT64              LoadDataPagesSize;  UINT64              BSCodePagesSize;  UINT64              BSDataPagesSize;  UINT64              RTDataPagesSize;  UINT64              RTCodePagesSize;  UINT64              AvailPagesSize;  UINT64              TotalPagesSize;  UINT64              AcpiReclaimPages;  UINT64              AcpiNvsPages;  UINT64              MmioSpacePages;  UINT64              AcpiReclaimPagesSize;  UINT64              AcpiNvsPagesSize;  UINT64              MmioSpacePagesSize;  BOOLEAN             Sfo;  AcpiReclaimPages    = 0;  AcpiNvsPages        = 0;  MmioSpacePages      = 0;  TotalPages          = 0;  ReservedPages       = 0;  LoadCodePages       = 0;  LoadDataPages       = 0;  BSCodePages         = 0;  BSDataPages         = 0;  RTDataPages         = 0;  RTCodePages         = 0;  AvailPages          = 0;  Size                = 0;  Buffer              = NULL;  ShellStatus         = SHELL_SUCCESS;  Status              = EFI_SUCCESS;  //  // initialize the shell lib (we must be in non-auto-init...)  //  Status = ShellInitialize();  ASSERT_EFI_ERROR(Status);  Status = CommandInit();  ASSERT_EFI_ERROR(Status);  //  // parse the command line  //  Status = ShellCommandLineParse (SfoParamList, &Package, &ProblemParam, TRUE);  if (EFI_ERROR(Status)) {    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam);      FreePool(ProblemParam);      ShellStatus = SHELL_INVALID_PARAMETER;    } else {      ASSERT(FALSE);    }  } else {    if (ShellCommandLineGetCount(Package) > 1) {      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);      ShellStatus = SHELL_INVALID_PARAMETER;    } else {      Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version);      if (Status == EFI_BUFFER_TOO_SMALL){        Size += SIZE_1KB;        Buffer = AllocateZeroPool(Size);        Status = gBS->GetMemoryMap(&Size, Buffer, &MapKey, &ItemSize, &Version);      }      if (EFI_ERROR(Status)) {        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MEMMAP_GET_FAILED), gShellDebug1HiiHandle, Status);//.........这里部分代码省略.........
开发者ID:AshleyDeSimone,项目名称:edk2,代码行数:101,


示例12: DebugPortSupported

/**  Checks to see if there's not already a DebugPort interface somewhere.  If there's a DEBUGPORT variable, the device path must match exactly.  If there's  no DEBUGPORT variable, then device path is not checked and does not matter.  Checks to see that there's a serial io interface on the controller handle  that can be bound BY_DRIVER | EXCLUSIVE.  If all these tests succeed, then we return EFI_SUCCESS, else, EFI_UNSUPPORTED  or other error returned by OpenProtocol.  @param  This                 Protocol instance pointer.  @param  ControllerHandle     Handle of device to test.  @param  RemainingDevicePath  Optional parameter use to pick a specific child                               device to start.  @retval EFI_SUCCESS          This driver supports this device.  @retval EFI_UNSUPPORTED      Debug Port device is not supported.  @retval EFI_OUT_OF_RESOURCES Fails to allocate memory for device.  @retval others               Some error occurs.**/EFI_STATUSEFIAPIDebugPortSupported (  IN EFI_DRIVER_BINDING_PROTOCOL    *This,  IN EFI_HANDLE                     ControllerHandle,  IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath  ){  EFI_STATUS                Status;  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;  EFI_DEVICE_PATH_PROTOCOL  *DebugPortVariable;  EFI_SERIAL_IO_PROTOCOL    *SerialIo;  EFI_DEBUGPORT_PROTOCOL    *DebugPortInterface;  EFI_HANDLE                TempHandle;  //  // Check to see that there's not a debugport protocol already published,  // since only one standard UART serial port could be supported by this driver.  //  if (gBS->LocateProtocol (&gEfiDebugPortProtocolGuid, NULL, (VOID **) &DebugPortInterface) != EFI_NOT_FOUND) {    return EFI_UNSUPPORTED;  }  //  // Read DebugPort variable to determine debug port selection and parameters  //  DebugPortVariable = GetDebugPortVariable ();  if (DebugPortVariable != NULL) {    //    // There's a DEBUGPORT variable, so do LocateDevicePath and check to see if    // the closest matching handle matches the controller handle, and if it does,    // check to see that the remaining device path has the DebugPort GUIDed messaging    // device path only.  Otherwise, it's a mismatch and EFI_UNSUPPORTED is returned.    //    DevicePath = DebugPortVariable;    Status = gBS->LocateDevicePath (                    &gEfiSerialIoProtocolGuid,                    &DevicePath,                    &TempHandle                    );    if (Status == EFI_SUCCESS && TempHandle != ControllerHandle) {      Status = EFI_UNSUPPORTED;    }    if (Status == EFI_SUCCESS &&        (DevicePath->Type != MESSAGING_DEVICE_PATH ||         DevicePath->SubType != MSG_VENDOR_DP ||         *((UINT16 *) DevicePath->Length) != sizeof (DEBUGPORT_DEVICE_PATH))) {      Status = EFI_UNSUPPORTED;    }    if (Status == EFI_SUCCESS && !CompareGuid (&gEfiDebugPortDevicePathGuid, (GUID *) (DevicePath + 1))) {      Status = EFI_UNSUPPORTED;    }    FreePool (DebugPortVariable);    if (EFI_ERROR (Status)) {      return Status;    }  }  Status = gBS->OpenProtocol (                  ControllerHandle,                  &gEfiSerialIoProtocolGuid,                  (VOID **) &SerialIo,                  This->DriverBindingHandle,                  ControllerHandle,                  EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE                  );  if (EFI_ERROR (Status)) {    return Status;  }  Status = gBS->CloseProtocol (                  ControllerHandle,                  &gEfiSerialIoProtocolGuid,                  This->DriverBindingHandle,//.........这里部分代码省略.........
开发者ID:lersek,项目名称:edk2,代码行数:101,


示例13: ExtractDisplayedHiiFormFromHiiHandle

//.........这里部分代码省略.........  *FormSetTitle = 0;  *FormSetHelp  = 0;  ClassGuidNum  = 0;  ClassGuid     = NULL;  FoundAndSkip  = FALSE;  //  // Get HII PackageList  //  BufferSize = 0;  HiiPackageList = NULL;  Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &BufferSize, HiiPackageList);  //  // Handle is a invalid handle. Check if Handle is corrupted.  //  ASSERT (Status != EFI_NOT_FOUND);  //  // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.  //  ASSERT (Status == EFI_BUFFER_TOO_SMALL);    HiiPackageList = AllocatePool (BufferSize);  ASSERT (HiiPackageList != NULL);  Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &BufferSize, HiiPackageList);  if (EFI_ERROR (Status)) {    return FALSE;  }  //  // Get Form package from this HII package List  //  Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);  PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);  while (Offset < PackageListLength) {    Package = ((UINT8 *) HiiPackageList) + Offset;    CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));    Offset += PackageHeader.Length;    if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {      //      // Search FormSet Opcode in this Form Package      //      Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);      while (Offset2 < PackageHeader.Length) {        OpCodeData = Package + Offset2;        Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;        if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {          if (((EFI_IFR_OP_HEADER *) OpCodeData)->Length > OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {            //            // Find FormSet OpCode            //            ClassGuidNum = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);            ClassGuid = (EFI_GUID *) (VOID *)(OpCodeData + sizeof (EFI_IFR_FORM_SET));            while (ClassGuidNum-- > 0) {              if (CompareGuid (SetupClassGuid, ClassGuid)) {                //                // Check whether need to skip the formset.                //                if (SkipCount != 0) {                  SkipCount--;                  FoundAndSkip = TRUE;                  break;                }                CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));                CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));                CopyGuid (FormSetGuid, (CONST EFI_GUID *)(&((EFI_IFR_FORM_SET *) OpCodeData)->Guid));                FreePool (HiiPackageList);                return TRUE;              }              ClassGuid ++;            }            if (FoundAndSkip) {              break;            }           } else if (CompareGuid (SetupClassGuid, &gEfiHiiPlatformSetupFormsetGuid)) {             //             //  Check whether need to skip the formset.             //             if (SkipCount != 0) {               SkipCount--;               break;             }             CopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));             CopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));             CopyGuid (FormSetGuid, (CONST EFI_GUID *)(&((EFI_IFR_FORM_SET *) OpCodeData)->Guid));             FreePool (HiiPackageList);             return TRUE;          }        }      }    }  }  FreePool (HiiPackageList);  return FALSE;}
开发者ID:ozbenh,项目名称:edk2,代码行数:101,


示例14: DebugPortStop

/**  Stop this driver on ControllerHandle by removing Serial IO protocol on  the ControllerHandle.  @param  This              Protocol instance pointer.  @param  ControllerHandle  Handle of device to stop driver on  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of                            children is zero stop the entire bus driver.  @param  ChildHandleBuffer List of Child Handles to Stop.  @retval EFI_SUCCESS       This driver is removed ControllerHandle.  @retval other             This driver was not removed from this device.**/EFI_STATUSEFIAPIDebugPortStop (  IN  EFI_DRIVER_BINDING_PROTOCOL    *This,  IN  EFI_HANDLE                     ControllerHandle,  IN  UINTN                          NumberOfChildren,  IN  EFI_HANDLE                     *ChildHandleBuffer  ){  EFI_STATUS  Status;  if (NumberOfChildren == 0) {    //    // Close the bus driver    //    gBS->CloseProtocol (          ControllerHandle,          &gEfiSerialIoProtocolGuid,          This->DriverBindingHandle,          ControllerHandle          );    mDebugPortDevice.SerialIoBinding = NULL;    gBS->CloseProtocol (          ControllerHandle,          &gEfiDevicePathProtocolGuid,          This->DriverBindingHandle,          ControllerHandle          );    FreePool (mDebugPortDevice.DebugPortDevicePath);    return EFI_SUCCESS;  } else {    //    // Disconnect SerialIo child handle    //    Status = gBS->CloseProtocol (                    mDebugPortDevice.SerialIoDeviceHandle,                    &gEfiSerialIoProtocolGuid,                    This->DriverBindingHandle,                    mDebugPortDevice.DebugPortDeviceHandle                    );    if (EFI_ERROR (Status)) {      return Status;    }    //    // Unpublish our protocols (DevicePath, DebugPort)    //    Status = gBS->UninstallMultipleProtocolInterfaces (                    mDebugPortDevice.DebugPortDeviceHandle,                    &gEfiDevicePathProtocolGuid,                    mDebugPortDevice.DebugPortDevicePath,                    &gEfiDebugPortProtocolGuid,                    &mDebugPortDevice.DebugPortInterface,                    NULL                    );    if (EFI_ERROR (Status)) {      gBS->OpenProtocol (            ControllerHandle,            &gEfiSerialIoProtocolGuid,            (VOID **) &mDebugPortDevice.SerialIoBinding,            This->DriverBindingHandle,            mDebugPortDevice.DebugPortDeviceHandle,            EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER            );    } else {      mDebugPortDevice.DebugPortDeviceHandle = NULL;    }  }  return Status;}
开发者ID:lersek,项目名称:edk2,代码行数:90,


示例15: InitializeLanguage

//.........这里部分代码省略.........    }    //    // Allocate extra 1 as the end tag.    //    gFrontPagePrivate.LanguageToken = AllocateZeroPool ((OptionCount + 1) * sizeof (EFI_STRING_ID));    ASSERT (gFrontPagePrivate.LanguageToken != NULL);    Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString);    ASSERT_EFI_ERROR (Status);    LangCode     = mLanguageString;    OptionCount  = 0;    while (*LangCode != 0) {      GetNextLanguage (&LangCode, Lang);      StringSize = 0;      Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);      if (Status == EFI_BUFFER_TOO_SMALL) {        StringBuffer = AllocateZeroPool (StringSize);        ASSERT (StringBuffer != NULL);        Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);        ASSERT_EFI_ERROR (Status);      }      if (EFI_ERROR (Status)) {        StringBuffer = AllocatePool (AsciiStrSize (Lang) * sizeof (CHAR16));        ASSERT (StringBuffer != NULL);        AsciiStrToUnicodeStr (Lang, StringBuffer);      }      ASSERT (StringBuffer != NULL);      gFrontPagePrivate.LanguageToken[OptionCount] = HiiSetString (HiiHandle, 0, StringBuffer, NULL);      FreePool (StringBuffer);      OptionCount++;    }  }  ASSERT (gFrontPagePrivate.LanguageToken != NULL);  LangCode     = mLanguageString;  OptionCount  = 0;  if (Lang == NULL) {    Lang = AllocatePool (AsciiStrSize (mLanguageString));    ASSERT (Lang != NULL);  }  while (*LangCode != 0) {    GetNextLanguage (&LangCode, Lang);    if (CurrentLang != NULL && AsciiStrCmp (Lang, CurrentLang) == 0) {      HiiCreateOneOfOptionOpCode (        OptionsOpCodeHandle,        gFrontPagePrivate.LanguageToken[OptionCount],        EFI_IFR_OPTION_DEFAULT,        EFI_IFR_NUMERIC_SIZE_1,        (UINT8) OptionCount        );    } else {      HiiCreateOneOfOptionOpCode (        OptionsOpCodeHandle,        gFrontPagePrivate.LanguageToken[OptionCount],        0,        EFI_IFR_NUMERIC_SIZE_1,        (UINT8) OptionCount        );    }
开发者ID:ozbenh,项目名称:edk2,代码行数:67,


示例16: MoveWithinFileSystems

/**  Function to do a move within a file system.  @param[in] Node               A pointer to the file to be removed.  @param[in] DestPath           A pointer to the destination file path.  @param[out] Resp              A pointer to response from question.  Pass back on looped calling.  @retval SHELL_SUCCESS           The source file was moved to the destination.  @retval SHELL_OUT_OF_RESOURCES  A memory allocation failed.**/EFI_STATUSEFIAPIMoveWithinFileSystems(  IN EFI_SHELL_FILE_INFO  *Node,  IN CHAR16               *DestPath,  OUT VOID                **Resp  ){  EFI_FILE_INFO             *NewFileInfo;  CHAR16                    *TempLocation;  UINTN                     NewSize;  UINTN                     Length;  EFI_STATUS                Status;  //  // Chop off map info from DestPath  //  if ((TempLocation = StrStr(DestPath, L":")) != NULL) {    CopyMem(DestPath, TempLocation+1, StrSize(TempLocation+1));  }  //  // construct the new file info block  //  NewSize = StrSize(DestPath);  NewSize += StrSize(Node->FileName) + SIZE_OF_EFI_FILE_INFO + sizeof(CHAR16);  NewFileInfo = AllocateZeroPool(NewSize);  if (NewFileInfo == NULL) {    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);    Status = EFI_OUT_OF_RESOURCES;  } else {    CopyMem(NewFileInfo, Node->Info, SIZE_OF_EFI_FILE_INFO);    if (DestPath[0] != L'//') {      StrCpy(NewFileInfo->FileName, L"//");      StrCat(NewFileInfo->FileName, DestPath);    } else {      StrCpy(NewFileInfo->FileName, DestPath);    }    Length = StrLen(NewFileInfo->FileName);    if (Length > 0) {      Length--;    }    if (NewFileInfo->FileName[Length] == L'//') {      if (Node->FileName[0] == L'//') {        //        // Don't allow for double slashes. Eliminate one of them.        //        NewFileInfo->FileName[Length] = CHAR_NULL;      }      StrCat(NewFileInfo->FileName, Node->FileName);    }    NewFileInfo->Size = SIZE_OF_EFI_FILE_INFO + StrSize(NewFileInfo->FileName);    //    // Perform the move operation    //    Status = ShellSetFileInfo(Node->Handle, NewFileInfo);    //    // Free the info object we used...    //    FreePool(NewFileInfo);  }  return (Status);}
开发者ID:Teino1978-Corp,项目名称:edk2,代码行数:76,


示例17: FrontPageCallback

/**  This function processes the results of changes in configuration.  @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.  @param Action          Specifies the type of action taken by the browser.  @param QuestionId      A unique value which is sent to the original exporting driver                         so that it can identify the type of data to expect.  @param Type            The type of value for the question.  @param Value           A pointer to the data being sent to the original exporting driver.  @param ActionRequest   On return, points to the action requested by the callback function.  @retval  EFI_SUCCESS           The callback successfully handled the action.  @retval  EFI_OUT_OF_RESOURCES  Not enough storage is available to hold the variable and its data.  @retval  EFI_DEVICE_ERROR      The variable could not be saved.  @retval  EFI_UNSUPPORTED       The specified Action is not supported by the callback.**/EFI_STATUSEFIAPIFrontPageCallback (  IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,  IN  EFI_BROWSER_ACTION                     Action,  IN  EFI_QUESTION_ID                        QuestionId,  IN  UINT8                                  Type,  IN  EFI_IFR_TYPE_VALUE                     *Value,  OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest  ){  CHAR8                         *LangCode;  CHAR8                         *Lang;  UINTN                         Index;  EFI_STATUS                    Status;  //  //Chech whether exit from BMM and reenter frontpage,if yes,reclaim string depositories  //  if (Action == EFI_BROWSER_ACTION_FORM_OPEN){    if (mEnterBmm){      ReclaimStringDepository();      mEnterBmm = FALSE;    }  }  if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {    //    // Do nothing for other UEFI Action. Only do call back when data is changed.    //    return EFI_UNSUPPORTED;  }  if (Action == EFI_BROWSER_ACTION_CHANGED) {    if ((Value == NULL) || (ActionRequest == NULL)) {      return EFI_INVALID_PARAMETER;    }    switch (QuestionId) {    case FRONT_PAGE_KEY_CONTINUE:      //      // This is the continue - clear the screen and return an error to get out of FrontPage loop      //      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;      break;    case FRONT_PAGE_KEY_LANGUAGE:      //      // Allocate working buffer for RFC 4646 language in supported LanguageString.      //      Lang = AllocatePool (AsciiStrSize (mLanguageString));      ASSERT (Lang != NULL);        Index = 0;      LangCode = mLanguageString;      while (*LangCode != 0) {        GetNextLanguage (&LangCode, Lang);        if (Index == Value->u8) {          break;        }        Index++;      }      if (Index == Value->u8) {        Status = gRT->SetVariable (                        L"PlatformLang",                        &gEfiGlobalVariableGuid,                        EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,                        AsciiStrSize (Lang),                        Lang                        );        ASSERT_EFI_ERROR(Status);      } else {        ASSERT (FALSE);      }      FreePool (Lang);      //      //Current language of platform is changed,recreate oneof options for language.      //      InitializeLanguage();//.........这里部分代码省略.........
开发者ID:ozbenh,项目名称:edk2,代码行数:101,


示例18: Image

/**  Function for 'mv' command.  @param[in] ImageHandle  Handle to the Image (NULL if Internal).  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).**/SHELL_STATUSEFIAPIShellCommandRunMv (  IN EFI_HANDLE        ImageHandle,  IN EFI_SYSTEM_TABLE  *SystemTable  ){  EFI_STATUS          Status;  LIST_ENTRY          *Package;  CHAR16              *ProblemParam;  SHELL_STATUS        ShellStatus;  UINTN               ParamCount;  UINTN               LoopCounter;  EFI_SHELL_FILE_INFO *FileList;  VOID                *Response;  ProblemParam        = NULL;  ShellStatus         = SHELL_SUCCESS;  ParamCount          = 0;  FileList            = NULL;  Response            = NULL;  //  // initialize the shell lib (we must be in non-auto-init...)  //  Status = ShellInitialize();  ASSERT_EFI_ERROR(Status);  //  // parse the command line  //  Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);  if (EFI_ERROR(Status)) {    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mv", ProblemParam);        FreePool(ProblemParam);      ShellStatus = SHELL_INVALID_PARAMETER;    } else {      ASSERT(FALSE);    }  } else {    //    // check for "-?"    //    if (ShellCommandLineGetFlag(Package, L"-?")) {      ASSERT(FALSE);    }    switch (ParamCount = ShellCommandLineGetCount(Package)) {      case 0:      case 1:        //        // we have insufficient parameters        //        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mv");          ShellStatus = SHELL_INVALID_PARAMETER;        break;      case 2:        //        // must have valid CWD for single parameter...        //        if (ShellGetCurrentDir(NULL) == NULL){          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"mv");            ShellStatus = SHELL_INVALID_PARAMETER;        } else {          Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);          if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1));              ShellStatus = SHELL_NOT_FOUND;          } else  {            //            // ValidateAndMoveFiles will report errors to the screen itself            //            ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellGetCurrentDir(NULL));          }        }        break;      default:        ///@todo make sure this works with error half way through and continues...        for (ParamCount--, LoopCounter = 1 ; LoopCounter < ParamCount ; LoopCounter++) {          if (ShellGetExecutionBreakFlag()) {            break;          }          Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);          if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, LoopCounter));              ShellStatus = SHELL_NOT_FOUND;          } else  {            //            // ValidateAndMoveFiles will report errors to the screen itself            // Only change ShellStatus if it's sucessful            //            if (ShellStatus == SHELL_SUCCESS) {//.........这里部分代码省略.........
开发者ID:Teino1978-Corp,项目名称:edk2,代码行数:101,


示例19: UpdateFrontPageStrings

/**  Update the banner information for the Front Page based on Smbios information.**/VOIDUpdateFrontPageStrings (  VOID  ){  UINT8                             StrIndex;  CHAR16                            *NewString;  CHAR16                            *FirmwareVersionString;  BOOLEAN                           Find[5];  EFI_STATUS                        Status;  EFI_STRING_ID                     TokenToUpdate;  EFI_SMBIOS_HANDLE                 SmbiosHandle;  EFI_SMBIOS_PROTOCOL               *Smbios;  SMBIOS_TABLE_TYPE0                *Type0Record;  SMBIOS_TABLE_TYPE1                *Type1Record;  SMBIOS_TABLE_TYPE4                *Type4Record;  SMBIOS_TABLE_TYPE19               *Type19Record;  EFI_SMBIOS_TABLE_HEADER           *Record;  ZeroMem (Find, sizeof (Find));  //  // Update Front Page strings  //  Status = gBS->LocateProtocol (                  &gEfiSmbiosProtocolGuid,                  NULL,                  (VOID **) &Smbios                  );  if (EFI_ERROR (Status)) {    return ;  }  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;  do {    Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);    if (EFI_ERROR(Status)) {      break;    }    if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {      Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;      StrIndex = Type0Record->BiosVersion;      GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);      TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);      FirmwareVersionString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);      if (*FirmwareVersionString != 0x0000 ) {        FreePool (NewString);        NewString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);      } else {        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);        FreePool (NewString);      }      Find[0] = TRUE;    }      if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {      Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;      StrIndex = Type1Record->ProductName;      GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);      TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);      HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);      FreePool (NewString);      Find[1] = TRUE;    }    if ((Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) && !Find[2]) {      Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;      //      // The information in the record should be only valid when the CPU Socket is populated.       //      if ((Type4Record->Status & SMBIOS_TYPE4_CPU_SOCKET_POPULATED) == SMBIOS_TYPE4_CPU_SOCKET_POPULATED) {        StrIndex = Type4Record->ProcessorVersion;        GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);        FreePool (NewString);        Find[2] = TRUE;      }    }        if ((Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) && !Find[3]) {      Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;      //      // The information in the record should be only valid when the CPU Socket is populated.       //      if ((Type4Record->Status & SMBIOS_TYPE4_CPU_SOCKET_POPULATED) == SMBIOS_TYPE4_CPU_SOCKET_POPULATED) {        ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);        TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);        HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);        FreePool (NewString);        Find[3] = TRUE;      }    }     if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {//.........这里部分代码省略.........
开发者ID:ozbenh,项目名称:edk2,代码行数:101,


示例20: UpdateFrontPageBannerStrings

/**  Update the banner information for the Front Page based on Smbios information.**/VOIDUpdateFrontPageBannerStrings (  VOID  ){  UINT8                             StrIndex;  CHAR16                            *NewString;  CHAR16                            *FirmwareVersionString;  EFI_STATUS                        Status;  EFI_SMBIOS_HANDLE                 SmbiosHandle;  EFI_SMBIOS_PROTOCOL               *Smbios;  SMBIOS_TABLE_TYPE0                *Type0Record;  SMBIOS_TABLE_TYPE1                *Type1Record;  SMBIOS_TABLE_TYPE4                *Type4Record;  SMBIOS_TABLE_TYPE19               *Type19Record;  EFI_SMBIOS_TABLE_HEADER           *Record;  UINT64                            InstalledMemory;  BOOLEAN                           FoundCpu;  InstalledMemory = 0;  FoundCpu = 0;  //  // Update default banner string.  //  NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NULL);  UiCustomizeFrontPageBanner (4, TRUE, &NewString);  HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NewString, NULL);  FreePool (NewString);  NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NULL);  UiCustomizeFrontPageBanner (4, FALSE, &NewString);  HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NewString, NULL);  FreePool (NewString);  NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NULL);  UiCustomizeFrontPageBanner (5, TRUE, &NewString);  HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NewString, NULL);  FreePool (NewString);  NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NULL);  UiCustomizeFrontPageBanner (5, FALSE, &NewString);  HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NewString, NULL);  FreePool (NewString);  //  // Update Front Page banner strings base on SmBios Table.  //  Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **) &Smbios);  if (EFI_ERROR (Status)) {    //    // Smbios protocol not found, get the default value.    //    NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NULL);    UiCustomizeFrontPageBanner (1, TRUE, &NewString);    HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);    FreePool (NewString);    NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NULL);    UiCustomizeFrontPageBanner (2, TRUE, &NewString);    HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL);    FreePool (NewString);    NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NULL);    UiCustomizeFrontPageBanner (2, FALSE, &NewString);    HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);    FreePool (NewString);    NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NULL);    UiCustomizeFrontPageBanner (3, TRUE, &NewString);    HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);    FreePool (NewString);    NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NULL);    UiCustomizeFrontPageBanner (3, FALSE, &NewString);    HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);    FreePool (NewString);    return;  }  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;  Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);  while (!EFI_ERROR(Status)) {    if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {      Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;      StrIndex = Type0Record->BiosVersion;      GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);      FirmwareVersionString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);      if (*FirmwareVersionString != 0x0000 ) {        FreePool (NewString);        NewString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);        UiCustomizeFrontPageBanner (3, TRUE, &NewString);        HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);//.........这里部分代码省略.........
开发者ID:jonpablo,项目名称:edk2,代码行数:101,


示例21: UpdateConModePage

//.........这里部分代码省略.........  UINTN                         MaxMode;  UINTN                         ValidMode;  EFI_STRING_ID                 *ModeToken;  EFI_STATUS                    Status;  VOID                          *OptionsOpCodeHandle;  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *ConOut;  ConOut    = gST->ConOut;  Index     = 0;  ValidMode = 0;  MaxMode   = (UINTN) (ConOut->Mode->MaxMode);  CallbackData->BmmAskSaveOrNot = TRUE;  UpdatePageStart (CallbackData);  //  // Check valid mode  //  for (Mode = 0; Mode < MaxMode; Mode++) {    Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);    if (EFI_ERROR (Status)) {      continue;    }    ValidMode++;  }  if (ValidMode == 0) {    return;  }  OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();  ASSERT (OptionsOpCodeHandle != NULL);  ModeToken           = AllocateZeroPool (sizeof (EFI_STRING_ID) * ValidMode);  ASSERT(ModeToken != NULL);  //  // Determin which mode should be the first entry in menu  //  // GetConsoleOutMode (CallbackData);  //  // Build text mode options  //  for (Mode = 0; Mode < MaxMode; Mode++) {    Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);    if (EFI_ERROR (Status)) {      continue;    }        //    // Build mode string Column x Row    //    UnicodeValueToString (ModeString, 0, Col, 0);    PStr = &ModeString[0];    StrCatS (PStr, sizeof (ModeString) / sizeof (ModeString[0]), L" x ");    PStr = PStr + StrLen (PStr);    UnicodeValueToString (PStr , 0, Row, 0);    ModeToken[Index] = HiiSetString (CallbackData->BmmHiiHandle, 0, ModeString, NULL);    if (Mode == CallbackData->BmmFakeNvData.ConsoleOutMode) {      HiiCreateOneOfOptionOpCode (        OptionsOpCodeHandle,        ModeToken[Index],        EFI_IFR_OPTION_DEFAULT,        EFI_IFR_TYPE_NUM_SIZE_16,        (UINT16) Mode        );    } else {      HiiCreateOneOfOptionOpCode (        OptionsOpCodeHandle,        ModeToken[Index],        0,        EFI_IFR_TYPE_NUM_SIZE_16,        (UINT16) Mode        );    }    Index++;  }  HiiCreateOneOfOpCode (    mStartOpCodeHandle,    (EFI_QUESTION_ID) CON_MODE_QUESTION_ID,    VARSTORE_ID_BOOT_MAINT,    CON_MODE_VAR_OFFSET,    STRING_TOKEN (STR_CON_MODE_SETUP),    STRING_TOKEN (STR_CON_MODE_SETUP),    EFI_IFR_FLAG_RESET_REQUIRED,    EFI_IFR_NUMERIC_SIZE_2,    OptionsOpCodeHandle,    NULL    );  HiiFreeOpCodeHandle (OptionsOpCodeHandle);  FreePool (ModeToken);  UpdatePageEnd (CallbackData);}
开发者ID:wensunshine,项目名称:VisualUefi,代码行数:101,


示例22: ASSERT

//.........这里部分代码省略.........  //  // Disable cursor and set the foreground and background colors specified by Attribute  //  ConOut->EnableCursor (ConOut, FALSE);  ConOut->SetAttribute (ConOut, Attribute);  //  // Limit NumberOfLines to height of the screen minus 3 rows for the box itself  //  NumberOfLines = MIN (NumberOfLines, Rows - 3);  //  // Limit MaxLength to width of the screen minus 2 columns for the box itself  //  MaxLength = MIN (MaxLength, Columns - 2);  //  // Compute the starting row and starting column for the popup  //  Row    = (Rows - (NumberOfLines + 3)) / 2;  Column = (Columns - (MaxLength + 2)) / 2;  //  // Allocate a buffer for a single line of the popup with borders and a Null-terminator  //  Line = AllocateZeroPool ((MaxLength + 3) * sizeof (CHAR16));  ASSERT (Line != NULL);  //  // Draw top of popup box     //  SetMem16 (Line, (MaxLength + 2) * 2, BOXDRAW_HORIZONTAL);  Line[0]             = BOXDRAW_DOWN_RIGHT;  Line[MaxLength + 1] = BOXDRAW_DOWN_LEFT;  Line[MaxLength + 2] = L'/0';  ConOut->SetCursorPosition (ConOut, Column, Row++);  ConOut->OutputString (ConOut, Line);  //  // Draw middle of the popup with strings  //  VA_START (Args, Key);  while ((String = VA_ARG (Args, CHAR16 *)) != NULL && NumberOfLines > 0) {    SetMem16 (Line, (MaxLength + 2) * 2, L' ');    Line[0]             = BOXDRAW_VERTICAL;    Line[MaxLength + 1] = BOXDRAW_VERTICAL;    Line[MaxLength + 2] = L'/0';    ConOut->SetCursorPosition (ConOut, Column, Row);    ConOut->OutputString (ConOut, Line);    Length = UefiLibGetStringWidth (String, FALSE, 0, NULL) / 2;    if (Length <= MaxLength) {      //      // Length <= MaxLength      //      ConOut->SetCursorPosition (ConOut, Column + 1 + (MaxLength - Length) / 2, Row++);      ConOut->OutputString (ConOut, String);    } else {      //      // Length > MaxLength      //      UefiLibGetStringWidth (String, TRUE, MaxLength, &Length);      String[Length] = L'/0';      ConOut->SetCursorPosition (ConOut, Column + 1, Row++);      ConOut->OutputString (ConOut, String);    }    NumberOfLines--;  }  VA_END (Args);  //  // Draw bottom of popup box  //  SetMem16 (Line, (MaxLength + 2) * 2, BOXDRAW_HORIZONTAL);  Line[0]             = BOXDRAW_UP_RIGHT;  Line[MaxLength + 1] = BOXDRAW_UP_LEFT;  Line[MaxLength + 2] = L'/0';  ConOut->SetCursorPosition (ConOut, Column, Row++);  ConOut->OutputString (ConOut, Line);  //  // Free the allocated line buffer  //  FreePool (Line);  //  // Restore the cursor visibility, position, and attributes  //  ConOut->EnableCursor      (ConOut, SavedConsoleMode.CursorVisible);  ConOut->SetCursorPosition (ConOut, SavedConsoleMode.CursorColumn, SavedConsoleMode.CursorRow);  ConOut->SetAttribute      (ConOut, SavedConsoleMode.Attribute);  //  // Wait for a keystroke  //  if (Key != NULL) {    gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);    gST->ConIn->ReadKeyStroke (gST->ConIn, Key);  }}
开发者ID:matsufan,项目名称:edk2,代码行数:101,


示例23: LocateSerialIo

/**  Build a list containing all serial devices.  @retval EFI_SUCCESS The function complete successfully.  @retval EFI_UNSUPPORTED No serial ports present.**/EFI_STATUSLocateSerialIo (  VOID  ){  UINTN                     Index;  UINTN                     Index2;  UINTN                     NoHandles;  EFI_HANDLE                *Handles;  EFI_STATUS                Status;  ACPI_HID_DEVICE_PATH      *Acpi;  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;  EFI_SERIAL_IO_PROTOCOL    *SerialIo;  EFI_DEVICE_PATH_PROTOCOL  *Node;  EFI_DEVICE_PATH_PROTOCOL  *OutDevicePath;  EFI_DEVICE_PATH_PROTOCOL  *InpDevicePath;  EFI_DEVICE_PATH_PROTOCOL  *ErrDevicePath;  BM_MENU_ENTRY             *NewMenuEntry;  BM_TERMINAL_CONTEXT       *NewTerminalContext;  EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;  VENDOR_DEVICE_PATH        Vendor;  UINT32                    FlowControl;  //  // Get all handles that have SerialIo protocol installed  //  InitializeListHead (&TerminalMenu.Head);  TerminalMenu.MenuNumber = 0;  Status = gBS->LocateHandleBuffer (                  ByProtocol,                  &gEfiSerialIoProtocolGuid,                  NULL,                  &NoHandles,                  &Handles                  );  if (EFI_ERROR (Status)) {    //    // No serial ports present    //    return EFI_UNSUPPORTED;  }  //  // Sort Uart handles array with Acpi->UID from low to high  // then Terminal menu can be built from low Acpi->UID to high Acpi->UID  //  SortedUartHandle (Handles, NoHandles);  for (Index = 0; Index < NoHandles; Index++) {    //    // Check to see whether the handle has DevicePath Protocol installed    //    gBS->HandleProtocol (          Handles[Index],          &gEfiDevicePathProtocolGuid,          (VOID **) &DevicePath          );    Acpi = NULL;    for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {      if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {        break;      }      //      // Acpi points to the node before Uart node      //      Acpi = (ACPI_HID_DEVICE_PATH *) Node;    }    if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {      NewMenuEntry = BOpt_CreateMenuEntry (BM_TERMINAL_CONTEXT_SELECT);      if (NewMenuEntry == NULL) {        FreePool (Handles);        return EFI_OUT_OF_RESOURCES;      }      NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;      CopyMem (&NewMenuEntry->OptionNumber, &Acpi->UID, sizeof (UINT32));      NewTerminalContext->DevicePath = DuplicateDevicePath (DevicePath);      //      // BugBug: I have no choice, calling EfiLibStrFromDatahub will hang the system!      // coz' the misc data for each platform is not correct, actually it's the device path stored in      // datahub which is not completed, so a searching for end of device path will enter a      // dead-loop.      //      NewMenuEntry->DisplayString = EfiLibStrFromDatahub (DevicePath);      if (NULL == NewMenuEntry->DisplayString) {        NewMenuEntry->DisplayString = DevicePathToStr (DevicePath);      }      NewMenuEntry->HelpString = NULL;      gBS->HandleProtocol (//.........这里部分代码省略.........
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:101,


示例24: IfName

//.........这里部分代码省略.........                       &DataSize,                       NULL                       );    if (Status != EFI_BUFFER_TOO_SMALL) {      goto ON_ERROR;    }    IfInfo = AllocateZeroPool (DataSize);    if (IfInfo == NULL) {      Status = EFI_OUT_OF_RESOURCES;      goto ON_ERROR;    }        //    // Get the interface info.    //    Status = Ip4Cfg2->GetData (                       Ip4Cfg2,                       Ip4Config2DataTypeInterfaceInfo,                       &DataSize,                       IfInfo                       );    if (EFI_ERROR (Status)) {      goto ON_ERROR;    }        //    // Check the interface name if required.    //    if ((IfName != NULL) && (StrCmp (IfName, IfInfo->Name) != 0)) {      FreePool (IfInfo);      continue;    }    DataSize = 0;        //    // Get the size of dns server list.    //    Status = Ip4Cfg2->GetData (                       Ip4Cfg2,                       Ip4Config2DataTypeDnsServer,                       &DataSize,                       NULL                       );    if ((Status != EFI_BUFFER_TOO_SMALL) && (Status != EFI_NOT_FOUND)) {      goto ON_ERROR;    }    IfCb = AllocateZeroPool (sizeof (IFCONFIG_INTERFACE_CB) + DataSize);    if (IfCb == NULL) {      Status = EFI_OUT_OF_RESOURCES;      goto ON_ERROR;    }    IfCb->NicHandle = HandleBuffer[HandleIndex];    IfCb->IfInfo    = IfInfo;    IfCb->IfCfg     = Ip4Cfg2;    IfCb->DnsCnt    = (UINT32) (DataSize / sizeof (EFI_IPv4_ADDRESS));    //
开发者ID:MHesham,项目名称:edk2-1,代码行数:67,


示例25: FindApplicationMatchingUiSection

EFI_STATUSFindApplicationMatchingUiSection (  IN  CHAR16      *UiString,  OUT EFI_HANDLE  *FvHandle,  OUT EFI_GUID    *NameGuid  ){  EFI_STATUS                    Status;  EFI_STATUS                    NextStatus;  UINTN                         NoHandles;  EFI_HANDLE                    *Buffer;  UINTN                         Index;  EFI_FV_FILETYPE               FileType;  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;  VOID                          *Key;  EFI_FV_FILE_ATTRIBUTES        Attributes;  UINTN                         Size;  UINTN                         UiStringLen;  CHAR16                        *UiSection;  UINT32                        Authentication;      UiStringLen = 0;  if (UiString != NULL) {    DEBUG ((DEBUG_ERROR, "UiString %s/n", UiString));    UiStringLen = StrLen (UiString);  }    Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, NULL, &NoHandles, &Buffer);  if (!EFI_ERROR (Status)) {    for (Index = 0; Index < NoHandles; Index++) {      Status = gBS->HandleProtocol (Buffer[Index], &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&Fv);      if (!EFI_ERROR (Status)) {        Key = AllocatePool (Fv->KeySize);        ASSERT (Key != NULL);        ZeroMem (Key, Fv->KeySize);                FileType = EFI_FV_FILETYPE_APPLICATION;                do {          NextStatus = Fv->GetNextFile (Fv, Key, &FileType, NameGuid, &Attributes, &Size);          if (!EFI_ERROR (NextStatus)) {            if (UiString == NULL) {              //              // If UiString is NULL match first application we find.              //              *FvHandle = Buffer[Index];              FreePool (Key);              return Status;            }                        UiSection = NULL;            Status = Fv->ReadSection (                          Fv,                           NameGuid,                           EFI_SECTION_USER_INTERFACE,                           0,                          (VOID **)&UiSection,                          &Size,                          &Authentication                          );            if (!EFI_ERROR (Status)) {              if (StrnCmp (UiString, UiSection, UiStringLen) == 0) {                //                // We found a UiString match.                 //                *FvHandle = Buffer[Index];                FreePool (Key);                FreePool (UiSection);                return Status;              }              FreePool (UiSection);            }          }        } while (!EFI_ERROR (NextStatus));                FreePool (Key);      }    }        FreePool (Buffer);   }  return EFI_NOT_FOUND;}
开发者ID:altera-opensource,项目名称:uefi-socfpga,代码行数:85,


示例26: Image

/**  Function for 'hexedit' command.  @param[in] ImageHandle  Handle to the Image (NULL if Internal).  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).**/SHELL_STATUSEFIAPIShellCommandRunHexEdit (  IN EFI_HANDLE        ImageHandle,  IN EFI_SYSTEM_TABLE  *SystemTable  ){  EFI_STATUS              Status;  CHAR16                  *Buffer;  CHAR16                  *ProblemParam;  SHELL_STATUS            ShellStatus;  LIST_ENTRY              *Package;  CHAR16                  *NewName;  CONST CHAR16            *Name;  UINTN                   Offset;  UINTN                   Size;  EDIT_FILE_TYPE          WhatToDo;  Buffer      = NULL;  ShellStatus = SHELL_SUCCESS;  NewName         = NULL;  Buffer      = NULL;  Name        = NULL;  Offset      = 0;  Size        = 0;  WhatToDo    = FileTypeNone;  //  // initialize the shell lib (we must be in non-auto-init...)  //  Status = ShellInitialize();  ASSERT_EFI_ERROR(Status);  Status = CommandInit();  ASSERT_EFI_ERROR(Status);  //  // parse the command line  //  Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);  if (EFI_ERROR(Status)) {    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"hexedit", ProblemParam);      FreePool(ProblemParam);      ShellStatus = SHELL_INVALID_PARAMETER;    } else {      ASSERT(FALSE);    }  } else {    //    // Check for -d    //    if (ShellCommandLineGetFlag(Package, L"-d")){      if (ShellCommandLineGetCount(Package) < 4) {        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");        ShellStatus = SHELL_INVALID_PARAMETER;      } else if (ShellCommandLineGetCount(Package) > 4) {        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");        ShellStatus = SHELL_INVALID_PARAMETER;      } else {        WhatToDo = FileTypeDiskBuffer;        Name    = ShellCommandLineGetRawValue(Package, 1);        Offset  = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2));        Size    = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 3));      }      if (Offset == (UINTN)-1 || Size == (UINTN)-1) {        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"hexedit", L"-d");        ShellStatus = SHELL_INVALID_PARAMETER;      }    }    //    // check for -f    //    if (ShellCommandLineGetFlag(Package, L"-f") && (WhatToDo == FileTypeNone)){      if (ShellCommandLineGetCount(Package) < 2) {        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"hexedit");        ShellStatus = SHELL_INVALID_PARAMETER;      } else if (ShellCommandLineGetCount(Package) > 2) {        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle, L"hexedit");        ShellStatus = SHELL_INVALID_PARAMETER;      } else {        Name      = ShellCommandLineGetRawValue(Package, 1);        if (Name == NULL || !IsValidFileName(Name)) {          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"hexedit", Name);          ShellStatus = SHELL_INVALID_PARAMETER;        } else {          WhatToDo  = FileTypeFileBuffer;        }      }    }    //    // check for -m//.........这里部分代码省略.........
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:101,



注:本文中的FreePool函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ FreeRCString函数代码示例
C++ FreeNode函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。