Revert "MdeModulePkg: Remove EmuVariableRuntimeDxe"
This reverts commit 4a7aa8d34a
.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
# EFI/PI Reference Module Package for All Architectures
|
# EFI/PI Reference Module Package for All Architectures
|
||||||
#
|
#
|
||||||
# (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
# (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
||||||
# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
#
|
#
|
||||||
@@ -444,6 +444,9 @@
|
|||||||
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
|
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
|
[Components.IA32, Components.X64, Components.Ebc]
|
||||||
|
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
|
||||||
|
|
||||||
[Components.IA32, Components.X64]
|
[Components.IA32, Components.X64]
|
||||||
MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
|
MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
|
||||||
MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.inf
|
MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.inf
|
||||||
|
1820
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
Normal file
1820
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariable.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,88 @@
|
|||||||
|
## @file
|
||||||
|
# Emulation Variable for EFI_RUNTIME_SERVICES.
|
||||||
|
#
|
||||||
|
# This module installs variable arch protocol and variable write arch protocol to provide
|
||||||
|
# four EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName and QueryVariableInfo.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006 - 2018, 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 = EmuVariableRuntimeDxe
|
||||||
|
MODULE_UNI_FILE = EmuVariableRuntimeDxe.uni
|
||||||
|
FILE_GUID = 02B01AD5-7E59-43e8-A6D8-238180613A5A
|
||||||
|
MODULE_TYPE = DXE_RUNTIME_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = VariableServiceInitialize
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
InitVariable.c
|
||||||
|
EmuVariable.c
|
||||||
|
Variable.h
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseLib
|
||||||
|
UefiLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiDriverEntryPoint
|
||||||
|
UefiRuntimeLib
|
||||||
|
DebugLib
|
||||||
|
MemoryAllocationLib
|
||||||
|
BaseMemoryLib
|
||||||
|
HobLib
|
||||||
|
PcdLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiVariableArchProtocolGuid ## PRODUCES
|
||||||
|
gEfiVariableWriteArchProtocolGuid ## PRODUCES
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gEfiEventVirtualAddressChangeGuid ## CONSUMES ## Event
|
||||||
|
## SOMETIMES_CONSUMES ## Variable:L"PlatformLang"
|
||||||
|
## SOMETIMES_PRODUCES ## Variable:L"PlatformLang"
|
||||||
|
## SOMETIMES_CONSUMES ## Variable:L"Lang"
|
||||||
|
## SOMETIMES_PRODUCES ## Variable:L"Lang"
|
||||||
|
gEfiGlobalVariableGuid
|
||||||
|
## PRODUCES ## GUID # Signature of Variable store header
|
||||||
|
## CONSUMES ## GUID # Signature of Variable store header
|
||||||
|
## SOMETIMES_CONSUMES ## HOB
|
||||||
|
## SOMETIMES_PRODUCES ## SystemTable
|
||||||
|
gEfiVariableGuid
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdHwErrStorageSize ## CONSUMES
|
||||||
|
|
||||||
|
[FeaturePcd]
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics ## CONSUMES # statistic the information of variable.
|
||||||
|
|
||||||
|
[Depex]
|
||||||
|
TRUE
|
||||||
|
|
||||||
|
[UserExtensions.TianoCore."ExtraFiles"]
|
||||||
|
EmuVariableRuntimeDxeExtra.uni
|
@@ -0,0 +1,22 @@
|
|||||||
|
// /** @file
|
||||||
|
// Emulation Variable for EFI_RUNTIME_SERVICES.
|
||||||
|
//
|
||||||
|
// This module installs variable arch protocol and variable write arch protocol to provide
|
||||||
|
// four EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName and QueryVariableInfo.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2006 - 2014, 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.
|
||||||
|
//
|
||||||
|
// **/
|
||||||
|
|
||||||
|
|
||||||
|
#string STR_MODULE_ABSTRACT #language en-US "Emulation Variable for EFI_RUNTIME_SERVICES"
|
||||||
|
|
||||||
|
#string STR_MODULE_DESCRIPTION #language en-US "This module installs variable arch protocol and variable write arch protocol to provide four EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName and QueryVariableInfo."
|
||||||
|
|
@@ -0,0 +1,19 @@
|
|||||||
|
// /** @file
|
||||||
|
// EmuVariableRuntimeDxe Localized Strings and Content
|
||||||
|
//
|
||||||
|
// Copyright (c) 2013 - 2018, 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.
|
||||||
|
//
|
||||||
|
// **/
|
||||||
|
|
||||||
|
#string STR_PROPERTIES_MODULE_NAME
|
||||||
|
#language en-US
|
||||||
|
"Emulation Variable DXE Driver"
|
||||||
|
|
||||||
|
|
259
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/InitVariable.c
Normal file
259
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/InitVariable.c
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
/** @file
|
||||||
|
|
||||||
|
Implment all four UEFI runtime variable services and
|
||||||
|
install variable architeture protocol.
|
||||||
|
|
||||||
|
Copyright (c) 2006 - 2018, 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 "Variable.h"
|
||||||
|
|
||||||
|
EFI_EVENT mVirtualAddressChangeEvent = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
This code finds variable in storage blocks (Volatile or Non-Volatile).
|
||||||
|
|
||||||
|
@param VariableName Name of Variable to be found.
|
||||||
|
@param VendorGuid Variable vendor GUID.
|
||||||
|
@param Attributes Attribute value of the variable found.
|
||||||
|
@param DataSize Size of Data found. If size is less than the
|
||||||
|
data, this value contains the required size.
|
||||||
|
@param Data The buffer to return the contents of the variable. May be NULL
|
||||||
|
with a zero DataSize in order to determine the size buffer needed.
|
||||||
|
|
||||||
|
@return EFI_INVALID_PARAMETER Invalid parameter
|
||||||
|
@return EFI_SUCCESS Find the specified variable
|
||||||
|
@return EFI_NOT_FOUND Not found
|
||||||
|
@return EFI_BUFFER_TO_SMALL DataSize is too small for the result
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeServiceGetVariable (
|
||||||
|
IN CHAR16 *VariableName,
|
||||||
|
IN EFI_GUID *VendorGuid,
|
||||||
|
OUT UINT32 *Attributes OPTIONAL,
|
||||||
|
IN OUT UINTN *DataSize,
|
||||||
|
OUT VOID *Data OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EmuGetVariable (
|
||||||
|
VariableName,
|
||||||
|
VendorGuid,
|
||||||
|
Attributes OPTIONAL,
|
||||||
|
DataSize,
|
||||||
|
Data,
|
||||||
|
&mVariableModuleGlobal->VariableGlobal[Physical]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
This code Finds the Next available variable.
|
||||||
|
|
||||||
|
@param VariableNameSize The size of the VariableName buffer. The size must be large enough to fit input
|
||||||
|
string supplied in VariableName buffer.
|
||||||
|
@param VariableName On input, supplies the last VariableName that was returned by GetNextVariableName().
|
||||||
|
On output, returns the Null-terminated Unicode string of the current variable.
|
||||||
|
@param VendorGuid On input, supplies the last VendorGuid that was returned by GetNextVariableName().
|
||||||
|
On output, returns the VendorGuid of the current variable.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The function completed successfully.
|
||||||
|
@retval EFI_NOT_FOUND The next variable was not found.
|
||||||
|
@retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.
|
||||||
|
VariableNameSize has been updated with the size needed to complete the request.
|
||||||
|
@retval EFI_INVALID_PARAMETER VariableNameSize or VariableName or VendorGuid is NULL.
|
||||||
|
@retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
|
||||||
|
GUID of an existing variable.
|
||||||
|
@retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of
|
||||||
|
the input VariableName buffer.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeServiceGetNextVariableName (
|
||||||
|
IN OUT UINTN *VariableNameSize,
|
||||||
|
IN OUT CHAR16 *VariableName,
|
||||||
|
IN OUT EFI_GUID *VendorGuid
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EmuGetNextVariableName (
|
||||||
|
VariableNameSize,
|
||||||
|
VariableName,
|
||||||
|
VendorGuid,
|
||||||
|
&mVariableModuleGlobal->VariableGlobal[Physical]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
This code sets variable in storage blocks (Volatile or Non-Volatile).
|
||||||
|
|
||||||
|
@param VariableName Name of Variable to be found
|
||||||
|
@param VendorGuid Variable vendor GUID
|
||||||
|
@param Attributes Attribute value of the variable found
|
||||||
|
@param DataSize Size of Data found. If size is less than the
|
||||||
|
data, this value contains the required size.
|
||||||
|
@param Data Data pointer
|
||||||
|
|
||||||
|
@return EFI_INVALID_PARAMETER Invalid parameter
|
||||||
|
@return EFI_SUCCESS Set successfully
|
||||||
|
@return EFI_OUT_OF_RESOURCES Resource not enough to set variable
|
||||||
|
@return EFI_NOT_FOUND Not found
|
||||||
|
@return EFI_WRITE_PROTECTED Variable is read-only
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeServiceSetVariable (
|
||||||
|
IN CHAR16 *VariableName,
|
||||||
|
IN EFI_GUID *VendorGuid,
|
||||||
|
IN UINT32 Attributes,
|
||||||
|
IN UINTN DataSize,
|
||||||
|
IN VOID *Data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EmuSetVariable (
|
||||||
|
VariableName,
|
||||||
|
VendorGuid,
|
||||||
|
Attributes,
|
||||||
|
DataSize,
|
||||||
|
Data,
|
||||||
|
&mVariableModuleGlobal->VariableGlobal[Physical],
|
||||||
|
&mVariableModuleGlobal->VolatileLastVariableOffset,
|
||||||
|
&mVariableModuleGlobal->NonVolatileLastVariableOffset
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
This code returns information about the EFI variables.
|
||||||
|
|
||||||
|
@param Attributes Attributes bitmask to specify the type of variables
|
||||||
|
on which to return information.
|
||||||
|
@param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
|
||||||
|
for the EFI variables associated with the attributes specified.
|
||||||
|
@param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
|
||||||
|
for EFI variables associated with the attributes specified.
|
||||||
|
@param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
|
||||||
|
associated with the attributes specified.
|
||||||
|
|
||||||
|
@return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
|
||||||
|
@return EFI_SUCCESS Query successfully.
|
||||||
|
@return EFI_UNSUPPORTED The attribute is not supported on this platform.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RuntimeServiceQueryVariableInfo (
|
||||||
|
IN UINT32 Attributes,
|
||||||
|
OUT UINT64 *MaximumVariableStorageSize,
|
||||||
|
OUT UINT64 *RemainingVariableStorageSize,
|
||||||
|
OUT UINT64 *MaximumVariableSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EmuQueryVariableInfo (
|
||||||
|
Attributes,
|
||||||
|
MaximumVariableStorageSize,
|
||||||
|
RemainingVariableStorageSize,
|
||||||
|
MaximumVariableSize,
|
||||||
|
&mVariableModuleGlobal->VariableGlobal[Physical]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
|
||||||
|
|
||||||
|
This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
|
||||||
|
It convers pointer to new virtual address.
|
||||||
|
|
||||||
|
@param Event Event whose notification function is being invoked.
|
||||||
|
@param Context Pointer to the notification function's context.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
VariableClassAddressChangeEvent (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->PlatformLangCodes);
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->LangCodes);
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->PlatformLang);
|
||||||
|
EfiConvertPointer (
|
||||||
|
0x0,
|
||||||
|
(VOID **) &mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase
|
||||||
|
);
|
||||||
|
EfiConvertPointer (
|
||||||
|
0x0,
|
||||||
|
(VOID **) &mVariableModuleGlobal->VariableGlobal[Physical].VolatileVariableBase
|
||||||
|
);
|
||||||
|
EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
EmuVariable Driver main entry point. The Variable driver places the 4 EFI
|
||||||
|
runtime services in the EFI System Table and installs arch protocols
|
||||||
|
for variable read and write services being available. It also registers
|
||||||
|
notification function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
|
||||||
|
|
||||||
|
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||||
|
@param[in] SystemTable A pointer to the EFI System Table.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Variable service successfully initialized.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
VariableServiceInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_HANDLE NewHandle;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
Status = VariableCommonInitialize (ImageHandle, SystemTable);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
SystemTable->RuntimeServices->GetVariable = RuntimeServiceGetVariable;
|
||||||
|
SystemTable->RuntimeServices->GetNextVariableName = RuntimeServiceGetNextVariableName;
|
||||||
|
SystemTable->RuntimeServices->SetVariable = RuntimeServiceSetVariable;
|
||||||
|
SystemTable->RuntimeServices->QueryVariableInfo = RuntimeServiceQueryVariableInfo;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Now install the Variable Runtime Architectural Protocol on a new handle
|
||||||
|
//
|
||||||
|
NewHandle = NULL;
|
||||||
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
|
&NewHandle,
|
||||||
|
&gEfiVariableArchProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
&gEfiVariableWriteArchProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
Status = gBS->CreateEventEx (
|
||||||
|
EVT_NOTIFY_SIGNAL,
|
||||||
|
TPL_NOTIFY,
|
||||||
|
VariableClassAddressChangeEvent,
|
||||||
|
NULL,
|
||||||
|
&gEfiEventVirtualAddressChangeGuid,
|
||||||
|
&mVirtualAddressChangeEvent
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
277
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/Variable.h
Normal file
277
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/Variable.h
Normal file
@@ -0,0 +1,277 @@
|
|||||||
|
/** @file
|
||||||
|
|
||||||
|
The internal header file includes the common header files, defines
|
||||||
|
internal structure and functions used by EmuVariable module.
|
||||||
|
|
||||||
|
Copyright (c) 2006 - 2018, 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 _VARIABLE_H_
|
||||||
|
#define _VARIABLE_H_
|
||||||
|
|
||||||
|
#include <Uefi.h>
|
||||||
|
|
||||||
|
#include <Protocol/VariableWrite.h>
|
||||||
|
#include <Protocol/Variable.h>
|
||||||
|
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiRuntimeLib.h>
|
||||||
|
#include <Library/UefiDriverEntryPoint.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/PcdLib.h>
|
||||||
|
#include <Library/HobLib.h>
|
||||||
|
#include <Guid/VariableFormat.h>
|
||||||
|
#include <Guid/GlobalVariable.h>
|
||||||
|
|
||||||
|
#include <Guid/EventGroup.h>
|
||||||
|
|
||||||
|
#define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The size of a 3 character ISO639 language code.
|
||||||
|
///
|
||||||
|
#define ISO_639_2_ENTRY_SIZE 3
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
Physical,
|
||||||
|
Virtual
|
||||||
|
} VARIABLE_POINTER_TYPE;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
VARIABLE_HEADER *CurrPtr;
|
||||||
|
VARIABLE_HEADER *EndPtr;
|
||||||
|
VARIABLE_HEADER *StartPtr;
|
||||||
|
BOOLEAN Volatile;
|
||||||
|
} VARIABLE_POINTER_TRACK;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
EFI_PHYSICAL_ADDRESS VolatileVariableBase;
|
||||||
|
EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;
|
||||||
|
EFI_LOCK VariableServicesLock;
|
||||||
|
} VARIABLE_GLOBAL;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
VARIABLE_GLOBAL VariableGlobal[2];
|
||||||
|
UINTN VolatileLastVariableOffset;
|
||||||
|
UINTN NonVolatileLastVariableOffset;
|
||||||
|
UINTN CommonVariableTotalSize;
|
||||||
|
UINTN HwErrVariableTotalSize;
|
||||||
|
CHAR8 *PlatformLangCodes;
|
||||||
|
CHAR8 *LangCodes;
|
||||||
|
CHAR8 *PlatformLang;
|
||||||
|
CHAR8 Lang[ISO_639_2_ENTRY_SIZE + 1];
|
||||||
|
} ESAL_VARIABLE_GLOBAL;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Don't use module globals after the SetVirtualAddress map is signaled
|
||||||
|
///
|
||||||
|
extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes variable store area for non-volatile and volatile variable.
|
||||||
|
|
||||||
|
This function allocates and initializes memory space for global context of ESAL
|
||||||
|
variable service and variable store area for non-volatile and volatile variable.
|
||||||
|
|
||||||
|
@param ImageHandle The Image handle of this driver.
|
||||||
|
@param SystemTable The pointer of EFI_SYSTEM_TABLE.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Function successfully executed.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
VariableCommonInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Entry point of EmuVariable service module.
|
||||||
|
|
||||||
|
This function is the entry point of EmuVariable service module.
|
||||||
|
It registers all interfaces of Variable Services, initializes
|
||||||
|
variable store for non-volatile and volatile variables, and registers
|
||||||
|
notification function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
|
||||||
|
|
||||||
|
@param ImageHandle The Image handle of this driver.
|
||||||
|
@param SystemTable The pointer of EFI_SYSTEM_TABLE.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Variable service successfully initialized.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
VariableServiceInitialize (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
|
||||||
|
|
||||||
|
This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
|
||||||
|
It convers pointer to new virtual address.
|
||||||
|
|
||||||
|
@param Event Event whose notification function is being invoked.
|
||||||
|
@param Context Pointer to the notification function's context.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
VariableClassAddressChangeEvent (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
This code finds variable in storage blocks (Volatile or Non-Volatile).
|
||||||
|
|
||||||
|
@param VariableName A Null-terminated Unicode string that is the name of
|
||||||
|
the vendor's variable.
|
||||||
|
@param VendorGuid A unique identifier for the vendor.
|
||||||
|
@param Attributes If not NULL, a pointer to the memory location to return the
|
||||||
|
attributes bitmask for the variable.
|
||||||
|
@param DataSize Size of Data found. If size is less than the
|
||||||
|
data, this value contains the required size.
|
||||||
|
@param Data On input, the size in bytes of the return Data buffer.
|
||||||
|
On output, the size of data returned in Data.
|
||||||
|
@param Global Pointer to VARIABLE_GLOBAL structure
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The function completed successfully.
|
||||||
|
@retval EFI_NOT_FOUND The variable was not found.
|
||||||
|
@retval EFI_BUFFER_TOO_SMALL DataSize is too small for the result. DataSize has
|
||||||
|
been updated with the size needed to complete the request.
|
||||||
|
@retval EFI_INVALID_PARAMETER VariableName or VendorGuid or DataSize is NULL.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
EmuGetVariable (
|
||||||
|
IN CHAR16 *VariableName,
|
||||||
|
IN EFI_GUID *VendorGuid,
|
||||||
|
OUT UINT32 *Attributes OPTIONAL,
|
||||||
|
IN OUT UINTN *DataSize,
|
||||||
|
OUT VOID *Data,
|
||||||
|
IN VARIABLE_GLOBAL *Global
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
This code finds the next available variable.
|
||||||
|
|
||||||
|
@param VariableNameSize The size of the VariableName buffer. The size must be large enough to fit input
|
||||||
|
string supplied in VariableName buffer.
|
||||||
|
@param VariableName On input, supplies the last VariableName that was returned by GetNextVariableName().
|
||||||
|
On output, returns the Null-terminated Unicode string of the current variable.
|
||||||
|
@param VendorGuid On input, supplies the last VendorGuid that was returned by GetNextVariableName().
|
||||||
|
On output, returns the VendorGuid of the current variable.
|
||||||
|
@param Global Pointer to VARIABLE_GLOBAL structure.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The function completed successfully.
|
||||||
|
@retval EFI_NOT_FOUND The next variable was not found.
|
||||||
|
@retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.
|
||||||
|
VariableNameSize has been updated with the size needed to complete the request.
|
||||||
|
@retval EFI_INVALID_PARAMETER VariableNameSize or VariableName or VendorGuid is NULL.
|
||||||
|
@retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
|
||||||
|
GUID of an existing variable.
|
||||||
|
@retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of
|
||||||
|
the input VariableName buffer.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
EmuGetNextVariableName (
|
||||||
|
IN OUT UINTN *VariableNameSize,
|
||||||
|
IN OUT CHAR16 *VariableName,
|
||||||
|
IN OUT EFI_GUID *VendorGuid,
|
||||||
|
IN VARIABLE_GLOBAL *Global
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
This code sets variable in storage blocks (Volatile or Non-Volatile).
|
||||||
|
|
||||||
|
@param VariableName A Null-terminated Unicode string that is the name of the vendor's
|
||||||
|
variable. Each VariableName is unique for each
|
||||||
|
VendorGuid. VariableName must contain 1 or more
|
||||||
|
Unicode characters. If VariableName is an empty Unicode
|
||||||
|
string, then EFI_INVALID_PARAMETER is returned.
|
||||||
|
@param VendorGuid A unique identifier for the vendor
|
||||||
|
@param Attributes Attributes bitmask to set for the variable
|
||||||
|
@param DataSize The size in bytes of the Data buffer. A size of zero causes the
|
||||||
|
variable to be deleted.
|
||||||
|
@param Data The contents for the variable
|
||||||
|
@param Global Pointer to VARIABLE_GLOBAL structure
|
||||||
|
@param VolatileOffset The offset of last volatile variable
|
||||||
|
@param NonVolatileOffset The offset of last non-volatile variable
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
|
||||||
|
defined by the Attributes.
|
||||||
|
@retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied, or the
|
||||||
|
DataSize exceeds the maximum allowed, or VariableName is an empty
|
||||||
|
Unicode string, or VendorGuid is NULL.
|
||||||
|
@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 due to a hardware failure.
|
||||||
|
@retval EFI_WRITE_PROTECTED The variable in question is read-only or cannot be deleted.
|
||||||
|
@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
EmuSetVariable (
|
||||||
|
IN CHAR16 *VariableName,
|
||||||
|
IN EFI_GUID *VendorGuid,
|
||||||
|
IN UINT32 Attributes,
|
||||||
|
IN UINTN DataSize,
|
||||||
|
IN VOID *Data,
|
||||||
|
IN VARIABLE_GLOBAL *Global,
|
||||||
|
IN UINTN *VolatileOffset,
|
||||||
|
IN UINTN *NonVolatileOffset
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
This code returns information about the EFI variables.
|
||||||
|
|
||||||
|
@param Attributes Attributes bitmask to specify the type of variables
|
||||||
|
on which to return information.
|
||||||
|
@param MaximumVariableStorageSize On output the maximum size of the storage space available for
|
||||||
|
the EFI variables associated with the attributes specified.
|
||||||
|
@param RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI
|
||||||
|
variables associated with the attributes specified.
|
||||||
|
@param MaximumVariableSize Returns the maximum size of an individual EFI variable
|
||||||
|
associated with the attributes specified.
|
||||||
|
@param Global Pointer to VARIABLE_GLOBAL structure.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Valid answer returned.
|
||||||
|
@retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied
|
||||||
|
@retval EFI_UNSUPPORTED The attribute is not supported on this platform, and the
|
||||||
|
MaximumVariableStorageSize, RemainingVariableStorageSize,
|
||||||
|
MaximumVariableSize are undefined.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
EmuQueryVariableInfo (
|
||||||
|
IN UINT32 Attributes,
|
||||||
|
OUT UINT64 *MaximumVariableStorageSize,
|
||||||
|
OUT UINT64 *RemainingVariableStorageSize,
|
||||||
|
OUT UINT64 *MaximumVariableSize,
|
||||||
|
IN VARIABLE_GLOBAL *Global
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user