2 * This is from the Android Project,
3 * Repository: https://android.googlesource.com/platform/system/core/
4 * File: mkbootimg/bootimg.h
5 * Commit: d162828814b08ada310846a33205befb69ef5799
7 * Copyright (C) 2008 The Android Open Source Project
9 * SPDX-License-Identifier: BSD-2-Clause
12 #ifndef _ANDROID_IMAGE_H_
13 #define _ANDROID_IMAGE_H_
15 typedef struct andr_img_hdr andr_img_hdr;
17 #define ANDR_BOOT_MAGIC "ANDROID!"
18 #define ANDR_BOOT_MAGIC_SIZE 8
19 #define ANDR_BOOT_NAME_SIZE 16
20 #define ANDR_BOOT_ARGS_SIZE 512
21 #define ANDR_BOOT_EXTRA_ARGS_SIZE 1024
24 char magic[ANDR_BOOT_MAGIC_SIZE];
26 u32 kernel_size; /* size in bytes */
27 u32 kernel_addr; /* physical load addr */
29 u32 ramdisk_size; /* size in bytes */
30 u32 ramdisk_addr; /* physical load addr */
32 u32 second_size; /* size in bytes */
33 u32 second_addr; /* physical load addr */
35 u32 tags_addr; /* physical addr for kernel tags */
36 u32 page_size; /* flash page size we assume */
37 u32 unused; /* reserved for future expansion: MUST be 0 */
39 /* operating system version and security patch level; for
40 * version "A.B.C" and patch level "Y-M-D":
41 * ver = A << 14 | B << 7 | C (7 bits for each of A, B, C)
42 * lvl = ((Y - 2000) & 127) << 4 | M (7 bits for Y, 4 bits for M)
43 * os_version = ver << 11 | lvl */
46 char name[ANDR_BOOT_NAME_SIZE]; /* asciiz product name */
48 char cmdline[ANDR_BOOT_ARGS_SIZE];
50 u32 id[8]; /* timestamp / checksum / sha1 / etc */
52 /* Supplemental command line data; kept here to maintain
53 * binary compatibility with older versions of mkbootimg */
54 char extra_cmdline[ANDR_BOOT_EXTRA_ARGS_SIZE];
55 } __attribute__((packed));
59 * | boot header | 1 page
65 * | second stage | o pages
68 * n = (kernel_size + page_size - 1) / page_size
69 * m = (ramdisk_size + page_size - 1) / page_size
70 * o = (second_size + page_size - 1) / page_size
72 * 0. all entities are page_size aligned in flash
73 * 1. kernel and ramdisk are required (size != 0)
74 * 2. second is optional (second_size == 0 -> no second)
75 * 3. load each element (kernel, ramdisk, second) at
76 * the specified physical address (kernel_addr, etc)
77 * 4. prepare tags at tag_addr. kernel_args[] is
78 * appended to the kernel commandline in the tags.
79 * 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
80 * 6. if second_size != 0: jump to second_addr
81 * else: jump to kernel_addr