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