]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/FileExplorerLib/FileExplorer.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Library / FileExplorerLib / FileExplorer.h
1 /** @file
2 File explorer lib.
3
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6 **/
7
8 #ifndef _FILE_EXPLORER_H_
9 #define _FILE_EXPLORER_H_
10
11 #include <PiDxe.h>
12 #include <Guid/FileSystemVolumeLabelInfo.h>
13 #include <Guid/FileInfo.h>
14 #include <Guid/MdeModuleHii.h>
15
16 #include <Protocol/HiiConfigAccess.h>
17 #include <Protocol/DevicePath.h>
18 #include <Protocol/SimpleFileSystem.h>
19 #include <Protocol/DevicePathToText.h>
20 #include <Protocol/FormBrowser2.h>
21
22 #include <Library/DebugLib.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/UefiBootServicesTableLib.h>
25 #include <Library/MemoryAllocationLib.h>
26 #include <Library/BaseLib.h>
27 #include <Library/UefiLib.h>
28 #include <Library/DevicePathLib.h>
29 #include <Library/FileExplorerLib.h>
30 #include <Library/HiiLib.h>
31 #include <Library/PrintLib.h>
32
33 #include "FormGuid.h"
34
35 #define FILE_EXPLORER_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('f', 'e', 'c', 'k')
36
37 #pragma pack(1)
38
39 ///
40 /// HII specific Vendor Device Path definition.
41 ///
42 typedef struct {
43 VENDOR_DEVICE_PATH VendorDevicePath;
44 EFI_DEVICE_PATH_PROTOCOL End;
45 } HII_VENDOR_DEVICE_PATH;
46
47 #pragma pack()
48
49 typedef struct {
50 EFI_HANDLE DeviceHandle;
51 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
52 EFI_FILE_HANDLE FileHandle;
53 UINT16 *FileName;
54
55 BOOLEAN IsRoot;
56 BOOLEAN IsDir;
57 } FILE_CONTEXT;
58
59 typedef struct {
60 UINTN Signature;
61 LIST_ENTRY Link;
62 UINT16 *DisplayString;
63 UINT16 *HelpString;
64 EFI_STRING_ID DisplayStringToken;
65 EFI_STRING_ID HelpStringToken;
66 VOID *VariableContext;
67 } MENU_ENTRY;
68
69 typedef struct {
70 UINTN Signature;
71 LIST_ENTRY Head;
72 UINTN MenuNumber;
73 BOOLEAN Used;
74 } MENU_OPTION;
75
76 typedef struct {
77 //
78 // Shared callback data.
79 //
80 UINTN Signature;
81
82 //
83 // File explorer formset callback data.
84 //
85 EFI_HII_HANDLE FeHiiHandle;
86 EFI_HANDLE FeDriverHandle;
87 EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess;
88 EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
89 MENU_OPTION *FsOptionMenu;
90 CHAR16 *FileType;
91 CHOOSE_HANDLER ChooseHandler;
92 EFI_DEVICE_PATH_PROTOCOL *RetDevicePath;
93 } FILE_EXPLORER_CALLBACK_DATA;
94
95 #define FILE_EXPLORER_PRIVATE_FROM_THIS(a) CR (a, FILE_EXPLORER_CALLBACK_DATA, FeConfigAccess, FILE_EXPLORER_CALLBACK_DATA_SIGNATURE)
96
97 extern UINT8 FileExplorerVfrBin[];
98
99 #define MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
100 #define MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
101
102 ///
103 /// Define the maximum characters that will be accepted.
104 ///
105 #define MAX_CHAR 480
106 #define FILE_OPTION_OFFSET 0x8000
107 #define FILE_OPTION_MASK 0x7FFF
108 #define QUESTION_ID_UPDATE_STEP 200
109 #define MAX_FILE_NAME_LEN 20
110 #define MAX_FOLDER_NAME_LEN 20
111 #define NEW_FILE_QUESTION_ID_BASE 0x5000;
112 #define NEW_FOLDER_QUESTION_ID_BASE 0x6000;
113
114 /**
115 This function processes the results of changes in configuration.
116 When user select a interactive opcode, this callback will be triggered.
117 Based on the Question(QuestionId) that triggers the callback, the corresponding
118 actions is performed. It handles:
119
120 1) the addition of boot option.
121 2) the addition of driver option.
122 3) exit from file browser
123 4) update of file content if a dir is selected.
124 5) boot the file if a file is selected in "boot from file"
125
126
127 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
128 @param Action Specifies the type of action taken by the browser.
129 @param QuestionId A unique value which is sent to the original exporting driver
130 so that it can identify the type of data to expect.
131 @param Type The type of value for the question.
132 @param Value A pointer to the data being sent to the original exporting driver.
133 @param ActionRequest On return, points to the action requested by the callback function.
134
135 @retval EFI_SUCCESS The callback successfully handled the action.
136 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
137 @retval EFI_DEVICE_ERROR The variable could not be saved.
138 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
139
140 **/
141 EFI_STATUS
142 EFIAPI
143 LibCallback (
144 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
145 IN EFI_BROWSER_ACTION Action,
146 IN EFI_QUESTION_ID QuestionId,
147 IN UINT8 Type,
148 IN EFI_IFR_TYPE_VALUE *Value,
149 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
150 );
151
152 /**
153 This function allows a caller to extract the current configuration for one
154 or more named elements from the target driver.
155
156
157 @param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
158 @param Request - A null-terminated Unicode string in <ConfigRequest> format.
159 @param Progress - On return, points to a character in the Request string.
160 Points to the string's null terminator if request was successful.
161 Points to the most recent '&' before the first failing name/value
162 pair (or the beginning of the string if the failure is in the
163 first name/value pair) if the request was not successful.
164 @param Results - A null-terminated Unicode string in <ConfigAltResp> format which
165 has all values filled in for the names in the Request string.
166 String to be allocated by the called function.
167
168 @retval EFI_SUCCESS The Results is filled with the requested values.
169 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
170 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
171 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
172
173 **/
174 EFI_STATUS
175 EFIAPI
176 LibExtractConfig (
177 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
178 IN CONST EFI_STRING Request,
179 OUT EFI_STRING *Progress,
180 OUT EFI_STRING *Results
181 );
182
183 /**
184 This function processes the results of changes in configuration.
185
186
187 @param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
188 @param Configuration - A null-terminated Unicode string in <ConfigResp> format.
189 @param Progress - A pointer to a string filled in with the offset of the most
190 recent '&' before the first failing name/value pair (or the
191 beginning of the string if the failure is in the first
192 name/value pair) or the terminating NULL if all was successful.
193
194 @retval EFI_SUCCESS The Results is processed successfully.
195 @retval EFI_INVALID_PARAMETER Configuration is NULL.
196 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
197
198 **/
199 EFI_STATUS
200 EFIAPI
201 LibRouteConfig (
202 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
203 IN CONST EFI_STRING Configuration,
204 OUT EFI_STRING *Progress
205 );
206
207 /**
208 Update the file explower page with the refershed file system.
209
210 @param KeyValue Key value to identify the type of data to expect.
211
212 @retval EFI_SUCCESS Update the file explorer form success.
213 @retval other errors Error occur when parse one directory.
214
215 **/
216 EFI_STATUS
217 LibUpdateFileExplorer (
218 IN UINT16 KeyValue
219 );
220
221 /**
222 Get the device path info saved in the menu structure.
223
224 @param KeyValue Key value to identify the type of data to expect.
225
226 **/
227 VOID
228 LibGetDevicePath (
229 IN UINT16 KeyValue
230 );
231
232 #endif