Untitled_Kernel/include/serial.h
2025-07-04 01:47:44 -04:00

50 lines
1.1 KiB
C

/* serial.h
* Serial Interface
*
* Send/receive data via serial ports.
*/
#ifndef SERIAL_H
#define SERIAL_H
#include "asm.h"
#include "io.h"
#include <stdint.h>
typedef struct serial_ctx_s {
uint16_t port;
} serial_ctx_t;
extern char_writer_t* default_COM;
/**
* @brief Initialize a serial port for communication
* @param port The serial port number to initialize
* @return Status code indicating success or failure
*/
int serial_init(serial_ctx_t* ctx);
/**
* @brief Check if there is pending data to receive on the serial port
* @return Non-zero if data is pending, 0 otherwise
*/
int serial_recv_pending();
/**
* @brief Receive a single byte from the serial port
* @return The received byte as an 8-bit unsigned integer
*/
uint8_t serial_recv8(serial_ctx_t* ctx);
/**
* @brief Check if the serial port is ready to send data
* @return Non-zero if ready to send, 0 otherwise
*/
int serial_send_pending(serial_ctx_t* ctx);
/**
* @brief Send a single byte through the serial port
* @param data The 8-bit data byte to send
*/
int serial_send8(void* ctx, char data);
#endif