TianoCore EDK2 master
Loading...
Searching...
No Matches
VariableDxe.c File Reference
#include "Variable.h"
#include <Protocol/VariablePolicy.h>
#include <Library/VariablePolicyLib.h>

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI ProtocolIsVariablePolicyEnabled (OUT BOOLEAN *State)
 
VOID EFIAPI RecordSecureBootPolicyVarData (VOID)
 
BOOLEAN AtRuntime (VOID)
 
EFI_LOCKInitializeLock (IN OUT EFI_LOCK *Lock, IN EFI_TPL Priority)
 
VOID AcquireLockOnlyAtBootTime (IN EFI_LOCK *Lock)
 
VOID ReleaseLockOnlyAtBootTime (IN EFI_LOCK *Lock)
 
EFI_STATUS GetFtwProtocol (OUT VOID **FtwProtocol)
 
EFI_STATUS GetFvbByHandle (IN EFI_HANDLE FvBlockHandle, OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock)
 
EFI_STATUS GetFvbCountAndBuffer (OUT UINTN *NumberHandles, OUT EFI_HANDLE **Buffer)
 
VOID EFIAPI VariableClassAddressChangeEvent (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI OnReadyToBoot (EFI_EVENT Event, VOID *Context)
 
VOID EFIAPI OnEndOfDxe (EFI_EVENT Event, VOID *Context)
 
VOID VariableWriteServiceInitializeDxe (VOID)
 
VOID EFIAPI FtwNotificationEvent (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI VariableServiceInitialize (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

EFI_HANDLE mHandle = NULL
 
EFI_EVENT mVirtualAddressChangeEvent = NULL
 
VOID * mFtwRegistration = NULL
 
VOID *** mVarCheckAddressPointer = NULL
 
UINTN mVarCheckAddressPointerCount = 0
 
EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock = { VariableLockRequestToLock }
 
EDKII_VARIABLE_POLICY_PROTOCOL mVariablePolicyProtocol
 
EDKII_VAR_CHECK_PROTOCOL mVarCheck
 

Detailed Description

Implement all four UEFI Runtime Variable services for the nonvolatile and volatile storage space and install variable architecture protocol.

Copyright (C) 2013, Red Hat, Inc. Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file VariableDxe.c.

Function Documentation

◆ AcquireLockOnlyAtBootTime()

VOID AcquireLockOnlyAtBootTime ( IN EFI_LOCK Lock)

Acquires lock only at boot time. Simply returns at runtime.

This is a temperary function that will be removed when EfiAcquireLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiAcquireLock() at boot time, and simply returns at runtime.

Parameters
LockA pointer to the lock to acquire.

Definition at line 108 of file VariableDxe.c.

◆ AtRuntime()

BOOLEAN AtRuntime ( VOID  )

Return TRUE if ExitBootServices () has been called.

Return values
TRUEIf ExitBootServices () has been called.

Definition at line 63 of file VariableDxe.c.

◆ FtwNotificationEvent()

VOID EFIAPI FtwNotificationEvent ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Fault Tolerant Write protocol notification event handler.

Non-Volatile variable write may needs FTW protocol to reclaim when writting variable.

Parameters
[in]EventEvent whose notification function is being invoked.
[in]ContextPointer to the notification function's context.

Definition at line 413 of file VariableDxe.c.

◆ GetFtwProtocol()

EFI_STATUS GetFtwProtocol ( OUT VOID **  FtwProtocol)

Retrieve the Fault Tolerent Write protocol interface.

Parameters
[out]FtwProtocolThe interface of Ftw protocol
Return values
EFI_SUCCESSThe FTW protocol instance was found and returned in FtwProtocol.
EFI_NOT_FOUNDThe FTW protocol instance was not found.
EFI_INVALID_PARAMETERSarProtocol is NULL.

Definition at line 150 of file VariableDxe.c.

◆ GetFvbByHandle()

EFI_STATUS GetFvbByHandle ( IN EFI_HANDLE  FvBlockHandle,
OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **  FvBlock 
)

Retrieve the FVB protocol interface by HANDLE.

Parameters
[in]FvBlockHandleThe handle of FVB protocol that provides services for reading, writing, and erasing the target block.
[out]FvBlockThe interface of FVB protocol
Return values
EFI_SUCCESSThe interface information for the specified protocol was returned.
EFI_UNSUPPORTEDThe device does not support the FVB protocol.
EFI_INVALID_PARAMETERFvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.

Definition at line 180 of file VariableDxe.c.

◆ GetFvbCountAndBuffer()

EFI_STATUS GetFvbCountAndBuffer ( OUT UINTN NumberHandles,
OUT EFI_HANDLE **  Buffer 
)

Function returns an array of handles that support the FVB protocol in a buffer allocated from pool.

Parameters
[out]NumberHandlesThe number of handles returned in Buffer.
[out]BufferA pointer to the buffer to return the requested array of handles that support FVB protocol.
Return values
EFI_SUCCESSThe array of handles was returned in Buffer, and the number of handles in Buffer was returned in NumberHandles.
EFI_NOT_FOUNDNo FVB handle was found.
EFI_OUT_OF_RESOURCESThere is not enough pool memory to store the matching results.
EFI_INVALID_PARAMETERNumberHandles is NULL or Buffer is NULL.

Definition at line 211 of file VariableDxe.c.

◆ InitializeLock()

EFI_LOCK * InitializeLock ( IN OUT EFI_LOCK Lock,
IN EFI_TPL  Priority 
)

Initializes a basic mutual exclusion lock.

This function initializes a basic mutual exclusion lock to the released state and returns the lock. Each lock provides mutual exclusion access at its task priority level. Since there is no preemption or multiprocessor support in EFI, acquiring the lock only consists of raising to the locks TPL. If Lock is NULL, then ASSERT(). If Priority is not a valid TPL value, then ASSERT().

Parameters
LockA pointer to the lock data structure to initialize.
PriorityEFI TPL is associated with the lock.
Returns
The lock.

Definition at line 87 of file VariableDxe.c.

◆ OnEndOfDxe()

VOID EFIAPI OnEndOfDxe ( EFI_EVENT  Event,
VOID *  Context 
)

Notification function of EFI_END_OF_DXE_EVENT_GROUP_GUID event group.

This is a notification function registered on EFI_END_OF_DXE_EVENT_GROUP_GUID event group.

Parameters
EventEvent whose notification function is being invoked.
ContextPointer to the notification function's context.

Definition at line 343 of file VariableDxe.c.

◆ OnReadyToBoot()

VOID EFIAPI OnReadyToBoot ( EFI_EVENT  Event,
VOID *  Context 
)

Notification function of EVT_GROUP_READY_TO_BOOT event group.

This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group. When the Boot Manager is about to load and execute a boot option, it reclaims variable storage if free size is below the threshold.

Parameters
EventEvent whose notification function is being invoked.
ContextPointer to the notification function's context.

Definition at line 297 of file VariableDxe.c.

◆ ProtocolIsVariablePolicyEnabled()

EFI_STATUS EFIAPI ProtocolIsVariablePolicyEnabled ( OUT BOOLEAN *  State)

This API function returns whether or not the policy engine is currently being enforced.

Parameters
[out]StatePointer to a return value for whether the policy enforcement is currently enabled.
Return values
EFI_SUCCESS
OthersAn error has prevented this command from completing.

Definition at line 516 of file VariableDxe.c.

◆ RecordSecureBootPolicyVarData()

VOID EFIAPI RecordSecureBootPolicyVarData ( VOID  )

Some Secure Boot Policy Variable may update following other variable changes(SecureBoot follows PK change, etc). Record their initial State when variable write service is ready.

Definition at line 347 of file Measurement.c.

◆ ReleaseLockOnlyAtBootTime()

VOID ReleaseLockOnlyAtBootTime ( IN EFI_LOCK Lock)

Releases lock only at boot time. Simply returns at runtime.

This is a temperary function which will be removed when EfiReleaseLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiReleaseLock() at boot time and simply returns at runtime.

Parameters
LockA pointer to the lock to release.

Definition at line 130 of file VariableDxe.c.

◆ VariableClassAddressChangeEvent()

VOID EFIAPI VariableClassAddressChangeEvent ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

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.

Parameters
EventEvent whose notification function is being invoked.
ContextPointer to the notification function's context.

Definition at line 243 of file VariableDxe.c.

◆ VariableServiceInitialize()

EFI_STATUS EFIAPI VariableServiceInitialize ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Variable 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 a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSVariable service successfully initialized.

Definition at line 538 of file VariableDxe.c.

◆ VariableWriteServiceInitializeDxe()

VOID VariableWriteServiceInitializeDxe ( VOID  )

Initializes variable write service for DXE.

Definition at line 372 of file VariableDxe.c.

Variable Documentation

◆ mFtwRegistration

VOID* mFtwRegistration = NULL

Definition at line 26 of file VariableDxe.c.

◆ mHandle

EFI_HANDLE mHandle = NULL

Handle for the Capsule Update Policy Protocol

Definition at line 24 of file VariableDxe.c.

◆ mVarCheck

Initial value:
= {
}
EFI_STATUS EFIAPI VarCheckVariablePropertySet(IN CHAR16 *Name, IN EFI_GUID *Guid, IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty)
Definition: VarCheck.c:59
EFI_STATUS EFIAPI VarCheckRegisterSetVariableCheckHandler(IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler)
Definition: VarCheck.c:29
EFI_STATUS EFIAPI VarCheckVariablePropertyGet(IN CHAR16 *Name, IN EFI_GUID *Guid, OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty)
Definition: VarCheck.c:88

Definition at line 40 of file VariableDxe.c.

◆ mVarCheckAddressPointer

VOID*** mVarCheckAddressPointer = NULL

Definition at line 27 of file VariableDxe.c.

◆ mVarCheckAddressPointerCount

UINTN mVarCheckAddressPointerCount = 0

Definition at line 28 of file VariableDxe.c.

◆ mVariableLock

Definition at line 29 of file VariableDxe.c.

◆ mVariablePolicyProtocol

EDKII_VARIABLE_POLICY_PROTOCOL mVariablePolicyProtocol
Initial value:
= {
EDKII_VARIABLE_POLICY_PROTOCOL_REVISION,
DisableVariablePolicy,
RegisterVariablePolicy,
DumpVariablePolicy,
LockVariablePolicy,
GetVariablePolicyInfo,
GetLockOnVariableStateVariablePolicyInfo
}
EFI_STATUS EFIAPI ProtocolIsVariablePolicyEnabled(OUT BOOLEAN *State)
Definition: VariableDxe.c:516

Definition at line 30 of file VariableDxe.c.

◆ mVirtualAddressChangeEvent

EFI_EVENT mVirtualAddressChangeEvent = NULL

Definition at line 25 of file VariableDxe.c.