MdeModulePkg: Add BdsDxe driver and PlatformBootManagerNull library.

BdsDxe driver links to UefiBootManagerLib and PlatformBootManager to
provide a pure UEFI boot manager conforming to the UEFI spec.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17328 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ruiyu Ni 2015-05-06 04:48:56 +00:00 committed by niruiyu
parent 1d11222925
commit f4cd24da28
12 changed files with 1937 additions and 0 deletions

View File

@ -0,0 +1,62 @@
/** @file
Platform Boot Manager library definition. A platform can implement
instances to support platform-specific behavior.
Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __PLATFORM_BOOT_MANAGER_LIB_H_
#define __PLATFORM_BOOT_MANAGER_LIB_H_
#include <Library/UefiBootManagerLib.h>
/**
Do the platform specific action before the console is connected.
Such as:
Update console variable;
Register new Driver#### or Boot####;
Signal ReadyToLock event.
**/
VOID
EFIAPI
PlatformBootManagerBeforeConsole (
VOID
);
/**
Do the platform specific action after the console is connected.
Such as:
Dynamically switch output mode;
Signal console ready platform customized event;
Run diagnostics like memory testing;
Connect certain devices;
Dispatch aditional option roms.
**/
VOID
EFIAPI
PlatformBootManagerAfterConsole (
VOID
);
/**
This function is called each second during the boot manager waits the timeout.
@param TimeoutRemain The remaining timeout.
**/
VOID
EFIAPI
PlatformBootManagerWaitCallback (
UINT16 TimeoutRemain
);
#endif

View File

@ -0,0 +1,67 @@
/** @file
This file include all platform action which can be customized
by IBV/OEM.
Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Library/PlatformBootManagerLib.h>
/**
Do the platform specific action before the console is connected.
Such as:
Update console variable;
Register new Driver#### or Boot####;
Signal ReadyToLock event.
**/
VOID
EFIAPI
PlatformBootManagerBeforeConsole (
VOID
)
{
return;
}
/**
Do the platform specific action after the console is connected.
Such as:
Dynamically switch output mode;
Signal console ready platform customized event;
Run diagnostics like memory testing;
Connect certain devices;
Dispatch aditional option roms.
**/
VOID
EFIAPI
PlatformBootManagerAfterConsole (
VOID
)
{
return;
}
/**
This function is called each second during the boot manager waits the timeout.
@param TimeoutRemain The remaining timeout.
**/
VOID
EFIAPI
PlatformBootManagerWaitCallback (
UINT16 TimeoutRemain
)
{
return;
}

View File

@ -0,0 +1,36 @@
## @file
# Include all platform action which can be customized by IBV/OEM.
#
# Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = PlatformBootManagerLib
FILE_GUID = 95C097CC-8943-4038-BB8A-1C70CF2E9F3C
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = PlatformBootManagerLib|DXE_DRIVER
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
#
[Sources]
PlatformBootManager.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec

View File

@ -108,6 +108,9 @@
## @libraryclass Provides core boot manager functions
UefiBootManagerLib|Include/Library/UefiBootManagerLib.h
## @libraryclass Provides core boot manager functions
PlatformBootManagerLib|Include/Library/PlatformBootManagerLib.h
[Guids]
## MdeModule package token space guid
# Include/Guid/MdeModulePkgTokenSpace.h

View File

@ -62,6 +62,7 @@
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
#
# Generic Modules
#
@ -93,6 +94,7 @@
SmbusLib|MdePkg/Library/DxeSmbusLib/DxeSmbusLib.inf
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
CpuExceptionHandlerLib|MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf
PlatformBootManagerLib|MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManagerLibNull.inf
[LibraryClasses.EBC.PEIM]
IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
@ -269,7 +271,9 @@
MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManagerLibNull.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Universal/CapsulePei/CapsulePei.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf

View File

@ -0,0 +1,106 @@
/** @file
Head file for BDS Architectural Protocol implementation
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _BDS_MODULE_H_
#define _BDS_MODULE_H_
#include <Uefi.h>
#include <Guid/GlobalVariable.h>
#include <Guid/ConnectConInEvent.h>
#include <Guid/Performance.h>
#include <Guid/StatusCodeDataTypeVariable.h>
#include <Protocol/Bds.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/VariableLock.h>
#include <Protocol/BlockIo.h>
#include <Protocol/LoadFile.h>
#include <Protocol/SimpleFileSystem.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/BaseLib.h>
#include <Library/PcdLib.h>
#include <Library/PerformanceLib.h>
#include <Library/DevicePathLib.h>
#include <Library/PrintLib.h>
#include <Library/UefiBootManagerLib.h>
#include <Library/PlatformBootManagerLib.h>
/**
Service routine for BdsInstance->Entry(). Devices are connected, the
consoles are initialized, and the boot options are tried.
@param This Protocol Instance structure.
**/
VOID
EFIAPI
BdsEntry (
IN EFI_BDS_ARCH_PROTOCOL *This
);
/**
Set the variable and report the error through status code upon failure.
@param VariableName A Null-terminated string that is the name of the vendor's variable.
Each VariableName is unique for each VendorGuid. VariableName must
contain 1 or more characters. If VariableName is an empty string,
then EFI_INVALID_PARAMETER is returned.
@param VendorGuid A unique identifier for the vendor.
@param Attributes Attributes bitmask to set for the variable.
@param DataSize The size in bytes of the Data buffer. Unless the EFI_VARIABLE_APPEND_WRITE,
EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a size of zero
causes the variable to be deleted. When the EFI_VARIABLE_APPEND_WRITE attribute is
set, then a SetVariable() call with a DataSize of zero will not cause any change to
the variable value (the timestamp associated with the variable may be updated however
even if no new data value is provided,see the description of the
EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the DataSize will not
be zero since the EFI_VARIABLE_AUTHENTICATION_2 descriptor will be populated).
@param Data The contents for the variable.
@retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
defined by the Attributes.
@retval EFI_INVALID_PARAMETER An invalid combination of attribute bits, name, and GUID was supplied, or the
DataSize exceeds the maximum allowed.
@retval EFI_INVALID_PARAMETER VariableName is an empty string.
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
@retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
@retval EFI_WRITE_PROTECTED The variable in question is read-only.
@retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.
@retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
or EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo
does NOT pass the validation check carried out by the firmware.
@retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
**/
EFI_STATUS
BdsDxeSetVariableAndReportStatusCodeOnError (
IN CHAR16 *VariableName,
IN EFI_GUID *VendorGuid,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data
);
#endif

View File

@ -0,0 +1,101 @@
## @file
# BdsDxe module is core driver for BDS phase.
#
# When DxeCore dispatching all DXE driver, this module will produce architecture protocol
# gEfiBdsArchProtocolGuid. After DxeCore finish dispatching, DxeCore will invoke Entry
# interface of protocol gEfiBdsArchProtocolGuid, then BDS phase is entered.
#
# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BdsDxe
FILE_GUID = 6D33944A-EC75-4855-A54D-809C75241F6C
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = BdsInitialize
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
Language.h
Bds.h
HwErrRecSupport.c
HwErrRecSupport.h
Language.c
BdsEntry.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
DevicePathLib
BaseLib
MemoryAllocationLib
UefiDriverEntryPoint
UefiBootServicesTableLib
UefiRuntimeServicesTableLib
ReportStatusCodeLib
UefiLib
BaseMemoryLib
DebugLib
UefiBootManagerLib
PlatformBootManagerLib
PcdLib
[Guids]
gEfiGlobalVariableGuid ## SOMETIMES_PRODUCES ## Variable:L"BootNext" (The number of next boot option)
## SOMETIMES_PRODUCES ## Variable:L"Boot####" (Boot option variable)
## SOMETIMES_PRODUCES ## Variable:L"PlatformLang" (Platform supported languange in Rfc4646 format)
## SOMETIMES_PRODUCES ## Variable:L"Lang" (Platform supported languange in Iso639 format)
## SOMETIMES_PRODUCES ## Variable:L"Key####" (Hotkey option variable)
## PRODUCES ## Variable:L"HwErrRecSupport" (The level of platform supported hardware Error Record Persistence)
## SOMETIMES_PRODUCES ## Variable:L"BootOptionSupport" (The feature supported in boot option menu, value could be: EFI_BOOT_OPTION_SUPPORT_KEY, EFI_BOOT_OPTION_SUPPORT_APP
## SOMETIMES_PRODUCES (not PcdUefiVariableDefaultLangDeprecate) ## Variable:L"LangCodes" (Value of PcdUefiVariableDefaultLangCodes)
## PRODUCES ## Variable:L"PlatformLangCodes" (Value of PcdUefiVariableDefaultPlatformLangCodes)
## PRODUCES ## Variable:L"Timeout" (The time out value in second of showing progress bar)
## SOMETIMES_PRODUCES ## Variable:L"BootOrder" (The boot option array)
## SOMETIMES_PRODUCES ## Variable:L"DriverOrder" (The driver order list)
## SOMETIMES_CONSUMES ## Variable:L"ConIn" (The device path of console in device)
## SOMETIMES_CONSUMES ## Variable:L"ConOut" (The device path of console out device)
## SOMETIMES_CONSUMES ## Variable:L"ErrOut" (The device path of error out device)
gConnectConInEventGuid ## SOMETIMES_CONSUMES ## Event
gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID
[Protocols]
gEfiBdsArchProtocolGuid ## PRODUCES
gEfiSimpleTextInputExProtocolGuid ## CONSUMES
gEdkiiVariableLockProtocolGuid ## CONSUMES
[FeaturePcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ## CONSUMES
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangCodes ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLang ## SOMETIMES_CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLangCodes ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdHardwareErrorRecordLevel ## CONSUMES
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdErrorCodeSetVariable ## SOMETIMES_CONSUMES
[Depex]
TRUE

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
/** @file
Set the level of support for Hardware Error Record Persistence that is
implemented by the platform.
Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "HwErrRecSupport.h"
/**
Set the HwErrRecSupport variable contains a binary UINT16 that supplies the
level of support for Hardware Error Record Persistence that is implemented
by the platform.
**/
VOID
InitializeHwErrRecSupport (
VOID
)
{
EFI_STATUS Status;
UINT16 HardwareErrorRecordLevel;
HardwareErrorRecordLevel = PcdGet16 (PcdHardwareErrorRecordLevel);
if (HardwareErrorRecordLevel != 0) {
//
// If level value equal 0, no need set to 0 to variable area because UEFI specification
// define same behavior between no value or 0 value for L"HwErrRecSupport".
//
Status = gRT->SetVariable (
L"HwErrRecSupport",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
sizeof (UINT16),
&HardwareErrorRecordLevel
);
ASSERT_EFI_ERROR(Status);
}
}

View File

@ -0,0 +1,32 @@
/** @file
Set the level of support for Hardware Error Record Persistence that is
implemented by the platform.
Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _HW_ERR_REC_SUPPORT_H_
#define _HW_ERR_REC_SUPPORT_H_
#include "Bds.h"
/**
Set the HwErrRecSupport variable contains a binary UINT16 that supplies the
level of support for Hardware Error Record Persistence that is implemented
by the platform.
**/
VOID
InitializeHwErrRecSupport (
VOID
);
#endif

View File

@ -0,0 +1,202 @@
/** @file
Language settings
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "Bds.h"
#define ISO_639_2_ENTRY_SIZE 3
/**
Check if lang is in supported language codes according to language string.
This code is used to check if lang is in in supported language codes. It can handle
RFC4646 and ISO639 language tags.
In ISO639 language tags, take 3-characters as a delimitation to find matched string.
In RFC4646 language tags, take semicolon as a delimitation to find matched string.
For example:
SupportedLang = "engfraengfra"
Iso639Language = TRUE
Lang = "eng", the return value is "TRUE", or
Lang = "chs", the return value is "FALSE".
Another example:
SupportedLang = "en;fr;en-US;fr-FR"
Iso639Language = FALSE
Lang = "en", the return value is "TRUE", or
Lang = "zh", the return value is "FALSE".
@param SupportedLang Platform supported language codes.
@param Lang Configured language.
@param Iso639Language A bool value to signify if the handler is operated on ISO639 or RFC4646.
@retval TRUE lang is in supported language codes.
@retval FALSE lang is not in supported language codes.
**/
BOOLEAN
IsLangInSupportedLangCodes(
IN CHAR8 *SupportedLang,
IN CHAR8 *Lang,
IN BOOLEAN Iso639Language
)
{
UINTN Index;
UINTN CompareLength;
UINTN LanguageLength;
if (Iso639Language) {
CompareLength = ISO_639_2_ENTRY_SIZE;
for (Index = 0; Index < AsciiStrLen (SupportedLang); Index += CompareLength) {
if (AsciiStrnCmp (Lang, SupportedLang + Index, CompareLength) == 0) {
//
// Successfully find the Lang string in SupportedLang string.
//
return TRUE;
}
}
return FALSE;
} else {
//
// Compare RFC4646 language code
//
for (LanguageLength = 0; Lang[LanguageLength] != '\0'; LanguageLength++);
for (; *SupportedLang != '\0'; SupportedLang += CompareLength) {
//
// Skip ';' characters in SupportedLang
//
for (; *SupportedLang != '\0' && *SupportedLang == ';'; SupportedLang++);
//
// Determine the length of the next language code in SupportedLang
//
for (CompareLength = 0; SupportedLang[CompareLength] != '\0' && SupportedLang[CompareLength] != ';'; CompareLength++);
if ((CompareLength == LanguageLength) &&
(AsciiStrnCmp (Lang, SupportedLang, CompareLength) == 0)) {
//
// Successfully find the Lang string in SupportedLang string.
//
return TRUE;
}
}
return FALSE;
}
}
/**
Initialize Lang or PlatformLang variable, if Lang or PlatformLang variable is not found,
or it has been set to an unsupported value(not one of platform supported language codes),
set the default language code to it.
@param LangName Language name, L"Lang" or L"PlatformLang".
@param SupportedLang Platform supported language codes.
@param DefaultLang Default language code.
@param Iso639Language A bool value to signify if the handler is operated on ISO639 or RFC4646,
TRUE for L"Lang" LangName or FALSE for L"PlatformLang" LangName.
**/
VOID
InitializeLangVariable (
IN CHAR16 *LangName,
IN CHAR8 *SupportedLang,
IN CHAR8 *DefaultLang,
IN BOOLEAN Iso639Language
)
{
CHAR8 *Lang;
//
// Find current Lang or PlatformLang from EFI Variable.
//
GetEfiGlobalVariable2 (LangName, (VOID **) &Lang, NULL);
//
// If Lang or PlatformLang variable is not found,
// or it has been set to an unsupported value(not one of the supported language codes),
// set the default language code to it.
//
if ((Lang == NULL) || !IsLangInSupportedLangCodes (SupportedLang, Lang, Iso639Language)) {
//
// The default language code should be one of the supported language codes.
//
ASSERT (IsLangInSupportedLangCodes (SupportedLang, DefaultLang, Iso639Language));
BdsDxeSetVariableAndReportStatusCodeOnError (
LangName,
&gEfiGlobalVariableGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
AsciiStrSize (DefaultLang),
DefaultLang
);
}
if (Lang != NULL) {
FreePool (Lang);
}
}
/**
Determine the current language that will be used
based on language related EFI Variables.
@param LangCodesSettingRequired - If required to set LangCodes variable
**/
VOID
InitializeLanguage (
BOOLEAN LangCodesSettingRequired
)
{
EFI_STATUS Status;
CHAR8 *LangCodes;
CHAR8 *PlatformLangCodes;
LangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultLangCodes);
PlatformLangCodes = (CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes);
if (LangCodesSettingRequired) {
if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) {
//
// UEFI 2.1 depricated this variable so we support turning it off
//
Status = gRT->SetVariable (
L"LangCodes",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
AsciiStrSize (LangCodes),
LangCodes
);
//
// Platform needs to make sure setting volatile variable before calling 3rd party code shouldn't fail.
//
ASSERT_EFI_ERROR(Status);
}
Status = gRT->SetVariable (
L"PlatformLangCodes",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
AsciiStrSize (PlatformLangCodes),
PlatformLangCodes
);
//
// Platform needs to make sure setting volatile variable before calling 3rd party code shouldn't fail.
//
ASSERT_EFI_ERROR(Status);
}
if (!FeaturePcdGet (PcdUefiVariableDefaultLangDeprecate)) {
//
// UEFI 2.1 depricated this variable so we support turning it off
//
InitializeLangVariable (L"Lang", LangCodes, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultLang), TRUE);
}
InitializeLangVariable (L"PlatformLang", PlatformLangCodes, (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang), FALSE);
}

View File

@ -0,0 +1,30 @@
/** @file
Language setting
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _LANGUAGE_H_
#define _LANGUAGE_H_
/**
Determine the current language that will be used
based on language related EFI Variables.
@param LangCodesSettingRequired If required to set LangCode variable
**/
VOID
InitializeLanguage (
BOOLEAN LangCodesSettingRequired
);
#endif // _LANGUAGE_H_