xref: /openbmc/u-boot/include/android_image.h (revision 1021af4d)
1 /*
2  * This is from the Android Project,
3  * Repository: https://android.googlesource.com/platform/bootable/bootloader/legacy
4  * File: include/boot/bootimg.h
5  * Commit: 4205b865141ff2e255fe1d3bd16de18e217ef06a
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 #define ANDR_BOOT_MAGIC "ANDROID!"
16 #define ANDR_BOOT_MAGIC_SIZE 8
17 #define ANDR_BOOT_NAME_SIZE 16
18 #define ANDR_BOOT_ARGS_SIZE 512
19 
20 struct andr_img_hdr {
21 	char magic[ANDR_BOOT_MAGIC_SIZE];
22 
23 	u32 kernel_size;	/* size in bytes */
24 	u32 kernel_addr;	/* physical load addr */
25 
26 	u32 ramdisk_size;	/* size in bytes */
27 	u32 ramdisk_addr;	/* physical load addr */
28 
29 	u32 second_size;	/* size in bytes */
30 	u32 second_addr;	/* physical load addr */
31 
32 	u32 tags_addr;		/* physical addr for kernel tags */
33 	u32 page_size;		/* flash page size we assume */
34 	u32 unused[2];		/* future expansion: should be 0 */
35 
36 	char name[ANDR_BOOT_NAME_SIZE]; /* asciiz product name */
37 
38 	char cmdline[ANDR_BOOT_ARGS_SIZE];
39 
40 	u32 id[8]; /* timestamp / checksum / sha1 / etc */
41 };
42 
43 /*
44  * +-----------------+
45  * | boot header     | 1 page
46  * +-----------------+
47  * | kernel          | n pages
48  * +-----------------+
49  * | ramdisk         | m pages
50  * +-----------------+
51  * | second stage    | o pages
52  * +-----------------+
53  *
54  * n = (kernel_size + page_size - 1) / page_size
55  * m = (ramdisk_size + page_size - 1) / page_size
56  * o = (second_size + page_size - 1) / page_size
57  *
58  * 0. all entities are page_size aligned in flash
59  * 1. kernel and ramdisk are required (size != 0)
60  * 2. second is optional (second_size == 0 -> no second)
61  * 3. load each element (kernel, ramdisk, second) at
62  *    the specified physical address (kernel_addr, etc)
63  * 4. prepare tags at tag_addr.  kernel_args[] is
64  *    appended to the kernel commandline in the tags.
65  * 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
66  * 6. if second_size != 0: jump to second_addr
67  *    else: jump to kernel_addr
68  */
69 #endif
70