3 This file contains the keyboard processing code to the HII database.
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "HiiDatabase.h"
22 IN EFI_HII_PROTOCOL
*This
,
23 IN CHAR16
*StringToTest
,
24 IN OUT UINT32
*FirstMissing
,
25 OUT UINT32
*GlyphBufferSize
30 Test if all of the characters in a string have corresponding font characters.
43 GetTagGuidByFrameworkHiiHandle (
44 IN CONST EFI_HII_THUNK_PRIVATE_DATA
*Private
,
45 IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle
,
49 LIST_ENTRY
*ListEntry
;
50 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY
*HandleMapEntry
;
52 ASSERT (TagGuid
!= NULL
);
54 for (ListEntry
= Private
->HiiThunkHandleMappingDBListHead
.ForwardLink
;
55 ListEntry
!= &Private
->HiiThunkHandleMappingDBListHead
;
56 ListEntry
= ListEntry
->ForwardLink
59 HandleMapEntry
= HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry
);
61 if (FrameworkHiiHandle
== HandleMapEntry
->FrameworkHiiHandle
) {
62 CopyGuid (TagGuid
, &HandleMapEntry
->TagGuid
);
71 HiiThunkNewStringForAllStringPackages (
72 IN CONST EFI_HII_THUNK_PRIVATE_DATA
*Private
,
73 OUT CONST EFI_GUID
*TagGuid
,
75 IN OUT STRING_REF
*Reference
,
80 LIST_ENTRY
*ListEntry
;
81 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY
*HandleMapEntry
;
82 EFI_STRING_ID StringId1
;
83 EFI_STRING_ID StringId2
;
87 ASSERT (TagGuid
!= NULL
);
89 StringId1
= (EFI_STRING_ID
) 0;
90 StringId2
= (EFI_STRING_ID
) 0;
93 if (Language
== NULL
) {
96 AsciiLanguage
= AllocateZeroPool (StrLen (Language
) + 1);
97 UnicodeStrToAsciiStr (Language
, AsciiLanguage
);
100 for (ListEntry
= Private
->HiiThunkHandleMappingDBListHead
.ForwardLink
;
101 ListEntry
!= &Private
->HiiThunkHandleMappingDBListHead
;
102 ListEntry
= ListEntry
->ForwardLink
105 HandleMapEntry
= HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry
);
107 if (CompareGuid (TagGuid
, &HandleMapEntry
->TagGuid
)) {
109 if (*Reference
== 0) {
110 if (AsciiLanguage
== NULL
) {
111 Status
= HiiLibNewString (HandleMapEntry
->UefiHiiHandle
, &StringId2
, NewString
);
113 Status
= mHiiStringProtocol
->NewString (
115 HandleMapEntry
->UefiHiiHandle
,
124 if (AsciiLanguage
== NULL
) {
125 Status
= HiiLibSetString (HandleMapEntry
->UefiHiiHandle
, *Reference
, NewString
);
127 Status
= mHiiStringProtocol
->SetString (
129 HandleMapEntry
->UefiHiiHandle
,
137 if (EFI_ERROR (Status
)) {
140 if (*Reference
== 0) {
141 if (StringId1
== (EFI_STRING_ID
) 0) {
142 StringId1
= StringId2
;
144 if (StringId1
!= StringId2
) {
146 return EFI_INVALID_PARAMETER
;
154 *Reference
= StringId1
;
155 Status
= EFI_SUCCESS
;
158 Status
= EFI_NOT_FOUND
;
167 IN EFI_HII_PROTOCOL
*This
,
169 IN FRAMEWORK_EFI_HII_HANDLE Handle
,
170 IN OUT STRING_REF
*Reference
,
176 This function allows a new String to be added to an already existing String Package.
177 We will make a buffer the size of the package + StrSize of the new string. We will
178 copy the string package that first gets changed and the following language packages until
179 we encounter the NULL string package. All this time we will ensure that the offsets have
189 EFI_HII_THUNK_PRIVATE_DATA
*Private
;
192 Private
= EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This
);
194 Status
= GetTagGuidByFrameworkHiiHandle (Private
, Handle
, &TagGuid
);
195 ASSERT_EFI_ERROR (Status
);
197 Status
= HiiThunkNewStringForAllStringPackages (Private
, &TagGuid
, Language
, Reference
, NewString
);
199 // For UNI file, some String may not be defined for a language. This has been true for a lot of platform code.
200 // For this case, EFI_NOT_FOUND will be returned. To allow the old code to be run without porting, we don't assert
201 // on EFI_NOT_FOUND. The missing Strings will be shown if user select a differnt languages other than the default
202 // English language for the platform.
204 ASSERT_EFI_ERROR (EFI_ERROR (Status
) && Status
!= EFI_NOT_FOUND
);
212 IN EFI_HII_PROTOCOL
*This
,
213 IN FRAMEWORK_EFI_HII_HANDLE Handle
219 This function removes any new strings that were added after the initial string export for this handle.
228 return EFI_UNSUPPORTED
;
234 } ISO639TORFC3066MAP
;
236 ISO639TORFC3066MAP Iso639ToRfc3066Map
[] = {
248 for (Index
= 0; Index
< sizeof (Iso639ToRfc3066Map
) / sizeof (Iso639ToRfc3066Map
[0]); Index
++) {
249 if (AsciiStrnCmp (Iso638Lang
, Iso639ToRfc3066Map
[Index
].Iso639
, AsciiStrSize (Iso638Lang
)) == 0) {
250 return Iso639ToRfc3066Map
[Index
].Rfc3066
;
254 return (CHAR8
*) NULL
;
260 IN EFI_HII_PROTOCOL
*This
,
261 IN FRAMEWORK_EFI_HII_HANDLE Handle
,
264 IN CHAR16
*LanguageString
,
265 IN OUT UINTN
*BufferLengthTemp
,
266 OUT EFI_STRING StringBuffer
272 This function extracts a string from a package already registered with the EFI HII database.
275 This - A pointer to the EFI_HII_PROTOCOL instance.
276 Handle - The HII handle on which the string resides.
277 Token - The string token assigned to the string.
278 Raw - If TRUE, the string is returned unedited in the internal storage format described
279 above. If false, the string returned is edited by replacing <cr> with <space>
280 and by removing special characters such as the <wide> prefix.
281 LanguageString - Pointer to a NULL-terminated string containing a single ISO 639-2 language
282 identifier, indicating the language to print. If the LanguageString is empty (starts
283 with a NULL), the default system language will be used to determine the language.
284 BufferLength - Length of the StringBuffer. If the status reports that the buffer width is too
285 small, this parameter is filled with the length of the buffer needed.
286 StringBuffer - The buffer designed to receive the characters in the string. Type EFI_STRING is
290 EFI_INVALID_PARAMETER - If input parameter is invalid.
291 EFI_BUFFER_TOO_SMALL - If the *BufferLength is too small.
292 EFI_SUCCESS - Operation is successful.
296 LIST_ENTRY
*ListEntry
;
297 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY
*HandleMapEntry
;
298 CHAR8
*AsciiLanguage
;
299 EFI_HII_THUNK_PRIVATE_DATA
*Private
;
300 CHAR8
*Rfc3066AsciiLanguage
;
302 Private
= EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This
);
304 if (LanguageString
== NULL
) {
305 AsciiLanguage
= NULL
;
307 AsciiLanguage
= AllocateZeroPool (StrLen (LanguageString
) + 1);
308 if (AsciiLanguage
== NULL
) {
309 return EFI_OUT_OF_RESOURCES
;
311 UnicodeStrToAsciiStr (LanguageString
, AsciiLanguage
);
313 Rfc3066AsciiLanguage
= Iso639ToRfc3066 (AsciiLanguage
);
315 // Caller of Framework HII Interface uses the Language Identification String defined
316 // in Iso639. So map it to the Language Identifier defined in RFC3066.
318 if (Rfc3066AsciiLanguage
!= NULL
) {
319 FreePool (AsciiLanguage
);
320 AsciiLanguage
= AllocateCopyPool (AsciiStrSize (Rfc3066AsciiLanguage
), Rfc3066AsciiLanguage
);
325 for (ListEntry
= Private
->HiiThunkHandleMappingDBListHead
.ForwardLink
;
326 ListEntry
!= &Private
->HiiThunkHandleMappingDBListHead
;
327 ListEntry
= ListEntry
->ForwardLink
330 HandleMapEntry
= HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry
);
332 if (Handle
== HandleMapEntry
->FrameworkHiiHandle
) {
333 if (AsciiLanguage
== NULL
) {
334 return HiiLibGetString (HandleMapEntry
->UefiHiiHandle
, Token
, StringBuffer
, BufferLengthTemp
);
336 return mHiiStringProtocol
->GetString (
339 HandleMapEntry
->UefiHiiHandle
,
349 return EFI_NOT_FOUND
;
355 IN EFI_HII_PROTOCOL
*This
,
356 IN FRAMEWORK_EFI_HII_HANDLE Handle
,
358 IN OUT UINT16
*Index
,
360 IN CHAR16
*LanguageString
,
361 IN OUT UINT16
*BufferLength
,
362 OUT EFI_STRING StringBuffer
368 This function allows a program to extract a part of a string of not more than a given width.
369 With repeated calls, this allows a calling program to extract "lines" of text that fit inside
370 columns. The effort of measuring the fit of strings inside columns is localized to this call.
379 return EFI_UNSUPPORTED
;