]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/BdsDxe/Language.c
Add debug prompt for showing progress bar.
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / Language.c
CommitLineData
93e3992d 1/*++\r
2\r
3Copyright (c) 2004 - 2008, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 Language.c\r
15\r
16Abstract:\r
17\r
18 Language settings\r
19\r
20Revision History\r
21\r
22--*/\r
23\r
24#include "Language.h"\r
25#include "FrontPage.h"\r
26\r
27#define NARROW_GLYPH_NUMBER 8\r
28#define WIDE_GLYPH_NUMBER 75\r
29\r
30EFI_GUID mFontPackageGuid = {\r
31 0x78941450, 0x90ab, 0x4fb1, {0xb7, 0x5f, 0x58, 0x92, 0x14, 0xe2, 0x4a, 0xc}\r
32};\r
33\r
34typedef struct {\r
35 //\r
9226efe5 36 // This 4-bytes total array length is required by HiiLibPreparePackageList()\r
93e3992d 37 //\r
38 UINT32 Length;\r
39\r
40 //\r
41 // This is the Font package definition\r
42 //\r
43 EFI_HII_PACKAGE_HEADER Header;\r
44 UINT16 NumberOfNarrowGlyphs;\r
45 UINT16 NumberOfWideGlyphs;\r
46 EFI_NARROW_GLYPH NarrowArray[NARROW_GLYPH_NUMBER];\r
47 EFI_WIDE_GLYPH WideArray[WIDE_GLYPH_NUMBER];\r
48} FONT_PACK_BIN;\r
49\r
50FONT_PACK_BIN mFontBin = {\r
51 sizeof (FONT_PACK_BIN),\r
52 {\r
53 sizeof (FONT_PACK_BIN) - sizeof (UINT32),\r
54 EFI_HII_PACKAGE_SIMPLE_FONTS,\r
55 },\r
56 NARROW_GLYPH_NUMBER,\r
57 0,\r
58 { // Narrow Glyphs\r
59 {\r
60 0x05d0,\r
61 0x00,\r
62 {\r
63 0x00,\r
64 0x00,\r
65 0x00,\r
66 0x4E,\r
67 0x6E,\r
68 0x62,\r
69 0x32,\r
70 0x32,\r
71 0x3C,\r
72 0x68,\r
73 0x4C,\r
74 0x4C,\r
75 0x46,\r
76 0x76,\r
77 0x72,\r
78 0x00,\r
79 0x00,\r
80 0x00,\r
81 0x00\r
82 }\r
83 },\r
84 {\r
85 0x05d1,\r
86 0x00,\r
87 {\r
88 0x00,\r
89 0x00,\r
90 0x00,\r
91 0x78,\r
92 0x7C,\r
93 0x0C,\r
94 0x0C,\r
95 0x0C,\r
96 0x0C,\r
97 0x0C,\r
98 0x0C,\r
99 0x0C,\r
100 0x0C,\r
101 0x7E,\r
102 0x7E,\r
103 0x00,\r
104 0x00,\r
105 0x00,\r
106 0x00\r
107 }\r
108 },\r
109 {\r
110 0x05d2,\r
111 0x00,\r
112 {\r
113 0x00,\r
114 0x00,\r
115 0x00,\r
116 0x78,\r
117 0x7C,\r
118 0x0C,\r
119 0x0C,\r
120 0x0C,\r
121 0x0C,\r
122 0x0C,\r
123 0x0C,\r
124 0x1C,\r
125 0x3E,\r
126 0x66,\r
127 0x66,\r
128 0x00,\r
129 0x00,\r
130 0x00,\r
131 0x00\r
132 }\r
133 },\r
134 {\r
135 0x05d3,\r
136 0x00,\r
137 {\r
138 0x00,\r
139 0x00,\r
140 0x00,\r
141 0x7E,\r
142 0x7E,\r
143 0x0C,\r
144 0x0C,\r
145 0x0C,\r
146 0x0C,\r
147 0x0C,\r
148 0x0C,\r
149 0x0C,\r
150 0x0C,\r
151 0x0C,\r
152 0x0C,\r
153 0x00,\r
154 0x00,\r
155 0x00,\r
156 0x00\r
157 }\r
158 },\r
159 {\r
160 0x05d4,\r
161 0x00,\r
162 {\r
163 0x00,\r
164 0x00,\r
165 0x00,\r
166 0x7C,\r
167 0x7E,\r
168 0x06,\r
169 0x06,\r
170 0x06,\r
171 0x06,\r
172 0x66,\r
173 0x66,\r
174 0x66,\r
175 0x66,\r
176 0x66,\r
177 0x66,\r
178 0x00,\r
179 0x00,\r
180 0x00,\r
181 0x00\r
182 }\r
183 },\r
184 {\r
185 0x05d5,\r
186 0x00,\r
187 {\r
188 0x00,\r
189 0x00,\r
190 0x00,\r
191 0x3C,\r
192 0x3C,\r
193 0x0C,\r
194 0x0C,\r
195 0x0C,\r
196 0x0C,\r
197 0x0C,\r
198 0x0C,\r
199 0x0C,\r
200 0x0C,\r
201 0x0C,\r
202 0x0C,\r
203 0x00,\r
204 0x00,\r
205 0x00,\r
206 0x00\r
207 }\r
208 },\r
209 {\r
210 0x05d6,\r
211 0x00,\r
212 {\r
213 0x00,\r
214 0x00,\r
215 0x00,\r
216 0x38,\r
217 0x38,\r
218 0x1E,\r
219 0x1E,\r
220 0x18,\r
221 0x18,\r
222 0x18,\r
223 0x18,\r
224 0x18,\r
225 0x18,\r
226 0x18,\r
227 0x18,\r
228 0x00,\r
229 0x00,\r
230 0x00,\r
231 0x00\r
232 }\r
233 },\r
234 {\r
235 0x0000,\r
236 0x00,\r
237 {\r
238 0x00,\r
239 0x00,\r
240 0x00,\r
241 0x00,\r
242 0x00,\r
243 0x00,\r
244 0x00,\r
245 0x00,\r
246 0x00,\r
247 0x00,\r
248 0x00,\r
249 0x00,\r
250 0x00,\r
251 0x00,\r
252 0x00,\r
253 0x00,\r
254 0x00,\r
255 0x00,\r
256 0x00\r
257 }\r
258 }\r
259 }\r
260};\r
261\r
262VOID\r
263ExportFonts (\r
264 VOID\r
265 )\r
266/*++\r
267\r
268Routine Description:\r
269 Routine to export glyphs to the HII database. This is in addition to whatever is defined in the Graphics Console driver.\r
270\r
271Arguments:\r
272 None\r
273\r
274Returns:\r
275\r
276--*/\r
277{\r
278 EFI_STATUS Status;\r
279 EFI_HANDLE DriverHandle;\r
280 EFI_HII_HANDLE HiiHandle;\r
281 EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
282\r
283 //\r
284 // Create driver handle used by HII database\r
285 //\r
286 Status = HiiLibCreateHiiDriverHandle (&DriverHandle);\r
287 if (EFI_ERROR (Status)) {\r
288 return ;\r
289 }\r
290\r
9226efe5 291 PackageList = HiiLibPreparePackageList (1, &mFontPackageGuid, &mFontBin);\r
93e3992d 292 ASSERT (PackageList != NULL);\r
293\r
294 gHiiDatabase->NewPackageList (gHiiDatabase, PackageList, DriverHandle, &HiiHandle);\r
295 FreePool (PackageList);\r
296}\r
297\r
298VOID\r
299InitializeLanguage (\r
300 BOOLEAN LangCodesSettingRequired\r
301 )\r
302/*++\r
303\r
304Routine Description:\r
305 Determine the current language that will be used\r
306 based on language related EFI Variables\r
307\r
308Arguments:\r
309 LangCodesSettingRequired - If required to set LangCode variable\r
310\r
311Returns:\r
312\r
313--*/\r
314{\r
315 EFI_STATUS Status;\r
316 UINTN Size;\r
317 CHAR8 *Lang;\r
318 CHAR8 LangCode[ISO_639_2_ENTRY_SIZE];\r
319 CHAR8 *LangCodes;\r
320 CHAR8 *PlatformLang;\r
321 CHAR8 *PlatformLangCodes;\r
322 UINTN Index;\r
323 BOOLEAN Invalid;\r
324\r
325 ExportFonts ();\r
326\r
327 LangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultLangCodes);\r
328 if (LangCodesSettingRequired) {\r
329 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate)) {\r
330 //\r
331 // UEFI 2.1 depricated this variable so we support turning it off\r
332 //\r
333 Status = gRT->SetVariable (\r
334 L"LangCodes",\r
335 &gEfiGlobalVariableGuid,\r
336 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
337 AsciiStrLen (LangCodes),\r
338 LangCodes\r
339 );\r
340 }\r
341\r
342\r
343 PlatformLangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes);\r
344 Status = gRT->SetVariable (\r
345 L"PlatformLangCodes",\r
346 &gEfiGlobalVariableGuid,\r
347 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
348 AsciiStrSize (PlatformLangCodes),\r
349 PlatformLangCodes\r
350 );\r
351 }\r
352\r
353 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate)) {\r
354 //\r
355 // UEFI 2.1 depricated this variable so we support turning it off\r
356 //\r
357\r
358 //\r
359 // Find current LangCode from Lang NV Variable\r
360 //\r
361 Size = ISO_639_2_ENTRY_SIZE;\r
362 Status = gRT->GetVariable (\r
363 L"Lang",\r
364 &gEfiGlobalVariableGuid,\r
365 NULL,\r
366 &Size,\r
367 &LangCode\r
368 );\r
369 if (!EFI_ERROR (Status)) {\r
370 Status = EFI_NOT_FOUND;\r
371 for (Index = 0; LangCodes[Index] != 0; Index += ISO_639_2_ENTRY_SIZE) {\r
372 if (CompareMem (&LangCodes[Index], LangCode, ISO_639_2_ENTRY_SIZE) == 0) {\r
373 Status = EFI_SUCCESS;\r
374 break;\r
375 }\r
376 }\r
377 }\r
378\r
379 //\r
380 // If we cannot get language code from Lang variable,\r
381 // or LangCode cannot be found from language table,\r
382 // set the mDefaultLangCode to Lang variable.\r
383 //\r
384 if (EFI_ERROR (Status)) {\r
385 Lang = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultLang);\r
386 Status = gRT->SetVariable (\r
387 L"Lang",\r
388 &gEfiGlobalVariableGuid,\r
389 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
390 ISO_639_2_ENTRY_SIZE,\r
391 Lang\r
392 );\r
393 }\r
394 }\r
395\r
396 Invalid = FALSE;\r
397 PlatformLang = BdsLibGetVariableAndSize (L"PlatformLang", &gEfiGlobalVariableGuid, &Size);\r
398 if (PlatformLang != NULL) {\r
399 //\r
400 // Check Current PlatformLang value against PlatformLangCode. Need a library that is TBD\r
401 // Set Invalid based on state of PlatformLang.\r
402 //\r
403\r
404 FreePool (PlatformLang);\r
405 } else {\r
406 // No valid variable is set\r
407 Invalid = TRUE;\r
408 }\r
409\r
410 if (Invalid) {\r
411 PlatformLang = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLang);\r
412 Status = gRT->SetVariable (\r
413 L"PlatformLang",\r
414 &gEfiGlobalVariableGuid,\r
415 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
416 AsciiStrSize (PlatformLang),\r
417 PlatformLang\r
418 );\r
419 }\r
420}\r