IPC_HLE: USB_VEN: Clean up (includes and naming)

This commit is contained in:
Léo Lam 2016-10-21 02:12:36 +02:00
parent b0377f02f0
commit 741a638f3e
2 changed files with 56 additions and 58 deletions

View File

@ -2,13 +2,13 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "Common/StringUtil.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h"
#include "Common/Logging/Log.h"
#include "Core/HW/Memmap.h"
CWII_IPC_HLE_Device_usb_ven::CWII_IPC_HLE_Device_usb_ven(u32 _DeviceID, CWII_IPC_HLE_Device_usb_ven::CWII_IPC_HLE_Device_usb_ven(const u32 device_id,
const std::string& _rDeviceName) const std::string& device_name)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) : IWII_IPC_HLE_Device(device_id, device_name)
{ {
} }
@ -16,55 +16,55 @@ CWII_IPC_HLE_Device_usb_ven::~CWII_IPC_HLE_Device_usb_ven()
{ {
} }
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::Open(u32 _CommandAddress, u32 _Mode) IPCCommandResult CWII_IPC_HLE_Device_usb_ven::Open(u32 command_address, u32 mode)
{ {
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4); Memory::Write_U32(GetDeviceID(), command_address + 4);
m_Active = true; m_Active = true;
return GetDefaultReply(); return GetDefaultReply();
} }
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::Close(u32 _CommandAddress, bool _bForce) IPCCommandResult CWII_IPC_HLE_Device_usb_ven::Close(u32 command_address, bool force)
{ {
if (!_bForce) if (!force)
Memory::Write_U32(0, _CommandAddress + 4); Memory::Write_U32(0, command_address + 4);
m_Active = false; m_Active = false;
return GetDefaultReply(); return GetDefaultReply();
} }
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtlV(u32 _CommandAddress) IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtlV(u32 command_address)
{ {
SIOCtlVBuffer CommandBuffer(_CommandAddress); SIOCtlVBuffer command_buffer(command_address);
INFO_LOG(OSHLE, "%s - IOCtlV:", GetDeviceName().c_str()); INFO_LOG(OSHLE, "%s - IOCtlV:", GetDeviceName().c_str());
INFO_LOG(OSHLE, " Parameter: 0x%x", CommandBuffer.Parameter); INFO_LOG(OSHLE, " Parameter: 0x%x", command_buffer.Parameter);
INFO_LOG(OSHLE, " NumberIn: 0x%08x", CommandBuffer.NumberInBuffer); INFO_LOG(OSHLE, " NumberIn: 0x%08x", command_buffer.NumberInBuffer);
INFO_LOG(OSHLE, " NumberOut: 0x%08x", CommandBuffer.NumberPayloadBuffer); INFO_LOG(OSHLE, " NumberOut: 0x%08x", command_buffer.NumberPayloadBuffer);
INFO_LOG(OSHLE, " BufferVector: 0x%08x", CommandBuffer.BufferVector); INFO_LOG(OSHLE, " BufferVector: 0x%08x", command_buffer.BufferVector);
DumpAsync(CommandBuffer.BufferVector, CommandBuffer.NumberInBuffer, DumpAsync(command_buffer.BufferVector, command_buffer.NumberInBuffer,
CommandBuffer.NumberPayloadBuffer); command_buffer.NumberPayloadBuffer);
Memory::Write_U32(0, _CommandAddress + 4); Memory::Write_U32(0, command_address + 4);
return GetNoReply(); return GetNoReply();
} }
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(u32 _CommandAddress) IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(u32 command_address)
{ {
IPCCommandResult Reply = GetNoReply(); IPCCommandResult reply = GetNoReply();
u32 Command = Memory::Read_U32(_CommandAddress + 0x0c); u32 command = Memory::Read_U32(command_address + 0x0c);
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 buffer_in = Memory::Read_U32(command_address + 0x10);
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); u32 buffer_in_size = Memory::Read_U32(command_address + 0x14);
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); u32 buffer_out = Memory::Read_U32(command_address + 0x18);
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1c); u32 buffer_out_size = Memory::Read_U32(command_address + 0x1c);
INFO_LOG(OSHLE, "%s - IOCtl: %x", GetDeviceName().c_str(), Command); INFO_LOG(OSHLE, "%s - IOCtl: %x", GetDeviceName().c_str(), command);
INFO_LOG(OSHLE, "%x:%x %x:%x", BufferIn, BufferInSize, BufferOut, BufferOutSize); INFO_LOG(OSHLE, "%x:%x %x:%x", buffer_in, buffer_in_size, buffer_out, buffer_out_size);
switch (Command) switch (command)
{ {
case USBV5_IOCTL_GETVERSION: case USBV5_IOCTL_GETVERSION:
Memory::Write_U32(0x50001, BufferOut); Memory::Write_U32(0x50001, buffer_out);
Reply = GetDefaultReply(); reply = GetDefaultReply();
break; break;
case USBV5_IOCTL_GETDEVICECHANGE: case USBV5_IOCTL_GETDEVICECHANGE:
@ -73,51 +73,46 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(u32 _CommandAddress)
static bool firstcall = true; static bool firstcall = true;
if (firstcall) if (firstcall)
{ {
Reply = GetDefaultReply(); reply = GetDefaultReply();
firstcall = false; firstcall = false;
} }
// num devices // num devices
Memory::Write_U32(0, _CommandAddress + 4); Memory::Write_U32(0, command_address + 4);
return Reply; return reply;
} }
break; break;
case USBV5_IOCTL_ATTACHFINISH: case USBV5_IOCTL_ATTACHFINISH:
Reply = GetDefaultReply(); reply = GetDefaultReply();
break; break;
case USBV5_IOCTL_SUSPEND_RESUME: case USBV5_IOCTL_SUSPEND_RESUME:
DEBUG_LOG(OSHLE, "Device: %i Resumed: %i", Memory::Read_U32(BufferIn), DEBUG_LOG(OSHLE, "Device: %i Resumed: %i", Memory::Read_U32(buffer_in),
Memory::Read_U32(BufferIn + 4)); Memory::Read_U32(buffer_in + 4));
Reply = GetDefaultReply(); reply = GetDefaultReply();
break; break;
case USBV5_IOCTL_GETDEVPARAMS: case USBV5_IOCTL_GETDEVPARAMS:
{ {
s32 device = Memory::Read_U32(BufferIn); s32 device = Memory::Read_U32(buffer_in);
u32 unk = Memory::Read_U32(BufferIn + 4); u32 unk = Memory::Read_U32(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, BufferOut); Memory::Write_U32(0, buffer_out);
Reply = GetDefaultReply(); reply = GetDefaultReply();
} }
break; break;
default: default:
DEBUG_LOG(OSHLE, "%x:%x %x:%x", BufferIn, BufferInSize, BufferOut, BufferOutSize); DEBUG_LOG(OSHLE, "%x:%x %x:%x", buffer_in, buffer_in_size, buffer_out, buffer_out_size);
break; break;
} }
Memory::Write_U32(0, _CommandAddress + 4); Memory::Write_U32(0, command_address + 4);
return Reply; return reply;
}
u32 CWII_IPC_HLE_Device_usb_ven::Update()
{
return IWII_IPC_HLE_Device::Update();
} }
void CWII_IPC_HLE_Device_usb_ven::DoState(PointerWrap& p) void CWII_IPC_HLE_Device_usb_ven::DoState(PointerWrap& p)

View File

@ -4,23 +4,26 @@
#pragma once #pragma once
#include <string>
#include "Common/CommonTypes.h"
#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 CWII_IPC_HLE_Device_usb_ven : public IWII_IPC_HLE_Device class PointerWrap;
class CWII_IPC_HLE_Device_usb_ven final : public IWII_IPC_HLE_Device
{ {
public: public:
CWII_IPC_HLE_Device_usb_ven(u32 _DeviceID, const std::string& _rDeviceName); CWII_IPC_HLE_Device_usb_ven(u32 device_id, const std::string& device_name);
~CWII_IPC_HLE_Device_usb_ven() override; ~CWII_IPC_HLE_Device_usb_ven() override;
IPCCommandResult Open(u32 _CommandAddress, u32 _Mode) override; IPCCommandResult Open(u32 command_address, u32 mode) override;
IPCCommandResult Close(u32 _CommandAddress, bool _bForce) override; IPCCommandResult Close(u32 command_address, bool force) override;
IPCCommandResult IOCtlV(u32 _CommandAddress) override; IPCCommandResult IOCtlV(u32 command_address) override;
IPCCommandResult IOCtl(u32 _CommandAddress) override; IPCCommandResult IOCtl(u32 command_address) override;
u32 Update() override;
void DoState(PointerWrap& p) override; void DoState(PointerWrap& p) override;