diff options
author | Jun Nie <jun.nie@linaro.org> | 2017-08-02 22:03:40 +0800 |
---|---|---|
committer | Leif Lindholm <leif.lindholm@linaro.org> | 2017-08-07 17:25:57 +0100 |
commit | 6e414300b5f19d3045a0d21ad90ac2fe965478a5 (patch) | |
tree | 4237da390f26bb7b4911295e87d11aa46c79b1af /EmbeddedPkg/Application | |
parent | dba1521c3d620b1ee8404591436fae8f69c83267 (diff) | |
download | edk2-6e414300b5f19d3045a0d21ad90ac2fe965478a5.zip edk2-6e414300b5f19d3045a0d21ad90ac2fe965478a5.tar.gz edk2-6e414300b5f19d3045a0d21ad90ac2fe965478a5.tar.bz2 |
EmbeddedPkg/AndroidFastboot: split android boot header
Split android boot header definition to share code among
different applications and libraries.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jun Nie <jun.nie@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'EmbeddedPkg/Application')
3 files changed, 7 insertions, 31 deletions
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c index f3e770b..2f7f093 100644 --- a/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c +++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c @@ -14,32 +14,6 @@ #include "AndroidFastbootApp.h"
-#define BOOT_MAGIC "ANDROID!"
-#define BOOT_MAGIC_LENGTH sizeof (BOOT_MAGIC) - 1
-
-// Check Val (unsigned) is a power of 2 (has only one bit set)
-#define IS_POWER_OF_2(Val) (Val != 0 && ((Val & (Val - 1)) == 0))
-
-// No documentation for this really - sizes of fields has been determined
-// empirically.
-#pragma pack(1)
-typedef struct {
- CHAR8 BootMagic[BOOT_MAGIC_LENGTH];
- UINT32 KernelSize;
- UINT32 KernelAddress;
- UINT32 RamdiskSize;
- UINT32 RamdiskAddress;
- UINT32 SecondStageBootloaderSize;
- UINT32 SecondStageBootloaderAddress;
- UINT32 KernelTaggsAddress;
- UINT32 PageSize;
- UINT32 Reserved[2];
- CHAR8 ProductName[16];
- CHAR8 KernelArgs[BOOTIMG_KERNEL_ARGS_SIZE];
- UINT32 Id[32];
-} ANDROID_BOOTIMG_HEADER;
-#pragma pack()
-
// Find the kernel and ramdisk in an Android boot.img.
// return EFI_INVALID_PARAMTER if the boot.img is invalid (i.e. doesn't have the
// right magic value),
@@ -64,7 +38,8 @@ ParseAndroidBootImg ( Header = (ANDROID_BOOTIMG_HEADER *) BootImg;
- if (AsciiStrnCmp (Header->BootMagic, BOOT_MAGIC, BOOT_MAGIC_LENGTH) != 0) {
+ if (AsciiStrnCmp ((CONST CHAR8 *)Header->BootMagic, ANDROID_BOOT_MAGIC,
+ ANDROID_BOOT_MAGIC_LENGTH) != 0) {
return EFI_INVALID_PARAMETER;
}
@@ -72,7 +47,7 @@ ParseAndroidBootImg ( return EFI_NOT_FOUND;
}
- ASSERT (IS_POWER_OF_2 (Header->PageSize));
+ ASSERT (IS_VALID_ANDROID_PAGE_SIZE (Header->PageSize));
*KernelSize = Header->KernelSize;
*Kernel = BootImgBytePtr + Header->PageSize;
@@ -84,8 +59,8 @@ ParseAndroidBootImg ( + ALIGN_VALUE (Header->KernelSize, Header->PageSize));
}
- AsciiStrnCpyS (KernelArgs, BOOTIMG_KERNEL_ARGS_SIZE, Header->KernelArgs,
- BOOTIMG_KERNEL_ARGS_SIZE);
+ AsciiStrnCpyS (KernelArgs, ANDROID_BOOTIMG_KERNEL_ARGS_SIZE, Header->KernelArgs,
+ ANDROID_BOOTIMG_KERNEL_ARGS_SIZE);
return EFI_SUCCESS;
}
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h index f62660f..e4c5aa3 100644 --- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h +++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h @@ -15,6 +15,7 @@ #ifndef __ANDROID_FASTBOOT_APP_H__
#define __ANDROID_FASTBOOT_APP_H__
+#include <Library/AndroidBootImgLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c index f446cce..1d9024b 100644 --- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c +++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c @@ -112,7 +112,7 @@ BootAndroidBootImg ( )
{
EFI_STATUS Status;
- CHAR8 KernelArgs[BOOTIMG_KERNEL_ARGS_SIZE];
+ CHAR8 KernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
VOID *Kernel;
UINTN KernelSize;
VOID *Ramdisk;
|