mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
Rename existing BBA to BBA (TAP) to prepare for new BBA
Based on work by tommy1019
This commit is contained in:
parent
94f317010e
commit
595e1197b6
@ -591,8 +591,8 @@ endif()
|
||||
|
||||
if(WIN32)
|
||||
target_sources(core PRIVATE
|
||||
HW/EXI/BBA-TAP/TAP_Win32.cpp
|
||||
HW/EXI/BBA-TAP/TAP_Win32.h
|
||||
HW/EXI/BBA/TAP_Win32.cpp
|
||||
HW/EXI/BBA/TAP_Win32.h
|
||||
HW/WiimoteReal/IOWin.cpp
|
||||
HW/WiimoteReal/IOWin.h
|
||||
)
|
||||
@ -605,7 +605,7 @@ if(WIN32)
|
||||
target_compile_definitions(core PRIVATE "-D_WINSOCK_DEPRECATED_NO_WARNINGS")
|
||||
elseif(APPLE)
|
||||
target_sources(core PRIVATE
|
||||
HW/EXI/BBA-TAP/TAP_Apple.cpp
|
||||
HW/EXI/BBA/TAP_Apple.cpp
|
||||
HW/WiimoteReal/IOdarwin.h
|
||||
HW/WiimoteReal/IOdarwin_private.h
|
||||
HW/WiimoteReal/IOdarwin.mm
|
||||
@ -613,7 +613,7 @@ elseif(APPLE)
|
||||
target_link_libraries(core PUBLIC ${IOB_LIBRARY})
|
||||
elseif(UNIX)
|
||||
target_sources(core PRIVATE
|
||||
HW/EXI/BBA-TAP/TAP_Unix.cpp
|
||||
HW/EXI/BBA/TAP_Unix.cpp
|
||||
)
|
||||
if(ANDROID)
|
||||
target_sources(core PRIVATE
|
||||
|
@ -223,7 +223,7 @@ void SConfig::SaveCoreSettings(IniFile& ini)
|
||||
core->Set("SlotA", m_EXIDevice[0]);
|
||||
core->Set("SlotB", m_EXIDevice[1]);
|
||||
core->Set("SerialPort1", m_EXIDevice[2]);
|
||||
core->Set("BBA_MAC", m_bba_mac);
|
||||
core->Set("BBA_TAP_MAC", m_bba_tap_mac);
|
||||
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
||||
{
|
||||
core->Set(fmt::format("SIDevice{}", i), m_SIDevice[i]);
|
||||
@ -488,7 +488,7 @@ void SConfig::LoadCoreSettings(IniFile& ini)
|
||||
core->Get("SlotA", (int*)&m_EXIDevice[0], ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER);
|
||||
core->Get("SlotB", (int*)&m_EXIDevice[1], ExpansionInterface::EXIDEVICE_NONE);
|
||||
core->Get("SerialPort1", (int*)&m_EXIDevice[2], ExpansionInterface::EXIDEVICE_NONE);
|
||||
core->Get("BBA_MAC", &m_bba_mac);
|
||||
core->Get("BBA_TAP_MAC", &m_bba_tap_mac);
|
||||
for (size_t i = 0; i < std::size(m_SIDevice); ++i)
|
||||
{
|
||||
core->Get(fmt::format("SIDevice{}", i), &m_SIDevice[i],
|
||||
|
@ -226,7 +226,8 @@ struct SConfig
|
||||
std::string m_strGbaCartB;
|
||||
ExpansionInterface::TEXIDevices m_EXIDevice[3];
|
||||
SerialInterface::SIDevices m_SIDevice[4];
|
||||
std::string m_bba_mac;
|
||||
|
||||
std::string m_bba_tap_mac;
|
||||
|
||||
// interface language
|
||||
std::string m_InterfaceLanguage;
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
@ -140,7 +140,7 @@
|
||||
<ClCompile Include="HW\DVD\DVDMath.cpp" />
|
||||
<ClCompile Include="HW\DVD\DVDThread.cpp" />
|
||||
<ClCompile Include="HW\DVD\FileMonitor.cpp" />
|
||||
<ClCompile Include="HW\EXI\BBA-TAP\TAP_Win32.cpp" />
|
||||
<ClCompile Include="HW\EXI\BBA\TAP_Win32.cpp" />
|
||||
<ClCompile Include="HW\EXI\EXI.cpp" />
|
||||
<ClCompile Include="HW\EXI\EXI_Channel.cpp" />
|
||||
<ClCompile Include="HW\EXI\EXI_Device.cpp" />
|
||||
@ -498,7 +498,7 @@
|
||||
<ClInclude Include="HW\DVD\DVDMath.h" />
|
||||
<ClInclude Include="HW\DVD\DVDThread.h" />
|
||||
<ClInclude Include="HW\DVD\FileMonitor.h" />
|
||||
<ClInclude Include="HW\EXI\BBA-TAP\TAP_Win32.h" />
|
||||
<ClInclude Include="HW\EXI\BBA\TAP_Win32.h" />
|
||||
<ClInclude Include="HW\EXI\EXI.h" />
|
||||
<ClInclude Include="HW\EXI\EXI_Channel.h" />
|
||||
<ClInclude Include="HW\EXI\EXI_Device.h" />
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="ActionReplay">
|
||||
@ -993,6 +993,9 @@
|
||||
<ClCompile Include="PowerPC\Jit64\RegCache\FPURegCache.cpp">
|
||||
<Filter>PowerPC\Jit64</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HW\EXI\BBA\TAP_Win32.cpp">
|
||||
<Filter>HW %28Flipper/Hollywood%29\EXI - Expansion Interface\BBA</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BootManager.h" />
|
||||
@ -1740,6 +1743,9 @@
|
||||
<ClInclude Include="PowerPC\JitArmCommon\BackPatch.h">
|
||||
<Filter>PowerPC\JitArmCommon</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HW\EXI\BBA\TAP_Win32.h">
|
||||
<Filter>HW %28Flipper/Hollywood%29\EXI - Expansion Interface\BBA</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="CMakeLists.txt" />
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
namespace ExpansionInterface
|
||||
{
|
||||
bool CEXIETHERNET::Activate()
|
||||
bool CEXIETHERNET::TAPNetworkInterface::Activate()
|
||||
{
|
||||
if (IsActivated())
|
||||
return true;
|
||||
@ -30,7 +30,7 @@ bool CEXIETHERNET::Activate()
|
||||
return RecvInit();
|
||||
}
|
||||
|
||||
void CEXIETHERNET::Deactivate()
|
||||
void CEXIETHERNET::TAPNetworkInterface::Deactivate()
|
||||
{
|
||||
close(fd);
|
||||
fd = -1;
|
||||
@ -41,12 +41,12 @@ void CEXIETHERNET::Deactivate()
|
||||
readThread.join();
|
||||
}
|
||||
|
||||
bool CEXIETHERNET::IsActivated()
|
||||
bool CEXIETHERNET::TAPNetworkInterface::IsActivated()
|
||||
{
|
||||
return fd != -1;
|
||||
}
|
||||
|
||||
bool CEXIETHERNET::SendFrame(const u8* frame, u32 size)
|
||||
bool CEXIETHERNET::TAPNetworkInterface::SendFrame(const u8* frame, u32 size)
|
||||
{
|
||||
INFO_LOG(SP1, "SendFrame %x\n%s", size, ArrayToString(frame, size, 0x10).c_str());
|
||||
|
||||
@ -58,12 +58,12 @@ bool CEXIETHERNET::SendFrame(const u8* frame, u32 size)
|
||||
}
|
||||
else
|
||||
{
|
||||
SendComplete();
|
||||
m_eth_ref->SendComplete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void CEXIETHERNET::ReadThreadHandler(CEXIETHERNET* self)
|
||||
void CEXIETHERNET::TAPNetworkInterface::ReadThreadHandler(TAPNetworkInterface* self)
|
||||
{
|
||||
while (!self->readThreadShutdown.IsSet())
|
||||
{
|
||||
@ -77,7 +77,7 @@ void CEXIETHERNET::ReadThreadHandler(CEXIETHERNET* self)
|
||||
if (select(self->fd + 1, &rfds, nullptr, nullptr, &timeout) <= 0)
|
||||
continue;
|
||||
|
||||
int readBytes = read(self->fd, self->mRecvBuffer.get(), BBA_RECV_SIZE);
|
||||
int readBytes = read(self->fd, self->m_eth_ref->mRecvBuffer.get(), BBA_RECV_SIZE);
|
||||
if (readBytes < 0)
|
||||
{
|
||||
ERROR_LOG(SP1, "Failed to read from BBA, err=%d", readBytes);
|
||||
@ -85,25 +85,25 @@ void CEXIETHERNET::ReadThreadHandler(CEXIETHERNET* self)
|
||||
else if (self->readEnabled.IsSet())
|
||||
{
|
||||
INFO_LOG(SP1, "Read data: %s",
|
||||
ArrayToString(self->mRecvBuffer.get(), readBytes, 0x10).c_str());
|
||||
self->mRecvBufferLength = readBytes;
|
||||
self->RecvHandlePacket();
|
||||
ArrayToString(self->m_eth_ref->mRecvBuffer.get(), readBytes, 0x10).c_str());
|
||||
self->m_eth_ref->mRecvBufferLength = readBytes;
|
||||
self->m_eth_ref->RecvHandlePacket();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CEXIETHERNET::RecvInit()
|
||||
bool CEXIETHERNET::TAPNetworkInterface::RecvInit()
|
||||
{
|
||||
readThread = std::thread(ReadThreadHandler, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEXIETHERNET::RecvStart()
|
||||
void CEXIETHERNET::TAPNetworkInterface::RecvStart()
|
||||
{
|
||||
readEnabled.Set();
|
||||
}
|
||||
|
||||
void CEXIETHERNET::RecvStop()
|
||||
void CEXIETHERNET::TAPNetworkInterface::RecvStop()
|
||||
{
|
||||
readEnabled.Clear();
|
||||
}
|
@ -28,7 +28,7 @@ namespace ExpansionInterface
|
||||
#define NOTIMPLEMENTED(Name) \
|
||||
NOTICE_LOG(SP1, "CEXIETHERNET::%s not implemented for your UNIX", Name);
|
||||
|
||||
bool CEXIETHERNET::Activate()
|
||||
bool CEXIETHERNET::TAPNetworkInterface::Activate()
|
||||
{
|
||||
#ifdef __linux__
|
||||
if (IsActivated())
|
||||
@ -50,7 +50,7 @@ bool CEXIETHERNET::Activate()
|
||||
const int MAX_INTERFACES = 32;
|
||||
for (int i = 0; i < MAX_INTERFACES; ++i)
|
||||
{
|
||||
strncpy(ifr.ifr_name, StringFromFormat("Dolphin%d", i).c_str(), IFNAMSIZ - 1);
|
||||
strncpy(ifr.ifr_name, StringFromFormat("Dolphin%d", i).c_str(), IFNAMSIZ);
|
||||
|
||||
int err;
|
||||
if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0)
|
||||
@ -78,7 +78,7 @@ bool CEXIETHERNET::Activate()
|
||||
#endif
|
||||
}
|
||||
|
||||
void CEXIETHERNET::Deactivate()
|
||||
void CEXIETHERNET::TAPNetworkInterface::Deactivate()
|
||||
{
|
||||
#ifdef __linux__
|
||||
close(fd);
|
||||
@ -93,7 +93,7 @@ void CEXIETHERNET::Deactivate()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CEXIETHERNET::IsActivated()
|
||||
bool CEXIETHERNET::TAPNetworkInterface::IsActivated()
|
||||
{
|
||||
#ifdef __linux__
|
||||
return fd != -1 ? true : false;
|
||||
@ -102,7 +102,7 @@ bool CEXIETHERNET::IsActivated()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CEXIETHERNET::SendFrame(const u8* frame, u32 size)
|
||||
bool CEXIETHERNET::TAPNetworkInterface::SendFrame(const u8* frame, u32 size)
|
||||
{
|
||||
#ifdef __linux__
|
||||
DEBUG_LOG(SP1, "SendFrame %x\n%s", size, ArrayToString(frame, size, 0x10).c_str());
|
||||
@ -115,7 +115,7 @@ bool CEXIETHERNET::SendFrame(const u8* frame, u32 size)
|
||||
}
|
||||
else
|
||||
{
|
||||
SendComplete();
|
||||
m_eth_ref->SendComplete();
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
@ -125,7 +125,7 @@ bool CEXIETHERNET::SendFrame(const u8* frame, u32 size)
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
void CEXIETHERNET::ReadThreadHandler(CEXIETHERNET* self)
|
||||
void CEXIETHERNET::TAPNetworkInterface::ReadThreadHandler(TAPNetworkInterface* self)
|
||||
{
|
||||
while (!self->readThreadShutdown.IsSet())
|
||||
{
|
||||
@ -139,7 +139,7 @@ void CEXIETHERNET::ReadThreadHandler(CEXIETHERNET* self)
|
||||
if (select(self->fd + 1, &rfds, nullptr, nullptr, &timeout) <= 0)
|
||||
continue;
|
||||
|
||||
int readBytes = read(self->fd, self->mRecvBuffer.get(), BBA_RECV_SIZE);
|
||||
int readBytes = read(self->fd, self->m_eth_ref->mRecvBuffer.get(), BBA_RECV_SIZE);
|
||||
if (readBytes < 0)
|
||||
{
|
||||
ERROR_LOG(SP1, "Failed to read from BBA, err=%d", readBytes);
|
||||
@ -147,15 +147,15 @@ void CEXIETHERNET::ReadThreadHandler(CEXIETHERNET* self)
|
||||
else if (self->readEnabled.IsSet())
|
||||
{
|
||||
DEBUG_LOG(SP1, "Read data: %s",
|
||||
ArrayToString(self->mRecvBuffer.get(), readBytes, 0x10).c_str());
|
||||
self->mRecvBufferLength = readBytes;
|
||||
self->RecvHandlePacket();
|
||||
ArrayToString(self->m_eth_ref->mRecvBuffer.get(), readBytes, 0x10).c_str());
|
||||
self->m_eth_ref->mRecvBufferLength = readBytes;
|
||||
self->m_eth_ref->RecvHandlePacket();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool CEXIETHERNET::RecvInit()
|
||||
bool CEXIETHERNET::TAPNetworkInterface::RecvInit()
|
||||
{
|
||||
#ifdef __linux__
|
||||
readThread = std::thread(ReadThreadHandler, this);
|
||||
@ -166,7 +166,7 @@ bool CEXIETHERNET::RecvInit()
|
||||
#endif
|
||||
}
|
||||
|
||||
void CEXIETHERNET::RecvStart()
|
||||
void CEXIETHERNET::TAPNetworkInterface::RecvStart()
|
||||
{
|
||||
#ifdef __linux__
|
||||
readEnabled.Set();
|
||||
@ -175,7 +175,7 @@ void CEXIETHERNET::RecvStart()
|
||||
#endif
|
||||
}
|
||||
|
||||
void CEXIETHERNET::RecvStop()
|
||||
void CEXIETHERNET::TAPNetworkInterface::RecvStop()
|
||||
{
|
||||
#ifdef __linux__
|
||||
readEnabled.Clear();
|
@ -2,7 +2,7 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/HW/EXI/BBA-TAP/TAP_Win32.h"
|
||||
#include "Core/HW/EXI/BBA/TAP_Win32.h"
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
@ -167,7 +167,7 @@ bool OpenTAP(HANDLE& adapter, const std::basic_string<TCHAR>& device_guid)
|
||||
|
||||
namespace ExpansionInterface
|
||||
{
|
||||
bool CEXIETHERNET::Activate()
|
||||
bool CEXIETHERNET::TAPNetworkInterface::Activate()
|
||||
{
|
||||
if (IsActivated())
|
||||
return true;
|
||||
@ -233,7 +233,7 @@ bool CEXIETHERNET::Activate()
|
||||
return RecvInit();
|
||||
}
|
||||
|
||||
void CEXIETHERNET::Deactivate()
|
||||
void CEXIETHERNET::TAPNetworkInterface::Deactivate()
|
||||
{
|
||||
if (!IsActivated())
|
||||
return;
|
||||
@ -258,19 +258,19 @@ void CEXIETHERNET::Deactivate()
|
||||
memset(&mWriteOverlapped, 0, sizeof(mWriteOverlapped));
|
||||
}
|
||||
|
||||
bool CEXIETHERNET::IsActivated()
|
||||
bool CEXIETHERNET::TAPNetworkInterface::IsActivated()
|
||||
{
|
||||
return mHAdapter != INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
void CEXIETHERNET::ReadThreadHandler(CEXIETHERNET* self)
|
||||
void CEXIETHERNET::TAPNetworkInterface::ReadThreadHandler(TAPNetworkInterface* self)
|
||||
{
|
||||
while (!self->readThreadShutdown.IsSet())
|
||||
{
|
||||
DWORD transferred;
|
||||
|
||||
// Read from TAP into internal buffer.
|
||||
if (ReadFile(self->mHAdapter, self->mRecvBuffer.get(), BBA_RECV_SIZE, &transferred,
|
||||
if (ReadFile(self->mHAdapter, self->m_eth_ref->mRecvBuffer.get(), BBA_RECV_SIZE, &transferred,
|
||||
&self->mReadOverlapped))
|
||||
{
|
||||
// Returning immediately is not likely to happen, but if so, reset the event state manually.
|
||||
@ -300,16 +300,16 @@ void CEXIETHERNET::ReadThreadHandler(CEXIETHERNET* self)
|
||||
|
||||
// Copy to BBA buffer, and fire interrupt if enabled.
|
||||
DEBUG_LOG(SP1, "Received %u bytes:\n %s", transferred,
|
||||
ArrayToString(self->mRecvBuffer.get(), transferred, 0x10).c_str());
|
||||
ArrayToString(self->m_eth_ref->mRecvBuffer.get(), transferred, 0x10).c_str());
|
||||
if (self->readEnabled.IsSet())
|
||||
{
|
||||
self->mRecvBufferLength = transferred;
|
||||
self->RecvHandlePacket();
|
||||
self->m_eth_ref->mRecvBufferLength = transferred;
|
||||
self->m_eth_ref->RecvHandlePacket();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CEXIETHERNET::SendFrame(const u8* frame, u32 size)
|
||||
bool CEXIETHERNET::TAPNetworkInterface::SendFrame(const u8* frame, u32 size)
|
||||
{
|
||||
DEBUG_LOG(SP1, "SendFrame %u bytes:\n%s", size, ArrayToString(frame, size, 0x10).c_str());
|
||||
|
||||
@ -345,22 +345,22 @@ bool CEXIETHERNET::SendFrame(const u8* frame, u32 size)
|
||||
}
|
||||
|
||||
// Always report the packet as being sent successfully, even though it might be a lie
|
||||
SendComplete();
|
||||
m_eth_ref->SendComplete();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEXIETHERNET::RecvInit()
|
||||
bool CEXIETHERNET::TAPNetworkInterface::RecvInit()
|
||||
{
|
||||
readThread = std::thread(ReadThreadHandler, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEXIETHERNET::RecvStart()
|
||||
void CEXIETHERNET::TAPNetworkInterface::RecvStart()
|
||||
{
|
||||
readEnabled.Set();
|
||||
}
|
||||
|
||||
void CEXIETHERNET::RecvStop()
|
||||
void CEXIETHERNET::TAPNetworkInterface::RecvStop()
|
||||
{
|
||||
readEnabled.Clear();
|
||||
}
|
@ -132,7 +132,7 @@ std::unique_ptr<IEXIDevice> EXIDevice_Create(const TEXIDevices device_type, cons
|
||||
break;
|
||||
|
||||
case EXIDEVICE_ETH:
|
||||
result = std::make_unique<CEXIETHERNET>();
|
||||
result = std::make_unique<CEXIETHERNET>(BBADeviceType::BBA_TAP);
|
||||
break;
|
||||
|
||||
case EXIDEVICE_GECKO:
|
||||
|
@ -23,17 +23,11 @@ namespace ExpansionInterface
|
||||
// Multiple parts of this implementation depend on Dolphin
|
||||
// being compiled for a little endian host.
|
||||
|
||||
CEXIETHERNET::CEXIETHERNET()
|
||||
CEXIETHERNET::CEXIETHERNET(BBADeviceType type)
|
||||
{
|
||||
tx_fifo = std::make_unique<u8[]>(BBA_TXFIFO_SIZE);
|
||||
mBbaMem = std::make_unique<u8[]>(BBA_MEM_SIZE);
|
||||
mRecvBuffer = std::make_unique<u8[]>(BBA_RECV_SIZE);
|
||||
|
||||
MXHardReset();
|
||||
|
||||
// Parse MAC address from config, and generate a new one if it doesn't
|
||||
// Parse BBA (TAP) MAC address from config, and generate a new one if it doesn't
|
||||
// exist or can't be parsed.
|
||||
std::string& mac_addr_setting = SConfig::GetInstance().m_bba_mac;
|
||||
std::string& mac_addr_setting = SConfig::GetInstance().m_bba_tap_mac;
|
||||
std::optional<Common::MACAddress> mac_addr = Common::StringToMacAddress(mac_addr_setting);
|
||||
|
||||
if (!mac_addr)
|
||||
@ -43,6 +37,20 @@ CEXIETHERNET::CEXIETHERNET()
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case BBADeviceType::BBA_TAP:
|
||||
network_interface = std::make_unique<TAPNetworkInterface>(this);
|
||||
INFO_LOG(SP1, "Created TAP physical network interface.");
|
||||
break;
|
||||
}
|
||||
|
||||
tx_fifo = std::make_unique<u8[]>(BBA_TXFIFO_SIZE);
|
||||
mBbaMem = std::make_unique<u8[]>(BBA_MEM_SIZE);
|
||||
mRecvBuffer = std::make_unique<u8[]>(BBA_RECV_SIZE);
|
||||
|
||||
MXHardReset();
|
||||
|
||||
const auto& mac = mac_addr.value();
|
||||
memcpy(&mBbaMem[BBA_NAFR_PAR0], mac.data(), mac.size());
|
||||
|
||||
@ -52,7 +60,7 @@ CEXIETHERNET::CEXIETHERNET()
|
||||
|
||||
CEXIETHERNET::~CEXIETHERNET()
|
||||
{
|
||||
Deactivate();
|
||||
network_interface->Deactivate();
|
||||
}
|
||||
|
||||
void CEXIETHERNET::SetCS(int cs)
|
||||
@ -303,7 +311,7 @@ void CEXIETHERNET::MXCommandHandler(u32 data, u32 size)
|
||||
{
|
||||
INFO_LOG(SP1, "Software reset");
|
||||
// MXSoftReset();
|
||||
Activate();
|
||||
network_interface->Activate();
|
||||
}
|
||||
|
||||
if ((mBbaMem[BBA_NCRA] & NCRA_SR) ^ (data & NCRA_SR))
|
||||
@ -311,9 +319,9 @@ void CEXIETHERNET::MXCommandHandler(u32 data, u32 size)
|
||||
DEBUG_LOG(SP1, "%s rx", (data & NCRA_SR) ? "start" : "stop");
|
||||
|
||||
if (data & NCRA_SR)
|
||||
RecvStart();
|
||||
network_interface->RecvStart();
|
||||
else
|
||||
RecvStop();
|
||||
network_interface->RecvStop();
|
||||
}
|
||||
|
||||
// Only start transfer if there isn't one currently running
|
||||
@ -386,7 +394,7 @@ void CEXIETHERNET::DirectFIFOWrite(const u8* data, u32 size)
|
||||
|
||||
void CEXIETHERNET::SendFromDirectFIFO()
|
||||
{
|
||||
SendFrame(tx_fifo.get(), *(u16*)&mBbaMem[BBA_TXFIFOCNT]);
|
||||
network_interface->SendFrame(tx_fifo.get(), *(u16*)&mBbaMem[BBA_TXFIFOCNT]);
|
||||
}
|
||||
|
||||
void CEXIETHERNET::SendFromPacketBuffer()
|
||||
@ -579,7 +587,7 @@ bool CEXIETHERNET::RecvHandlePacket()
|
||||
|
||||
wait_for_next:
|
||||
if (mBbaMem[BBA_NCRA] & NCRA_SR)
|
||||
RecvStart();
|
||||
network_interface->RecvStart();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -196,10 +196,15 @@ enum RecvStatus
|
||||
|
||||
#define BBA_RECV_SIZE 0x800
|
||||
|
||||
enum class BBADeviceType
|
||||
{
|
||||
BBA_TAP,
|
||||
};
|
||||
|
||||
class CEXIETHERNET : public IEXIDevice
|
||||
{
|
||||
public:
|
||||
CEXIETHERNET();
|
||||
explicit CEXIETHERNET(BBADeviceType type);
|
||||
virtual ~CEXIETHERNET();
|
||||
void SetCS(int cs) override;
|
||||
bool IsPresent() const override;
|
||||
@ -297,34 +302,70 @@ private:
|
||||
std::unique_ptr<u8[]> mBbaMem;
|
||||
std::unique_ptr<u8[]> tx_fifo;
|
||||
|
||||
// TAP interface
|
||||
static void ReadThreadHandler(CEXIETHERNET* self);
|
||||
bool Activate();
|
||||
void Deactivate();
|
||||
bool IsActivated();
|
||||
bool SendFrame(const u8* frame, u32 size);
|
||||
bool RecvInit();
|
||||
void RecvStart();
|
||||
void RecvStop();
|
||||
class NetworkInterface
|
||||
{
|
||||
protected:
|
||||
CEXIETHERNET* m_eth_ref = nullptr;
|
||||
explicit NetworkInterface(CEXIETHERNET* eth_ref) : m_eth_ref{eth_ref} {}
|
||||
|
||||
std::unique_ptr<u8[]> mRecvBuffer;
|
||||
u32 mRecvBufferLength = 0;
|
||||
public:
|
||||
virtual bool Activate() { return false; }
|
||||
virtual void Deactivate() {}
|
||||
virtual bool IsActivated() { return false; }
|
||||
virtual bool SendFrame(const u8* frame, u32 size) { return false; }
|
||||
virtual bool RecvInit() { return false; }
|
||||
virtual void RecvStart() {}
|
||||
virtual void RecvStop() {}
|
||||
|
||||
#if defined(_WIN32)
|
||||
HANDLE mHAdapter = INVALID_HANDLE_VALUE;
|
||||
OVERLAPPED mReadOverlapped = {};
|
||||
OVERLAPPED mWriteOverlapped = {};
|
||||
std::vector<u8> mWriteBuffer;
|
||||
bool mWritePending = false;
|
||||
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
int fd = -1;
|
||||
virtual ~NetworkInterface() = default;
|
||||
};
|
||||
|
||||
class TAPNetworkInterface : public NetworkInterface
|
||||
{
|
||||
public:
|
||||
explicit TAPNetworkInterface(CEXIETHERNET* eth_ref) : NetworkInterface(eth_ref)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
bool Activate() override;
|
||||
void Deactivate() override;
|
||||
bool IsActivated() override;
|
||||
bool SendFrame(const u8* frame, u32 size) override;
|
||||
bool RecvInit() override;
|
||||
void RecvStart() override;
|
||||
void RecvStop() override;
|
||||
|
||||
private:
|
||||
#if defined(WIN32) || defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
|
||||
defined(__OpenBSD__)
|
||||
std::thread readThread;
|
||||
Common::Flag readEnabled;
|
||||
Common::Flag readThreadShutdown;
|
||||
static void ReadThreadHandler(TAPNetworkInterface* self);
|
||||
#endif
|
||||
#if defined(_WIN32)
|
||||
HANDLE mHAdapter = INVALID_HANDLE_VALUE;
|
||||
OVERLAPPED mReadOverlapped = {};
|
||||
OVERLAPPED mWriteOverlapped = {};
|
||||
std::vector<u8> mWriteBuffer;
|
||||
bool mWritePending = false;
|
||||
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
int fd = -1;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(WIN32) || defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
|
||||
defined(__OpenBSD__)
|
||||
std::thread readThread;
|
||||
Common::Flag readEnabled;
|
||||
Common::Flag readThreadShutdown;
|
||||
std::thread readThread;
|
||||
Common::Flag readEnabled;
|
||||
Common::Flag readThreadShutdown;
|
||||
#endif
|
||||
};
|
||||
|
||||
std::unique_ptr<NetworkInterface> network_interface;
|
||||
|
||||
std::unique_ptr<u8[]> mRecvBuffer;
|
||||
u32 mRecvBufferLength = 0;
|
||||
};
|
||||
} // namespace ExpansionInterface
|
||||
|
@ -103,7 +103,7 @@ void GameCubePane::CreateWidgets()
|
||||
for (const auto& entry :
|
||||
{std::make_pair(tr("<Nothing>"), ExpansionInterface::EXIDEVICE_NONE),
|
||||
std::make_pair(tr("Dummy"), ExpansionInterface::EXIDEVICE_DUMMY),
|
||||
std::make_pair(tr("Broadband Adapter"), ExpansionInterface::EXIDEVICE_ETH)})
|
||||
std::make_pair(tr("Broadband Adapter (TAP)"), ExpansionInterface::EXIDEVICE_ETH),
|
||||
{
|
||||
m_slot_combos[2]->addItem(entry.first, entry.second);
|
||||
}
|
||||
@ -186,10 +186,13 @@ void GameCubePane::OnConfigPressed(int slot)
|
||||
{
|
||||
bool ok;
|
||||
const auto new_mac = QInputDialog::getText(
|
||||
this, tr("Broadband Adapter MAC address"), tr("Enter new Broadband Adapter MAC address:"),
|
||||
QLineEdit::Normal, QString::fromStdString(SConfig::GetInstance().m_bba_mac), &ok);
|
||||
this, tr("Broadband Adapter (TAP) MAC address"),
|
||||
tr("Enter new Broadband Adapter (TAP) MAC address:"), QLineEdit::Normal,
|
||||
QString::fromStdString(SConfig::GetInstance().m_bba_tap_mac), &ok);
|
||||
if (ok)
|
||||
SConfig::GetInstance().m_bba_mac = new_mac.toStdString();
|
||||
SConfig::GetInstance().m_bba_tap_mac = new_mac.toStdString();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user