cvmx-bootloader.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2020 Marvell International Ltd.
  4. */
  5. /*
  6. * Bootloader definitions that are shared with other programs
  7. */
  8. #ifndef __CVMX_BOOTLOADER__
  9. #define __CVMX_BOOTLOADER__
  10. /*
  11. * The bootloader_header_t structure defines the header that is present
  12. * at the start of binary u-boot images. This header is used to locate
  13. * the bootloader image in NAND, and also to allow verification of images
  14. * for normal NOR booting. This structure is placed at the beginning of a
  15. * bootloader binary image, and remains in the executable code.
  16. */
  17. #define BOOTLOADER_HEADER_MAGIC 0x424f4f54 /* "BOOT" in ASCII */
  18. #define BOOTLOADER_HEADER_COMMENT_LEN 64
  19. #define BOOTLOADER_HEADER_VERSION_LEN 64
  20. /* limited by the space to the next exception handler */
  21. #define BOOTLOADER_HEADER_MAX_SIZE 0x200
  22. #define BOOTLOADER_HEADER_CURRENT_MAJOR_REV 1
  23. #define BOOTLOADER_HEADER_CURRENT_MINOR_REV 2
  24. /*
  25. * Revision history
  26. * 1.1 Initial released revision. (SDK 1.9)
  27. * 1.2 TLB based relocatable image (SDK 2.0)
  28. */
  29. #ifndef __ASSEMBLY__
  30. struct bootloader_header {
  31. uint32_t jump_instr; /*
  32. * Jump to executable code following the
  33. * header. This allows this header to be
  34. * (and remain) part of the executable image)
  35. */
  36. uint32_t nop_instr; /* Must be 0x0 */
  37. uint32_t magic; /* Magic number to identify header */
  38. uint32_t hcrc; /* CRC of all of header excluding this field */
  39. uint16_t hlen; /* Length of header in bytes */
  40. uint16_t maj_rev; /* Major revision */
  41. uint16_t min_rev; /* Minor revision */
  42. uint16_t board_type; /* Board type that the image is for */
  43. uint32_t dlen; /* Length of data (following header) in bytes */
  44. uint32_t dcrc; /* CRC of data */
  45. uint64_t address; /* Mips virtual address */
  46. uint32_t flags;
  47. uint16_t image_type; /* Defined in bootloader_image_t enum */
  48. uint16_t resv0; /* pad */
  49. uint32_t reserved1;
  50. uint32_t reserved2;
  51. uint32_t reserved3;
  52. uint32_t reserved4;
  53. /* Optional, for descriptive purposes */
  54. char comment_string[BOOTLOADER_HEADER_COMMENT_LEN];
  55. /* Optional, for descriptive purposes */
  56. char version_string[BOOTLOADER_HEADER_VERSION_LEN];
  57. } __packed;
  58. /* Defines for flag field */
  59. #define BL_HEADER_FLAG_FAILSAFE 1
  60. enum bootloader_image {
  61. BL_HEADER_IMAGE_UNKNOWN = 0x0,
  62. BL_HEADER_IMAGE_STAGE2, /* Binary bootloader stage2 image */
  63. BL_HEADER_IMAGE_STAGE3, /* Binary bootloader stage3 image */
  64. BL_HEADER_IMAGE_NOR, /* Binary bootloader for NOR boot */
  65. BL_HEADER_IMAGE_PCIBOOT, /* Binary bootloader for PCI boot */
  66. BL_HEADER_IMAGE_UBOOT_ENV, /* Environment for u-boot */
  67. /* Bootloader before U-Boot (stage 1/1.5) */
  68. BL_HEADER_IMAGE_PRE_UBOOT,
  69. BL_HEADER_IMAGE_STAGE1, /* NOR stage 1 bootloader */
  70. BL_HEADER_IMAGE_MAX,
  71. /* Range for customer private use. Will not be used by Cavium Inc. */
  72. BL_HEADER_IMAGE_CUST_RESERVED_MIN = 0x1000,
  73. BL_HEADER_IMAGE_CUST_RESERVED_MAX = 0x1fff
  74. };
  75. #endif /* __ASSEMBLY__ */
  76. /*
  77. * Maximum address searched for NAND boot images and environments.
  78. * This is used by stage1 and stage2.
  79. */
  80. #define MAX_NAND_SEARCH_ADDR 0x800000
  81. /* Maximum address to look for start of normal bootloader */
  82. #define MAX_NOR_SEARCH_ADDR 0x400000
  83. /*
  84. * Defines for RAM based environment set by the host or the previous
  85. * bootloader in a chain boot configuration.
  86. */
  87. #define U_BOOT_RAM_ENV_ADDR 0x1000
  88. #define U_BOOT_RAM_ENV_SIZE 0x1000
  89. #define U_BOOT_RAM_ENV_CRC_SIZE 0x4
  90. #define U_BOOT_RAM_ENV_ADDR_2 (U_BOOT_RAM_ENV_ADDR + U_BOOT_RAM_ENV_SIZE)
  91. /* Address of environment in L2 cache if booted from cache */
  92. #define U_BOOT_CACHE_ENV_ADDR 0x000ff000
  93. /* Size of environment in L2 cache */
  94. #define U_BOOT_CACHE_ENV_SIZE 0x1000
  95. /* Board numbers and names */
  96. /* Type defines for board and chip types */
  97. enum cvmx_board_types_enum {
  98. CVMX_BOARD_TYPE_NULL = 0,
  99. CVMX_BOARD_TYPE_SIM = 1,
  100. /* Special 'generic' board type, supports many boards */
  101. CVMX_BOARD_TYPE_GENERIC = 28,
  102. CVMX_BOARD_TYPE_EBB7304 = 76,
  103. CVMX_BOARD_TYPE_MAX,
  104. /* NOTE: 256-257 are being used by a customer. */
  105. /*
  106. * The range from CVMX_BOARD_TYPE_MAX to
  107. * CVMX_BOARD_TYPE_CUST_DEFINED_MIN is reserved
  108. * for future SDK use.
  109. */
  110. /*
  111. * Set aside a range for customer boards. These numbers are managed
  112. * by Cavium.
  113. */
  114. CVMX_BOARD_TYPE_CUST_DEFINED_MIN = 10000,
  115. CVMX_BOARD_TYPE_CUST_DEFINED_MAX = 20000,
  116. /*
  117. * Set aside a range for customer private use. The SDK won't
  118. * use any numbers in this range.
  119. */
  120. CVMX_BOARD_TYPE_CUST_PRIVATE_MIN = 20001,
  121. CVMX_BOARD_TYPE_CUST_PRIVATE_MAX = 30000,
  122. };
  123. /* Functions to return string based on type */
  124. /* Skip CVMX_BOARD_TYPE_ */
  125. #define ENUM_BRD_TYPE_CASE(x) case x: return(#x + 16)
  126. static inline const char
  127. *cvmx_board_type_to_string(enum cvmx_board_types_enum type)
  128. {
  129. switch (type) {
  130. ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NULL);
  131. ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_SIM);
  132. ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_GENERIC);
  133. ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBB7304);
  134. ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_MAX);
  135. /* Customer boards listed here */
  136. ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DEFINED_MIN);
  137. ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DEFINED_MAX);
  138. /* Customer private range */
  139. ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MIN);
  140. ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_PRIVATE_MAX);
  141. }
  142. return "Unsupported Board";
  143. }
  144. #endif /* __CVMX_BOOTLOADER__ */