
On Friday, April 18, 2014 at 08:05:49 PM, Ian Campbell wrote:
Add support for booting from an MMC card.
Signed-off-by: Stefan Roese sr@denx.de Signed-off-by: Henrik Nordström henrik@henriknordstrom.net Signed-off-by: Ian Campbell ijc@hellion.org.uk Cc: Tom Cubie Mr.hipboi@gmail.com
[...]
+typedef unsigned char u8; +typedef unsigned int u32;
Uh, really ? Just use uint8_t or uint32_t ...
+/* boot head definition from sun4i boot code */ +struct boot_file_head {
- u32 jump_instruction; /* one intruction jumping to real code */
- u8 magic[8]; /* ="eGON.BT0" or "eGON.BT1", not C-style str */
- u32 check_sum; /* generated by PC */
- u32 length; /* generated by PC */
+#if 1
- /* We use a simplified header, only filling in what is needed by the
* boot ROM. To be compatible with Allwinner tools the larger header
* below should be used, followed by a custom header if desired. */
- u8 pad[12]; /* align to 32 bytes */
+#else
Please fix or remove dead code.
- u32 pub_head_size; /* the size of boot_file_head */
- u8 pub_head_vsn[4]; /* the version of boot_file_head */
- u8 file_head_vsn[4]; /* the version of boot0_file_head or
boot1_file_head */
- u8 Boot_vsn[4]; /* Boot version */
- u8 eGON_vsn[4]; /* eGON version */
- u8 platform[8]; /* platform information */
+#endif +};
+#define BOOT0_MAGIC "eGON.BT0" +#define STAMP_VALUE 0x5F0A6C39
+/* check sum functon from sun4i boot code */ +int gen_check_sum(void *boot_buf) +{
- struct boot_file_head *head_p;
- u32 length;
- u32 *buf;
- u32 loop;
- u32 i;
- u32 sum;
- head_p = (struct boot_file_head *)boot_buf;
- length = head_p->length;
- if ((length & 0x3) != 0) /* must 4-byte-aligned */
return -1;
- buf = (u32 *)boot_buf;
This will cause unaligned access if ran on ARM and boot_buf is not aligned.
- head_p->check_sum = STAMP_VALUE; /* fill stamp */
- loop = length >> 2;
- /* calculate the sum */
- for (i = 0, sum = 0; i < loop; i++)
sum += buf[i];
- /* write back check sum */
- head_p->check_sum = sum;
- return 0;
+}
+#define ALIGN(x, a) __ALIGN_MASK((x), (typeof(x))(a)-1) +#define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
Isn't this already defined in include/common.h ?
Looks like this tool might as well be wrapped into the mkimage toolset ...