AquilaOS documentation
How it works, and its code
Toggle main menu visibility
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
17
struct
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 */
28
struct
waitq
read_queue
;
29
struct
waitq
write_queue
;
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). */
37
int
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. */
41
void
uart_receive_handler
(
struct
uart
*u,
size_t
size);
42
void
uart_transmit_handler
(
struct
uart
*u,
size_t
size);
43
44
#endif
/* ! _DEV_UART_H */
uart_transmit_handler
void uart_transmit_handler(struct uart *u, size_t size)
Sends characters that the terminal output to its UART.
Definition
uart.c:59
uart_register
int uart_register(int id, struct uart *u)
Registers a UART, as /dev/ttyS<id>.
Definition
uart.c:278
uart_receive_handler
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
queue.h
ringbuf
A ring buffer.
Definition
ringbuf.h:18
uart
A serial port.
Definition
uart.h:17
uart::vnode
struct vnode * vnode
Definition
uart.h:24
uart::name
char * name
Definition
uart.h:18
uart::read_queue
struct waitq read_queue
Definition
uart.h:28
uart::transmit
ssize_t(*) transmit(struct uart *u, char c)
Definition
uart.h:32
uart::init
void(*) init(struct uart *u)
Definition
uart.h:31
uart::receive
char(*) receive(struct uart *u)
Definition
uart.h:33
uart::in
struct ringbuf * in
Definition
uart.h:20
uart::out
struct ringbuf * out
Definition
uart.h:21
uart::write_queue
struct waitq write_queue
Definition
uart.h:29
uart::tty
struct tty * tty
Definition
uart.h:23
waitq
Definition
waitq.h:19
tty.h
ssize_t
long int ssize_t
Definition
types.h:12
vfs.h
kernel
include
dev
uart.h
Generated by
1.18.0