blob: ef0e61c3271fdfd9583dcf5b6362079828a06c39 [file] [log] [blame]
Ketut Putu Kumajaya63846372014-06-23 20:05:33 +07001/* 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
18#ifndef _BOOT_IMAGE_H_
19#define _BOOT_IMAGE_H_
20
21typedef struct boot_img_hdr boot_img_hdr;
22
23#define BOOT_MAGIC "ANDROID!"
24#define BOOT_MAGIC_SIZE 8
25#define BOOT_NAME_SIZE 16
26#define BOOT_ARGS_SIZE 512
27
28struct boot_img_hdr
29{
30 unsigned char magic[BOOT_MAGIC_SIZE];
31
32 unsigned kernel_size; /* size in bytes */
33 unsigned kernel_addr; /* physical load addr */
34
35 unsigned ramdisk_size; /* size in bytes */
36 unsigned ramdisk_addr; /* physical load addr */
37
38 unsigned second_size; /* size in bytes */
39 unsigned second_addr; /* physical load addr */
40
41 unsigned tags_addr; /* physical addr for kernel tags */
42 unsigned page_size; /* flash page size we assume */
43 unsigned dt_size; /* device tree in bytes */
44 unsigned unused; /* future expansion: should be 0 */
45 unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
46
47 unsigned char cmdline[BOOT_ARGS_SIZE];
48
49 unsigned id[8]; /* timestamp / checksum / sha1 / etc */
50};
51
52/*
53** +-----------------+
54** | boot header | 1 page
55** +-----------------+
56** | kernel | n pages
57** +-----------------+
58** | ramdisk | m pages
59** +-----------------+
60** | second stage | o pages
61** +-----------------+
62** | device tree | p pages
63** +-----------------+
Ketut Putu Kumajaya0c2cc5a2014-06-23 20:18:46 +070064** | signature | 256 bytes
65** +-----------------+
Ketut Putu Kumajaya63846372014-06-23 20:05:33 +070066**
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** p = (dt_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
84#if 0
85typedef struct ptentry ptentry;
86
87struct ptentry {
88 char name[16]; /* asciiz partition name */
89 unsigned start; /* starting block number */
90 unsigned length; /* length in blocks */
91 unsigned flags; /* set to zero */
92};
93
94/* MSM Partition Table ATAG
95**
96** length: 2 + 7 * n
97** atag: 0x4d534d70
98** <ptentry> x n
99*/
100#endif
101
102#endif