]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
91fdf9dbfd586078304fce9597f6b2ecae578b24
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / Variable.h
1 /** @file
2
3 The internal header file includes the common header files, defines
4 internal structure and functions used by RuntimeVariable module.
5
6 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #ifndef _VARIABLE_H_
18 #define _VARIABLE_H_
19
20 #include <PiDxe.h>
21 #include <Protocol/VariableWrite.h>
22 #include <Protocol/FaultTolerantWrite.h>
23 #include <Protocol/FirmwareVolumeBlock.h>
24 #include <Protocol/Variable.h>
25 #include <Library/PcdLib.h>
26 #include <Library/UefiDriverEntryPoint.h>
27 #include <Library/DxeServicesTableLib.h>
28 #include <Library/UefiRuntimeLib.h>
29 #include <Library/DebugLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/UefiBootServicesTableLib.h>
32 #include <Library/UefiLib.h>
33 #include <Library/BaseLib.h>
34 #include <Library/SynchronizationLib.h>
35 #include <Library/MemoryAllocationLib.h>
36 #include <Guid/GlobalVariable.h>
37 #include <Guid/EventGroup.h>
38 #include <Guid/VariableFormat.h>
39
40 #define VARIABLE_RECLAIM_THRESHOLD (1024)
41
42 ///
43 /// The size of a 3 character ISO639 language code.
44 ///
45 #define ISO_639_2_ENTRY_SIZE 3
46
47 typedef struct {
48 VARIABLE_HEADER *CurrPtr;
49 VARIABLE_HEADER *EndPtr;
50 VARIABLE_HEADER *StartPtr;
51 BOOLEAN Volatile;
52 } VARIABLE_POINTER_TRACK;
53
54 typedef struct {
55 EFI_PHYSICAL_ADDRESS VolatileVariableBase;
56 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;
57 EFI_LOCK VariableServicesLock;
58 UINT32 ReentrantState;
59 } VARIABLE_GLOBAL;
60
61 typedef struct {
62 VARIABLE_GLOBAL VariableGlobal;
63 UINTN VolatileLastVariableOffset;
64 UINTN NonVolatileLastVariableOffset;
65 UINTN CommonVariableTotalSize;
66 UINTN HwErrVariableTotalSize;
67 CHAR8 *PlatformLangCodes;
68 CHAR8 *LangCodes;
69 CHAR8 *PlatformLang;
70 CHAR8 Lang[ISO_639_2_ENTRY_SIZE + 1];
71 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbInstance;
72 } VARIABLE_MODULE_GLOBAL;
73
74 typedef struct {
75 EFI_GUID *Guid;
76 CHAR16 *Name;
77 UINT32 Attributes;
78 UINTN DataSize;
79 VOID *Data;
80 } VARIABLE_CACHE_ENTRY;
81
82 /**
83 Writes a buffer to variable storage space, in the working block.
84
85 This function writes a buffer to variable storage space into firmware
86 volume block device. The destination is specified by parameter
87 VariableBase. Fault Tolerant Write protocol is used for writing.
88
89 @param VariableBase Base address of variable to write
90 @param Buffer Point to the data buffer
91 @param BufferSize The number of bytes of the data Buffer
92
93 @retval EFI_SUCCESS The function completed successfully
94 @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol
95 @retval EFI_ABORTED The function could not complete successfully
96
97 **/
98 EFI_STATUS
99 FtwVariableSpace (
100 IN EFI_PHYSICAL_ADDRESS VariableBase,
101 IN UINT8 *Buffer,
102 IN UINTN BufferSize
103 );
104
105
106 #endif