Software APIs
sw
device
lib
dif
autogen
dif_pattgen_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_PATTGEN_AUTOGEN_H_
6
#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_PATTGEN_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/pattgen/">PATTGEN</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 pattgen.
29
*
30
* This type should be treated as opaque by users.
31
*/
32
typedef
struct
dif_pattgen
{
33
/**
34
* The base address for the pattgen hardware registers.
35
*/
36
mmio_region_t
base_addr
;
37
}
dif_pattgen_t
;
38
39
/**
40
* Creates a new handle for a(n) pattgen peripheral.
41
*
42
* This function does not actuate the hardware.
43
*
44
* @param base_addr The MMIO base address of the pattgen peripheral.
45
* @param[out] pattgen Out param for the initialized handle.
46
* @return The result of the operation.
47
*/
48
OT_WARN_UNUSED_RESULT
49
dif_result_t
dif_pattgen_init
(
mmio_region_t
base_addr,
dif_pattgen_t
*pattgen);
50
51
/**
52
* A pattgen alert type.
53
*/
54
typedef
enum
dif_pattgen_alert
{
55
/**
56
* This fatal alert is triggered when a fatal TL-UL bus integrity fault is
57
* detected.
58
*/
59
kDifPattgenAlertFatalFault
= 0,
60
}
dif_pattgen_alert_t
;
61
62
/**
63
* Forces a particular alert, causing it to be escalated as if the hardware
64
* had raised it.
65
*
66
* @param pattgen A pattgen handle.
67
* @param alert The alert to force.
68
* @return The result of the operation.
69
*/
70
OT_WARN_UNUSED_RESULT
71
dif_result_t
dif_pattgen_alert_force
(
const
dif_pattgen_t
*pattgen,
72
dif_pattgen_alert_t
alert);
73
74
/**
75
* A pattgen interrupt request type.
76
*/
77
typedef
enum
dif_pattgen_irq
{
78
/**
79
* Raise if pattern generation on Channel 0 is complete
80
*/
81
kDifPattgenIrqDoneCh0
= 0,
82
/**
83
* Raise if pattern generation on Channel 1 is complete
84
*/
85
kDifPattgenIrqDoneCh1
= 1,
86
}
dif_pattgen_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_pattgen_irq_get_state()`
92
* and `dif_pattgen_irq_acknowledge_state()` functions.
93
*/
94
typedef
uint32_t
dif_pattgen_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 pattgen A pattgen 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_pattgen_irq_get_type
(
const
dif_pattgen_t
*pattgen,
106
dif_pattgen_irq_t
irq,
107
dif_irq_type_t
*type);
108
109
/**
110
* Returns the state of all interrupts (i.e., pending or not) for this IP.
111
*
112
* @param pattgen A pattgen handle.
113
* @param[out] snapshot Out-param for interrupt state snapshot.
114
* @return The result of the operation.
115
*/
116
OT_WARN_UNUSED_RESULT
117
dif_result_t
dif_pattgen_irq_get_state
(
118
const
dif_pattgen_t
*pattgen,
dif_pattgen_irq_state_snapshot_t
*snapshot);
119
120
/**
121
* Returns whether a particular interrupt is currently pending.
122
*
123
* @param pattgen A pattgen handle.
124
* @param irq An interrupt request.
125
* @param[out] is_pending Out-param for whether the interrupt is pending.
126
* @return The result of the operation.
127
*/
128
OT_WARN_UNUSED_RESULT
129
dif_result_t
dif_pattgen_irq_is_pending
(
const
dif_pattgen_t
*pattgen,
130
dif_pattgen_irq_t
irq,
131
bool
*is_pending);
132
133
/**
134
* Acknowledges all interrupts that were pending at the time of the state
135
* snapshot.
136
*
137
* @param pattgen A pattgen handle.
138
* @param snapshot Interrupt state snapshot.
139
* @return The result of the operation.
140
*/
141
OT_WARN_UNUSED_RESULT
142
dif_result_t
dif_pattgen_irq_acknowledge_state
(
143
const
dif_pattgen_t
*pattgen,
dif_pattgen_irq_state_snapshot_t
snapshot);
144
145
/**
146
* Acknowledges all interrupts, indicating to the hardware that all
147
* interrupts have been successfully serviced.
148
*
149
* @param pattgen A pattgen handle.
150
* @return The result of the operation.
151
*/
152
OT_WARN_UNUSED_RESULT
153
dif_result_t
dif_pattgen_irq_acknowledge_all
(
const
dif_pattgen_t
*pattgen);
154
155
/**
156
* Acknowledges a particular interrupt, indicating to the hardware that it has
157
* been successfully serviced.
158
*
159
* @param pattgen A pattgen handle.
160
* @param irq An interrupt request.
161
* @return The result of the operation.
162
*/
163
OT_WARN_UNUSED_RESULT
164
dif_result_t
dif_pattgen_irq_acknowledge
(
const
dif_pattgen_t
*pattgen,
165
dif_pattgen_irq_t
irq);
166
167
/**
168
* Forces a particular interrupt, causing it to be serviced as if hardware had
169
* asserted it.
170
*
171
* @param pattgen A pattgen handle.
172
* @param irq An interrupt request.
173
* @param val Value to be set.
174
* @return The result of the operation.
175
*/
176
OT_WARN_UNUSED_RESULT
177
dif_result_t
dif_pattgen_irq_force
(
const
dif_pattgen_t
*pattgen,
178
dif_pattgen_irq_t
irq,
const
bool
val);
179
180
/**
181
* A snapshot of the enablement state of the interrupts for this IP.
182
*
183
* This is an opaque type, to be used with the
184
* `dif_pattgen_irq_disable_all()` and `dif_pattgen_irq_restore_all()`
185
* functions.
186
*/
187
typedef
uint32_t
dif_pattgen_irq_enable_snapshot_t
;
188
189
/**
190
* Checks whether a particular interrupt is currently enabled or disabled.
191
*
192
* @param pattgen A pattgen handle.
193
* @param irq An interrupt request.
194
* @param[out] state Out-param toggle state of the interrupt.
195
* @return The result of the operation.
196
*/
197
OT_WARN_UNUSED_RESULT
198
dif_result_t
dif_pattgen_irq_get_enabled
(
const
dif_pattgen_t
*pattgen,
199
dif_pattgen_irq_t
irq,
200
dif_toggle_t
*state);
201
202
/**
203
* Sets whether a particular interrupt is currently enabled or disabled.
204
*
205
* @param pattgen A pattgen handle.
206
* @param irq An interrupt request.
207
* @param state The new toggle state for the interrupt.
208
* @return The result of the operation.
209
*/
210
OT_WARN_UNUSED_RESULT
211
dif_result_t
dif_pattgen_irq_set_enabled
(
const
dif_pattgen_t
*pattgen,
212
dif_pattgen_irq_t
irq,
213
dif_toggle_t
state);
214
215
/**
216
* Disables all interrupts, optionally snapshotting all enable states for later
217
* restoration.
218
*
219
* @param pattgen A pattgen handle.
220
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
221
* @return The result of the operation.
222
*/
223
OT_WARN_UNUSED_RESULT
224
dif_result_t
dif_pattgen_irq_disable_all
(
225
const
dif_pattgen_t
*pattgen,
dif_pattgen_irq_enable_snapshot_t
*snapshot);
226
227
/**
228
* Restores interrupts from the given (enable) snapshot.
229
*
230
* @param pattgen A pattgen handle.
231
* @param snapshot A snapshot to restore from.
232
* @return The result of the operation.
233
*/
234
OT_WARN_UNUSED_RESULT
235
dif_result_t
dif_pattgen_irq_restore_all
(
236
const
dif_pattgen_t
*pattgen,
237
const
dif_pattgen_irq_enable_snapshot_t
*snapshot);
238
239
#ifdef __cplusplus
240
}
// extern "C"
241
#endif
// __cplusplus
242
243
#endif
// OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_PATTGEN_AUTOGEN_H_
Return to
OpenTitan Documentation