Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement /dev/usb/ven with very basic functionality (based on the ol…
…d wiispeak branch)
- Loading branch information
Showing
6 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// Copyright 2016 Dolphin Emulator Project | ||
// Licensed under GPLv2+ | ||
// Refer to the license.txt file included. | ||
|
||
#include "Common/StringUtil.h" | ||
|
||
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h" | ||
|
||
CWII_IPC_HLE_Device_usb_ven::CWII_IPC_HLE_Device_usb_ven(u32 _DeviceID, | ||
const std::string& _rDeviceName) | ||
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) | ||
{ | ||
} | ||
|
||
CWII_IPC_HLE_Device_usb_ven::~CWII_IPC_HLE_Device_usb_ven() | ||
{ | ||
} | ||
|
||
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::Open(u32 _CommandAddress, u32 _Mode) | ||
{ | ||
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4); | ||
m_Active = true; | ||
return GetDefaultReply(); | ||
} | ||
|
||
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::Close(u32 _CommandAddress, bool _bForce) | ||
{ | ||
if (!_bForce) | ||
Memory::Write_U32(0, _CommandAddress + 4); | ||
|
||
m_Active = false; | ||
return GetDefaultReply(); | ||
} | ||
|
||
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtlV(u32 _CommandAddress) | ||
{ | ||
SIOCtlVBuffer CommandBuffer(_CommandAddress); | ||
|
||
DEBUG_LOG(OSHLE, "%s - IOCtlV:", GetDeviceName().c_str()); | ||
DEBUG_LOG(OSHLE, " Parameter: 0x%x", CommandBuffer.Parameter); | ||
DEBUG_LOG(OSHLE, " NumberIn: 0x%08x", CommandBuffer.NumberInBuffer); | ||
DEBUG_LOG(OSHLE, " NumberOut: 0x%08x", CommandBuffer.NumberPayloadBuffer); | ||
DEBUG_LOG(OSHLE, " BufferVector: 0x%08x", CommandBuffer.BufferVector); | ||
DumpAsync(CommandBuffer.BufferVector, CommandBuffer.NumberInBuffer, | ||
CommandBuffer.NumberPayloadBuffer); | ||
|
||
Memory::Write_U32(0, _CommandAddress + 4); | ||
return GetNoReply(); | ||
} | ||
|
||
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(u32 _CommandAddress) | ||
{ | ||
IPCCommandResult Reply = GetNoReply(); | ||
u32 Command = Memory::Read_U32(_CommandAddress + 0x0c); | ||
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); | ||
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); | ||
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); | ||
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1c); | ||
|
||
DEBUG_LOG(OSHLE, "%s - IOCtl: %x", GetDeviceName().c_str(), Command); | ||
DEBUG_LOG(OSHLE, "%x:%x %x:%x", BufferIn, BufferInSize, BufferOut, BufferOutSize); | ||
|
||
switch (Command) | ||
{ | ||
case USBV5_IOCTL_GETVERSION: | ||
Memory::Write_U32(0x50001, BufferOut); | ||
Reply = GetDefaultReply(); | ||
break; | ||
|
||
case USBV5_IOCTL_GETDEVICECHANGE: | ||
{ | ||
// sent on change | ||
static bool firstcall = true; | ||
if (firstcall) | ||
{ | ||
Reply = GetDefaultReply(); | ||
firstcall = false; | ||
} | ||
|
||
// num devices | ||
Memory::Write_U32(0, _CommandAddress + 4); | ||
return Reply; | ||
} | ||
break; | ||
|
||
case USBV5_IOCTL_ATTACHFINISH: | ||
Reply = GetDefaultReply(); | ||
break; | ||
|
||
case USBV5_IOCTL_SUSPEND_RESUME: | ||
DEBUG_LOG(OSHLE, "Device: %i Resumed: %i", Memory::Read_U32(BufferIn), | ||
Memory::Read_U32(BufferIn + 4)); | ||
Reply = GetDefaultReply(); | ||
break; | ||
|
||
case USBV5_IOCTL_GETDEVPARAMS: | ||
{ | ||
s32 device = Memory::Read_U32(BufferIn); | ||
u32 unk = Memory::Read_U32(BufferIn + 4); | ||
|
||
DEBUG_LOG(OSHLE, "USBV5_IOCTL_GETDEVPARAMS device: %i unk: %i", device, unk); | ||
|
||
Memory::Write_U32(0, BufferOut); | ||
|
||
Reply = GetDefaultReply(); | ||
} | ||
break; | ||
|
||
default: | ||
DEBUG_LOG(OSHLE, "%x:%x %x:%x", BufferIn, BufferInSize, BufferOut, BufferOutSize); | ||
break; | ||
} | ||
|
||
Memory::Write_U32(0, _CommandAddress + 4); | ||
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) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2016 Dolphin Emulator Project | ||
// Licensed under GPLv2+ | ||
// Refer to the license.txt file included. | ||
|
||
#pragma once | ||
|
||
#include "Core/IPC_HLE/WII_IPC_HLE.h" | ||
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" | ||
|
||
class CWII_IPC_HLE_Device_usb_ven : public IWII_IPC_HLE_Device | ||
{ | ||
public: | ||
CWII_IPC_HLE_Device_usb_ven(u32 _DeviceID, const std::string& _rDeviceName); | ||
|
||
~CWII_IPC_HLE_Device_usb_ven() override; | ||
|
||
virtual IPCCommandResult Open(u32 _CommandAddress, u32 _Mode); | ||
virtual IPCCommandResult Close(u32 _CommandAddress, bool _bForce); | ||
|
||
virtual IPCCommandResult IOCtlV(u32 _CommandAddress); | ||
virtual IPCCommandResult IOCtl(u32 _CommandAddress); | ||
|
||
virtual u32 Update(); | ||
|
||
void DoState(PointerWrap& p); | ||
|
||
private: | ||
enum USBIOCtl | ||
{ | ||
USBV5_IOCTL_GETVERSION = 0, | ||
USBV5_IOCTL_GETDEVICECHANGE = 1, | ||
USBV5_IOCTL_SHUTDOWN = 2, | ||
USBV5_IOCTL_GETDEVPARAMS = 3, | ||
USBV5_IOCTL_ATTACHFINISH = 6, | ||
USBV5_IOCTL_SETALTERNATE = 7, | ||
USBV5_IOCTL_SUSPEND_RESUME = 16, | ||
USBV5_IOCTL_CANCELENDPOINT = 17, | ||
USBV5_IOCTL_CTRLMSG = 18, | ||
USBV5_IOCTL_INTRMSG = 19, | ||
USBV5_IOCTL_ISOMSG = 20, | ||
USBV5_IOCTL_BULKMSG = 21 | ||
}; | ||
}; |