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
;
84 CHAR8
*UefiStringProtocolLanguage
;
87 ASSERT (TagGuid
!= NULL
);
89 StringId1
= (EFI_STRING_ID
) 0;
90 StringId2
= (EFI_STRING_ID
) 0;
94 // BugBug: We will handle the case that Language is not NULL later.
96 ASSERT (Language
== NULL
);
98 //if (Language == NULL) {
99 UefiStringProtocolLanguage
= NULL
;
102 for (ListEntry
= Private
->HiiThunkHandleMappingDBListHead
.ForwardLink
;
103 ListEntry
!= &Private
->HiiThunkHandleMappingDBListHead
;
104 ListEntry
= ListEntry
->ForwardLink
107 HandleMapEntry
= HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry
);
109 if (CompareGuid (TagGuid
, &HandleMapEntry
->TagGuid
)) {
111 if (*Reference
== 0) {
112 Status
= HiiLibNewString (HandleMapEntry
->UefiHiiHandle
, &StringId2
, NewString
);
114 Status
= HiiLibSetString (HandleMapEntry
->UefiHiiHandle
, *Reference
, NewString
);
116 if (EFI_ERROR (Status
)) {
119 if (*Reference
== 0) {
120 if (StringId1
== (EFI_STRING_ID
) 0) {
121 StringId1
= StringId2
;
123 if (StringId1
!= StringId2
) {
125 return EFI_INVALID_PARAMETER
;
133 *Reference
= StringId1
;
134 Status
= EFI_SUCCESS
;
137 Status
= EFI_NOT_FOUND
;
146 IN EFI_HII_PROTOCOL
*This
,
148 IN FRAMEWORK_EFI_HII_HANDLE Handle
,
149 IN OUT STRING_REF
*Reference
,
155 This function allows a new String to be added to an already existing String Package.
156 We will make a buffer the size of the package + StrSize of the new string. We will
157 copy the string package that first gets changed and the following language packages until
158 we encounter the NULL string package. All this time we will ensure that the offsets have
168 EFI_HII_THUNK_PRIVATE_DATA
*Private
;
171 Private
= EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This
);
173 Status
= GetTagGuidByFrameworkHiiHandle (Private
, Handle
, &TagGuid
);
174 ASSERT_EFI_ERROR (Status
);
176 Status
= HiiThunkNewStringForAllStringPackages (Private
, &TagGuid
, Language
, Reference
, NewString
);
178 // For UNI file, some String may not be defined for a language. This has been true for a lot of platform code.
179 // For this case, EFI_NOT_FOUND will be returned. To allow the old code to be run without porting, we don't assert
180 // on EFI_NOT_FOUND. The missing String will be declared if user select differnt languages for the platform.
182 ASSERT_EFI_ERROR (EFI_ERROR (Status
) && Status
!= EFI_NOT_FOUND
);
190 IN EFI_HII_PROTOCOL
*This
,
191 IN FRAMEWORK_EFI_HII_HANDLE Handle
197 This function removes any new strings that were added after the initial string export for this handle.
206 return EFI_UNSUPPORTED
;
212 IN EFI_HII_PROTOCOL
*This
,
213 IN FRAMEWORK_EFI_HII_HANDLE Handle
,
216 IN CHAR16
*LanguageString
,
217 IN OUT UINTN
*BufferLengthTemp
,
218 OUT EFI_STRING StringBuffer
224 This function extracts a string from a package already registered with the EFI HII database.
227 This - A pointer to the EFI_HII_PROTOCOL instance.
228 Handle - The HII handle on which the string resides.
229 Token - The string token assigned to the string.
230 Raw - If TRUE, the string is returned unedited in the internal storage format described
231 above. If false, the string returned is edited by replacing <cr> with <space>
232 and by removing special characters such as the <wide> prefix.
233 LanguageString - Pointer to a NULL-terminated string containing a single ISO 639-2 language
234 identifier, indicating the language to print. If the LanguageString is empty (starts
235 with a NULL), the default system language will be used to determine the language.
236 BufferLength - Length of the StringBuffer. If the status reports that the buffer width is too
237 small, this parameter is filled with the length of the buffer needed.
238 StringBuffer - The buffer designed to receive the characters in the string. Type EFI_STRING is
242 EFI_INVALID_PARAMETER - If input parameter is invalid.
243 EFI_BUFFER_TOO_SMALL - If the *BufferLength is too small.
244 EFI_SUCCESS - Operation is successful.
248 LIST_ENTRY
*ListEntry
;
249 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY
*HandleMapEntry
;
250 CHAR8
*AsciiLanguage
;
251 EFI_HII_THUNK_PRIVATE_DATA
*Private
;
253 Private
= EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This
);
255 if (LanguageString
== NULL
) {
256 AsciiLanguage
= NULL
;
258 AsciiLanguage
= AllocateZeroPool (StrLen (LanguageString
) + 1);
259 if (AsciiLanguage
== NULL
) {
260 return EFI_OUT_OF_RESOURCES
;
262 UnicodeStrToAsciiStr (LanguageString
, AsciiLanguage
);
265 for (ListEntry
= Private
->HiiThunkHandleMappingDBListHead
.ForwardLink
;
266 ListEntry
!= &Private
->HiiThunkHandleMappingDBListHead
;
267 ListEntry
= ListEntry
->ForwardLink
270 HandleMapEntry
= HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry
);
272 if (Handle
== HandleMapEntry
->FrameworkHiiHandle
) {
273 if (AsciiLanguage
== NULL
) {
274 return HiiLibGetString (HandleMapEntry
->UefiHiiHandle
, Token
, StringBuffer
, BufferLengthTemp
);
276 return mHiiStringProtocol
->GetString (
279 HandleMapEntry
->UefiHiiHandle
,
289 return EFI_NOT_FOUND
;
295 IN EFI_HII_PROTOCOL
*This
,
296 IN FRAMEWORK_EFI_HII_HANDLE Handle
,
298 IN OUT UINT16
*Index
,
300 IN CHAR16
*LanguageString
,
301 IN OUT UINT16
*BufferLength
,
302 OUT EFI_STRING StringBuffer
308 This function allows a program to extract a part of a string of not more than a given width.
309 With repeated calls, this allows a calling program to extract "lines" of text that fit inside
310 columns. The effort of measuring the fit of strings inside columns is localized to this call.
319 return EFI_UNSUPPORTED
;