Files
novaos/kernel/include/kernel/serial.h

92 lines
2.2 KiB
C

#include <stdint.h>
#ifndef _KERNEL_SERIAL_H
#define _KERNEL_SERIAL_H
/**
* serial_initialize:
* Initializes the serial port for writing.
*/
void serial_initialize(void);
/**
* serial_configure_baud_rate:
* Sets the speed of the data being sent.
* The argument is a divisor of that number, hence the speed becomes
* (speed / divisor) bits/s.
*
* @param com The COM port to configure
* @param divisor The divisor
*/
void serial_configure_baud_rate(unsigned short com, unsigned short divisor);
/**
* serial_configure_line:
* Configures the line of the given serial port. The port is set to have a
* data length of 8 bits, no parity bits, one stop bit and break control
* disabled.
*
* @param com The serial port to configure
*/
void serial_configure_line(unsigned short com);
/**
* serial_configure_buffers:
* Configures the buffer of the given serial port. The port is set to
* enable FIFO, clear the receiver and transmission FIFO queues,
* and to use 14 bytes as a size of the queue.
*
* @param com The serial port to configure
*/
void serial_configure_buffers(unsigned short com);
/**
* serial_configure_modem:
* Configures the modem of the given serial port.
* We don't need interrupts, and just need RTS and DTS.
*
* @param com The serial port to configure
*/
void serial_configure_modem(unsigned short com);
/**
* serial_is_transmit_fifo_empty:
* Checks whether the transmit FIFO queue is empty or not for the given COM port.
*
* @param com The COM port
*
* @return 0 if the transmit FIFO queue is not empty
* 1 if the transmit FIFO queue is empty
*/
int serial_is_transmit_fifo_empty(unsigned int com);
/**
* serial_write_byte:
* Writes a byte to the serial port, and adhering to the FIFO queue,
* ensures bytes aren't overwritten
*
* @param com The serial port
* @param c The character to write
*/
void serial_write_byte(unsigned short com, char c);
/**
* serial_write:
* Writes to the serial output (DEFAULTS TO COM1)
*
* @param buf The character buffer
* @param len The length of the buffer
*/
void serial_write(const char* buf, size_t len);
/**
* serial_writestring:
* Writes toe the serial output (DEFAULT TO COM1)
*
* @param buf The character buffer
*/
void serial_writestring(const char* buf);
#endif