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.
17 #include "IfrSupportLibInternal.h"
20 Create a SubTitle opcode independent of string creation
21 This is used primarily by users who need to create just one particular valid op-code and the string
22 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
23 location to pre-defined forms in HII)
25 @param StringToken StringToken of the subtitle
26 @param FormBuffer Output of subtitle as a form
28 @retval EFI_SUCCESS Subtitle created to be a form
31 CreateSubTitleOpCode (
32 IN STRING_REF StringToken
,
33 IN OUT VOID
*FormBuffer
36 FRAMEWORK_EFI_IFR_SUBTITLE Subtitle
;
38 Subtitle
.Header
.OpCode
= FRAMEWORK_EFI_IFR_SUBTITLE_OP
;
39 Subtitle
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_SUBTITLE
);
40 Subtitle
.SubTitle
= StringToken
;
42 CopyMem (FormBuffer
, &Subtitle
, sizeof (FRAMEWORK_EFI_IFR_SUBTITLE
));
47 Create a Text opcode independent of string creation
48 This is used primarily by users who need to create just one particular valid op-code and the string
49 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
50 location to pre-defined forms in HII)
52 @param StringToken - First string token of the text
53 @param StringTokenTwo - Second string token of the text
54 @param StringTokenThree - Help string token of the text
55 @param Flags - Flag of the text
56 @param Key - Key of the text
57 @param FormBuffer - Output of text as a form
59 @retval EFI_SUCCESS - Text created to be a form
63 IN STRING_REF StringToken
,
64 IN STRING_REF StringTokenTwo
,
65 IN STRING_REF StringTokenThree
,
68 IN OUT VOID
*FormBuffer
71 FRAMEWORK_EFI_IFR_TEXT Text
;
73 Text
.Header
.OpCode
= FRAMEWORK_EFI_IFR_TEXT_OP
;
74 Text
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_TEXT
);
75 Text
.Text
= StringToken
;
77 Text
.TextTwo
= StringTokenTwo
;
78 Text
.Help
= StringTokenThree
;
82 CopyMem (FormBuffer
, &Text
, sizeof (FRAMEWORK_EFI_IFR_TEXT
));
88 Create a hyperlink opcode independent of string creation
89 This is used primarily by users who need to create just one particular valid op-code and the string
90 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
91 location to pre-defined forms in HII)
94 @param FormId - Form ID of the hyperlink
95 @param StringToken - Prompt string token of the hyperlink
96 @param StringTokenTwo - Help string token of the hyperlink
97 @param Flags - Flags of the hyperlink
98 @param Key - Key of the hyperlink
99 @param FormBuffer - Output of hyperlink as a form
100 @retval EFI_SUCCESS - Hyperlink created to be a form
105 IN STRING_REF StringToken
,
106 IN STRING_REF StringTokenTwo
,
109 IN OUT VOID
*FormBuffer
113 FRAMEWORK_EFI_IFR_REF Hyperlink
;
115 Hyperlink
.Header
.OpCode
= FRAMEWORK_EFI_IFR_REF_OP
;
116 Hyperlink
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_REF
);
117 Hyperlink
.FormId
= FormId
;
118 Hyperlink
.Prompt
= StringToken
;
119 Hyperlink
.Help
= StringTokenTwo
;
121 Hyperlink
.Flags
= Flags
;
123 CopyMem (FormBuffer
, &Hyperlink
, sizeof (FRAMEWORK_EFI_IFR_REF
));
129 Create a one-of opcode with a set of option op-codes to choose from independent of string creation.
130 This is used primarily by users who need to create just one particular valid op-code and the string
131 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
132 location to pre-defined forms in HII)
134 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
135 has been filled in since this routine will not generate StringToken values.
137 @param QuestionId - Question ID of the one-of box
138 @param DataWidth - DataWidth of the one-of box
139 @param PromptToken - Prompt string token of the one-of box
140 @param HelpToken - Help string token of the one-of box
141 @param OptionsList - Each string in it is an option of the one-of box
142 @param OptionCount - Option string count
143 @param FormBuffer - Output of One-Of box as a form
146 @retval EFI_SUCCESS - One-Of box created to be a form
147 @retval EFI_DEVICE_ERROR - DataWidth > 2
151 IN UINT16 QuestionId
,
153 IN STRING_REF PromptToken
,
154 IN STRING_REF HelpToken
,
155 IN IFR_OPTION
*OptionsList
,
156 IN UINTN OptionCount
,
157 IN OUT VOID
*FormBuffer
161 FRAMEWORK_EFI_IFR_ONE_OF OneOf
;
162 FRAMEWORK_EFI_IFR_ONE_OF_OPTION OneOfOption
;
163 FRAMEWORK_EFI_IFR_END_ONE_OF EndOneOf
;
167 // We do not create op-code storage widths for one-of in excess of 16 bits for now
170 return EFI_DEVICE_ERROR
;
173 OneOf
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ONE_OF_OP
;
174 OneOf
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ONE_OF
);
175 OneOf
.QuestionId
= QuestionId
;
176 OneOf
.Width
= DataWidth
;
177 OneOf
.Prompt
= PromptToken
;
179 OneOf
.Help
= HelpToken
;
181 LocalBuffer
= (UINT8
*) FormBuffer
;
183 CopyMem (LocalBuffer
, &OneOf
, sizeof (FRAMEWORK_EFI_IFR_ONE_OF
));
185 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ONE_OF
));
187 for (Index
= 0; Index
< OptionCount
; Index
++) {
188 OneOfOption
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP
;
189 OneOfOption
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
);
191 OneOfOption
.Option
= OptionsList
[Index
].StringToken
;
192 OneOfOption
.Value
= OptionsList
[Index
].Value
;
193 OneOfOption
.Flags
= OptionsList
[Index
].Flags
;
194 OneOfOption
.Key
= OptionsList
[Index
].Key
;
196 CopyMem (LocalBuffer
, &OneOfOption
, sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
198 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
201 EndOneOf
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
);
202 EndOneOf
.Header
.OpCode
= FRAMEWORK_EFI_IFR_END_ONE_OF_OP
;
204 CopyMem (LocalBuffer
, &EndOneOf
, sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
206 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
212 Create a ordered list opcode with a set of option op-codes to choose from independent of string creation.
213 This is used primarily by users who need to create just one particular valid op-code and the string
214 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
215 location to pre-defined forms in HII)
217 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
218 has been filled in since this routine will not generate StringToken values.
220 @param QuestionId - Question ID of the ordered list
221 @param MaxEntries - MaxEntries of the ordered list
222 @param PromptToken - Prompt string token of the ordered list
223 @param HelpToken - Help string token of the ordered list
224 @param OptionsList - Each string in it is an option of the ordered list
225 @param OptionCount - Option string count
226 @param FormBuffer - Output of ordered list as a form
228 @retval EFI_SUCCESS - Ordered list created to be a form
231 CreateOrderedListOpCode (
232 IN UINT16 QuestionId
,
234 IN STRING_REF PromptToken
,
235 IN STRING_REF HelpToken
,
236 IN IFR_OPTION
*OptionsList
,
237 IN UINTN OptionCount
,
238 IN OUT VOID
*FormBuffer
242 FRAMEWORK_EFI_IFR_ORDERED_LIST OrderedList
;
243 FRAMEWORK_EFI_IFR_ONE_OF_OPTION OrderedListOption
;
244 FRAMEWORK_EFI_IFR_END_ONE_OF EndOrderedList
;
247 OrderedList
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ORDERED_LIST_OP
;
248 OrderedList
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
);
249 OrderedList
.QuestionId
= QuestionId
;
250 OrderedList
.MaxEntries
= MaxEntries
;
251 OrderedList
.Prompt
= PromptToken
;
253 OrderedList
.Help
= HelpToken
;
255 LocalBuffer
= (UINT8
*) FormBuffer
;
257 CopyMem (LocalBuffer
, &OrderedList
, sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
));
259 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
));
261 for (Index
= 0; Index
< OptionCount
; Index
++) {
262 OrderedListOption
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP
;
263 OrderedListOption
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
);
265 OrderedListOption
.Option
= OptionsList
[Index
].StringToken
;
266 OrderedListOption
.Value
= OptionsList
[Index
].Value
;
267 OrderedListOption
.Flags
= OptionsList
[Index
].Flags
;
268 OrderedListOption
.Key
= OptionsList
[Index
].Key
;
270 CopyMem (LocalBuffer
, &OrderedListOption
, sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
272 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
275 EndOrderedList
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
);
276 EndOrderedList
.Header
.OpCode
= FRAMEWORK_EFI_IFR_END_ONE_OF_OP
;
278 CopyMem (LocalBuffer
, &EndOrderedList
, sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
280 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
286 Create a checkbox opcode independent of string creation
287 This is used primarily by users who need to create just one particular valid op-code and the string
288 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
289 location to pre-defined forms in HII)
291 @param QuestionId - Question ID of the check box
292 @param DataWidth - DataWidth of the check box
293 @param PromptToken - Prompt string token of the check box
294 @param HelpToken - Help string token of the check box
295 @param Flags - Flags of the check box
296 @param Key - Key of the check box
297 @param FormBuffer - Output of the check box as a form
299 @retval EFI_SUCCESS - Checkbox created to be a form
300 @retval EFI_DEVICE_ERROR - DataWidth > 1
303 CreateCheckBoxOpCode (
304 IN UINT16 QuestionId
,
306 IN STRING_REF PromptToken
,
307 IN STRING_REF HelpToken
,
310 IN OUT VOID
*FormBuffer
314 FRAMEWORK_EFI_IFR_CHECKBOX CheckBox
;
317 // We do not create op-code storage widths for checkbox in excess of 8 bits for now
320 return EFI_DEVICE_ERROR
;
323 CheckBox
.Header
.OpCode
= FRAMEWORK_EFI_IFR_CHECKBOX_OP
;
324 CheckBox
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_CHECKBOX
);
325 CheckBox
.QuestionId
= QuestionId
;
326 CheckBox
.Width
= DataWidth
;
327 CheckBox
.Prompt
= PromptToken
;
329 CheckBox
.Help
= HelpToken
;
330 CheckBox
.Flags
= Flags
;
333 CopyMem (FormBuffer
, &CheckBox
, sizeof (FRAMEWORK_EFI_IFR_CHECKBOX
));
339 Create a numeric opcode independent of string creation
340 This is used primarily by users who need to create just one particular valid op-code and the string
341 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
342 location to pre-defined forms in HII)
344 @param QuestionId - Question ID of the numeric
345 @param DataWidth - DataWidth of the numeric
346 @param PromptToken - Prompt string token of the numeric
347 @param HelpToken - Help string token of the numeric
348 @param Minimum - Minumun boundary of the numeric
349 @param Maximum - Maximum boundary of the numeric
350 @param Step - Step of the numeric
351 @param Default - Default value of the numeric
352 @param Flags - Flags of the numeric
353 @param Key - Key of the numeric
354 @param FormBuffer - Output of the numeric as a form
357 @retval EFI_SUCCESS - The numeric created to be a form.
358 @retval EFI_DEVICE_ERROR - DataWidth > 2
361 CreateNumericOpCode (
362 IN UINT16 QuestionId
,
364 IN STRING_REF PromptToken
,
365 IN STRING_REF HelpToken
,
372 IN OUT VOID
*FormBuffer
376 FRAMEWORK_EFI_IFR_NUMERIC Numeric
;
379 // We do not create op-code storage widths for numerics in excess of 16 bits for now
382 return EFI_DEVICE_ERROR
;
385 Numeric
.Header
.OpCode
= FRAMEWORK_EFI_IFR_NUMERIC_OP
;
386 Numeric
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_NUMERIC
);
387 Numeric
.QuestionId
= QuestionId
;
388 Numeric
.Width
= DataWidth
;
389 Numeric
.Prompt
= PromptToken
;
391 Numeric
.Help
= HelpToken
;
392 Numeric
.Minimum
= Minimum
;
393 Numeric
.Maximum
= Maximum
;
395 Numeric
.Default
= Default
;
396 Numeric
.Flags
= Flags
;
399 CopyMem (FormBuffer
, &Numeric
, sizeof (FRAMEWORK_EFI_IFR_NUMERIC
));
405 Create a numeric opcode independent of string creation
406 This is used primarily by users who need to create just one particular valid op-code and the string
407 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
408 location to pre-defined forms in HII)
410 @param QuestionId Question ID of the string
411 @param DataWidth DataWidth of the string
412 @param PromptToken Prompt token of the string
413 @param HelpToken Help token of the string
414 @param MinSize Min size boundary of the string
415 @param MaxSize Max size boundary of the string
416 @param Flags Flags of the string
417 @param Key Key of the string
418 @param FormBuffer Output of the string as a form
420 @retval EFI_SUCCESS String created to be a form.
424 IN UINT16 QuestionId
,
426 IN STRING_REF PromptToken
,
427 IN STRING_REF HelpToken
,
432 IN OUT VOID
*FormBuffer
436 FRAMEWORK_EFI_IFR_STRING String
;
438 String
.Header
.OpCode
= FRAMEWORK_EFI_IFR_STRING_OP
;
439 String
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_STRING
);
440 String
.QuestionId
= QuestionId
;
441 String
.Width
= DataWidth
;
442 String
.Prompt
= PromptToken
;
444 String
.Help
= HelpToken
;
445 String
.MinSize
= MinSize
;
446 String
.MaxSize
= MaxSize
;
447 String
.Flags
= Flags
;
450 CopyMem (FormBuffer
, &String
, sizeof (FRAMEWORK_EFI_IFR_STRING
));
456 Create a banner opcode. This is primarily used by the FrontPage implementation from BDS.
458 @param Title - Title of the banner
459 @param LineNumber - LineNumber of the banner
460 @param Alignment - Alignment of the banner
461 @param FormBuffer - Output of banner as a form
463 @retval EFI_SUCCESS - Banner created to be a form.
468 IN UINT16 LineNumber
,
470 IN OUT VOID
*FormBuffer
474 FRAMEWORK_EFI_IFR_BANNER Banner
;
476 Banner
.Header
.OpCode
= FRAMEWORK_EFI_IFR_BANNER_OP
;
477 Banner
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_BANNER
);
478 CopyMem (&Banner
.Title
, &Title
, sizeof (UINT16
));
479 CopyMem (&Banner
.LineNumber
, &LineNumber
, sizeof (UINT16
));
480 Banner
.Alignment
= Alignment
;
482 CopyMem (FormBuffer
, &Banner
, sizeof (FRAMEWORK_EFI_IFR_BANNER
));