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