]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
Align the header of variable from 1 to 4, which can avoid the size of variable conten...
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / Variable.h
1 /*++
2
3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 Variable.h
15
16 Abstract:
17
18 --*/
19
20 #ifndef _VARIABLE_H
21 #define _VARIABLE_H
22
23 #include <PiDxe.h>
24 #include <Protocol/VariableWrite.h>
25 #include <Protocol/FaultTolerantWriteLite.h>
26 #include <Protocol/FirmwareVolumeBlock.h>
27 #include <Protocol/Variable.h>
28 #include <Library/PcdLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/DxeServicesTableLib.h>
31 #include <Library/UefiRuntimeLib.h>
32 #include <Library/DebugLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/FvbServiceLib.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/BaseLib.h>
38 #include <Library/MemoryAllocationLib.h>
39 #include <Library/HobLib.h>
40 #include <Guid/VariableInfo.h>
41 #include <Guid/GlobalVariable.h>
42 #include <VariableFormat.h>
43
44
45
46 #define VARIABLE_RECLAIM_THRESHOLD (1024)
47
48 #define VARIABLE_STORE_SIZE FixedPcdGet32(PcdVariableStoreSize)
49 #define SCRATCH_SIZE FixedPcdGet32(PcdMaxVariableSize)
50
51 //
52 // Define GET_PAD_SIZE to optimize compiler
53 //
54 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
55 #define GET_PAD_SIZE(a) (0)
56 #else
57 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
58 #endif
59
60 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
61
62 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
63
64
65 typedef struct {
66 VARIABLE_HEADER *CurrPtr;
67 VARIABLE_HEADER *EndPtr;
68 VARIABLE_HEADER *StartPtr;
69 BOOLEAN Volatile;
70 } VARIABLE_POINTER_TRACK;
71
72 typedef struct {
73 EFI_PHYSICAL_ADDRESS VolatileVariableBase;
74 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;
75 EFI_LOCK VariableServicesLock;
76 UINT32 ReentrantState;
77 } VARIABLE_GLOBAL;
78
79 typedef struct {
80 VARIABLE_GLOBAL VariableGlobal;
81 UINTN VolatileLastVariableOffset;
82 UINTN NonVolatileLastVariableOffset;
83 UINT32 FvbInstance;
84 } VARIABLE_MODULE_GLOBAL;
85
86 typedef struct {
87 EFI_GUID *Guid;
88 CHAR16 *Name;
89 UINT32 Attributes;
90 UINTN DataSize;
91 VOID *Data;
92 } VARIABLE_CACHE_ENTRY;
93
94
95 //
96 // Functions
97 //
98
99 EFI_STATUS
100 EFIAPI
101 VariableServiceInitialize (
102 IN EFI_HANDLE ImageHandle,
103 IN EFI_SYSTEM_TABLE *SystemTable
104 );
105
106
107 EFI_STATUS
108 FtwVariableSpace (
109 IN EFI_PHYSICAL_ADDRESS VariableBaseAddress,
110 IN UINT8 *Buffer,
111 IN UINTN BufferSize
112 );
113
114 #endif