option to pipe the dc serial port to a pty on linux
allow the use of dcload-serial
This commit is contained in:
parent
3b83a4e4d5
commit
3e6bef3cc0
|
@ -2,10 +2,18 @@
|
|||
Dreamcast serial port.
|
||||
This is missing most of the functionality, but works for KOS (And thats all that uses it)
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#include "types.h"
|
||||
#include "hw/sh4/sh4_mmr.h"
|
||||
#include "hw/sh4/sh4_interrupts.h"
|
||||
|
||||
static int tty = 1; // stdout by default
|
||||
|
||||
SCIF_SCFSR2_type SCIF_SCFSR2;
|
||||
SCIF_SCSCR2_type SCIF_SCSCR2;
|
||||
|
||||
|
@ -55,7 +63,7 @@ static void Serial_UpdateInterrupts()
|
|||
static void SerialWrite(u32 addr, u32 data)
|
||||
{
|
||||
if (settings.debug.SerialConsole)
|
||||
putc(data, stdout);
|
||||
write(tty, &data, 1);
|
||||
|
||||
SCIF_SCFSR2.TDFE = 1;
|
||||
SCIF_SCFSR2.TEND = 1;
|
||||
|
@ -66,11 +74,14 @@ static void SerialWrite(u32 addr, u32 data)
|
|||
//SCIF_SCFSR2 read
|
||||
static u32 ReadSerialStatus(u32 addr)
|
||||
{
|
||||
if (false /*PendingSerialData()*/)
|
||||
#if HOST_OS == OS_LINUX || HOST_OS == OS_DARWIN
|
||||
int count = 0;
|
||||
if (settings.debug.SerialConsole && ioctl(tty, FIONREAD, &count) == 0 && count > 0)
|
||||
{
|
||||
return SCIF_SCFSR2.full | 2;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return SCIF_SCFSR2.full | 0;
|
||||
}
|
||||
|
@ -97,8 +108,9 @@ static u32 Read_SCFDR2(u32 addr)
|
|||
//SCIF_SCFRDR2
|
||||
static u32 ReadSerialData(u32 addr)
|
||||
{
|
||||
s32 rd=0;//ReadSerial();
|
||||
return (u8)rd ;
|
||||
u8 data = 0;
|
||||
read(tty, &data, 1);
|
||||
return data;
|
||||
}
|
||||
|
||||
//SCSCR2
|
||||
|
@ -150,6 +162,21 @@ void serial_init()
|
|||
|
||||
//SCIF SCLSR2 0xFFE80024 0x1FE80024 16 0x0000 0x0000 Held Held Pclk
|
||||
sh4_rio_reg(SCIF,SCIF_SCLSR2_addr,RIO_DATA,16);
|
||||
|
||||
#if HOST_OS == OS_LINUX || HOST_OS == OS_DARWIN
|
||||
if (settings.debug.SerialConsole && settings.debug.SerialPTY)
|
||||
{
|
||||
tty = open("/dev/ptmx", O_RDWR | O_NDELAY | O_NOCTTY | O_NONBLOCK);
|
||||
if (tty < 0)
|
||||
ERROR_LOG(BOOT, "Cannot open /dev/ptmx: errno %d", errno);
|
||||
else
|
||||
{
|
||||
grantpt(tty);
|
||||
unlockpt(tty);
|
||||
NOTICE_LOG(BOOT, "Pseudoterminal is at %s", ptsname(tty));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void serial_reset()
|
||||
{
|
||||
|
@ -176,5 +203,10 @@ void serial_reset()
|
|||
|
||||
void serial_term()
|
||||
{
|
||||
if (tty > 2)
|
||||
{
|
||||
close(tty);
|
||||
tty = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -738,6 +738,7 @@ void InitSettings()
|
|||
settings.pvr.SynchronousRender = true;
|
||||
|
||||
settings.debug.SerialConsole = false;
|
||||
settings.debug.SerialPTY = false;
|
||||
|
||||
settings.bios.UseReios = false;
|
||||
settings.reios.ElfFile = "";
|
||||
|
@ -834,6 +835,7 @@ void LoadSettings(bool game_specific)
|
|||
settings.pvr.SynchronousRender = cfgLoadBool(config_section, "pvr.SynchronousRendering", settings.pvr.SynchronousRender);
|
||||
|
||||
settings.debug.SerialConsole = cfgLoadBool(config_section, "Debug.SerialConsoleEnabled", settings.debug.SerialConsole);
|
||||
settings.debug.SerialPTY = cfgLoadBool(config_section, "Debug.SerialPTY", settings.debug.SerialPTY);
|
||||
|
||||
settings.bios.UseReios = cfgLoadBool(config_section, "bios.UseReios", settings.bios.UseReios);
|
||||
settings.reios.ElfFile = cfgLoadStr(game_specific ? cfgGetGameId() : "reios", "ElfFile", settings.reios.ElfFile.c_str());
|
||||
|
@ -992,6 +994,7 @@ void SaveSettings()
|
|||
cfgSaveBool("config", "pvr.SynchronousRendering", settings.pvr.SynchronousRender);
|
||||
|
||||
cfgSaveBool("config", "Debug.SerialConsoleEnabled", settings.debug.SerialConsole);
|
||||
cfgSaveBool("config", "Debug.SerialPTY", settings.debug.SerialPTY);
|
||||
cfgSaveInt("input", "MouseSensitivity", settings.input.MouseSensitivity);
|
||||
cfgSaveInt("input", "VirtualGamepadVibration", settings.input.VirtualGamepadVibration);
|
||||
for (int i = 0; i < MAPLE_PORTS; i++)
|
||||
|
|
12
core/types.h
12
core/types.h
|
@ -320,13 +320,8 @@ bool dc_unserialize(void **data, unsigned int *total_size);
|
|||
#define stricmp strcasecmp
|
||||
#endif
|
||||
|
||||
#ifndef STRIP_TEXT
|
||||
#define verify(x) do { if ((x) == false){ msgboxf("Verify Failed : " #x "\n in %s -> %s : %d \n", MBX_ICONERROR, (__FUNCTION__), (__FILE__), __LINE__); dbgbreak;}} while (false)
|
||||
#define die(reason) do { msgboxf("Fatal error : %s\n in %s -> %s : %d \n", MBX_ICONERROR,(reason), (__FUNCTION__), (__FILE__), __LINE__); dbgbreak;} while (false)
|
||||
#else
|
||||
#define verify(x) do { if ((x) == false) dbgbreak; } while (false)
|
||||
#define die(reason) do { dbgbreak; } while (false)
|
||||
#endif
|
||||
|
||||
|
||||
//will be removed sometime soon
|
||||
|
@ -346,16 +341,10 @@ typedef void RegWriteAddrFP(u32 addr, u32 data);
|
|||
*/
|
||||
enum RegStructFlags
|
||||
{
|
||||
//Basic :
|
||||
REG_ACCESS_8=1,
|
||||
REG_ACCESS_16=2,
|
||||
REG_ACCESS_32=4,
|
||||
|
||||
REG_RF=8,
|
||||
REG_WF=16,
|
||||
REG_RO=32,
|
||||
REG_WO=64,
|
||||
REG_CONST=128,
|
||||
REG_NO_ACCESS=REG_RO|REG_WO,
|
||||
};
|
||||
|
||||
|
@ -531,6 +520,7 @@ struct settings_t
|
|||
|
||||
struct {
|
||||
bool SerialConsole;
|
||||
bool SerialPTY;
|
||||
} debug;
|
||||
|
||||
struct {
|
||||
|
|
Loading…
Reference in New Issue