2 The file contain all library functions and definitions for IFR opcode creation and
3 related Form Browser utility Operations.
5 Copyright (c) 2007, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _IFR_SUPPORT_LIBRARY_H
17 #define _IFR_SUPPORT_LIBRARY_H
20 #include <Protocol/HiiFont.h>
21 #include <Protocol/HiiImage.h>
22 #include <Protocol/HiiString.h>
23 #include <Protocol/HiiDatabase.h>
24 #include <Protocol/HiiConfigRouting.h>
25 #include <Protocol/HiiConfigAccess.h>
26 #include <Protocol/FormBrowser2.h>
27 #include <Protocol/SimpleTextOut.h>
29 #include <Guid/GlobalVariable.h>
32 // The architectural variable "Lang" and "LangCodes" are deprecated in UEFI
33 // specification. While, UEFI specification also states that these deprecated
34 // variables may be provided for backwards compatibility.
35 // If "LANG_SUPPORT" is defined, "Lang" and "LangCodes" will be produced;
36 // If "LANG_SUPPORT" is undefined, "Lang" and "LangCodes" will not be produced.
40 #define EFI_LANGUAGE_VARIABLE L"Lang"
41 #define EFI_LANGUAGE_CODES_VARIABLE L"LangCodes"
43 #define UEFI_LANGUAGE_VARIABLE L"PlatformLang"
44 #define UEFI_LANGUAGE_CODES_VARIABLE L"PlatformLangCodes"
47 // Limited buffer size recommended by RFC4646 (4.3. Length Considerations)
48 // (42 characters plus a NULL terminator)
50 #define RFC_3066_ENTRY_SIZE (42 + 1)
51 #define ISO_639_2_ENTRY_SIZE 3
53 #define INVALID_VARSTORE_ID 0
55 #define QUESTION_FLAGS (EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY)
56 #define QUESTION_FLAGS_MASK (~QUESTION_FLAGS)
58 extern EFI_HII_DATABASE_PROTOCOL
*gIfrLibHiiDatabase
;
59 extern EFI_HII_STRING_PROTOCOL
*gIfrLibHiiString
;
63 EFI_STRING_ID StringToken
;
64 EFI_IFR_TYPE_VALUE Value
;
71 // Buffer size allocated for Data.
76 // Offset in Data to append the newly created opcode binary.
77 // It will be adjusted automatically in Create***OpCode(), and should be
78 // initialized to 0 before invocation of a serial of Create***OpCode()
83 // The destination buffer for created op-codes
86 } EFI_HII_UPDATE_DATA
;
90 Create EFI_IFR_END_OP opcode.
92 If Data is NULL or Data->Data is NULL, then ASSERT.
94 @param Data Destination for the created opcode binary
96 @retval EFI_SUCCESS Opcode create success
97 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
103 IN OUT EFI_HII_UPDATE_DATA
*Data
108 Create EFI_IFR_DEFAULT_OP opcode.
110 @param Value Value for the default
111 @param Type Type for the default
112 @param Data Destination for the created opcode binary
114 @retval EFI_SUCCESS Opcode create success
115 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
116 @retval EFI_INVALID_PARAMETER The type is not valid.
121 CreateDefaultOpCode (
122 IN EFI_IFR_TYPE_VALUE
*Value
,
124 IN OUT EFI_HII_UPDATE_DATA
*Data
129 Create EFI_IFR_ACTION_OP opcode.
131 @param QuestionId Question ID
132 @param Prompt String ID for Prompt
133 @param Help String ID for Help
134 @param QuestionFlags Flags in Question Header
135 @param QuestionConfig String ID for configuration
136 @param Data Destination for the created opcode binary
138 @retval EFI_SUCCESS Opcode create success
139 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
140 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
146 IN EFI_QUESTION_ID QuestionId
,
147 IN EFI_STRING_ID Prompt
,
148 IN EFI_STRING_ID Help
,
149 IN UINT8 QuestionFlags
,
150 IN EFI_STRING_ID QuestionConfig
,
151 IN OUT EFI_HII_UPDATE_DATA
*Data
156 Create EFI_IFR_SUBTITLE_OP opcode.
158 @param Prompt String ID for Prompt
159 @param Help String ID for Help
160 @param Flags Subtitle opcode flags
161 @param Scope Subtitle Scope bit
162 @param Data Destination for the created opcode binary
164 @retval EFI_SUCCESS Opcode create success
165 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
170 CreateSubTitleOpCode (
171 IN EFI_STRING_ID Prompt
,
172 IN EFI_STRING_ID Help
,
175 IN OUT EFI_HII_UPDATE_DATA
*Data
180 Create EFI_IFR_TEXT_OP opcode.
182 @param Prompt String ID for Prompt
183 @param Help String ID for Help
184 @param TextTwo String ID for text two
185 @param Data Destination for the created opcode binary
187 @retval EFI_SUCCESS Opcode create success
188 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
194 IN EFI_STRING_ID Prompt
,
195 IN EFI_STRING_ID Help
,
196 IN EFI_STRING_ID TextTwo
,
197 IN OUT EFI_HII_UPDATE_DATA
*Data
202 Create EFI_IFR_REF_OP opcode.
204 @param FormId Destination Form ID
205 @param Prompt String ID for Prompt
206 @param Help String ID for Help
207 @param QuestionFlags Flags in Question Header
208 @param QuestionId Question ID
209 @param Data Destination for the created opcode binary
211 @retval EFI_SUCCESS Opcode create success
212 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
213 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
219 IN EFI_FORM_ID FormId
,
220 IN EFI_STRING_ID Prompt
,
221 IN EFI_STRING_ID Help
,
222 IN UINT8 QuestionFlags
,
223 IN EFI_QUESTION_ID QuestionId
,
224 IN OUT EFI_HII_UPDATE_DATA
*Data
229 Create EFI_IFR_ONE_OF_OPTION_OP opcode.
231 @param QuestionId Question ID
232 @param OptionList The list of Options.
233 @param Type The data type.
234 @param Data Destination for the created opcode binary
236 @retval EFI_SUCCESS Opcode create success
237 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
242 CreateOneOfOptionOpCode (
243 IN UINTN OptionCount
,
244 IN IFR_OPTION
*OptionsList
,
246 IN OUT EFI_HII_UPDATE_DATA
*Data
251 Create EFI_IFR_ONE_OF_OP opcode.
253 @param QuestionId Question ID
254 @param VarStoreId Storage ID
255 @param VarOffset Offset in Storage
256 @param Prompt String ID for Prompt
257 @param Help String ID for Help
258 @param QuestionFlags Flags in Question Header
259 @param OneOfFlags Flags for oneof opcode
260 @param OptionsList List of options
261 @param OptionCount Number of options in option list
262 @param Data Destination for the created opcode binary
264 @retval EFI_SUCCESS Opcode create success
265 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
266 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
272 IN EFI_QUESTION_ID QuestionId
,
273 IN EFI_VARSTORE_ID VarStoreId
,
275 IN EFI_STRING_ID Prompt
,
276 IN EFI_STRING_ID Help
,
277 IN UINT8 QuestionFlags
,
279 IN IFR_OPTION
*OptionsList
,
280 IN UINTN OptionCount
,
281 IN OUT EFI_HII_UPDATE_DATA
*Data
286 Create EFI_IFR_ORDERED_LIST_OP opcode.
288 @param QuestionId Question ID
289 @param VarStoreId Storage ID
290 @param VarOffset Offset in Storage
291 @param Prompt String ID for Prompt
292 @param Help String ID for Help
293 @param QuestionFlags Flags in Question Header
294 @param Flags Flags for ordered list opcode
295 @param DataType Type for option value
296 @param MaxContainers Maximum count for options in this ordered list
297 @param OptionsList List of options
298 @param OptionCount Number of options in option list
299 @param Data Destination for the created opcode binary
301 @retval EFI_SUCCESS Opcode create success
302 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
303 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
308 CreateOrderedListOpCode (
309 IN EFI_QUESTION_ID QuestionId
,
310 IN EFI_VARSTORE_ID VarStoreId
,
312 IN EFI_STRING_ID Prompt
,
313 IN EFI_STRING_ID Help
,
314 IN UINT8 QuestionFlags
,
317 IN UINT8 MaxContainers
,
318 IN IFR_OPTION
*OptionsList
,
319 IN UINTN OptionCount
,
320 IN OUT EFI_HII_UPDATE_DATA
*Data
325 Create EFI_IFR_CHECKBOX_OP opcode.
327 @param QuestionId Question ID
328 @param VarStoreId Storage ID
329 @param VarOffset Offset in Storage
330 @param Prompt String ID for Prompt
331 @param Help String ID for Help
332 @param QuestionFlags Flags in Question Header
333 @param CheckBoxFlags Flags for checkbox opcode
334 @param Data Destination for the created opcode binary
336 @retval EFI_SUCCESS Opcode create success
337 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
338 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
343 CreateCheckBoxOpCode (
344 IN EFI_QUESTION_ID QuestionId
,
345 IN EFI_VARSTORE_ID VarStoreId
,
347 IN EFI_STRING_ID Prompt
,
348 IN EFI_STRING_ID Help
,
349 IN UINT8 QuestionFlags
,
350 IN UINT8 CheckBoxFlags
,
351 IN OUT EFI_HII_UPDATE_DATA
*Data
356 Create EFI_IFR_NUMERIC_OP opcode.
358 @param QuestionId Question ID
359 @param VarStoreId Storage ID
360 @param VarOffset Offset in Storage
361 @param Prompt String ID for Prompt
362 @param Help String ID for Help
363 @param QuestionFlags Flags in Question Header
364 @param NumericFlags Flags for numeric opcode
365 @param Minimum Numeric minimum value
366 @param Maximum Numeric maximum value
367 @param Step Numeric step for edit
368 @param Default Numeric default value
369 @param Data Destination for the created opcode binary
371 @retval EFI_SUCCESS Opcode create success
372 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
373 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
378 CreateNumericOpCode (
379 IN EFI_QUESTION_ID QuestionId
,
380 IN EFI_VARSTORE_ID VarStoreId
,
382 IN EFI_STRING_ID Prompt
,
383 IN EFI_STRING_ID Help
,
384 IN UINT8 QuestionFlags
,
385 IN UINT8 NumericFlags
,
390 IN OUT EFI_HII_UPDATE_DATA
*Data
395 Create EFI_IFR_STRING_OP opcode.
397 @param QuestionId Question ID
398 @param VarStoreId Storage ID
399 @param VarOffset Offset in Storage
400 @param Prompt String ID for Prompt
401 @param Help String ID for Help
402 @param QuestionFlags Flags in Question Header
403 @param StringFlags Flags for string opcode
404 @param MinSize String minimum length
405 @param MaxSize String maximum length
406 @param Data Destination for the created opcode binary
408 @retval EFI_SUCCESS Opcode create success
409 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
410 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
416 IN EFI_QUESTION_ID QuestionId
,
417 IN EFI_VARSTORE_ID VarStoreId
,
419 IN EFI_STRING_ID Prompt
,
420 IN EFI_STRING_ID Help
,
421 IN UINT8 QuestionFlags
,
422 IN UINT8 StringFlags
,
425 IN OUT EFI_HII_UPDATE_DATA
*Data
430 Converts binary buffer to Unicode string in reversed byte order to BufToHexString().
432 @param Str String for output
433 @param Buffer Binary buffer.
434 @param BufferSize Size of the buffer in bytes.
436 @retval EFI_SUCCESS The function completed successfully.
449 Converts Hex String to binary buffer in reversed byte order to HexStringToBuf().
451 @param Buffer Pointer to buffer that receives the data.
452 @param BufferSize Length in bytes of the buffer to hold converted
453 data. If routine return with EFI_SUCCESS,
454 containing length of converted data. If routine
455 return with EFI_BUFFER_TOO_SMALL, containg length
457 @param Str String to be converted from.
459 @retval EFI_SUCCESS The function completed successfully.
465 IN OUT UINT8
*Buffer
,
466 IN OUT UINTN
*BufferSize
,
472 Construct <ConfigHdr> using routing information GUID/NAME/PATH.
474 @param ConfigHdr Pointer to the ConfigHdr string.
475 @param StrBufferLen On input: Length in bytes of buffer to hold the
476 ConfigHdr string. Includes tailing '\0' character.
477 On output: If return EFI_SUCCESS, containing
478 length of ConfigHdr string buffer. If return
479 EFI_BUFFER_TOO_SMALL, containg length of string
481 @param Guid Routing information: GUID.
482 @param Name Routing information: NAME.
483 @param DriverHandle Driver handle which contains the routing
486 @retval EFI_SUCCESS Routine success.
487 @retval EFI_BUFFER_TOO_SMALL The ConfigHdr string buffer is too small.
493 IN OUT CHAR16
*ConfigHdr
,
494 IN OUT UINTN
*StrBufferLen
,
496 IN CHAR16
*Name
, OPTIONAL
497 IN EFI_HANDLE
*DriverHandle
503 Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.
505 @param String The string to be searched in.
506 @param Offset Offset in BlockName.
507 @param Width Width in BlockName.
509 @retval TRUE Block name found.
510 @retval FALSE Block name not found.
516 IN OUT CHAR16
*String
,
523 This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.
525 @param VariableGuid An optional field to indicate the target variable
527 @param VariableName An optional field to indicate the target
528 human-readable variable name.
529 @param BufferSize On input: Length in bytes of buffer to hold
530 retrived data. On output: If return
531 EFI_BUFFER_TOO_SMALL, containg length of buffer
533 @param Buffer Buffer to hold retrived data.
535 @retval EFI_SUCCESS Routine success.
536 @retval EFI_BUFFER_TOO_SMALL The intput buffer is too small.
542 EFI_GUID
*VariableGuid
, OPTIONAL
543 CHAR16
*VariableName
, OPTIONAL
550 This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.
552 @param VariableGuid An optional field to indicate the target variable
554 @param VariableName An optional field to indicate the target
555 human-readable variable name.
556 @param BufferSize Length in bytes of buffer to hold retrived data.
557 @param Buffer Buffer to hold retrived data.
558 @param RequestElement An optional field to specify which part of the
559 buffer data will be send back to Browser. If NULL,
560 the whole buffer of data will be committed to
561 Browser. <RequestElement> ::=
562 &OFFSET=<Number>&WIDTH=<Number>*
564 @retval EFI_SUCCESS Routine success.
565 @retval Other Updating Browser uncommitted data failed.
571 EFI_GUID
*VariableGuid
, OPTIONAL
572 CHAR16
*VariableName
, OPTIONAL
575 CHAR16
*RequestElement OPTIONAL
580 Draw a dialog and return the selected key.
582 @param NumberOfLines The number of lines for the dialog box
583 @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
584 @param String Pointer to the first string in the list
585 @param ... A series of (quantity == NumberOfLines) text
586 strings which will be used to construct the dialog
589 @retval EFI_SUCCESS Displayed dialog and received user interaction
590 @retval EFI_INVALID_PARAMETER One of the parameters was invalid.
597 IN UINTN NumberOfLines
,
598 OUT EFI_INPUT_KEY
*KeyValue
,