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  */
111  /**
112  * Raised if the transmit FIFO is empty.
113  */
116 
117 /**
118  * A snapshot of the state of the interrupts for this IP.
119  *
120  * This is an opaque type, to be used with the `dif_uart_irq_get_state()`
121  * and `dif_uart_irq_acknowledge_state()` functions.
122  */
124 
125 /**
126  * Returns the type of a given interrupt (i.e., event or status) for this IP.
127  *
128  * @param uart A uart handle.
129  * @param irq An interrupt request.
130  * @param[out] type Out-param for the interrupt type.
131  * @return The result of the operation.
132  */
135  dif_irq_type_t *type);
136 
137 /**
138  * Returns the state of all interrupts (i.e., pending or not) for this IP.
139  *
140  * @param uart A uart handle.
141  * @param[out] snapshot Out-param for interrupt state snapshot.
142  * @return The result of the operation.
143  */
147 
148 /**
149  * Returns whether a particular interrupt is currently pending.
150  *
151  * @param uart A uart handle.
152  * @param irq An interrupt request.
153  * @param[out] is_pending Out-param for whether the interrupt is pending.
154  * @return The result of the operation.
155  */
158  bool *is_pending);
159 
160 /**
161  * Acknowledges all interrupts that were pending at the time of the state
162  * snapshot.
163  *
164  * @param uart A uart handle.
165  * @param snapshot Interrupt state snapshot.
166  * @return The result of the operation.
167  */
170  const dif_uart_t *uart, dif_uart_irq_state_snapshot_t snapshot);
171 
172 /**
173  * Acknowledges all interrupts, indicating to the hardware that all
174  * interrupts have been successfully serviced.
175  *
176  * @param uart A uart handle.
177  * @return The result of the operation.
178  */
181 
182 /**
183  * Acknowledges a particular interrupt, indicating to the hardware that it has
184  * been successfully serviced.
185  *
186  * @param uart A uart handle.
187  * @param irq An interrupt request.
188  * @return The result of the operation.
189  */
192  dif_uart_irq_t irq);
193 
194 /**
195  * Forces a particular interrupt, causing it to be serviced as if hardware had
196  * asserted it.
197  *
198  * @param uart A uart handle.
199  * @param irq An interrupt request.
200  * @param val Value to be set.
201  * @return The result of the operation.
202  */
205  const bool val);
206 
207 /**
208  * A snapshot of the enablement state of the interrupts for this IP.
209  *
210  * This is an opaque type, to be used with the
211  * `dif_uart_irq_disable_all()` and `dif_uart_irq_restore_all()`
212  * functions.
213  */
215 
216 /**
217  * Checks whether a particular interrupt is currently enabled or disabled.
218  *
219  * @param uart A uart handle.
220  * @param irq An interrupt request.
221  * @param[out] state Out-param toggle state of the interrupt.
222  * @return The result of the operation.
223  */
226  dif_uart_irq_t irq, dif_toggle_t *state);
227 
228 /**
229  * Sets whether a particular interrupt is currently enabled or disabled.
230  *
231  * @param uart A uart handle.
232  * @param irq An interrupt request.
233  * @param state The new toggle state for the interrupt.
234  * @return The result of the operation.
235  */
238  dif_uart_irq_t irq, dif_toggle_t state);
239 
240 /**
241  * Disables all interrupts, optionally snapshotting all enable states for later
242  * restoration.
243  *
244  * @param uart A uart handle.
245  * @param[out] snapshot Out-param for the snapshot; may be `NULL`.
246  * @return The result of the operation.
247  */
251 
252 /**
253  * Restores interrupts from the given (enable) snapshot.
254  *
255  * @param uart A uart handle.
256  * @param snapshot A snapshot to restore from.
257  * @return The result of the operation.
258  */
261  const dif_uart_t *uart, const dif_uart_irq_enable_snapshot_t *snapshot);
262 
263 #ifdef __cplusplus
264 } // extern "C"
265 #endif // __cplusplus
266 
267 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_UART_AUTOGEN_H_