blob: dfd4d9d72c74e6302373e4716d64df48195a0909 [file] [log] [blame]
Sebastian Siewior686d6672014-05-05 15:08:09 -05001/*
2 * This is from the Android Project,
Alex Deymo41f513a2017-04-02 01:49:47 -07003 * Repository: https://android.googlesource.com/platform/system/core/
4 * File: mkbootimg/bootimg.h
5 * Commit: d162828814b08ada310846a33205befb69ef5799
Sebastian Siewior686d6672014-05-05 15:08:09 -05006 *
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
Alex Deymo41f513a2017-04-02 01:49:47 -070015typedef struct andr_img_hdr andr_img_hdr;
16
Sebastian Siewior686d6672014-05-05 15:08:09 -050017#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
Alex Deymo41f513a2017-04-02 01:49:47 -070021#define ANDR_BOOT_EXTRA_ARGS_SIZE 1024
Sebastian Siewior686d6672014-05-05 15:08:09 -050022
23struct 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 */
Alex Deymo41f513a2017-04-02 01:49:47 -070037 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;
Sebastian Siewior686d6672014-05-05 15:08:09 -050045
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 */
Alex Deymo41f513a2017-04-02 01:49:47 -070051
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));
Sebastian Siewior686d6672014-05-05 15:08:09 -050056
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