blob: a129dd4ee0a09e2d92cf11a7edd9caec8165ad61 [file] [log] [blame]
Ian Campbell6efe3692014-05-05 11:52:26 +01001/*
Bernhard Nortmannc9e89612015-09-17 18:52:50 +02002 * (C) Copyright 2007-2011
3 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
4 * Tom Cubie <tangliang@allwinnertech.com>
Ian Campbell6efe3692014-05-05 11:52:26 +01005 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8#ifndef _ASM_ARCH_SPL_H_
Jeroen Hofsteec5d88a52014-06-11 22:01:48 +02009#define _ASM_ARCH_SPL_H_
Ian Campbell6efe3692014-05-05 11:52:26 +010010
Bernhard Nortmannc9e89612015-09-17 18:52:50 +020011#define BOOT0_MAGIC "eGON.BT0"
Bernhard Nortmann01ad4932015-09-17 18:52:51 +020012#define SPL_SIGNATURE "SPL" /* marks "sunxi" SPL header */
13#define SPL_HEADER_VERSION 1
Bernhard Nortmannc9e89612015-09-17 18:52:50 +020014
Bernhard Nortmannead498a2015-09-17 18:52:52 +020015/* Note: A80 will require special handling here: SPL_ADDR 0x10000 */
16#define SPL_ADDR 0x0
17
Bernhard Nortmannc9e89612015-09-17 18:52:50 +020018/* boot head definition from sun4i boot code */
19struct boot_file_head {
20 uint32_t b_instruction; /* one intruction jumping to real code */
21 uint8_t magic[8]; /* ="eGON.BT0" or "eGON.BT1", not C-style str */
22 uint32_t check_sum; /* generated by PC */
23 uint32_t length; /* generated by PC */
24 /*
25 * We use a simplified header, only filling in what is needed
26 * by the boot ROM. To be compatible with Allwinner tools we
27 * would need to implement the proper fields here instead of
28 * padding.
Bernhard Nortmann01ad4932015-09-17 18:52:51 +020029 *
30 * Actually we want the ability to recognize our "sunxi" variant
31 * of the SPL. To do so, let's place a special signature into the
32 * "pub_head_size" field. We can reasonably expect Allwinner's
33 * boot0 to always have the upper 16 bits of this set to 0 (after
34 * all the value shouldn't be larger than the limit imposed by
35 * SRAM size).
36 * If the signature is present (at 0x14), then we know it's safe
37 * to use the remaining 8 bytes (at 0x18) for our own purposes.
38 * (E.g. sunxi-tools "fel" utility can pass information there.)
Bernhard Nortmannc9e89612015-09-17 18:52:50 +020039 */
Bernhard Nortmann01ad4932015-09-17 18:52:51 +020040 union {
41 uint32_t pub_head_size;
42 uint8_t spl_signature[4];
43 };
44 uint32_t fel_script_address;
45 uint32_t reserved; /* padding, align to 32 bytes */
Bernhard Nortmannc9e89612015-09-17 18:52:50 +020046};
47
Bernhard Nortmannead498a2015-09-17 18:52:52 +020048#define is_boot0_magic(addr) (memcmp((void *)addr, BOOT0_MAGIC, 8) == 0)
49
Ian Campbell6efe3692014-05-05 11:52:26 +010050#endif