2 The file contain all library functions and definitions for IFR opcode creation and
3 related Form Browser utility Operations.
5 Copyright (c) 2007 - 2008, 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.
36 #define EFI_LANGUAGE_VARIABLE L"Lang"
37 #define EFI_LANGUAGE_CODES_VARIABLE L"LangCodes"
39 #define UEFI_LANGUAGE_VARIABLE L"PlatformLang"
40 #define UEFI_LANGUAGE_CODES_VARIABLE L"PlatformLangCodes"
43 /// Limited buffer size recommended by RFC3066
44 /// (42 characters plus a NULL terminator)
46 #define RFC_3066_ENTRY_SIZE (42 + 1)
47 #define ISO_639_2_ENTRY_SIZE 3
49 #define INVALID_VARSTORE_ID 0
51 #define QUESTION_FLAGS (EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY)
52 #define QUESTION_FLAGS_MASK (~QUESTION_FLAGS)
56 EFI_STRING_ID StringToken
;
57 EFI_IFR_TYPE_VALUE Value
;
64 /// Buffer size allocated for Data.
69 /// Offset in Data to append the newly created opcode binary.
70 /// It will be adjusted automatically in Create***OpCode(), and should be
71 /// initialized to 0 before invocation of a serial of Create***OpCode()
76 /// The destination buffer for created op-codes
79 } EFI_HII_UPDATE_DATA
;
83 Create EFI_IFR_END_OP opcode.
85 If Data is NULL or Data->Data is NULL, then ASSERT.
87 @param Data Destination for the created opcode binary
89 @retval EFI_SUCCESS Opcode create success
90 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
96 IN OUT EFI_HII_UPDATE_DATA
*Data
101 Create EFI_IFR_DEFAULT_OP opcode.
103 @param Value Value for the default
104 @param Type Type for the default
105 @param Data Destination for the created opcode binary
107 @retval EFI_SUCCESS Opcode create success
108 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
109 @retval EFI_INVALID_PARAMETER The type is not valid.
114 CreateDefaultOpCode (
115 IN EFI_IFR_TYPE_VALUE
*Value
,
117 IN OUT EFI_HII_UPDATE_DATA
*Data
122 Create EFI_IFR_ACTION_OP opcode.
124 @param QuestionId Question ID
125 @param Prompt String ID for Prompt
126 @param Help String ID for Help
127 @param QuestionFlags Flags in Question Header
128 @param QuestionConfig String ID for configuration
129 @param Data Destination for the created opcode binary
131 @retval EFI_SUCCESS Opcode create success
132 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
133 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
139 IN EFI_QUESTION_ID QuestionId
,
140 IN EFI_STRING_ID Prompt
,
141 IN EFI_STRING_ID Help
,
142 IN UINT8 QuestionFlags
,
143 IN EFI_STRING_ID QuestionConfig
,
144 IN OUT EFI_HII_UPDATE_DATA
*Data
149 Create EFI_IFR_SUBTITLE_OP opcode.
151 @param Prompt String ID for Prompt
152 @param Help String ID for Help
153 @param Flags Subtitle opcode flags
154 @param Scope Subtitle Scope bit
155 @param Data Destination for the created opcode binary
157 @retval EFI_SUCCESS Opcode create success
158 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
163 CreateSubTitleOpCode (
164 IN EFI_STRING_ID Prompt
,
165 IN EFI_STRING_ID Help
,
168 IN OUT EFI_HII_UPDATE_DATA
*Data
173 Create EFI_IFR_TEXT_OP opcode.
175 @param Prompt String ID for Prompt
176 @param Help String ID for Help
177 @param TextTwo String ID for text two
178 @param Data Destination for the created opcode binary
180 @retval EFI_SUCCESS Opcode create success
181 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
187 IN EFI_STRING_ID Prompt
,
188 IN EFI_STRING_ID Help
,
189 IN EFI_STRING_ID TextTwo
,
190 IN OUT EFI_HII_UPDATE_DATA
*Data
195 Create EFI_IFR_REF_OP opcode.
197 @param FormId Destination Form ID
198 @param Prompt String ID for Prompt
199 @param Help String ID for Help
200 @param QuestionFlags Flags in Question Header
201 @param QuestionId Question ID
202 @param Data Destination for the created opcode binary
204 @retval EFI_SUCCESS Opcode create success
205 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
206 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
212 IN EFI_FORM_ID FormId
,
213 IN EFI_STRING_ID Prompt
,
214 IN EFI_STRING_ID Help
,
215 IN UINT8 QuestionFlags
,
216 IN EFI_QUESTION_ID QuestionId
,
217 IN OUT EFI_HII_UPDATE_DATA
*Data
222 Create EFI_IFR_ONE_OF_OPTION_OP opcode.
224 @param OptionCount The number of options.
225 @param OptionsList The list of Options.
226 @param Type The data type.
227 @param Data Destination for the created opcode binary
229 @retval EFI_SUCCESS Opcode create success
230 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
235 CreateOneOfOptionOpCode (
236 IN UINTN OptionCount
,
237 IN IFR_OPTION
*OptionsList
,
239 IN OUT EFI_HII_UPDATE_DATA
*Data
244 Create EFI_IFR_ONE_OF_OP opcode.
246 @param QuestionId Question ID
247 @param VarStoreId Storage ID
248 @param VarOffset Offset in Storage
249 @param Prompt String ID for Prompt
250 @param Help String ID for Help
251 @param QuestionFlags Flags in Question Header
252 @param OneOfFlags Flags for oneof opcode
253 @param OptionsList List of options
254 @param OptionCount Number of options in option list
255 @param Data Destination for the created opcode binary
257 @retval EFI_SUCCESS Opcode create success
258 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
259 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
265 IN EFI_QUESTION_ID QuestionId
,
266 IN EFI_VARSTORE_ID VarStoreId
,
268 IN EFI_STRING_ID Prompt
,
269 IN EFI_STRING_ID Help
,
270 IN UINT8 QuestionFlags
,
272 IN IFR_OPTION
*OptionsList
,
273 IN UINTN OptionCount
,
274 IN OUT EFI_HII_UPDATE_DATA
*Data
279 Create EFI_IFR_ORDERED_LIST_OP opcode.
281 @param QuestionId Question ID
282 @param VarStoreId Storage ID
283 @param VarOffset Offset in Storage
284 @param Prompt String ID for Prompt
285 @param Help String ID for Help
286 @param QuestionFlags Flags in Question Header
287 @param OrderedListFlags Flags for ordered list opcode
288 @param DataType Type for option value
289 @param MaxContainers Maximum count for options in this ordered list
290 @param OptionsList List of options
291 @param OptionCount Number of options in option list
292 @param Data Destination for the created opcode binary
294 @retval EFI_SUCCESS Opcode create success
295 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
296 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
301 CreateOrderedListOpCode (
302 IN EFI_QUESTION_ID QuestionId
,
303 IN EFI_VARSTORE_ID VarStoreId
,
305 IN EFI_STRING_ID Prompt
,
306 IN EFI_STRING_ID Help
,
307 IN UINT8 QuestionFlags
,
308 IN UINT8 OrderedListFlags
,
310 IN UINT8 MaxContainers
,
311 IN IFR_OPTION
*OptionsList
,
312 IN UINTN OptionCount
,
313 IN OUT EFI_HII_UPDATE_DATA
*Data
318 Create EFI_IFR_CHECKBOX_OP opcode.
320 @param QuestionId Question ID
321 @param VarStoreId Storage ID
322 @param VarOffset Offset in Storage
323 @param Prompt String ID for Prompt
324 @param Help String ID for Help
325 @param QuestionFlags Flags in Question Header
326 @param CheckBoxFlags Flags for checkbox opcode
327 @param Data Destination for the created opcode binary
329 @retval EFI_SUCCESS Opcode create success
330 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
331 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
336 CreateCheckBoxOpCode (
337 IN EFI_QUESTION_ID QuestionId
,
338 IN EFI_VARSTORE_ID VarStoreId
,
340 IN EFI_STRING_ID Prompt
,
341 IN EFI_STRING_ID Help
,
342 IN UINT8 QuestionFlags
,
343 IN UINT8 CheckBoxFlags
,
344 IN OUT EFI_HII_UPDATE_DATA
*Data
349 Create EFI_IFR_NUMERIC_OP opcode.
351 @param QuestionId Question ID
352 @param VarStoreId Storage ID
353 @param VarOffset Offset in Storage
354 @param Prompt String ID for Prompt
355 @param Help String ID for Help
356 @param QuestionFlags Flags in Question Header
357 @param NumericFlags Flags for numeric opcode
358 @param Minimum Numeric minimum value
359 @param Maximum Numeric maximum value
360 @param Step Numeric step for edit
361 @param Default Numeric default value
362 @param Data Destination for the created opcode binary
364 @retval EFI_SUCCESS Opcode create success
365 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
366 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
371 CreateNumericOpCode (
372 IN EFI_QUESTION_ID QuestionId
,
373 IN EFI_VARSTORE_ID VarStoreId
,
375 IN EFI_STRING_ID Prompt
,
376 IN EFI_STRING_ID Help
,
377 IN UINT8 QuestionFlags
,
378 IN UINT8 NumericFlags
,
383 IN OUT EFI_HII_UPDATE_DATA
*Data
388 Create EFI_IFR_STRING_OP opcode.
390 @param QuestionId Question ID
391 @param VarStoreId Storage ID
392 @param VarOffset Offset in Storage
393 @param Prompt String ID for Prompt
394 @param Help String ID for Help
395 @param QuestionFlags Flags in Question Header
396 @param StringFlags Flags for string opcode
397 @param MinSize String minimum length
398 @param MaxSize String maximum length
399 @param Data Destination for the created opcode binary
401 @retval EFI_SUCCESS Opcode create success
402 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
403 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
409 IN EFI_QUESTION_ID QuestionId
,
410 IN EFI_VARSTORE_ID VarStoreId
,
412 IN EFI_STRING_ID Prompt
,
413 IN EFI_STRING_ID Help
,
414 IN UINT8 QuestionFlags
,
415 IN UINT8 StringFlags
,
418 IN OUT EFI_HII_UPDATE_DATA
*Data
423 Converts the unicode character of the string from uppercase to lowercase.
425 @param Str String to be converted
437 Converts binary buffer to Unicode string in reversed byte order to BufToHexString().
439 @param Str String for output
440 @param Buffer Binary buffer.
441 @param BufferSize Size of the buffer in bytes.
443 @retval EFI_SUCCESS The function completed successfully.
456 Converts Hex String to binary buffer in reversed byte order to HexStringToBuf().
458 @param Buffer Pointer to buffer that receives the data.
459 @param BufferSize Length in bytes of the buffer to hold converted
460 data. If routine return with EFI_SUCCESS,
461 containing length of converted data. If routine
462 return with EFI_BUFFER_TOO_SMALL, containg length
464 @param Str String to be converted from.
466 @retval EFI_SUCCESS The function completed successfully.
472 IN OUT UINT8
*Buffer
,
473 IN OUT UINTN
*BufferSize
,
479 Convert binary representation Config string (e.g. "0041004200430044") to the
480 original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.
481 "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
483 @param UnicodeString Original Unicode string.
484 @param StrBufferLen On input: Length in bytes of buffer to hold the Unicode string.
485 Includes tailing '\0' character.
487 If return EFI_SUCCESS, containing length of Unicode string buffer.
488 If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
489 @param ConfigString Binary representation of Unicode String, <string> := (<HexCh>4)+
491 @retval EFI_SUCCESS Routine success.
492 @retval EFI_BUFFER_TOO_SMALL The string buffer is too small.
497 ConfigStringToUnicode (
498 IN OUT CHAR16
*UnicodeString
,
499 IN OUT UINTN
*StrBufferLen
,
500 IN CHAR16
*ConfigString
505 Convert Unicode string to binary representation Config string, e.g.
506 "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
507 "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
509 @param ConfigString Binary representation of Unicode String, <string> := (<HexCh>4)+
510 @param StrBufferLen On input: Length in bytes of buffer to hold the Unicode string.
511 Includes tailing '\0' character.
513 If return EFI_SUCCESS, containing length of Unicode string buffer.
514 If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
515 @param UnicodeString Original Unicode string.
517 @retval EFI_SUCCESS Routine success.
518 @retval EFI_BUFFER_TOO_SMALL The string buffer is too small.
523 UnicodeToConfigString (
524 IN OUT CHAR16
*ConfigString
,
525 IN OUT UINTN
*StrBufferLen
,
526 IN CHAR16
*UnicodeString
531 Construct <ConfigHdr> using routing information GUID/NAME/PATH.
533 @param ConfigHdr Pointer to the ConfigHdr string.
534 @param StrBufferLen On input: Length in bytes of buffer to hold the
535 ConfigHdr string. Includes tailing '\0' character.
536 On output: If return EFI_SUCCESS, containing
537 length of ConfigHdr string buffer. If return
538 EFI_BUFFER_TOO_SMALL, containg length of string
540 @param Guid Routing information: GUID.
541 @param Name Routing information: NAME.
542 @param DriverHandle Driver handle which contains the routing
545 @retval EFI_SUCCESS Routine success.
546 @retval EFI_BUFFER_TOO_SMALL The ConfigHdr string buffer is too small.
552 IN OUT CHAR16
*ConfigHdr
,
553 IN OUT UINTN
*StrBufferLen
,
554 IN CONST EFI_GUID
*Guid
,
555 IN CHAR16
*Name
, OPTIONAL
556 IN EFI_HANDLE
*DriverHandle
562 Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.
564 @param String The string to be searched in.
565 @param Offset Offset in BlockName.
566 @param Width Width in BlockName.
568 @retval TRUE Block name found.
569 @retval FALSE Block name not found.
575 IN OUT CHAR16
*String
,
582 This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.
584 @param VariableGuid An optional field to indicate the target variable
586 @param VariableName An optional field to indicate the target
587 human-readable variable name.
588 @param BufferSize On input: Length in bytes of buffer to hold
589 retrived data. On output: If return
590 EFI_BUFFER_TOO_SMALL, containg length of buffer
592 @param Buffer Buffer to hold retrived data.
594 @retval EFI_SUCCESS Routine success.
595 @retval EFI_BUFFER_TOO_SMALL The intput buffer is too small.
601 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
602 IN CONST CHAR16
*VariableName
, OPTIONAL
603 IN OUT UINTN
*BufferSize
,
609 This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.
611 @param VariableGuid An optional field to indicate the target variable
613 @param VariableName An optional field to indicate the target
614 human-readable variable name.
615 @param BufferSize Length in bytes of buffer to hold retrived data.
616 @param Buffer Buffer to hold retrived data.
617 @param RequestElement An optional field to specify which part of the
618 buffer data will be send back to Browser. If NULL,
619 the whole buffer of data will be committed to
620 Browser. <RequestElement> ::=
621 &OFFSET=<Number>&WIDTH=<Number>*
623 @retval EFI_SUCCESS Routine success.
624 @retval Other Updating Browser uncommitted data failed.
630 IN CONST EFI_GUID
*VariableGuid
, OPTIONAL
631 IN CONST CHAR16
*VariableName
, OPTIONAL
633 IN CONST UINT8
*Buffer
,
634 IN CONST CHAR16
*RequestElement OPTIONAL
639 Draw a dialog and return the selected key.
641 @param NumberOfLines The number of lines for the dialog box
642 @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
643 @param String Pointer to the first string in the list
644 @param ... A series of (quantity == NumberOfLines - 1) text
645 strings which will be used to construct the dialog
648 @retval EFI_SUCCESS Displayed dialog and received user interaction
649 @retval EFI_INVALID_PARAMETER One of the parameters was invalid.
655 IN UINTN NumberOfLines
,
656 OUT EFI_INPUT_KEY
*KeyValue
,
663 Draw a dialog and return the selected key using Variable Argument List.
665 @param NumberOfLines The number of lines for the dialog box
666 @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
667 @param String Pointer to the first string in the list
668 @param Args VA_LIST marker for the variable argument list.
669 A series of (quantity == NumberOfLines - 1) text
670 strings which will be used to construct the dialog
673 @retval EFI_SUCCESS Displayed dialog and received user interaction
674 @retval EFI_INVALID_PARAMETER One of the parameters was invalid.
680 IN UINTN NumberOfLines
,
681 OUT EFI_INPUT_KEY
*KeyValue
,