Modify ModifyInf task's attributes from "inputfvinffilename" to "inputfvinffile"...
[mirror_edk2.git] / EdkModulePkg / Library / EdkIfrSupportLib / IfrOnTheFly.c
1 /*++
2 Copyright (c) 2006, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
7
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10
11 Module Name:
12 IfrOnTheFly.c
13
14 Abstract:
15
16 Library Routines to create IFR on-the-fly
17
18 Revision History:
19
20 --*/
21
22 EFI_STATUS
23 CreateFormSet (
24 IN CHAR16 *FormSetTitle,
25 IN EFI_GUID *Guid,
26 IN UINT8 Class,
27 IN UINT8 SubClass,
28 IN OUT VOID **FormBuffer,
29 IN OUT VOID **StringBuffer
30 )
31 /*++
32
33 Routine Description:
34
35 Create a formset
36
37 Arguments:
38
39 FormSetTitle - Title of formset
40
41 Guid - Guid of formset
42
43 Class - Class of formset
44
45 SubClass - Sub class of formset
46
47 FormBuffer - Pointer of the formset created
48
49 StringBuffer - Pointer of FormSetTitile string created
50
51 Returns:
52
53 EFI_OUT_OF_RESOURCES - No enough buffer to allocate
54
55 EFI_SUCCESS - Formset successfully created
56
57 --*/
58 {
59 EFI_STATUS Status;
60 EFI_HII_IFR_PACK IfrPack;
61 EFI_IFR_FORM_SET FormSet;
62 EFI_IFR_END_FORM_SET EndFormSet;
63 UINT8 *Destination;
64 CHAR16 CurrentLanguage[4];
65 STRING_REF StringToken;
66
67 //
68 // Pre-allocate a buffer sufficient for us to work from.
69 //
70 FormBuffer = AllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE);
71 if (FormBuffer == NULL) {
72 return EFI_OUT_OF_RESOURCES;
73 }
74
75 //
76 // Pre-allocate a buffer sufficient for us to work from.
77 //
78 StringBuffer = AllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE);
79 if (StringBuffer == NULL) {
80 gBS->FreePool (FormBuffer);
81 return EFI_OUT_OF_RESOURCES;
82 }
83
84 //
85 // Obtain current language value
86 //
87 GetCurrentLanguage (CurrentLanguage);
88
89 //
90 // Add the FormSetTitle to the string buffer and get the StringToken
91 //
92 Status = AddString (*StringBuffer, CurrentLanguage, FormSetTitle, &StringToken);
93
94 if (EFI_ERROR (Status)) {
95 return Status;
96 }
97
98 //
99 // Initialize the Ifr Package header data
100 //
101 IfrPack.Header.Length = sizeof (EFI_HII_PACK_HEADER) + sizeof (EFI_IFR_FORM_SET) + sizeof (EFI_IFR_END_FORM_SET);
102 IfrPack.Header.Type = EFI_HII_IFR;
103
104 //
105 // Initialize FormSet with the appropriate information
106 //
107 FormSet.Header.OpCode = EFI_IFR_FORM_SET_OP;
108 FormSet.Header.Length = sizeof (EFI_IFR_FORM_SET);
109 FormSet.FormSetTitle = StringToken;
110 FormSet.Class = Class;
111 FormSet.SubClass = SubClass;
112 CopyMem (&FormSet.Guid, Guid, sizeof (EFI_GUID));
113
114 //
115 // Initialize the end formset data
116 //
117 EndFormSet.Header.Length = sizeof (EFI_IFR_END_FORM_SET);
118 EndFormSet.Header.OpCode = EFI_IFR_END_FORM_SET_OP;
119
120 Destination = (UINT8 *) *FormBuffer;
121
122 //
123 // Copy the formset/endformset data to the form buffer
124 //
125 CopyMem (Destination, &IfrPack, sizeof (EFI_HII_PACK_HEADER));
126
127 Destination = Destination + sizeof (EFI_HII_PACK_HEADER);
128
129 CopyMem (Destination, &FormSet, sizeof (EFI_IFR_FORM_SET));
130
131 Destination = Destination + sizeof (EFI_IFR_FORM_SET);
132
133 CopyMem (Destination, &EndFormSet, sizeof (EFI_IFR_END_FORM_SET));
134 return EFI_SUCCESS;
135 }
136
137
138 EFI_STATUS
139 CreateForm (
140 IN CHAR16 *FormTitle,
141 IN UINT16 FormId,
142 IN OUT VOID *FormBuffer,
143 IN OUT VOID *StringBuffer
144 )
145 /*++
146
147 Routine Description:
148
149 Create a form
150
151 Arguments:
152
153 FormTitle - Title of the form
154
155 FormId - Id of the form
156
157 FormBuffer - Pointer of the form created
158
159 StringBuffer - Pointer of FormTitil string created
160
161 Returns:
162
163 EFI_SUCCESS - Form successfully created
164
165 --*/
166 {
167 EFI_STATUS Status;
168 EFI_IFR_FORM Form;
169 EFI_IFR_END_FORM EndForm;
170 CHAR16 CurrentLanguage[4];
171 STRING_REF StringToken;
172
173 //
174 // Obtain current language value
175 //
176 GetCurrentLanguage (CurrentLanguage);
177
178 Status = AddString (StringBuffer, CurrentLanguage, FormTitle, &StringToken);
179
180 if (EFI_ERROR (Status)) {
181 return Status;
182 }
183
184 Form.Header.OpCode = EFI_IFR_FORM_OP;
185 Form.Header.Length = sizeof (EFI_IFR_FORM);
186 Form.FormId = FormId;
187 Form.FormTitle = StringToken;
188
189 Status = AddOpCode (FormBuffer, &Form);
190
191 if (EFI_ERROR (Status)) {
192 return Status;
193 }
194
195 EndForm.Header.OpCode = EFI_IFR_END_FORM_OP;
196 EndForm.Header.Length = sizeof (EFI_IFR_END_FORM);
197
198 Status = AddOpCode (FormBuffer, &EndForm);
199
200 if (EFI_ERROR (Status)) {
201 return Status;
202 }
203
204 return EFI_SUCCESS;
205 }
206
207
208 EFI_STATUS
209 CreateSubTitle (
210 IN CHAR16 *SubTitle,
211 IN OUT VOID *FormBuffer,
212 IN OUT VOID *StringBuffer
213 )
214 /*++
215
216 Routine Description:
217
218 Create a SubTitle
219
220 Arguments:
221
222 SubTitle - Sub title to be created
223
224 FormBuffer - Where this subtitle to add to
225
226 StringBuffer - String buffer created for subtitle
227
228 Returns:
229
230 EFI_SUCCESS - Subtitle successfully created
231
232 --*/
233 {
234 EFI_STATUS Status;
235 EFI_IFR_SUBTITLE Subtitle;
236 CHAR16 CurrentLanguage[4];
237 STRING_REF StringToken;
238
239 //
240 // Obtain current language value
241 //
242 GetCurrentLanguage (CurrentLanguage);
243
244 Status = AddString (StringBuffer, CurrentLanguage, SubTitle, &StringToken);
245
246 if (EFI_ERROR (Status)) {
247 return Status;
248 }
249
250 Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP;
251 Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE);
252 Subtitle.SubTitle = StringToken;
253
254 Status = AddOpCode (FormBuffer, &Subtitle);
255
256 if (EFI_ERROR (Status)) {
257 return Status;
258 }
259
260 return EFI_SUCCESS;
261 }
262
263
264 EFI_STATUS
265 CreateText (
266 IN CHAR16 *String,
267 IN CHAR16 *String2,
268 IN CHAR16 *String3,
269 IN UINT8 Flags,
270 IN UINT16 Key,
271 IN OUT VOID *FormBuffer,
272 IN OUT VOID *StringBuffer
273 )
274 /*++
275
276 Routine Description:
277
278 Create a line of text
279
280 Arguments:
281
282 String - First string of the text
283
284 String2 - Second string of the text
285
286 String3 - Help string of the text
287
288 Flags - Flag of the text
289
290 Key - Key of the text
291
292 FormBuffer - The form where this text adds to
293
294 StringBuffer - String buffer created for String, String2 and String3
295
296 Returns:
297
298 EFI_SUCCESS - Text successfully created
299
300 --*/
301 {
302 EFI_STATUS Status;
303 EFI_IFR_TEXT Text;
304 CHAR16 CurrentLanguage[4];
305 STRING_REF StringToken;
306
307 //
308 // Obtain current language value
309 //
310 GetCurrentLanguage (CurrentLanguage);
311
312 //
313 // Add first string, get first string's token
314 //
315 Status = AddString (StringBuffer, CurrentLanguage, String, &StringToken);
316
317 if (EFI_ERROR (Status)) {
318 return Status;
319 }
320
321 Text.Header.OpCode = EFI_IFR_TEXT_OP;
322 Text.Header.Length = sizeof (EFI_IFR_TEXT);
323 Text.Text = StringToken;
324
325 //
326 // Add second string, get first string's token
327 //
328 Status = AddString (StringBuffer, CurrentLanguage, String2, &StringToken);
329
330 if (EFI_ERROR (Status)) {
331 return Status;
332 }
333
334 Text.TextTwo = StringToken;
335
336 Text.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
337 Text.Key = Key;
338
339 //
340 // Add second string, get first string's token
341 //
342 Status = AddString (StringBuffer, CurrentLanguage, String3, &StringToken);
343
344 if (EFI_ERROR (Status)) {
345 return Status;
346 }
347
348 Text.Help = StringToken;
349
350 Status = AddOpCode (FormBuffer, &Text);
351
352 if (EFI_ERROR (Status)) {
353 return Status;
354 }
355
356 return EFI_SUCCESS;
357 }
358
359
360 EFI_STATUS
361 CreateGoto (
362 IN UINT16 FormId,
363 IN CHAR16 *Prompt,
364 IN OUT VOID *FormBuffer,
365 IN OUT VOID *StringBuffer
366 )
367 /*++
368
369 Routine Description:
370
371 Create a hyperlink
372
373 Arguments:
374
375 FormId - Form ID of the hyperlink
376
377 Prompt - Prompt of the hyperlink
378
379 FormBuffer - The form where this hyperlink adds to
380
381 StringBuffer - String buffer created for Prompt
382
383 Returns:
384
385 EFI_SUCCESS - Hyperlink successfully created
386
387 --*/
388 {
389 EFI_STATUS Status;
390 EFI_IFR_REF Hyperlink;
391 CHAR16 CurrentLanguage[4];
392 STRING_REF StringToken;
393
394 //
395 // Obtain current language value
396 //
397 GetCurrentLanguage (CurrentLanguage);
398
399 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
400
401 if (EFI_ERROR (Status)) {
402 return Status;
403 }
404
405 Hyperlink.Header.OpCode = EFI_IFR_REF_OP;
406 Hyperlink.Header.Length = sizeof (EFI_IFR_REF);
407 Hyperlink.FormId = FormId;
408 Hyperlink.Prompt = StringToken;
409
410 Status = AddOpCode (FormBuffer, &Hyperlink);
411
412 if (EFI_ERROR (Status)) {
413 return Status;
414 }
415
416 return EFI_SUCCESS;
417 }
418
419
420 EFI_STATUS
421 CreateOneOf (
422 IN UINT16 QuestionId,
423 IN UINT8 DataWidth,
424 IN CHAR16 *Prompt,
425 IN CHAR16 *Help,
426 IN IFR_OPTION *OptionsList,
427 IN UINTN OptionCount,
428 IN OUT VOID *FormBuffer,
429 IN OUT VOID *StringBuffer
430 )
431 /*++
432
433 Routine Description:
434
435 Create a one-of question with a set of options to choose from. The
436 OptionsList is a pointer to a null-terminated list of option descriptions.
437
438 Arguments:
439
440 QuestionId - Question ID of the one-of box
441
442 DataWidth - DataWidth of the one-of box
443
444 Prompt - Prompt of the one-of box
445
446 Help - Help of the one-of box
447
448 OptionsList - Each string in it is an option of the one-of box
449
450 OptionCount - Option string count
451
452 FormBuffer - The form where this one-of box adds to
453
454 StringBuffer - String buffer created for Prompt, Help and Option strings
455
456 Returns:
457
458 EFI_DEVICE_ERROR - DataWidth > 2
459
460 EFI_SUCCESS - One-Of box successfully created.
461
462 --*/
463 {
464 EFI_STATUS Status;
465 UINTN Index;
466 EFI_IFR_ONE_OF OneOf;
467 EFI_IFR_ONE_OF_OPTION OneOfOption;
468 EFI_IFR_END_ONE_OF EndOneOf;
469 CHAR16 CurrentLanguage[4];
470 STRING_REF StringToken;
471
472 //
473 // We do not create op-code storage widths for one-of in excess of 16 bits for now
474 //
475 if (DataWidth > 2) {
476 return EFI_DEVICE_ERROR;
477 }
478
479 //
480 // Obtain current language value
481 //
482 GetCurrentLanguage (CurrentLanguage);
483
484 //
485 // Add first string, get first string's token
486 //
487 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
488
489 if (EFI_ERROR (Status)) {
490 return Status;
491 }
492
493 OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;
494 OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);
495 OneOf.QuestionId = QuestionId;
496 OneOf.Width = DataWidth;
497 OneOf.Prompt = StringToken;
498
499 //
500 // Add second string, get first string's token
501 //
502 Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
503
504 if (EFI_ERROR (Status)) {
505 return Status;
506 }
507
508 OneOf.Help = StringToken;
509
510 Status = AddOpCode (FormBuffer, &OneOf);
511
512 if (EFI_ERROR (Status)) {
513 return Status;
514 }
515
516 for (Index = 0; Index < OptionCount; Index++) {
517 OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
518 OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
519
520 //
521 // Add string and get token back
522 //
523 Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken);
524
525 OneOfOption.Option = StringToken;
526 OneOfOption.Value = OptionsList[Index].Value;
527 OneOfOption.Flags = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED);
528 OneOfOption.Key = OptionsList[Index].Key;
529
530 Status = AddOpCode (FormBuffer, &OneOfOption);
531
532 if (EFI_ERROR (Status)) {
533 return Status;
534 }
535 }
536
537 EndOneOf.Header.Length = sizeof (EFI_IFR_END_ONE_OF);
538 EndOneOf.Header.OpCode = EFI_IFR_END_ONE_OF_OP;
539
540 Status = AddOpCode (FormBuffer, &EndOneOf);
541
542 if (EFI_ERROR (Status)) {
543 return Status;
544 }
545
546 return EFI_SUCCESS;
547 }
548
549 EFI_STATUS
550 CreateOrderedList (
551 IN UINT16 QuestionId,
552 IN UINT8 MaxEntries,
553 IN CHAR16 *Prompt,
554 IN CHAR16 *Help,
555 IN IFR_OPTION *OptionsList,
556 IN UINTN OptionCount,
557 IN OUT VOID *FormBuffer,
558 IN OUT VOID *StringBuffer
559 )
560 /*++
561
562 Routine Description:
563
564 Create a one-of question with a set of options to choose from. The
565 OptionsList is a pointer to a null-terminated list of option descriptions.
566
567 Arguments:
568
569 QuestionId - Question ID of the ordered list
570
571 MaxEntries - MaxEntries of the ordered list
572
573 Prompt - Prompt of the ordered list
574
575 Help - Help of the ordered list
576
577 OptionsList - Each string in it is an option of the ordered list
578
579 OptionCount - Option string count
580
581 FormBuffer - The form where this ordered list adds to
582
583 StringBuffer - String buffer created for Prompt, Help and Option strings
584
585 Returns:
586
587 EFI_SUCCESS - Ordered list successfully created.
588
589 --*/
590 {
591 EFI_STATUS Status;
592 UINTN Index;
593 EFI_IFR_ORDERED_LIST OrderedList;
594 EFI_IFR_ONE_OF_OPTION OrderedListOption;
595 EFI_IFR_END_ONE_OF EndOrderedList;
596 CHAR16 CurrentLanguage[4];
597 STRING_REF StringToken;
598
599 //
600 // Obtain current language value
601 //
602 GetCurrentLanguage (CurrentLanguage);
603
604 //
605 // Add first string, get first string's token
606 //
607 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
608
609 if (EFI_ERROR (Status)) {
610 return Status;
611 }
612
613 OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;
614 OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);
615 OrderedList.QuestionId = QuestionId;
616 OrderedList.MaxEntries = MaxEntries;
617 OrderedList.Prompt = StringToken;
618
619 //
620 // Add second string, get first string's token
621 //
622 Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
623
624 if (EFI_ERROR (Status)) {
625 return Status;
626 }
627
628 OrderedList.Help = StringToken;
629
630 Status = AddOpCode (FormBuffer, &OrderedList);
631
632 if (EFI_ERROR (Status)) {
633 return Status;
634 }
635
636 for (Index = 0; Index < OptionCount; Index++) {
637 OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
638 OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
639
640 //
641 // Add string and get token back
642 //
643 Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken);
644
645 OrderedListOption.Option = StringToken;
646 OrderedListOption.Value = OptionsList[Index].Value;
647 OrderedListOption.Flags = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED);
648 OrderedListOption.Key = OptionsList[Index].Key;
649
650 Status = AddOpCode (FormBuffer, &OrderedListOption);
651
652 if (EFI_ERROR (Status)) {
653 return Status;
654 }
655 }
656
657 EndOrderedList.Header.Length = sizeof (EFI_IFR_END_ONE_OF);
658 EndOrderedList.Header.OpCode = EFI_IFR_END_ONE_OF_OP;
659
660 Status = AddOpCode (FormBuffer, &EndOrderedList);
661
662 if (EFI_ERROR (Status)) {
663 return Status;
664 }
665
666 return EFI_SUCCESS;
667 }
668
669
670 EFI_STATUS
671 CreateCheckBox (
672 IN UINT16 QuestionId,
673 IN UINT8 DataWidth,
674 IN CHAR16 *Prompt,
675 IN CHAR16 *Help,
676 IN UINT8 Flags,
677 IN OUT VOID *FormBuffer,
678 IN OUT VOID *StringBuffer
679 )
680 /*++
681
682 Routine Description:
683
684 Create a checkbox
685
686 Arguments:
687
688 QuestionId - Question ID of the check box
689
690 DataWidth - DataWidth of the check box
691
692 Prompt - Prompt of the check box
693
694 Help - Help of the check box
695
696 Flags - Flags of the check box
697
698 FormBuffer - The form where this check box adds to
699
700 StringBuffer - String buffer created for Prompt and Help.
701
702 Returns:
703
704 EFI_DEVICE_ERROR - DataWidth > 1
705
706 EFI_SUCCESS - Check box successfully created
707
708 --*/
709 {
710 EFI_STATUS Status;
711 EFI_IFR_CHECKBOX CheckBox;
712 CHAR16 CurrentLanguage[4];
713 STRING_REF StringToken;
714
715 //
716 // We do not create op-code storage widths for checkbox in excess of 8 bits for now
717 //
718 if (DataWidth > 1) {
719 return EFI_DEVICE_ERROR;
720 }
721
722 //
723 // Obtain current language value
724 //
725 GetCurrentLanguage (CurrentLanguage);
726
727 //
728 // Add first string, get first string's token
729 //
730 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
731
732 if (EFI_ERROR (Status)) {
733 return Status;
734 }
735
736 CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP;
737 CheckBox.Header.Length = sizeof (EFI_IFR_CHECKBOX);
738 CheckBox.QuestionId = QuestionId;
739 CheckBox.Width = DataWidth;
740 CheckBox.Prompt = StringToken;
741
742 //
743 // Add second string, get first string's token
744 //
745 Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
746
747 if (EFI_ERROR (Status)) {
748 return Status;
749 }
750
751 CheckBox.Help = StringToken;
752 CheckBox.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
753
754 Status = AddOpCode (FormBuffer, &CheckBox);
755
756 if (EFI_ERROR (Status)) {
757 return Status;
758 }
759
760 return EFI_SUCCESS;
761 }
762
763
764 EFI_STATUS
765 CreateNumeric (
766 IN UINT16 QuestionId,
767 IN UINT8 DataWidth,
768 IN CHAR16 *Prompt,
769 IN CHAR16 *Help,
770 IN UINT16 Minimum,
771 IN UINT16 Maximum,
772 IN UINT16 Step,
773 IN UINT16 Default,
774 IN UINT8 Flags,
775 IN UINT16 Key,
776 IN OUT VOID *FormBuffer,
777 IN OUT VOID *StringBuffer
778 )
779 /*++
780
781 Routine Description:
782
783 Create a numeric
784
785 Arguments:
786
787 QuestionId - Question ID of the numeric
788
789 DataWidth - DataWidth of the numeric
790
791 Prompt - Prompt of the numeric
792
793 Help - Help of the numeric
794
795 Minimum - Minumun boundary of the numeric
796
797 Maximum - Maximum boundary of the numeric
798
799 Step - Step of the numeric
800
801 Default - Default value
802
803 Flags - Flags of the numeric
804
805 Key - Key of the numeric
806
807 FormBuffer - The form where this numeric adds to
808
809 StringBuffer - String buffer created for Prompt and Help.
810
811 Returns:
812
813 EFI_DEVICE_ERROR - DataWidth > 2
814
815 EFI_SUCCESS - Numeric is successfully created
816
817 --*/
818 {
819 EFI_STATUS Status;
820 EFI_IFR_NUMERIC Numeric;
821 CHAR16 CurrentLanguage[4];
822 STRING_REF StringToken;
823
824 //
825 // We do not create op-code storage widths for numerics in excess of 16 bits for now
826 //
827 if (DataWidth > 2) {
828 return EFI_DEVICE_ERROR;
829 }
830
831 //
832 // Obtain current language value
833 //
834 GetCurrentLanguage (CurrentLanguage);
835
836 //
837 // Add first string, get first string's token
838 //
839 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
840
841 if (EFI_ERROR (Status)) {
842 return Status;
843 }
844
845 Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;
846 Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);
847 Numeric.QuestionId = QuestionId;
848 Numeric.Width = DataWidth;
849 Numeric.Prompt = StringToken;
850
851 //
852 // Add second string, get first string's token
853 //
854 Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
855
856 if (EFI_ERROR (Status)) {
857 return Status;
858 }
859
860 Numeric.Help = StringToken;
861 Numeric.Minimum = Minimum;
862 Numeric.Maximum = Maximum;
863 Numeric.Step = Step;
864 Numeric.Default = Default;
865 Numeric.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
866 Numeric.Key = Key;
867
868 Status = AddOpCode (FormBuffer, &Numeric);
869
870 if (EFI_ERROR (Status)) {
871 return Status;
872 }
873
874 return EFI_SUCCESS;
875 }
876
877
878 EFI_STATUS
879 CreateString (
880 IN UINT16 QuestionId,
881 IN UINT8 DataWidth,
882 IN CHAR16 *Prompt,
883 IN CHAR16 *Help,
884 IN UINT8 MinSize,
885 IN UINT8 MaxSize,
886 IN UINT8 Flags,
887 IN UINT16 Key,
888 IN OUT VOID *FormBuffer,
889 IN OUT VOID *StringBuffer
890 )
891 /*++
892
893 Routine Description:
894
895 Create a string
896
897 Arguments:
898
899 QuestionId - Question ID of the string
900
901 DataWidth - DataWidth of the string
902
903 Prompt - Prompt of the string
904
905 Help - Help of the string
906
907 MinSize - Min size boundary of the string
908
909 MaxSize - Max size boundary of the string
910
911 Flags - Flags of the string
912
913 Key - Key of the string
914
915 FormBuffer - The form where this string adds to
916
917 StringBuffer - String buffer created for Prompt and Help.
918
919 Returns:
920
921 EFI_SUCCESS - String successfully created.
922
923 --*/
924 {
925 EFI_STATUS Status;
926 EFI_IFR_STRING String;
927 CHAR16 CurrentLanguage[4];
928 STRING_REF StringToken;
929
930 //
931 // Obtain current language value
932 //
933 GetCurrentLanguage (CurrentLanguage);
934
935 //
936 // Add first string, get first string's token
937 //
938 Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
939
940 if (EFI_ERROR (Status)) {
941 return Status;
942 }
943
944 String.Header.OpCode = EFI_IFR_STRING_OP;
945 String.Header.Length = sizeof (EFI_IFR_STRING);
946 String.QuestionId = QuestionId;
947 String.Width = DataWidth;
948 String.Prompt = StringToken;
949
950 //
951 // Add second string, get first string's token
952 //
953 Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
954
955 if (EFI_ERROR (Status)) {
956 return Status;
957 }
958
959 String.Help = StringToken;
960 String.MinSize = MinSize;
961 String.MaxSize = MaxSize;
962 String.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
963 String.Key = Key;
964
965 Status = AddOpCode (FormBuffer, &String);
966
967 if (EFI_ERROR (Status)) {
968 return Status;
969 }
970
971 return EFI_SUCCESS;
972 }