}\r
\r
/**\r
- This function looks up a Unicode string in UnicodeStringTable. If Language is\r
- a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable\r
- that matches the language code specified by Language, then it is returned in\r
+ This function looks up a Unicode string in UnicodeStringTable.\r
+ If Language is a member of SupportedLanguages and a Unicode\r
+ string is found in UnicodeStringTable that matches the\r
+ language code specified by Language, then it is returned in\r
UnicodeString.\r
\r
- @param Language A pointer to the ISO 639-2 language code for the\r
- Unicode string to look up and return.\r
- @param SupportedLanguages A pointer to the set of ISO 639-2 language codes\r
- that the Unicode string table supports. Language\r
- must be a member of this set.\r
- @param UnicodeStringTable A pointer to the table of Unicode strings.\r
- @param UnicodeString A pointer to the Unicode string from UnicodeStringTable\r
- that matches the language specified by Language.\r
-\r
- @retval EFI_SUCCESS The Unicode string that matches the language\r
- specified by Language was found\r
- in the table of Unicoide strings UnicodeStringTable,\r
- and it was returned in UnicodeString.\r
+ @param Language A pointer to the ISO 639-2\r
+ language code for the Unicode\r
+ string to look up and return.\r
+ \r
+ @param SupportedLanguages A pointer to the set of ISO\r
+ 639-2language\r
+ codes that the Unicode string\r
+ table supports. Language must\r
+ be a member of this set.\r
+ \r
+ @param UnicodeStringTable A pointer to the table of\r
+ Unicode strings.\r
+ \r
+ @param UnicodeString A pointer to the Unicode\r
+ string from UnicodeStringTable\r
+ that matches the language\r
+ specified by Language.\r
+\r
+ @retval EFI_SUCCESS The Unicode string that\r
+ matches the language specified\r
+ by Language was found in the\r
+ table of Unicoide strings\r
+ UnicodeStringTable, and it was\r
+ returned in UnicodeString.\r
+ \r
@retval EFI_INVALID_PARAMETER Language is NULL.\r
+ \r
@retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
@retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
+ \r
@retval EFI_UNSUPPORTED UnicodeStringTable is NULL.\r
- @retval EFI_UNSUPPORTED The language specified by Language is not a\r
- member of SupportedLanguages.\r
- @retval EFI_UNSUPPORTED The language specified by Language is not\r
- supported by UnicodeStringTable.\r
+ \r
+ @retval EFI_UNSUPPORTED The language specified by\r
+ Language is not a member\r
+ ofSupportedLanguages.\r
+ \r
+ @retval EFI_UNSUPPORTED The language specified by\r
+ Language is not supported by\r
+ UnicodeStringTable.\r
\r
**/\r
EFI_STATUS\r
return EFI_UNSUPPORTED;\r
}\r
\r
+\r
+\r
/**\r
+ This function looks up a Unicode string in UnicodeStringTable.\r
+ If Language is a member of SupportedLanguages and a Unicode\r
+ string is found in UnicodeStringTable that matches the\r
+ language code specified by Language, then it is returned in\r
+ UnicodeString.\r
+\r
+ @param Language A pointer to the ISO 639-2 or\r
+ RFC 3066 language code for the\r
+ Unicode string to look up and\r
+ return.\r
+ \r
+ @param SupportedLanguages A pointer to the set of ISO\r
+ 639-2 or RFC 3066 language\r
+ codes that the Unicode string\r
+ table supports. Language must\r
+ be a member of this set.\r
+ \r
+ @param UnicodeStringTable A pointer to the table of\r
+ Unicode strings.\r
+ \r
+ @param UnicodeString A pointer to the Unicode\r
+ string from UnicodeStringTable\r
+ that matches the language\r
+ specified by Language.\r
+\r
+ @param Iso639Language Specify the language code\r
+ format supported. If true,\r
+ then the format follow ISO\r
+ 639-2. If false, then it\r
+ follows RFC3066.\r
+\r
+ @retval EFI_SUCCESS The Unicode string that\r
+ matches the language specified\r
+ by Language was found in the\r
+ table of Unicoide strings\r
+ UnicodeStringTable, and it was\r
+ returned in UnicodeString.\r
+ \r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+ \r
+ @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
+ \r
+ @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
+ \r
+ @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.\r
+ \r
+ @retval EFI_UNSUPPORTED The language specified by\r
+ Language is not a member\r
+ ofSupportedLanguages.\r
+ \r
+ @retval EFI_UNSUPPORTED The language specified by\r
+ Language is not supported by\r
+ UnicodeStringTable.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LookupUnicodeString2 (\r
+ IN CONST CHAR8 *Language,\r
+ IN CONST CHAR8 *SupportedLanguages,\r
+ IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,\r
+ OUT CHAR16 **UnicodeString,\r
+ IN BOOLEAN Iso639Language\r
+ )\r
+{\r
+ BOOLEAN Found;\r
+ UINTN Index;\r
+ CHAR8 *LanguageString;\r
+\r
+ //\r
+ // Make sure the parameters are valid\r
+ //\r
+ if (Language == NULL || UnicodeString == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // If there are no supported languages, or the Unicode String Table is empty, then the\r
+ // Unicode String specified by Language is not supported by this Unicode String Table\r
+ //\r
+ if (SupportedLanguages == NULL || UnicodeStringTable == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Make sure Language is in the set of Supported Languages\r
+ //\r
+ Found = FALSE;\r
+ while (*SupportedLanguages != 0) {\r
+ if (Iso639Language) {\r
+ if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
+ Found = TRUE;\r
+ break;\r
+ }\r
+ SupportedLanguages += 3;\r
+ } else {\r
+ for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
+ if (AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) {\r
+ Found = TRUE;\r
+ break;\r
+ }\r
+ SupportedLanguages += Index;\r
+ for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
+ }\r
+ }\r
+\r
+ //\r
+ // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED\r
+ //\r
+ if (!Found) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Search the Unicode String Table for the matching Language specifier\r
+ //\r
+ while (UnicodeStringTable->Language != NULL) {\r
+ LanguageString = UnicodeStringTable->Language;\r
+ while (0 != *LanguageString) {\r
+ for (Index = 0 ;LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++);\r
+ if (AsciiStrnCmp(LanguageString, Language, Index) == 0) {\r
+ *UnicodeString = UnicodeStringTable->UnicodeString;\r
+ return EFI_SUCCESS;\r
+ }\r
+ LanguageString += Index;\r
+ for (Index = 0 ;LanguageString[Index] != 0 && LanguageString[Index] == ';'; Index++);\r
+ }\r
+ UnicodeStringTable++;\r
+ }\r
+\r
+ return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+/**\r
+ \r
This function adds a Unicode string to UnicodeStringTable.\r
- If Language is a member of SupportedLanguages then UnicodeString is added to\r
- UnicodeStringTable. New buffers are allocated for both Language and\r
- UnicodeString. The contents of Language and UnicodeString are copied into\r
- these new buffers. These buffers are automatically freed when\r
+ If Language is a member of SupportedLanguages then\r
+ UnicodeString is added to UnicodeStringTable. New buffers are\r
+ allocated for both Language and UnicodeString. The contents\r
+ of Language and UnicodeString are copied into these new\r
+ buffers. These buffers are automatically freed when\r
FreeUnicodeStringTable() is called.\r
\r
- @param Language A pointer to the ISO 639-2 language code for the Unicode\r
+ @param Language A pointer to the ISO 639-2\r
+ language code for the Unicode\r
string to add.\r
- @param SupportedLanguages A pointer to the set of ISO 639-2 language codes\r
- that the Unicode string table supports.\r
- Language must be a member of this set.\r
- @param UnicodeStringTable A pointer to the table of Unicode strings.\r
- @param UnicodeString A pointer to the Unicode string to add.\r
-\r
- @retval EFI_SUCCESS The Unicode string that matches the language\r
- specified by Language was found in the table of\r
- Unicode strings UnicodeStringTable, and it was\r
+ \r
+ @param SupportedLanguages A pointer to the set of ISO\r
+ 639-2 language codes that the\r
+ Unicode string table supports.\r
+ Language must be a member of\r
+ this set.\r
+ \r
+ @param UnicodeStringTable A pointer to the table of\r
+ Unicode strings.\r
+ \r
+ @param UnicodeString A pointer to the Unicode\r
+ string to add.\r
+\r
+ @retval EFI_SUCCESS The Unicode string that\r
+ matches the language specified\r
+ by Language was found in the\r
+ table of Unicode strings\r
+ UnicodeStringTable, and it was\r
returned in UnicodeString.\r
+ \r
@retval EFI_INVALID_PARAMETER Language is NULL.\r
+ \r
@retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
+ \r
@retval EFI_INVALID_PARAMETER UnicodeString is an empty string.\r
+ \r
@retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
- @retval EFI_ALREADY_STARTED A Unicode string with language Language is\r
- already present in UnicodeStringTable.\r
- @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another\r
- Unicode string to UnicodeStringTable.\r
- @retval EFI_UNSUPPORTED The language specified by Language is not a\r
- member of SupportedLanguages.\r
+ \r
+ @retval EFI_ALREADY_STARTED A Unicode string with language\r
+ Language is already present in\r
+ UnicodeStringTable.\r
+ \r
+ @retval EFI_OUT_OF_RESOURCES There is not enough memory to\r
+ add another Unicode string to\r
+ UnicodeStringTable.\r
+ \r
+ @retval EFI_UNSUPPORTED The language specified by\r
+ Language is not a member of\r
+ SupportedLanguages.\r
\r
**/\r
EFI_STATUS\r
return EFI_UNSUPPORTED;\r
}\r
\r
+\r
+/**\r
+ \r
+ This function adds a Unicode string to UnicodeStringTable.\r
+ If Language is a member of SupportedLanguages then\r
+ UnicodeString is added to UnicodeStringTable. New buffers are\r
+ allocated for both Language and UnicodeString. The contents\r
+ of Language and UnicodeString are copied into these new\r
+ buffers. These buffers are automatically freed when\r
+ FreeUnicodeStringTable() is called.\r
+\r
+ @param Language A pointer to the ISO 639-2 or\r
+ RFC 3066 language code for the\r
+ Unicode string to add.\r
+ \r
+ @param SupportedLanguages A pointer to the set of ISO\r
+ 639-2 or RFC 3.66 language\r
+ codes that the Unicode string\r
+ table supports. Language must\r
+ be a member of this set.\r
+ \r
+ @param UnicodeStringTable A pointer to the table of\r
+ Unicode strings.\r
+ \r
+ @param UnicodeString A pointer to the Unicode\r
+ string to add.\r
+ \r
+ @param Iso639Language Specify the language code\r
+ format supported. If true,\r
+ then the format follow ISO\r
+ 639-2. If false, then it\r
+ follows RFC3066.\r
+\r
+ @retval EFI_SUCCESS The Unicode string that\r
+ matches the language specified\r
+ by Language was found in the\r
+ table of Unicode strings\r
+ UnicodeStringTable, and it was\r
+ returned in UnicodeString.\r
+ \r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+ \r
+ @retval EFI_INVALID_PARAMETER UnicodeString is NULL.\r
+ \r
+ @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.\r
+ \r
+ @retval EFI_UNSUPPORTED SupportedLanguages is NULL.\r
+ \r
+ @retval EFI_ALREADY_STARTED A Unicode string with language\r
+ Language is already present in\r
+ UnicodeStringTable.\r
+ \r
+ @retval EFI_OUT_OF_RESOURCES There is not enough memory to\r
+ add another Unicode string to\r
+ UnicodeStringTable.\r
+ \r
+ @retval EFI_UNSUPPORTED The language specified by\r
+ Language is not a member of\r
+ SupportedLanguages.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+AddUnicodeString2 (\r
+ IN CONST CHAR8 *Language,\r
+ IN CONST CHAR8 *SupportedLanguages,\r
+ IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable,\r
+ IN CONST CHAR16 *UnicodeString,\r
+ IN BOOLEAN Iso639Language\r
+ )\r
+{\r
+ UINTN NumberOfEntries;\r
+ EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable;\r
+ EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable;\r
+ UINTN UnicodeStringLength;\r
+ BOOLEAN Found;\r
+ UINTN Index;\r
+ CHAR8 *LanguageString;\r
+\r
+ //\r
+ // Make sure the parameter are valid\r
+ //\r
+ if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // If there are no supported languages, then a Unicode String can not be added\r
+ //\r
+ if (SupportedLanguages == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // If the Unicode String is empty, then a Unicode String can not be added\r
+ //\r
+ if (UnicodeString[0] == 0) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Make sure Language is a member of SupportedLanguages\r
+ //\r
+ Found = FALSE;\r
+ while (*SupportedLanguages != 0) {\r
+ if (Iso639Language) {\r
+ if (CompareIso639LanguageCode (Language, SupportedLanguages)) {\r
+ Found = TRUE;\r
+ break;\r
+ }\r
+ SupportedLanguages += 3;\r
+ } else {\r
+ for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);\r
+ if (AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) {\r
+ Found = TRUE;\r
+ break;\r
+ }\r
+ SupportedLanguages += Index;\r
+ for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);\r
+ }\r
+ }\r
+\r
+ //\r
+ // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED\r
+ //\r
+ if (!Found) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Determine the size of the Unicode String Table by looking for a NULL Language entry\r
+ //\r
+ NumberOfEntries = 0;\r
+ if (*UnicodeStringTable != NULL) {\r
+ OldUnicodeStringTable = *UnicodeStringTable;\r
+ while (OldUnicodeStringTable->Language != NULL) {\r
+ LanguageString = OldUnicodeStringTable->Language;\r
+\r
+ while (*LanguageString) {\r
+ for (Index = 0; LanguageString[Index] != 0 && LanguageString[Index] != ';'; Index++);\r
+\r
+ if (AsciiStrnCmp (Language, LanguageString, Index) == 0) { \r
+ return EFI_ALREADY_STARTED;\r
+ }\r
+ LanguageString += Index;\r
+ for (; *LanguageString != 0 && *LanguageString == ';'; LanguageString++);\r
+ }\r
+ OldUnicodeStringTable++;\r
+ NumberOfEntries++;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Allocate space for a new Unicode String Table. It must hold the current number of\r
+ // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table\r
+ // marker\r
+ //\r
+ NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE));\r
+ if (NewUnicodeStringTable == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ //\r
+ // If the current Unicode String Table contains any entries, then copy them to the\r
+ // newly allocated Unicode String Table.\r
+ //\r
+ if (*UnicodeStringTable != NULL) {\r
+ CopyMem (\r
+ NewUnicodeStringTable,\r
+ *UnicodeStringTable,\r
+ NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE)\r
+ );\r
+ }\r
+\r
+ //\r
+ // Allocate space for a copy of the Language specifier\r
+ //\r
+ NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize(Language), Language);\r
+ if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {\r
+ gBS->FreePool (NewUnicodeStringTable);\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ //\r
+ // Compute the length of the Unicode String\r
+ //\r
+ for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++);\r
+\r
+ //\r
+ // Allocate space for a copy of the Unicode String\r
+ //\r
+ NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool (StrSize (UnicodeString), UnicodeString);\r
+ if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) {\r
+ gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language);\r
+ gBS->FreePool (NewUnicodeStringTable);\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ //\r
+ // Mark the end of the Unicode String Table\r
+ //\r
+ NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL;\r
+ NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL;\r
+\r
+ //\r
+ // Free the old Unicode String Table\r
+ //\r
+ if (*UnicodeStringTable != NULL) {\r
+ gBS->FreePool (*UnicodeStringTable);\r
+ }\r
+\r
+ //\r
+ // Point UnicodeStringTable at the newly allocated Unicode String Table\r
+ //\r
+ *UnicodeStringTable = NewUnicodeStringTable;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
/**\r
This function frees the table of Unicode strings in UnicodeStringTable.\r
If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.\r
- Otherwise, each language code, and each Unicode string in the Unicode string\r
+ Otherwise, each language code, and each Unicode string in the Unicode string \r
table are freed, and EFI_SUCCESS is returned.\r
\r
@param UnicodeStringTable A pointer to the table of Unicode strings.\r
return EFI_SUCCESS;\r
}\r
\r
-/**\r
- Intialize a driver by installing the Driver Binding Protocol onto the\r
- driver's DriverBindingHandle. This is typically the same as the driver's\r
- ImageHandle, but it can be different if the driver produces multiple\r
- DriverBinding Protocols. This function also initializes the EFI Driver\r
- Library that initializes the global variables gST, gBS, gRT.\r
-\r
- @param ImageHandle The image handle of the driver\r
- @param SystemTable The EFI System Table that was passed to the driver's entry point\r
- @param DriverBinding A Driver Binding Protocol instance that this driver is producing\r
- @param DriverBindingHandle The handle that DriverBinding is to be installe onto. If this\r
- parameter is NULL, then a new handle is created.\r
-\r
- @retval EFI_SUCCESS DriverBinding is installed onto DriverBindingHandle\r
- @retval Other Status from gBS->InstallProtocolInterface()\r
-\r
-**/\r
-EFI_STATUS\r
-EfiLibInstallDriverBinding (\r
- IN const EFI_HANDLE ImageHandle,\r
- IN const EFI_SYSTEM_TABLE *SystemTable,\r
- IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
- IN EFI_HANDLE DriverBindingHandle\r
- )\r
-{\r
- //\r
- // bugbug:Need to implement ...\r
- //\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Intialize a driver by installing the Driver Binding Protocol onto the\r
- driver's DriverBindingHandle. This is typically the same as the driver's\r
- ImageHandle, but it can be different if the driver produces multiple\r
- DriverBinding Protocols. This function also initializes the EFI Driver\r
- Library that initializes the global variables gST, gBS, gRT.\r
-\r
- @ImageHandle The image handle of the driver\r
- @SystemTable The EFI System Table that was passed to the driver's entry point\r
- @DriverBinding A Driver Binding Protocol instance that this driver is producing\r
- @DriverBindingHandle The handle that DriverBinding is to be installe onto. If this\r
- parameter is NULL, then a new handle is created.\r
- @ComponentName A Component Name Protocol instance that this driver is producing\r
- @DriverConfiguration A Driver Configuration Protocol instance that this driver is producing\r
- @DriverDiagnostics A Driver Diagnostics Protocol instance that this driver is producing\r
-\r
- @retval EFI_SUCCESS DriverBinding is installed onto DriverBindingHandle\r
- @retval Other Status from gBS->InstallProtocolInterface()\r
-\r
-**/\r
-EFI_STATUS\r
-EfiLibInstallAllDriverProtocols (\r
- IN const EFI_HANDLE ImageHandle,\r
- IN const EFI_SYSTEM_TABLE *SystemTable,\r
- IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,\r
- IN EFI_HANDLE DriverBindingHandle,\r
- IN const EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL\r
- IN const EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL\r
- IN const EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL\r
- )\r
-{\r
- //\r
- // bugbug:Need to implement ...\r
- //\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r