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
30 CreateSubTitleOpCode (
31 IN STRING_REF StringToken
,
32 IN OUT VOID
*FormBuffer
35 FRAMEWORK_EFI_IFR_SUBTITLE Subtitle
;
37 Subtitle
.Header
.OpCode
= FRAMEWORK_EFI_IFR_SUBTITLE_OP
;
38 Subtitle
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_SUBTITLE
);
39 Subtitle
.SubTitle
= StringToken
;
41 CopyMem (FormBuffer
, &Subtitle
, sizeof (FRAMEWORK_EFI_IFR_SUBTITLE
));
46 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.
90 This is used primarily by users who need to create just one particular valid op-code and the string
91 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
92 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
101 @retval EFI_SUCCESS Hyperlink created to be a form
106 IN STRING_REF StringToken
,
107 IN STRING_REF StringTokenTwo
,
110 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
;
178 OneOf
.Help
= HelpToken
;
179 LocalBuffer
= (UINT8
*) FormBuffer
;
181 CopyMem (LocalBuffer
, &OneOf
, sizeof (FRAMEWORK_EFI_IFR_ONE_OF
));
183 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ONE_OF
));
185 for (Index
= 0; Index
< OptionCount
; Index
++) {
186 OneOfOption
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP
;
187 OneOfOption
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
);
189 OneOfOption
.Option
= OptionsList
[Index
].StringToken
;
190 OneOfOption
.Value
= OptionsList
[Index
].Value
;
191 OneOfOption
.Flags
= OptionsList
[Index
].Flags
;
192 OneOfOption
.Key
= OptionsList
[Index
].Key
;
194 CopyMem (LocalBuffer
, &OneOfOption
, sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
196 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
199 EndOneOf
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
);
200 EndOneOf
.Header
.OpCode
= FRAMEWORK_EFI_IFR_END_ONE_OF_OP
;
202 CopyMem (LocalBuffer
, &EndOneOf
, sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
204 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
210 Create a ordered list opcode with a set of option op-codes to choose from independent of string creation.
211 This is used primarily by users who need to create just one particular valid op-code and the string
212 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
213 location to pre-defined forms in HII)
215 OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
216 has been filled in since this routine will not generate StringToken values.
218 @param QuestionId Question ID of the ordered list
219 @param MaxEntries MaxEntries of the ordered list
220 @param PromptToken Prompt string token of the ordered list
221 @param HelpToken Help string token of the ordered list
222 @param OptionsList Each string in it is an option of the ordered list
223 @param OptionCount Option string count
224 @param FormBuffer Output of ordered list as a form
226 @retval EFI_SUCCESS Ordered list created to be a form
229 CreateOrderedListOpCode (
230 IN UINT16 QuestionId
,
232 IN STRING_REF PromptToken
,
233 IN STRING_REF HelpToken
,
234 IN IFR_OPTION
*OptionsList
,
235 IN UINTN OptionCount
,
236 IN OUT VOID
*FormBuffer
240 FRAMEWORK_EFI_IFR_ORDERED_LIST OrderedList
;
241 FRAMEWORK_EFI_IFR_ONE_OF_OPTION OrderedListOption
;
242 FRAMEWORK_EFI_IFR_END_ONE_OF EndOrderedList
;
245 OrderedList
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ORDERED_LIST_OP
;
246 OrderedList
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
);
247 OrderedList
.QuestionId
= QuestionId
;
248 OrderedList
.MaxEntries
= MaxEntries
;
249 OrderedList
.Prompt
= PromptToken
;
250 OrderedList
.Help
= HelpToken
;
251 LocalBuffer
= (UINT8
*) FormBuffer
;
253 CopyMem (LocalBuffer
, &OrderedList
, sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
));
255 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST
));
257 for (Index
= 0; Index
< OptionCount
; Index
++) {
258 OrderedListOption
.Header
.OpCode
= FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP
;
259 OrderedListOption
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
);
261 OrderedListOption
.Option
= OptionsList
[Index
].StringToken
;
262 OrderedListOption
.Value
= OptionsList
[Index
].Value
;
263 OrderedListOption
.Flags
= OptionsList
[Index
].Flags
;
264 OrderedListOption
.Key
= OptionsList
[Index
].Key
;
266 CopyMem (LocalBuffer
, &OrderedListOption
, sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
268 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION
));
271 EndOrderedList
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
);
272 EndOrderedList
.Header
.OpCode
= FRAMEWORK_EFI_IFR_END_ONE_OF_OP
;
274 CopyMem (LocalBuffer
, &EndOrderedList
, sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
276 LocalBuffer
= (UINT8
*) (LocalBuffer
+ sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF
));
282 Create a checkbox opcode independent of string creation.
283 This is used primarily by users who need to create just one particular valid op-code and the string
284 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
285 location to pre-defined forms in HII)
287 @param QuestionId Question ID of the check box
288 @param DataWidth DataWidth of the check box
289 @param PromptToken Prompt string token of the check box
290 @param HelpToken Help string token of the check box
291 @param Flags Flags of the check box
292 @param Key Key of the check box
293 @param FormBuffer Output of the check box as a form
295 @retval EFI_SUCCESS Checkbox created to be a form
296 @retval EFI_DEVICE_ERROR DataWidth > 1
299 CreateCheckBoxOpCode (
300 IN UINT16 QuestionId
,
302 IN STRING_REF PromptToken
,
303 IN STRING_REF HelpToken
,
306 IN OUT VOID
*FormBuffer
309 FRAMEWORK_EFI_IFR_CHECKBOX CheckBox
;
312 // We do not create op-code storage widths for checkbox in excess of 8 bits for now
315 return EFI_DEVICE_ERROR
;
318 CheckBox
.Header
.OpCode
= FRAMEWORK_EFI_IFR_CHECKBOX_OP
;
319 CheckBox
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_CHECKBOX
);
320 CheckBox
.QuestionId
= QuestionId
;
321 CheckBox
.Width
= DataWidth
;
322 CheckBox
.Prompt
= PromptToken
;
323 CheckBox
.Help
= HelpToken
;
324 CheckBox
.Flags
= Flags
;
327 CopyMem (FormBuffer
, &CheckBox
, sizeof (FRAMEWORK_EFI_IFR_CHECKBOX
));
333 Create a numeric opcode independent of string creation.
334 This is used primarily by users who need to create just one particular valid op-code and the string
335 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
336 location to pre-defined forms in HII)
338 @param QuestionId Question ID of the numeric
339 @param DataWidth DataWidth of the numeric
340 @param PromptToken Prompt string token of the numeric
341 @param HelpToken Help string token of the numeric
342 @param Minimum Minumun boundary of the numeric
343 @param Maximum Maximum boundary of the numeric
344 @param Step Step of the numeric
345 @param Default Default value of the numeric
346 @param Flags Flags of the numeric
347 @param Key Key of the numeric
348 @param FormBuffer Output of the numeric as a form
351 @retval EFI_SUCCESS The numeric created to be a form.
352 @retval EFI_DEVICE_ERROR DataWidth > 2
355 CreateNumericOpCode (
356 IN UINT16 QuestionId
,
358 IN STRING_REF PromptToken
,
359 IN STRING_REF HelpToken
,
366 IN OUT VOID
*FormBuffer
369 FRAMEWORK_EFI_IFR_NUMERIC Numeric
;
372 // We do not create op-code storage widths for numerics in excess of 16 bits for now
375 return EFI_DEVICE_ERROR
;
378 Numeric
.Header
.OpCode
= FRAMEWORK_EFI_IFR_NUMERIC_OP
;
379 Numeric
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_NUMERIC
);
380 Numeric
.QuestionId
= QuestionId
;
381 Numeric
.Width
= DataWidth
;
382 Numeric
.Prompt
= PromptToken
;
383 Numeric
.Help
= HelpToken
;
384 Numeric
.Minimum
= Minimum
;
385 Numeric
.Maximum
= Maximum
;
387 Numeric
.Default
= Default
;
388 Numeric
.Flags
= Flags
;
391 CopyMem (FormBuffer
, &Numeric
, sizeof (FRAMEWORK_EFI_IFR_NUMERIC
));
397 Create a numeric opcode independent of string creation.
398 This is used primarily by users who need to create just one particular valid op-code and the string
399 data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
400 location to pre-defined forms in HII)
402 @param QuestionId Question ID of the string
403 @param DataWidth DataWidth of the string
404 @param PromptToken Prompt token of the string
405 @param HelpToken Help token of the string
406 @param MinSize Min size boundary of the string
407 @param MaxSize Max size boundary of the string
408 @param Flags Flags of the string
409 @param Key Key of the string
410 @param FormBuffer Output of the string as a form
412 @retval EFI_SUCCESS String created to be a form.
416 IN UINT16 QuestionId
,
418 IN STRING_REF PromptToken
,
419 IN STRING_REF HelpToken
,
424 IN OUT VOID
*FormBuffer
427 FRAMEWORK_EFI_IFR_STRING String
;
429 String
.Header
.OpCode
= FRAMEWORK_EFI_IFR_STRING_OP
;
430 String
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_STRING
);
431 String
.QuestionId
= QuestionId
;
432 String
.Width
= DataWidth
;
433 String
.Prompt
= PromptToken
;
434 String
.Help
= HelpToken
;
435 String
.MinSize
= MinSize
;
436 String
.MaxSize
= MaxSize
;
437 String
.Flags
= Flags
;
440 CopyMem (FormBuffer
, &String
, sizeof (FRAMEWORK_EFI_IFR_STRING
));
446 Create a banner opcode. This is primarily used by the FrontPage implementation from BDS.
448 @param Title Title of the banner
449 @param LineNumber LineNumber of the banner
450 @param Alignment Alignment of the banner
451 @param FormBuffer Output of banner as a form
453 @retval EFI_SUCCESS Banner created to be a form.
458 IN UINT16 LineNumber
,
460 IN OUT VOID
*FormBuffer
463 FRAMEWORK_EFI_IFR_BANNER Banner
;
465 Banner
.Header
.OpCode
= FRAMEWORK_EFI_IFR_BANNER_OP
;
466 Banner
.Header
.Length
= sizeof (FRAMEWORK_EFI_IFR_BANNER
);
467 CopyMem (&Banner
.Title
, &Title
, sizeof (UINT16
));
468 CopyMem (&Banner
.LineNumber
, &LineNumber
, sizeof (UINT16
));
469 Banner
.Alignment
= Alignment
;
471 CopyMem (FormBuffer
, &Banner
, sizeof (FRAMEWORK_EFI_IFR_BANNER
));