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