]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrOnTheFly.c
correct some coding style issues.
[mirror_edk2.git] / IntelFrameworkPkg / Library / FrameworkIfrSupportLib / IfrOnTheFly.c
1 /** @file
2 Library Routines to create IFR on-the-fly
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "IfrSupportLibInternal.h"
16
17 /**
18 Create a formset
19
20 The form package is a collection of forms that are intended to describe the pages that will be
21 displayed to the user.
22
23 @param FormSetTitle Title of formset
24 @param Guid Guid of formset
25 @param Class Class of formset
26 @param SubClass Sub class of formset
27 @param FormBuffer Pointer of the formset created
28 @param StringBuffer Pointer of FormSetTitile string created
29
30 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate
31 @retval EFI_SUCCESS Formset successfully created
32 **/
33 EFI_STATUS
34 CreateFormSet (
35 IN CHAR16 *FormSetTitle,
36 IN EFI_GUID *Guid,
37 IN UINT8 Class,
38 IN UINT8 SubClass,
39 IN OUT VOID **FormBuffer,
40 IN OUT VOID **StringBuffer
41 )
42 {
43 EFI_STATUS Status;
44 EFI_HII_IFR_PACK IfrPack;
45 FRAMEWORK_EFI_IFR_FORM_SET FormSet;
46 FRAMEWORK_EFI_IFR_END_FORM_SET EndFormSet;
47 UINT8 *Destination;
48 CHAR16 CurrentLanguage[4];
49 STRING_REF StringToken;
50
51 //
52 // Pre-allocate a buffer sufficient for us to work from.
53 //
54 FormBuffer = AllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE);
55 if (FormBuffer == NULL) {
56 return EFI_OUT_OF_RESOURCES;
57 }
58
59 //
60 // Pre-allocate a buffer sufficient for us to work from.
61 //
62 StringBuffer = AllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE);
63 if (StringBuffer == NULL) {
64 gBS->FreePool (FormBuffer);
65 return EFI_OUT_OF_RESOURCES;
66 }
67
68 //
69 // Obtain current language value
70 //
71 GetCurrentLanguage (CurrentLanguage);
72
73 //
74 // Add the FormSetTitle to the string buffer and get the StringToken
75 //
76 Status = AddString (*StringBuffer, CurrentLanguage, FormSetTitle, &StringToken);
77
78 if (EFI_ERROR (Status)) {
79 return Status;
80 }
81
82 //
83 // Initialize the Ifr Package header data
84 //
85 IfrPack.Header.Length = sizeof (EFI_HII_PACK_HEADER) + sizeof (FRAMEWORK_EFI_IFR_FORM_SET) + sizeof (FRAMEWORK_EFI_IFR_END_FORM_SET);
86 IfrPack.Header.Type = EFI_HII_IFR;
87
88 //
89 // Initialize FormSet with the appropriate information
90 //
91 FormSet.Header.OpCode = FRAMEWORK_EFI_IFR_FORM_SET_OP;
92 FormSet.Header.Length = sizeof (FRAMEWORK_EFI_IFR_FORM_SET);
93 FormSet.FormSetTitle = StringToken;
94 FormSet.Class = Class;
95 FormSet.SubClass = SubClass;
96 CopyMem (&FormSet.Guid, Guid, sizeof (EFI_GUID));
97
98 //
99 // Initialize the end formset data
100 //
101 EndFormSet.Header.Length = sizeof (FRAMEWORK_EFI_IFR_END_FORM_SET);
102 EndFormSet.Header.OpCode = FRAMEWORK_EFI_IFR_END_FORM_SET_OP;
103
104 Destination = (UINT8 *) *FormBuffer;
105
106 //
107 // Copy the formset/endformset data to the form buffer
108 //
109 CopyMem (Destination, &IfrPack, sizeof (EFI_HII_PACK_HEADER));
110
111 Destination = Destination + sizeof (EFI_HII_PACK_HEADER);
112
113 CopyMem (Destination, &FormSet, sizeof (FRAMEWORK_EFI_IFR_FORM_SET));
114
115 Destination = Destination + sizeof (FRAMEWORK_EFI_IFR_FORM_SET);
116
117 CopyMem (Destination, &EndFormSet, sizeof (FRAMEWORK_EFI_IFR_END_FORM_SET));
118 return EFI_SUCCESS;
119 }
120
121 /**
122 Create a form.
123 A form is the encapsulation of what amounts to a browser page. The header defines a FormId,
124 which is referenced by the form package, among others. It also defines a FormTitle, which is a
125 string to be used as the title for the form
126
127 @param FormTitle Title of the form
128 @param FormId Id of the form
129 @param FormBuffer Pointer of the form created
130 @param StringBuffer Pointer of FormTitil string created
131
132 @retval EFI_SUCCESS Form successfully created
133 **/
134 EFI_STATUS
135 CreateForm (
136 IN CHAR16 *FormTitle,
137 IN UINT16 FormId,
138 IN OUT VOID *FormBuffer,
139 IN OUT VOID *StringBuffer
140 )
141 {
142 EFI_STATUS Status;
143 FRAMEWORK_EFI_IFR_FORM Form;
144 FRAMEWORK_EFI_IFR_END_FORM EndForm;
145 CHAR16 CurrentLanguage[4];
146 STRING_REF StringToken;
147
148 //
149 // Obtain current language value
150 //
151 GetCurrentLanguage (CurrentLanguage);
152
153 Status = AddString (StringBuffer, CurrentLanguage, FormTitle, &StringToken);
154
155 if (EFI_ERROR (Status)) {
156 return Status;
157 }
158
159 Form.Header.OpCode = FRAMEWORK_EFI_IFR_FORM_OP;
160 Form.Header.Length = sizeof (FRAMEWORK_EFI_IFR_FORM);
161 Form.FormId = FormId;
162 Form.FormTitle = StringToken;
163
164 Status = AddOpCode (FormBuffer, &Form);
165
166 if (EFI_ERROR (Status)) {
167 return Status;
168 }
169
170 EndForm.Header.OpCode = FRAMEWORK_EFI_IFR_END_FORM_OP;
171 EndForm.Header.Length = sizeof (FRAMEWORK_EFI_IFR_END_FORM);
172
173 Status = AddOpCode (FormBuffer, &EndForm);
174
175 return Status;
176 }
177
178 /**
179 Create a SubTitle
180
181 Subtitle strings are intended to be used by authors to separate sections of questions into semantic
182 groups.
183
184 @param SubTitle Sub title to be created
185 @param FormBuffer Where this subtitle to add to
186 @param StringBuffer String buffer created for subtitle
187
188 @retval EFI_SUCCESS Subtitle successfully created
189 **/
190 EFI_STATUS
191 CreateSubTitle (
192 IN CHAR16 *SubTitle,
193 IN OUT VOID *FormBuffer,
194 IN OUT VOID *StringBuffer
195 )
196 {
197 EFI_STATUS Status;
198 FRAMEWORK_EFI_IFR_SUBTITLE Subtitle;
199 CHAR16 CurrentLanguage[4];
200 STRING_REF StringToken;
201
202 //
203 // Obtain current language value
204 //
205 GetCurrentLanguage (CurrentLanguage);
206
207 Status = AddString (StringBuffer, CurrentLanguage, SubTitle, &StringToken);
208
209 if (EFI_ERROR (Status)) {
210 return Status;
211 }
212
213 Subtitle.Header.OpCode = FRAMEWORK_EFI_IFR_SUBTITLE_OP;
214 Subtitle.Header.Length = sizeof (FRAMEWORK_EFI_IFR_SUBTITLE);
215 Subtitle.SubTitle = StringToken;
216
217 Status = AddOpCode (FormBuffer, &Subtitle);
218
219 return Status;
220 }
221
222 /**
223 Create a line of text
224 Unlike HTML, text is simply another tag.
225 This tag type enables IFR to be more easily localized.
226
227 @param String First string of the text
228 @param String2 Second string of the text
229 @param String3 Help string of the text
230 @param Flags Flag of the text
231 @param Key Key of the text
232 @param FormBuffer The form where this text adds to
233 @param StringBuffer String buffer created for String, String2 and String3
234
235 @retval EFI_SUCCESS Text successfully created
236 **/
237 EFI_STATUS
238 CreateText (
239 IN CHAR16 *String,
240 IN CHAR16 *String2,
241 IN CHAR16 *String3,
242 IN UINT8 Flags,
243 IN UINT16 Key,
244 IN OUT VOID *FormBuffer,
245 IN OUT VOID *StringBuffer
246 )
247 {
248 EFI_STATUS Status;
249 FRAMEWORK_EFI_IFR_TEXT Text;
250 CHAR16 CurrentLanguage[4];
251 STRING_REF StringToken;
252
253 //
254 // Obtain current language value
255 //
256 GetCurrentLanguage (CurrentLanguage);
257
258 //
259 // Add first string, get first string's token
260 //
261 Status = AddString (StringBuffer, CurrentLanguage, String, &StringToken);
262
263 if (EFI_ERROR (Status)) {
264 return Status;
265 }
266
267 Text.Header.OpCode = FRAMEWORK_EFI_IFR_TEXT_OP;
268 Text.Header.Length = sizeof (FRAMEWORK_EFI_IFR_TEXT);
269 Text.Text = StringToken;
270
271 //
272 // Add second string, get first string's token
273 //
274 Status = AddString (StringBuffer, CurrentLanguage, String2, &StringToken);
275
276 if (EFI_ERROR (Status)) {
277 return Status;
278 }
279
280 Text.TextTwo = StringToken;
281
282 Text.Flags = (UINT8) (Flags | FRAMEWORK_EFI_IFR_FLAG_CREATED);
283 Text.Key = Key;
284
285 //
286 // Add second string, get first string's token
287 //
288 Status = AddString (StringBuffer, CurrentLanguage, String3, &StringToken);
289
290 if (EFI_ERROR (Status)) {
291 return Status;
292 }
293
294 Text.Help = StringToken;
295
296 Status = AddOpCode (FormBuffer, &Text);
297
298 return Status;
299 }
300
301 /**
302 Create a hyperlink.
303
304 @param FormId Form ID of the hyperlink
305 @param Prompt Prompt of the hyperlink
306 @param FormBuffer The form where this hyperlink adds to
307 @param StringBuffer String buffer created for Prompt
308
309 @retval EFI_SUCCESS Hyperlink successfully created
310 **/
311 EFI_STATUS
312 CreateGoto (
313 IN UINT16 FormId,
314 IN CHAR16 *Prompt,
315 IN OUT VOID *FormBuffer,
316 IN OUT VOID *StringBuffer
317 )
318 {
319 EFI_STATUS Status;
320 FRAMEWORK_EFI_IFR_REF Hyperlink;
321 CHAR16 CurrentLanguage[4];
322 STRING_REF StringToken;
323
324 //
325 // Obtain current language value
326 //
327 GetCurrentLanguage (CurrentLanguage);
328
329 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
330
331 if (EFI_ERROR (Status)) {
332 return Status;
333 }
334
335 Hyperlink.Header.OpCode = FRAMEWORK_EFI_IFR_REF_OP;
336 Hyperlink.Header.Length = sizeof (FRAMEWORK_EFI_IFR_REF);
337 Hyperlink.FormId = FormId;
338 Hyperlink.Prompt = StringToken;
339
340 Status = AddOpCode (FormBuffer, &Hyperlink);
341
342 return Status;
343 }
344
345 /**
346 Create a one-of question with a set of options to choose from. The
347 OptionsList is a pointer to a null-terminated list of option descriptions.
348
349 @param QuestionId Question ID of the one-of box
350 @param DataWidth DataWidth of the one-of box
351 @param Prompt Prompt of the one-of box
352 @param Help Help of the one-of box
353 @param OptionsList Each string in it is an option of the one-of box
354 @param OptionCount Option string count
355 @param FormBuffer The form where this one-of box adds to
356 @param StringBuffer String buffer created for Prompt, Help and Option strings
357
358 @retval EFI_DEVICE_ERROR DataWidth > 2
359 @retval EFI_SUCCESS One-Of box successfully created.
360 **/
361 EFI_STATUS
362 CreateOneOf (
363 IN UINT16 QuestionId,
364 IN UINT8 DataWidth,
365 IN CHAR16 *Prompt,
366 IN CHAR16 *Help,
367 IN IFR_OPTION *OptionsList,
368 IN UINTN OptionCount,
369 IN OUT VOID *FormBuffer,
370 IN OUT VOID *StringBuffer
371 )
372 {
373 EFI_STATUS Status;
374 UINTN Index;
375 FRAMEWORK_EFI_IFR_ONE_OF OneOf;
376 FRAMEWORK_EFI_IFR_ONE_OF_OPTION OneOfOption;
377 FRAMEWORK_EFI_IFR_END_ONE_OF EndOneOf;
378 CHAR16 CurrentLanguage[4];
379 STRING_REF StringToken;
380
381 //
382 // We do not create op-code storage widths for one-of in excess of 16 bits for now
383 //
384 if (DataWidth > 2) {
385 return EFI_DEVICE_ERROR;
386 }
387
388 //
389 // Obtain current language value
390 //
391 GetCurrentLanguage (CurrentLanguage);
392
393 //
394 // Add first string, get first string's token
395 //
396 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
397
398 if (EFI_ERROR (Status)) {
399 return Status;
400 }
401
402 OneOf.Header.OpCode = FRAMEWORK_EFI_IFR_ONE_OF_OP;
403 OneOf.Header.Length = sizeof (FRAMEWORK_EFI_IFR_ONE_OF);
404 OneOf.QuestionId = QuestionId;
405 OneOf.Width = DataWidth;
406 OneOf.Prompt = StringToken;
407
408 //
409 // Add second string, get first string's token
410 //
411 Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
412
413 if (EFI_ERROR (Status)) {
414 return Status;
415 }
416
417 OneOf.Help = StringToken;
418
419 Status = AddOpCode (FormBuffer, &OneOf);
420
421 if (EFI_ERROR (Status)) {
422 return Status;
423 }
424
425 for (Index = 0; Index < OptionCount; Index++) {
426 OneOfOption.Header.OpCode = FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP;
427 OneOfOption.Header.Length = sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION);
428
429 //
430 // Add string and get token back
431 //
432 Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken);
433
434 OneOfOption.Option = StringToken;
435 OneOfOption.Value = OptionsList[Index].Value;
436 OneOfOption.Flags = (UINT8) (OptionsList[Index].Flags | FRAMEWORK_EFI_IFR_FLAG_CREATED);
437 OneOfOption.Key = OptionsList[Index].Key;
438
439 Status = AddOpCode (FormBuffer, &OneOfOption);
440
441 if (EFI_ERROR (Status)) {
442 return Status;
443 }
444 }
445
446 EndOneOf.Header.Length = sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF);
447 EndOneOf.Header.OpCode = FRAMEWORK_EFI_IFR_END_ONE_OF_OP;
448
449 Status = AddOpCode (FormBuffer, &EndOneOf);
450
451 if (EFI_ERROR (Status)) {
452 return Status;
453 }
454
455 return EFI_SUCCESS;
456 }
457
458 /**
459 Create a one-of question with a set of options to choose from. The
460 OptionsList is a pointer to a null-terminated list of option descriptions.
461
462 @param QuestionId Question ID of the ordered list
463 @param MaxEntries MaxEntries of the ordered list
464 @param Prompt Prompt of the ordered list
465 @param Help Help of the ordered list
466 @param OptionsList Each string in it is an option of the ordered list
467 @param OptionCount Option string count
468 @param FormBuffer The form where this ordered list adds to
469 @param StringBuffer String buffer created for Prompt, Help and Option strings
470
471 @retval EFI_SUCCESS Ordered list successfully created.
472 **/
473 EFI_STATUS
474 CreateOrderedList (
475 IN UINT16 QuestionId,
476 IN UINT8 MaxEntries,
477 IN CHAR16 *Prompt,
478 IN CHAR16 *Help,
479 IN IFR_OPTION *OptionsList,
480 IN UINTN OptionCount,
481 IN OUT VOID *FormBuffer,
482 IN OUT VOID *StringBuffer
483 )
484 {
485 EFI_STATUS Status;
486 UINTN Index;
487 FRAMEWORK_EFI_IFR_ORDERED_LIST OrderedList;
488 FRAMEWORK_EFI_IFR_ONE_OF_OPTION OrderedListOption;
489 FRAMEWORK_EFI_IFR_END_ONE_OF EndOrderedList;
490 CHAR16 CurrentLanguage[4];
491 STRING_REF StringToken;
492
493 //
494 // Obtain current language value
495 //
496 GetCurrentLanguage (CurrentLanguage);
497
498 //
499 // Add first string, get first string's token
500 //
501 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
502
503 if (EFI_ERROR (Status)) {
504 return Status;
505 }
506
507 OrderedList.Header.OpCode = FRAMEWORK_EFI_IFR_ORDERED_LIST_OP;
508 OrderedList.Header.Length = sizeof (FRAMEWORK_EFI_IFR_ORDERED_LIST);
509 OrderedList.QuestionId = QuestionId;
510 OrderedList.MaxEntries = MaxEntries;
511 OrderedList.Prompt = StringToken;
512
513 //
514 // Add second string, get first string's token
515 //
516 Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
517
518 if (EFI_ERROR (Status)) {
519 return Status;
520 }
521
522 OrderedList.Help = StringToken;
523
524 Status = AddOpCode (FormBuffer, &OrderedList);
525
526 if (EFI_ERROR (Status)) {
527 return Status;
528 }
529
530 for (Index = 0; Index < OptionCount; Index++) {
531 OrderedListOption.Header.OpCode = FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP;
532 OrderedListOption.Header.Length = sizeof (FRAMEWORK_EFI_IFR_ONE_OF_OPTION);
533
534 //
535 // Add string and get token back
536 //
537 Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken);
538
539 OrderedListOption.Option = StringToken;
540 OrderedListOption.Value = OptionsList[Index].Value;
541 OrderedListOption.Flags = (UINT8) (OptionsList[Index].Flags | FRAMEWORK_EFI_IFR_FLAG_CREATED);
542 OrderedListOption.Key = OptionsList[Index].Key;
543
544 Status = AddOpCode (FormBuffer, &OrderedListOption);
545
546 if (EFI_ERROR (Status)) {
547 return Status;
548 }
549 }
550
551 EndOrderedList.Header.Length = sizeof (FRAMEWORK_EFI_IFR_END_ONE_OF);
552 EndOrderedList.Header.OpCode = FRAMEWORK_EFI_IFR_END_ONE_OF_OP;
553
554 Status = AddOpCode (FormBuffer, &EndOrderedList);
555
556 return Status;
557 }
558
559 /**
560 Create a checkbox.
561
562 @param QuestionId Question ID of the check box
563 @param DataWidth DataWidth of the check box
564 @param Prompt Prompt of the check box
565 @param Help Help of the check box
566 @param Flags Flags of the check box
567 @param FormBuffer The form where this check box adds to
568 @param StringBuffer String buffer created for Prompt and Help.
569
570 @retval EFI_DEVICE_ERROR DataWidth > 1
571 @retval EFI_SUCCESS Check box successfully created
572 **/
573 EFI_STATUS
574 CreateCheckBox (
575 IN UINT16 QuestionId,
576 IN UINT8 DataWidth,
577 IN CHAR16 *Prompt,
578 IN CHAR16 *Help,
579 IN UINT8 Flags,
580 IN OUT VOID *FormBuffer,
581 IN OUT VOID *StringBuffer
582 )
583 {
584 EFI_STATUS Status;
585 FRAMEWORK_EFI_IFR_CHECKBOX CheckBox;
586 CHAR16 CurrentLanguage[4];
587 STRING_REF StringToken;
588
589 //
590 // We do not create op-code storage widths for checkbox in excess of 8 bits for now
591 //
592 if (DataWidth > 1) {
593 return EFI_DEVICE_ERROR;
594 }
595
596 //
597 // Obtain current language value
598 //
599 GetCurrentLanguage (CurrentLanguage);
600
601 //
602 // Add first string, get first string's token
603 //
604 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
605
606 if (EFI_ERROR (Status)) {
607 return Status;
608 }
609
610 CheckBox.Header.OpCode = FRAMEWORK_EFI_IFR_CHECKBOX_OP;
611 CheckBox.Header.Length = sizeof (FRAMEWORK_EFI_IFR_CHECKBOX);
612 CheckBox.QuestionId = QuestionId;
613 CheckBox.Width = DataWidth;
614 CheckBox.Prompt = StringToken;
615
616 //
617 // Add second string, get first string's token
618 //
619 Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
620
621 if (EFI_ERROR (Status)) {
622 return Status;
623 }
624
625 CheckBox.Help = StringToken;
626 CheckBox.Flags = (UINT8) (Flags | FRAMEWORK_EFI_IFR_FLAG_CREATED);
627
628 Status = AddOpCode (FormBuffer, &CheckBox);
629
630 return Status;
631 }
632
633 /**
634 Create a numeric
635
636 @param QuestionId Question ID of the numeric
637 @param DataWidth DataWidth of the numeric
638 @param Prompt Prompt of the numeric
639 @param Help Help of the numeric
640 @param Minimum Minumun boundary of the numeric
641 @param Maximum Maximum boundary of the numeric
642 @param Step Step of the numeric
643 @param Default Default value
644 @param Flags Flags of the numeric
645 @param Key Key of the numeric
646 @param FormBuffer The form where this numeric adds to
647 @param StringBuffer String buffer created for Prompt and Help.
648
649 @retval EFI_DEVICE_ERROR DataWidth > 2
650 @retval EFI_SUCCESS Numeric is successfully created
651 **/
652 EFI_STATUS
653 CreateNumeric (
654 IN UINT16 QuestionId,
655 IN UINT8 DataWidth,
656 IN CHAR16 *Prompt,
657 IN CHAR16 *Help,
658 IN UINT16 Minimum,
659 IN UINT16 Maximum,
660 IN UINT16 Step,
661 IN UINT16 Default,
662 IN UINT8 Flags,
663 IN UINT16 Key,
664 IN OUT VOID *FormBuffer,
665 IN OUT VOID *StringBuffer
666 )
667 {
668 EFI_STATUS Status;
669 FRAMEWORK_EFI_IFR_NUMERIC Numeric;
670 CHAR16 CurrentLanguage[4];
671 STRING_REF StringToken;
672
673 //
674 // We do not create op-code storage widths for numerics in excess of 16 bits for now
675 //
676 if (DataWidth > 2) {
677 return EFI_DEVICE_ERROR;
678 }
679
680 //
681 // Obtain current language value
682 //
683 GetCurrentLanguage (CurrentLanguage);
684
685 //
686 // Add first string, get first string's token
687 //
688 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
689
690 if (EFI_ERROR (Status)) {
691 return Status;
692 }
693
694 Numeric.Header.OpCode = FRAMEWORK_EFI_IFR_NUMERIC_OP;
695 Numeric.Header.Length = sizeof (FRAMEWORK_EFI_IFR_NUMERIC);
696 Numeric.QuestionId = QuestionId;
697 Numeric.Width = DataWidth;
698 Numeric.Prompt = StringToken;
699
700 //
701 // Add second string, get first string's token
702 //
703 Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
704
705 if (EFI_ERROR (Status)) {
706 return Status;
707 }
708
709 Numeric.Help = StringToken;
710 Numeric.Minimum = Minimum;
711 Numeric.Maximum = Maximum;
712 Numeric.Step = Step;
713 Numeric.Default = Default;
714 Numeric.Flags = (UINT8) (Flags | FRAMEWORK_EFI_IFR_FLAG_CREATED);
715 Numeric.Key = Key;
716
717 Status = AddOpCode (FormBuffer, &Numeric);
718
719 return Status;
720 }
721
722 /**
723 Create a string.
724
725 @param QuestionId Question ID of the string
726 @param DataWidth DataWidth of the string
727 @param Prompt Prompt of the string
728 @param Help Help of the string
729 @param MinSize Min size boundary of the string
730 @param MaxSize Max size boundary of the string
731 @param Flags Flags of the string
732 @param Key Key of the string
733 @param FormBuffer The form where this string adds to
734 @param StringBuffer String buffer created for Prompt and Help.
735
736 @retval EFI_SUCCESS String successfully created.
737 **/
738 EFI_STATUS
739 CreateString (
740 IN UINT16 QuestionId,
741 IN UINT8 DataWidth,
742 IN CHAR16 *Prompt,
743 IN CHAR16 *Help,
744 IN UINT8 MinSize,
745 IN UINT8 MaxSize,
746 IN UINT8 Flags,
747 IN UINT16 Key,
748 IN OUT VOID *FormBuffer,
749 IN OUT VOID *StringBuffer
750 )
751 {
752 EFI_STATUS Status;
753 FRAMEWORK_EFI_IFR_STRING String;
754 CHAR16 CurrentLanguage[4];
755 STRING_REF StringToken;
756
757 //
758 // Obtain current language value
759 //
760 GetCurrentLanguage (CurrentLanguage);
761
762 //
763 // Add first string, get first string's token
764 //
765 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
766
767 if (EFI_ERROR (Status)) {
768 return Status;
769 }
770
771 String.Header.OpCode = FRAMEWORK_EFI_IFR_STRING_OP;
772 String.Header.Length = sizeof (FRAMEWORK_EFI_IFR_STRING);
773 String.QuestionId = QuestionId;
774 String.Width = DataWidth;
775 String.Prompt = StringToken;
776
777 //
778 // Add second string, get first string's token
779 //
780 Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
781
782 if (EFI_ERROR (Status)) {
783 return Status;
784 }
785
786 String.Help = StringToken;
787 String.MinSize = MinSize;
788 String.MaxSize = MaxSize;
789 String.Flags = (UINT8) (Flags | FRAMEWORK_EFI_IFR_FLAG_CREATED);
790 String.Key = Key;
791
792 Status = AddOpCode (FormBuffer, &String);
793
794 return Status;
795 }
796