本文整理汇总了C++中FreePool函数的典型用法代码示例。如果您正苦于以下问题:C++ FreePool函数的具体用法?C++ FreePool怎么用?C++ FreePool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FreePool函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:FaultTolerantWrite.c
示例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.
**/
VOID
EFIAPI
CurrentLanguageMatch (
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,代码来源:MiscNumberOfInstallableLanguagesFunction.c
示例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
**/
BOOLEAN
EFIAPI
IsValidMove(
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,代码来源:Mv.c
示例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,代码来源:FrontPage.c
示例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]
**/
VOID
GroupMultipleLegacyBootOption4SameType (
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,代码来源:BootManager.c
示例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_STATUS
EFIAPI
ValidateAndMoveFiles(
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,代码来源:Mv.c
示例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_STATUS
BOpt_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,代码来源:BootOption.c
示例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,代码来源:BootOption.c
示例9: BOpt_DestroyMenuEntry
/**
Free up all resource allocated for a BM_MENU_ENTRY.
@param MenuEntry A pointer to BM_MENU_ENTRY.
**/
VOID
BOpt_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,代码来源:BootOption.c
示例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_STATUS
BOpt_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,代码来源:BootOption.c
示例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_STATUS
EFIAPI
ShellCommandRunMemMap (
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,代码来源:MemMap.c
示例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_STATUS
EFIAPI
DebugPortSupported (
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,代码来源:DebugPort.c
示例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,代码来源:FrontPage.c
示例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_STATUS
EFIAPI
DebugPortStop (
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,代码来源:DebugPort.c
示例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 (Asc
|
请发表评论