Software APIs
keymgr.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_KEYMGR_H_
8
#define OPENTITAN_DT_KEYMGR_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP keymgr and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the keymgr.
19
*/
20
21
#include "hw/top/dt/api.h"
22
#include <stdint.h>
23
24
25
26
/**
27
* List of instances.
28
*/
29
typedef
enum
dt_keymgr
{
30
kDtKeymgrFirst
= 0,
/**< First instance */
31
kDtKeymgr
= 0,
/**< keymgr */
32
}
dt_keymgr_t
;
33
34
enum
{
35
kDtKeymgrCount
= 1,
/**< Number of instances */
36
};
37
38
39
/**
40
* List of register blocks.
41
*
42
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
43
*/
44
typedef
enum
dt_keymgr_reg_block
{
45
kDtKeymgrRegBlockCore = 0,
/**< */
46
}
dt_keymgr_reg_block_t
;
47
48
enum
{
49
kDtKeymgrRegBlockCount
= 1,
/**< Number of register blocks */
50
};
51
52
53
/** Primary register block (associated with the "primary" set of registers that control the IP). */
54
static
const
dt_keymgr_reg_block_t
kDtKeymgrRegBlockPrimary = kDtKeymgrRegBlockCore;
55
56
/**
57
* List of IRQs.
58
*
59
* IRQs are guaranteed to be numbered consecutively from 0.
60
*/
61
typedef
enum
dt_keymgr_irq
{
62
kDtKeymgrIrqOpDone
= 0,
/**< Operation complete */
63
}
dt_keymgr_irq_t
;
64
65
enum
{
66
kDtKeymgrIrqCount
= 1,
/**< Number of IRQs */
67
};
68
69
70
/**
71
* List of Alerts.
72
*
73
* Alerts are guaranteed to be numbered consecutively from 0.
74
*/
75
typedef
enum
dt_keymgr_alert
{
76
kDtKeymgrAlertRecovOperationErr
= 0,
/**< Alert for key manager operation errors. These errors could have been caused by
77
software */
78
kDtKeymgrAlertFatalFaultErr
= 1,
/**< Alert for key manager faults. These errors cannot be caused by software */
79
}
dt_keymgr_alert_t
;
80
81
enum
{
82
kDtKeymgrAlertCount
= 2,
/**< Number of Alerts */
83
};
84
85
86
/**
87
* List of clock ports.
88
*
89
* Clock ports are guaranteed to be numbered consecutively from 0.
90
*/
91
typedef
enum
dt_keymgr_clock
{
92
kDtKeymgrClockClk
= 0,
/**< Clock port clk_i */
93
kDtKeymgrClockEdn
= 1,
/**< Clock port clk_edn_i */
94
}
dt_keymgr_clock_t
;
95
96
enum
{
97
kDtKeymgrClockCount
= 2,
/**< Number of clock ports */
98
};
99
100
101
/**
102
* List of reset ports.
103
*
104
* Reset ports are guaranteed to be numbered consecutively from 0.
105
*/
106
typedef
enum
dt_keymgr_reset
{
107
kDtKeymgrResetRst
= 0,
/**< Reset port rst_ni */
108
kDtKeymgrResetEdn
= 1,
/**< Reset port rst_edn_ni */
109
}
dt_keymgr_reset_t
;
110
111
enum
{
112
kDtKeymgrResetCount
= 2,
/**< Number of reset ports */
113
};
114
115
116
/**
117
* List of supported hardware features.
118
*/
119
#define OPENTITAN_KEYMGR_HAS_SIDELOAD_KMAC 1
120
#define OPENTITAN_KEYMGR_HAS_SIDELOAD_AES 1
121
#define OPENTITAN_KEYMGR_HAS_SIDELOAD_OTBN 1
122
#define OPENTITAN_KEYMGR_HAS_DERIVE_ATTESTATION 1
123
#define OPENTITAN_KEYMGR_HAS_DERIVE_SEALING 1
124
#define OPENTITAN_KEYMGR_HAS_GENERATE_OUTPUT 1
125
#define OPENTITAN_KEYMGR_HAS_GENERATE_IDENTITY 1
126
#define OPENTITAN_KEYMGR_HAS_KEY_VERSIONING 1
127
128
129
130
/**
131
* Get the keymgr instance from an instance ID
132
*
133
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
134
*
135
* @param inst_id Instance ID.
136
* @return A keymgr instance.
137
*
138
* **Note:** This function only makes sense if the instance ID has device type keymgr,
139
* otherwise the returned value is unspecified.
140
*/
141
dt_keymgr_t
dt_keymgr_from_instance_id
(
dt_instance_id_t
inst_id);
142
143
/**
144
* Get the instance ID of an instance.
145
*
146
* @param dt Instance of keymgr.
147
* @return The instance ID of that instance.
148
*/
149
dt_instance_id_t
dt_keymgr_instance_id
(
dt_keymgr_t
dt);
150
151
/**
152
* Get the register base address of an instance.
153
*
154
* @param dt Instance of keymgr.
155
* @param reg_block The register block requested.
156
* @return The register base address of the requested block.
157
*/
158
uint32_t
dt_keymgr_reg_block
(
159
dt_keymgr_t
dt,
160
dt_keymgr_reg_block_t
reg_block);
161
162
/**
163
* Get the primary register base address of an instance.
164
*
165
* This is just a convenience function, equivalent to
166
* `dt_keymgr_reg_block(dt, kDtKeymgrRegBlockCore)`
167
*
168
* @param dt Instance of keymgr.
169
* @return The register base address of the primary register block.
170
*/
171
static
inline
uint32_t dt_keymgr_primary_reg_block(
172
dt_keymgr_t
dt) {
173
return
dt_keymgr_reg_block
(dt, kDtKeymgrRegBlockCore);
174
}
175
176
/**
177
* Get the PLIC ID of a keymgr IRQ for a given instance.
178
*
179
* If the instance is not connected to the PLIC, this function
180
* will return `kDtPlicIrqIdNone`.
181
*
182
* @param dt Instance of keymgr.
183
* @param irq A keymgr IRQ.
184
* @return The PLIC ID of the IRQ of this instance.
185
*/
186
dt_plic_irq_id_t
dt_keymgr_irq_to_plic_id
(
187
dt_keymgr_t
dt,
188
dt_keymgr_irq_t
irq);
189
190
/**
191
* Convert a global IRQ ID to a local keymgr IRQ type.
192
*
193
* @param dt Instance of keymgr.
194
* @param irq A PLIC ID that belongs to this instance.
195
* @return The keymgr IRQ, or `kDtKeymgrIrqCount`.
196
*
197
* **Note:** This function assumes that the PLIC ID belongs to the instance
198
* of keymgr passed in parameter. In other words, it must be the case that
199
* `dt_keymgr_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
200
* will return `kDtKeymgrIrqCount`.
201
*/
202
dt_keymgr_irq_t
dt_keymgr_irq_from_plic_id
(
203
dt_keymgr_t
dt,
204
dt_plic_irq_id_t
irq);
205
206
207
/**
208
* Get the alert ID of a keymgr alert for a given instance.
209
*
210
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
211
* instances where the instance is not connected, the return value is unspecified.
212
*
213
* @param dt Instance of keymgr.
214
* @param alert A keymgr alert.
215
* @return The Alert Handler alert ID of the alert of this instance.
216
*/
217
dt_alert_id_t
dt_keymgr_alert_to_alert_id
(
218
dt_keymgr_t
dt,
219
dt_keymgr_alert_t
alert);
220
221
/**
222
* Convert a global alert ID to a local keymgr alert type.
223
*
224
* @param dt Instance of keymgr.
225
* @param alert A global alert ID that belongs to this instance.
226
* @return The keymgr alert, or `kDtKeymgrAlertCount`.
227
*
228
* **Note:** This function assumes that the global alert ID belongs to the
229
* instance of keymgr passed in parameter. In other words, it must be the case
230
* that `dt_keymgr_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
231
* this function will return `kDtKeymgrAlertCount`.
232
*/
233
dt_keymgr_alert_t
dt_keymgr_alert_from_alert_id
(
234
dt_keymgr_t
dt,
235
dt_alert_id_t
alert);
236
237
238
239
/**
240
* Get the clock signal connected to a clock port of an instance.
241
*
242
* @param dt Instance of keymgr.
243
* @param clk Clock port.
244
* @return Clock signal.
245
*/
246
dt_clock_t
dt_keymgr_clock
(
247
dt_keymgr_t
dt,
248
dt_keymgr_clock_t
clk);
249
250
/**
251
* Get the reset signal connected to a reset port of an instance.
252
*
253
* @param dt Instance of keymgr.
254
* @param rst Reset port.
255
* @return Reset signal.
256
*/
257
dt_reset_t
dt_keymgr_reset
(
258
dt_keymgr_t
dt,
259
dt_keymgr_reset_t
rst);
260
261
262
263
#ifdef __cplusplus
264
}
// extern "C"
265
#endif
// __cplusplus
266
267
#endif
// OPENTITAN_DT_KEYMGR_H_
(earlgrey)
hw
top
dt
keymgr.h
Return to
OpenTitan Documentation