3 Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>
4 Copyright (c) 2017, Linaro.
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef __ABOOTIMG_H__
17 #define __ABOOTIMG_H__
19 #include <Library/BaseLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/MemoryAllocationLib.h>
23 #include <Uefi/UefiBaseType.h>
24 #include <Uefi/UefiSpec.h>
26 #define ANDROID_BOOTIMG_KERNEL_ARGS_SIZE 512
28 #define ANDROID_BOOT_MAGIC "ANDROID!"
29 #define ANDROID_BOOT_MAGIC_LENGTH (sizeof (ANDROID_BOOT_MAGIC) - 1)
31 // No documentation for this really - sizes of fields has been determined
34 /* https://android.googlesource.com/platform/system/core/+/master/mkbootimg/bootimg.h */
36 UINT8 BootMagic
[ANDROID_BOOT_MAGIC_LENGTH
];
40 UINT32 RamdiskAddress
;
41 UINT32 SecondStageBootloaderSize
;
42 UINT32 SecondStageBootloaderAddress
;
43 UINT32 KernelTaggsAddress
;
46 CHAR8 ProductName
[16];
47 CHAR8 KernelArgs
[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE
];
49 } ANDROID_BOOTIMG_HEADER
;
52 /* Check Val (unsigned) is a power of 2 (has only one bit set) */
53 #define IS_POWER_OF_2(Val) ((Val) != 0 && (((Val) & ((Val) - 1)) == 0))
54 /* Android boot image page size is not specified, but it should be power of 2
55 * and larger than boot header */
56 #define IS_VALID_ANDROID_PAGE_SIZE(Val) \
57 (IS_POWER_OF_2(Val) && (Val > sizeof(ANDROID_BOOTIMG_HEADER)))
60 AndroidBootImgGetImgSize (
71 #endif /* __ABOOTIMG_H__ */