1 /*++ 2 3 Caution: This file is used for Duet platform only, do not use them in real platform. 4 All variable code, variable metadata, and variable data used by Duet platform are on 5 disk. They can be changed by user. BIOS is not able to protoect those. 6 Duet trusts all meta data from disk. If variable code, variable metadata and variable 7 data is modified in inproper way, the behavior is undefined. 8 9 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> 10 This program and the accompanying materials 11 are licensed and made available under the terms and conditions of the BSD License 12 which accompanies this distribution. The full text of the license may be found at 13 http://opensource.org/licenses/bsd-license.php 14 15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 17 18 Module Name: 19 20 FSVariable.h 21 22 Abstract: 23 24 --*/ 25 26 #ifndef _FS_VARIABLE_H 27 #define _FS_VARIABLE_H 28 29 // 30 // Statements that include other header files 31 // 32 #include <PiDxe.h> 33 34 #include <Library/BaseLib.h> 35 #include <Library/PcdLib.h> 36 #include <Library/BaseMemoryLib.h> 37 #include <Library/MemoryAllocationLib.h> 38 #include <Library/UefiBootServicesTableLib.h> 39 #include <Library/UefiRuntimeLib.h> 40 #include <Library/DebugLib.h> 41 #include <Library/UefiLib.h> 42 #include <Library/HobLib.h> 43 #include <Library/DxeServicesTableLib.h> 44 #include <Library/DevicePathLib.h> 45 46 #include <Guid/HobList.h> 47 #include <Guid/FlashMapHob.h> 48 #include <Guid/VariableFormat.h> 49 #include <Guid/GlobalVariable.h> 50 #include <Protocol/Variable.h> 51 #include <Protocol/VariableWrite.h> 52 #include <Protocol/SimpleFileSystem.h> 53 #include <Protocol/BlockIo.h> 54 55 56 #include "EfiFlashMap.h" 57 #include "VariableStorage.h" 58 59 #define VOLATILE_VARIABLE_STORE_SIZE FixedPcdGet32(PcdVariableStoreSize) 60 #define VARIABLE_SCRATCH_SIZE MAX(FixedPcdGet32(PcdMaxVariableSize), FixedPcdGet32(PcdMaxHardwareErrorVariableSize)) 61 #define VARIABLE_RECLAIM_THRESHOLD (1024) 62 /// 63 /// The size of a 3 character ISO639 language code. 64 /// 65 #define ISO_639_2_ENTRY_SIZE 3 66 67 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER)) 68 69 typedef enum { 70 Physical, 71 Virtual 72 } VARIABLE_POINTER_TYPE; 73 74 typedef enum { 75 NonVolatile, 76 Volatile, 77 MaxType 78 } VARIABLE_STORAGE_TYPE; 79 80 typedef struct { 81 VARIABLE_HEADER *CurrPtr; 82 VARIABLE_HEADER *EndPtr; 83 VARIABLE_HEADER *StartPtr; 84 VARIABLE_STORAGE_TYPE Type; 85 } VARIABLE_POINTER_TRACK; 86 87 #define VARIABLE_MEMBER_OFFSET(Member, StartOffset) \ 88 ( sizeof (VARIABLE_STORE_HEADER) + (StartOffset) + \ 89 (UINTN) ((UINT8 *) &((VARIABLE_HEADER*) 0)->Member - (UINT8 *) &((VARIABLE_HEADER*) 0)->StartId) \ 90 ) 91 92 93 typedef struct { 94 EFI_EVENT_NOTIFY GoVirtualChildEvent[MaxType]; 95 VARIABLE_STORAGE *VariableStore[MaxType]; // Instance of VariableStorage 96 VOID *VariableBase[MaxType]; // Start address of variable storage 97 UINTN LastVariableOffset[MaxType]; // The position to write new variable to (index from VariableBase) 98 VOID *Scratch; // Buffer used during reclaim 99 UINTN CommonVariableTotalSize; 100 UINTN HwErrVariableTotalSize; 101 CHAR8 *PlatformLangCodes; 102 CHAR8 *LangCodes; 103 CHAR8 *PlatformLang; 104 CHAR8 Lang[ISO_639_2_ENTRY_SIZE + 1]; 105 } VARIABLE_GLOBAL; 106 107 // 108 // Functions 109 // 110 111 EFI_STATUS 112 EFIAPI 113 VariableServiceInitialize ( 114 IN EFI_HANDLE ImageHandle, 115 IN EFI_SYSTEM_TABLE *SystemTable 116 ); 117 118 VOID 119 EFIAPI 120 VariableClassAddressChangeEvent ( 121 IN EFI_EVENT Event, 122 IN VOID *Context 123 ); 124 125 EFI_STATUS 126 EFIAPI 127 DuetGetVariable ( 128 IN CHAR16 *VariableName, 129 IN EFI_GUID *VendorGuid, 130 OUT UINT32 *Attributes OPTIONAL, 131 IN OUT UINTN *DataSize, 132 OUT VOID *Data 133 ); 134 135 EFI_STATUS 136 EFIAPI 137 GetNextVariableName ( 138 IN OUT UINTN *VariableNameSize, 139 IN OUT CHAR16 *VariableName, 140 IN OUT EFI_GUID *VendorGuid 141 ); 142 143 EFI_STATUS 144 EFIAPI 145 SetVariable ( 146 IN CHAR16 *VariableName, 147 IN EFI_GUID *VendorGuid, 148 IN UINT32 Attributes, 149 IN UINTN DataSize, 150 IN VOID *Data 151 ); 152 153 EFI_STATUS 154 EFIAPI 155 QueryVariableInfo ( 156 IN UINT32 Attributes, 157 OUT UINT64 *MaximumVariableStorageSize, 158 OUT UINT64 *RemainingVariableStorageSize, 159 OUT UINT64 *MaximumVariableSize 160 ); 161 162 #endif 163