MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / AddUnicodeString

Function AddUnicodeString

MdePkg/Library/UefiLib/UefiLib.c:911–1043  ·  view source on GitHub ↗

This function adds a Unicode string to UnicodeStringTable. If Language is a member of SupportedLanguages then UnicodeString is added to UnicodeStringTable. New buffers are allocated for both Language and UnicodeString. The contents of Language and UnicodeString are copied into these new buffers. These buffers are automatically freed when FreeUnicodeStringTable() is called.

Source from the content-addressed store, hash-verified

909
910**/
911EFI_STATUS
912EFIAPI
913AddUnicodeString (
914 IN CONST CHAR8 *Language,
915 IN CONST CHAR8 *SupportedLanguages,
916 IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable,
917 IN CONST CHAR16 *UnicodeString
918 )
919{
920 UINTN NumberOfEntries;
921 EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable;
922 EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable;
923 UINTN UnicodeStringLength;
924
925 //
926 // Make sure the parameter are valid
927 //
928 if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {
929 return EFI_INVALID_PARAMETER;
930 }
931
932 //
933 // If there are no supported languages, then a Unicode String can not be added
934 //
935 if (SupportedLanguages == NULL) {
936 return EFI_UNSUPPORTED;
937 }
938
939 //
940 // If the Unicode String is empty, then a Unicode String can not be added
941 //
942 if (UnicodeString[0] == 0) {
943 return EFI_INVALID_PARAMETER;
944 }
945
946 //
947 // Make sure Language is a member of SupportedLanguages
948 //
949 while (*SupportedLanguages != 0) {
950 if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
951
952 //
953 // Determine the size of the Unicode String Table by looking for a NULL Language entry
954 //
955 NumberOfEntries = 0;
956 if (*UnicodeStringTable != NULL) {
957 OldUnicodeStringTable = *UnicodeStringTable;
958 while (OldUnicodeStringTable->Language != NULL) {
959 if (CompareIso639LanguageCode (Language, OldUnicodeStringTable->Language)) {
960 return EFI_ALREADY_STARTED;
961 }
962
963 OldUnicodeStringTable++;
964 NumberOfEntries++;
965 }
966 }
967
968 //

Callers

nothing calls this directly

Calls 5

AllocateCopyPoolFunction · 0.85
AllocatePoolFunction · 0.50
CopyMemFunction · 0.50
FreePoolFunction · 0.50

Tested by

no test coverage detected