Untitled_Kernel/include/serial.h
Jake Holtham 20357559c1 The beginning of paging!
The kernel resides in the higher half, and as of now still identity maps the lower half for compatibility. Will not merge back to master until all the previous features work properly in virtual memory..
2025-07-15 14:52:48 -04:00

55 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>
#define COM1 0x3F8
#define COM2 0x2F8
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