aes_struct.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. /**
  2. * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /** Group: key register */
  12. /** Type of key_0 register
  13. * Key material key_0 configure register
  14. */
  15. typedef union {
  16. struct {
  17. /** key_0 : R/W; bitpos: [31:0]; default: 0;
  18. * This bits stores key_0 that is a part of key material.
  19. */
  20. uint32_t key_0:32;
  21. };
  22. uint32_t val;
  23. } aes_key_0_reg_t;
  24. /** Type of key_1 register
  25. * Key material key_1 configure register
  26. */
  27. typedef union {
  28. struct {
  29. /** key_1 : R/W; bitpos: [31:0]; default: 0;
  30. * This bits stores key_1 that is a part of key material.
  31. */
  32. uint32_t key_1:32;
  33. };
  34. uint32_t val;
  35. } aes_key_1_reg_t;
  36. /** Type of key_2 register
  37. * Key material key_2 configure register
  38. */
  39. typedef union {
  40. struct {
  41. /** key_2 : R/W; bitpos: [31:0]; default: 0;
  42. * This bits stores key_2 that is a part of key material.
  43. */
  44. uint32_t key_2:32;
  45. };
  46. uint32_t val;
  47. } aes_key_2_reg_t;
  48. /** Type of key_3 register
  49. * Key material key_3 configure register
  50. */
  51. typedef union {
  52. struct {
  53. /** key_3 : R/W; bitpos: [31:0]; default: 0;
  54. * This bits stores key_3 that is a part of key material.
  55. */
  56. uint32_t key_3:32;
  57. };
  58. uint32_t val;
  59. } aes_key_3_reg_t;
  60. /** Type of key_4 register
  61. * Key material key_4 configure register
  62. */
  63. typedef union {
  64. struct {
  65. /** key_4 : R/W; bitpos: [31:0]; default: 0;
  66. * This bits stores key_4 that is a part of key material.
  67. */
  68. uint32_t key_4:32;
  69. };
  70. uint32_t val;
  71. } aes_key_4_reg_t;
  72. /** Type of key_5 register
  73. * Key material key_5 configure register
  74. */
  75. typedef union {
  76. struct {
  77. /** key_5 : R/W; bitpos: [31:0]; default: 0;
  78. * This bits stores key_5 that is a part of key material.
  79. */
  80. uint32_t key_5:32;
  81. };
  82. uint32_t val;
  83. } aes_key_5_reg_t;
  84. /** Type of key_6 register
  85. * Key material key_6 configure register
  86. */
  87. typedef union {
  88. struct {
  89. /** key_6 : R/W; bitpos: [31:0]; default: 0;
  90. * This bits stores key_6 that is a part of key material.
  91. */
  92. uint32_t key_6:32;
  93. };
  94. uint32_t val;
  95. } aes_key_6_reg_t;
  96. /** Type of key_7 register
  97. * Key material key_7 configure register
  98. */
  99. typedef union {
  100. struct {
  101. /** key_7 : R/W; bitpos: [31:0]; default: 0;
  102. * This bits stores key_7 that is a part of key material.
  103. */
  104. uint32_t key_7:32;
  105. };
  106. uint32_t val;
  107. } aes_key_7_reg_t;
  108. /** Group: text in register */
  109. /** Type of text_in_0 register
  110. * source text material text_in_0 configure register
  111. */
  112. typedef union {
  113. struct {
  114. /** text_in_0 : R/W; bitpos: [31:0]; default: 0;
  115. * This bits stores text_in_0 that is a part of source text material.
  116. */
  117. uint32_t text_in_0:32;
  118. };
  119. uint32_t val;
  120. } aes_text_in_0_reg_t;
  121. /** Type of text_in_1 register
  122. * source text material text_in_1 configure register
  123. */
  124. typedef union {
  125. struct {
  126. /** text_in_1 : R/W; bitpos: [31:0]; default: 0;
  127. * This bits stores text_in_1 that is a part of source text material.
  128. */
  129. uint32_t text_in_1:32;
  130. };
  131. uint32_t val;
  132. } aes_text_in_1_reg_t;
  133. /** Type of text_in_2 register
  134. * source text material text_in_2 configure register
  135. */
  136. typedef union {
  137. struct {
  138. /** text_in_2 : R/W; bitpos: [31:0]; default: 0;
  139. * This bits stores text_in_2 that is a part of source text material.
  140. */
  141. uint32_t text_in_2:32;
  142. };
  143. uint32_t val;
  144. } aes_text_in_2_reg_t;
  145. /** Type of text_in_3 register
  146. * source text material text_in_3 configure register
  147. */
  148. typedef union {
  149. struct {
  150. /** text_in_3 : R/W; bitpos: [31:0]; default: 0;
  151. * This bits stores text_in_3 that is a part of source text material.
  152. */
  153. uint32_t text_in_3:32;
  154. };
  155. uint32_t val;
  156. } aes_text_in_3_reg_t;
  157. /** Group: text out register */
  158. /** Type of text_out_0 register
  159. * result text material text_out_0 configure register
  160. */
  161. typedef union {
  162. struct {
  163. /** text_out_0 : R/W; bitpos: [31:0]; default: 0;
  164. * This bits stores text_out_0 that is a part of result text material.
  165. */
  166. uint32_t text_out_0:32;
  167. };
  168. uint32_t val;
  169. } aes_text_out_0_reg_t;
  170. /** Type of text_out_1 register
  171. * result text material text_out_1 configure register
  172. */
  173. typedef union {
  174. struct {
  175. /** text_out_1 : R/W; bitpos: [31:0]; default: 0;
  176. * This bits stores text_out_1 that is a part of result text material.
  177. */
  178. uint32_t text_out_1:32;
  179. };
  180. uint32_t val;
  181. } aes_text_out_1_reg_t;
  182. /** Type of text_out_2 register
  183. * result text material text_out_2 configure register
  184. */
  185. typedef union {
  186. struct {
  187. /** text_out_2 : R/W; bitpos: [31:0]; default: 0;
  188. * This bits stores text_out_2 that is a part of result text material.
  189. */
  190. uint32_t text_out_2:32;
  191. };
  192. uint32_t val;
  193. } aes_text_out_2_reg_t;
  194. /** Type of text_out_3 register
  195. * result text material text_out_3 configure register
  196. */
  197. typedef union {
  198. struct {
  199. /** text_out_3 : R/W; bitpos: [31:0]; default: 0;
  200. * This bits stores text_out_3 that is a part of result text material.
  201. */
  202. uint32_t text_out_3:32;
  203. };
  204. uint32_t val;
  205. } aes_text_out_3_reg_t;
  206. /** Group: Configuration register */
  207. /** Type of mode register
  208. * AES Mode register
  209. */
  210. typedef union {
  211. struct {
  212. /** mode : R/W; bitpos: [2:0]; default: 0;
  213. * This bits decides which one operation mode will be used. 3'd0: AES-EN-128, 3'd1:
  214. * AES-EN-192, 3'd2: AES-EN-256, 3'd4: AES-DE-128, 3'd5: AES-DE-192, 3'd6: AES-DE-256.
  215. */
  216. uint32_t mode:3;
  217. uint32_t reserved_3:29;
  218. };
  219. uint32_t val;
  220. } aes_mode_reg_t;
  221. /** Type of block_mode register
  222. * AES cipher block mode register
  223. */
  224. typedef union {
  225. struct {
  226. /** block_mode : R/W; bitpos: [2:0]; default: 0;
  227. * Those bits decides which block mode will be used. 0x0: ECB, 0x1: CBC, 0x2: OFB,
  228. * 0x3: CTR, 0x4: CFB-8, 0x5: CFB-128, 0x6: GCM, 0x7: reserved.
  229. */
  230. uint32_t block_mode:3;
  231. uint32_t reserved_3:29;
  232. };
  233. uint32_t val;
  234. } aes_block_mode_reg_t;
  235. /** Type of block_num register
  236. * AES block number register
  237. */
  238. typedef union {
  239. struct {
  240. /** block_num : R/W; bitpos: [31:0]; default: 0;
  241. * Those bits stores the number of Plaintext/ciphertext block.
  242. */
  243. uint32_t block_num:32;
  244. };
  245. uint32_t val;
  246. } aes_block_num_reg_t;
  247. /** Type of inc_sel register
  248. * Standard incrementing function configure register
  249. */
  250. typedef union {
  251. struct {
  252. /** inc_sel : R/W; bitpos: [0]; default: 0;
  253. * This bit decides the standard incrementing function. 0: INC32. 1: INC128.
  254. */
  255. uint32_t inc_sel:1;
  256. uint32_t reserved_1:31;
  257. };
  258. uint32_t val;
  259. } aes_inc_sel_reg_t;
  260. /** Group: Control/Status register */
  261. /** Type of trigger register
  262. * AES trigger register
  263. */
  264. typedef union {
  265. struct {
  266. /** trigger : WT; bitpos: [0]; default: 0;
  267. * Set this bit to start AES calculation.
  268. */
  269. uint32_t trigger:1;
  270. uint32_t reserved_1:31;
  271. };
  272. uint32_t val;
  273. } aes_trigger_reg_t;
  274. /** Type of state register
  275. * AES state register
  276. */
  277. typedef union {
  278. struct {
  279. /** state : RO; bitpos: [1:0]; default: 0;
  280. * Those bits shows AES status. For typical AES, 0: idle, 1: busy. For DMA-AES, 0:
  281. * idle, 1: busy, 2: calculation_done.
  282. */
  283. uint32_t state:2;
  284. uint32_t reserved_2:30;
  285. };
  286. uint32_t val;
  287. } aes_state_reg_t;
  288. /** Type of dma_enable register
  289. * DMA-AES working mode register
  290. */
  291. typedef union {
  292. struct {
  293. /** dma_enable : R/W; bitpos: [0]; default: 0;
  294. * 1'b0: typical AES working mode, 1'b1: DMA-AES working mode.
  295. */
  296. uint32_t dma_enable:1;
  297. uint32_t reserved_1:31;
  298. };
  299. uint32_t val;
  300. } aes_dma_enable_reg_t;
  301. /** Type of dma_exit register
  302. * AES-DMA exit config
  303. */
  304. typedef union {
  305. struct {
  306. /** dma_exit : WT; bitpos: [0]; default: 0;
  307. * Set this register to leave calculation done stage. Recommend to use it after
  308. * software finishes reading DMA's output buffer.
  309. */
  310. uint32_t dma_exit:1;
  311. uint32_t reserved_1:31;
  312. };
  313. uint32_t val;
  314. } aes_dma_exit_reg_t;
  315. /** Group: memory type */
  316. /** Group: interrupt register */
  317. /** Type of int_clear register
  318. * AES Interrupt clear register
  319. */
  320. typedef union {
  321. struct {
  322. /** int_clear : WT; bitpos: [0]; default: 0;
  323. * Set this bit to clear the AES interrupt.
  324. */
  325. uint32_t int_clear:1;
  326. uint32_t reserved_1:31;
  327. };
  328. uint32_t val;
  329. } aes_int_clear_reg_t;
  330. /** Type of int_ena register
  331. * AES Interrupt enable register
  332. */
  333. typedef union {
  334. struct {
  335. /** int_ena : R/W; bitpos: [0]; default: 0;
  336. * Set this bit to enable interrupt that occurs when DMA-AES calculation is done.
  337. */
  338. uint32_t int_ena:1;
  339. uint32_t reserved_1:31;
  340. };
  341. uint32_t val;
  342. } aes_int_ena_reg_t;
  343. /** Group: Version control register */
  344. /** Type of date register
  345. * AES version control register
  346. */
  347. typedef union {
  348. struct {
  349. /** date : R/W; bitpos: [29:0]; default: 538513936;
  350. * This bits stores the version information of AES.
  351. */
  352. uint32_t date:30;
  353. uint32_t reserved_30:2;
  354. };
  355. uint32_t val;
  356. } aes_date_reg_t;
  357. typedef struct {
  358. volatile aes_key_0_reg_t key_0;
  359. volatile aes_key_1_reg_t key_1;
  360. volatile aes_key_2_reg_t key_2;
  361. volatile aes_key_3_reg_t key_3;
  362. volatile aes_key_4_reg_t key_4;
  363. volatile aes_key_5_reg_t key_5;
  364. volatile aes_key_6_reg_t key_6;
  365. volatile aes_key_7_reg_t key_7;
  366. volatile aes_text_in_0_reg_t text_in_0;
  367. volatile aes_text_in_1_reg_t text_in_1;
  368. volatile aes_text_in_2_reg_t text_in_2;
  369. volatile aes_text_in_3_reg_t text_in_3;
  370. volatile aes_text_out_0_reg_t text_out_0;
  371. volatile aes_text_out_1_reg_t text_out_1;
  372. volatile aes_text_out_2_reg_t text_out_2;
  373. volatile aes_text_out_3_reg_t text_out_3;
  374. volatile aes_mode_reg_t mode;
  375. uint32_t reserved_044;
  376. volatile aes_trigger_reg_t trigger;
  377. volatile aes_state_reg_t state;
  378. volatile uint32_t iv[4];
  379. volatile uint32_t h[4];
  380. volatile uint32_t j0[4];
  381. volatile uint32_t t0[4];
  382. volatile aes_dma_enable_reg_t dma_enable;
  383. volatile aes_block_mode_reg_t block_mode;
  384. volatile aes_block_num_reg_t block_num;
  385. volatile aes_inc_sel_reg_t inc_sel;
  386. uint32_t reserved_0a0[3];
  387. volatile aes_int_clear_reg_t int_clear;
  388. volatile aes_int_ena_reg_t int_ena;
  389. volatile aes_date_reg_t date;
  390. volatile aes_dma_exit_reg_t dma_exit;
  391. } aes_dev_t;
  392. #ifndef __cplusplus
  393. _Static_assert(sizeof(aes_dev_t) == 0xbc, "Invalid size of aes_dev_t structure");
  394. #endif
  395. #ifdef __cplusplus
  396. }
  397. #endif