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"
29 #include "BdsString.h"
35 BOOLEAN LangCodesSettingRequired
40 Determine the current language that will be used
41 based on language related EFI Variables
44 LangCodesSettingRequired - If required to set LangCode variable
53 CHAR8 LangCode
[ISO_639_2_ENTRY_SIZE
];
56 CHAR8
*PlatformLangCodes
;
61 LangCodes
= (CHAR8
*)PcdGetPtr (PcdUefiVariableDefaultLangCodes
);
62 if (LangCodesSettingRequired
) {
63 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate
)) {
65 // UEFI 2.1 depricated this variable so we support turning it off
67 Status
= gRT
->SetVariable (
69 &gEfiGlobalVariableGuid
,
70 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
71 AsciiStrLen (LangCodes
),
77 PlatformLangCodes
= (CHAR8
*)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes
);
78 Status
= gRT
->SetVariable (
80 &gEfiGlobalVariableGuid
,
81 EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
82 AsciiStrSize (PlatformLangCodes
),
87 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate
)) {
89 // UEFI 2.1 depricated this variable so we support turning it off
93 // Find current LangCode from Lang NV Variable
95 Size
= ISO_639_2_ENTRY_SIZE
;
96 Status
= gRT
->GetVariable (
98 &gEfiGlobalVariableGuid
,
103 if (!EFI_ERROR (Status
)) {
104 Status
= EFI_NOT_FOUND
;
105 for (Index
= 0; LangCodes
[Index
] != 0; Index
+= ISO_639_2_ENTRY_SIZE
) {
106 if (CompareMem (&LangCodes
[Index
], LangCode
, ISO_639_2_ENTRY_SIZE
) == 0) {
107 Status
= EFI_SUCCESS
;
114 // If we cannot get language code from Lang variable,
115 // or LangCode cannot be found from language table,
116 // set the mDefaultLangCode to Lang variable.
118 if (EFI_ERROR (Status
)) {
119 Lang
= (CHAR8
*)PcdGetPtr (PcdUefiVariableDefaultLang
);
120 Status
= gRT
->SetVariable (
122 &gEfiGlobalVariableGuid
,
123 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
124 ISO_639_2_ENTRY_SIZE
,
131 PlatformLang
= BdsLibGetVariableAndSize (L
"PlatformLang", &gEfiGlobalVariableGuid
, &Size
);
132 if (PlatformLang
!= NULL
) {
134 // Check Current PlatformLang value against PlatformLangCode. Need a library that is TBD
135 // Set Invalid based on state of PlatformLang.
138 FreePool (PlatformLang
);
140 // No valid variable is set
145 PlatformLang
= (CHAR8
*)PcdGetPtr (PcdUefiVariableDefaultPlatformLang
);
146 Status
= gRT
->SetVariable (
148 &gEfiGlobalVariableGuid
,
149 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
150 AsciiStrSize (PlatformLang
),