blob: 785fa06175de63e5dcec4bb8cb24cf90328891cd [file] [log] [blame]
Ajay Dudani168f6cb2009-12-07 19:04:02 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
Duy Truongf3ac7b32013-02-13 01:07:28 -08004 * Copyright (c) 2009, The Linux Foundation. All rights reserved.
Ajay Dudani168f6cb2009-12-07 19:04:02 -08005 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
23 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#ifndef _BOOT_IMAGE_H_
31#define _BOOT_IMAGE_H_
32
33typedef struct boot_img_hdr boot_img_hdr;
34
35#define BOOT_MAGIC "ANDROID!"
36#define BOOT_MAGIC_SIZE 8
37#define BOOT_NAME_SIZE 16
38#define BOOT_ARGS_SIZE 512
39
40struct boot_img_hdr
41{
42 unsigned char magic[BOOT_MAGIC_SIZE];
43
44 unsigned kernel_size; /* size in bytes */
45 unsigned kernel_addr; /* physical load addr */
46
47 unsigned ramdisk_size; /* size in bytes */
48 unsigned ramdisk_addr; /* physical load addr */
49
50 unsigned second_size; /* size in bytes */
51 unsigned second_addr; /* physical load addr */
52
53 unsigned tags_addr; /* physical addr for kernel tags */
54 unsigned page_size; /* flash page size we assume */
55 unsigned unused[2]; /* future expansion: should be 0 */
56
57 unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
58
59 unsigned char cmdline[BOOT_ARGS_SIZE];
60
61 unsigned id[8]; /* timestamp / checksum / sha1 / etc */
62};
63
64/*
65** +-----------------+
66** | boot header | 1 page
67** +-----------------+
68** | kernel | n pages
69** +-----------------+
70** | ramdisk | m pages
71** +-----------------+
72** | second stage | o pages
73** +-----------------+
74**
75** n = (kernel_size + page_size - 1) / page_size
76** m = (ramdisk_size + page_size - 1) / page_size
77** o = (second_size + page_size - 1) / page_size
78**
79** 0. all entities are page_size aligned in flash
80** 1. kernel and ramdisk are required (size != 0)
81** 2. second is optional (second_size == 0 -> no second)
82** 3. load each element (kernel, ramdisk, second) at
83** the specified physical address (kernel_addr, etc)
84** 4. prepare tags at tag_addr. kernel_args[] is
85** appended to the kernel commandline in the tags.
86** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
87** 6. if second_size != 0: jump to second_addr
88** else: jump to kernel_addr
89*/
90
91boot_img_hdr *mkbootimg(void *kernel, unsigned kernel_size,
92 void *ramdisk, unsigned ramdisk_size,
93 void *second, unsigned second_size,
94 unsigned page_size,
95 unsigned *bootimg_size);
96
97void bootimg_set_cmdline(boot_img_hdr *hdr, const char *cmdline);
98#endif
99