sunxi_image.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2007-2011
  4. * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
  5. * Tom Cubie <tangliang@allwinnertech.com>
  6. *
  7. * Constants and data structures used in Allwinner "eGON" images, as
  8. * parsed by the Boot-ROM.
  9. *
  10. * Shared between mkimage and the SPL.
  11. */
  12. #ifndef SUNXI_IMAGE_H
  13. #define SUNXI_IMAGE_H
  14. #define BOOT0_MAGIC "eGON.BT0"
  15. #define SPL_SIGNATURE "SPL" /* marks "sunxi" SPL header */
  16. #define SPL_MAJOR_BITS 3
  17. #define SPL_MINOR_BITS 5
  18. #define SPL_VERSION(maj, min) \
  19. ((((maj) & ((1U << SPL_MAJOR_BITS) - 1)) << SPL_MINOR_BITS) | \
  20. ((min) & ((1U << SPL_MINOR_BITS) - 1)))
  21. #define SPL_HEADER_VERSION SPL_VERSION(0, 2)
  22. #define SPL_ENV_HEADER_VERSION SPL_VERSION(0, 1)
  23. #define SPL_DT_HEADER_VERSION SPL_VERSION(0, 2)
  24. #define SPL_DRAM_HEADER_VERSION SPL_VERSION(0, 3)
  25. /* boot head definition from sun4i boot code */
  26. struct boot_file_head {
  27. uint32_t b_instruction; /* one intruction jumping to real code */
  28. uint8_t magic[8]; /* ="eGON.BT0" or "eGON.BT1", not C-style str */
  29. uint32_t check_sum; /* generated by PC */
  30. uint32_t length; /* generated by PC */
  31. /*
  32. * We use a simplified header, only filling in what is needed
  33. * by the boot ROM. To be compatible with Allwinner tools we
  34. * would need to implement the proper fields here instead of
  35. * padding.
  36. *
  37. * Actually we want the ability to recognize our "sunxi" variant
  38. * of the SPL. To do so, let's place a special signature into the
  39. * "pub_head_size" field. We can reasonably expect Allwinner's
  40. * boot0 to always have the upper 16 bits of this set to 0 (after
  41. * all the value shouldn't be larger than the limit imposed by
  42. * SRAM size).
  43. * If the signature is present (at 0x14), then we know it's safe
  44. * to use the remaining 8 bytes (at 0x18) for our own purposes.
  45. * (E.g. sunxi-tools "fel" utility can pass information there.)
  46. */
  47. union {
  48. uint32_t pub_head_size;
  49. uint8_t spl_signature[4];
  50. };
  51. uint32_t fel_script_address; /* since v0.1, set by sunxi-fel */
  52. /*
  53. * If the fel_uEnv_length member below is set to a non-zero value,
  54. * it specifies the size (byte count) of data at fel_script_address.
  55. * At the same time this indicates that the data is in uEnv.txt
  56. * compatible format, ready to be imported via "env import -t".
  57. */
  58. uint32_t fel_uEnv_length; /* since v0.1, set by sunxi-fel */
  59. /*
  60. * Offset of an ASCIIZ string (relative to the SPL header), which
  61. * contains the default device tree name (CONFIG_DEFAULT_DEVICE_TREE).
  62. * This is optional and may be set to NULL. Is intended to be used
  63. * by flash programming tools for providing nice informative messages
  64. * to the users.
  65. */
  66. uint32_t dt_name_offset; /* since v0.2, set by mksunxiboot */
  67. uint32_t dram_size; /* in MiB, since v0.3, set by SPL */
  68. uint32_t boot_media; /* written here by the boot ROM */
  69. /* A padding area (may be used for storing text strings) */
  70. uint32_t string_pool[13]; /* since v0.2, filled by mksunxiboot */
  71. /* The header must be a multiple of 32 bytes (for VBAR alignment) */
  72. };
  73. /* Compile time check to assure proper alignment of structure */
  74. typedef char boot_file_head_not_multiple_of_32[1 - 2*(sizeof(struct boot_file_head) % 32)];
  75. #endif