blob: d78db9e2b7adbf121cbcd247fa5d4706e07dc592 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: BSD-2-Clause */
Sebastian Siewior686d6672014-05-05 15:08:09 -05002/*
3 * This is from the Android Project,
Alex Deymo41f513a2017-04-02 01:49:47 -07004 * Repository: https://android.googlesource.com/platform/system/core/
5 * File: mkbootimg/bootimg.h
6 * Commit: d162828814b08ada310846a33205befb69ef5799
Sebastian Siewior686d6672014-05-05 15:08:09 -05007 *
8 * Copyright (C) 2008 The Android Open Source Project
Sebastian Siewior686d6672014-05-05 15:08:09 -05009 */
10
11#ifndef _ANDROID_IMAGE_H_
12#define _ANDROID_IMAGE_H_
13
Alex Deymo41f513a2017-04-02 01:49:47 -070014typedef struct andr_img_hdr andr_img_hdr;
15
Sebastian Siewior686d6672014-05-05 15:08:09 -050016#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
Alex Deymo41f513a2017-04-02 01:49:47 -070020#define ANDR_BOOT_EXTRA_ARGS_SIZE 1024
Sebastian Siewior686d6672014-05-05 15:08:09 -050021
22struct 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 */
Alex Deymo41f513a2017-04-02 01:49:47 -070036 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;
Sebastian Siewior686d6672014-05-05 15:08:09 -050044
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 */
Alex Deymo41f513a2017-04-02 01:49:47 -070050
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));
Sebastian Siewior686d6672014-05-05 15:08:09 -050055
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