Core: Convert logging over to fmt pt.4
Continues the migration of logging in the Core library. This part finishes up the remaining log calls within the IOS code.
This commit is contained in:
parent
17b11cf4a4
commit
6cd718163f
|
@ -181,7 +181,7 @@ ReturnCode ES::VerifySign(const std::vector<u8>& hash, const std::vector<u8>& ec
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_ES, "VerifySign: all checks passed");
|
INFO_LOG_FMT(IOS_ES, "VerifySign: all checks passed");
|
||||||
return IPC_SUCCESS;
|
return IPC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,10 @@ template <typename... Args>
|
||||||
static void LogResult(ResultCode code, std::string_view format, Args&&... args)
|
static void LogResult(ResultCode code, std::string_view format, Args&&... args)
|
||||||
{
|
{
|
||||||
const std::string command = fmt::format(format, std::forward<Args>(args)...);
|
const std::string command = fmt::format(format, std::forward<Args>(args)...);
|
||||||
GENERIC_LOG(Common::Log::IOS_FS,
|
const auto type = code == ResultCode::Success ? Common::Log::LINFO : Common::Log::LERROR;
|
||||||
(code == ResultCode::Success ? Common::Log::LINFO : Common::Log::LERROR),
|
|
||||||
"%s: result %d", command.c_str(), ConvertResult(code));
|
GENERIC_LOG_FMT(Common::Log::IOS_FS, type, "Command: {}: Result {}", command,
|
||||||
|
ConvertResult(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
|
@ -544,7 +545,8 @@ IPCCommandResult FS::SetFileVersionControl(const Handle& handle, const IOCtlRequ
|
||||||
return GetFSReply(ConvertResult(params.Error()));
|
return GetFSReply(ConvertResult(params.Error()));
|
||||||
|
|
||||||
// FS_SetFileVersionControl(ctx->uid, params->path, params->attribute)
|
// FS_SetFileVersionControl(ctx->uid, params->path, params->attribute)
|
||||||
ERROR_LOG(IOS_FS, "SetFileVersionControl(%s, 0x%x): Stubbed", params->path, params->attribute);
|
ERROR_LOG_FMT(IOS_FS, "SetFileVersionControl({}, {:#x}): Stubbed", params->path,
|
||||||
|
params->attribute);
|
||||||
return GetFSReply(IPC_SUCCESS);
|
return GetFSReply(IPC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +588,7 @@ IPCCommandResult FS::GetUsage(const Handle& handle, const IOCtlVRequest& request
|
||||||
|
|
||||||
IPCCommandResult FS::Shutdown(const Handle& handle, const IOCtlRequest& request)
|
IPCCommandResult FS::Shutdown(const Handle& handle, const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_FS, "Shutdown");
|
INFO_LOG_FMT(IOS_FS, "Shutdown");
|
||||||
return GetFSReply(IPC_SUCCESS);
|
return GetFSReply(IPC_SUCCESS);
|
||||||
}
|
}
|
||||||
} // namespace IOS::HLE::Device
|
} // namespace IOS::HLE::Device
|
||||||
|
|
|
@ -156,7 +156,7 @@ void HostFileSystem::LoadFst()
|
||||||
const auto root_entry = parse_entry(parse_entry, 0);
|
const auto root_entry = parse_entry(parse_entry, 0);
|
||||||
if (!root_entry.has_value())
|
if (!root_entry.has_value())
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_FS, "Failed to parse FST: at least one of the entries was invalid");
|
ERROR_LOG_FMT(IOS_FS, "Failed to parse FST: at least one of the entries was invalid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_root_entry = *root_entry;
|
m_root_entry = *root_entry;
|
||||||
|
@ -182,12 +182,12 @@ void HostFileSystem::SaveFst()
|
||||||
File::IOFile file{temp_path, "wb"};
|
File::IOFile file{temp_path, "wb"};
|
||||||
if (!file.WriteArray(to_write.data(), to_write.size()))
|
if (!file.WriteArray(to_write.data(), to_write.size()))
|
||||||
{
|
{
|
||||||
PanicAlert("IOS_FS: Failed to write new FST");
|
PanicAlertFmt("IOS_FS: Failed to write new FST");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!File::Rename(temp_path, dest_path))
|
if (!File::Rename(temp_path, dest_path))
|
||||||
PanicAlert("IOS_FS: Failed to rename temporary FST file");
|
PanicAlertFmt("IOS_FS: Failed to rename temporary FST file");
|
||||||
}
|
}
|
||||||
|
|
||||||
HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string& path)
|
HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string& path)
|
||||||
|
@ -218,7 +218,7 @@ HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string&
|
||||||
// Fall back to dummy data to avoid breaking existing filesystems.
|
// Fall back to dummy data to avoid breaking existing filesystems.
|
||||||
// This code path is also reached when creating a new file or directory;
|
// This code path is also reached when creating a new file or directory;
|
||||||
// proper metadata is filled in later.
|
// proper metadata is filled in later.
|
||||||
INFO_LOG(IOS_FS, "Creating a default entry for %s", complete_path.c_str());
|
INFO_LOG_FMT(IOS_FS, "Creating a default entry for {}", complete_path);
|
||||||
entry = &entry->children.emplace_back();
|
entry = &entry->children.emplace_back();
|
||||||
entry->name = component;
|
entry->name = component;
|
||||||
entry->data.modes = {Mode::ReadWrite, Mode::ReadWrite, Mode::ReadWrite};
|
entry->data.modes = {Mode::ReadWrite, Mode::ReadWrite, Mode::ReadWrite};
|
||||||
|
@ -228,7 +228,7 @@ HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string&
|
||||||
entry->data.is_file = host_file_info.IsFile();
|
entry->data.is_file = host_file_info.IsFile();
|
||||||
if (entry->data.is_file && !entry->children.empty())
|
if (entry->data.is_file && !entry->children.empty())
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_FS, "%s is a file but also has children; clearing children", path.c_str());
|
WARN_LOG_FMT(IOS_FS, "{} is a file but also has children; clearing children", path);
|
||||||
entry->children.clear();
|
entry->children.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ ResultCode HostFileSystem::CreateFileOrDirectory(Uid uid, Gid gid, const std::st
|
||||||
const bool ok = is_file ? File::CreateEmptyFile(host_path) : File::CreateDir(host_path);
|
const bool ok = is_file ? File::CreateEmptyFile(host_path) : File::CreateDir(host_path);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_FS, "Failed to create file or directory: %s", host_path.c_str());
|
ERROR_LOG_FMT(IOS_FS, "Failed to create file or directory: {}", host_path);
|
||||||
return ResultCode::UnknownError;
|
return ResultCode::UnknownError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ ResultCode HostFileSystem::Rename(Uid uid, Gid gid, const std::string& old_path,
|
||||||
|
|
||||||
if (!File::Rename(host_old_path, host_new_path))
|
if (!File::Rename(host_old_path, host_new_path))
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_FS, "Rename %s to %s - failed", host_old_path.c_str(), host_new_path.c_str());
|
ERROR_LOG_FMT(IOS_FS, "Rename {} to {} - failed", host_old_path, host_new_path);
|
||||||
return ResultCode::NotFound;
|
return ResultCode::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ ResultCode HostFileSystem::SetMetadata(Uid caller_uid, const std::string& path,
|
||||||
|
|
||||||
Result<NandStats> HostFileSystem::GetNandStats()
|
Result<NandStats> HostFileSystem::GetNandStats()
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_FS, "GET STATS - returning static values for now");
|
WARN_LOG_FMT(IOS_FS, "GET STATS - returning static values for now");
|
||||||
|
|
||||||
// TODO: scrape the real amounts from somewhere...
|
// TODO: scrape the real amounts from somewhere...
|
||||||
NandStats stats{};
|
NandStats stats{};
|
||||||
|
@ -681,7 +681,7 @@ Result<DirectoryStats> HostFileSystem::GetDirectoryStats(const std::string& wii_
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_FS, "fsBlock failed, cannot find directory: %s", path.c_str());
|
WARN_LOG_FMT(IOS_FS, "fsBlock failed, cannot find directory: {}", path);
|
||||||
}
|
}
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,15 +47,15 @@ std::shared_ptr<File::IOFile> HostFileSystem::OpenHostFile(const std::string& ho
|
||||||
while (!file.Open(host_path, "r+b"))
|
while (!file.Open(host_path, "r+b"))
|
||||||
{
|
{
|
||||||
const bool try_again =
|
const bool try_again =
|
||||||
PanicYesNo("File \"%s\" could not be opened!\n"
|
PanicYesNoFmt("File \"{}\" could not be opened!\n"
|
||||||
"This may happen with improper permissions or use by another process.\n"
|
"This may happen with improper permissions or use by another process.\n"
|
||||||
"Press \"Yes\" to make another attempt.",
|
"Press \"Yes\" to make another attempt.",
|
||||||
host_path.c_str());
|
host_path);
|
||||||
|
|
||||||
if (!try_again)
|
if (!try_again)
|
||||||
{
|
{
|
||||||
// We've failed to open the file:
|
// We've failed to open the file:
|
||||||
ERROR_LOG(IOS_FS, "OpenHostFile %s", host_path.c_str());
|
ERROR_LOG_FMT(IOS_FS, "OpenHostFile {}", host_path);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ enum SOResultCode : s32
|
||||||
NetIPTop::NetIPTop(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
|
NetIPTop::NetIPTop(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int ret = WSAStartup(MAKEWORD(2, 2), &InitData);
|
const int ret = WSAStartup(MAKEWORD(2, 2), &InitData);
|
||||||
INFO_LOG(IOS_NET, "WSAStartup: %d", ret);
|
INFO_LOG_FMT(IOS_NET, "WSAStartup: {}", ret);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ static s32 MapWiiSockOptLevelToNative(u32 level)
|
||||||
if (level == 0xFFFF)
|
if (level == 0xFFFF)
|
||||||
return SOL_SOCKET;
|
return SOL_SOCKET;
|
||||||
|
|
||||||
INFO_LOG(IOS_NET, "SO_SETSOCKOPT: unknown level %u", level);
|
INFO_LOG_FMT(IOS_NET, "SO_SETSOCKOPT: unknown level {}", level);
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ static s32 MapWiiSockOptNameToNative(u32 optname)
|
||||||
return SO_ERROR;
|
return SO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_NET, "SO_SETSOCKOPT: unknown optname %u", optname);
|
INFO_LOG_FMT(IOS_NET, "SO_SETSOCKOPT: unknown optname {}", optname);
|
||||||
return optname;
|
return optname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,46 +367,47 @@ IPCCommandResult NetIPTop::HandleInitInterfaceRequest(const IOCtlRequest& reques
|
||||||
|
|
||||||
IPCCommandResult NetIPTop::HandleSocketRequest(const IOCtlRequest& request)
|
IPCCommandResult NetIPTop::HandleSocketRequest(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
u32 af = Memory::Read_U32(request.buffer_in);
|
const u32 af = Memory::Read_U32(request.buffer_in);
|
||||||
u32 type = Memory::Read_U32(request.buffer_in + 4);
|
const u32 type = Memory::Read_U32(request.buffer_in + 4);
|
||||||
u32 prot = Memory::Read_U32(request.buffer_in + 8);
|
const u32 prot = Memory::Read_U32(request.buffer_in + 8);
|
||||||
|
|
||||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||||
const s32 return_value = sm.NewSocket(af, type, prot);
|
const s32 return_value = sm.NewSocket(af, type, prot);
|
||||||
INFO_LOG(IOS_NET,
|
INFO_LOG_FMT(IOS_NET,
|
||||||
"IOCTL_SO_SOCKET "
|
"IOCTL_SO_SOCKET "
|
||||||
"Socket: %08x (%d,%d,%d), BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
"Socket: {:08x} ({},{},{}), BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {})",
|
||||||
return_value, af, type, prot, request.buffer_in, request.buffer_in_size,
|
return_value, af, type, prot, request.buffer_in, request.buffer_in_size,
|
||||||
request.buffer_out, request.buffer_out_size);
|
request.buffer_out, request.buffer_out_size);
|
||||||
|
|
||||||
return GetDefaultReply(return_value);
|
return GetDefaultReply(return_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult NetIPTop::HandleICMPSocketRequest(const IOCtlRequest& request)
|
IPCCommandResult NetIPTop::HandleICMPSocketRequest(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
u32 pf = Memory::Read_U32(request.buffer_in);
|
const u32 pf = Memory::Read_U32(request.buffer_in);
|
||||||
|
|
||||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||||
const s32 return_value = sm.NewSocket(pf, SOCK_RAW, IPPROTO_ICMP);
|
const s32 return_value = sm.NewSocket(pf, SOCK_RAW, IPPROTO_ICMP);
|
||||||
INFO_LOG(IOS_NET, "IOCTL_SO_ICMPSOCKET(%x) %d", pf, return_value);
|
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_ICMPSOCKET({:x}) {}", pf, return_value);
|
||||||
return GetDefaultReply(return_value);
|
return GetDefaultReply(return_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult NetIPTop::HandleCloseRequest(const IOCtlRequest& request)
|
IPCCommandResult NetIPTop::HandleCloseRequest(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
u32 fd = Memory::Read_U32(request.buffer_in);
|
const u32 fd = Memory::Read_U32(request.buffer_in);
|
||||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||||
const s32 return_value = sm.DeleteSocket(fd);
|
const s32 return_value = sm.DeleteSocket(fd);
|
||||||
INFO_LOG(IOS_NET, "%s(%x) %x",
|
const char* const close_fn =
|
||||||
request.request == IOCTL_SO_ICMPCLOSE ? "IOCTL_SO_ICMPCLOSE" : "IOCTL_SO_CLOSE", fd,
|
request.request == IOCTL_SO_ICMPCLOSE ? "IOCTL_SO_ICMPCLOSE" : "IOCTL_SO_CLOSE";
|
||||||
return_value);
|
|
||||||
|
INFO_LOG_FMT(IOS_NET, "{}({:x}) {:x}", close_fn, fd, return_value);
|
||||||
|
|
||||||
return GetDefaultReply(return_value);
|
return GetDefaultReply(return_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult NetIPTop::HandleDoSockRequest(const IOCtlRequest& request)
|
IPCCommandResult NetIPTop::HandleDoSockRequest(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
u32 fd = Memory::Read_U32(request.buffer_in);
|
const u32 fd = Memory::Read_U32(request.buffer_in);
|
||||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||||
sm.DoSock(fd, request, static_cast<NET_IOCTL>(request.request));
|
sm.DoSock(fd, request, static_cast<NET_IOCTL>(request.request));
|
||||||
return GetNoReply();
|
return GetNoReply();
|
||||||
|
@ -416,8 +417,8 @@ IPCCommandResult NetIPTop::HandleShutdownRequest(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
if (request.buffer_in == 0 || request.buffer_in_size < 8)
|
if (request.buffer_in == 0 || request.buffer_in_size < 8)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_NET, "IOCTL_SO_SHUTDOWN = EINVAL, BufferIn: (%08x, %i)", request.buffer_in,
|
ERROR_LOG_FMT(IOS_NET, "IOCTL_SO_SHUTDOWN = EINVAL, BufferIn: ({:08x}, {})", request.buffer_in,
|
||||||
request.buffer_in_size);
|
request.buffer_in_size);
|
||||||
return GetDefaultReply(-SO_EINVAL);
|
return GetDefaultReply(-SO_EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +426,8 @@ IPCCommandResult NetIPTop::HandleShutdownRequest(const IOCtlRequest& request)
|
||||||
const u32 how = Memory::Read_U32(request.buffer_in + 4);
|
const u32 how = Memory::Read_U32(request.buffer_in + 4);
|
||||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||||
const s32 return_value = sm.ShutdownSocket(fd, how);
|
const s32 return_value = sm.ShutdownSocket(fd, how);
|
||||||
INFO_LOG(IOS_NET, "IOCTL_SO_SHUTDOWN(fd=%d, how=%d) = %d", fd, how, return_value);
|
|
||||||
|
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_SHUTDOWN(fd={}, how={}) = {}", fd, how, return_value);
|
||||||
return GetDefaultReply(return_value);
|
return GetDefaultReply(return_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,24 +476,24 @@ IPCCommandResult NetIPTop::HandleGetSockOptRequest(const IOCtlRequest& request)
|
||||||
|
|
||||||
IPCCommandResult NetIPTop::HandleSetSockOptRequest(const IOCtlRequest& request)
|
IPCCommandResult NetIPTop::HandleSetSockOptRequest(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
u32 fd = Memory::Read_U32(request.buffer_in);
|
const u32 fd = Memory::Read_U32(request.buffer_in);
|
||||||
u32 level = Memory::Read_U32(request.buffer_in + 4);
|
const u32 level = Memory::Read_U32(request.buffer_in + 4);
|
||||||
u32 optname = Memory::Read_U32(request.buffer_in + 8);
|
const u32 optname = Memory::Read_U32(request.buffer_in + 8);
|
||||||
u32 optlen = Memory::Read_U32(request.buffer_in + 0xc);
|
u32 optlen = Memory::Read_U32(request.buffer_in + 0xc);
|
||||||
u8 optval[20];
|
u8 optval[20];
|
||||||
optlen = std::min(optlen, (u32)sizeof(optval));
|
optlen = std::min(optlen, (u32)sizeof(optval));
|
||||||
Memory::CopyFromEmu(optval, request.buffer_in + 0x10, optlen);
|
Memory::CopyFromEmu(optval, request.buffer_in + 0x10, optlen);
|
||||||
|
|
||||||
INFO_LOG(IOS_NET,
|
INFO_LOG_FMT(IOS_NET,
|
||||||
"IOCTL_SO_SETSOCKOPT(%08x, %08x, %08x, %08x) "
|
"IOCTL_SO_SETSOCKOPT({:08x}, {:08x}, {:08x}, {:08x}) "
|
||||||
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)"
|
"BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {})"
|
||||||
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx "
|
"{:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} "
|
||||||
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx",
|
"{:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}",
|
||||||
fd, level, optname, optlen, request.buffer_in, request.buffer_in_size,
|
fd, level, optname, optlen, request.buffer_in, request.buffer_in_size,
|
||||||
request.buffer_out, request.buffer_out_size, optval[0], optval[1], optval[2], optval[3],
|
request.buffer_out, request.buffer_out_size, optval[0], optval[1], optval[2],
|
||||||
optval[4], optval[5], optval[6], optval[7], optval[8], optval[9], optval[10], optval[11],
|
optval[3], optval[4], optval[5], optval[6], optval[7], optval[8], optval[9],
|
||||||
optval[12], optval[13], optval[14], optval[15], optval[16], optval[17], optval[18],
|
optval[10], optval[11], optval[12], optval[13], optval[14], optval[15], optval[16],
|
||||||
optval[19]);
|
optval[17], optval[18], optval[19]);
|
||||||
|
|
||||||
// TODO: bug booto about this, 0x2005 most likely timeout related, default value on Wii is ,
|
// TODO: bug booto about this, 0x2005 most likely timeout related, default value on Wii is ,
|
||||||
// 0x2001 is most likely tcpnodelay
|
// 0x2001 is most likely tcpnodelay
|
||||||
|
@ -499,11 +501,11 @@ IPCCommandResult NetIPTop::HandleSetSockOptRequest(const IOCtlRequest& request)
|
||||||
return GetDefaultReply(0);
|
return GetDefaultReply(0);
|
||||||
|
|
||||||
// Do the level/optname translation
|
// Do the level/optname translation
|
||||||
int nat_level = MapWiiSockOptLevelToNative(level);
|
const int nat_level = MapWiiSockOptLevelToNative(level);
|
||||||
int nat_optname = MapWiiSockOptNameToNative(optname);
|
const int nat_optname = MapWiiSockOptNameToNative(optname);
|
||||||
|
|
||||||
int ret = setsockopt(WiiSockMan::GetInstance().GetHostSocket(fd), nat_level, nat_optname,
|
const int ret = setsockopt(WiiSockMan::GetInstance().GetHostSocket(fd), nat_level, nat_optname,
|
||||||
(char*)optval, optlen);
|
reinterpret_cast<char*>(optval), optlen);
|
||||||
return GetDefaultReply(WiiSockMan::GetNetErrorCode(ret, "SO_SETSOCKOPT", false));
|
return GetDefaultReply(WiiSockMan::GetNetErrorCode(ret, "SO_SETSOCKOPT", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,10 +517,10 @@ IPCCommandResult NetIPTop::HandleGetSockNameRequest(const IOCtlRequest& request)
|
||||||
|
|
||||||
sockaddr sa;
|
sockaddr sa;
|
||||||
socklen_t sa_len = sizeof(sa);
|
socklen_t sa_len = sizeof(sa);
|
||||||
int ret = getsockname(WiiSockMan::GetInstance().GetHostSocket(fd), &sa, &sa_len);
|
const int ret = getsockname(WiiSockMan::GetInstance().GetHostSocket(fd), &sa, &sa_len);
|
||||||
|
|
||||||
if (request.buffer_out_size < 2 + sizeof(sa.sa_data))
|
if (request.buffer_out_size < 2 + sizeof(sa.sa_data))
|
||||||
WARN_LOG(IOS_NET, "IOCTL_SO_GETSOCKNAME output buffer is too small. Truncating");
|
WARN_LOG_FMT(IOS_NET, "IOCTL_SO_GETSOCKNAME output buffer is too small. Truncating");
|
||||||
|
|
||||||
if (request.buffer_out_size > 0)
|
if (request.buffer_out_size > 0)
|
||||||
Memory::Write_U8(request.buffer_out_size, request.buffer_out);
|
Memory::Write_U8(request.buffer_out_size, request.buffer_out);
|
||||||
|
@ -539,10 +541,10 @@ IPCCommandResult NetIPTop::HandleGetPeerNameRequest(const IOCtlRequest& request)
|
||||||
|
|
||||||
sockaddr sa;
|
sockaddr sa;
|
||||||
socklen_t sa_len = sizeof(sa);
|
socklen_t sa_len = sizeof(sa);
|
||||||
int ret = getpeername(WiiSockMan::GetInstance().GetHostSocket(fd), &sa, &sa_len);
|
const int ret = getpeername(WiiSockMan::GetInstance().GetHostSocket(fd), &sa, &sa_len);
|
||||||
|
|
||||||
if (request.buffer_out_size < 2 + sizeof(sa.sa_data))
|
if (request.buffer_out_size < 2 + sizeof(sa.sa_data))
|
||||||
WARN_LOG(IOS_NET, "IOCTL_SO_GETPEERNAME output buffer is too small. Truncating");
|
WARN_LOG_FMT(IOS_NET, "IOCTL_SO_GETPEERNAME output buffer is too small. Truncating");
|
||||||
|
|
||||||
if (request.buffer_out_size > 0)
|
if (request.buffer_out_size > 0)
|
||||||
Memory::Write_U8(request.buffer_out_size, request.buffer_out);
|
Memory::Write_U8(request.buffer_out_size, request.buffer_out);
|
||||||
|
@ -554,7 +556,7 @@ IPCCommandResult NetIPTop::HandleGetPeerNameRequest(const IOCtlRequest& request)
|
||||||
std::min<size_t>(sizeof(sa.sa_data), request.buffer_out_size - 2));
|
std::min<size_t>(sizeof(sa.sa_data), request.buffer_out_size - 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_NET, "IOCTL_SO_GETPEERNAME(%x)", fd);
|
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_GETPEERNAME({:x})", fd);
|
||||||
return GetDefaultReply(ret);
|
return GetDefaultReply(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,40 +564,44 @@ IPCCommandResult NetIPTop::HandleGetHostIDRequest(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
const DefaultInterface interface = GetSystemDefaultInterfaceOrFallback();
|
const DefaultInterface interface = GetSystemDefaultInterfaceOrFallback();
|
||||||
const u32 host_ip = Common::swap32(interface.inet);
|
const u32 host_ip = Common::swap32(interface.inet);
|
||||||
INFO_LOG(IOS_NET, "IOCTL_SO_GETHOSTID = %u.%u.%u.%u", host_ip >> 24, (host_ip >> 16) & 0xFF,
|
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_GETHOSTID = {}.{}.{}.{}", host_ip >> 24, (host_ip >> 16) & 0xFF,
|
||||||
(host_ip >> 8) & 0xFF, host_ip & 0xFF);
|
(host_ip >> 8) & 0xFF, host_ip & 0xFF);
|
||||||
return GetDefaultReply(host_ip);
|
return GetDefaultReply(host_ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult NetIPTop::HandleInetAToNRequest(const IOCtlRequest& request)
|
IPCCommandResult NetIPTop::HandleInetAToNRequest(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
std::string hostname = Memory::GetString(request.buffer_in);
|
const std::string hostname = Memory::GetString(request.buffer_in);
|
||||||
struct hostent* remoteHost = gethostbyname(hostname.c_str());
|
struct hostent* remoteHost = gethostbyname(hostname.c_str());
|
||||||
|
|
||||||
if (remoteHost == nullptr || remoteHost->h_addr_list == nullptr ||
|
if (remoteHost == nullptr || remoteHost->h_addr_list == nullptr ||
|
||||||
remoteHost->h_addr_list[0] == nullptr)
|
remoteHost->h_addr_list[0] == nullptr)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_NET,
|
INFO_LOG_FMT(IOS_NET,
|
||||||
"IOCTL_SO_INETATON = -1 "
|
"IOCTL_SO_INETATON = -1 "
|
||||||
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: None",
|
"{}, BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {}), IP Found: None",
|
||||||
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
|
hostname, request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||||
request.buffer_out_size);
|
request.buffer_out_size);
|
||||||
|
|
||||||
return GetDefaultReply(0);
|
return GetDefaultReply(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory::Write_U32(Common::swap32(*(u32*)remoteHost->h_addr_list[0]), request.buffer_out);
|
const auto ip = Common::swap32(reinterpret_cast<u8*>(remoteHost->h_addr_list[0]));
|
||||||
INFO_LOG(IOS_NET,
|
Memory::Write_U32(ip, request.buffer_out);
|
||||||
"IOCTL_SO_INETATON = 0 "
|
|
||||||
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: %08X",
|
INFO_LOG_FMT(IOS_NET,
|
||||||
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
|
"IOCTL_SO_INETATON = 0 "
|
||||||
request.buffer_out_size, Common::swap32(*(u32*)remoteHost->h_addr_list[0]));
|
"{}, BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {}), IP Found: {:08X}",
|
||||||
|
hostname, request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||||
|
request.buffer_out_size, ip);
|
||||||
|
|
||||||
return GetDefaultReply(1);
|
return GetDefaultReply(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult NetIPTop::HandleInetPToNRequest(const IOCtlRequest& request)
|
IPCCommandResult NetIPTop::HandleInetPToNRequest(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
std::string address = Memory::GetString(request.buffer_in);
|
const std::string address = Memory::GetString(request.buffer_in);
|
||||||
INFO_LOG(IOS_NET, "IOCTL_SO_INETPTON (Translating: %s)", address.c_str());
|
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_INETPTON (Translating: {})", address);
|
||||||
return GetDefaultReply(inet_pton(address.c_str(), Memory::GetPointer(request.buffer_out + 4)));
|
return GetDefaultReply(inet_pton(address.c_str(), Memory::GetPointer(request.buffer_out + 4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,8 +616,8 @@ IPCCommandResult NetIPTop::HandleInetNToPRequest(const IOCtlRequest& request)
|
||||||
Memory::Read_U8(request.buffer_in + 8 + 1), Memory::Read_U8(request.buffer_in + 8 + 2),
|
Memory::Read_U8(request.buffer_in + 8 + 1), Memory::Read_U8(request.buffer_in + 8 + 2),
|
||||||
Memory::Read_U8(request.buffer_in + 8 + 3));
|
Memory::Read_U8(request.buffer_in + 8 + 3));
|
||||||
|
|
||||||
INFO_LOG(IOS_NET, "IOCTL_SO_INETNTOP %s", ip_s);
|
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_INETNTOP {}", ip_s);
|
||||||
Memory::CopyToEmu(request.buffer_out, (u8*)ip_s, strlen(ip_s));
|
Memory::CopyToEmu(request.buffer_out, reinterpret_cast<u8*>(ip_s), std::strlen(ip_s));
|
||||||
return GetDefaultReply(0);
|
return GetDefaultReply(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,7 +634,7 @@ IPCCommandResult NetIPTop::HandlePollRequest(const IOCtlRequest& request)
|
||||||
const u32 nfds = request.buffer_out_size / 0xc;
|
const u32 nfds = request.buffer_out_size / 0xc;
|
||||||
if (nfds == 0 || nfds > WII_SOCKET_FD_MAX)
|
if (nfds == 0 || nfds > WII_SOCKET_FD_MAX)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_NET, "IOCTL_SO_POLL failed: Invalid array size %d, ret=%d", nfds, -SO_EINVAL);
|
ERROR_LOG_FMT(IOS_NET, "IOCTL_SO_POLL failed: Invalid array size {}, ret={}", nfds, -SO_EINVAL);
|
||||||
return GetDefaultReply(-SO_EINVAL);
|
return GetDefaultReply(-SO_EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,11 +649,11 @@ IPCCommandResult NetIPTop::HandlePollRequest(const IOCtlRequest& request)
|
||||||
|
|
||||||
// Translate Wii to native events
|
// Translate Wii to native events
|
||||||
ufds[i].events = WiiSockMan::ConvertEvents(events, WiiSockMan::ConvertDirection::WiiToNative);
|
ufds[i].events = WiiSockMan::ConvertEvents(events, WiiSockMan::ConvertDirection::WiiToNative);
|
||||||
DEBUG_LOG(IOS_NET,
|
DEBUG_LOG_FMT(IOS_NET,
|
||||||
"IOCTL_SO_POLL(%d) "
|
"IOCTL_SO_POLL({}) "
|
||||||
"Sock: %08x, Events: %08x, "
|
"Sock: {:08x}, Events: {:08x}, "
|
||||||
"NativeEvents: %08x",
|
"NativeEvents: {:08x}",
|
||||||
i, wii_fd, events, ufds[i].events);
|
i, wii_fd, events, ufds[i].events);
|
||||||
|
|
||||||
// Do not pass return-only events to the native poll
|
// Do not pass return-only events to the native poll
|
||||||
ufds[i].events &= ~(POLLERR | POLLHUP | POLLNVAL | UNSUPPORTED_WSAPOLL);
|
ufds[i].events &= ~(POLLERR | POLLHUP | POLLNVAL | UNSUPPORTED_WSAPOLL);
|
||||||
|
@ -662,25 +668,25 @@ IPCCommandResult NetIPTop::HandleGetHostByNameRequest(const IOCtlRequest& reques
|
||||||
{
|
{
|
||||||
if (request.buffer_out_size != 0x460)
|
if (request.buffer_out_size != 0x460)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_NET, "Bad buffer size for IOCTL_SO_GETHOSTBYNAME");
|
ERROR_LOG_FMT(IOS_NET, "Bad buffer size for IOCTL_SO_GETHOSTBYNAME");
|
||||||
return GetDefaultReply(-1);
|
return GetDefaultReply(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string hostname = Memory::GetString(request.buffer_in);
|
const std::string hostname = Memory::GetString(request.buffer_in);
|
||||||
hostent* remoteHost = gethostbyname(hostname.c_str());
|
hostent* remoteHost = gethostbyname(hostname.c_str());
|
||||||
|
|
||||||
INFO_LOG(IOS_NET,
|
INFO_LOG_FMT(IOS_NET,
|
||||||
"IOCTL_SO_GETHOSTBYNAME "
|
"IOCTL_SO_GETHOSTBYNAME "
|
||||||
"Address: %s, BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
"Address: {}, BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {})",
|
||||||
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
|
hostname, request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||||
request.buffer_out_size);
|
request.buffer_out_size);
|
||||||
|
|
||||||
if (remoteHost == nullptr)
|
if (remoteHost == nullptr)
|
||||||
return GetDefaultReply(-1);
|
return GetDefaultReply(-1);
|
||||||
|
|
||||||
for (int i = 0; remoteHost->h_aliases[i]; ++i)
|
for (int i = 0; remoteHost->h_aliases[i]; ++i)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_NET, "alias%i:%s", i, remoteHost->h_aliases[i]);
|
DEBUG_LOG_FMT(IOS_NET, "alias{}:{}", i, remoteHost->h_aliases[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; remoteHost->h_addr_list[i]; ++i)
|
for (int i = 0; remoteHost->h_addr_list[i]; ++i)
|
||||||
|
@ -688,17 +694,17 @@ IPCCommandResult NetIPTop::HandleGetHostByNameRequest(const IOCtlRequest& reques
|
||||||
const u32 ip = Common::swap32(*(u32*)(remoteHost->h_addr_list[i]));
|
const u32 ip = Common::swap32(*(u32*)(remoteHost->h_addr_list[i]));
|
||||||
const std::string ip_s =
|
const std::string ip_s =
|
||||||
fmt::format("{}.{}.{}.{}", ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
|
fmt::format("{}.{}.{}.{}", ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
|
||||||
DEBUG_LOG(IOS_NET, "addr%i:%s", i, ip_s.c_str());
|
DEBUG_LOG_FMT(IOS_NET, "addr{}:{}", i, ip_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Host name; located immediately after struct
|
// Host name; located immediately after struct
|
||||||
static const u32 GETHOSTBYNAME_STRUCT_SIZE = 0x10;
|
static constexpr u32 GETHOSTBYNAME_STRUCT_SIZE = 0x10;
|
||||||
static const u32 GETHOSTBYNAME_IP_LIST_OFFSET = 0x110;
|
static constexpr u32 GETHOSTBYNAME_IP_LIST_OFFSET = 0x110;
|
||||||
// Limit host name length to avoid buffer overflow.
|
// Limit host name length to avoid buffer overflow.
|
||||||
u32 name_length = (u32)strlen(remoteHost->h_name) + 1;
|
const auto name_length = static_cast<u32>(strlen(remoteHost->h_name)) + 1;
|
||||||
if (name_length > (GETHOSTBYNAME_IP_LIST_OFFSET - GETHOSTBYNAME_STRUCT_SIZE))
|
if (name_length > (GETHOSTBYNAME_IP_LIST_OFFSET - GETHOSTBYNAME_STRUCT_SIZE))
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_NET, "Hostname too long in IOCTL_SO_GETHOSTBYNAME");
|
ERROR_LOG_FMT(IOS_NET, "Hostname too long in IOCTL_SO_GETHOSTBYNAME");
|
||||||
return GetDefaultReply(-1);
|
return GetDefaultReply(-1);
|
||||||
}
|
}
|
||||||
Memory::CopyToEmu(request.buffer_out + GETHOSTBYNAME_STRUCT_SIZE, remoteHost->h_name,
|
Memory::CopyToEmu(request.buffer_out + GETHOSTBYNAME_STRUCT_SIZE, remoteHost->h_name,
|
||||||
|
@ -746,7 +752,7 @@ IPCCommandResult NetIPTop::HandleGetHostByNameRequest(const IOCtlRequest& reques
|
||||||
|
|
||||||
IPCCommandResult NetIPTop::HandleICMPCancelRequest(const IOCtlRequest& request)
|
IPCCommandResult NetIPTop::HandleICMPCancelRequest(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_NET, "IOCTL_SO_ICMPCANCEL");
|
ERROR_LOG_FMT(IOS_NET, "IOCTL_SO_ICMPCANCEL");
|
||||||
return GetDefaultReply(0);
|
return GetDefaultReply(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,7 +766,7 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
||||||
|
|
||||||
if (param != 0xfffe)
|
if (param != 0xfffe)
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_NET, "GetInterfaceOpt: received invalid request with param0=%08x", param);
|
WARN_LOG_FMT(IOS_NET, "GetInterfaceOpt: received invalid request with param0={:08x}", param);
|
||||||
return GetDefaultReply(SO_ERROR_INVALID_REQUEST);
|
return GetDefaultReply(SO_ERROR_INVALID_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,13 +775,13 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
||||||
param5 = Memory::Read_U32(request.io_vectors[0].address + 4);
|
param5 = Memory::Read_U32(request.io_vectors[0].address + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_NET,
|
INFO_LOG_FMT(IOS_NET,
|
||||||
"IOCTLV_SO_GETINTERFACEOPT(%08X, %08X, %X, %X, %X) "
|
"IOCTLV_SO_GETINTERFACEOPT({:08X}, {:08X}, {:X}, {:X}, {:X}) "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i) ",
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}) ",
|
||||||
param, param2, param3, param4, param5, request.in_vectors[0].address,
|
param, param2, param3, param4, param5, request.in_vectors[0].address,
|
||||||
request.in_vectors[0].size,
|
request.in_vectors[0].size,
|
||||||
request.in_vectors.size() > 1 ? request.in_vectors[1].address : 0,
|
request.in_vectors.size() > 1 ? request.in_vectors[1].address : 0,
|
||||||
request.in_vectors.size() > 1 ? request.in_vectors[1].size : 0);
|
request.in_vectors.size() > 1 ? request.in_vectors[1].size : 0);
|
||||||
|
|
||||||
switch (param2)
|
switch (param2)
|
||||||
{
|
{
|
||||||
|
@ -824,14 +830,13 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
||||||
if (AdapterList->IfIndex == dwBestIfIndex && AdapterList->FirstDnsServerAddress &&
|
if (AdapterList->IfIndex == dwBestIfIndex && AdapterList->FirstDnsServerAddress &&
|
||||||
AdapterList->OperStatus == IfOperStatusUp)
|
AdapterList->OperStatus == IfOperStatusUp)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_NET, "Name of valid interface: %S", AdapterList->FriendlyName);
|
INFO_LOG_FMT(IOS_NET, "Name of valid interface: {}",
|
||||||
INFO_LOG(
|
WStringToUTF8(AdapterList->FriendlyName));
|
||||||
IOS_NET, "DNS: %u.%u.%u.%u",
|
INFO_LOG_FMT(IOS_NET, "DNS: {}.{}.{}.{}",
|
||||||
(unsigned char)AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2],
|
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2]),
|
||||||
(unsigned char)AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[3],
|
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[3]),
|
||||||
(unsigned char)AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[4],
|
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[4]),
|
||||||
(unsigned char)
|
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[5]));
|
||||||
AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[5]);
|
|
||||||
address = Common::swap32(
|
address = Common::swap32(
|
||||||
*(u32*)(&AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2]));
|
*(u32*)(&AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2]));
|
||||||
break;
|
break;
|
||||||
|
@ -851,14 +856,14 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
||||||
if (res_init() == 0)
|
if (res_init() == 0)
|
||||||
address = ntohl(_res.nsaddr_list[0].sin_addr.s_addr);
|
address = ntohl(_res.nsaddr_list[0].sin_addr.s_addr);
|
||||||
else
|
else
|
||||||
WARN_LOG(IOS_NET, "Call to res_init failed");
|
WARN_LOG_FMT(IOS_NET, "Call to res_init failed");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (address == 0)
|
if (address == 0)
|
||||||
address = default_main_dns_resolver;
|
address = default_main_dns_resolver;
|
||||||
|
|
||||||
INFO_LOG(IOS_NET, "Primary DNS: %X", address);
|
INFO_LOG_FMT(IOS_NET, "Primary DNS: {:X}", address);
|
||||||
INFO_LOG(IOS_NET, "Secondary DNS: %X", default_backup_dns_resolver);
|
INFO_LOG_FMT(IOS_NET, "Secondary DNS: {:X}", default_backup_dns_resolver);
|
||||||
|
|
||||||
Memory::Write_U32(address, request.io_vectors[0].address);
|
Memory::Write_U32(address, request.io_vectors[0].address);
|
||||||
Memory::Write_U32(default_backup_dns_resolver, request.io_vectors[0].address + 4);
|
Memory::Write_U32(default_backup_dns_resolver, request.io_vectors[0].address + 4);
|
||||||
|
@ -920,7 +925,7 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(IOS_NET, "Unknown param2: %08X", param2);
|
ERROR_LOG_FMT(IOS_NET, "Unknown param2: {:08X}", param2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,13 +1047,13 @@ IPCCommandResult NetIPTop::HandleICMPPingRequest(const IOCtlVRequest& request)
|
||||||
u32 ip;
|
u32 ip;
|
||||||
} ip_info;
|
} ip_info;
|
||||||
|
|
||||||
u32 fd = Memory::Read_U32(request.in_vectors[0].address);
|
const u32 fd = Memory::Read_U32(request.in_vectors[0].address);
|
||||||
u32 num_ip = Memory::Read_U32(request.in_vectors[0].address + 4);
|
const u32 num_ip = Memory::Read_U32(request.in_vectors[0].address + 4);
|
||||||
u64 timeout = Memory::Read_U64(request.in_vectors[0].address + 8);
|
const u64 timeout = Memory::Read_U64(request.in_vectors[0].address + 8);
|
||||||
|
|
||||||
if (num_ip != 1)
|
if (num_ip != 1)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_NET, "IOCTLV_SO_ICMPPING %i IPs", num_ip);
|
INFO_LOG_FMT(IOS_NET, "IOCTLV_SO_ICMPPING {} IPs", num_ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
ip_info.length = Memory::Read_U8(request.in_vectors[0].address + 16);
|
ip_info.length = Memory::Read_U8(request.in_vectors[0].address + 16);
|
||||||
|
@ -1058,13 +1063,13 @@ IPCCommandResult NetIPTop::HandleICMPPingRequest(const IOCtlVRequest& request)
|
||||||
|
|
||||||
if (ip_info.length != 8 || ip_info.addr_family != AF_INET)
|
if (ip_info.length != 8 || ip_info.addr_family != AF_INET)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_NET,
|
INFO_LOG_FMT(IOS_NET,
|
||||||
"IOCTLV_SO_ICMPPING strange IPInfo:\n"
|
"IOCTLV_SO_ICMPPING strange IPInfo:\n"
|
||||||
"length %x addr_family %x",
|
"length {:x} addr_family {:x}",
|
||||||
ip_info.length, ip_info.addr_family);
|
ip_info.length, ip_info.addr_family);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_NET, "IOCTLV_SO_ICMPPING %x", ip_info.ip);
|
INFO_LOG_FMT(IOS_NET, "IOCTLV_SO_ICMPPING {:x}", ip_info.ip);
|
||||||
|
|
||||||
sockaddr_in addr;
|
sockaddr_in addr;
|
||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
|
|
|
@ -30,7 +30,7 @@ void NWC24Config::ReadConfig()
|
||||||
{
|
{
|
||||||
const s32 config_error = CheckNwc24Config();
|
const s32 config_error = CheckNwc24Config();
|
||||||
if (config_error)
|
if (config_error)
|
||||||
ERROR_LOG(IOS_WC24, "There is an error in the config for for WC24: %d", config_error);
|
ERROR_LOG_FMT(IOS_WC24, "There is an error in the config for for WC24: {}", config_error);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ void NWC24Config::WriteConfig() const
|
||||||
m_fs->CreateFullPath(PID_KD, PID_KD, CONFIG_PATH, 0, public_modes);
|
m_fs->CreateFullPath(PID_KD, PID_KD, CONFIG_PATH, 0, public_modes);
|
||||||
const auto file = m_fs->CreateAndOpenFile(PID_KD, PID_KD, CONFIG_PATH, public_modes);
|
const auto file = m_fs->CreateAndOpenFile(PID_KD, PID_KD, CONFIG_PATH, public_modes);
|
||||||
if (!file || !file->Write(&m_data, 1))
|
if (!file || !file->Write(&m_data, 1))
|
||||||
ERROR_LOG(IOS_WC24, "Failed to open or write WC24 config file");
|
ERROR_LOG_FMT(IOS_WC24, "Failed to open or write WC24 config file");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NWC24Config::ResetConfig()
|
void NWC24Config::ResetConfig()
|
||||||
|
@ -93,21 +93,21 @@ s32 NWC24Config::CheckNwc24Config() const
|
||||||
// 'WcCf' magic
|
// 'WcCf' magic
|
||||||
if (Magic() != 0x57634366)
|
if (Magic() != 0x57634366)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WC24, "Magic mismatch");
|
ERROR_LOG_FMT(IOS_WC24, "Magic mismatch");
|
||||||
return -14;
|
return -14;
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 checksum = CalculateNwc24ConfigChecksum();
|
const u32 checksum = CalculateNwc24ConfigChecksum();
|
||||||
DEBUG_LOG(IOS_WC24, "Checksum: %X", checksum);
|
DEBUG_LOG_FMT(IOS_WC24, "Checksum: {:X}", checksum);
|
||||||
if (Checksum() != checksum)
|
if (Checksum() != checksum)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WC24, "Checksum mismatch expected %X and got %X", checksum, Checksum());
|
ERROR_LOG_FMT(IOS_WC24, "Checksum mismatch expected {:X} and got {:X}", checksum, Checksum());
|
||||||
return -14;
|
return -14;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IdGen() > 0x1F)
|
if (IdGen() > 0x1F)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WC24, "Id gen error");
|
ERROR_LOG_FMT(IOS_WC24, "Id gen error");
|
||||||
return -14;
|
return -14;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,16 +39,16 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
case IOCTL_NWC24_SUSPEND_SCHEDULAR:
|
case IOCTL_NWC24_SUSPEND_SCHEDULAR:
|
||||||
// NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes)
|
// NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes)
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI");
|
||||||
WriteReturnValue(0, request.buffer_out); // no error
|
WriteReturnValue(0, request.buffer_out); // no error
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib
|
case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NWC24_EXEC_RESUME_SCHEDULAR: // NWC24iResumeForCloseLib
|
case IOCTL_NWC24_EXEC_RESUME_SCHEDULAR: // NWC24iResumeForCloseLib
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI");
|
||||||
WriteReturnValue(0, request.buffer_out); // no error
|
WriteReturnValue(0, request.buffer_out); // no error
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -56,30 +56,30 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
||||||
WriteReturnValue(0, request.buffer_out);
|
WriteReturnValue(0, request.buffer_out);
|
||||||
Memory::Write_U32(0, request.buffer_out + 4);
|
Memory::Write_U32(0, request.buffer_out + 4);
|
||||||
return_value = 0;
|
return_value = 0;
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NWC24_CLEANUP_SOCKET:
|
case IOCTL_NWC24_CLEANUP_SOCKET:
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET");
|
||||||
WiiSockMan::GetInstance().Clean();
|
WiiSockMan::GetInstance().Clean();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu
|
case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NWC24_UNLOCK_SOCKET:
|
case IOCTL_NWC24_UNLOCK_SOCKET:
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NWC24_REQUEST_REGISTER_USER_ID:
|
case IOCTL_NWC24_REQUEST_REGISTER_USER_ID:
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_REGISTER_USER_ID");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_REGISTER_USER_ID");
|
||||||
WriteReturnValue(0, request.buffer_out);
|
WriteReturnValue(0, request.buffer_out);
|
||||||
Memory::Write_U32(0, request.buffer_out + 4);
|
Memory::Write_U32(0, request.buffer_out + 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes)
|
case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes)
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID");
|
||||||
if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_INITIAL)
|
if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_INITIAL)
|
||||||
{
|
{
|
||||||
const std::string settings_file_path =
|
const std::string settings_file_path =
|
||||||
|
@ -133,11 +133,11 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NWC24_GET_SCHEDULAR_STAT:
|
case IOCTL_NWC24_GET_SCHEDULAR_STAT:
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NWC24_SAVE_MAIL_NOW:
|
case IOCTL_NWC24_SAVE_MAIL_NOW:
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NWC24_REQUEST_SHUTDOWN:
|
case IOCTL_NWC24_REQUEST_SHUTDOWN:
|
||||||
|
@ -146,11 +146,11 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
||||||
request.buffer_out == 0 || request.buffer_out % 4 != 0 || request.buffer_out_size < 4)
|
request.buffer_out == 0 || request.buffer_out % 4 != 0 || request.buffer_out_size < 4)
|
||||||
{
|
{
|
||||||
return_value = IPC_EINVAL;
|
return_value = IPC_EINVAL;
|
||||||
ERROR_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN = IPC_EINVAL");
|
ERROR_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN = IPC_EINVAL");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN");
|
INFO_LOG_FMT(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN");
|
||||||
[[maybe_unused]] const u32 event = Memory::Read_U32(request.buffer_in);
|
[[maybe_unused]] const u32 event = Memory::Read_U32(request.buffer_in);
|
||||||
// TODO: Advertise shutdown event
|
// TODO: Advertise shutdown event
|
||||||
// TODO: Shutdown USB keyboard LEDs if event == 3
|
// TODO: Shutdown USB keyboard LEDs if event == 3
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "Core/IOS/Network/KD/NetKDTime.h"
|
#include "Core/IOS/Network/KD/NetKDTime.h"
|
||||||
|
|
||||||
#include <cinttypes>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
@ -32,7 +31,7 @@ IPCCommandResult NetKDTime::IOCtl(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
const u64 adjusted_utc = GetAdjustedUTC();
|
const u64 adjusted_utc = GetAdjustedUTC();
|
||||||
Memory::Write_U64(adjusted_utc, request.buffer_out + 4);
|
Memory::Write_U64(adjusted_utc, request.buffer_out + 4);
|
||||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_GET_UNIVERSAL_TIME = %d, time = %" PRIu64, result, adjusted_utc);
|
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_GET_UNIVERSAL_TIME = {}, time = {}", result, adjusted_utc);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -41,29 +40,28 @@ IPCCommandResult NetKDTime::IOCtl(const IOCtlRequest& request)
|
||||||
const u64 adjusted_utc = Memory::Read_U64(request.buffer_in);
|
const u64 adjusted_utc = Memory::Read_U64(request.buffer_in);
|
||||||
SetAdjustedUTC(adjusted_utc);
|
SetAdjustedUTC(adjusted_utc);
|
||||||
update_misc = Memory::Read_U32(request.buffer_in + 8);
|
update_misc = Memory::Read_U32(request.buffer_in + 8);
|
||||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_SET_UNIVERSAL_TIME (%" PRIu64 ", %u) = %d", adjusted_utc,
|
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_SET_UNIVERSAL_TIME ({}, {}) = {}", adjusted_utc, update_misc,
|
||||||
update_misc, result);
|
result);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NW24_SET_RTC_COUNTER:
|
case IOCTL_NW24_SET_RTC_COUNTER:
|
||||||
rtc = Memory::Read_U32(request.buffer_in);
|
rtc = Memory::Read_U32(request.buffer_in);
|
||||||
update_misc = Memory::Read_U32(request.buffer_in + 4);
|
update_misc = Memory::Read_U32(request.buffer_in + 4);
|
||||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_SET_RTC_COUNTER (%" PRIu64 ", %u) = %d", rtc, update_misc,
|
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_SET_RTC_COUNTER ({}, {}) = {}", rtc, update_misc, result);
|
||||||
result);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NW24_GET_TIME_DIFF:
|
case IOCTL_NW24_GET_TIME_DIFF:
|
||||||
{
|
{
|
||||||
const u64 time_diff = GetAdjustedUTC() - rtc;
|
const u64 time_diff = GetAdjustedUTC() - rtc;
|
||||||
Memory::Write_U64(time_diff, request.buffer_out + 4);
|
Memory::Write_U64(time_diff, request.buffer_out + 4);
|
||||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_GET_TIME_DIFF = %d, time_diff = %" PRIu64, result, time_diff);
|
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_GET_TIME_DIFF = {}, time_diff = {}", result, time_diff);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_NW24_UNIMPLEMENTED:
|
case IOCTL_NW24_UNIMPLEMENTED:
|
||||||
result = -9;
|
result = -9;
|
||||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_UNIMPLEMENTED = %d", result);
|
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_UNIMPLEMENTED = {}", result);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -39,14 +39,14 @@ Common::MACAddress GetMACAddress()
|
||||||
SaveMACAddress(mac.value());
|
SaveMACAddress(mac.value());
|
||||||
if (!wireless_mac.empty())
|
if (!wireless_mac.empty())
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_NET,
|
ERROR_LOG_FMT(IOS_NET,
|
||||||
"The MAC provided (%s) is invalid. We have "
|
"The MAC provided ({}) is invalid. We have "
|
||||||
"generated another one for you.",
|
"generated another one for you.",
|
||||||
Common::MacAddressToString(mac.value()).c_str());
|
Common::MacAddressToString(mac.value()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_NET, "Using MAC address: %s", Common::MacAddressToString(mac.value()).c_str());
|
INFO_LOG_FMT(IOS_NET, "Using MAC address: {}", Common::MacAddressToString(mac.value()));
|
||||||
return mac.value();
|
return mac.value();
|
||||||
}
|
}
|
||||||
} // namespace IOS::Net
|
} // namespace IOS::Net
|
||||||
|
|
|
@ -36,37 +36,37 @@ IPCCommandResult NetNCDManage::IOCtlV(const IOCtlVRequest& request)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTLV_NCD_GETCONFIG:
|
case IOCTLV_NCD_GETCONFIG:
|
||||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETCONFIG");
|
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETCONFIG");
|
||||||
config.WriteToMem(request.io_vectors.at(0).address);
|
config.WriteToMem(request.io_vectors.at(0).address);
|
||||||
common_vector = 1;
|
common_vector = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTLV_NCD_SETCONFIG:
|
case IOCTLV_NCD_SETCONFIG:
|
||||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_SETCONFIG");
|
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_SETCONFIG");
|
||||||
config.ReadFromMem(request.in_vectors.at(0).address);
|
config.ReadFromMem(request.in_vectors.at(0).address);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTLV_NCD_READCONFIG:
|
case IOCTLV_NCD_READCONFIG:
|
||||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_READCONFIG");
|
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_READCONFIG");
|
||||||
config.ReadConfig(m_ios.GetFS().get());
|
config.ReadConfig(m_ios.GetFS().get());
|
||||||
config.WriteToMem(request.io_vectors.at(0).address);
|
config.WriteToMem(request.io_vectors.at(0).address);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTLV_NCD_WRITECONFIG:
|
case IOCTLV_NCD_WRITECONFIG:
|
||||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_WRITECONFIG");
|
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_WRITECONFIG");
|
||||||
config.ReadFromMem(request.in_vectors.at(0).address);
|
config.ReadFromMem(request.in_vectors.at(0).address);
|
||||||
config.WriteConfig(m_ios.GetFS().get());
|
config.WriteConfig(m_ios.GetFS().get());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTLV_NCD_GETLINKSTATUS:
|
case IOCTLV_NCD_GETLINKSTATUS:
|
||||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETLINKSTATUS");
|
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETLINKSTATUS");
|
||||||
// Always connected
|
// Always connected
|
||||||
Memory::Write_U32(Net::ConnectionSettings::LINK_WIRED, request.io_vectors.at(0).address + 4);
|
Memory::Write_U32(Net::ConnectionSettings::LINK_WIRED, request.io_vectors.at(0).address + 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTLV_NCD_GETWIRELESSMACADDRESS:
|
case IOCTLV_NCD_GETWIRELESSMACADDRESS:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETWIRELESSMACADDRESS");
|
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETWIRELESSMACADDRESS");
|
||||||
|
|
||||||
const Common::MACAddress address = IOS::Net::GetMACAddress();
|
const Common::MACAddress address = IOS::Net::GetMACAddress();
|
||||||
Memory::CopyToEmu(request.io_vectors.at(1).address, address.data(), address.size());
|
Memory::CopyToEmu(request.io_vectors.at(1).address, address.data(), address.size());
|
||||||
|
@ -74,7 +74,7 @@ IPCCommandResult NetNCDManage::IOCtlV(const IOCtlVRequest& request)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
INFO_LOG(IOS_NET, "NET_NCD_MANAGE IOCtlV: %#x", request.request);
|
INFO_LOG_FMT(IOS_NET, "NET_NCD_MANAGE IOCtlV: {:#x}", request.request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ void WiiNetConfig::WriteConfig(FS::FileSystem* fs) const
|
||||||
fs->CreateFullPath(PID_NCD, PID_NCD, CONFIG_PATH, 0, public_modes);
|
fs->CreateFullPath(PID_NCD, PID_NCD, CONFIG_PATH, 0, public_modes);
|
||||||
const auto file = fs->CreateAndOpenFile(PID_NCD, PID_NCD, CONFIG_PATH, public_modes);
|
const auto file = fs->CreateAndOpenFile(PID_NCD, PID_NCD, CONFIG_PATH, public_modes);
|
||||||
if (!file || !file->Write(&m_data, 1))
|
if (!file || !file->Write(&m_data, 1))
|
||||||
ERROR_LOG(IOS_NET, "Failed to write config");
|
ERROR_LOG_FMT(IOS_NET, "Failed to write config");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiiNetConfig::ResetConfig(FS::FileSystem* fs)
|
void WiiNetConfig::ResetConfig(FS::FileSystem* fs)
|
||||||
|
|
|
@ -106,13 +106,13 @@ static std::vector<u8> ReadCertFile(const std::string& path, const std::array<u8
|
||||||
std::vector<u8> bytes(file.GetSize());
|
std::vector<u8> bytes(file.GetSize());
|
||||||
if (!file.ReadBytes(bytes.data(), bytes.size()))
|
if (!file.ReadBytes(bytes.data(), bytes.size()))
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_SSL, "Failed to read %s", path.c_str());
|
ERROR_LOG_FMT(IOS_SSL, "Failed to read {}", path);
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
PanicAlertT("IOS: Could not read a file required for SSL services (%s). Please refer to "
|
PanicAlertFmtT("IOS: Could not read a file required for SSL services ({0}). Please refer to "
|
||||||
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
||||||
"instructions on setting up Wii networking.",
|
"instructions on setting up Wii networking.",
|
||||||
path.c_str());
|
path);
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -121,13 +121,13 @@ static std::vector<u8> ReadCertFile(const std::string& path, const std::array<u8
|
||||||
mbedtls_sha256_ret(bytes.data(), bytes.size(), hash.data(), 0);
|
mbedtls_sha256_ret(bytes.data(), bytes.size(), hash.data(), 0);
|
||||||
if (hash != correct_hash)
|
if (hash != correct_hash)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_SSL, "Wrong hash for %s", path.c_str());
|
ERROR_LOG_FMT(IOS_SSL, "Wrong hash for {}", path);
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
PanicAlertT("IOS: A file required for SSL services (%s) is invalid. Please refer to "
|
PanicAlertFmtT("IOS: A file required for SSL services ({0}) is invalid. Please refer to "
|
||||||
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
||||||
"instructions on setting up Wii networking.",
|
"instructions on setting up Wii networking.",
|
||||||
path.c_str());
|
path);
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -234,14 +234,14 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
WriteReturnValue(SSL_ERR_FAILED, BufferIn);
|
WriteReturnValue(SSL_ERR_FAILED, BufferIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_NEW (%d, %s) "
|
"IOCTLV_NET_SSL_NEW ({}, {}) "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
verifyOption, hostname.c_str(), BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
verifyOption, hostname, BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||||
BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2,
|
BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2,
|
||||||
BufferOut3, BufferOutSize3);
|
BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_SHUTDOWN:
|
case IOCTLV_NET_SSL_SHUTDOWN:
|
||||||
|
@ -272,24 +272,24 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_SHUTDOWN "
|
"IOCTLV_NET_SSL_SHUTDOWN "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_SETROOTCA:
|
case IOCTLV_NET_SSL_SETROOTCA:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_SETROOTCA "
|
"IOCTLV_NET_SSL_SETROOTCA "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
|
|
||||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||||
if (IsSSLIDValid(sslID))
|
if (IsSSLIDValid(sslID))
|
||||||
|
@ -314,7 +314,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
WriteReturnValue(SSL_OK, BufferIn);
|
WriteReturnValue(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret);
|
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCA = {}", ret);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -324,13 +324,13 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_SETBUILTINCLIENTCERT:
|
case IOCTLV_NET_SSL_SETBUILTINCLIENTCERT:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
|
"IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
|
|
||||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||||
if (IsSSLIDValid(sslID))
|
if (IsSSLIDValid(sslID))
|
||||||
|
@ -360,24 +360,24 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
WriteReturnValue(SSL_OK, BufferIn);
|
WriteReturnValue(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, pk_ret);
|
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = ({}, {})", ret, pk_ret);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID);
|
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = {}", sslID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_REMOVECLIENTCERT:
|
case IOCTLV_NET_SSL_REMOVECLIENTCERT:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_REMOVECLIENTCERT "
|
"IOCTLV_NET_SSL_REMOVECLIENTCERT "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
|
|
||||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||||
if (IsSSLIDValid(sslID))
|
if (IsSSLIDValid(sslID))
|
||||||
|
@ -392,7 +392,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID);
|
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = {}", sslID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -419,19 +419,19 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr);
|
mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr);
|
||||||
WriteReturnValue(SSL_OK, BufferIn);
|
WriteReturnValue(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret);
|
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = {}", ret);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_SETBUILTINROOTCA "
|
"IOCTLV_NET_SSL_SETBUILTINROOTCA "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_CONNECT:
|
case IOCTLV_NET_SSL_CONNECT:
|
||||||
|
@ -444,7 +444,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
ssl->sockfd = Memory::Read_U32(BufferOut2);
|
ssl->sockfd = Memory::Read_U32(BufferOut2);
|
||||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||||
ssl->hostfd = sm.GetHostSocket(ssl->sockfd);
|
ssl->hostfd = sm.GetHostSocket(ssl->sockfd);
|
||||||
INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", ssl->sockfd);
|
INFO_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_CONNECT socket = {}", ssl->sockfd);
|
||||||
mbedtls_ssl_set_bio(&ssl->ctx, &ssl->hostfd, mbedtls_net_send, mbedtls_net_recv, nullptr);
|
mbedtls_ssl_set_bio(&ssl->ctx, &ssl->hostfd, mbedtls_net_send, mbedtls_net_recv, nullptr);
|
||||||
WriteReturnValue(SSL_OK, BufferIn);
|
WriteReturnValue(SSL_OK, BufferIn);
|
||||||
}
|
}
|
||||||
|
@ -452,13 +452,13 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_CONNECT "
|
"IOCTLV_NET_SSL_CONNECT "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
||||||
|
@ -478,7 +478,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_WRITE:
|
case IOCTLV_NET_SSL_WRITE:
|
||||||
{
|
{
|
||||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
const int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||||
if (IsSSLIDValid(sslID))
|
if (IsSSLIDValid(sslID))
|
||||||
{
|
{
|
||||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||||
|
@ -489,14 +489,14 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_WRITE "
|
"IOCTLV_NET_SSL_WRITE "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
INFO_LOG(IOS_SSL, "%s", Memory::GetString(BufferOut2).c_str());
|
INFO_LOG_FMT(IOS_SSL, "{}", Memory::GetString(BufferOut2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_READ:
|
case IOCTLV_NET_SSL_READ:
|
||||||
|
@ -514,13 +514,13 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_READ(%d)"
|
"IOCTLV_NET_SSL_READ({})"
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_SETROOTCADEFAULT:
|
case IOCTLV_NET_SSL_SETROOTCADEFAULT:
|
||||||
|
@ -534,24 +534,24 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||||
}
|
}
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_SETROOTCADEFAULT "
|
"IOCTLV_NET_SSL_SETROOTCADEFAULT "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT:
|
case IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
|
"IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||||
|
|
||||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||||
if (IsSSLIDValid(sslID))
|
if (IsSSLIDValid(sslID))
|
||||||
|
|
|
@ -63,7 +63,7 @@ static s32 TranslateErrorCode(s32 native_error, bool is_rw)
|
||||||
switch (native_error)
|
switch (native_error)
|
||||||
{
|
{
|
||||||
case ERRORCODE(EMSGSIZE):
|
case ERRORCODE(EMSGSIZE):
|
||||||
ERROR_LOG(IOS_NET, "Find out why this happened, looks like PEEK failure?");
|
ERROR_LOG_FMT(IOS_NET, "Find out why this happened, looks like PEEK failure?");
|
||||||
return -1; // Should be -SO_EMSGSIZE
|
return -1; // Should be -SO_EMSGSIZE
|
||||||
case EITHER(WSAENOTSOCK, EBADF):
|
case EITHER(WSAENOTSOCK, EBADF):
|
||||||
return -SO_EBADF;
|
return -SO_EBADF;
|
||||||
|
@ -100,12 +100,12 @@ static s32 TranslateErrorCode(s32 native_error, bool is_rw)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't use string! (see https://github.com/dolphin-emu/dolphin/pull/3143)
|
// Don't use string! (see https://github.com/dolphin-emu/dolphin/pull/3143)
|
||||||
s32 WiiSockMan::GetNetErrorCode(s32 ret, const char* caller, bool isRW)
|
s32 WiiSockMan::GetNetErrorCode(s32 ret, std::string_view caller, bool is_rw)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
s32 errorCode = WSAGetLastError();
|
s32 error_code = WSAGetLastError();
|
||||||
#else
|
#else
|
||||||
s32 errorCode = errno;
|
s32 error_code = errno;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
|
@ -114,13 +114,13 @@ s32 WiiSockMan::GetNetErrorCode(s32 ret, const char* caller, bool isRW)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR_LOG(IOS_NET, "%s failed with error %d: %s, ret= %d", caller, errorCode,
|
ERROR_LOG_FMT(IOS_NET, "{} failed with error {}: {}, ret= {}", caller, error_code,
|
||||||
DecodeError(errorCode), ret);
|
DecodeError(error_code), ret);
|
||||||
|
|
||||||
s32 ReturnValue = TranslateErrorCode(errorCode, isRW);
|
const s32 return_value = TranslateErrorCode(error_code, is_rw);
|
||||||
WiiSockMan::GetInstance().SetLastNetError(ReturnValue);
|
WiiSockMan::GetInstance().SetLastNetError(return_value);
|
||||||
|
|
||||||
return ReturnValue;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
WiiSocket::~WiiSocket()
|
WiiSocket::~WiiSocket()
|
||||||
|
@ -248,10 +248,10 @@ s32 WiiSocket::FCntl(u32 cmd, u32 arg)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_NET, "SO_FCNTL unknown command");
|
ERROR_LOG_FMT(IOS_NET, "SO_FCNTL unknown command");
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_NET, "IOCTL_SO_FCNTL(%08x, %08X, %08X)", wii_fd, cmd, arg);
|
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_FCNTL({:08x}, {:08X}, {:08X})", wii_fd, cmd, arg);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -285,8 +285,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
int ret = bind(fd, (sockaddr*)&local_name, sizeof(local_name));
|
int ret = bind(fd, (sockaddr*)&local_name, sizeof(local_name));
|
||||||
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_BIND", false);
|
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_BIND", false);
|
||||||
|
|
||||||
INFO_LOG(IOS_NET, "IOCTL_SO_BIND (%08X, %s:%d) = %d", wii_fd,
|
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_BIND ({:08X}, {}:{}) = {}", wii_fd,
|
||||||
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTL_SO_CONNECT:
|
case IOCTL_SO_CONNECT:
|
||||||
|
@ -298,8 +298,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
int ret = connect(fd, (sockaddr*)&local_name, sizeof(local_name));
|
int ret = connect(fd, (sockaddr*)&local_name, sizeof(local_name));
|
||||||
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_CONNECT", false);
|
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_CONNECT", false);
|
||||||
|
|
||||||
INFO_LOG(IOS_NET, "IOCTL_SO_CONNECT (%08x, %s:%d) = %d", wii_fd,
|
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_CONNECT ({:08x}, {}:{}) = {}", wii_fd,
|
||||||
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTL_SO_ACCEPT:
|
case IOCTL_SO_ACCEPT:
|
||||||
|
@ -381,12 +381,12 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
||||||
{
|
{
|
||||||
mbedtls_ssl_context* ctx = &Device::NetSSL::_SSL[sslID].ctx;
|
mbedtls_ssl_context* ctx = &Device::NetSSL::_SSL[sslID].ctx;
|
||||||
int ret = mbedtls_ssl_handshake(ctx);
|
const int ret = mbedtls_ssl_handshake(ctx);
|
||||||
if (ret)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
char error_buffer[256] = "";
|
char error_buffer[256] = "";
|
||||||
mbedtls_strerror(ret, error_buffer, sizeof(error_buffer));
|
mbedtls_strerror(ret, error_buffer, sizeof(error_buffer));
|
||||||
ERROR_LOG(IOS_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE: %s", error_buffer);
|
ERROR_LOG_FMT(IOS_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE: {}", error_buffer);
|
||||||
}
|
}
|
||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
|
@ -408,8 +408,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
char error_buffer[256] = "";
|
char error_buffer[256] = "";
|
||||||
int res = mbedtls_ssl_get_verify_result(ctx);
|
int res = mbedtls_ssl_get_verify_result(ctx);
|
||||||
mbedtls_x509_crt_verify_info(error_buffer, sizeof(error_buffer), "", res);
|
mbedtls_x509_crt_verify_info(error_buffer, sizeof(error_buffer), "", res);
|
||||||
ERROR_LOG(IOS_SSL, "MBEDTLS_ERR_X509_CERT_VERIFY_FAILED (verify_result = %d): %s",
|
ERROR_LOG_FMT(IOS_SSL, "MBEDTLS_ERR_X509_CERT_VERIFY_FAILED (verify_result = {}): {}",
|
||||||
res, error_buffer);
|
res, error_buffer);
|
||||||
|
|
||||||
if (res & MBEDTLS_X509_BADCERT_CN_MISMATCH)
|
if (res & MBEDTLS_X509_BADCERT_CN_MISMATCH)
|
||||||
res = SSL_ERR_VCOMMONNAME;
|
res = SSL_ERR_VCOMMONNAME;
|
||||||
|
@ -447,12 +447,12 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_SSL,
|
INFO_LOG_FMT(IOS_SSL,
|
||||||
"IOCTLV_NET_SSL_DOHANDSHAKE = (%d) "
|
"IOCTLV_NET_SSL_DOHANDSHAKE = ({}) "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
|
"BufferOut: ({:08x}, {}), BufferOut2: ({:08x}, {})",
|
||||||
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
|
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2);
|
BufferOutSize, BufferOut2, BufferOutSize2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_NET_SSL_WRITE:
|
case IOCTLV_NET_SSL_WRITE:
|
||||||
|
@ -564,18 +564,19 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
WiiSockMan::Convert(*wii_name, local_name);
|
WiiSockMan::Convert(*wii_name, local_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = sendto(fd, data, BufferInSize, flags,
|
const int ret = sendto(fd, data, BufferInSize, flags,
|
||||||
has_destaddr ? (struct sockaddr*)&local_name : nullptr,
|
has_destaddr ? (struct sockaddr*)&local_name : nullptr,
|
||||||
has_destaddr ? sizeof(sockaddr) : 0);
|
has_destaddr ? sizeof(sockaddr) : 0);
|
||||||
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_SENDTO", true);
|
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_SENDTO", true);
|
||||||
|
|
||||||
INFO_LOG(IOS_NET,
|
INFO_LOG_FMT(IOS_NET,
|
||||||
"%s = %d Socket: %08x, BufferIn: (%08x, %i), BufferIn2: (%08x, %i), %u.%u.%u.%u",
|
"{} = {} Socket: {:08x}, BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
has_destaddr ? "IOCTLV_SO_SENDTO " : "IOCTLV_SO_SEND ", ReturnValue, wii_fd,
|
"{}.{}.{}.{}",
|
||||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
has_destaddr ? "IOCTLV_SO_SENDTO " : "IOCTLV_SO_SEND ", ReturnValue, wii_fd,
|
||||||
local_name.sin_addr.s_addr & 0xFF, (local_name.sin_addr.s_addr >> 8) & 0xFF,
|
BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||||
(local_name.sin_addr.s_addr >> 16) & 0xFF,
|
local_name.sin_addr.s_addr & 0xFF, (local_name.sin_addr.s_addr >> 8) & 0xFF,
|
||||||
(local_name.sin_addr.s_addr >> 24) & 0xFF);
|
(local_name.sin_addr.s_addr >> 16) & 0xFF,
|
||||||
|
(local_name.sin_addr.s_addr >> 24) & 0xFF);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IOCTLV_SO_RECVFROM:
|
case IOCTLV_SO_RECVFROM:
|
||||||
|
@ -609,19 +610,19 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
socklen_t addrlen = sizeof(sockaddr_in);
|
socklen_t addrlen = sizeof(sockaddr_in);
|
||||||
int ret = recvfrom(fd, data, data_len, flags,
|
const int ret = recvfrom(fd, data, data_len, flags,
|
||||||
BufferOutSize2 ? (struct sockaddr*)&local_name : nullptr,
|
BufferOutSize2 ? (struct sockaddr*)&local_name : nullptr,
|
||||||
BufferOutSize2 ? &addrlen : nullptr);
|
BufferOutSize2 ? &addrlen : nullptr);
|
||||||
ReturnValue =
|
ReturnValue =
|
||||||
WiiSockMan::GetNetErrorCode(ret, BufferOutSize2 ? "SO_RECVFROM" : "SO_RECV", true);
|
WiiSockMan::GetNetErrorCode(ret, BufferOutSize2 ? "SO_RECVFROM" : "SO_RECV", true);
|
||||||
|
|
||||||
INFO_LOG(IOS_NET,
|
INFO_LOG_FMT(IOS_NET,
|
||||||
"%s(%d, %p) Socket: %08X, Flags: %08X, "
|
"{}({}, {}) Socket: {:08X}, Flags: {:08X}, "
|
||||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||||
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
|
"BufferOut: ({:08x}, {}), BufferOut2: ({:08x}, {})",
|
||||||
BufferOutSize2 ? "IOCTLV_SO_RECVFROM " : "IOCTLV_SO_RECV ", ReturnValue, data,
|
BufferOutSize2 ? "IOCTLV_SO_RECVFROM " : "IOCTLV_SO_RECV ", ReturnValue,
|
||||||
wii_fd, flags, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
|
fmt::ptr(data), wii_fd, flags, BufferIn, BufferInSize, BufferIn2,
|
||||||
BufferOutSize, BufferOut2, BufferOutSize2);
|
BufferInSize2, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2);
|
||||||
|
|
||||||
if (BufferOutSize2 != 0)
|
if (BufferOutSize2 != 0)
|
||||||
{
|
{
|
||||||
|
@ -647,10 +648,10 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||||
ReturnValue != -SO_EALREADY) ||
|
ReturnValue != -SO_EALREADY) ||
|
||||||
(it->is_ssl && ReturnValue != SSL_ERR_WAGAIN && ReturnValue != SSL_ERR_RAGAIN))
|
(it->is_ssl && ReturnValue != SSL_ERR_WAGAIN && ReturnValue != SSL_ERR_RAGAIN))
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_NET,
|
DEBUG_LOG_FMT(
|
||||||
"IOCTL(V) Sock: %08x ioctl/v: %d returned: %d nonBlock: %d forceNonBlock: %d",
|
IOS_NET, "IOCTL(V) Sock: {:08x} ioctl/v: {} returned: {} nonBlock: {} forceNonBlock: {}",
|
||||||
wii_fd, it->is_ssl ? (int)it->ssl_type : (int)it->net_type, ReturnValue, nonBlock,
|
wii_fd, it->is_ssl ? static_cast<int>(it->ssl_type) : static_cast<int>(it->net_type),
|
||||||
forceNonBlock);
|
ReturnValue, nonBlock, forceNonBlock);
|
||||||
|
|
||||||
// TODO: remove the dependency on a running IOS instance.
|
// TODO: remove the dependency on a running IOS instance.
|
||||||
GetIOS()->EnqueueIPCReply(it->request, ReturnValue);
|
GetIOS()->EnqueueIPCReply(it->request, ReturnValue);
|
||||||
|
@ -697,7 +698,7 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
|
||||||
// Close host socket
|
// Close host socket
|
||||||
closesocket(fd);
|
closesocket(fd);
|
||||||
wii_fd = -SO_EMFILE;
|
wii_fd = -SO_EMFILE;
|
||||||
ERROR_LOG(IOS_NET, "%s failed: Too many open sockets, ret=%d", caller, wii_fd);
|
ERROR_LOG_FMT(IOS_NET, "{} failed: Too many open sockets, ret={}", caller, wii_fd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -708,7 +709,7 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
int opt_no_sigpipe = 1;
|
int opt_no_sigpipe = 1;
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &opt_no_sigpipe, sizeof(opt_no_sigpipe)) < 0)
|
if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &opt_no_sigpipe, sizeof(opt_no_sigpipe)) < 0)
|
||||||
ERROR_LOG(IOS_NET, "Failed to set SO_NOSIGPIPE on socket");
|
ERROR_LOG_FMT(IOS_NET, "Failed to set SO_NOSIGPIPE on socket");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -883,8 +884,9 @@ void WiiSockMan::UpdatePollCommands()
|
||||||
// Memory::Write_U32(ufds[i].fd, request.buffer_out + 0xc*i); //fd
|
// Memory::Write_U32(ufds[i].fd, request.buffer_out + 0xc*i); //fd
|
||||||
// Memory::Write_U32(events, request.buffer_out + 0xc*i + 4); //events
|
// Memory::Write_U32(events, request.buffer_out + 0xc*i + 4); //events
|
||||||
Memory::Write_U32(revents, pcmd.buffer_out + 0xc * i + 8); // revents
|
Memory::Write_U32(revents, pcmd.buffer_out + 0xc * i + 8); // revents
|
||||||
DEBUG_LOG(IOS_NET, "IOCTL_SO_POLL socket %d wevents %08X events %08X revents %08X", i,
|
DEBUG_LOG_FMT(IOS_NET,
|
||||||
revents, pfds[i].events, pfds[i].revents);
|
"IOCTL_SO_POLL socket {} wevents {:08X} events {:08X} revents {:08X}",
|
||||||
|
i, revents, pfds[i].events, pfds[i].revents);
|
||||||
}
|
}
|
||||||
GetIOS()->EnqueueIPCReply(request, ret);
|
GetIOS()->EnqueueIPCReply(request, ret);
|
||||||
return true;
|
return true;
|
||||||
|
@ -932,7 +934,7 @@ s32 WiiSockMan::ConvertEvents(s32 events, ConvertDirection dir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unhandled_events)
|
if (unhandled_events)
|
||||||
ERROR_LOG(IOS_NET, "SO_POLL: unhandled Wii event types: %04x", unhandled_events);
|
ERROR_LOG_FMT(IOS_NET, "SO_POLL: unhandled Wii event types: {:04x}", unhandled_events);
|
||||||
return converted_events;
|
return converted_events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ typedef struct pollfd pollfd_t;
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
@ -229,7 +230,7 @@ public:
|
||||||
s64 timeout;
|
s64 timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
static s32 GetNetErrorCode(s32 ret, const char* caller, bool isRW);
|
static s32 GetNetErrorCode(s32 ret, std::string_view caller, bool is_rw);
|
||||||
static char* DecodeError(s32 ErrorCode);
|
static char* DecodeError(s32 ErrorCode);
|
||||||
|
|
||||||
static WiiSockMan& GetInstance()
|
static WiiSockMan& GetInstance()
|
||||||
|
@ -260,8 +261,8 @@ public:
|
||||||
auto socket_entry = WiiSockets.find(sock);
|
auto socket_entry = WiiSockets.find(sock);
|
||||||
if (socket_entry == WiiSockets.end())
|
if (socket_entry == WiiSockets.end())
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_NET, "DoSock: Error, fd not found (%08x, %08X, %08X)", sock, request.address,
|
ERROR_LOG_FMT(IOS_NET, "DoSock: Error, fd not found ({:08x}, {:08X}, {:08X})", sock,
|
||||||
type);
|
request.address, type);
|
||||||
GetIOS()->EnqueueIPCReply(request, -SO_EBADF);
|
GetIOS()->EnqueueIPCReply(request, -SO_EBADF);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -27,7 +27,7 @@ SDIOSlot0::SDIOSlot0(Kernel& ios, const std::string& device_name)
|
||||||
: Device(ios, device_name), m_sdhc_supported(HasFeature(ios.GetVersion(), Feature::SDv2))
|
: Device(ios, device_name), m_sdhc_supported(HasFeature(ios.GetVersion(), Feature::SDv2))
|
||||||
{
|
{
|
||||||
if (!Config::Get(Config::MAIN_ALLOW_SD_WRITES))
|
if (!Config::Get(Config::MAIN_ALLOW_SD_WRITES))
|
||||||
INFO_LOG(IOS_SD, "Writes to SD card disabled by user");
|
INFO_LOG_FMT(IOS_SD, "Writes to SD card disabled by user");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDIOSlot0::DoState(PointerWrap& p)
|
void SDIOSlot0::DoState(PointerWrap& p)
|
||||||
|
@ -65,16 +65,16 @@ void SDIOSlot0::OpenInternal()
|
||||||
m_card.Open(filename, "r+b");
|
m_card.Open(filename, "r+b");
|
||||||
if (!m_card)
|
if (!m_card)
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_SD, "Failed to open SD Card image, trying to create a new 128 MB image...");
|
WARN_LOG_FMT(IOS_SD, "Failed to open SD Card image, trying to create a new 128 MB image...");
|
||||||
if (Common::SDCardCreate(128, filename))
|
if (Common::SDCardCreate(128, filename))
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_SD, "Successfully created %s", filename.c_str());
|
INFO_LOG_FMT(IOS_SD, "Successfully created {}", filename);
|
||||||
m_card.Open(filename, "r+b");
|
m_card.Open(filename, "r+b");
|
||||||
}
|
}
|
||||||
if (!m_card)
|
if (!m_card)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_SD, "Could not open SD Card image or create a new one, are you running "
|
ERROR_LOG_FMT(IOS_SD, "Could not open SD Card image or create a new one, are you running "
|
||||||
"from a read-only directory?");
|
"from a read-only directory?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ IPCCommandResult SDIOSlot0::IOCtl(const IOCtlRequest& request)
|
||||||
case IOCTL_GETOCR:
|
case IOCTL_GETOCR:
|
||||||
return GetOCRegister(request);
|
return GetOCRegister(request);
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(IOS_SD, "Unknown SD IOCtl command (0x%08x)", request.request);
|
ERROR_LOG_FMT(IOS_SD, "Unknown SD IOCtl command ({:#010x})", request.request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ IPCCommandResult SDIOSlot0::IOCtlV(const IOCtlVRequest& request)
|
||||||
case IOCTLV_SENDCMD:
|
case IOCTLV_SENDCMD:
|
||||||
return SendCommand(request);
|
return SendCommand(request);
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(IOS_SD, "Unknown SD IOCtlV command 0x%08x", request.request);
|
ERROR_LOG_FMT(IOS_SD, "Unknown SD IOCtlV command {:#010x}", request.request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||||
switch (req.command)
|
switch (req.command)
|
||||||
{
|
{
|
||||||
case GO_IDLE_STATE:
|
case GO_IDLE_STATE:
|
||||||
INFO_LOG(IOS_SD, "GO_IDLE_STATE");
|
INFO_LOG_FMT(IOS_SD, "GO_IDLE_STATE");
|
||||||
// Response is R1 (idle state)
|
// Response is R1 (idle state)
|
||||||
Memory::Write_U32(0x00, buffer_out);
|
Memory::Write_U32(0x00, buffer_out);
|
||||||
break;
|
break;
|
||||||
|
@ -194,7 +194,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEND_IF_COND:
|
case SEND_IF_COND:
|
||||||
INFO_LOG(IOS_SD, "SEND_IF_COND");
|
INFO_LOG_FMT(IOS_SD, "SEND_IF_COND");
|
||||||
// If the card can operate on the supplied voltage, the response echoes back the supply
|
// If the card can operate on the supplied voltage, the response echoes back the supply
|
||||||
// voltage and the check pattern that were set in the command argument.
|
// voltage and the check pattern that were set in the command argument.
|
||||||
// This command is used to differentiate between protocol v1 and v2.
|
// This command is used to differentiate between protocol v1 and v2.
|
||||||
|
@ -211,7 +211,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||||
|
|
||||||
case ALL_SEND_CID:
|
case ALL_SEND_CID:
|
||||||
case SEND_CID:
|
case SEND_CID:
|
||||||
INFO_LOG(IOS_SD, "(ALL_)SEND_CID");
|
INFO_LOG_FMT(IOS_SD, "(ALL_)SEND_CID");
|
||||||
Memory::Write_U32(0x80114d1c, buffer_out);
|
Memory::Write_U32(0x80114d1c, buffer_out);
|
||||||
Memory::Write_U32(0x80080000, buffer_out + 4);
|
Memory::Write_U32(0x80080000, buffer_out + 4);
|
||||||
Memory::Write_U32(0x8007b520, buffer_out + 8);
|
Memory::Write_U32(0x8007b520, buffer_out + 8);
|
||||||
|
@ -244,25 +244,25 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||||
{
|
{
|
||||||
// Data address (req.arg) is in byte units in a Standard Capacity SD Memory Card
|
// Data address (req.arg) is in byte units in a Standard Capacity SD Memory Card
|
||||||
// and in block (512 Byte) units in a High Capacity SD Memory Card.
|
// and in block (512 Byte) units in a High Capacity SD Memory Card.
|
||||||
INFO_LOG(IOS_SD, "%sRead %i Block(s) from 0x%08x bsize %i into 0x%08x!",
|
INFO_LOG_FMT(IOS_SD, "{}Read {} Block(s) from {:#010x} bsize {} into {:#010x}!",
|
||||||
req.isDMA ? "DMA " : "", req.blocks, req.arg, req.bsize, req.addr);
|
req.isDMA ? "DMA " : "", req.blocks, req.arg, req.bsize, req.addr);
|
||||||
|
|
||||||
if (m_card)
|
if (m_card)
|
||||||
{
|
{
|
||||||
u32 size = req.bsize * req.blocks;
|
const u32 size = req.bsize * req.blocks;
|
||||||
u64 address = GetAddressFromRequest(req.arg);
|
const u64 address = GetAddressFromRequest(req.arg);
|
||||||
|
|
||||||
if (!m_card.Seek(address, SEEK_SET))
|
if (!m_card.Seek(address, SEEK_SET))
|
||||||
ERROR_LOG(IOS_SD, "Seek failed WTF");
|
ERROR_LOG_FMT(IOS_SD, "Seek failed WTF");
|
||||||
|
|
||||||
if (m_card.ReadBytes(Memory::GetPointer(req.addr), size))
|
if (m_card.ReadBytes(Memory::GetPointer(req.addr), size))
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_SD, "Outbuffer size %i got %i", rw_buffer_size, size);
|
DEBUG_LOG_FMT(IOS_SD, "Outbuffer size {} got {}", rw_buffer_size, size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_SD, "Read Failed - error: %i, eof: %i", ferror(m_card.GetHandle()),
|
ERROR_LOG_FMT(IOS_SD, "Read Failed - error: {}, eof: {}", std::ferror(m_card.GetHandle()),
|
||||||
feof(m_card.GetHandle()));
|
std::feof(m_card.GetHandle()));
|
||||||
ret = RET_FAIL;
|
ret = RET_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,22 +274,22 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||||
{
|
{
|
||||||
// Data address (req.arg) is in byte units in a Standard Capacity SD Memory Card
|
// Data address (req.arg) is in byte units in a Standard Capacity SD Memory Card
|
||||||
// and in block (512 Byte) units in a High Capacity SD Memory Card.
|
// and in block (512 Byte) units in a High Capacity SD Memory Card.
|
||||||
INFO_LOG(IOS_SD, "%sWrite %i Block(s) from 0x%08x bsize %i to offset 0x%08x!",
|
INFO_LOG_FMT(IOS_SD, "{}Write {} Block(s) from {:#010x} bsize {} to offset {:#010x}!",
|
||||||
req.isDMA ? "DMA " : "", req.blocks, req.addr, req.bsize, req.arg);
|
req.isDMA ? "DMA " : "", req.blocks, req.addr, req.bsize, req.arg);
|
||||||
|
|
||||||
if (m_card && SConfig::GetInstance().bEnableMemcardSdWriting &&
|
if (m_card && SConfig::GetInstance().bEnableMemcardSdWriting &&
|
||||||
Config::Get(Config::MAIN_ALLOW_SD_WRITES))
|
Config::Get(Config::MAIN_ALLOW_SD_WRITES))
|
||||||
{
|
{
|
||||||
u32 size = req.bsize * req.blocks;
|
const u32 size = req.bsize * req.blocks;
|
||||||
u64 address = GetAddressFromRequest(req.arg);
|
const u64 address = GetAddressFromRequest(req.arg);
|
||||||
|
|
||||||
if (!m_card.Seek(address, SEEK_SET))
|
if (!m_card.Seek(address, SEEK_SET))
|
||||||
ERROR_LOG(IOS_SD, "fseeko failed WTF");
|
ERROR_LOG_FMT(IOS_SD, "fseeko failed WTF");
|
||||||
|
|
||||||
if (!m_card.WriteBytes(Memory::GetPointer(req.addr), size))
|
if (!m_card.WriteBytes(Memory::GetPointer(req.addr), size))
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_SD, "Write Failed - error: %i, eof: %i", ferror(m_card.GetHandle()),
|
ERROR_LOG_FMT(IOS_SD, "Write Failed - error: {}, eof: {}", std::ferror(m_card.GetHandle()),
|
||||||
feof(m_card.GetHandle()));
|
std::feof(m_card.GetHandle()));
|
||||||
ret = RET_FAIL;
|
ret = RET_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_REGISTER: // async
|
case EVENT_REGISTER: // async
|
||||||
INFO_LOG(IOS_SD, "Register event %x", req.arg);
|
INFO_LOG_FMT(IOS_SD, "Register event {:x}", req.arg);
|
||||||
m_event = std::make_unique<Event>(static_cast<EventType>(req.arg), request);
|
m_event = std::make_unique<Event>(static_cast<EventType>(req.arg), request);
|
||||||
ret = RET_EVENT_REGISTER;
|
ret = RET_EVENT_REGISTER;
|
||||||
break;
|
break;
|
||||||
|
@ -306,7 +306,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||||
// Used to cancel an event that was already registered.
|
// Used to cancel an event that was already registered.
|
||||||
case EVENT_UNREGISTER:
|
case EVENT_UNREGISTER:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_SD, "Unregister event %x", req.arg);
|
INFO_LOG_FMT(IOS_SD, "Unregister event {:x}", req.arg);
|
||||||
if (!m_event)
|
if (!m_event)
|
||||||
return IPC_EINVAL;
|
return IPC_EINVAL;
|
||||||
// release returns 0
|
// release returns 0
|
||||||
|
@ -318,7 +318,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(IOS_SD, "Unknown SD command 0x%08x", req.command);
|
ERROR_LOG_FMT(IOS_SD, "Unknown SD command {:#010x}", req.command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,14 +327,14 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
||||||
|
|
||||||
IPCCommandResult SDIOSlot0::WriteHCRegister(const IOCtlRequest& request)
|
IPCCommandResult SDIOSlot0::WriteHCRegister(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
u32 reg = Memory::Read_U32(request.buffer_in);
|
const u32 reg = Memory::Read_U32(request.buffer_in);
|
||||||
u32 val = Memory::Read_U32(request.buffer_in + 16);
|
const u32 val = Memory::Read_U32(request.buffer_in + 16);
|
||||||
|
|
||||||
INFO_LOG(IOS_SD, "IOCTL_WRITEHCR 0x%08x - 0x%08x", reg, val);
|
INFO_LOG_FMT(IOS_SD, "IOCTL_WRITEHCR {:#010x} - {:#010x}", reg, val);
|
||||||
|
|
||||||
if (reg >= m_registers.size())
|
if (reg >= m_registers.size())
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_SD, "IOCTL_WRITEHCR out of range");
|
WARN_LOG_FMT(IOS_SD, "IOCTL_WRITEHCR out of range");
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetDefaultReply(IPC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,16 +359,16 @@ IPCCommandResult SDIOSlot0::WriteHCRegister(const IOCtlRequest& request)
|
||||||
|
|
||||||
IPCCommandResult SDIOSlot0::ReadHCRegister(const IOCtlRequest& request)
|
IPCCommandResult SDIOSlot0::ReadHCRegister(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
u32 reg = Memory::Read_U32(request.buffer_in);
|
const u32 reg = Memory::Read_U32(request.buffer_in);
|
||||||
|
|
||||||
if (reg >= m_registers.size())
|
if (reg >= m_registers.size())
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_SD, "IOCTL_READHCR out of range");
|
WARN_LOG_FMT(IOS_SD, "IOCTL_READHCR out of range");
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetDefaultReply(IPC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 val = m_registers[reg];
|
const u32 val = m_registers[reg];
|
||||||
INFO_LOG(IOS_SD, "IOCTL_READHCR 0x%08x - 0x%08x", reg, val);
|
INFO_LOG_FMT(IOS_SD, "IOCTL_READHCR {:#010x} - {:#010x}", reg, val);
|
||||||
|
|
||||||
// Just reading the register
|
// Just reading the register
|
||||||
Memory::Write_U32(val, request.buffer_out);
|
Memory::Write_U32(val, request.buffer_out);
|
||||||
|
@ -377,7 +377,7 @@ IPCCommandResult SDIOSlot0::ReadHCRegister(const IOCtlRequest& request)
|
||||||
|
|
||||||
IPCCommandResult SDIOSlot0::ResetCard(const IOCtlRequest& request)
|
IPCCommandResult SDIOSlot0::ResetCard(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_SD, "IOCTL_RESETCARD");
|
INFO_LOG_FMT(IOS_SD, "IOCTL_RESETCARD");
|
||||||
|
|
||||||
// Returns 16bit RCA and 16bit 0s (meaning success)
|
// Returns 16bit RCA and 16bit 0s (meaning success)
|
||||||
Memory::Write_U32(m_status, request.buffer_out);
|
Memory::Write_U32(m_status, request.buffer_out);
|
||||||
|
@ -387,21 +387,21 @@ IPCCommandResult SDIOSlot0::ResetCard(const IOCtlRequest& request)
|
||||||
|
|
||||||
IPCCommandResult SDIOSlot0::SetClk(const IOCtlRequest& request)
|
IPCCommandResult SDIOSlot0::SetClk(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_SD, "IOCTL_SETCLK");
|
INFO_LOG_FMT(IOS_SD, "IOCTL_SETCLK");
|
||||||
|
|
||||||
// libogc only sets it to 1 and makes sure the return isn't negative...
|
// libogc only sets it to 1 and makes sure the return isn't negative...
|
||||||
// one half of the sdclk divisor: a power of two or zero.
|
// one half of the sdclk divisor: a power of two or zero.
|
||||||
u32 clock = Memory::Read_U32(request.buffer_in);
|
const u32 clock = Memory::Read_U32(request.buffer_in);
|
||||||
if (clock != 1)
|
if (clock != 1)
|
||||||
INFO_LOG(IOS_SD, "Setting to %i, interesting", clock);
|
INFO_LOG_FMT(IOS_SD, "Setting to {}, interesting", clock);
|
||||||
|
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetDefaultReply(IPC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCCommandResult SDIOSlot0::SendCommand(const IOCtlRequest& request)
|
IPCCommandResult SDIOSlot0::SendCommand(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_SD, "IOCTL_SENDCMD %x IPC:%08x", Memory::Read_U32(request.buffer_in),
|
INFO_LOG_FMT(IOS_SD, "IOCTL_SENDCMD {:x} IPC:{:08x}", Memory::Read_U32(request.buffer_in),
|
||||||
request.address);
|
request.address);
|
||||||
|
|
||||||
const s32 return_value = ExecuteCommand(request, request.buffer_in, request.buffer_in_size, 0, 0,
|
const s32 return_value = ExecuteCommand(request, request.buffer_in, request.buffer_in_size, 0, 0,
|
||||||
request.buffer_out, request.buffer_out_size);
|
request.buffer_out, request.buffer_out_size);
|
||||||
|
@ -444,10 +444,10 @@ IPCCommandResult SDIOSlot0::GetStatus(const IOCtlRequest& request)
|
||||||
const u32 status =
|
const u32 status =
|
||||||
SConfig::GetInstance().m_WiiSDCard ? (m_status | CARD_INSERTED) : CARD_NOT_EXIST;
|
SConfig::GetInstance().m_WiiSDCard ? (m_status | CARD_INSERTED) : CARD_NOT_EXIST;
|
||||||
|
|
||||||
INFO_LOG(IOS_SD, "IOCTL_GETSTATUS. Replying that %s card is %s%s",
|
INFO_LOG_FMT(IOS_SD, "IOCTL_GETSTATUS. Replying that {} card is {}{}",
|
||||||
(status & CARD_SDHC) ? "SDHC" : "SD",
|
(status & CARD_SDHC) ? "SDHC" : "SD",
|
||||||
(status & CARD_INSERTED) ? "inserted" : "not present",
|
(status & CARD_INSERTED) ? "inserted" : "not present",
|
||||||
(status & CARD_INITIALIZED) ? " and initialized" : "");
|
(status & CARD_INITIALIZED) ? " and initialized" : "");
|
||||||
|
|
||||||
Memory::Write_U32(status, request.buffer_out);
|
Memory::Write_U32(status, request.buffer_out);
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetDefaultReply(IPC_SUCCESS);
|
||||||
|
@ -455,8 +455,8 @@ IPCCommandResult SDIOSlot0::GetStatus(const IOCtlRequest& request)
|
||||||
|
|
||||||
IPCCommandResult SDIOSlot0::GetOCRegister(const IOCtlRequest& request)
|
IPCCommandResult SDIOSlot0::GetOCRegister(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
u32 ocr = GetOCRegister();
|
const u32 ocr = GetOCRegister();
|
||||||
INFO_LOG(IOS_SD, "IOCTL_GETOCR. Replying with ocr %x", ocr);
|
INFO_LOG_FMT(IOS_SD, "IOCTL_GETOCR. Replying with ocr {:x}", ocr);
|
||||||
Memory::Write_U32(ocr, request.buffer_out);
|
Memory::Write_U32(ocr, request.buffer_out);
|
||||||
|
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetDefaultReply(IPC_SUCCESS);
|
||||||
|
@ -464,7 +464,7 @@ IPCCommandResult SDIOSlot0::GetOCRegister(const IOCtlRequest& request)
|
||||||
|
|
||||||
IPCCommandResult SDIOSlot0::SendCommand(const IOCtlVRequest& request)
|
IPCCommandResult SDIOSlot0::SendCommand(const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_SD, "IOCTLV_SENDCMD 0x%08x", Memory::Read_U32(request.in_vectors[0].address));
|
DEBUG_LOG_FMT(IOS_SD, "IOCTLV_SENDCMD {:#010x}", Memory::Read_U32(request.in_vectors[0].address));
|
||||||
Memory::Memset(request.io_vectors[0].address, 0, request.io_vectors[0].size);
|
Memory::Memset(request.io_vectors[0].address, 0, request.io_vectors[0].size);
|
||||||
|
|
||||||
const s32 return_value =
|
const s32 return_value =
|
||||||
|
@ -502,7 +502,7 @@ std::array<u32, 4> SDIOSlot0::GetCSDv1() const
|
||||||
size >>= 1;
|
size >>= 1;
|
||||||
if (++c_size_mult >= 8 + 2 + read_bl_len)
|
if (++c_size_mult >= 8 + 2 + read_bl_len)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_SD, "SD Card is too big!");
|
ERROR_LOG_FMT(IOS_SD, "SD Card is too big!");
|
||||||
// Set max values
|
// Set max values
|
||||||
size = 4096;
|
size = 4096;
|
||||||
c_size_mult = 7 + 2 + read_bl_len;
|
c_size_mult = 7 + 2 + read_bl_len;
|
||||||
|
@ -513,9 +513,9 @@ std::array<u32, 4> SDIOSlot0::GetCSDv1() const
|
||||||
const u32 c_size(size);
|
const u32 c_size(size);
|
||||||
|
|
||||||
if (invalid_size)
|
if (invalid_size)
|
||||||
WARN_LOG(IOS_SD, "SD Card size is invalid");
|
WARN_LOG_FMT(IOS_SD, "SD Card size is invalid");
|
||||||
else
|
else
|
||||||
INFO_LOG(IOS_SD, "SD C_SIZE = %u, C_SIZE_MULT = %u", c_size, c_size_mult);
|
INFO_LOG_FMT(IOS_SD, "SD C_SIZE = {}, C_SIZE_MULT = {}", c_size, c_size_mult);
|
||||||
|
|
||||||
// 0b00 CSD_STRUCTURE (SDv1)
|
// 0b00 CSD_STRUCTURE (SDv1)
|
||||||
// 0b000000 reserved
|
// 0b000000 reserved
|
||||||
|
@ -574,7 +574,7 @@ std::array<u32, 4> SDIOSlot0::GetCSDv2() const
|
||||||
const u64 size = m_card.GetSize();
|
const u64 size = m_card.GetSize();
|
||||||
|
|
||||||
if (size % (512 * 1024) != 0)
|
if (size % (512 * 1024) != 0)
|
||||||
WARN_LOG(IOS_SD, "SDHC Card size cannot be divided by 1024 * 512");
|
WARN_LOG_FMT(IOS_SD, "SDHC Card size cannot be divided by 1024 * 512");
|
||||||
|
|
||||||
const u32 c_size(size / (512 * 1024) - 1);
|
const u32 c_size(size / (512 * 1024) - 1);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ IPCCommandResult STMImmediate::IOCtl(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
case IOCTL_STM_IDLE:
|
case IOCTL_STM_IDLE:
|
||||||
case IOCTL_STM_SHUTDOWN:
|
case IOCTL_STM_SHUTDOWN:
|
||||||
NOTICE_LOG(IOS_STM, "IOCTL_STM_IDLE or IOCTL_STM_SHUTDOWN received, shutting down");
|
NOTICE_LOG_FMT(IOS_STM, "IOCTL_STM_IDLE or IOCTL_STM_SHUTDOWN received, shutting down");
|
||||||
Core::QueueHostJob(&Core::Stop, false);
|
Core::QueueHostJob(&Core::Stop, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -39,20 +39,20 @@ IPCCommandResult STMImmediate::IOCtl(const IOCtlRequest& request)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_STM_HOTRESET:
|
case IOCTL_STM_HOTRESET:
|
||||||
INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
INFO_LOG_FMT(IOS_STM, "{} - IOCtl:", GetDeviceName());
|
||||||
INFO_LOG(IOS_STM, " IOCTL_STM_HOTRESET");
|
INFO_LOG_FMT(IOS_STM, " IOCTL_STM_HOTRESET");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_STM_VIDIMMING: // (Input: 20 bytes, Output: 20 bytes)
|
case IOCTL_STM_VIDIMMING: // (Input: 20 bytes, Output: 20 bytes)
|
||||||
INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
INFO_LOG_FMT(IOS_STM, "{} - IOCtl:", GetDeviceName());
|
||||||
INFO_LOG(IOS_STM, " IOCTL_STM_VIDIMMING");
|
INFO_LOG_FMT(IOS_STM, " IOCTL_STM_VIDIMMING");
|
||||||
// Memory::Write_U32(1, buffer_out);
|
// Memory::Write_U32(1, buffer_out);
|
||||||
// return_value = 1;
|
// return_value = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_STM_LEDMODE: // (Input: 20 bytes, Output: 20 bytes)
|
case IOCTL_STM_LEDMODE: // (Input: 20 bytes, Output: 20 bytes)
|
||||||
INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
INFO_LOG_FMT(IOS_STM, "{} - IOCtl:", GetDeviceName());
|
||||||
INFO_LOG(IOS_STM, " IOCTL_STM_LEDMODE");
|
INFO_LOG_FMT(IOS_STM, " IOCTL_STM_LEDMODE");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -30,7 +30,7 @@ void BackUpBTInfoSection(const SysConf* sysconf)
|
||||||
|
|
||||||
const std::vector<u8>& section = btdinf->bytes;
|
const std::vector<u8>& section = btdinf->bytes;
|
||||||
if (!backup.WriteBytes(section.data(), section.size()))
|
if (!backup.WriteBytes(section.data(), section.size()))
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Failed to back up BT.DINF section");
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Failed to back up BT.DINF section");
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreBTInfoSection(SysConf* sysconf)
|
void RestoreBTInfoSection(SysConf* sysconf)
|
||||||
|
@ -43,7 +43,7 @@ void RestoreBTInfoSection(SysConf* sysconf)
|
||||||
auto& section = sysconf->GetOrAddEntry("BT.DINF", SysConf::Entry::Type::BigArray)->bytes;
|
auto& section = sysconf->GetOrAddEntry("BT.DINF", SysConf::Entry::Type::BigArray)->bytes;
|
||||||
if (!backup.ReadBytes(section.data(), section.size()))
|
if (!backup.ReadBytes(section.data(), section.size()))
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Failed to read backed up BT.DINF section");
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Failed to read backed up BT.DINF section");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace IOS::HLE
|
||||||
SQueuedEvent::SQueuedEvent(u32 size_, u16 handle) : size(size_), connection_handle(handle)
|
SQueuedEvent::SQueuedEvent(u32 size_, u16 handle) : size(size_), connection_handle(handle)
|
||||||
{
|
{
|
||||||
if (size > 1024)
|
if (size > 1024)
|
||||||
PanicAlert("SQueuedEvent: The size is too large.");
|
PanicAlertFmt("SQueuedEvent: The size is too large.");
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Device
|
namespace Device
|
||||||
|
@ -58,8 +58,8 @@ BluetoothEmu::BluetoothEmu(Kernel& ios, const std::string& device_name)
|
||||||
memcpy(bt_dinf.registered[i].name, wm_name, 20);
|
memcpy(bt_dinf.registered[i].name, wm_name, 20);
|
||||||
memcpy(bt_dinf.active[i].name, wm_name, 20);
|
memcpy(bt_dinf.active[i].name, wm_name, 20);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Wii Remote %d BT ID %x,%x,%x,%x,%x,%x", i, tmp_bd[0], tmp_bd[1],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Wii Remote {} BT ID {:x},{:x},{:x},{:x},{:x},{:x}", i, tmp_bd[0],
|
||||||
tmp_bd[2], tmp_bd[3], tmp_bd[4], tmp_bd[5]);
|
tmp_bd[1], tmp_bd[2], tmp_bd[3], tmp_bd[4], tmp_bd[5]);
|
||||||
|
|
||||||
m_wiimotes.emplace_back(std::make_unique<WiimoteDevice>(this, i, tmp_bd));
|
m_wiimotes.emplace_back(std::make_unique<WiimoteDevice>(this, i, tmp_bd));
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ BluetoothEmu::BluetoothEmu(Kernel& ios, const std::string& device_name)
|
||||||
section.resize(sizeof(ConfPads));
|
section.resize(sizeof(ConfPads));
|
||||||
std::memcpy(section.data(), &bt_dinf, sizeof(ConfPads));
|
std::memcpy(section.data(), &bt_dinf, sizeof(ConfPads));
|
||||||
if (!sysconf.Save())
|
if (!sysconf.Save())
|
||||||
PanicAlertT("Failed to write BT.DINF to SYSCONF");
|
PanicAlertFmtT("Failed to write BT.DINF to SYSCONF");
|
||||||
}
|
}
|
||||||
|
|
||||||
BluetoothEmu::~BluetoothEmu() = default;
|
BluetoothEmu::~BluetoothEmu() = default;
|
||||||
|
@ -176,7 +176,7 @@ IPCCommandResult BluetoothEmu::IOCtlV(const IOCtlVRequest& request)
|
||||||
case ACL_DATA_IN: // We are given an ACL buffer to fill
|
case ACL_DATA_IN: // We are given an ACL buffer to fill
|
||||||
{
|
{
|
||||||
m_acl_endpoint = std::make_unique<USB::V0BulkMessage>(m_ios, request);
|
m_acl_endpoint = std::make_unique<USB::V0BulkMessage>(m_ios, request);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "ACL_DATA_IN: 0x%08x ", request.address);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "ACL_DATA_IN: {:#010x}", request.address);
|
||||||
send_reply = false;
|
send_reply = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ IPCCommandResult BluetoothEmu::IOCtlV(const IOCtlVRequest& request)
|
||||||
if (ctrl.endpoint == HCI_EVENT) // We are given a HCI buffer to fill
|
if (ctrl.endpoint == HCI_EVENT) // We are given a HCI buffer to fill
|
||||||
{
|
{
|
||||||
m_hci_endpoint = std::make_unique<USB::V0IntrMessage>(m_ios, request);
|
m_hci_endpoint = std::make_unique<USB::V0IntrMessage>(m_ios, request);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "HCI_EVENT: 0x%08x ", request.address);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "HCI_EVENT: {:#010x}", request.address);
|
||||||
send_reply = false;
|
send_reply = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -216,7 +216,7 @@ void BluetoothEmu::SendToDevice(u16 connection_handle, u8* data, u32 size)
|
||||||
if (wiimote == nullptr)
|
if (wiimote == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Send ACL Packet to ConnectionHandle 0x%04x", connection_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Send ACL Packet to ConnectionHandle {:#06x}", connection_handle);
|
||||||
IncDataPacket(connection_handle);
|
IncDataPacket(connection_handle);
|
||||||
wiimote->ExecuteL2capCmd(data, size);
|
wiimote->ExecuteL2capCmd(data, size);
|
||||||
}
|
}
|
||||||
|
@ -232,12 +232,12 @@ void BluetoothEmu::SendACLPacket(const bdaddr_t& source, const u8* data, u32 siz
|
||||||
{
|
{
|
||||||
const u16 connection_handle = GetConnectionHandle(source);
|
const u16 connection_handle = GetConnectionHandle(source);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "ACL packet from %x ready to send to stack...", connection_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "ACL packet from {:x} ready to send to stack...", connection_handle);
|
||||||
|
|
||||||
if (m_acl_endpoint && !m_hci_endpoint && m_event_queue.empty())
|
if (m_acl_endpoint && !m_hci_endpoint && m_event_queue.empty())
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "ACL endpoint valid, sending packet to %08x",
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "ACL endpoint valid, sending packet to {:08x}",
|
||||||
m_acl_endpoint->ios_request.address);
|
m_acl_endpoint->ios_request.address);
|
||||||
|
|
||||||
hci_acldata_hdr_t* header =
|
hci_acldata_hdr_t* header =
|
||||||
reinterpret_cast<hci_acldata_hdr_t*>(Memory::GetPointer(m_acl_endpoint->data_address));
|
reinterpret_cast<hci_acldata_hdr_t*>(Memory::GetPointer(m_acl_endpoint->data_address));
|
||||||
|
@ -252,7 +252,7 @@ void BluetoothEmu::SendACLPacket(const bdaddr_t& source, const u8* data, u32 siz
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "ACL endpoint not currently valid, queuing...");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "ACL endpoint not currently valid, queuing...");
|
||||||
m_acl_pool.Store(data, size, connection_handle);
|
m_acl_pool.Store(data, size, connection_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,14 +264,15 @@ void BluetoothEmu::SendACLPacket(const bdaddr_t& source, const u8* data, u32 siz
|
||||||
// rather than enqueue it to some other memory and this will do good for StateSave
|
// rather than enqueue it to some other memory and this will do good for StateSave
|
||||||
void BluetoothEmu::AddEventToQueue(const SQueuedEvent& event)
|
void BluetoothEmu::AddEventToQueue(const SQueuedEvent& event)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "HCI event %x completed...", ((hci_event_hdr_t*)event.buffer)->event);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "HCI event {:x} completed...",
|
||||||
|
((hci_event_hdr_t*)event.buffer)->event);
|
||||||
|
|
||||||
if (m_hci_endpoint)
|
if (m_hci_endpoint)
|
||||||
{
|
{
|
||||||
if (m_event_queue.empty()) // fast path :)
|
if (m_event_queue.empty()) // fast path :)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "HCI endpoint valid, sending packet to %08x",
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "HCI endpoint valid, sending packet to {:08x}",
|
||||||
m_hci_endpoint->ios_request.address);
|
m_hci_endpoint->ios_request.address);
|
||||||
m_hci_endpoint->FillBuffer(event.buffer, event.size);
|
m_hci_endpoint->FillBuffer(event.buffer, event.size);
|
||||||
|
|
||||||
// Send a reply to indicate HCI buffer is filled
|
// Send a reply to indicate HCI buffer is filled
|
||||||
|
@ -280,15 +281,15 @@ void BluetoothEmu::AddEventToQueue(const SQueuedEvent& event)
|
||||||
}
|
}
|
||||||
else // push new one, pop oldest
|
else // push new one, pop oldest
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "HCI endpoint not currently valid, queueing (%zu)...",
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "HCI endpoint not currently valid, queueing ({})...",
|
||||||
m_event_queue.size());
|
m_event_queue.size());
|
||||||
m_event_queue.push_back(event);
|
m_event_queue.push_back(event);
|
||||||
const SQueuedEvent& queued_event = m_event_queue.front();
|
const SQueuedEvent& queued_event = m_event_queue.front();
|
||||||
DEBUG_LOG(IOS_WIIMOTE,
|
DEBUG_LOG_FMT(IOS_WIIMOTE,
|
||||||
"HCI event %x "
|
"HCI event {:x} "
|
||||||
"being written from queue (%zu) to %08x...",
|
"being written from queue ({}) to {:08x}...",
|
||||||
((hci_event_hdr_t*)queued_event.buffer)->event, m_event_queue.size() - 1,
|
((hci_event_hdr_t*)queued_event.buffer)->event, m_event_queue.size() - 1,
|
||||||
m_hci_endpoint->ios_request.address);
|
m_hci_endpoint->ios_request.address);
|
||||||
m_hci_endpoint->FillBuffer(queued_event.buffer, queued_event.size);
|
m_hci_endpoint->FillBuffer(queued_event.buffer, queued_event.size);
|
||||||
|
|
||||||
// Send a reply to indicate HCI buffer is filled
|
// Send a reply to indicate HCI buffer is filled
|
||||||
|
@ -299,8 +300,8 @@ void BluetoothEmu::AddEventToQueue(const SQueuedEvent& event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "HCI endpoint not currently valid, queuing (%zu)...",
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "HCI endpoint not currently valid, queuing ({})...",
|
||||||
m_event_queue.size());
|
m_event_queue.size());
|
||||||
m_event_queue.push_back(event);
|
m_event_queue.push_back(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,9 +313,9 @@ void BluetoothEmu::Update()
|
||||||
{
|
{
|
||||||
// an endpoint has become available, and we have a stored response.
|
// an endpoint has become available, and we have a stored response.
|
||||||
const SQueuedEvent& event = m_event_queue.front();
|
const SQueuedEvent& event = m_event_queue.front();
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "HCI event %x being written from queue (%zu) to %08x...",
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "HCI event {:x} being written from queue ({}) to {:08x}...",
|
||||||
((hci_event_hdr_t*)event.buffer)->event, m_event_queue.size() - 1,
|
((hci_event_hdr_t*)event.buffer)->event, m_event_queue.size() - 1,
|
||||||
m_hci_endpoint->ios_request.address);
|
m_hci_endpoint->ios_request.address);
|
||||||
m_hci_endpoint->FillBuffer(event.buffer, event.size);
|
m_hci_endpoint->FillBuffer(event.buffer, event.size);
|
||||||
|
|
||||||
// Send a reply to indicate HCI buffer is filled
|
// Send a reply to indicate HCI buffer is filled
|
||||||
|
@ -352,7 +353,7 @@ void BluetoothEmu::ACLPool::Store(const u8* data, const u16 size, const u16 conn
|
||||||
if (m_queue.size() >= 100)
|
if (m_queue.size() >= 100)
|
||||||
{
|
{
|
||||||
// Many simultaneous exchanges of ACL packets tend to cause the queue to fill up.
|
// Many simultaneous exchanges of ACL packets tend to cause the queue to fill up.
|
||||||
ERROR_LOG(IOS_WIIMOTE, "ACL queue size reached 100 - current packet will be dropped!");
|
ERROR_LOG_FMT(IOS_WIIMOTE, "ACL queue size reached 100 - current packet will be dropped!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,10 +375,8 @@ void BluetoothEmu::ACLPool::WriteToEndpoint(const USB::V0BulkMessage& endpoint)
|
||||||
const u16 size = packet.size;
|
const u16 size = packet.size;
|
||||||
const u16 conn_handle = packet.conn_handle;
|
const u16 conn_handle = packet.conn_handle;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE,
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "ACL packet being written from queue to {:08x}",
|
||||||
"ACL packet being written from "
|
endpoint.ios_request.address);
|
||||||
"queue to %08x",
|
|
||||||
endpoint.ios_request.address);
|
|
||||||
|
|
||||||
hci_acldata_hdr_t* header = (hci_acldata_hdr_t*)Memory::GetPointer(endpoint.data_address);
|
hci_acldata_hdr_t* header = (hci_acldata_hdr_t*)Memory::GetPointer(endpoint.data_address);
|
||||||
header->con_handle = HCI_MK_CON_HANDLE(conn_handle, HCI_PACKET_START, HCI_POINT2POINT);
|
header->con_handle = HCI_MK_CON_HANDLE(conn_handle, HCI_PACKET_START, HCI_POINT2POINT);
|
||||||
|
@ -403,7 +402,7 @@ bool BluetoothEmu::SendEventInquiryComplete(u8 num_responses)
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: Inquiry complete");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: Inquiry complete");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -447,10 +446,10 @@ bool BluetoothEmu::SendEventInquiryResponse()
|
||||||
std::copy_n(wiimote->GetClass().begin(), HCI_CLASS_SIZE, response->uclass);
|
std::copy_n(wiimote->GetClass().begin(), HCI_CLASS_SIZE, response->uclass);
|
||||||
response->clock_offset = 0x3818;
|
response->clock_offset = 0x3818;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: Send Fake Inquiry of one controller");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: Send Fake Inquiry of one controller");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", response->bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", response->bdaddr[0],
|
||||||
response->bdaddr[1], response->bdaddr[2], response->bdaddr[3], response->bdaddr[4],
|
response->bdaddr[1], response->bdaddr[2], response->bdaddr[3], response->bdaddr[4],
|
||||||
response->bdaddr[5]);
|
response->bdaddr[5]);
|
||||||
|
|
||||||
inquiry_result->PayloadLength =
|
inquiry_result->PayloadLength =
|
||||||
u8(sizeof(SHCIEventInquiryResult) - 2 +
|
u8(sizeof(SHCIEventInquiryResult) - 2 +
|
||||||
|
@ -483,14 +482,15 @@ bool BluetoothEmu::SendEventConnectionComplete(const bdaddr_t& bd, u8 status)
|
||||||
"HCI_LINK_eSCO 0x02 - eSCO",
|
"HCI_LINK_eSCO 0x02 - eSCO",
|
||||||
};
|
};
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventConnectionComplete");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventConnectionComplete");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", connection_complete->Connection_Handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", connection_complete->bdaddr[0],
|
connection_complete->Connection_Handle);
|
||||||
connection_complete->bdaddr[1], connection_complete->bdaddr[2],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
connection_complete->bdaddr[3], connection_complete->bdaddr[4],
|
connection_complete->bdaddr[0], connection_complete->bdaddr[1],
|
||||||
connection_complete->bdaddr[5]);
|
connection_complete->bdaddr[2], connection_complete->bdaddr[3],
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " LinkType: %s", link_type[connection_complete->LinkType]);
|
connection_complete->bdaddr[4], connection_complete->bdaddr[5]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " EncryptionEnabled: %i", connection_complete->EncryptionEnabled);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " LinkType: {}", link_type[connection_complete->LinkType]);
|
||||||
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " EncryptionEnabled: {}", connection_complete->EncryptionEnabled);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -517,15 +517,15 @@ bool BluetoothEmu::SendEventRequestConnection(const WiimoteDevice& wiimote)
|
||||||
"HCI_LINK_eSCO 0x02 - eSCO",
|
"HCI_LINK_eSCO 0x02 - eSCO",
|
||||||
};
|
};
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRequestConnection");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventRequestConnection");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", event_request_connection->bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
event_request_connection->bdaddr[1], event_request_connection->bdaddr[2],
|
event_request_connection->bdaddr[0], event_request_connection->bdaddr[1],
|
||||||
event_request_connection->bdaddr[3], event_request_connection->bdaddr[4],
|
event_request_connection->bdaddr[2], event_request_connection->bdaddr[3],
|
||||||
event_request_connection->bdaddr[5]);
|
event_request_connection->bdaddr[4], event_request_connection->bdaddr[5]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " COD[0]: 0x%02x", event_request_connection->uclass[0]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[0]: {:#04x}", event_request_connection->uclass[0]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " COD[1]: 0x%02x", event_request_connection->uclass[1]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[1]: {:#04x}", event_request_connection->uclass[1]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " COD[2]: 0x%02x", event_request_connection->uclass[2]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[2]: {:#04x}", event_request_connection->uclass[2]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " LinkType: %s", link_type[event_request_connection->LinkType]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " LinkType: {}", link_type[event_request_connection->LinkType]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -547,9 +547,9 @@ bool BluetoothEmu::SendEventDisconnect(u16 connection_handle, u8 reason)
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventDisconnect");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventDisconnect");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", disconnect->Connection_Handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}", disconnect->Connection_Handle);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Reason: 0x%02x", disconnect->Reason);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Reason: {:#04x}", disconnect->Reason);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -569,9 +569,9 @@ bool BluetoothEmu::SendEventAuthenticationCompleted(u16 connection_handle)
|
||||||
event_authentication_completed->EventStatus = 0;
|
event_authentication_completed->EventStatus = 0;
|
||||||
event_authentication_completed->Connection_Handle = connection_handle;
|
event_authentication_completed->Connection_Handle = connection_handle;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventAuthenticationCompleted");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventAuthenticationCompleted");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x",
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||||
event_authentication_completed->Connection_Handle);
|
event_authentication_completed->Connection_Handle);
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
|
@ -594,11 +594,11 @@ bool BluetoothEmu::SendEventRemoteNameReq(const bdaddr_t& bd)
|
||||||
remote_name_req->bdaddr = bd;
|
remote_name_req->bdaddr = bd;
|
||||||
strcpy((char*)remote_name_req->RemoteName, wiimote->GetName());
|
strcpy((char*)remote_name_req->RemoteName, wiimote->GetName());
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRemoteNameReq");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventRemoteNameReq");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", remote_name_req->bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
remote_name_req->bdaddr[1], remote_name_req->bdaddr[2], remote_name_req->bdaddr[3],
|
remote_name_req->bdaddr[0], remote_name_req->bdaddr[1], remote_name_req->bdaddr[2],
|
||||||
remote_name_req->bdaddr[4], remote_name_req->bdaddr[5]);
|
remote_name_req->bdaddr[3], remote_name_req->bdaddr[4], remote_name_req->bdaddr[5]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " RemoteName: %s", remote_name_req->RemoteName);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " RemoteName: {}", remote_name_req->RemoteName);
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
|
@ -621,13 +621,14 @@ bool BluetoothEmu::SendEventReadRemoteFeatures(u16 connection_handle)
|
||||||
read_remote_features->ConnectionHandle = connection_handle;
|
read_remote_features->ConnectionHandle = connection_handle;
|
||||||
std::copy_n(wiimote->GetFeatures().begin(), HCI_FEATURES_SIZE, read_remote_features->features);
|
std::copy_n(wiimote->GetFeatures().begin(), HCI_FEATURES_SIZE, read_remote_features->features);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventReadRemoteFeatures");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventReadRemoteFeatures");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", read_remote_features->ConnectionHandle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " features: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
read_remote_features->ConnectionHandle);
|
||||||
read_remote_features->features[0], read_remote_features->features[1],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " features: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
read_remote_features->features[2], read_remote_features->features[3],
|
read_remote_features->features[0], read_remote_features->features[1],
|
||||||
read_remote_features->features[4], read_remote_features->features[5],
|
read_remote_features->features[2], read_remote_features->features[3],
|
||||||
read_remote_features->features[6], read_remote_features->features[7]);
|
read_remote_features->features[4], read_remote_features->features[5],
|
||||||
|
read_remote_features->features[6], read_remote_features->features[7]);
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
|
@ -651,11 +652,12 @@ bool BluetoothEmu::SendEventReadRemoteVerInfo(u16 connection_handle)
|
||||||
read_remote_ver_info->manufacturer = wiimote->GetManufactorID();
|
read_remote_ver_info->manufacturer = wiimote->GetManufactorID();
|
||||||
read_remote_ver_info->lmp_subversion = wiimote->GetLMPSubVersion();
|
read_remote_ver_info->lmp_subversion = wiimote->GetLMPSubVersion();
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventReadRemoteVerInfo");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventReadRemoteVerInfo");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", read_remote_ver_info->ConnectionHandle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " lmp_version: 0x%02x", read_remote_ver_info->lmp_version);
|
read_remote_ver_info->ConnectionHandle);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " manufacturer: 0x%04x", read_remote_ver_info->manufacturer);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " lmp_version: {:#04x}", read_remote_ver_info->lmp_version);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " lmp_subversion: 0x%04x", read_remote_ver_info->lmp_subversion);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " manufacturer: {:#06x}", read_remote_ver_info->manufacturer);
|
||||||
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " lmp_subversion: {:#06x}", read_remote_ver_info->lmp_subversion);
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
|
@ -681,7 +683,7 @@ void BluetoothEmu::SendEventCommandComplete(u16 opcode, const void* data, u32 da
|
||||||
memcpy(payload, data, data_size);
|
memcpy(payload, data, data_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: Command Complete (Opcode: 0x%04x)", hci_event->Opcode);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: Command Complete (Opcode: {:#06x})", hci_event->Opcode);
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
}
|
}
|
||||||
|
@ -697,7 +699,7 @@ bool BluetoothEmu::SendEventCommandStatus(u16 opcode)
|
||||||
hci_event->PacketIndicator = 0x01;
|
hci_event->PacketIndicator = 0x01;
|
||||||
hci_event->Opcode = opcode;
|
hci_event->Opcode = opcode;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Event: Command Status (Opcode: 0x%04x)", hci_event->Opcode);
|
INFO_LOG_FMT(IOS_WIIMOTE, "Event: Command Status (Opcode: {:#06x})", hci_event->Opcode);
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
|
@ -722,11 +724,11 @@ bool BluetoothEmu::SendEventRoleChange(bdaddr_t bd, bool master)
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRoleChange");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventRoleChange");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", role_change->bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
role_change->bdaddr[1], role_change->bdaddr[2], role_change->bdaddr[3],
|
role_change->bdaddr[0], role_change->bdaddr[1], role_change->bdaddr[2],
|
||||||
role_change->bdaddr[4], role_change->bdaddr[5]);
|
role_change->bdaddr[3], role_change->bdaddr[4], role_change->bdaddr[5]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " NewRole: %i", role_change->NewRole);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " NewRole: {}", role_change->NewRole);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -737,7 +739,7 @@ bool BluetoothEmu::SendEventNumberOfCompletedPackets()
|
||||||
(sizeof(hci_num_compl_pkts_info) * m_wiimotes.size())),
|
(sizeof(hci_num_compl_pkts_info) * m_wiimotes.size())),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventNumberOfCompletedPackets");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventNumberOfCompletedPackets");
|
||||||
|
|
||||||
auto* event_hdr = (hci_event_hdr_t*)event.buffer;
|
auto* event_hdr = (hci_event_hdr_t*)event.buffer;
|
||||||
auto* hci_event = (hci_num_compl_pkts_ep*)((u8*)event_hdr + sizeof(hci_event_hdr_t));
|
auto* hci_event = (hci_num_compl_pkts_ep*)((u8*)event_hdr + sizeof(hci_event_hdr_t));
|
||||||
|
@ -756,8 +758,8 @@ bool BluetoothEmu::SendEventNumberOfCompletedPackets()
|
||||||
info->compl_pkts = m_packet_count[i];
|
info->compl_pkts = m_packet_count[i];
|
||||||
info->con_handle = GetConnectionHandle(m_wiimotes[i]->GetBD());
|
info->con_handle = GetConnectionHandle(m_wiimotes[i]->GetBD());
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", info->con_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}", info->con_handle);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Number_Of_Completed_Packets: %i", info->compl_pkts);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Number_Of_Completed_Packets: {}", info->compl_pkts);
|
||||||
|
|
||||||
acc += info->compl_pkts;
|
acc += info->compl_pkts;
|
||||||
m_packet_count[i] = 0;
|
m_packet_count[i] = 0;
|
||||||
|
@ -770,7 +772,7 @@ bool BluetoothEmu::SendEventNumberOfCompletedPackets()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "SendEventNumberOfCompletedPackets: no packets; no event");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "SendEventNumberOfCompletedPackets: no packets; no event");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -792,9 +794,9 @@ bool BluetoothEmu::SendEventModeChange(u16 connection_handle, u8 mode, u16 value
|
||||||
mode_change->CurrentMode = mode;
|
mode_change->CurrentMode = mode;
|
||||||
mode_change->Value = value;
|
mode_change->Value = value;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventModeChange");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventModeChange");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", mode_change->Connection_Handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}", mode_change->Connection_Handle);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Current Mode: 0x%02x", mode_change->CurrentMode = mode);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Current Mode: {:#04x}", mode_change->CurrentMode = mode);
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
|
@ -807,7 +809,7 @@ bool BluetoothEmu::SendEventLinkKeyNotification(const u8 num_to_send)
|
||||||
SQueuedEvent event(2 + payload_length, 0);
|
SQueuedEvent event(2 + payload_length, 0);
|
||||||
SHCIEventLinkKeyNotification* event_link_key = (SHCIEventLinkKeyNotification*)event.buffer;
|
SHCIEventLinkKeyNotification* event_link_key = (SHCIEventLinkKeyNotification*)event.buffer;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventLinkKeyNotification");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventLinkKeyNotification");
|
||||||
|
|
||||||
// event header
|
// event header
|
||||||
event_link_key->EventType = HCI_EVENT_RETURN_LINK_KEYS;
|
event_link_key->EventType = HCI_EVENT_RETURN_LINK_KEYS;
|
||||||
|
@ -824,9 +826,9 @@ bool BluetoothEmu::SendEventLinkKeyNotification(const u8 num_to_send)
|
||||||
link_key_info->bdaddr = m_wiimotes[i]->GetBD();
|
link_key_info->bdaddr = m_wiimotes[i]->GetBD();
|
||||||
std::copy_n(m_wiimotes[i]->GetLinkKey().begin(), HCI_KEY_SIZE, link_key_info->key);
|
std::copy_n(m_wiimotes[i]->GetLinkKey().begin(), HCI_KEY_SIZE, link_key_info->key);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", link_key_info->bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
link_key_info->bdaddr[1], link_key_info->bdaddr[2], link_key_info->bdaddr[3],
|
link_key_info->bdaddr[0], link_key_info->bdaddr[1], link_key_info->bdaddr[2],
|
||||||
link_key_info->bdaddr[4], link_key_info->bdaddr[5]);
|
link_key_info->bdaddr[3], link_key_info->bdaddr[4], link_key_info->bdaddr[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
@ -844,11 +846,11 @@ bool BluetoothEmu::SendEventRequestLinkKey(const bdaddr_t& bd)
|
||||||
event_request_link_key->PayloadLength = sizeof(SHCIEventRequestLinkKey) - 2;
|
event_request_link_key->PayloadLength = sizeof(SHCIEventRequestLinkKey) - 2;
|
||||||
event_request_link_key->bdaddr = bd;
|
event_request_link_key->bdaddr = bd;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRequestLinkKey");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventRequestLinkKey");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", event_request_link_key->bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
event_request_link_key->bdaddr[1], event_request_link_key->bdaddr[2],
|
event_request_link_key->bdaddr[0], event_request_link_key->bdaddr[1],
|
||||||
event_request_link_key->bdaddr[3], event_request_link_key->bdaddr[4],
|
event_request_link_key->bdaddr[2], event_request_link_key->bdaddr[3],
|
||||||
event_request_link_key->bdaddr[5]);
|
event_request_link_key->bdaddr[4], event_request_link_key->bdaddr[5]);
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
|
@ -871,10 +873,10 @@ bool BluetoothEmu::SendEventReadClockOffsetComplete(u16 connection_handle)
|
||||||
read_clock_offset_complete->ConnectionHandle = connection_handle;
|
read_clock_offset_complete->ConnectionHandle = connection_handle;
|
||||||
read_clock_offset_complete->ClockOffset = 0x3818;
|
read_clock_offset_complete->ClockOffset = 0x3818;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventReadClockOffsetComplete");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventReadClockOffsetComplete");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x",
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||||
read_clock_offset_complete->ConnectionHandle);
|
read_clock_offset_complete->ConnectionHandle);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " ClockOffset: 0x%04x", read_clock_offset_complete->ClockOffset);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " ClockOffset: {:#06x}", read_clock_offset_complete->ClockOffset);
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
|
@ -897,9 +899,10 @@ bool BluetoothEmu::SendEventConPacketTypeChange(u16 connection_handle, u16 packe
|
||||||
change_con_packet_type->ConnectionHandle = connection_handle;
|
change_con_packet_type->ConnectionHandle = connection_handle;
|
||||||
change_con_packet_type->PacketType = packet_type;
|
change_con_packet_type->PacketType = packet_type;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventConPacketTypeChange");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventConPacketTypeChange");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", change_con_packet_type->ConnectionHandle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " PacketType: 0x%04x", change_con_packet_type->PacketType);
|
change_con_packet_type->ConnectionHandle);
|
||||||
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " PacketType: {:#06x}", change_con_packet_type->PacketType);
|
||||||
|
|
||||||
AddEventToQueue(event);
|
AddEventToQueue(event);
|
||||||
|
|
||||||
|
@ -918,9 +921,9 @@ void BluetoothEmu::ExecuteHCICommandMessage(const USB::V0CtrlMessage& ctrl_messa
|
||||||
const u16 ocf = HCI_OCF(msg.Opcode);
|
const u16 ocf = HCI_OCF(msg.Opcode);
|
||||||
const u16 ogf = HCI_OGF(msg.Opcode);
|
const u16 ogf = HCI_OGF(msg.Opcode);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "**************************************************");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "**************************************************");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Execute HCI Command: 0x%04x (ocf: 0x%02x, ogf: 0x%02x)", msg.Opcode, ocf,
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Execute HCI Command: {:#06x} (ocf: {:#04x}, ogf: {:#04x})",
|
||||||
ogf);
|
msg.Opcode, ocf, ogf);
|
||||||
|
|
||||||
switch (msg.Opcode)
|
switch (msg.Opcode)
|
||||||
{
|
{
|
||||||
|
@ -1074,10 +1077,10 @@ void BluetoothEmu::ExecuteHCICommandMessage(const USB::V0CtrlMessage& ctrl_messa
|
||||||
|
|
||||||
if (ogf == HCI_OGF_VENDOR)
|
if (ogf == HCI_OGF_VENDOR)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Command: vendor specific: 0x%04X (ocf: 0x%x)", msg.Opcode, ocf);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Command: vendor specific: {:#06x} (ocf: {:#x})", msg.Opcode, ocf);
|
||||||
for (int i = 0; i < msg.len; i++)
|
for (int i = 0; i < msg.len; i++)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, " 0x02%x", input[i]);
|
ERROR_LOG_FMT(IOS_WIIMOTE, " 0x02{:#x}", input[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1103,13 +1106,13 @@ void BluetoothEmu::CommandInquiry(const u8* input)
|
||||||
hci_inquiry_cp inquiry;
|
hci_inquiry_cp inquiry;
|
||||||
std::memcpy(&inquiry, input, sizeof(inquiry));
|
std::memcpy(&inquiry, input, sizeof(inquiry));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_INQUIRY:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_INQUIRY:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "write:");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "write:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " LAP[0]: 0x%02x", inquiry.lap[0]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " LAP[0]: {:#04x}", inquiry.lap[0]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " LAP[1]: 0x%02x", inquiry.lap[1]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " LAP[1]: {:#04x}", inquiry.lap[1]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " LAP[2]: 0x%02x", inquiry.lap[2]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " LAP[2]: {:#04x}", inquiry.lap[2]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " inquiry_length: %i (N x 1.28) sec", inquiry.inquiry_length);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " inquiry_length: {} (N x 1.28) sec", inquiry.inquiry_length);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " num_responses: %i (N x 1.28) sec", inquiry.num_responses);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " num_responses: {} (N x 1.28) sec", inquiry.num_responses);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_INQUIRY);
|
SendEventCommandStatus(HCI_CMD_INQUIRY);
|
||||||
SendEventInquiryResponse();
|
SendEventInquiryResponse();
|
||||||
|
@ -1120,7 +1123,7 @@ void BluetoothEmu::CommandInquiryCancel(const u8* input)
|
||||||
hci_inquiry_cancel_rp reply;
|
hci_inquiry_cancel_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_INQUIRY_CANCEL");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_INQUIRY_CANCEL");
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_INQUIRY_CANCEL, &reply, sizeof(hci_inquiry_cancel_rp));
|
SendEventCommandComplete(HCI_CMD_INQUIRY_CANCEL, &reply, sizeof(hci_inquiry_cancel_rp));
|
||||||
}
|
}
|
||||||
|
@ -1130,16 +1133,17 @@ void BluetoothEmu::CommandCreateCon(const u8* input)
|
||||||
hci_create_con_cp create_connection;
|
hci_create_con_cp create_connection;
|
||||||
std::memcpy(&create_connection, input, sizeof(create_connection));
|
std::memcpy(&create_connection, input, sizeof(create_connection));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_CREATE_CON");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_CREATE_CON");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Input:");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Input:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", create_connection.bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
create_connection.bdaddr[1], create_connection.bdaddr[2], create_connection.bdaddr[3],
|
create_connection.bdaddr[0], create_connection.bdaddr[1],
|
||||||
create_connection.bdaddr[4], create_connection.bdaddr[5]);
|
create_connection.bdaddr[2], create_connection.bdaddr[3],
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " pkt_type: %i", create_connection.pkt_type);
|
create_connection.bdaddr[4], create_connection.bdaddr[5]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " page_scan_rep_mode: %i", create_connection.page_scan_rep_mode);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " pkt_type: {}", create_connection.pkt_type);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " page_scan_mode: %i", create_connection.page_scan_mode);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " page_scan_rep_mode: {}", create_connection.page_scan_rep_mode);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " clock_offset: %i", create_connection.clock_offset);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " page_scan_mode: {}", create_connection.page_scan_mode);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " accept_role_switch: %i", create_connection.accept_role_switch);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " clock_offset: {}", create_connection.clock_offset);
|
||||||
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " accept_role_switch: {}", create_connection.accept_role_switch);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_CREATE_CON);
|
SendEventCommandStatus(HCI_CMD_CREATE_CON);
|
||||||
|
|
||||||
|
@ -1155,9 +1159,9 @@ void BluetoothEmu::CommandDisconnect(const u8* input)
|
||||||
hci_discon_cp disconnect;
|
hci_discon_cp disconnect;
|
||||||
std::memcpy(&disconnect, input, sizeof(disconnect));
|
std::memcpy(&disconnect, input, sizeof(disconnect));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_DISCONNECT");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_DISCONNECT");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", disconnect.con_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", disconnect.con_handle);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Reason: 0x%02x", disconnect.reason);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Reason: {:#04x}", disconnect.reason);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_DISCONNECT);
|
SendEventCommandStatus(HCI_CMD_DISCONNECT);
|
||||||
SendEventDisconnect(disconnect.con_handle, disconnect.reason);
|
SendEventDisconnect(disconnect.con_handle, disconnect.reason);
|
||||||
|
@ -1177,11 +1181,12 @@ void BluetoothEmu::CommandAcceptCon(const u8* input)
|
||||||
"Slave (0x01)",
|
"Slave (0x01)",
|
||||||
};
|
};
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_ACCEPT_CON");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_ACCEPT_CON");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", accept_connection.bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
accept_connection.bdaddr[1], accept_connection.bdaddr[2], accept_connection.bdaddr[3],
|
accept_connection.bdaddr[0], accept_connection.bdaddr[1],
|
||||||
accept_connection.bdaddr[4], accept_connection.bdaddr[5]);
|
accept_connection.bdaddr[2], accept_connection.bdaddr[3],
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " role: %s", roles[accept_connection.role]);
|
accept_connection.bdaddr[4], accept_connection.bdaddr[5]);
|
||||||
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " role: {}", roles[accept_connection.role]);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_ACCEPT_CON);
|
SendEventCommandStatus(HCI_CMD_ACCEPT_CON);
|
||||||
|
|
||||||
|
@ -1209,10 +1214,10 @@ void BluetoothEmu::CommandLinkKeyRep(const u8* input)
|
||||||
hci_link_key_rep_cp key_rep;
|
hci_link_key_rep_cp key_rep;
|
||||||
std::memcpy(&key_rep, input, sizeof(key_rep));
|
std::memcpy(&key_rep, input, sizeof(key_rep));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_LINK_KEY_REP");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_LINK_KEY_REP");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", key_rep.bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", key_rep.bdaddr[0],
|
||||||
key_rep.bdaddr[1], key_rep.bdaddr[2], key_rep.bdaddr[3], key_rep.bdaddr[4],
|
key_rep.bdaddr[1], key_rep.bdaddr[2], key_rep.bdaddr[3], key_rep.bdaddr[4],
|
||||||
key_rep.bdaddr[5]);
|
key_rep.bdaddr[5]);
|
||||||
|
|
||||||
hci_link_key_rep_rp reply;
|
hci_link_key_rep_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
@ -1226,10 +1231,10 @@ void BluetoothEmu::CommandLinkKeyNegRep(const u8* input)
|
||||||
hci_link_key_neg_rep_cp key_neg;
|
hci_link_key_neg_rep_cp key_neg;
|
||||||
std::memcpy(&key_neg, input, sizeof(key_neg));
|
std::memcpy(&key_neg, input, sizeof(key_neg));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_LINK_KEY_NEG_REP");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_LINK_KEY_NEG_REP");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", key_neg.bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", key_neg.bdaddr[0],
|
||||||
key_neg.bdaddr[1], key_neg.bdaddr[2], key_neg.bdaddr[3], key_neg.bdaddr[4],
|
key_neg.bdaddr[1], key_neg.bdaddr[2], key_neg.bdaddr[3], key_neg.bdaddr[4],
|
||||||
key_neg.bdaddr[5]);
|
key_neg.bdaddr[5]);
|
||||||
|
|
||||||
hci_link_key_neg_rep_rp reply;
|
hci_link_key_neg_rep_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
@ -1246,9 +1251,9 @@ void BluetoothEmu::CommandChangeConPacketType(const u8* input)
|
||||||
// ntd stack sets packet type 0xcc18, which is HCI_PKT_DH5 | HCI_PKT_DM5 | HCI_PKT_DH1 |
|
// ntd stack sets packet type 0xcc18, which is HCI_PKT_DH5 | HCI_PKT_DM5 | HCI_PKT_DH1 |
|
||||||
// HCI_PKT_DM1
|
// HCI_PKT_DM1
|
||||||
// dunno what to do...run awayyyyyy!
|
// dunno what to do...run awayyyyyy!
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_CHANGE_CON_PACKET_TYPE");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_CHANGE_CON_PACKET_TYPE");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", change_packet_type.con_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", change_packet_type.con_handle);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " PacketType: 0x%04x", change_packet_type.pkt_type);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " PacketType: {:#06x}", change_packet_type.pkt_type);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_CHANGE_CON_PACKET_TYPE);
|
SendEventCommandStatus(HCI_CMD_CHANGE_CON_PACKET_TYPE);
|
||||||
SendEventConPacketTypeChange(change_packet_type.con_handle, change_packet_type.pkt_type);
|
SendEventConPacketTypeChange(change_packet_type.con_handle, change_packet_type.pkt_type);
|
||||||
|
@ -1259,8 +1264,8 @@ void BluetoothEmu::CommandAuthenticationRequested(const u8* input)
|
||||||
hci_auth_req_cp auth_req;
|
hci_auth_req_cp auth_req;
|
||||||
std::memcpy(&auth_req, input, sizeof(auth_req));
|
std::memcpy(&auth_req, input, sizeof(auth_req));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_AUTH_REQ");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_AUTH_REQ");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", auth_req.con_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", auth_req.con_handle);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_AUTH_REQ);
|
SendEventCommandStatus(HCI_CMD_AUTH_REQ);
|
||||||
SendEventAuthenticationCompleted(auth_req.con_handle);
|
SendEventAuthenticationCompleted(auth_req.con_handle);
|
||||||
|
@ -1271,13 +1276,13 @@ void BluetoothEmu::CommandRemoteNameReq(const u8* input)
|
||||||
hci_remote_name_req_cp remote_name_req;
|
hci_remote_name_req_cp remote_name_req;
|
||||||
std::memcpy(&remote_name_req, input, sizeof(remote_name_req));
|
std::memcpy(&remote_name_req, input, sizeof(remote_name_req));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_REMOTE_NAME_REQ");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_REMOTE_NAME_REQ");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", remote_name_req.bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
remote_name_req.bdaddr[1], remote_name_req.bdaddr[2], remote_name_req.bdaddr[3],
|
remote_name_req.bdaddr[0], remote_name_req.bdaddr[1], remote_name_req.bdaddr[2],
|
||||||
remote_name_req.bdaddr[4], remote_name_req.bdaddr[5]);
|
remote_name_req.bdaddr[3], remote_name_req.bdaddr[4], remote_name_req.bdaddr[5]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " page_scan_rep_mode: %i", remote_name_req.page_scan_rep_mode);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " page_scan_rep_mode: {}", remote_name_req.page_scan_rep_mode);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " page_scan_mode: %i", remote_name_req.page_scan_mode);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " page_scan_mode: {}", remote_name_req.page_scan_mode);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " clock_offset: %i", remote_name_req.clock_offset);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " clock_offset: {}", remote_name_req.clock_offset);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_REMOTE_NAME_REQ);
|
SendEventCommandStatus(HCI_CMD_REMOTE_NAME_REQ);
|
||||||
SendEventRemoteNameReq(remote_name_req.bdaddr);
|
SendEventRemoteNameReq(remote_name_req.bdaddr);
|
||||||
|
@ -1288,8 +1293,8 @@ void BluetoothEmu::CommandReadRemoteFeatures(const u8* input)
|
||||||
hci_read_remote_features_cp read_remote_features;
|
hci_read_remote_features_cp read_remote_features;
|
||||||
std::memcpy(&read_remote_features, input, sizeof(read_remote_features));
|
std::memcpy(&read_remote_features, input, sizeof(read_remote_features));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_FEATURES");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_FEATURES");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", read_remote_features.con_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", read_remote_features.con_handle);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_READ_REMOTE_FEATURES);
|
SendEventCommandStatus(HCI_CMD_READ_REMOTE_FEATURES);
|
||||||
SendEventReadRemoteFeatures(read_remote_features.con_handle);
|
SendEventReadRemoteFeatures(read_remote_features.con_handle);
|
||||||
|
@ -1300,8 +1305,8 @@ void BluetoothEmu::CommandReadRemoteVerInfo(const u8* input)
|
||||||
hci_read_remote_ver_info_cp read_remote_ver_info;
|
hci_read_remote_ver_info_cp read_remote_ver_info;
|
||||||
std::memcpy(&read_remote_ver_info, input, sizeof(read_remote_ver_info));
|
std::memcpy(&read_remote_ver_info, input, sizeof(read_remote_ver_info));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_VER_INFO");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_VER_INFO");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%02x", read_remote_ver_info.con_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#04x}", read_remote_ver_info.con_handle);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_READ_REMOTE_VER_INFO);
|
SendEventCommandStatus(HCI_CMD_READ_REMOTE_VER_INFO);
|
||||||
SendEventReadRemoteVerInfo(read_remote_ver_info.con_handle);
|
SendEventReadRemoteVerInfo(read_remote_ver_info.con_handle);
|
||||||
|
@ -1312,8 +1317,8 @@ void BluetoothEmu::CommandReadClockOffset(const u8* input)
|
||||||
hci_read_clock_offset_cp read_clock_offset;
|
hci_read_clock_offset_cp read_clock_offset;
|
||||||
std::memcpy(&read_clock_offset, input, sizeof(read_clock_offset));
|
std::memcpy(&read_clock_offset, input, sizeof(read_clock_offset));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_CLOCK_OFFSET");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_CLOCK_OFFSET");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%02x", read_clock_offset.con_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#04x}", read_clock_offset.con_handle);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_READ_CLOCK_OFFSET);
|
SendEventCommandStatus(HCI_CMD_READ_CLOCK_OFFSET);
|
||||||
SendEventReadClockOffsetComplete(read_clock_offset.con_handle);
|
SendEventReadClockOffsetComplete(read_clock_offset.con_handle);
|
||||||
|
@ -1324,12 +1329,12 @@ void BluetoothEmu::CommandSniffMode(const u8* input)
|
||||||
hci_sniff_mode_cp sniff_mode;
|
hci_sniff_mode_cp sniff_mode;
|
||||||
std::memcpy(&sniff_mode, input, sizeof(sniff_mode));
|
std::memcpy(&sniff_mode, input, sizeof(sniff_mode));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_SNIFF_MODE");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_SNIFF_MODE");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", sniff_mode.con_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", sniff_mode.con_handle);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " max_interval: %f msec", sniff_mode.max_interval * .625);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_interval: {} msec", sniff_mode.max_interval * .625);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " min_interval: %f msec", sniff_mode.min_interval * .625);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " min_interval: {} msec", sniff_mode.min_interval * .625);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " attempt: %f msec", sniff_mode.attempt * 1.25);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " attempt: {} msec", sniff_mode.attempt * 1.25);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " timeout: %f msec", sniff_mode.timeout * 1.25);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " timeout: {} msec", sniff_mode.timeout * 1.25);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_SNIFF_MODE);
|
SendEventCommandStatus(HCI_CMD_SNIFF_MODE);
|
||||||
SendEventModeChange(sniff_mode.con_handle, 0x02, sniff_mode.max_interval); // 0x02 - sniff mode
|
SendEventModeChange(sniff_mode.con_handle, 0x02, sniff_mode.max_interval); // 0x02 - sniff mode
|
||||||
|
@ -1340,9 +1345,9 @@ void BluetoothEmu::CommandWriteLinkPolicy(const u8* input)
|
||||||
hci_write_link_policy_settings_cp link_policy;
|
hci_write_link_policy_settings_cp link_policy;
|
||||||
std::memcpy(&link_policy, input, sizeof(link_policy));
|
std::memcpy(&link_policy, input, sizeof(link_policy));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_POLICY_SETTINGS");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_POLICY_SETTINGS");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", link_policy.con_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", link_policy.con_handle);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Policy: 0x%04x", link_policy.settings);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Policy: {:#06x}", link_policy.settings);
|
||||||
|
|
||||||
SendEventCommandStatus(HCI_CMD_WRITE_LINK_POLICY_SETTINGS);
|
SendEventCommandStatus(HCI_CMD_WRITE_LINK_POLICY_SETTINGS);
|
||||||
}
|
}
|
||||||
|
@ -1352,7 +1357,7 @@ void BluetoothEmu::CommandReset(const u8* input)
|
||||||
hci_status_rp reply;
|
hci_status_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_RESET");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_RESET");
|
||||||
SendEventCommandComplete(HCI_CMD_RESET, &reply, sizeof(hci_status_rp));
|
SendEventCommandComplete(HCI_CMD_RESET, &reply, sizeof(hci_status_rp));
|
||||||
|
|
||||||
// TODO: We should actually reset connections and channels and everything here.
|
// TODO: We should actually reset connections and channels and everything here.
|
||||||
|
@ -1372,9 +1377,9 @@ void BluetoothEmu::CommandSetEventFilter(const u8* input)
|
||||||
hci_set_event_filter_rp reply;
|
hci_set_event_filter_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_SET_EVENT_FILTER:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_SET_EVENT_FILTER:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " filter_type: %i", set_event_filter.filter_type);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " filter_type: {}", set_event_filter.filter_type);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " filter_condition_type: %i", set_event_filter.filter_condition_type);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " filter_condition_type: {}", set_event_filter.filter_condition_type);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_SET_EVENT_FILTER, &reply, sizeof(hci_set_event_filter_rp));
|
SendEventCommandComplete(HCI_CMD_SET_EVENT_FILTER, &reply, sizeof(hci_set_event_filter_rp));
|
||||||
}
|
}
|
||||||
|
@ -1387,8 +1392,8 @@ void BluetoothEmu::CommandWritePinType(const u8* input)
|
||||||
hci_write_pin_type_rp reply;
|
hci_write_pin_type_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PIN_TYPE:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PIN_TYPE:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " pin_type: %x", write_pin_type.pin_type);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " pin_type: {:x}", write_pin_type.pin_type);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_WRITE_PIN_TYPE, &reply, sizeof(hci_write_pin_type_rp));
|
SendEventCommandComplete(HCI_CMD_WRITE_PIN_TYPE, &reply, sizeof(hci_write_pin_type_rp));
|
||||||
}
|
}
|
||||||
|
@ -1406,18 +1411,18 @@ void BluetoothEmu::CommandReadStoredLinkKey(const u8* input)
|
||||||
if (read_stored_link_key.read_all == 1)
|
if (read_stored_link_key.read_all == 1)
|
||||||
reply.num_keys_read = static_cast<u16>(m_wiimotes.size());
|
reply.num_keys_read = static_cast<u16>(m_wiimotes.size());
|
||||||
else
|
else
|
||||||
ERROR_LOG(IOS_WIIMOTE, "CommandReadStoredLinkKey isn't looking for all devices");
|
ERROR_LOG_FMT(IOS_WIIMOTE, "CommandReadStoredLinkKey isn't looking for all devices");
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_STORED_LINK_KEY:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_STORED_LINK_KEY:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "input:");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "input:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", read_stored_link_key.bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
read_stored_link_key.bdaddr[1], read_stored_link_key.bdaddr[2],
|
read_stored_link_key.bdaddr[0], read_stored_link_key.bdaddr[1],
|
||||||
read_stored_link_key.bdaddr[3], read_stored_link_key.bdaddr[4],
|
read_stored_link_key.bdaddr[2], read_stored_link_key.bdaddr[3],
|
||||||
read_stored_link_key.bdaddr[5]);
|
read_stored_link_key.bdaddr[4], read_stored_link_key.bdaddr[5]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " read_all: %i", read_stored_link_key.read_all);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " read_all: {}", read_stored_link_key.read_all);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "return:");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "return:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " max_num_keys: %i", reply.max_num_keys);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_num_keys: {}", reply.max_num_keys);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " num_keys_read: %i", reply.num_keys_read);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " num_keys_read: {}", reply.num_keys_read);
|
||||||
|
|
||||||
SendEventLinkKeyNotification(static_cast<u8>(reply.num_keys_read));
|
SendEventLinkKeyNotification(static_cast<u8>(reply.num_keys_read));
|
||||||
SendEventCommandComplete(HCI_CMD_READ_STORED_LINK_KEY, &reply,
|
SendEventCommandComplete(HCI_CMD_READ_STORED_LINK_KEY, &reply,
|
||||||
|
@ -1429,12 +1434,12 @@ void BluetoothEmu::CommandDeleteStoredLinkKey(const u8* input)
|
||||||
hci_delete_stored_link_key_cp delete_stored_link_key;
|
hci_delete_stored_link_key_cp delete_stored_link_key;
|
||||||
std::memcpy(&delete_stored_link_key, input, sizeof(delete_stored_link_key));
|
std::memcpy(&delete_stored_link_key, input, sizeof(delete_stored_link_key));
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_OCF_DELETE_STORED_LINK_KEY");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_OCF_DELETE_STORED_LINK_KEY");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", delete_stored_link_key.bdaddr[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
delete_stored_link_key.bdaddr[1], delete_stored_link_key.bdaddr[2],
|
delete_stored_link_key.bdaddr[0], delete_stored_link_key.bdaddr[1],
|
||||||
delete_stored_link_key.bdaddr[3], delete_stored_link_key.bdaddr[4],
|
delete_stored_link_key.bdaddr[2], delete_stored_link_key.bdaddr[3],
|
||||||
delete_stored_link_key.bdaddr[5]);
|
delete_stored_link_key.bdaddr[4], delete_stored_link_key.bdaddr[5]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " delete_all: 0x%01x", delete_stored_link_key.delete_all);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " delete_all: {:#x}", delete_stored_link_key.delete_all);
|
||||||
|
|
||||||
const WiimoteDevice* wiimote = AccessWiimote(delete_stored_link_key.bdaddr);
|
const WiimoteDevice* wiimote = AccessWiimote(delete_stored_link_key.bdaddr);
|
||||||
if (wiimote == nullptr)
|
if (wiimote == nullptr)
|
||||||
|
@ -1447,8 +1452,8 @@ void BluetoothEmu::CommandDeleteStoredLinkKey(const u8* input)
|
||||||
SendEventCommandComplete(HCI_CMD_DELETE_STORED_LINK_KEY, &reply,
|
SendEventCommandComplete(HCI_CMD_DELETE_STORED_LINK_KEY, &reply,
|
||||||
sizeof(hci_delete_stored_link_key_rp));
|
sizeof(hci_delete_stored_link_key_rp));
|
||||||
|
|
||||||
ERROR_LOG(IOS_WIIMOTE, "HCI: CommandDeleteStoredLinkKey... Probably the security for linking "
|
ERROR_LOG_FMT(IOS_WIIMOTE, "HCI: CommandDeleteStoredLinkKey... Probably the security for linking "
|
||||||
"has failed. Could be a problem with loading the SCONF");
|
"has failed. Could be a problem with loading the SCONF");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BluetoothEmu::CommandWriteLocalName(const u8* input)
|
void BluetoothEmu::CommandWriteLocalName(const u8* input)
|
||||||
|
@ -1459,8 +1464,8 @@ void BluetoothEmu::CommandWriteLocalName(const u8* input)
|
||||||
hci_write_local_name_rp reply;
|
hci_write_local_name_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LOCAL_NAME:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LOCAL_NAME:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " local_name: %s", write_local_name.name);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " local_name: {}", write_local_name.name);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_WRITE_LOCAL_NAME, &reply, sizeof(hci_write_local_name_rp));
|
SendEventCommandComplete(HCI_CMD_WRITE_LOCAL_NAME, &reply, sizeof(hci_write_local_name_rp));
|
||||||
}
|
}
|
||||||
|
@ -1473,8 +1478,8 @@ void BluetoothEmu::CommandWritePageTimeOut(const u8* input)
|
||||||
hci_host_buffer_size_rp reply;
|
hci_host_buffer_size_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_TIMEOUT:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_TIMEOUT:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " timeout: %i", write_page_timeout.timeout);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " timeout: {}", write_page_timeout.timeout);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_WRITE_PAGE_TIMEOUT, &reply, sizeof(hci_host_buffer_size_rp));
|
SendEventCommandComplete(HCI_CMD_WRITE_PAGE_TIMEOUT, &reply, sizeof(hci_host_buffer_size_rp));
|
||||||
}
|
}
|
||||||
|
@ -1496,9 +1501,9 @@ void BluetoothEmu::CommandWriteScanEnable(const u8* input)
|
||||||
"HCI_INQUIRY_AND_PAGE_SCAN_ENABLE",
|
"HCI_INQUIRY_AND_PAGE_SCAN_ENABLE",
|
||||||
};
|
};
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_SCAN_ENABLE: (0x%02x)",
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_SCAN_ENABLE: ({:#04x})",
|
||||||
write_scan_enable.scan_enable);
|
write_scan_enable.scan_enable);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " scan_enable: %s", scanning[write_scan_enable.scan_enable]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " scan_enable: {}", scanning[write_scan_enable.scan_enable]);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_WRITE_SCAN_ENABLE, &reply, sizeof(hci_write_scan_enable_rp));
|
SendEventCommandComplete(HCI_CMD_WRITE_SCAN_ENABLE, &reply, sizeof(hci_write_scan_enable_rp));
|
||||||
}
|
}
|
||||||
|
@ -1511,10 +1516,10 @@ void BluetoothEmu::CommandWriteUnitClass(const u8* input)
|
||||||
hci_write_unit_class_rp reply;
|
hci_write_unit_class_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_UNIT_CLASS:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_UNIT_CLASS:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " COD[0]: 0x%02x", write_unit_class.uclass[0]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[0]: {:#04x}", write_unit_class.uclass[0]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " COD[1]: 0x%02x", write_unit_class.uclass[1]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[1]: {:#04x}", write_unit_class.uclass[1]);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " COD[2]: 0x%02x", write_unit_class.uclass[2]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[2]: {:#04x}", write_unit_class.uclass[2]);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_WRITE_UNIT_CLASS, &reply, sizeof(hci_write_unit_class_rp));
|
SendEventCommandComplete(HCI_CMD_WRITE_UNIT_CLASS, &reply, sizeof(hci_write_unit_class_rp));
|
||||||
}
|
}
|
||||||
|
@ -1527,11 +1532,11 @@ void BluetoothEmu::CommandHostBufferSize(const u8* input)
|
||||||
hci_host_buffer_size_rp reply;
|
hci_host_buffer_size_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_HOST_BUFFER_SIZE:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_HOST_BUFFER_SIZE:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " max_acl_size: %i", host_buffer_size.max_acl_size);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_acl_size: {}", host_buffer_size.max_acl_size);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " max_sco_size: %i", host_buffer_size.max_sco_size);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_sco_size: {}", host_buffer_size.max_sco_size);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " num_acl_pkts: %i", host_buffer_size.num_acl_pkts);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " num_acl_pkts: {}", host_buffer_size.num_acl_pkts);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " num_sco_pkts: %i", host_buffer_size.num_sco_pkts);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " num_sco_pkts: {}", host_buffer_size.num_sco_pkts);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_HOST_BUFFER_SIZE, &reply, sizeof(hci_host_buffer_size_rp));
|
SendEventCommandComplete(HCI_CMD_HOST_BUFFER_SIZE, &reply, sizeof(hci_host_buffer_size_rp));
|
||||||
}
|
}
|
||||||
|
@ -1542,9 +1547,9 @@ void BluetoothEmu::CommandWriteLinkSupervisionTimeout(const u8* input)
|
||||||
std::memcpy(&supervision, input, sizeof(supervision));
|
std::memcpy(&supervision, input, sizeof(supervision));
|
||||||
|
|
||||||
// timeout of 0 means timing out is disabled
|
// timeout of 0 means timing out is disabled
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " con_handle: 0x%04x", supervision.con_handle);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " con_handle: {:#06x}", supervision.con_handle);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " timeout: 0x%02x", supervision.timeout);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " timeout: {:#04x}", supervision.timeout);
|
||||||
|
|
||||||
hci_write_link_supervision_timeout_rp reply;
|
hci_write_link_supervision_timeout_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
@ -1562,8 +1567,8 @@ void BluetoothEmu::CommandWriteInquiryScanType(const u8* input)
|
||||||
hci_write_inquiry_scan_type_rp reply;
|
hci_write_inquiry_scan_type_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_SCAN_TYPE:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_SCAN_TYPE:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " type: %i", set_event_filter.type);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " type: {}", set_event_filter.type);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_WRITE_INQUIRY_SCAN_TYPE, &reply,
|
SendEventCommandComplete(HCI_CMD_WRITE_INQUIRY_SCAN_TYPE, &reply,
|
||||||
sizeof(hci_write_inquiry_scan_type_rp));
|
sizeof(hci_write_inquiry_scan_type_rp));
|
||||||
|
@ -1584,8 +1589,8 @@ void BluetoothEmu::CommandWriteInquiryMode(const u8* input)
|
||||||
"Inquiry Result format with RSSI",
|
"Inquiry Result format with RSSI",
|
||||||
"Inquiry Result with RSSI format or Extended Inquiry Result format",
|
"Inquiry Result with RSSI format or Extended Inquiry Result format",
|
||||||
};
|
};
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_MODE:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_MODE:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " mode: %s", inquiry_mode_tag[inquiry_mode.mode]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " mode: {}", inquiry_mode_tag[inquiry_mode.mode]);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_WRITE_INQUIRY_MODE, &reply, sizeof(hci_write_inquiry_mode_rp));
|
SendEventCommandComplete(HCI_CMD_WRITE_INQUIRY_MODE, &reply, sizeof(hci_write_inquiry_mode_rp));
|
||||||
}
|
}
|
||||||
|
@ -1603,8 +1608,8 @@ void BluetoothEmu::CommandWritePageScanType(const u8* input)
|
||||||
"Optional: Interlaced Scan",
|
"Optional: Interlaced Scan",
|
||||||
};
|
};
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_SCAN_TYPE:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_SCAN_TYPE:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " type: %s", page_scan_type[write_page_scan_type.type]);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " type: {}", page_scan_type[write_page_scan_type.type]);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_WRITE_PAGE_SCAN_TYPE, &reply,
|
SendEventCommandComplete(HCI_CMD_WRITE_PAGE_SCAN_TYPE, &reply,
|
||||||
sizeof(hci_write_page_scan_type_rp));
|
sizeof(hci_write_page_scan_type_rp));
|
||||||
|
@ -1620,13 +1625,13 @@ void BluetoothEmu::CommandReadLocalVer(const u8* input)
|
||||||
reply.manufacturer = 0x000F; // manufacturer: reserved for tests
|
reply.manufacturer = 0x000F; // manufacturer: reserved for tests
|
||||||
reply.lmp_subversion = 0x430e; // LMP subversion
|
reply.lmp_subversion = 0x430e; // LMP subversion
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_VER:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_VER:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "return:");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "return:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " status: %i", reply.status);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " status: {}", reply.status);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " hci_revision: %i", reply.hci_revision);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " hci_revision: {}", reply.hci_revision);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " lmp_version: %i", reply.lmp_version);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " lmp_version: {}", reply.lmp_version);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " manufacturer: %i", reply.manufacturer);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " manufacturer: {}", reply.manufacturer);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " lmp_subversion: %i", reply.lmp_subversion);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " lmp_subversion: {}", reply.lmp_subversion);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_READ_LOCAL_VER, &reply, sizeof(hci_read_local_ver_rp));
|
SendEventCommandComplete(HCI_CMD_READ_LOCAL_VER, &reply, sizeof(hci_read_local_ver_rp));
|
||||||
}
|
}
|
||||||
|
@ -1644,11 +1649,11 @@ void BluetoothEmu::CommandReadLocalFeatures(const u8* input)
|
||||||
reply.features[6] = 0x00;
|
reply.features[6] = 0x00;
|
||||||
reply.features[7] = 0x80;
|
reply.features[7] = 0x80;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_FEATURES:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_FEATURES:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "return:");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "return:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " features: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", reply.features[0],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " features: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||||
reply.features[1], reply.features[2], reply.features[3], reply.features[4],
|
reply.features[0], reply.features[1], reply.features[2], reply.features[3],
|
||||||
reply.features[5], reply.features[6], reply.features[7]);
|
reply.features[4], reply.features[5], reply.features[6], reply.features[7]);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_READ_LOCAL_FEATURES, &reply, sizeof(hci_read_local_features_rp));
|
SendEventCommandComplete(HCI_CMD_READ_LOCAL_FEATURES, &reply, sizeof(hci_read_local_features_rp));
|
||||||
}
|
}
|
||||||
|
@ -1665,12 +1670,12 @@ void BluetoothEmu::CommandReadBufferSize(const u8* input)
|
||||||
reply.max_sco_size = SCO_PKT_SIZE;
|
reply.max_sco_size = SCO_PKT_SIZE;
|
||||||
reply.num_sco_pkts = SCO_PKT_NUM;
|
reply.num_sco_pkts = SCO_PKT_NUM;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_BUFFER_SIZE:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_BUFFER_SIZE:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "return:");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "return:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " max_acl_size: %i", reply.max_acl_size);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_acl_size: {}", reply.max_acl_size);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " num_acl_pkts: %i", reply.num_acl_pkts);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " num_acl_pkts: {}", reply.num_acl_pkts);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " max_sco_size: %i", reply.max_sco_size);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_sco_size: {}", reply.max_sco_size);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " num_sco_pkts: %i", reply.num_sco_pkts);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " num_sco_pkts: {}", reply.num_sco_pkts);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_READ_BUFFER_SIZE, &reply, sizeof(hci_read_buffer_size_rp));
|
SendEventCommandComplete(HCI_CMD_READ_BUFFER_SIZE, &reply, sizeof(hci_read_buffer_size_rp));
|
||||||
}
|
}
|
||||||
|
@ -1681,10 +1686,11 @@ void BluetoothEmu::CommandReadBDAdrr(const u8* input)
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
reply.bdaddr = m_controller_bd;
|
reply.bdaddr = m_controller_bd;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_BDADDR:");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_BDADDR:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "return:");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "return:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", reply.bdaddr[0], reply.bdaddr[1],
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", reply.bdaddr[0],
|
||||||
reply.bdaddr[2], reply.bdaddr[3], reply.bdaddr[4], reply.bdaddr[5]);
|
reply.bdaddr[1], reply.bdaddr[2], reply.bdaddr[3], reply.bdaddr[4],
|
||||||
|
reply.bdaddr[5]);
|
||||||
|
|
||||||
SendEventCommandComplete(HCI_CMD_READ_BDADDR, &reply, sizeof(hci_read_bdaddr_rp));
|
SendEventCommandComplete(HCI_CMD_READ_BDADDR, &reply, sizeof(hci_read_bdaddr_rp));
|
||||||
}
|
}
|
||||||
|
@ -1701,8 +1707,8 @@ void BluetoothEmu::CommandVendorSpecific_FC4F(const u8* input, u32 size)
|
||||||
hci_status_rp reply;
|
hci_status_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
INFO_LOG(IOS_WIIMOTE, "Command: CommandVendorSpecific_FC4F: (callstack WUDiRemovePatch)");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Command: CommandVendorSpecific_FC4F: (callstack WUDiRemovePatch)");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Input (size 0x%x):", size);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Input (size {:#x}):", size);
|
||||||
|
|
||||||
Dolphin_Debugger::PrintDataBuffer(Common::Log::IOS_WIIMOTE, input, size, "Data: ");
|
Dolphin_Debugger::PrintDataBuffer(Common::Log::IOS_WIIMOTE, input, size, "Data: ");
|
||||||
|
|
||||||
|
@ -1714,8 +1720,8 @@ void BluetoothEmu::CommandVendorSpecific_FC4C(const u8* input, u32 size)
|
||||||
hci_status_rp reply;
|
hci_status_rp reply;
|
||||||
reply.status = 0x00;
|
reply.status = 0x00;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Command: CommandVendorSpecific_FC4C:");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Command: CommandVendorSpecific_FC4C:");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Input (size 0x%x):", size);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Input (size {:#x}):", size);
|
||||||
Dolphin_Debugger::PrintDataBuffer(Common::Log::IOS_WIIMOTE, input, size, "Data: ");
|
Dolphin_Debugger::PrintDataBuffer(Common::Log::IOS_WIIMOTE, input, size, "Data: ");
|
||||||
|
|
||||||
SendEventCommandComplete(0xFC4C, &reply, sizeof(hci_status_rp));
|
SendEventCommandComplete(0xFC4C, &reply, sizeof(hci_status_rp));
|
||||||
|
@ -1760,8 +1766,8 @@ WiimoteDevice* BluetoothEmu::AccessWiimote(u16 connection_handle)
|
||||||
if (wiimote)
|
if (wiimote)
|
||||||
return wiimote;
|
return wiimote;
|
||||||
|
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Can't find Wiimote by connection handle %02x", connection_handle);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Can't find Wiimote by connection handle {:02x}", connection_handle);
|
||||||
PanicAlertT("Can't find Wii Remote by connection handle %02x", connection_handle);
|
PanicAlertFmtT("Can't find Wii Remote by connection handle {0:02x}", connection_handle);
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,8 @@ IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
|
||||||
auto config_descriptor = LibusbUtils::MakeConfigDescriptor(device);
|
auto config_descriptor = LibusbUtils::MakeConfigDescriptor(device);
|
||||||
if (!config_descriptor)
|
if (!config_descriptor)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Failed to get config descriptor for device %04x:%04x",
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Failed to get config descriptor for device {:04x}:{:04x}",
|
||||||
device_descriptor.idVendor, device_descriptor.idProduct);
|
device_descriptor.idVendor, device_descriptor.idProduct);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,9 +105,9 @@ IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
|
||||||
sizeof(product));
|
sizeof(product));
|
||||||
libusb_get_string_descriptor_ascii(m_handle, device_descriptor.iSerialNumber, serial_number,
|
libusb_get_string_descriptor_ascii(m_handle, device_descriptor.iSerialNumber, serial_number,
|
||||||
sizeof(serial_number));
|
sizeof(serial_number));
|
||||||
NOTICE_LOG(IOS_WIIMOTE, "Using device %04x:%04x (rev %x) for Bluetooth: %s %s %s",
|
NOTICE_LOG_FMT(IOS_WIIMOTE, "Using device {:04x}:{:04x} (rev {:x}) for Bluetooth: {} {} {}",
|
||||||
device_descriptor.idVendor, device_descriptor.idProduct,
|
device_descriptor.idVendor, device_descriptor.idProduct,
|
||||||
device_descriptor.bcdDevice, manufacturer, product, serial_number);
|
device_descriptor.bcdDevice, manufacturer, product, serial_number);
|
||||||
m_is_wii_bt_module =
|
m_is_wii_bt_module =
|
||||||
device_descriptor.idVendor == 0x57e && device_descriptor.idProduct == 0x305;
|
device_descriptor.idVendor == 0x57e && device_descriptor.idProduct == 0x305;
|
||||||
return false;
|
return false;
|
||||||
|
@ -119,16 +119,17 @@ IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
|
||||||
{
|
{
|
||||||
if (m_last_open_error.empty())
|
if (m_last_open_error.empty())
|
||||||
{
|
{
|
||||||
CriticalAlertT(
|
CriticalAlertFmtT(
|
||||||
"Could not find any usable Bluetooth USB adapter for Bluetooth Passthrough.\n\n"
|
"Could not find any usable Bluetooth USB adapter for Bluetooth Passthrough.\n\n"
|
||||||
"The emulated console will now stop.");
|
"The emulated console will now stop.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CriticalAlertT("Could not find any usable Bluetooth USB adapter for Bluetooth Passthrough.\n"
|
CriticalAlertFmtT(
|
||||||
"The following error occurred when Dolphin tried to use an adapter:\n%s\n\n"
|
"Could not find any usable Bluetooth USB adapter for Bluetooth Passthrough.\n"
|
||||||
"The emulated console will now stop.",
|
"The following error occurred when Dolphin tried to use an adapter:\n{0}\n\n"
|
||||||
m_last_open_error.c_str());
|
"The emulated console will now stop.",
|
||||||
|
m_last_open_error);
|
||||||
}
|
}
|
||||||
Core::QueueHostJob(Core::Stop);
|
Core::QueueHostJob(Core::Stop);
|
||||||
return GetDefaultReply(IPC_ENOENT);
|
return GetDefaultReply(IPC_ENOENT);
|
||||||
|
@ -368,7 +369,7 @@ void BluetoothReal::SendHCIResetCommand()
|
||||||
const u16 payload[] = {HCI_CMD_RESET};
|
const u16 payload[] = {HCI_CMD_RESET};
|
||||||
memcpy(packet, payload, sizeof(payload));
|
memcpy(packet, payload, sizeof(payload));
|
||||||
libusb_control_transfer(m_handle, REQUEST_TYPE, 0, 0, 0, packet, sizeof(packet), TIMEOUT);
|
libusb_control_transfer(m_handle, REQUEST_TYPE, 0, 0, 0, packet, sizeof(packet), TIMEOUT);
|
||||||
INFO_LOG(IOS_WIIMOTE, "Sent a reset command to adapter");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Sent a reset command to adapter");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BluetoothReal::SendHCIDeleteLinkKeyCommand()
|
void BluetoothReal::SendHCIDeleteLinkKeyCommand()
|
||||||
|
@ -481,8 +482,8 @@ void BluetoothReal::FakeSyncButtonEvent(USB::V0IntrMessage& ctrl, const u8* payl
|
||||||
// This causes the emulated software to perform a BT inquiry and connect to found Wiimotes.
|
// This causes the emulated software to perform a BT inquiry and connect to found Wiimotes.
|
||||||
void BluetoothReal::FakeSyncButtonPressedEvent(USB::V0IntrMessage& ctrl)
|
void BluetoothReal::FakeSyncButtonPressedEvent(USB::V0IntrMessage& ctrl)
|
||||||
{
|
{
|
||||||
NOTICE_LOG(IOS_WIIMOTE, "Faking 'sync button pressed' (0x08) event packet");
|
NOTICE_LOG_FMT(IOS_WIIMOTE, "Faking 'sync button pressed' (0x08) event packet");
|
||||||
const u8 payload[1] = {0x08};
|
constexpr u8 payload[1] = {0x08};
|
||||||
FakeSyncButtonEvent(ctrl, payload, sizeof(payload));
|
FakeSyncButtonEvent(ctrl, payload, sizeof(payload));
|
||||||
m_sync_button_state = SyncButtonState::Ignored;
|
m_sync_button_state = SyncButtonState::Ignored;
|
||||||
}
|
}
|
||||||
|
@ -490,8 +491,8 @@ void BluetoothReal::FakeSyncButtonPressedEvent(USB::V0IntrMessage& ctrl)
|
||||||
// When the red sync button is held for 10 seconds, a HCI event with payload 09 is sent.
|
// When the red sync button is held for 10 seconds, a HCI event with payload 09 is sent.
|
||||||
void BluetoothReal::FakeSyncButtonHeldEvent(USB::V0IntrMessage& ctrl)
|
void BluetoothReal::FakeSyncButtonHeldEvent(USB::V0IntrMessage& ctrl)
|
||||||
{
|
{
|
||||||
NOTICE_LOG(IOS_WIIMOTE, "Faking 'sync button held' (0x09) event packet");
|
NOTICE_LOG_FMT(IOS_WIIMOTE, "Faking 'sync button held' (0x09) event packet");
|
||||||
const u8 payload[1] = {0x09};
|
constexpr u8 payload[1] = {0x09};
|
||||||
FakeSyncButtonEvent(ctrl, payload, sizeof(payload));
|
FakeSyncButtonEvent(ctrl, payload, sizeof(payload));
|
||||||
m_sync_button_state = SyncButtonState::Ignored;
|
m_sync_button_state = SyncButtonState::Ignored;
|
||||||
}
|
}
|
||||||
|
@ -511,8 +512,9 @@ void BluetoothReal::LoadLinkKeys()
|
||||||
std::optional<bdaddr_t> address = Common::StringToMacAddress(address_string);
|
std::optional<bdaddr_t> address = Common::StringToMacAddress(address_string);
|
||||||
if (!address)
|
if (!address)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Malformed MAC address (%s). Skipping loading of current link key.",
|
ERROR_LOG_FMT(IOS_WIIMOTE,
|
||||||
address_string.c_str());
|
"Malformed MAC address ({}). Skipping loading of current link key.",
|
||||||
|
address_string);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +600,7 @@ void BluetoothReal::HandleCtrlTransfer(libusb_transfer* tr)
|
||||||
|
|
||||||
if (tr->status != LIBUSB_TRANSFER_COMPLETED && tr->status != LIBUSB_TRANSFER_NO_DEVICE)
|
if (tr->status != LIBUSB_TRANSFER_COMPLETED && tr->status != LIBUSB_TRANSFER_NO_DEVICE)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "libusb command transfer failed, status: 0x%02x", tr->status);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "libusb command transfer failed, status: {:#04x}", tr->status);
|
||||||
if (!m_showed_failed_transfer.IsSet())
|
if (!m_showed_failed_transfer.IsSet())
|
||||||
{
|
{
|
||||||
Core::DisplayMessage("Failed to send a command to the Bluetooth adapter.", 10000);
|
Core::DisplayMessage("Failed to send a command to the Bluetooth adapter.", 10000);
|
||||||
|
@ -625,7 +627,7 @@ void BluetoothReal::HandleBulkOrIntrTransfer(libusb_transfer* tr)
|
||||||
if (tr->status != LIBUSB_TRANSFER_COMPLETED && tr->status != LIBUSB_TRANSFER_TIMED_OUT &&
|
if (tr->status != LIBUSB_TRANSFER_COMPLETED && tr->status != LIBUSB_TRANSFER_TIMED_OUT &&
|
||||||
tr->status != LIBUSB_TRANSFER_NO_DEVICE)
|
tr->status != LIBUSB_TRANSFER_NO_DEVICE)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "libusb transfer failed, status: 0x%02x", tr->status);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "libusb transfer failed, status: {:#04x}", tr->status);
|
||||||
if (!m_showed_failed_transfer.IsSet())
|
if (!m_showed_failed_transfer.IsSet())
|
||||||
{
|
{
|
||||||
Core::DisplayMessage("Failed to transfer to or from to the Bluetooth adapter.", 10000);
|
Core::DisplayMessage("Failed to transfer to or from to the Bluetooth adapter.", 10000);
|
||||||
|
|
|
@ -12,8 +12,8 @@ namespace IOS::HLE::Device
|
||||||
{
|
{
|
||||||
IPCCommandResult BluetoothStub::Open(const OpenRequest& request)
|
IPCCommandResult BluetoothStub::Open(const OpenRequest& request)
|
||||||
{
|
{
|
||||||
PanicAlertT("Bluetooth passthrough mode is enabled, but Dolphin was built without libusb."
|
PanicAlertFmtT("Bluetooth passthrough mode is enabled, but Dolphin was built without libusb."
|
||||||
" Passthrough mode cannot be used.");
|
" Passthrough mode cannot be used.");
|
||||||
return GetDefaultReply(IPC_ENOENT);
|
return GetDefaultReply(IPC_ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ WiimoteDevice::WiimoteDevice(Device::BluetoothEmu* host, int number, bdaddr_t bd
|
||||||
m_name(number == WIIMOTE_BALANCE_BOARD ? "Nintendo RVL-WBC-01" : "Nintendo RVL-CNT-01")
|
m_name(number == WIIMOTE_BALANCE_BOARD ? "Nintendo RVL-WBC-01" : "Nintendo RVL-CNT-01")
|
||||||
|
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WIIMOTE, "Wiimote: #%i Constructed", number);
|
INFO_LOG_FMT(IOS_WIIMOTE, "Wiimote: #{} Constructed", number);
|
||||||
|
|
||||||
m_link_key.fill(0xa0 + number);
|
m_link_key.fill(0xa0 + number);
|
||||||
m_class = {0x00, 0x04, 0x48};
|
m_class = {0x00, 0x04, 0x48};
|
||||||
|
@ -335,7 +335,7 @@ void WiimoteDevice::Update()
|
||||||
{
|
{
|
||||||
if (LinkChannel(L2CAP_PSM_HID_CNTL) && LinkChannel(L2CAP_PSM_HID_INTR))
|
if (LinkChannel(L2CAP_PSM_HID_CNTL) && LinkChannel(L2CAP_PSM_HID_INTR))
|
||||||
{
|
{
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "HID linking is complete.");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "HID linking is complete.");
|
||||||
m_hid_state = HIDState::Inactive;
|
m_hid_state = HIDState::Inactive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,12 +368,12 @@ void WiimoteDevice::ExecuteL2capCmd(u8* ptr, u32 size)
|
||||||
l2cap_hdr_t* header = (l2cap_hdr_t*)ptr;
|
l2cap_hdr_t* header = (l2cap_hdr_t*)ptr;
|
||||||
u8* data = ptr + sizeof(l2cap_hdr_t);
|
u8* data = ptr + sizeof(l2cap_hdr_t);
|
||||||
const u32 data_size = size - sizeof(l2cap_hdr_t);
|
const u32 data_size = size - sizeof(l2cap_hdr_t);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " CID 0x%04x, Len 0x%x, DataSize 0x%x", header->dcid, header->length,
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " CID {:#06x}, Len {:#x}, DataSize {:#x}", header->dcid,
|
||||||
data_size);
|
header->length, data_size);
|
||||||
|
|
||||||
if (header->length != data_size)
|
if (header->length != data_size)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WIIMOTE, "Faulty packet. It is dropped.");
|
INFO_LOG_FMT(IOS_WIIMOTE, "Faulty packet. It is dropped.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ void WiimoteDevice::ExecuteL2capCmd(u8* ptr, u32 size)
|
||||||
const auto itr = m_channels.find(header->dcid);
|
const auto itr = m_channels.find(header->dcid);
|
||||||
if (itr == m_channels.end())
|
if (itr == m_channels.end())
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "L2CAP: SendACLPacket to unknown channel %i", header->dcid);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "L2CAP: SendACLPacket to unknown channel {}", header->dcid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ void WiimoteDevice::ExecuteL2capCmd(u8* ptr, u32 size)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Unknown HID-type (0x%x) on L2CAP_PSM_HID_CNTL", hid_type);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Unknown HID-type ({:#x}) on L2CAP_PSM_HID_CNTL", hid_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -434,12 +434,12 @@ void WiimoteDevice::ExecuteL2capCmd(u8* ptr, u32 size)
|
||||||
if (hid_type == ((WiimoteCommon::HID_TYPE_DATA << 4) | WiimoteCommon::HID_PARAM_OUTPUT))
|
if (hid_type == ((WiimoteCommon::HID_TYPE_DATA << 4) | WiimoteCommon::HID_PARAM_OUTPUT))
|
||||||
m_hid_source->InterruptDataOutput(data + sizeof(hid_type), data_size - sizeof(hid_type));
|
m_hid_source->InterruptDataOutput(data + sizeof(hid_type), data_size - sizeof(hid_type));
|
||||||
else
|
else
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Unknown HID-type (0x%x) on L2CAP_PSM_HID_INTR", hid_type);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Unknown HID-type ({:#x}) on L2CAP_PSM_HID_INTR", hid_type);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Channel 0x%x has unknown PSM %x", header->dcid, channel.psm);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Channel {:#x} has unknown PSM {:x}", header->dcid, channel.psm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,8 +455,8 @@ void WiimoteDevice::SignalChannel(u8* data, u32 size)
|
||||||
switch (cmd_hdr->code)
|
switch (cmd_hdr->code)
|
||||||
{
|
{
|
||||||
case L2CAP_COMMAND_REJ:
|
case L2CAP_COMMAND_REJ:
|
||||||
ERROR_LOG(IOS_WIIMOTE, "SignalChannel - L2CAP_COMMAND_REJ (something went wrong)."
|
ERROR_LOG_FMT(IOS_WIIMOTE, "SignalChannel - L2CAP_COMMAND_REJ (something went wrong)."
|
||||||
"Try to replace your SYSCONF file with a new copy.");
|
"Try to replace your SYSCONF file with a new copy.");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L2CAP_CONNECT_REQ:
|
case L2CAP_CONNECT_REQ:
|
||||||
|
@ -480,7 +480,7 @@ void WiimoteDevice::SignalChannel(u8* data, u32 size)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(IOS_WIIMOTE, " Unknown Command-Code (0x%02x)", cmd_hdr->code);
|
ERROR_LOG_FMT(IOS_WIIMOTE, " Unknown Command-Code ({:#04x})", cmd_hdr->code);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,10 +492,10 @@ void WiimoteDevice::ReceiveConnectionReq(u8 ident, u8* data, u32 size)
|
||||||
{
|
{
|
||||||
l2cap_con_req_cp* command_connection_req = (l2cap_con_req_cp*)data;
|
l2cap_con_req_cp* command_connection_req = (l2cap_con_req_cp*)data;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionRequest");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionRequest");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Ident: {:#04x}", ident);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " PSM: 0x%04x", command_connection_req->psm);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " PSM: {:#06x}", command_connection_req->psm);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", command_connection_req->scid);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " SCID: {:#06x}", command_connection_req->scid);
|
||||||
|
|
||||||
l2cap_con_rsp_cp rsp = {};
|
l2cap_con_rsp_cp rsp = {};
|
||||||
rsp.scid = command_connection_req->scid;
|
rsp.scid = command_connection_req->scid;
|
||||||
|
@ -503,8 +503,8 @@ void WiimoteDevice::ReceiveConnectionReq(u8 ident, u8* data, u32 size)
|
||||||
|
|
||||||
if (FindChannelWithPSM(command_connection_req->psm) != nullptr)
|
if (FindChannelWithPSM(command_connection_req->psm) != nullptr)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Multiple channels with same PSM (%d) are not allowed.",
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Multiple channels with same PSM ({}) are not allowed.",
|
||||||
command_connection_req->psm);
|
command_connection_req->psm);
|
||||||
|
|
||||||
// A real wii remote refuses multiple connections with the same PSM.
|
// A real wii remote refuses multiple connections with the same PSM.
|
||||||
rsp.result = L2CAP_NO_RESOURCES;
|
rsp.result = L2CAP_NO_RESOURCES;
|
||||||
|
@ -522,14 +522,14 @@ void WiimoteDevice::ReceiveConnectionReq(u8 ident, u8* data, u32 size)
|
||||||
if (channel.psm != L2CAP_PSM_SDP && channel.psm != L2CAP_PSM_HID_CNTL &&
|
if (channel.psm != L2CAP_PSM_SDP && channel.psm != L2CAP_PSM_HID_CNTL &&
|
||||||
channel.psm != L2CAP_PSM_HID_INTR)
|
channel.psm != L2CAP_PSM_HID_INTR)
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_WIIMOTE, "L2CAP connection with unknown psm (0x%x)", channel.psm);
|
WARN_LOG_FMT(IOS_WIIMOTE, "L2CAP connection with unknown psm ({:#x})", channel.psm);
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp.result = L2CAP_SUCCESS;
|
rsp.result = L2CAP_SUCCESS;
|
||||||
rsp.dcid = local_cid;
|
rsp.dcid = local_cid;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConnectionResponse");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] SendConnectionResponse");
|
||||||
SendCommandToACL(ident, L2CAP_CONNECT_RSP, sizeof(l2cap_con_rsp_cp), (u8*)&rsp);
|
SendCommandToACL(ident, L2CAP_CONNECT_RSP, sizeof(l2cap_con_rsp_cp), (u8*)&rsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,11 +539,11 @@ void WiimoteDevice::ReceiveConnectionResponse(u8 ident, u8* data, u32 size)
|
||||||
|
|
||||||
DEBUG_ASSERT(size == sizeof(l2cap_con_rsp_cp));
|
DEBUG_ASSERT(size == sizeof(l2cap_con_rsp_cp));
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionResponse");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionResponse");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", rsp->dcid);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " DCID: {:#06x}", rsp->dcid);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", rsp->scid);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " SCID: {:#06x}", rsp->scid);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Result: 0x%04x", rsp->result);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Result: {:#06x}", rsp->result);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Status: 0x%04x", rsp->status);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Status: {:#06x}", rsp->status);
|
||||||
|
|
||||||
DEBUG_ASSERT(rsp->result == L2CAP_SUCCESS);
|
DEBUG_ASSERT(rsp->result == L2CAP_SUCCESS);
|
||||||
DEBUG_ASSERT(rsp->status == L2CAP_NO_INFO);
|
DEBUG_ASSERT(rsp->status == L2CAP_NO_INFO);
|
||||||
|
@ -564,10 +564,10 @@ void WiimoteDevice::ReceiveConfigurationReq(u8 ident, u8* data, u32 size)
|
||||||
|
|
||||||
SChannel& channel = m_channels[command_config_req->dcid];
|
SChannel& channel = m_channels[command_config_req->dcid];
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationRequest");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationRequest");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Ident: {:#04x}", ident);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", command_config_req->dcid);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " DCID: {:#06x}", command_config_req->dcid);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", command_config_req->flags);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Flags: {:#06x}", command_config_req->flags);
|
||||||
|
|
||||||
offset += sizeof(l2cap_cfg_req_cp);
|
offset += sizeof(l2cap_cfg_req_cp);
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ void WiimoteDevice::ReceiveConfigurationReq(u8 ident, u8* data, u32 size)
|
||||||
DEBUG_ASSERT(options->length == L2CAP_OPT_MTU_SIZE);
|
DEBUG_ASSERT(options->length == L2CAP_OPT_MTU_SIZE);
|
||||||
l2cap_cfg_opt_val_t* mtu = (l2cap_cfg_opt_val_t*)&data[offset];
|
l2cap_cfg_opt_val_t* mtu = (l2cap_cfg_opt_val_t*)&data[offset];
|
||||||
remote_mtu = mtu->mtu;
|
remote_mtu = mtu->mtu;
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " MTU: 0x%04x", mtu->mtu);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " MTU: {:#06x}", mtu->mtu);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -606,12 +606,12 @@ void WiimoteDevice::ReceiveConfigurationReq(u8 ident, u8* data, u32 size)
|
||||||
{
|
{
|
||||||
DEBUG_ASSERT(options->length == L2CAP_OPT_FLUSH_TIMO_SIZE);
|
DEBUG_ASSERT(options->length == L2CAP_OPT_FLUSH_TIMO_SIZE);
|
||||||
l2cap_cfg_opt_val_t* flush_time_out = (l2cap_cfg_opt_val_t*)&data[offset];
|
l2cap_cfg_opt_val_t* flush_time_out = (l2cap_cfg_opt_val_t*)&data[offset];
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " FlushTimeOut: 0x%04x", flush_time_out->flush_timo);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " FlushTimeOut: {:#06x}", flush_time_out->flush_timo);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown Option: 0x%02x", options->type);
|
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown Option: {:#04x}", options->type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +622,7 @@ void WiimoteDevice::ReceiveConfigurationReq(u8 ident, u8* data, u32 size)
|
||||||
resp_len += option_size;
|
resp_len += option_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConfigurationResponse");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] SendConfigurationResponse");
|
||||||
SendCommandToACL(ident, L2CAP_CONFIG_RSP, resp_len, temp_buffer);
|
SendCommandToACL(ident, L2CAP_CONFIG_RSP, resp_len, temp_buffer);
|
||||||
|
|
||||||
channel.remote_mtu = remote_mtu;
|
channel.remote_mtu = remote_mtu;
|
||||||
|
@ -632,10 +632,10 @@ void WiimoteDevice::ReceiveConfigurationResponse(u8 ident, u8* data, u32 size)
|
||||||
{
|
{
|
||||||
l2cap_cfg_rsp_cp* rsp = (l2cap_cfg_rsp_cp*)data;
|
l2cap_cfg_rsp_cp* rsp = (l2cap_cfg_rsp_cp*)data;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationResponse");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationResponse");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", rsp->scid);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " SCID: {:#06x}", rsp->scid);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", rsp->flags);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Flags: {:#06x}", rsp->flags);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Result: 0x%04x", rsp->result);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Result: {:#06x}", rsp->result);
|
||||||
|
|
||||||
DEBUG_ASSERT(rsp->result == L2CAP_SUCCESS);
|
DEBUG_ASSERT(rsp->result == L2CAP_SUCCESS);
|
||||||
|
|
||||||
|
@ -646,10 +646,10 @@ void WiimoteDevice::ReceiveDisconnectionReq(u8 ident, u8* data, u32 size)
|
||||||
{
|
{
|
||||||
l2cap_discon_req_cp* command_disconnection_req = (l2cap_discon_req_cp*)data;
|
l2cap_discon_req_cp* command_disconnection_req = (l2cap_discon_req_cp*)data;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveDisconnectionReq");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] ReceiveDisconnectionReq");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Ident: {:#04x}", ident);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", command_disconnection_req->dcid);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " DCID: {:#06x}", command_disconnection_req->dcid);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", command_disconnection_req->scid);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " SCID: {:#06x}", command_disconnection_req->scid);
|
||||||
|
|
||||||
DEBUG_ASSERT(DoesChannelExist(command_disconnection_req->dcid));
|
DEBUG_ASSERT(DoesChannelExist(command_disconnection_req->dcid));
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ void WiimoteDevice::ReceiveDisconnectionReq(u8 ident, u8* data, u32 size)
|
||||||
rsp.dcid = command_disconnection_req->dcid;
|
rsp.dcid = command_disconnection_req->dcid;
|
||||||
rsp.scid = command_disconnection_req->scid;
|
rsp.scid = command_disconnection_req->scid;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendDisconnectionResponse");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] SendDisconnectionResponse");
|
||||||
SendCommandToACL(ident, L2CAP_DISCONNECT_RSP, sizeof(l2cap_discon_req_cp), (u8*)&rsp);
|
SendCommandToACL(ident, L2CAP_DISCONNECT_RSP, sizeof(l2cap_discon_req_cp), (u8*)&rsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,9 +677,9 @@ void WiimoteDevice::SendConnectionRequest(u16 psm)
|
||||||
cr.psm = psm;
|
cr.psm = psm;
|
||||||
cr.scid = local_cid;
|
cr.scid = local_cid;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConnectionRequest");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] SendConnectionRequest");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Psm: 0x%04x", cr.psm);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Psm: {:#06x}", cr.psm);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Scid: 0x%04x", cr.scid);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Scid: {:#06x}", cr.scid);
|
||||||
|
|
||||||
SendCommandToACL(L2CAP_CONNECT_REQ, L2CAP_CONNECT_REQ, sizeof(l2cap_con_req_cp), (u8*)&cr);
|
SendCommandToACL(L2CAP_CONNECT_REQ, L2CAP_CONNECT_REQ, sizeof(l2cap_con_req_cp), (u8*)&cr);
|
||||||
}
|
}
|
||||||
|
@ -694,9 +694,9 @@ void WiimoteDevice::SendConfigurationRequest(u16 cid, u16 mtu, u16 flush_time_ou
|
||||||
cr->flags = 0;
|
cr->flags = 0;
|
||||||
offset += sizeof(l2cap_cfg_req_cp);
|
offset += sizeof(l2cap_cfg_req_cp);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConfigurationRequest");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] SendConfigurationRequest");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Dcid: 0x%04x", cr->dcid);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Dcid: {:#06x}", cr->dcid);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", cr->flags);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Flags: {:#06x}", cr->flags);
|
||||||
|
|
||||||
l2cap_cfg_opt_t* options;
|
l2cap_cfg_opt_t* options;
|
||||||
|
|
||||||
|
@ -708,7 +708,7 @@ void WiimoteDevice::SendConfigurationRequest(u16 cid, u16 mtu, u16 flush_time_ou
|
||||||
options->length = L2CAP_OPT_MTU_SIZE;
|
options->length = L2CAP_OPT_MTU_SIZE;
|
||||||
*(u16*)&buffer[offset] = mtu;
|
*(u16*)&buffer[offset] = mtu;
|
||||||
offset += L2CAP_OPT_MTU_SIZE;
|
offset += L2CAP_OPT_MTU_SIZE;
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " MTU: 0x%04x", mtu);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " MTU: {:#06x}", mtu);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flush_time_out != L2CAP_FLUSH_TIMO_DEFAULT)
|
if (flush_time_out != L2CAP_FLUSH_TIMO_DEFAULT)
|
||||||
|
@ -719,7 +719,7 @@ void WiimoteDevice::SendConfigurationRequest(u16 cid, u16 mtu, u16 flush_time_ou
|
||||||
options->length = L2CAP_OPT_FLUSH_TIMO_SIZE;
|
options->length = L2CAP_OPT_FLUSH_TIMO_SIZE;
|
||||||
*(u16*)&buffer[offset] = flush_time_out;
|
*(u16*)&buffer[offset] = flush_time_out;
|
||||||
offset += L2CAP_OPT_FLUSH_TIMO_SIZE;
|
offset += L2CAP_OPT_FLUSH_TIMO_SIZE;
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " FlushTimeOut: 0x%04x", flush_time_out);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " FlushTimeOut: {:#06x}", flush_time_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendCommandToACL(L2CAP_CONFIG_REQ, L2CAP_CONFIG_REQ, offset, buffer);
|
SendCommandToACL(L2CAP_CONFIG_REQ, L2CAP_CONFIG_REQ, offset, buffer);
|
||||||
|
@ -788,8 +788,8 @@ static u32 ParseCont(u8* cont)
|
||||||
{
|
{
|
||||||
return 0x00;
|
return 0x00;
|
||||||
}
|
}
|
||||||
ERROR_LOG(IOS_WIIMOTE, "ParseCont: wrong cont: %i", type_id);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "ParseCont: wrong cont: {}", type_id);
|
||||||
PanicAlert("ParseCont: wrong cont: %i", type_id);
|
PanicAlertFmt("ParseCont: wrong cont: {}", type_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,8 +823,8 @@ static int ParseAttribList(u8* attrib_id_list, u16& start_id, u16& end_id)
|
||||||
start_id = attrib_list.Read16(attrib_offset);
|
start_id = attrib_list.Read16(attrib_offset);
|
||||||
attrib_offset += 2;
|
attrib_offset += 2;
|
||||||
end_id = start_id;
|
end_id = start_id;
|
||||||
WARN_LOG(IOS_WIIMOTE, "Read just a single attrib - not tested");
|
WARN_LOG_FMT(IOS_WIIMOTE, "Read just a single attrib - not tested");
|
||||||
PanicAlert("Read just a single attrib - not tested");
|
PanicAlertFmt("Read just a single attrib - not tested");
|
||||||
}
|
}
|
||||||
|
|
||||||
return attrib_offset;
|
return attrib_offset;
|
||||||
|
@ -837,8 +837,8 @@ void WiimoteDevice::SDPSendServiceAttributeResponse(u16 cid, u16 transaction_id,
|
||||||
{
|
{
|
||||||
if (service_handle != 0x10000)
|
if (service_handle != 0x10000)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Unknown service handle %x", service_handle);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Unknown service handle {:x}", service_handle);
|
||||||
PanicAlert("Unknown service handle %x", service_handle);
|
PanicAlertFmt("Unknown service handle {:x}", service_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 cont_state = ParseCont(continuation_state);
|
const u32 cont_state = ParseCont(continuation_state);
|
||||||
|
@ -876,7 +876,7 @@ void WiimoteDevice::HandleSDP(u16 cid, u8* data, u32 size)
|
||||||
// SDP_ServiceSearchRequest
|
// SDP_ServiceSearchRequest
|
||||||
case 0x02:
|
case 0x02:
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_WIIMOTE, "!!! SDP_ServiceSearchRequest !!!");
|
WARN_LOG_FMT(IOS_WIIMOTE, "!!! SDP_ServiceSearchRequest !!!");
|
||||||
|
|
||||||
DEBUG_ASSERT(size == 13);
|
DEBUG_ASSERT(size == 13);
|
||||||
|
|
||||||
|
@ -892,7 +892,7 @@ void WiimoteDevice::HandleSDP(u16 cid, u8* data, u32 size)
|
||||||
// SDP_ServiceAttributeRequest
|
// SDP_ServiceAttributeRequest
|
||||||
case 0x04:
|
case 0x04:
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_WIIMOTE, "!!! SDP_ServiceAttributeRequest !!!");
|
WARN_LOG_FMT(IOS_WIIMOTE, "!!! SDP_ServiceAttributeRequest !!!");
|
||||||
|
|
||||||
u16 start_attr_id, end_attr_id;
|
u16 start_attr_id, end_attr_id;
|
||||||
u32 offset = 1;
|
u32 offset = 1;
|
||||||
|
@ -914,8 +914,8 @@ void WiimoteDevice::HandleSDP(u16 cid, u8* data, u32 size)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(IOS_WIIMOTE, "Unknown SDP command %x", data[0]);
|
ERROR_LOG_FMT(IOS_WIIMOTE, "Unknown SDP command {:x}", data[0]);
|
||||||
PanicAlert("WIIMOTE: Unknown SDP command %x", data[0]);
|
PanicAlertFmt("WIIMOTE: Unknown SDP command {:x}", data[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -938,9 +938,9 @@ void WiimoteDevice::SendCommandToACL(u8 ident, u8 code, u8 command_length, u8* c
|
||||||
|
|
||||||
memcpy(&data_frame[offset], command_data, command_length);
|
memcpy(&data_frame[offset], command_data, command_length);
|
||||||
|
|
||||||
DEBUG_LOG(IOS_WIIMOTE, "Send ACL Command to CPU");
|
DEBUG_LOG_FMT(IOS_WIIMOTE, "Send ACL Command to CPU");
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Ident: {:#04x}", ident);
|
||||||
DEBUG_LOG(IOS_WIIMOTE, " Code: 0x%02x", code);
|
DEBUG_LOG_FMT(IOS_WIIMOTE, " Code: {:#04x}", code);
|
||||||
|
|
||||||
m_host->SendACLPacket(GetBD(), data_frame, header->length + sizeof(l2cap_hdr_t));
|
m_host->SendACLPacket(GetBD(), data_frame, header->length + sizeof(l2cap_hdr_t));
|
||||||
}
|
}
|
||||||
|
@ -951,7 +951,7 @@ void WiimoteDevice::InterruptDataInputCallback(u8 hid_type, const u8* data, u32
|
||||||
|
|
||||||
if (!channel)
|
if (!channel)
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_WIIMOTE, "Data callback with invalid L2CAP_PSM_HID_INTR channel.");
|
WARN_LOG_FMT(IOS_WIIMOTE, "Data callback with invalid L2CAP_PSM_HID_INTR channel.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,9 +164,9 @@ void USBHost::DispatchHooks(const DeviceChangeHooks& hooks)
|
||||||
{
|
{
|
||||||
for (const auto& hook : hooks)
|
for (const auto& hook : hooks)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_USB, "%s - %s device: %04x:%04x", GetDeviceName().c_str(),
|
INFO_LOG_FMT(IOS_USB, "{} - {} device: {:04x}:{:04x}", GetDeviceName(),
|
||||||
hook.second == ChangeEvent::Inserted ? "New" : "Removed", hook.first->GetVid(),
|
hook.second == ChangeEvent::Inserted ? "New" : "Removed", hook.first->GetVid(),
|
||||||
hook.first->GetPid());
|
hook.first->GetPid());
|
||||||
OnDeviceChange(hook.second, hook.first);
|
OnDeviceChange(hook.second, hook.first);
|
||||||
}
|
}
|
||||||
if (!hooks.empty())
|
if (!hooks.empty())
|
||||||
|
@ -223,8 +223,8 @@ IPCCommandResult USBHost::HandleTransfer(std::shared_ptr<USB::Device> device, u3
|
||||||
if (ret == IPC_SUCCESS)
|
if (ret == IPC_SUCCESS)
|
||||||
return GetNoReply();
|
return GetNoReply();
|
||||||
|
|
||||||
ERROR_LOG(IOS_USB, "[%04x:%04x] Failed to submit transfer (request %u): %s", device->GetVid(),
|
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x}] Failed to submit transfer (request {}): {}",
|
||||||
device->GetPid(), request, device->GetErrorName(ret).c_str());
|
device->GetVid(), device->GetPid(), request, device->GetErrorName(ret));
|
||||||
return GetDefaultReply(ret <= 0 ? ret : IPC_EINVAL);
|
return GetDefaultReply(ret <= 0 ? ret : IPC_EINVAL);
|
||||||
}
|
}
|
||||||
} // namespace IOS::HLE::Device
|
} // namespace IOS::HLE::Device
|
||||||
|
|
|
@ -67,7 +67,7 @@ std::vector<ConfigDescriptor> LibusbDevice::GetConfigurations() const
|
||||||
{
|
{
|
||||||
if (!config_descriptor)
|
if (!config_descriptor)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_USB, "Ignoring invalid config descriptor for %04x:%04x", m_vid, m_pid);
|
ERROR_LOG_FMT(IOS_USB, "Ignoring invalid config descriptor for {:04x}:{:04x}", m_vid, m_pid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ConfigDescriptor descriptor;
|
ConfigDescriptor descriptor;
|
||||||
|
@ -82,7 +82,7 @@ std::vector<InterfaceDescriptor> LibusbDevice::GetInterfaces(const u8 config) co
|
||||||
std::vector<InterfaceDescriptor> descriptors;
|
std::vector<InterfaceDescriptor> descriptors;
|
||||||
if (config >= m_config_descriptors.size() || !m_config_descriptors[config])
|
if (config >= m_config_descriptors.size() || !m_config_descriptors[config])
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_USB, "Invalid config descriptor %u for %04x:%04x", config, m_vid, m_pid);
|
ERROR_LOG_FMT(IOS_USB, "Invalid config descriptor {} for {:04x}:{:04x}", config, m_vid, m_pid);
|
||||||
return descriptors;
|
return descriptors;
|
||||||
}
|
}
|
||||||
for (u8 i = 0; i < m_config_descriptors[config]->bNumInterfaces; ++i)
|
for (u8 i = 0; i < m_config_descriptors[config]->bNumInterfaces; ++i)
|
||||||
|
@ -104,7 +104,7 @@ LibusbDevice::GetEndpoints(const u8 config, const u8 interface_number, const u8
|
||||||
std::vector<EndpointDescriptor> descriptors;
|
std::vector<EndpointDescriptor> descriptors;
|
||||||
if (config >= m_config_descriptors.size() || !m_config_descriptors[config])
|
if (config >= m_config_descriptors.size() || !m_config_descriptors[config])
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_USB, "Invalid config descriptor %u for %04x:%04x", config, m_vid, m_pid);
|
ERROR_LOG_FMT(IOS_USB, "Invalid config descriptor {} for {:04x}:{:04x}", config, m_vid, m_pid);
|
||||||
return descriptors;
|
return descriptors;
|
||||||
}
|
}
|
||||||
ASSERT(interface_number < m_config_descriptors[config]->bNumInterfaces);
|
ASSERT(interface_number < m_config_descriptors[config]->bNumInterfaces);
|
||||||
|
@ -132,11 +132,12 @@ bool LibusbDevice::Attach()
|
||||||
|
|
||||||
if (!m_handle)
|
if (!m_handle)
|
||||||
{
|
{
|
||||||
NOTICE_LOG(IOS_USB, "[%04x:%04x] Opening device", m_vid, m_pid);
|
NOTICE_LOG_FMT(IOS_USB, "[{:04x}:{:04x}] Opening device", m_vid, m_pid);
|
||||||
const int ret = libusb_open(m_device, &m_handle);
|
const int ret = libusb_open(m_device, &m_handle);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_USB, "[%04x:%04x] Failed to open: %s", m_vid, m_pid, libusb_error_name(ret));
|
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x}] Failed to open: {}", m_vid, m_pid,
|
||||||
|
libusb_error_name(ret));
|
||||||
m_handle = nullptr;
|
m_handle = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -160,8 +161,8 @@ bool LibusbDevice::AttachAndChangeInterface(const u8 interface)
|
||||||
|
|
||||||
int LibusbDevice::CancelTransfer(const u8 endpoint)
|
int LibusbDevice::CancelTransfer(const u8 endpoint)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] Cancelling transfers (endpoint 0x%x)", m_vid, m_pid,
|
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Cancelling transfers (endpoint {:#x})", m_vid, m_pid,
|
||||||
m_active_interface, endpoint);
|
m_active_interface, endpoint);
|
||||||
const auto iterator = m_transfer_endpoints.find(endpoint);
|
const auto iterator = m_transfer_endpoints.find(endpoint);
|
||||||
if (iterator == m_transfer_endpoints.cend())
|
if (iterator == m_transfer_endpoints.cend())
|
||||||
return IPC_ENOENT;
|
return IPC_ENOENT;
|
||||||
|
@ -171,8 +172,8 @@ int LibusbDevice::CancelTransfer(const u8 endpoint)
|
||||||
|
|
||||||
int LibusbDevice::ChangeInterface(const u8 interface)
|
int LibusbDevice::ChangeInterface(const u8 interface)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] Changing interface to %d", m_vid, m_pid, m_active_interface,
|
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Changing interface to {}", m_vid, m_pid,
|
||||||
interface);
|
m_active_interface, interface);
|
||||||
m_active_interface = interface;
|
m_active_interface = interface;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -182,8 +183,8 @@ int LibusbDevice::SetAltSetting(const u8 alt_setting)
|
||||||
if (!m_device_attached)
|
if (!m_device_attached)
|
||||||
return LIBUSB_ERROR_NOT_FOUND;
|
return LIBUSB_ERROR_NOT_FOUND;
|
||||||
|
|
||||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] Setting alt setting %d", m_vid, m_pid, m_active_interface,
|
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Setting alt setting {}", m_vid, m_pid,
|
||||||
alt_setting);
|
m_active_interface, alt_setting);
|
||||||
return libusb_set_interface_alt_setting(m_handle, m_active_interface, alt_setting);
|
return libusb_set_interface_alt_setting(m_handle, m_active_interface, alt_setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,26 +193,26 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr<CtrlMessage> cmd)
|
||||||
if (!m_device_attached)
|
if (!m_device_attached)
|
||||||
return LIBUSB_ERROR_NOT_FOUND;
|
return LIBUSB_ERROR_NOT_FOUND;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_USB,
|
DEBUG_LOG_FMT(IOS_USB,
|
||||||
"[%04x:%04x %d] Control: bRequestType=%02x bRequest=%02x wValue=%04x"
|
"[{:04x}:{:04x} {}] Control: bRequestType={:02x} bRequest={:02x} wValue={:04x}"
|
||||||
" wIndex=%04x wLength=%04x",
|
" wIndex={:04x} wLength={:04x}",
|
||||||
m_vid, m_pid, m_active_interface, cmd->request_type, cmd->request, cmd->value,
|
m_vid, m_pid, m_active_interface, cmd->request_type, cmd->request, cmd->value,
|
||||||
cmd->index, cmd->length);
|
cmd->index, cmd->length);
|
||||||
|
|
||||||
switch ((cmd->request_type << 8) | cmd->request)
|
switch ((cmd->request_type << 8) | cmd->request)
|
||||||
{
|
{
|
||||||
// The following requests have to go through libusb and cannot be directly sent to the device.
|
// The following requests have to go through libusb and cannot be directly sent to the device.
|
||||||
case USBHDR(DIR_HOST2DEVICE, TYPE_STANDARD, REC_INTERFACE, REQUEST_SET_INTERFACE):
|
case USBHDR(DIR_HOST2DEVICE, TYPE_STANDARD, REC_INTERFACE, REQUEST_SET_INTERFACE):
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] REQUEST_SET_INTERFACE index=%04x value=%04x", m_vid, m_pid,
|
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] REQUEST_SET_INTERFACE index={:04x} value={:04x}",
|
||||||
m_active_interface, cmd->index, cmd->value);
|
m_vid, m_pid, m_active_interface, cmd->index, cmd->value);
|
||||||
if (static_cast<u8>(cmd->index) != m_active_interface)
|
if (static_cast<u8>(cmd->index) != m_active_interface)
|
||||||
{
|
{
|
||||||
const int ret = ChangeInterface(static_cast<u8>(cmd->index));
|
const int ret = ChangeInterface(static_cast<u8>(cmd->index));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_USB, "[%04x:%04x %d] Failed to change interface to %d: %s", m_vid, m_pid,
|
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Failed to change interface to {}: {}", m_vid,
|
||||||
m_active_interface, cmd->index, libusb_error_name(ret));
|
m_pid, m_active_interface, cmd->index, libusb_error_name(ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,8 +223,8 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr<CtrlMessage> cmd)
|
||||||
}
|
}
|
||||||
case USBHDR(DIR_HOST2DEVICE, TYPE_STANDARD, REC_DEVICE, REQUEST_SET_CONFIGURATION):
|
case USBHDR(DIR_HOST2DEVICE, TYPE_STANDARD, REC_DEVICE, REQUEST_SET_CONFIGURATION):
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] REQUEST_SET_CONFIGURATION index=%04x value=%04x", m_vid,
|
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] REQUEST_SET_CONFIGURATION index={:04x} value={:04x}",
|
||||||
m_pid, m_active_interface, cmd->index, cmd->value);
|
m_vid, m_pid, m_active_interface, cmd->index, cmd->value);
|
||||||
ReleaseAllInterfacesForCurrentConfig();
|
ReleaseAllInterfacesForCurrentConfig();
|
||||||
const int ret = libusb_set_configuration(m_handle, cmd->value);
|
const int ret = libusb_set_configuration(m_handle, cmd->value);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
@ -252,8 +253,8 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr<BulkMessage> cmd)
|
||||||
if (!m_device_attached)
|
if (!m_device_attached)
|
||||||
return LIBUSB_ERROR_NOT_FOUND;
|
return LIBUSB_ERROR_NOT_FOUND;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_USB, "[%04x:%04x %d] Bulk: length=%04x endpoint=%02x", m_vid, m_pid,
|
DEBUG_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Bulk: length={:04x} endpoint={:02x}", m_vid, m_pid,
|
||||||
m_active_interface, cmd->length, cmd->endpoint);
|
m_active_interface, cmd->length, cmd->endpoint);
|
||||||
|
|
||||||
libusb_transfer* transfer = libusb_alloc_transfer(0);
|
libusb_transfer* transfer = libusb_alloc_transfer(0);
|
||||||
libusb_fill_bulk_transfer(transfer, m_handle, cmd->endpoint,
|
libusb_fill_bulk_transfer(transfer, m_handle, cmd->endpoint,
|
||||||
|
@ -269,8 +270,8 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr<IntrMessage> cmd)
|
||||||
if (!m_device_attached)
|
if (!m_device_attached)
|
||||||
return LIBUSB_ERROR_NOT_FOUND;
|
return LIBUSB_ERROR_NOT_FOUND;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_USB, "[%04x:%04x %d] Interrupt: length=%04x endpoint=%02x", m_vid, m_pid,
|
DEBUG_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Interrupt: length={:04x} endpoint={:02x}", m_vid,
|
||||||
m_active_interface, cmd->length, cmd->endpoint);
|
m_pid, m_active_interface, cmd->length, cmd->endpoint);
|
||||||
|
|
||||||
libusb_transfer* transfer = libusb_alloc_transfer(0);
|
libusb_transfer* transfer = libusb_alloc_transfer(0);
|
||||||
libusb_fill_interrupt_transfer(transfer, m_handle, cmd->endpoint,
|
libusb_fill_interrupt_transfer(transfer, m_handle, cmd->endpoint,
|
||||||
|
@ -286,8 +287,9 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr<IsoMessage> cmd)
|
||||||
if (!m_device_attached)
|
if (!m_device_attached)
|
||||||
return LIBUSB_ERROR_NOT_FOUND;
|
return LIBUSB_ERROR_NOT_FOUND;
|
||||||
|
|
||||||
DEBUG_LOG(IOS_USB, "[%04x:%04x %d] Isochronous: length=%04x endpoint=%02x num_packets=%02x",
|
DEBUG_LOG_FMT(IOS_USB,
|
||||||
m_vid, m_pid, m_active_interface, cmd->length, cmd->endpoint, cmd->num_packets);
|
"[{:04x}:{:04x} {}] Isochronous: length={:04x} endpoint={:02x} num_packets={:02x}",
|
||||||
|
m_vid, m_pid, m_active_interface, cmd->length, cmd->endpoint, cmd->num_packets);
|
||||||
|
|
||||||
libusb_transfer* transfer = libusb_alloc_transfer(cmd->num_packets);
|
libusb_transfer* transfer = libusb_alloc_transfer(cmd->num_packets);
|
||||||
transfer->buffer = cmd->MakeBuffer(cmd->length).release();
|
transfer->buffer = cmd->MakeBuffer(cmd->length).release();
|
||||||
|
@ -360,7 +362,7 @@ void LibusbDevice::TransferEndpoint::HandleTransfer(libusb_transfer* transfer,
|
||||||
const auto iterator = m_transfers.find(transfer);
|
const auto iterator = m_transfers.find(transfer);
|
||||||
if (iterator == m_transfers.cend())
|
if (iterator == m_transfers.cend())
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_USB, "No such transfer");
|
ERROR_LOG_FMT(IOS_USB, "No such transfer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,9 +380,10 @@ void LibusbDevice::TransferEndpoint::HandleTransfer(libusb_transfer* transfer,
|
||||||
case LIBUSB_TRANSFER_TIMED_OUT:
|
case LIBUSB_TRANSFER_TIMED_OUT:
|
||||||
case LIBUSB_TRANSFER_OVERFLOW:
|
case LIBUSB_TRANSFER_OVERFLOW:
|
||||||
case LIBUSB_TRANSFER_STALL:
|
case LIBUSB_TRANSFER_STALL:
|
||||||
ERROR_LOG(IOS_USB, "[%04x:%04x %d] %s transfer (endpoint 0x%02x) failed: %s", device->m_vid,
|
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] {} transfer (endpoint {:#04x}) failed: {}",
|
||||||
device->m_pid, device->m_active_interface, s_transfer_types.at(transfer->type),
|
device->m_vid, device->m_pid, device->m_active_interface,
|
||||||
transfer->endpoint, libusb_error_name(transfer->status));
|
s_transfer_types.at(transfer->type), transfer->endpoint,
|
||||||
|
libusb_error_name(transfer->status));
|
||||||
return_value = transfer->status == LIBUSB_TRANSFER_STALL ? -7004 : -5;
|
return_value = transfer->status == LIBUSB_TRANSFER_STALL ? -7004 : -5;
|
||||||
break;
|
break;
|
||||||
case LIBUSB_TRANSFER_NO_DEVICE:
|
case LIBUSB_TRANSFER_NO_DEVICE:
|
||||||
|
@ -396,7 +399,7 @@ void LibusbDevice::TransferEndpoint::CancelTransfers()
|
||||||
std::lock_guard<std::mutex> lk(m_transfers_mutex);
|
std::lock_guard<std::mutex> lk(m_transfers_mutex);
|
||||||
if (m_transfers.empty())
|
if (m_transfers.empty())
|
||||||
return;
|
return;
|
||||||
INFO_LOG(IOS_USB, "Cancelling %ld transfer(s)", m_transfers.size());
|
INFO_LOG_FMT(IOS_USB, "Cancelling {} transfer(s)", m_transfers.size());
|
||||||
for (const auto& pending_transfer : m_transfers)
|
for (const auto& pending_transfer : m_transfers)
|
||||||
libusb_cancel_transfer(pending_transfer.first);
|
libusb_cancel_transfer(pending_transfer.first);
|
||||||
}
|
}
|
||||||
|
@ -427,16 +430,16 @@ int LibusbDevice::ClaimAllInterfaces(u8 config_num) const
|
||||||
const int ret2 = libusb_detach_kernel_driver(m_handle, i);
|
const int ret2 = libusb_detach_kernel_driver(m_handle, i);
|
||||||
if (ret2 < 0 && ret2 != LIBUSB_ERROR_NOT_FOUND && ret2 != LIBUSB_ERROR_NOT_SUPPORTED)
|
if (ret2 < 0 && ret2 != LIBUSB_ERROR_NOT_FOUND && ret2 != LIBUSB_ERROR_NOT_SUPPORTED)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_USB, "[%04x:%04x] Failed to detach kernel driver: %s", m_vid, m_pid,
|
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x}] Failed to detach kernel driver: {}", m_vid, m_pid,
|
||||||
libusb_error_name(ret2));
|
libusb_error_name(ret2));
|
||||||
return ret2;
|
return ret2;
|
||||||
}
|
}
|
||||||
return libusb_claim_interface(m_handle, i);
|
return libusb_claim_interface(m_handle, i);
|
||||||
});
|
});
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_USB, "[%04x:%04x] Failed to claim all interfaces (configuration %u)", m_vid,
|
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x}] Failed to claim all interfaces (configuration {})",
|
||||||
m_pid, config_num);
|
m_vid, m_pid, config_num);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -448,8 +451,8 @@ int LibusbDevice::ReleaseAllInterfaces(u8 config_num) const
|
||||||
});
|
});
|
||||||
if (ret < 0 && ret != LIBUSB_ERROR_NO_DEVICE && ret != LIBUSB_ERROR_NOT_FOUND)
|
if (ret < 0 && ret != LIBUSB_ERROR_NO_DEVICE && ret != LIBUSB_ERROR_NOT_FOUND)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_USB, "[%04x:%04x] Failed to release all interfaces (configuration %u)", m_vid,
|
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x}] Failed to release all interfaces (configuration {})",
|
||||||
m_pid, config_num);
|
m_vid, m_pid, config_num);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ IPCCommandResult OH0::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
IPCCommandResult OH0::IOCtlV(const IOCtlVRequest& request)
|
IPCCommandResult OH0::IOCtlV(const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_USB, "/dev/usb/oh0 - IOCtlV %u", request.request);
|
INFO_LOG_FMT(IOS_USB, "/dev/usb/oh0 - IOCtlV {}", request.request);
|
||||||
switch (request.request)
|
switch (request.request)
|
||||||
{
|
{
|
||||||
case USB::IOCTLV_USBV0_GETDEVLIST:
|
case USB::IOCTLV_USBV0_GETDEVLIST:
|
||||||
|
@ -145,7 +145,7 @@ IPCCommandResult OH0::GetRhPortStatus(const IOCtlVRequest& request) const
|
||||||
if (!request.HasNumberOfValidVectors(1, 1))
|
if (!request.HasNumberOfValidVectors(1, 1))
|
||||||
return GetDefaultReply(IPC_EINVAL);
|
return GetDefaultReply(IPC_EINVAL);
|
||||||
|
|
||||||
ERROR_LOG(IOS_USB, "Unimplemented IOCtlV: IOCTLV_USBV0_GETRHPORTSTATUS");
|
ERROR_LOG_FMT(IOS_USB, "Unimplemented IOCtlV: IOCTLV_USBV0_GETRHPORTSTATUS");
|
||||||
request.Dump(GetDeviceName(), Common::Log::IOS_USB, Common::Log::LERROR);
|
request.Dump(GetDeviceName(), Common::Log::IOS_USB, Common::Log::LERROR);
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetDefaultReply(IPC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ IPCCommandResult OH0::SetRhPortStatus(const IOCtlVRequest& request)
|
||||||
if (!request.HasNumberOfValidVectors(2, 0))
|
if (!request.HasNumberOfValidVectors(2, 0))
|
||||||
return GetDefaultReply(IPC_EINVAL);
|
return GetDefaultReply(IPC_EINVAL);
|
||||||
|
|
||||||
ERROR_LOG(IOS_USB, "Unimplemented IOCtlV: IOCTLV_USBV0_SETRHPORTSTATUS");
|
ERROR_LOG_FMT(IOS_USB, "Unimplemented IOCtlV: IOCTLV_USBV0_SETRHPORTSTATUS");
|
||||||
request.Dump(GetDeviceName(), Common::Log::IOS_USB, Common::Log::LERROR);
|
request.Dump(GetDeviceName(), Common::Log::IOS_USB, Common::Log::LERROR);
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetDefaultReply(IPC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ IPCCommandResult OH0::RegisterClassChangeHook(const IOCtlVRequest& request)
|
||||||
{
|
{
|
||||||
if (!request.HasNumberOfValidVectors(1, 0))
|
if (!request.HasNumberOfValidVectors(1, 0))
|
||||||
return GetDefaultReply(IPC_EINVAL);
|
return GetDefaultReply(IPC_EINVAL);
|
||||||
WARN_LOG(IOS_USB, "Unimplemented IOCtlV: USB::IOCTLV_USBV0_DEVICECLASSCHANGE (no reply)");
|
WARN_LOG_FMT(IOS_USB, "Unimplemented IOCtlV: USB::IOCTLV_USBV0_DEVICECLASSCHANGE (no reply)");
|
||||||
request.Dump(GetDeviceName(), Common::Log::IOS_USB, Common::Log::LWARNING);
|
request.Dump(GetDeviceName(), Common::Log::IOS_USB, Common::Log::LWARNING);
|
||||||
return GetNoReply();
|
return GetNoReply();
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,8 +169,8 @@ IPCCommandResult USBV5ResourceManager::SuspendResume(USBV5Device& device,
|
||||||
|
|
||||||
// Note: this is unimplemented because there's no easy way to do this in a
|
// Note: this is unimplemented because there's no easy way to do this in a
|
||||||
// platform-independant way (libusb does not support power management).
|
// platform-independant way (libusb does not support power management).
|
||||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] Received %s command", host_device->GetVid(),
|
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Received {} command", host_device->GetVid(),
|
||||||
host_device->GetPid(), device.interface_number, resumed == 0 ? "suspend" : "resume");
|
host_device->GetPid(), device.interface_number, resumed == 0 ? "suspend" : "resume");
|
||||||
return GetDefaultReply(IPC_SUCCESS);
|
return GetDefaultReply(IPC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ void USBV5ResourceManager::TriggerDeviceChangeReply()
|
||||||
|
|
||||||
m_ios.EnqueueIPCReply(*m_devicechange_hook_request, num_devices, 0, CoreTiming::FromThread::ANY);
|
m_ios.EnqueueIPCReply(*m_devicechange_hook_request, num_devices, 0, CoreTiming::FromThread::ANY);
|
||||||
m_devicechange_hook_request.reset();
|
m_devicechange_hook_request.reset();
|
||||||
INFO_LOG(IOS_USB, "%d USBv5 device(s), including interfaces", num_devices);
|
INFO_LOG_FMT(IOS_USB, "{} USBv5 device(s), including interfaces", num_devices);
|
||||||
}
|
}
|
||||||
} // namespace Device
|
} // namespace Device
|
||||||
} // namespace IOS::HLE
|
} // namespace IOS::HLE
|
||||||
|
|
|
@ -192,7 +192,7 @@ void USB_HIDv4::TriggerDeviceChangeReply()
|
||||||
const std::vector<u8> device_section = GetDeviceEntry(*device.second.get());
|
const std::vector<u8> device_section = GetDeviceEntry(*device.second.get());
|
||||||
if (offset + device_section.size() > m_devicechange_hook_request->buffer_out_size - 1)
|
if (offset + device_section.size() > m_devicechange_hook_request->buffer_out_size - 1)
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_USB, "Too many devices connected, skipping");
|
WARN_LOG_FMT(IOS_USB, "Too many devices connected, skipping");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Memory::CopyToEmu(dest + offset, device_section.data(), device_section.size());
|
Memory::CopyToEmu(dest + offset, device_section.data(), device_section.size());
|
||||||
|
|
|
@ -190,7 +190,7 @@ USB_KBD::USB_KBD(Kernel& ios, const std::string& device_name) : Device(ios, devi
|
||||||
|
|
||||||
IPCCommandResult USB_KBD::Open(const OpenRequest& request)
|
IPCCommandResult USB_KBD::Open(const OpenRequest& request)
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS, "USB_KBD: Open");
|
INFO_LOG_FMT(IOS, "USB_KBD: Open");
|
||||||
IniFile ini;
|
IniFile ini;
|
||||||
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||||
ini.GetOrCreateSection("USB Keyboard")->Get("Layout", &m_keyboard_layout, KBD_LAYOUT_QWERTY);
|
ini.GetOrCreateSection("USB Keyboard")->Get("Layout", &m_keyboard_layout, KBD_LAYOUT_QWERTY);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "Core/IOS/WFS/WFSI.h"
|
#include "Core/IOS/WFS/WFSI.h"
|
||||||
|
|
||||||
#include <cinttypes>
|
|
||||||
#include <mbedtls/aes.h>
|
#include <mbedtls/aes.h>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -51,10 +50,10 @@ void ARCUnpacker::AddBytes(const std::vector<u8>& bytes)
|
||||||
|
|
||||||
void ARCUnpacker::Extract(const WriteCallback& callback)
|
void ARCUnpacker::Extract(const WriteCallback& callback)
|
||||||
{
|
{
|
||||||
u32 fourcc = Common::swap32(m_whole_file.data());
|
const u32 fourcc = Common::swap32(m_whole_file.data());
|
||||||
if (fourcc != 0x55AA382D)
|
if (fourcc != 0x55AA382D)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WFS, "ARCUnpacker: invalid fourcc (%08x)", fourcc);
|
ERROR_LOG_FMT(IOS_WFS, "ARCUnpacker: invalid fourcc ({:08x})", fourcc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,14 +134,14 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
case IOCTL_WFSI_IMPORT_TITLE_INIT:
|
case IOCTL_WFSI_IMPORT_TITLE_INIT:
|
||||||
{
|
{
|
||||||
u32 tmd_addr = Memory::Read_U32(request.buffer_in);
|
const u32 tmd_addr = Memory::Read_U32(request.buffer_in);
|
||||||
u32 tmd_size = Memory::Read_U32(request.buffer_in + 4);
|
const u32 tmd_size = Memory::Read_U32(request.buffer_in + 4);
|
||||||
|
|
||||||
m_patch_type = static_cast<PatchType>(Memory::Read_U32(request.buffer_in + 32));
|
m_patch_type = static_cast<PatchType>(Memory::Read_U32(request.buffer_in + 32));
|
||||||
m_continue_install = Memory::Read_U32(request.buffer_in + 36);
|
m_continue_install = Memory::Read_U32(request.buffer_in + 36);
|
||||||
|
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_IMPORT_TITLE_INIT: patch type %d, continue install: %s",
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_IMPORT_TITLE_INIT: patch type {}, continue install: {}",
|
||||||
m_patch_type, m_continue_install ? "true" : "false");
|
m_patch_type, m_continue_install ? "true" : "false");
|
||||||
|
|
||||||
if (m_patch_type == PatchType::PATCH_TYPE_2)
|
if (m_patch_type == PatchType::PATCH_TYPE_2)
|
||||||
{
|
{
|
||||||
|
@ -155,7 +154,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
if (!IOS::ES::IsValidTMDSize(tmd_size))
|
if (!IOS::ES::IsValidTMDSize(tmd_size))
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WFS, "IOCTL_WFSI_IMPORT_TITLE_INIT: TMD size too large (%d)", tmd_size);
|
ERROR_LOG_FMT(IOS_WFS, "IOCTL_WFSI_IMPORT_TITLE_INIT: TMD size too large ({})", tmd_size);
|
||||||
return_error_code = IPC_EINVAL;
|
return_error_code = IPC_EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +163,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
Memory::CopyFromEmu(tmd_bytes.data(), tmd_addr, tmd_size);
|
Memory::CopyFromEmu(tmd_bytes.data(), tmd_addr, tmd_size);
|
||||||
m_tmd.SetBytes(std::move(tmd_bytes));
|
m_tmd.SetBytes(std::move(tmd_bytes));
|
||||||
|
|
||||||
IOS::ES::TicketReader ticket = m_ios.GetES()->FindSignedTicket(m_tmd.GetTitleId());
|
const IOS::ES::TicketReader ticket = m_ios.GetES()->FindSignedTicket(m_tmd.GetTitleId());
|
||||||
if (!ticket.IsValid())
|
if (!ticket.IsValid())
|
||||||
{
|
{
|
||||||
return_error_code = -11028;
|
return_error_code = -11028;
|
||||||
|
@ -195,11 +194,11 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
"IOCTL_WFSI_PREPARE_CONTENT";
|
"IOCTL_WFSI_PREPARE_CONTENT";
|
||||||
|
|
||||||
// Initializes the IV from the index of the content in the TMD contents.
|
// Initializes the IV from the index of the content in the TMD contents.
|
||||||
u32 content_id = Memory::Read_U32(request.buffer_in + 8);
|
const u32 content_id = Memory::Read_U32(request.buffer_in + 8);
|
||||||
IOS::ES::Content content_info;
|
IOS::ES::Content content_info;
|
||||||
if (!m_tmd.FindContentById(content_id, &content_info))
|
if (!m_tmd.FindContentById(content_id, &content_info))
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_WFS, "%s: Content id %08x not found", ioctl_name, content_id);
|
WARN_LOG_FMT(IOS_WFS, "{}: Content id {:08x} not found", ioctl_name, content_id);
|
||||||
return_error_code = -10003;
|
return_error_code = -10003;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -207,8 +206,8 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
memset(m_aes_iv, 0, sizeof(m_aes_iv));
|
memset(m_aes_iv, 0, sizeof(m_aes_iv));
|
||||||
m_aes_iv[0] = content_info.index >> 8;
|
m_aes_iv[0] = content_info.index >> 8;
|
||||||
m_aes_iv[1] = content_info.index & 0xFF;
|
m_aes_iv[1] = content_info.index & 0xFF;
|
||||||
INFO_LOG(IOS_WFS, "%s: Content id %08x found at index %d", ioctl_name, content_id,
|
INFO_LOG_FMT(IOS_WFS, "{}: Content id {:08x} found at index {}", ioctl_name, content_id,
|
||||||
content_info.index);
|
content_info.index);
|
||||||
|
|
||||||
m_arc_unpacker.Reset();
|
m_arc_unpacker.Reset();
|
||||||
break;
|
break;
|
||||||
|
@ -221,11 +220,11 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
"IOCTL_WFSI_IMPORT_PROFILE" :
|
"IOCTL_WFSI_IMPORT_PROFILE" :
|
||||||
"IOCTL_WFSI_IMPORT_CONTENT";
|
"IOCTL_WFSI_IMPORT_CONTENT";
|
||||||
|
|
||||||
u32 content_id = Memory::Read_U32(request.buffer_in + 0xC);
|
const u32 content_id = Memory::Read_U32(request.buffer_in + 0xC);
|
||||||
u32 input_ptr = Memory::Read_U32(request.buffer_in + 0x10);
|
const u32 input_ptr = Memory::Read_U32(request.buffer_in + 0x10);
|
||||||
u32 input_size = Memory::Read_U32(request.buffer_in + 0x14);
|
const u32 input_size = Memory::Read_U32(request.buffer_in + 0x14);
|
||||||
INFO_LOG(IOS_WFS, "%s: %08x bytes of data at %08x from content id %d", ioctl_name, input_size,
|
INFO_LOG_FMT(IOS_WFS, "{}: {:08x} bytes of data at {:08x} from content id {}", ioctl_name,
|
||||||
input_ptr, content_id);
|
input_size, input_ptr, content_id);
|
||||||
|
|
||||||
std::vector<u8> decrypted(input_size);
|
std::vector<u8> decrypted(input_size);
|
||||||
mbedtls_aes_crypt_cbc(&m_aes_ctx, MBEDTLS_AES_DECRYPT, input_size, m_aes_iv,
|
mbedtls_aes_crypt_cbc(&m_aes_ctx, MBEDTLS_AES_DECRYPT, input_size, m_aes_iv,
|
||||||
|
@ -241,17 +240,17 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
const char* ioctl_name = request.request == IOCTL_WFSI_IMPORT_PROFILE_END ?
|
const char* ioctl_name = request.request == IOCTL_WFSI_IMPORT_PROFILE_END ?
|
||||||
"IOCTL_WFSI_IMPORT_PROFILE_END" :
|
"IOCTL_WFSI_IMPORT_PROFILE_END" :
|
||||||
"IOCTL_WFSI_IMPORT_CONTENT_END";
|
"IOCTL_WFSI_IMPORT_CONTENT_END";
|
||||||
INFO_LOG(IOS_WFS, "%s", ioctl_name);
|
INFO_LOG_FMT(IOS_WFS, "{}", ioctl_name);
|
||||||
|
|
||||||
auto callback = [this](const std::string& filename, const std::vector<u8>& bytes) {
|
const auto callback = [this](const std::string& filename, const std::vector<u8>& bytes) {
|
||||||
INFO_LOG(IOS_WFS, "Extract: %s (%zd bytes)", filename.c_str(), bytes.size());
|
INFO_LOG_FMT(IOS_WFS, "Extract: {} ({} bytes)", filename, bytes.size());
|
||||||
|
|
||||||
std::string path = WFS::NativePath(m_base_extract_path + "/" + filename);
|
const std::string path = WFS::NativePath(m_base_extract_path + '/' + filename);
|
||||||
File::CreateFullPath(path);
|
File::CreateFullPath(path);
|
||||||
File::IOFile f(path, "wb");
|
File::IOFile f(path, "wb");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WFS, "Could not extract %s to %s", filename.c_str(), path.c_str());
|
ERROR_LOG_FMT(IOS_WFS, "Could not extract {} to {}", filename, path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
f.WriteBytes(bytes.data(), bytes.size());
|
f.WriteBytes(bytes.data(), bytes.size());
|
||||||
|
@ -321,7 +320,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
case IOCTL_WFSI_FINALIZE_PATCH_INSTALL:
|
case IOCTL_WFSI_FINALIZE_PATCH_INSTALL:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_FINALIZE_PATCH_INSTALL");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_FINALIZE_PATCH_INSTALL");
|
||||||
if (m_patch_type != NOT_A_PATCH)
|
if (m_patch_type != NOT_A_PATCH)
|
||||||
FinalizePatchInstall();
|
FinalizePatchInstall();
|
||||||
break;
|
break;
|
||||||
|
@ -331,13 +330,13 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
// Bytes 0-4: ??
|
// Bytes 0-4: ??
|
||||||
// Bytes 4-8: game id
|
// Bytes 4-8: game id
|
||||||
// Bytes 1c-1e: title id?
|
// Bytes 1c-1e: title id?
|
||||||
WARN_LOG(IOS_WFS, "IOCTL_WFSI_DELETE_TITLE: unimplemented");
|
WARN_LOG_FMT(IOS_WFS, "IOCTL_WFSI_DELETE_TITLE: unimplemented");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFSI_CHANGE_TITLE:
|
case IOCTL_WFSI_CHANGE_TITLE:
|
||||||
{
|
{
|
||||||
u64 title_id = Memory::Read_U64(request.buffer_in);
|
const u64 title_id = Memory::Read_U64(request.buffer_in);
|
||||||
u16 group_id = Memory::Read_U16(request.buffer_in + 0x1C);
|
const u16 group_id = Memory::Read_U16(request.buffer_in + 0x1C);
|
||||||
|
|
||||||
// TODO: Handle permissions
|
// TODO: Handle permissions
|
||||||
SetCurrentTitleIdAndGroupId(title_id, group_id);
|
SetCurrentTitleIdAndGroupId(title_id, group_id);
|
||||||
|
@ -346,8 +345,8 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
const std::string homedir_path = fmt::format("/vol/{}/title/{}/{}/", m_device_name,
|
const std::string homedir_path = fmt::format("/vol/{}/title/{}/{}/", m_device_name,
|
||||||
m_current_group_id_str, m_current_title_id_str);
|
m_current_group_id_str, m_current_title_id_str);
|
||||||
const u16 homedir_path_len = static_cast<u16>(homedir_path.size());
|
const u16 homedir_path_len = static_cast<u16>(homedir_path.size());
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_CHANGE_TITLE: %s (path_len: 0x%x)", homedir_path.c_str(),
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_CHANGE_TITLE: {} (path_len: {:#x})", homedir_path,
|
||||||
homedir_path_len);
|
homedir_path_len);
|
||||||
|
|
||||||
return_error_code = -3;
|
return_error_code = -3;
|
||||||
if (homedir_path_len > 0x1FD)
|
if (homedir_path_len > 0x1FD)
|
||||||
|
@ -361,15 +360,15 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
}
|
}
|
||||||
|
|
||||||
case IOCTL_WFSI_GET_VERSION:
|
case IOCTL_WFSI_GET_VERSION:
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_GET_VERSION");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_GET_VERSION");
|
||||||
Memory::Write_U32(0x20, request.buffer_out);
|
Memory::Write_U32(0x20, request.buffer_out);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFSI_IMPORT_TITLE_CANCEL:
|
case IOCTL_WFSI_IMPORT_TITLE_CANCEL:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_IMPORT_TITLE_CANCEL");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_IMPORT_TITLE_CANCEL");
|
||||||
|
|
||||||
bool continue_install = Memory::Read_U32(request.buffer_in) != 0;
|
const bool continue_install = Memory::Read_U32(request.buffer_in) != 0;
|
||||||
if (m_patch_type == PatchType::NOT_A_PATCH)
|
if (m_patch_type == PatchType::NOT_A_PATCH)
|
||||||
return_error_code = CancelTitleImport(continue_install);
|
return_error_code = CancelTitleImport(continue_install);
|
||||||
else if (m_patch_type == PatchType::PATCH_TYPE_1 || m_patch_type == PatchType::PATCH_TYPE_2)
|
else if (m_patch_type == PatchType::PATCH_TYPE_1 || m_patch_type == PatchType::PATCH_TYPE_2)
|
||||||
|
@ -383,28 +382,28 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
case IOCTL_WFSI_INIT:
|
case IOCTL_WFSI_INIT:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_INIT");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_INIT");
|
||||||
u64 tid;
|
u64 tid;
|
||||||
if (GetIOS()->GetES()->GetTitleId(&tid) < 0)
|
if (GetIOS()->GetES()->GetTitleId(&tid) < 0)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WFS, "IOCTL_WFSI_INIT: Could not get title id.");
|
ERROR_LOG_FMT(IOS_WFS, "IOCTL_WFSI_INIT: Could not get title id.");
|
||||||
return_error_code = IPC_EINVAL;
|
return_error_code = IPC_EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
IOS::ES::TMDReader tmd = GetIOS()->GetES()->FindInstalledTMD(tid);
|
const IOS::ES::TMDReader tmd = GetIOS()->GetES()->FindInstalledTMD(tid);
|
||||||
SetCurrentTitleIdAndGroupId(tmd.GetTitleId(), tmd.GetGroupId());
|
SetCurrentTitleIdAndGroupId(tmd.GetTitleId(), tmd.GetGroupId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IOCTL_WFSI_SET_DEVICE_NAME:
|
case IOCTL_WFSI_SET_DEVICE_NAME:
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_SET_DEVICE_NAME");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_SET_DEVICE_NAME");
|
||||||
m_device_name = Memory::GetString(request.buffer_in);
|
m_device_name = Memory::GetString(request.buffer_in);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFSI_APPLY_TITLE_PROFILE:
|
case IOCTL_WFSI_APPLY_TITLE_PROFILE:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_APPLY_TITLE_PROFILE");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_APPLY_TITLE_PROFILE");
|
||||||
|
|
||||||
if (m_patch_type == NOT_A_PATCH)
|
if (m_patch_type == NOT_A_PATCH)
|
||||||
{
|
{
|
||||||
|
@ -443,9 +442,9 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
case IOCTL_WFSI_GET_TMD:
|
case IOCTL_WFSI_GET_TMD:
|
||||||
{
|
{
|
||||||
u64 subtitle_id = Memory::Read_U64(request.buffer_in);
|
const u64 subtitle_id = Memory::Read_U64(request.buffer_in);
|
||||||
u32 address = Memory::Read_U32(request.buffer_in + 24);
|
const u32 address = Memory::Read_U32(request.buffer_in + 24);
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_GET_TMD: subtitle ID %016" PRIx64, subtitle_id);
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_GET_TMD: subtitle ID {:016x}", subtitle_id);
|
||||||
|
|
||||||
u32 tmd_size;
|
u32 tmd_size;
|
||||||
return_error_code =
|
return_error_code =
|
||||||
|
@ -456,12 +455,13 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
case IOCTL_WFSI_GET_TMD_ABSOLUTE:
|
case IOCTL_WFSI_GET_TMD_ABSOLUTE:
|
||||||
{
|
{
|
||||||
u64 subtitle_id = Memory::Read_U64(request.buffer_in);
|
const u64 subtitle_id = Memory::Read_U64(request.buffer_in);
|
||||||
u32 address = Memory::Read_U32(request.buffer_in + 24);
|
const u32 address = Memory::Read_U32(request.buffer_in + 24);
|
||||||
u16 group_id = Memory::Read_U16(request.buffer_in + 36);
|
const u16 group_id = Memory::Read_U16(request.buffer_in + 36);
|
||||||
u32 title_id = Memory::Read_U32(request.buffer_in + 32);
|
const u32 title_id = Memory::Read_U32(request.buffer_in + 32);
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_GET_TMD_ABSOLUTE: tid %08x, gid %04x, subtitle ID %016" PRIx64,
|
INFO_LOG_FMT(IOS_WFS,
|
||||||
title_id, group_id, subtitle_id);
|
"IOCTL_WFSI_GET_TMD_ABSOLUTE: tid {:08x}, gid {:04x}, subtitle ID {:016x}",
|
||||||
|
title_id, group_id, subtitle_id);
|
||||||
|
|
||||||
u32 tmd_size;
|
u32 tmd_size;
|
||||||
return_error_code = GetTmd(group_id, title_id, subtitle_id, address, &tmd_size);
|
return_error_code = GetTmd(group_id, title_id, subtitle_id, address, &tmd_size);
|
||||||
|
@ -471,8 +471,8 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
case IOCTL_WFSI_SET_FST_BUFFER:
|
case IOCTL_WFSI_SET_FST_BUFFER:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_SET_FST_BUFFER: address %08x, size %08x", request.buffer_in,
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_SET_FST_BUFFER: address {:08x}, size {:08x}",
|
||||||
request.buffer_in_size);
|
request.buffer_in, request.buffer_in_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,18 +497,18 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
path += fmt::format("/extension{}.dol", dol_extension_id);
|
path += fmt::format("/extension{}.dol", dol_extension_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_LOAD_DOL: loading %s at address %08x (size %d)", path.c_str(),
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_LOAD_DOL: loading {} at address {:08x} (size {})", path,
|
||||||
dol_addr, max_dol_size);
|
dol_addr, max_dol_size);
|
||||||
|
|
||||||
File::IOFile fp(WFS::NativePath(path), "rb");
|
File::IOFile fp(WFS::NativePath(path), "rb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_WFS, "IOCTL_WFSI_LOAD_DOL: no such file or directory: %s", path.c_str());
|
WARN_LOG_FMT(IOS_WFS, "IOCTL_WFSI_LOAD_DOL: no such file or directory: {}", path);
|
||||||
return_error_code = WFS_ENOENT;
|
return_error_code = WFS_ENOENT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 real_dol_size = fp.GetSize();
|
const auto real_dol_size = static_cast<u32>(fp.GetSize());
|
||||||
if (dol_addr == 0)
|
if (dol_addr == 0)
|
||||||
{
|
{
|
||||||
// Write the expected size to the size parameter, in the input.
|
// Write the expected size to the size parameter, in the input.
|
||||||
|
@ -523,7 +523,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
||||||
}
|
}
|
||||||
|
|
||||||
case IOCTL_WFSI_CHECK_HAS_SPACE:
|
case IOCTL_WFSI_CHECK_HAS_SPACE:
|
||||||
WARN_LOG(IOS_WFS, "IOCTL_WFSI_CHECK_HAS_SPACE: returning true");
|
WARN_LOG_FMT(IOS_WFS, "IOCTL_WFSI_CHECK_HAS_SPACE: returning true");
|
||||||
|
|
||||||
// TODO(wfs): implement this properly.
|
// TODO(wfs): implement this properly.
|
||||||
// 1 is returned if there is free space, 0 otherwise.
|
// 1 is returned if there is free space, 0 otherwise.
|
||||||
|
@ -558,7 +558,7 @@ u32 WFSI::GetTmd(u16 group_id, u32 title_id, u64 subtitle_id, u32 address, u32*
|
||||||
File::IOFile fp(WFS::NativePath(path), "rb");
|
File::IOFile fp(WFS::NativePath(path), "rb");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
WARN_LOG(IOS_WFS, "GetTmd: no such file or directory: %s", path.c_str());
|
WARN_LOG_FMT(IOS_WFS, "GetTmd: no such file or directory: {}", path);
|
||||||
return WFS_ENOENT;
|
return WFS_ENOENT;
|
||||||
}
|
}
|
||||||
if (address)
|
if (address)
|
||||||
|
|
|
@ -41,18 +41,18 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
case IOCTL_WFS_INIT:
|
case IOCTL_WFS_INIT:
|
||||||
// TODO(wfs): Implement.
|
// TODO(wfs): Implement.
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_INIT");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_INIT");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_UNKNOWN_8:
|
case IOCTL_WFS_UNKNOWN_8:
|
||||||
// TODO(wfs): Figure out what this actually does.
|
// TODO(wfs): Figure out what this actually does.
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_UNKNOWN_8");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_UNKNOWN_8");
|
||||||
Memory::Write_U8(7, request.buffer_out);
|
Memory::Write_U8(7, request.buffer_out);
|
||||||
Memory::CopyToEmu(request.buffer_out + 1, "msc01\x00\x00\x00", 8);
|
Memory::CopyToEmu(request.buffer_out + 1, "msc01\x00\x00\x00", 8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_SHUTDOWN:
|
case IOCTL_WFS_SHUTDOWN:
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_SHUTDOWN");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_SHUTDOWN");
|
||||||
|
|
||||||
// Close all hanging attach/detach ioctls with an appropriate error code.
|
// Close all hanging attach/detach ioctls with an appropriate error code.
|
||||||
for (auto address : m_hanging)
|
for (auto address : m_hanging)
|
||||||
|
@ -66,14 +66,14 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_DEVICE_INFO:
|
case IOCTL_WFS_DEVICE_INFO:
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_DEVICE_INFO");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_DEVICE_INFO");
|
||||||
Memory::Write_U64(16ull << 30, request.buffer_out); // 16GB storage.
|
Memory::Write_U64(16ull << 30, request.buffer_out); // 16GB storage.
|
||||||
Memory::Write_U8(4, request.buffer_out + 8);
|
Memory::Write_U8(4, request.buffer_out + 8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_GET_DEVICE_NAME:
|
case IOCTL_WFS_GET_DEVICE_NAME:
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_GET_DEVICE_NAME");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GET_DEVICE_NAME");
|
||||||
Memory::Write_U8(static_cast<u8>(m_device_name.size()), request.buffer_out);
|
Memory::Write_U8(static_cast<u8>(m_device_name.size()), request.buffer_out);
|
||||||
Memory::CopyToEmu(request.buffer_out + 1, m_device_name.data(), m_device_name.size());
|
Memory::CopyToEmu(request.buffer_out + 1, m_device_name.data(), m_device_name.size());
|
||||||
break;
|
break;
|
||||||
|
@ -81,14 +81,14 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
case IOCTL_WFS_ATTACH_DETACH_2:
|
case IOCTL_WFS_ATTACH_DETACH_2:
|
||||||
// TODO(wfs): Implement.
|
// TODO(wfs): Implement.
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_ATTACH_DETACH_2(%u)", request.request);
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_ATTACH_DETACH_2({})", request.request);
|
||||||
Memory::Write_U32(1, request.buffer_out);
|
Memory::Write_U32(1, request.buffer_out);
|
||||||
Memory::Write_U32(0, request.buffer_out + 4); // device id?
|
Memory::Write_U32(0, request.buffer_out + 4); // device id?
|
||||||
Memory::Write_U32(0, request.buffer_out + 8);
|
Memory::Write_U32(0, request.buffer_out + 8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_ATTACH_DETACH:
|
case IOCTL_WFS_ATTACH_DETACH:
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_ATTACH_DETACH(%u)", request.request);
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_ATTACH_DETACH({})", request.request);
|
||||||
|
|
||||||
// Leave hanging, but we need to acknowledge the request at shutdown time.
|
// Leave hanging, but we need to acknowledge the request at shutdown time.
|
||||||
m_hanging.push_back(request.address);
|
m_hanging.push_back(request.address);
|
||||||
|
@ -96,28 +96,28 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
case IOCTL_WFS_FLUSH:
|
case IOCTL_WFS_FLUSH:
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_FLUSH: doing nothing");
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_FLUSH: doing nothing");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_MKDIR:
|
case IOCTL_WFS_MKDIR:
|
||||||
{
|
{
|
||||||
std::string path = NormalizePath(
|
const std::string path = NormalizePath(
|
||||||
Memory::GetString(request.buffer_in + 34, Memory::Read_U16(request.buffer_in + 32)));
|
Memory::GetString(request.buffer_in + 34, Memory::Read_U16(request.buffer_in + 32)));
|
||||||
std::string native_path = WFS::NativePath(path);
|
const std::string native_path = WFS::NativePath(path);
|
||||||
|
|
||||||
if (File::Exists(native_path))
|
if (File::Exists(native_path))
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_MKDIR(%s): already exists", path.c_str());
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_MKDIR({}): already exists", path);
|
||||||
return_error_code = WFS_EEXIST;
|
return_error_code = WFS_EEXIST;
|
||||||
}
|
}
|
||||||
else if (!File::CreateDir(native_path))
|
else if (!File::CreateDir(native_path))
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_MKDIR(%s): no such file or directory", path.c_str());
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_MKDIR({}): no such file or directory", path);
|
||||||
return_error_code = WFS_ENOENT;
|
return_error_code = WFS_ENOENT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_MKDIR(%s): directory created", path.c_str());
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_MKDIR({}): directory created", path);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -125,59 +125,60 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
// TODO(wfs): Globbing is not really implemented, we just fake the one case
|
// TODO(wfs): Globbing is not really implemented, we just fake the one case
|
||||||
// (listing /vol/*) which is required to get the installer to work.
|
// (listing /vol/*) which is required to get the installer to work.
|
||||||
case IOCTL_WFS_GLOB_START:
|
case IOCTL_WFS_GLOB_START:
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_GLOB_START(%u)", request.request);
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GLOB_START({})", request.request);
|
||||||
Memory::Memset(request.buffer_out, 0, request.buffer_out_size);
|
Memory::Memset(request.buffer_out, 0, request.buffer_out_size);
|
||||||
Memory::CopyToEmu(request.buffer_out + 0x14, m_device_name.data(), m_device_name.size());
|
Memory::CopyToEmu(request.buffer_out + 0x14, m_device_name.data(), m_device_name.size());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_GLOB_NEXT:
|
case IOCTL_WFS_GLOB_NEXT:
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_GLOB_NEXT(%u)", request.request);
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GLOB_NEXT({})", request.request);
|
||||||
return_error_code = WFS_ENOENT;
|
return_error_code = WFS_ENOENT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_GLOB_END:
|
case IOCTL_WFS_GLOB_END:
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_GLOB_END(%u)", request.request);
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GLOB_END({})", request.request);
|
||||||
Memory::Memset(request.buffer_out, 0, request.buffer_out_size);
|
Memory::Memset(request.buffer_out, 0, request.buffer_out_size);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_SET_HOMEDIR:
|
case IOCTL_WFS_SET_HOMEDIR:
|
||||||
m_home_directory =
|
m_home_directory =
|
||||||
Memory::GetString(request.buffer_in + 2, Memory::Read_U16(request.buffer_in));
|
Memory::GetString(request.buffer_in + 2, Memory::Read_U16(request.buffer_in));
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_SET_HOMEDIR: %s", m_home_directory.c_str());
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_SET_HOMEDIR: {}", m_home_directory);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_CHDIR:
|
case IOCTL_WFS_CHDIR:
|
||||||
m_current_directory =
|
m_current_directory =
|
||||||
Memory::GetString(request.buffer_in + 2, Memory::Read_U16(request.buffer_in));
|
Memory::GetString(request.buffer_in + 2, Memory::Read_U16(request.buffer_in));
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_CHDIR: %s", m_current_directory.c_str());
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_CHDIR: {}", m_current_directory);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_GET_HOMEDIR:
|
case IOCTL_WFS_GET_HOMEDIR:
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_GET_HOMEDIR: %s", m_home_directory.c_str());
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GET_HOMEDIR: {}", m_home_directory);
|
||||||
Memory::Write_U16(static_cast<u16>(m_home_directory.size()), request.buffer_out);
|
Memory::Write_U16(static_cast<u16>(m_home_directory.size()), request.buffer_out);
|
||||||
Memory::CopyToEmu(request.buffer_out + 2, m_home_directory.data(), m_home_directory.size());
|
Memory::CopyToEmu(request.buffer_out + 2, m_home_directory.data(), m_home_directory.size());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_WFS_GET_ATTRIBUTES:
|
case IOCTL_WFS_GET_ATTRIBUTES:
|
||||||
{
|
{
|
||||||
std::string path = NormalizePath(
|
const std::string path = NormalizePath(
|
||||||
Memory::GetString(request.buffer_in + 2, Memory::Read_U16(request.buffer_in)));
|
Memory::GetString(request.buffer_in + 2, Memory::Read_U16(request.buffer_in)));
|
||||||
std::string native_path = WFS::NativePath(path);
|
const std::string native_path = WFS::NativePath(path);
|
||||||
|
|
||||||
Memory::Memset(0, request.buffer_out, request.buffer_out_size);
|
Memory::Memset(0, request.buffer_out, request.buffer_out_size);
|
||||||
if (!File::Exists(native_path))
|
if (!File::Exists(native_path))
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_GET_ATTRIBUTES(%s): no such file or directory", path.c_str());
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GET_ATTRIBUTES({}): no such file or directory", path);
|
||||||
return_error_code = WFS_ENOENT;
|
return_error_code = WFS_ENOENT;
|
||||||
}
|
}
|
||||||
else if (File::IsDirectory(native_path))
|
else if (File::IsDirectory(native_path))
|
||||||
{
|
{
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_GET_ATTRIBUTES(%s): directory", path.c_str());
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GET_ATTRIBUTES({}): directory", path);
|
||||||
Memory::Write_U32(0x80000000, request.buffer_out + 4);
|
Memory::Write_U32(0x80000000, request.buffer_out + 4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u32 size = static_cast<u32>(File::GetSize(native_path));
|
const auto size = static_cast<u32>(File::GetSize(native_path));
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_GET_ATTRIBUTES(%s): file with size %d", path.c_str(), size);
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GET_ATTRIBUTES({}): file with size {}", path, size);
|
||||||
Memory::Write_U32(size, request.buffer_out);
|
Memory::Write_U32(size, request.buffer_out);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -199,13 +200,13 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
const char* ioctl_name =
|
const char* ioctl_name =
|
||||||
request.request == IOCTL_WFS_OPEN ? "IOCTL_WFS_OPEN" : "IOCTL_WFS_CREATE_OPEN";
|
request.request == IOCTL_WFS_OPEN ? "IOCTL_WFS_OPEN" : "IOCTL_WFS_CREATE_OPEN";
|
||||||
u32 mode = request.request == IOCTL_WFS_OPEN ? Memory::Read_U32(request.buffer_in) : 2;
|
const u32 mode = request.request == IOCTL_WFS_OPEN ? Memory::Read_U32(request.buffer_in) : 2;
|
||||||
u16 path_len = Memory::Read_U16(request.buffer_in + 0x20);
|
const u16 path_len = Memory::Read_U16(request.buffer_in + 0x20);
|
||||||
std::string path = Memory::GetString(request.buffer_in + 0x22, path_len);
|
std::string path = Memory::GetString(request.buffer_in + 0x22, path_len);
|
||||||
|
|
||||||
path = NormalizePath(path);
|
path = NormalizePath(path);
|
||||||
|
|
||||||
u16 fd = GetNewFileDescriptor();
|
const u16 fd = GetNewFileDescriptor();
|
||||||
FileDescriptor* fd_obj = &m_fds[fd];
|
FileDescriptor* fd_obj = &m_fds[fd];
|
||||||
fd_obj->in_use = true;
|
fd_obj->in_use = true;
|
||||||
fd_obj->path = path;
|
fd_obj->path = path;
|
||||||
|
@ -214,13 +215,13 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
if (!fd_obj->Open())
|
if (!fd_obj->Open())
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WFS, "%s(%s, %d): error opening file", ioctl_name, path.c_str(), mode);
|
ERROR_LOG_FMT(IOS_WFS, "{}({}, {}): error opening file", ioctl_name, path, mode);
|
||||||
ReleaseFileDescriptor(fd);
|
ReleaseFileDescriptor(fd);
|
||||||
return_error_code = WFS_ENOENT;
|
return_error_code = WFS_ENOENT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_WFS, "%s(%s, %d) -> %d", ioctl_name, path.c_str(), mode, fd);
|
INFO_LOG_FMT(IOS_WFS, "{}({}, {}) -> {}", ioctl_name, path, mode, fd);
|
||||||
if (request.request == IOCTL_WFS_OPEN)
|
if (request.request == IOCTL_WFS_OPEN)
|
||||||
{
|
{
|
||||||
Memory::Write_U16(fd, request.buffer_out + 0x14);
|
Memory::Write_U16(fd, request.buffer_out + 0x14);
|
||||||
|
@ -234,21 +235,21 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
case IOCTL_WFS_GET_SIZE:
|
case IOCTL_WFS_GET_SIZE:
|
||||||
{
|
{
|
||||||
u16 fd = Memory::Read_U16(request.buffer_in);
|
const u16 fd = Memory::Read_U16(request.buffer_in);
|
||||||
FileDescriptor* fd_obj = FindFileDescriptor(fd);
|
FileDescriptor* fd_obj = FindFileDescriptor(fd);
|
||||||
if (fd_obj == nullptr)
|
if (fd_obj == nullptr)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WFS, "IOCTL_WFS_GET_SIZE: invalid file descriptor %d", fd);
|
ERROR_LOG_FMT(IOS_WFS, "IOCTL_WFS_GET_SIZE: invalid file descriptor {}", fd);
|
||||||
return_error_code = WFS_EBADFD;
|
return_error_code = WFS_EBADFD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 size = fd_obj->file.GetSize();
|
const u64 size = fd_obj->file.GetSize();
|
||||||
u32 truncated_size = static_cast<u32>(size);
|
const u32 truncated_size = static_cast<u32>(size);
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_GET_SIZE(%d) -> %d", fd, truncated_size);
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GET_SIZE({}) -> {}", fd, truncated_size);
|
||||||
if (size != truncated_size)
|
if (size != truncated_size)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WFS, "IOCTL_WFS_GET_SIZE: file %d too large (%" PRIu64 ")", fd, size);
|
ERROR_LOG_FMT(IOS_WFS, "IOCTL_WFS_GET_SIZE: file {} too large ({})", fd, size);
|
||||||
}
|
}
|
||||||
Memory::Write_U32(truncated_size, request.buffer_out);
|
Memory::Write_U32(truncated_size, request.buffer_out);
|
||||||
break;
|
break;
|
||||||
|
@ -256,8 +257,8 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
|
|
||||||
case IOCTL_WFS_CLOSE:
|
case IOCTL_WFS_CLOSE:
|
||||||
{
|
{
|
||||||
u16 fd = Memory::Read_U16(request.buffer_in + 0x4);
|
const u16 fd = Memory::Read_U16(request.buffer_in + 0x4);
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_CLOSE(%d)", fd);
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_CLOSE({})", fd);
|
||||||
ReleaseFileDescriptor(fd);
|
ReleaseFileDescriptor(fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -266,8 +267,8 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
// TODO(wfs): Figure out the exact semantics difference from the other
|
// TODO(wfs): Figure out the exact semantics difference from the other
|
||||||
// close.
|
// close.
|
||||||
u16 fd = Memory::Read_U16(request.buffer_in + 0x4);
|
const u16 fd = Memory::Read_U16(request.buffer_in + 0x4);
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_CLOSE_2(%d)", fd);
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_CLOSE_2({})", fd);
|
||||||
ReleaseFileDescriptor(fd);
|
ReleaseFileDescriptor(fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -275,22 +276,22 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
case IOCTL_WFS_READ:
|
case IOCTL_WFS_READ:
|
||||||
case IOCTL_WFS_READ_ABSOLUTE:
|
case IOCTL_WFS_READ_ABSOLUTE:
|
||||||
{
|
{
|
||||||
u32 addr = Memory::Read_U32(request.buffer_in);
|
const u32 addr = Memory::Read_U32(request.buffer_in);
|
||||||
u32 position = Memory::Read_U32(request.buffer_in + 4); // Only for absolute.
|
const u32 position = Memory::Read_U32(request.buffer_in + 4); // Only for absolute.
|
||||||
u16 fd = Memory::Read_U16(request.buffer_in + 0xC);
|
const u16 fd = Memory::Read_U16(request.buffer_in + 0xC);
|
||||||
u32 size = Memory::Read_U32(request.buffer_in + 8);
|
const u32 size = Memory::Read_U32(request.buffer_in + 8);
|
||||||
|
|
||||||
bool absolute = request.request == IOCTL_WFS_READ_ABSOLUTE;
|
const bool absolute = request.request == IOCTL_WFS_READ_ABSOLUTE;
|
||||||
|
|
||||||
FileDescriptor* fd_obj = FindFileDescriptor(fd);
|
FileDescriptor* fd_obj = FindFileDescriptor(fd);
|
||||||
if (fd_obj == nullptr)
|
if (fd_obj == nullptr)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WFS, "IOCTL_WFS_READ: invalid file descriptor %d", fd);
|
ERROR_LOG_FMT(IOS_WFS, "IOCTL_WFS_READ: invalid file descriptor {}", fd);
|
||||||
return_error_code = WFS_EBADFD;
|
return_error_code = WFS_EBADFD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 previous_position = fd_obj->file.Tell();
|
const u64 previous_position = fd_obj->file.Tell();
|
||||||
if (absolute)
|
if (absolute)
|
||||||
{
|
{
|
||||||
fd_obj->file.Seek(position, SEEK_SET);
|
fd_obj->file.Seek(position, SEEK_SET);
|
||||||
|
@ -307,8 +308,8 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
fd_obj->position += read_bytes;
|
fd_obj->position += read_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_READ: read %zd bytes from FD %d (%s)", read_bytes, fd,
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_READ: read {} bytes from FD {} ({})", read_bytes, fd,
|
||||||
fd_obj->path.c_str());
|
fd_obj->path);
|
||||||
return_error_code = static_cast<int>(read_bytes);
|
return_error_code = static_cast<int>(read_bytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -316,22 +317,22 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
case IOCTL_WFS_WRITE:
|
case IOCTL_WFS_WRITE:
|
||||||
case IOCTL_WFS_WRITE_ABSOLUTE:
|
case IOCTL_WFS_WRITE_ABSOLUTE:
|
||||||
{
|
{
|
||||||
u32 addr = Memory::Read_U32(request.buffer_in);
|
const u32 addr = Memory::Read_U32(request.buffer_in);
|
||||||
u32 position = Memory::Read_U32(request.buffer_in + 4); // Only for absolute.
|
const u32 position = Memory::Read_U32(request.buffer_in + 4); // Only for absolute.
|
||||||
u16 fd = Memory::Read_U16(request.buffer_in + 0xC);
|
const u16 fd = Memory::Read_U16(request.buffer_in + 0xC);
|
||||||
u32 size = Memory::Read_U32(request.buffer_in + 8);
|
const u32 size = Memory::Read_U32(request.buffer_in + 8);
|
||||||
|
|
||||||
bool absolute = request.request == IOCTL_WFS_WRITE_ABSOLUTE;
|
const bool absolute = request.request == IOCTL_WFS_WRITE_ABSOLUTE;
|
||||||
|
|
||||||
FileDescriptor* fd_obj = FindFileDescriptor(fd);
|
FileDescriptor* fd_obj = FindFileDescriptor(fd);
|
||||||
if (fd_obj == nullptr)
|
if (fd_obj == nullptr)
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WFS, "IOCTL_WFS_WRITE: invalid file descriptor %d", fd);
|
ERROR_LOG_FMT(IOS_WFS, "IOCTL_WFS_WRITE: invalid file descriptor {}", fd);
|
||||||
return_error_code = WFS_EBADFD;
|
return_error_code = WFS_EBADFD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 previous_position = fd_obj->file.Tell();
|
const u64 previous_position = fd_obj->file.Tell();
|
||||||
if (absolute)
|
if (absolute)
|
||||||
{
|
{
|
||||||
fd_obj->file.Seek(position, SEEK_SET);
|
fd_obj->file.Seek(position, SEEK_SET);
|
||||||
|
@ -347,8 +348,8 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
||||||
fd_obj->position += size;
|
fd_obj->position += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_WRITE: written %d bytes from FD %d (%s)", size, fd,
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_WRITE: written {} bytes from FD {} ({})", size, fd,
|
||||||
fd_obj->path.c_str());
|
fd_obj->path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +369,7 @@ s32 WFSSRV::Rename(std::string source, std::string dest) const
|
||||||
source = NormalizePath(source);
|
source = NormalizePath(source);
|
||||||
dest = NormalizePath(dest);
|
dest = NormalizePath(dest);
|
||||||
|
|
||||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_RENAME: %s to %s", source.c_str(), dest.c_str());
|
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_RENAME: {} to {}", source, dest);
|
||||||
|
|
||||||
const bool opened = std::any_of(m_fds.begin(), m_fds.end(),
|
const bool opened = std::any_of(m_fds.begin(), m_fds.end(),
|
||||||
[&](const auto& fd) { return fd.in_use && fd.path == source; });
|
[&](const auto& fd) { return fd.in_use && fd.path == source; });
|
||||||
|
@ -480,7 +481,7 @@ bool WFSSRV::FileDescriptor::Open()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERROR_LOG(IOS_WFS, "WFSOpen: invalid mode %d", mode);
|
ERROR_LOG_FMT(IOS_WFS, "WFSOpen: invalid mode {}", mode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue