]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/FSVariable/FSVariable.h
Fix AutoUpdateLangVariable() logic to handle the case PlatformLang/Lang is set before...
[mirror_edk2.git] / DuetPkg / FSVariable / FSVariable.h
1 /*++
2
3 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
4 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 FSVariable.h
15
16 Abstract:
17
18 --*/
19
20 #ifndef _FS_VARIABLE_H
21 #define _FS_VARIABLE_H
22
23 //
24 // Statements that include other header files
25 //
26 #include <PiDxe.h>
27
28 #include <Library/BaseLib.h>
29 #include <Library/PcdLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/MemoryAllocationLib.h>
32 #include <Library/UefiBootServicesTableLib.h>
33 #include <Library/UefiRuntimeLib.h>
34 #include <Library/DebugLib.h>
35 #include <Library/UefiLib.h>
36 #include <Library/HobLib.h>
37 #include <Library/DxeServicesTableLib.h>
38 #include <Library/DevicePathLib.h>
39
40 #include <Guid/HobList.h>
41 #include <Guid/FlashMapHob.h>
42 #include <Guid/VariableFormat.h>
43 #include <Guid/GlobalVariable.h>
44 #include <Protocol/Variable.h>
45 #include <Protocol/VariableWrite.h>
46 #include <Protocol/SimpleFileSystem.h>
47 #include <Protocol/BlockIo.h>
48
49
50 #include "EfiFlashMap.h"
51 #include "VariableStorage.h"
52
53 #define VOLATILE_VARIABLE_STORE_SIZE FixedPcdGet32(PcdVariableStoreSize)
54 #define VARIABLE_SCRATCH_SIZE MAX(FixedPcdGet32(PcdMaxVariableSize), FixedPcdGet32(PcdMaxHardwareErrorVariableSize))
55 #define VARIABLE_RECLAIM_THRESHOLD (1024)
56 ///
57 /// The size of a 3 character ISO639 language code.
58 ///
59 #define ISO_639_2_ENTRY_SIZE 3
60
61 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
62
63 typedef enum {
64 Physical,
65 Virtual
66 } VARIABLE_POINTER_TYPE;
67
68 typedef enum {
69 NonVolatile,
70 Volatile,
71 MaxType
72 } VARIABLE_STORAGE_TYPE;
73
74 typedef struct {
75 VARIABLE_HEADER *CurrPtr;
76 VARIABLE_HEADER *EndPtr;
77 VARIABLE_HEADER *StartPtr;
78 VARIABLE_STORAGE_TYPE Type;
79 } VARIABLE_POINTER_TRACK;
80
81 #define VARIABLE_MEMBER_OFFSET(Member, StartOffset) \
82 ( sizeof (VARIABLE_STORE_HEADER) + (StartOffset) + \
83 (UINTN) ((UINT8 *) &((VARIABLE_HEADER*) 0)->Member - (UINT8 *) &((VARIABLE_HEADER*) 0)->StartId) \
84 )
85
86
87 typedef struct {
88 EFI_EVENT_NOTIFY GoVirtualChildEvent[MaxType];
89 VARIABLE_STORAGE *VariableStore[MaxType]; // Instance of VariableStorage
90 VOID *VariableBase[MaxType]; // Start address of variable storage
91 UINTN LastVariableOffset[MaxType]; // The position to write new variable to (index from VariableBase)
92 VOID *Scratch; // Buffer used during reclaim
93 UINTN CommonVariableTotalSize;
94 UINTN HwErrVariableTotalSize;
95 CHAR8 *PlatformLangCodes;
96 CHAR8 *LangCodes;
97 CHAR8 *PlatformLang;
98 CHAR8 Lang[ISO_639_2_ENTRY_SIZE + 1];
99 } VARIABLE_GLOBAL;
100
101 //
102 // Functions
103 //
104
105 EFI_STATUS
106 EFIAPI
107 VariableServiceInitialize (
108 IN EFI_HANDLE ImageHandle,
109 IN EFI_SYSTEM_TABLE *SystemTable
110 );
111
112 VOID
113 EFIAPI
114 VariableClassAddressChangeEvent (
115 IN EFI_EVENT Event,
116 IN VOID *Context
117 );
118
119 EFI_STATUS
120 EFIAPI
121 DuetGetVariable (
122 IN CHAR16 *VariableName,
123 IN EFI_GUID *VendorGuid,
124 OUT UINT32 *Attributes OPTIONAL,
125 IN OUT UINTN *DataSize,
126 OUT VOID *Data
127 );
128
129 EFI_STATUS
130 EFIAPI
131 GetNextVariableName (
132 IN OUT UINTN *VariableNameSize,
133 IN OUT CHAR16 *VariableName,
134 IN OUT EFI_GUID *VendorGuid
135 );
136
137 EFI_STATUS
138 EFIAPI
139 SetVariable (
140 IN CHAR16 *VariableName,
141 IN EFI_GUID *VendorGuid,
142 IN UINT32 Attributes,
143 IN UINTN DataSize,
144 IN VOID *Data
145 );
146
147 EFI_STATUS
148 EFIAPI
149 QueryVariableInfo (
150 IN UINT32 Attributes,
151 OUT UINT64 *MaximumVariableStorageSize,
152 OUT UINT64 *RemainingVariableStorageSize,
153 OUT UINT64 *MaximumVariableSize
154 );
155
156 #endif