Uthernet2 as a Card.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-12-03 19:42:53 +00:00
commit 6e42274033
7 changed files with 933 additions and 872 deletions

View file

@ -41,6 +41,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "SerialComms.h"
#include "SNESMAX.h"
#include "VidHD.h"
#include "linux/network/uthernet2.h"
void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
{
@ -92,7 +93,7 @@ void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
m_slot[slot] = new DummyCard(type, slot);
break;
case CT_Uthernet2:
m_slot[slot] = new DummyCard(type, slot);
m_slot[slot] = new Uthernet2(slot);
break;
case CT_FourPlay:
m_slot[slot] = new FourPlayCard(slot);

View file

@ -2,8 +2,6 @@
#include "frontends/common2/utils.h"
#include "frontends/common2/programoptions.h"
#include "linux/network/uthernet2.h"
#include "SaveState.h"
#include "Common.h"
@ -62,20 +60,6 @@ namespace common2
}
}
void LoadUthernet2()
{
CardManager & cardManager = GetCardMgr();
for (UINT slot = SLOT1; slot < NUM_SLOTS; slot++)
{
if (cardManager.QuerySlot(slot) == CT_Uthernet2)
{
// AppleWin does not know anything about this
registerUthernet2(slot);
break;
}
}
}
void InitialiseEmulator()
{
#ifdef RIFF_SPKR
@ -92,7 +76,6 @@ namespace common2
GetVideo().SetVidHD(false);
LoadConfiguration();
LoadUthernet2();
SetCurrentCLK6502();
GetAppleWindowTitle();
GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS);
@ -131,7 +114,6 @@ namespace common2
MB_Destroy();
DSUninit();
unRegisterUthernet2();
tfe_shutdown();
if (cardManager.QuerySlot(SLOT7) == CT_GenericHDD)

View file

@ -331,6 +331,8 @@ namespace sa2
if (ImGui::Selectable(getCardName(card).c_str(), isSelected))
{
SetExpansionMemType(card);
CreateLanguageCard();
MemInitializeIO();
}
if (isSelected)
{

View file

@ -3,6 +3,7 @@
#include "Registry.h"
#include "Harddisk.h"
#include "Core.h"
#include "Memory.h"
#include "Debugger/Debug.h"
#include "Tfe/tfe.h"
@ -102,8 +103,8 @@ namespace
{3, {CT_Empty, CT_Uthernet, CT_Uthernet2, CT_VidHD}},
{4, {CT_Empty, CT_MockingboardC, CT_MouseInterface, CT_Phasor, CT_Uthernet2}},
{5, {CT_Empty, CT_MockingboardC, CT_Z80, CT_SAM, CT_Disk2, CT_FourPlay, CT_SNESMAX, CT_Uthernet2}},
{6, {CT_Empty, CT_Disk2}},
{7, {CT_Empty, CT_GenericHDD}},
{6, {CT_Empty, CT_Disk2, CT_Uthernet2}},
{7, {CT_Empty, CT_GenericHDD, CT_Uthernet2}},
};
const std::vector<SS_CARDTYPE> expansionCards =
@ -183,19 +184,11 @@ namespace sa2
}
};
if (card == CT_Uthernet2)
{
// only 1 Uthernet2 allowed
for (size_t s = SLOT1; s < NUM_SLOTS; ++s)
{
if (cardManager.QuerySlot(s) == card)
{
cardManager.Insert(s, CT_Empty);
}
}
}
cardManager.Insert(slot, card);
// keep everything consistent
// a bit of a heavy call, but nothing simpler is available now
MemInitializeIO();
}
void setVideoStyle(Video & video, const VideoStyle_e style, const bool enabled)

View file

@ -7,7 +7,6 @@
#include "StdAfx.h"
#include "linux/benchmark.h"
#include "linux/context.h"
#include "linux/network/uthernet2.h"
#include "frontends/common2/fileregistry.h"
#include "frontends/common2/utils.h"
@ -143,7 +142,6 @@ void run_sdl(int argc, const char * argv [])
eventTimer.tic();
sa2::writeAudio();
processEventsUthernet2(5);
frame->ProcessEvents(quit);
eventTimer.toc();

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,100 @@
#pragma once
// this register the IOCalls for Uthernet 2 on slot 3
// if TFE is not enabled (or available) all operations will timeout
void registerUthernet2(UINT uSlot);
void unRegisterUthernet2();
void processEventsUthernet2(uint32_t timeout);
#include "Card.h"
#include <vector>
class SlirpNet;
struct Socket
{
uint16_t transmitBase;
uint16_t transmitSize;
uint16_t receiveBase;
uint16_t receiveSize;
uint16_t registers;
uint16_t sn_rx_wr;
uint16_t sn_rx_rsr;
uint8_t sn_sr;
int myFD;
int myErrno;
void clearFD();
void setFD(const int fd, const int status);
void process();
bool isThereRoomFor(const size_t len, const size_t header) const;
uint16_t getFreeRoom() const;
Socket();
~Socket();
};
class Uthernet2 : public Card
{
public:
Uthernet2(UINT slot);
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
virtual void Init();
virtual void Reset(const bool powerCycle);
virtual void Update(const ULONG nExecutedCycles);
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper);
virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version);
BYTE IO_C0(WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles);
private:
std::vector<uint8_t> myMemory;
std::vector<Socket> mySockets;
uint8_t myModeRegister;
uint16_t myDataAddress;
std::shared_ptr<SlirpNet> mySlirp;
void setSocketModeRegister(const size_t i, const uint16_t address, const uint8_t value);
void setTXSizes(const uint16_t address, uint8_t value);
void setRXSizes(const uint16_t address, uint8_t value);
uint16_t getTXDataSize(const size_t i) const;
uint8_t getTXFreeSizeRegister(const size_t i, const size_t shift) const;
uint8_t getRXDataSizeRegister(const size_t i, const size_t shift) const;
void receiveOnePacketMacRaw(const size_t i);
void receiveOnePacketFromSocket(const size_t i);
void receiveOnePacket(const size_t i);
void sendDataMacRaw(const size_t i, const std::vector<uint8_t> & data) const;
void sendDataToSocket(const size_t i, std::vector<uint8_t> & data);
void sendData(const size_t i);
void resetRXTXBuffers(const size_t i);
void updateRSR(const size_t i);
void openSystemSocket(const size_t i, const int type, const int protocol, const int state);
void openSocket(const size_t i);
void closeSocket(const size_t i);
void connectSocket(const size_t i);
void setCommandRegister(const size_t i, const uint8_t value);
uint8_t readSocketRegister(const uint16_t address);
uint8_t readValueAt(const uint16_t address);
void autoIncrement();
uint8_t readValue();
void setIPProtocol(const size_t i, const uint16_t address, const uint8_t value);
void setIPTypeOfService(const size_t i, const uint16_t address, const uint8_t value);
void setIPTTL(const size_t i, const uint16_t address, const uint8_t value);
void writeSocketRegister(const uint16_t address, const uint8_t value);
void setModeRegister(const uint16_t address, const uint8_t value);
void writeCommonRegister(const uint16_t address, const uint8_t value);
void writeValueAt(const uint16_t address, const uint8_t value);
void writeValue(const uint8_t value);
void processEvents(uint32_t timeout);
};