]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c
Add doxygen style comments for functions in DxeIpl.
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiToUefiHiiThunk / Strings.c
CommitLineData
4259256b 1/**@file\r
2\r
3 This file contains the keyboard processing code to the HII database.\r
4\r
5Copyright (c) 2006 - 2008, Intel Corporation\r
6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16\r
17#include "HiiDatabase.h"\r
18\r
19EFI_STATUS\r
20EFIAPI\r
21HiiTestString (\r
22 IN EFI_HII_PROTOCOL *This,\r
23 IN CHAR16 *StringToTest,\r
24 IN OUT UINT32 *FirstMissing,\r
25 OUT UINT32 *GlyphBufferSize\r
26 )\r
27/*++\r
28\r
29Routine Description:\r
30 Test if all of the characters in a string have corresponding font characters.\r
31\r
32Arguments:\r
33\r
34Returns:\r
35\r
36--*/\r
37{\r
38 ASSERT (FALSE);\r
39 return EFI_SUCCESS;\r
40}\r
41\r
42EFI_STATUS\r
43GetTagGuidByFrameworkHiiHandle (\r
44 IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,\r
45 IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle,\r
46 OUT EFI_GUID *TagGuid\r
47 )\r
48{\r
49 LIST_ENTRY *ListEntry;\r
50 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;\r
51\r
52 ASSERT (TagGuid != NULL);\r
53\r
54 for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;\r
55 ListEntry != &Private->HiiThunkHandleMappingDBListHead;\r
56 ListEntry = ListEntry->ForwardLink\r
57 ) {\r
58\r
59 HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);\r
60\r
61 if (FrameworkHiiHandle == HandleMapEntry->FrameworkHiiHandle) {\r
62 CopyGuid (TagGuid, &HandleMapEntry->TagGuid);\r
63 return EFI_SUCCESS;\r
64 }\r
65 }\r
66 \r
67 return EFI_NOT_FOUND;\r
68}\r
69\r
70EFI_STATUS\r
71HiiThunkNewStringForAllStringPackages (\r
72 IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,\r
73 OUT CONST EFI_GUID *TagGuid,\r
74 IN CHAR16 *Language,\r
75 IN OUT STRING_REF *Reference,\r
76 IN CHAR16 *NewString\r
77 )\r
78{\r
79 EFI_STATUS Status;\r
80 LIST_ENTRY *ListEntry;\r
81 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;\r
82 EFI_STRING_ID StringId1;\r
83 EFI_STRING_ID StringId2;\r
84 CHAR8 *UefiStringProtocolLanguage;\r
85 BOOLEAN Found;\r
86\r
87 ASSERT (TagGuid != NULL);\r
88\r
89 StringId1 = (EFI_STRING_ID) 0;\r
90 StringId2 = (EFI_STRING_ID) 0;\r
91 Found = FALSE;\r
92\r
93 //\r
94 // BugBug: We will handle the case that Language is not NULL later.\r
95 //\r
96 ASSERT (Language == NULL);\r
97 \r
98 //if (Language == NULL) {\r
99 UefiStringProtocolLanguage = NULL;\r
100 //}\r
101\r
102 for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;\r
103 ListEntry != &Private->HiiThunkHandleMappingDBListHead;\r
104 ListEntry = ListEntry->ForwardLink\r
105 ) {\r
106\r
107 HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);\r
108\r
109 if (CompareGuid (TagGuid, &HandleMapEntry->TagGuid)) {\r
110 Found = TRUE;\r
111 if (*Reference == 0) {\r
112 Status = HiiLibNewString (HandleMapEntry->UefiHiiHandle, &StringId2, NewString);\r
113 } else {\r
114 Status = HiiLibSetString (HandleMapEntry->UefiHiiHandle, *Reference, NewString);\r
115 }\r
116 if (EFI_ERROR (Status)) {\r
117 return Status;\r
118 }\r
119 if (*Reference == 0) {\r
120 if (StringId1 == (EFI_STRING_ID) 0) {\r
121 StringId1 = StringId2;\r
122 } else {\r
123 if (StringId1 != StringId2) {\r
124 ASSERT(FALSE);\r
125 return EFI_INVALID_PARAMETER;\r
126 }\r
127 }\r
128 }\r
129 }\r
130 }\r
131\r
132 if (Found) {\r
133 *Reference = StringId1;\r
134 Status = EFI_SUCCESS;\r
135 } else {\r
46b5ebc8 136 ASSERT (FALSE);\r
4259256b 137 Status = EFI_NOT_FOUND;\r
138 }\r
139 \r
140 return Status;\r
141}\r
142\r
143EFI_STATUS\r
144EFIAPI\r
145HiiNewString (\r
146 IN EFI_HII_PROTOCOL *This,\r
147 IN CHAR16 *Language,\r
148 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
149 IN OUT STRING_REF *Reference,\r
150 IN CHAR16 *NewString\r
151 )\r
152/*++\r
153\r
154Routine Description:\r
155 This function allows a new String to be added to an already existing String Package.\r
156 We will make a buffer the size of the package + StrSize of the new string. We will\r
157 copy the string package that first gets changed and the following language packages until\r
158 we encounter the NULL string package. All this time we will ensure that the offsets have\r
159 been adjusted.\r
160\r
161Arguments:\r
162\r
163Returns:\r
164\r
165--*/\r
166{\r
167 EFI_STATUS Status;\r
168 EFI_HII_THUNK_PRIVATE_DATA *Private;\r
169 EFI_GUID TagGuid;\r
170\r
171 Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
172\r
173 Status = GetTagGuidByFrameworkHiiHandle (Private, Handle, &TagGuid);\r
174 ASSERT_EFI_ERROR (Status);\r
175\r
176 Status = HiiThunkNewStringForAllStringPackages (Private, &TagGuid, Language, Reference, NewString);\r
46b5ebc8 177 //\r
178 // For UNI file, some String may not be defined for a language. This has been true for a lot of platform code.\r
179 // For this case, EFI_NOT_FOUND will be returned. To allow the old code to be run without porting, we don't assert \r
180 // on EFI_NOT_FOUND. The missing String will be declared if user select differnt languages for the platform.\r
181 //\r
182 ASSERT_EFI_ERROR (EFI_ERROR (Status) && Status != EFI_NOT_FOUND); \r
4259256b 183\r
46b5ebc8 184 return Status;\r
4259256b 185}\r
186\r
187EFI_STATUS\r
188EFIAPI\r
189HiiResetStrings (\r
190 IN EFI_HII_PROTOCOL *This,\r
191 IN FRAMEWORK_EFI_HII_HANDLE Handle\r
192 )\r
193/*++\r
194\r
195Routine Description:\r
196\r
197 This function removes any new strings that were added after the initial string export for this handle.\r
198\r
199Arguments:\r
200\r
201Returns:\r
202\r
203--*/\r
204{\r
205 ASSERT (FALSE);\r
206 return EFI_UNSUPPORTED;\r
207}\r
208\r
209EFI_STATUS\r
210EFIAPI\r
211HiiGetString (\r
212 IN EFI_HII_PROTOCOL *This,\r
213 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
214 IN STRING_REF Token,\r
215 IN BOOLEAN Raw,\r
216 IN CHAR16 *LanguageString,\r
217 IN OUT UINTN *BufferLengthTemp,\r
218 OUT EFI_STRING StringBuffer\r
219 )\r
220/*++\r
221\r
222Routine Description:\r
223\r
224 This function extracts a string from a package already registered with the EFI HII database.\r
225\r
226Arguments:\r
227 This - A pointer to the EFI_HII_PROTOCOL instance.\r
228 Handle - The HII handle on which the string resides.\r
229 Token - The string token assigned to the string.\r
230 Raw - If TRUE, the string is returned unedited in the internal storage format described\r
231 above. If false, the string returned is edited by replacing <cr> with <space>\r
232 and by removing special characters such as the <wide> prefix.\r
233 LanguageString - Pointer to a NULL-terminated string containing a single ISO 639-2 language\r
234 identifier, indicating the language to print. If the LanguageString is empty (starts\r
235 with a NULL), the default system language will be used to determine the language.\r
236 BufferLength - Length of the StringBuffer. If the status reports that the buffer width is too\r
237 small, this parameter is filled with the length of the buffer needed.\r
238 StringBuffer - The buffer designed to receive the characters in the string. Type EFI_STRING is\r
239 defined in String.\r
240\r
241Returns:\r
242 EFI_INVALID_PARAMETER - If input parameter is invalid.\r
243 EFI_BUFFER_TOO_SMALL - If the *BufferLength is too small.\r
244 EFI_SUCCESS - Operation is successful.\r
245\r
246--*/\r
247{\r
248 LIST_ENTRY *ListEntry;\r
249 HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;\r
250 CHAR8 *AsciiLanguage;\r
251 EFI_HII_THUNK_PRIVATE_DATA *Private;\r
252\r
253 Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r
254\r
255 if (LanguageString == NULL) {\r
256 AsciiLanguage = NULL;\r
257 } else {\r
258 AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);\r
259 if (AsciiLanguage == NULL) {\r
260 return EFI_OUT_OF_RESOURCES;\r
261 }\r
262 UnicodeStrToAsciiStr (LanguageString, AsciiLanguage);\r
263 }\r
264\r
265 for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;\r
266 ListEntry != &Private->HiiThunkHandleMappingDBListHead;\r
267 ListEntry = ListEntry->ForwardLink\r
268 ) {\r
269\r
270 HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);\r
271\r
272 if (Handle == HandleMapEntry->FrameworkHiiHandle) {\r
273 if (AsciiLanguage == NULL) {\r
274 return HiiLibGetString (HandleMapEntry->UefiHiiHandle, Token, StringBuffer, BufferLengthTemp);\r
275 } else {\r
59336178 276 return mHiiStringProtocol->GetString (\r
277 mHiiStringProtocol,\r
4259256b 278 AsciiLanguage,\r
279 HandleMapEntry->UefiHiiHandle,\r
280 Token,\r
281 StringBuffer,\r
282 BufferLengthTemp,\r
283 NULL\r
284 );\r
285 }\r
286 }\r
287 }\r
288\r
289 return EFI_NOT_FOUND;\r
290}\r
291\r
292EFI_STATUS\r
293EFIAPI\r
294HiiGetLine (\r
295 IN EFI_HII_PROTOCOL *This,\r
296 IN FRAMEWORK_EFI_HII_HANDLE Handle,\r
297 IN STRING_REF Token,\r
298 IN OUT UINT16 *Index,\r
299 IN UINT16 LineWidth,\r
300 IN CHAR16 *LanguageString,\r
301 IN OUT UINT16 *BufferLength,\r
302 OUT EFI_STRING StringBuffer\r
303 )\r
304/*++\r
305\r
306Routine Description:\r
307\r
308 This function allows a program to extract a part of a string of not more than a given width.\r
309 With repeated calls, this allows a calling program to extract "lines" of text that fit inside\r
310 columns. The effort of measuring the fit of strings inside columns is localized to this call.\r
311\r
312Arguments:\r
313\r
314Returns:\r
315\r
316--*/\r
317{\r
318 ASSERT (FALSE);\r
319 return EFI_UNSUPPORTED;\r
320}\r
321\r