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