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 CreateSubTitleOpCode (
25 IN STRING_REF StringToken
,
26 IN OUT VOID
*FormBuffer
32 Create a SubTitle opcode independent of string creation
33 This is used primarily by users who need to create just one particular valid op-code and the string
34 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
35 location to pre-defined forms in HII)
39 StringToken - StringToken of the subtitle
41 FormBuffer - Output of subtitle as a form
45 EFI_SUCCESS - Subtitle created to be a form
49 EFI_IFR_SUBTITLE Subtitle
;
51 Subtitle
.Header
.OpCode
= EFI_IFR_SUBTITLE_OP
;
52 Subtitle
.Header
.Length
= sizeof (EFI_IFR_SUBTITLE
);
53 Subtitle
.SubTitle
= StringToken
;
55 CopyMem (FormBuffer
, &Subtitle
, sizeof (EFI_IFR_SUBTITLE
));
62 IN STRING_REF StringToken
,
63 IN STRING_REF StringTokenTwo
,
64 IN STRING_REF StringTokenThree
,
67 IN OUT VOID
*FormBuffer
73 Create a Text opcode independent of string creation
74 This is used primarily by users who need to create just one particular valid op-code and the string
75 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
76 location to pre-defined forms in HII)
80 StringToken - First string token of the text
82 StringTokenTwo - Second string token of the text
84 StringTokenThree - Help string token of the text
86 Flags - Flag of the text
90 FormBuffer - Output of text as a form
94 EFI_SUCCESS - Text created to be a form
100 Text
.Header
.OpCode
= EFI_IFR_TEXT_OP
;
101 Text
.Header
.Length
= sizeof (EFI_IFR_TEXT
);
102 Text
.Text
= StringToken
;
104 Text
.TextTwo
= StringTokenTwo
;
105 Text
.Help
= StringTokenThree
;
109 CopyMem (FormBuffer
, &Text
, sizeof (EFI_IFR_TEXT
));
118 IN STRING_REF StringToken
,
119 IN STRING_REF StringTokenTwo
,
122 IN OUT VOID
*FormBuffer
128 Create a hyperlink opcode independent of string creation
129 This is used primarily by users who need to create just one particular valid op-code and the string
130 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
131 location to pre-defined forms in HII)
135 FormId - Form ID of the hyperlink
137 StringToken - Prompt string token of the hyperlink
139 StringTokenTwo - Help string token of the hyperlink
141 Flags - Flags of the hyperlink
143 Key - Key of the hyperlink
145 FormBuffer - Output of hyperlink as a form
149 EFI_SUCCESS - Hyperlink created to be a form
153 EFI_IFR_REF Hyperlink
;
155 Hyperlink
.Header
.OpCode
= EFI_IFR_REF_OP
;
156 Hyperlink
.Header
.Length
= sizeof (EFI_IFR_REF
);
157 Hyperlink
.FormId
= FormId
;
158 Hyperlink
.Prompt
= StringToken
;
159 Hyperlink
.Help
= StringTokenTwo
;
161 Hyperlink
.Flags
= Flags
;
163 CopyMem (FormBuffer
, &Hyperlink
, sizeof (EFI_IFR_REF
));
171 IN UINT16 QuestionId
,
173 IN STRING_REF PromptToken
,
174 IN STRING_REF HelpToken
,
175 IN IFR_OPTION
*OptionsList
,
176 IN UINTN OptionCount
,
177 IN OUT VOID
*FormBuffer
183 Create a one-of opcode with a set of option op-codes to choose from independent of string creation.
184 This is used primarily by users who need to create just one particular valid op-code and the string
185 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
186 location to pre-defined forms in HII)
188 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
189 has been filled in since this routine will not generate StringToken values.
193 QuestionId - Question ID of the one-of box
195 DataWidth - DataWidth of the one-of box
197 PromptToken - Prompt string token of the one-of box
199 HelpToken - Help string token of the one-of box
201 OptionsList - Each string in it is an option of the one-of box
203 OptionCount - Option string count
205 FormBuffer - Output of One-Of box as a form
209 EFI_SUCCESS - One-Of box created to be a form
211 EFI_DEVICE_ERROR - DataWidth > 2
216 EFI_IFR_ONE_OF OneOf
;
217 EFI_IFR_ONE_OF_OPTION OneOfOption
;
218 EFI_IFR_END_ONE_OF EndOneOf
;
222 // We do not create op-code storage widths for one-of in excess of 16 bits for now
225 return EFI_DEVICE_ERROR
;
228 OneOf
.Header
.OpCode
= EFI_IFR_ONE_OF_OP
;
229 OneOf
.Header
.Length
= sizeof (EFI_IFR_ONE_OF
);
230 OneOf
.QuestionId
= QuestionId
;
231 OneOf
.Width
= DataWidth
;
232 OneOf
.Prompt
= PromptToken
;
234 OneOf
.Help
= HelpToken
;
236 LocalBuffer
= (UINT8
*) FormBuffer
;
238 CopyMem (LocalBuffer
, &OneOf
, sizeof (EFI_IFR_ONE_OF
));
240 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ONE_OF
));
242 for (Index
= 0; Index
< OptionCount
; Index
++) {
243 OneOfOption
.Header
.OpCode
= EFI_IFR_ONE_OF_OPTION_OP
;
244 OneOfOption
.Header
.Length
= sizeof (EFI_IFR_ONE_OF_OPTION
);
246 OneOfOption
.Option
= OptionsList
[Index
].StringToken
;
247 OneOfOption
.Value
= OptionsList
[Index
].Value
;
248 OneOfOption
.Flags
= OptionsList
[Index
].Flags
;
249 OneOfOption
.Key
= OptionsList
[Index
].Key
;
251 CopyMem (LocalBuffer
, &OneOfOption
, sizeof (EFI_IFR_ONE_OF_OPTION
));
253 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ONE_OF_OPTION
));
256 EndOneOf
.Header
.Length
= sizeof (EFI_IFR_END_ONE_OF
);
257 EndOneOf
.Header
.OpCode
= EFI_IFR_END_ONE_OF_OP
;
259 CopyMem (LocalBuffer
, &EndOneOf
, sizeof (EFI_IFR_END_ONE_OF
));
261 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_END_ONE_OF
));
267 CreateOrderedListOpCode (
268 IN UINT16 QuestionId
,
270 IN STRING_REF PromptToken
,
271 IN STRING_REF HelpToken
,
272 IN IFR_OPTION
*OptionsList
,
273 IN UINTN OptionCount
,
274 IN OUT VOID
*FormBuffer
280 Create a ordered list opcode with a set of option op-codes to choose from independent of string creation.
281 This is used primarily by users who need to create just one particular valid op-code and the string
282 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
283 location to pre-defined forms in HII)
285 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
286 has been filled in since this routine will not generate StringToken values.
290 QuestionId - Question ID of the ordered list
292 MaxEntries - MaxEntries of the ordered list
294 PromptToken - Prompt string token of the ordered list
296 HelpToken - Help string token of the ordered list
298 OptionsList - Each string in it is an option of the ordered list
300 OptionCount - Option string count
302 FormBuffer - Output of ordered list as a form
306 EFI_SUCCESS - Ordered list created to be a form
311 EFI_IFR_ORDERED_LIST OrderedList
;
312 EFI_IFR_ONE_OF_OPTION OrderedListOption
;
313 EFI_IFR_END_ONE_OF EndOrderedList
;
316 OrderedList
.Header
.OpCode
= EFI_IFR_ORDERED_LIST_OP
;
317 OrderedList
.Header
.Length
= sizeof (EFI_IFR_ORDERED_LIST
);
318 OrderedList
.QuestionId
= QuestionId
;
319 OrderedList
.MaxEntries
= MaxEntries
;
320 OrderedList
.Prompt
= PromptToken
;
322 OrderedList
.Help
= HelpToken
;
324 LocalBuffer
= (UINT8
*) FormBuffer
;
326 CopyMem (LocalBuffer
, &OrderedList
, sizeof (EFI_IFR_ORDERED_LIST
));
328 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ORDERED_LIST
));
330 for (Index
= 0; Index
< OptionCount
; Index
++) {
331 OrderedListOption
.Header
.OpCode
= EFI_IFR_ONE_OF_OPTION_OP
;
332 OrderedListOption
.Header
.Length
= sizeof (EFI_IFR_ONE_OF_OPTION
);
334 OrderedListOption
.Option
= OptionsList
[Index
].StringToken
;
335 OrderedListOption
.Value
= OptionsList
[Index
].Value
;
336 OrderedListOption
.Flags
= OptionsList
[Index
].Flags
;
337 OrderedListOption
.Key
= OptionsList
[Index
].Key
;
339 CopyMem (LocalBuffer
, &OrderedListOption
, sizeof (EFI_IFR_ONE_OF_OPTION
));
341 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_ONE_OF_OPTION
));
344 EndOrderedList
.Header
.Length
= sizeof (EFI_IFR_END_ONE_OF
);
345 EndOrderedList
.Header
.OpCode
= EFI_IFR_END_ONE_OF_OP
;
347 CopyMem (LocalBuffer
, &EndOrderedList
, sizeof (EFI_IFR_END_ONE_OF
));
349 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (EFI_IFR_END_ONE_OF
));
355 CreateCheckBoxOpCode (
356 IN UINT16 QuestionId
,
358 IN STRING_REF PromptToken
,
359 IN STRING_REF HelpToken
,
362 IN OUT VOID
*FormBuffer
368 Create a checkbox opcode independent of string creation
369 This is used primarily by users who need to create just one particular valid op-code and the string
370 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
371 location to pre-defined forms in HII)
375 QuestionId - Question ID of the check box
377 DataWidth - DataWidth of the check box
379 PromptToken - Prompt string token of the check box
381 HelpToken - Help string token of the check box
383 Flags - Flags of the check box
385 Key - Key of the check box
387 FormBuffer - Output of the check box as a form
391 EFI_SUCCESS - Checkbox created to be a form
393 EFI_DEVICE_ERROR - DataWidth > 1
397 EFI_IFR_CHECKBOX CheckBox
;
400 // We do not create op-code storage widths for checkbox in excess of 8 bits for now
403 return EFI_DEVICE_ERROR
;
406 CheckBox
.Header
.OpCode
= EFI_IFR_CHECKBOX_OP
;
407 CheckBox
.Header
.Length
= sizeof (EFI_IFR_CHECKBOX
);
408 CheckBox
.QuestionId
= QuestionId
;
409 CheckBox
.Width
= DataWidth
;
410 CheckBox
.Prompt
= PromptToken
;
412 CheckBox
.Help
= HelpToken
;
413 CheckBox
.Flags
= Flags
;
416 CopyMem (FormBuffer
, &CheckBox
, sizeof (EFI_IFR_CHECKBOX
));
423 CreateNumericOpCode (
424 IN UINT16 QuestionId
,
426 IN STRING_REF PromptToken
,
427 IN STRING_REF HelpToken
,
434 IN OUT VOID
*FormBuffer
440 Create a numeric opcode independent of string creation
441 This is used primarily by users who need to create just one particular valid op-code and the string
442 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
443 location to pre-defined forms in HII)
447 QuestionId - Question ID of the numeric
449 DataWidth - DataWidth of the numeric
451 PromptToken - Prompt string token of the numeric
453 HelpToken - Help string token of the numeric
455 Minimum - Minumun boundary of the numeric
457 Maximum - Maximum boundary of the numeric
459 Step - Step of the numeric
461 Default - Default value of the numeric
463 Flags - Flags of the numeric
465 Key - Key of the numeric
467 FormBuffer - Output of the numeric as a form
471 EFI_SUCCESS - The numeric created to be a form.
473 EFI_DEVICE_ERROR - DataWidth > 2
477 EFI_IFR_NUMERIC Numeric
;
480 // We do not create op-code storage widths for numerics in excess of 16 bits for now
483 return EFI_DEVICE_ERROR
;
486 Numeric
.Header
.OpCode
= EFI_IFR_NUMERIC_OP
;
487 Numeric
.Header
.Length
= sizeof (EFI_IFR_NUMERIC
);
488 Numeric
.QuestionId
= QuestionId
;
489 Numeric
.Width
= DataWidth
;
490 Numeric
.Prompt
= PromptToken
;
492 Numeric
.Help
= HelpToken
;
493 Numeric
.Minimum
= Minimum
;
494 Numeric
.Maximum
= Maximum
;
496 Numeric
.Default
= Default
;
497 Numeric
.Flags
= Flags
;
500 CopyMem (FormBuffer
, &Numeric
, sizeof (EFI_IFR_NUMERIC
));
508 IN UINT16 QuestionId
,
510 IN STRING_REF PromptToken
,
511 IN STRING_REF HelpToken
,
516 IN OUT VOID
*FormBuffer
522 Create a numeric opcode independent of string creation
523 This is used primarily by users who need to create just one particular valid op-code and the string
524 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
525 location to pre-defined forms in HII)
529 QuestionId - Question ID of the string
531 DataWidth - DataWidth of the string
533 PromptToken - Prompt token of the string
535 HelpToken - Help token of the string
537 MinSize - Min size boundary of the string
539 MaxSize - Max size boundary of the string
541 Flags - Flags of the string
543 Key - Key of the string
545 FormBuffer - Output of the string as a form
549 EFI_SUCCESS - String created to be a form.
553 EFI_IFR_STRING String
;
555 String
.Header
.OpCode
= EFI_IFR_STRING_OP
;
556 String
.Header
.Length
= sizeof (EFI_IFR_STRING
);
557 String
.QuestionId
= QuestionId
;
558 String
.Width
= DataWidth
;
559 String
.Prompt
= PromptToken
;
561 String
.Help
= HelpToken
;
562 String
.MinSize
= MinSize
;
563 String
.MaxSize
= MaxSize
;
564 String
.Flags
= Flags
;
567 CopyMem (FormBuffer
, &String
, sizeof (EFI_IFR_STRING
));
576 IN UINT16 LineNumber
,
578 IN OUT VOID
*FormBuffer
584 Create a banner opcode. This is primarily used by the FrontPage implementation from BDS.
588 Title - Title of the banner
590 LineNumber - LineNumber of the banner
592 Alignment - Alignment of the banner
594 FormBuffer - Output of banner as a form
598 EFI_SUCCESS - Banner created to be a form.
602 EFI_IFR_BANNER Banner
;
604 Banner
.Header
.OpCode
= EFI_IFR_BANNER_OP
;
605 Banner
.Header
.Length
= sizeof (EFI_IFR_BANNER
);
606 CopyMem (&Banner
.Title
, &Title
, sizeof (UINT16
));
607 CopyMem (&Banner
.LineNumber
, &LineNumber
, sizeof (UINT16
));
608 Banner
.Alignment
= Alignment
;
610 CopyMem (FormBuffer
, &Banner
, sizeof (EFI_IFR_BANNER
));