]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/SetupBrowserDxe/Setup.h
Update Browser to provide the customization possibilities.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Setup.h
CommitLineData
7936fb6a 1/** @file\r
d66e6c16 2Private MACRO, structure and function definitions for Setup Browser module.\r
7936fb6a 3\r
80a047f0 4Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials\r
7936fb6a 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13\r
14**/\r
15\r
16#ifndef _SETUP_H_\r
17#define _SETUP_H_\r
18\r
19\r
39099938 20#include <PiDxe.h>\r
7936fb6a 21\r
7936fb6a 22#include <Protocol/SimpleTextOut.h>\r
23#include <Protocol/SimpleTextIn.h>\r
24#include <Protocol/FormBrowser2.h>\r
7c6c064c
ED
25#include <Protocol/FormBrowserEx2.h>\r
26#include <Protocol/DisplayProtocol.h>\r
7936fb6a 27#include <Protocol/DevicePath.h>\r
28#include <Protocol/UnicodeCollation.h>\r
29#include <Protocol/HiiConfigAccess.h>\r
30#include <Protocol/HiiConfigRouting.h>\r
31#include <Protocol/HiiDatabase.h>\r
32#include <Protocol/HiiString.h>\r
cbf73e50 33#include <Protocol/UserManager.h>\r
80a047f0 34#include <Protocol/DevicePathFromText.h>\r
7936fb6a 35\r
5c526736 36#include <Guid/MdeModuleHii.h>\r
0a1147ed 37#include <Guid/HiiPlatformSetupFormset.h>\r
2573712e 38#include <Guid/HiiFormMapMethodGuid.h>\r
7936fb6a 39\r
7936fb6a 40#include <Library/PrintLib.h>\r
41#include <Library/DebugLib.h>\r
42#include <Library/BaseMemoryLib.h>\r
43#include <Library/UefiRuntimeServicesTableLib.h>\r
44#include <Library/UefiDriverEntryPoint.h>\r
45#include <Library/UefiBootServicesTableLib.h>\r
46#include <Library/BaseLib.h>\r
47#include <Library/MemoryAllocationLib.h>\r
7936fb6a 48#include <Library/HiiLib.h>\r
f511d656 49#include <Library/PcdLib.h>\r
cb7d01c0 50#include <Library/DevicePathLib.h>\r
7c6c064c 51#include <Library/UefiLib.h>\r
7936fb6a 52\r
7936fb6a 53\r
54//\r
55// This is the generated header file which includes whatever needs to be exported (strings + IFR)\r
56//\r
57\r
7c6c064c
ED
58#define UI_ACTION_NONE 0\r
59#define UI_ACTION_REFRESH_FORM 1\r
60#define UI_ACTION_REFRESH_FORMSET 2\r
61#define UI_ACTION_EXIT 3\r
7936fb6a 62\r
63//\r
7936fb6a 64//\r
65// Time definitions\r
66//\r
67#define ONE_SECOND 10000000\r
68\r
7936fb6a 69// Incremental string lenght of ConfigRequest\r
70//\r
71#define CONFIG_REQUEST_STRING_INCREMENTAL 1024\r
72\r
7936fb6a 73//\r
74// Incremental size of stack for expression\r
75//\r
76#define EXPRESSION_STACK_SIZE_INCREMENT 0x100\r
77\r
0269d14b 78#define EFI_IFR_SPECIFICATION_VERSION (UINT16) (((EFI_SYSTEM_TABLE_REVISION >> 16) << 8) | (((EFI_SYSTEM_TABLE_REVISION & 0xFFFF) / 10) << 4) | ((EFI_SYSTEM_TABLE_REVISION & 0xFFFF) % 10))\r
7936fb6a 79\r
7936fb6a 80\r
f3f2e05d 81#define SETUP_DRIVER_SIGNATURE SIGNATURE_32 ('F', 'B', 'D', 'V')\r
7936fb6a 82typedef struct {\r
83 UINT32 Signature;\r
84\r
85 EFI_HANDLE Handle;\r
86\r
87 //\r
88 // Produced protocol\r
89 //\r
7c6c064c
ED
90 EFI_FORM_BROWSER2_PROTOCOL FormBrowser2;\r
91 EFI_FORM_BROWSER_EXTENSION_PROTOCOL FormBrowserEx;\r
7936fb6a 92\r
7c6c064c 93 EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL FormBrowserEx2;\r
7936fb6a 94\r
7c6c064c 95} SETUP_DRIVER_PRIVATE_DATA;\r
25361615 96\r
7936fb6a 97//\r
98// IFR relative definition\r
99//\r
100#define EFI_HII_EXPRESSION_INCONSISTENT_IF 0\r
101#define EFI_HII_EXPRESSION_NO_SUBMIT_IF 1\r
102#define EFI_HII_EXPRESSION_GRAY_OUT_IF 2\r
103#define EFI_HII_EXPRESSION_SUPPRESS_IF 3\r
104#define EFI_HII_EXPRESSION_DISABLE_IF 4\r
105#define EFI_HII_EXPRESSION_VALUE 5\r
106#define EFI_HII_EXPRESSION_RULE 6\r
2573712e
LG
107#define EFI_HII_EXPRESSION_READ 7\r
108#define EFI_HII_EXPRESSION_WRITE 8\r
7936fb6a 109\r
110#define EFI_HII_VARSTORE_BUFFER 0\r
111#define EFI_HII_VARSTORE_NAME_VALUE 1\r
112#define EFI_HII_VARSTORE_EFI_VARIABLE 2\r
cce6230f 113#define EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER 3\r
7936fb6a 114\r
115#define FORM_INCONSISTENT_VALIDATION 0\r
116#define FORM_NO_SUBMIT_VALIDATION 1\r
117\r
f3f2e05d 118#define NAME_VALUE_NODE_SIGNATURE SIGNATURE_32 ('N', 'V', 'S', 'T')\r
7936fb6a 119\r
120typedef struct {\r
121 UINTN Signature;\r
122 LIST_ENTRY Link;\r
123 CHAR16 *Name;\r
124 CHAR16 *Value;\r
125 CHAR16 *EditValue;\r
126} NAME_VALUE_NODE;\r
127\r
128#define NAME_VALUE_NODE_FROM_LINK(a) CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)\r
129\r
94f3aae7 130#define BROWSER_STORAGE_SIGNATURE SIGNATURE_32 ('B', 'S', 'T', 'G')\r
7936fb6a 131\r
132typedef struct {\r
133 UINTN Signature;\r
134 LIST_ENTRY Link;\r
135\r
136 UINT8 Type; // Storage type\r
137\r
7936fb6a 138 EFI_GUID Guid;\r
139\r
140 CHAR16 *Name; // For EFI_IFR_VARSTORE\r
141 UINT16 Size;\r
142 UINT8 *Buffer;\r
143 UINT8 *EditBuffer; // Edit copy for Buffer Storage\r
144\r
145 LIST_ENTRY NameValueListHead; // List of NAME_VALUE_NODE\r
146\r
147 UINT32 Attributes; // For EFI_IFR_VARSTORE_EFI: EFI Variable attribute\r
148\r
149 CHAR16 *ConfigHdr; // <ConfigHdr>\r
efffd9c1
ED
150 CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>\r
151 // <RequestElement> includes all fields which is used by current form sets.\r
152 UINTN SpareStrLen; // Spare length of ConfigRequest string buffer\r
94f3aae7
ED
153 UINT8 ReferenceCount; // How many form set storage refrence this storage.\r
154} BROWSER_STORAGE;\r
155\r
156#define BROWSER_STORAGE_FROM_LINK(a) CR (a, BROWSER_STORAGE, Link, BROWSER_STORAGE_SIGNATURE)\r
157\r
158#define FORMSET_STORAGE_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'G')\r
159\r
160typedef struct {\r
161 UINTN Signature;\r
162 LIST_ENTRY Link;\r
163\r
164 UINT16 VarStoreId;\r
165\r
166 BROWSER_STORAGE *BrowserStorage;\r
167\r
7936fb6a 168 CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>\r
7c6c064c 169 CHAR16 *ConfigElements;// Elements need to load initial data.\r
7936fb6a 170 UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>\r
171 UINTN SpareStrLen; // Spare length of ConfigRequest string buffer\r
172} FORMSET_STORAGE;\r
173\r
174#define FORMSET_STORAGE_FROM_LINK(a) CR (a, FORMSET_STORAGE, Link, FORMSET_STORAGE_SIGNATURE)\r
175\r
2573712e
LG
176typedef union {\r
177 EFI_STRING_ID VarName;\r
178 UINT16 VarOffset;\r
179} VAR_STORE_INFO;\r
180\r
f3f2e05d 181#define EXPRESSION_OPCODE_SIGNATURE SIGNATURE_32 ('E', 'X', 'O', 'P')\r
7936fb6a 182\r
183typedef struct {\r
184 UINTN Signature;\r
185 LIST_ENTRY Link;\r
186\r
187 UINT8 Operand;\r
188\r
189 UINT8 Format; // For EFI_IFR_TO_STRING, EFI_IFR_FIND\r
190 UINT8 Flags; // For EFI_IFR_SPAN\r
191 UINT8 RuleId; // For EFI_IFR_RULE_REF\r
192\r
193 EFI_HII_VALUE Value; // For EFI_IFR_EQ_ID_VAL, EFI_IFR_UINT64, EFI_IFR_UINT32, EFI_IFR_UINT16, EFI_IFR_UINT8, EFI_IFR_STRING_REF1\r
194\r
2654f642 195 EFI_QUESTION_ID QuestionId; // For EFI_IFR_EQ_ID_ID, EFI_IFR_EQ_ID_VAL_LIST, EFI_IFR_QUESTION_REF1\r
7936fb6a 196 EFI_QUESTION_ID QuestionId2;\r
197\r
2654f642 198 UINT16 ListLength; // For EFI_IFR_EQ_ID_VAL_LIST\r
7936fb6a 199 UINT16 *ValueList;\r
200\r
201 EFI_STRING_ID DevicePath; // For EFI_IFR_QUESTION_REF3_2, EFI_IFR_QUESTION_REF3_3\r
202 EFI_GUID Guid;\r
2573712e 203\r
94f3aae7 204 BROWSER_STORAGE *VarStorage; // For EFI_IFR_SET, EFI_IFR_GET\r
2573712e
LG
205 VAR_STORE_INFO VarStoreInfo;// For EFI_IFR_SET, EFI_IFR_GET\r
206 UINT8 ValueType; // For EFI_IFR_SET, EFI_IFR_GET\r
207 UINT8 ValueWidth; // For EFI_IFR_SET, EFI_IFR_GET\r
208 CHAR16 *ValueName; // For EFI_IFR_SET, EFI_IFR_GET\r
209 LIST_ENTRY MapExpressionList; // nested expressions inside of Map opcode.\r
7936fb6a 210} EXPRESSION_OPCODE;\r
211\r
212#define EXPRESSION_OPCODE_FROM_LINK(a) CR (a, EXPRESSION_OPCODE, Link, EXPRESSION_OPCODE_SIGNATURE)\r
213\r
f3f2e05d 214#define FORM_EXPRESSION_SIGNATURE SIGNATURE_32 ('F', 'E', 'X', 'P')\r
7936fb6a 215\r
216typedef struct {\r
217 UINTN Signature;\r
218 LIST_ENTRY Link;\r
219\r
220 UINT8 Type; // Type for this expression\r
221\r
222 UINT8 RuleId; // For EFI_IFR_RULE only\r
223 EFI_STRING_ID Error; // For EFI_IFR_NO_SUBMIT_IF, EFI_IFR_INCONSISTENT_IF only\r
224\r
225 EFI_HII_VALUE Result; // Expression evaluation result\r
226\r
227 LIST_ENTRY OpCodeListHead; // OpCodes consist of this expression (EXPRESSION_OPCODE)\r
228} FORM_EXPRESSION;\r
229\r
230#define FORM_EXPRESSION_FROM_LINK(a) CR (a, FORM_EXPRESSION, Link, FORM_EXPRESSION_SIGNATURE)\r
231\r
31585af4
ED
232#define FORM_EXPRESSION_LIST_SIGNATURE SIGNATURE_32 ('F', 'E', 'X', 'R')\r
233\r
234typedef struct {\r
235 UINTN Signature;\r
236 UINTN Count;\r
237 FORM_EXPRESSION *Expression[1]; // Array[Count] of expressions\r
238} FORM_EXPRESSION_LIST;\r
239\r
f3f2e05d 240#define QUESTION_DEFAULT_SIGNATURE SIGNATURE_32 ('Q', 'D', 'F', 'T')\r
7936fb6a 241\r
242typedef struct {\r
243 UINTN Signature;\r
244 LIST_ENTRY Link;\r
245\r
246 UINT16 DefaultId;\r
247 EFI_HII_VALUE Value; // Default value\r
248\r
249 FORM_EXPRESSION *ValueExpression; // Not-NULL indicates default value is provided by EFI_IFR_VALUE\r
250} QUESTION_DEFAULT;\r
251\r
252#define QUESTION_DEFAULT_FROM_LINK(a) CR (a, QUESTION_DEFAULT, Link, QUESTION_DEFAULT_SIGNATURE)\r
253\r
f3f2e05d 254#define QUESTION_OPTION_SIGNATURE SIGNATURE_32 ('Q', 'O', 'P', 'T')\r
7936fb6a 255\r
256typedef struct {\r
31585af4
ED
257 UINTN Signature;\r
258 LIST_ENTRY Link;\r
7c6c064c
ED
259 \r
260 EFI_IFR_ONE_OF_OPTION *OpCode; // OneOfOption Data\r
7936fb6a 261\r
31585af4
ED
262 EFI_STRING_ID Text;\r
263 UINT8 Flags;\r
264 EFI_HII_VALUE Value;\r
265 EFI_IMAGE_ID ImageId;\r
7936fb6a 266\r
31585af4 267 FORM_EXPRESSION_LIST *SuppressExpression; // Non-NULL indicates nested inside of SuppressIf\r
7936fb6a 268} QUESTION_OPTION;\r
269\r
270#define QUESTION_OPTION_FROM_LINK(a) CR (a, QUESTION_OPTION, Link, QUESTION_OPTION_SIGNATURE)\r
271\r
31585af4
ED
272typedef enum {\r
273 ExpressFalse = 0,\r
274 ExpressGrayOut, \r
275 ExpressSuppress,\r
276 ExpressDisable\r
277} EXPRESS_RESULT;\r
278\r
279typedef enum {\r
280 ExpressNone = 0,\r
281 ExpressForm, \r
282 ExpressStatement,\r
283 ExpressOption\r
284} EXPRESS_LEVEL;\r
285\r
f3f2e05d 286#define FORM_BROWSER_STATEMENT_SIGNATURE SIGNATURE_32 ('F', 'S', 'T', 'A')\r
1ccdbf2a 287\r
7936fb6a 288typedef struct {\r
289 UINTN Signature;\r
290 LIST_ENTRY Link;\r
291\r
292 UINT8 Operand; // The operand (first byte) of this Statement or Question\r
7c6c064c 293 EFI_IFR_OP_HEADER *OpCode;\r
7936fb6a 294\r
295 //\r
296 // Statement Header\r
297 //\r
298 EFI_STRING_ID Prompt;\r
299 EFI_STRING_ID Help;\r
300 EFI_STRING_ID TextTwo; // For EFI_IFR_TEXT\r
301\r
7c6c064c
ED
302 //\r
303 // Fake Question Id, used for statement not has true QuestionId.\r
304 //\r
305 EFI_QUESTION_ID FakeQuestionId;\r
306\r
7936fb6a 307 //\r
308 // Question Header\r
309 //\r
310 EFI_QUESTION_ID QuestionId; // The value of zero is reserved\r
311 EFI_VARSTORE_ID VarStoreId; // A value of zero indicates no variable storage\r
94f3aae7 312 BROWSER_STORAGE *Storage;\r
1ccdbf2a 313 VAR_STORE_INFO VarStoreInfo;\r
7936fb6a 314 UINT16 StorageWidth;\r
315 UINT8 QuestionFlags;\r
316 CHAR16 *VariableName; // Name/Value or EFI Variable name\r
317 CHAR16 *BlockName; // Buffer storage block name: "OFFSET=...WIDTH=..."\r
318\r
319 EFI_HII_VALUE HiiValue; // Edit copy for checkbox, numberic, oneof\r
320 UINT8 *BufferValue; // Edit copy for string, password, orderedlist\r
d02847d3 321 UINT8 ValueType; // Data type for orderedlist value array\r
7936fb6a 322\r
323 //\r
324 // OpCode specific members\r
325 //\r
326 UINT8 Flags; // for EFI_IFR_CHECKBOX, EFI_IFR_DATE, EFI_IFR_NUMERIC, EFI_IFR_ONE_OF,\r
327 // EFI_IFR_ORDERED_LIST, EFI_IFR_STRING,EFI_IFR_SUBTITLE,EFI_IFR_TIME, EFI_IFR_BANNER\r
328 UINT8 MaxContainers; // for EFI_IFR_ORDERED_LIST\r
329\r
330 UINT16 BannerLineNumber; // for EFI_IFR_BANNER, 1-based line number\r
331 EFI_STRING_ID QuestionConfig; // for EFI_IFR_ACTION, if 0 then no configuration string will be processed\r
332\r
333 UINT64 Minimum; // for EFI_IFR_ONE_OF/EFI_IFR_NUMERIC, it's Min/Max value\r
334 UINT64 Maximum; // for EFI_IFR_STRING/EFI_IFR_PASSWORD, it's Min/Max length\r
335 UINT64 Step;\r
336\r
337 EFI_DEFAULT_ID DefaultId; // for EFI_IFR_RESET_BUTTON\r
211cc6e5 338 EFI_GUID RefreshGuid; // for EFI_IFR_REFRESH_ID\r
f67c4382 339 BOOLEAN Locked; // Whether this statement is locked.\r
7c6c064c 340 BOOLEAN ValueChanged; // Whether this statement's value is changed.\r
7936fb6a 341 //\r
342 // Get from IFR parsing\r
343 //\r
344 FORM_EXPRESSION *ValueExpression; // nested EFI_IFR_VALUE, provide Question value and indicate Question is ReadOnly\r
345 LIST_ENTRY DefaultListHead; // nested EFI_IFR_DEFAULT list (QUESTION_DEFAULT), provide default values\r
346 LIST_ENTRY OptionListHead; // nested EFI_IFR_ONE_OF_OPTION list (QUESTION_OPTION)\r
347\r
348 EFI_IMAGE_ID ImageId; // nested EFI_IFR_IMAGE\r
349 UINT8 RefreshInterval; // nested EFI_IFR_REFRESH, refresh interval(in seconds) for Question value, 0 means no refresh\r
350 BOOLEAN InSubtitle; // nesting inside of EFI_IFR_SUBTITLE\r
351\r
352 LIST_ENTRY InconsistentListHead;// nested inconsistent expression list (FORM_EXPRESSION)\r
353 LIST_ENTRY NoSubmitListHead; // nested nosubmit expression list (FORM_EXPRESSION)\r
31585af4 354 FORM_EXPRESSION_LIST *Expression; // nesting inside of GrayOutIf/DisableIf/SuppressIf\r
7936fb6a 355\r
2573712e
LG
356 FORM_EXPRESSION *ReadExpression; // nested EFI_IFR_READ, provide this question value by read expression.\r
357 FORM_EXPRESSION *WriteExpression; // nested EFI_IFR_WRITE, evaluate write expression after this question value is set.\r
7936fb6a 358} FORM_BROWSER_STATEMENT;\r
359\r
360#define FORM_BROWSER_STATEMENT_FROM_LINK(a) CR (a, FORM_BROWSER_STATEMENT, Link, FORM_BROWSER_STATEMENT_SIGNATURE)\r
361\r
b18e7050
ED
362#define FORM_BROWSER_CONFIG_REQUEST_SIGNATURE SIGNATURE_32 ('F', 'C', 'R', 'S')\r
363typedef struct {\r
364 UINTN Signature;\r
365 LIST_ENTRY Link;\r
366\r
367 CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>\r
368 UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest> \r
369 UINTN SpareStrLen;\r
370\r
94f3aae7 371 BROWSER_STORAGE *Storage;\r
b18e7050
ED
372} FORM_BROWSER_CONFIG_REQUEST;\r
373#define FORM_BROWSER_CONFIG_REQUEST_FROM_LINK(a) CR (a, FORM_BROWSER_CONFIG_REQUEST, Link, FORM_BROWSER_CONFIG_REQUEST_SIGNATURE)\r
374\r
f3f2e05d 375#define FORM_BROWSER_FORM_SIGNATURE SIGNATURE_32 ('F', 'F', 'R', 'M')\r
2573712e 376#define STANDARD_MAP_FORM_TYPE 0x01\r
7936fb6a 377\r
378typedef struct {\r
31585af4
ED
379 UINTN Signature;\r
380 LIST_ENTRY Link;\r
7936fb6a 381\r
31585af4
ED
382 UINT16 FormId; // FormId of normal form or formmap form.\r
383 EFI_STRING_ID FormTitle; // FormTile of normal form, or FormMapMethod title of formmap form.\r
384 UINT16 FormType; // Specific form type for the different form.\r
7936fb6a 385\r
31585af4 386 EFI_IMAGE_ID ImageId;\r
7936fb6a 387\r
31585af4
ED
388 BOOLEAN ModalForm; // Whether this is a modal form.\r
389 BOOLEAN Locked; // Whether this form is locked.\r
b00964a9 390\r
31585af4
ED
391 LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)\r
392 LIST_ENTRY StatementListHead; // List of Statements and Questions (FORM_BROWSER_STATEMENT)\r
393 LIST_ENTRY ConfigRequestHead; // List of configreques for all storage.\r
394 FORM_EXPRESSION_LIST *SuppressExpression; // nesting inside of SuppressIf\r
7936fb6a 395} FORM_BROWSER_FORM;\r
396\r
397#define FORM_BROWSER_FORM_FROM_LINK(a) CR (a, FORM_BROWSER_FORM, Link, FORM_BROWSER_FORM_SIGNATURE)\r
398\r
f3f2e05d 399#define FORMSET_DEFAULTSTORE_SIGNATURE SIGNATURE_32 ('F', 'D', 'F', 'S')\r
7936fb6a 400\r
401typedef struct {\r
402 UINTN Signature;\r
403 LIST_ENTRY Link;\r
404\r
405 UINT16 DefaultId;\r
406 EFI_STRING_ID DefaultName;\r
407} FORMSET_DEFAULTSTORE;\r
408\r
409#define FORMSET_DEFAULTSTORE_FROM_LINK(a) CR (a, FORMSET_DEFAULTSTORE, Link, FORMSET_DEFAULTSTORE_SIGNATURE)\r
410\r
48a9d5f7
LG
411#define FORM_BROWSER_FORMSET_SIGNATURE SIGNATURE_32 ('F', 'B', 'F', 'S')\r
412\r
7936fb6a 413typedef struct {\r
48a9d5f7
LG
414 UINTN Signature;\r
415 LIST_ENTRY Link;\r
416 EFI_HII_HANDLE HiiHandle; // unique id for formset.\r
7936fb6a 417 EFI_HANDLE DriverHandle;\r
418 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
419 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
420\r
421 UINTN IfrBinaryLength;\r
422 UINT8 *IfrBinaryData;\r
423\r
7c6c064c 424 BOOLEAN QuestionInited; // Have finished question initilization?\r
7936fb6a 425 EFI_GUID Guid;\r
426 EFI_STRING_ID FormSetTitle;\r
427 EFI_STRING_ID Help;\r
0a1147ed
LG
428 UINT8 NumberOfClassGuid;\r
429 EFI_GUID ClassGuid[3]; // Up to three ClassGuid\r
430 UINT16 Class; // Tiano extended Class code\r
431 UINT16 SubClass; // Tiano extended Subclass code\r
7936fb6a 432 EFI_IMAGE_ID ImageId;\r
433\r
434 FORM_BROWSER_STATEMENT *StatementBuffer; // Buffer for all Statements and Questions\r
435 EXPRESSION_OPCODE *ExpressionBuffer; // Buffer for all Expression OpCode\r
436\r
7c6c064c 437 LIST_ENTRY StatementListOSF; // Statement list out side of the form.\r
7936fb6a 438 LIST_ENTRY StorageListHead; // Storage list (FORMSET_STORAGE)\r
439 LIST_ENTRY DefaultStoreListHead; // DefaultStore list (FORMSET_DEFAULTSTORE)\r
440 LIST_ENTRY FormListHead; // Form list (FORM_BROWSER_FORM)\r
0c66bc76 441 LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)\r
7936fb6a 442} FORM_BROWSER_FORMSET;\r
25361615 443#define FORM_BROWSER_FORMSET_FROM_LINK(a) CR (a, FORM_BROWSER_FORMSET, Link, FORM_BROWSER_FORMSET_SIGNATURE)\r
b9feb4bd 444\r
7c6c064c
ED
445typedef struct {\r
446 LIST_ENTRY Link;\r
447 EFI_EVENT RefreshEvent;\r
448} FORM_BROWSER_REFRESH_EVENT_NODE;\r
449\r
450#define FORM_BROWSER_REFRESH_EVENT_FROM_LINK(a) BASE_CR (a, FORM_BROWSER_REFRESH_EVENT_NODE, Link)\r
451\r
25361615 452#define BROWSER_CONTEXT_SIGNATURE SIGNATURE_32 ('B', 'C', 'T', 'X')\r
ce6d12cc 453\r
454typedef struct {\r
25361615
ED
455 UINTN Signature;\r
456 LIST_ENTRY Link;\r
ce6d12cc 457\r
b9feb4bd 458 //\r
25361615 459 // Globals defined in Setup.c\r
b9feb4bd 460 //\r
7c6c064c
ED
461 BOOLEAN ResetRequired;\r
462 BOOLEAN ExitRequired;\r
463 EFI_HII_HANDLE HiiHandle;\r
7936fb6a 464\r
7c6c064c 465 LIST_ENTRY FormHistoryList;\r
25361615 466} BROWSER_CONTEXT;\r
b9feb4bd 467\r
25361615 468#define BROWSER_CONTEXT_FROM_LINK(a) CR (a, BROWSER_CONTEXT, Link, BROWSER_CONTEXT_SIGNATURE)\r
b9feb4bd 469\r
48a9d5f7 470typedef struct {\r
7c6c064c 471 EFI_HII_HANDLE Handle;\r
48a9d5f7 472\r
7c6c064c
ED
473 //\r
474 // Target formset/form/Question information\r
475 //\r
476 EFI_GUID FormSetGuid;\r
477 UINT16 FormId;\r
478 UINT16 QuestionId;\r
479 UINTN Sequence; // used for time/date only.\r
480\r
481 UINTN TopRow;\r
482 UINTN BottomRow;\r
483 UINTN PromptCol;\r
484 UINTN OptionCol;\r
485 UINTN CurrentRow;\r
486\r
487 //\r
488 // Ation for Browser to taken:\r
489 // UI_ACTION_NONE - navigation inside a form\r
490 // UI_ACTION_REFRESH_FORM - re-evaluate expressions and repaint form\r
491 // UI_ACTION_REFRESH_FORMSET - re-parse formset IFR binary\r
492 //\r
493 UINTN Action;\r
494\r
495 //\r
496 // Current selected fomset/form/Question\r
497 //\r
498 FORM_BROWSER_FORMSET *FormSet;\r
499 FORM_BROWSER_FORM *Form;\r
500 FORM_BROWSER_STATEMENT *Statement;\r
501\r
502 //\r
503 // Whether the Form is editable\r
504 //\r
505 BOOLEAN FormEditable;\r
506\r
507 FORM_ENTRY_INFO *CurrentMenu;\r
508} UI_MENU_SELECTION;\r
48a9d5f7 509\r
09cdd7d2
ED
510//\r
511// Scope for get defaut value. It may be GetDefaultForNoStorage, GetDefaultForStorage or GetDefaultForAll.\r
512//\r
513typedef enum {\r
514 GetDefaultForNoStorage, // Get default value for question which not has storage.\r
515 GetDefaultForStorage, // Get default value for question which has storage.\r
516 GetDefaultForAll, // Get default value for all questions.\r
517 GetDefaultForMax // Invalid value.\r
518} BROWSER_GET_DEFAULT_VALUE;\r
519\r
816a7110
ED
520//\r
521// Get/set question value from/to.\r
522//\r
523typedef enum {\r
524 GetSetValueWithEditBuffer, // Get/Set question value from/to editbuffer in the storage.\r
525 GetSetValueWithBuffer, // Get/Set question value from/to buffer in the storage.\r
526 GetSetValueWithHiiDriver, // Get/Set question value from/to hii driver.\r
527 GetSetValueWithMax // Invalid value.\r
528} GET_SET_QUESTION_VALUE_WITH;\r
529\r
7936fb6a 530extern EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;\r
7936fb6a 531extern EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRouting;\r
80a047f0 532extern EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mPathFromText;\r
7c6c064c 533extern EDKII_FORM_DISPLAY_ENGINE_PROTOCOL *mFormDisplay;\r
7936fb6a 534\r
7936fb6a 535extern BOOLEAN gResetRequired;\r
7c6c064c 536extern BOOLEAN gExitRequired;\r
7936fb6a 537\r
25361615 538extern FORM_BROWSER_FORMSET *gOldFormSet;\r
48a9d5f7
LG
539extern LIST_ENTRY gBrowserFormSetList;\r
540extern LIST_ENTRY gBrowserHotKeyList;\r
541extern BROWSER_SETTING_SCOPE gBrowserSettingScope;\r
542extern EXIT_HANDLER ExitHandlerFunction;\r
7c6c064c 543extern EFI_HII_HANDLE mCurrentHiiHandle;\r
7936fb6a 544//\r
545// Browser Global Strings\r
546//\r
7936fb6a 547extern CHAR16 *gEmptyString;\r
7936fb6a 548\r
549extern EFI_GUID gZeroGuid;\r
7936fb6a 550\r
7c6c064c
ED
551extern UI_MENU_SELECTION *gCurrentSelection;\r
552\r
7936fb6a 553//\r
554// Global Procedure Defines\r
555//\r
7c6c064c 556#include "Expression.h"\r
7936fb6a 557\r
558/**\r
559 Initialize the HII String Token to the correct values.\r
560\r
561**/\r
562VOID\r
563InitializeBrowserStrings (\r
564 VOID\r
ed66e1bc 565 );\r
7936fb6a 566\r
7936fb6a 567/**\r
568 Parse opcodes in the formset IFR binary.\r
569\r
570 @param FormSet Pointer of the FormSet data structure.\r
571\r
572 @retval EFI_SUCCESS Opcode parse success.\r
573 @retval Other Opcode parse fail.\r
574\r
575**/\r
576EFI_STATUS\r
577ParseOpCodes (\r
578 IN FORM_BROWSER_FORMSET *FormSet\r
ed66e1bc 579 );\r
7936fb6a 580\r
581/**\r
582 Free resources allocated for a FormSet.\r
583\r
584 @param FormSet Pointer of the FormSet\r
585\r
586**/\r
587VOID\r
588DestroyFormSet (\r
589 IN OUT FORM_BROWSER_FORMSET *FormSet\r
ed66e1bc 590 );\r
7936fb6a 591\r
7936fb6a 592\r
593/**\r
594 Create a new string in HII Package List.\r
595\r
596 @param String The String to be added\r
597 @param HiiHandle The package list in the HII database to insert the\r
598 specified string.\r
599\r
600 @return The output string.\r
601\r
602**/\r
603EFI_STRING_ID\r
604NewString (\r
605 IN CHAR16 *String,\r
606 IN EFI_HII_HANDLE HiiHandle\r
ed66e1bc 607 );\r
7936fb6a 608\r
609/**\r
610 Delete a string from HII Package List.\r
611\r
612 @param StringId Id of the string in HII database.\r
613 @param HiiHandle The HII package list handle.\r
614\r
615 @retval EFI_SUCCESS The string was deleted successfully.\r
616\r
617**/\r
618EFI_STATUS\r
619DeleteString (\r
620 IN EFI_STRING_ID StringId,\r
621 IN EFI_HII_HANDLE HiiHandle\r
ed66e1bc 622 );\r
7936fb6a 623\r
624/**\r
625 Get the string based on the StringId and HII Package List Handle.\r
626\r
627 @param Token The String's ID.\r
628 @param HiiHandle The package list in the HII database to search for\r
629 the specified string.\r
630\r
631 @return The output string.\r
632\r
633**/\r
634CHAR16 *\r
635GetToken (\r
636 IN EFI_STRING_ID Token,\r
637 IN EFI_HII_HANDLE HiiHandle\r
ed66e1bc 638 );\r
7936fb6a 639\r
2573712e
LG
640/**\r
641 Get Value for given Name from a NameValue Storage.\r
642\r
643 @param Storage The NameValue Storage.\r
644 @param Name The Name.\r
645 @param Value The retured Value.\r
816a7110 646 @param GetValueFrom Where to get source value, from EditValue or Value.\r
2573712e
LG
647\r
648 @retval EFI_SUCCESS Value found for given Name.\r
649 @retval EFI_NOT_FOUND No such Name found in NameValue storage.\r
650\r
651**/\r
652EFI_STATUS\r
653GetValueByName (\r
94f3aae7 654 IN BROWSER_STORAGE *Storage,\r
816a7110
ED
655 IN CHAR16 *Name,\r
656 IN OUT CHAR16 **Value,\r
657 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom\r
2573712e
LG
658 );\r
659\r
660/**\r
661 Set Value of given Name in a NameValue Storage.\r
662\r
663 @param Storage The NameValue Storage.\r
664 @param Name The Name.\r
665 @param Value The Value to set.\r
816a7110 666 @param SetValueTo Whether update editValue or Value.\r
7c6c064c 667 @param ReturnNode The node use the input name.\r
2573712e
LG
668\r
669 @retval EFI_SUCCESS Value found for given Name.\r
670 @retval EFI_NOT_FOUND No such Name found in NameValue storage.\r
671\r
672**/\r
673EFI_STATUS\r
674SetValueByName (\r
7c6c064c
ED
675 IN BROWSER_STORAGE *Storage,\r
676 IN CHAR16 *Name,\r
677 IN CHAR16 *Value,\r
678 IN GET_SET_QUESTION_VALUE_WITH SetValueTo,\r
679 OUT NAME_VALUE_NODE **ReturnNode\r
680 );\r
681\r
682/**\r
683 Validate whether this question's value has changed.\r
684\r
685 @param FormSet FormSet data structure.\r
686 @param Form Form data structure.\r
687 @param Question Question to be initialized.\r
688 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.\r
689\r
690 @retval TRUE Question's value has changed.\r
691 @retval FALSE Question's value has not changed\r
692\r
693**/\r
694BOOLEAN\r
695IsQuestionValueChanged (\r
696 IN FORM_BROWSER_FORMSET *FormSet,\r
697 IN FORM_BROWSER_FORM *Form,\r
698 IN OUT FORM_BROWSER_STATEMENT *Question,\r
699 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom\r
2573712e
LG
700 );\r
701\r
7936fb6a 702/**\r
703 Get Question's current Value.\r
704\r
705 @param FormSet FormSet data structure.\r
706 @param Form Form data structure.\r
707 @param Question Question to be initialized.\r
816a7110 708 @param GetValueFrom Where to get value, may from editbuffer, buffer or hii driver.\r
7936fb6a 709\r
710 @retval EFI_SUCCESS The function completed successfully.\r
711\r
712**/\r
713EFI_STATUS\r
714GetQuestionValue (\r
715 IN FORM_BROWSER_FORMSET *FormSet,\r
716 IN FORM_BROWSER_FORM *Form,\r
717 IN OUT FORM_BROWSER_STATEMENT *Question,\r
816a7110 718 IN GET_SET_QUESTION_VALUE_WITH GetValueFrom\r
ed66e1bc 719 );\r
7936fb6a 720\r
721/**\r
722 Save Question Value to edit copy(cached) or Storage(uncached).\r
723\r
724 @param FormSet FormSet data structure.\r
725 @param Form Form data structure.\r
726 @param Question Pointer to the Question.\r
816a7110 727 @param SetValueTo Update the question value to editbuffer , buffer or hii driver.\r
7936fb6a 728\r
729 @retval EFI_SUCCESS The function completed successfully.\r
730\r
731**/\r
732EFI_STATUS\r
733SetQuestionValue (\r
734 IN FORM_BROWSER_FORMSET *FormSet,\r
735 IN FORM_BROWSER_FORM *Form,\r
736 IN OUT FORM_BROWSER_STATEMENT *Question,\r
816a7110 737 IN GET_SET_QUESTION_VALUE_WITH SetValueTo\r
ed66e1bc 738 );\r
7936fb6a 739\r
740/**\r
741 Perform inconsistent check for a Form.\r
742\r
743 @param FormSet FormSet data structure.\r
744 @param Form Form data structure.\r
745 @param Question The Question to be validated.\r
746 @param Type Validation type: InConsistent or NoSubmit\r
747\r
748 @retval EFI_SUCCESS Form validation pass.\r
749 @retval other Form validation failed.\r
750\r
751**/\r
752EFI_STATUS\r
753ValidateQuestion (\r
754 IN FORM_BROWSER_FORMSET *FormSet,\r
755 IN FORM_BROWSER_FORM *Form,\r
756 IN FORM_BROWSER_STATEMENT *Question,\r
757 IN UINTN Type\r
ed66e1bc 758 );\r
7936fb6a 759\r
48a9d5f7 760\r
7936fb6a 761/**\r
48a9d5f7 762 Discard data based on the input setting scope (Form, FormSet or System).\r
7936fb6a 763\r
764 @param FormSet FormSet data structure.\r
765 @param Form Form data structure.\r
48a9d5f7 766 @param SettingScope Setting Scope for Discard action.\r
b18e7050
ED
767\r
768 @retval EFI_SUCCESS The function completed successfully.\r
48a9d5f7 769 @retval EFI_UNSUPPORTED Unsupport SettingScope.\r
b18e7050
ED
770\r
771**/\r
772EFI_STATUS\r
773DiscardForm (\r
774 IN FORM_BROWSER_FORMSET *FormSet,\r
775 IN FORM_BROWSER_FORM *Form,\r
48a9d5f7 776 IN BROWSER_SETTING_SCOPE SettingScope\r
b18e7050
ED
777 );\r
778\r
779/**\r
48a9d5f7 780 Submit data based on the input Setting level (Form, FormSet or System).\r
b18e7050
ED
781\r
782 @param FormSet FormSet data structure.\r
783 @param Form Form data structure.\r
48a9d5f7 784 @param SettingScope Setting Scope for Submit action.\r
7936fb6a 785\r
786 @retval EFI_SUCCESS The function completed successfully.\r
48a9d5f7 787 @retval EFI_UNSUPPORTED Unsupport SettingScope.\r
7936fb6a 788\r
789**/\r
790EFI_STATUS\r
791SubmitForm (\r
792 IN FORM_BROWSER_FORMSET *FormSet,\r
b18e7050 793 IN FORM_BROWSER_FORM *Form,\r
48a9d5f7 794 IN BROWSER_SETTING_SCOPE SettingScope\r
ed66e1bc 795 );\r
7936fb6a 796\r
797/**\r
798 Reset Question to its default value.\r
799\r
800 @param FormSet The form set.\r
801 @param Form The form.\r
802 @param Question The question.\r
803 @param DefaultId The Class of the default.\r
804\r
805 @retval EFI_SUCCESS Question is reset to default value.\r
806\r
807**/\r
808EFI_STATUS\r
809GetQuestionDefault (\r
810 IN FORM_BROWSER_FORMSET *FormSet,\r
811 IN FORM_BROWSER_FORM *Form,\r
812 IN FORM_BROWSER_STATEMENT *Question,\r
813 IN UINT16 DefaultId\r
ed66e1bc 814 );\r
7936fb6a 815\r
816/**\r
817 Get current setting of Questions.\r
818\r
819 @param FormSet FormSet data structure.\r
820\r
7936fb6a 821**/\r
7c6c064c 822VOID\r
7936fb6a 823InitializeCurrentSetting (\r
824 IN OUT FORM_BROWSER_FORMSET *FormSet\r
ed66e1bc 825 );\r
7936fb6a 826\r
827/**\r
828 Initialize the internal data structure of a FormSet.\r
829\r
830 @param Handle PackageList Handle\r
831 @param FormSetGuid GUID of a formset. If not specified (NULL or zero\r
832 GUID), take the first FormSet found in package\r
833 list.\r
834 @param FormSet FormSet data structure.\r
835\r
836 @retval EFI_SUCCESS The function completed successfully.\r
837 @retval EFI_NOT_FOUND The specified FormSet could not be found.\r
838\r
839**/\r
840EFI_STATUS\r
841InitializeFormSet (\r
842 IN EFI_HII_HANDLE Handle,\r
843 IN OUT EFI_GUID *FormSetGuid,\r
7c6c064c 844 OUT FORM_BROWSER_FORMSET *FormSet \r
ed66e1bc 845 );\r
7936fb6a 846\r
847/**\r
9776099f 848 Reset Questions to their initial value or default value in a Form, Formset or System.\r
7936fb6a 849\r
09cdd7d2
ED
850 GetDefaultValueScope parameter decides which questions will reset \r
851 to its default value.\r
852\r
7936fb6a 853 @param FormSet FormSet data structure.\r
48a9d5f7 854 @param Form Form data structure.\r
7936fb6a 855 @param DefaultId The Class of the default.\r
48a9d5f7 856 @param SettingScope Setting Scope for Default action.\r
09cdd7d2 857 @param GetDefaultValueScope Get default value scope.\r
3347d410 858 @param Storage Get default value only for this storage.\r
9776099f
ED
859 @param RetrieveValueFirst Whether call the retrieve call back to\r
860 get the initial value before get default\r
861 value.\r
7936fb6a 862\r
863 @retval EFI_SUCCESS The function completed successfully.\r
48a9d5f7 864 @retval EFI_UNSUPPORTED Unsupport SettingScope.\r
7936fb6a 865\r
866**/\r
867EFI_STATUS\r
48a9d5f7 868ExtractDefault (\r
7936fb6a 869 IN FORM_BROWSER_FORMSET *FormSet,\r
48a9d5f7
LG
870 IN FORM_BROWSER_FORM *Form,\r
871 IN UINT16 DefaultId,\r
3347d410 872 IN BROWSER_SETTING_SCOPE SettingScope,\r
09cdd7d2 873 IN BROWSER_GET_DEFAULT_VALUE GetDefaultValueScope,\r
94f3aae7 874 IN BROWSER_STORAGE *Storage,\r
9776099f 875 IN BOOLEAN RetrieveValueFirst\r
ed66e1bc 876 );\r
7936fb6a 877\r
878/**\r
879 Initialize Question's Edit copy from Storage.\r
880\r
eccfeab1
LG
881 @param Selection Selection contains the information about \r
882 the Selection, form and formset to be displayed.\r
883 Selection action may be updated in retrieve callback.\r
7d1b202d 884 If Selection is NULL, only initialize Question value.\r
7936fb6a 885 @param FormSet FormSet data structure.\r
886 @param Form Form data structure.\r
887\r
888 @retval EFI_SUCCESS The function completed successfully.\r
889\r
890**/\r
891EFI_STATUS\r
892LoadFormConfig (\r
eccfeab1
LG
893 IN OUT UI_MENU_SELECTION *Selection,\r
894 IN FORM_BROWSER_FORMSET *FormSet,\r
895 IN FORM_BROWSER_FORM *Form\r
ed66e1bc 896 );\r
7936fb6a 897\r
d66e6c16 898/**\r
899 Initialize Question's Edit copy from Storage for the whole Formset.\r
900\r
eccfeab1
LG
901 @param Selection Selection contains the information about \r
902 the Selection, form and formset to be displayed.\r
903 Selection action may be updated in retrieve callback.\r
7d1b202d 904 If Selection is NULL, only initialize Question value.\r
d66e6c16 905 @param FormSet FormSet data structure.\r
906\r
907 @retval EFI_SUCCESS The function completed successfully.\r
908\r
909**/\r
910EFI_STATUS\r
911LoadFormSetConfig (\r
eccfeab1
LG
912 IN OUT UI_MENU_SELECTION *Selection,\r
913 IN FORM_BROWSER_FORMSET *FormSet\r
d66e6c16 914 );\r
915\r
7936fb6a 916/**\r
917 Convert setting of Buffer Storage or NameValue Storage to <ConfigResp>.\r
918\r
94f3aae7 919 @param Storage The Storage to be conveted.\r
7936fb6a 920 @param ConfigResp The returned <ConfigResp>.\r
94f3aae7 921 @param ConfigRequest The ConfigRequest string.\r
7c6c064c 922 @param GetEditBuf Get the data from editbuffer or buffer.\r
7936fb6a 923\r
924 @retval EFI_SUCCESS Convert success.\r
925 @retval EFI_INVALID_PARAMETER Incorrect storage type.\r
926\r
927**/\r
928EFI_STATUS\r
929StorageToConfigResp (\r
94f3aae7 930 IN BROWSER_STORAGE *Storage,\r
b18e7050 931 IN CHAR16 **ConfigResp,\r
7c6c064c
ED
932 IN CHAR16 *ConfigRequest,\r
933 IN BOOLEAN GetEditBuf\r
ed66e1bc 934 );\r
7936fb6a 935\r
936/**\r
937 Convert <ConfigResp> to settings in Buffer Storage or NameValue Storage.\r
938\r
939 @param Storage The Storage to receive the settings.\r
940 @param ConfigResp The <ConfigResp> to be converted.\r
941\r
942 @retval EFI_SUCCESS Convert success.\r
943 @retval EFI_INVALID_PARAMETER Incorrect storage type.\r
944\r
945**/\r
946EFI_STATUS\r
947ConfigRespToStorage (\r
94f3aae7 948 IN BROWSER_STORAGE *Storage,\r
7936fb6a 949 IN CHAR16 *ConfigResp\r
ed66e1bc 950 );\r
7936fb6a 951\r
952/**\r
953 Fill storage's edit copy with settings requested from Configuration Driver.\r
954\r
955 @param FormSet FormSet data structure.\r
956 @param Storage Buffer Storage.\r
957\r
7936fb6a 958**/\r
7c6c064c 959VOID\r
7936fb6a 960LoadStorage (\r
961 IN FORM_BROWSER_FORMSET *FormSet,\r
962 IN FORMSET_STORAGE *Storage\r
ed66e1bc 963 );\r
7936fb6a 964\r
965/**\r
966 Fetch the Ifr binary data of a FormSet.\r
967\r
968 @param Handle PackageList Handle\r
969 @param FormSetGuid GUID of a formset. If not specified (NULL or zero\r
970 GUID), take the first FormSet found in package\r
971 list.\r
972 @param BinaryLength The length of the FormSet IFR binary.\r
973 @param BinaryData The buffer designed to receive the FormSet.\r
974\r
975 @retval EFI_SUCCESS Buffer filled with the requested FormSet.\r
976 BufferLength was updated.\r
977 @retval EFI_INVALID_PARAMETER The handle is unknown.\r
978 @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot\r
979 be found with the requested FormId.\r
980\r
981**/\r
982EFI_STATUS\r
983GetIfrBinaryData (\r
984 IN EFI_HII_HANDLE Handle,\r
985 IN OUT EFI_GUID *FormSetGuid,\r
986 OUT UINTN *BinaryLength,\r
987 OUT UINT8 **BinaryData\r
ed66e1bc 988 );\r
7936fb6a 989\r
ce6d12cc 990/**\r
991 Save globals used by previous call to SendForm(). SendForm() may be called from \r
992 HiiConfigAccess.Callback(), this will cause SendForm() be reentried.\r
993 So, save globals of previous call to SendForm() and restore them upon exit.\r
994\r
995**/\r
996VOID\r
997SaveBrowserContext (\r
998 VOID\r
999 );\r
1000\r
1001/**\r
1002 Restore globals used by previous call to SendForm().\r
1003\r
1004**/\r
1005VOID\r
1006RestoreBrowserContext (\r
1007 VOID\r
1008 );\r
1009\r
7936fb6a 1010/**\r
1011 This is the routine which an external caller uses to direct the browser\r
1012 where to obtain it's information.\r
1013\r
1014\r
1015 @param This The Form Browser protocol instanse.\r
1016 @param Handles A pointer to an array of Handles. If HandleCount > 1 we\r
1017 display a list of the formsets for the handles specified.\r
1018 @param HandleCount The number of Handles specified in Handle.\r
1019 @param FormSetGuid This field points to the EFI_GUID which must match the Guid\r
1020 field in the EFI_IFR_FORM_SET op-code for the specified\r
1021 forms-based package. If FormSetGuid is NULL, then this\r
1022 function will display the first found forms package.\r
1023 @param FormId This field specifies which EFI_IFR_FORM to render as the first\r
1024 displayable page. If this field has a value of 0x0000, then\r
1025 the forms browser will render the specified forms in their encoded order.\r
1026 ScreenDimenions - This allows the browser to be called so that it occupies a\r
1027 portion of the physical screen instead of dynamically determining the screen dimensions.\r
1028 ActionRequest - Points to the action recommended by the form.\r
d66e6c16 1029 @param ScreenDimensions Points to recommended form dimensions, including any non-content area, in\r
7936fb6a 1030 characters.\r
1031 @param ActionRequest Points to the action recommended by the form.\r
1032\r
1033 @retval EFI_SUCCESS The function completed successfully.\r
1034 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
1035 @retval EFI_NOT_FOUND No valid forms could be found to display.\r
1036\r
1037**/\r
1038EFI_STATUS\r
1039EFIAPI\r
1040SendForm (\r
1041 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,\r
1042 IN EFI_HII_HANDLE *Handles,\r
1043 IN UINTN HandleCount,\r
1044 IN EFI_GUID *FormSetGuid, OPTIONAL\r
1045 IN UINT16 FormId, OPTIONAL\r
1046 IN CONST EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL\r
1047 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OPTIONAL\r
ed66e1bc 1048 );\r
7936fb6a 1049\r
1050/**\r
1051 This function is called by a callback handler to retrieve uncommitted state\r
1052 data from the browser.\r
1053\r
1054 @param This A pointer to the EFI_FORM_BROWSER2_PROTOCOL\r
1055 instance.\r
1056 @param ResultsDataSize A pointer to the size of the buffer associated\r
1057 with ResultsData.\r
1058 @param ResultsData A string returned from an IFR browser or\r
1059 equivalent. The results string will have no\r
1060 routing information in them.\r
1061 @param RetrieveData A BOOLEAN field which allows an agent to retrieve\r
1062 (if RetrieveData = TRUE) data from the uncommitted\r
1063 browser state information or set (if RetrieveData\r
1064 = FALSE) data in the uncommitted browser state\r
1065 information.\r
1066 @param VariableGuid An optional field to indicate the target variable\r
1067 GUID name to use.\r
1068 @param VariableName An optional field to indicate the target\r
1069 human-readable variable name.\r
1070\r
1071 @retval EFI_SUCCESS The results have been distributed or are awaiting\r
1072 distribution.\r
1073 @retval EFI_BUFFER_TOO_SMALL The ResultsDataSize specified was too small to\r
1074 contain the results data.\r
1075\r
1076**/\r
1077EFI_STATUS\r
1078EFIAPI\r
1079BrowserCallback (\r
1080 IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,\r
1081 IN OUT UINTN *ResultsDataSize,\r
1082 IN OUT EFI_STRING ResultsData,\r
1083 IN BOOLEAN RetrieveData,\r
1084 IN CONST EFI_GUID *VariableGuid, OPTIONAL\r
1085 IN CONST CHAR16 *VariableName OPTIONAL\r
ed66e1bc 1086 );\r
7936fb6a 1087\r
b18e7050
ED
1088/**\r
1089 Find menu which will show next time.\r
1090\r
1091 @param Selection On input, Selection tell setup browser the information\r
1092 about the Selection, form and formset to be displayed.\r
1093 On output, Selection return the screen item that is selected\r
1094 by user.\r
7c6c064c
ED
1095 @param SettingLevel Input Settting level, if it is FormLevel, just exit current form. \r
1096 else, we need to exit current formset.\r
b18e7050 1097 \r
7c6c064c
ED
1098 @retval TRUE Exit current form.\r
1099 @retval FALSE User press ESC and keep in current form.\r
b18e7050
ED
1100**/\r
1101BOOLEAN\r
1102FindNextMenu (\r
7c6c064c
ED
1103 IN OUT UI_MENU_SELECTION *Selection,\r
1104 IN BROWSER_SETTING_SCOPE SettingLevel\r
b18e7050
ED
1105 );\r
1106\r
1107/**\r
7c6c064c 1108 check whether the form need to update the NV.\r
b18e7050 1109\r
7c6c064c 1110 @param Form Form data structure.\r
b18e7050 1111\r
7c6c064c
ED
1112 @retval TRUE Need to update the NV.\r
1113 @retval FALSE No need to update the NV.\r
b18e7050 1114**/\r
7c6c064c
ED
1115BOOLEAN\r
1116IsNvUpdateRequiredForForm (\r
1117 IN FORM_BROWSER_FORM *Form\r
b18e7050
ED
1118 );\r
1119\r
1120/**\r
1121 check whether the formset need to update the NV.\r
1122\r
1123 @param FormSet FormSet data structure.\r
1124\r
1125 @retval TRUE Need to update the NV.\r
1126 @retval FALSE No need to update the NV.\r
1127**/\r
7c6c064c
ED
1128BOOLEAN\r
1129IsNvUpdateRequiredForFormSet (\r
25361615 1130 IN FORM_BROWSER_FORMSET *FormSet\r
b9feb4bd
ED
1131 );\r
1132\r
7c6c064c
ED
1133/**\r
1134 Check whether the storage data for current form set is changed.\r
1135\r
1136 @param FormSet FormSet data structure.\r
1137\r
1138 @retval TRUE Data is changed.\r
1139 @retval FALSE Data is not changed.\r
1140**/\r
1141BOOLEAN \r
1142IsStorageDataChangedForFormSet (\r
1143 IN FORM_BROWSER_FORMSET *FormSet\r
1144 );\r
1145\r
b18e7050
ED
1146/**\r
1147 Call the call back function for the question and process the return action.\r
1148\r
1149 @param Selection On input, Selection tell setup browser the information\r
1150 about the Selection, form and formset to be displayed.\r
1151 On output, Selection return the screen item that is selected\r
1152 by user.\r
1153 @param Statement The Question which need to call.\r
1154 @param Action The action request.\r
1155 @param SkipSaveOrDiscard Whether skip save or discard action.\r
1156\r
1157 @retval EFI_SUCCESS The call back function excutes successfully.\r
1158 @return Other value if the call back function failed to excute. \r
1159**/\r
1160EFI_STATUS \r
1161ProcessCallBackFunction (\r
1162 IN OUT UI_MENU_SELECTION *Selection,\r
1163 IN FORM_BROWSER_STATEMENT *Question,\r
1164 IN EFI_BROWSER_ACTION Action,\r
1165 IN BOOLEAN SkipSaveOrDiscard\r
1166 );\r
9776099f
ED
1167 \r
1168/**\r
1169 Call the retrieve type call back function for one question to get the initialize data.\r
1170 \r
1171 This function only used when in the initialize stage, because in this stage, the \r
1172 Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.\r
1173\r
1174 @param ConfigAccess The config access protocol produced by the hii driver.\r
1175 @param Statement The Question which need to call.\r
1176\r
1177 @retval EFI_SUCCESS The call back function excutes successfully.\r
1178 @return Other value if the call back function failed to excute. \r
1179**/\r
1180EFI_STATUS \r
1181ProcessRetrieveForQuestion (\r
1182 IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess,\r
1183 IN FORM_BROWSER_STATEMENT *Statement\r
1184 );\r
48a9d5f7
LG
1185\r
1186/**\r
1187 Find the matched FormSet context in the backup maintain list based on HiiHandle.\r
1188 \r
1189 @param Handle The Hii Handle.\r
1190 \r
1191 @return the found FormSet context. If no found, NULL will return.\r
1192\r
1193**/\r
1194FORM_BROWSER_FORMSET * \r
1195GetFormSetFromHiiHandle (\r
1196 EFI_HII_HANDLE Handle\r
1197 );\r
1198\r
1199/**\r
1200 Check whether the input HII handle is the FormSet that is being used.\r
1201 \r
1202 @param Handle The Hii Handle.\r
1203 \r
1204 @retval TRUE HII handle is being used.\r
1205 @retval FALSE HII handle is not being used.\r
1206\r
1207**/\r
1208BOOLEAN\r
1209IsHiiHandleInBrowserContext (\r
1210 EFI_HII_HANDLE Handle\r
1211 );\r
1212\r
1213/**\r
1214 Configure what scope the hot key will impact.\r
1215 All hot keys have the same scope. The mixed hot keys with the different level are not supported.\r
1216 If no scope is set, the default scope will be FormSet level.\r
1217 After all registered hot keys are removed, previous Scope can reset to another level.\r
1218 \r
1219 @param[in] Scope Scope level to be set. \r
1220 \r
1221 @retval EFI_SUCCESS Scope is set correctly.\r
1222 @retval EFI_INVALID_PARAMETER Scope is not the valid value specified in BROWSER_SETTING_SCOPE. \r
1223 @retval EFI_UNSPPORTED Scope level is different from current one that the registered hot keys have.\r
1224\r
1225**/\r
1226EFI_STATUS\r
1227EFIAPI\r
1228SetScope (\r
1229 IN BROWSER_SETTING_SCOPE Scope\r
1230 );\r
1231\r
1232/**\r
1233 Register the hot key with its browser action, or unregistered the hot key.\r
1234 Only support hot key that is not printable character (control key, function key, etc.).\r
1235 If the action value is zero, the hot key will be unregistered if it has been registered.\r
1236 If the same hot key has been registered, the new action and help string will override the previous ones.\r
1237 \r
1238 @param[in] KeyData A pointer to a buffer that describes the keystroke\r
1239 information for the hot key. Its type is EFI_INPUT_KEY to \r
1240 be supported by all ConsoleIn devices.\r
1241 @param[in] Action Action value that describes what action will be trigged when the hot key is pressed. \r
1242 @param[in] DefaultId Specifies the type of defaults to retrieve, which is only for DEFAULT action.\r
1243 @param[in] HelpString Help string that describes the hot key information.\r
1244 Its value may be NULL for the unregistered hot key.\r
1245 \r
1246 @retval EFI_SUCCESS Hot key is registered or unregistered.\r
1247 @retval EFI_INVALID_PARAMETER KeyData is NULL.\r
1248 @retval EFI_NOT_FOUND KeyData is not found to be unregistered.\r
1249 @retval EFI_UNSUPPORTED Key represents a printable character. It is conflicted with Browser.\r
1250**/\r
1251EFI_STATUS\r
1252EFIAPI\r
1253RegisterHotKey (\r
1254 IN EFI_INPUT_KEY *KeyData,\r
1255 IN UINT32 Action,\r
1256 IN UINT16 DefaultId,\r
1257 IN EFI_STRING HelpString OPTIONAL\r
1258 );\r
1259\r
1260/**\r
1261 Register Exit handler function. \r
1262 When more than one handler function is registered, the latter one will override the previous one. \r
1263 When NULL handler is specified, the previous Exit handler will be unregistered. \r
1264 \r
1265 @param[in] Handler Pointer to handler function. \r
1266\r
1267**/\r
1268VOID\r
1269EFIAPI\r
1270RegiserExitHandler (\r
1271 IN EXIT_HANDLER Handler\r
1272 );\r
1273\r
7c6c064c
ED
1274/**\r
1275 \r
1276 Check whether the browser data has been modified. \r
1277\r
1278 @retval TRUE Browser data is changed.\r
1279 @retval FALSE No browser data is changed.\r
1280\r
1281**/\r
1282BOOLEAN \r
1283EFIAPI\r
1284IsBrowserDataModified (\r
1285 VOID\r
1286 );\r
1287\r
1288/**\r
1289 \r
1290 Execute the action requested by the Action parameter. \r
1291\r
1292 @param[in] Action Execute the request action.\r
1293 @param[in] DefaultId The default Id info when need to load default value.\r
1294\r
1295 @retval EFI_SUCCESS Execute the request action succss.\r
1296 @retval EFI_INVALID_PARAMETER The input action value is invalid.\r
1297\r
1298**/\r
1299EFI_STATUS \r
1300EFIAPI\r
1301ExecuteAction (\r
1302 IN UINT32 Action,\r
1303 IN UINT16 DefaultId\r
1304 );\r
1305\r
48a9d5f7
LG
1306/**\r
1307 Create reminder to let user to choose save or discard the changed browser data.\r
1308 Caller can use it to actively check the changed browser data.\r
1309\r
1310 @retval BROWSER_NO_CHANGES No browser data is changed.\r
1311 @retval BROWSER_SAVE_CHANGES The changed browser data is saved.\r
1312 @retval BROWSER_DISCARD_CHANGES The changed browser data is discard.\r
1313\r
1314**/\r
1315UINT32\r
1316EFIAPI\r
1317SaveReminder (\r
1318 VOID\r
1319 );\r
1320\r
1321/**\r
1322 Find the registered HotKey based on KeyData.\r
1323 \r
1324 @param[in] KeyData A pointer to a buffer that describes the keystroke\r
1325 information for the hot key.\r
1326\r
1327 @return The registered HotKey context. If no found, NULL will return.\r
1328**/\r
1329BROWSER_HOT_KEY *\r
1330GetHotKeyFromRegisterList (\r
1331 IN EFI_INPUT_KEY *KeyData\r
1332 );\r
1333\r
7c6c064c
ED
1334/**\r
1335\r
1336 Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.\r
1337\r
1338 @param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.\r
1339\r
1340 @retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.\r
1341\r
1342**/\r
1343FORM_BROWSER_STATEMENT *\r
1344GetBrowserStatement (\r
1345 IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement\r
1346 );\r
1347 \r
1348/**\r
1349 Password may be stored as encrypted by Configuration Driver. When change a\r
1350 password, user will be challenged with old password. To validate user input old\r
1351 password, we will send the clear text to Configuration Driver via Callback().\r
1352 Configuration driver is responsible to check the passed in password and return\r
1353 the validation result. If validation pass, state machine in password Callback()\r
1354 will transit from BROWSER_STATE_VALIDATE_PASSWORD to BROWSER_STATE_SET_PASSWORD.\r
1355 After user type in new password twice, Callback() will be invoked to send the\r
1356 new password to Configuration Driver.\r
1357\r
1358 @param Selection Pointer to UI_MENU_SELECTION.\r
1359 @param MenuOption The MenuOption for this password Question.\r
1360 @param String The clear text of password.\r
1361\r
1362 @retval EFI_NOT_AVAILABLE_YET Callback() request to terminate password input.\r
1363 @return In state of BROWSER_STATE_VALIDATE_PASSWORD:\r
1364 @retval EFI_SUCCESS Password correct, Browser will prompt for new\r
1365 password.\r
1366 @retval EFI_NOT_READY Password incorrect, Browser will show error\r
1367 message.\r
1368 @retval Other Browser will do nothing.\r
1369 @return In state of BROWSER_STATE_SET_PASSWORD:\r
1370 @retval EFI_SUCCESS Set password success.\r
1371 @retval Other Set password failed.\r
1372\r
1373**/\r
1374EFI_STATUS\r
1375PasswordCallback (\r
1376 IN UI_MENU_SELECTION *Selection,\r
1377 IN FORM_BROWSER_STATEMENT *Question,\r
1378 IN CHAR16 *String\r
1379 );\r
1380\r
1381/**\r
1382 Display error message for invalid password.\r
1383\r
1384**/\r
1385VOID\r
1386PasswordInvalid (\r
1387 VOID\r
1388 );\r
1389\r
1390/**\r
1391 The worker function that send the displays to the screen. On output,\r
1392 the selection made by user is returned.\r
1393\r
1394 @param Selection On input, Selection tell setup browser the information\r
1395 about the Selection, form and formset to be displayed.\r
1396 On output, Selection return the screen item that is selected\r
1397 by user.\r
1398\r
1399 @retval EFI_SUCCESS The page is displayed successfully.\r
1400 @return Other value if the page failed to be diplayed.\r
1401\r
1402**/\r
1403EFI_STATUS\r
1404SetupBrowser (\r
1405 IN OUT UI_MENU_SELECTION *Selection\r
1406 );\r
1407 \r
1408/**\r
1409 Free up the resource allocated for all strings required\r
1410 by Setup Browser.\r
1411\r
1412**/\r
1413VOID\r
1414FreeBrowserStrings (\r
1415 VOID\r
1416 );\r
1417\r
1418/**\r
1419 Create a menu with specified formset GUID and form ID, and add it as a child\r
1420 of the given parent menu.\r
1421\r
1422 @param HiiHandle Hii handle related to this formset.\r
1423 @param FormSetGuid The Formset Guid of menu to be added.\r
1424 @param FormId The Form ID of menu to be added.\r
1425 @param QuestionId The question id of this menu to be added.\r
1426\r
1427 @return A pointer to the newly added menu or NULL if memory is insufficient.\r
1428\r
1429**/\r
1430FORM_ENTRY_INFO *\r
1431UiAddMenuList (\r
1432 IN EFI_HII_HANDLE HiiHandle,\r
1433 IN EFI_GUID *FormSetGuid,\r
1434 IN UINT16 FormId,\r
1435 IN UINT16 QuestionId\r
1436 );\r
1437\r
1438/**\r
1439 Search Menu with given FormSetGuid and FormId in all cached menu list.\r
1440\r
1441 @param HiiHandle HiiHandle for FormSet.\r
1442 @param FormSetGuid The Formset GUID of the menu to search.\r
1443 @param FormId The Form ID of menu to search.\r
1444\r
1445 @return A pointer to menu found or NULL if not found.\r
1446\r
1447**/\r
1448FORM_ENTRY_INFO *\r
1449UiFindMenuList (\r
1450 IN EFI_HII_HANDLE HiiHandle, \r
1451 IN EFI_GUID *FormSetGuid,\r
1452 IN UINT16 FormId\r
1453 );\r
1454\r
1455/**\r
1456 Free Menu list linked list.\r
1457\r
1458 @param MenuListHead One Menu list point in the menu list.\r
1459\r
1460**/\r
1461VOID\r
1462UiFreeMenuList (\r
1463 LIST_ENTRY *MenuListHead\r
1464 );\r
1465\r
1466/**\r
1467 Find parent menu for current menu.\r
1468\r
1469 @param CurrentMenu Current Menu\r
1470\r
1471 @retval The parent menu for current menu.\r
1472**/\r
1473FORM_ENTRY_INFO *\r
1474UiFindParentMenu (\r
1475 IN FORM_ENTRY_INFO *CurrentMenu\r
1476 );\r
1477\r
1478/**\r
1479 Search an Option of a Question by its value.\r
1480\r
1481 @param Question The Question\r
1482 @param OptionValue Value for Option to be searched.\r
1483\r
1484 @retval Pointer Pointer to the found Option.\r
1485 @retval NULL Option not found.\r
1486\r
1487**/\r
1488QUESTION_OPTION *\r
1489ValueToOption (\r
1490 IN FORM_BROWSER_STATEMENT *Question,\r
1491 IN EFI_HII_VALUE *OptionValue\r
1492 );\r
1493/**\r
1494 Return data element in an Array by its Index.\r
1495\r
1496 @param Array The data array.\r
1497 @param Type Type of the data in this array.\r
1498 @param Index Zero based index for data in this array.\r
1499\r
1500 @retval Value The data to be returned\r
1501\r
1502**/\r
1503UINT64\r
1504GetArrayData (\r
1505 IN VOID *Array,\r
1506 IN UINT8 Type,\r
1507 IN UINTN Index\r
1508 );\r
1509\r
1510/**\r
1511 Set value of a data element in an Array by its Index.\r
1512\r
1513 @param Array The data array.\r
1514 @param Type Type of the data in this array.\r
1515 @param Index Zero based index for data in this array.\r
1516 @param Value The value to be set.\r
1517\r
1518**/\r
1519VOID\r
1520SetArrayData (\r
1521 IN VOID *Array,\r
1522 IN UINT8 Type,\r
1523 IN UINTN Index,\r
1524 IN UINT64 Value\r
1525 );\r
1526\r
1527/**\r
1528 Compare two Hii value.\r
1529 \r
1530 @param Value1 Expression value to compare on left-hand.\r
1531 @param Value2 Expression value to compare on right-hand.\r
1532 @param Result Return value after compare.\r
1533 retval 0 Two operators equal.\r
1534 return Positive value if Value1 is greater than Value2.\r
1535 retval Negative value if Value1 is less than Value2.\r
1536 @param HiiHandle Only required for string compare.\r
1537 \r
1538 @retval other Could not perform compare on two values.\r
1539 @retval EFI_SUCCESS Compare the value success.\r
1540 \r
1541**/\r
1542EFI_STATUS\r
1543CompareHiiValue (\r
1544 IN EFI_HII_VALUE *Value1,\r
1545 IN EFI_HII_VALUE *Value2,\r
1546 OUT INTN *Result,\r
1547 IN EFI_HII_HANDLE HiiHandle OPTIONAL\r
1548 );\r
1549\r
1550/**\r
1551 Perform Password check. \r
1552 Passwork may be encrypted by driver that requires the specific check.\r
1553 \r
1554 @param Form Form where Password Statement is in.\r
1555 @param Statement Password statement\r
1556 @param PasswordString Password string to be checked. It may be NULL.\r
1557 NULL means to restore password.\r
1558 "" string can be used to checked whether old password does exist.\r
1559 \r
1560 @return Status Status of Password check.\r
1561**/\r
1562EFI_STATUS\r
1563EFIAPI\r
1564PasswordCheck (\r
1565 IN FORM_DISPLAY_ENGINE_FORM *Form,\r
1566 IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,\r
1567 IN EFI_STRING PasswordString OPTIONAL\r
1568 );\r
1569\r
1570/**\r
1571\r
1572 Get FORM_BROWSER_STATEMENT from FORM_DISPLAY_ENGINE_STATEMENT based on the OpCode info.\r
1573\r
1574 @param DisplayStatement The input FORM_DISPLAY_ENGINE_STATEMENT.\r
1575\r
1576 @retval FORM_BROWSER_STATEMENT The return FORM_BROWSER_STATEMENT info.\r
1577\r
1578**/\r
1579FORM_BROWSER_STATEMENT *\r
1580GetBrowserStatement (\r
1581 IN FORM_DISPLAY_ENGINE_STATEMENT *DisplayStatement\r
1582 );\r
1583 \r
1584/**\r
1585\r
1586 Initialize the Display form structure data.\r
1587\r
1588**/\r
1589VOID\r
1590InitializeDisplayFormData (\r
1591 VOID\r
1592 );\r
1593\r
1594\r
0a6f8af5
ED
1595/**\r
1596 Base on the current formset info, clean the ConfigRequest string in browser storage.\r
1597\r
1598 @param FormSet Pointer of the FormSet\r
1599\r
1600**/\r
1601VOID\r
1602CleanBrowserStorage (\r
1603 IN OUT FORM_BROWSER_FORMSET *FormSet\r
1604 );\r
7c6c064c 1605 \r
7936fb6a 1606#endif\r