blob: 5ab619599fc83430fe8a3b56e9524afa0a5179bc [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001/* tools/mkbootimg/bootimg.h
2**
3** Copyright 2007, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
Rom Lemarchanddfff8292015-05-07 14:08:31 -070018#include <stdint.h>
19
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080020#ifndef _BOOT_IMAGE_H_
21#define _BOOT_IMAGE_H_
22
23typedef struct boot_img_hdr boot_img_hdr;
24
25#define BOOT_MAGIC "ANDROID!"
26#define BOOT_MAGIC_SIZE 8
27#define BOOT_NAME_SIZE 16
28#define BOOT_ARGS_SIZE 512
Andrew Boied35ce352013-08-21 15:48:40 -070029#define BOOT_EXTRA_ARGS_SIZE 1024
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080030
31struct boot_img_hdr
32{
Rom Lemarchanddfff8292015-05-07 14:08:31 -070033 uint8_t magic[BOOT_MAGIC_SIZE];
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080034
Rom Lemarchanddfff8292015-05-07 14:08:31 -070035 uint32_t kernel_size; /* size in bytes */
36 uint32_t kernel_addr; /* physical load addr */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080037
Rom Lemarchanddfff8292015-05-07 14:08:31 -070038 uint32_t ramdisk_size; /* size in bytes */
39 uint32_t ramdisk_addr; /* physical load addr */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080040
Rom Lemarchanddfff8292015-05-07 14:08:31 -070041 uint32_t second_size; /* size in bytes */
42 uint32_t second_addr; /* physical load addr */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080043
Rom Lemarchanddfff8292015-05-07 14:08:31 -070044 uint32_t tags_addr; /* physical addr for kernel tags */
45 uint32_t page_size; /* flash page size we assume */
46 uint32_t unused[2]; /* future expansion: should be 0 */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080047
Rom Lemarchanddfff8292015-05-07 14:08:31 -070048 uint8_t name[BOOT_NAME_SIZE]; /* asciiz product name */
Andrew Boied35ce352013-08-21 15:48:40 -070049
Rom Lemarchanddfff8292015-05-07 14:08:31 -070050 uint8_t cmdline[BOOT_ARGS_SIZE];
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080051
Rom Lemarchanddfff8292015-05-07 14:08:31 -070052 uint32_t id[8]; /* timestamp / checksum / sha1 / etc */
Andrew Boied35ce352013-08-21 15:48:40 -070053
54 /* Supplemental command line data; kept here to maintain
55 * binary compatibility with older versions of mkbootimg */
Rom Lemarchanddfff8292015-05-07 14:08:31 -070056 uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
57} __attribute__((packed));
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080058
59/*
60** +-----------------+
61** | boot header | 1 page
62** +-----------------+
63** | kernel | n pages
64** +-----------------+
65** | ramdisk | m pages
66** +-----------------+
67** | second stage | o pages
68** +-----------------+
69**
70** n = (kernel_size + page_size - 1) / page_size
71** m = (ramdisk_size + page_size - 1) / page_size
72** o = (second_size + page_size - 1) / page_size
73**
74** 0. all entities are page_size aligned in flash
75** 1. kernel and ramdisk are required (size != 0)
76** 2. second is optional (second_size == 0 -> no second)
77** 3. load each element (kernel, ramdisk, second) at
78** the specified physical address (kernel_addr, etc)
79** 4. prepare tags at tag_addr. kernel_args[] is
80** appended to the kernel commandline in the tags.
81** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
82** 6. if second_size != 0: jump to second_addr
83** else: jump to kernel_addr
84*/
85
86#if 0
87typedef struct ptentry ptentry;
88
89struct ptentry {
90 char name[16]; /* asciiz partition name */
91 unsigned start; /* starting block number */
92 unsigned length; /* length in blocks */
93 unsigned flags; /* set to zero */
94};
95
96/* MSM Partition Table ATAG
97**
98** length: 2 + 7 * n
99** atag: 0x4d534d70
100** <ptentry> x n
101*/
102#endif
103
104#endif