From 5efbed3b272b2b8b6bfa1e8317801f1637eeec88 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 11 Apr 2012 07:42:34 +0200 Subject: arm: add Android boot image support The Android Image contains 3 components and params - kernel - initrd - second stage (optional) - tags addr - bootargs In fast boot the initrd is mandatory, in barebox we are less restrictive use the initrd only if present add to env params: aimage_noverwrite_bootargs Disable overwrite of the bootargs with the one present in aimage aimage_noverwrite_tags Disable overwrite of the tags addr with the one present in aimage Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Cc: Magnus Damm Signed-off-by: Sascha Hauer --- include/aimage.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 include/aimage.h (limited to 'include') diff --git a/include/aimage.h b/include/aimage.h new file mode 100644 index 0000000000..9702b7d35c --- /dev/null +++ b/include/aimage.h @@ -0,0 +1,74 @@ +/* + * (C) Copyright 2011 Jean-Christhophe PLAGNIOL-VILLARD + * + * Android boot image + * + * Under GPLv2 only + */ + +#ifndef __AIMAGE_H__ +#define __AIMAGE_H__ + +#define BOOT_MAGIC "ANDROID!" +#define BOOT_MAGIC_SIZE 8 +#define BOOT_NAME_SIZE 16 +#define BOOT_ARGS_SIZE 512 + +struct android_header_comp +{ + unsigned size; + unsigned load_addr; +}; + +struct android_header +{ + u8 magic[BOOT_MAGIC_SIZE]; + + struct android_header_comp kernel; + + struct android_header_comp ramdisk; + + struct android_header_comp second_stage; + + /* physical addr for kernel tags */ + unsigned tags_addr; + /* flash page size we assume */ + unsigned page_size; + /* future expansion: should be 0 */ + unsigned unused[2]; + + unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */ + + unsigned char cmdline[BOOT_ARGS_SIZE]; + + unsigned id[8]; /* timestamp / checksum / sha1 / etc */ +}; + +/* + * +-----------------+ + * | boot header | 1 page + * +-----------------+ + * | kernel | n pages + * +-----------------+ + * | ramdisk | m pages + * +-----------------+ + * | second stage | o 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 + * + * 0. all entities are page_size aligned in flash + * 1. kernel and ramdisk are required (size != 0) + * 2. second is optional (second_size == 0 -> no second) + * 3. load each element (kernel, ramdisk, second) at + * the specified physical address (kernel_addr, etc) + * 4. prepare tags at tag_addr. kernel_args[] is + * appended to the kernel commandline in the tags. + * 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr + * 6. if second_size != 0: jump to second_addr + * else: jump to kernel_addr + */ + +#endif /* __AIMAGE_H__ */ -- cgit v1.2.3