Software APIs
sw
device
lib
dif
autogen
dif_alert_handler_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_ALERT_HANDLER_AUTOGEN_H_
6
#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ALERT_HANDLER_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/alert_handler/">ALERT_HANDLER</a> Device
14
* Interface Functions
15
*/
16
17
#include <
stdbool.h
>
18
#include <
stdint.h
>
19
20
#include "
sw/device/lib/base/macros.h
"
21
#include "
sw/device/lib/base/mmio.h
"
22
#include "
sw/device/lib/dif/dif_base.h
"
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif
// __cplusplus
27
28
/**
29
* A handle to alert_handler.
30
*
31
* This type should be treated as opaque by users.
32
*/
33
typedef
struct
dif_alert_handler
{
34
/**
35
* The base address for the alert_handler hardware registers.
36
*/
37
mmio_region_t
base_addr
;
38
}
dif_alert_handler_t
;
39
40
/**
41
* Creates a new handle for a(n) alert_handler peripheral.
42
*
43
* This function does not actuate the hardware.
44
*
45
* @param base_addr The MMIO base address of the alert_handler peripheral.
46
* @param[out] alert_handler Out param for the initialized handle.
47
* @return The result of the operation.
48
*/
49
OT_WARN_UNUSED_RESULT
50
dif_result_t
dif_alert_handler_init
(
mmio_region_t
base_addr,
51
dif_alert_handler_t
*alert_handler);
52
53
/**
54
* A alert_handler interrupt request type.
55
*/
56
typedef
enum
dif_alert_handler_irq
{
57
/**
58
* Interrupt state bit of Class A. Set by HW in case an alert within this
59
* class triggered. Defaults true, write one to clear.
60
*/
61
kDifAlertHandlerIrqClassa
= 0,
62
/**
63
* Interrupt state bit of Class B. Set by HW in case an alert within this
64
* class triggered. Defaults true, write one to clear.
65
*/
66
kDifAlertHandlerIrqClassb
= 1,
67
/**
68
* Interrupt state bit of Class C. Set by HW in case an alert within this
69
* class triggered. Defaults true, write one to clear.
70
*/
71
kDifAlertHandlerIrqClassc
= 2,
72
/**
73
* Interrupt state bit of Class D. Set by HW in case an alert within this
74
* class triggered. Defaults true, write one to clear.
75
*/
76
kDifAlertHandlerIrqClassd
= 3,
77
}
dif_alert_handler_irq_t
;
78
79
/**
80
* A snapshot of the state of the interrupts for this IP.
81
*
82
* This is an opaque type, to be used with the
83
* `dif_alert_handler_irq_get_state()` and
84
* `dif_alert_handler_irq_acknowledge_state()` functions.
85
*/
86
typedef
uint32_t
dif_alert_handler_irq_state_snapshot_t
;
87
88
/**
89
* Returns the type of a given interrupt (i.e., event or status) for this IP.
90
*
91
* @param alert_handler A alert_handler handle.
92
* @param irq An interrupt request.
93
* @param[out] type Out-param for the interrupt type.
94
* @return The result of the operation.
95
*/
96
OT_WARN_UNUSED_RESULT
97
dif_result_t
dif_alert_handler_irq_get_type
(
98
const
dif_alert_handler_t
*alert_handler,
dif_alert_handler_irq_t
irq,
99
dif_irq_type_t
*type);
100
101
/**
102
* Returns the state of all interrupts (i.e., pending or not) for this IP.
103
*
104
* @param alert_handler A alert_handler handle.
105
* @param[out] snapshot Out-param for interrupt state snapshot.
106
* @return The result of the operation.
107
*/
108
OT_WARN_UNUSED_RESULT
109
dif_result_t
dif_alert_handler_irq_get_state
(
110
const
dif_alert_handler_t
*alert_handler,
111
dif_alert_handler_irq_state_snapshot_t
*snapshot);
112
113
/**
114
* Returns whether a particular interrupt is currently pending.
115
*
116
* @param alert_handler A alert_handler handle.
117
* @param irq An interrupt request.
118
* @param[out] is_pending Out-param for whether the interrupt is pending.
119
* @return The result of the operation.
120
*/
121
OT_WARN_UNUSED_RESULT
122
dif_result_t
dif_alert_handler_irq_is_pending
(
123
const
dif_alert_handler_t
*alert_handler,
dif_alert_handler_irq_t
irq,
124
bool
*is_pending);
125
126
/**
127
* Acknowledges all interrupts that were pending at the time of the state
128
* snapshot.
129
*
130
* @param alert_handler A alert_handler handle.
131
* @param snapshot Interrupt state snapshot.
132
* @return The result of the operation.
133
*/
134
OT_WARN_UNUSED_RESULT
135
dif_result_t
dif_alert_handler_irq_acknowledge_state
(
136
const
dif_alert_handler_t
*alert_handler,
137
dif_alert_handler_irq_state_snapshot_t
snapshot);
138
139
/**
140
* Acknowledges all interrupts, indicating to the hardware that all
141
* interrupts have been successfully serviced.
142
*
143
* @param alert_handler A alert_handler handle.
144
* @return The result of the operation.
145
*/
146
OT_WARN_UNUSED_RESULT
147
dif_result_t
dif_alert_handler_irq_acknowledge_all
(
148
const
dif_alert_handler_t
*alert_handler);
149
150
/**
151
* Acknowledges a particular interrupt, indicating to the hardware that it has
152
* been successfully serviced.
153
*
154
* @param alert_handler A alert_handler handle.
155
* @param irq An interrupt request.
156
* @return The result of the operation.
157
*/
158
OT_WARN_UNUSED_RESULT
159
dif_result_t
dif_alert_handler_irq_acknowledge
(
160
const
dif_alert_handler_t
*alert_handler,
dif_alert_handler_irq_t
irq);
161
162
/**
163
* Forces a particular interrupt, causing it to be serviced as if hardware had
164
* asserted it.
165
*
166
* @param alert_handler A alert_handler handle.
167
* @param irq An interrupt request.
168
* @param val Value to be set.
169
* @return The result of the operation.
170
*/
171
OT_WARN_UNUSED_RESULT
172
dif_result_t
dif_alert_handler_irq_force
(
173
const
dif_alert_handler_t
*alert_handler,
dif_alert_handler_irq_t
irq,
174
const
bool
val);
175
176
/**
177
* A snapshot of the enablement state of the interrupts for this IP.
178
*
179
* This is an opaque type, to be used with the
180
* `dif_alert_handler_irq_disable_all()` and
181
* `dif_alert_handler_irq_restore_all()` functions.
182
*/
183
typedef
uint32_t
dif_alert_handler_irq_enable_snapshot_t
;
184
185
/**
186
* Checks whether a particular interrupt is currently enabled or disabled.
187
*
188
* @param alert_handler A alert_handler handle.
189
* @param irq An interrupt request.
190
* @param[out] state Out-param toggle state of the interrupt.
191
* @return The result of the operation.
192
*/
193
OT_WARN_UNUSED_RESULT
194
dif_result_t
dif_alert_handler_irq_get_enabled
(
195
const
dif_alert_handler_t
*alert_handler,
dif_alert_handler_irq_t
irq,
196
dif_toggle_t
*state);
197
198
/**
199
* Sets whether a particular interrupt is currently enabled or disabled.
200
*
201
* @param alert_handler A alert_handler handle.
202
* @param irq An interrupt request.
203
* @param state The new toggle state for the interrupt.
204
* @return The result of the operation.
205
*/
206
OT_WARN_UNUSED_RESULT
207
dif_result_t
dif_alert_handler_irq_set_enabled
(
208
const
dif_alert_handler_t
*alert_handler,
dif_alert_handler_irq_t
irq,
209
dif_toggle_t
state);
210
211
/**
212
* Disables all interrupts, optionally snapshotting all enable states for later
213
* restoration.
214
*
215
* @param alert_handler A alert_handler 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_alert_handler_irq_disable_all
(
221
const
dif_alert_handler_t
*alert_handler,
222
dif_alert_handler_irq_enable_snapshot_t
*snapshot);
223
224
/**
225
* Restores interrupts from the given (enable) snapshot.
226
*
227
* @param alert_handler A alert_handler handle.
228
* @param snapshot A snapshot to restore from.
229
* @return The result of the operation.
230
*/
231
OT_WARN_UNUSED_RESULT
232
dif_result_t
dif_alert_handler_irq_restore_all
(
233
const
dif_alert_handler_t
*alert_handler,
234
const
dif_alert_handler_irq_enable_snapshot_t
*snapshot);
235
236
#ifdef __cplusplus
237
}
// extern "C"
238
#endif
// __cplusplus
239
240
#endif
// OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_ALERT_HANDLER_AUTOGEN_H_
Return to
OpenTitan Documentation