3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
25 // Include common header file for this module.
27 #include "CommonHeader.h"
32 #define NARROW_GLYPH_NUMBER 8
33 #define WIDE_GLYPH_NUMBER 75
36 // Default language code, currently is English
38 CHAR8
*mDefaultLangCode
= "eng";
41 EFI_HII_FONT_PACK FixedLength
;
42 EFI_NARROW_GLYPH NarrowArray
[NARROW_GLYPH_NUMBER
];
43 EFI_WIDE_GLYPH WideArray
[WIDE_GLYPH_NUMBER
];
46 FONT_PACK mFontPack
= {
47 sizeof (EFI_HII_FONT_PACK
) + (NARROW_GLYPH_NUMBER
* sizeof (EFI_NARROW_GLYPH
)) + (WIDE_GLYPH_NUMBER
* sizeof (EFI_WIDE_GLYPH
)),
315 Routine to export glyphs to the HII database. This is in addition to whatever is defined in the Graphics Console driver.
324 EFI_HII_HANDLE HiiHandle
;
325 EFI_HII_PACKAGES
*PackageList
;
327 PackageList
= PreparePackages (1, NULL
, &mFontPack
);
329 // Register our Fonts into the global database
332 Hii
->NewPack (Hii
, PackageList
, &HiiHandle
);
334 FreePool (PackageList
);
339 BOOLEAN LangCodesSettingRequired
344 Determine the current language that will be used
345 based on language related EFI Variables
348 LangCodesSettingRequired - If required to set LangCode variable
357 CHAR8 LangCode
[ISO_639_2_ENTRY_SIZE
];
359 CHAR16
*LanguageString
;
361 LanguageString
= NULL
;
367 // Collect the languages from what our current Language support is based on our VFR
369 Hii
->GetPrimaryLanguages (Hii
, gStringPackHandle
, &LanguageString
);
371 LangCodes
= AllocatePool (StrLen (LanguageString
));
375 // Convert LanguageString from Unicode to EFI defined ASCII LangCodes
377 for (Index
= 0; LanguageString
[Index
] != 0x0000; Index
++) {
378 LangCodes
[Index
] = (CHAR8
) LanguageString
[Index
];
381 LangCodes
[Index
] = 0;
383 if (LangCodesSettingRequired
) {
384 Status
= gRT
->SetVariable (
386 &gEfiGlobalVariableGuid
,
387 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
388 AsciiStrLen (LangCodes
),
393 // Find current LangCode from Lang NV Variable
395 Size
= ISO_639_2_ENTRY_SIZE
;
396 Status
= gRT
->GetVariable (
398 &gEfiGlobalVariableGuid
,
404 if (!EFI_ERROR (Status
)) {
405 Status
= EFI_NOT_FOUND
;
406 for (Index
= 0; LangCodes
[Index
] != 0; Index
+= ISO_639_2_ENTRY_SIZE
) {
407 if (CompareMem (&LangCodes
[Index
], LangCode
, ISO_639_2_ENTRY_SIZE
) == 0) {
408 Status
= EFI_SUCCESS
;
414 // If we cannot get language code from Lang variable,
415 // or LangCode cannot be found from language table,
416 // set the mDefaultLangCode to Lang variable.
418 if (EFI_ERROR (Status
)) {
419 Status
= gRT
->SetVariable (
421 &gEfiGlobalVariableGuid
,
422 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
423 ISO_639_2_ENTRY_SIZE
,
429 FreePool (LangCodes
);
432 if (LanguageString
!= NULL
) {
433 FreePool (LanguageString
);