AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
uart.h File Reference
#include <ds/queue.h>
#include <fs/vfs.h>
#include <dev/tty.h>

Go to the source code of this file.

Data Structures

struct  uart
 A serial port. More...

Functions

int uart_register (int id, struct uart *u)
 Registers a UART, as /dev/ttyS<id>.
void uart_receive_handler (struct uart *u, size_t size)
 Takes characters a UART received, and gives them to its terminal.
void uart_transmit_handler (struct uart *u, size_t size)
 Sends characters that the terminal output to its UART.

Function Documentation

◆ uart_receive_handler()

void uart_receive_handler ( struct uart * u,
size_t size )

Takes characters a UART received, and gives them to its terminal.

The UART's driver calls it from its interrupt handler.

Parameters
uthe UART
sizehow many characters to take from it

Definition at line 35 of file uart.c.

References MIN, uart::read_queue, uart::receive, uart::tty, tty_master_write(), UART_BUF, uart_receive_handler(), and waitq_wakeup().

Referenced by pl011_irq(), uart_8250_irq(), and uart_receive_handler().

◆ uart_register()

int uart_register ( int id,
struct uart * u )

Registers a UART, as /dev/ttyS<id>.

Parameters
idits number (below 192), or -1 for the first free one
uthe UART
Returns
its number, -EINVAL if id is too big, or -ENOSPC if every number is taken

Definition at line 278 of file uart.c.

References devices, uart::name, printk(), and uart_register().

Referenced by pl011_init(), uart_8250_attach(), and uart_register().

◆ uart_transmit_handler()

void uart_transmit_handler ( struct uart * u,
size_t size )

Sends characters that the terminal output to its UART.

Parameters
uthe UART
sizehow many characters to send, at most

Definition at line 59 of file uart.c.

References MIN, uart::out, uart::transmit, uart_transmit_handler(), waitq_wakeup(), and uart::write_queue.

Referenced by uart_8250_irq(), uart_master_write(), and uart_transmit_handler().