From d536082e4273e878e2f93a85e9ab13aae804b95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 15 Jan 2017 11:45:16 +0100 Subject: [PATCH] IOS HLE: Deduplicate request code in USB_VEN --- .../IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp | 56 ++++++------------- .../Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h | 10 +--- 2 files changed, 18 insertions(+), 48 deletions(-) diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp index d448c38586..db025b3d07 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp @@ -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) { -} - -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); + request.Dump(GetDeviceName()); + request.SetReturnValue(IPC_SUCCESS); 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(); - u32 command = Memory::Read_U32(command_address + 0x0c); - 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) + switch (request.request) { case USBV5_IOCTL_GETVERSION: - Memory::Write_U32(0x50001, buffer_out); + Memory::Write_U32(0x50001, request.buffer_out); reply = GetDefaultReply(); break; @@ -60,7 +43,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(u32 command_address) } // num devices - Memory::Write_U32(0, command_address + 4); + request.SetReturnValue(0); return reply; } break; @@ -70,33 +53,26 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(u32 command_address) break; case USBV5_IOCTL_SUSPEND_RESUME: - DEBUG_LOG(OSHLE, "Device: %i Resumed: %i", Memory::Read_U32(buffer_in), - Memory::Read_U32(buffer_in + 4)); + DEBUG_LOG(OSHLE, "Device: %i Resumed: %i", Memory::Read_U32(request.buffer_in), + Memory::Read_U32(request.buffer_in + 4)); reply = GetDefaultReply(); break; case USBV5_IOCTL_GETDEVPARAMS: { - s32 device = Memory::Read_U32(buffer_in); - u32 unk = Memory::Read_U32(buffer_in + 4); + s32 device = Memory::Read_U32(request.buffer_in); + u32 unk = Memory::Read_U32(request.buffer_in + 4); 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(); } break; default: - DEBUG_LOG(OSHLE, "%x:%x %x:%x", buffer_in, buffer_in_size, buffer_out, buffer_out_size); - break; + request.Log(GetDeviceName(), LogTypes::OSHLE, LogTypes::LDEBUG); } - - Memory::Write_U32(0, command_address + 4); return reply; } - -void CWII_IPC_HLE_Device_usb_ven::DoState(PointerWrap& p) -{ -} diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h index 612400f1e0..7cb5406483 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h @@ -10,19 +10,13 @@ #include "Core/IPC_HLE/WII_IPC_HLE.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 { public: CWII_IPC_HLE_Device_usb_ven(u32 device_id, const std::string& device_name); - ~CWII_IPC_HLE_Device_usb_ven() override; - - IPCCommandResult IOCtlV(u32 command_address) override; - IPCCommandResult IOCtl(u32 command_address) override; - - void DoState(PointerWrap& p) override; + IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; + IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; private: enum USBIOCtl