/* Copyright Statement: * * This software/firmware and related documentation ("MediaTek Software") are * protected under relevant copyright laws. The information contained herein * is confidential and proprietary to MediaTek Inc. and/or its licensors. * Without the prior written permission of MediaTek inc. and/or its licensors, * any reproduction, modification, use or disclosure of MediaTek Software, * and information contained herein, in whole or in part, shall be strictly prohibited. */ /* MediaTek Inc. (C) 2017. All rights reserved. * * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. * * The following software/firmware and/or related documentation ("MediaTek Software") * have been modified by MediaTek Inc. All revisions are subject to any receiver\'s * applicable license agreements with MediaTek Inc. */ #ifndef __BOOTIMG_H__ #define __BOOTIMG_H__ #include #define BOOTIMG_MAGIC "ANDROID!" #define BOOTIMG_MAGIC_SZ (8) #define BOOTIMG_NAME_SZ (16) #define BOOTIMG_ARGS_SZ (512) #define BOOT_EXTRA_ARGS_SIZE (1024) #define BOOT_HEADER_VERSION_ZERO 0 #define BOOT_HEADER_VERSION_ONE 1 #define BOOT_HEADER_VERSION_TWO 2 #define BOOTIMG_HDR_SZ (0x800) /* When the boot image header has a version of 2, the structure of the boot * image is as follows: * * +---------------------+ * | boot header | 1 page * +---------------------+ * | kernel | n pages * +---------------------+ * | ramdisk | m pages * +---------------------+ * | second stage | o pages * +---------------------+ * | recovery dtbo/acpio | p pages * +---------------------+ * | dtb | q pages * +---------------------+ * n = (kernel_size + page_size - 1) / page_size * m = (ramdisk_size + page_size - 1) / page_size * o = (second_size + page_size - 1) / page_size * p = (recovery_dtbo_size + page_size - 1) / page_size * q = (dtb_size + page_size - 1) / page_size * * 0. all entities are page_size aligned in flash * 1. kernel, ramdisk and DTB are required (size != 0) * 2. recovery_dtbo/recovery_acpio is required for recovery.img in non-A/B * devices(recovery_dtbo_size != 0) * 3. second is optional (second_size == 0 -> no second) * 4. load each element (kernel, ramdisk, second, dtb) at * the specified physical address (kernel_addr, etc) * 5. If booting to recovery mode in a non-A/B device, extract recovery * dtbo/acpio and apply the correct set of overlays on the base device tree * depending on the hardware/product revision. * 6. prepare tags at tag_addr. kernel_args[] is * appended to the kernel commandline in the tags. * 7. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr * 8. if second_size != 0: jump to second_addr * else: jump to kernel_addr */ struct bootimg_hdr { uint8_t magic[BOOTIMG_MAGIC_SZ]; uint32_t kernel_sz; /* size in bytes */ uint32_t kernel_addr; /* physical load addr */ uint32_t ramdisk_sz; /* size in bytes */ uint32_t ramdisk_addr; /* physical load addr */ uint32_t second_sz; /* size in bytes */ uint32_t second_addr; /* physical load addr */ uint32_t tags_addr; /* physical addr for kernel tags */ uint32_t page_sz; /* flash page size we assume */ uint32_t header_version; uint32_t os_version; uint8_t name[BOOTIMG_NAME_SZ]; /* asciiz product name */ uint8_t cmdline[BOOTIMG_ARGS_SZ]; uint32_t id[8]; /* timestamp / checksum / sha1 / etc */ uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE]; uint32_t recovery_dtbo_size; /* size of recovery dtbo image */ uint64_t recovery_dtbo_offset; /* physical load addr */ uint32_t header_size; /* size of boot image header in bytes */ uint32_t dtb_size; /* size in bytes for DTB image */ uint64_t dtb_addr; /* physical load address for DTB image */ } __attribute__((packed)); #endif /* __BOOTIMG_H__ */