]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/IfrSupportLib.h
Merged in the following trackers from EDK:
[mirror_edk2.git] / MdePkg / Include / Library / IfrSupportLib.h
CommitLineData
8069d49e 1/** @file
d9e5c1ff 2 The file contain all library functions and definitions for IFR opcode creation and
8069d49e
LG
3 related Form Browser utility Operations.
4
54cf8780 5 Copyright (c) 2007 - 2008, Intel Corporation
8069d49e
LG
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
d9e5c1ff 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
54extern EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;
55extern EFI_HII_STRING_PROTOCOL *gIfrLibHiiString;
56
57#pragma pack(1)
58typedef struct {
59 EFI_STRING_ID StringToken;
60 EFI_IFR_TYPE_VALUE Value;
61 UINT8 Flags;
62} IFR_OPTION;
63#pragma pack()
64
65typedef 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**/
96EFI_STATUS
97EFIAPI
98CreateEndOpCode (
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**/
115EFI_STATUS
116EFIAPI
117CreateDefaultOpCode (
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**/
139EFI_STATUS
140EFIAPI
141CreateActionOpCode (
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**/
164EFI_STATUS
165EFIAPI
166CreateSubTitleOpCode (
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**/
187EFI_STATUS
188EFIAPI
189CreateTextOpCode (
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**/
212EFI_STATUS
213EFIAPI
214CreateGotoOpCode (
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 QuestionId Question ID
228 @param OptionList 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**/
236EFI_STATUS
237EFIAPI
238CreateOneOfOptionOpCode (
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**/
265EFI_STATUS
266EFIAPI
267CreateOneOfOpCode (
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 Flags 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**/
302EFI_STATUS
303EFIAPI
304CreateOrderedListOpCode (
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 Flags,
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**/
337EFI_STATUS
338EFIAPI
339CreateCheckBoxOpCode (
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**/
372EFI_STATUS
373EFIAPI
374CreateNumericOpCode (
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**/
409EFI_STATUS
410EFIAPI
411CreateStringOpCode (
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
54cf8780 425/**
426 Converts the unicode character of the string from uppercase to lowercase.
427
428 @param Str String to be converted
429
430 @retval VOID
431
432**/
433VOID
434ToLower (
435 IN OUT CHAR16 *Str
436 )
437;
438
d9e5c1ff 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**/
449EFI_STATUS
450EFIAPI
451BufferToHexString (
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**/
472EFI_STATUS
473EFIAPI
474HexStringToBuffer (
475 IN OUT UINT8 *Buffer,
476 IN OUT UINTN *BufferSize,
477 IN CHAR16 *Str
478 )
479;
480
54cf8780 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**/EFI_STATUS
498ConfigStringToUnicode (
499 IN OUT CHAR16 *UnicodeString,
500 IN OUT UINTN *StrBufferLen,
501 IN CHAR16 *ConfigString
502 )
503;
504
505/**
506 Convert Unicode string to binary representation Config string, e.g.
507 "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
508 "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
509
510 @param ConfigString Binary representation of Unicode String, <string> := (<HexCh>4)+
511 @param StrBufferLen On input: Length in bytes of buffer to hold the Unicode string.
512 Includes tailing '\0' character.
513 On output:
514 If return EFI_SUCCESS, containing length of Unicode string buffer.
515 If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
516 @param UnicodeString Original Unicode string.
517
518 @retval EFI_SUCCESS Routine success.
519 @retval EFI_BUFFER_TOO_SMALL The string buffer is too small.
520
521**/EFI_STATUS
522UnicodeToConfigString (
523 IN OUT CHAR16 *ConfigString,
524 IN OUT UINTN *StrBufferLen,
525 IN CHAR16 *UnicodeString
526 )
527;
528
d9e5c1ff 529/**
530 Construct <ConfigHdr> using routing information GUID/NAME/PATH.
531
532 @param ConfigHdr Pointer to the ConfigHdr string.
533 @param StrBufferLen On input: Length in bytes of buffer to hold the
534 ConfigHdr string. Includes tailing '\0' character.
535 On output: If return EFI_SUCCESS, containing
536 length of ConfigHdr string buffer. If return
537 EFI_BUFFER_TOO_SMALL, containg length of string
538 buffer desired.
539 @param Guid Routing information: GUID.
540 @param Name Routing information: NAME.
541 @param DriverHandle Driver handle which contains the routing
542 information: PATH.
543
544 @retval EFI_SUCCESS Routine success.
545 @retval EFI_BUFFER_TOO_SMALL The ConfigHdr string buffer is too small.
546
547**/
548EFI_STATUS
549EFIAPI
550ConstructConfigHdr (
551 IN OUT CHAR16 *ConfigHdr,
552 IN OUT UINTN *StrBufferLen,
553 IN EFI_GUID *Guid,
554 IN CHAR16 *Name, OPTIONAL
555 IN EFI_HANDLE *DriverHandle
556 )
557
558;
559
560/**
561 Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.
562
563 @param String The string to be searched in.
564 @param Offset Offset in BlockName.
565 @param Width Width in BlockName.
566
567 @retval TRUE Block name found.
568 @retval FALSE Block name not found.
569
570**/
571BOOLEAN
572EFIAPI
573FindBlockName (
574 IN OUT CHAR16 *String,
575 UINTN Offset,
576 UINTN Width
577 )
578;
579
580/**
581 This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.
582
583 @param VariableGuid An optional field to indicate the target variable
584 GUID name to use.
585 @param VariableName An optional field to indicate the target
586 human-readable variable name.
587 @param BufferSize On input: Length in bytes of buffer to hold
588 retrived data. On output: If return
589 EFI_BUFFER_TOO_SMALL, containg length of buffer
590 desired.
591 @param Buffer Buffer to hold retrived data.
592
593 @retval EFI_SUCCESS Routine success.
594 @retval EFI_BUFFER_TOO_SMALL The intput buffer is too small.
595
596**/
597EFI_STATUS
598EFIAPI
599GetBrowserData (
600 EFI_GUID *VariableGuid, OPTIONAL
601 CHAR16 *VariableName, OPTIONAL
602 UINTN *BufferSize,
603 UINT8 *Buffer
604 )
605;
606
607/**
608 This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.
609
610 @param VariableGuid An optional field to indicate the target variable
611 GUID name to use.
612 @param VariableName An optional field to indicate the target
613 human-readable variable name.
614 @param BufferSize Length in bytes of buffer to hold retrived data.
615 @param Buffer Buffer to hold retrived data.
616 @param RequestElement An optional field to specify which part of the
617 buffer data will be send back to Browser. If NULL,
618 the whole buffer of data will be committed to
619 Browser. <RequestElement> ::=
620 &OFFSET=<Number>&WIDTH=<Number>*
621
622 @retval EFI_SUCCESS Routine success.
623 @retval Other Updating Browser uncommitted data failed.
624
625**/
626EFI_STATUS
627EFIAPI
628SetBrowserData (
629 EFI_GUID *VariableGuid, OPTIONAL
630 CHAR16 *VariableName, OPTIONAL
631 UINTN BufferSize,
632 UINT8 *Buffer,
633 CHAR16 *RequestElement OPTIONAL
634 )
635;
636
637/**
638 Draw a dialog and return the selected key.
639
640 @param NumberOfLines The number of lines for the dialog box
641 @param KeyValue The EFI_KEY value returned if HotKey is TRUE..
642 @param String Pointer to the first string in the list
643 @param ... A series of (quantity == NumberOfLines) text
644 strings which will be used to construct the dialog
645 box
646
647 @retval EFI_SUCCESS Displayed dialog and received user interaction
648 @retval EFI_INVALID_PARAMETER One of the parameters was invalid.
649
650**/
651
652EFI_STATUS
653EFIAPI
654IfrLibCreatePopUp (
655 IN UINTN NumberOfLines,
656 OUT EFI_INPUT_KEY *KeyValue,
657 IN CHAR16 *String,
658 ...
659 )
660;
661
662#endif