The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
serial.c File Reference
#include "serial.h"
#include "arch/x86/cpu/io.h"

Macros

#define TX_WAIT_LOOPS   100000

Enumerations

enum  {
  COM1_PORT = 0x3F8 , UART_DATA = 0 , UART_INT_ENABLE = 1 , UART_DIVISOR_LOW = 0 ,
  UART_DIVISOR_HIGH = 1 , UART_FIFO_CTRL = 2 , UART_LINE_CTRL = 3 , UART_MODEM_CTRL = 4 ,
  UART_LINE_STATUS = 5 , UART_SCRATCH = 7
}
enum  {
  LINE_CTRL_8BITS = 0x03 , LINE_CTRL_DLAB = 0x80 , FIFO_ENABLE_CLEAR = 0xC7 , MODEM_READY = 0x0B ,
  LINE_STATUS_TX_EMPTY = 0x20 , BAUD_DIVISOR_115200 = 0x0001
}

Functions

void serial_initialize (void)
 minimal COM1 serial port driver (16550 UART), polling-mode transmit.
void serial_putchar (char c)
 write a single character to COM1, blocking until the UART is ready.
void serial_write (const char *str)
 write a null-terminated string to COM1.

Macro Definition Documentation

◆ TX_WAIT_LOOPS

#define TX_WAIT_LOOPS   100000

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
COM1_PORT 
UART_DATA 
UART_INT_ENABLE 
UART_DIVISOR_LOW 
UART_DIVISOR_HIGH 
UART_FIFO_CTRL 
UART_LINE_CTRL 
UART_MODEM_CTRL 
UART_LINE_STATUS 
UART_SCRATCH 

◆ anonymous enum

anonymous enum
Enumerator
LINE_CTRL_8BITS 
LINE_CTRL_DLAB 
FIFO_ENABLE_CLEAR 
MODEM_READY 
LINE_STATUS_TX_EMPTY 
BAUD_DIVISOR_115200 

Function Documentation

◆ serial_initialize()

void serial_initialize ( void )

minimal COM1 serial port driver (16550 UART), polling-mode transmit.

intended for kernel debug output: it works before the VGA console is up and is visible headlessly under QEMU with -serial stdio. transmit only blocks by polling the line-status register, so it needs no IRQ and is safe to call from panic and early boot. initialize COM1 (115200 baud, 8N1, FIFO enabled). safe to call once, early in boot, before interrupts are enabled.

◆ serial_putchar()

void serial_putchar ( char c)

write a single character to COM1, blocking until the UART is ready.

translates '
' to "\r\n" so terminals render lines correctly.

Parameters
ccharacter to send.

◆ serial_write()

void serial_write ( const char * str)

write a null-terminated string to COM1.

Parameters
strstring to send.