diff options
author | Olivier Martin <olivier.martin@arm.com> | 2014-04-11 10:55:02 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-04-11 10:55:02 +0000 |
commit | 9fc9aa46ccf2d942b98d921bb22987fd232f6248 (patch) | |
tree | 2b269251cf83aef4437cd41fc1087170fd7e014a /ArmPlatformPkg/Bds | |
parent | e213ae45524e00441287176b962008a13a093804 (diff) | |
download | edk2-9fc9aa46ccf2d942b98d921bb22987fd232f6248.tar.gz edk2-9fc9aa46ccf2d942b98d921bb22987fd232f6248.tar.bz2 edk2-9fc9aa46ccf2d942b98d921bb22987fd232f6248.zip |
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
Diffstat (limited to 'ArmPlatformPkg/Bds')
-rw-r--r-- | ArmPlatformPkg/Bds/Bds.c | 62 | ||||
-rw-r--r-- | ArmPlatformPkg/Bds/BdsHelper.c | 15 | ||||
-rw-r--r-- | ArmPlatformPkg/Bds/BdsInternal.h | 5 |
3 files changed, 75 insertions, 7 deletions
diff --git a/ArmPlatformPkg/Bds/Bds.c b/ArmPlatformPkg/Bds/Bds.c index 2801fac531..76dd5465a2 100644 --- a/ArmPlatformPkg/Bds/Bds.c +++ b/ArmPlatformPkg/Bds/Bds.c @@ -1,6 +1,6 @@ /** @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
* 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_TYPE BootType;
EFI_DEVICE_PATH* InitrdPath;
- UINTN CmdLineSize;
UINTN InitrdSize;
+ UINTN CmdLineSize;
+ UINTN CmdLineAsciiSize;
+ CHAR16* DefaultBootArgument;
+ CHAR8* AsciiDefaultBootArgument;
//
// If Boot Order does not exist then create a default entry
@@ -262,17 +265,56 @@ DefineDefaultBootEntries ( if (BootDevicePath != NULL) {
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)) {
- CmdLineSize = AsciiStrSize ((CHAR8*)PcdGetPtr(PcdDefaultBootArgument));
InitrdPath = EfiDevicePathFromTextProtocol->ConvertTextToDevicePath ((CHAR16*)PcdGetPtr(PcdDefaultBootInitrdPath));
InitrdSize = GetDevicePathSize (InitrdPath);
- BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineSize + InitrdSize);
- BootArguments->LinuxArguments.CmdLineSize = CmdLineSize;
+ BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)AllocatePool (sizeof(ARM_BDS_LOADER_ARGUMENTS) + CmdLineAsciiSize + InitrdSize);
+ if (BootArguments == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ BootArguments->LinuxArguments.CmdLineSize = CmdLineAsciiSize;
BootArguments->LinuxArguments.InitrdSize = InitrdSize;
- CopyMem ((VOID*)(BootArguments + 1), (CHAR8*)PcdGetPtr(PcdDefaultBootArgument), CmdLineSize);
- CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineSize), InitrdPath, InitrdSize);
+ CopyMem ((VOID*)(BootArguments + 1), AsciiDefaultBootArgument, CmdLineAsciiSize);
+ CopyMem ((VOID*)((UINTN)(BootArguments + 1) + CmdLineAsciiSize), InitrdPath, InitrdSize);
} else {
BootArguments = NULL;
}
@@ -285,6 +327,12 @@ DefineDefaultBootEntries ( &BdsLoadOption
);
FreePool (BdsLoadOption);
+
+ if (DefaultBootArgument == (CHAR16*)PcdGetPtr (PcdDefaultBootArgument)) {
+ FreePool (AsciiDefaultBootArgument);
+ } else {
+ FreePool (DefaultBootArgument);
+ }
} else {
Status = EFI_UNSUPPORTED;
}
diff --git a/ArmPlatformPkg/Bds/BdsHelper.c b/ArmPlatformPkg/Bds/BdsHelper.c index 1c233d76c5..b5a3fa91b1 100644 --- a/ArmPlatformPkg/Bds/BdsHelper.c +++ b/ArmPlatformPkg/Bds/BdsHelper.c @@ -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;
+ }
+}
diff --git a/ArmPlatformPkg/Bds/BdsInternal.h b/ArmPlatformPkg/Bds/BdsInternal.h index ad593bbea6..d2c1655114 100644 --- a/ArmPlatformPkg/Bds/BdsInternal.h +++ b/ArmPlatformPkg/Bds/BdsInternal.h @@ -243,4 +243,9 @@ BootMenuMain ( VOID
);
+BOOLEAN
+IsUnicodeString (
+ IN VOID* String
+ );
+
#endif /* _BDSINTERNAL_H_ */
|