Skip to content

Commit

Permalink
Merge pull request #12422 from lioncash/global
Browse files Browse the repository at this point in the history
WiiNetConfig: Eliminate usages of the global system accessor
  • Loading branch information
AdmiralCurtiss committed Dec 14, 2023
2 parents f777a58 + 27806d8 commit 370474a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Source/Core/Core/IOS/Network/NCD/Manage.cpp
Expand Up @@ -87,24 +87,24 @@ std::optional<IPCReply> NetNCDManageDevice::IOCtlV(const IOCtlVRequest& request)

case IOCTLV_NCD_GETCONFIG:
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETCONFIG");
config.WriteToMem(request.io_vectors.at(0).address);
config.WriteToMem(memory, request.io_vectors.at(0).address);
common_vector = 1;
break;

case IOCTLV_NCD_SETCONFIG:
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_SETCONFIG");
config.ReadFromMem(request.in_vectors.at(0).address);
config.ReadFromMem(memory, request.in_vectors.at(0).address);
break;

case IOCTLV_NCD_READCONFIG:
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_READCONFIG");
config.ReadConfig(m_ios.GetFS().get());
config.WriteToMem(request.io_vectors.at(0).address);
config.WriteToMem(memory, request.io_vectors.at(0).address);
break;

case IOCTLV_NCD_WRITECONFIG:
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_WRITECONFIG");
config.ReadFromMem(request.in_vectors.at(0).address);
config.ReadFromMem(memory, request.in_vectors.at(0).address);
config.WriteConfig(m_ios.GetFS().get());
break;

Expand Down
9 changes: 2 additions & 7 deletions Source/Core/Core/IOS/Network/NCD/WiiNetConfig.cpp
Expand Up @@ -12,7 +12,6 @@
#include "Core/IOS/FS/FileSystem.h"
#include "Core/IOS/IOS.h"
#include "Core/IOS/Uids.h"
#include "Core/System.h"

namespace IOS::HLE::Net
{
Expand Down Expand Up @@ -52,17 +51,13 @@ void WiiNetConfig::ResetConfig(FS::FileSystem* fs)
WriteConfig(fs);
}

void WiiNetConfig::WriteToMem(const u32 address) const
void WiiNetConfig::WriteToMem(Memory::MemoryManager& memory, const u32 address) const
{
auto& system = Core::System::GetInstance();
auto& memory = system.GetMemory();
memory.CopyToEmu(address, &m_data, sizeof(m_data));
}

void WiiNetConfig::ReadFromMem(const u32 address)
void WiiNetConfig::ReadFromMem(const Memory::MemoryManager& memory, const u32 address)
{
auto& system = Core::System::GetInstance();
auto& memory = system.GetMemory();
memory.CopyFromEmu(&m_data, address, sizeof(m_data));
}
} // namespace IOS::HLE::Net
9 changes: 7 additions & 2 deletions Source/Core/Core/IOS/Network/NCD/WiiNetConfig.h
Expand Up @@ -6,6 +6,11 @@
#include <string>
#include "Common/CommonTypes.h"

namespace Memory
{
class MemoryManager;
}

namespace IOS::HLE
{
namespace FS
Expand Down Expand Up @@ -111,8 +116,8 @@ class WiiNetConfig final
void WriteConfig(FS::FileSystem* fs) const;
void ResetConfig(FS::FileSystem* fs);

void WriteToMem(u32 address) const;
void ReadFromMem(u32 address);
void WriteToMem(Memory::MemoryManager& memory, u32 address) const;
void ReadFromMem(const Memory::MemoryManager& memory, u32 address);

private:
// Data layout of the network configuration file (/shared2/sys/net/02/config.dat)
Expand Down

0 comments on commit 370474a

Please sign in to comment.