Skip to content

Commit

Permalink
Merge pull request #4625 from leoetlino/remove-unneeded
Browse files Browse the repository at this point in the history
IOS HLE: Remove unneeded code
  • Loading branch information
Parlane committed Jan 8, 2017
2 parents 7847ca4 + 22fcb73 commit 27d7c26
Show file tree
Hide file tree
Showing 23 changed files with 17 additions and 256 deletions.
2 changes: 2 additions & 0 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ static IPCCommandResult HandleCommand(const u32 address)
{
case IPC_CMD_CLOSE:
s_fdmap[fd].reset();
// A close on a valid device returns FS_SUCCESS.
Memory::Write_U32(FS_SUCCESS, address + 4);
return device->Close(address);
case IPC_CMD_READ:
return device->Read(address);
Expand Down
5 changes: 0 additions & 5 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,12 @@ void IWII_IPC_HLE_Device::DoStateShared(PointerWrap& p)

IPCCommandResult IWII_IPC_HLE_Device::Open(u32 command_address, u32 mode)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Open()", m_Name.c_str());
Memory::Write_U32(FS_ENOENT, command_address + 4);
m_Active = true;
return GetDefaultReply();
}

IPCCommandResult IWII_IPC_HLE_Device::Close(u32 command_address, bool force)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Close()", m_Name.c_str());
if (!force)
Memory::Write_U32(FS_EINVAL, command_address + 4);
m_Active = false;
return GetDefaultReply();
}
Expand Down
15 changes: 0 additions & 15 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,6 @@ void CWII_IPC_HLE_Device_di::DoState(PointerWrap& p)
p.Do(m_commands_to_execute);
}

IPCCommandResult CWII_IPC_HLE_Device_di::Open(u32 _CommandAddress, u32 _Mode)
{
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
m_Active = true;
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_di::Close(u32 _CommandAddress, bool _bForce)
{
if (!_bForce)
Memory::Write_U32(0, _CommandAddress + 4);
m_Active = false;
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_di::IOCtl(u32 _CommandAddress)
{
// DI IOCtls are handled in a special way by Dolphin
Expand Down
3 changes: 0 additions & 3 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class CWII_IPC_HLE_Device_di : public IWII_IPC_HLE_Device

void DoState(PointerWrap& p) override;

IPCCommandResult Open(u32 _CommandAddress, u32 _Mode) override;
IPCCommandResult Close(u32 _CommandAddress, bool _bForce) override;

IPCCommandResult IOCtl(u32 _CommandAddress) override;
IPCCommandResult IOCtlV(u32 _CommandAddress) override;

Expand Down
18 changes: 6 additions & 12 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,13 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Close(u32 _CommandAddress, bool _bF
// accessing it.
m_file.reset();

// Close always return 0 for success
if (_CommandAddress && !_bForce)
Memory::Write_U32(0, _CommandAddress + 4);
m_Active = false;
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
IPCCommandResult CWII_IPC_HLE_Device_FileIO::Open(u32 command_address, u32 mode)
{
m_Mode = _Mode;
u32 ReturnValue = 0;
m_Mode = mode;

static const char* const Modes[] = {"Unk Mode", "Read only", "Write only", "Read and Write"};

Expand All @@ -104,19 +100,17 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode
// It should be created by ISFS_CreateFile, not here
if (File::Exists(m_filepath) && !File::IsDirectory(m_filepath))
{
INFO_LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s == %08X)", m_Name.c_str(), Modes[_Mode], _Mode);
INFO_LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s == %08X)", m_Name.c_str(), Modes[mode], mode);
OpenFile();
ReturnValue = m_DeviceID;
}
else
{
WARN_LOG(WII_IPC_FILEIO, "FileIO: Open (%s) failed - File doesn't exist %s", Modes[_Mode],
WARN_LOG(WII_IPC_FILEIO, "FileIO: Open (%s) failed - File doesn't exist %s", Modes[mode],
m_filepath.c_str());
ReturnValue = FS_FILE_NOT_EXIST;
if (command_address)
Memory::Write_U32(FS_FILE_NOT_EXIST, command_address + 4);
}

if (_CommandAddress)
Memory::Write_U32(ReturnValue, _CommandAddress + 4);
m_Active = true;
return GetDefaultReply();
}
Expand Down
3 changes: 0 additions & 3 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ IPCCommandResult CWII_IPC_HLE_Device_es::Open(u32 _CommandAddress, u32 _Mode)
{
OpenInternal();

Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
if (m_Active)
INFO_LOG(WII_IPC_ES, "Device was re-opened.");
m_Active = true;
Expand All @@ -199,8 +198,6 @@ IPCCommandResult CWII_IPC_HLE_Device_es::Close(u32 _CommandAddress, bool _bForce
m_AccessIdentID = 0x6000000;

INFO_LOG(WII_IPC_ES, "ES: Close");
if (!_bForce)
Memory::Write_U32(0, _CommandAddress + 4);
m_Active = false;
// clear the NAND content cache to make sure nothing remains open.
DiscIO::CNANDContentManager::Access().ClearCache();
Expand Down
10 changes: 0 additions & 10 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,10 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode)
File::CreateDir(Path);
}

Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
m_Active = true;
return GetFSReply();
}

IPCCommandResult CWII_IPC_HLE_Device_fs::Close(u32 _CommandAddress, bool _bForce)
{
INFO_LOG(WII_IPC_FILEIO, "Close");
if (!_bForce)
Memory::Write_U32(0, _CommandAddress + 4);
m_Active = false;
return GetFSReply();
}

// Get total filesize of contents of a directory (recursive)
// Only used for ES_GetUsage atm, could be useful elsewhere?
static u64 ComputeTotalFileSize(const File::FSTEntry& parentEntry)
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class CWII_IPC_HLE_Device_fs : public IWII_IPC_HLE_Device
void DoState(PointerWrap& p) override;

IPCCommandResult Open(u32 _CommandAddress, u32 _Mode) override;
IPCCommandResult Close(u32 _CommandAddress, bool _bForce) override;

IPCCommandResult IOCtl(u32 _CommandAddress) override;
IPCCommandResult IOCtlV(u32 _CommandAddress) override;
Expand Down
39 changes: 9 additions & 30 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <libusb.h>

#include "Common/Align.h"
#include "Common/CommonFuncs.h"
#include "Common/Logging/Log.h"
#include "Core/Core.h"
Expand Down Expand Up @@ -104,23 +105,6 @@ CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid()
libusb_exit(nullptr);
}

IPCCommandResult CWII_IPC_HLE_Device_hid::Open(u32 _CommandAddress, u32 _Mode)
{
INFO_LOG(WII_IPC_HID, "HID::Open");
m_Active = true;
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_hid::Close(u32 _CommandAddress, bool _bForce)
{
INFO_LOG(WII_IPC_HID, "HID::Close");
m_Active = false;
if (!_bForce)
Memory::Write_U32(0, _CommandAddress + 4);
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
{
if (Core::g_want_determinism)
Expand Down Expand Up @@ -390,8 +374,8 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)

WiiHIDDeviceDescriptor wii_device;
ConvertDeviceToWii(&wii_device, &desc);
Memory::CopyToEmu(OffsetBuffer, &wii_device, Align(wii_device.bLength, 4));
OffsetBuffer += Align(wii_device.bLength, 4);
Memory::CopyToEmu(OffsetBuffer, &wii_device, wii_device.bLength);
OffsetBuffer += Common::AlignUp(wii_device.bLength, 4);
bool deviceValid = true;
bool isHID = false;

Expand All @@ -404,8 +388,8 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
{
WiiHIDConfigDescriptor wii_config;
ConvertConfigToWii(&wii_config, config);
Memory::CopyToEmu(OffsetBuffer, &wii_config, Align(wii_config.bLength, 4));
OffsetBuffer += Align(wii_config.bLength, 4);
Memory::CopyToEmu(OffsetBuffer, &wii_config, wii_config.bLength);
OffsetBuffer += Common::AlignUp(wii_config.bLength, 4);

for (ic = 0; ic < config->bNumInterfaces; ic++)
{
Expand All @@ -421,17 +405,17 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)

WiiHIDInterfaceDescriptor wii_interface;
ConvertInterfaceToWii(&wii_interface, interface);
Memory::CopyToEmu(OffsetBuffer, &wii_interface, Align(wii_interface.bLength, 4));
OffsetBuffer += Align(wii_interface.bLength, 4);
Memory::CopyToEmu(OffsetBuffer, &wii_interface, wii_interface.bLength);
OffsetBuffer += Common::AlignUp(wii_interface.bLength, 4);

for (e = 0; e < interface->bNumEndpoints; e++)
{
const struct libusb_endpoint_descriptor* endpoint = &interface->endpoint[e];

WiiHIDEndpointDescriptor wii_endpoint;
ConvertEndpointToWii(&wii_endpoint, endpoint);
Memory::CopyToEmu(OffsetBuffer, &wii_endpoint, Align(wii_endpoint.bLength, 4));
OffsetBuffer += Align(wii_endpoint.bLength, 4);
Memory::CopyToEmu(OffsetBuffer, &wii_endpoint, wii_endpoint.bLength);
OffsetBuffer += Common::AlignUp(wii_endpoint.bLength, 4);

} // endpoints
} // interfaces
Expand Down Expand Up @@ -500,11 +484,6 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
Memory::Write_U32(0xFFFFFFFF, OffsetBuffer); // no more devices
}

int CWII_IPC_HLE_Device_hid::Align(int num, int alignment)
{
return (num + (alignment - 1)) & ~(alignment - 1);
}

libusb_device_handle* CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum)
{
libusb_device** list;
Expand Down
4 changes: 0 additions & 4 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device

virtual ~CWII_IPC_HLE_Device_hid();

IPCCommandResult Open(u32 _CommandAddress, u32 _Mode) override;
IPCCommandResult Close(u32 _CommandAddress, bool _bForce) override;

IPCCommandResult IOCtlV(u32 _CommandAddress) override;
IPCCommandResult IOCtl(u32 _CommandAddress) override;

Expand Down Expand Up @@ -130,7 +127,6 @@ class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device
const libusb_interface_descriptor* src);
void ConvertEndpointToWii(WiiHIDEndpointDescriptor* dest, const libusb_endpoint_descriptor* src);

int Align(int num, int alignment);
static void checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid);
static void LIBUSB_CALL handleUsbUpdates(libusb_transfer* transfer);

Expand Down
68 changes: 0 additions & 68 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,6 @@ CWII_IPC_HLE_Device_net_kd_request::~CWII_IPC_HLE_Device_net_kd_request()
WiiSockMan::GetInstance().Clean();
}

IPCCommandResult CWII_IPC_HLE_Device_net_kd_request::Open(u32 _CommandAddress, u32 _Mode)
{
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: Open");
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
m_Active = true;
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_net_kd_request::Close(u32 _CommandAddress, bool _bForce)
{
INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: Close");
if (!_bForce)
Memory::Write_U32(0, _CommandAddress + 4);
m_Active = false;
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
{
u32 Parameter = Memory::Read_U32(_CommandAddress + 0xC);
Expand Down Expand Up @@ -354,23 +337,6 @@ CWII_IPC_HLE_Device_net_ncd_manage::~CWII_IPC_HLE_Device_net_ncd_manage()
{
}

IPCCommandResult CWII_IPC_HLE_Device_net_ncd_manage::Open(u32 _CommandAddress, u32 _Mode)
{
INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: Open");
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
m_Active = true;
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_net_ncd_manage::Close(u32 _CommandAddress, bool _bForce)
{
INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: Close");
if (!_bForce)
Memory::Write_U32(0, _CommandAddress + 4);
m_Active = false;
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress)
{
u32 return_value = 0;
Expand Down Expand Up @@ -453,23 +419,6 @@ CWII_IPC_HLE_Device_net_wd_command::~CWII_IPC_HLE_Device_net_wd_command()
{
}

IPCCommandResult CWII_IPC_HLE_Device_net_wd_command::Open(u32 CommandAddress, u32 Mode)
{
INFO_LOG(WII_IPC_NET, "NET_WD_COMMAND: Open");
Memory::Write_U32(GetDeviceID(), CommandAddress + 4);
m_Active = true;
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_net_wd_command::Close(u32 CommandAddress, bool Force)
{
INFO_LOG(WII_IPC_NET, "NET_WD_COMMAND: Close");
if (!Force)
Memory::Write_U32(0, CommandAddress + 4);
m_Active = false;
return GetDefaultReply();
}

// This is just for debugging / playing around.
// There really is no reason to implement wd unless we can bend it such that
// we can talk to the DS.
Expand Down Expand Up @@ -582,23 +531,6 @@ CWII_IPC_HLE_Device_net_ip_top::~CWII_IPC_HLE_Device_net_ip_top()
#endif
}

IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::Open(u32 _CommandAddress, u32 _Mode)
{
INFO_LOG(WII_IPC_NET, "NET_IP_TOP: Open");
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
m_Active = true;
return GetDefaultReply();
}

IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::Close(u32 _CommandAddress, bool _bForce)
{
INFO_LOG(WII_IPC_NET, "NET_IP_TOP: Close");
if (!_bForce)
Memory::Write_U32(0, _CommandAddress + 4);
m_Active = false;
return GetDefaultReply();
}

static int inet_pton(const char* src, unsigned char* dst)
{
int saw_digit, octets;
Expand Down

0 comments on commit 27d7c26

Please sign in to comment.