]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/HiiLib.h
add in a new API HiiLibGetSupportedSecondaryLanguages
[mirror_edk2.git] / MdePkg / Include / Library / HiiLib.h
CommitLineData
fb3df220 1/** @file\r
2 Public include file for the HII Library\r
3\r
e52c5a9f 4 Copyright (c) 2007 - 2008, Intel Corporation \r
fb3df220 5 All rights reserved. This program and the accompanying materials \r
6 are licensed and made available under the terms and conditions of the BSD License \r
7 which accompanies this distribution. The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php \r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
fb3df220 13**/\r
14\r
15#ifndef __HII_LIB_H__\r
16#define __HII_LIB_H__\r
17\r
7d582d6b 18//\r
19// Limited buffer size recommended by RFC4646 (4.3. Length Considerations)\r
20// (42 characters plus a NULL terminator)\r
21//\r
22#define RFC_3066_ENTRY_SIZE (42 + 1)\r
fb3df220 23\r
e52c5a9f 24#define ISO_639_2_ENTRY_SIZE 3\r
25\r
26/**\r
27 Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.\r
28\r
29 If GuidId is NULL, then ASSERT.\r
30 If not enough resource to complete the operation, then ASSERT.\r
31\r
32 @param NumberOfPackages Number of packages.\r
33 @param GuidId Package GUID.\r
34 @param ... Variable argument list for packages to be assembled.\r
35\r
36 @return EFI_HII_PACKAGE_LIST_HEADER Pointer of EFI_HII_PACKAGE_LIST_HEADER. The function will ASSERT if system has\r
37 not enough resource to complete the operation.\r
38\r
39**/\r
40EFI_HII_PACKAGE_LIST_HEADER *\r
41EFIAPI\r
42HiiLibPreparePackageList (\r
43 IN UINTN NumberOfPackages,\r
44 IN CONST EFI_GUID *GuidId,\r
45 ...\r
46 )\r
47;\r
48\r
fb3df220 49/**\r
7d582d6b 50 This function allocates pool for an EFI_HII_PACKAGE_LIST structure\r
51 with additional space that is big enough to host all packages described by the variable \r
52 argument list of package pointers. The allocated structure is initialized using NumberOfPackages, \r
53 GuidId, and the variable length argument list of package pointers.\r
fb3df220 54\r
7d582d6b 55 Then, EFI_HII_PACKAGE_LIST will be register to the default System HII Database. The\r
56 Handle to the newly registered Package List is returned throught HiiHandle.\r
57\r
e52c5a9f 58 If HiiHandle is NULL, then ASSERT.\r
59\r
7d582d6b 60 @param NumberOfPackages The number of HII packages to register.\r
61 @param GuidId Package List GUID ID.\r
e52c5a9f 62 @param EFI_HANDLE Optional. If not NULL, the DriverHandle on which an instance of DEVICE_PATH_PROTOCOL is installed.\r
63 This DriverHandle uniquely defines the device that the added packages are associated with.\r
64 @param HiiHandle On output, the HiiHandle is update with the handle which can be used to retrieve the Package \r
65 List later. If the functions failed to add the package to the default HII database, this value will\r
66 be set to NULL.\r
7d582d6b 67 @param ... The variable argument list describing all HII Package.\r
fb3df220 68\r
e52c5a9f 69 @return EFI_SUCCESS If the packages are successfully added to the default HII database.\r
70 @return EFI_OUT_OF_RESOURCE Not enough resource to complete the operation.\r
fb3df220 71\r
72**/\r
7d582d6b 73EFI_STATUS\r
fb3df220 74EFIAPI\r
e52c5a9f 75HiiLibAddPackages (\r
7d582d6b 76 IN UINTN NumberOfPackages,\r
77 IN CONST EFI_GUID *GuidId,\r
78 IN EFI_HANDLE DriverHandle, OPTIONAL\r
e52c5a9f 79 OUT EFI_HII_HANDLE *HiiHandle,\r
fb3df220 80 ...\r
7d582d6b 81 )\r
82;\r
83\r
e52c5a9f 84/**\r
85 Removes a package list from the default HII database.\r
86\r
87 If HiiHandle is NULL, then ASSERT.\r
88 If HiiHandle is not a valid EFI_HII_HANDLE in the default HII database, then ASSERT.\r
89\r
90 @param HiiHandle The handle that was previously registered to the data base that is requested for removal.\r
91 List later.\r
92\r
93 @return VOID\r
94\r
95**/\r
96VOID\r
7d582d6b 97EFIAPI\r
e52c5a9f 98HiiLibRemovePackages (\r
7d582d6b 99 IN EFI_HII_HANDLE HiiHandle\r
100 )\r
101;\r
102\r
103/**\r
e52c5a9f 104 This function adds the string into String Package of each language\r
105 supported by the package list.\r
106\r
107 If String is NULL, then ASSERT.\r
108 If StringId is NULL, the ASSERT.\r
109 If PackageList could not be found in the default HII database, then ASSERT.\r
7d582d6b 110\r
111 @param PackageList Handle of the package list where this string will\r
e52c5a9f 112 be added.\r
7d582d6b 113 @param StringId On return, contains the new strings id, which is\r
e52c5a9f 114 unique within PackageList.\r
7d582d6b 115 @param String Points to the new null-terminated string.\r
116\r
e52c5a9f 117 @retval EFI_SUCCESS The new string was added successfully.\r
7d582d6b 118 @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.\r
7d582d6b 119\r
120**/\r
121EFI_STATUS\r
122EFIAPI\r
e52c5a9f 123HiiLibNewString (\r
7d582d6b 124 IN EFI_HII_HANDLE PackageList,\r
125 OUT EFI_STRING_ID *StringId,\r
126 IN CONST EFI_STRING String\r
127 )\r
128;\r
129\r
130/**\r
e52c5a9f 131 This function update the specified string in String Package of each language\r
132 supported by the package list.\r
133\r
134 If String is NULL, then ASSERT.\r
135 If PackageList could not be found in the default HII database, then ASSERT.\r
136 If StringId is not found in PackageList, then ASSERT.\r
7d582d6b 137\r
138 @param PackageList Handle of the package list where this string will\r
e52c5a9f 139 be added.\r
7d582d6b 140 @param StringId Ths String Id to be updated.\r
141 @param String Points to the new null-terminated string.\r
142\r
143 @retval EFI_SUCCESS The new string was added successfully.\r
7d582d6b 144 @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.\r
7d582d6b 145\r
146**/\r
147EFI_STATUS\r
148EFIAPI\r
e52c5a9f 149HiiLibSetString (\r
7d582d6b 150 IN EFI_HII_HANDLE PackageList,\r
151 IN EFI_STRING_ID StringId,\r
152 IN CONST EFI_STRING String\r
153 )\r
154;\r
155\r
e52c5a9f 156/**\r
157 This function try to retrieve string from String package of current language.\r
158 If fails, it try to retrieve string from String package of first language it support.\r
159\r
160 If String is NULL, then ASSERT.\r
161 If StringSize is NULL, then ASSERT.\r
162 If PackageList could not be found in the default HII database, then ASSERT.\r
163 If StringId is not found in PackageList, then ASSERT.\r
164\r
165 @param PackageList The package list in the HII database to search for\r
166 the specified string.\r
167 @param StringId The string's id, which is unique within\r
168 PackageList.\r
169 @param String Points to the new null-terminated string.\r
170 @param StringSize On entry, points to the size of the buffer pointed\r
171 to by String, in bytes. On return, points to the\r
172 length of the string, in bytes.\r
173\r
174 @retval EFI_SUCCESS The string was returned successfully.\r
175 @retval EFI_NOT_FOUND The string specified by StringId is not available.\r
176 @retval EFI_BUFFER_TOO_SMALL The buffer specified by StringLength is too small\r
177 to hold the string.\r
178 @retval EFI_INVALID_PARAMETER The String or StringSize was NULL.\r
7d582d6b 179\r
e52c5a9f 180**/\r
7d582d6b 181\r
7d582d6b 182EFI_STATUS\r
183EFIAPI\r
e52c5a9f 184HiiLibGetString (\r
185 IN EFI_HII_HANDLE PackageList,\r
186 IN EFI_STRING_ID StringId,\r
187 OUT EFI_STRING String,\r
188 IN OUT UINTN *StringSize\r
189 )\r
190;\r
191\r
192/**\r
193 Get string specified by StringId form the HiiHandle. The caller\r
194 is responsible to free the *String.\r
195\r
196 If String is NULL, then ASSERT.\r
197 If HiiHandle could not be found in the default HII database, then ASSERT.\r
198 If StringId is not found in PackageList, then ASSERT.\r
199\r
200 @param HiiHandle The HII handle of package list.\r
201 @param StringId The String ID.\r
202 @param String The output string.\r
203\r
204 @retval EFI_NOT_FOUND String is not found.\r
205 @retval EFI_SUCCESS Operation is successful.\r
206 @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.\r
207 @retval EFI_INVALID_PARAMETER The String is NULL.\r
208\r
209**/\r
210EFI_STATUS\r
211EFIAPI\r
212HiiLibGetStringFromHandle (\r
213 IN EFI_HII_HANDLE HiiHandle,\r
7d582d6b 214 IN EFI_STRING_ID StringId,\r
215 OUT EFI_STRING *String\r
216 )\r
217;\r
218\r
e52c5a9f 219/**\r
220 Get the string given the StringId and String package Producer's Guid. The caller\r
221 is responsible to free the *String.\r
222\r
223 If PackageList with the matching ProducerGuid is not found, then ASSERT.\r
224 If PackageList with the matching ProducerGuid is found but no String is\r
225 specified by StringId is found, then ASSERT.\r
226\r
227 @param ProducerGuid The Guid of String package list.\r
228 @param StringId The String ID.\r
229 @param String The output string.\r
230\r
231 @retval EFI_SUCCESS Operation is successful.\r
232 @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.\r
233\r
234**/\r
7d582d6b 235EFI_STATUS\r
236EFIAPI\r
e52c5a9f 237HiiLibGetStringFromToken (\r
238 IN EFI_GUID *ProducerGuid,\r
239 IN EFI_STRING_ID StringId,\r
240 OUT EFI_STRING *String\r
7d582d6b 241 )\r
242;\r
243\r
e52c5a9f 244/**\r
245 Determines the handles that are currently active in the database.\r
246 It's the caller's responsibility to free handle buffer.\r
247\r
248 If HandleBufferLength is NULL, then ASSERT.\r
249 If HiiHandleBuffer is NULL, then ASSERT.\r
250\r
251 @param HiiDatabase A pointer to the EFI_HII_DATABASE_PROTOCOL\r
252 instance.\r
253 @param HandleBufferLength On input, a pointer to the length of the handle\r
254 buffer. On output, the length of the handle buffer\r
255 that is required for the handles found.\r
256 @param HiiHandleBuffer Pointer to an array of Hii Handles returned.\r
257\r
258 @retval EFI_SUCCESS Get an array of Hii Handles successfully.\r
259\r
260**/\r
7d582d6b 261EFI_STATUS\r
262EFIAPI\r
e52c5a9f 263HiiLibGetHiiHandles (\r
264 IN OUT UINTN *HandleBufferLength,\r
265 OUT EFI_HII_HANDLE **HiiHandleBuffer\r
7d582d6b 266 )\r
267;\r
268\r
e52c5a9f 269/**\r
270 Extract Hii package list GUID for given HII handle.\r
271\r
272 If HiiHandle could not be found in the default HII database, then ASSERT.\r
273 If Guid is NULL, then ASSERT.\r
274\r
275 @param HiiHandle Hii handle\r
276 @param Guid Package list GUID\r
7d582d6b 277\r
e52c5a9f 278 @retval EFI_SUCCESS Successfully extract GUID from Hii database.\r
279\r
280**/\r
7d582d6b 281EFI_STATUS\r
e52c5a9f 282EFIAPI\r
283HiiLibExtractGuidFromHiiHandle (\r
7d582d6b 284 IN EFI_HII_HANDLE Handle,\r
e52c5a9f 285 OUT EFI_GUID *Guid\r
286 )\r
287;\r
288\r
289/**\r
290 Find HII Handle in the default HII database associated with given Device Path.\r
291\r
292 If DevicePath is NULL, then ASSERT.\r
293\r
294 @param DevicePath Device Path associated with the HII package list\r
295 handle.\r
296\r
297 @retval Handle HII package list Handle associated with the Device\r
298 Path.\r
299 @retval NULL Hii Package list handle is not found.\r
300\r
301**/\r
302EFI_HII_HANDLE\r
303EFIAPI\r
304HiiLibDevicePathToHiiHandle (\r
305 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
306 )\r
307;\r
308\r
309\r
310/**\r
311 Determine what is the current language setting. The space reserved for Lang\r
312 must be at least RFC_3066_ENTRY_SIZE bytes;\r
313\r
314 If Lang is NULL, then ASSERT.\r
315\r
316 @param Lang Pointer of system language. Lang will always be filled with \r
317 a valid RFC 3066 language string. If "PlatformLang" is not\r
318 set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang\r
319 is returned.\r
320\r
321 @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.\r
322 @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.\r
323\r
324**/\r
325EFI_STATUS\r
326EFIAPI\r
327HiiLibGetCurrentLanguage (\r
328 OUT CHAR8 *Lang\r
7d582d6b 329 )\r
e52c5a9f 330;\r
7d582d6b 331\r
e52c5a9f 332/**\r
333 Get next language from language code list (with separator ';').\r
7d582d6b 334\r
e52c5a9f 335 If LangCode is NULL, then ASSERT.\r
336 If Lang is NULL, then ASSERT.\r
7d582d6b 337\r
e52c5a9f 338 @param LangCode On input: point to first language in the list. On\r
339 output: point to next language in the list, or\r
340 NULL if no more language in the list.\r
341 @param Lang The first language in the list.\r
7d582d6b 342\r
e52c5a9f 343**/\r
344VOID\r
345EFIAPI\r
346HiiLibGetNextLanguage (\r
347 IN OUT CHAR8 **LangCode,\r
348 OUT CHAR8 *Lang\r
349 )\r
350;\r
351\r
352/**\r
353 This function returns the list of supported languages, in the format specified\r
354 in UEFI specification Appendix M.\r
355\r
356 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r
e52c5a9f 357\r
358 @param HiiHandle The HII package list handle.\r
359\r
33b3b832 360 @retval !NULL The supported languages.\r
361 @retval NULL If Supported Languages can not be retrived.\r
e52c5a9f 362\r
363**/\r
364CHAR8 *\r
365EFIAPI\r
366HiiLibGetSupportedLanguages (\r
367 IN EFI_HII_HANDLE HiiHandle\r
368 )\r
369;\r
370\r
33b3b832 371/**\r
372 This function returns the list of supported 2nd languages, in the format specified\r
373 in UEFI specification Appendix M.\r
374\r
375 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r
376 If not enough resource to complete the operation, then ASSERT.\r
377\r
378 @param HiiHandle The HII package list handle.\r
379\r
380 @return The supported languages.\r
381\r
382**/\r
383CHAR8 *\r
384EFIAPI\r
385HiiLibGetSupportedSecondaryLanguages (\r
386 IN EFI_HII_HANDLE HiiHandle,\r
387 IN CONST CHAR8 *FirstLanguage\r
388 )\r
389;\r
390\r
391\r
e52c5a9f 392/**\r
393 This function returns the number of supported languages on HiiHandle.\r
394\r
395 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r
396 If not enough resource to complete the operation, then ASSERT.\r
397\r
398 @param HiiHandle The HII package list handle.\r
399\r
400 @return The number of supported languages.\r
401\r
402**/\r
403UINT16\r
404EFIAPI\r
405HiiLibGetSupportedLanguageNumber (\r
406 IN EFI_HII_HANDLE HiiHandle\r
407 )\r
408;\r
409\r
410/**\r
411 Convert language code from RFC3066 to ISO639-2.\r
412\r
413 If LanguageRfc3066 is NULL, then ASSERT.\r
414 If LanguageIso639 is NULL, then ASSERT.\r
415\r
416 @param LanguageRfc3066 RFC3066 language code.\r
417 @param LanguageIso639 ISO639-2 language code.\r
418\r
419 @retval EFI_SUCCESS Language code converted.\r
420 @retval EFI_NOT_FOUND Language code not found.\r
421\r
422**/\r
423EFI_STATUS\r
424EFIAPI\r
425ConvertRfc3066LanguageToIso639Language (\r
426 CHAR8 *LanguageRfc3066,\r
427 CHAR8 *LanguageIso639\r
428 )\r
429;\r
430\r
431/**\r
432 Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will\r
433 be converted to "engfra".\r
434\r
435 If SupportedLanguages is NULL, then ASSERT.\r
436\r
437 @param SupportedLanguages The RFC3066 language list.\r
438\r
439 @return The ISO639-2 language list.\r
440\r
441**/\r
442CHAR8 *\r
443EFIAPI\r
444Rfc3066ToIso639 (\r
445 CHAR8 *SupportedLanguages\r
446 )\r
7d582d6b 447;\r
fb3df220 448\r
449#endif\r