Software APIs
sw
device
lib
dif
autogen
dif_otbn_autogen.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
#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_OTBN_AUTOGEN_H_
6
#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_OTBN_AUTOGEN_H_
7
8
// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
9
// util/make_new_dif.py --mode=regen --only=autogen
10
11
/**
12
* @file
13
* @brief <a href="/book/hw/ip/otbn/">OTBN</a> Device Interface Functions
14
*/
15
16
#include <
stdbool.h
>
17
#include <
stdint.h
>
18
19
#include "
sw/device/lib/base/macros.h
"
20
#include "
sw/device/lib/base/mmio.h
"
21
#include "
sw/device/lib/dif/dif_base.h
"
22
23
#ifdef __cplusplus
24
extern
"C"
{
25
#endif
// __cplusplus
26
27
/**
28
* A handle to otbn.
29
*
30
* This type should be treated as opaque by users.
31
*/
32
typedef
struct
dif_otbn
{
33
/**
34
* The base address for the otbn hardware registers.
35
*/
36
mmio_region_t
base_addr
;
37
}
dif_otbn_t
;
38
39
/**
40
* Creates a new handle for a(n) otbn peripheral.
41
*
42
* This function does not actuate the hardware.
43
*
44
* @param base_addr The MMIO base address of the otbn peripheral.
45
* @param[out] otbn Out param for the initialized handle.
46
* @return The result of the operation.
47
*/
48
OT_WARN_UNUSED_RESULT
49
dif_result_t
dif_otbn_init
(
mmio_region_t
base_addr,
dif_otbn_t
*otbn);
50
51
/**
52
* A otbn alert type.
53
*/
54
typedef
enum
dif_otbn_alert
{
55
/**
56
* A fatal error. Fatal alerts are non-recoverable and will be asserted until
57
* a hard reset.
58
*/
59
kDifOtbnAlertFatal
= 0,
60
/**
61
* A recoverable error. Just sent once (as the processor stops).
62
*/
63
kDifOtbnAlertRecov
= 1,
64
}
dif_otbn_alert_t
;
65
66
/**
67
* Forces a particular alert, causing it to be escalated as if the hardware
68
* had raised it.
69
*
70
* @param otbn A otbn handle.
71
* @param alert The alert to force.
72
* @return The result of the operation.
73
*/
74
OT_WARN_UNUSED_RESULT
75
dif_result_t
dif_otbn_alert_force
(
const
dif_otbn_t
*otbn,
76
dif_otbn_alert_t
alert);
77
78
/**
79
* A otbn interrupt request type.
80
*/
81
typedef
enum
dif_otbn_irq
{
82
/**
83
* OTBN has completed the operation.
84
*/
85
kDifOtbnIrqDone
= 0,
86
}
dif_otbn_irq_t
;
87
88
/**
89
* A snapshot of the state of the interrupts for this IP.
90
*
91
* This is an opaque type, to be used with the `dif_otbn_irq_get_state()`
92
* and `dif_otbn_irq_acknowledge_state()` functions.
93
*/
94
typedef
uint32_t
dif_otbn_irq_state_snapshot_t
;
95
96
/**
97
* Returns the type of a given interrupt (i.e., event or status) for this IP.
98
*
99
* @param otbn A otbn handle.
100
* @param irq An interrupt request.
101
* @param[out] type Out-param for the interrupt type.
102
* @return The result of the operation.
103
*/
104
OT_WARN_UNUSED_RESULT
105
dif_result_t
dif_otbn_irq_get_type
(
const
dif_otbn_t
*otbn,
dif_otbn_irq_t
irq,
106
dif_irq_type_t
*type);
107
108
/**
109
* Returns the state of all interrupts (i.e., pending or not) for this IP.
110
*
111
* @param otbn A otbn handle.
112
* @param[out] snapshot Out-param for interrupt state snapshot.
113
* @return The result of the operation.
114
*/
115
OT_WARN_UNUSED_RESULT
116
dif_result_t
dif_otbn_irq_get_state
(
const
dif_otbn_t
*otbn,
117
dif_otbn_irq_state_snapshot_t
*snapshot);
118
119
/**
120
* Returns whether a particular interrupt is currently pending.
121
*
122
* @param otbn A otbn handle.
123
* @param irq An interrupt request.
124
* @param[out] is_pending Out-param for whether the interrupt is pending.
125
* @return The result of the operation.
126
*/
127
OT_WARN_UNUSED_RESULT
128
dif_result_t
dif_otbn_irq_is_pending
(
const
dif_otbn_t
*otbn,
dif_otbn_irq_t
irq,
129
bool
*is_pending);
130
131
/**
132
* Acknowledges all interrupts that were pending at the time of the state
133
* snapshot.
134
*
135
* @param otbn A otbn handle.
136
* @param snapshot Interrupt state snapshot.
137
* @return The result of the operation.
138
*/
139
OT_WARN_UNUSED_RESULT
140
dif_result_t
dif_otbn_irq_acknowledge_state
(
141
const
dif_otbn_t
*otbn,
dif_otbn_irq_state_snapshot_t
snapshot);
142
143
/**
144
* Acknowledges all interrupts, indicating to the hardware that all
145
* interrupts have been successfully serviced.
146
*
147
* @param otbn A otbn handle.
148
* @return The result of the operation.
149
*/
150
OT_WARN_UNUSED_RESULT
151
dif_result_t
dif_otbn_irq_acknowledge_all
(
const
dif_otbn_t
*otbn);
152
153
/**
154
* Acknowledges a particular interrupt, indicating to the hardware that it has
155
* been successfully serviced.
156
*
157
* @param otbn A otbn handle.
158
* @param irq An interrupt request.
159
* @return The result of the operation.
160
*/
161
OT_WARN_UNUSED_RESULT
162
dif_result_t
dif_otbn_irq_acknowledge
(
const
dif_otbn_t
*otbn,
163
dif_otbn_irq_t
irq);
164
165
/**
166
* Forces a particular interrupt, causing it to be serviced as if hardware had
167
* asserted it.
168
*
169
* @param otbn A otbn handle.
170
* @param irq An interrupt request.
171
* @param val Value to be set.
172
* @return The result of the operation.
173
*/
174
OT_WARN_UNUSED_RESULT
175
dif_result_t
dif_otbn_irq_force
(
const
dif_otbn_t
*otbn,
dif_otbn_irq_t
irq,
176
const
bool
val);
177
178
/**
179
* A snapshot of the enablement state of the interrupts for this IP.
180
*
181
* This is an opaque type, to be used with the
182
* `dif_otbn_irq_disable_all()` and `dif_otbn_irq_restore_all()`
183
* functions.
184
*/
185
typedef
uint32_t
dif_otbn_irq_enable_snapshot_t
;
186
187
/**
188
* Checks whether a particular interrupt is currently enabled or disabled.
189
*
190
* @param otbn A otbn handle.
191
* @param irq An interrupt request.
192
* @param[out] state Out-param toggle state of the interrupt.
193
* @return The result of the operation.
194
*/
195
OT_WARN_UNUSED_RESULT
196
dif_result_t
dif_otbn_irq_get_enabled
(
const
dif_otbn_t
*otbn,
197
dif_otbn_irq_t
irq,
dif_toggle_t
*state);
198
199
/**
200
* Sets whether a particular interrupt is currently enabled or disabled.
201
*
202
* @param otbn A otbn handle.
203
* @param irq An interrupt request.
204
* @param state The new toggle state for the interrupt.
205
* @return The result of the operation.
206
*/
207
OT_WARN_UNUSED_RESULT
208
dif_result_t
dif_otbn_irq_set_enabled
(
const
dif_otbn_t
*otbn,
209
dif_otbn_irq_t
irq,
dif_toggle_t
state);
210
211
/**
212
* Disables all interrupts, optionally snapshotting all enable states for later
213
* restoration.
214
*
215
* @param otbn A otbn handle.
216
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
217
* @return The result of the operation.
218
*/
219
OT_WARN_UNUSED_RESULT
220
dif_result_t
dif_otbn_irq_disable_all
(
const
dif_otbn_t
*otbn,
221
dif_otbn_irq_enable_snapshot_t
*snapshot);
222
223
/**
224
* Restores interrupts from the given (enable) snapshot.
225
*
226
* @param otbn A otbn handle.
227
* @param snapshot A snapshot to restore from.
228
* @return The result of the operation.
229
*/
230
OT_WARN_UNUSED_RESULT
231
dif_result_t
dif_otbn_irq_restore_all
(
232
const
dif_otbn_t
*otbn,
const
dif_otbn_irq_enable_snapshot_t
*snapshot);
233
234
#ifdef __cplusplus
235
}
// extern "C"
236
#endif
// __cplusplus
237
238
#endif
// OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_OTBN_AUTOGEN_H_
Return to
OpenTitan Documentation