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.
24 #include "BdsString.h"
30 BOOLEAN LangCodesSettingRequired
35 Determine the current language that will be used
36 based on language related EFI Variables
39 LangCodesSettingRequired - If required to set LangCode variable
48 CHAR8 LangCode
[ISO_639_2_ENTRY_SIZE
];
51 CHAR8
*PlatformLangCodes
;
56 LangCodes
= (CHAR8
*)PcdGetPtr (PcdUefiVariableDefaultLangCodes
);
57 if (LangCodesSettingRequired
) {
58 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate
)) {
60 // UEFI 2.1 depricated this variable so we support turning it off
62 Status
= gRT
->SetVariable (
64 &gEfiGlobalVariableGuid
,
65 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
66 AsciiStrLen (LangCodes
),
72 PlatformLangCodes
= (CHAR8
*)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
);
73 Status
= gRT
->SetVariable (
75 &gEfiGlobalVariableGuid
,
76 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
77 AsciiStrSize (PlatformLangCodes
),
82 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate
)) {
84 // UEFI 2.1 depricated this variable so we support turning it off
88 // Find current LangCode from Lang NV Variable
90 Size
= ISO_639_2_ENTRY_SIZE
;
91 Status
= gRT
->GetVariable (
93 &gEfiGlobalVariableGuid
,
98 if (!EFI_ERROR (Status
)) {
99 Status
= EFI_NOT_FOUND
;
100 for (Index
= 0; LangCodes
[Index
] != 0; Index
+= ISO_639_2_ENTRY_SIZE
) {
101 if (CompareMem (&LangCodes
[Index
], LangCode
, ISO_639_2_ENTRY_SIZE
) == 0) {
102 Status
= EFI_SUCCESS
;
109 // If we cannot get language code from Lang variable,
110 // or LangCode cannot be found from language table,
111 // set the mDefaultLangCode to Lang variable.
113 if (EFI_ERROR (Status
)) {
114 Lang
= (CHAR8
*)PcdGetPtr (PcdUefiVariableDefaultLang
);
115 Status
= gRT
->SetVariable (
117 &gEfiGlobalVariableGuid
,
118 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
119 ISO_639_2_ENTRY_SIZE
,
126 PlatformLang
= BdsLibGetVariableAndSize (L
"PlatformLang", &gEfiGlobalVariableGuid
, &Size
);
127 if (PlatformLang
!= NULL
) {
129 // Check Current PlatformLang value against PlatformLangCode. Need a library that is TBD
130 // Set Invalid based on state of PlatformLang.
133 FreePool (PlatformLang
);
135 // No valid variable is set
140 PlatformLang
= (CHAR8
*)PcdGetPtr (PcdUefiVariableDefaultPlatformLang
);
141 Status
= gRT
->SetVariable (
143 &gEfiGlobalVariableGuid
,
144 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
145 AsciiStrSize (PlatformLang
),