All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 8/9] sunxi: non-FEL SPL boot support for sun7i
Date: Sat, 26 Apr 2014 20:46:12 +0200	[thread overview]
Message-ID: <201404262046.12540.marex@denx.de> (raw)
In-Reply-To: <1397844350-7341-8-git-send-email-ijc@hellion.org.uk>

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 ...

  reply	other threads:[~2014-04-26 18:46 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-18 18:05 [U-Boot] [PATCH v3 0/9] sunxi: initial upstreamining effort Ian Campbell
2014-04-18 18:05 ` [U-Boot] [PATCH v3 1/9] sunxi: add sun7i clocks and timer support Ian Campbell
2014-04-26 18:31   ` Marek Vasut
2014-04-18 18:05 ` [U-Boot] [PATCH v3 2/9] sunxi: add sun7i pinmux and gpio support Ian Campbell
2014-04-26 18:33   ` Marek Vasut
2014-04-18 18:05 ` [U-Boot] [PATCH v3 3/9] sunxi: add sun7i dram setup support Ian Campbell
2014-04-26 18:35   ` Marek Vasut
2014-04-18 18:05 ` [U-Boot] [PATCH v3 4/9] sunxi: add sun7i cpu, board and start of day support Ian Campbell
2014-04-18 18:05 ` [U-Boot] [PATCH v3 5/9] sunxi: add support for Cubietruck booting in FEL mode Ian Campbell
2014-04-26 18:38   ` Marek Vasut
2014-04-18 18:05 ` [U-Boot] [PATCH v3 6/9] sunxi: add gmac Ethernet support Ian Campbell
2014-04-26 18:41   ` Marek Vasut
2014-04-27 16:33     ` Ian Campbell
2014-04-27 18:10       ` Marek Vasut
2014-04-27 18:35         ` Ian Campbell
2014-04-27 19:15           ` Marek Vasut
2014-04-18 18:05 ` [U-Boot] [PATCH v3 7/9] sunxi: mmc support Ian Campbell
2014-04-26 18:43   ` Marek Vasut
2014-04-18 18:05 ` [U-Boot] [PATCH v3 8/9] sunxi: non-FEL SPL boot support for sun7i Ian Campbell
2014-04-26 18:46   ` Marek Vasut [this message]
2014-04-27 17:00     ` Ian Campbell
2014-04-27 18:07       ` Marek Vasut
2014-04-27 18:38         ` Ian Campbell
2014-04-27 19:15           ` Marek Vasut
2014-04-27 19:29             ` Ian Campbell
2014-04-27 23:58               ` Marek Vasut
2014-04-28  9:06                 ` Ian Campbell
2014-04-18 18:05 ` [U-Boot] [PATCH v3 9/9] net/designware: Reduce DMA burst length Ian Campbell
2014-04-26 18:28   ` Marek Vasut
2014-04-27 15:25     ` Ian Campbell
2014-04-27 15:29       ` Chen-Yu Tsai
2014-04-27 18:08         ` Marek Vasut
2014-04-28  5:51           ` Chen-Yu Tsai
2014-04-28  5:55             ` Marek Vasut
2014-04-28 20:18               ` Alexey Brodkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201404262046.12540.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.