Home | History | Annotate | Download | only in mkbootimg
      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 
     28 struct 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 unused[2];    /* future expansion: should be 0 */
     44 
     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 **
     63 ** n = (kernel_size + page_size - 1) / page_size
     64 ** m = (ramdisk_size + page_size - 1) / page_size
     65 ** o = (second_size + page_size - 1) / page_size
     66 **
     67 ** 0. all entities are page_size aligned in flash
     68 ** 1. kernel and ramdisk are required (size != 0)
     69 ** 2. second is optional (second_size == 0 -> no second)
     70 ** 3. load each element (kernel, ramdisk, second) at
     71 **    the specified physical address (kernel_addr, etc)
     72 ** 4. prepare tags at tag_addr.  kernel_args[] is
     73 **    appended to the kernel commandline in the tags.
     74 ** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
     75 ** 6. if second_size != 0: jump to second_addr
     76 **    else: jump to kernel_addr
     77 */
     78 
     79 #if 0
     80 typedef struct ptentry ptentry;
     81 
     82 struct ptentry {
     83     char name[16];      /* asciiz partition name    */
     84     unsigned start;     /* starting block number    */
     85     unsigned length;    /* length in blocks         */
     86     unsigned flags;     /* set to zero              */
     87 };
     88 
     89 /* MSM Partition Table ATAG
     90 **
     91 ** length: 2 + 7 * n
     92 ** atag:   0x4d534d70
     93 **         <ptentry> x n
     94 */
     95 #endif
     96 
     97 #endif
     98