boot_platform.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* Copyright (C) 2017 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _BOOT_PLATFORM_H_
  13. #define _BOOT_PLATFORM_H_
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include <stddef.h>
  17. #include "boot_config.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. typedef enum bootResetMode
  22. {
  23. BOOT_RESET_NORMAL, ///< normal reset
  24. BOOT_RESET_FORCE_DOWNLOAD, ///< reset to force download mode
  25. } bootResetMode_t;
  26. enum
  27. {
  28. BOOT_DOWNLOAD_UART1 = 0x01,
  29. BOOT_DOWNLOAD_UART2 = 0x02,
  30. BOOT_DOWNLOAD_UART3 = 0x03,
  31. BOOT_DOWNLOAD_UART4 = 0x04,
  32. BOOT_DOWNLOAD_UART5 = 0x05,
  33. BOOT_DOWNLOAD_UART6 = 0x06,
  34. BOOT_DOWNLOAD_USERIAL = 0x08,
  35. BOOT_LOAD_FROM_BOOT2 = 0x10,
  36. BOOT_LOAD_FROM_SDCARD = 0x11,
  37. };
  38. #define BOOT_DNLD_FROM_UART(mode) ((mode) >= BOOT_DOWNLOAD_UART1 && (mode) <= BOOT_DOWNLOAD_UART6)
  39. #define BOOT_DNLD_FROM_USERIAL(mode) ((mode) == BOOT_DOWNLOAD_USERIAL)
  40. /**
  41. * \brief image entry prototype
  42. */
  43. typedef void (*bootJumpFunc_t)(uint32_t param);
  44. /**
  45. * \brief reset the chip
  46. *
  47. * \param mode reboot mode
  48. */
  49. void bootReset(bootResetMode_t mode);
  50. /**
  51. * \brief power off the chip
  52. */
  53. void bootPowerOff(void);
  54. /**
  55. * \brief check if the chip is boot from psm
  56. *
  57. * \return
  58. * - true if from psm else false
  59. */
  60. bool bootIsFromPsmSleep(void);
  61. /**
  62. * \brief get poweron cause refer to `osiBootCause`
  63. */
  64. int bootPowerOnCause(void);
  65. /**
  66. * \brief force update current version if secure boot enabled
  67. *
  68. * If a new version found at startup,
  69. * update the new version number into the EFUSE,
  70. * then ROM can Do the Anti-Rollback check.
  71. *
  72. * \return
  73. * - true on succeed else false
  74. */
  75. bool bootUpdateVersion(void);
  76. /**
  77. * \brief check if secure boot enabled
  78. *
  79. * \return
  80. * - true if ebable secure boot else false
  81. */
  82. bool bootSecureBootEnable(void);
  83. /**
  84. * \brief if second bootloader enabled, return the offset from the first
  85. * bootloader start address in bytes
  86. *
  87. * \return
  88. * - 0 the second bootloader not support
  89. * - other the second bootloader start address from the first one.
  90. * (first bootloader address + this offset = second bootloader address)
  91. */
  92. uint32_t bootSecondOffsetBytes(void);
  93. /**
  94. * \brief platform init
  95. */
  96. void bootPlatformInit(void);
  97. /**
  98. * \brief Enable the funtion pin reset.
  99. */
  100. void bootResetPinEnable(void);
  101. /**
  102. * \brief jump to image entry
  103. *
  104. * There are some housekeeping before jump. For 8910, D-cache cleanup
  105. * should be called outside.
  106. *
  107. * \param param jump entry parameter
  108. * \param entry jump entry
  109. */
  110. void bootJumpImageEntry(unsigned param, bootJumpFunc_t entry);
  111. /**
  112. * \brief initialize trace
  113. *
  114. * \param enabled whether trace is enabled
  115. */
  116. void bootTraceInit(bool enabled);
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif