3 Copyright (c) 2006, 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.
27 #define NARROW_GLYPH_NUMBER 8
28 #define WIDE_GLYPH_NUMBER 75
31 // Default language code, currently is English
33 CHAR8
*mDefaultLangCode
= "eng";
36 EFI_HII_FONT_PACK FixedLength
;
37 EFI_NARROW_GLYPH NarrowArray
[NARROW_GLYPH_NUMBER
];
38 EFI_WIDE_GLYPH WideArray
[WIDE_GLYPH_NUMBER
];
41 FONT_PACK mFontPack
= {
42 sizeof (EFI_HII_FONT_PACK
) + (NARROW_GLYPH_NUMBER
* sizeof (EFI_NARROW_GLYPH
)) + (WIDE_GLYPH_NUMBER
* sizeof (EFI_WIDE_GLYPH
)),
310 Routine to export glyphs to the HII database. This is in addition to whatever is defined in the Graphics Console driver.
319 EFI_HII_HANDLE HiiHandle
;
320 EFI_HII_PACKAGES
*PackageList
;
322 PackageList
= PreparePackages (1, NULL
, &mFontPack
);
324 // Register our Fonts into the global database
327 Hii
->NewPack (Hii
, PackageList
, &HiiHandle
);
329 gBS
->FreePool (PackageList
);
334 BOOLEAN LangCodesSettingRequired
339 Determine the current language that will be used
340 based on language related EFI Variables
343 LangCodesSettingRequired - If required to set LangCode variable
352 CHAR8 LangCode
[ISO_639_2_ENTRY_SIZE
];
354 CHAR16
*LanguageString
;
356 LanguageString
= NULL
;
362 // Collect the languages from what our current Language support is based on our VFR
364 Hii
->GetPrimaryLanguages (Hii
, gStringPackHandle
, &LanguageString
);
366 LangCodes
= AllocatePool (StrLen (LanguageString
));
370 // Convert LanguageString from Unicode to EFI defined ASCII LangCodes
372 for (Index
= 0; LanguageString
[Index
] != 0x0000; Index
++) {
373 LangCodes
[Index
] = (CHAR8
) LanguageString
[Index
];
376 LangCodes
[Index
] = 0;
378 if (LangCodesSettingRequired
) {
379 Status
= gRT
->SetVariable (
381 &gEfiGlobalVariableGuid
,
382 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
383 AsciiStrLen (LangCodes
),
388 // Find current LangCode from Lang NV Variable
390 Size
= ISO_639_2_ENTRY_SIZE
;
391 Status
= gRT
->GetVariable (
393 &gEfiGlobalVariableGuid
,
399 if (!EFI_ERROR (Status
)) {
400 Status
= EFI_NOT_FOUND
;
401 for (Index
= 0; LangCodes
[Index
] != 0; Index
+= ISO_639_2_ENTRY_SIZE
) {
402 if (CompareMem (&LangCodes
[Index
], LangCode
, ISO_639_2_ENTRY_SIZE
) == 0) {
403 Status
= EFI_SUCCESS
;
409 // If we cannot get language code from Lang variable,
410 // or LangCode cannot be found from language table,
411 // set the mDefaultLangCode to Lang variable.
413 if (EFI_ERROR (Status
)) {
414 Status
= gRT
->SetVariable (
416 &gEfiGlobalVariableGuid
,
417 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
418 ISO_639_2_ENTRY_SIZE
,
424 gBS
->FreePool (LangCodes
);
427 if (LanguageString
!= NULL
) {
428 gBS
->FreePool (LanguageString
);