Software APIs
dif_uart_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_UART_AUTOGEN_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_UART_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/uart/">UART</a> Device Interface Functions
14  */
15 
16 #include <stdbool.h>
17 #include <stdint.h>
18 
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif // __cplusplus
26 
27 /**
28  * A handle to uart.
29  *
30  * This type should be treated as opaque by users.
31  */
32 typedef struct dif_uart {
33  /**
34  * The base address for the uart hardware registers.
35  */
37 } dif_uart_t;
38 
39 /**
40  * Creates a new handle for a(n) uart peripheral.
41  *
42  * This function does not actuate the hardware.
43  *
44  * @param base_addr The MMIO base address of the uart peripheral.
45  * @param[out] uart Out param for the initialized handle.
46  * @return The result of the operation.
47  */
50 
51 /**
52  * A uart alert type.
53  */
54 typedef enum dif_uart_alert {
55  /**
56  * This fatal alert is triggered when a fatal TL-UL bus integrity fault is
57  * detected.
58  */
61 
62 /**
63  * Forces a particular alert, causing it to be escalated as if the hardware
64  * had raised it.
65  *
66  * @param uart A uart handle.
67  * @param alert The alert to force.
68  * @return The result of the operation.
69  */
72  dif_uart_alert_t alert);
73 
74 /**
75  * A uart interrupt request type.
76  */
77 typedef enum dif_uart_irq {
78  /**
79  * Raised if the transmit FIFO is past the high-water mark.
80  */
82  /**
83  * Raised if the receive FIFO is past the high-water mark.
84  */
86  /**
87  * Raised if the transmit FIFO has emptied and no transmit is ongoing.
88  */
90  /**
91  * Raised if the receive FIFO has overflowed.
92  */
94  /**
95  * Raised if a framing error has been detected on receive.
96  */
98  /**
99  * Raised if break condition has been detected on receive.
100  */
102  /**
103  * Raised if RX FIFO has characters remaining in the FIFO without being
104  * retrieved for the programmed time period.
105  */
107  /**
108  * Raised if the receiver has detected a parity error.
109  */
112 
113 /**
114  * A snapshot of the state of the interrupts for this IP.
115  *
116  * This is an opaque type, to be used with the `dif_uart_irq_get_state()`
117  * and `dif_uart_irq_acknowledge_state()` functions.
118  */
120 
121 /**
122  * Returns the type of a given interrupt (i.e., event or status) for this IP.
123  *
124  * @param uart A uart handle.
125  * @param irq An interrupt request.
126  * @param[out] type Out-param for the interrupt type.
127  * @return The result of the operation.
128  */
131  dif_irq_type_t *type);
132 
133 /**
134  * Returns the state of all interrupts (i.e., pending or not) for this IP.
135  *
136  * @param uart A uart handle.
137  * @param[out] snapshot Out-param for interrupt state snapshot.
138  * @return The result of the operation.
139  */
143 
144 /**
145  * Returns whether a particular interrupt is currently pending.
146  *
147  * @param uart A uart handle.
148  * @param irq An interrupt request.
149  * @param[out] is_pending Out-param for whether the interrupt is pending.
150  * @return The result of the operation.
151  */
154  bool *is_pending);
155 
156 /**
157  * Acknowledges all interrupts that were pending at the time of the state
158  * snapshot.
159  *
160  * @param uart A uart handle.
161  * @param snapshot Interrupt state snapshot.
162  * @return The result of the operation.
163  */
166  const dif_uart_t *uart, dif_uart_irq_state_snapshot_t snapshot);
167 
168 /**
169  * Acknowledges all interrupts, indicating to the hardware that all
170  * interrupts have been successfully serviced.
171  *
172  * @param uart A uart handle.
173  * @return The result of the operation.
174  */
177 
178 /**
179  * Acknowledges a particular interrupt, indicating to the hardware that it has
180  * been successfully serviced.
181  *
182  * @param uart A uart handle.
183  * @param irq An interrupt request.
184  * @return The result of the operation.
185  */
188  dif_uart_irq_t irq);
189 
190 /**
191  * Forces a particular interrupt, causing it to be serviced as if hardware had
192  * asserted it.
193  *
194  * @param uart A uart handle.
195  * @param irq An interrupt request.
196  * @param val Value to be set.
197  * @return The result of the operation.
198  */
201  const bool val);
202 
203 /**
204  * A snapshot of the enablement state of the interrupts for this IP.
205  *
206  * This is an opaque type, to be used with the
207  * `dif_uart_irq_disable_all()` and `dif_uart_irq_restore_all()`
208  * functions.
209  */
211 
212 /**
213  * Checks whether a particular interrupt is currently enabled or disabled.
214  *
215  * @param uart A uart handle.
216  * @param irq An interrupt request.
217  * @param[out] state Out-param toggle state of the interrupt.
218  * @return The result of the operation.
219  */
222  dif_uart_irq_t irq, dif_toggle_t *state);
223 
224 /**
225  * Sets whether a particular interrupt is currently enabled or disabled.
226  *
227  * @param uart A uart handle.
228  * @param irq An interrupt request.
229  * @param state The new toggle state for the interrupt.
230  * @return The result of the operation.
231  */
234  dif_uart_irq_t irq, dif_toggle_t state);
235 
236 /**
237  * Disables all interrupts, optionally snapshotting all enable states for later
238  * restoration.
239  *
240  * @param uart A uart handle.
241  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
242  * @return The result of the operation.
243  */
247 
248 /**
249  * Restores interrupts from the given (enable) snapshot.
250  *
251  * @param uart A uart handle.
252  * @param snapshot A snapshot to restore from.
253  * @return The result of the operation.
254  */
257  const dif_uart_t *uart, const dif_uart_irq_enable_snapshot_t *snapshot);
258 
259 #ifdef __cplusplus
260 } // extern "C"
261 #endif // __cplusplus
262 
263 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_UART_AUTOGEN_H_