]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/PlatformBdsDxe/Generic/Language.c
Replaced by Y:\work\MdeModulePkg\Library\GenericBdsLib\GenericBdsLib.inf
[mirror_edk2.git] / Nt32Pkg / PlatformBdsDxe / Generic / Language.c
1 /*++
2
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
8
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.
11
12 Module Name:
13
14 language.c
15
16 Abstract:
17
18 Language settings
19
20 Revision History
21
22 --*/
23 #include "Bds.h"
24 #include "BdsString.h"
25 #include "Language.h"
26
27
28 VOID
29 InitializeLanguage (
30 BOOLEAN LangCodesSettingRequired
31 )
32 /*++
33
34 Routine Description:
35 Determine the current language that will be used
36 based on language related EFI Variables
37
38 Arguments:
39 LangCodesSettingRequired - If required to set LangCode variable
40
41 Returns:
42
43 --*/
44 {
45 EFI_STATUS Status;
46 UINTN Size;
47 CHAR8 *Lang;
48 CHAR8 LangCode[ISO_639_2_ENTRY_SIZE];
49 CHAR8 *LangCodes;
50 CHAR8 *PlatformLang;
51 CHAR8 *PlatformLangCodes;
52 UINTN Index;
53 BOOLEAN Invalid;
54
55
56 LangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultLangCodes);
57 if (LangCodesSettingRequired) {
58 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate)) {
59 //
60 // UEFI 2.1 depricated this variable so we support turning it off
61 //
62 Status = gRT->SetVariable (
63 L"LangCodes",
64 &gEfiGlobalVariableGuid,
65 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
66 AsciiStrLen (LangCodes),
67 LangCodes
68 );
69 }
70
71
72 PlatformLangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes);
73 Status = gRT->SetVariable (
74 L"PlatformLangCodes",
75 &gEfiGlobalVariableGuid,
76 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
77 AsciiStrSize (PlatformLangCodes),
78 PlatformLangCodes
79 );
80 }
81
82 if (!FeaturePcdGet (PcdUefiVariableDefaultLangDepricate)) {
83 //
84 // UEFI 2.1 depricated this variable so we support turning it off
85 //
86
87 //
88 // Find current LangCode from Lang NV Variable
89 //
90 Size = ISO_639_2_ENTRY_SIZE;
91 Status = gRT->GetVariable (
92 L"Lang",
93 &gEfiGlobalVariableGuid,
94 NULL,
95 &Size,
96 &LangCode
97 );
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;
103 break;
104 }
105 }
106 }
107
108 //
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.
112 //
113 if (EFI_ERROR (Status)) {
114 Lang = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultLang);
115 Status = gRT->SetVariable (
116 L"Lang",
117 &gEfiGlobalVariableGuid,
118 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
119 ISO_639_2_ENTRY_SIZE,
120 Lang
121 );
122 }
123 }
124
125 Invalid = FALSE;
126 PlatformLang = BdsLibGetVariableAndSize (L"PlatformLang", &gEfiGlobalVariableGuid, &Size);
127 if (PlatformLang != NULL) {
128 //
129 // Check Current PlatformLang value against PlatformLangCode. Need a library that is TBD
130 // Set Invalid based on state of PlatformLang.
131 //
132
133 FreePool (PlatformLang);
134 } else {
135 // No valid variable is set
136 Invalid = TRUE;
137 }
138
139 if (Invalid) {
140 PlatformLang = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLang);
141 Status = gRT->SetVariable (
142 L"PlatformLang",
143 &gEfiGlobalVariableGuid,
144 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
145 AsciiStrSize (PlatformLang),
146 PlatformLang
147 );
148 }
149 }