|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | +#pragma once |
| 7 | + |
| 8 | +#include <stdint.h> |
| 9 | +#ifdef __cplusplus |
| 10 | +extern "C" { |
| 11 | +#endif |
| 12 | + |
| 13 | +/** Group: Key Registers */ |
| 14 | +/** Type of key_n register |
| 15 | + * AES key data register n |
| 16 | + */ |
| 17 | +typedef union { |
| 18 | + struct { |
| 19 | + /** key_0 : R/W; bitpos: [31:0]; default: 0; |
| 20 | + * This bits stores key_0 that is a part of key material. |
| 21 | + */ |
| 22 | + uint32_t key_0:32; |
| 23 | + }; |
| 24 | + uint32_t val; |
| 25 | +} aes_key_n_reg_t; |
| 26 | + |
| 27 | + |
| 28 | +/** Group: TEXT_IN Registers */ |
| 29 | +/** Type of text_in_n register |
| 30 | + * Source text data register n |
| 31 | + */ |
| 32 | +typedef union { |
| 33 | + struct { |
| 34 | + /** text_in_0 : R/W; bitpos: [31:0]; default: 0; |
| 35 | + * This bits stores text_in_0 that is a part of source text material. |
| 36 | + */ |
| 37 | + uint32_t text_in_0:32; |
| 38 | + }; |
| 39 | + uint32_t val; |
| 40 | +} aes_text_in_n_reg_t; |
| 41 | + |
| 42 | + |
| 43 | +/** Group: TEXT_OUT Registers */ |
| 44 | +/** Type of text_out_n register |
| 45 | + * Result text data register n |
| 46 | + */ |
| 47 | +typedef union { |
| 48 | + struct { |
| 49 | + /** text_out_0 : R/W; bitpos: [31:0]; default: 0; |
| 50 | + * This bits stores text_out_0 that is a part of result text material. |
| 51 | + */ |
| 52 | + uint32_t text_out_0:32; |
| 53 | + }; |
| 54 | + uint32_t val; |
| 55 | +} aes_text_out_n_reg_t; |
| 56 | + |
| 57 | + |
| 58 | +/** Group: Control / Configuration Registers */ |
| 59 | +/** Type of mode register |
| 60 | + * Defines key length and encryption / decryption |
| 61 | + */ |
| 62 | +typedef union { |
| 63 | + struct { |
| 64 | + /** mode : R/W; bitpos: [2:0]; default: 0; |
| 65 | + * Configures the key length and encryption / decryption of the AES accelerator. |
| 66 | + * 0: AES-128 encryption |
| 67 | + * 1: AES-192 encryption |
| 68 | + * 2: AES-256 encryption |
| 69 | + * 3: Reserved |
| 70 | + * 4: AES-128 decryption |
| 71 | + * 5: AES-192 decryption |
| 72 | + * 6: AES-256 decryption |
| 73 | + * 7: Reserved |
| 74 | + */ |
| 75 | + uint32_t mode:3; |
| 76 | + uint32_t reserved_3:29; |
| 77 | + }; |
| 78 | + uint32_t val; |
| 79 | +} aes_mode_reg_t; |
| 80 | + |
| 81 | +/** Type of trigger register |
| 82 | + * Operation start controlling register |
| 83 | + */ |
| 84 | +typedef union { |
| 85 | + struct { |
| 86 | + /** trigger : WT; bitpos: [0]; default: 0; |
| 87 | + * Configures whether or not to start AES operation. |
| 88 | + * 0: No effect |
| 89 | + * 1: Start |
| 90 | + */ |
| 91 | + uint32_t trigger:1; |
| 92 | + uint32_t reserved_1:31; |
| 93 | + }; |
| 94 | + uint32_t val; |
| 95 | +} aes_trigger_reg_t; |
| 96 | + |
| 97 | +/** Type of dma_enable register |
| 98 | + * Selects the working mode of the AES accelerator |
| 99 | + */ |
| 100 | +typedef union { |
| 101 | + struct { |
| 102 | + /** dma_enable : R/W; bitpos: [0]; default: 0; |
| 103 | + * Configures the working mode of the AES accelerator. |
| 104 | + * 0: Typical AES |
| 105 | + * 1: DMA-AES |
| 106 | + */ |
| 107 | + uint32_t dma_enable:1; |
| 108 | + uint32_t reserved_1:31; |
| 109 | + }; |
| 110 | + uint32_t val; |
| 111 | +} aes_dma_enable_reg_t; |
| 112 | + |
| 113 | +/** Type of block_mode register |
| 114 | + * Defines the block cipher mode |
| 115 | + */ |
| 116 | +typedef union { |
| 117 | + struct { |
| 118 | + /** block_mode : R/W; bitpos: [2:0]; default: 0; |
| 119 | + * Configures the block cipher mode of the AES accelerator operating under the DMA-AES |
| 120 | + * working mode. |
| 121 | + * 0: ECB (Electronic Code Block) |
| 122 | + * 1: CBC (Cipher Block Chaining) |
| 123 | + * 2: OFB (Output FeedBack) |
| 124 | + * 3: CTR (Counter) |
| 125 | + * 4: CFB8 (8-bit Cipher FeedBack) |
| 126 | + * 5: CFB128 (128-bit Cipher FeedBack) |
| 127 | + * 6: GCM |
| 128 | + * 7: Reserved |
| 129 | + */ |
| 130 | + uint32_t block_mode:3; |
| 131 | + uint32_t reserved_3:29; |
| 132 | + }; |
| 133 | + uint32_t val; |
| 134 | +} aes_block_mode_reg_t; |
| 135 | + |
| 136 | +/** Type of block_num register |
| 137 | + * Block number configuration register |
| 138 | + */ |
| 139 | +typedef union { |
| 140 | + struct { |
| 141 | + /** block_num : R/W; bitpos: [31:0]; default: 0; |
| 142 | + * Represents the Block Number of plaintext or ciphertext when the AES accelerator |
| 143 | + * operates under the DMA-AES working mode. For details, see Section . " |
| 144 | + */ |
| 145 | + uint32_t block_num:32; |
| 146 | + }; |
| 147 | + uint32_t val; |
| 148 | +} aes_block_num_reg_t; |
| 149 | + |
| 150 | +/** Type of inc_sel register |
| 151 | + * Standard incrementing function register |
| 152 | + */ |
| 153 | +typedef union { |
| 154 | + struct { |
| 155 | + /** inc_sel : R/W; bitpos: [0]; default: 0; |
| 156 | + * Configures the Standard Incrementing Function for CTR block operation. |
| 157 | + * 0: INC_32 |
| 158 | + * 1: INC_128 |
| 159 | + */ |
| 160 | + uint32_t inc_sel:1; |
| 161 | + uint32_t reserved_1:31; |
| 162 | + }; |
| 163 | + uint32_t val; |
| 164 | +} aes_inc_sel_reg_t; |
| 165 | + |
| 166 | +/** Type of dma_exit register |
| 167 | + * Operation exit controlling register |
| 168 | + */ |
| 169 | +typedef union { |
| 170 | + struct { |
| 171 | + /** dma_exit : WT; bitpos: [0]; default: 0; |
| 172 | + * Configures whether or not to exit AES operation. |
| 173 | + * 0: No effect |
| 174 | + * 1: Exit |
| 175 | + * Only valid for DMA-AES operation. |
| 176 | + */ |
| 177 | + uint32_t dma_exit:1; |
| 178 | + uint32_t reserved_1:31; |
| 179 | + }; |
| 180 | + uint32_t val; |
| 181 | +} aes_dma_exit_reg_t; |
| 182 | + |
| 183 | +/** Type of rx_reset register |
| 184 | + * AES-DMA reset rx-fifo register |
| 185 | + */ |
| 186 | +typedef union { |
| 187 | + struct { |
| 188 | + /** rx_reset : WT; bitpos: [0]; default: 0; |
| 189 | + * Set this bit to reset rx_fifo under dma_aes working mode. |
| 190 | + */ |
| 191 | + uint32_t rx_reset:1; |
| 192 | + uint32_t reserved_1:31; |
| 193 | + }; |
| 194 | + uint32_t val; |
| 195 | +} aes_rx_reset_reg_t; |
| 196 | + |
| 197 | +/** Type of tx_reset register |
| 198 | + * AES-DMA reset tx-fifo register |
| 199 | + */ |
| 200 | +typedef union { |
| 201 | + struct { |
| 202 | + /** tx_reset : WT; bitpos: [0]; default: 0; |
| 203 | + * Set this bit to reset tx_fifo under dma_aes working mode. |
| 204 | + */ |
| 205 | + uint32_t tx_reset:1; |
| 206 | + uint32_t reserved_1:31; |
| 207 | + }; |
| 208 | + uint32_t val; |
| 209 | +} aes_tx_reset_reg_t; |
| 210 | + |
| 211 | + |
| 212 | +/** Group: Configuration register */ |
| 213 | +/** Type of pseudo register |
| 214 | + * AES PSEUDO function configure register |
| 215 | + */ |
| 216 | +typedef union { |
| 217 | + struct { |
| 218 | + /** pseudo_en : R/W; bitpos: [0]; default: 0; |
| 219 | + * This bit decides whether the pseudo round function is enable or not. |
| 220 | + */ |
| 221 | + uint32_t pseudo_en:1; |
| 222 | + /** pseudo_base : R/W; bitpos: [4:1]; default: 2; |
| 223 | + * Those bits decides the basic number of pseudo round number. |
| 224 | + */ |
| 225 | + uint32_t pseudo_base:4; |
| 226 | + /** pseudo_inc : R/W; bitpos: [6:5]; default: 2; |
| 227 | + * Those bits decides the increment number of pseudo round number |
| 228 | + */ |
| 229 | + uint32_t pseudo_inc:2; |
| 230 | + /** pseudo_rng_cnt : R/W; bitpos: [9:7]; default: 7; |
| 231 | + * Those bits decides the update frequency of the pseudo-key. |
| 232 | + */ |
| 233 | + uint32_t pseudo_rng_cnt:3; |
| 234 | + uint32_t reserved_10:22; |
| 235 | + }; |
| 236 | + uint32_t val; |
| 237 | +} aes_pseudo_reg_t; |
| 238 | + |
| 239 | + |
| 240 | +/** Group: Status Register */ |
| 241 | +/** Type of state register |
| 242 | + * Operation status register |
| 243 | + */ |
| 244 | +typedef union { |
| 245 | + struct { |
| 246 | + /** state : RO; bitpos: [1:0]; default: 0; |
| 247 | + * Represents the working status of the AES accelerator. |
| 248 | + * In Typical AES working mode: |
| 249 | + * 0: IDLE |
| 250 | + * 1: WORK |
| 251 | + * 2: No effect |
| 252 | + * 3: No effect |
| 253 | + * In DMA-AES working mode: |
| 254 | + * 0: IDLE |
| 255 | + * 1: WORK |
| 256 | + * 2: DONE |
| 257 | + * 3: No effect |
| 258 | + */ |
| 259 | + uint32_t state:2; |
| 260 | + uint32_t reserved_2:30; |
| 261 | + }; |
| 262 | + uint32_t val; |
| 263 | +} aes_state_reg_t; |
| 264 | + |
| 265 | + |
| 266 | +/** Group: memory type */ |
| 267 | + |
| 268 | +/** Group: Interrupt Registers */ |
| 269 | +/** Type of int_clear register |
| 270 | + * DMA-AES interrupt clear register |
| 271 | + */ |
| 272 | +typedef union { |
| 273 | + struct { |
| 274 | + /** int_clear : WT; bitpos: [0]; default: 0; |
| 275 | + * Configures whether or not to clear AES interrupt. |
| 276 | + * 0: No effect |
| 277 | + * 1: Clear |
| 278 | + */ |
| 279 | + uint32_t int_clear:1; |
| 280 | + uint32_t reserved_1:31; |
| 281 | + }; |
| 282 | + uint32_t val; |
| 283 | +} aes_int_clear_reg_t; |
| 284 | + |
| 285 | +/** Type of int_ena register |
| 286 | + * DMA-AES interrupt enable register |
| 287 | + */ |
| 288 | +typedef union { |
| 289 | + struct { |
| 290 | + /** int_ena : R/W; bitpos: [0]; default: 0; |
| 291 | + * Configures whether or not to enable AES interrupt. |
| 292 | + * 0: Disable |
| 293 | + * 1: Enable |
| 294 | + */ |
| 295 | + uint32_t int_ena:1; |
| 296 | + uint32_t reserved_1:31; |
| 297 | + }; |
| 298 | + uint32_t val; |
| 299 | +} aes_int_ena_reg_t; |
| 300 | + |
| 301 | + |
| 302 | +/** Group: Version control register */ |
| 303 | +/** Type of date register |
| 304 | + * AES version control register |
| 305 | + */ |
| 306 | +typedef union { |
| 307 | + struct { |
| 308 | + /** date : R/W; bitpos: [27:0]; default: 36774000; |
| 309 | + * This bits stores the version information of AES. |
| 310 | + */ |
| 311 | + uint32_t date:28; |
| 312 | + uint32_t reserved_28:4; |
| 313 | + }; |
| 314 | + uint32_t val; |
| 315 | +} aes_date_reg_t; |
| 316 | + |
| 317 | + |
| 318 | +typedef struct { |
| 319 | + volatile aes_key_n_reg_t key_n[8]; |
| 320 | + volatile aes_text_in_n_reg_t text_in_n[4]; |
| 321 | + volatile aes_text_out_n_reg_t text_out_n[4]; |
| 322 | + volatile aes_mode_reg_t mode; |
| 323 | + uint32_t reserved_044; |
| 324 | + volatile aes_trigger_reg_t trigger; |
| 325 | + volatile aes_state_reg_t state; |
| 326 | + volatile uint32_t iv[4]; |
| 327 | + volatile uint32_t h[4]; |
| 328 | + volatile uint32_t j0[4]; |
| 329 | + volatile uint32_t t0[4]; |
| 330 | + volatile aes_dma_enable_reg_t dma_enable; |
| 331 | + volatile aes_block_mode_reg_t block_mode; |
| 332 | + volatile aes_block_num_reg_t block_num; |
| 333 | + volatile aes_inc_sel_reg_t inc_sel; |
| 334 | + uint32_t reserved_0a0[3]; |
| 335 | + volatile aes_int_clear_reg_t int_clear; |
| 336 | + volatile aes_int_ena_reg_t int_ena; |
| 337 | + volatile aes_date_reg_t date; |
| 338 | + volatile aes_dma_exit_reg_t dma_exit; |
| 339 | + uint32_t reserved_0bc; |
| 340 | + volatile aes_rx_reset_reg_t rx_reset; |
| 341 | + volatile aes_tx_reset_reg_t tx_reset; |
| 342 | + uint32_t reserved_0c8[2]; |
| 343 | + volatile aes_pseudo_reg_t pseudo; |
| 344 | +} aes_dev_t; |
| 345 | + |
| 346 | +extern aes_dev_t AES; |
| 347 | + |
| 348 | +#ifndef __cplusplus |
| 349 | +_Static_assert(sizeof(aes_dev_t) == 0xd4, "Invalid size of aes_dev_t structure"); |
| 350 | +#endif |
| 351 | + |
| 352 | +#ifdef __cplusplus |
| 353 | +} |
| 354 | +#endif |
0 commit comments