xref: /openbmc/u-boot/include/android_image.h (revision d9b23e26)
1 /*
2  * This is from the Android Project,
3  * Repository: https://android.googlesource.com/platform/system/core/
4  * File: mkbootimg/bootimg.h
5  * Commit: d162828814b08ada310846a33205befb69ef5799
6  *
7  * Copyright (C) 2008 The Android Open Source Project
8  *
9  * SPDX-License-Identifier: BSD-2-Clause
10  */
11 
12 #ifndef _ANDROID_IMAGE_H_
13 #define _ANDROID_IMAGE_H_
14 
15 typedef struct andr_img_hdr andr_img_hdr;
16 
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
22 
23 struct andr_img_hdr {
24 	char magic[ANDR_BOOT_MAGIC_SIZE];
25 
26 	u32 kernel_size;	/* size in bytes */
27 	u32 kernel_addr;	/* physical load addr */
28 
29 	u32 ramdisk_size;	/* size in bytes */
30 	u32 ramdisk_addr;	/* physical load addr */
31 
32 	u32 second_size;	/* size in bytes */
33 	u32 second_addr;	/* physical load addr */
34 
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 */
38 
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 */
44 	u32 os_version;
45 
46 	char name[ANDR_BOOT_NAME_SIZE]; /* asciiz product name */
47 
48 	char cmdline[ANDR_BOOT_ARGS_SIZE];
49 
50 	u32 id[8]; /* timestamp / checksum / sha1 / etc */
51 
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));
56 
57 /*
58  * +-----------------+
59  * | boot header     | 1 page
60  * +-----------------+
61  * | kernel          | n pages
62  * +-----------------+
63  * | ramdisk         | m pages
64  * +-----------------+
65  * | second stage    | o pages
66  * +-----------------+
67  *
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
71  *
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
82  */
83 #endif
84