• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     VariableStorage.h
21 
22 Abstract:
23 
24     handles variable store/reads with memory and file
25 
26 Revision History
27 
28 --*/
29 #ifndef _VARIABLE_STORAGE_H_
30 #define _VARIABLE_STORAGE_H_
31 
32 #define VAR_DEFAULT_VALUE           (0xff)
33 #define VAR_DEFAULT_VALUE_16        SIGNATURE_16 (VAR_DEFAULT_VALUE, VAR_DEFAULT_VALUE)
34 #define VAR_DEFAULT_VALUE_32        SIGNATURE_32 (VAR_DEFAULT_VALUE, VAR_DEFAULT_VALUE, \
35                                                       VAR_DEFAULT_VALUE, VAR_DEFAULT_VALUE)
36 
37 typedef struct _VARIABLE_STORAGE VARIABLE_STORAGE;
38 
39 EFI_STATUS
40 FileStorageConstructor (
41   OUT VARIABLE_STORAGE      **VarStore,
42   OUT EFI_EVENT_NOTIFY      *GoVirtualEvent,
43   IN  EFI_PHYSICAL_ADDRESS  NvStorageBase,
44   IN  UINTN                 Size,
45   IN  UINT32                VolumeId,
46   IN  CHAR16                *FilePath
47   );
48 
49 EFI_STATUS
50 MemStorageConstructor (
51   OUT VARIABLE_STORAGE          **VarStore,
52   OUT EFI_EVENT_NOTIFY          *GoVirtualEvent,
53   IN  UINTN                     Size
54   );
55 
56 typedef
57 EFI_STATUS
58 (EFIAPI *ERASE_STORE) (
59   IN VARIABLE_STORAGE   *This
60   );
61 
62 typedef
63 EFI_STATUS
64 (EFIAPI *WRITE_STORE) (
65   IN VARIABLE_STORAGE   *This,
66   IN UINTN              Offset,
67   IN UINTN              BufferSize,
68   IN VOID               *Buffer
69   );
70 
71 struct _VARIABLE_STORAGE {
72 
73   //
74   // Functions to access the storage
75   //
76   ERASE_STORE           Erase;
77   WRITE_STORE           Write;
78 };
79 
80 typedef struct _VS_FILE_INFO {
81   UINT8                     *FileData;      // local buffer for reading acceleration
82 
83   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;    // device having storage file
84   UINT32                    VolumeId;
85   CHAR16                    FilePath[256];
86 } VS_FILE_INFO;
87 
88 typedef struct _VS_MEM_INFO {
89   UINT8                     *MemData;
90 } VS_MEM_INFO;
91 
92 typedef struct _VS_DEV {
93   UINT32             Signature;
94   VARIABLE_STORAGE   VarStore;
95   UINTN              Size;
96 
97   union {
98     //
99     // finally visit FileInfo.FileData or MemInfo.MemData
100     //
101     UINT8            *Data;
102 
103     VS_FILE_INFO     FileInfo;
104     VS_MEM_INFO      MemInfo;
105   } Info;
106 
107 } VS_DEV;
108 
109 #define VS_DEV_SIGNATURE        SIGNATURE_32 ('$', 'V', 'S', 'D')
110 #define DEV_FROM_THIS(a)        CR (a, VS_DEV, VarStore, VS_DEV_SIGNATURE)
111 
112 #define VAR_DATA_PTR(a)         ((a)->Info.Data)
113 #define VAR_FILE_DEVICEPATH(a)  ((a)->Info.FileInfo.DevicePath)
114 #define VAR_FILE_VOLUMEID(a)    ((a)->Info.FileInfo.VolumeId)
115 #define VAR_FILE_FILEPATH(a)    ((a)->Info.FileInfo.FilePath)
116 
117 
118 #endif
119