MdeModulePkg: Add PlatformVarCleanupLib library
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18295 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
61
MdeModulePkg/Include/Library/PlatformVarCleanupLib.h
Normal file
61
MdeModulePkg/Include/Library/PlatformVarCleanupLib.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/** @file
|
||||||
|
The library class provides platform variable cleanup services.
|
||||||
|
|
||||||
|
Copyright (c) 2015, 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
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _PLATFORM_VARIABLE_CLEANUP_LIB_
|
||||||
|
#define _PLATFORM_VARIABLE_CLEANUP_LIB_
|
||||||
|
|
||||||
|
#include <Guid/VarErrorFlag.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VarCleanupAll,
|
||||||
|
VarCleanupManually,
|
||||||
|
VarCleanupMax,
|
||||||
|
} VAR_CLEANUP_TYPE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get last boot variable error flag.
|
||||||
|
|
||||||
|
@return Last boot variable error flag.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VAR_ERROR_FLAG
|
||||||
|
EFIAPI
|
||||||
|
GetLastBootVarErrorFlag (
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Platform variable cleanup.
|
||||||
|
|
||||||
|
@param[in] Flag Variable error flag.
|
||||||
|
@param[in] Type Variable cleanup type.
|
||||||
|
If it is VarCleanupManually, the interface must be called after console connected.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS No error or error processed.
|
||||||
|
@retval EFI_UNSUPPORTED The specified Flag or Type is not supported.
|
||||||
|
For example, system error may be not supported to process and Platform should have mechanism to reset system to manufacture mode.
|
||||||
|
Another, if system and user variables are wanted to be distinguished to process, the interface must be called after EndOfDxe.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Not enough resource to process the error.
|
||||||
|
@retval EFI_INVALID_PARAMETER The specified Flag or Type is an invalid value.
|
||||||
|
@retval Others Other failure occurs.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
PlatformVarCleanup (
|
||||||
|
IN VAR_ERROR_FLAG Flag,
|
||||||
|
IN VAR_CLEANUP_TYPE Type
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
108
MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h
Normal file
108
MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/** @file
|
||||||
|
Include file for platform variable cleanup.
|
||||||
|
|
||||||
|
Copyright (c) 2015, 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
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _PLAT_VAR_CLEANUP_
|
||||||
|
#define _PLAT_VAR_CLEANUP_
|
||||||
|
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/PrintLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/HiiLib.h>
|
||||||
|
#include <Library/PlatformVarCleanupLib.h>
|
||||||
|
|
||||||
|
#include <Protocol/Variable.h>
|
||||||
|
#include <Protocol/VarCheck.h>
|
||||||
|
#include <Protocol/FormBrowser2.h>
|
||||||
|
#include <Protocol/HiiConfigAccess.h>
|
||||||
|
#include <Protocol/HiiConfigRouting.h>
|
||||||
|
#include <Protocol/DevicePath.h>
|
||||||
|
|
||||||
|
#include <Guid/EventGroup.h>
|
||||||
|
#include <Guid/MdeModuleHii.h>
|
||||||
|
#include <Guid/ImageAuthentication.h>
|
||||||
|
#include <Guid/VarErrorFlag.h>
|
||||||
|
|
||||||
|
#include "PlatVarCleanupHii.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// This is the generated IFR binary data for each formset defined in VFR.
|
||||||
|
// This data array is ready to be used as input of HiiAddPackages() to
|
||||||
|
// create a packagelist (which contains Form packages, String packages, etc).
|
||||||
|
//
|
||||||
|
extern UINT8 PlatVarCleanupBin[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// This is the generated String package data for all .UNI files.
|
||||||
|
// This data array is ready to be used as input of HiiAddPackages() to
|
||||||
|
// create a packagelist (which contains Form packages, String packages, etc).
|
||||||
|
//
|
||||||
|
extern UINT8 PlatformVarCleanupLibStrings[];
|
||||||
|
|
||||||
|
#define USER_VARIABLE_NODE_SIGNATURE SIGNATURE_32 ('U', 'V', 'N', 'S')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
EFI_GUID Guid;
|
||||||
|
CHAR16 *PromptString;
|
||||||
|
LIST_ENTRY NameLink;
|
||||||
|
} USER_VARIABLE_NODE;
|
||||||
|
|
||||||
|
#define USER_VARIABLE_FROM_LINK(a) CR (a, USER_VARIABLE_NODE, Link, USER_VARIABLE_NODE_SIGNATURE)
|
||||||
|
|
||||||
|
#define USER_VARIABLE_NAME_NODE_SIGNATURE SIGNATURE_32 ('U', 'V', 'N', 'N')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link;
|
||||||
|
CHAR16 *Name;
|
||||||
|
UINTN DataSize;
|
||||||
|
UINT32 Attributes;
|
||||||
|
UINT16 Index;
|
||||||
|
EFI_QUESTION_ID QuestionId;
|
||||||
|
CHAR16 *PromptString;
|
||||||
|
CHAR16 *HelpString;
|
||||||
|
BOOLEAN Deleted;
|
||||||
|
} USER_VARIABLE_NAME_NODE;
|
||||||
|
|
||||||
|
#define USER_VARIABLE_NAME_FROM_LINK(a) CR (a, USER_VARIABLE_NAME_NODE, Link, USER_VARIABLE_NAME_NODE_SIGNATURE)
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
//
|
||||||
|
// HII specific Vendor Device Path definition.
|
||||||
|
//
|
||||||
|
typedef struct {
|
||||||
|
VENDOR_DEVICE_PATH VendorDevicePath;
|
||||||
|
EFI_DEVICE_PATH_PROTOCOL End;
|
||||||
|
} HII_VENDOR_DEVICE_PATH;
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
#define VARIABLE_CLEANUP_HII_PRIVATE_SIGNATURE SIGNATURE_32 ('V', 'C', 'H', 'P')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
EFI_HANDLE DriverHandle;
|
||||||
|
EFI_HII_HANDLE HiiHandle;
|
||||||
|
EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
|
||||||
|
EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;
|
||||||
|
VARIABLE_CLEANUP_DATA VariableCleanupData;
|
||||||
|
} VARIABLE_CLEANUP_HII_PRIVATE_DATA;
|
||||||
|
|
||||||
|
#define VARIABLE_CLEANUP_HII_PRIVATE_FROM_THIS(a) CR (a, VARIABLE_CLEANUP_HII_PRIVATE_DATA, ConfigAccess, VARIABLE_CLEANUP_HII_PRIVATE_SIGNATURE)
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,41 @@
|
|||||||
|
/** @file
|
||||||
|
Platform variable cleanup Formset.
|
||||||
|
|
||||||
|
Copyright (c) 2015, 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
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "PlatVarCleanupHii.h"
|
||||||
|
|
||||||
|
formset
|
||||||
|
guid = VARIABLE_CLEANUP_HII_GUID,
|
||||||
|
title = STRING_TOKEN(STR_ENTRY_TITLE),
|
||||||
|
help = STRING_TOKEN(STR_TITLE_HELP),
|
||||||
|
|
||||||
|
varstore VARIABLE_CLEANUP_DATA,
|
||||||
|
varid = VARIABLE_CLEANUP_VARSTORE_ID,
|
||||||
|
name = VariableCleanup,
|
||||||
|
guid = VARIABLE_CLEANUP_HII_GUID;
|
||||||
|
|
||||||
|
form formid = FORM_ID_VARIABLE_CLEANUP,
|
||||||
|
title = STRING_TOKEN(STR_TITLE);
|
||||||
|
|
||||||
|
checkbox varid = VARIABLE_CLEANUP_DATA.SelectAll,
|
||||||
|
prompt = STRING_TOKEN(STR_SELECT_ALL_PROMPT),
|
||||||
|
help = STRING_TOKEN(STR_SELECT_ALL_HELP),
|
||||||
|
flags = INTERACTIVE,
|
||||||
|
key = SELECT_ALL_QUESTION_ID,
|
||||||
|
endcheckbox;
|
||||||
|
|
||||||
|
label LABEL_START;
|
||||||
|
label LABEL_END;
|
||||||
|
|
||||||
|
endform;
|
||||||
|
endformset;
|
@ -0,0 +1,59 @@
|
|||||||
|
/** @file
|
||||||
|
Include file for platform variable cleanup HII.
|
||||||
|
|
||||||
|
Copyright (c) 2015, 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
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _PLAT_VAR_CLEANUP_HII_
|
||||||
|
#define _PLAT_VAR_CLEANUP_HII_
|
||||||
|
|
||||||
|
//
|
||||||
|
// {24F14D8A-D7A8-4991-91E0-96C3B7DB8456}
|
||||||
|
//
|
||||||
|
#define VARIABLE_CLEANUP_HII_GUID \
|
||||||
|
{ \
|
||||||
|
0x24f14d8a, 0xd7a8, 0x4991, { 0x91, 0xe0, 0x96, 0xc3, 0xb7, 0xdb, 0x84, 0x56 } \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MAX_USER_VARIABLE_COUNT 0x1000
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT8 SelectAll;
|
||||||
|
//
|
||||||
|
// FALSE is to not delete, TRUE is to delete.
|
||||||
|
//
|
||||||
|
UINT8 UserVariable[MAX_USER_VARIABLE_COUNT];
|
||||||
|
} VARIABLE_CLEANUP_DATA;
|
||||||
|
|
||||||
|
#define VARIABLE_CLEANUP_VARSTORE_ID 0x8000
|
||||||
|
|
||||||
|
//
|
||||||
|
// Field offset of structure VARIABLE_CLEANUP_DATA
|
||||||
|
//
|
||||||
|
#define VAR_OFFSET(Field) ((UINTN) &(((VARIABLE_CLEANUP_DATA *) 0)->Field))
|
||||||
|
#define USER_VARIABLE_VAR_OFFSET (VAR_OFFSET (UserVariable))
|
||||||
|
|
||||||
|
#define FORM_ID_VARIABLE_CLEANUP 0x8000
|
||||||
|
|
||||||
|
#define LABEL_START 0x0000
|
||||||
|
#define LABEL_END 0xFFFF
|
||||||
|
|
||||||
|
#define SELECT_ALL_QUESTION_ID 0x7FFD
|
||||||
|
#define SAVE_AND_EXIT_QUESTION_ID 0x7FFE
|
||||||
|
#define NO_SAVE_AND_EXIT_QUESTION_ID 0x7FFF
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tool automatic generated Question Id start from 1.
|
||||||
|
// In order to avoid to conflict them, the user variable QuestionID offset is defined from 0x8000.
|
||||||
|
//
|
||||||
|
#define USER_VARIABLE_QUESTION_ID 0x8000
|
||||||
|
|
||||||
|
#endif
|
1250
MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
Normal file
1250
MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,73 @@
|
|||||||
|
## @file
|
||||||
|
# Sample platform variable cleanup library instance.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2015, 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
|
||||||
|
# http://opensource.org/licenses/bsd-license.php
|
||||||
|
#
|
||||||
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = PlatformVarCleanupLib
|
||||||
|
MODULE_UNI_FILE = PlatformVarCleanupLib.uni
|
||||||
|
FILE_GUID = 9C9623EB-4EF3-44e0-A931-F3A340D1A0F9
|
||||||
|
MODULE_TYPE = DXE_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
LIBRARY_CLASS = PlatformVarCleanupLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
|
||||||
|
CONSTRUCTOR = PlatformVarCleanupLibConstructor
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
PlatVarCleanupLib.c
|
||||||
|
PlatVarCleanup.h
|
||||||
|
PlatVarCleanupHii.h
|
||||||
|
PlatVarCleanup.vfr
|
||||||
|
VfrStrings.uni
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiRuntimeServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
BaseLib
|
||||||
|
DebugLib
|
||||||
|
BaseMemoryLib
|
||||||
|
PrintLib
|
||||||
|
MemoryAllocationLib
|
||||||
|
HiiLib
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gEfiIfrTianoGuid ## SOMETIMES_PRODUCES ## GUID
|
||||||
|
gEdkiiVarErrorFlagGuid ## CONSUMES ## Variable:L"VarErrorFlag"
|
||||||
|
gEfiEndOfDxeEventGroupGuid ## CONSUMES ## Event
|
||||||
|
gEfiCertPkcs7Guid ## SOMETIMES_CONSUMES ## GUID
|
||||||
|
gEfiCertTypeRsa2048Sha256Guid ## SOMETIMES_CONSUMES ## GUID
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiVariableArchProtocolGuid ## CONSUMES
|
||||||
|
gEdkiiVarCheckProtocolGuid ## CONSUMES
|
||||||
|
gEfiDevicePathProtocolGuid ## SOMETIMES_PRODUCES
|
||||||
|
gEfiFormBrowser2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiHiiConfigAccessProtocolGuid ## SOMETIMES_PRODUCES
|
||||||
|
gEfiHiiConfigRoutingProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
|
||||||
|
[Depex]
|
||||||
|
gEdkiiVarCheckProtocolGuid AND
|
||||||
|
gEfiVariableArchProtocolGuid
|
||||||
|
|
Binary file not shown.
BIN
MdeModulePkg/Library/PlatformVarCleanupLib/VfrStrings.uni
Normal file
BIN
MdeModulePkg/Library/PlatformVarCleanupLib/VfrStrings.uni
Normal file
Binary file not shown.
@ -127,6 +127,10 @@
|
|||||||
#
|
#
|
||||||
VarCheckLib|Include/Library/VarCheckLib.h
|
VarCheckLib|Include/Library/VarCheckLib.h
|
||||||
|
|
||||||
|
## @libraryclass Provides services to get variable error flag and do platform variable cleanup.
|
||||||
|
#
|
||||||
|
PlatformVarCleanupLib|Include/Library/PlatformVarCleanupLib.h
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
## MdeModule package token space guid
|
## MdeModule package token space guid
|
||||||
# Include/Guid/MdeModulePkgTokenSpace.h
|
# Include/Guid/MdeModulePkgTokenSpace.h
|
||||||
|
@ -282,6 +282,7 @@
|
|||||||
MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
|
MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
|
||||||
MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf
|
MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf
|
||||||
MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLib.inf
|
MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLib.inf
|
||||||
|
MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf
|
||||||
|
|
||||||
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
|
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
|
||||||
MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
|
MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
|
||||||
|
Reference in New Issue
Block a user