The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 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 | |
Rom Lemarchand | dfff829 | 2015-05-07 14:08:31 -0700 | [diff] [blame] | 18 | #include <stdint.h> |
| 19 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 20 | #ifndef _BOOT_IMAGE_H_ |
| 21 | #define _BOOT_IMAGE_H_ |
| 22 | |
| 23 | typedef 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 Boie | d35ce35 | 2013-08-21 15:48:40 -0700 | [diff] [blame] | 29 | #define BOOT_EXTRA_ARGS_SIZE 1024 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 30 | |
| 31 | struct boot_img_hdr |
| 32 | { |
Rom Lemarchand | dfff829 | 2015-05-07 14:08:31 -0700 | [diff] [blame] | 33 | uint8_t magic[BOOT_MAGIC_SIZE]; |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 34 | |
Rom Lemarchand | dfff829 | 2015-05-07 14:08:31 -0700 | [diff] [blame] | 35 | uint32_t kernel_size; /* size in bytes */ |
| 36 | uint32_t kernel_addr; /* physical load addr */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 37 | |
Rom Lemarchand | dfff829 | 2015-05-07 14:08:31 -0700 | [diff] [blame] | 38 | uint32_t ramdisk_size; /* size in bytes */ |
| 39 | uint32_t ramdisk_addr; /* physical load addr */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 40 | |
Rom Lemarchand | dfff829 | 2015-05-07 14:08:31 -0700 | [diff] [blame] | 41 | uint32_t second_size; /* size in bytes */ |
| 42 | uint32_t second_addr; /* physical load addr */ |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 43 | |
Rom Lemarchand | dfff829 | 2015-05-07 14:08:31 -0700 | [diff] [blame] | 44 | uint32_t tags_addr; /* physical addr for kernel tags */ |
| 45 | uint32_t page_size; /* flash page size we assume */ |
Sami Tolvanen | d162828 | 2016-03-14 09:08:59 -0700 | [diff] [blame] | 46 | uint32_t unused; /* reserved for future expansion: MUST be 0 */ |
| 47 | |
| 48 | /* operating system version and security patch level; for |
| 49 | * version "A.B.C" and patch level "Y-M-D": |
| 50 | * ver = A << 14 | B << 7 | C (7 bits for each of A, B, C) |
| 51 | * lvl = ((Y - 2000) & 127) << 4 | M (7 bits for Y, 4 bits for M) |
| 52 | * os_version = ver << 11 | lvl */ |
| 53 | uint32_t os_version; |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 54 | |
Rom Lemarchand | dfff829 | 2015-05-07 14:08:31 -0700 | [diff] [blame] | 55 | uint8_t name[BOOT_NAME_SIZE]; /* asciiz product name */ |
Andrew Boie | d35ce35 | 2013-08-21 15:48:40 -0700 | [diff] [blame] | 56 | |
Rom Lemarchand | dfff829 | 2015-05-07 14:08:31 -0700 | [diff] [blame] | 57 | uint8_t cmdline[BOOT_ARGS_SIZE]; |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 58 | |
Rom Lemarchand | dfff829 | 2015-05-07 14:08:31 -0700 | [diff] [blame] | 59 | uint32_t id[8]; /* timestamp / checksum / sha1 / etc */ |
Andrew Boie | d35ce35 | 2013-08-21 15:48:40 -0700 | [diff] [blame] | 60 | |
| 61 | /* Supplemental command line data; kept here to maintain |
| 62 | * binary compatibility with older versions of mkbootimg */ |
Rom Lemarchand | dfff829 | 2015-05-07 14:08:31 -0700 | [diff] [blame] | 63 | uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE]; |
| 64 | } __attribute__((packed)); |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 65 | |
| 66 | /* |
| 67 | ** +-----------------+ |
| 68 | ** | boot header | 1 page |
| 69 | ** +-----------------+ |
| 70 | ** | kernel | n pages |
| 71 | ** +-----------------+ |
| 72 | ** | ramdisk | m pages |
| 73 | ** +-----------------+ |
| 74 | ** | second stage | o pages |
| 75 | ** +-----------------+ |
| 76 | ** |
| 77 | ** n = (kernel_size + page_size - 1) / page_size |
| 78 | ** m = (ramdisk_size + page_size - 1) / page_size |
| 79 | ** o = (second_size + page_size - 1) / page_size |
| 80 | ** |
| 81 | ** 0. all entities are page_size aligned in flash |
| 82 | ** 1. kernel and ramdisk are required (size != 0) |
| 83 | ** 2. second is optional (second_size == 0 -> no second) |
| 84 | ** 3. load each element (kernel, ramdisk, second) at |
| 85 | ** the specified physical address (kernel_addr, etc) |
| 86 | ** 4. prepare tags at tag_addr. kernel_args[] is |
| 87 | ** appended to the kernel commandline in the tags. |
| 88 | ** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr |
| 89 | ** 6. if second_size != 0: jump to second_addr |
| 90 | ** else: jump to kernel_addr |
| 91 | */ |
| 92 | |
| 93 | #if 0 |
| 94 | typedef struct ptentry ptentry; |
| 95 | |
| 96 | struct ptentry { |
| 97 | char name[16]; /* asciiz partition name */ |
| 98 | unsigned start; /* starting block number */ |
| 99 | unsigned length; /* length in blocks */ |
| 100 | unsigned flags; /* set to zero */ |
| 101 | }; |
| 102 | |
| 103 | /* MSM Partition Table ATAG |
| 104 | ** |
| 105 | ** length: 2 + 7 * n |
| 106 | ** atag: 0x4d534d70 |
| 107 | ** <ptentry> x n |
| 108 | */ |
| 109 | #endif |
| 110 | |
| 111 | #endif |