2 Copyright (c) 2006, 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.
24 // Include common header file for this module.
26 #include "CommonHeader.h"
29 CreateSubTitleOpCode (
30 IN STRING_REF StringToken
,
31 IN OUT VOID
*FormBuffer
37 Create a SubTitle opcode independent of string creation
38 This is used primarily by users who need to create just one particular valid op-code and the string
39 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
40 location to pre-defined forms in HII)
44 StringToken - StringToken of the subtitle
46 FormBuffer - Output of subtitle as a form
50 EFI_SUCCESS - Subtitle created to be a form
54 EFI_IFR_SUBTITLE Subtitle
;
56 Subtitle
.Header
.OpCode
= EFI_IFR_SUBTITLE_OP
;
57 Subtitle
.Header
.Length
= sizeof (EFI_IFR_SUBTITLE
);
58 Subtitle
.SubTitle
= StringToken
;
60 CopyMem (FormBuffer
, &Subtitle
, sizeof (EFI_IFR_SUBTITLE
));
67 IN STRING_REF StringToken
,
68 IN STRING_REF StringTokenTwo
,
69 IN STRING_REF StringTokenThree
,
72 IN OUT VOID
*FormBuffer
78 Create a Text opcode independent of string creation
79 This is used primarily by users who need to create just one particular valid op-code and the string
80 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
81 location to pre-defined forms in HII)
85 StringToken - First string token of the text
87 StringTokenTwo - Second string token of the text
89 StringTokenThree - Help string token of the text
91 Flags - Flag of the text
95 FormBuffer - Output of text as a form
99 EFI_SUCCESS - Text created to be a form
105 Text
.Header
.OpCode
= EFI_IFR_TEXT_OP
;
106 Text
.Header
.Length
= sizeof (EFI_IFR_TEXT
);
107 Text
.Text
= StringToken
;
109 Text
.TextTwo
= StringTokenTwo
;
110 Text
.Help
= StringTokenThree
;
114 CopyMem (FormBuffer
, &Text
, sizeof (EFI_IFR_TEXT
));
123 IN STRING_REF StringToken
,
124 IN STRING_REF StringTokenTwo
,
127 IN OUT VOID
*FormBuffer
133 Create a hyperlink opcode independent of string creation
134 This is used primarily by users who need to create just one particular valid op-code and the string
135 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
136 location to pre-defined forms in HII)
140 FormId - Form ID of the hyperlink
142 StringToken - Prompt string token of the hyperlink
144 StringTokenTwo - Help string token of the hyperlink
146 Flags - Flags of the hyperlink
148 Key - Key of the hyperlink
150 FormBuffer - Output of hyperlink as a form
154 EFI_SUCCESS - Hyperlink created to be a form
158 EFI_IFR_REF Hyperlink
;
160 Hyperlink
.Header
.OpCode
= EFI_IFR_REF_OP
;
161 Hyperlink
.Header
.Length
= sizeof (EFI_IFR_REF
);
162 Hyperlink
.FormId
= FormId
;
163 Hyperlink
.Prompt
= StringToken
;
164 Hyperlink
.Help
= StringTokenTwo
;
166 Hyperlink
.Flags
= Flags
;
168 CopyMem (FormBuffer
, &Hyperlink
, sizeof (EFI_IFR_REF
));
176 IN UINT16 QuestionId
,
178 IN STRING_REF PromptToken
,
179 IN STRING_REF HelpToken
,
180 IN IFR_OPTION
*OptionsList
,
181 IN UINTN OptionCount
,
182 IN OUT VOID
*FormBuffer
188 Create a one-of opcode with a set of option op-codes to choose from independent of string creation.
189 This is used primarily by users who need to create just one particular valid op-code and the string
190 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
191 location to pre-defined forms in HII)
193 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
194 has been filled in since this routine will not generate StringToken values.
198 QuestionId - Question ID of the one-of box
200 DataWidth - DataWidth of the one-of box
202 PromptToken - Prompt string token of the one-of box
204 HelpToken - Help string token of the one-of box
206 OptionsList - Each string in it is an option of the one-of box
208 OptionCount - Option string count
210 FormBuffer - Output of One-Of box as a form
214 EFI_SUCCESS - One-Of box created to be a form
216 EFI_DEVICE_ERROR - DataWidth > 2
221 EFI_IFR_ONE_OF OneOf
;
222 EFI_IFR_ONE_OF_OPTION OneOfOption
;
223 EFI_IFR_END_ONE_OF EndOneOf
;
227 // We do not create op-code storage widths for one-of in excess of 16 bits for now
230 return EFI_DEVICE_ERROR
;
233 OneOf
.Header
.OpCode
= EFI_IFR_ONE_OF_OP
;
234 OneOf
.Header
.Length
= sizeof (EFI_IFR_ONE_OF
);
235 OneOf
.QuestionId
= QuestionId
;
236 OneOf
.Width
= DataWidth
;
237 OneOf
.Prompt
= PromptToken
;
239 OneOf
.Help
= HelpToken
;
241 LocalBuffer
= (UINT8
*) FormBuffer
;
243 CopyMem (LocalBuffer
, &OneOf
, sizeof (EFI_IFR_ONE_OF
));
245 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ONE_OF
));
247 for (Index
= 0; Index
< OptionCount
; Index
++) {
248 OneOfOption
.Header
.OpCode
= EFI_IFR_ONE_OF_OPTION_OP
;
249 OneOfOption
.Header
.Length
= sizeof (EFI_IFR_ONE_OF_OPTION
);
251 OneOfOption
.Option
= OptionsList
[Index
].StringToken
;
252 OneOfOption
.Value
= OptionsList
[Index
].Value
;
253 OneOfOption
.Flags
= OptionsList
[Index
].Flags
;
254 OneOfOption
.Key
= OptionsList
[Index
].Key
;
256 CopyMem (LocalBuffer
, &OneOfOption
, sizeof (EFI_IFR_ONE_OF_OPTION
));
258 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ONE_OF_OPTION
));
261 EndOneOf
.Header
.Length
= sizeof (EFI_IFR_END_ONE_OF
);
262 EndOneOf
.Header
.OpCode
= EFI_IFR_END_ONE_OF_OP
;
264 CopyMem (LocalBuffer
, &EndOneOf
, sizeof (EFI_IFR_END_ONE_OF
));
266 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_END_ONE_OF
));
272 CreateOrderedListOpCode (
273 IN UINT16 QuestionId
,
275 IN STRING_REF PromptToken
,
276 IN STRING_REF HelpToken
,
277 IN IFR_OPTION
*OptionsList
,
278 IN UINTN OptionCount
,
279 IN OUT VOID
*FormBuffer
285 Create a ordered list opcode with a set of option op-codes to choose from independent of string creation.
286 This is used primarily by users who need to create just one particular valid op-code and the string
287 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
288 location to pre-defined forms in HII)
290 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
291 has been filled in since this routine will not generate StringToken values.
295 QuestionId - Question ID of the ordered list
297 MaxEntries - MaxEntries of the ordered list
299 PromptToken - Prompt string token of the ordered list
301 HelpToken - Help string token of the ordered list
303 OptionsList - Each string in it is an option of the ordered list
305 OptionCount - Option string count
307 FormBuffer - Output of ordered list as a form
311 EFI_SUCCESS - Ordered list created to be a form
316 EFI_IFR_ORDERED_LIST OrderedList
;
317 EFI_IFR_ONE_OF_OPTION OrderedListOption
;
318 EFI_IFR_END_ONE_OF EndOrderedList
;
321 OrderedList
.Header
.OpCode
= EFI_IFR_ORDERED_LIST_OP
;
322 OrderedList
.Header
.Length
= sizeof (EFI_IFR_ORDERED_LIST
);
323 OrderedList
.QuestionId
= QuestionId
;
324 OrderedList
.MaxEntries
= MaxEntries
;
325 OrderedList
.Prompt
= PromptToken
;
327 OrderedList
.Help
= HelpToken
;
329 LocalBuffer
= (UINT8
*) FormBuffer
;
331 CopyMem (LocalBuffer
, &OrderedList
, sizeof (EFI_IFR_ORDERED_LIST
));
333 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ORDERED_LIST
));
335 for (Index
= 0; Index
< OptionCount
; Index
++) {
336 OrderedListOption
.Header
.OpCode
= EFI_IFR_ONE_OF_OPTION_OP
;
337 OrderedListOption
.Header
.Length
= sizeof (EFI_IFR_ONE_OF_OPTION
);
339 OrderedListOption
.Option
= OptionsList
[Index
].StringToken
;
340 OrderedListOption
.Value
= OptionsList
[Index
].Value
;
341 OrderedListOption
.Flags
= OptionsList
[Index
].Flags
;
342 OrderedListOption
.Key
= OptionsList
[Index
].Key
;
344 CopyMem (LocalBuffer
, &OrderedListOption
, sizeof (EFI_IFR_ONE_OF_OPTION
));
346 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ONE_OF_OPTION
));
349 EndOrderedList
.Header
.Length
= sizeof (EFI_IFR_END_ONE_OF
);
350 EndOrderedList
.Header
.OpCode
= EFI_IFR_END_ONE_OF_OP
;
352 CopyMem (LocalBuffer
, &EndOrderedList
, sizeof (EFI_IFR_END_ONE_OF
));
354 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_END_ONE_OF
));
360 CreateCheckBoxOpCode (
361 IN UINT16 QuestionId
,
363 IN STRING_REF PromptToken
,
364 IN STRING_REF HelpToken
,
367 IN OUT VOID
*FormBuffer
373 Create a checkbox opcode independent of string creation
374 This is used primarily by users who need to create just one particular valid op-code and the string
375 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
376 location to pre-defined forms in HII)
380 QuestionId - Question ID of the check box
382 DataWidth - DataWidth of the check box
384 PromptToken - Prompt string token of the check box
386 HelpToken - Help string token of the check box
388 Flags - Flags of the check box
390 Key - Key of the check box
392 FormBuffer - Output of the check box as a form
396 EFI_SUCCESS - Checkbox created to be a form
398 EFI_DEVICE_ERROR - DataWidth > 1
402 EFI_IFR_CHECKBOX CheckBox
;
405 // We do not create op-code storage widths for checkbox in excess of 8 bits for now
408 return EFI_DEVICE_ERROR
;
411 CheckBox
.Header
.OpCode
= EFI_IFR_CHECKBOX_OP
;
412 CheckBox
.Header
.Length
= sizeof (EFI_IFR_CHECKBOX
);
413 CheckBox
.QuestionId
= QuestionId
;
414 CheckBox
.Width
= DataWidth
;
415 CheckBox
.Prompt
= PromptToken
;
417 CheckBox
.Help
= HelpToken
;
418 CheckBox
.Flags
= Flags
;
421 CopyMem (FormBuffer
, &CheckBox
, sizeof (EFI_IFR_CHECKBOX
));
428 CreateNumericOpCode (
429 IN UINT16 QuestionId
,
431 IN STRING_REF PromptToken
,
432 IN STRING_REF HelpToken
,
439 IN OUT VOID
*FormBuffer
445 Create a numeric opcode independent of string creation
446 This is used primarily by users who need to create just one particular valid op-code and the string
447 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
448 location to pre-defined forms in HII)
452 QuestionId - Question ID of the numeric
454 DataWidth - DataWidth of the numeric
456 PromptToken - Prompt string token of the numeric
458 HelpToken - Help string token of the numeric
460 Minimum - Minumun boundary of the numeric
462 Maximum - Maximum boundary of the numeric
464 Step - Step of the numeric
466 Default - Default value of the numeric
468 Flags - Flags of the numeric
470 Key - Key of the numeric
472 FormBuffer - Output of the numeric as a form
476 EFI_SUCCESS - The numeric created to be a form.
478 EFI_DEVICE_ERROR - DataWidth > 2
482 EFI_IFR_NUMERIC Numeric
;
485 // We do not create op-code storage widths for numerics in excess of 16 bits for now
488 return EFI_DEVICE_ERROR
;
491 Numeric
.Header
.OpCode
= EFI_IFR_NUMERIC_OP
;
492 Numeric
.Header
.Length
= sizeof (EFI_IFR_NUMERIC
);
493 Numeric
.QuestionId
= QuestionId
;
494 Numeric
.Width
= DataWidth
;
495 Numeric
.Prompt
= PromptToken
;
497 Numeric
.Help
= HelpToken
;
498 Numeric
.Minimum
= Minimum
;
499 Numeric
.Maximum
= Maximum
;
501 Numeric
.Default
= Default
;
502 Numeric
.Flags
= Flags
;
505 CopyMem (FormBuffer
, &Numeric
, sizeof (EFI_IFR_NUMERIC
));
513 IN UINT16 QuestionId
,
515 IN STRING_REF PromptToken
,
516 IN STRING_REF HelpToken
,
521 IN OUT VOID
*FormBuffer
527 Create a numeric opcode independent of string creation
528 This is used primarily by users who need to create just one particular valid op-code and the string
529 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
530 location to pre-defined forms in HII)
534 QuestionId - Question ID of the string
536 DataWidth - DataWidth of the string
538 PromptToken - Prompt token of the string
540 HelpToken - Help token of the string
542 MinSize - Min size boundary of the string
544 MaxSize - Max size boundary of the string
546 Flags - Flags of the string
548 Key - Key of the string
550 FormBuffer - Output of the string as a form
554 EFI_SUCCESS - String created to be a form.
558 EFI_IFR_STRING String
;
560 String
.Header
.OpCode
= EFI_IFR_STRING_OP
;
561 String
.Header
.Length
= sizeof (EFI_IFR_STRING
);
562 String
.QuestionId
= QuestionId
;
563 String
.Width
= DataWidth
;
564 String
.Prompt
= PromptToken
;
566 String
.Help
= HelpToken
;
567 String
.MinSize
= MinSize
;
568 String
.MaxSize
= MaxSize
;
569 String
.Flags
= Flags
;
572 CopyMem (FormBuffer
, &String
, sizeof (EFI_IFR_STRING
));
581 IN UINT16 LineNumber
,
583 IN OUT VOID
*FormBuffer
589 Create a banner opcode. This is primarily used by the FrontPage implementation from BDS.
593 Title - Title of the banner
595 LineNumber - LineNumber of the banner
597 Alignment - Alignment of the banner
599 FormBuffer - Output of banner as a form
603 EFI_SUCCESS - Banner created to be a form.
607 EFI_IFR_BANNER Banner
;
609 Banner
.Header
.OpCode
= EFI_IFR_BANNER_OP
;
610 Banner
.Header
.Length
= sizeof (EFI_IFR_BANNER
);
611 CopyMem (&Banner
.Title
, &Title
, sizeof (UINT16
));
612 CopyMem (&Banner
.LineNumber
, &LineNumber
, sizeof (UINT16
));
613 Banner
.Alignment
= Alignment
;
615 CopyMem (FormBuffer
, &Banner
, sizeof (EFI_IFR_BANNER
));