]>
Commit | Line | Data |
---|---|---|
9071550e | 1 | /*++\r |
2 | \r | |
741a1e58 ED |
3 | Caution: This file is used for Duet platform only, do not use them in real platform.\r |
4 | All variable code, variable metadata, and variable data used by Duet platform are on \r | |
5 | disk. They can be changed by user. BIOS is not able to protoect those.\r | |
6 | Duet trusts all meta data from disk. If variable code, variable metadata and variable\r | |
7 | data is modified in inproper way, the behavior is undefined.\r | |
8 | \r | |
9 | Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
b1f700a8 | 10 | This program and the accompanying materials \r |
9071550e | 11 | are licensed and made available under the terms and conditions of the BSD License \r |
12 | which accompanies this distribution. The full text of the license may be found at \r | |
13 | http://opensource.org/licenses/bsd-license.php \r | |
14 | \r | |
15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
17 | \r | |
18 | Module Name:\r | |
19 | \r | |
20 | VariableStorage.h\r | |
21 | \r | |
22 | Abstract:\r | |
23 | \r | |
24 | handles variable store/reads with memory and file\r | |
25 | \r | |
26 | Revision History\r | |
27 | \r | |
28 | --*/\r | |
29 | #ifndef _VARIABLE_STORAGE_H_\r | |
30 | #define _VARIABLE_STORAGE_H_\r | |
31 | \r | |
32 | #define VAR_DEFAULT_VALUE (0xff)\r | |
eea53ce1 | 33 | #define VAR_DEFAULT_VALUE_16 SIGNATURE_16 (VAR_DEFAULT_VALUE, VAR_DEFAULT_VALUE)\r |
34 | #define VAR_DEFAULT_VALUE_32 SIGNATURE_32 (VAR_DEFAULT_VALUE, VAR_DEFAULT_VALUE, \\r | |
9071550e | 35 | VAR_DEFAULT_VALUE, VAR_DEFAULT_VALUE)\r |
36 | \r | |
37 | typedef struct _VARIABLE_STORAGE VARIABLE_STORAGE;\r | |
38 | \r | |
39 | EFI_STATUS\r | |
40 | FileStorageConstructor (\r | |
41 | OUT VARIABLE_STORAGE **VarStore,\r | |
42 | OUT EFI_EVENT_NOTIFY *GoVirtualEvent,\r | |
43 | IN EFI_PHYSICAL_ADDRESS NvStorageBase,\r | |
44 | IN UINTN Size,\r | |
45 | IN UINT32 VolumeId,\r | |
46 | IN CHAR16 *FilePath\r | |
47 | );\r | |
48 | \r | |
49 | EFI_STATUS\r | |
50 | MemStorageConstructor (\r | |
51 | OUT VARIABLE_STORAGE **VarStore,\r | |
52 | OUT EFI_EVENT_NOTIFY *GoVirtualEvent,\r | |
53 | IN UINTN Size\r | |
54 | );\r | |
55 | \r | |
56 | typedef\r | |
57 | EFI_STATUS\r | |
58 | (EFIAPI *ERASE_STORE) (\r | |
59 | IN VARIABLE_STORAGE *This\r | |
60 | );\r | |
61 | \r | |
62 | typedef\r | |
63 | EFI_STATUS\r | |
64 | (EFIAPI *WRITE_STORE) (\r | |
65 | IN VARIABLE_STORAGE *This,\r | |
66 | IN UINTN Offset,\r | |
67 | IN UINTN BufferSize,\r | |
68 | IN VOID *Buffer\r | |
69 | );\r | |
70 | \r | |
71 | struct _VARIABLE_STORAGE {\r | |
72 | \r | |
73 | //\r | |
74 | // Functions to access the storage\r | |
75 | //\r | |
76 | ERASE_STORE Erase;\r | |
77 | WRITE_STORE Write;\r | |
78 | };\r | |
79 | \r | |
80 | typedef struct _VS_FILE_INFO {\r | |
81 | UINT8 *FileData; // local buffer for reading acceleration\r | |
82 | \r | |
83 | EFI_DEVICE_PATH_PROTOCOL *DevicePath; // device having storage file\r | |
84 | UINT32 VolumeId;\r | |
85 | CHAR16 FilePath[256];\r | |
86 | } VS_FILE_INFO;\r | |
87 | \r | |
88 | typedef struct _VS_MEM_INFO {\r | |
89 | UINT8 *MemData;\r | |
90 | } VS_MEM_INFO;\r | |
91 | \r | |
92 | typedef struct _VS_DEV {\r | |
93 | UINT32 Signature;\r | |
94 | VARIABLE_STORAGE VarStore;\r | |
95 | UINTN Size;\r | |
96 | \r | |
97 | union {\r | |
98 | //\r | |
99 | // finally visit FileInfo.FileData or MemInfo.MemData\r | |
100 | //\r | |
101 | UINT8 *Data;\r | |
102 | \r | |
103 | VS_FILE_INFO FileInfo;\r | |
104 | VS_MEM_INFO MemInfo;\r | |
105 | } Info;\r | |
106 | \r | |
107 | } VS_DEV;\r | |
108 | \r | |
3709c4cd | 109 | #define VS_DEV_SIGNATURE SIGNATURE_32 ('$', 'V', 'S', 'D')\r |
110 | #define DEV_FROM_THIS(a) CR (a, VS_DEV, VarStore, VS_DEV_SIGNATURE)\r | |
9071550e | 111 | \r |
112 | #define VAR_DATA_PTR(a) ((a)->Info.Data)\r | |
113 | #define VAR_FILE_DEVICEPATH(a) ((a)->Info.FileInfo.DevicePath)\r | |
114 | #define VAR_FILE_VOLUMEID(a) ((a)->Info.FileInfo.VolumeId)\r | |
115 | #define VAR_FILE_FILEPATH(a) ((a)->Info.FileInfo.FilePath)\r | |
116 | \r | |
117 | \r | |
118 | #endif\r |