2 Library Routines to create IFR independent of string data - assume tokens already exist
3 Primarily to be used for exporting op-codes at a label in pre-defined forms.
5 Copyright (c) 2006, 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
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.
18 // Include common header file for this module.
20 #include "IfrSupportLibInternal.h"
23 Create a SubTitle opcode independent of string creation
24 This is used primarily by users who need to create just one particular valid op-code and the string
25 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
26 location to pre-defined forms in HII)
28 @param StringToken StringToken of the subtitle
29 @param FormBuffer Output of subtitle as a form
31 @retval EFI_SUCCESS Subtitle created to be a form
34 CreateSubTitleOpCode (
35 IN STRING_REF StringToken
,
36 IN OUT VOID
*FormBuffer
39 FRAMEWORK_EFI_IFR_SUBTITLE Subtitle
;
41 Subtitle
.Header
.OpCode
= FRAMEWORK_EFI_IFR_SUBTITLE_OP
;
42 Subtitle
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_SUBTITLE
);
43 Subtitle
.SubTitle
= StringToken
;
45 CopyMem (FormBuffer
, &Subtitle
, sizeof (FRAMEWORK_EFI_IFR_SUBTITLE
));
50 Create a Text opcode independent of string creation
51 This is used primarily by users who need to create just one particular valid op-code and the string
52 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
53 location to pre-defined forms in HII)
55 @param StringToken - First string token of the text
56 @param StringTokenTwo - Second string token of the text
57 @param StringTokenThree - Help string token of the text
58 @param Flags - Flag of the text
59 @param Key - Key of the text
60 @param FormBuffer - Output of text as a form
62 @retval EFI_SUCCESS - Text created to be a form
66 IN STRING_REF StringToken
,
67 IN STRING_REF StringTokenTwo
,
68 IN STRING_REF StringTokenThree
,
71 IN OUT VOID
*FormBuffer
74 FRAMEWORK_EFI_IFR_TEXT Text
;
76 Text
.Header
.OpCode
= FRAMEWORK_EFI_IFR_TEXT_OP
;
77 Text
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_TEXT
);
78 Text
.Text
= StringToken
;
80 Text
.TextTwo
= StringTokenTwo
;
81 Text
.Help
= StringTokenThree
;
85 CopyMem (FormBuffer
, &Text
, sizeof (FRAMEWORK_EFI_IFR_TEXT
));
91 Create a hyperlink opcode independent of string creation
92 This is used primarily by users who need to create just one particular valid op-code and the string
93 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
94 location to pre-defined forms in HII)
97 @param FormId - Form ID of the hyperlink
98 @param StringToken - Prompt string token of the hyperlink
99 @param StringTokenTwo - Help string token of the hyperlink
100 @param Flags - Flags of the hyperlink
101 @param Key - Key of the hyperlink
102 @param FormBuffer - Output of hyperlink as a form
103 @retval EFI_SUCCESS - Hyperlink created to be a form
108 IN STRING_REF StringToken
,
109 IN STRING_REF StringTokenTwo
,
112 IN OUT VOID
*FormBuffer
116 FRAMEWORK_EFI_IFR_REF Hyperlink
;
118 Hyperlink
.Header
.OpCode
= FRAMEWORK_EFI_IFR_REF_OP
;
119 Hyperlink
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_REF
);
120 Hyperlink
.FormId
= FormId
;
121 Hyperlink
.Prompt
= StringToken
;
122 Hyperlink
.Help
= StringTokenTwo
;
124 Hyperlink
.Flags
= Flags
;
126 CopyMem (FormBuffer
, &Hyperlink
, sizeof (FRAMEWORK_EFI_IFR_REF
));
132 Create a one-of opcode with a set of option op-codes to choose from independent of string creation.
133 This is used primarily by users who need to create just one particular valid op-code and the string
134 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
135 location to pre-defined forms in HII)
137 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
138 has been filled in since this routine will not generate StringToken values.
140 @param QuestionId - Question ID of the one-of box
141 @param DataWidth - DataWidth of the one-of box
142 @param PromptToken - Prompt string token of the one-of box
143 @param HelpToken - Help string token of the one-of box
144 @param OptionsList - Each string in it is an option of the one-of box
145 @param OptionCount - Option string count
146 @param FormBuffer - Output of One-Of box as a form
149 @retval EFI_SUCCESS - One-Of box created to be a form
150 @retval EFI_DEVICE_ERROR - DataWidth > 2
154 IN UINT16 QuestionId
,
156 IN STRING_REF PromptToken
,
157 IN STRING_REF HelpToken
,
158 IN IFR_OPTION
*OptionsList
,
159 IN UINTN OptionCount
,
160 IN OUT VOID
*FormBuffer
164 FRAMEWORK_EFI_IFR_ONE_OF OneOf
;
165 FRAMEWORK_EFI_IFR_ONE_OF_OPTION OneOfOption
;
166 FRAMEWORK_EFI_IFR_END_ONE_OF EndOneOf
;
170 // We do not create op-code storage widths for one-of in excess of 16 bits for now
173 return EFI_DEVICE_ERROR
;
176 OneOf
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ONE_OF_OP
;
177 OneOf
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ONE_OF
);
178 OneOf
.QuestionId
= QuestionId
;
179 OneOf
.Width
= DataWidth
;
180 OneOf
.Prompt
= PromptToken
;
182 OneOf
.Help
= HelpToken
;
184 LocalBuffer
= (UINT8
*) FormBuffer
;
186 CopyMem (LocalBuffer
, &OneOf
, sizeof (FRAMEWORK_EFI_IFR_ONE_OF
));
188 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ONE_OF
));
190 for (Index
= 0; Index
< OptionCount
; Index
++) {
191 OneOfOption
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP
;
192 OneOfOption
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
);
194 OneOfOption
.Option
= OptionsList
[Index
].StringToken
;
195 OneOfOption
.Value
= OptionsList
[Index
].Value
;
196 OneOfOption
.Flags
= OptionsList
[Index
].Flags
;
197 OneOfOption
.Key
= OptionsList
[Index
].Key
;
199 CopyMem (LocalBuffer
, &OneOfOption
, sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
201 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
204 EndOneOf
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
);
205 EndOneOf
.Header
.OpCode
= FRAMEWORK_EFI_IFR_END_ONE_OF_OP
;
207 CopyMem (LocalBuffer
, &EndOneOf
, sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
209 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
215 Create a ordered list opcode with a set of option op-codes to choose from independent of string creation.
216 This is used primarily by users who need to create just one particular valid op-code and the string
217 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
218 location to pre-defined forms in HII)
220 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
221 has been filled in since this routine will not generate StringToken values.
223 @param QuestionId - Question ID of the ordered list
224 @param MaxEntries - MaxEntries of the ordered list
225 @param PromptToken - Prompt string token of the ordered list
226 @param HelpToken - Help string token of the ordered list
227 @param OptionsList - Each string in it is an option of the ordered list
228 @param OptionCount - Option string count
229 @param FormBuffer - Output of ordered list as a form
231 @retval EFI_SUCCESS - Ordered list created to be a form
234 CreateOrderedListOpCode (
235 IN UINT16 QuestionId
,
237 IN STRING_REF PromptToken
,
238 IN STRING_REF HelpToken
,
239 IN IFR_OPTION
*OptionsList
,
240 IN UINTN OptionCount
,
241 IN OUT VOID
*FormBuffer
245 FRAMEWORK_EFI_IFR_ORDERED_LIST OrderedList
;
246 FRAMEWORK_EFI_IFR_ONE_OF_OPTION OrderedListOption
;
247 FRAMEWORK_EFI_IFR_END_ONE_OF EndOrderedList
;
250 OrderedList
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ORDERED_LIST_OP
;
251 OrderedList
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
);
252 OrderedList
.QuestionId
= QuestionId
;
253 OrderedList
.MaxEntries
= MaxEntries
;
254 OrderedList
.Prompt
= PromptToken
;
256 OrderedList
.Help
= HelpToken
;
258 LocalBuffer
= (UINT8
*) FormBuffer
;
260 CopyMem (LocalBuffer
, &OrderedList
, sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
));
262 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
));
264 for (Index
= 0; Index
< OptionCount
; Index
++) {
265 OrderedListOption
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP
;
266 OrderedListOption
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
);
268 OrderedListOption
.Option
= OptionsList
[Index
].StringToken
;
269 OrderedListOption
.Value
= OptionsList
[Index
].Value
;
270 OrderedListOption
.Flags
= OptionsList
[Index
].Flags
;
271 OrderedListOption
.Key
= OptionsList
[Index
].Key
;
273 CopyMem (LocalBuffer
, &OrderedListOption
, sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
275 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
278 EndOrderedList
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
);
279 EndOrderedList
.Header
.OpCode
= FRAMEWORK_EFI_IFR_END_ONE_OF_OP
;
281 CopyMem (LocalBuffer
, &EndOrderedList
, sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
283 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
289 Create a checkbox opcode independent of string creation
290 This is used primarily by users who need to create just one particular valid op-code and the string
291 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
292 location to pre-defined forms in HII)
294 @param QuestionId - Question ID of the check box
295 @param DataWidth - DataWidth of the check box
296 @param PromptToken - Prompt string token of the check box
297 @param HelpToken - Help string token of the check box
298 @param Flags - Flags of the check box
299 @param Key - Key of the check box
300 @param FormBuffer - Output of the check box as a form
302 @retval EFI_SUCCESS - Checkbox created to be a form
303 @retval EFI_DEVICE_ERROR - DataWidth > 1
306 CreateCheckBoxOpCode (
307 IN UINT16 QuestionId
,
309 IN STRING_REF PromptToken
,
310 IN STRING_REF HelpToken
,
313 IN OUT VOID
*FormBuffer
317 FRAMEWORK_EFI_IFR_CHECKBOX CheckBox
;
320 // We do not create op-code storage widths for checkbox in excess of 8 bits for now
323 return EFI_DEVICE_ERROR
;
326 CheckBox
.Header
.OpCode
= FRAMEWORK_EFI_IFR_CHECKBOX_OP
;
327 CheckBox
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_CHECKBOX
);
328 CheckBox
.QuestionId
= QuestionId
;
329 CheckBox
.Width
= DataWidth
;
330 CheckBox
.Prompt
= PromptToken
;
332 CheckBox
.Help
= HelpToken
;
333 CheckBox
.Flags
= Flags
;
336 CopyMem (FormBuffer
, &CheckBox
, sizeof (FRAMEWORK_EFI_IFR_CHECKBOX
));
342 Create a numeric opcode independent of string creation
343 This is used primarily by users who need to create just one particular valid op-code and the string
344 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
345 location to pre-defined forms in HII)
347 @param QuestionId - Question ID of the numeric
348 @param DataWidth - DataWidth of the numeric
349 @param PromptToken - Prompt string token of the numeric
350 @param HelpToken - Help string token of the numeric
351 @param Minimum - Minumun boundary of the numeric
352 @param Maximum - Maximum boundary of the numeric
353 @param Step - Step of the numeric
354 @param Default - Default value of the numeric
355 @param Flags - Flags of the numeric
356 @param Key - Key of the numeric
357 @param FormBuffer - Output of the numeric as a form
360 @retval EFI_SUCCESS - The numeric created to be a form.
361 @retval EFI_DEVICE_ERROR - DataWidth > 2
364 CreateNumericOpCode (
365 IN UINT16 QuestionId
,
367 IN STRING_REF PromptToken
,
368 IN STRING_REF HelpToken
,
375 IN OUT VOID
*FormBuffer
379 FRAMEWORK_EFI_IFR_NUMERIC Numeric
;
382 // We do not create op-code storage widths for numerics in excess of 16 bits for now
385 return EFI_DEVICE_ERROR
;
388 Numeric
.Header
.OpCode
= FRAMEWORK_EFI_IFR_NUMERIC_OP
;
389 Numeric
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_NUMERIC
);
390 Numeric
.QuestionId
= QuestionId
;
391 Numeric
.Width
= DataWidth
;
392 Numeric
.Prompt
= PromptToken
;
394 Numeric
.Help
= HelpToken
;
395 Numeric
.Minimum
= Minimum
;
396 Numeric
.Maximum
= Maximum
;
398 Numeric
.Default
= Default
;
399 Numeric
.Flags
= Flags
;
402 CopyMem (FormBuffer
, &Numeric
, sizeof (FRAMEWORK_EFI_IFR_NUMERIC
));
408 Create a numeric opcode independent of string creation
409 This is used primarily by users who need to create just one particular valid op-code and the string
410 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
411 location to pre-defined forms in HII)
413 @param QuestionId Question ID of the string
414 @param DataWidth DataWidth of the string
415 @param PromptToken Prompt token of the string
416 @param HelpToken Help token of the string
417 @param MinSize Min size boundary of the string
418 @param MaxSize Max size boundary of the string
419 @param Flags Flags of the string
420 @param Key Key of the string
421 @param FormBuffer Output of the string as a form
423 @retval EFI_SUCCESS String created to be a form.
427 IN UINT16 QuestionId
,
429 IN STRING_REF PromptToken
,
430 IN STRING_REF HelpToken
,
435 IN OUT VOID
*FormBuffer
439 FRAMEWORK_EFI_IFR_STRING String
;
441 String
.Header
.OpCode
= FRAMEWORK_EFI_IFR_STRING_OP
;
442 String
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_STRING
);
443 String
.QuestionId
= QuestionId
;
444 String
.Width
= DataWidth
;
445 String
.Prompt
= PromptToken
;
447 String
.Help
= HelpToken
;
448 String
.MinSize
= MinSize
;
449 String
.MaxSize
= MaxSize
;
450 String
.Flags
= Flags
;
453 CopyMem (FormBuffer
, &String
, sizeof (FRAMEWORK_EFI_IFR_STRING
));
459 Create a banner opcode. This is primarily used by the FrontPage implementation from BDS.
461 @param Title - Title of the banner
462 @param LineNumber - LineNumber of the banner
463 @param Alignment - Alignment of the banner
464 @param FormBuffer - Output of banner as a form
466 @retval EFI_SUCCESS - Banner created to be a form.
471 IN UINT16 LineNumber
,
473 IN OUT VOID
*FormBuffer
477 FRAMEWORK_EFI_IFR_BANNER Banner
;
479 Banner
.Header
.OpCode
= FRAMEWORK_EFI_IFR_BANNER_OP
;
480 Banner
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_BANNER
);
481 CopyMem (&Banner
.Title
, &Title
, sizeof (UINT16
));
482 CopyMem (&Banner
.LineNumber
, &LineNumber
, sizeof (UINT16
));
483 Banner
.Alignment
= Alignment
;
485 CopyMem (FormBuffer
, &Banner
, sizeof (FRAMEWORK_EFI_IFR_BANNER
));