Software APIs
sw
device
lib
dif
autogen
dif_flash_ctrl_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_FLASH_CTRL_AUTOGEN_H_
6
#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_FLASH_CTRL_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/flash_ctrl/">FLASH_CTRL</a> Device Interface
14
* 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 flash_ctrl.
30
*
31
* This type should be treated as opaque by users.
32
*/
33
typedef
struct
dif_flash_ctrl
{
34
/**
35
* The base address for the flash_ctrl hardware registers.
36
*/
37
mmio_region_t
base_addr
;
38
}
dif_flash_ctrl_t
;
39
40
/**
41
* Creates a new handle for a(n) flash_ctrl peripheral.
42
*
43
* This function does not actuate the hardware.
44
*
45
* @param base_addr The MMIO base address of the flash_ctrl peripheral.
46
* @param[out] flash_ctrl Out param for the initialized handle.
47
* @return The result of the operation.
48
*/
49
OT_WARN_UNUSED_RESULT
50
dif_result_t
dif_flash_ctrl_init
(
mmio_region_t
base_addr,
51
dif_flash_ctrl_t
*flash_ctrl);
52
53
/**
54
* A flash_ctrl alert type.
55
*/
56
typedef
enum
dif_flash_ctrl_alert
{
57
/**
58
* Flash recoverable errors
59
*/
60
kDifFlashCtrlAlertRecovErr
= 0,
61
/**
62
* Flash standard fatal errors
63
*/
64
kDifFlashCtrlAlertFatalStdErr
= 1,
65
/**
66
* Flash fatal errors including uncorrectable ECC errors. Note that this
67
* alert is not always fatal. The underlying error bits in the !!FAULT_STATUS
68
* register remain set until reset, meaning the alert keeps firing. This
69
* doesn't hold for !!FAULT_STATUS.PHY_RELBL_ERR and
70
* !!FAULT_STATUS.PHY_STORAGE_ERR. To enable firmware dealing with multi-bit
71
* ECC and ICV errors during firmware selection and verification, these error
72
* bits can be cleared. After passing this stage, it is recommended that
73
* firmware classifies the corresponding alert as fatal on the receiver end,
74
* i.e, inside the alert handler.
75
*/
76
kDifFlashCtrlAlertFatalErr
= 2,
77
/**
78
* Fatal alert triggered inside the flash primitive, including fatal TL-UL bus
79
* integrity faults of the test interface.
80
*/
81
kDifFlashCtrlAlertFatalPrimFlashAlert
= 3,
82
/**
83
* Recoverable alert triggered inside the flash primitive.
84
*/
85
kDifFlashCtrlAlertRecovPrimFlashAlert
= 4,
86
}
dif_flash_ctrl_alert_t
;
87
88
/**
89
* Forces a particular alert, causing it to be escalated as if the hardware
90
* had raised it.
91
*
92
* @param flash_ctrl A flash_ctrl handle.
93
* @param alert The alert to force.
94
* @return The result of the operation.
95
*/
96
OT_WARN_UNUSED_RESULT
97
dif_result_t
dif_flash_ctrl_alert_force
(
const
dif_flash_ctrl_t
*flash_ctrl,
98
dif_flash_ctrl_alert_t
alert);
99
100
/**
101
* A flash_ctrl interrupt request type.
102
*/
103
typedef
enum
dif_flash_ctrl_irq
{
104
/**
105
* Program FIFO empty
106
*/
107
kDifFlashCtrlIrqProgEmpty
= 0,
108
/**
109
* Program FIFO drained to level
110
*/
111
kDifFlashCtrlIrqProgLvl
= 1,
112
/**
113
* Read FIFO full
114
*/
115
kDifFlashCtrlIrqRdFull
= 2,
116
/**
117
* Read FIFO filled to level
118
*/
119
kDifFlashCtrlIrqRdLvl
= 3,
120
/**
121
* Operation complete
122
*/
123
kDifFlashCtrlIrqOpDone
= 4,
124
/**
125
* Correctable error encountered
126
*/
127
kDifFlashCtrlIrqCorrErr
= 5,
128
}
dif_flash_ctrl_irq_t
;
129
130
/**
131
* A snapshot of the state of the interrupts for this IP.
132
*
133
* This is an opaque type, to be used with the `dif_flash_ctrl_irq_get_state()`
134
* and `dif_flash_ctrl_irq_acknowledge_state()` functions.
135
*/
136
typedef
uint32_t
dif_flash_ctrl_irq_state_snapshot_t
;
137
138
/**
139
* Returns the type of a given interrupt (i.e., event or status) for this IP.
140
*
141
* @param flash_ctrl A flash_ctrl handle.
142
* @param irq An interrupt request.
143
* @param[out] type Out-param for the interrupt type.
144
* @return The result of the operation.
145
*/
146
OT_WARN_UNUSED_RESULT
147
dif_result_t
dif_flash_ctrl_irq_get_type
(
const
dif_flash_ctrl_t
*flash_ctrl,
148
dif_flash_ctrl_irq_t
irq,
149
dif_irq_type_t
*type);
150
151
/**
152
* Returns the state of all interrupts (i.e., pending or not) for this IP.
153
*
154
* @param flash_ctrl A flash_ctrl handle.
155
* @param[out] snapshot Out-param for interrupt state snapshot.
156
* @return The result of the operation.
157
*/
158
OT_WARN_UNUSED_RESULT
159
dif_result_t
dif_flash_ctrl_irq_get_state
(
160
const
dif_flash_ctrl_t
*flash_ctrl,
161
dif_flash_ctrl_irq_state_snapshot_t
*snapshot);
162
163
/**
164
* Returns whether a particular interrupt is currently pending.
165
*
166
* @param flash_ctrl A flash_ctrl handle.
167
* @param irq An interrupt request.
168
* @param[out] is_pending Out-param for whether the interrupt is pending.
169
* @return The result of the operation.
170
*/
171
OT_WARN_UNUSED_RESULT
172
dif_result_t
dif_flash_ctrl_irq_is_pending
(
const
dif_flash_ctrl_t
*flash_ctrl,
173
dif_flash_ctrl_irq_t
irq,
174
bool
*is_pending);
175
176
/**
177
* Acknowledges all interrupts that were pending at the time of the state
178
* snapshot.
179
*
180
* @param flash_ctrl A flash_ctrl handle.
181
* @param snapshot Interrupt state snapshot.
182
* @return The result of the operation.
183
*/
184
OT_WARN_UNUSED_RESULT
185
dif_result_t
dif_flash_ctrl_irq_acknowledge_state
(
186
const
dif_flash_ctrl_t
*flash_ctrl,
187
dif_flash_ctrl_irq_state_snapshot_t
snapshot);
188
189
/**
190
* Acknowledges all interrupts, indicating to the hardware that all
191
* interrupts have been successfully serviced.
192
*
193
* @param flash_ctrl A flash_ctrl handle.
194
* @return The result of the operation.
195
*/
196
OT_WARN_UNUSED_RESULT
197
dif_result_t
dif_flash_ctrl_irq_acknowledge_all
(
198
const
dif_flash_ctrl_t
*flash_ctrl);
199
200
/**
201
* Acknowledges a particular interrupt, indicating to the hardware that it has
202
* been successfully serviced.
203
*
204
* @param flash_ctrl A flash_ctrl handle.
205
* @param irq An interrupt request.
206
* @return The result of the operation.
207
*/
208
OT_WARN_UNUSED_RESULT
209
dif_result_t
dif_flash_ctrl_irq_acknowledge
(
const
dif_flash_ctrl_t
*flash_ctrl,
210
dif_flash_ctrl_irq_t
irq);
211
212
/**
213
* Forces a particular interrupt, causing it to be serviced as if hardware had
214
* asserted it.
215
*
216
* @param flash_ctrl A flash_ctrl handle.
217
* @param irq An interrupt request.
218
* @param val Value to be set.
219
* @return The result of the operation.
220
*/
221
OT_WARN_UNUSED_RESULT
222
dif_result_t
dif_flash_ctrl_irq_force
(
const
dif_flash_ctrl_t
*flash_ctrl,
223
dif_flash_ctrl_irq_t
irq,
const
bool
val);
224
225
/**
226
* A snapshot of the enablement state of the interrupts for this IP.
227
*
228
* This is an opaque type, to be used with the
229
* `dif_flash_ctrl_irq_disable_all()` and `dif_flash_ctrl_irq_restore_all()`
230
* functions.
231
*/
232
typedef
uint32_t
dif_flash_ctrl_irq_enable_snapshot_t
;
233
234
/**
235
* Checks whether a particular interrupt is currently enabled or disabled.
236
*
237
* @param flash_ctrl A flash_ctrl handle.
238
* @param irq An interrupt request.
239
* @param[out] state Out-param toggle state of the interrupt.
240
* @return The result of the operation.
241
*/
242
OT_WARN_UNUSED_RESULT
243
dif_result_t
dif_flash_ctrl_irq_get_enabled
(
const
dif_flash_ctrl_t
*flash_ctrl,
244
dif_flash_ctrl_irq_t
irq,
245
dif_toggle_t
*state);
246
247
/**
248
* Sets whether a particular interrupt is currently enabled or disabled.
249
*
250
* @param flash_ctrl A flash_ctrl handle.
251
* @param irq An interrupt request.
252
* @param state The new toggle state for the interrupt.
253
* @return The result of the operation.
254
*/
255
OT_WARN_UNUSED_RESULT
256
dif_result_t
dif_flash_ctrl_irq_set_enabled
(
const
dif_flash_ctrl_t
*flash_ctrl,
257
dif_flash_ctrl_irq_t
irq,
258
dif_toggle_t
state);
259
260
/**
261
* Disables all interrupts, optionally snapshotting all enable states for later
262
* restoration.
263
*
264
* @param flash_ctrl A flash_ctrl handle.
265
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
266
* @return The result of the operation.
267
*/
268
OT_WARN_UNUSED_RESULT
269
dif_result_t
dif_flash_ctrl_irq_disable_all
(
270
const
dif_flash_ctrl_t
*flash_ctrl,
271
dif_flash_ctrl_irq_enable_snapshot_t
*snapshot);
272
273
/**
274
* Restores interrupts from the given (enable) snapshot.
275
*
276
* @param flash_ctrl A flash_ctrl handle.
277
* @param snapshot A snapshot to restore from.
278
* @return The result of the operation.
279
*/
280
OT_WARN_UNUSED_RESULT
281
dif_result_t
dif_flash_ctrl_irq_restore_all
(
282
const
dif_flash_ctrl_t
*flash_ctrl,
283
const
dif_flash_ctrl_irq_enable_snapshot_t
*snapshot);
284
285
#ifdef __cplusplus
286
}
// extern "C"
287
#endif
// __cplusplus
288
289
#endif
// OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_FLASH_CTRL_AUTOGEN_H_
Return to
OpenTitan Documentation