Software APIs
dt_aes.h
Go to the documentation of this file.
1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4//
5// Device table API auto-generated by `dtgen`
6
7#ifndef OPENTITAN_DT_AES_H_
8#define OPENTITAN_DT_AES_H_
9
10/**
11 * @file
12 * @brief Device Tables (DT) for IP aes and top earlgrey.
13 *
14 * This file contains the type definitions and global functions of the aes.
15 */
16
17#include "dt_api.h"
18#include <stdint.h>
19
20/**
21 * List of instances.
22 */
23typedef enum dt_aes {
24 kDtAes = 0, /**< aes */
25 kDtAesFirst = 0, /**< \internal First instance */
26 kDtAesCount = 1, /**< \internal Number of instances */
28
29/**
30 * List of register blocks.
31 *
32 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
33 */
34typedef enum dt_aes_reg_block {
35 kDtAesRegBlockCore = 0, /**< */
36 kDtAesRegBlockCount = 1, /**< \internal Number of register blocks */
38
39/** Primary register block (associated with the "primary" set of registers that control the IP). */
40static const dt_aes_reg_block_t kDtAesRegBlockPrimary = kDtAesRegBlockCore;
41
42/**
43 * List of Alerts.
44 *
45 * Alerts are guaranteed to be numbered consecutively from 0.
46 */
47typedef enum dt_aes_alert {
48 kDtAesAlertRecovCtrlUpdateErr = 0, /**< This recoverable alert is triggered upon detecting an update error in the shadowed Control Register.
49The content of the Control Register is not modified (See Control Register).
50The AES unit can be recovered from such a condition by restarting the AES operation, i.e., by re-writing the Control Register.
51This should be monitored by the system. */
52 kDtAesAlertFatalFault = 1, /**< This fatal alert is triggered upon detecting a fatal fault inside the AES unit.
53Examples for such faults include
54i) storage errors in the shadowed Control Register,
55ii) any internal FSM entering an invalid state,
56iii) any sparsely encoded signal taking on an invalid value,
57iv) errors in the internal round counter,
58v) escalations triggered by the life cycle controller, and
59vi) fatal integrity failures on the TL-UL bus.
60The AES unit cannot recover from such an error and needs to be reset. */
61 kDtAesAlertCount = 2, /**< \internal Number of Alerts */
63
64/**
65 * List of clock ports.
66 *
67 * Clock ports are guaranteed to be numbered consecutively from 0.
68 */
69typedef enum dt_aes_clock {
70 kDtAesClockClk = 0, /**< Clock port clk_i */
71 kDtAesClockEdn = 1, /**< Clock port clk_edn_i */
72 kDtAesClockCount = 2, /**< \internal Number of clock ports */
74
75/**
76 * List of reset ports.
77 *
78 * Reset ports are guaranteed to be numbered consecutively from 0.
79 */
80typedef enum dt_aes_reset {
81 kDtAesResetRst = 0, /**< Reset port rst_ni */
82 kDtAesResetEdn = 1, /**< Reset port rst_edn_ni */
83 kDtAesResetCount = 2, /**< \internal Number of reset ports */
85
86/**
87 * List of supported hardware features.
88 */
89#define OPENTITAN_AES_HAS_KEY_LEN_128 1
90#define OPENTITAN_AES_HAS_KEY_LEN_192 1
91#define OPENTITAN_AES_HAS_KEY_LEN_256 1
92#define OPENTITAN_AES_HAS_MODE_ECB 1
93#define OPENTITAN_AES_HAS_MODE_CBC 1
94#define OPENTITAN_AES_HAS_MODE_CFB_128 1
95#define OPENTITAN_AES_HAS_MODE_OFB 1
96#define OPENTITAN_AES_HAS_MODE_CTR 1
97#define OPENTITAN_AES_HAS_KEY_SIDELOAD 1
98#define OPENTITAN_AES_HAS_CLEAR_DATA_OUT 1
99#define OPENTITAN_AES_HAS_CLEAR_KEY_IV_DATA_IN 1
100#define OPENTITAN_AES_HAS_PRNG_RESEED_RATE 1
101#define OPENTITAN_AES_HAS_PRNG_KEY_TOUCH_FORCES_RESEED 1
102#define OPENTITAN_AES_HAS_PRNG_FORCE_MASKS 1
103#define OPENTITAN_AES_HAS_MANUAL_OPERATION 1
104
105
106
107/**
108 * Get the aes instance from an instance ID
109 *
110 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
111 *
112 * @param inst_id Instance ID.
113 * @return A aes instance.
114 *
115 * **Note:** This function only makes sense if the instance ID has device type aes,
116 * otherwise the returned value is unspecified.
117 */
119
120/**
121 * Get the instance ID of an instance.
122 *
123 * @param dt Instance of aes.
124 * @return The instance ID of that instance.
125 */
127
128/**
129 * Get the register base address of an instance.
130 *
131 * @param dt Instance of aes.
132 * @param reg_block The register block requested.
133 * @return The register base address of the requested block.
134 */
135uint32_t dt_aes_reg_block(
136 dt_aes_t dt,
137 dt_aes_reg_block_t reg_block);
138
139/**
140 * Get the primary register base address of an instance.
141 *
142 * This is just a convenience function, equivalent to
143 * `dt_aes_reg_block(dt, kDtAesRegBlockCore)`
144 *
145 * @param dt Instance of aes.
146 * @return The register base address of the primary register block.
147 */
148static inline uint32_t dt_aes_primary_reg_block(
149 dt_aes_t dt) {
150 return dt_aes_reg_block(dt, kDtAesRegBlockCore);
151}
152
153
154/**
155 * Get the alert ID of a aes alert for a given instance.
156 *
157 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
158 * instances where the instance is not connected, the return value is unspecified.
159 *
160 * @param dt Instance of aes.
161 * @param alert A aes alert.
162 * @return The Alert Handler alert ID of the alert of this instance.
163 */
165 dt_aes_t dt,
166 dt_aes_alert_t alert);
167
168/**
169 * Convert a global alert ID to a local aes alert type.
170 *
171 * @param dt Instance of aes.
172 * @param alert A global alert ID that belongs to this instance.
173 * @return The aes alert, or `kDtAesAlertCount`.
174 *
175 * **Note:** This function assumes that the global alert ID belongs to the
176 * instance of aes passed in parameter. In other words, it must be the case
177 * that `dt_aes_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
178 * this function will return `kDtAesAlertCount`.
179 */
181 dt_aes_t dt,
182 dt_alert_id_t alert);
183
184
185
186/**
187 * Get the clock signal connected to a clock port of an instance.
188 *
189 * @param dt Instance of aes.
190 * @param clk Clock port.
191 * @return Clock signal.
192 */
194 dt_aes_t dt,
195 dt_aes_clock_t clk);
196
197/**
198 * Get the reset signal connected to a reset port of an instance.
199 *
200 * @param dt Instance of aes.
201 * @param rst Reset port.
202 * @return Reset signal.
203 */
205 dt_aes_t dt,
206 dt_aes_reset_t rst);
207
208
209
210#endif // OPENTITAN_DT_AES_H_