2008-07-08 15:29:42 +02:00
|
|
|
/** @file
|
2009-06-11 16:17:23 +02:00
|
|
|
The variable data structures are related to EDK II-specific implementation of UEFI variables.
|
|
|
|
VariableFormat.h defines variable data headers and variable storage region headers.
|
2007-07-24 12:52:02 +02:00
|
|
|
|
2016-02-02 01:53:39 +01:00
|
|
|
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
2015-07-01 05:04:18 +02:00
|
|
|
This program and the accompanying materials are licensed and made available under
|
|
|
|
the terms and conditions of the BSD License that accompanies this distribution.
|
2010-03-17 21:48:52 +01:00
|
|
|
The full text of the license may be found at
|
2015-07-01 05:04:18 +02:00
|
|
|
http://opensource.org/licenses/bsd-license.php.
|
2008-11-27 05:53:43 +01:00
|
|
|
|
2015-07-01 05:04:18 +02:00
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
2010-03-17 21:48:52 +01:00
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
2007-07-24 12:52:02 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef __VARIABLE_FORMAT_H__
|
|
|
|
#define __VARIABLE_FORMAT_H__
|
|
|
|
|
2009-02-27 06:35:08 +01:00
|
|
|
#define EFI_VARIABLE_GUID \
|
|
|
|
{ 0xddcf3616, 0x3275, 0x4164, { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d } }
|
|
|
|
|
2015-07-01 05:02:08 +02:00
|
|
|
#define EFI_AUTHENTICATED_VARIABLE_GUID \
|
|
|
|
{ 0xaaf32c78, 0x947b, 0x439a, { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 } }
|
|
|
|
|
2009-02-27 06:35:08 +01:00
|
|
|
extern EFI_GUID gEfiVariableGuid;
|
2015-07-01 05:02:08 +02:00
|
|
|
extern EFI_GUID gEfiAuthenticatedVariableGuid;
|
2009-02-27 06:35:08 +01:00
|
|
|
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2009-06-11 16:17:23 +02:00
|
|
|
/// Alignment of variable name and data, according to the architecture:
|
2010-03-17 21:48:52 +01:00
|
|
|
/// * For IA-32 and Intel(R) 64 architectures: 1.
|
|
|
|
/// * For IA-64 architecture: 8.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
#if defined (MDE_CPU_IPF)
|
2008-01-10 05:26:13 +01:00
|
|
|
#define ALIGNMENT 8
|
2007-07-24 12:52:02 +02:00
|
|
|
#else
|
2008-01-10 05:26:13 +01:00
|
|
|
#define ALIGNMENT 1
|
2007-07-24 12:52:02 +02:00
|
|
|
#endif
|
|
|
|
|
2009-01-09 07:26:42 +01:00
|
|
|
//
|
2009-06-11 16:17:23 +02:00
|
|
|
// GET_PAD_SIZE calculates the miminal pad bytes needed to make the current pad size satisfy the alignment requirement.
|
2009-01-09 07:26:42 +01:00
|
|
|
//
|
2009-02-27 08:07:27 +01:00
|
|
|
#if (ALIGNMENT == 1)
|
2009-01-09 07:26:42 +01:00
|
|
|
#define GET_PAD_SIZE(a) (0)
|
|
|
|
#else
|
|
|
|
#define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Alignment of Variable Data Header in Variable Store region.
|
2009-01-09 07:26:42 +01:00
|
|
|
///
|
2008-01-10 05:26:13 +01:00
|
|
|
#define HEADER_ALIGNMENT 4
|
2009-01-09 07:26:42 +01:00
|
|
|
#define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
|
2008-01-10 05:26:13 +01:00
|
|
|
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Status of Variable Store Region.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
typedef enum {
|
|
|
|
EfiRaw,
|
|
|
|
EfiValid,
|
|
|
|
EfiInvalid,
|
|
|
|
EfiUnknown
|
|
|
|
} VARIABLE_STORE_STATUS;
|
|
|
|
|
|
|
|
#pragma pack(1)
|
|
|
|
|
2009-02-27 06:35:08 +01:00
|
|
|
#define VARIABLE_STORE_SIGNATURE EFI_VARIABLE_GUID
|
2015-07-01 05:02:08 +02:00
|
|
|
#define AUTHENTICATED_VARIABLE_STORE_SIGNATURE EFI_AUTHENTICATED_VARIABLE_GUID
|
2008-11-27 05:53:43 +01:00
|
|
|
|
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Variable Store Header Format and State.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
|
|
|
#define VARIABLE_STORE_FORMATTED 0x5a
|
|
|
|
#define VARIABLE_STORE_HEALTHY 0xfe
|
|
|
|
|
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Variable Store region header.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
typedef struct {
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
|
|
|
/// Variable store region signature.
|
|
|
|
///
|
2009-02-27 06:35:08 +01:00
|
|
|
EFI_GUID Signature;
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2015-07-01 05:04:18 +02:00
|
|
|
/// Size of entire variable store,
|
2009-02-27 06:35:08 +01:00
|
|
|
/// including size of variable store header but not including the size of FvHeader.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
UINT32 Size;
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Variable region format state.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
UINT8 Format;
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Variable region healthy state.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
UINT8 State;
|
|
|
|
UINT16 Reserved;
|
|
|
|
UINT32 Reserved1;
|
|
|
|
} VARIABLE_STORE_HEADER;
|
|
|
|
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Variable data start flag.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
|
|
|
#define VARIABLE_DATA 0x55AA
|
|
|
|
|
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Variable State flags.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
#define VAR_IN_DELETED_TRANSITION 0xfe ///< Variable is in obsolete transition.
|
|
|
|
#define VAR_DELETED 0xfd ///< Variable is obsolete.
|
|
|
|
#define VAR_HEADER_VALID_ONLY 0x7f ///< Variable header has been valid.
|
|
|
|
#define VAR_ADDED 0x3f ///< Variable has been completely added.
|
2008-11-27 05:53:43 +01:00
|
|
|
|
2015-07-01 05:04:18 +02:00
|
|
|
///
|
|
|
|
/// Variable Attribute combinations.
|
|
|
|
///
|
|
|
|
#define VARIABLE_ATTRIBUTE_NV_BS (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
|
|
|
|
#define VARIABLE_ATTRIBUTE_BS_RT (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
|
|
|
|
#define VARIABLE_ATTRIBUTE_AT_AW (EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS)
|
2016-02-02 01:53:39 +01:00
|
|
|
#define VARIABLE_ATTRIBUTE_BS_RT_AT (VARIABLE_ATTRIBUTE_BS_RT | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)
|
2015-07-01 05:04:18 +02:00
|
|
|
#define VARIABLE_ATTRIBUTE_NV_BS_RT (VARIABLE_ATTRIBUTE_BS_RT | EFI_VARIABLE_NON_VOLATILE)
|
|
|
|
#define VARIABLE_ATTRIBUTE_NV_BS_RT_HR (VARIABLE_ATTRIBUTE_NV_BS_RT | EFI_VARIABLE_HARDWARE_ERROR_RECORD)
|
|
|
|
#define VARIABLE_ATTRIBUTE_NV_BS_RT_AT (VARIABLE_ATTRIBUTE_NV_BS_RT | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)
|
|
|
|
#define VARIABLE_ATTRIBUTE_NV_BS_RT_AW (VARIABLE_ATTRIBUTE_NV_BS_RT | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS)
|
|
|
|
#define VARIABLE_ATTRIBUTE_NV_BS_RT_HR_AT_AW (VARIABLE_ATTRIBUTE_NV_BS_RT_HR | VARIABLE_ATTRIBUTE_AT_AW)
|
|
|
|
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Single Variable Data Header Structure.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
typedef struct {
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Variable Data Start Flag.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
UINT16 StartId;
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Variable State defined above.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
UINT8 State;
|
|
|
|
UINT8 Reserved;
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Attributes of variable defined in UEFI specification.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
UINT32 Attributes;
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Size of variable null-terminated Unicode string name.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
UINT32 NameSize;
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2010-03-17 21:48:52 +01:00
|
|
|
/// Size of the variable data without this header.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
UINT32 DataSize;
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2009-06-11 16:17:23 +02:00
|
|
|
/// A unique identifier for the vendor that produces and consumes this varaible.
|
2008-11-27 05:53:43 +01:00
|
|
|
///
|
2007-07-24 12:52:02 +02:00
|
|
|
EFI_GUID VendorGuid;
|
|
|
|
} VARIABLE_HEADER;
|
|
|
|
|
2015-07-01 05:02:08 +02:00
|
|
|
///
|
|
|
|
/// Single Authenticated Variable Data Header Structure.
|
|
|
|
///
|
|
|
|
typedef struct {
|
|
|
|
///
|
|
|
|
/// Variable Data Start Flag.
|
|
|
|
///
|
|
|
|
UINT16 StartId;
|
|
|
|
///
|
|
|
|
/// Variable State defined above.
|
|
|
|
///
|
|
|
|
UINT8 State;
|
|
|
|
UINT8 Reserved;
|
|
|
|
///
|
|
|
|
/// Attributes of variable defined in UEFI specification.
|
|
|
|
///
|
|
|
|
UINT32 Attributes;
|
|
|
|
///
|
|
|
|
/// Associated monotonic count value against replay attack.
|
|
|
|
///
|
|
|
|
UINT64 MonotonicCount;
|
|
|
|
///
|
|
|
|
/// Associated TimeStamp value against replay attack.
|
|
|
|
///
|
|
|
|
EFI_TIME TimeStamp;
|
|
|
|
///
|
|
|
|
/// Index of associated public key in database.
|
|
|
|
///
|
|
|
|
UINT32 PubKeyIndex;
|
|
|
|
///
|
|
|
|
/// Size of variable null-terminated Unicode string name.
|
|
|
|
///
|
|
|
|
UINT32 NameSize;
|
|
|
|
///
|
|
|
|
/// Size of the variable data without this header.
|
|
|
|
///
|
|
|
|
UINT32 DataSize;
|
|
|
|
///
|
|
|
|
/// A unique identifier for the vendor that produces and consumes this varaible.
|
|
|
|
///
|
|
|
|
EFI_GUID VendorGuid;
|
|
|
|
} AUTHENTICATED_VARIABLE_HEADER;
|
|
|
|
|
2015-07-01 05:04:18 +02:00
|
|
|
typedef struct {
|
|
|
|
EFI_GUID *Guid;
|
|
|
|
CHAR16 *Name;
|
|
|
|
UINTN VariableSize;
|
|
|
|
} VARIABLE_ENTRY_CONSISTENCY;
|
|
|
|
|
2007-07-24 12:52:02 +02:00
|
|
|
#pragma pack()
|
|
|
|
|
2009-02-27 06:35:08 +01:00
|
|
|
typedef struct _VARIABLE_INFO_ENTRY VARIABLE_INFO_ENTRY;
|
|
|
|
|
|
|
|
///
|
|
|
|
/// This structure contains the variable list that is put in EFI system table.
|
2009-06-11 16:17:23 +02:00
|
|
|
/// The variable driver collects all variables that were used at boot service time and produces this list.
|
2015-07-01 05:04:18 +02:00
|
|
|
/// This is an optional feature to dump all used variables in shell environment.
|
2009-02-27 06:35:08 +01:00
|
|
|
///
|
|
|
|
struct _VARIABLE_INFO_ENTRY {
|
2010-03-17 21:48:52 +01:00
|
|
|
VARIABLE_INFO_ENTRY *Next; ///< Pointer to next entry.
|
|
|
|
EFI_GUID VendorGuid; ///< Guid of Variable.
|
2015-07-01 05:04:18 +02:00
|
|
|
CHAR16 *Name; ///< Name of Variable.
|
2010-03-17 21:48:52 +01:00
|
|
|
UINT32 Attributes; ///< Attributes of variable defined in UEFI specification.
|
|
|
|
UINT32 ReadCount; ///< Number of times to read this variable.
|
|
|
|
UINT32 WriteCount; ///< Number of times to write this variable.
|
|
|
|
UINT32 DeleteCount; ///< Number of times to delete this variable.
|
|
|
|
UINT32 CacheCount; ///< Number of times that cache hits this variable.
|
|
|
|
BOOLEAN Volatile; ///< TRUE if volatile, FALSE if non-volatile.
|
2009-02-27 06:35:08 +01:00
|
|
|
};
|
|
|
|
|
2007-07-24 12:52:02 +02:00
|
|
|
#endif // _EFI_VARIABLE_H_
|