AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
uart.h
Go to the documentation of this file.
1#ifndef _DEV_UART_H
2#define _DEV_UART_H
3
4#include <ds/queue.h>
5
6#include <fs/vfs.h>
7#include <dev/tty.h>
8
9/*
10 * Serial ports (dev/tty/uart/uart.c): a UART is a terminal, /dev/ttyS0
11 * and up. A UART driver (8250, PL011) provides the operations below, and
12 * calls uart_receive_handler() and uart_transmit_handler() from its
13 * interrupt handler.
14 */
15
17struct uart {
18 char *name;
19
20 struct ringbuf *in;
21 struct ringbuf *out;
22
23 struct tty *tty; /* its terminal, once it has been opened */
24 struct vnode *vnode; /* the node it was first opened through (held) */
25
26 /* the readers and writers of every node of it sleep on these, so
27 * that the interrupt handler doesn't need a vnode that may be gone */
30
31 void (*init) (struct uart *u);
32 ssize_t (*transmit)(struct uart *u, char c);
33 char (*receive) (struct uart *u);
34};
35
36/* Registers a UART as /dev/ttyS<id> (-1: the first free one). */
37int uart_register(int id, struct uart *u);
38
39/* Called by a driver when it has received `size` bytes, or has room to
40 * send `size` more. */
41void uart_receive_handler(struct uart *u, size_t size);
42void uart_transmit_handler(struct uart *u, size_t size);
43
44#endif /* ! _DEV_UART_H */
void uart_transmit_handler(struct uart *u, size_t size)
Sends characters that the terminal output to its UART.
Definition uart.c:59
int uart_register(int id, struct uart *u)
Registers a UART, as /dev/ttyS<id>.
Definition uart.c:278
void uart_receive_handler(struct uart *u, size_t size)
Takes characters a UART received, and gives them to its terminal.
Definition uart.c:35
A ring buffer.
Definition ringbuf.h:18
A serial port.
Definition uart.h:17
struct vnode * vnode
Definition uart.h:24
char * name
Definition uart.h:18
struct waitq read_queue
Definition uart.h:28
ssize_t(*) transmit(struct uart *u, char c)
Definition uart.h:32
void(*) init(struct uart *u)
Definition uart.h:31
char(*) receive(struct uart *u)
Definition uart.h:33
struct ringbuf * in
Definition uart.h:20
struct ringbuf * out
Definition uart.h:21
struct waitq write_queue
Definition uart.h:29
struct tty * tty
Definition uart.h:23
Definition waitq.h:19
long int ssize_t
Definition types.h:12