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