1 /* 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 21 typedef 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 #define BOOT_EXTRA_ARGS_SIZE 1024 28 29 struct boot_img_hdr 30 { 31 unsigned char magic[BOOT_MAGIC_SIZE]; 32 33 unsigned kernel_size; /* size in bytes */ 34 unsigned kernel_addr; /* physical load addr */ 35 36 unsigned ramdisk_size; /* size in bytes */ 37 unsigned ramdisk_addr; /* physical load addr */ 38 39 unsigned second_size; /* size in bytes */ 40 unsigned second_addr; /* physical load addr */ 41 42 unsigned tags_addr; /* physical addr for kernel tags */ 43 unsigned page_size; /* flash page size we assume */ 44 unsigned unused[2]; /* future expansion: should be 0 */ 45 46 unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */ 47 48 unsigned char cmdline[BOOT_ARGS_SIZE]; 49 50 unsigned id[8]; /* timestamp / checksum / sha1 / etc */ 51 52 /* Supplemental command line data; kept here to maintain 53 * binary compatibility with older versions of mkbootimg */ 54 unsigned char extra_cmdline[BOOT_EXTRA_ARGS_SIZE]; 55 }; 56 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 84 #if 0 85 typedef struct ptentry ptentry; 86 87 struct 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 103