Skip to content
Permalink
Browse files

IOS/USB: Fix TransferCommand length type

The total buffer size for isochronous transfers should be a u32,
not a u16. It is easy to hit the bug with devices such as cameras,
which require larger buffers.

This fixes Your Shape.

This also fixes the length type for bulk and interrupt transfers,
which should be u32 as that's what IOS supports. I'm not sure why
I made them u16... probably because OH0 uses u16 for most lengths...
  • Loading branch information...
leoetlino committed May 2, 2019
1 parent 5226d61 commit a6da38d75dce7941262a64b0097a9e2502bff22e
Showing with 7 additions and 7 deletions.
  1. +3 −3 Source/Core/Core/IOS/USB/Common.h
  2. +1 −1 Source/Core/Core/IOS/USB/USBV4.cpp
  3. +3 −3 Source/Core/Core/IOS/USB/USBV5.cpp
@@ -127,14 +127,14 @@ struct CtrlMessage : TransferCommand

struct BulkMessage : TransferCommand
{
u16 length = 0;
u32 length = 0;
u8 endpoint = 0;
using TransferCommand::TransferCommand;
};

struct IntrMessage : TransferCommand
{
u16 length = 0;
u32 length = 0;
u8 endpoint = 0;
using TransferCommand::TransferCommand;
};
@@ -143,7 +143,7 @@ struct IsoMessage : TransferCommand
{
u32 packet_sizes_addr = 0;
std::vector<u16> packet_sizes;
u16 length = 0;
u32 length = 0;
u8 num_packets = 0;
u8 endpoint = 0;
using TransferCommand::TransferCommand;
@@ -87,7 +87,7 @@ V4IntrMessage::V4IntrMessage(Kernel& ios, const IOCtlRequest& ioctl) : IntrMessa
{
HIDRequest hid_request;
Memory::CopyFromEmu(&hid_request, ioctl.buffer_in, sizeof(hid_request));
length = static_cast<u16>(Common::swap32(hid_request.interrupt.length));
length = Common::swap32(hid_request.interrupt.length);
endpoint = static_cast<u8>(Common::swap32(hid_request.interrupt.endpoint));
data_address = Common::swap32(hid_request.data_addr);
}
@@ -31,14 +31,14 @@ V5CtrlMessage::V5CtrlMessage(Kernel& ios, const IOCtlVRequest& ioctlv)
V5BulkMessage::V5BulkMessage(Kernel& ios, const IOCtlVRequest& ioctlv)
: BulkMessage(ios, ioctlv, ioctlv.GetVector(1)->address)
{
length = static_cast<u16>(ioctlv.GetVector(1)->size);
length = ioctlv.GetVector(1)->size;
endpoint = Memory::Read_U8(ioctlv.in_vectors[0].address + 18);
}

V5IntrMessage::V5IntrMessage(Kernel& ios, const IOCtlVRequest& ioctlv)
: IntrMessage(ios, ioctlv, ioctlv.GetVector(1)->address)
{
length = static_cast<u16>(ioctlv.GetVector(1)->size);
length = ioctlv.GetVector(1)->size;
endpoint = Memory::Read_U8(ioctlv.in_vectors[0].address + 14);
}

@@ -50,7 +50,7 @@ V5IsoMessage::V5IsoMessage(Kernel& ios, const IOCtlVRequest& ioctlv)
packet_sizes_addr = ioctlv.GetVector(1)->address;
for (size_t i = 0; i < num_packets; ++i)
packet_sizes.push_back(Memory::Read_U16(static_cast<u32>(packet_sizes_addr + i * sizeof(u16))));
length = static_cast<u16>(ioctlv.GetVector(2)->size);
length = ioctlv.GetVector(2)->size;
}
} // namespace USB

0 comments on commit a6da38d

Please sign in to comment.
You can’t perform that action at this time.