]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
Change C functions, xxxSizeOfVariable(), to MACRO, which can avoid the ICC compile...
[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 NAMESIZE_OF_VARIABLE(Variable) \
63 ((((Variable)->DataSize == (UINT32) -1) || \
64 ((Variable)->Attributes == (UINT32) -1) || \
65 ((Variable)->NameSize == (UINT32) -1)) ? \
66 0 : \
67 (Variable)->NameSize \
68 )
69
70 #define DATASIZE_OF_VARIABLE(Variable) \
71 ((((Variable)->DataSize == (UINT32) -1) || \
72 ((Variable)->Attributes == (UINT32) -1) || \
73 ((Variable)->NameSize == (UINT32) -1)) ? \
74 0 : \
75 (Variable)->DataSize \
76 )
77
78 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
79
80
81 typedef struct {
82 VARIABLE_HEADER *CurrPtr;
83 VARIABLE_HEADER *EndPtr;
84 VARIABLE_HEADER *StartPtr;
85 BOOLEAN Volatile;
86 } VARIABLE_POINTER_TRACK;
87
88 typedef struct {
89 EFI_PHYSICAL_ADDRESS VolatileVariableBase;
90 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;
91 EFI_LOCK VariableServicesLock;
92 UINT32 ReentrantState;
93 } VARIABLE_GLOBAL;
94
95 typedef struct {
96 VARIABLE_GLOBAL VariableGlobal;
97 UINTN VolatileLastVariableOffset;
98 UINTN NonVolatileLastVariableOffset;
99 UINT32 FvbInstance;
100 } VARIABLE_MODULE_GLOBAL;
101
102 typedef struct {
103 EFI_GUID *Guid;
104 CHAR16 *Name;
105 UINT32 Attributes;
106 UINTN DataSize;
107 VOID *Data;
108 } VARIABLE_CACHE_ENTRY;
109
110
111 //
112 // Functions
113 //
114
115 EFI_STATUS
116 EFIAPI
117 VariableServiceInitialize (
118 IN EFI_HANDLE ImageHandle,
119 IN EFI_SYSTEM_TABLE *SystemTable
120 );
121
122
123 EFI_STATUS
124 FtwVariableSpace (
125 IN EFI_PHYSICAL_ADDRESS VariableBaseAddress,
126 IN UINT8 *Buffer,
127 IN UINTN BufferSize
128 );
129
130 #endif