TianoCore EDK2 master
Loading...
Searching...
No Matches
RedfishPlatformConfigImpl.c
Go to the documentation of this file.
1
13
14extern REDFISH_PLATFORM_CONFIG_PRIVATE *mRedfishPlatformConfigPrivate;
15
28 IN EFI_HII_HANDLE HiiHandle,
29 IN EFI_STRING_ID StringId
30 )
31{
32 EFI_STRING String;
33
34 if ((HiiHandle == NULL) || (StringId == 0)) {
36 return EFI_INVALID_PARAMETER;
37 }
38
39 String = HiiGetString (HiiHandle, StringId, NULL);
40 if (String == NULL) {
41 return EFI_NOT_FOUND;
42 }
43
44 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%s", String));
45 FreePool (String);
46
47 return EFI_SUCCESS;
48}
49
62 )
63{
64 LIST_ENTRY *HiiFormLink;
65 LIST_ENTRY *HiiNextFormLink;
67 LIST_ENTRY *HiiStatementLink;
68 LIST_ENTRY *HiiNextStatementLink;
70 UINTN Index;
71
72 if (FormsetPrivate == NULL) {
73 return EFI_INVALID_PARAMETER;
74 }
75
76 Index = 0;
77 HiiFormLink = GetFirstNode (&FormsetPrivate->HiiFormList);
78 while (!IsNull (&FormsetPrivate->HiiFormList, HiiFormLink)) {
79 HiiFormPrivate = REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLink);
80 HiiNextFormLink = GetNextNode (&FormsetPrivate->HiiFormList, HiiFormLink);
81
82 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " [%d] form: %d title: ", ++Index, HiiFormPrivate->Id));
83 DumpHiiString (FormsetPrivate->HiiHandle, HiiFormPrivate->Title);
85
86 HiiStatementLink = GetFirstNode (&HiiFormPrivate->StatementList);
87 while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) {
88 HiiStatementPrivate = REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK (HiiStatementLink);
89 HiiNextStatementLink = GetNextNode (&HiiFormPrivate->StatementList, HiiStatementLink);
90
91 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " QID: 0x%x Prompt: ", HiiStatementPrivate->QuestionId));
92 DumpHiiString (FormsetPrivate->HiiHandle, HiiStatementPrivate->Description);
94
95 HiiStatementLink = HiiNextStatementLink;
96 }
97
98 HiiFormLink = HiiNextFormLink;
99 }
100
101 return EFI_SUCCESS;
102}
103
115 IN LIST_ENTRY *FormsetList
116 )
117{
118 LIST_ENTRY *HiiFormsetLink;
119 LIST_ENTRY *HiiFormsetNextLink;
121 UINTN Index;
122
123 if (FormsetList == NULL) {
124 return EFI_INVALID_PARAMETER;
125 }
126
127 if (IsListEmpty (FormsetList)) {
128 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: Empty formset list\n", __func__));
129 return EFI_SUCCESS;
130 }
131
132 Index = 0;
133 HiiFormsetLink = GetFirstNode (FormsetList);
134 while (!IsNull (FormsetList, HiiFormsetLink)) {
135 HiiFormsetNextLink = GetNextNode (FormsetList, HiiFormsetLink);
136 HiiFormsetPrivate = REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFormsetLink);
137
138 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "[%d] HII Handle: 0x%x formset: %g at %s\n", ++Index, HiiFormsetPrivate->HiiHandle, &HiiFormsetPrivate->Guid, HiiFormsetPrivate->DevicePathStr));
139 DumpFormset (HiiFormsetPrivate);
140
141 HiiFormsetLink = HiiFormsetNextLink;
142 }
143
144 return EFI_SUCCESS;
145}
146
158UINTN
159EFIAPI
161 IN CONST CHAR16 *String
162 )
163{
164 UINTN Length;
165
166 ASSERT (String != NULL);
167
168 for (Length = 0; *String != L'\0'; String++, Length++) {
169 }
170
171 return Length;
172}
173
185UINTN
186EFIAPI
188 IN CONST CHAR16 *String
189 )
190{
191 return (HiiStrLen (String) + 1) * sizeof (*String);
192}
193
208INTN
209EFIAPI
211 IN CONST CHAR16 *FirstString,
212 IN CONST CHAR16 *SecondString
213 )
214{
215 //
216 // ASSERT both strings are less long than PcdMaximumUnicodeStringLength
217 //
218 ASSERT (HiiStrSize (FirstString) != 0);
219 ASSERT (HiiStrSize (SecondString) != 0);
220
221 while ((*FirstString != L'\0') && (*FirstString == *SecondString)) {
222 FirstString++;
223 SecondString++;
224 }
225
226 return *FirstString - *SecondString;
227}
228
241 IN EFI_STRING_ID StringId,
242 IN EFI_HII_HANDLE HiiHandle
243 )
244{
245 CHAR16 NullChar;
246
247 if (StringId == 0x00) {
248 return EFI_INVALID_PARAMETER;
249 }
250
251 NullChar = CHAR_NULL;
252 HiiSetString (HiiHandle, StringId, &NullChar, NULL);
253
254 return EFI_SUCCESS;
255}
256
274EFI_STRING
276 IN EFI_HII_HANDLE HiiHandle,
277 IN CHAR8 *Language,
278 IN EFI_STRING_ID StringId
279 )
280{
281 EFI_STATUS Status;
282 UINTN StringSize;
283 CHAR16 TempString;
284 EFI_STRING String;
285
286 if ((mRedfishPlatformConfigPrivate->HiiString == NULL) || (HiiHandle == NULL) || (StringId == 0) || IS_EMPTY_STRING (Language)) {
287 ASSERT (FALSE);
288 return NULL;
289 }
290
291 //
292 // Retrieve the size of the string in the string package for the BestLanguage
293 //
294 StringSize = 0;
295 Status = mRedfishPlatformConfigPrivate->HiiString->GetString (
296 mRedfishPlatformConfigPrivate->HiiString,
297 Language,
298 HiiHandle,
299 StringId,
300 &TempString,
301 &StringSize,
302 NULL
303 );
304 //
305 // If GetString() returns EFI_SUCCESS for a zero size,
306 // then there are no supported languages registered for HiiHandle. If GetString()
307 // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present
308 // in the HII Database
309 //
310 if (Status != EFI_BUFFER_TOO_SMALL) {
311 return NULL;
312 }
313
314 //
315 // Allocate a buffer for the return string
316 //
317 String = AllocateZeroPool (StringSize);
318 if (String == NULL) {
319 return NULL;
320 }
321
322 //
323 // Retrieve the string from the string package
324 //
325 Status = mRedfishPlatformConfigPrivate->HiiString->GetString (
326 mRedfishPlatformConfigPrivate->HiiString,
327 Language,
328 HiiHandle,
329 StringId,
330 String,
331 &StringSize,
332 NULL
333 );
334 if (EFI_ERROR (Status)) {
335 //
336 // Free the buffer and return NULL if the supported languages can not be retrieved.
337 //
338 FreePool (String);
339 String = NULL;
340 }
341
342 //
343 // Return the Null-terminated Unicode string
344 //
345 return String;
346}
347
365CHAR8 *
367 IN EFI_HII_HANDLE HiiHandle,
368 IN CHAR8 *Language,
369 IN EFI_STRING_ID StringId
370 )
371{
372 EFI_STRING HiiString;
373 CHAR8 *AsciiString;
374
375 HiiString = HiiGetRedfishString (HiiHandle, Language, StringId);
376 if (HiiString == NULL) {
377 DEBUG ((DEBUG_ERROR, "%a: Can not find string ID: 0x%x with %a\n", __func__, StringId, Language));
378 return NULL;
379 }
380
381 AsciiString = StrToAsciiStr (HiiString);
382 FreePool (HiiString);
383
384 return AsciiString;
385}
386
400CHAR8 *
402 IN EFI_HII_HANDLE HiiHandle,
403 IN EFI_STRING_ID StringId
404 )
405{
406 EFI_STRING HiiString;
407 CHAR8 *AsciiString;
408
409 HiiString = HiiGetRedfishString (HiiHandle, ENGLISH_LANGUAGE_CODE, StringId);
410 if (HiiString == NULL) {
411 DEBUG ((DEBUG_ERROR, "%a: Can not find string ID: 0x%x with %a\n", __func__, StringId, ENGLISH_LANGUAGE_CODE));
412 return NULL;
413 }
414
415 AsciiString = StrToAsciiStr (HiiString);
416 FreePool (HiiString);
417
418 return AsciiString;
419}
420
430BOOLEAN
432 IN REDFISH_PLATFORM_CONFIG_SCHEMA *SupportedSchema,
433 IN CHAR8 *Schema
434 )
435{
436 UINTN Index;
437
438 if ((SupportedSchema == NULL) || IS_EMPTY_STRING (Schema)) {
439 return FALSE;
440 }
441
442 if (SupportedSchema->Count == 0) {
443 return FALSE;
444 }
445
446 for (Index = 0; Index < SupportedSchema->Count; Index++) {
447 if (AsciiStrCmp (SupportedSchema->SchemaList[Index], Schema) == 0) {
448 return TRUE;
449 }
450 }
451
452 return FALSE;
453}
454
469 IN EFI_HII_HANDLE HiiHandle,
470 OUT REDFISH_PLATFORM_CONFIG_SCHEMA *SupportedSchema
471 )
472{
473 CHAR8 *SupportedLanguages;
474 UINTN Index;
475 UINTN LangIndex;
476 UINTN Count;
478 UINTN ListIndex;
479
480 if ((HiiHandle == NULL) || (SupportedSchema == NULL)) {
481 return EFI_INVALID_PARAMETER;
482 }
483
484 SupportedSchema->Count = 0;
485
486 SupportedLanguages = HiiGetSupportedLanguages (HiiHandle);
487 if (SupportedLanguages == NULL) {
488 return EFI_NOT_FOUND;
489 }
490
491 Index = 0;
492 LangIndex = 0;
493 Count = 0;
494 while (TRUE) {
495 if ((SupportedLanguages[Index] == ';') || (SupportedLanguages[Index] == '\0')) {
496 if (AsciiStrnCmp (&SupportedLanguages[LangIndex], X_UEFI_SCHEMA_PREFIX, AsciiStrLen (X_UEFI_SCHEMA_PREFIX)) == 0) {
497 ++Count;
498 }
499
500 LangIndex = Index + 1;
501 }
502
503 if (SupportedLanguages[Index] == '\0') {
504 break;
505 }
506
507 ++Index;
508 }
509
510 if (Count == 0) {
511 return EFI_NOT_FOUND;
512 }
513
514 SupportedSchema->Count = Count;
515 SupportedSchema->SchemaList = AllocatePool (sizeof (CHAR8 *) * Count);
516 if (SupportedSchema->SchemaList == NULL) {
517 return EFI_OUT_OF_RESOURCES;
518 }
519
520 Index = 0;
521 LangIndex = 0;
522 ListIndex = 0;
523 while (TRUE) {
524 if ((SupportedLanguages[Index] == ';') || (SupportedLanguages[Index] == '\0')) {
525 if (AsciiStrnCmp (&SupportedLanguages[LangIndex], X_UEFI_SCHEMA_PREFIX, AsciiStrLen (X_UEFI_SCHEMA_PREFIX)) == 0) {
526 StrSize = Index - LangIndex;
527 SupportedSchema->SchemaList[ListIndex] = AllocateCopyPool ((StrSize + 1), &SupportedLanguages[LangIndex]);
528 SupportedSchema->SchemaList[ListIndex][StrSize] = '\0';
529 ++ListIndex;
530 }
531
532 LangIndex = Index + 1;
533 }
534
535 if (SupportedLanguages[Index] == '\0') {
536 break;
537 }
538
539 ++Index;
540 }
541
542 return EFI_SUCCESS;
543}
544
564 IN EFI_REGULAR_EXPRESSION_PROTOCOL *RegularExpressionProtocol,
565 IN LIST_ENTRY *FormsetList,
566 IN CHAR8 *Schema,
567 IN EFI_STRING Pattern,
569 )
570{
571 LIST_ENTRY *HiiFormsetLink;
572 LIST_ENTRY *HiiFormsetNextLink;
574 LIST_ENTRY *HiiFormLink;
575 LIST_ENTRY *HiiNextFormLink;
577 LIST_ENTRY *HiiStatementLink;
578 LIST_ENTRY *HiiNextStatementLink;
580 EFI_STRING TmpString;
581 UINTN CaptureCount;
582 BOOLEAN IsMatch;
583 EFI_STATUS Status;
585
586 if ((FormsetList == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (Pattern) || (StatementList == NULL)) {
587 return EFI_INVALID_PARAMETER;
588 }
589
590 if (RegularExpressionProtocol == NULL) {
591 return EFI_NOT_READY;
592 }
593
594 StatementList->Count = 0;
595 InitializeListHead (&StatementList->StatementList);
596
597 if (IsListEmpty (FormsetList)) {
598 return EFI_NOT_FOUND;
599 }
600
601 HiiFormsetLink = GetFirstNode (FormsetList);
602 while (!IsNull (FormsetList, HiiFormsetLink)) {
603 HiiFormsetNextLink = GetNextNode (FormsetList, HiiFormsetLink);
604 HiiFormsetPrivate = REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFormsetLink);
605
606 //
607 // Performance check.
608 // If there is no desired Redfish schema found, skip this formset.
609 //
610 if (!CheckSupportedSchema (&HiiFormsetPrivate->SupportedSchema, Schema)) {
611 HiiFormsetLink = HiiFormsetNextLink;
612 continue;
613 }
614
615 HiiFormLink = GetFirstNode (&HiiFormsetPrivate->HiiFormList);
616 while (!IsNull (&HiiFormsetPrivate->HiiFormList, HiiFormLink)) {
617 HiiNextFormLink = GetNextNode (&HiiFormsetPrivate->HiiFormList, HiiFormLink);
618 HiiFormPrivate = REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLink);
619
620 HiiStatementLink = GetFirstNode (&HiiFormPrivate->StatementList);
621 while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) {
622 HiiNextStatementLink = GetNextNode (&HiiFormPrivate->StatementList, HiiStatementLink);
623 HiiStatementPrivate = REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK (HiiStatementLink);
624
625 if ((HiiStatementPrivate->Description != 0) &&
626 (RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_ALLOW_SUPPRESSED) || !HiiStatementPrivate->Suppressed))
627 {
628 TmpString = HiiStatementPrivate->XuefiRedfishStr;
629 if (TmpString != NULL) {
630 Status = RegularExpressionProtocol->MatchString (
631 RegularExpressionProtocol,
632 TmpString,
633 Pattern,
634 &gEfiRegexSyntaxTypePerlGuid,
635 &IsMatch,
636 NULL,
637 &CaptureCount
638 );
639 if (EFI_ERROR (Status)) {
640 DEBUG ((DEBUG_ERROR, "%a: MatchString \"%s\" failed: %r\n", __func__, Pattern, Status));
641 ASSERT (FALSE);
642 return Status;
643 }
644
645 //
646 // Found
647 //
648 if (IsMatch) {
650 if (StatementRef == NULL) {
651 return EFI_OUT_OF_RESOURCES;
652 }
653
654 StatementRef->Statement = HiiStatementPrivate;
655 InsertTailList (&StatementList->StatementList, &StatementRef->Link);
656 ++StatementList->Count;
657 }
658 } else {
659 if (!RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH)) {
660 DEBUG ((DEBUG_ERROR, "%a: HiiStatementPrivate->XuefiRedfishStr is NULL, x-UEFI-string has something wrong.\n", __func__));
661 ASSERT (FALSE);
662 }
663 }
664 }
665
666 HiiStatementLink = HiiNextStatementLink;
667 }
668
669 HiiFormLink = HiiNextFormLink;
670 }
671
672 HiiFormsetLink = HiiFormsetNextLink;
673 }
674
675 return EFI_SUCCESS;
676}
677
690 IN LIST_ENTRY *FormsetList,
691 IN CHAR8 *Schema,
692 IN EFI_STRING ConfigureLang
693 )
694{
695 LIST_ENTRY *HiiFormsetLink;
696 LIST_ENTRY *HiiFormsetNextLink;
698 LIST_ENTRY *HiiFormLink;
699 LIST_ENTRY *HiiNextFormLink;
701 LIST_ENTRY *HiiStatementLink;
702 LIST_ENTRY *HiiNextStatementLink;
704 EFI_STRING TmpString;
705 UINTN Index;
706
707 if ((FormsetList == NULL) || IS_EMPTY_STRING (Schema) || IS_EMPTY_STRING (ConfigureLang)) {
708 return NULL;
709 }
710
711 if (IsListEmpty (FormsetList)) {
712 return NULL;
713 }
714
715 Index = 0;
716 HiiFormsetLink = GetFirstNode (FormsetList);
717 while (!IsNull (FormsetList, HiiFormsetLink)) {
718 HiiFormsetNextLink = GetNextNode (FormsetList, HiiFormsetLink);
719 HiiFormsetPrivate = REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFormsetLink);
720
721 //
722 // Performance check.
723 // If there is no desired Redfish schema found, skip this formset.
724 //
725 if (!CheckSupportedSchema (&HiiFormsetPrivate->SupportedSchema, Schema)) {
726 HiiFormsetLink = HiiFormsetNextLink;
727 continue;
728 }
729
730 HiiFormLink = GetFirstNode (&HiiFormsetPrivate->HiiFormList);
731 while (!IsNull (&HiiFormsetPrivate->HiiFormList, HiiFormLink)) {
732 HiiNextFormLink = GetNextNode (&HiiFormsetPrivate->HiiFormList, HiiFormLink);
733 HiiFormPrivate = REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLink);
734
735 HiiStatementLink = GetFirstNode (&HiiFormPrivate->StatementList);
736 while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) {
737 HiiNextStatementLink = GetNextNode (&HiiFormPrivate->StatementList, HiiStatementLink);
738 HiiStatementPrivate = REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK (HiiStatementLink);
739
740 if ((HiiStatementPrivate->Description != 0) &&
741 (RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_ALLOW_SUPPRESSED) || !HiiStatementPrivate->Suppressed))
742 {
743 TmpString = HiiStatementPrivate->XuefiRedfishStr;
744 if (TmpString != NULL) {
745 Index++;
746 DEBUG_REDFISH_THIS_MODULE (
747 REDFISH_PLATFORM_CONFIG_DEBUG_CONFIG_LANG_SEARCH,
748 "%a: [%d] check %s in QID: 0x%x form: 0x%x formset: %g\n",
749 __func__,
750 Index,
751 ConfigureLang,
752 HiiStatementPrivate->QuestionId,
753 HiiFormPrivate->Id,
754 &HiiFormsetPrivate->Guid
755 );
756 if (HiiStrCmp (TmpString, ConfigureLang) == 0) {
757 return HiiStatementPrivate;
758 }
759 } else {
760 if (!RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH)) {
761 DEBUG ((DEBUG_ERROR, "%a: HiiStatementPrivate->XuefiRedfishStr is NULL, x-UEFI-string has something wrong.\n", __func__));
762 ASSERT (FALSE);
763 }
764 }
765 }
766
767 HiiStatementLink = HiiNextStatementLink;
768 }
769
770 HiiFormLink = HiiNextFormLink;
771 }
772
773 HiiFormsetLink = HiiFormsetNextLink;
774 }
775
776 return NULL;
777}
778
790 IN EFI_HII_HANDLE HiiHandle,
791 IN LIST_ENTRY *FormsetList
792 )
793{
794 LIST_ENTRY *HiiFormsetLink;
795 LIST_ENTRY *HiiFormsetNextLink;
797
798 if ((HiiHandle == NULL) || (FormsetList == NULL)) {
799 return NULL;
800 }
801
802 if (IsListEmpty (FormsetList)) {
803 return NULL;
804 }
805
806 HiiFormsetLink = GetFirstNode (FormsetList);
807 while (!IsNull (FormsetList, HiiFormsetLink)) {
808 HiiFormsetNextLink = GetNextNode (FormsetList, HiiFormsetLink);
809 HiiFormsetPrivate = REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFormsetLink);
810
811 if (HiiFormsetPrivate->HiiHandle == HiiHandle) {
812 return HiiFormsetPrivate;
813 }
814
815 HiiFormsetLink = HiiFormsetNextLink;
816 }
817
818 return NULL;
819}
820
832 )
833{
834 REDFISH_X_UEFI_STRING_DATABASE *ThisDatabase;
836 REDFISH_X_UEFI_STRINGS_ARRAY *ThisStringArray;
837 REDFISH_X_UEFI_STRINGS_ARRAY *PreStringArray;
838 BOOLEAN EndDatabase;
839 BOOLEAN EndArray;
840
841 if (FormsetPrivate->HiiPackageListHeader != NULL) {
842 FreePool (FormsetPrivate->HiiPackageListHeader);
843 }
844
845 // Walk through x-UEFI-redfish string database.
846 if (!IsListEmpty (&FormsetPrivate->XuefiRedfishStringDatabase)) {
847 EndDatabase = FALSE;
848 ThisDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)GetFirstNode (&FormsetPrivate->XuefiRedfishStringDatabase);
849 while (!EndDatabase) {
850 // Walk through string arrays.
851 if (!IsListEmpty (&ThisDatabase->XuefiRedfishStringArrays)) {
852 EndArray = FALSE;
853 ThisStringArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetFirstNode (&ThisDatabase->XuefiRedfishStringArrays);
854 while (!EndArray) {
855 // Remove this array
856 FreePool (ThisStringArray->ArrayEntryAddress);
857 EndArray = IsNodeAtEnd (&ThisDatabase->XuefiRedfishStringArrays, &ThisStringArray->NextArray);
858 PreStringArray = ThisStringArray;
859 if (!EndArray) {
860 ThisStringArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetNextNode (&ThisDatabase->XuefiRedfishStringArrays, &ThisStringArray->NextArray);
861 }
862
863 RemoveEntryList (&PreStringArray->NextArray);
864 FreePool (PreStringArray);
865 }
866 }
867
868 //
869 // Remove this database
870 //
871 EndDatabase = IsNodeAtEnd (&FormsetPrivate->XuefiRedfishStringDatabase, &ThisDatabase->NextXuefiRedfishLanguage);
872 PreDatabase = ThisDatabase;
873 if (!EndDatabase) {
874 ThisDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)GetNextNode (&FormsetPrivate->XuefiRedfishStringDatabase, &ThisDatabase->NextXuefiRedfishLanguage);
875 }
876
877 RemoveEntryList (&PreDatabase->NextXuefiRedfishLanguage);
878 FreePool (PreDatabase);
879 }
880 }
881
882 return EFI_SUCCESS;
883}
884
896 )
897{
898 LIST_ENTRY *HiiFormLink;
899 LIST_ENTRY *HiiNextFormLink;
901 LIST_ENTRY *HiiStatementLink;
902 LIST_ENTRY *HiiNextStatementLink;
904 UINTN Index;
905
906 if (FormsetPrivate == NULL) {
907 return EFI_INVALID_PARAMETER;
908 }
909
910 HiiFormLink = GetFirstNode (&FormsetPrivate->HiiFormList);
911 while (!IsNull (&FormsetPrivate->HiiFormList, HiiFormLink)) {
912 HiiFormPrivate = REDFISH_PLATFORM_CONFIG_FORM_FROM_LINK (HiiFormLink);
913 HiiNextFormLink = GetNextNode (&FormsetPrivate->HiiFormList, HiiFormLink);
914
915 HiiStatementLink = GetFirstNode (&HiiFormPrivate->StatementList);
916 while (!IsNull (&HiiFormPrivate->StatementList, HiiStatementLink)) {
917 HiiStatementPrivate = REDFISH_PLATFORM_CONFIG_STATEMENT_FROM_LINK (HiiStatementLink);
918 HiiNextStatementLink = GetNextNode (&HiiFormPrivate->StatementList, HiiStatementLink);
919
920 //
921 // HiiStatementPrivate->HiiStatement will be released in DestroyFormSet().
922 //
923 RemoveEntryList (&HiiStatementPrivate->Link);
924 FreePool (HiiStatementPrivate);
925 HiiStatementLink = HiiNextStatementLink;
926 }
927
928 //
929 // HiiStatementPrivate->HiiForm will be released in DestroyFormSet().
930 //
931
932 RemoveEntryList (&HiiFormPrivate->Link);
933 FreePool (HiiFormPrivate);
934 HiiFormLink = HiiNextFormLink;
935 }
936
937 if (FormsetPrivate->HiiFormSet != NULL) {
938 DestroyFormSet (FormsetPrivate->HiiFormSet);
939 FormsetPrivate->HiiFormSet = NULL;
940 }
941
942 if (FormsetPrivate->DevicePathStr != NULL) {
943 FreePool (FormsetPrivate->DevicePathStr);
944 }
945
946 //
947 // Release schema list
948 //
949 if (FormsetPrivate->SupportedSchema.SchemaList != NULL) {
950 for (Index = 0; Index < FormsetPrivate->SupportedSchema.Count; Index++) {
951 FreePool (FormsetPrivate->SupportedSchema.SchemaList[Index]);
952 }
953
954 FreePool (FormsetPrivate->SupportedSchema.SchemaList);
955 FormsetPrivate->SupportedSchema.SchemaList = NULL;
956 FormsetPrivate->SupportedSchema.Count = 0;
957 }
958
959 ReleaseXuefiStringDatabase (FormsetPrivate);
960
961 return EFI_SUCCESS;
962}
963
972 VOID
973 )
974{
976
978 if (NewFormsetPrivate == NULL) {
979 return NULL;
980 }
981
982 //
983 // Initial newly created formset private data.
984 //
986 InitializeListHead (&NewFormsetPrivate->XuefiRedfishStringDatabase);
987
988 return NewFormsetPrivate;
989}
990
1002 IN REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase
1003 )
1004{
1005 REDFISH_X_UEFI_STRINGS_ARRAY *ArrayAddress;
1006
1007 // Initial first REDFISH_X_UEFI_STRINGS_ARRAY memory.
1009 if (ArrayAddress == NULL) {
1010 DEBUG ((DEBUG_ERROR, "%a: Failed to allocate REDFISH_X_UEFI_STRINGS_ARRAY.\n", __func__));
1011 return EFI_OUT_OF_RESOURCES;
1012 }
1013
1014 InitializeListHead (&ArrayAddress->NextArray);
1015
1016 // Allocate memory buffer for REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT elements.
1017 ArrayAddress->ArrayEntryAddress = \
1018 (REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT *)AllocateZeroPool (sizeof (REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENT) * X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER);
1019 if (ArrayAddress->ArrayEntryAddress == NULL) {
1020 FreePool (ArrayAddress);
1021 DEBUG ((DEBUG_ERROR, "%a: Failed to allocate array for REDFISH_X_UEFI_STRINGS_ARRAY_ELEMENTs.\n", __func__));
1022 return EFI_OUT_OF_RESOURCES;
1023 }
1024
1025 XuefiRedfishStringDatabase->StringsArrayBlocks++;
1026 InsertTailList (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, &ArrayAddress->NextArray);
1027 return EFI_SUCCESS;
1028}
1029
1043 IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader
1044 )
1045{
1046 EFI_STATUS Status;
1047 BOOLEAN CreateNewOne;
1048 REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase;
1049
1050 CreateNewOne = TRUE;
1051 XuefiRedfishStringDatabase = NULL;
1052 if (!IsListEmpty (&FormsetPrivate->XuefiRedfishStringDatabase)) {
1053 XuefiRedfishStringDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)GetFirstNode (&FormsetPrivate->XuefiRedfishStringDatabase);
1054
1055 while (TRUE) {
1056 if (AsciiStriCmp (XuefiRedfishStringDatabase->XuefiRedfishLanguage, HiiStringPackageHeader->Language) == 0) {
1057 CreateNewOne = FALSE;
1058 break;
1059 }
1060
1061 if (IsNodeAtEnd (&FormsetPrivate->XuefiRedfishStringDatabase, &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage)) {
1062 break;
1063 }
1064
1065 XuefiRedfishStringDatabase = \
1066 (REDFISH_X_UEFI_STRING_DATABASE *)GetNextNode (&FormsetPrivate->XuefiRedfishStringDatabase, &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage);
1067 }
1068 }
1069
1070 if (CreateNewOne) {
1071 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " Creating x-UEFI-redfish (%a) string database...\n", HiiStringPackageHeader->Language));
1072 XuefiRedfishStringDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)AllocateZeroPool (sizeof (REDFISH_X_UEFI_STRING_DATABASE));
1073 if (XuefiRedfishStringDatabase == NULL) {
1074 DEBUG ((DEBUG_ERROR, " Failed to allocate REDFISH_X_UEFI_STRING_DATABASE.\n"));
1075 return NULL;
1076 }
1077
1078 InitializeListHead (&XuefiRedfishStringDatabase->NextXuefiRedfishLanguage);
1079 InitializeListHead (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays);
1080 XuefiRedfishStringDatabase->StringsArrayBlocks = 0;
1081 XuefiRedfishStringDatabase->XuefiRedfishLanguage = HiiStringPackageHeader->Language;
1082
1083 Status = NewRedfishXuefiStringArray (XuefiRedfishStringDatabase);
1084 if (EFI_ERROR (Status)) {
1085 FreePool (XuefiRedfishStringDatabase);
1086 return NULL;
1087 }
1088
1089 DEBUG ((
1091 " x-UEFI-redfish (%a):\n String array is added to XuefiRedfishStringDatabase, total %d arrays now.\n",
1092 XuefiRedfishStringDatabase->XuefiRedfishLanguage,
1093 XuefiRedfishStringDatabase->StringsArrayBlocks
1094 ));
1095
1096 // Link string database to FormsetPrivate.
1097 InsertTailList (&FormsetPrivate->XuefiRedfishStringDatabase, &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage);
1098 }
1099
1100 return XuefiRedfishStringDatabase;
1101}
1102
1119 IN REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase,
1120 IN EFI_STRING_ID StringId
1121 )
1122{
1123 EFI_STATUS Status;
1124
1125 while (((StringId + X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) / X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) > (UINT16)XuefiRedfishStringDatabase->StringsArrayBlocks) {
1126 Status = NewRedfishXuefiStringArray (XuefiRedfishStringDatabase);
1127 if (EFI_ERROR (Status)) {
1128 DEBUG ((DEBUG_ERROR, "%a: Failed to adjust x-UEFI-string array", __func__));
1129 return Status;
1130 }
1131 }
1132
1133 return EFI_SUCCESS;
1134}
1135
1152 IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader,
1153 IN EFI_STRING_ID StringId,
1154 IN CHAR16 *StringTextPtr
1155 )
1156{
1157 EFI_STATUS Status;
1158 UINTN StringIdOffset;
1159 REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase;
1161
1162 XuefiRedfishStringDatabase = GetExistOrCreateXuefiStringDatabase (FormsetPrivate, HiiStringPackageHeader);
1163 if (XuefiRedfishStringDatabase == NULL) {
1164 DEBUG ((DEBUG_ERROR, "%a: Failed to get REDFISH_X_UEFI_STRING_DATABASE of x-UEFI-redfish language %a.\n", __func__, HiiStringPackageHeader->Language));
1165 ReleaseXuefiStringDatabase (FormsetPrivate);
1166 return EFI_LOAD_ERROR;
1167 }
1168
1169 Status = RedfishXuefiStringAdjustArrays (FormsetPrivate, XuefiRedfishStringDatabase, StringId);
1170 if (EFI_ERROR (Status)) {
1171 DEBUG ((DEBUG_ERROR, "%a: Failed to adjust x-UEFI-redfish string array.\n", __func__));
1172 ReleaseXuefiStringDatabase (FormsetPrivate);
1173 return EFI_LOAD_ERROR;
1174 }
1175
1176 // Insert string to x-UEFI-redfish string array.
1177 StringIdOffset = (UINTN)StringId;
1178 ThisArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetFirstNode (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays);
1179 while (StringIdOffset >= X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) {
1180 ThisArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetNextNode (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, &ThisArray->NextArray);
1181 StringIdOffset -= X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER;
1182 }
1183
1184 // Insert string
1185 (ThisArray->ArrayEntryAddress + StringIdOffset)->StringId = StringId;
1186 (ThisArray->ArrayEntryAddress + StringIdOffset)->UcsString = StringTextPtr;
1187
1188 DEBUG_REDFISH_THIS_MODULE (
1189 REDFISH_PLATFORM_CONFIG_DEBUG_STRING_DATABASE,
1190 " Insert string ID: (%d) to database\n x-UEFI-string: \"%s\"\n Language: %a.\n",
1191 StringId,
1192 StringTextPtr,
1193 HiiStringPackageHeader->Language
1194 );
1195 return EFI_SUCCESS;
1196}
1197
1209BOOLEAN
1212 IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader,
1213 OUT UINTN *TotalStringAdded
1214 )
1215{
1216 EFI_STATUS Status;
1217 UINT8 *BlockHdr;
1218 EFI_STRING_ID CurrentStringId;
1219 UINTN BlockSize;
1220 UINTN Index;
1221 UINT8 *StringTextPtr;
1222 UINTN Offset;
1223 UINT16 StringCount;
1224 UINT16 SkipCount;
1225 UINT8 Length8;
1227 UINT32 Length32;
1228 UINT8 *StringBlockInfo;
1229 UINTN StringsAdded;
1230
1231 StringsAdded = 0;
1232
1233 //
1234 // Parse the string blocks to get the string text and font.
1235 //
1236 StringBlockInfo = (UINT8 *)((UINTN)HiiStringPackageHeader + HiiStringPackageHeader->StringInfoOffset);
1237 BlockHdr = StringBlockInfo;
1238 BlockSize = 0;
1239 Offset = 0;
1240 CurrentStringId = 1;
1241 while (*BlockHdr != EFI_HII_SIBT_END) {
1242 switch (*BlockHdr) {
1243 case EFI_HII_SIBT_STRING_SCSU:
1244 Offset = sizeof (EFI_HII_STRING_BLOCK);
1245 StringTextPtr = BlockHdr + Offset;
1246 BlockSize += Offset + AsciiStrSize ((CHAR8 *)StringTextPtr);
1247 CurrentStringId++;
1248 break;
1249
1250 case EFI_HII_SIBT_STRING_SCSU_FONT:
1251 Offset = sizeof (EFI_HII_SIBT_STRING_SCSU_FONT_BLOCK) - sizeof (UINT8);
1252 StringTextPtr = BlockHdr + Offset;
1253 BlockSize += Offset + AsciiStrSize ((CHAR8 *)StringTextPtr);
1254 CurrentStringId++;
1255 break;
1256
1257 case EFI_HII_SIBT_STRINGS_SCSU:
1258 CopyMem (&StringCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), sizeof (UINT16));
1259 StringTextPtr = (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_SIBT_STRINGS_SCSU_BLOCK) - sizeof (UINT8));
1260 BlockSize += StringTextPtr - BlockHdr;
1261
1262 for (Index = 0; Index < StringCount; Index++) {
1263 BlockSize += AsciiStrSize ((CHAR8 *)StringTextPtr);
1264 StringTextPtr = StringTextPtr + AsciiStrSize ((CHAR8 *)StringTextPtr);
1265 CurrentStringId++;
1266 }
1267
1268 break;
1269
1270 case EFI_HII_SIBT_STRINGS_SCSU_FONT:
1271 CopyMem (
1272 &StringCount,
1273 (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)),
1274 sizeof (UINT16)
1275 );
1276 StringTextPtr = (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_SIBT_STRINGS_SCSU_FONT_BLOCK) - sizeof (UINT8));
1277 BlockSize += StringTextPtr - BlockHdr;
1278
1279 for (Index = 0; Index < StringCount; Index++) {
1280 BlockSize += AsciiStrSize ((CHAR8 *)StringTextPtr);
1281 StringTextPtr = StringTextPtr + AsciiStrSize ((CHAR8 *)StringTextPtr);
1282 CurrentStringId++;
1283 }
1284
1285 break;
1286
1287 case EFI_HII_SIBT_STRING_UCS2:
1288 Offset = sizeof (EFI_HII_STRING_BLOCK);
1289 StringTextPtr = BlockHdr + Offset;
1290
1291 // x-UEFI-redfish string is always encoded as UCS and started with '/'.
1292 if (*StringTextPtr == (UINT16)'/') {
1294 FormsetPrivate,
1295 HiiStringPackageHeader,
1296 CurrentStringId,
1297 (CHAR16 *)StringTextPtr
1298 );
1299 if (EFI_ERROR (Status)) {
1300 DEBUG ((DEBUG_ERROR, "%a: Failed to insert x-UEFI-redfish string %s.\n", __func__, StringTextPtr));
1301 return FALSE;
1302 }
1303
1304 StringsAdded++;
1305 }
1306
1307 BlockSize += (Offset + HiiStrSize ((CHAR16 *)StringTextPtr));
1308 CurrentStringId++;
1309 break;
1310
1311 case EFI_HII_SIBT_STRING_UCS2_FONT:
1312 Offset = sizeof (EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK) - sizeof (CHAR16);
1313 StringTextPtr = BlockHdr + Offset;
1314 BlockSize += (Offset + HiiStrSize ((CHAR16 *)StringTextPtr));
1315 CurrentStringId++;
1316 break;
1317
1318 case EFI_HII_SIBT_STRINGS_UCS2:
1319 Offset = sizeof (EFI_HII_SIBT_STRINGS_UCS2_BLOCK) - sizeof (CHAR16);
1320 StringTextPtr = BlockHdr + Offset;
1321 BlockSize += Offset;
1322 CopyMem (&StringCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), sizeof (UINT16));
1323 for (Index = 0; Index < StringCount; Index++) {
1324 BlockSize += HiiStrSize ((CHAR16 *)StringTextPtr);
1325 StringTextPtr = StringTextPtr + HiiStrSize ((CHAR16 *)StringTextPtr);
1326 CurrentStringId++;
1327 }
1328
1329 break;
1330
1331 case EFI_HII_SIBT_STRINGS_UCS2_FONT:
1332 Offset = sizeof (EFI_HII_SIBT_STRINGS_UCS2_FONT_BLOCK) - sizeof (CHAR16);
1333 StringTextPtr = BlockHdr + Offset;
1334 BlockSize += Offset;
1335 CopyMem (
1336 &StringCount,
1337 (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)),
1338 sizeof (UINT16)
1339 );
1340 for (Index = 0; Index < StringCount; Index++) {
1341 BlockSize += HiiStrSize ((CHAR16 *)StringTextPtr);
1342 StringTextPtr = StringTextPtr + HiiStrSize ((CHAR16 *)StringTextPtr);
1343 CurrentStringId++;
1344 }
1345
1346 break;
1347
1348 case EFI_HII_SIBT_DUPLICATE:
1349 BlockSize += sizeof (EFI_HII_SIBT_DUPLICATE_BLOCK);
1350 CurrentStringId++;
1351 break;
1352
1353 case EFI_HII_SIBT_SKIP1:
1354 SkipCount = (UINT16)(*(UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK)));
1355 CurrentStringId = (UINT16)(CurrentStringId + SkipCount);
1356 BlockSize += sizeof (EFI_HII_SIBT_SKIP1_BLOCK);
1357 break;
1358
1359 case EFI_HII_SIBT_SKIP2:
1360 CopyMem (&SkipCount, BlockHdr + sizeof (EFI_HII_STRING_BLOCK), sizeof (UINT16));
1361 CurrentStringId = (UINT16)(CurrentStringId + SkipCount);
1362 BlockSize += sizeof (EFI_HII_SIBT_SKIP2_BLOCK);
1363 break;
1364
1365 case EFI_HII_SIBT_EXT1:
1366 CopyMem (
1367 &Length8,
1368 (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)),
1369 sizeof (UINT8)
1370 );
1371 BlockSize += Length8;
1372 break;
1373
1374 case EFI_HII_SIBT_EXT2:
1375 CopyMem (&Ext2, BlockHdr, sizeof (EFI_HII_SIBT_EXT2_BLOCK));
1376 BlockSize += Ext2.Length;
1377 break;
1378
1379 case EFI_HII_SIBT_EXT4:
1380 CopyMem (
1381 &Length32,
1382 (UINT8 *)((UINTN)BlockHdr + sizeof (EFI_HII_STRING_BLOCK) + sizeof (UINT8)),
1383 sizeof (UINT32)
1384 );
1385
1386 BlockSize += Length32;
1387 break;
1388
1389 default:
1390 break;
1391 }
1392
1393 BlockHdr = (UINT8 *)(StringBlockInfo + BlockSize);
1394 }
1395
1396 *TotalStringAdded = StringsAdded;
1397 return TRUE;
1398}
1399
1418 IN EFI_STRING_ID StringId,
1419 OUT CHAR16 **String OPTIONAL,
1420 OUT CHAR8 **Language OPTIONAL,
1421 OUT REDFISH_X_UEFI_STRING_DATABASE **XuefiStringDatabase OPTIONAL
1422 )
1423{
1424 REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase;
1425 REDFISH_X_UEFI_STRINGS_ARRAY *StringArray;
1426 UINT16 StringIndex;
1427
1428 if ((String == NULL) && (Language == NULL) && (XuefiStringDatabase == NULL)) {
1429 DEBUG ((DEBUG_ERROR, "%a: Invalid parameters for this function.\n", __func__));
1430 return EFI_INVALID_PARAMETER;
1431 }
1432
1433 if (IsListEmpty (&FormsetPrivate->XuefiRedfishStringDatabase)) {
1434 return EFI_NOT_FOUND;
1435 }
1436
1437 XuefiRedfishStringDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)GetFirstNode (&FormsetPrivate->XuefiRedfishStringDatabase);
1438 while (TRUE) {
1439 if (Language != NULL) {
1440 *Language = XuefiRedfishStringDatabase->XuefiRedfishLanguage;
1441 }
1442
1443 StringArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetFirstNode (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays);
1444
1445 // Loop to the correct string array.
1446 StringIndex = StringId;
1447 while (StringIndex >= X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER) {
1448 if (IsNodeAtEnd (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, &StringArray->NextArray)) {
1449 goto ErrorExit;
1450 }
1451
1452 StringArray = (REDFISH_X_UEFI_STRINGS_ARRAY *)GetNextNode (&XuefiRedfishStringDatabase->XuefiRedfishStringArrays, &StringArray->NextArray);
1453 StringIndex -= X_UEFI_REDFISH_STRING_ARRAY_ENTRY_NUMBER;
1454 }
1455
1456 //
1457 // NOTE: The string ID in the formset is a unique number.
1458 // If the string in the array is NULL, then the matched string ID
1459 // should be in another x-UEFI-redfish database.
1460 //
1461 if ((StringArray->ArrayEntryAddress + StringIndex)->UcsString != NULL) {
1462 //
1463 // String ID is belong to this x-uef-redfish language database.
1464 //
1465 if (String != NULL) {
1466 *String = (StringArray->ArrayEntryAddress + StringIndex)->UcsString;
1467 }
1468
1469 if (XuefiStringDatabase != NULL) {
1470 *XuefiStringDatabase = XuefiRedfishStringDatabase;
1471 }
1472
1473 return EFI_SUCCESS;
1474 }
1475
1476 if (IsNodeAtEnd (&FormsetPrivate->XuefiRedfishStringDatabase, &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage)) {
1477 return EFI_NOT_FOUND;
1478 }
1479
1480 XuefiRedfishStringDatabase = (REDFISH_X_UEFI_STRING_DATABASE *)GetNextNode (
1481 &FormsetPrivate->XuefiRedfishStringDatabase,
1482 &XuefiRedfishStringDatabase->NextXuefiRedfishLanguage
1483 );
1484 }
1485
1486ErrorExit:;
1487 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: String ID (%d) is not in any x-uef-redfish string databases.\n", __func__, StringId));
1488 return EFI_NOT_FOUND;
1489}
1490
1497VOID
1500 )
1501{
1502 EFI_STATUS Status;
1503 UINTN BufferSize;
1504 EFI_HII_PACKAGE_HEADER *PackageHeader;
1505 UINTN EndingPackageAddress;
1506 EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader;
1507 UINTN SupportedSchemaLangCount;
1508 CHAR8 **SupportedSchemaLang;
1509 BOOLEAN StringIdMapIsBuilt;
1510 UINTN TotalStringsAdded;
1511 UINTN NumberPackageStrings;
1512
1513 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: Building x-UEFI-redfish string database, HII Formset GUID - %g.\n", __func__, FormsetPrivate->Guid));
1514
1515 BufferSize = 0;
1516 Status = mRedfishPlatformConfigPrivate->HiiDatabase->ExportPackageLists (
1517 mRedfishPlatformConfigPrivate->HiiDatabase,
1518 FormsetPrivate->HiiHandle,
1519 &BufferSize,
1520 FormsetPrivate->HiiPackageListHeader
1521 );
1522 if (Status != EFI_BUFFER_TOO_SMALL) {
1523 DEBUG ((DEBUG_ERROR, " Failed to export package list.\n"));
1524 return;
1525 }
1526
1527 FormsetPrivate->HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *)AllocateZeroPool (BufferSize);
1528 if (FormsetPrivate->HiiPackageListHeader == NULL) {
1529 DEBUG ((DEBUG_ERROR, " Failed to allocate memory for the exported package list.\n"));
1530 return;
1531 }
1532
1533 Status = mRedfishPlatformConfigPrivate->HiiDatabase->ExportPackageLists (
1534 mRedfishPlatformConfigPrivate->HiiDatabase,
1535 FormsetPrivate->HiiHandle,
1536 &BufferSize,
1537 FormsetPrivate->HiiPackageListHeader
1538 );
1539 if (EFI_ERROR (Status)) {
1540 FreePool (FormsetPrivate->HiiPackageListHeader);
1541 FormsetPrivate->HiiPackageListHeader = NULL;
1542 return;
1543 }
1544
1545 TotalStringsAdded = 0;
1546 //
1547 // Finding the string package.
1548 //
1549 EndingPackageAddress = (UINTN)FormsetPrivate->HiiPackageListHeader + FormsetPrivate->HiiPackageListHeader->PackageLength;
1550 PackageHeader = (EFI_HII_PACKAGE_HEADER *)(FormsetPrivate->HiiPackageListHeader + 1);
1551 SupportedSchemaLang = FormsetPrivate->SupportedSchema.SchemaList;
1552 while ((UINTN)PackageHeader < EndingPackageAddress) {
1553 switch (PackageHeader->Type) {
1554 case EFI_HII_PACKAGE_STRINGS:
1555 StringIdMapIsBuilt = FALSE;
1556 HiiStringPackageHeader = (EFI_HII_STRING_PACKAGE_HDR *)PackageHeader;
1557
1558 // Check if this is the string package for x-UEFI-redfish
1559 for (SupportedSchemaLangCount = 0;
1560 SupportedSchemaLangCount < FormsetPrivate->SupportedSchema.Count;
1561 SupportedSchemaLangCount++
1562 )
1563 {
1564 if (AsciiStrnCmp (
1565 *(SupportedSchemaLang + SupportedSchemaLangCount),
1566 HiiStringPackageHeader->Language,
1567 AsciiStrLen (HiiStringPackageHeader->Language)
1568 ) == 0)
1569 {
1570 StringIdMapIsBuilt = CreateXuefiLanguageStringIdMap (FormsetPrivate, HiiStringPackageHeader, &NumberPackageStrings);
1571 if (StringIdMapIsBuilt) {
1572 TotalStringsAdded += NumberPackageStrings;
1573 }
1574
1575 break;
1576 }
1577 }
1578
1579 if (StringIdMapIsBuilt == FALSE) {
1580 if (AsciiStrStr (HiiStringPackageHeader->Language, X_UEFI_SCHEMA_PREFIX) == NULL) {
1581 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " No need to build x-UEFI-redfish string ID map for HII language %a\n", HiiStringPackageHeader->Language));
1582 } else {
1583 DEBUG ((DEBUG_ERROR, " Failed to build x-UEFI-redfish string ID map of HII language %a\n", HiiStringPackageHeader->Language));
1584 }
1585 }
1586
1587 default:
1588 PackageHeader = (EFI_HII_PACKAGE_HEADER *)((UINTN)PackageHeader + PackageHeader->Length);
1589 }
1590 }
1591
1592 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, " Total %d x-UEFI-redfish config language are added.\n", TotalStringsAdded));
1593}
1594
1607 IN EFI_HII_HANDLE HiiHandle,
1609 )
1610{
1611 EFI_STATUS Status;
1612 HII_FORMSET *HiiFormSet;
1613 HII_FORM *HiiForm;
1614 LIST_ENTRY *HiiFormLink;
1616 HII_STATEMENT *HiiStatement;
1617 LIST_ENTRY *HiiStatementLink;
1618 REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE *HiiStatementPrivate;
1619 EFI_GUID ZeroGuid;
1620 EXPRESS_RESULT ExpressionResult;
1621 CHAR16 *String;
1622
1623 if ((HiiHandle == NULL) || (FormsetPrivate == NULL)) {
1624 return EFI_INVALID_PARAMETER;
1625 }
1626
1627 HiiFormSet = AllocateZeroPool (sizeof (HII_FORMSET));
1628 if (HiiFormSet == NULL) {
1629 DEBUG ((DEBUG_ERROR, "%a: No memory resource for HII_FORMSET - %g\n", __func__, FormsetPrivate->Guid));
1630 return EFI_OUT_OF_RESOURCES;
1631 }
1632
1633 //
1634 // Find HII formset by the given HII handle.
1635 //
1636 ZeroMem (&ZeroGuid, sizeof (ZeroGuid));
1637 Status = CreateFormSetFromHiiHandle (HiiHandle, &ZeroGuid, HiiFormSet);
1638 if (EFI_ERROR (Status) || IsListEmpty (&HiiFormSet->FormListHead)) {
1639 DEBUG ((DEBUG_ERROR, "%a: Formset not found by HII handle - %g\n", __func__, FormsetPrivate->Guid));
1640 Status = EFI_NOT_FOUND;
1641 goto ErrorExit;
1642 }
1643
1644 //
1645 // Initialize formset
1646 //
1647 InitializeFormSet (HiiFormSet);
1648
1649 //
1650 // Initialize formset private data.
1651 //
1652 FormsetPrivate->HiiFormSet = HiiFormSet;
1653 FormsetPrivate->HiiHandle = HiiHandle;
1654 CopyGuid (&FormsetPrivate->Guid, &HiiFormSet->Guid);
1655 FormsetPrivate->DevicePathStr = ConvertDevicePathToText (HiiFormSet->DevicePath, FALSE, FALSE);
1656 Status = GetSupportedSchema (FormsetPrivate->HiiHandle, &FormsetPrivate->SupportedSchema);
1657 if (EFI_ERROR (Status)) {
1658 if (!RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH)) {
1659 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: No x-UEFI-redfish configuration found on the formset - %g\n", __func__, FormsetPrivate->Guid));
1660 //
1661 // If there is no x-UEFI-redfish language in this form-set, we don't add formset
1662 // since we don't need to build menu path for attribute registry.
1663 //
1664 return EFI_UNSUPPORTED;
1665 }
1666 } else {
1667 // Building x-UEFI-redfish string database
1668 BuildXUefiRedfishStringDatabase (FormsetPrivate);
1669 }
1670
1671 HiiFormLink = GetFirstNode (&HiiFormSet->FormListHead);
1672 while (!IsNull (&HiiFormSet->FormListHead, HiiFormLink)) {
1673 HiiForm = HII_FORM_FROM_LINK (HiiFormLink);
1674
1675 HiiFormPrivate = AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_FORM_PRIVATE));
1676 if (HiiFormPrivate == NULL) {
1677 Status = EFI_OUT_OF_RESOURCES;
1678 DEBUG ((DEBUG_ERROR, "%a: No memory resource for REDFISH_PLATFORM_CONFIG_FORM_PRIVATE.\n", __func__));
1679 goto ErrorExit;
1680 }
1681
1682 //
1683 // Initialize form private data.
1684 //
1685 HiiFormPrivate->HiiForm = HiiForm;
1686 HiiFormPrivate->Id = HiiForm->FormId;
1687 HiiFormPrivate->Title = HiiForm->FormTitle;
1688 HiiFormPrivate->ParentFormset = FormsetPrivate;
1689 HiiFormPrivate->Suppressed = FALSE;
1690 InitializeListHead (&HiiFormPrivate->StatementList);
1691
1692 if ((HiiForm->SuppressExpression != NULL) &&
1693 (EvaluateExpressionList (HiiForm->SuppressExpression, TRUE, HiiFormSet, HiiForm) == ExpressSuppress))
1694 {
1695 HiiFormPrivate->Suppressed = TRUE;
1696 }
1697
1698 HiiStatementLink = GetFirstNode (&HiiForm->StatementListHead);
1699 while (!IsNull (&HiiForm->StatementListHead, HiiStatementLink)) {
1700 HiiStatement = HII_STATEMENT_FROM_LINK (HiiStatementLink);
1701
1702 HiiStatementPrivate = AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE));
1703 if (HiiStatementPrivate == NULL) {
1704 DEBUG ((DEBUG_ERROR, "%a: No memory resource for REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE.\n", __func__));
1705 Status = EFI_OUT_OF_RESOURCES;
1706 goto ErrorExit;
1707 }
1708
1709 //
1710 // Initialize statement private data.
1711 //
1712 HiiStatementPrivate->HiiStatement = HiiStatement;
1713 HiiStatementPrivate->QuestionId = HiiStatement->QuestionId;
1714 HiiStatementPrivate->Description = HiiStatement->Prompt;
1715 HiiStatementPrivate->Help = HiiStatement->Help;
1716 HiiStatementPrivate->ParentForm = HiiFormPrivate;
1717 HiiStatementPrivate->Flags = HiiStatement->QuestionFlags;
1718 HiiStatementPrivate->StatementData.NumMaximum = HiiStatement->ExtraData.NumData.Maximum;
1719 HiiStatementPrivate->StatementData.NumMinimum = HiiStatement->ExtraData.NumData.Minimum;
1720 HiiStatementPrivate->StatementData.NumStep = HiiStatement->ExtraData.NumData.Step;
1721 HiiStatementPrivate->StatementData.StrMaxSize = HiiStatement->ExtraData.StrData.MaxSize;
1722 HiiStatementPrivate->StatementData.StrMinSize = HiiStatement->ExtraData.StrData.MinSize;
1723 HiiStatementPrivate->Suppressed = FALSE;
1724 HiiStatementPrivate->GrayedOut = FALSE;
1725
1726 //
1727 // Expression
1728 //
1729 if (HiiFormPrivate->Suppressed) {
1730 HiiStatementPrivate->Suppressed = TRUE;
1731 } else {
1732 if (HiiStatement->ExpressionList != NULL) {
1733 ExpressionResult = EvaluateExpressionList (HiiStatement->ExpressionList, TRUE, HiiFormSet, HiiForm);
1734 if (ExpressionResult == ExpressGrayOut) {
1735 HiiStatementPrivate->GrayedOut = TRUE;
1736 } else if (ExpressionResult == ExpressSuppress) {
1737 HiiStatementPrivate->Suppressed = TRUE;
1738 }
1739 }
1740 }
1741
1742 // Get x-UEFI-redfish string using String ID.
1743 Status = GetXuefiStringAndLangByStringId (FormsetPrivate, HiiStatementPrivate->Description, &String, NULL, NULL);
1744 if (!EFI_ERROR (Status)) {
1745 HiiStatementPrivate->XuefiRedfishStr = String;
1746 //
1747 // Attach to statement list.
1748 //
1749 InsertTailList (&HiiFormPrivate->StatementList, &HiiStatementPrivate->Link);
1750 } else {
1751 if (!RedfishPlatformConfigFeatureProp (REDFISH_PLATFORM_CONFIG_BUILD_MENU_PATH)) {
1752 //
1753 // If there is no x-UEFI-redfish language for this statement, we don't add this statement
1754 // since we don't need to build menu path for attribute registry.
1755 //
1756 FreePool (HiiStatementPrivate);
1757 } else {
1758 //
1759 // This is not x-UEFI-redfish string and we don't cache its string for searching Redfish configure language.
1760 // When caller wants the string, we will read English string by calling HiiGetString().
1761 //
1762 HiiStatementPrivate->XuefiRedfishStr = NULL;
1763 //
1764 // Attach to statement list.
1765 //
1766 InsertTailList (&HiiFormPrivate->StatementList, &HiiStatementPrivate->Link);
1767 }
1768 }
1769
1770 HiiStatementLink = GetNextNode (&HiiForm->StatementListHead, HiiStatementLink);
1771 }
1772
1773 //
1774 // Attach to form list.
1775 //
1776 InsertTailList (&FormsetPrivate->HiiFormList, &HiiFormPrivate->Link);
1777 HiiFormLink = GetNextNode (&HiiFormSet->FormListHead, HiiFormLink);
1778 }
1779
1780 return EFI_SUCCESS;
1781
1782ErrorExit:
1783
1784 //
1785 // Release HiiFormSet if HiiFormSet is not linked to FormsetPrivate yet.
1786 //
1787 if ((HiiFormSet != NULL) && (FormsetPrivate->HiiFormSet != HiiFormSet)) {
1788 DestroyFormSet (HiiFormSet);
1789 }
1790
1791 //
1792 // Release resource when error happens.
1793 //
1794 ReleaseFormset (FormsetPrivate);
1795
1796 return Status;
1797}
1798
1810 IN EFI_HII_HANDLE *HiiHandle,
1811 OUT LIST_ENTRY *FormsetList
1812 )
1813{
1814 EFI_STATUS Status;
1816
1817 if ((HiiHandle == NULL) || (FormsetList == NULL)) {
1818 return EFI_INVALID_PARAMETER;
1819 }
1820
1821 FormsetPrivate = GetFormsetPrivateByHiiHandle (HiiHandle, FormsetList);
1822 if (FormsetPrivate != NULL) {
1823 return EFI_ALREADY_STARTED;
1824 }
1825
1826 FormsetPrivate = NewFormsetPrivate ();
1827 if (FormsetPrivate == NULL) {
1828 DEBUG ((DEBUG_ERROR, "%a: out of resource\n", __func__));
1829 return EFI_OUT_OF_RESOURCES;
1830 }
1831
1832 //
1833 // Load formset on the given HII handle.
1834 //
1835 Status = LoadFormset (HiiHandle, FormsetPrivate);
1836 if (EFI_ERROR (Status)) {
1837 DEBUG ((DEBUG_ERROR, "%a: Formset is not loaded for edk2 redfish: %r\n", __func__, Status));
1838 FreePool (FormsetPrivate);
1839 return Status;
1840 }
1841
1842 //
1843 // Attach to cache list.
1844 //
1845 InsertTailList (FormsetList, &FormsetPrivate->Link);
1846
1847 DEBUG_CODE (
1848 if (RedfishPlatformConfigDebugProp (REDFISH_PLATFORM_CONFIG_DEBUG_DUMP_FORMSET)) {
1849 DumpFormsetList (FormsetList);
1850 }
1851
1852 );
1853
1854 return EFI_SUCCESS;
1855}
1856
1868 IN LIST_ENTRY *FormsetList
1869 )
1870{
1871 LIST_ENTRY *HiiFormsetLink;
1872 LIST_ENTRY *HiiFormsetNextLink;
1874
1875 if (FormsetList == NULL) {
1876 return EFI_INVALID_PARAMETER;
1877 }
1878
1879 if (IsListEmpty (FormsetList)) {
1880 return EFI_SUCCESS;
1881 }
1882
1883 HiiFormsetLink = GetFirstNode (FormsetList);
1884 while (!IsNull (FormsetList, HiiFormsetLink)) {
1885 HiiFormsetNextLink = GetNextNode (FormsetList, HiiFormsetLink);
1886 HiiFormsetPrivate = REDFISH_PLATFORM_CONFIG_FORMSET_FROM_LINK (HiiFormsetLink);
1887
1888 //
1889 // Detach from list.
1890 //
1891 RemoveEntryList (&HiiFormsetPrivate->Link);
1892 ReleaseFormset (HiiFormsetPrivate);
1893 FreePool (HiiFormsetPrivate);
1894 HiiFormsetLink = HiiFormsetNextLink;
1895 }
1896
1897 return EFI_SUCCESS;
1898}
1899
1911 IN EFI_HII_HANDLE *HiiHandle,
1912 IN LIST_ENTRY *PendingList
1913 )
1914{
1915 LIST_ENTRY *PendingListLink;
1917
1918 if ((HiiHandle == NULL) || (PendingList == NULL)) {
1919 return NULL;
1920 }
1921
1922 if (IsListEmpty (PendingList)) {
1923 return NULL;
1924 }
1925
1926 PendingListLink = GetFirstNode (PendingList);
1927 while (!IsNull (PendingList, PendingListLink)) {
1928 Target = REDFISH_PLATFORM_CONFIG_PENDING_LIST_FROM_LINK (PendingListLink);
1929
1930 if (Target->HiiHandle == HiiHandle) {
1931 return Target;
1932 }
1933
1934 PendingListLink = GetNextNode (PendingList, PendingListLink);
1935 }
1936
1937 return NULL;
1938}
1939
1954 IN EFI_HII_HANDLE *HiiHandle,
1955 IN LIST_ENTRY *PendingList
1956 )
1957{
1958 REDFISH_PLATFORM_CONFIG_PENDING_LIST *TargetPendingList;
1959
1960 if ((HiiHandle == NULL) || (PendingList == NULL)) {
1961 return EFI_INVALID_PARAMETER;
1962 }
1963
1964 //
1965 // Check and see if this HII handle is processed already.
1966 //
1967 TargetPendingList = GetPendingList (HiiHandle, PendingList);
1968 if (TargetPendingList != NULL) {
1969 TargetPendingList->IsDeleted = FALSE;
1970 DEBUG_CODE (
1971 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: HII handle: 0x%x is updated\n", __func__, HiiHandle));
1972 );
1973 return EFI_SUCCESS;
1974 }
1975
1976 TargetPendingList = AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_PENDING_LIST));
1977 if (TargetPendingList == NULL) {
1978 return EFI_OUT_OF_RESOURCES;
1979 }
1980
1981 TargetPendingList->HiiHandle = HiiHandle;
1982 TargetPendingList->IsDeleted = FALSE;
1983
1984 InsertTailList (PendingList, &TargetPendingList->Link);
1985
1986 DEBUG_CODE (
1987 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: HII handle: 0x%x is created\n", __func__, HiiHandle));
1988 );
1989
1990 return EFI_SUCCESS;
1991}
1992
2007 IN EFI_HII_HANDLE *HiiHandle,
2008 IN LIST_ENTRY *PendingList
2009 )
2010{
2011 REDFISH_PLATFORM_CONFIG_PENDING_LIST *TargetPendingList;
2012
2013 if ((HiiHandle == NULL) || (PendingList == NULL)) {
2014 return EFI_INVALID_PARAMETER;
2015 }
2016
2017 //
2018 // Check and see if this HII handle is processed already.
2019 //
2020 TargetPendingList = GetPendingList (HiiHandle, PendingList);
2021 if (TargetPendingList != NULL) {
2022 TargetPendingList->IsDeleted = TRUE;
2023 DEBUG_CODE (
2024 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: HII handle: 0x%x is updated and deleted\n", __func__, HiiHandle));
2025 );
2026 return EFI_SUCCESS;
2027 }
2028
2029 TargetPendingList = AllocateZeroPool (sizeof (REDFISH_PLATFORM_CONFIG_PENDING_LIST));
2030 if (TargetPendingList == NULL) {
2031 return EFI_OUT_OF_RESOURCES;
2032 }
2033
2034 TargetPendingList->HiiHandle = HiiHandle;
2035 TargetPendingList->IsDeleted = TRUE;
2036
2037 InsertTailList (PendingList, &TargetPendingList->Link);
2038
2039 DEBUG_CODE (
2040 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: HII handle: 0x%x is deleted\n", __func__, HiiHandle));
2041 );
2042
2043 return EFI_SUCCESS;
2044}
2045
2060 IN LIST_ENTRY *FormsetList,
2061 IN LIST_ENTRY *PendingList
2062 )
2063{
2064 LIST_ENTRY *PendingListLink;
2065 LIST_ENTRY *PendingListNextLink;
2068 EFI_STATUS Status;
2069
2070 if ((FormsetList == NULL) || (PendingList == NULL)) {
2071 return EFI_INVALID_PARAMETER;
2072 }
2073
2074 if (IsListEmpty (PendingList)) {
2075 return EFI_SUCCESS;
2076 }
2077
2078 PendingListLink = GetFirstNode (PendingList);
2079 while (!IsNull (PendingList, PendingListLink)) {
2080 PendingListNextLink = GetNextNode (PendingList, PendingListLink);
2081 Target = REDFISH_PLATFORM_CONFIG_PENDING_LIST_FROM_LINK (PendingListLink);
2082
2083 if (Target->IsDeleted) {
2084 //
2085 // The HII resource on this HII handle is removed. Release the formset.
2086 //
2087 FormsetPrivate = GetFormsetPrivateByHiiHandle (Target->HiiHandle, FormsetList);
2088 if (FormsetPrivate != NULL) {
2089 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: formset: %g is removed because driver release HII resource it already\n", __func__, FormsetPrivate->Guid));
2090 RemoveEntryList (&FormsetPrivate->Link);
2091 ReleaseFormset (FormsetPrivate);
2092 FreePool (FormsetPrivate);
2093 } else {
2094 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: formset on HII handle 0x%x was removed already\n", __func__, Target->HiiHandle));
2095 }
2096 } else {
2097 //
2098 // The HII resource on this HII handle is updated/removed.
2099 //
2100 FormsetPrivate = GetFormsetPrivateByHiiHandle (Target->HiiHandle, FormsetList);
2101 if (FormsetPrivate != NULL) {
2102 //
2103 // HII formset already exist, release it and query again.
2104 //
2105 DEBUG ((DEBUG_REDFISH_PLATFORM_CONFIG, "%a: formset: %g is updated. Release current formset\n", __func__, &FormsetPrivate->Guid));
2106 RemoveEntryList (&FormsetPrivate->Link);
2107 ReleaseFormset (FormsetPrivate);
2108 FreePool (FormsetPrivate);
2109 }
2110
2111 Status = LoadFormsetList (Target->HiiHandle, FormsetList);
2112 if (EFI_ERROR (Status)) {
2113 if (Status == EFI_UNSUPPORTED) {
2114 DEBUG ((DEBUG_ERROR, " The formset has no x-UEFI-redfish configurations.\n"));
2115 } else {
2116 DEBUG ((DEBUG_ERROR, " load formset from HII handle: 0x%x failed: %r\n", Target->HiiHandle, Status));
2117 }
2118 }
2119 }
2120
2121 //
2122 // Detach it from list first.
2123 //
2124 RemoveEntryList (&Target->Link);
2125 FreePool (Target);
2126
2127 PendingListLink = PendingListNextLink;
2128 }
2129
2130 return EFI_SUCCESS;
2131}
2132
2145 )
2146{
2148 LIST_ENTRY *NextLink;
2149
2150 if (StatementList == NULL) {
2151 return EFI_INVALID_PARAMETER;
2152 }
2153
2154 if (IsListEmpty (&StatementList->StatementList)) {
2155 return EFI_SUCCESS;
2156 }
2157
2158 NextLink = GetFirstNode (&StatementList->StatementList);
2159 while (!IsNull (&StatementList->StatementList, NextLink)) {
2160 StatementRef = REDFISH_PLATFORM_CONFIG_STATEMENT_REF_FROM_LINK (NextLink);
2161 NextLink = GetNextNode (&StatementList->StatementList, NextLink);
2162
2163 RemoveEntryList (&StatementRef->Link);
2164 FreePool (StatementRef);
2165 }
2166
2167 return EFI_SUCCESS;
2168}
UINT64 UINTN
INT64 INTN
INTN EFIAPI AsciiStriCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
Definition: String.c:814
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:443
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:333
BOOLEAN EFIAPI IsNodeAtEnd(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:481
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
Definition: String.c:641
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
Definition: LinkedList.c:298
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
Definition: String.c:716
INTN EFIAPI AsciiStrnCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString, IN UINTN Length)
Definition: String.c:872
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
Definition: String.c:681
CHAR8 *EFIAPI AsciiStrStr(IN CONST CHAR8 *String, IN CONST CHAR8 *SearchString)
Definition: String.c:931
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
CHAR16 *EFIAPI ConvertDevicePathToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EXPRESS_RESULT EvaluateExpressionList(IN FORM_EXPRESSION_LIST *ExpList, IN BOOLEAN Evaluate, IN FORM_BROWSER_FORMSET *FormSet OPTIONAL, IN FORM_BROWSER_FORM *Form OPTIONAL)
Definition: Expression.c:3732
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
Definition: HiiString.c:211
CHAR8 *EFIAPI HiiGetSupportedLanguages(IN EFI_HII_HANDLE HiiHandle)
Definition: HiiLanguage.c:31
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
Definition: HiiString.c:52
EFI_STATUS CreateFormSetFromHiiHandle(IN EFI_HII_HANDLE Handle, IN OUT EFI_GUID *FormSetGuid, OUT HII_FORMSET *FormSet)
Definition: HiiUtilityLib.c:30
VOID DestroyFormSet(IN OUT FORM_BROWSER_FORMSET *FormSet)
Definition: IfrParse.c:943
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define DEBUG_CODE(Expression)
Definition: DebugLib.h:590
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
#define DEBUG_REDFISH_PLATFORM_CONFIG
Debug error level for Redfish Platform Configure Driver.
BOOLEAN RedfishPlatformConfigDebugProp(IN UINT64 DebugType)
BOOLEAN RedfishPlatformConfigFeatureProp(IN UINT64 FeatureType)
CHAR8 * StrToAsciiStr(IN EFI_STRING UnicodeString)
REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE * GetStatementPrivateByConfigureLang(IN LIST_ENTRY *FormsetList, IN CHAR8 *Schema, IN EFI_STRING ConfigureLang)
EFI_STATUS ReleaseFormset(IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate)
EFI_STATUS NotifyFormsetUpdate(IN EFI_HII_HANDLE *HiiHandle, IN LIST_ENTRY *PendingList)
EFI_STATUS LoadFormsetList(IN EFI_HII_HANDLE *HiiHandle, OUT LIST_ENTRY *FormsetList)
BOOLEAN CheckSupportedSchema(IN REDFISH_PLATFORM_CONFIG_SCHEMA *SupportedSchema, IN CHAR8 *Schema)
EFI_STATUS ReleaseStatementList(IN REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList)
REDFISH_X_UEFI_STRING_DATABASE * GetExistOrCreateXuefiStringDatabase(IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader)
UINTN EFIAPI HiiStrSize(IN CONST CHAR16 *String)
EFI_STATUS ProcessPendingList(IN LIST_ENTRY *FormsetList, IN LIST_ENTRY *PendingList)
EFI_STATUS GetSupportedSchema(IN EFI_HII_HANDLE HiiHandle, OUT REDFISH_PLATFORM_CONFIG_SCHEMA *SupportedSchema)
EFI_STATUS DumpHiiString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId)
EFI_STATUS NotifyFormsetDeleted(IN EFI_HII_HANDLE *HiiHandle, IN LIST_ENTRY *PendingList)
EFI_STATUS GetXuefiStringAndLangByStringId(IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, IN EFI_STRING_ID StringId, OUT CHAR16 **String OPTIONAL, OUT CHAR8 **Language OPTIONAL, OUT REDFISH_X_UEFI_STRING_DATABASE **XuefiStringDatabase OPTIONAL)
EFI_STATUS GetStatementPrivateByConfigureLangRegex(IN EFI_REGULAR_EXPRESSION_PROTOCOL *RegularExpressionProtocol, IN LIST_ENTRY *FormsetList, IN CHAR8 *Schema, IN EFI_STRING Pattern, OUT REDFISH_PLATFORM_CONFIG_STATEMENT_PRIVATE_LIST *StatementList)
REDFISH_PLATFORM_CONFIG_PENDING_LIST * GetPendingList(IN EFI_HII_HANDLE *HiiHandle, IN LIST_ENTRY *PendingList)
EFI_STATUS DumpFormset(IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate)
EFI_STATUS RedfishXuefiStringInsertDatabase(IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader, IN EFI_STRING_ID StringId, IN CHAR16 *StringTextPtr)
EFI_STATUS NewRedfishXuefiStringArray(IN REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase)
EFI_STATUS ReleaseXuefiStringDatabase(IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate)
INTN EFIAPI HiiStrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE * NewFormsetPrivate(VOID)
EFI_STATUS RedfishXuefiStringAdjustArrays(IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, IN REDFISH_X_UEFI_STRING_DATABASE *XuefiRedfishStringDatabase, IN EFI_STRING_ID StringId)
CHAR8 * HiiGetEnglishAsciiString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId)
VOID BuildXUefiRedfishStringDatabase(IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate)
EFI_STRING HiiGetRedfishString(IN EFI_HII_HANDLE HiiHandle, IN CHAR8 *Language, IN EFI_STRING_ID StringId)
UINTN EFIAPI HiiStrLen(IN CONST CHAR16 *String)
EFI_STATUS HiiDeleteString(IN EFI_STRING_ID StringId, IN EFI_HII_HANDLE HiiHandle)
REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE * GetFormsetPrivateByHiiHandle(IN EFI_HII_HANDLE HiiHandle, IN LIST_ENTRY *FormsetList)
EFI_STATUS DumpFormsetList(IN LIST_ENTRY *FormsetList)
CHAR8 * HiiGetRedfishAsciiString(IN EFI_HII_HANDLE HiiHandle, IN CHAR8 *Language, IN EFI_STRING_ID StringId)
EFI_STATUS ReleaseFormsetList(IN LIST_ENTRY *FormsetList)
BOOLEAN CreateXuefiLanguageStringIdMap(IN REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate, IN EFI_HII_STRING_PACKAGE_HDR *HiiStringPackageHeader, OUT UINTN *TotalStringAdded)
EFI_STATUS LoadFormset(IN EFI_HII_HANDLE HiiHandle, OUT REDFISH_PLATFORM_CONFIG_FORM_SET_PRIVATE *FormsetPrivate)
EFI_STATUS InitializeFormSet(IN EFI_HII_HANDLE Handle, IN OUT EFI_GUID *FormSetGuid, OUT FORM_BROWSER_FORMSET *FormSet)
Definition: Setup.c:6011
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
VOID * EFI_HII_HANDLE
EFI_STRING_ID Prompt
UINT8 QuestionFlags
The flag of this Question.(Readonly, reset required, callback attribute....)
HII_EXPRESSION_LIST * ExpressionList
nesting inside of GrayedOutIf/DisableIf/SuppressIf
EFI_QUESTION_ID QuestionId
Question id, the value of zero is reserved.
Definition: Base.h:213
LIST_ENTRY StatementListHead
List of Statements and Questions (HII_STATEMENT)
EFI_STRING_ID FormTitle
FormTile of normal form, or FormMapMethod title of formmap form.
HII_EXPRESSION_LIST * SuppressExpression
nesting inside of SuppressIf
UINT16 FormId
FormId of normal form or formmap form.
EFI_HII_HANDLE HiiHandle
Unique id for formset, HII Handle of this FormSet package.
LIST_ENTRY FormListHead
Form list (HII_FORM_BROWSER_FORM)
EFI_GUID Guid
Formset Guid.
EFI_HII_DATABASE_PROTOCOL * HiiDatabase
The HII database protocol.
EFI_HII_STRING_PROTOCOL * HiiString
HII String Protocol.
UINT64 Maximum
for EFI_IFR_STRING/EFI_IFR_PASSWORD, it's Min/Max length
UINT64 Minimum
for EFI_IFR_ONE_OF/EFI_IFR_NUMERIC, it's Min/Max value