3 Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>
4 Copyright (c) 2017, Linaro.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef __ABOOTIMG_H__
11 #define __ABOOTIMG_H__
13 #include <Library/BaseLib.h>
14 #include <Library/DebugLib.h>
15 #include <Library/MemoryAllocationLib.h>
17 #include <Uefi/UefiBaseType.h>
18 #include <Uefi/UefiSpec.h>
20 #define ANDROID_BOOTIMG_KERNEL_ARGS_SIZE 512
22 #define ANDROID_BOOT_MAGIC "ANDROID!"
23 #define ANDROID_BOOT_MAGIC_LENGTH (sizeof (ANDROID_BOOT_MAGIC) - 1)
25 // No documentation for this really - sizes of fields has been determined
28 /* https://android.googlesource.com/platform/system/core/+/master/mkbootimg/bootimg.h */
30 UINT8 BootMagic
[ANDROID_BOOT_MAGIC_LENGTH
];
34 UINT32 RamdiskAddress
;
35 UINT32 SecondStageBootloaderSize
;
36 UINT32 SecondStageBootloaderAddress
;
37 UINT32 KernelTaggsAddress
;
40 CHAR8 ProductName
[16];
41 CHAR8 KernelArgs
[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE
];
43 } ANDROID_BOOTIMG_HEADER
;
46 /* Check Val (unsigned) is a power of 2 (has only one bit set) */
47 #define IS_POWER_OF_2(Val) ((Val) != 0 && (((Val) & ((Val) - 1)) == 0))
49 /* Android boot image page size is not specified, but it should be power of 2
50 * and larger than boot header */
51 #define IS_VALID_ANDROID_PAGE_SIZE(Val) \
52 (IS_POWER_OF_2(Val) && (Val > sizeof(ANDROID_BOOTIMG_HEADER)))
55 AndroidBootImgGetImgSize (
66 #endif /* __ABOOTIMG_H__ */