Refine BdsDxe driver and GenericBdsLib library so that the GenericBdsLib doesn't depend on the BdsDxe implementation.

Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13418 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
niruiyu 2012-06-01 03:39:39 +00:00
parent 38fcd0270f
commit 16e5944abd
10 changed files with 1788 additions and 1869 deletions

File diff suppressed because it is too large Load Diff

View File

@ -701,21 +701,9 @@ BdsLibVariableToOption (
+ (UINT16) (CharToUint (VariableName[NumOff+2]) * 0x10)
+ (UINT16) (CharToUint (VariableName[NumOff+3]) * 0x1);
}
//
// Insert active entry to BdsDeviceList
//
if ((Option->Attribute & LOAD_OPTION_ACTIVE) == LOAD_OPTION_ACTIVE) {
InsertTailList (BdsCommonOptionList, &Option->Link);
FreePool (Variable);
return Option;
}
InsertTailList (BdsCommonOptionList, &Option->Link);
FreePool (Variable);
FreePool (Option->Description);
FreePool (Option->DevicePath);
FreePool (Option->LoadOptions);
FreePool (Option);
return NULL;
return Option;
}
/**

View File

@ -51,6 +51,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/BdsLibHii.h>
#include <Guid/HdBootVariable.h>
#include <Guid/LastEnumLang.h>
#include <Guid/LegacyDevOrder.h>
#include <Library/PrintLib.h>
#include <Library/DebugLib.h>

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/** @file
declares interface functions
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@ -50,14 +50,10 @@ BdsBuildLegacyDevNameString (
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]
@param BootOption Pointer to buffer containing Boot Option Numbers
@param BootOptionCount Count of the Boot Option Numbers
**/
VOID
GroupMultipleLegacyBootOption4SameType (
UINT16 *BootOption,
UINTN BootOptionCount
VOID
);
/**
@ -66,25 +62,21 @@ GroupMultipleLegacyBootOption4SameType (
The routine re-orders the Boot Option in BootOption array according to
the order specified by DevOrder.
@param BootOption Pointer to buffer containing the Boot Option Numbers
@param BootOptionCount Count of the Boot Option Numbers
@param DevOrder Pointer to buffer containing the BBS Index,
high 8-bit value 0xFF indicating a disabled boot option
@param DevOrderCount Count of the BBS Index
@param EnBootOption Pointer to buffer receiving the enabled Boot Option Numbers
@param EnBootOption Callee allocated buffer containing the enabled Boot Option Numbers
@param EnBootOptionCount Count of the enabled Boot Option Numbers
@param DisBootOption Pointer to buffer receiving the disabled Boot Option Numbers
@param DisBootOption Callee allocated buffer containing the disabled Boot Option Numbers
@param DisBootOptionCount Count of the disabled Boot Option Numbers
**/
VOID
OrderLegacyBootOption4SameType (
UINT16 *BootOption,
UINTN BootOptionCount,
UINT16 *DevOrder,
UINTN DevOrderCount,
UINT16 *EnBootOption,
UINT16 **EnBootOption,
UINTN *EnBootOptionCount,
UINT16 *DisBootOption,
UINT16 **DisBootOption,
UINTN *DisBootOptionCount
);
#endif

View File

@ -1,7 +1,7 @@
/** @file
Utility routines used by boot maintenance modules.
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@ -14,36 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "BootMaint.h"
/**
Find the first instance of this Protocol
in the system and return it's interface.
@param ProtocolGuid Provides the protocol to search for
@param Interface On return, a pointer to the first interface
that matches ProtocolGuid
@retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
@retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
**/
EFI_STATUS
EfiLibLocateProtocol (
IN EFI_GUID *ProtocolGuid,
OUT VOID **Interface
)
{
EFI_STATUS Status;
Status = gBS->LocateProtocol (
ProtocolGuid,
NULL,
(VOID **) Interface
);
return Status;
}
/**
Function opens and returns a file handle to the root directory of a volume.
@ -201,7 +171,13 @@ EfiLibDeleteVariable (
//
// Delete variable from Storage
//
Status = gRT->SetVariable (VarName, VarGuid, VAR_FLAG, 0, NULL);
Status = gRT->SetVariable (
VarName,
VarGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
0,
NULL
);
ASSERT (!EFI_ERROR (Status));
FreePool (VarBuf);
}

View File

@ -1,7 +1,7 @@
/** @file
The functions for Boot Maintainence Main menu.
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@ -1016,7 +1016,7 @@ InitializeBM (
UpdateTerminalPage (BmmCallbackInfo);
}
Status = EfiLibLocateProtocol (&gEfiLegacyBiosProtocolGuid, (VOID **) &LegacyBios);
Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);
if (!EFI_ERROR (Status)) {
RefreshUpdateData ();
mStartLabel->Number = FORM_BOOT_LEGACY_DEVICE_ID;
@ -1327,6 +1327,11 @@ BdsStartBootMaint (
//
BdsLibEnumerateAllBootOption (&BdsBootOptionList);
//
// Group the legacy boot options for the same device type
//
GroupMultipleLegacyBootOption4SameType ();
//
// Init the BMM
//
@ -1404,60 +1409,3 @@ FormSetDispatcher (
return Status;
}
/**
Deletete the Boot Option from EFI Variable. The Boot Order Arrray
is also updated.
@param OptionNumber The number of Boot option want to be deleted.
@param BootOrder The Boot Order array.
@param BootOrderSize The size of the Boot Order Array.
@retval EFI_SUCCESS The Boot Option Variable was found and removed
@retval EFI_UNSUPPORTED The Boot Option Variable store was inaccessible
@retval EFI_NOT_FOUND The Boot Option Variable was not found
**/
EFI_STATUS
EFIAPI
BdsDeleteBootOption (
IN UINTN OptionNumber,
IN OUT UINT16 *BootOrder,
IN OUT UINTN *BootOrderSize
)
{
UINT16 BootOption[100];
UINTN Index;
EFI_STATUS Status;
UINTN Index2Del;
Status = EFI_SUCCESS;
Index2Del = 0;
UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", OptionNumber);
Status = EfiLibDeleteVariable (BootOption, &gEfiGlobalVariableGuid);
//
// adjust boot order array
//
for (Index = 0; Index < *BootOrderSize / sizeof (UINT16); Index++) {
if (BootOrder[Index] == OptionNumber) {
Index2Del = Index;
break;
}
}
if (Index != *BootOrderSize / sizeof (UINT16)) {
for (Index = 0; Index < *BootOrderSize / sizeof (UINT16) - 1; Index++) {
if (Index >= Index2Del) {
BootOrder[Index] = BootOrder[Index + 1];
}
}
*BootOrderSize -= sizeof (UINT16);
}
return Status;
}

View File

@ -1,7 +1,7 @@
/** @file
Header file for boot maintenance module.
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@ -39,11 +39,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define STR_NET_HELP L"NET Drive #%02x"
#define STR_BEV_HELP L"BEV Drive #%02x"
//
// Variable created with this flag will be "Efi:...."
//
#define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
extern CHAR16 mFileExplorerStorageName[];
extern CHAR16 mBootMaintStorageName[];
//
@ -238,18 +233,6 @@ typedef struct {
UINT16 StringToken;
} COM_ATTR;
#pragma pack(1)
///
/// For each legacy boot option in BBS table, a corresponding Boot#### variables is created.
/// The structure saves the mapping relationship between #### and the index in the BBS table.
///
typedef struct {
UINT16 BootOptionNumber;
UINT16 BbsIndex;
UINT16 BbsType;
} BOOT_OPTION_BBS_MAPPING;
#pragma pack()
typedef struct {
UINT64 BaudRate;
UINT8 DataBits;
@ -1160,23 +1143,6 @@ EfiLibFileInfo (
IN EFI_FILE_HANDLE FHand
);
/**
Find the first instance of this Protocol in the system and return it's interface.
@param ProtocolGuid Provides the protocol to search for
@param Interface On return, a pointer to the first interface
that matches ProtocolGuid
@retval EFI_SUCCESS A protocol instance matching ProtocolGuid was found
@retval EFI_NOT_FOUND No protocol instances were found that match ProtocolGuid
**/
EFI_STATUS
EfiLibLocateProtocol (
IN EFI_GUID *ProtocolGuid,
OUT VOID **Interface
);
/**
Adjusts the size of a previously allocated buffer.

View File

@ -1,7 +1,7 @@
/** @file
Variable operation that will be used by bootmaint
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
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
@ -161,7 +161,7 @@ Var_ChangeBootOrder (
Status = gRT->SetVariable (
L"BootOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
BootOrderListSize * sizeof (UINT16),
BootOrderList
);
@ -299,7 +299,7 @@ Var_ChangeDriverOrder (
Status = gRT->SetVariable (
L"DriverOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
DriverOrderListSize * sizeof (UINT16),
DriverOrderList
);
@ -334,7 +334,7 @@ Var_UpdateAllConsoleOption (
Status = gRT->SetVariable (
L"ConOut",
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
GetDevicePathSize (OutDevicePath),
OutDevicePath
);
@ -346,7 +346,7 @@ Var_UpdateAllConsoleOption (
Status = gRT->SetVariable (
L"ConIn",
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
GetDevicePathSize (InpDevicePath),
InpDevicePath
);
@ -358,7 +358,7 @@ Var_UpdateAllConsoleOption (
Status = gRT->SetVariable (
L"ErrOut",
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
GetDevicePathSize (ErrDevicePath),
ErrDevicePath
);
@ -461,7 +461,7 @@ Var_UpdateConsoleOption (
Status = gRT->SetVariable (
ConsoleName,
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
GetDevicePathSize (ConDevicePath),
ConDevicePath
);
@ -663,7 +663,7 @@ Var_UpdateDriverOption (
Status = gRT->SetVariable (
DriverString,
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
BufferSize,
Buffer
);
@ -684,7 +684,7 @@ Var_UpdateDriverOption (
Status = gRT->SetVariable (
L"DriverOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
DriverOrderListSize + sizeof (UINT16),
NewDriverOrderList
);
@ -831,7 +831,7 @@ Var_UpdateBootOption (
Status = gRT->SetVariable (
BootString,
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
BufferSize,
Buffer
);
@ -855,7 +855,7 @@ Var_UpdateBootOption (
Status = gRT->SetVariable (
L"BootOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
BootOrderListSize + sizeof (UINT16),
NewBootOrderList
);
@ -920,7 +920,7 @@ Var_UpdateBootNext (
Status = gRT->SetVariable (
L"BootNext",
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
sizeof (UINT16),
&NewMenuEntry->OptionNumber
);
@ -980,20 +980,17 @@ Var_UpdateBootOrder (
}
}
GroupMultipleLegacyBootOption4SameType (
BootOrderList,
BootOrderListSize / sizeof (UINT16)
);
Status = gRT->SetVariable (
L"BootOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
BootOrderListSize,
BootOrderList
);
FreePool (BootOrderList);
GroupMultipleLegacyBootOption4SameType ();
BOpt_FreeMenu (&BootOptionMenu);
BOpt_GetBootOptions (CallbackData);
@ -1057,7 +1054,7 @@ Var_UpdateDriverOrder (
Status = gRT->SetVariable (
L"DriverOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
DriverOrderListSize,
NewDriverOrderList
);
@ -1108,7 +1105,6 @@ Var_UpdateBBSOption (
UINTN EnBootOptionCount;
UINT16 *DisBootOption;
UINTN DisBootOptionCount;
UINT16 *BootOrder;
DisMap = NULL;
NewOrder = NULL;
@ -1219,7 +1215,7 @@ Var_UpdateBBSOption (
Status = gRT->SetVariable (
VAR_LEGACY_DEV_ORDER,
&gEfiLegacyDevOrderVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
VarSize,
OriginalPtr
);
@ -1231,39 +1227,15 @@ Var_UpdateBBSOption (
// 1. Re-order the Option Number in BootOrder according to Legacy Dev Order
//
ASSERT (OptionMenu->MenuNumber == DevOrder->Length / sizeof (UINT16) - 1);
BootOrder = BdsLibGetVariableAndSize (
L"BootOrder",
&gEfiGlobalVariableGuid,
&VarSize
);
ASSERT (BootOrder != NULL);
DisBootOption = AllocatePool (VarSize);
ASSERT (DisBootOption != NULL);
EnBootOption = AllocatePool (VarSize);
ASSERT (EnBootOption != NULL);
OrderLegacyBootOption4SameType (
BootOrder,
VarSize / sizeof (UINT16),
DevOrder->Data,
DevOrder->Length / sizeof (UINT16) - 1,
EnBootOption,
&EnBootOption,
&EnBootOptionCount,
DisBootOption,
&DisBootOption,
&DisBootOptionCount
);
Status = gRT->SetVariable (
L"BootOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
VarSize,
BootOrder
);
ASSERT_EFI_ERROR (Status);
FreePool (BootOrder);
//
// 2. Deactivate the DisBootOption and activate the EnBootOption
@ -1282,7 +1254,7 @@ Var_UpdateBBSOption (
Status = gRT->SetVariable (
VarName,
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
OptionSize,
BootOptionVar
);
@ -1305,7 +1277,7 @@ Var_UpdateBBSOption (
Status = gRT->SetVariable (
VarName,
&gEfiGlobalVariableGuid,
VAR_FLAG,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
OptionSize,
BootOptionVar
);

View File

@ -232,6 +232,14 @@ CallBootManager (
BdsLibEnumerateAllBootOption (&mBootOptionsList);
//
// Group the legacy boot options for the same device type
//
GroupMultipleLegacyBootOption4SameType ();
InitializeListHead (&mBootOptionsList);
BdsLibBuildOptionFromVar (&mBootOptionsList, L"BootOrder");
HiiHandle = gBootManagerPrivate.HiiHandle;
//
@ -268,9 +276,9 @@ CallBootManager (
mKeyInput++;
//
// Don't display the boot option marked as LOAD_OPTION_HIDDEN
// Don't display the hidden/inactive boot option
//
if ((Option->Attribute & LOAD_OPTION_HIDDEN) != 0) {
if (((Option->Attribute & LOAD_OPTION_HIDDEN) != 0) || ((Option->Attribute & LOAD_OPTION_ACTIVE) == 0)) {
continue;
}