ArmPkg: only attempt buildin MmCommunicationDxe for AArch64
[mirror_edk2.git] / EmbeddedPkg / Include / Library / AndroidBootImgLib.h
1 /** @file
2
3 Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>
4 Copyright (c) 2017, Linaro.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef __ABOOTIMG_H__
11 #define __ABOOTIMG_H__
12
13 #include <Library/BaseLib.h>
14 #include <Library/DebugLib.h>
15 #include <Library/MemoryAllocationLib.h>
16
17 #include <Uefi/UefiBaseType.h>
18 #include <Uefi/UefiSpec.h>
19
20 #define ANDROID_BOOTIMG_KERNEL_ARGS_SIZE 512
21
22 #define ANDROID_BOOT_MAGIC "ANDROID!"
23 #define ANDROID_BOOT_MAGIC_LENGTH (sizeof (ANDROID_BOOT_MAGIC) - 1)
24
25 // No documentation for this really - sizes of fields has been determined
26 // empirically.
27 #pragma pack(1)
28 /* https://android.googlesource.com/platform/system/core/+/master/mkbootimg/bootimg.h */
29 typedef struct {
30 UINT8 BootMagic[ANDROID_BOOT_MAGIC_LENGTH];
31 UINT32 KernelSize;
32 UINT32 KernelAddress;
33 UINT32 RamdiskSize;
34 UINT32 RamdiskAddress;
35 UINT32 SecondStageBootloaderSize;
36 UINT32 SecondStageBootloaderAddress;
37 UINT32 KernelTaggsAddress;
38 UINT32 PageSize;
39 UINT32 Reserved[2];
40 CHAR8 ProductName[16];
41 CHAR8 KernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
42 UINT32 Id[32];
43 } ANDROID_BOOTIMG_HEADER;
44 #pragma pack ()
45
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))
48 /* Android boot image page size is not specified, but it should be power of 2
49 * and larger than boot header */
50 #define IS_VALID_ANDROID_PAGE_SIZE(Val) \
51 (IS_POWER_OF_2(Val) && (Val > sizeof(ANDROID_BOOTIMG_HEADER)))
52
53 EFI_STATUS
54 AndroidBootImgGetImgSize (
55 IN VOID *BootImg,
56 OUT UINTN *ImgSize
57 );
58
59 EFI_STATUS
60 AndroidBootImgBoot (
61 IN VOID *Buffer,
62 IN UINTN BufferSize
63 );
64
65 #endif /* __ABOOTIMG_H__ */