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