IOS HLE: Deduplicate request code in USB_VEN

This commit is contained in:
Léo Lam 2017-01-15 11:45:16 +01:00
parent d7b4e6ead5
commit d536082e42
2 changed files with 18 additions and 48 deletions

View File

@ -12,40 +12,23 @@ CWII_IPC_HLE_Device_usb_ven::CWII_IPC_HLE_Device_usb_ven(const u32 device_id,
{ {
} }
CWII_IPC_HLE_Device_usb_ven::~CWII_IPC_HLE_Device_usb_ven() IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtlV(const IOSIOCtlVRequest& request)
{ {
} request.Dump(GetDeviceName());
request.SetReturnValue(IPC_SUCCESS);
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtlV(u32 command_address)
{
SIOCtlVBuffer command_buffer(command_address);
INFO_LOG(OSHLE, "%s - IOCtlV:", GetDeviceName().c_str());
INFO_LOG(OSHLE, " Parameter: 0x%x", command_buffer.Parameter);
INFO_LOG(OSHLE, " NumberIn: 0x%08x", command_buffer.NumberInBuffer);
INFO_LOG(OSHLE, " NumberOut: 0x%08x", command_buffer.NumberPayloadBuffer);
INFO_LOG(OSHLE, " BufferVector: 0x%08x", command_buffer.BufferVector);
Memory::Write_U32(0, command_address + 4);
return GetNoReply(); return GetNoReply();
} }
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(u32 command_address) IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(const IOSIOCtlRequest& request)
{ {
request.Log(GetDeviceName(), LogTypes::OSHLE);
request.SetReturnValue(IPC_SUCCESS);
IPCCommandResult reply = GetDefaultReply(); IPCCommandResult reply = GetDefaultReply();
u32 command = Memory::Read_U32(command_address + 0x0c); switch (request.request)
u32 buffer_in = Memory::Read_U32(command_address + 0x10);
u32 buffer_in_size = Memory::Read_U32(command_address + 0x14);
u32 buffer_out = Memory::Read_U32(command_address + 0x18);
u32 buffer_out_size = Memory::Read_U32(command_address + 0x1c);
INFO_LOG(OSHLE, "%s - IOCtl: %x", GetDeviceName().c_str(), command);
INFO_LOG(OSHLE, "%x:%x %x:%x", buffer_in, buffer_in_size, buffer_out, buffer_out_size);
switch (command)
{ {
case USBV5_IOCTL_GETVERSION: case USBV5_IOCTL_GETVERSION:
Memory::Write_U32(0x50001, buffer_out); Memory::Write_U32(0x50001, request.buffer_out);
reply = GetDefaultReply(); reply = GetDefaultReply();
break; break;
@ -60,7 +43,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(u32 command_address)
} }
// num devices // num devices
Memory::Write_U32(0, command_address + 4); request.SetReturnValue(0);
return reply; return reply;
} }
break; break;
@ -70,33 +53,26 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(u32 command_address)
break; break;
case USBV5_IOCTL_SUSPEND_RESUME: case USBV5_IOCTL_SUSPEND_RESUME:
DEBUG_LOG(OSHLE, "Device: %i Resumed: %i", Memory::Read_U32(buffer_in), DEBUG_LOG(OSHLE, "Device: %i Resumed: %i", Memory::Read_U32(request.buffer_in),
Memory::Read_U32(buffer_in + 4)); Memory::Read_U32(request.buffer_in + 4));
reply = GetDefaultReply(); reply = GetDefaultReply();
break; break;
case USBV5_IOCTL_GETDEVPARAMS: case USBV5_IOCTL_GETDEVPARAMS:
{ {
s32 device = Memory::Read_U32(buffer_in); s32 device = Memory::Read_U32(request.buffer_in);
u32 unk = Memory::Read_U32(buffer_in + 4); u32 unk = Memory::Read_U32(request.buffer_in + 4);
DEBUG_LOG(OSHLE, "USBV5_IOCTL_GETDEVPARAMS device: %i unk: %i", device, unk); DEBUG_LOG(OSHLE, "USBV5_IOCTL_GETDEVPARAMS device: %i unk: %i", device, unk);
Memory::Write_U32(0, buffer_out); Memory::Write_U32(0, request.buffer_out);
reply = GetDefaultReply(); reply = GetDefaultReply();
} }
break; break;
default: default:
DEBUG_LOG(OSHLE, "%x:%x %x:%x", buffer_in, buffer_in_size, buffer_out, buffer_out_size); request.Log(GetDeviceName(), LogTypes::OSHLE, LogTypes::LDEBUG);
break;
} }
Memory::Write_U32(0, command_address + 4);
return reply; return reply;
} }
void CWII_IPC_HLE_Device_usb_ven::DoState(PointerWrap& p)
{
}

View File

@ -10,19 +10,13 @@
#include "Core/IPC_HLE/WII_IPC_HLE.h" #include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
class PointerWrap;
class CWII_IPC_HLE_Device_usb_ven final : public IWII_IPC_HLE_Device class CWII_IPC_HLE_Device_usb_ven final : public IWII_IPC_HLE_Device
{ {
public: public:
CWII_IPC_HLE_Device_usb_ven(u32 device_id, const std::string& device_name); CWII_IPC_HLE_Device_usb_ven(u32 device_id, const std::string& device_name);
~CWII_IPC_HLE_Device_usb_ven() override; IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override;
IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override;
IPCCommandResult IOCtlV(u32 command_address) override;
IPCCommandResult IOCtl(u32 command_address) override;
void DoState(PointerWrap& p) override;
private: private:
enum USBIOCtl enum USBIOCtl