Skip to content

Commit

Permalink
Ported RemoveServer classes from vAmiga (not functional yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Aug 20, 2024
1 parent 419cdef commit 2189090
Show file tree
Hide file tree
Showing 27 changed files with 1,657 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Emulator/Base/Defaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ Defaults::Defaults()
setFallback(OPT_REC_ASPECT_X, 768);
setFallback(OPT_REC_ASPECT_Y, 702);

setFallback(OPT_SRV_PORT, 8081, { SERVER_RSH });
setFallback(OPT_SRV_PROTOCOL, SRVPROT_DEFAULT, { SERVER_RSH });
setFallback(OPT_SRV_AUTORUN, false, { SERVER_RSH });
setFallback(OPT_SRV_VERBOSE, true, { SERVER_RSH });

setFallback("BASIC_PATH", "");
setFallback("CHAR_PATH", "");
setFallback("KERNAL_PATH", "");
Expand Down
31 changes: 31 additions & 0 deletions Emulator/Base/ErrorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ enum_long(ERROR_CODE)
ERROR_CRT_TOO_MANY_PACKETS, ///< CRT file contains too many Rom packets
ERROR_CRT_CORRUPTED_PACKET, ///< CRT file contains a corrupted Rom package

// Remote servers
ERROR_SOCK_CANT_CREATE,
ERROR_SOCK_CANT_CONNECT,
ERROR_SOCK_CANT_BIND,
ERROR_SOCK_CANT_LISTEN,
ERROR_SOCK_CANT_ACCEPT,
ERROR_SOCK_CANT_RECEIVE,
ERROR_SOCK_CANT_SEND,
ERROR_SOCK_DISCONNECTED,
ERROR_SERVER_PORT_IN_USE,
ERROR_SERVER_ON,
ERROR_SERVER_OFF,
ERROR_SERVER_RUNNING,
ERROR_SERVER_NOT_RUNNING,
ERROR_SERVER_NO_CLIENT,

// File systems
ERROR_FS_UNSUPPORTED, ///< Unsupported file system
ERROR_FS_WRONG_CAPACITY, ///< Wrong file system capacity
Expand Down Expand Up @@ -171,6 +187,21 @@ struct ErrorCodeEnum : util::Reflection<ErrorCodeEnum, ErrorCode> {
case ERROR_CRT_TOO_MANY_PACKETS: return "CRT_TOO_MANY_PACKETS";
case ERROR_CRT_CORRUPTED_PACKET: return "CRT_CORRUPTED_PACKET";

case ERROR_SOCK_CANT_CREATE: return "SOCK_CANT_CREATE";
case ERROR_SOCK_CANT_CONNECT: return "SOCK_CANT_CONNECT";
case ERROR_SOCK_CANT_BIND: return "SOCK_CANT_BIND";
case ERROR_SOCK_CANT_LISTEN: return "SOCK_CANT_LISTEN";
case ERROR_SOCK_CANT_ACCEPT: return "SOCK_CANT_ACCEPT";
case ERROR_SOCK_CANT_RECEIVE: return "SOCK_CANT_RECEIVE";
case ERROR_SOCK_CANT_SEND: return "SOCK_CANT_SEND";
case ERROR_SOCK_DISCONNECTED: return "SOCK_DISCONNECTED";
case ERROR_SERVER_PORT_IN_USE: return "SERVER_PORT_IN_USE";
case ERROR_SERVER_ON: return "SERVER_ON";
case ERROR_SERVER_OFF: return "SERVER_OFF";
case ERROR_SERVER_RUNNING: return "SERVER_RUNNING";
case ERROR_SERVER_NOT_RUNNING: return "SERVER_NOT_RUNNING";
case ERROR_SERVER_NO_CLIENT: return "SERVER_NO_CLIENT";

case ERROR_FS_UNSUPPORTED: return "FS_UNSUPPORTED";
case ERROR_FS_WRONG_CAPACITY: return "FS_WRONG_CAPACITY";
case ERROR_FS_CORRUPTED: return "FS_CORRUPTED";
Expand Down
13 changes: 11 additions & 2 deletions Emulator/Base/MsgQueueTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,20 @@ enum_long(MSG_TYPE)
MSG_ALARM, ///< A user-set alarm event has fired
MSG_RS232, ///< RS232 activity (DEPRECATED)
MSG_RS232_IN, ///< RS232 adapter has received data
MSG_RS232_OUT ///< RS232 adapter has sent data
MSG_RS232_OUT, ///< RS232 adapter has sent data

// Remote server
MSG_SRV_STATE,
MSG_SRV_RECEIVE,
MSG_SRV_SEND
};

typedef MSG_TYPE MsgType;

struct MsgTypeEnum : util::Reflection<MsgTypeEnum, MsgType> {

static constexpr long minVal = 0;
static constexpr long maxVal = MSG_ALARM;
static constexpr long maxVal = MSG_SRV_SEND;
static bool isValid(auto value) { return value >= minVal && value <= maxVal; }

static const char *prefix() { return "MSG"; }
Expand Down Expand Up @@ -198,6 +203,10 @@ struct MsgTypeEnum : util::Reflection<MsgTypeEnum, MsgType> {
case MSG_RS232: return "RS232";
case MSG_RS232_IN: return "RS232_IN";
case MSG_RS232_OUT: return "RS232_OUT";

case MSG_SRV_STATE: return "SRV_STATE";
case MSG_SRV_RECEIVE: return "SRV_RECEIVE";
case MSG_SRV_SEND: return "SRV_SEND";
}
return "???";
}
Expand Down
5 changes: 5 additions & 0 deletions Emulator/Base/Option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ OptionParser::create(Option opt, i64 arg)
case OPT_REC_ASPECT_X: return numParser();
case OPT_REC_ASPECT_Y: return numParser();

case OPT_SRV_PORT: return numParser();
case OPT_SRV_PROTOCOL: return enumParser.template operator()<ServerProtocolEnum>();
case OPT_SRV_AUTORUN: return boolParser();
case OPT_SRV_VERBOSE: return boolParser();

default:
fatalError;
}
Expand Down
16 changes: 16 additions & 0 deletions Emulator/Base/OptionTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ enum_long(OPT)
OPT_REC_ASPECT_X, ///< Numerator of the video's aspect ratio
OPT_REC_ASPECT_Y, ///< Denumerator of the video's aspect ratio

// Remote servers
OPT_SRV_PORT,
OPT_SRV_PROTOCOL,
OPT_SRV_AUTORUN,
OPT_SRV_VERBOSE,

OPT_COUNT
};
typedef OPT Option;
Expand Down Expand Up @@ -332,6 +338,11 @@ struct OptionEnum : util::Reflection<OptionEnum, Option> {
case OPT_REC_ASPECT_X: return "REC.ASPECT_X";
case OPT_REC_ASPECT_Y: return "REC.ASPECT_Y";

case OPT_SRV_PORT: return "SRV.PORT";
case OPT_SRV_PROTOCOL: return "SRV.PROTOCOL";
case OPT_SRV_AUTORUN: return "SRV.AUTORUN";
case OPT_SRV_VERBOSE: return "SRV.VERBOSE";

case OPT_COUNT: return "???";
}
return "???";
Expand Down Expand Up @@ -476,6 +487,11 @@ struct OptionEnum : util::Reflection<OptionEnum, Option> {
case OPT_REC_ASPECT_X: return "Numerator of the video's aspect ratio";
case OPT_REC_ASPECT_Y: return "Denumerator of the video's aspect ratio";

case OPT_SRV_PORT: return "Server port";
case OPT_SRV_PROTOCOL: return "Server protocol";
case OPT_SRV_AUTORUN: return "Auto run";
case OPT_SRV_VERBOSE: return "Verbose mode";

case OPT_COUNT: return "???";
}
return "???";
Expand Down
1 change: 1 addition & 0 deletions Emulator/Base/SubComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ parCable(ref.parCable),
powerSupply(ref.supply),
recorder(ref.recorder),
regressionTester(ref.regressionTester),
remoteManager(ref.remoteManager),
retroShell(ref.retroShell),
sidBridge(ref.sidBridge),
sid0(ref.sidBridge.sid[0]),
Expand Down
1 change: 1 addition & 0 deletions Emulator/Base/SubComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class References {
class PowerPort &powerSupply;
class Recorder &recorder;
class RegressionTester &regressionTester;
class RemoteManager &remoteManager;
class RetroShell &retroShell;
class SIDBridge &sidBridge;
class SID& sid0;
Expand Down
18 changes: 18 additions & 0 deletions Emulator/Components/C64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ C64::eventName(EventSlot slot, EventID id)
}
break;

case SLOT_SRV:

switch (id) {

case EVENT_NONE: return "none";
case SRV_LAUNCH_DAEMON: return "SRV_LAUNCH_DAEMON";
default: return "*** INVALID ***";
}
break;

case SLOT_ALA:

switch (id) {
Expand Down Expand Up @@ -302,6 +312,7 @@ C64::operator << (SerResetter &worker)
// Schedule initial events
scheduleAbs<SLOT_CIA1>(cpu.clock, CIA_EXECUTE);
scheduleAbs<SLOT_CIA2>(cpu.clock, CIA_EXECUTE);
scheduleRel<SLOT_SRV>(C64::sec(0.5), SRV_LAUNCH_DAEMON);
if (insEvent) scheduleRel <SLOT_INS> (0, insEvent);
scheduleNextSNPEvent();

Expand Down Expand Up @@ -860,6 +871,9 @@ C64::processEvents(Cycle cycle)
if (isDue<SLOT_KEY>(cycle)) {
keyboard.processKeyEvent(eventid[SLOT_KEY]);
}
if (isDue<SLOT_SRV>(cycle)) {
remoteManager.serviceServerEvent();
}
if (isDue<SLOT_ALA>(cycle)) {
processAlarmEvent();
}
Expand Down Expand Up @@ -1528,6 +1542,8 @@ C64::getDebugVariable(DebugFlag flag)

case FLAG_REC_DEBUG: return REC_DEBUG;
case FLAG_REU_DEBUG: return REU_DEBUG;
case FLAG_SCK_DEBUG: return SCK_DEBUG;
case FLAG_SRV_DEBUG: return SRV_DEBUG;

case FLAG_FORCE_ROM_MISSING: return FORCE_ROM_MISSING;
case FLAG_FORCE_MEGA64_MISMATCH: return FORCE_MEGA64_MISMATCH;
Expand Down Expand Up @@ -1615,6 +1631,8 @@ C64::setDebugVariable(DebugFlag flag, int val)

case FLAG_REC_DEBUG: REC_DEBUG = val; break;
case FLAG_REU_DEBUG: REU_DEBUG = val; break;
case FLAG_SCK_DEBUG: SCK_DEBUG = val; break;
case FLAG_SRV_DEBUG: SRV_DEBUG = val; break;

case FLAG_FORCE_ROM_MISSING: FORCE_ROM_MISSING = val; break;
case FLAG_FORCE_MEGA64_MISMATCH: FORCE_MEGA64_MISMATCH = val; break;
Expand Down
10 changes: 8 additions & 2 deletions Emulator/Components/C64.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include "CIA.h"
#include "CPU.h"
#include "Recorder.h"
#include "RegressionTester.h"
#include "RetroShell.h"

// Ports
#include "AudioPort.h"
Expand Down Expand Up @@ -64,6 +62,13 @@
#include "CRTFile.h"
#include "FileSystem.h"

// Misc
#include "Host.h"
#include "RegressionTester.h"
#include "RemoteManager.h"
#include "RetroShell.h"
#include "RshServer.h"

namespace vc64 {

//
Expand Down Expand Up @@ -156,6 +161,7 @@ class C64 final : public CoreComponent, public Inspectable<C64Info> {

// Misc
RetroShell retroShell = RetroShell(*this);
RemoteManager remoteManager = RemoteManager(*this);
Debugger debugger = Debugger(*this);
RegressionTester regressionTester = RegressionTester(*this);
Recorder recorder = Recorder(*this);
Expand Down
6 changes: 6 additions & 0 deletions Emulator/Components/C64Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ enum_long(SLOT)
SLOT_SNP, // Snapshots
SLOT_RSH, // Retro Shell
SLOT_KEY, // Auto-typing
SLOT_SRV, // Remote server manager
SLOT_ALA, // Alarms (set by the GUI)
SLOT_INS, // Handles periodic calls to inspect()

Expand Down Expand Up @@ -143,6 +144,7 @@ struct EventSlotEnum : util::Reflection<EventSlotEnum, EventSlot>
case SLOT_SNP: return "SNP";
case SLOT_RSH: return "RSH";
case SLOT_KEY: return "KEY";
case SLOT_SRV: return "SRV";
case SLOT_ALA: return "ALA";
case SLOT_INS: return "INS";

Expand Down Expand Up @@ -223,6 +225,10 @@ enum_i8(EventID)
KEY_AUTO_TYPE = 1,
KEY_EVENT_COUNT,

// Remote server manager
SRV_LAUNCH_DAEMON = 1,
SRV_EVENT_COUNT,

// Alarm event slot
ALA_TRIGGER = 1,
ALA_EVENT_COUNT,
Expand Down
6 changes: 6 additions & 0 deletions Emulator/Components/EmulatorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ enum_long(DEBUG_FLAG)
// Other components
FLAG_REC_DEBUG, ///< Debug the screen recorder
FLAG_REU_DEBUG, ///< Debug the REU memory expansion
FLAG_SCK_DEBUG, ///< Debug the socket interface
FLAG_SRV_DEBUG, ///< Debug the remote servers

//! Forced error condition
FLAG_FORCE_ROM_MISSING,
Expand Down Expand Up @@ -186,6 +188,8 @@ struct DebugFlagEnum : util::Reflection<DebugFlagEnum, DebugFlag>
// Other components
case FLAG_REC_DEBUG: return "REC_DEBUG";
case FLAG_REU_DEBUG: return "REU_DEBUG";
case FLAG_SCK_DEBUG: return "SCK_DEBUG";
case FLAG_SRV_DEBUG: return "SRV_DEBUG";

// Forced error conditions
case FLAG_FORCE_ROM_MISSING: return "FORCE_ROM_MISSING";
Expand Down Expand Up @@ -273,6 +277,8 @@ struct DebugFlagEnum : util::Reflection<DebugFlagEnum, DebugFlag>
// Other components
case FLAG_REC_DEBUG: return "Screen recorder";
case FLAG_REU_DEBUG: return "REU memory expansion";
case FLAG_SCK_DEBUG: return "Sockets";
case FLAG_SRV_DEBUG: return "Remote servers";

// Forced error conditions
case FLAG_FORCE_ROM_MISSING: return "";
Expand Down
11 changes: 11 additions & 0 deletions Emulator/Misc/RemoteServers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
target_include_directories(vc64Core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

target_sources(vc64Core PRIVATE

RemoteManager.cpp
RemoteServer.cpp
SerServer.cpp
RshServer.cpp
Socket.cpp

)
Loading

0 comments on commit 2189090

Please sign in to comment.