summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/Include
diff options
context:
space:
mode:
authorJun Nie <jun.nie@linaro.org>2017-08-02 22:03:40 +0800
committerLeif Lindholm <leif.lindholm@linaro.org>2017-08-07 17:25:57 +0100
commit6e414300b5f19d3045a0d21ad90ac2fe965478a5 (patch)
tree4237da390f26bb7b4911295e87d11aa46c79b1af /EmbeddedPkg/Include
parentdba1521c3d620b1ee8404591436fae8f69c83267 (diff)
downloadedk2-6e414300b5f19d3045a0d21ad90ac2fe965478a5.tar.gz
edk2-6e414300b5f19d3045a0d21ad90ac2fe965478a5.tar.bz2
edk2-6e414300b5f19d3045a0d21ad90ac2fe965478a5.zip
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/Include')
-rw-r--r--EmbeddedPkg/Include/Library/AndroidBootImgLib.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/EmbeddedPkg/Include/Library/AndroidBootImgLib.h b/EmbeddedPkg/Include/Library/AndroidBootImgLib.h
new file mode 100644
index 0000000000..06da751181
--- /dev/null
+++ b/EmbeddedPkg/Include/Library/AndroidBootImgLib.h
@@ -0,0 +1,58 @@
+/** @file
+
+ Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>
+ Copyright (c) 2017, Linaro.
+
+ 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 __ABOOTIMG_H__
+#define __ABOOTIMG_H__
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+#include <Uefi/UefiBaseType.h>
+#include <Uefi/UefiSpec.h>
+
+#define ANDROID_BOOTIMG_KERNEL_ARGS_SIZE 512
+
+#define ANDROID_BOOT_MAGIC "ANDROID!"
+#define ANDROID_BOOT_MAGIC_LENGTH (sizeof (ANDROID_BOOT_MAGIC) - 1)
+
+// No documentation for this really - sizes of fields has been determined
+// empirically.
+#pragma pack(1)
+/* https://android.googlesource.com/platform/system/core/+/master/mkbootimg/bootimg.h */
+typedef struct {
+ UINT8 BootMagic[ANDROID_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[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
+ UINT32 Id[32];
+} ANDROID_BOOTIMG_HEADER;
+#pragma pack ()
+
+/* 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))
+/* Android boot image page size is not specified, but it should be power of 2
+ * and larger than boot header */
+#define IS_VALID_ANDROID_PAGE_SIZE(Val) \
+ (IS_POWER_OF_2(Val) && (Val > sizeof(ANDROID_BOOTIMG_HEADER)))
+#endif /* __ABOOTIMG_H__ */