Software APIs
sw
device
lib
dif
autogen
dif_dma_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_DMA_AUTOGEN_H_
6
#define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_DMA_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/dma/">DMA</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 dma.
29
*
30
* This type should be treated as opaque by users.
31
*/
32
typedef
struct
dif_dma
{
33
/**
34
* The base address for the dma hardware registers.
35
*/
36
mmio_region_t
base_addr
;
37
}
dif_dma_t
;
38
39
/**
40
* Creates a new handle for a(n) dma peripheral.
41
*
42
* This function does not actuate the hardware.
43
*
44
* @param base_addr The MMIO base address of the dma peripheral.
45
* @param[out] dma Out param for the initialized handle.
46
* @return The result of the operation.
47
*/
48
OT_WARN_UNUSED_RESULT
49
dif_result_t
dif_dma_init
(
mmio_region_t
base_addr,
dif_dma_t
*dma);
50
51
/**
52
* A dma alert type.
53
*/
54
typedef
enum
dif_dma_alert
{
55
/**
56
* This fatal alert is triggered when a fatal TL-UL bus integrity fault is
57
* detected.
58
*/
59
kDifDmaAlertFatalFault
= 0,
60
}
dif_dma_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 dma A dma 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_dma_alert_force
(
const
dif_dma_t
*dma,
dif_dma_alert_t
alert);
72
73
/**
74
* A dma interrupt request type.
75
*/
76
typedef
enum
dif_dma_irq
{
77
/**
78
* DMA operation has been completed.
79
*/
80
kDifDmaIrqDmaDone
= 0,
81
/**
82
* Indicates the transfer of a single chunk has been completed.
83
*/
84
kDifDmaIrqDmaChunkDone
= 1,
85
/**
86
* DMA error has occurred. DMA_STATUS.error_code register shows the details.
87
*/
88
kDifDmaIrqDmaError
= 2,
89
}
dif_dma_irq_t
;
90
91
/**
92
* A snapshot of the state of the interrupts for this IP.
93
*
94
* This is an opaque type, to be used with the `dif_dma_irq_get_state()`
95
* and `dif_dma_irq_acknowledge_state()` functions.
96
*/
97
typedef
uint32_t
dif_dma_irq_state_snapshot_t
;
98
99
/**
100
* Returns the type of a given interrupt (i.e., event or status) for this IP.
101
*
102
* @param dma A dma handle.
103
* @param irq An interrupt request.
104
* @param[out] type Out-param for the interrupt type.
105
* @return The result of the operation.
106
*/
107
OT_WARN_UNUSED_RESULT
108
dif_result_t
dif_dma_irq_get_type
(
const
dif_dma_t
*dma,
dif_dma_irq_t
irq,
109
dif_irq_type_t
*type);
110
111
/**
112
* Returns the state of all interrupts (i.e., pending or not) for this IP.
113
*
114
* @param dma A dma handle.
115
* @param[out] snapshot Out-param for interrupt state snapshot.
116
* @return The result of the operation.
117
*/
118
OT_WARN_UNUSED_RESULT
119
dif_result_t
dif_dma_irq_get_state
(
const
dif_dma_t
*dma,
120
dif_dma_irq_state_snapshot_t
*snapshot);
121
122
/**
123
* Returns whether a particular interrupt is currently pending.
124
*
125
* @param dma A dma handle.
126
* @param irq An interrupt request.
127
* @param[out] is_pending Out-param for whether the interrupt is pending.
128
* @return The result of the operation.
129
*/
130
OT_WARN_UNUSED_RESULT
131
dif_result_t
dif_dma_irq_is_pending
(
const
dif_dma_t
*dma,
dif_dma_irq_t
irq,
132
bool
*is_pending);
133
134
/**
135
* Acknowledges all interrupts that were pending at the time of the state
136
* snapshot.
137
*
138
* @param dma A dma handle.
139
* @param snapshot Interrupt state snapshot.
140
* @return The result of the operation.
141
*/
142
OT_WARN_UNUSED_RESULT
143
dif_result_t
dif_dma_irq_acknowledge_state
(
144
const
dif_dma_t
*dma,
dif_dma_irq_state_snapshot_t
snapshot);
145
146
/**
147
* Acknowledges all interrupts, indicating to the hardware that all
148
* interrupts have been successfully serviced.
149
*
150
* @param dma A dma handle.
151
* @return The result of the operation.
152
*/
153
OT_WARN_UNUSED_RESULT
154
dif_result_t
dif_dma_irq_acknowledge_all
(
const
dif_dma_t
*dma);
155
156
/**
157
* Acknowledges a particular interrupt, indicating to the hardware that it has
158
* been successfully serviced.
159
*
160
* @param dma A dma handle.
161
* @param irq An interrupt request.
162
* @return The result of the operation.
163
*/
164
OT_WARN_UNUSED_RESULT
165
dif_result_t
dif_dma_irq_acknowledge
(
const
dif_dma_t
*dma,
dif_dma_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 dma A dma 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_dma_irq_force
(
const
dif_dma_t
*dma,
dif_dma_irq_t
irq,
178
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_dma_irq_disable_all()` and `dif_dma_irq_restore_all()`
185
* functions.
186
*/
187
typedef
uint32_t
dif_dma_irq_enable_snapshot_t
;
188
189
/**
190
* Checks whether a particular interrupt is currently enabled or disabled.
191
*
192
* @param dma A dma 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_dma_irq_get_enabled
(
const
dif_dma_t
*dma,
dif_dma_irq_t
irq,
199
dif_toggle_t
*state);
200
201
/**
202
* Sets whether a particular interrupt is currently enabled or disabled.
203
*
204
* @param dma A dma handle.
205
* @param irq An interrupt request.
206
* @param state The new toggle state for the interrupt.
207
* @return The result of the operation.
208
*/
209
OT_WARN_UNUSED_RESULT
210
dif_result_t
dif_dma_irq_set_enabled
(
const
dif_dma_t
*dma,
dif_dma_irq_t
irq,
211
dif_toggle_t
state);
212
213
/**
214
* Disables all interrupts, optionally snapshotting all enable states for later
215
* restoration.
216
*
217
* @param dma A dma handle.
218
* @param[out] snapshot Out-param for the snapshot; may be `NULL`.
219
* @return The result of the operation.
220
*/
221
OT_WARN_UNUSED_RESULT
222
dif_result_t
dif_dma_irq_disable_all
(
const
dif_dma_t
*dma,
223
dif_dma_irq_enable_snapshot_t
*snapshot);
224
225
/**
226
* Restores interrupts from the given (enable) snapshot.
227
*
228
* @param dma A dma handle.
229
* @param snapshot A snapshot to restore from.
230
* @return The result of the operation.
231
*/
232
OT_WARN_UNUSED_RESULT
233
dif_result_t
dif_dma_irq_restore_all
(
234
const
dif_dma_t
*dma,
const
dif_dma_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_DMA_AUTOGEN_H_
Return to
OpenTitan Documentation