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.
16 #include "IfrSupportLibInternal.h"
19 Create a SubTitle opcode independent of string creation.
20 This is used primarily by users who need to create just one particular valid op-code and the string
21 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
22 location to pre-defined forms in HII)
24 @param StringToken StringToken of the subtitle
25 @param FormBuffer Output of subtitle as a form
27 @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
));
48 Create a Text opcode independent of string creation.
50 This is used primarily by users who need to create just one particular valid op-code and the string
51 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
52 location to pre-defined forms in HII)
54 @param StringToken First string token of the text
55 @param StringTokenTwo Second string token of the text
56 @param StringTokenThree Help string token of the text
57 @param Flags Flag of the text
58 @param Key Key of the text
59 @param FormBuffer Output of text as a form
61 @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.
93 This is used primarily by users who need to create just one particular valid op-code and the string
94 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
95 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
104 @retval EFI_SUCCESS Hyperlink created to be a form
110 IN STRING_REF StringToken
,
111 IN STRING_REF StringTokenTwo
,
114 IN OUT VOID
*FormBuffer
117 FRAMEWORK_EFI_IFR_REF Hyperlink
;
119 Hyperlink
.Header
.OpCode
= FRAMEWORK_EFI_IFR_REF_OP
;
120 Hyperlink
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_REF
);
121 Hyperlink
.FormId
= FormId
;
122 Hyperlink
.Prompt
= StringToken
;
123 Hyperlink
.Help
= StringTokenTwo
;
125 Hyperlink
.Flags
= Flags
;
127 CopyMem (FormBuffer
, &Hyperlink
, sizeof (FRAMEWORK_EFI_IFR_REF
));
133 Create a one-of opcode with a set of option op-codes to choose from 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)
138 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
139 has been filled in since this routine will not generate StringToken values.
141 @param QuestionId Question ID of the one-of box
142 @param DataWidth DataWidth of the one-of box
143 @param PromptToken Prompt string token of the one-of box
144 @param HelpToken Help string token of the one-of box
145 @param OptionsList Each string in it is an option of the one-of box
146 @param OptionCount Option string count
147 @param FormBuffer Output of One-Of box as a form
150 @retval EFI_SUCCESS One-Of box created to be a form
151 @retval EFI_DEVICE_ERROR DataWidth > 2
156 IN UINT16 QuestionId
,
158 IN STRING_REF PromptToken
,
159 IN STRING_REF HelpToken
,
160 IN IFR_OPTION
*OptionsList
,
161 IN UINTN OptionCount
,
162 IN OUT VOID
*FormBuffer
166 FRAMEWORK_EFI_IFR_ONE_OF OneOf
;
167 FRAMEWORK_EFI_IFR_ONE_OF_OPTION OneOfOption
;
168 FRAMEWORK_EFI_IFR_END_ONE_OF EndOneOf
;
172 // We do not create op-code storage widths for one-of in excess of 16 bits for now
175 return EFI_DEVICE_ERROR
;
178 OneOf
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ONE_OF_OP
;
179 OneOf
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ONE_OF
);
180 OneOf
.QuestionId
= QuestionId
;
181 OneOf
.Width
= DataWidth
;
182 OneOf
.Prompt
= PromptToken
;
183 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
235 CreateOrderedListOpCode (
236 IN UINT16 QuestionId
,
238 IN STRING_REF PromptToken
,
239 IN STRING_REF HelpToken
,
240 IN IFR_OPTION
*OptionsList
,
241 IN UINTN OptionCount
,
242 IN OUT VOID
*FormBuffer
246 FRAMEWORK_EFI_IFR_ORDERED_LIST OrderedList
;
247 FRAMEWORK_EFI_IFR_ONE_OF_OPTION OrderedListOption
;
248 FRAMEWORK_EFI_IFR_END_ONE_OF EndOrderedList
;
251 OrderedList
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ORDERED_LIST_OP
;
252 OrderedList
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
);
253 OrderedList
.QuestionId
= QuestionId
;
254 OrderedList
.MaxEntries
= MaxEntries
;
255 OrderedList
.Prompt
= PromptToken
;
256 OrderedList
.Help
= HelpToken
;
257 LocalBuffer
= (UINT8
*) FormBuffer
;
259 CopyMem (LocalBuffer
, &OrderedList
, sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
));
261 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
));
263 for (Index
= 0; Index
< OptionCount
; Index
++) {
264 OrderedListOption
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP
;
265 OrderedListOption
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
);
267 OrderedListOption
.Option
= OptionsList
[Index
].StringToken
;
268 OrderedListOption
.Value
= OptionsList
[Index
].Value
;
269 OrderedListOption
.Flags
= OptionsList
[Index
].Flags
;
270 OrderedListOption
.Key
= OptionsList
[Index
].Key
;
272 CopyMem (LocalBuffer
, &OrderedListOption
, sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
274 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
277 EndOrderedList
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
);
278 EndOrderedList
.Header
.OpCode
= FRAMEWORK_EFI_IFR_END_ONE_OF_OP
;
280 CopyMem (LocalBuffer
, &EndOrderedList
, sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
282 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
288 Create a checkbox opcode independent of string creation.
289 This is used primarily by users who need to create just one particular valid op-code and the string
290 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
291 location to pre-defined forms in HII)
293 @param QuestionId Question ID of the check box
294 @param DataWidth DataWidth of the check box
295 @param PromptToken Prompt string token of the check box
296 @param HelpToken Help string token of the check box
297 @param Flags Flags of the check box
298 @param Key Key of the check box
299 @param FormBuffer Output of the check box as a form
301 @retval EFI_SUCCESS Checkbox created to be a form
302 @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
316 FRAMEWORK_EFI_IFR_CHECKBOX CheckBox
;
319 // We do not create op-code storage widths for checkbox in excess of 8 bits for now
322 return EFI_DEVICE_ERROR
;
325 CheckBox
.Header
.OpCode
= FRAMEWORK_EFI_IFR_CHECKBOX_OP
;
326 CheckBox
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_CHECKBOX
);
327 CheckBox
.QuestionId
= QuestionId
;
328 CheckBox
.Width
= DataWidth
;
329 CheckBox
.Prompt
= PromptToken
;
330 CheckBox
.Help
= HelpToken
;
331 CheckBox
.Flags
= Flags
;
334 CopyMem (FormBuffer
, &CheckBox
, sizeof (FRAMEWORK_EFI_IFR_CHECKBOX
));
340 Create a numeric opcode independent of string creation.
341 This is used primarily by users who need to create just one particular valid op-code and the string
342 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
343 location to pre-defined forms in HII)
345 @param QuestionId Question ID of the numeric
346 @param DataWidth DataWidth of the numeric
347 @param PromptToken Prompt string token of the numeric
348 @param HelpToken Help string token of the numeric
349 @param Minimum Minumun boundary of the numeric
350 @param Maximum Maximum boundary of the numeric
351 @param Step Step of the numeric
352 @param Default Default value of the numeric
353 @param Flags Flags of the numeric
354 @param Key Key of the numeric
355 @param FormBuffer Output of the numeric as a form
358 @retval EFI_SUCCESS The numeric created to be a form.
359 @retval EFI_DEVICE_ERROR DataWidth > 2
363 CreateNumericOpCode (
364 IN UINT16 QuestionId
,
366 IN STRING_REF PromptToken
,
367 IN STRING_REF HelpToken
,
374 IN OUT VOID
*FormBuffer
377 FRAMEWORK_EFI_IFR_NUMERIC Numeric
;
380 // We do not create op-code storage widths for numerics in excess of 16 bits for now
383 return EFI_DEVICE_ERROR
;
386 Numeric
.Header
.OpCode
= FRAMEWORK_EFI_IFR_NUMERIC_OP
;
387 Numeric
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_NUMERIC
);
388 Numeric
.QuestionId
= QuestionId
;
389 Numeric
.Width
= DataWidth
;
390 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.
425 IN UINT16 QuestionId
,
427 IN STRING_REF PromptToken
,
428 IN STRING_REF HelpToken
,
433 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
;
443 String
.Help
= HelpToken
;
444 String
.MinSize
= MinSize
;
445 String
.MaxSize
= MaxSize
;
446 String
.Flags
= Flags
;
449 CopyMem (FormBuffer
, &String
, sizeof (FRAMEWORK_EFI_IFR_STRING
));
455 Create a banner opcode. This is primarily used by the FrontPage implementation from BDS.
457 @param Title Title of the banner
458 @param LineNumber LineNumber of the banner
459 @param Alignment Alignment of the banner
460 @param FormBuffer Output of banner as a form
462 @retval EFI_SUCCESS Banner created to be a form.
468 IN UINT16 LineNumber
,
470 IN OUT VOID
*FormBuffer
473 FRAMEWORK_EFI_IFR_BANNER Banner
;
475 Banner
.Header
.OpCode
= FRAMEWORK_EFI_IFR_BANNER_OP
;
476 Banner
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_BANNER
);
477 CopyMem (&Banner
.Title
, &Title
, sizeof (UINT16
));
478 CopyMem (&Banner
.LineNumber
, &LineNumber
, sizeof (UINT16
));
479 Banner
.Alignment
= Alignment
;
481 CopyMem (FormBuffer
, &Banner
, sizeof (FRAMEWORK_EFI_IFR_BANNER
));