mirror of https://github.com/acidanthera/audk.git
ArmPlatformPkg/Bds: Add support to handle Unicode parameters
Most UEFI applications expect unicode string parameter. This change is allows to support Ascii or Unicode strings. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15450 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
e213ae4552
commit
9fc9aa46cc
|
@ -1,6 +1,6 @@
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
|
* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials
|
* This program and the accompanying materials
|
||||||
* are licensed and made available under the terms and conditions of the BSD License
|
* are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
@ -223,8 +223,11 @@ DefineDefaultBootEntries (
|
||||||
ARM_BDS_LOADER_ARGUMENTS* BootArguments;
|
ARM_BDS_LOADER_ARGUMENTS* BootArguments;
|
||||||
ARM_BDS_LOADER_TYPE BootType;
|
ARM_BDS_LOADER_TYPE BootType;
|
||||||
EFI_DEVICE_PATH* InitrdPath;
|
EFI_DEVICE_PATH* InitrdPath;
|
||||||
UINTN CmdLineSize;
|
|
||||||
UINTN InitrdSize;
|
UINTN InitrdSize;
|
||||||
|
UINTN CmdLineSize;
|
||||||
|
UINTN CmdLineAsciiSize;
|
||||||
|
CHAR16* DefaultBootArgument;
|
||||||
|
CHAR8* AsciiDefaultBootArgument;
|
||||||
|
|
||||||
//
|
//
|
||||||
// If Boot Order does not exist then create a default entry
|
// If Boot Order does not exist then create a default entry
|
||||||
|
@ -262,17 +265,56 @@ DefineDefaultBootEntries (
|
||||||
if (BootDevicePath != NULL) {
|
if (BootDevicePath != NULL) {
|
||||||
BootType = (ARM_BDS_LOADER_TYPE)PcdGet32 (PcdDefaultBootType);
|
BootType = (ARM_BDS_LOADER_TYPE)PcdGet32 (PcdDefaultBootType);
|
||||||
|
|
||||||
|
// We do not support NULL pointer
|
||||||
|
ASSERT (PcdGetPtr (PcdDefaultBootArgument) != NULL);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Logic to handle ASCII or Unicode default parameters
|
||||||
|
//
|
||||||
|
if (*(CHAR8*)PcdGetPtr (PcdDefaultBootArgument) == '\0') {
|
||||||
|
CmdLineSize = 0;
|
||||||
|
CmdLineAsciiSize = 0;
|
||||||
|
DefaultBootArgument = NULL;
|
||||||
|
AsciiDefaultBootArgument = NULL;
|
||||||
|
} else if (IsUnicodeString ((CHAR16*)PcdGetPtr (PcdDefaultBootArgument))) {
|
||||||
|
// The command line is a Unicode string
|
||||||
|
DefaultBootArgument = (CHAR16*)PcdGetPtr (PcdDefaultBootArgument);
|
||||||
|
CmdLineSize = StrSize (DefaultBootArgument);
|
||||||
|
|
||||||
|
// Initialize ASCII variables
|
||||||
|
CmdLineAsciiSize = CmdLineSize / 2;
|
||||||
|
AsciiDefaultBootArgument = AllocatePool (CmdLineAsciiSize);
|
||||||
|
if (AsciiDefaultBootArgument == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
UnicodeStrToAsciiStr ((CHAR16*)PcdGetPtr (PcdDefaultBootArgument), AsciiDefaultBootArgument);
|
||||||
|
} else {
|
||||||
|
// The command line is a ASCII string
|
||||||
|
AsciiDefaultBootArgument = (CHAR8*)PcdGetPtr (PcdDefaultBootArgument);
|
||||||
|
CmdLineAsciiSize = AsciiStrSize (AsciiDefaultBootArgument);
|
||||||
|
|
||||||
|
// Initialize ASCII variables
|
||||||
|
CmdLineSize = CmdLineAsciiSize * 2;
|
||||||
|
DefaultBootArgument = AllocatePool (CmdLineSize);
|
||||||
|
if (DefaultBootArgument == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
AsciiStrToUnicodeStr (AsciiDefaultBootArgument, DefaultBootArgument);
|
||||||
|
}
|
||||||
|
|
||||||
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
|
if ((BootType == BDS_LOADER_KERNEL_LINUX_ATAG) || (BootType == BDS_LOADER_KERNEL_LINUX_FDT)) {
|
||||||
CmdLineSize = AsciiStrSize ((CHAR8*)PcdGetPtr(PcdDefaultBootArgument));
|
|
||||||
InitrdPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath));
|
InitrdPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath));
|
||||||
InitrdSize = GetDevicePathSize (InitrdPath);
|
InitrdSize = GetDevicePathSize (InitrdPath);
|
||||||
|
|
||||||
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
|
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineAsciiSize + InitrdSize);
|
||||||
BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
|
if (BootArguments == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
BootArguments->LinuxArguments.CmdLineSize = CmdLineAsciiSize;
|
||||||
BootArguments->LinuxArguments.InitrdSize = InitrdSize;
|
BootArguments->LinuxArguments.InitrdSize = InitrdSize;
|
||||||
|
|
||||||
CopyMem ((VOID*)(BootArguments + 1), (CHAR8*)PcdGetPtr(PcdDefaultBootArgument), CmdLineSize);
|
CopyMem ((VOID*)(BootArguments + 1), AsciiDefaultBootArgument, CmdLineAsciiSize);
|
||||||
CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
|
CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineAsciiSize), InitrdPath, InitrdSize);
|
||||||
} else {
|
} else {
|
||||||
BootArguments = NULL;
|
BootArguments = NULL;
|
||||||
}
|
}
|
||||||
|
@ -285,6 +327,12 @@ DefineDefaultBootEntries (
|
||||||
&BdsLoadOption
|
&BdsLoadOption
|
||||||
);
|
);
|
||||||
FreePool (BdsLoadOption);
|
FreePool (BdsLoadOption);
|
||||||
|
|
||||||
|
if (DefaultBootArgument == (CHAR16*)PcdGetPtr (PcdDefaultBootArgument)) {
|
||||||
|
FreePool (AsciiDefaultBootArgument);
|
||||||
|
} else {
|
||||||
|
FreePool (DefaultBootArgument);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Status = EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,3 +323,18 @@ GetAlignedDevicePath (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
IsUnicodeString (
|
||||||
|
IN VOID* String
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// We do not support NULL pointer
|
||||||
|
ASSERT (String != NULL);
|
||||||
|
|
||||||
|
if (*(CHAR16*)String < 0x100) {
|
||||||
|
//Note: We could get issue if the string is an empty Ascii string...
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -243,4 +243,9 @@ BootMenuMain (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
IsUnicodeString (
|
||||||
|
IN VOID* String
|
||||||
|
);
|
||||||
|
|
||||||
#endif /* _BDSINTERNAL_H_ */
|
#endif /* _BDSINTERNAL_H_ */
|
||||||
|
|
Loading…
Reference in New Issue