Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS: USB fixes #8109

Merged
merged 7 commits into from May 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 21, 2019
commit a6da38d75dce7941262a64b0097a9e2502bff22e
6 changes: 3 additions & 3 deletions Source/Core/Core/IOS/USB/Common.h
Expand Up @@ -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;
};
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/IOS/USB/USBV4.cpp
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/IOS/USB/USBV5.cpp
Expand Up @@ -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);
}

Expand All @@ -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

Expand Down