2 Copyright (c) 2004, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 Library Routines to create IFR independent of string data - assume tokens already exist
17 Primarily to be used for exporting op-codes at a label in pre-defined forms.
23 #include "IfrLibrary.h"
26 CreateSubTitleOpCode (
27 IN STRING_REF StringToken
,
28 IN OUT VOID
*FormBuffer
34 Create a SubTitle opcode independent of string creation
35 This is used primarily by users who need to create just one particular valid op-code and the string
36 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
37 location to pre-defined forms in HII)
41 StringToken - StringToken of the subtitle
43 FormBuffer - Output of subtitle as a form
47 EFI_SUCCESS - Subtitle created to be a form
51 EFI_IFR_SUBTITLE Subtitle
;
53 Subtitle
.Header
.OpCode
= EFI_IFR_SUBTITLE_OP
;
54 Subtitle
.Header
.Length
= sizeof (EFI_IFR_SUBTITLE
);
55 Subtitle
.SubTitle
= StringToken
;
57 EfiCopyMem (FormBuffer
, &Subtitle
, sizeof (EFI_IFR_SUBTITLE
));
64 IN STRING_REF StringToken
,
65 IN STRING_REF StringTokenTwo
,
66 IN STRING_REF StringTokenThree
,
69 IN OUT VOID
*FormBuffer
75 Create a Text opcode independent of string creation
76 This is used primarily by users who need to create just one particular valid op-code and the string
77 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
78 location to pre-defined forms in HII)
82 StringToken - First string token of the text
84 StringTokenTwo - Second string token of the text
86 StringTokenThree - Help string token of the text
88 Flags - Flag of the text
92 FormBuffer - Output of text as a form
96 EFI_SUCCESS - Text created to be a form
102 Text
.Header
.OpCode
= EFI_IFR_TEXT_OP
;
103 Text
.Header
.Length
= sizeof (EFI_IFR_TEXT
);
104 Text
.Text
= StringToken
;
106 Text
.TextTwo
= StringTokenTwo
;
107 Text
.Help
= StringTokenThree
;
111 EfiCopyMem (FormBuffer
, &Text
, sizeof (EFI_IFR_TEXT
));
120 IN STRING_REF StringToken
,
121 IN STRING_REF StringTokenTwo
,
124 IN OUT VOID
*FormBuffer
130 Create a hyperlink opcode independent of string creation
131 This is used primarily by users who need to create just one particular valid op-code and the string
132 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
133 location to pre-defined forms in HII)
137 FormId - Form ID of the hyperlink
139 StringToken - Prompt string token of the hyperlink
141 StringTokenTwo - Help string token of the hyperlink
143 Flags - Flags of the hyperlink
145 Key - Key of the hyperlink
147 FormBuffer - Output of hyperlink as a form
151 EFI_SUCCESS - Hyperlink created to be a form
155 EFI_IFR_REF Hyperlink
;
157 Hyperlink
.Header
.OpCode
= EFI_IFR_REF_OP
;
158 Hyperlink
.Header
.Length
= sizeof (EFI_IFR_REF
);
159 Hyperlink
.FormId
= FormId
;
160 Hyperlink
.Prompt
= StringToken
;
161 Hyperlink
.Help
= StringTokenTwo
;
163 Hyperlink
.Flags
= Flags
;
165 EfiCopyMem (FormBuffer
, &Hyperlink
, sizeof (EFI_IFR_REF
));
173 IN UINT16 QuestionId
,
175 IN STRING_REF PromptToken
,
176 IN STRING_REF HelpToken
,
177 IN IFR_OPTION
*OptionsList
,
178 IN UINTN OptionCount
,
179 IN OUT VOID
*FormBuffer
185 Create a one-of opcode with a set of option op-codes to choose from independent of string creation.
186 This is used primarily by users who need to create just one particular valid op-code and the string
187 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
188 location to pre-defined forms in HII)
190 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
191 has been filled in since this routine will not generate StringToken values.
195 QuestionId - Question ID of the one-of box
197 DataWidth - DataWidth of the one-of box
199 PromptToken - Prompt string token of the one-of box
201 HelpToken - Help string token of the one-of box
203 OptionsList - Each string in it is an option of the one-of box
205 OptionCount - Option string count
207 FormBuffer - Output of One-Of box as a form
211 EFI_SUCCESS - One-Of box created to be a form
213 EFI_DEVICE_ERROR - DataWidth > 2
218 EFI_IFR_ONE_OF OneOf
;
219 EFI_IFR_ONE_OF_OPTION OneOfOption
;
220 EFI_IFR_END_ONE_OF EndOneOf
;
224 // We do not create op-code storage widths for one-of in excess of 16 bits for now
227 return EFI_DEVICE_ERROR
;
230 OneOf
.Header
.OpCode
= EFI_IFR_ONE_OF_OP
;
231 OneOf
.Header
.Length
= sizeof (EFI_IFR_ONE_OF
);
232 OneOf
.QuestionId
= QuestionId
;
233 OneOf
.Width
= DataWidth
;
234 OneOf
.Prompt
= PromptToken
;
236 OneOf
.Help
= HelpToken
;
238 LocalBuffer
= (UINT8
*) FormBuffer
;
240 EfiCopyMem (LocalBuffer
, &OneOf
, sizeof (EFI_IFR_ONE_OF
));
242 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ONE_OF
));
244 for (Index
= 0; Index
< OptionCount
; Index
++) {
245 OneOfOption
.Header
.OpCode
= EFI_IFR_ONE_OF_OPTION_OP
;
246 OneOfOption
.Header
.Length
= sizeof (EFI_IFR_ONE_OF_OPTION
);
248 OneOfOption
.Option
= OptionsList
[Index
].StringToken
;
249 OneOfOption
.Value
= OptionsList
[Index
].Value
;
250 OneOfOption
.Flags
= OptionsList
[Index
].Flags
;
251 OneOfOption
.Key
= OptionsList
[Index
].Key
;
253 EfiCopyMem (LocalBuffer
, &OneOfOption
, sizeof (EFI_IFR_ONE_OF_OPTION
));
255 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ONE_OF_OPTION
));
258 EndOneOf
.Header
.Length
= sizeof (EFI_IFR_END_ONE_OF
);
259 EndOneOf
.Header
.OpCode
= EFI_IFR_END_ONE_OF_OP
;
261 EfiCopyMem (LocalBuffer
, &EndOneOf
, sizeof (EFI_IFR_END_ONE_OF
));
263 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_END_ONE_OF
));
269 CreateOrderedListOpCode (
270 IN UINT16 QuestionId
,
272 IN STRING_REF PromptToken
,
273 IN STRING_REF HelpToken
,
274 IN IFR_OPTION
*OptionsList
,
275 IN UINTN OptionCount
,
276 IN OUT VOID
*FormBuffer
282 Create a ordered list opcode with a set of option op-codes to choose from independent of string creation.
283 This is used primarily by users who need to create just one particular valid op-code and the string
284 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
285 location to pre-defined forms in HII)
287 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
288 has been filled in since this routine will not generate StringToken values.
292 QuestionId - Question ID of the ordered list
294 MaxEntries - MaxEntries of the ordered list
296 PromptToken - Prompt string token of the ordered list
298 HelpToken - Help string token of the ordered list
300 OptionsList - Each string in it is an option of the ordered list
302 OptionCount - Option string count
304 FormBuffer - Output of ordered list as a form
308 EFI_SUCCESS - Ordered list created to be a form
313 EFI_IFR_ORDERED_LIST OrderedList
;
314 EFI_IFR_ONE_OF_OPTION OrderedListOption
;
315 EFI_IFR_END_ONE_OF EndOrderedList
;
318 OrderedList
.Header
.OpCode
= EFI_IFR_ORDERED_LIST_OP
;
319 OrderedList
.Header
.Length
= sizeof (EFI_IFR_ORDERED_LIST
);
320 OrderedList
.QuestionId
= QuestionId
;
321 OrderedList
.MaxEntries
= MaxEntries
;
322 OrderedList
.Prompt
= PromptToken
;
324 OrderedList
.Help
= HelpToken
;
326 LocalBuffer
= (UINT8
*) FormBuffer
;
328 EfiCopyMem (LocalBuffer
, &OrderedList
, sizeof (EFI_IFR_ORDERED_LIST
));
330 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ORDERED_LIST
));
332 for (Index
= 0; Index
< OptionCount
; Index
++) {
333 OrderedListOption
.Header
.OpCode
= EFI_IFR_ONE_OF_OPTION_OP
;
334 OrderedListOption
.Header
.Length
= sizeof (EFI_IFR_ONE_OF_OPTION
);
336 OrderedListOption
.Option
= OptionsList
[Index
].StringToken
;
337 OrderedListOption
.Value
= OptionsList
[Index
].Value
;
338 OrderedListOption
.Flags
= OptionsList
[Index
].Flags
;
339 OrderedListOption
.Key
= OptionsList
[Index
].Key
;
341 EfiCopyMem (LocalBuffer
, &OrderedListOption
, sizeof (EFI_IFR_ONE_OF_OPTION
));
343 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ONE_OF_OPTION
));
346 EndOrderedList
.Header
.Length
= sizeof (EFI_IFR_END_ONE_OF
);
347 EndOrderedList
.Header
.OpCode
= EFI_IFR_END_ONE_OF_OP
;
349 EfiCopyMem (LocalBuffer
, &EndOrderedList
, sizeof (EFI_IFR_END_ONE_OF
));
351 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_END_ONE_OF
));
357 CreateCheckBoxOpCode (
358 IN UINT16 QuestionId
,
360 IN STRING_REF PromptToken
,
361 IN STRING_REF HelpToken
,
364 IN OUT VOID
*FormBuffer
370 Create a checkbox opcode independent of string creation
371 This is used primarily by users who need to create just one particular valid op-code and the string
372 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
373 location to pre-defined forms in HII)
377 QuestionId - Question ID of the check box
379 DataWidth - DataWidth of the check box
381 PromptToken - Prompt string token of the check box
383 HelpToken - Help string token of the check box
385 Flags - Flags of the check box
387 Key - Key of the check box
389 FormBuffer - Output of the check box as a form
393 EFI_SUCCESS - Checkbox created to be a form
395 EFI_DEVICE_ERROR - DataWidth > 1
399 EFI_IFR_CHECK_BOX CheckBox
;
402 // We do not create op-code storage widths for checkbox in excess of 8 bits for now
405 return EFI_DEVICE_ERROR
;
408 CheckBox
.Header
.OpCode
= EFI_IFR_CHECKBOX_OP
;
409 CheckBox
.Header
.Length
= sizeof (EFI_IFR_CHECK_BOX
);
410 CheckBox
.QuestionId
= QuestionId
;
411 CheckBox
.Width
= DataWidth
;
412 CheckBox
.Prompt
= PromptToken
;
414 CheckBox
.Help
= HelpToken
;
415 CheckBox
.Flags
= Flags
;
418 EfiCopyMem (FormBuffer
, &CheckBox
, sizeof (EFI_IFR_CHECK_BOX
));
425 CreateNumericOpCode (
426 IN UINT16 QuestionId
,
428 IN STRING_REF PromptToken
,
429 IN STRING_REF HelpToken
,
436 IN OUT VOID
*FormBuffer
442 Create a numeric opcode independent of string creation
443 This is used primarily by users who need to create just one particular valid op-code and the string
444 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
445 location to pre-defined forms in HII)
449 QuestionId - Question ID of the numeric
451 DataWidth - DataWidth of the numeric
453 PromptToken - Prompt string token of the numeric
455 HelpToken - Help string token of the numeric
457 Minimum - Minumun boundary of the numeric
459 Maximum - Maximum boundary of the numeric
461 Step - Step of the numeric
463 Default - Default value of the numeric
465 Flags - Flags of the numeric
467 Key - Key of the numeric
469 FormBuffer - Output of the numeric as a form
473 EFI_SUCCESS - The numeric created to be a form.
475 EFI_DEVICE_ERROR - DataWidth > 2
479 EFI_IFR_NUMERIC Numeric
;
482 // We do not create op-code storage widths for numerics in excess of 16 bits for now
485 return EFI_DEVICE_ERROR
;
488 Numeric
.Header
.OpCode
= EFI_IFR_NUMERIC_OP
;
489 Numeric
.Header
.Length
= sizeof (EFI_IFR_NUMERIC
);
490 Numeric
.QuestionId
= QuestionId
;
491 Numeric
.Width
= DataWidth
;
492 Numeric
.Prompt
= PromptToken
;
494 Numeric
.Help
= HelpToken
;
495 Numeric
.Minimum
= Minimum
;
496 Numeric
.Maximum
= Maximum
;
498 Numeric
.Default
= Default
;
499 Numeric
.Flags
= Flags
;
502 EfiCopyMem (FormBuffer
, &Numeric
, sizeof (EFI_IFR_NUMERIC
));
510 IN UINT16 QuestionId
,
512 IN STRING_REF PromptToken
,
513 IN STRING_REF HelpToken
,
518 IN OUT VOID
*FormBuffer
524 Create a numeric opcode independent of string creation
525 This is used primarily by users who need to create just one particular valid op-code and the string
526 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
527 location to pre-defined forms in HII)
531 QuestionId - Question ID of the string
533 DataWidth - DataWidth of the string
535 PromptToken - Prompt token of the string
537 HelpToken - Help token of the string
539 MinSize - Min size boundary of the string
541 MaxSize - Max size boundary of the string
543 Flags - Flags of the string
545 Key - Key of the string
547 FormBuffer - Output of the string as a form
551 EFI_SUCCESS - String created to be a form.
555 EFI_IFR_STRING String
;
557 String
.Header
.OpCode
= EFI_IFR_STRING_OP
;
558 String
.Header
.Length
= sizeof (EFI_IFR_STRING
);
559 String
.QuestionId
= QuestionId
;
560 String
.Width
= DataWidth
;
561 String
.Prompt
= PromptToken
;
563 String
.Help
= HelpToken
;
564 String
.MinSize
= MinSize
;
565 String
.MaxSize
= MaxSize
;
566 String
.Flags
= Flags
;
569 EfiCopyMem (FormBuffer
, &String
, sizeof (EFI_IFR_STRING
));
578 IN UINT16 LineNumber
,
580 IN OUT VOID
*FormBuffer
586 Create a banner opcode. This is primarily used by the FrontPage implementation from BDS.
590 Title - Title of the banner
592 LineNumber - LineNumber of the banner
594 Alignment - Alignment of the banner
596 FormBuffer - Output of banner as a form
600 EFI_SUCCESS - Banner created to be a form.
604 EFI_IFR_BANNER Banner
;
606 Banner
.Header
.OpCode
= EFI_IFR_BANNER_OP
;
607 Banner
.Header
.Length
= sizeof (EFI_IFR_BANNER
);
608 EfiCopyMem (&Banner
.Title
, &Title
, sizeof (UINT16
));
609 EfiCopyMem (&Banner
.LineNumber
, &LineNumber
, sizeof (UINT16
));
610 Banner
.Alignment
= Alignment
;
612 EfiCopyMem (FormBuffer
, &Banner
, sizeof (EFI_IFR_BANNER
));