esp_regdma.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*
  2. * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #include <stdbool.h>
  9. #include "esp_assert.h"
  10. #include "esp_macros.h"
  11. #include "esp_err.h"
  12. #include "esp_bit_defs.h"
  13. #include "soc/soc_caps.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #if SOC_PAU_SUPPORTED
  18. #include "hal/pau_types.h"
  19. #define REGDMA_LINK_DBG 0 /* Enable REGDMA link info dump apis*/
  20. #define REGDMA_LINK_ENTRY_NUM (PAU_REGDMA_LINK_NUM) /* Maximum number of REG DMA linked list entries */
  21. #define ENTRY(n) (BIT(n))
  22. #define REGDMA_PHY_LINK(_pri) ((0x00 << 8) | _pri)
  23. #define REGDMA_PCR_LINK(_pri) ((0x01 << 8) | _pri)
  24. #define REGDMA_MODEMSYSCON_LINK(_pri) ((0x02 << 8) | _pri)
  25. #define REGDMA_MODEMLPCON_LINK(_pri) ((0x03 << 8) | _pri)
  26. #define REGDMA_INTMTX_LINK(_pri) ((0x0d << 8) | _pri)
  27. #define REGDMA_HPSYS_LINK(_pri) ((0x0e << 8) | _pri)
  28. #define REGDMA_TEEAPM_LINK(_pri) ((0x0f << 8) | _pri)
  29. #define REGDMA_UART_LINK(_pri) ((0x10 << 8) | _pri)
  30. #define REGDMA_TIMG_LINK(_pri) ((0x11 << 8) | _pri)
  31. #define REGDMA_IOMUX_LINK(_pri) ((0x12 << 8) | _pri)
  32. #define REGDMA_SPIMEM_LINK(_pri) ((0x13 << 8) | _pri)
  33. #define REGDMA_SYSTIMER_LINK(_pri) ((0x14 << 8) | _pri)
  34. #define REGDMA_BLE_MAC_LINK(_pri) ((0x15 << 8) | _pri)
  35. #define REGDMA_MODEM_BT_BB_LINK(_pri) ((0x16 << 8) | _pri)
  36. #define REGDMA_MODEM_IEEE802154_LINK(_pri) ((0x17 << 8) | _pri)
  37. #define REGDMA_MODEM_FE_LINK(_pri) ((0xFF << 8) | _pri)
  38. typedef enum {
  39. REGDMA_LINK_PRI_0 = 0,
  40. REGDMA_LINK_PRI_1,
  41. REGDMA_LINK_PRI_2,
  42. REGDMA_LINK_PRI_3,
  43. REGDMA_LINK_PRI_4,
  44. REGDMA_LINK_PRI_5,
  45. REGDMA_LINK_PRI_6,
  46. REGDMA_LINK_PRI_7,
  47. } regdma_link_priority_t;
  48. typedef pau_regdma_link_addr_t regdma_entry_buf_t;
  49. typedef enum regdma_link_mode {
  50. REGDMA_LINK_MODE_CONTINUOUS = 0, /*!< Link used to backup registers with consecutive addresses */
  51. REGDMA_LINK_MODE_ADDR_MAP, /*!< Link used to backup selected registers according to bitmap */
  52. REGDMA_LINK_MODE_WRITE, /*!< Link used to direct write to registers*/
  53. REGDMA_LINK_MODE_WAIT /*!< Link used to wait for register value to meet condition*/
  54. } regdma_link_mode_t;
  55. typedef struct regdma_link_head {
  56. volatile uint32_t length: 10, /* total count of registers that need to be backup or restore, unit: 1 word = 4 bytes */
  57. reserve0: 6,
  58. mode : 4, /* mode of current link */
  59. reserve1: 8,
  60. branch : 1, /* branch link flag */
  61. skip_r : 1, /* skip the current linked node when restore the register */
  62. skip_b : 1, /* skip the current linked node when backup the register */
  63. eof : 1; /* end of link */
  64. } regdma_link_head_t;
  65. /* Continuous type linked list node body type definition */
  66. typedef struct regdma_link_continuous_body {
  67. volatile void *next;
  68. volatile void *backup;
  69. volatile void *restore;
  70. volatile void *mem;
  71. } regdma_link_continuous_body_t;
  72. /* Address Map type linked list node body type definition */
  73. typedef struct regdma_link_addr_map_body {
  74. volatile void *next;
  75. volatile void *backup;
  76. volatile void *restore;
  77. volatile void *mem;
  78. volatile uint32_t map[4];
  79. } regdma_link_addr_map_body_t;
  80. /* Write/Wait type linked list node body type definition */
  81. typedef struct regdma_link_write_wait_body {
  82. volatile void *next;
  83. volatile void *backup;
  84. volatile uint32_t value;
  85. volatile uint32_t mask;
  86. } regdma_link_write_wait_body_t;
  87. /* Branch Continuous type linked list node body type definition */
  88. typedef struct regdma_link_branch_continuous_body {
  89. regdma_entry_buf_t next;
  90. volatile void *backup;
  91. volatile void *restore;
  92. volatile void *mem;
  93. } regdma_link_branch_continuous_body_t;
  94. /* Branch Address Map type linked list node body type definition */
  95. typedef struct regdma_link_branch_addr_map_body {
  96. regdma_entry_buf_t next;
  97. volatile void *backup;
  98. volatile void *restore;
  99. volatile void *mem;
  100. volatile uint32_t map[4];
  101. } regdma_link_branch_addr_map_body_t;
  102. /* Branch Write/Wait type linked list node body type definition */
  103. typedef struct regdma_link_branch_write_wait_body {
  104. regdma_entry_buf_t next;
  105. volatile void *backup;
  106. volatile uint32_t value;
  107. volatile uint32_t mask;
  108. } regdma_link_branch_write_wait_body_t;
  109. ESP_STATIC_ASSERT(REGDMA_LINK_ENTRY_NUM < 16, "regdma link entry number should less 16");
  110. typedef struct regdma_link_stats {
  111. volatile uint32_t ref: REGDMA_LINK_ENTRY_NUM, /* a bitmap, identifies which entry has referenced the current link */
  112. reserve: 16-REGDMA_LINK_ENTRY_NUM,
  113. id: 16; /* REGDMA linked list node unique identifier */
  114. volatile uint32_t module; /* a bitmap used to identify the module to which the current node belongs */
  115. } regdma_link_stats_t;
  116. typedef struct regdma_link_continuous {
  117. regdma_link_stats_t stat;
  118. regdma_link_head_t head;
  119. regdma_link_continuous_body_t body;
  120. volatile uint32_t buff[0];
  121. } regdma_link_continuous_t;
  122. typedef struct regdma_link_addr_map {
  123. regdma_link_stats_t stat;
  124. regdma_link_head_t head;
  125. regdma_link_addr_map_body_t body;
  126. volatile uint32_t buff[0];
  127. } regdma_link_addr_map_t;
  128. typedef struct regdma_link_write_wait {
  129. regdma_link_stats_t stat;
  130. regdma_link_head_t head;
  131. regdma_link_write_wait_body_t body;
  132. } regdma_link_write_wait_t;
  133. typedef struct regdma_link_branch_continuous {
  134. regdma_link_stats_t stat;
  135. regdma_link_head_t head;
  136. regdma_link_branch_continuous_body_t body;
  137. volatile uint32_t buff[0];
  138. } regdma_link_branch_continuous_t;
  139. typedef struct regdma_link_branch_addr_map {
  140. regdma_link_stats_t stat;
  141. regdma_link_head_t head;
  142. regdma_link_branch_addr_map_body_t body;
  143. volatile uint32_t buff[0];
  144. } regdma_link_branch_addr_map_t;
  145. typedef struct regdma_link_branch_write_wait {
  146. regdma_link_stats_t stat;
  147. regdma_link_head_t head;
  148. regdma_link_branch_write_wait_body_t body;
  149. } regdma_link_branch_write_wait_t;
  150. typedef struct regdma_link_config {
  151. regdma_link_head_t head;
  152. union {
  153. regdma_link_continuous_body_t continuous;
  154. regdma_link_addr_map_body_t addr_map;
  155. regdma_link_write_wait_body_t write_wait;
  156. };
  157. int id; /* REGDMA linked list node unique identifier */
  158. } regdma_link_config_t;
  159. #define REGDMA_LINK_HEAD(plink) (((regdma_link_config_t *)plink)->head)
  160. #ifndef ARRAY_SIZE
  161. # define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
  162. #endif
  163. #define REGDMA_LINK_HEAD_INIT(_l, _m, _b, _sr, _sb) \
  164. { \
  165. .length = (_l), \
  166. .mode = (_m), \
  167. .branch = (_b), \
  168. .skip_r = (_sr), \
  169. .skip_b = (_sb), \
  170. .eof = 0 \
  171. }
  172. #define REGDMA_LINK_CONTINUOUS_INIT(_id, _backup, _restore, _len, _skip_b, _skip_r) \
  173. { \
  174. .head = REGDMA_LINK_HEAD_INIT( \
  175. _len, \
  176. REGDMA_LINK_MODE_CONTINUOUS,\
  177. 0, \
  178. _skip_r, \
  179. _skip_b \
  180. ), \
  181. .continuous = { \
  182. .next = NULL, \
  183. .backup = (void *)_backup, \
  184. .restore = (void *)_restore, \
  185. .mem = NULL \
  186. }, \
  187. .id = (_id) \
  188. }
  189. #define REGDMA_LINK_ADDR_MAP_INIT(_id, _backup, _restore, _len, _skip_b, _skip_r, ...) \
  190. { \
  191. .head = REGDMA_LINK_HEAD_INIT( \
  192. _len, \
  193. REGDMA_LINK_MODE_ADDR_MAP, \
  194. 0, \
  195. _skip_r, \
  196. _skip_b \
  197. ), \
  198. .addr_map = { \
  199. .next = NULL, \
  200. .backup = (void *)_backup, \
  201. .restore = (void *)_restore, \
  202. .mem = NULL, \
  203. .map = {__VA_ARGS__} \
  204. }, \
  205. .id = (_id) \
  206. }
  207. #define REGDMA_LINK_WRITE_INIT(_id, _backup, _val, _mask, _skip_b, _skip_r) \
  208. { \
  209. .head = REGDMA_LINK_HEAD_INIT( \
  210. 0, \
  211. REGDMA_LINK_MODE_WRITE, \
  212. 0, \
  213. _skip_r, \
  214. _skip_b \
  215. ), \
  216. .write_wait = { \
  217. .next = NULL, \
  218. .backup = (void *)_backup, \
  219. .value = (_val), \
  220. .mask = (_mask) \
  221. }, \
  222. .id = (_id) \
  223. }
  224. #define REGDMA_LINK_WAIT_INIT(_id, _backup, _val, _mask, _skip_b, _skip_r) \
  225. { \
  226. .head = REGDMA_LINK_HEAD_INIT( \
  227. 0, \
  228. REGDMA_LINK_MODE_WAIT, \
  229. 0, \
  230. _skip_r, \
  231. _skip_b \
  232. ), \
  233. .write_wait = { \
  234. .next = NULL, \
  235. .backup = (void *)_backup, \
  236. .value = (_val), \
  237. .mask = (_mask) \
  238. }, \
  239. .id = (_id) \
  240. }
  241. /**
  242. * @brief Create a REGDMA continuous type linked list node without retention buffer and the retention buffer is passed in by the caller
  243. * @param backup Register address to be backed up by REGDMA
  244. * @param buff Retention buffer, it needs to be allocated by the caller and passed in by this argument
  245. * @param len Number of registers to be backed up
  246. * @param restore Register address to be restored by REGDMA
  247. * @param next The next REGDMA linked list node
  248. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  249. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  250. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  251. * @param module The module identifier of the current linked list node
  252. * @return Created REGDMA linked list node pointer
  253. */
  254. void *regdma_link_new_continuous(void *backup, void *buff, int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module);
  255. /**
  256. * @brief Create a REGDMA addr_map type linked list node without retention buffer and the retention buffer is passed in by the caller
  257. * @param backup Register address to be backed up by REGDMA
  258. * @param buff Retention buffer, it needs to be allocated by the caller and passed in by this argument
  259. * @param bitmap The register bitmap that needs to be backed up and restored. when the bitmap corresponding to the
  260. * register is 1, it needs to be backed up or restored, otherwise the corresponding register is skipped.
  261. * @param len Number of registers to be backed up
  262. * @param restore Register address to be restored by REGDMA
  263. * @param next The next REGDMA linked list node
  264. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  265. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  266. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  267. * @param module The module identifier of the current linked list node
  268. * @return Created REGDMA linked list node pointer
  269. */
  270. void *regdma_link_new_addr_map(void *backup, void *buff, uint32_t bitmap[4], int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module);
  271. /**
  272. * @brief Create a REGDMA write type linked list node without retention buffer and the retention buffer is passed in by the caller
  273. * @param backup Register address to be backed up by REGDMA
  274. * @param value The value to be written to the register
  275. * @param mask The mask of value
  276. * @param next The next REGDMA linked list node
  277. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  278. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  279. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  280. * @param module The module identifier of the current linked list node
  281. * @return Created REGDMA linked list node pointer
  282. */
  283. void *regdma_link_new_write(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module);
  284. /**
  285. * @brief Create a REGDMA write type linked list node without retention buffer and the retention buffer is passed in by the caller
  286. * @param backup Register address to be backed up by REGDMA
  287. * @param value The register value that needs to be waited for
  288. * @param mask The mask of value
  289. * @param next The next REGDMA linked list node
  290. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  291. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  292. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  293. * @param module The module identifier of the current linked list node
  294. * @return Created REGDMA linked list node pointer
  295. */
  296. void *regdma_link_new_wait(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module);
  297. /**
  298. * @brief Create a REGDMA continuouos branch list node without retention buffer and the retention buffer is passed in by the caller
  299. * @param backup Register address to be backed up by REGDMA
  300. * @param buff Retention buffer, it needs to be allocated by the caller and passed in by this argument
  301. * @param len Number of registers to be backed up
  302. * @param restore Register address to be restored by REGDMA
  303. * @param next The next REGDMA linked list node (supports up to 4 next pointers)
  304. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  305. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  306. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  307. * @param module The module identifier of the current linked list node
  308. * @return Created REGDMA linked list node pointer
  309. */
  310. void *regdma_link_new_branch_continuous(void *backup, void *buff, int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module);
  311. /**
  312. * @brief Create a REGDMA addr_map branch list node without retention buffer and the retention buffer is passed in by the caller
  313. * @param backup Register address to be backed up by REGDMA
  314. * @param buff Retention buffer, it needs to be allocated by the caller and passed in by this argument
  315. * @param bitmap The register bitmap that needs to be backed up and restored. when the bitmap corresponding to the
  316. * register is 1, it needs to be backed up or restored, otherwise the corresponding register is skipped.
  317. * @param len Number of registers to be backed up
  318. * @param restore Register address to be restored by REGDMA
  319. * @param next The next REGDMA linked list node (supports up to 4 next pointers)
  320. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  321. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  322. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  323. * @param module The module identifier of the current linked list node
  324. * @return Created REGDMA linked list node pointer
  325. */
  326. void *regdma_link_new_branch_addr_map(void *backup, void *buff, uint32_t bitmap[4], int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module);
  327. /**
  328. * @brief Create a REGDMA write branch list node without retention buffer and the retention buffer is passed in by the caller
  329. * @param backup Register address to be backed up by REGDMA
  330. * @param value The value to be written to the register
  331. * @param mask The mask of value
  332. * @param next The next REGDMA linked list node (supports up to 4 next pointers)
  333. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  334. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  335. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  336. * @param module The module identifier of the current linked list node
  337. * @return Created REGDMA linked list node pointer
  338. */
  339. void *regdma_link_new_branch_write(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module);
  340. /**
  341. * @brief Create a REGDMA wait branch list node without retention buffer and the retention buffer is passed in by the caller
  342. * @param backup Register address to be backed up by REGDMA
  343. * @param value The register value that needs to be waited for
  344. * @param mask The mask of value
  345. * @param next The next REGDMA linked list node (supports up to 4 next pointers)
  346. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  347. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  348. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  349. * @param module The module identifier of the current linked list node
  350. * @return Created REGDMA linked list node pointer
  351. */
  352. void *regdma_link_new_branch_wait(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module);
  353. /**
  354. * @brief Create a default REGDMA continuous type linked list node with retention buffer
  355. * @param backup Register address to be backed up by REGDMA
  356. * @param len Number of registers to be backed up
  357. * @param restore Register address to be restored by REGDMA
  358. * @param next The next REGDMA linked list node
  359. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  360. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  361. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  362. * @param module The module identifier of the current linked list node
  363. * @return Created REGDMA linked list node pointer
  364. */
  365. void *regdma_link_new_continuous_default(void *backup, int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module);
  366. /**
  367. * @brief Create a default REGDMA addr_map type linked list node with retention buffer
  368. * @param backup Register address to be backed up by REGDMA
  369. * @param bitmap The register bitmap that needs to be backed up and restored. when the bitmap corresponding to the
  370. * register is 1, it needs to be backed up or restored, otherwise the corresponding register is skipped.
  371. * @param len Number of registers to be backed up
  372. * @param restore Register address to be restored by REGDMA
  373. * @param next The next REGDMA linked list node
  374. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  375. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  376. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  377. * @param module The module identifier of the current linked list node
  378. * @return Created REGDMA linked list node pointer
  379. */
  380. void *regdma_link_new_addr_map_default(void *backup, uint32_t bitmap[4], int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module);
  381. /**
  382. * @brief Create a default REGDMA write type linked list node with retention buffer
  383. * @param backup Register address to be backed up by REGDMA
  384. * @param value The register value that needs to be waited for
  385. * @param mask The mask of value
  386. * @param next The next REGDMA linked list node
  387. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  388. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  389. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  390. * @param module The module identifier of the current linked list node
  391. * @return Created REGDMA linked list node pointer
  392. */
  393. void *regdma_link_new_write_default(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module);
  394. /**
  395. * @brief Create a default REGDMA wait type linked list node with retention buffer
  396. * @param backup Register address to be backed up by REGDMA
  397. * @param value The register value that needs to be waited for
  398. * @param mask The mask of value
  399. * @param next The next REGDMA linked list node
  400. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  401. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  402. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  403. * @param module The module identifier of the current linked list node
  404. * @return Created REGDMA linked list node pointer
  405. */
  406. void *regdma_link_new_wait_default(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module);
  407. /**
  408. * @brief Create a default REGDMA continuous branch list node with retention buffer
  409. * @param backup Register address to be backed up by REGDMA
  410. * @param len Number of registers to be backed up
  411. * @param restore Register address to be restored by REGDMA
  412. * @param next The next REGDMA linked list node (supports up to 4 next pointers)
  413. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  414. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  415. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  416. * @param module The module identifier of the current linked list node
  417. * @return Created REGDMA linked list node pointer
  418. */
  419. void *regdma_link_new_branch_continuous_default(void *backup, int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module);
  420. /**
  421. * @brief Create a default REGDMA addr_map branch list node with retention buffer
  422. * @param backup Register address to be backed up by REGDMA
  423. * @param bitmap The register bitmap that needs to be backed up and restored. when the bitmap corresponding to the
  424. * register is 1, it needs to be backed up or restored, otherwise the corresponding register is skipped.
  425. * @param len Number of registers to be backed up
  426. * @param restore Register address to be restored by REGDMA
  427. * @param next The next REGDMA linked list node (supports up to 4 next pointers)
  428. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  429. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  430. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  431. * @param module The module identifier of the current linked list node
  432. * @return Created REGDMA linked list node pointer
  433. */
  434. void *regdma_link_new_branch_addr_map_default(void *backup, uint32_t bitmap[4], int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module);
  435. /**
  436. * @brief Create a default REGDMA write branch list node with retention buffer
  437. * @param backup Register address to be backed up by REGDMA
  438. * @param value The value to be written to the register
  439. * @param mask The mask of value
  440. * @param next The next REGDMA linked list node (supports up to 4 next pointers)
  441. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  442. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  443. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  444. * @param module The module identifier of the current linked list node
  445. * @return Created REGDMA linked list node pointer
  446. */
  447. void *regdma_link_new_branch_write_default(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module);
  448. /**
  449. * @brief Create a default REGDMA wait branch list node with retention buffer
  450. * @param backup Register address to be backed up by REGDMA
  451. * @param value The register value that needs to be waited for
  452. * @param mask The mask of value
  453. * @param next The next REGDMA linked list node (supports up to 4 next pointers)
  454. * @param skip_b Skip backup, True means that REGDMA skips the current node when executing the backup task
  455. * @param skip_r Skip restore, True means that REGDMA skips the current node when executing the restore task
  456. * @param id REGDMA linked list node unique identifier, the caller needs to ensure that the id of each node is unique
  457. * @param module The module identifier of the current linked list node
  458. * @return Created REGDMA linked list node pointer
  459. */
  460. void *regdma_link_new_branch_wait_default(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module);
  461. /**
  462. * @brief Create and initialize a REGDMA linked list node through configuration parameters
  463. * @param config REGDMA linked node configuration parameters
  464. * @param branch Is it a branch node
  465. * @param module The module identifier of the current linked list node
  466. * @param nentry The number of next pointers
  467. * @param args next pointer, Since REGDMA supports 4 entries, it supports up to 4 variable parameter next pointers, and more will be ignored
  468. * @return Initialized REGDMA linked list head node pointer
  469. */
  470. void *regdma_link_init(const regdma_link_config_t *config, bool branch, uint32_t module, int nentry, ...);
  471. /**
  472. * @brief Recurse the REGDMA linked list and call the hook subroutine for each node
  473. * @param link The REGDMA linkded list head pointer
  474. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  475. * @param hook Subroutines called during recursion, argument 1 is the pointer to the
  476. * recursive node object, argument 2 is the entry to which the node belongs
  477. * and the argument 3 is the position of the node in the current linked
  478. * list (from head to tail, the position of the head node is 0)
  479. * @return The REGDMA linked list node pointer indicated by the link argument
  480. */
  481. void *regdma_link_recursive(void *link, int entry, void (*hook)(void *, int, int));
  482. /**
  483. * @brief Find the linked list node object by node position
  484. * @param link The REGDMA linkded list head pointer
  485. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  486. * @param pos Node position
  487. * @return The linked list node object pointer or NULL
  488. */
  489. void *regdma_find_link_by_pos(void *link, int entry, int pos);
  490. /**
  491. * @brief Find the linked list node object by node unique identifier
  492. * @param link The REGDMA linkded list head pointer
  493. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  494. * @param id REGDMA linked list node unique identifier
  495. * @return The linked list node object pointer or NULL
  496. */
  497. void *regdma_find_link_by_id(void *link, int entry, int id);
  498. /**
  499. * @brief Destroy the REGDMA linked list indicated by the entry argument
  500. * @param link The REGDMA linkded list head pointer
  501. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  502. */
  503. void regdma_link_destroy(void *link, int entry);
  504. /**
  505. * @brief Generate the statistics information of the REGDMA linked list indicated by the entry argument
  506. * @param link The REGDMA linkded list head pointer
  507. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  508. */
  509. void regdma_link_stats(void *link, int entry);
  510. /**
  511. * @brief Set the value and mask of write or wait type REGDMA linked list node
  512. * @param link Write or wait type REGDMA linked list node pointer
  513. * @param value The value to be written to the register
  514. * @param mask The mask of value
  515. */
  516. void regdma_link_set_write_wait_content(void *link, uint32_t value, uint32_t mask);
  517. /**
  518. * @brief Print all node information of the REGDMA linked list indicated by the entry argument
  519. * @param link The REGDMA linkded list head pointer
  520. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  521. */
  522. void regdma_link_show_memories(void *link, int entry);
  523. /**
  524. * @brief Update REGDMA linked list node next pointers
  525. * @param link The pointer of the REGDMA linked list node whose next field will be modified
  526. * @param nentry The number of next pointers
  527. */
  528. void regdma_link_update_next(void *link, int nentry, ...);
  529. /**
  530. * @brief Get all node entry reference bitmaps from the start of the link argument to the
  531. * end of the tail argument in the REGDMA linked list indicated by the entry argument
  532. * @param link The REGDMA linkded list head pointer
  533. * @param tail The REGDMA linkded list tail pointer
  534. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  535. * @return The entry reference bitmap of all nodes starting from the link argument to the end of the tail argument
  536. */
  537. uint32_t regdma_link_get_owner_bitmap(void *link, void *tail, int entry);
  538. /**
  539. * @brief Find the head node of the specified module in the REGDMA linked list indicated by the
  540. * entry argument starting from the link argument to the end of the tail argument
  541. * @param link The REGDMA linkded list head pointer
  542. * @param tail The REGDMA linkded list tail pointer
  543. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  544. * @param module Module bitmap Identification
  545. * @return The found head node pointer or NULL
  546. */
  547. void *regdma_find_module_link_head(void *link, void *tail, int entry, uint32_t module);
  548. /**
  549. * @brief Find the tail node of the specified module in the REGDMA linked list indicated by the
  550. * entry argument starting from the link argument to the end of the tail argument
  551. * @param link The REGDMA linkded list head pointer
  552. * @param tail The REGDMA linkded list tail pointer
  553. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  554. * @param module Module bitmap Identification
  555. * @return The found tail node pointer or NULL
  556. */
  557. void *regdma_find_module_link_tail(void *link, void *tail, int entry, uint32_t module);
  558. /**
  559. * @brief Find the tail node of the previous module of the specified module in the REGDMA linked list
  560. * indicated by the entry argument starting from the link argment to the end of the tail argument
  561. * @param link The REGDMA linkded list head pointer
  562. * @param tail The REGDMA linkded list tail pointer
  563. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  564. * @param module Module bitmap Identification
  565. * @return The found tail node pointer or NULL
  566. */
  567. void *regdma_find_prev_module_link_tail(void *link, void *tail, int entry, uint32_t module);
  568. /**
  569. * @brief Find the head node of the next module of the specified module in the REGDMA linked list
  570. * indicated by the entry argument starting from the link argment to the end of the tail argument
  571. * @param link The REGDMA linkded list head pointer
  572. * @param tail The REGDMA linkded list tail pointer
  573. * @param entry For nodes that support branching, use the branch specified by entry argument recursively
  574. * @param module Module bitmap Identification
  575. * @return The found head node pointer or NULL
  576. */
  577. void *regdma_find_next_module_link_head(void *link, void *tail, int entry, uint32_t module);
  578. #define regdma_link_init_safe(pcfg, branch, module, ...) regdma_link_init((pcfg), (branch), (module), __VA_NARG__(__VA_ARGS__), ##__VA_ARGS__)
  579. #define regdma_link_update_next_safe(link, ...) regdma_link_update_next((link), __VA_NARG__(__VA_ARGS__), ##__VA_ARGS__)
  580. #endif // SOC_PAU_SUPPORTED
  581. #ifdef __cplusplus
  582. }
  583. #endif