]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/IfrSupportLib.h
Use doxygen comment style for document entity such as struct, enum, variable that...
[mirror_edk2.git] / MdePkg / Include / Library / IfrSupportLib.h
1 /** @file
2 The file contain all library functions and definitions for IFR opcode creation and
3 related Form Browser utility Operations.
4
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
10
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.
13
14 **/
15
16 #ifndef _IFR_SUPPORT_LIBRARY_H_
17 #define _IFR_SUPPORT_LIBRARY_H_
18
19
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>
28
29 #include <Guid/GlobalVariable.h>
30
31 //
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
36 #define EFI_LANGUAGE_VARIABLE L"Lang"
37 #define EFI_LANGUAGE_CODES_VARIABLE L"LangCodes"
38
39 #define UEFI_LANGUAGE_VARIABLE L"PlatformLang"
40 #define UEFI_LANGUAGE_CODES_VARIABLE L"PlatformLangCodes"
41
42 //
43 // Limited buffer size recommended by RFC4646 (4.3. Length Considerations)
44 // (42 characters plus a NULL terminator)
45 //
46 #define RFC_3066_ENTRY_SIZE (42 + 1)
47 #define ISO_639_2_ENTRY_SIZE 3
48
49 #define INVALID_VARSTORE_ID 0
50
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)
53
54 extern EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;
55 extern EFI_HII_STRING_PROTOCOL *gIfrLibHiiString;
56
57 #pragma pack(1)
58 typedef struct {
59 EFI_STRING_ID StringToken;
60 EFI_IFR_TYPE_VALUE Value;
61 UINT8 Flags;
62 } IFR_OPTION;
63 #pragma pack()
64
65 typedef struct {
66 ///
67 /// Buffer size allocated for Data.
68 ///
69 UINT32 BufferSize;
70
71 ///
72 /// Offset in Data to append the newly created opcode binary.
73 /// It will be adjusted automatically in Create***OpCode(), and should be
74 /// initialized to 0 before invocation of a serial of Create***OpCode()
75 ///
76 UINT32 Offset;
77
78 ///
79 /// The destination buffer for created op-codes
80 ///
81 UINT8 *Data;
82 } EFI_HII_UPDATE_DATA;
83
84
85 /**
86 Create EFI_IFR_END_OP opcode.
87
88 If Data is NULL or Data->Data is NULL, then ASSERT.
89
90 @param Data Destination for the created opcode binary
91
92 @retval EFI_SUCCESS Opcode create success
93 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
94
95 **/
96 EFI_STATUS
97 EFIAPI
98 CreateEndOpCode (
99 IN OUT EFI_HII_UPDATE_DATA *Data
100 )
101 ;
102
103 /**
104 Create EFI_IFR_DEFAULT_OP opcode.
105
106 @param Value Value for the default
107 @param Type Type for the default
108 @param Data Destination for the created opcode binary
109
110 @retval EFI_SUCCESS Opcode create success
111 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
112 @retval EFI_INVALID_PARAMETER The type is not valid.
113
114 **/
115 EFI_STATUS
116 EFIAPI
117 CreateDefaultOpCode (
118 IN EFI_IFR_TYPE_VALUE *Value,
119 IN UINT8 Type,
120 IN OUT EFI_HII_UPDATE_DATA *Data
121 )
122 ;
123
124 /**
125 Create EFI_IFR_ACTION_OP opcode.
126
127 @param QuestionId Question ID
128 @param Prompt String ID for Prompt
129 @param Help String ID for Help
130 @param QuestionFlags Flags in Question Header
131 @param QuestionConfig String ID for configuration
132 @param Data Destination for the created opcode binary
133
134 @retval EFI_SUCCESS Opcode create success
135 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
136 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
137
138 **/
139 EFI_STATUS
140 EFIAPI
141 CreateActionOpCode (
142 IN EFI_QUESTION_ID QuestionId,
143 IN EFI_STRING_ID Prompt,
144 IN EFI_STRING_ID Help,
145 IN UINT8 QuestionFlags,
146 IN EFI_STRING_ID QuestionConfig,
147 IN OUT EFI_HII_UPDATE_DATA *Data
148 )
149 ;
150
151 /**
152 Create EFI_IFR_SUBTITLE_OP opcode.
153
154 @param Prompt String ID for Prompt
155 @param Help String ID for Help
156 @param Flags Subtitle opcode flags
157 @param Scope Subtitle Scope bit
158 @param Data Destination for the created opcode binary
159
160 @retval EFI_SUCCESS Opcode create success
161 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
162
163 **/
164 EFI_STATUS
165 EFIAPI
166 CreateSubTitleOpCode (
167 IN EFI_STRING_ID Prompt,
168 IN EFI_STRING_ID Help,
169 IN UINT8 Flags,
170 IN UINT8 Scope,
171 IN OUT EFI_HII_UPDATE_DATA *Data
172 )
173 ;
174
175 /**
176 Create EFI_IFR_TEXT_OP opcode.
177
178 @param Prompt String ID for Prompt
179 @param Help String ID for Help
180 @param TextTwo String ID for text two
181 @param Data Destination for the created opcode binary
182
183 @retval EFI_SUCCESS Opcode create success
184 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
185
186 **/
187 EFI_STATUS
188 EFIAPI
189 CreateTextOpCode (
190 IN EFI_STRING_ID Prompt,
191 IN EFI_STRING_ID Help,
192 IN EFI_STRING_ID TextTwo,
193 IN OUT EFI_HII_UPDATE_DATA *Data
194 )
195 ;
196
197 /**
198 Create EFI_IFR_REF_OP opcode.
199
200 @param FormId Destination Form ID
201 @param Prompt String ID for Prompt
202 @param Help String ID for Help
203 @param QuestionFlags Flags in Question Header
204 @param QuestionId Question ID
205 @param Data Destination for the created opcode binary
206
207 @retval EFI_SUCCESS Opcode create success
208 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
209 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
210
211 **/
212 EFI_STATUS
213 EFIAPI
214 CreateGotoOpCode (
215 IN EFI_FORM_ID FormId,
216 IN EFI_STRING_ID Prompt,
217 IN EFI_STRING_ID Help,
218 IN UINT8 QuestionFlags,
219 IN EFI_QUESTION_ID QuestionId,
220 IN OUT EFI_HII_UPDATE_DATA *Data
221 )
222 ;
223
224 /**
225 Create EFI_IFR_ONE_OF_OPTION_OP opcode.
226
227 @param OptionCount The number of options.
228 @param OptionsList The list of Options.
229 @param Type The data type.
230 @param Data Destination for the created opcode binary
231
232 @retval EFI_SUCCESS Opcode create success
233 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
234
235 **/
236 EFI_STATUS
237 EFIAPI
238 CreateOneOfOptionOpCode (
239 IN UINTN OptionCount,
240 IN IFR_OPTION *OptionsList,
241 IN UINT8 Type,
242 IN OUT EFI_HII_UPDATE_DATA *Data
243 )
244 ;
245
246 /**
247 Create EFI_IFR_ONE_OF_OP opcode.
248
249 @param QuestionId Question ID
250 @param VarStoreId Storage ID
251 @param VarOffset Offset in Storage
252 @param Prompt String ID for Prompt
253 @param Help String ID for Help
254 @param QuestionFlags Flags in Question Header
255 @param OneOfFlags Flags for oneof opcode
256 @param OptionsList List of options
257 @param OptionCount Number of options in option list
258 @param Data Destination for the created opcode binary
259
260 @retval EFI_SUCCESS Opcode create success
261 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
262 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
263
264 **/
265 EFI_STATUS
266 EFIAPI
267 CreateOneOfOpCode (
268 IN EFI_QUESTION_ID QuestionId,
269 IN EFI_VARSTORE_ID VarStoreId,
270 IN UINT16 VarOffset,
271 IN EFI_STRING_ID Prompt,
272 IN EFI_STRING_ID Help,
273 IN UINT8 QuestionFlags,
274 IN UINT8 OneOfFlags,
275 IN IFR_OPTION *OptionsList,
276 IN UINTN OptionCount,
277 IN OUT EFI_HII_UPDATE_DATA *Data
278 )
279 ;
280
281 /**
282 Create EFI_IFR_ORDERED_LIST_OP opcode.
283
284 @param QuestionId Question ID
285 @param VarStoreId Storage ID
286 @param VarOffset Offset in Storage
287 @param Prompt String ID for Prompt
288 @param Help String ID for Help
289 @param QuestionFlags Flags in Question Header
290 @param OrderedListFlags Flags for ordered list opcode
291 @param DataType Type for option value
292 @param MaxContainers Maximum count for options in this ordered list
293 @param OptionsList List of options
294 @param OptionCount Number of options in option list
295 @param Data Destination for the created opcode binary
296
297 @retval EFI_SUCCESS Opcode create success
298 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
299 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
300
301 **/
302 EFI_STATUS
303 EFIAPI
304 CreateOrderedListOpCode (
305 IN EFI_QUESTION_ID QuestionId,
306 IN EFI_VARSTORE_ID VarStoreId,
307 IN UINT16 VarOffset,
308 IN EFI_STRING_ID Prompt,
309 IN EFI_STRING_ID Help,
310 IN UINT8 QuestionFlags,
311 IN UINT8 OrderedListFlags,
312 IN UINT8 DataType,
313 IN UINT8 MaxContainers,
314 IN IFR_OPTION *OptionsList,
315 IN UINTN OptionCount,
316 IN OUT EFI_HII_UPDATE_DATA *Data
317 )
318 ;
319
320 /**
321 Create EFI_IFR_CHECKBOX_OP opcode.
322
323 @param QuestionId Question ID
324 @param VarStoreId Storage ID
325 @param VarOffset Offset in Storage
326 @param Prompt String ID for Prompt
327 @param Help String ID for Help
328 @param QuestionFlags Flags in Question Header
329 @param CheckBoxFlags Flags for checkbox opcode
330 @param Data Destination for the created opcode binary
331
332 @retval EFI_SUCCESS Opcode create success
333 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
334 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
335
336 **/
337 EFI_STATUS
338 EFIAPI
339 CreateCheckBoxOpCode (
340 IN EFI_QUESTION_ID QuestionId,
341 IN EFI_VARSTORE_ID VarStoreId,
342 IN UINT16 VarOffset,
343 IN EFI_STRING_ID Prompt,
344 IN EFI_STRING_ID Help,
345 IN UINT8 QuestionFlags,
346 IN UINT8 CheckBoxFlags,
347 IN OUT EFI_HII_UPDATE_DATA *Data
348 )
349 ;
350
351 /**
352 Create EFI_IFR_NUMERIC_OP opcode.
353
354 @param QuestionId Question ID
355 @param VarStoreId Storage ID
356 @param VarOffset Offset in Storage
357 @param Prompt String ID for Prompt
358 @param Help String ID for Help
359 @param QuestionFlags Flags in Question Header
360 @param NumericFlags Flags for numeric opcode
361 @param Minimum Numeric minimum value
362 @param Maximum Numeric maximum value
363 @param Step Numeric step for edit
364 @param Default Numeric default value
365 @param Data Destination for the created opcode binary
366
367 @retval EFI_SUCCESS Opcode create success
368 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
369 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
370
371 **/
372 EFI_STATUS
373 EFIAPI
374 CreateNumericOpCode (
375 IN EFI_QUESTION_ID QuestionId,
376 IN EFI_VARSTORE_ID VarStoreId,
377 IN UINT16 VarOffset,
378 IN EFI_STRING_ID Prompt,
379 IN EFI_STRING_ID Help,
380 IN UINT8 QuestionFlags,
381 IN UINT8 NumericFlags,
382 IN UINT64 Minimum,
383 IN UINT64 Maximum,
384 IN UINT64 Step,
385 IN UINT64 Default,
386 IN OUT EFI_HII_UPDATE_DATA *Data
387 )
388 ;
389
390 /**
391 Create EFI_IFR_STRING_OP opcode.
392
393 @param QuestionId Question ID
394 @param VarStoreId Storage ID
395 @param VarOffset Offset in Storage
396 @param Prompt String ID for Prompt
397 @param Help String ID for Help
398 @param QuestionFlags Flags in Question Header
399 @param StringFlags Flags for string opcode
400 @param MinSize String minimum length
401 @param MaxSize String maximum length
402 @param Data Destination for the created opcode binary
403
404 @retval EFI_SUCCESS Opcode create success
405 @retval EFI_BUFFER_TOO_SMALL The space reserved in Data field is too small.
406 @retval EFI_INVALID_PARAMETER If QuestionFlags is not valid.
407
408 **/
409 EFI_STATUS
410 EFIAPI
411 CreateStringOpCode (
412 IN EFI_QUESTION_ID QuestionId,
413 IN EFI_VARSTORE_ID VarStoreId,
414 IN UINT16 VarOffset,
415 IN EFI_STRING_ID Prompt,
416 IN EFI_STRING_ID Help,
417 IN UINT8 QuestionFlags,
418 IN UINT8 StringFlags,
419 IN UINT8 MinSize,
420 IN UINT8 MaxSize,
421 IN OUT EFI_HII_UPDATE_DATA *Data
422 )
423 ;
424
425 /**
426 Converts the unicode character of the string from uppercase to lowercase.
427
428 @param Str String to be converted
429
430
431 **/
432 VOID
433 EFIAPI
434 ToLower (
435 IN OUT CHAR16 *Str
436 )
437 ;
438
439 /**
440 Converts binary buffer to Unicode string in reversed byte order to BufToHexString().
441
442 @param Str String for output
443 @param Buffer Binary buffer.
444 @param BufferSize Size of the buffer in bytes.
445
446 @retval EFI_SUCCESS The function completed successfully.
447
448 **/
449 EFI_STATUS
450 EFIAPI
451 BufferToHexString (
452 IN OUT CHAR16 *Str,
453 IN UINT8 *Buffer,
454 IN UINTN BufferSize
455 )
456 ;
457
458 /**
459 Converts Hex String to binary buffer in reversed byte order to HexStringToBuf().
460
461 @param Buffer Pointer to buffer that receives the data.
462 @param BufferSize Length in bytes of the buffer to hold converted
463 data. If routine return with EFI_SUCCESS,
464 containing length of converted data. If routine
465 return with EFI_BUFFER_TOO_SMALL, containg length
466 of buffer desired.
467 @param Str String to be converted from.
468
469 @retval EFI_SUCCESS The function completed successfully.
470
471 **/
472 EFI_STATUS
473 EFIAPI
474 HexStringToBuffer (
475 IN OUT UINT8 *Buffer,
476 IN OUT UINTN *BufferSize,
477 IN CHAR16 *Str
478 )
479 ;
480
481 /**
482 Convert binary representation Config string (e.g. "0041004200430044") to the
483 original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.
484 "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
485
486 @param UnicodeString Original Unicode string.
487 @param StrBufferLen On input: Length in bytes of buffer to hold the Unicode string.
488 Includes tailing '\0' character.
489 On output:
490 If return EFI_SUCCESS, containing length of Unicode string buffer.
491 If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
492 @param ConfigString Binary representation of Unicode String, <string> := (<HexCh>4)+
493
494 @retval EFI_SUCCESS Routine success.
495 @retval EFI_BUFFER_TOO_SMALL The string buffer is too small.
496
497 **/
498 EFI_STATUS
499 EFIAPI
500 ConfigStringToUnicode (
501 IN OUT CHAR16 *UnicodeString,
502 IN OUT UINTN *StrBufferLen,
503 IN CHAR16 *ConfigString
504 )
505 ;
506
507 /**
508 Convert Unicode string to binary representation Config string, e.g.
509 "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
510 "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
511
512 @param ConfigString Binary representation of Unicode String, <string> := (<HexCh>4)+
513 @param StrBufferLen On input: Length in bytes of buffer to hold the Unicode string.
514 Includes tailing '\0' character.
515 On output:
516 If return EFI_SUCCESS, containing length of Unicode string buffer.
517 If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
518 @param UnicodeString Original Unicode string.
519
520 @retval EFI_SUCCESS Routine success.
521 @retval EFI_BUFFER_TOO_SMALL The string buffer is too small.
522
523 **/
524 EFI_STATUS
525 EFIAPI
526 UnicodeToConfigString (
527 IN OUT CHAR16 *ConfigString,
528 IN OUT UINTN *StrBufferLen,
529 IN CHAR16 *UnicodeString
530 )
531 ;
532
533 /**
534 Construct <ConfigHdr> using routing information GUID/NAME/PATH.
535
536 @param ConfigHdr Pointer to the ConfigHdr string.
537 @param StrBufferLen On input: Length in bytes of buffer to hold the
538 ConfigHdr string. Includes tailing '\0' character.
539 On output: If return EFI_SUCCESS, containing
540 length of ConfigHdr string buffer. If return
541 EFI_BUFFER_TOO_SMALL, containg length of string
542 buffer desired.
543 @param Guid Routing information: GUID.
544 @param Name Routing information: NAME.
545 @param DriverHandle Driver handle which contains the routing
546 information: PATH.
547
548 @retval EFI_SUCCESS Routine success.
549 @retval EFI_BUFFER_TOO_SMALL The ConfigHdr string buffer is too small.
550
551 **/
552 EFI_STATUS
553 EFIAPI
554 ConstructConfigHdr (
555 IN OUT CHAR16 *ConfigHdr,
556 IN OUT UINTN *StrBufferLen,
557 IN EFI_GUID *Guid,
558 IN CHAR16 *Name, OPTIONAL
559 IN EFI_HANDLE *DriverHandle
560 )
561
562 ;
563
564 /**
565 Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.
566
567 @param String The string to be searched in.
568 @param Offset Offset in BlockName.
569 @param Width Width in BlockName.
570
571 @retval TRUE Block name found.
572 @retval FALSE Block name not found.
573
574 **/
575 BOOLEAN
576 EFIAPI
577 FindBlockName (
578 IN OUT CHAR16 *String,
579 UINTN Offset,
580 UINTN Width
581 )
582 ;
583
584 /**
585 This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.
586
587 @param VariableGuid An optional field to indicate the target variable
588 GUID name to use.
589 @param VariableName An optional field to indicate the target
590 human-readable variable name.
591 @param BufferSize On input: Length in bytes of buffer to hold
592 retrived data. On output: If return
593 EFI_BUFFER_TOO_SMALL, containg length of buffer
594 desired.
595 @param Buffer Buffer to hold retrived data.
596
597 @retval EFI_SUCCESS Routine success.
598 @retval EFI_BUFFER_TOO_SMALL The intput buffer is too small.
599
600 **/
601 EFI_STATUS
602 EFIAPI
603 GetBrowserData (
604 EFI_GUID *VariableGuid, OPTIONAL
605 CHAR16 *VariableName, OPTIONAL
606 UINTN *BufferSize,
607 UINT8 *Buffer
608 )
609 ;
610
611 /**
612 This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.
613
614 @param VariableGuid An optional field to indicate the target variable
615 GUID name to use.
616 @param VariableName An optional field to indicate the target
617 human-readable variable name.
618 @param BufferSize Length in bytes of buffer to hold retrived data.
619 @param Buffer Buffer to hold retrived data.
620 @param RequestElement An optional field to specify which part of the
621 buffer data will be send back to Browser. If NULL,
622 the whole buffer of data will be committed to
623 Browser. <RequestElement> ::=
624 &OFFSET=<Number>&WIDTH=<Number>*
625
626 @retval EFI_SUCCESS Routine success.
627 @retval Other Updating Browser uncommitted data failed.
628
629 **/
630 EFI_STATUS
631 EFIAPI
632 SetBrowserData (
633 EFI_GUID *VariableGuid, OPTIONAL
634 CHAR16 *VariableName, OPTIONAL
635 UINTN BufferSize,
636 UINT8 *Buffer,
637 CHAR16 *RequestElement OPTIONAL
638 )
639 ;
640
641 /**
642 Draw a dialog and return the selected key.
643
644 @param NumberOfLines The number of lines for the dialog box
645 @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
646 @param String Pointer to the first string in the list
647 @param ... A series of (quantity == NumberOfLines - 1) text
648 strings which will be used to construct the dialog
649 box
650
651 @retval EFI_SUCCESS Displayed dialog and received user interaction
652 @retval EFI_INVALID_PARAMETER One of the parameters was invalid.
653
654 **/
655 EFI_STATUS
656 EFIAPI
657 IfrLibCreatePopUp (
658 IN UINTN NumberOfLines,
659 OUT EFI_INPUT_KEY *KeyValue,
660 IN CHAR16 *String,
661 ...
662 )
663 ;
664
665 #endif