MdeModulePkg: Refine the code in BootMaintenanceManagerUiLib

Refine the code in function Var_UpdateDriverOption and Var_UpdateBootOption,
use the existed API(EfiBootManagerInitializeLoadOption and
EfiBootManagerAddLoadOptionVariable) supplied by UefiBootManagerLib
to replace the same logic in the two functions. And remove the useless
code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Dandan Bi 2016-01-26 16:07:18 +08:00 committed by Star Zeng
parent 3a2718d74e
commit 2ba36b2f0e
3 changed files with 71 additions and 187 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
Header file for boot maintenance module. Header file for boot maintenance module.
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -268,24 +268,15 @@ typedef struct {
typedef struct { typedef struct {
BOOLEAN IsBootNext; BOOLEAN IsBootNext;
BOOLEAN LoadOptionModified;
BOOLEAN Deleted; BOOLEAN Deleted;
BOOLEAN IsLegacy; BOOLEAN IsLegacy;
BOOLEAN IsActive;
BOOLEAN ForceReconnect;
UINTN OptionalDataSize;
UINTN LoadOptionSize;
UINT8 *LoadOption;
UINT32 Attributes; UINT32 Attributes;
UINT16 FilePathListLength; UINT16 FilePathListLength;
UINT16 *Description; UINT16 *Description;
EFI_DEVICE_PATH_PROTOCOL *FilePathList; EFI_DEVICE_PATH_PROTOCOL *FilePathList;
UINT8 *OptionalData; UINT8 *OptionalData;
UINT16 BbsIndex;
} BM_LOAD_CONTEXT; } BM_LOAD_CONTEXT;
typedef struct { typedef struct {

View File

@ -5,7 +5,7 @@
Boot option manipulation Boot option manipulation
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -116,7 +116,6 @@ BOpt_DestroyMenuEntry (
case BM_LOAD_CONTEXT_SELECT: case BM_LOAD_CONTEXT_SELECT:
LoadContext = (BM_LOAD_CONTEXT *) MenuEntry->VariableContext; LoadContext = (BM_LOAD_CONTEXT *) MenuEntry->VariableContext;
FreePool (LoadContext->FilePathList); FreePool (LoadContext->FilePathList);
FreePool (LoadContext->LoadOption);
if (LoadContext->OptionalData != NULL) { if (LoadContext->OptionalData != NULL) {
FreePool (LoadContext->OptionalData); FreePool (LoadContext->OptionalData);
} }
@ -336,7 +335,6 @@ BOpt_GetBootOptions (
LoadOptionEnd = LoadOption + BootOptionSize; LoadOptionEnd = LoadOption + BootOptionSize;
NewMenuEntry->OptionNumber = BootOrderList[Index]; NewMenuEntry->OptionNumber = BootOrderList[Index];
NewLoadContext->LoadOptionModified = FALSE;
NewLoadContext->Deleted = FALSE; NewLoadContext->Deleted = FALSE;
NewLoadContext->IsBootNext = BootNextFlag; NewLoadContext->IsBootNext = BootNextFlag;
@ -374,13 +372,8 @@ BOpt_GetBootOptions (
// for easy use with following LOAD_OPTION // for easy use with following LOAD_OPTION
// embedded in this struct // embedded in this struct
// //
NewLoadContext->LoadOption = LoadOption;
NewLoadContext->LoadOptionSize = BootOptionSize;
NewLoadContext->Attributes = *(UINT32 *) LoadOptionPtr; NewLoadContext->Attributes = *(UINT32 *) LoadOptionPtr;
NewLoadContext->IsActive = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_ACTIVE);
NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);
LoadOptionPtr += sizeof (UINT32); LoadOptionPtr += sizeof (UINT32);
@ -426,8 +419,6 @@ BOpt_GetBootOptions (
LoadOptionPtr, LoadOptionPtr,
OptionalDataSize OptionalDataSize
); );
NewLoadContext->OptionalDataSize = OptionalDataSize;
} }
InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link); InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);
@ -441,6 +432,8 @@ BOpt_GetBootOptions (
if (BootOrderList != NULL) { if (BootOrderList != NULL) {
FreePool (BootOrderList); FreePool (BootOrderList);
} }
FreePool(LoadOption);
BootOptionMenu.MenuNumber = MenuCount; BootOptionMenu.MenuNumber = MenuCount;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -708,7 +701,6 @@ BOpt_GetDriverOptions (
LoadOptionPtr = LoadOption; LoadOptionPtr = LoadOption;
LoadOptionEnd = LoadOption + DriverOptionSize; LoadOptionEnd = LoadOption + DriverOptionSize;
NewMenuEntry->OptionNumber = DriverOrderList[Index]; NewMenuEntry->OptionNumber = DriverOrderList[Index];
NewLoadContext->LoadOptionModified = FALSE;
NewLoadContext->Deleted = FALSE; NewLoadContext->Deleted = FALSE;
NewLoadContext->IsLegacy = FALSE; NewLoadContext->IsLegacy = FALSE;
@ -717,13 +709,8 @@ BOpt_GetDriverOptions (
// for easy use with following LOAD_OPTION // for easy use with following LOAD_OPTION
// embedded in this struct // embedded in this struct
// //
NewLoadContext->LoadOption = LoadOption;
NewLoadContext->LoadOptionSize = DriverOptionSize;
NewLoadContext->Attributes = *(UINT32 *) LoadOptionPtr; NewLoadContext->Attributes = *(UINT32 *) LoadOptionPtr;
NewLoadContext->IsActive = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_ACTIVE);
NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);
LoadOptionPtr += sizeof (UINT32); LoadOptionPtr += sizeof (UINT32);
@ -771,7 +758,6 @@ BOpt_GetDriverOptions (
OptionalDataSize OptionalDataSize
); );
NewLoadContext->OptionalDataSize = OptionalDataSize;
} }
InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link); InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);
@ -781,6 +767,7 @@ BOpt_GetDriverOptions (
if (DriverOrderList != NULL) { if (DriverOrderList != NULL) {
FreePool (DriverOrderList); FreePool (DriverOrderList);
} }
FreePool(LoadOption);
DriverOptionMenu.MenuNumber = Index; DriverOptionMenu.MenuNumber = Index;
return EFI_SUCCESS; return EFI_SUCCESS;

View File

@ -1,7 +1,7 @@
/** @file /** @file
Variable operation that will be used by bootmaint Variable operation that will be used by bootmaint
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -535,19 +535,18 @@ Var_UpdateDriverOption (
) )
{ {
UINT16 Index; UINT16 Index;
UINT16 *DriverOrderList;
UINT16 *NewDriverOrderList;
UINT16 DriverString[12]; UINT16 DriverString[12];
UINTN DriverOrderListSize;
VOID *Buffer;
UINTN BufferSize;
UINT8 *Ptr;
BM_MENU_ENTRY *NewMenuEntry; BM_MENU_ENTRY *NewMenuEntry;
BM_LOAD_CONTEXT *NewLoadContext; BM_LOAD_CONTEXT *NewLoadContext;
BOOLEAN OptionalDataExist; BOOLEAN OptionalDataExist;
EFI_STATUS Status; EFI_STATUS Status;
EFI_BOOT_MANAGER_LOAD_OPTION LoadOption;
UINT8 *OptionalDesData;
UINT32 OptionalDataSize;
OptionalDataExist = FALSE; OptionalDataExist = FALSE;
OptionalDesData = NULL;
OptionalDataSize = 0;
Index = BOpt_GetDriverOptionNumber (); Index = BOpt_GetDriverOptionNumber ();
UnicodeSPrint ( UnicodeSPrint (
@ -561,68 +560,50 @@ Var_UpdateDriverOption (
StrCpyS (DescriptionData, MAX_MENU_NUMBER, DriverString); StrCpyS (DescriptionData, MAX_MENU_NUMBER, DriverString);
} }
BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescriptionData);
BufferSize += GetDevicePathSize (CallbackData->LoadContext->FilePathList);
if (*OptionalData != 0x0000) { if (*OptionalData != 0x0000) {
OptionalDataExist = TRUE; OptionalDataExist = TRUE;
BufferSize += StrSize (OptionalData); OptionalDesData = (UINT8 *)OptionalData;
} OptionalDataSize = (UINT32)StrSize (OptionalData);
Buffer = AllocateZeroPool (BufferSize);
if (NULL == Buffer) {
return EFI_OUT_OF_RESOURCES;
} }
NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT); NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
if (NULL == NewMenuEntry) { if (NULL == NewMenuEntry) {
FreePool (Buffer);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Status = EfiBootManagerInitializeLoadOption (
&LoadOption,
Index,
LoadOptionTypeDriver,
LOAD_OPTION_ACTIVE | (ForceReconnect << 1),
DescriptionData,
CallbackData->LoadContext->FilePathList,
OptionalDesData,
OptionalDataSize
);
if (!EFI_ERROR (Status)){
Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );
}
NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext; NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
NewLoadContext->Deleted = FALSE; NewLoadContext->Deleted = FALSE;
NewLoadContext->LoadOptionSize = BufferSize; NewLoadContext->Attributes = LoadOption.Attributes;
Ptr = (UINT8 *) Buffer; NewLoadContext->FilePathListLength = (UINT16)GetDevicePathSize (LoadOption.FilePath);
NewLoadContext->LoadOption = Ptr;
*((UINT32 *) Ptr) = LOAD_OPTION_ACTIVE | (ForceReconnect << 1);
NewLoadContext->Attributes = *((UINT32 *) Ptr);
NewLoadContext->IsActive = TRUE;
NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);
Ptr += sizeof (UINT32);
*((UINT16 *) Ptr) = (UINT16) GetDevicePathSize (CallbackData->LoadContext->FilePathList);
NewLoadContext->FilePathListLength = *((UINT16 *) Ptr);
Ptr += sizeof (UINT16);
CopyMem (
Ptr,
DescriptionData,
StrSize (DescriptionData)
);
NewLoadContext->Description = AllocateZeroPool (StrSize (DescriptionData)); NewLoadContext->Description = AllocateZeroPool (StrSize (DescriptionData));
ASSERT (NewLoadContext->Description != NULL); ASSERT (NewLoadContext->Description != NULL);
NewMenuEntry->DisplayString = NewLoadContext->Description; NewMenuEntry->DisplayString = NewLoadContext->Description;
CopyMem ( CopyMem (
NewLoadContext->Description, NewLoadContext->Description,
(VOID *) Ptr, LoadOption.Description,
StrSize (DescriptionData) StrSize (DescriptionData)
); );
Ptr += StrSize (DescriptionData);
CopyMem (
Ptr,
CallbackData->LoadContext->FilePathList,
GetDevicePathSize (CallbackData->LoadContext->FilePathList)
);
NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList)); NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));
ASSERT (NewLoadContext->FilePathList != NULL); ASSERT (NewLoadContext->FilePathList != NULL);
CopyMem ( CopyMem (
NewLoadContext->FilePathList, NewLoadContext->FilePathList,
(VOID *) Ptr, LoadOption.FilePath,
GetDevicePathSize (CallbackData->LoadContext->FilePathList) GetDevicePathSize (CallbackData->LoadContext->FilePathList)
); );
@ -632,50 +613,19 @@ Var_UpdateDriverOption (
NewMenuEntry->HelpStringToken = HiiSetString (HiiHandle, 0, NewMenuEntry->HelpString, NULL); NewMenuEntry->HelpStringToken = HiiSetString (HiiHandle, 0, NewMenuEntry->HelpString, NULL);
if (OptionalDataExist) { if (OptionalDataExist) {
Ptr += (UINT8) GetDevicePathSize (CallbackData->LoadContext->FilePathList); NewLoadContext->OptionalData = AllocateZeroPool (LoadOption.OptionalDataSize);
CopyMem ( CopyMem (
Ptr, NewLoadContext->OptionalData,
OptionalData, LoadOption.OptionalData,
StrSize (OptionalData) LoadOption.OptionalDataSize
); );
} }
Status = gRT->SetVariable (
DriverString,
&gEfiGlobalVariableGuid,
VAR_FLAG,
BufferSize,
Buffer
);
ASSERT_EFI_ERROR (Status);
GetEfiGlobalVariable2 (L"DriverOrder", (VOID **) &DriverOrderList, &DriverOrderListSize);
NewDriverOrderList = AllocateZeroPool (DriverOrderListSize + sizeof (UINT16));
ASSERT (NewDriverOrderList != NULL);
if (DriverOrderList != NULL){
CopyMem (NewDriverOrderList, DriverOrderList, DriverOrderListSize);
}
NewDriverOrderList[DriverOrderListSize / sizeof (UINT16)] = Index;
if (DriverOrderList != NULL) {
EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);
}
Status = gRT->SetVariable (
L"DriverOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
DriverOrderListSize + sizeof (UINT16),
NewDriverOrderList
);
ASSERT_EFI_ERROR (Status);
if (DriverOrderList != NULL) {
FreePool (DriverOrderList);
}
DriverOrderList = NULL;
FreePool (NewDriverOrderList);
InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link); InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);
DriverOptionMenu.MenuNumber++; DriverOptionMenu.MenuNumber++;
EfiBootManagerFreeLoadOption(&LoadOption);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -696,22 +646,21 @@ Var_UpdateBootOption (
IN BMM_CALLBACK_DATA *CallbackData IN BMM_CALLBACK_DATA *CallbackData
) )
{ {
UINT16 *BootOrderList;
UINT16 *NewBootOrderList;
UINTN BootOrderListSize;
UINT16 BootString[10]; UINT16 BootString[10];
VOID *Buffer;
UINTN BufferSize;
UINT8 *Ptr;
UINT16 Index; UINT16 Index;
BM_MENU_ENTRY *NewMenuEntry; BM_MENU_ENTRY *NewMenuEntry;
BM_LOAD_CONTEXT *NewLoadContext; BM_LOAD_CONTEXT *NewLoadContext;
BOOLEAN OptionalDataExist; BOOLEAN OptionalDataExist;
EFI_STATUS Status; EFI_STATUS Status;
BMM_FAKE_NV_DATA *NvRamMap; BMM_FAKE_NV_DATA *NvRamMap;
EFI_BOOT_MANAGER_LOAD_OPTION LoadOption;
UINT8 *OptionalData;
UINT32 OptionalDataSize;
OptionalDataExist = FALSE; OptionalDataExist = FALSE;
NvRamMap = &CallbackData->BmmFakeNvData; NvRamMap = &CallbackData->BmmFakeNvData;
OptionalData = NULL;
OptionalDataSize = 0;
Index = BOpt_GetBootOptionNumber () ; Index = BOpt_GetBootOptionNumber () ;
UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", Index); UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", Index);
@ -720,17 +669,10 @@ Var_UpdateBootOption (
StrCpyS (NvRamMap->BootDescriptionData, sizeof (NvRamMap->BootDescriptionData) / sizeof (NvRamMap->BootDescriptionData[0]), BootString); StrCpyS (NvRamMap->BootDescriptionData, sizeof (NvRamMap->BootDescriptionData) / sizeof (NvRamMap->BootDescriptionData[0]), BootString);
} }
BufferSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (NvRamMap->BootDescriptionData);
BufferSize += GetDevicePathSize (CallbackData->LoadContext->FilePathList);
if (NvRamMap->BootOptionalData[0] != 0x0000) { if (NvRamMap->BootOptionalData[0] != 0x0000) {
OptionalDataExist = TRUE; OptionalDataExist = TRUE;
BufferSize += StrSize (NvRamMap->BootOptionalData); OptionalData = (UINT8 *)NvRamMap->BootOptionalData;
} OptionalDataSize = (UINT32)StrSize (NvRamMap->BootOptionalData);
Buffer = AllocateZeroPool (BufferSize);
if (NULL == Buffer) {
return EFI_OUT_OF_RESOURCES;
} }
NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT); NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
@ -738,50 +680,41 @@ Var_UpdateBootOption (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Status = EfiBootManagerInitializeLoadOption (
&LoadOption,
Index,
LoadOptionTypeBoot,
LOAD_OPTION_ACTIVE,
NvRamMap->BootDescriptionData,
CallbackData->LoadContext->FilePathList,
OptionalData,
OptionalDataSize
);
if (!EFI_ERROR (Status)){
Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );
}
NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext; NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
NewLoadContext->Deleted = FALSE; NewLoadContext->Deleted = FALSE;
NewLoadContext->LoadOptionSize = BufferSize; NewLoadContext->Attributes = LoadOption.Attributes;
Ptr = (UINT8 *) Buffer; NewLoadContext->FilePathListLength = (UINT16) GetDevicePathSize (LoadOption.FilePath);
NewLoadContext->LoadOption = Ptr;
*((UINT32 *) Ptr) = LOAD_OPTION_ACTIVE;
NewLoadContext->Attributes = *((UINT32 *) Ptr);
NewLoadContext->IsActive = TRUE;
NewLoadContext->ForceReconnect = (BOOLEAN) (NewLoadContext->Attributes & LOAD_OPTION_FORCE_RECONNECT);
Ptr += sizeof (UINT32);
*((UINT16 *) Ptr) = (UINT16) GetDevicePathSize (CallbackData->LoadContext->FilePathList);
NewLoadContext->FilePathListLength = *((UINT16 *) Ptr);
Ptr += sizeof (UINT16);
CopyMem (
Ptr,
NvRamMap->BootDescriptionData,
StrSize (NvRamMap->BootDescriptionData)
);
NewLoadContext->Description = AllocateZeroPool (StrSize (NvRamMap->BootDescriptionData)); NewLoadContext->Description = AllocateZeroPool (StrSize (NvRamMap->BootDescriptionData));
ASSERT (NewLoadContext->Description != NULL); ASSERT (NewLoadContext->Description != NULL);
NewMenuEntry->DisplayString = NewLoadContext->Description; NewMenuEntry->DisplayString = NewLoadContext->Description;
CopyMem ( CopyMem (
NewLoadContext->Description, NewLoadContext->Description,
(VOID *) Ptr, LoadOption.Description,
StrSize (NvRamMap->BootDescriptionData) StrSize (NvRamMap->BootDescriptionData)
); );
Ptr += StrSize (NvRamMap->BootDescriptionData);
CopyMem (
Ptr,
CallbackData->LoadContext->FilePathList,
GetDevicePathSize (CallbackData->LoadContext->FilePathList)
);
NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList)); NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));
ASSERT (NewLoadContext->FilePathList != NULL); ASSERT (NewLoadContext->FilePathList != NULL);
CopyMem ( CopyMem (
NewLoadContext->FilePathList, NewLoadContext->FilePathList,
(VOID *) Ptr, LoadOption.FilePath,
GetDevicePathSize (CallbackData->LoadContext->FilePathList) GetDevicePathSize (CallbackData->LoadContext->FilePathList)
); );
@ -791,46 +724,19 @@ Var_UpdateBootOption (
NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL); NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);
if (OptionalDataExist) { if (OptionalDataExist) {
Ptr += (UINT8) GetDevicePathSize (CallbackData->LoadContext->FilePathList); NewLoadContext->OptionalData = AllocateZeroPool (LoadOption.OptionalDataSize);
CopyMem (
CopyMem (Ptr, NvRamMap->BootOptionalData, StrSize (NvRamMap->BootOptionalData)); NewLoadContext->OptionalData,
LoadOption.OptionalData,
LoadOption.OptionalDataSize
);
} }
Status = gRT->SetVariable (
BootString,
&gEfiGlobalVariableGuid,
VAR_FLAG,
BufferSize,
Buffer
);
ASSERT_EFI_ERROR (Status);
GetEfiGlobalVariable2 (L"BootOrder", (VOID **) &BootOrderList, &BootOrderListSize);
NewBootOrderList = AllocateZeroPool (BootOrderListSize + sizeof (UINT16));
ASSERT (NewBootOrderList != NULL);
if (BootOrderList != NULL){
CopyMem (NewBootOrderList, BootOrderList, BootOrderListSize);
}
NewBootOrderList[BootOrderListSize / sizeof (UINT16)] = Index;
if (BootOrderList != NULL) {
FreePool (BootOrderList);
}
Status = gRT->SetVariable (
L"BootOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
BootOrderListSize + sizeof (UINT16),
NewBootOrderList
);
ASSERT_EFI_ERROR (Status);
FreePool (NewBootOrderList);
NewBootOrderList = NULL;
InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link); InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);
BootOptionMenu.MenuNumber++; BootOptionMenu.MenuNumber++;
EfiBootManagerFreeLoadOption(&LoadOption);
return EFI_SUCCESS; return EFI_SUCCESS;
} }