TianoCore EDK2 master
Loading...
Searching...
No Matches
AndroidBootImgLib.h
Go to the documentation of this file.
1
10#ifndef __ABOOTIMG_H__
11#define __ABOOTIMG_H__
12
13#include <Library/BaseLib.h>
14#include <Library/DebugLib.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 */
29typedef 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];
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
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)))
53
55AndroidBootImgGetImgSize (
56 IN VOID *BootImg,
57 OUT UINTN *ImgSize
58 );
59
61AndroidBootImgBoot (
62 IN VOID *Buffer,
63 IN UINTN BufferSize
64 );
65
66#endif /* __ABOOTIMG_H__ */
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29