/*
 * Minimal dummy serialport implementation for QNX aarch64
 * No real hardware serial support - just enough to link DOSBox-X.
 */

#include "dosbox.h"
#include "serialport.h"
#include "programs.h"

#ifdef __QNX__
// QNX stubs - using unsigned char directly to avoid Bit8u visibility issues
bool CSerial::Putchar(unsigned char data, bool wait_dsr, bool wait_cts, Bitu timeout)
{
    (void)data; (void)wait_dsr; (void)wait_cts; (void)timeout;
    return false;
}

bool CSerial::Getchar(unsigned char *data, unsigned char *status, bool wait, Bitu timeout)
{
    (void)wait; (void)timeout;
    if (data)   *data = 0;
    if (status) *status = 0;
    return false;
}
#endif

/* Globals - must match serialport.h exactly */
CSerial* serialports[4] = {nullptr, nullptr, nullptr, nullptr};
bool serialMouseEmulated = false;

/* Core dummy functions */
Bitu SERIAL_ProgramStart(Program** /*make*/) { return 0; }
void SERIAL_Init() {}
void SERIAL_EventHandler_PIC_Event(Bitu /*val*/) {}

void BIOS_Post_register_comports() {}
void BIOS_Post_register_comports_PNP() {}
int bios_post_comport_count() { return 0; }

void on_mouse_event_for_serial(int /*dx*/, int /*dy*/, unsigned char /*button*/) {}
void runSerial(const char* /*command*/) {}

/* Platform stubs used by OPL2/OPL3 boards */
int SERIAL_open(const char* /*port*/, void** /*comport*/) { return 0; }
void SERIAL_close(void* /*comport*/) {}
void SERIAL_setCommParameters(void* /*comport*/, int, char, int, int) {}
int SERIAL_sendchar(void* /*comport*/, char) { return 0; }
int SERIAL_getchar(void* /*comport*/, unsigned char*, unsigned char*, bool, unsigned long) { return 0; }

/* Legacy global stubs (harmless) */
bool CSerial_Putchar(uint8_t /*data*/, bool /*wait_dsr*/, bool /*wait_cts*/, Bitu /*timeout*/) { return false; }
bool CSerial_Getchar(uint8_t* /*data*/, uint8_t* /*lsr*/, bool /*wait_dsr*/, Bitu /*timeout*/) { return false; }
