Merge pull request #9276 from lioncash/core-log4
Core: Convert logging over to fmt pt.4
This commit is contained in:
commit
e2a019ae9a
|
@ -181,7 +181,7 @@ ReturnCode ES::VerifySign(const std::vector<u8>& hash, const std::vector<u8>& ec
|
|||
return ret;
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_ES, "VerifySign: all checks passed");
|
||||
INFO_LOG_FMT(IOS_ES, "VerifySign: all checks passed");
|
||||
return IPC_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,10 @@ template <typename... Args>
|
|||
static void LogResult(ResultCode code, std::string_view format, Args&&... args)
|
||||
{
|
||||
const std::string command = fmt::format(format, std::forward<Args>(args)...);
|
||||
GENERIC_LOG(Common::Log::IOS_FS,
|
||||
(code == ResultCode::Success ? Common::Log::LINFO : Common::Log::LERROR),
|
||||
"%s: result %d", command.c_str(), ConvertResult(code));
|
||||
const auto type = code == ResultCode::Success ? Common::Log::LINFO : Common::Log::LERROR;
|
||||
|
||||
GENERIC_LOG_FMT(Common::Log::IOS_FS, type, "Command: {}: Result {}", command,
|
||||
ConvertResult(code));
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
|
@ -544,7 +545,8 @@ IPCCommandResult FS::SetFileVersionControl(const Handle& handle, const IOCtlRequ
|
|||
return GetFSReply(ConvertResult(params.Error()));
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -586,7 +588,7 @@ IPCCommandResult FS::GetUsage(const Handle& handle, const IOCtlVRequest& 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);
|
||||
}
|
||||
} // namespace IOS::HLE::Device
|
||||
|
|
|
@ -156,7 +156,7 @@ void HostFileSystem::LoadFst()
|
|||
const auto root_entry = parse_entry(parse_entry, 0);
|
||||
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;
|
||||
}
|
||||
m_root_entry = *root_entry;
|
||||
|
@ -182,12 +182,12 @@ void HostFileSystem::SaveFst()
|
|||
File::IOFile file{temp_path, "wb"};
|
||||
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;
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
@ -218,7 +218,7 @@ HostFileSystem::FstEntry* HostFileSystem::GetFstEntryForPath(const std::string&
|
|||
// Fall back to dummy data to avoid breaking existing filesystems.
|
||||
// This code path is also reached when creating a new file or directory;
|
||||
// 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->name = component;
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -647,7 +647,7 @@ ResultCode HostFileSystem::SetMetadata(Uid caller_uid, const std::string& path,
|
|||
|
||||
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...
|
||||
NandStats stats{};
|
||||
|
@ -681,7 +681,7 @@ Result<DirectoryStats> HostFileSystem::GetDirectoryStats(const std::string& wii_
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,15 @@ std::shared_ptr<File::IOFile> HostFileSystem::OpenHostFile(const std::string& ho
|
|||
while (!file.Open(host_path, "r+b"))
|
||||
{
|
||||
const bool try_again =
|
||||
PanicYesNo("File \"%s\" could not be opened!\n"
|
||||
"This may happen with improper permissions or use by another process.\n"
|
||||
"Press \"Yes\" to make another attempt.",
|
||||
host_path.c_str());
|
||||
PanicYesNoFmt("File \"{}\" could not be opened!\n"
|
||||
"This may happen with improper permissions or use by another process.\n"
|
||||
"Press \"Yes\" to make another attempt.",
|
||||
host_path);
|
||||
|
||||
if (!try_again)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ enum SOResultCode : s32
|
|||
NetIPTop::NetIPTop(Kernel& ios, const std::string& device_name) : Device(ios, device_name)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int ret = WSAStartup(MAKEWORD(2, 2), &InitData);
|
||||
INFO_LOG(IOS_NET, "WSAStartup: %d", ret);
|
||||
const int ret = WSAStartup(MAKEWORD(2, 2), &InitData);
|
||||
INFO_LOG_FMT(IOS_NET, "WSAStartup: {}", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ static s32 MapWiiSockOptLevelToNative(u32 level)
|
|||
if (level == 0xFFFF)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ static s32 MapWiiSockOptNameToNative(u32 optname)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -367,46 +367,47 @@ IPCCommandResult NetIPTop::HandleInitInterfaceRequest(const IOCtlRequest& reques
|
|||
|
||||
IPCCommandResult NetIPTop::HandleSocketRequest(const IOCtlRequest& request)
|
||||
{
|
||||
u32 af = Memory::Read_U32(request.buffer_in);
|
||||
u32 type = Memory::Read_U32(request.buffer_in + 4);
|
||||
u32 prot = Memory::Read_U32(request.buffer_in + 8);
|
||||
const u32 af = Memory::Read_U32(request.buffer_in);
|
||||
const u32 type = Memory::Read_U32(request.buffer_in + 4);
|
||||
const u32 prot = Memory::Read_U32(request.buffer_in + 8);
|
||||
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
const s32 return_value = sm.NewSocket(af, type, prot);
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTL_SO_SOCKET "
|
||||
"Socket: %08x (%d,%d,%d), BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
||||
return_value, af, type, prot, request.buffer_in, request.buffer_in_size,
|
||||
request.buffer_out, request.buffer_out_size);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_SOCKET "
|
||||
"Socket: {:08x} ({},{},{}), BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {})",
|
||||
return_value, af, type, prot, request.buffer_in, request.buffer_in_size,
|
||||
request.buffer_out, request.buffer_out_size);
|
||||
|
||||
return GetDefaultReply(return_value);
|
||||
}
|
||||
|
||||
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();
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
const s32 return_value = sm.DeleteSocket(fd);
|
||||
INFO_LOG(IOS_NET, "%s(%x) %x",
|
||||
request.request == IOCTL_SO_ICMPCLOSE ? "IOCTL_SO_ICMPCLOSE" : "IOCTL_SO_CLOSE", fd,
|
||||
return_value);
|
||||
const char* const close_fn =
|
||||
request.request == IOCTL_SO_ICMPCLOSE ? "IOCTL_SO_ICMPCLOSE" : "IOCTL_SO_CLOSE";
|
||||
|
||||
INFO_LOG_FMT(IOS_NET, "{}({:x}) {:x}", close_fn, fd, return_value);
|
||||
|
||||
return GetDefaultReply(return_value);
|
||||
}
|
||||
|
||||
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();
|
||||
sm.DoSock(fd, request, static_cast<NET_IOCTL>(request.request));
|
||||
return GetNoReply();
|
||||
|
@ -416,8 +417,8 @@ IPCCommandResult NetIPTop::HandleShutdownRequest(const IOCtlRequest& request)
|
|||
{
|
||||
if (request.buffer_in == 0 || request.buffer_in_size < 8)
|
||||
{
|
||||
ERROR_LOG(IOS_NET, "IOCTL_SO_SHUTDOWN = EINVAL, BufferIn: (%08x, %i)", request.buffer_in,
|
||||
request.buffer_in_size);
|
||||
ERROR_LOG_FMT(IOS_NET, "IOCTL_SO_SHUTDOWN = EINVAL, BufferIn: ({:08x}, {})", request.buffer_in,
|
||||
request.buffer_in_size);
|
||||
return GetDefaultReply(-SO_EINVAL);
|
||||
}
|
||||
|
||||
|
@ -425,7 +426,8 @@ IPCCommandResult NetIPTop::HandleShutdownRequest(const IOCtlRequest& request)
|
|||
const u32 how = Memory::Read_U32(request.buffer_in + 4);
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -474,24 +476,24 @@ IPCCommandResult NetIPTop::HandleGetSockOptRequest(const IOCtlRequest& request)
|
|||
|
||||
IPCCommandResult NetIPTop::HandleSetSockOptRequest(const IOCtlRequest& request)
|
||||
{
|
||||
u32 fd = Memory::Read_U32(request.buffer_in);
|
||||
u32 level = Memory::Read_U32(request.buffer_in + 4);
|
||||
u32 optname = Memory::Read_U32(request.buffer_in + 8);
|
||||
const u32 fd = Memory::Read_U32(request.buffer_in);
|
||||
const u32 level = Memory::Read_U32(request.buffer_in + 4);
|
||||
const u32 optname = Memory::Read_U32(request.buffer_in + 8);
|
||||
u32 optlen = Memory::Read_U32(request.buffer_in + 0xc);
|
||||
u8 optval[20];
|
||||
optlen = std::min(optlen, (u32)sizeof(optval));
|
||||
Memory::CopyFromEmu(optval, request.buffer_in + 0x10, optlen);
|
||||
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTL_SO_SETSOCKOPT(%08x, %08x, %08x, %08x) "
|
||||
"BufferIn: (%08x, %i), BufferOut: (%08x, %i)"
|
||||
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx "
|
||||
"%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx",
|
||||
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],
|
||||
optval[4], optval[5], optval[6], optval[7], optval[8], optval[9], optval[10], optval[11],
|
||||
optval[12], optval[13], optval[14], optval[15], optval[16], optval[17], optval[18],
|
||||
optval[19]);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_SETSOCKOPT({:08x}, {:08x}, {:08x}, {:08x}) "
|
||||
"BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {})"
|
||||
"{:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} "
|
||||
"{:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}",
|
||||
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], optval[4], optval[5], optval[6], optval[7], optval[8], optval[9],
|
||||
optval[10], optval[11], optval[12], optval[13], optval[14], optval[15], optval[16],
|
||||
optval[17], optval[18], optval[19]);
|
||||
|
||||
// TODO: bug booto about this, 0x2005 most likely timeout related, default value on Wii is ,
|
||||
// 0x2001 is most likely tcpnodelay
|
||||
|
@ -499,11 +501,11 @@ IPCCommandResult NetIPTop::HandleSetSockOptRequest(const IOCtlRequest& request)
|
|||
return GetDefaultReply(0);
|
||||
|
||||
// Do the level/optname translation
|
||||
int nat_level = MapWiiSockOptLevelToNative(level);
|
||||
int nat_optname = MapWiiSockOptNameToNative(optname);
|
||||
const int nat_level = MapWiiSockOptLevelToNative(level);
|
||||
const int nat_optname = MapWiiSockOptNameToNative(optname);
|
||||
|
||||
int ret = setsockopt(WiiSockMan::GetInstance().GetHostSocket(fd), nat_level, nat_optname,
|
||||
(char*)optval, optlen);
|
||||
const int ret = setsockopt(WiiSockMan::GetInstance().GetHostSocket(fd), nat_level, nat_optname,
|
||||
reinterpret_cast<char*>(optval), optlen);
|
||||
return GetDefaultReply(WiiSockMan::GetNetErrorCode(ret, "SO_SETSOCKOPT", false));
|
||||
}
|
||||
|
||||
|
@ -515,10 +517,10 @@ IPCCommandResult NetIPTop::HandleGetSockNameRequest(const IOCtlRequest& request)
|
|||
|
||||
sockaddr 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))
|
||||
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)
|
||||
Memory::Write_U8(request.buffer_out_size, request.buffer_out);
|
||||
|
@ -539,10 +541,10 @@ IPCCommandResult NetIPTop::HandleGetPeerNameRequest(const IOCtlRequest& request)
|
|||
|
||||
sockaddr 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))
|
||||
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)
|
||||
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));
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_GETPEERNAME(%x)", fd);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_GETPEERNAME({:x})", fd);
|
||||
return GetDefaultReply(ret);
|
||||
}
|
||||
|
||||
|
@ -562,40 +564,44 @@ IPCCommandResult NetIPTop::HandleGetHostIDRequest(const IOCtlRequest& request)
|
|||
{
|
||||
const DefaultInterface interface = GetSystemDefaultInterfaceOrFallback();
|
||||
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,
|
||||
(host_ip >> 8) & 0xFF, host_ip & 0xFF);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_GETHOSTID = {}.{}.{}.{}", host_ip >> 24, (host_ip >> 16) & 0xFF,
|
||||
(host_ip >> 8) & 0xFF, host_ip & 0xFF);
|
||||
return GetDefaultReply(host_ip);
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
if (remoteHost == nullptr || remoteHost->h_addr_list == nullptr ||
|
||||
remoteHost->h_addr_list[0] == nullptr)
|
||||
{
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTL_SO_INETATON = -1 "
|
||||
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: None",
|
||||
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_INETATON = -1 "
|
||||
"{}, BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {}), IP Found: None",
|
||||
hostname, request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size);
|
||||
|
||||
return GetDefaultReply(0);
|
||||
}
|
||||
|
||||
Memory::Write_U32(Common::swap32(*(u32*)remoteHost->h_addr_list[0]), request.buffer_out);
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTL_SO_INETATON = 0 "
|
||||
"%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: %08X",
|
||||
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size, Common::swap32(*(u32*)remoteHost->h_addr_list[0]));
|
||||
const auto ip = Common::swap32(reinterpret_cast<u8*>(remoteHost->h_addr_list[0]));
|
||||
Memory::Write_U32(ip, request.buffer_out);
|
||||
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_INETATON = 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);
|
||||
}
|
||||
|
||||
IPCCommandResult NetIPTop::HandleInetPToNRequest(const IOCtlRequest& request)
|
||||
{
|
||||
std::string address = Memory::GetString(request.buffer_in);
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_INETPTON (Translating: %s)", address.c_str());
|
||||
const std::string address = Memory::GetString(request.buffer_in);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_INETPTON (Translating: {})", address);
|
||||
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 + 3));
|
||||
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_INETNTOP %s", ip_s);
|
||||
Memory::CopyToEmu(request.buffer_out, (u8*)ip_s, strlen(ip_s));
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_INETNTOP {}", ip_s);
|
||||
Memory::CopyToEmu(request.buffer_out, reinterpret_cast<u8*>(ip_s), std::strlen(ip_s));
|
||||
return GetDefaultReply(0);
|
||||
}
|
||||
|
||||
|
@ -628,7 +634,7 @@ IPCCommandResult NetIPTop::HandlePollRequest(const IOCtlRequest& request)
|
|||
const u32 nfds = request.buffer_out_size / 0xc;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -643,11 +649,11 @@ IPCCommandResult NetIPTop::HandlePollRequest(const IOCtlRequest& request)
|
|||
|
||||
// Translate Wii to native events
|
||||
ufds[i].events = WiiSockMan::ConvertEvents(events, WiiSockMan::ConvertDirection::WiiToNative);
|
||||
DEBUG_LOG(IOS_NET,
|
||||
"IOCTL_SO_POLL(%d) "
|
||||
"Sock: %08x, Events: %08x, "
|
||||
"NativeEvents: %08x",
|
||||
i, wii_fd, events, ufds[i].events);
|
||||
DEBUG_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_POLL({}) "
|
||||
"Sock: {:08x}, Events: {:08x}, "
|
||||
"NativeEvents: {:08x}",
|
||||
i, wii_fd, events, ufds[i].events);
|
||||
|
||||
// Do not pass return-only events to the native poll
|
||||
ufds[i].events &= ~(POLLERR | POLLHUP | POLLNVAL | UNSUPPORTED_WSAPOLL);
|
||||
|
@ -662,25 +668,25 @@ IPCCommandResult NetIPTop::HandleGetHostByNameRequest(const IOCtlRequest& reques
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
||||
std::string hostname = Memory::GetString(request.buffer_in);
|
||||
const std::string hostname = Memory::GetString(request.buffer_in);
|
||||
hostent* remoteHost = gethostbyname(hostname.c_str());
|
||||
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTL_SO_GETHOSTBYNAME "
|
||||
"Address: %s, BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
||||
hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_GETHOSTBYNAME "
|
||||
"Address: {}, BufferIn: ({:08x}, {}), BufferOut: ({:08x}, {})",
|
||||
hostname, request.buffer_in, request.buffer_in_size, request.buffer_out,
|
||||
request.buffer_out_size);
|
||||
|
||||
if (remoteHost == nullptr)
|
||||
return GetDefaultReply(-1);
|
||||
|
||||
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)
|
||||
|
@ -688,17 +694,17 @@ IPCCommandResult NetIPTop::HandleGetHostByNameRequest(const IOCtlRequest& reques
|
|||
const u32 ip = Common::swap32(*(u32*)(remoteHost->h_addr_list[i]));
|
||||
const std::string ip_s =
|
||||
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
|
||||
static const u32 GETHOSTBYNAME_STRUCT_SIZE = 0x10;
|
||||
static const u32 GETHOSTBYNAME_IP_LIST_OFFSET = 0x110;
|
||||
static constexpr u32 GETHOSTBYNAME_STRUCT_SIZE = 0x10;
|
||||
static constexpr u32 GETHOSTBYNAME_IP_LIST_OFFSET = 0x110;
|
||||
// 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))
|
||||
{
|
||||
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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
ERROR_LOG(IOS_NET, "IOCTL_SO_ICMPCANCEL");
|
||||
ERROR_LOG_FMT(IOS_NET, "IOCTL_SO_ICMPCANCEL");
|
||||
return GetDefaultReply(0);
|
||||
}
|
||||
|
||||
|
@ -760,7 +766,7 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -769,13 +775,13 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
|||
param5 = Memory::Read_U32(request.io_vectors[0].address + 4);
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTLV_SO_GETINTERFACEOPT(%08X, %08X, %X, %X, %X) "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i) ",
|
||||
param, param2, param3, param4, param5, request.in_vectors[0].address,
|
||||
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].size : 0);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTLV_SO_GETINTERFACEOPT({:08X}, {:08X}, {:X}, {:X}, {:X}) "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}) ",
|
||||
param, param2, param3, param4, param5, request.in_vectors[0].address,
|
||||
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].size : 0);
|
||||
|
||||
switch (param2)
|
||||
{
|
||||
|
@ -824,14 +830,13 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
|||
if (AdapterList->IfIndex == dwBestIfIndex && AdapterList->FirstDnsServerAddress &&
|
||||
AdapterList->OperStatus == IfOperStatusUp)
|
||||
{
|
||||
INFO_LOG(IOS_NET, "Name of valid interface: %S", AdapterList->FriendlyName);
|
||||
INFO_LOG(
|
||||
IOS_NET, "DNS: %u.%u.%u.%u",
|
||||
(unsigned char)AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2],
|
||||
(unsigned char)AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[3],
|
||||
(unsigned char)AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[4],
|
||||
(unsigned char)
|
||||
AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[5]);
|
||||
INFO_LOG_FMT(IOS_NET, "Name of valid interface: {}",
|
||||
WStringToUTF8(AdapterList->FriendlyName));
|
||||
INFO_LOG_FMT(IOS_NET, "DNS: {}.{}.{}.{}",
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2]),
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[3]),
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[4]),
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[5]));
|
||||
address = Common::swap32(
|
||||
*(u32*)(&AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2]));
|
||||
break;
|
||||
|
@ -851,14 +856,14 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
|||
if (res_init() == 0)
|
||||
address = ntohl(_res.nsaddr_list[0].sin_addr.s_addr);
|
||||
else
|
||||
WARN_LOG(IOS_NET, "Call to res_init failed");
|
||||
WARN_LOG_FMT(IOS_NET, "Call to res_init failed");
|
||||
}
|
||||
#endif
|
||||
if (address == 0)
|
||||
address = default_main_dns_resolver;
|
||||
|
||||
INFO_LOG(IOS_NET, "Primary DNS: %X", address);
|
||||
INFO_LOG(IOS_NET, "Secondary DNS: %X", default_backup_dns_resolver);
|
||||
INFO_LOG_FMT(IOS_NET, "Primary DNS: {:X}", address);
|
||||
INFO_LOG_FMT(IOS_NET, "Secondary DNS: {:X}", default_backup_dns_resolver);
|
||||
|
||||
Memory::Write_U32(address, request.io_vectors[0].address);
|
||||
Memory::Write_U32(default_backup_dns_resolver, request.io_vectors[0].address + 4);
|
||||
|
@ -920,7 +925,7 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
|
|||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(IOS_NET, "Unknown param2: %08X", param2);
|
||||
ERROR_LOG_FMT(IOS_NET, "Unknown param2: {:08X}", param2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1042,13 +1047,13 @@ IPCCommandResult NetIPTop::HandleICMPPingRequest(const IOCtlVRequest& request)
|
|||
u32 ip;
|
||||
} ip_info;
|
||||
|
||||
u32 fd = Memory::Read_U32(request.in_vectors[0].address);
|
||||
u32 num_ip = Memory::Read_U32(request.in_vectors[0].address + 4);
|
||||
u64 timeout = Memory::Read_U64(request.in_vectors[0].address + 8);
|
||||
const u32 fd = Memory::Read_U32(request.in_vectors[0].address);
|
||||
const u32 num_ip = Memory::Read_U32(request.in_vectors[0].address + 4);
|
||||
const u64 timeout = Memory::Read_U64(request.in_vectors[0].address + 8);
|
||||
|
||||
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);
|
||||
|
@ -1058,13 +1063,13 @@ IPCCommandResult NetIPTop::HandleICMPPingRequest(const IOCtlVRequest& request)
|
|||
|
||||
if (ip_info.length != 8 || ip_info.addr_family != AF_INET)
|
||||
{
|
||||
INFO_LOG(IOS_NET,
|
||||
"IOCTLV_SO_ICMPPING strange IPInfo:\n"
|
||||
"length %x addr_family %x",
|
||||
ip_info.length, ip_info.addr_family);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"IOCTLV_SO_ICMPPING strange IPInfo:\n"
|
||||
"length {:x} addr_family {:x}",
|
||||
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;
|
||||
addr.sin_family = AF_INET;
|
||||
|
|
|
@ -30,7 +30,7 @@ void NWC24Config::ReadConfig()
|
|||
{
|
||||
const s32 config_error = CheckNwc24Config();
|
||||
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;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ void NWC24Config::WriteConfig() const
|
|||
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);
|
||||
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()
|
||||
|
@ -93,21 +93,21 @@ s32 NWC24Config::CheckNwc24Config() const
|
|||
// 'WcCf' magic
|
||||
if (Magic() != 0x57634366)
|
||||
{
|
||||
ERROR_LOG(IOS_WC24, "Magic mismatch");
|
||||
ERROR_LOG_FMT(IOS_WC24, "Magic mismatch");
|
||||
return -14;
|
||||
}
|
||||
|
||||
const u32 checksum = CalculateNwc24ConfigChecksum();
|
||||
DEBUG_LOG(IOS_WC24, "Checksum: %X", checksum);
|
||||
DEBUG_LOG_FMT(IOS_WC24, "Checksum: {:X}", 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;
|
||||
}
|
||||
|
||||
if (IdGen() > 0x1F)
|
||||
{
|
||||
ERROR_LOG(IOS_WC24, "Id gen error");
|
||||
ERROR_LOG_FMT(IOS_WC24, "Id gen error");
|
||||
return -14;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,16 +39,16 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
|||
{
|
||||
case IOCTL_NWC24_SUSPEND_SCHEDULAR:
|
||||
// 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
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
break;
|
||||
|
||||
|
@ -56,30 +56,30 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
|||
WriteReturnValue(0, request.buffer_out);
|
||||
Memory::Write_U32(0, request.buffer_out + 4);
|
||||
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;
|
||||
|
||||
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();
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
Memory::Write_U32(0, request.buffer_out + 4);
|
||||
break;
|
||||
|
||||
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)
|
||||
{
|
||||
const std::string settings_file_path =
|
||||
|
@ -133,11 +133,11 @@ IPCCommandResult NetKDRequest::IOCtl(const IOCtlRequest& request)
|
|||
break;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
// TODO: Advertise shutdown event
|
||||
// TODO: Shutdown USB keyboard LEDs if event == 3
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "Core/IOS/Network/KD/NetKDTime.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
@ -32,7 +31,7 @@ IPCCommandResult NetKDTime::IOCtl(const IOCtlRequest& request)
|
|||
{
|
||||
const u64 adjusted_utc = GetAdjustedUTC();
|
||||
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;
|
||||
|
||||
|
@ -41,29 +40,28 @@ IPCCommandResult NetKDTime::IOCtl(const IOCtlRequest& request)
|
|||
const u64 adjusted_utc = Memory::Read_U64(request.buffer_in);
|
||||
SetAdjustedUTC(adjusted_utc);
|
||||
update_misc = Memory::Read_U32(request.buffer_in + 8);
|
||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_SET_UNIVERSAL_TIME (%" PRIu64 ", %u) = %d", adjusted_utc,
|
||||
update_misc, result);
|
||||
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_SET_UNIVERSAL_TIME ({}, {}) = {}", adjusted_utc, update_misc,
|
||||
result);
|
||||
}
|
||||
break;
|
||||
|
||||
case IOCTL_NW24_SET_RTC_COUNTER:
|
||||
rtc = Memory::Read_U32(request.buffer_in);
|
||||
update_misc = Memory::Read_U32(request.buffer_in + 4);
|
||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_SET_RTC_COUNTER (%" PRIu64 ", %u) = %d", rtc, update_misc,
|
||||
result);
|
||||
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_SET_RTC_COUNTER ({}, {}) = {}", rtc, update_misc, result);
|
||||
break;
|
||||
|
||||
case IOCTL_NW24_GET_TIME_DIFF:
|
||||
{
|
||||
const u64 time_diff = GetAdjustedUTC() - rtc;
|
||||
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;
|
||||
|
||||
case IOCTL_NW24_UNIMPLEMENTED:
|
||||
result = -9;
|
||||
INFO_LOG(IOS_WC24, "IOCTL_NW24_UNIMPLEMENTED = %d", result);
|
||||
INFO_LOG_FMT(IOS_WC24, "IOCTL_NW24_UNIMPLEMENTED = {}", result);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -39,14 +39,14 @@ Common::MACAddress GetMACAddress()
|
|||
SaveMACAddress(mac.value());
|
||||
if (!wireless_mac.empty())
|
||||
{
|
||||
ERROR_LOG(IOS_NET,
|
||||
"The MAC provided (%s) is invalid. We have "
|
||||
"generated another one for you.",
|
||||
Common::MacAddressToString(mac.value()).c_str());
|
||||
ERROR_LOG_FMT(IOS_NET,
|
||||
"The MAC provided ({}) is invalid. We have "
|
||||
"generated another one for you.",
|
||||
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();
|
||||
}
|
||||
} // namespace IOS::Net
|
||||
|
|
|
@ -36,37 +36,37 @@ IPCCommandResult NetNCDManage::IOCtlV(const IOCtlVRequest& request)
|
|||
break;
|
||||
|
||||
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);
|
||||
common_vector = 1;
|
||||
break;
|
||||
|
||||
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);
|
||||
break;
|
||||
|
||||
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.WriteToMem(request.io_vectors.at(0).address);
|
||||
break;
|
||||
|
||||
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.WriteConfig(m_ios.GetFS().get());
|
||||
break;
|
||||
|
||||
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
|
||||
Memory::Write_U32(Net::ConnectionSettings::LINK_WIRED, request.io_vectors.at(0).address + 4);
|
||||
break;
|
||||
|
||||
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();
|
||||
Memory::CopyToEmu(request.io_vectors.at(1).address, address.data(), address.size());
|
||||
|
@ -74,7 +74,7 @@ IPCCommandResult NetNCDManage::IOCtlV(const IOCtlVRequest& request)
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ void WiiNetConfig::WriteConfig(FS::FileSystem* fs) const
|
|||
fs->CreateFullPath(PID_NCD, PID_NCD, CONFIG_PATH, 0, public_modes);
|
||||
const auto file = fs->CreateAndOpenFile(PID_NCD, PID_NCD, CONFIG_PATH, public_modes);
|
||||
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)
|
||||
|
|
|
@ -106,13 +106,13 @@ static std::vector<u8> ReadCertFile(const std::string& path, const std::array<u8
|
|||
std::vector<u8> bytes(file.GetSize());
|
||||
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)
|
||||
{
|
||||
PanicAlertT("IOS: Could not read a file required for SSL services (%s). Please refer to "
|
||||
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
||||
"instructions on setting up Wii networking.",
|
||||
path.c_str());
|
||||
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 "
|
||||
"instructions on setting up Wii networking.",
|
||||
path);
|
||||
}
|
||||
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);
|
||||
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)
|
||||
{
|
||||
PanicAlertT("IOS: A file required for SSL services (%s) is invalid. Please refer to "
|
||||
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
||||
"instructions on setting up Wii networking.",
|
||||
path.c_str());
|
||||
PanicAlertFmtT("IOS: A file required for SSL services ({0}) is invalid. Please refer to "
|
||||
"https://dolphin-emu.org/docs/guides/wii-network-guide/ for "
|
||||
"instructions on setting up Wii networking.",
|
||||
path);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -234,14 +234,14 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
WriteReturnValue(SSL_ERR_FAILED, BufferIn);
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_NEW (%d, %s) "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
verifyOption, hostname.c_str(), BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||
BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2,
|
||||
BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_NEW ({}, {}) "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
verifyOption, hostname, BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||
BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2,
|
||||
BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_SHUTDOWN:
|
||||
|
@ -272,24 +272,24 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SHUTDOWN "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SHUTDOWN "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_SETROOTCA:
|
||||
{
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETROOTCA "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETROOTCA "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
|
||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
if (IsSSLIDValid(sslID))
|
||||
|
@ -314,7 +314,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
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
|
||||
{
|
||||
|
@ -324,13 +324,13 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
}
|
||||
case IOCTLV_NET_SSL_SETBUILTINCLIENTCERT:
|
||||
{
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
|
||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
if (IsSSLIDValid(sslID))
|
||||
|
@ -360,24 +360,24 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
case IOCTLV_NET_SSL_REMOVECLIENTCERT:
|
||||
{
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_REMOVECLIENTCERT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_REMOVECLIENTCERT "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
|
||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
if (IsSSLIDValid(sslID))
|
||||
|
@ -392,7 +392,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -419,19 +419,19 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr);
|
||||
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
|
||||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETBUILTINROOTCA "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETBUILTINROOTCA "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_CONNECT:
|
||||
|
@ -444,7 +444,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
ssl->sockfd = Memory::Read_U32(BufferOut2);
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
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);
|
||||
WriteReturnValue(SSL_OK, BufferIn);
|
||||
}
|
||||
|
@ -452,13 +452,13 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_CONNECT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_CONNECT "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
||||
|
@ -478,7 +478,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
}
|
||||
case IOCTLV_NET_SSL_WRITE:
|
||||
{
|
||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
const int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
if (IsSSLIDValid(sslID))
|
||||
{
|
||||
WiiSockMan& sm = WiiSockMan::GetInstance();
|
||||
|
@ -489,14 +489,14 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_WRITE "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG(IOS_SSL, "%s", Memory::GetString(BufferOut2).c_str());
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_WRITE "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL, "{}", Memory::GetString(BufferOut2));
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_READ:
|
||||
|
@ -514,13 +514,13 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_READ(%d)"
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_READ({})"
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_SETROOTCADEFAULT:
|
||||
|
@ -534,24 +534,24 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
|
|||
{
|
||||
WriteReturnValue(SSL_ERR_ID, BufferIn);
|
||||
}
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETROOTCADEFAULT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETROOTCADEFAULT "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT:
|
||||
{
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferIn3: ({:08x}, {}), BufferOut: ({:08x}, {}), "
|
||||
"BufferOut2: ({:08x}, {}), BufferOut3: ({:08x}, {})",
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3,
|
||||
BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3);
|
||||
|
||||
int sslID = Memory::Read_U32(BufferOut) - 1;
|
||||
if (IsSSLIDValid(sslID))
|
||||
|
|
|
@ -63,7 +63,7 @@ static s32 TranslateErrorCode(s32 native_error, bool is_rw)
|
|||
switch (native_error)
|
||||
{
|
||||
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
|
||||
case EITHER(WSAENOTSOCK, 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)
|
||||
s32 WiiSockMan::GetNetErrorCode(s32 ret, const char* caller, bool isRW)
|
||||
s32 WiiSockMan::GetNetErrorCode(s32 ret, std::string_view caller, bool is_rw)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
s32 errorCode = WSAGetLastError();
|
||||
s32 error_code = WSAGetLastError();
|
||||
#else
|
||||
s32 errorCode = errno;
|
||||
s32 error_code = errno;
|
||||
#endif
|
||||
|
||||
if (ret >= 0)
|
||||
|
@ -114,13 +114,13 @@ s32 WiiSockMan::GetNetErrorCode(s32 ret, const char* caller, bool isRW)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ERROR_LOG(IOS_NET, "%s failed with error %d: %s, ret= %d", caller, errorCode,
|
||||
DecodeError(errorCode), ret);
|
||||
ERROR_LOG_FMT(IOS_NET, "{} failed with error {}: {}, ret= {}", caller, error_code,
|
||||
DecodeError(error_code), ret);
|
||||
|
||||
s32 ReturnValue = TranslateErrorCode(errorCode, isRW);
|
||||
WiiSockMan::GetInstance().SetLastNetError(ReturnValue);
|
||||
const s32 return_value = TranslateErrorCode(error_code, is_rw);
|
||||
WiiSockMan::GetInstance().SetLastNetError(return_value);
|
||||
|
||||
return ReturnValue;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
WiiSocket::~WiiSocket()
|
||||
|
@ -248,10 +248,10 @@ s32 WiiSocket::FCntl(u32 cmd, u32 arg)
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
@ -285,8 +285,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
|||
int ret = bind(fd, (sockaddr*)&local_name, sizeof(local_name));
|
||||
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_BIND", false);
|
||||
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_BIND (%08X, %s:%d) = %d", wii_fd,
|
||||
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_BIND ({:08X}, {}:{}) = {}", wii_fd,
|
||||
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
||||
break;
|
||||
}
|
||||
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));
|
||||
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_CONNECT", false);
|
||||
|
||||
INFO_LOG(IOS_NET, "IOCTL_SO_CONNECT (%08x, %s:%d) = %d", wii_fd,
|
||||
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
||||
INFO_LOG_FMT(IOS_NET, "IOCTL_SO_CONNECT ({:08x}, {}:{}) = {}", wii_fd,
|
||||
inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret);
|
||||
break;
|
||||
}
|
||||
case IOCTL_SO_ACCEPT:
|
||||
|
@ -381,12 +381,12 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
|||
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
||||
{
|
||||
mbedtls_ssl_context* ctx = &Device::NetSSL::_SSL[sslID].ctx;
|
||||
int ret = mbedtls_ssl_handshake(ctx);
|
||||
if (ret)
|
||||
const int ret = mbedtls_ssl_handshake(ctx);
|
||||
if (ret != 0)
|
||||
{
|
||||
char error_buffer[256] = "";
|
||||
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)
|
||||
{
|
||||
|
@ -408,8 +408,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
|||
char error_buffer[256] = "";
|
||||
int res = mbedtls_ssl_get_verify_result(ctx);
|
||||
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",
|
||||
res, error_buffer);
|
||||
ERROR_LOG_FMT(IOS_SSL, "MBEDTLS_ERR_X509_CERT_VERIFY_FAILED (verify_result = {}): {}",
|
||||
res, error_buffer);
|
||||
|
||||
if (res & MBEDTLS_X509_BADCERT_CN_MISMATCH)
|
||||
res = SSL_ERR_VCOMMONNAME;
|
||||
|
@ -447,12 +447,12 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
|||
}
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_DOHANDSHAKE = (%d) "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
|
||||
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2);
|
||||
INFO_LOG_FMT(IOS_SSL,
|
||||
"IOCTLV_NET_SSL_DOHANDSHAKE = ({}) "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferOut: ({:08x}, {}), BufferOut2: ({:08x}, {})",
|
||||
ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_WRITE:
|
||||
|
@ -564,18 +564,19 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
|||
WiiSockMan::Convert(*wii_name, local_name);
|
||||
}
|
||||
|
||||
int ret = sendto(fd, data, BufferInSize, flags,
|
||||
has_destaddr ? (struct sockaddr*)&local_name : nullptr,
|
||||
has_destaddr ? sizeof(sockaddr) : 0);
|
||||
const int ret = sendto(fd, data, BufferInSize, flags,
|
||||
has_destaddr ? (struct sockaddr*)&local_name : nullptr,
|
||||
has_destaddr ? sizeof(sockaddr) : 0);
|
||||
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_SENDTO", true);
|
||||
|
||||
INFO_LOG(IOS_NET,
|
||||
"%s = %d Socket: %08x, BufferIn: (%08x, %i), BufferIn2: (%08x, %i), %u.%u.%u.%u",
|
||||
has_destaddr ? "IOCTLV_SO_SENDTO " : "IOCTLV_SO_SEND ", ReturnValue, wii_fd,
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||
local_name.sin_addr.s_addr & 0xFF, (local_name.sin_addr.s_addr >> 8) & 0xFF,
|
||||
(local_name.sin_addr.s_addr >> 16) & 0xFF,
|
||||
(local_name.sin_addr.s_addr >> 24) & 0xFF);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"{} = {} Socket: {:08x}, BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"{}.{}.{}.{}",
|
||||
has_destaddr ? "IOCTLV_SO_SENDTO " : "IOCTLV_SO_SEND ", ReturnValue, wii_fd,
|
||||
BufferIn, BufferInSize, BufferIn2, BufferInSize2,
|
||||
local_name.sin_addr.s_addr & 0xFF, (local_name.sin_addr.s_addr >> 8) & 0xFF,
|
||||
(local_name.sin_addr.s_addr >> 16) & 0xFF,
|
||||
(local_name.sin_addr.s_addr >> 24) & 0xFF);
|
||||
break;
|
||||
}
|
||||
case IOCTLV_SO_RECVFROM:
|
||||
|
@ -609,19 +610,19 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
|||
}
|
||||
#endif
|
||||
socklen_t addrlen = sizeof(sockaddr_in);
|
||||
int ret = recvfrom(fd, data, data_len, flags,
|
||||
BufferOutSize2 ? (struct sockaddr*)&local_name : nullptr,
|
||||
BufferOutSize2 ? &addrlen : nullptr);
|
||||
const int ret = recvfrom(fd, data, data_len, flags,
|
||||
BufferOutSize2 ? (struct sockaddr*)&local_name : nullptr,
|
||||
BufferOutSize2 ? &addrlen : nullptr);
|
||||
ReturnValue =
|
||||
WiiSockMan::GetNetErrorCode(ret, BufferOutSize2 ? "SO_RECVFROM" : "SO_RECV", true);
|
||||
|
||||
INFO_LOG(IOS_NET,
|
||||
"%s(%d, %p) Socket: %08X, Flags: %08X, "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferOut: (%08x, %i), BufferOut2: (%08x, %i)",
|
||||
BufferOutSize2 ? "IOCTLV_SO_RECVFROM " : "IOCTLV_SO_RECV ", ReturnValue, data,
|
||||
wii_fd, flags, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut,
|
||||
BufferOutSize, BufferOut2, BufferOutSize2);
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"{}({}, {}) Socket: {:08X}, Flags: {:08X}, "
|
||||
"BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
"BufferOut: ({:08x}, {}), BufferOut2: ({:08x}, {})",
|
||||
BufferOutSize2 ? "IOCTLV_SO_RECVFROM " : "IOCTLV_SO_RECV ", ReturnValue,
|
||||
fmt::ptr(data), wii_fd, flags, BufferIn, BufferInSize, BufferIn2,
|
||||
BufferInSize2, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2);
|
||||
|
||||
if (BufferOutSize2 != 0)
|
||||
{
|
||||
|
@ -647,10 +648,10 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
|||
ReturnValue != -SO_EALREADY) ||
|
||||
(it->is_ssl && ReturnValue != SSL_ERR_WAGAIN && ReturnValue != SSL_ERR_RAGAIN))
|
||||
{
|
||||
DEBUG_LOG(IOS_NET,
|
||||
"IOCTL(V) Sock: %08x ioctl/v: %d returned: %d nonBlock: %d forceNonBlock: %d",
|
||||
wii_fd, it->is_ssl ? (int)it->ssl_type : (int)it->net_type, ReturnValue, nonBlock,
|
||||
forceNonBlock);
|
||||
DEBUG_LOG_FMT(
|
||||
IOS_NET, "IOCTL(V) Sock: {:08x} ioctl/v: {} returned: {} nonBlock: {} forceNonBlock: {}",
|
||||
wii_fd, it->is_ssl ? static_cast<int>(it->ssl_type) : static_cast<int>(it->net_type),
|
||||
ReturnValue, nonBlock, forceNonBlock);
|
||||
|
||||
// TODO: remove the dependency on a running IOS instance.
|
||||
GetIOS()->EnqueueIPCReply(it->request, ReturnValue);
|
||||
|
@ -697,7 +698,7 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
|
|||
// Close host socket
|
||||
closesocket(fd);
|
||||
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
|
||||
{
|
||||
|
@ -708,7 +709,7 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
|
|||
#ifdef __APPLE__
|
||||
int opt_no_sigpipe = 1;
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -883,8 +884,9 @@ void WiiSockMan::UpdatePollCommands()
|
|||
// 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(revents, pcmd.buffer_out + 0xc * i + 8); // revents
|
||||
DEBUG_LOG(IOS_NET, "IOCTL_SO_POLL socket %d wevents %08X events %08X revents %08X", i,
|
||||
revents, pfds[i].events, pfds[i].revents);
|
||||
DEBUG_LOG_FMT(IOS_NET,
|
||||
"IOCTL_SO_POLL socket {} wevents {:08X} events {:08X} revents {:08X}",
|
||||
i, revents, pfds[i].events, pfds[i].revents);
|
||||
}
|
||||
GetIOS()->EnqueueIPCReply(request, ret);
|
||||
return true;
|
||||
|
@ -932,7 +934,7 @@ s32 WiiSockMan::ConvertEvents(s32 events, ConvertDirection dir)
|
|||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ typedef struct pollfd pollfd_t;
|
|||
#include <cstdio>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
|
@ -229,7 +230,7 @@ public:
|
|||
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 WiiSockMan& GetInstance()
|
||||
|
@ -260,8 +261,8 @@ public:
|
|||
auto socket_entry = WiiSockets.find(sock);
|
||||
if (socket_entry == WiiSockets.end())
|
||||
{
|
||||
ERROR_LOG(IOS_NET, "DoSock: Error, fd not found (%08x, %08X, %08X)", sock, request.address,
|
||||
type);
|
||||
ERROR_LOG_FMT(IOS_NET, "DoSock: Error, fd not found ({:08x}, {:08X}, {:08X})", sock,
|
||||
request.address, type);
|
||||
GetIOS()->EnqueueIPCReply(request, -SO_EBADF);
|
||||
}
|
||||
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))
|
||||
{
|
||||
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)
|
||||
|
@ -65,16 +65,16 @@ void SDIOSlot0::OpenInternal()
|
|||
m_card.Open(filename, "r+b");
|
||||
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))
|
||||
{
|
||||
INFO_LOG(IOS_SD, "Successfully created %s", filename.c_str());
|
||||
INFO_LOG_FMT(IOS_SD, "Successfully created {}", filename);
|
||||
m_card.Open(filename, "r+b");
|
||||
}
|
||||
if (!m_card)
|
||||
{
|
||||
ERROR_LOG(IOS_SD, "Could not open SD Card image or create a new one, are you running "
|
||||
"from a read-only directory?");
|
||||
ERROR_LOG_FMT(IOS_SD, "Could not open SD Card image or create a new one, are you running "
|
||||
"from a read-only directory?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ IPCCommandResult SDIOSlot0::IOCtl(const IOCtlRequest& request)
|
|||
case IOCTL_GETOCR:
|
||||
return GetOCRegister(request);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ IPCCommandResult SDIOSlot0::IOCtlV(const IOCtlVRequest& request)
|
|||
case IOCTLV_SENDCMD:
|
||||
return SendCommand(request);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
|||
switch (req.command)
|
||||
{
|
||||
case GO_IDLE_STATE:
|
||||
INFO_LOG(IOS_SD, "GO_IDLE_STATE");
|
||||
INFO_LOG_FMT(IOS_SD, "GO_IDLE_STATE");
|
||||
// Response is R1 (idle state)
|
||||
Memory::Write_U32(0x00, buffer_out);
|
||||
break;
|
||||
|
@ -194,7 +194,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
|||
break;
|
||||
|
||||
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
|
||||
// voltage and the check pattern that were set in the command argument.
|
||||
// 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 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(0x80080000, buffer_out + 4);
|
||||
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
|
||||
// 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!",
|
||||
req.isDMA ? "DMA " : "", req.blocks, req.arg, req.bsize, req.addr);
|
||||
INFO_LOG_FMT(IOS_SD, "{}Read {} Block(s) from {:#010x} bsize {} into {:#010x}!",
|
||||
req.isDMA ? "DMA " : "", req.blocks, req.arg, req.bsize, req.addr);
|
||||
|
||||
if (m_card)
|
||||
{
|
||||
u32 size = req.bsize * req.blocks;
|
||||
u64 address = GetAddressFromRequest(req.arg);
|
||||
const u32 size = req.bsize * req.blocks;
|
||||
const u64 address = GetAddressFromRequest(req.arg);
|
||||
|
||||
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))
|
||||
{
|
||||
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
|
||||
{
|
||||
ERROR_LOG(IOS_SD, "Read Failed - error: %i, eof: %i", ferror(m_card.GetHandle()),
|
||||
feof(m_card.GetHandle()));
|
||||
ERROR_LOG_FMT(IOS_SD, "Read Failed - error: {}, eof: {}", std::ferror(m_card.GetHandle()),
|
||||
std::feof(m_card.GetHandle()));
|
||||
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
|
||||
// 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!",
|
||||
req.isDMA ? "DMA " : "", req.blocks, req.addr, req.bsize, req.arg);
|
||||
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);
|
||||
|
||||
if (m_card && SConfig::GetInstance().bEnableMemcardSdWriting &&
|
||||
Config::Get(Config::MAIN_ALLOW_SD_WRITES))
|
||||
{
|
||||
u32 size = req.bsize * req.blocks;
|
||||
u64 address = GetAddressFromRequest(req.arg);
|
||||
const u32 size = req.bsize * req.blocks;
|
||||
const u64 address = GetAddressFromRequest(req.arg);
|
||||
|
||||
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))
|
||||
{
|
||||
ERROR_LOG(IOS_SD, "Write Failed - error: %i, eof: %i", ferror(m_card.GetHandle()),
|
||||
feof(m_card.GetHandle()));
|
||||
ERROR_LOG_FMT(IOS_SD, "Write Failed - error: {}, eof: {}", std::ferror(m_card.GetHandle()),
|
||||
std::feof(m_card.GetHandle()));
|
||||
ret = RET_FAIL;
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
|||
break;
|
||||
|
||||
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);
|
||||
ret = RET_EVENT_REGISTER;
|
||||
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.
|
||||
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)
|
||||
return IPC_EINVAL;
|
||||
// release returns 0
|
||||
|
@ -318,7 +318,7 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
|||
}
|
||||
|
||||
default:
|
||||
ERROR_LOG(IOS_SD, "Unknown SD command 0x%08x", req.command);
|
||||
ERROR_LOG_FMT(IOS_SD, "Unknown SD command {:#010x}", req.command);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -327,14 +327,14 @@ s32 SDIOSlot0::ExecuteCommand(const Request& request, u32 buffer_in, u32 buffer_
|
|||
|
||||
IPCCommandResult SDIOSlot0::WriteHCRegister(const IOCtlRequest& request)
|
||||
{
|
||||
u32 reg = Memory::Read_U32(request.buffer_in);
|
||||
u32 val = Memory::Read_U32(request.buffer_in + 16);
|
||||
const u32 reg = Memory::Read_U32(request.buffer_in);
|
||||
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())
|
||||
{
|
||||
WARN_LOG(IOS_SD, "IOCTL_WRITEHCR out of range");
|
||||
WARN_LOG_FMT(IOS_SD, "IOCTL_WRITEHCR out of range");
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -359,16 +359,16 @@ IPCCommandResult SDIOSlot0::WriteHCRegister(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())
|
||||
{
|
||||
WARN_LOG(IOS_SD, "IOCTL_READHCR out of range");
|
||||
WARN_LOG_FMT(IOS_SD, "IOCTL_READHCR out of range");
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
}
|
||||
|
||||
u32 val = m_registers[reg];
|
||||
INFO_LOG(IOS_SD, "IOCTL_READHCR 0x%08x - 0x%08x", reg, val);
|
||||
const u32 val = m_registers[reg];
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_READHCR {:#010x} - {:#010x}", reg, val);
|
||||
|
||||
// Just reading the register
|
||||
Memory::Write_U32(val, request.buffer_out);
|
||||
|
@ -377,7 +377,7 @@ IPCCommandResult SDIOSlot0::ReadHCRegister(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)
|
||||
Memory::Write_U32(m_status, request.buffer_out);
|
||||
|
@ -387,21 +387,21 @@ IPCCommandResult SDIOSlot0::ResetCard(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...
|
||||
// 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)
|
||||
INFO_LOG(IOS_SD, "Setting to %i, interesting", clock);
|
||||
INFO_LOG_FMT(IOS_SD, "Setting to {}, interesting", clock);
|
||||
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
}
|
||||
|
||||
IPCCommandResult SDIOSlot0::SendCommand(const IOCtlRequest& request)
|
||||
{
|
||||
INFO_LOG(IOS_SD, "IOCTL_SENDCMD %x IPC:%08x", Memory::Read_U32(request.buffer_in),
|
||||
request.address);
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_SENDCMD {:x} IPC:{:08x}", Memory::Read_U32(request.buffer_in),
|
||||
request.address);
|
||||
|
||||
const s32 return_value = ExecuteCommand(request, request.buffer_in, request.buffer_in_size, 0, 0,
|
||||
request.buffer_out, request.buffer_out_size);
|
||||
|
@ -444,10 +444,10 @@ IPCCommandResult SDIOSlot0::GetStatus(const IOCtlRequest& request)
|
|||
const u32 status =
|
||||
SConfig::GetInstance().m_WiiSDCard ? (m_status | CARD_INSERTED) : CARD_NOT_EXIST;
|
||||
|
||||
INFO_LOG(IOS_SD, "IOCTL_GETSTATUS. Replying that %s card is %s%s",
|
||||
(status & CARD_SDHC) ? "SDHC" : "SD",
|
||||
(status & CARD_INSERTED) ? "inserted" : "not present",
|
||||
(status & CARD_INITIALIZED) ? " and initialized" : "");
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_GETSTATUS. Replying that {} card is {}{}",
|
||||
(status & CARD_SDHC) ? "SDHC" : "SD",
|
||||
(status & CARD_INSERTED) ? "inserted" : "not present",
|
||||
(status & CARD_INITIALIZED) ? " and initialized" : "");
|
||||
|
||||
Memory::Write_U32(status, request.buffer_out);
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
|
@ -455,8 +455,8 @@ IPCCommandResult SDIOSlot0::GetStatus(const IOCtlRequest& request)
|
|||
|
||||
IPCCommandResult SDIOSlot0::GetOCRegister(const IOCtlRequest& request)
|
||||
{
|
||||
u32 ocr = GetOCRegister();
|
||||
INFO_LOG(IOS_SD, "IOCTL_GETOCR. Replying with ocr %x", ocr);
|
||||
const u32 ocr = GetOCRegister();
|
||||
INFO_LOG_FMT(IOS_SD, "IOCTL_GETOCR. Replying with ocr {:x}", ocr);
|
||||
Memory::Write_U32(ocr, request.buffer_out);
|
||||
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
|
@ -464,7 +464,7 @@ IPCCommandResult SDIOSlot0::GetOCRegister(const IOCtlRequest& 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);
|
||||
|
||||
const s32 return_value =
|
||||
|
@ -502,7 +502,7 @@ std::array<u32, 4> SDIOSlot0::GetCSDv1() const
|
|||
size >>= 1;
|
||||
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
|
||||
size = 4096;
|
||||
c_size_mult = 7 + 2 + read_bl_len;
|
||||
|
@ -513,9 +513,9 @@ std::array<u32, 4> SDIOSlot0::GetCSDv1() const
|
|||
const u32 c_size(size);
|
||||
|
||||
if (invalid_size)
|
||||
WARN_LOG(IOS_SD, "SD Card size is invalid");
|
||||
WARN_LOG_FMT(IOS_SD, "SD Card size is invalid");
|
||||
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)
|
||||
// 0b000000 reserved
|
||||
|
@ -574,7 +574,7 @@ std::array<u32, 4> SDIOSlot0::GetCSDv2() const
|
|||
const u64 size = m_card.GetSize();
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ IPCCommandResult STMImmediate::IOCtl(const IOCtlRequest& request)
|
|||
{
|
||||
case IOCTL_STM_IDLE:
|
||||
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);
|
||||
break;
|
||||
|
||||
|
@ -39,20 +39,20 @@ IPCCommandResult STMImmediate::IOCtl(const IOCtlRequest& request)
|
|||
break;
|
||||
|
||||
case IOCTL_STM_HOTRESET:
|
||||
INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(IOS_STM, " IOCTL_STM_HOTRESET");
|
||||
INFO_LOG_FMT(IOS_STM, "{} - IOCtl:", GetDeviceName());
|
||||
INFO_LOG_FMT(IOS_STM, " IOCTL_STM_HOTRESET");
|
||||
break;
|
||||
|
||||
case IOCTL_STM_VIDIMMING: // (Input: 20 bytes, Output: 20 bytes)
|
||||
INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(IOS_STM, " IOCTL_STM_VIDIMMING");
|
||||
INFO_LOG_FMT(IOS_STM, "{} - IOCtl:", GetDeviceName());
|
||||
INFO_LOG_FMT(IOS_STM, " IOCTL_STM_VIDIMMING");
|
||||
// Memory::Write_U32(1, buffer_out);
|
||||
// return_value = 1;
|
||||
break;
|
||||
|
||||
case IOCTL_STM_LEDMODE: // (Input: 20 bytes, Output: 20 bytes)
|
||||
INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(IOS_STM, " IOCTL_STM_LEDMODE");
|
||||
INFO_LOG_FMT(IOS_STM, "{} - IOCtl:", GetDeviceName());
|
||||
INFO_LOG_FMT(IOS_STM, " IOCTL_STM_LEDMODE");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -30,7 +30,7 @@ void BackUpBTInfoSection(const SysConf* sysconf)
|
|||
|
||||
const std::vector<u8>& section = btdinf->bytes;
|
||||
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)
|
||||
|
@ -43,7 +43,7 @@ void RestoreBTInfoSection(SysConf* sysconf)
|
|||
auto& section = sysconf->GetOrAddEntry("BT.DINF", SysConf::Entry::Type::BigArray)->bytes;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace IOS::HLE
|
|||
SQueuedEvent::SQueuedEvent(u32 size_, u16 handle) : size(size_), connection_handle(handle)
|
||||
{
|
||||
if (size > 1024)
|
||||
PanicAlert("SQueuedEvent: The size is too large.");
|
||||
PanicAlertFmt("SQueuedEvent: The size is too large.");
|
||||
}
|
||||
|
||||
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.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],
|
||||
tmp_bd[2], tmp_bd[3], tmp_bd[4], tmp_bd[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Wii Remote {} BT ID {:x},{:x},{:x},{:x},{:x},{:x}", i, tmp_bd[0],
|
||||
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));
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ BluetoothEmu::BluetoothEmu(Kernel& ios, const std::string& device_name)
|
|||
section.resize(sizeof(ConfPads));
|
||||
std::memcpy(section.data(), &bt_dinf, sizeof(ConfPads));
|
||||
if (!sysconf.Save())
|
||||
PanicAlertT("Failed to write BT.DINF to SYSCONF");
|
||||
PanicAlertFmtT("Failed to write BT.DINF to SYSCONF");
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ IPCCommandResult BluetoothEmu::IOCtlV(const IOCtlVRequest& request)
|
|||
if (ctrl.endpoint == HCI_EVENT) // We are given a HCI buffer to fill
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
|
@ -216,7 +216,7 @@ void BluetoothEmu::SendToDevice(u16 connection_handle, u8* data, u32 size)
|
|||
if (wiimote == nullptr)
|
||||
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);
|
||||
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);
|
||||
|
||||
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())
|
||||
{
|
||||
DEBUG_LOG(IOS_WIIMOTE, "ACL endpoint valid, sending packet to %08x",
|
||||
m_acl_endpoint->ios_request.address);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "ACL endpoint valid, sending packet to {:08x}",
|
||||
m_acl_endpoint->ios_request.address);
|
||||
|
||||
hci_acldata_hdr_t* header =
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
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_event_queue.empty()) // fast path :)
|
||||
{
|
||||
DEBUG_LOG(IOS_WIIMOTE, "HCI endpoint valid, sending packet to %08x",
|
||||
m_hci_endpoint->ios_request.address);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "HCI endpoint valid, sending packet to {:08x}",
|
||||
m_hci_endpoint->ios_request.address);
|
||||
m_hci_endpoint->FillBuffer(event.buffer, event.size);
|
||||
|
||||
// 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
|
||||
{
|
||||
DEBUG_LOG(IOS_WIIMOTE, "HCI endpoint not currently valid, queueing (%zu)...",
|
||||
m_event_queue.size());
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "HCI endpoint not currently valid, queueing ({})...",
|
||||
m_event_queue.size());
|
||||
m_event_queue.push_back(event);
|
||||
const SQueuedEvent& queued_event = m_event_queue.front();
|
||||
DEBUG_LOG(IOS_WIIMOTE,
|
||||
"HCI event %x "
|
||||
"being written from queue (%zu) to %08x...",
|
||||
((hci_event_hdr_t*)queued_event.buffer)->event, m_event_queue.size() - 1,
|
||||
m_hci_endpoint->ios_request.address);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE,
|
||||
"HCI event {:x} "
|
||||
"being written from queue ({}) to {:08x}...",
|
||||
((hci_event_hdr_t*)queued_event.buffer)->event, m_event_queue.size() - 1,
|
||||
m_hci_endpoint->ios_request.address);
|
||||
m_hci_endpoint->FillBuffer(queued_event.buffer, queued_event.size);
|
||||
|
||||
// Send a reply to indicate HCI buffer is filled
|
||||
|
@ -299,8 +300,8 @@ void BluetoothEmu::AddEventToQueue(const SQueuedEvent& event)
|
|||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(IOS_WIIMOTE, "HCI endpoint not currently valid, queuing (%zu)...",
|
||||
m_event_queue.size());
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "HCI endpoint not currently valid, queuing ({})...",
|
||||
m_event_queue.size());
|
||||
m_event_queue.push_back(event);
|
||||
}
|
||||
}
|
||||
|
@ -312,9 +313,9 @@ void BluetoothEmu::Update()
|
|||
{
|
||||
// an endpoint has become available, and we have a stored response.
|
||||
const SQueuedEvent& event = m_event_queue.front();
|
||||
DEBUG_LOG(IOS_WIIMOTE, "HCI event %x being written from queue (%zu) to %08x...",
|
||||
((hci_event_hdr_t*)event.buffer)->event, m_event_queue.size() - 1,
|
||||
m_hci_endpoint->ios_request.address);
|
||||
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,
|
||||
m_hci_endpoint->ios_request.address);
|
||||
m_hci_endpoint->FillBuffer(event.buffer, event.size);
|
||||
|
||||
// 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)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -374,10 +375,8 @@ void BluetoothEmu::ACLPool::WriteToEndpoint(const USB::V0BulkMessage& endpoint)
|
|||
const u16 size = packet.size;
|
||||
const u16 conn_handle = packet.conn_handle;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE,
|
||||
"ACL packet being written from "
|
||||
"queue to %08x",
|
||||
endpoint.ios_request.address);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "ACL packet being written from queue to {:08x}",
|
||||
endpoint.ios_request.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);
|
||||
|
@ -403,7 +402,7 @@ bool BluetoothEmu::SendEventInquiryComplete(u8 num_responses)
|
|||
|
||||
AddEventToQueue(event);
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: Inquiry complete");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: Inquiry complete");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -447,10 +446,10 @@ bool BluetoothEmu::SendEventInquiryResponse()
|
|||
std::copy_n(wiimote->GetClass().begin(), HCI_CLASS_SIZE, response->uclass);
|
||||
response->clock_offset = 0x3818;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: Send Fake Inquiry of one controller");
|
||||
DEBUG_LOG(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[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: Send Fake Inquiry of one controller");
|
||||
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[5]);
|
||||
|
||||
inquiry_result->PayloadLength =
|
||||
u8(sizeof(SHCIEventInquiryResult) - 2 +
|
||||
|
@ -483,14 +482,15 @@ bool BluetoothEmu::SendEventConnectionComplete(const bdaddr_t& bd, u8 status)
|
|||
"HCI_LINK_eSCO 0x02 - eSCO",
|
||||
};
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventConnectionComplete");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", connection_complete->Connection_Handle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", connection_complete->bdaddr[0],
|
||||
connection_complete->bdaddr[1], connection_complete->bdaddr[2],
|
||||
connection_complete->bdaddr[3], connection_complete->bdaddr[4],
|
||||
connection_complete->bdaddr[5]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " LinkType: %s", link_type[connection_complete->LinkType]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " EncryptionEnabled: %i", connection_complete->EncryptionEnabled);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventConnectionComplete");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||
connection_complete->Connection_Handle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
connection_complete->bdaddr[0], connection_complete->bdaddr[1],
|
||||
connection_complete->bdaddr[2], connection_complete->bdaddr[3],
|
||||
connection_complete->bdaddr[4], connection_complete->bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " LinkType: {}", link_type[connection_complete->LinkType]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " EncryptionEnabled: {}", connection_complete->EncryptionEnabled);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -517,15 +517,15 @@ bool BluetoothEmu::SendEventRequestConnection(const WiimoteDevice& wiimote)
|
|||
"HCI_LINK_eSCO 0x02 - eSCO",
|
||||
};
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRequestConnection");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", event_request_connection->bdaddr[0],
|
||||
event_request_connection->bdaddr[1], event_request_connection->bdaddr[2],
|
||||
event_request_connection->bdaddr[3], 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(IOS_WIIMOTE, " COD[1]: 0x%02x", event_request_connection->uclass[1]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " COD[2]: 0x%02x", event_request_connection->uclass[2]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " LinkType: %s", link_type[event_request_connection->LinkType]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventRequestConnection");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
event_request_connection->bdaddr[0], event_request_connection->bdaddr[1],
|
||||
event_request_connection->bdaddr[2], event_request_connection->bdaddr[3],
|
||||
event_request_connection->bdaddr[4], event_request_connection->bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[0]: {:#04x}", event_request_connection->uclass[0]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[1]: {:#04x}", event_request_connection->uclass[1]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[2]: {:#04x}", event_request_connection->uclass[2]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " LinkType: {}", link_type[event_request_connection->LinkType]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -547,9 +547,9 @@ bool BluetoothEmu::SendEventDisconnect(u16 connection_handle, u8 reason)
|
|||
|
||||
AddEventToQueue(event);
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventDisconnect");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", disconnect->Connection_Handle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Reason: 0x%02x", disconnect->Reason);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventDisconnect");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}", disconnect->Connection_Handle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Reason: {:#04x}", disconnect->Reason);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -569,9 +569,9 @@ bool BluetoothEmu::SendEventAuthenticationCompleted(u16 connection_handle)
|
|||
event_authentication_completed->EventStatus = 0;
|
||||
event_authentication_completed->Connection_Handle = connection_handle;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventAuthenticationCompleted");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x",
|
||||
event_authentication_completed->Connection_Handle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventAuthenticationCompleted");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||
event_authentication_completed->Connection_Handle);
|
||||
|
||||
AddEventToQueue(event);
|
||||
|
||||
|
@ -594,11 +594,11 @@ bool BluetoothEmu::SendEventRemoteNameReq(const bdaddr_t& bd)
|
|||
remote_name_req->bdaddr = bd;
|
||||
strcpy((char*)remote_name_req->RemoteName, wiimote->GetName());
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRemoteNameReq");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", remote_name_req->bdaddr[0],
|
||||
remote_name_req->bdaddr[1], remote_name_req->bdaddr[2], 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, "Event: SendEventRemoteNameReq");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
remote_name_req->bdaddr[0], remote_name_req->bdaddr[1], remote_name_req->bdaddr[2],
|
||||
remote_name_req->bdaddr[3], remote_name_req->bdaddr[4], remote_name_req->bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " RemoteName: {}", remote_name_req->RemoteName);
|
||||
|
||||
AddEventToQueue(event);
|
||||
|
||||
|
@ -621,13 +621,14 @@ bool BluetoothEmu::SendEventReadRemoteFeatures(u16 connection_handle)
|
|||
read_remote_features->ConnectionHandle = connection_handle;
|
||||
std::copy_n(wiimote->GetFeatures().begin(), HCI_FEATURES_SIZE, read_remote_features->features);
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventReadRemoteFeatures");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", read_remote_features->ConnectionHandle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " features: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
read_remote_features->features[0], read_remote_features->features[1],
|
||||
read_remote_features->features[2], read_remote_features->features[3],
|
||||
read_remote_features->features[4], read_remote_features->features[5],
|
||||
read_remote_features->features[6], read_remote_features->features[7]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventReadRemoteFeatures");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||
read_remote_features->ConnectionHandle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " features: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
read_remote_features->features[0], read_remote_features->features[1],
|
||||
read_remote_features->features[2], read_remote_features->features[3],
|
||||
read_remote_features->features[4], read_remote_features->features[5],
|
||||
read_remote_features->features[6], read_remote_features->features[7]);
|
||||
|
||||
AddEventToQueue(event);
|
||||
|
||||
|
@ -651,11 +652,12 @@ bool BluetoothEmu::SendEventReadRemoteVerInfo(u16 connection_handle)
|
|||
read_remote_ver_info->manufacturer = wiimote->GetManufactorID();
|
||||
read_remote_ver_info->lmp_subversion = wiimote->GetLMPSubVersion();
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventReadRemoteVerInfo");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", read_remote_ver_info->ConnectionHandle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " lmp_version: 0x%02x", read_remote_ver_info->lmp_version);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " manufacturer: 0x%04x", read_remote_ver_info->manufacturer);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " lmp_subversion: 0x%04x", read_remote_ver_info->lmp_subversion);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventReadRemoteVerInfo");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||
read_remote_ver_info->ConnectionHandle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " lmp_version: {:#04x}", read_remote_ver_info->lmp_version);
|
||||
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);
|
||||
|
||||
|
@ -681,7 +683,7 @@ void BluetoothEmu::SendEventCommandComplete(u16 opcode, const void* data, u32 da
|
|||
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);
|
||||
}
|
||||
|
@ -697,7 +699,7 @@ bool BluetoothEmu::SendEventCommandStatus(u16 opcode)
|
|||
hci_event->PacketIndicator = 0x01;
|
||||
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);
|
||||
|
||||
|
@ -722,11 +724,11 @@ bool BluetoothEmu::SendEventRoleChange(bdaddr_t bd, bool master)
|
|||
|
||||
AddEventToQueue(event);
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRoleChange");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", role_change->bdaddr[0],
|
||||
role_change->bdaddr[1], role_change->bdaddr[2], 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, "Event: SendEventRoleChange");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
role_change->bdaddr[0], role_change->bdaddr[1], role_change->bdaddr[2],
|
||||
role_change->bdaddr[3], role_change->bdaddr[4], role_change->bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " NewRole: {}", role_change->NewRole);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -737,7 +739,7 @@ bool BluetoothEmu::SendEventNumberOfCompletedPackets()
|
|||
(sizeof(hci_num_compl_pkts_info) * m_wiimotes.size())),
|
||||
0);
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventNumberOfCompletedPackets");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventNumberOfCompletedPackets");
|
||||
|
||||
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));
|
||||
|
@ -756,8 +758,8 @@ bool BluetoothEmu::SendEventNumberOfCompletedPackets()
|
|||
info->compl_pkts = m_packet_count[i];
|
||||
info->con_handle = GetConnectionHandle(m_wiimotes[i]->GetBD());
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", info->con_handle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Number_Of_Completed_Packets: %i", info->compl_pkts);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}", info->con_handle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Number_Of_Completed_Packets: {}", info->compl_pkts);
|
||||
|
||||
acc += info->compl_pkts;
|
||||
m_packet_count[i] = 0;
|
||||
|
@ -770,7 +772,7 @@ bool BluetoothEmu::SendEventNumberOfCompletedPackets()
|
|||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(IOS_WIIMOTE, "SendEventNumberOfCompletedPackets: no packets; no event");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "SendEventNumberOfCompletedPackets: no packets; no event");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -792,9 +794,9 @@ bool BluetoothEmu::SendEventModeChange(u16 connection_handle, u8 mode, u16 value
|
|||
mode_change->CurrentMode = mode;
|
||||
mode_change->Value = value;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventModeChange");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", mode_change->Connection_Handle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Current Mode: 0x%02x", mode_change->CurrentMode = mode);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventModeChange");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}", mode_change->Connection_Handle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Current Mode: {:#04x}", mode_change->CurrentMode = mode);
|
||||
|
||||
AddEventToQueue(event);
|
||||
|
||||
|
@ -807,7 +809,7 @@ bool BluetoothEmu::SendEventLinkKeyNotification(const u8 num_to_send)
|
|||
SQueuedEvent event(2 + payload_length, 0);
|
||||
SHCIEventLinkKeyNotification* event_link_key = (SHCIEventLinkKeyNotification*)event.buffer;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventLinkKeyNotification");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventLinkKeyNotification");
|
||||
|
||||
// event header
|
||||
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();
|
||||
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],
|
||||
link_key_info->bdaddr[1], link_key_info->bdaddr[2], link_key_info->bdaddr[3],
|
||||
link_key_info->bdaddr[4], link_key_info->bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
link_key_info->bdaddr[0], link_key_info->bdaddr[1], link_key_info->bdaddr[2],
|
||||
link_key_info->bdaddr[3], link_key_info->bdaddr[4], link_key_info->bdaddr[5]);
|
||||
}
|
||||
|
||||
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->bdaddr = bd;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRequestLinkKey");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", event_request_link_key->bdaddr[0],
|
||||
event_request_link_key->bdaddr[1], event_request_link_key->bdaddr[2],
|
||||
event_request_link_key->bdaddr[3], event_request_link_key->bdaddr[4],
|
||||
event_request_link_key->bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventRequestLinkKey");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
event_request_link_key->bdaddr[0], event_request_link_key->bdaddr[1],
|
||||
event_request_link_key->bdaddr[2], event_request_link_key->bdaddr[3],
|
||||
event_request_link_key->bdaddr[4], event_request_link_key->bdaddr[5]);
|
||||
|
||||
AddEventToQueue(event);
|
||||
|
||||
|
@ -871,10 +873,10 @@ bool BluetoothEmu::SendEventReadClockOffsetComplete(u16 connection_handle)
|
|||
read_clock_offset_complete->ConnectionHandle = connection_handle;
|
||||
read_clock_offset_complete->ClockOffset = 0x3818;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventReadClockOffsetComplete");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x",
|
||||
read_clock_offset_complete->ConnectionHandle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " ClockOffset: 0x%04x", read_clock_offset_complete->ClockOffset);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventReadClockOffsetComplete");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||
read_clock_offset_complete->ConnectionHandle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " ClockOffset: {:#06x}", read_clock_offset_complete->ClockOffset);
|
||||
|
||||
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->PacketType = packet_type;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventConPacketTypeChange");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", change_con_packet_type->ConnectionHandle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " PacketType: 0x%04x", change_con_packet_type->PacketType);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Event: SendEventConPacketTypeChange");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Connection_Handle: {:#06x}",
|
||||
change_con_packet_type->ConnectionHandle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " PacketType: {:#06x}", change_con_packet_type->PacketType);
|
||||
|
||||
AddEventToQueue(event);
|
||||
|
||||
|
@ -918,9 +921,9 @@ void BluetoothEmu::ExecuteHCICommandMessage(const USB::V0CtrlMessage& ctrl_messa
|
|||
const u16 ocf = HCI_OCF(msg.Opcode);
|
||||
const u16 ogf = HCI_OGF(msg.Opcode);
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "**************************************************");
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Execute HCI Command: 0x%04x (ocf: 0x%02x, ogf: 0x%02x)", msg.Opcode, ocf,
|
||||
ogf);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "**************************************************");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Execute HCI Command: {:#06x} (ocf: {:#04x}, ogf: {:#04x})",
|
||||
msg.Opcode, ocf, ogf);
|
||||
|
||||
switch (msg.Opcode)
|
||||
{
|
||||
|
@ -1074,10 +1077,10 @@ void BluetoothEmu::ExecuteHCICommandMessage(const USB::V0CtrlMessage& ctrl_messa
|
|||
|
||||
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++)
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, " 0x02%x", input[i]);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, " 0x02{:#x}", input[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1103,13 +1106,13 @@ void BluetoothEmu::CommandInquiry(const u8* input)
|
|||
hci_inquiry_cp inquiry;
|
||||
std::memcpy(&inquiry, input, sizeof(inquiry));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_INQUIRY:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, "write:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " LAP[0]: 0x%02x", inquiry.lap[0]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " LAP[1]: 0x%02x", inquiry.lap[1]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " LAP[2]: 0x%02x", inquiry.lap[2]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " inquiry_length: %i (N x 1.28) sec", inquiry.inquiry_length);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " num_responses: %i (N x 1.28) sec", inquiry.num_responses);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_INQUIRY:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "write:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " LAP[0]: {:#04x}", inquiry.lap[0]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " LAP[1]: {:#04x}", inquiry.lap[1]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " LAP[2]: {:#04x}", inquiry.lap[2]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " inquiry_length: {} (N x 1.28) sec", inquiry.inquiry_length);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " num_responses: {} (N x 1.28) sec", inquiry.num_responses);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_INQUIRY);
|
||||
SendEventInquiryResponse();
|
||||
|
@ -1120,7 +1123,7 @@ void BluetoothEmu::CommandInquiryCancel(const u8* input)
|
|||
hci_inquiry_cancel_rp reply;
|
||||
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));
|
||||
}
|
||||
|
@ -1130,16 +1133,17 @@ void BluetoothEmu::CommandCreateCon(const u8* input)
|
|||
hci_create_con_cp create_connection;
|
||||
std::memcpy(&create_connection, input, sizeof(create_connection));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_CREATE_CON");
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Input:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", create_connection.bdaddr[0],
|
||||
create_connection.bdaddr[1], create_connection.bdaddr[2], create_connection.bdaddr[3],
|
||||
create_connection.bdaddr[4], create_connection.bdaddr[5]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " pkt_type: %i", create_connection.pkt_type);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " page_scan_rep_mode: %i", create_connection.page_scan_rep_mode);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " page_scan_mode: %i", create_connection.page_scan_mode);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " clock_offset: %i", create_connection.clock_offset);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " accept_role_switch: %i", create_connection.accept_role_switch);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_CREATE_CON");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Input:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
create_connection.bdaddr[0], create_connection.bdaddr[1],
|
||||
create_connection.bdaddr[2], create_connection.bdaddr[3],
|
||||
create_connection.bdaddr[4], create_connection.bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " pkt_type: {}", create_connection.pkt_type);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " page_scan_rep_mode: {}", create_connection.page_scan_rep_mode);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " page_scan_mode: {}", create_connection.page_scan_mode);
|
||||
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);
|
||||
|
||||
|
@ -1155,9 +1159,9 @@ void BluetoothEmu::CommandDisconnect(const u8* input)
|
|||
hci_discon_cp disconnect;
|
||||
std::memcpy(&disconnect, input, sizeof(disconnect));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_DISCONNECT");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", disconnect.con_handle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Reason: 0x%02x", disconnect.reason);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_DISCONNECT");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", disconnect.con_handle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Reason: {:#04x}", disconnect.reason);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_DISCONNECT);
|
||||
SendEventDisconnect(disconnect.con_handle, disconnect.reason);
|
||||
|
@ -1177,11 +1181,12 @@ void BluetoothEmu::CommandAcceptCon(const u8* input)
|
|||
"Slave (0x01)",
|
||||
};
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_ACCEPT_CON");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", accept_connection.bdaddr[0],
|
||||
accept_connection.bdaddr[1], accept_connection.bdaddr[2], accept_connection.bdaddr[3],
|
||||
accept_connection.bdaddr[4], accept_connection.bdaddr[5]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " role: %s", roles[accept_connection.role]);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_ACCEPT_CON");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
accept_connection.bdaddr[0], accept_connection.bdaddr[1],
|
||||
accept_connection.bdaddr[2], accept_connection.bdaddr[3],
|
||||
accept_connection.bdaddr[4], accept_connection.bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " role: {}", roles[accept_connection.role]);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_ACCEPT_CON);
|
||||
|
||||
|
@ -1209,10 +1214,10 @@ void BluetoothEmu::CommandLinkKeyRep(const u8* input)
|
|||
hci_link_key_rep_cp key_rep;
|
||||
std::memcpy(&key_rep, input, sizeof(key_rep));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_LINK_KEY_REP");
|
||||
DEBUG_LOG(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[5]);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_LINK_KEY_REP");
|
||||
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[5]);
|
||||
|
||||
hci_link_key_rep_rp reply;
|
||||
reply.status = 0x00;
|
||||
|
@ -1226,10 +1231,10 @@ void BluetoothEmu::CommandLinkKeyNegRep(const u8* input)
|
|||
hci_link_key_neg_rep_cp key_neg;
|
||||
std::memcpy(&key_neg, input, sizeof(key_neg));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_LINK_KEY_NEG_REP");
|
||||
DEBUG_LOG(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[5]);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_LINK_KEY_NEG_REP");
|
||||
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[5]);
|
||||
|
||||
hci_link_key_neg_rep_rp reply;
|
||||
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 |
|
||||
// HCI_PKT_DM1
|
||||
// dunno what to do...run awayyyyyy!
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_CHANGE_CON_PACKET_TYPE");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", change_packet_type.con_handle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " PacketType: 0x%04x", change_packet_type.pkt_type);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_CHANGE_CON_PACKET_TYPE");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", change_packet_type.con_handle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " PacketType: {:#06x}", change_packet_type.pkt_type);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_CHANGE_CON_PACKET_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;
|
||||
std::memcpy(&auth_req, input, sizeof(auth_req));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_AUTH_REQ");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", auth_req.con_handle);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_AUTH_REQ");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", auth_req.con_handle);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_AUTH_REQ);
|
||||
SendEventAuthenticationCompleted(auth_req.con_handle);
|
||||
|
@ -1271,13 +1276,13 @@ void BluetoothEmu::CommandRemoteNameReq(const u8* input)
|
|||
hci_remote_name_req_cp remote_name_req;
|
||||
std::memcpy(&remote_name_req, input, sizeof(remote_name_req));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_REMOTE_NAME_REQ");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", remote_name_req.bdaddr[0],
|
||||
remote_name_req.bdaddr[1], remote_name_req.bdaddr[2], 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(IOS_WIIMOTE, " page_scan_mode: %i", remote_name_req.page_scan_mode);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " clock_offset: %i", remote_name_req.clock_offset);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_REMOTE_NAME_REQ");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
remote_name_req.bdaddr[0], remote_name_req.bdaddr[1], remote_name_req.bdaddr[2],
|
||||
remote_name_req.bdaddr[3], remote_name_req.bdaddr[4], remote_name_req.bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " page_scan_rep_mode: {}", remote_name_req.page_scan_rep_mode);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " page_scan_mode: {}", remote_name_req.page_scan_mode);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " clock_offset: {}", remote_name_req.clock_offset);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_REMOTE_NAME_REQ);
|
||||
SendEventRemoteNameReq(remote_name_req.bdaddr);
|
||||
|
@ -1288,8 +1293,8 @@ void BluetoothEmu::CommandReadRemoteFeatures(const u8* input)
|
|||
hci_read_remote_features_cp read_remote_features;
|
||||
std::memcpy(&read_remote_features, input, sizeof(read_remote_features));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_FEATURES");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", read_remote_features.con_handle);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_FEATURES");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", read_remote_features.con_handle);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_READ_REMOTE_FEATURES);
|
||||
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;
|
||||
std::memcpy(&read_remote_ver_info, input, sizeof(read_remote_ver_info));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_VER_INFO");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%02x", read_remote_ver_info.con_handle);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_VER_INFO");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#04x}", read_remote_ver_info.con_handle);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_READ_REMOTE_VER_INFO);
|
||||
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;
|
||||
std::memcpy(&read_clock_offset, input, sizeof(read_clock_offset));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_CLOCK_OFFSET");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%02x", read_clock_offset.con_handle);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_CLOCK_OFFSET");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#04x}", read_clock_offset.con_handle);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_READ_CLOCK_OFFSET);
|
||||
SendEventReadClockOffsetComplete(read_clock_offset.con_handle);
|
||||
|
@ -1324,12 +1329,12 @@ void BluetoothEmu::CommandSniffMode(const u8* input)
|
|||
hci_sniff_mode_cp sniff_mode;
|
||||
std::memcpy(&sniff_mode, input, sizeof(sniff_mode));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_SNIFF_MODE");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", sniff_mode.con_handle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " max_interval: %f msec", sniff_mode.max_interval * .625);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " min_interval: %f msec", sniff_mode.min_interval * .625);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " attempt: %f msec", sniff_mode.attempt * 1.25);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " timeout: %f msec", sniff_mode.timeout * 1.25);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_SNIFF_MODE");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", sniff_mode.con_handle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_interval: {} msec", sniff_mode.max_interval * .625);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " min_interval: {} msec", sniff_mode.min_interval * .625);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " attempt: {} msec", sniff_mode.attempt * 1.25);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " timeout: {} msec", sniff_mode.timeout * 1.25);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_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;
|
||||
std::memcpy(&link_policy, input, sizeof(link_policy));
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_POLICY_SETTINGS");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", link_policy.con_handle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Policy: 0x%04x", link_policy.settings);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_POLICY_SETTINGS");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " ConnectionHandle: {:#06x}", link_policy.con_handle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Policy: {:#06x}", link_policy.settings);
|
||||
|
||||
SendEventCommandStatus(HCI_CMD_WRITE_LINK_POLICY_SETTINGS);
|
||||
}
|
||||
|
@ -1352,7 +1357,7 @@ void BluetoothEmu::CommandReset(const u8* input)
|
|||
hci_status_rp reply;
|
||||
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));
|
||||
|
||||
// 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;
|
||||
reply.status = 0x00;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_SET_EVENT_FILTER:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " filter_type: %i", set_event_filter.filter_type);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " filter_condition_type: %i", set_event_filter.filter_condition_type);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_SET_EVENT_FILTER:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " filter_type: {}", set_event_filter.filter_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));
|
||||
}
|
||||
|
@ -1387,8 +1392,8 @@ void BluetoothEmu::CommandWritePinType(const u8* input)
|
|||
hci_write_pin_type_rp reply;
|
||||
reply.status = 0x00;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PIN_TYPE:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " pin_type: %x", write_pin_type.pin_type);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_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));
|
||||
}
|
||||
|
@ -1406,18 +1411,18 @@ void BluetoothEmu::CommandReadStoredLinkKey(const u8* input)
|
|||
if (read_stored_link_key.read_all == 1)
|
||||
reply.num_keys_read = static_cast<u16>(m_wiimotes.size());
|
||||
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:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, "input:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", read_stored_link_key.bdaddr[0],
|
||||
read_stored_link_key.bdaddr[1], read_stored_link_key.bdaddr[2],
|
||||
read_stored_link_key.bdaddr[3], 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(IOS_WIIMOTE, "return:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " max_num_keys: %i", reply.max_num_keys);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " num_keys_read: %i", reply.num_keys_read);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_STORED_LINK_KEY:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "input:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
read_stored_link_key.bdaddr[0], read_stored_link_key.bdaddr[1],
|
||||
read_stored_link_key.bdaddr[2], read_stored_link_key.bdaddr[3],
|
||||
read_stored_link_key.bdaddr[4], read_stored_link_key.bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " read_all: {}", read_stored_link_key.read_all);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "return:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_num_keys: {}", reply.max_num_keys);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " num_keys_read: {}", reply.num_keys_read);
|
||||
|
||||
SendEventLinkKeyNotification(static_cast<u8>(reply.num_keys_read));
|
||||
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;
|
||||
std::memcpy(&delete_stored_link_key, input, sizeof(delete_stored_link_key));
|
||||
|
||||
INFO_LOG(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],
|
||||
delete_stored_link_key.bdaddr[1], delete_stored_link_key.bdaddr[2],
|
||||
delete_stored_link_key.bdaddr[3], 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);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_OCF_DELETE_STORED_LINK_KEY");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
delete_stored_link_key.bdaddr[0], delete_stored_link_key.bdaddr[1],
|
||||
delete_stored_link_key.bdaddr[2], delete_stored_link_key.bdaddr[3],
|
||||
delete_stored_link_key.bdaddr[4], delete_stored_link_key.bdaddr[5]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " delete_all: {:#x}", delete_stored_link_key.delete_all);
|
||||
|
||||
const WiimoteDevice* wiimote = AccessWiimote(delete_stored_link_key.bdaddr);
|
||||
if (wiimote == nullptr)
|
||||
|
@ -1447,8 +1452,8 @@ void BluetoothEmu::CommandDeleteStoredLinkKey(const u8* input)
|
|||
SendEventCommandComplete(HCI_CMD_DELETE_STORED_LINK_KEY, &reply,
|
||||
sizeof(hci_delete_stored_link_key_rp));
|
||||
|
||||
ERROR_LOG(IOS_WIIMOTE, "HCI: CommandDeleteStoredLinkKey... Probably the security for linking "
|
||||
"has failed. Could be a problem with loading the SCONF");
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "HCI: CommandDeleteStoredLinkKey... Probably the security for linking "
|
||||
"has failed. Could be a problem with loading the SCONF");
|
||||
}
|
||||
|
||||
void BluetoothEmu::CommandWriteLocalName(const u8* input)
|
||||
|
@ -1459,8 +1464,8 @@ void BluetoothEmu::CommandWriteLocalName(const u8* input)
|
|||
hci_write_local_name_rp reply;
|
||||
reply.status = 0x00;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LOCAL_NAME:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " local_name: %s", write_local_name.name);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LOCAL_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));
|
||||
}
|
||||
|
@ -1473,8 +1478,8 @@ void BluetoothEmu::CommandWritePageTimeOut(const u8* input)
|
|||
hci_host_buffer_size_rp reply;
|
||||
reply.status = 0x00;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_TIMEOUT:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " timeout: %i", write_page_timeout.timeout);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_TIMEOUT:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " timeout: {}", write_page_timeout.timeout);
|
||||
|
||||
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",
|
||||
};
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_SCAN_ENABLE: (0x%02x)",
|
||||
write_scan_enable.scan_enable);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " scan_enable: %s", scanning[write_scan_enable.scan_enable]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_SCAN_ENABLE: ({:#04x})",
|
||||
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));
|
||||
}
|
||||
|
@ -1511,10 +1516,10 @@ void BluetoothEmu::CommandWriteUnitClass(const u8* input)
|
|||
hci_write_unit_class_rp reply;
|
||||
reply.status = 0x00;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_UNIT_CLASS:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " COD[0]: 0x%02x", write_unit_class.uclass[0]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " COD[1]: 0x%02x", write_unit_class.uclass[1]);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " COD[2]: 0x%02x", write_unit_class.uclass[2]);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_UNIT_CLASS:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[0]: {:#04x}", write_unit_class.uclass[0]);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " COD[1]: {:#04x}", write_unit_class.uclass[1]);
|
||||
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));
|
||||
}
|
||||
|
@ -1527,11 +1532,11 @@ void BluetoothEmu::CommandHostBufferSize(const u8* input)
|
|||
hci_host_buffer_size_rp reply;
|
||||
reply.status = 0x00;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_HOST_BUFFER_SIZE:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " max_acl_size: %i", host_buffer_size.max_acl_size);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " max_sco_size: %i", host_buffer_size.max_sco_size);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " num_acl_pkts: %i", host_buffer_size.num_acl_pkts);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " num_sco_pkts: %i", host_buffer_size.num_sco_pkts);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_HOST_BUFFER_SIZE:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_acl_size: {}", host_buffer_size.max_acl_size);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_sco_size: {}", host_buffer_size.max_sco_size);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " num_acl_pkts: {}", host_buffer_size.num_acl_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));
|
||||
}
|
||||
|
@ -1542,9 +1547,9 @@ void BluetoothEmu::CommandWriteLinkSupervisionTimeout(const u8* input)
|
|||
std::memcpy(&supervision, input, sizeof(supervision));
|
||||
|
||||
// timeout of 0 means timing out is disabled
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " con_handle: 0x%04x", supervision.con_handle);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " timeout: 0x%02x", supervision.timeout);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " con_handle: {:#06x}", supervision.con_handle);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " timeout: {:#04x}", supervision.timeout);
|
||||
|
||||
hci_write_link_supervision_timeout_rp reply;
|
||||
reply.status = 0x00;
|
||||
|
@ -1562,8 +1567,8 @@ void BluetoothEmu::CommandWriteInquiryScanType(const u8* input)
|
|||
hci_write_inquiry_scan_type_rp reply;
|
||||
reply.status = 0x00;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_SCAN_TYPE:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " type: %i", set_event_filter.type);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_SCAN_TYPE:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " type: {}", set_event_filter.type);
|
||||
|
||||
SendEventCommandComplete(HCI_CMD_WRITE_INQUIRY_SCAN_TYPE, &reply,
|
||||
sizeof(hci_write_inquiry_scan_type_rp));
|
||||
|
@ -1584,8 +1589,8 @@ void BluetoothEmu::CommandWriteInquiryMode(const u8* input)
|
|||
"Inquiry Result format with RSSI",
|
||||
"Inquiry Result with RSSI format or Extended Inquiry Result format",
|
||||
};
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_MODE:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " mode: %s", inquiry_mode_tag[inquiry_mode.mode]);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_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));
|
||||
}
|
||||
|
@ -1603,8 +1608,8 @@ void BluetoothEmu::CommandWritePageScanType(const u8* input)
|
|||
"Optional: Interlaced Scan",
|
||||
};
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_SCAN_TYPE:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " type: %s", page_scan_type[write_page_scan_type.type]);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_SCAN_TYPE:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " type: {}", page_scan_type[write_page_scan_type.type]);
|
||||
|
||||
SendEventCommandComplete(HCI_CMD_WRITE_PAGE_SCAN_TYPE, &reply,
|
||||
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.lmp_subversion = 0x430e; // LMP subversion
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_VER:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, "return:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " status: %i", reply.status);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " hci_revision: %i", reply.hci_revision);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " lmp_version: %i", reply.lmp_version);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " manufacturer: %i", reply.manufacturer);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " lmp_subversion: %i", reply.lmp_subversion);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_VER:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "return:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " status: {}", reply.status);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " hci_revision: {}", reply.hci_revision);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " lmp_version: {}", reply.lmp_version);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " manufacturer: {}", reply.manufacturer);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " lmp_subversion: {}", reply.lmp_subversion);
|
||||
|
||||
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[7] = 0x80;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_FEATURES:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, "return:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " features: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", reply.features[0],
|
||||
reply.features[1], reply.features[2], reply.features[3], reply.features[4],
|
||||
reply.features[5], reply.features[6], reply.features[7]);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_FEATURES:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "return:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " features: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
|
||||
reply.features[0], reply.features[1], reply.features[2], reply.features[3],
|
||||
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));
|
||||
}
|
||||
|
@ -1665,12 +1670,12 @@ void BluetoothEmu::CommandReadBufferSize(const u8* input)
|
|||
reply.max_sco_size = SCO_PKT_SIZE;
|
||||
reply.num_sco_pkts = SCO_PKT_NUM;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_BUFFER_SIZE:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, "return:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " max_acl_size: %i", reply.max_acl_size);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " num_acl_pkts: %i", reply.num_acl_pkts);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " max_sco_size: %i", reply.max_sco_size);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " num_sco_pkts: %i", reply.num_sco_pkts);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_BUFFER_SIZE:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "return:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_acl_size: {}", reply.max_acl_size);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " num_acl_pkts: {}", reply.num_acl_pkts);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " max_sco_size: {}", reply.max_sco_size);
|
||||
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));
|
||||
}
|
||||
|
@ -1681,10 +1686,11 @@ void BluetoothEmu::CommandReadBDAdrr(const u8* input)
|
|||
reply.status = 0x00;
|
||||
reply.bdaddr = m_controller_bd;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_BDADDR:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, "return:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", reply.bdaddr[0], reply.bdaddr[1],
|
||||
reply.bdaddr[2], reply.bdaddr[3], reply.bdaddr[4], reply.bdaddr[5]);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: HCI_CMD_READ_BDADDR:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "return:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", reply.bdaddr[0],
|
||||
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));
|
||||
}
|
||||
|
@ -1701,8 +1707,8 @@ void BluetoothEmu::CommandVendorSpecific_FC4F(const u8* input, u32 size)
|
|||
hci_status_rp reply;
|
||||
reply.status = 0x00;
|
||||
|
||||
INFO_LOG(IOS_WIIMOTE, "Command: CommandVendorSpecific_FC4F: (callstack WUDiRemovePatch)");
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Input (size 0x%x):", size);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Command: CommandVendorSpecific_FC4F: (callstack WUDiRemovePatch)");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Input (size {:#x}):", size);
|
||||
|
||||
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;
|
||||
reply.status = 0x00;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Command: CommandVendorSpecific_FC4C:");
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Input (size 0x%x):", size);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Command: CommandVendorSpecific_FC4C:");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Input (size {:#x}):", size);
|
||||
Dolphin_Debugger::PrintDataBuffer(Common::Log::IOS_WIIMOTE, input, size, "Data: ");
|
||||
|
||||
SendEventCommandComplete(0xFC4C, &reply, sizeof(hci_status_rp));
|
||||
|
@ -1760,8 +1766,8 @@ WiimoteDevice* BluetoothEmu::AccessWiimote(u16 connection_handle)
|
|||
if (wiimote)
|
||||
return wiimote;
|
||||
|
||||
ERROR_LOG(IOS_WIIMOTE, "Can't find Wiimote by connection handle %02x", connection_handle);
|
||||
PanicAlertT("Can't find Wii Remote by connection handle %02x", connection_handle);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "Can't find Wiimote by connection handle {:02x}", connection_handle);
|
||||
PanicAlertFmtT("Can't find Wii Remote by connection handle {0:02x}", connection_handle);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -89,8 +89,8 @@ IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
|
|||
auto config_descriptor = LibusbUtils::MakeConfigDescriptor(device);
|
||||
if (!config_descriptor)
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, "Failed to get config descriptor for device %04x:%04x",
|
||||
device_descriptor.idVendor, device_descriptor.idProduct);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "Failed to get config descriptor for device {:04x}:{:04x}",
|
||||
device_descriptor.idVendor, device_descriptor.idProduct);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -105,9 +105,9 @@ IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
|
|||
sizeof(product));
|
||||
libusb_get_string_descriptor_ascii(m_handle, device_descriptor.iSerialNumber, serial_number,
|
||||
sizeof(serial_number));
|
||||
NOTICE_LOG(IOS_WIIMOTE, "Using device %04x:%04x (rev %x) for Bluetooth: %s %s %s",
|
||||
device_descriptor.idVendor, device_descriptor.idProduct,
|
||||
device_descriptor.bcdDevice, manufacturer, product, serial_number);
|
||||
NOTICE_LOG_FMT(IOS_WIIMOTE, "Using device {:04x}:{:04x} (rev {:x}) for Bluetooth: {} {} {}",
|
||||
device_descriptor.idVendor, device_descriptor.idProduct,
|
||||
device_descriptor.bcdDevice, manufacturer, product, serial_number);
|
||||
m_is_wii_bt_module =
|
||||
device_descriptor.idVendor == 0x57e && device_descriptor.idProduct == 0x305;
|
||||
return false;
|
||||
|
@ -119,16 +119,17 @@ IPCCommandResult BluetoothReal::Open(const OpenRequest& request)
|
|||
{
|
||||
if (m_last_open_error.empty())
|
||||
{
|
||||
CriticalAlertT(
|
||||
CriticalAlertFmtT(
|
||||
"Could not find any usable Bluetooth USB adapter for Bluetooth Passthrough.\n\n"
|
||||
"The emulated console will now stop.");
|
||||
}
|
||||
else
|
||||
{
|
||||
CriticalAlertT("Could not find any usable Bluetooth USB adapter for Bluetooth Passthrough.\n"
|
||||
"The following error occurred when Dolphin tried to use an adapter:\n%s\n\n"
|
||||
"The emulated console will now stop.",
|
||||
m_last_open_error.c_str());
|
||||
CriticalAlertFmtT(
|
||||
"Could not find any usable Bluetooth USB adapter for Bluetooth Passthrough.\n"
|
||||
"The following error occurred when Dolphin tried to use an adapter:\n{0}\n\n"
|
||||
"The emulated console will now stop.",
|
||||
m_last_open_error);
|
||||
}
|
||||
Core::QueueHostJob(Core::Stop);
|
||||
return GetDefaultReply(IPC_ENOENT);
|
||||
|
@ -368,7 +369,7 @@ void BluetoothReal::SendHCIResetCommand()
|
|||
const u16 payload[] = {HCI_CMD_RESET};
|
||||
memcpy(packet, payload, sizeof(payload));
|
||||
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()
|
||||
|
@ -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.
|
||||
void BluetoothReal::FakeSyncButtonPressedEvent(USB::V0IntrMessage& ctrl)
|
||||
{
|
||||
NOTICE_LOG(IOS_WIIMOTE, "Faking 'sync button pressed' (0x08) event packet");
|
||||
const u8 payload[1] = {0x08};
|
||||
NOTICE_LOG_FMT(IOS_WIIMOTE, "Faking 'sync button pressed' (0x08) event packet");
|
||||
constexpr u8 payload[1] = {0x08};
|
||||
FakeSyncButtonEvent(ctrl, payload, sizeof(payload));
|
||||
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.
|
||||
void BluetoothReal::FakeSyncButtonHeldEvent(USB::V0IntrMessage& ctrl)
|
||||
{
|
||||
NOTICE_LOG(IOS_WIIMOTE, "Faking 'sync button held' (0x09) event packet");
|
||||
const u8 payload[1] = {0x09};
|
||||
NOTICE_LOG_FMT(IOS_WIIMOTE, "Faking 'sync button held' (0x09) event packet");
|
||||
constexpr u8 payload[1] = {0x09};
|
||||
FakeSyncButtonEvent(ctrl, payload, sizeof(payload));
|
||||
m_sync_button_state = SyncButtonState::Ignored;
|
||||
}
|
||||
|
@ -511,8 +512,9 @@ void BluetoothReal::LoadLinkKeys()
|
|||
std::optional<bdaddr_t> address = Common::StringToMacAddress(address_string);
|
||||
if (!address)
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, "Malformed MAC address (%s). Skipping loading of current link key.",
|
||||
address_string.c_str());
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE,
|
||||
"Malformed MAC address ({}). Skipping loading of current link key.",
|
||||
address_string);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -598,7 +600,7 @@ void BluetoothReal::HandleCtrlTransfer(libusb_transfer* tr)
|
|||
|
||||
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())
|
||||
{
|
||||
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 &&
|
||||
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())
|
||||
{
|
||||
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)
|
||||
{
|
||||
PanicAlertT("Bluetooth passthrough mode is enabled, but Dolphin was built without libusb."
|
||||
" Passthrough mode cannot be used.");
|
||||
PanicAlertFmtT("Bluetooth passthrough mode is enabled, but Dolphin was built without libusb."
|
||||
" Passthrough mode cannot be used.");
|
||||
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")
|
||||
|
||||
{
|
||||
INFO_LOG(IOS_WIIMOTE, "Wiimote: #%i Constructed", number);
|
||||
INFO_LOG_FMT(IOS_WIIMOTE, "Wiimote: #{} Constructed", number);
|
||||
|
||||
m_link_key.fill(0xa0 + number);
|
||||
m_class = {0x00, 0x04, 0x48};
|
||||
|
@ -335,7 +335,7 @@ void WiimoteDevice::Update()
|
|||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -368,12 +368,12 @@ void WiimoteDevice::ExecuteL2capCmd(u8* ptr, u32 size)
|
|||
l2cap_hdr_t* header = (l2cap_hdr_t*)ptr;
|
||||
u8* data = ptr + 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,
|
||||
data_size);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " CID {:#06x}, Len {:#x}, DataSize {:#x}", header->dcid,
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ void WiimoteDevice::ExecuteL2capCmd(u8* ptr, u32 size)
|
|||
const auto itr = m_channels.find(header->dcid);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -423,7 +423,7 @@ void WiimoteDevice::ExecuteL2capCmd(u8* ptr, u32 size)
|
|||
}
|
||||
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;
|
||||
|
@ -434,12 +434,12 @@ void WiimoteDevice::ExecuteL2capCmd(u8* ptr, u32 size)
|
|||
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));
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -455,8 +455,8 @@ void WiimoteDevice::SignalChannel(u8* data, u32 size)
|
|||
switch (cmd_hdr->code)
|
||||
{
|
||||
case L2CAP_COMMAND_REJ:
|
||||
ERROR_LOG(IOS_WIIMOTE, "SignalChannel - L2CAP_COMMAND_REJ (something went wrong)."
|
||||
"Try to replace your SYSCONF file with a new copy.");
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "SignalChannel - L2CAP_COMMAND_REJ (something went wrong)."
|
||||
"Try to replace your SYSCONF file with a new copy.");
|
||||
break;
|
||||
|
||||
case L2CAP_CONNECT_REQ:
|
||||
|
@ -480,7 +480,7 @@ void WiimoteDevice::SignalChannel(u8* data, u32 size)
|
|||
break;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionRequest");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " PSM: 0x%04x", command_connection_req->psm);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", command_connection_req->scid);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionRequest");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Ident: {:#04x}", ident);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " PSM: {:#06x}", command_connection_req->psm);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " SCID: {:#06x}", command_connection_req->scid);
|
||||
|
||||
l2cap_con_rsp_cp rsp = {};
|
||||
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)
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, "Multiple channels with same PSM (%d) are not allowed.",
|
||||
command_connection_req->psm);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "Multiple channels with same PSM ({}) are not allowed.",
|
||||
command_connection_req->psm);
|
||||
|
||||
// A real wii remote refuses multiple connections with the same PSM.
|
||||
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 &&
|
||||
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.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);
|
||||
}
|
||||
|
||||
|
@ -539,11 +539,11 @@ void WiimoteDevice::ReceiveConnectionResponse(u8 ident, u8* data, u32 size)
|
|||
|
||||
DEBUG_ASSERT(size == sizeof(l2cap_con_rsp_cp));
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionResponse");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", rsp->dcid);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", rsp->scid);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Result: 0x%04x", rsp->result);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Status: 0x%04x", rsp->status);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionResponse");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " DCID: {:#06x}", rsp->dcid);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " SCID: {:#06x}", rsp->scid);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Result: {:#06x}", rsp->result);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Status: {:#06x}", rsp->status);
|
||||
|
||||
DEBUG_ASSERT(rsp->result == L2CAP_SUCCESS);
|
||||
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];
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationRequest");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", command_config_req->dcid);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", command_config_req->flags);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationRequest");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Ident: {:#04x}", ident);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " DCID: {:#06x}", command_config_req->dcid);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Flags: {:#06x}", command_config_req->flags);
|
||||
|
||||
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);
|
||||
l2cap_cfg_opt_val_t* mtu = (l2cap_cfg_opt_val_t*)&data[offset];
|
||||
remote_mtu = mtu->mtu;
|
||||
DEBUG_LOG(IOS_WIIMOTE, " MTU: 0x%04x", mtu->mtu);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " MTU: {:#06x}", mtu->mtu);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -606,12 +606,12 @@ void WiimoteDevice::ReceiveConfigurationReq(u8 ident, u8* data, u32 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];
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -622,7 +622,7 @@ void WiimoteDevice::ReceiveConfigurationReq(u8 ident, u8* data, u32 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);
|
||||
|
||||
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;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationResponse");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", rsp->scid);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", rsp->flags);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Result: 0x%04x", rsp->result);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationResponse");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " SCID: {:#06x}", rsp->scid);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Flags: {:#06x}", rsp->flags);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Result: {:#06x}", rsp->result);
|
||||
|
||||
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;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveDisconnectionReq");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", command_disconnection_req->dcid);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", command_disconnection_req->scid);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] ReceiveDisconnectionReq");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Ident: {:#04x}", ident);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " DCID: {:#06x}", command_disconnection_req->dcid);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " SCID: {:#06x}", command_disconnection_req->scid);
|
||||
|
||||
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.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);
|
||||
}
|
||||
|
||||
|
@ -677,9 +677,9 @@ void WiimoteDevice::SendConnectionRequest(u16 psm)
|
|||
cr.psm = psm;
|
||||
cr.scid = local_cid;
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConnectionRequest");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Psm: 0x%04x", cr.psm);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Scid: 0x%04x", cr.scid);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] SendConnectionRequest");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Psm: {:#06x}", cr.psm);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Scid: {:#06x}", cr.scid);
|
||||
|
||||
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;
|
||||
offset += sizeof(l2cap_cfg_req_cp);
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConfigurationRequest");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Dcid: 0x%04x", cr->dcid);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", cr->flags);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "[L2CAP] SendConfigurationRequest");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Dcid: {:#06x}", cr->dcid);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Flags: {:#06x}", cr->flags);
|
||||
|
||||
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;
|
||||
*(u16*)&buffer[offset] = mtu;
|
||||
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)
|
||||
|
@ -719,7 +719,7 @@ void WiimoteDevice::SendConfigurationRequest(u16 cid, u16 mtu, u16 flush_time_ou
|
|||
options->length = L2CAP_OPT_FLUSH_TIMO_SIZE;
|
||||
*(u16*)&buffer[offset] = flush_time_out;
|
||||
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);
|
||||
|
@ -788,8 +788,8 @@ static u32 ParseCont(u8* cont)
|
|||
{
|
||||
return 0x00;
|
||||
}
|
||||
ERROR_LOG(IOS_WIIMOTE, "ParseCont: wrong cont: %i", type_id);
|
||||
PanicAlert("ParseCont: wrong cont: %i", type_id);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "ParseCont: wrong cont: {}", type_id);
|
||||
PanicAlertFmt("ParseCont: wrong cont: {}", type_id);
|
||||
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);
|
||||
attrib_offset += 2;
|
||||
end_id = start_id;
|
||||
WARN_LOG(IOS_WIIMOTE, "Read just a single attrib - not tested");
|
||||
PanicAlert("Read just a single attrib - not tested");
|
||||
WARN_LOG_FMT(IOS_WIIMOTE, "Read just a single attrib - not tested");
|
||||
PanicAlertFmt("Read just a single attrib - not tested");
|
||||
}
|
||||
|
||||
return attrib_offset;
|
||||
|
@ -837,8 +837,8 @@ void WiimoteDevice::SDPSendServiceAttributeResponse(u16 cid, u16 transaction_id,
|
|||
{
|
||||
if (service_handle != 0x10000)
|
||||
{
|
||||
ERROR_LOG(IOS_WIIMOTE, "Unknown service handle %x", service_handle);
|
||||
PanicAlert("Unknown service handle %x", service_handle);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "Unknown service handle {:x}", service_handle);
|
||||
PanicAlertFmt("Unknown service handle {:x}", service_handle);
|
||||
}
|
||||
|
||||
const u32 cont_state = ParseCont(continuation_state);
|
||||
|
@ -876,7 +876,7 @@ void WiimoteDevice::HandleSDP(u16 cid, u8* data, u32 size)
|
|||
// SDP_ServiceSearchRequest
|
||||
case 0x02:
|
||||
{
|
||||
WARN_LOG(IOS_WIIMOTE, "!!! SDP_ServiceSearchRequest !!!");
|
||||
WARN_LOG_FMT(IOS_WIIMOTE, "!!! SDP_ServiceSearchRequest !!!");
|
||||
|
||||
DEBUG_ASSERT(size == 13);
|
||||
|
||||
|
@ -892,7 +892,7 @@ void WiimoteDevice::HandleSDP(u16 cid, u8* data, u32 size)
|
|||
// SDP_ServiceAttributeRequest
|
||||
case 0x04:
|
||||
{
|
||||
WARN_LOG(IOS_WIIMOTE, "!!! SDP_ServiceAttributeRequest !!!");
|
||||
WARN_LOG_FMT(IOS_WIIMOTE, "!!! SDP_ServiceAttributeRequest !!!");
|
||||
|
||||
u16 start_attr_id, end_attr_id;
|
||||
u32 offset = 1;
|
||||
|
@ -914,8 +914,8 @@ void WiimoteDevice::HandleSDP(u16 cid, u8* data, u32 size)
|
|||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(IOS_WIIMOTE, "Unknown SDP command %x", data[0]);
|
||||
PanicAlert("WIIMOTE: Unknown SDP command %x", data[0]);
|
||||
ERROR_LOG_FMT(IOS_WIIMOTE, "Unknown SDP command {:x}", data[0]);
|
||||
PanicAlertFmt("WIIMOTE: Unknown SDP command {:x}", data[0]);
|
||||
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);
|
||||
|
||||
DEBUG_LOG(IOS_WIIMOTE, "Send ACL Command to CPU");
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", ident);
|
||||
DEBUG_LOG(IOS_WIIMOTE, " Code: 0x%02x", code);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, "Send ACL Command to CPU");
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Ident: {:#04x}", ident);
|
||||
DEBUG_LOG_FMT(IOS_WIIMOTE, " Code: {:#04x}", code);
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,9 +164,9 @@ void USBHost::DispatchHooks(const DeviceChangeHooks& hooks)
|
|||
{
|
||||
for (const auto& hook : hooks)
|
||||
{
|
||||
INFO_LOG(IOS_USB, "%s - %s device: %04x:%04x", GetDeviceName().c_str(),
|
||||
hook.second == ChangeEvent::Inserted ? "New" : "Removed", hook.first->GetVid(),
|
||||
hook.first->GetPid());
|
||||
INFO_LOG_FMT(IOS_USB, "{} - {} device: {:04x}:{:04x}", GetDeviceName(),
|
||||
hook.second == ChangeEvent::Inserted ? "New" : "Removed", hook.first->GetVid(),
|
||||
hook.first->GetPid());
|
||||
OnDeviceChange(hook.second, hook.first);
|
||||
}
|
||||
if (!hooks.empty())
|
||||
|
@ -223,8 +223,8 @@ IPCCommandResult USBHost::HandleTransfer(std::shared_ptr<USB::Device> device, u3
|
|||
if (ret == IPC_SUCCESS)
|
||||
return GetNoReply();
|
||||
|
||||
ERROR_LOG(IOS_USB, "[%04x:%04x] Failed to submit transfer (request %u): %s", device->GetVid(),
|
||||
device->GetPid(), request, device->GetErrorName(ret).c_str());
|
||||
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x}] Failed to submit transfer (request {}): {}",
|
||||
device->GetVid(), device->GetPid(), request, device->GetErrorName(ret));
|
||||
return GetDefaultReply(ret <= 0 ? ret : IPC_EINVAL);
|
||||
}
|
||||
} // namespace IOS::HLE::Device
|
||||
|
|
|
@ -67,7 +67,7 @@ std::vector<ConfigDescriptor> LibusbDevice::GetConfigurations() const
|
|||
{
|
||||
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;
|
||||
}
|
||||
ConfigDescriptor descriptor;
|
||||
|
@ -82,7 +82,7 @@ std::vector<InterfaceDescriptor> LibusbDevice::GetInterfaces(const u8 config) co
|
|||
std::vector<InterfaceDescriptor> descriptors;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
ASSERT(interface_number < m_config_descriptors[config]->bNumInterfaces);
|
||||
|
@ -132,11 +132,12 @@ bool LibusbDevice::Attach()
|
|||
|
||||
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);
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
@ -160,8 +161,8 @@ bool LibusbDevice::AttachAndChangeInterface(const u8 interface)
|
|||
|
||||
int LibusbDevice::CancelTransfer(const u8 endpoint)
|
||||
{
|
||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] Cancelling transfers (endpoint 0x%x)", m_vid, m_pid,
|
||||
m_active_interface, endpoint);
|
||||
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Cancelling transfers (endpoint {:#x})", m_vid, m_pid,
|
||||
m_active_interface, endpoint);
|
||||
const auto iterator = m_transfer_endpoints.find(endpoint);
|
||||
if (iterator == m_transfer_endpoints.cend())
|
||||
return IPC_ENOENT;
|
||||
|
@ -171,8 +172,8 @@ int LibusbDevice::CancelTransfer(const u8 endpoint)
|
|||
|
||||
int LibusbDevice::ChangeInterface(const u8 interface)
|
||||
{
|
||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] Changing interface to %d", m_vid, m_pid, m_active_interface,
|
||||
interface);
|
||||
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Changing interface to {}", m_vid, m_pid,
|
||||
m_active_interface, interface);
|
||||
m_active_interface = interface;
|
||||
return 0;
|
||||
}
|
||||
|
@ -182,8 +183,8 @@ int LibusbDevice::SetAltSetting(const u8 alt_setting)
|
|||
if (!m_device_attached)
|
||||
return LIBUSB_ERROR_NOT_FOUND;
|
||||
|
||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] Setting alt setting %d", m_vid, m_pid, m_active_interface,
|
||||
alt_setting);
|
||||
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Setting alt setting {}", m_vid, m_pid,
|
||||
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)
|
||||
return LIBUSB_ERROR_NOT_FOUND;
|
||||
|
||||
DEBUG_LOG(IOS_USB,
|
||||
"[%04x:%04x %d] Control: bRequestType=%02x bRequest=%02x wValue=%04x"
|
||||
" wIndex=%04x wLength=%04x",
|
||||
m_vid, m_pid, m_active_interface, cmd->request_type, cmd->request, cmd->value,
|
||||
cmd->index, cmd->length);
|
||||
DEBUG_LOG_FMT(IOS_USB,
|
||||
"[{:04x}:{:04x} {}] Control: bRequestType={:02x} bRequest={:02x} wValue={:04x}"
|
||||
" wIndex={:04x} wLength={:04x}",
|
||||
m_vid, m_pid, m_active_interface, cmd->request_type, cmd->request, cmd->value,
|
||||
cmd->index, cmd->length);
|
||||
|
||||
switch ((cmd->request_type << 8) | cmd->request)
|
||||
{
|
||||
// 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):
|
||||
{
|
||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] REQUEST_SET_INTERFACE index=%04x value=%04x", m_vid, m_pid,
|
||||
m_active_interface, cmd->index, cmd->value);
|
||||
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] REQUEST_SET_INTERFACE index={:04x} value={:04x}",
|
||||
m_vid, m_pid, m_active_interface, cmd->index, cmd->value);
|
||||
if (static_cast<u8>(cmd->index) != m_active_interface)
|
||||
{
|
||||
const int ret = ChangeInterface(static_cast<u8>(cmd->index));
|
||||
if (ret < 0)
|
||||
{
|
||||
ERROR_LOG(IOS_USB, "[%04x:%04x %d] Failed to change interface to %d: %s", m_vid, m_pid,
|
||||
m_active_interface, cmd->index, libusb_error_name(ret));
|
||||
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Failed to change interface to {}: {}", m_vid,
|
||||
m_pid, m_active_interface, cmd->index, libusb_error_name(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):
|
||||
{
|
||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] REQUEST_SET_CONFIGURATION index=%04x value=%04x", m_vid,
|
||||
m_pid, m_active_interface, cmd->index, cmd->value);
|
||||
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] REQUEST_SET_CONFIGURATION index={:04x} value={:04x}",
|
||||
m_vid, m_pid, m_active_interface, cmd->index, cmd->value);
|
||||
ReleaseAllInterfacesForCurrentConfig();
|
||||
const int ret = libusb_set_configuration(m_handle, cmd->value);
|
||||
if (ret == 0)
|
||||
|
@ -252,8 +253,8 @@ int LibusbDevice::SubmitTransfer(std::unique_ptr<BulkMessage> cmd)
|
|||
if (!m_device_attached)
|
||||
return LIBUSB_ERROR_NOT_FOUND;
|
||||
|
||||
DEBUG_LOG(IOS_USB, "[%04x:%04x %d] Bulk: length=%04x endpoint=%02x", m_vid, m_pid,
|
||||
m_active_interface, cmd->length, cmd->endpoint);
|
||||
DEBUG_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Bulk: length={:04x} endpoint={:02x}", m_vid, m_pid,
|
||||
m_active_interface, cmd->length, cmd->endpoint);
|
||||
|
||||
libusb_transfer* transfer = libusb_alloc_transfer(0);
|
||||
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)
|
||||
return LIBUSB_ERROR_NOT_FOUND;
|
||||
|
||||
DEBUG_LOG(IOS_USB, "[%04x:%04x %d] Interrupt: length=%04x endpoint=%02x", m_vid, m_pid,
|
||||
m_active_interface, cmd->length, cmd->endpoint);
|
||||
DEBUG_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Interrupt: length={:04x} endpoint={:02x}", m_vid,
|
||||
m_pid, m_active_interface, cmd->length, cmd->endpoint);
|
||||
|
||||
libusb_transfer* transfer = libusb_alloc_transfer(0);
|
||||
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)
|
||||
return LIBUSB_ERROR_NOT_FOUND;
|
||||
|
||||
DEBUG_LOG(IOS_USB, "[%04x:%04x %d] Isochronous: length=%04x endpoint=%02x num_packets=%02x",
|
||||
m_vid, m_pid, m_active_interface, cmd->length, cmd->endpoint, cmd->num_packets);
|
||||
DEBUG_LOG_FMT(IOS_USB,
|
||||
"[{: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);
|
||||
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);
|
||||
if (iterator == m_transfers.cend())
|
||||
{
|
||||
ERROR_LOG(IOS_USB, "No such transfer");
|
||||
ERROR_LOG_FMT(IOS_USB, "No such transfer");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -378,9 +380,10 @@ void LibusbDevice::TransferEndpoint::HandleTransfer(libusb_transfer* transfer,
|
|||
case LIBUSB_TRANSFER_TIMED_OUT:
|
||||
case LIBUSB_TRANSFER_OVERFLOW:
|
||||
case LIBUSB_TRANSFER_STALL:
|
||||
ERROR_LOG(IOS_USB, "[%04x:%04x %d] %s transfer (endpoint 0x%02x) failed: %s", device->m_vid,
|
||||
device->m_pid, device->m_active_interface, s_transfer_types.at(transfer->type),
|
||||
transfer->endpoint, libusb_error_name(transfer->status));
|
||||
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] {} transfer (endpoint {:#04x}) failed: {}",
|
||||
device->m_vid, device->m_pid, device->m_active_interface,
|
||||
s_transfer_types.at(transfer->type), transfer->endpoint,
|
||||
libusb_error_name(transfer->status));
|
||||
return_value = transfer->status == LIBUSB_TRANSFER_STALL ? -7004 : -5;
|
||||
break;
|
||||
case LIBUSB_TRANSFER_NO_DEVICE:
|
||||
|
@ -396,7 +399,7 @@ void LibusbDevice::TransferEndpoint::CancelTransfers()
|
|||
std::lock_guard<std::mutex> lk(m_transfers_mutex);
|
||||
if (m_transfers.empty())
|
||||
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)
|
||||
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);
|
||||
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,
|
||||
libusb_error_name(ret2));
|
||||
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x}] Failed to detach kernel driver: {}", m_vid, m_pid,
|
||||
libusb_error_name(ret2));
|
||||
return ret2;
|
||||
}
|
||||
return libusb_claim_interface(m_handle, i);
|
||||
});
|
||||
if (ret < 0)
|
||||
{
|
||||
ERROR_LOG(IOS_USB, "[%04x:%04x] Failed to claim all interfaces (configuration %u)", m_vid,
|
||||
m_pid, config_num);
|
||||
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x}] Failed to claim all interfaces (configuration {})",
|
||||
m_vid, m_pid, config_num);
|
||||
}
|
||||
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)
|
||||
{
|
||||
ERROR_LOG(IOS_USB, "[%04x:%04x] Failed to release all interfaces (configuration %u)", m_vid,
|
||||
m_pid, config_num);
|
||||
ERROR_LOG_FMT(IOS_USB, "[{:04x}:{:04x}] Failed to release all interfaces (configuration {})",
|
||||
m_vid, m_pid, config_num);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ IPCCommandResult OH0::IOCtl(const IOCtlRequest& 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)
|
||||
{
|
||||
case USB::IOCTLV_USBV0_GETDEVLIST:
|
||||
|
@ -145,7 +145,7 @@ IPCCommandResult OH0::GetRhPortStatus(const IOCtlVRequest& request) const
|
|||
if (!request.HasNumberOfValidVectors(1, 1))
|
||||
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);
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ IPCCommandResult OH0::SetRhPortStatus(const IOCtlVRequest& request)
|
|||
if (!request.HasNumberOfValidVectors(2, 0))
|
||||
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);
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ IPCCommandResult OH0::RegisterClassChangeHook(const IOCtlVRequest& request)
|
|||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 0))
|
||||
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);
|
||||
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
|
||||
// platform-independant way (libusb does not support power management).
|
||||
INFO_LOG(IOS_USB, "[%04x:%04x %d] Received %s command", host_device->GetVid(),
|
||||
host_device->GetPid(), device.interface_number, resumed == 0 ? "suspend" : "resume");
|
||||
INFO_LOG_FMT(IOS_USB, "[{:04x}:{:04x} {}] Received {} command", host_device->GetVid(),
|
||||
host_device->GetPid(), device.interface_number, resumed == 0 ? "suspend" : "resume");
|
||||
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_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 IOS::HLE
|
||||
|
|
|
@ -192,7 +192,7 @@ void USB_HIDv4::TriggerDeviceChangeReply()
|
|||
const std::vector<u8> device_section = GetDeviceEntry(*device.second.get());
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
INFO_LOG(IOS, "USB_KBD: Open");
|
||||
INFO_LOG_FMT(IOS, "USB_KBD: Open");
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||
ini.GetOrCreateSection("USB Keyboard")->Get("Layout", &m_keyboard_layout, KBD_LAYOUT_QWERTY);
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "Core/IOS/WFS/WFSI.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <mbedtls/aes.h>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
|
@ -51,10 +50,10 @@ void ARCUnpacker::AddBytes(const std::vector<u8>& bytes)
|
|||
|
||||
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)
|
||||
{
|
||||
ERROR_LOG(IOS_WFS, "ARCUnpacker: invalid fourcc (%08x)", fourcc);
|
||||
ERROR_LOG_FMT(IOS_WFS, "ARCUnpacker: invalid fourcc ({:08x})", fourcc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -135,14 +134,14 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
{
|
||||
case IOCTL_WFSI_IMPORT_TITLE_INIT:
|
||||
{
|
||||
u32 tmd_addr = Memory::Read_U32(request.buffer_in);
|
||||
u32 tmd_size = Memory::Read_U32(request.buffer_in + 4);
|
||||
const u32 tmd_addr = Memory::Read_U32(request.buffer_in);
|
||||
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_continue_install = Memory::Read_U32(request.buffer_in + 36);
|
||||
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_IMPORT_TITLE_INIT: patch type %d, continue install: %s",
|
||||
m_patch_type, m_continue_install ? "true" : "false");
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_IMPORT_TITLE_INIT: patch type {}, continue install: {}",
|
||||
m_patch_type, m_continue_install ? "true" : "false");
|
||||
|
||||
if (m_patch_type == PatchType::PATCH_TYPE_2)
|
||||
{
|
||||
|
@ -155,7 +154,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -164,7 +163,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
Memory::CopyFromEmu(tmd_bytes.data(), tmd_addr, tmd_size);
|
||||
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())
|
||||
{
|
||||
return_error_code = -11028;
|
||||
|
@ -195,11 +194,11 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
"IOCTL_WFSI_PREPARE_CONTENT";
|
||||
|
||||
// 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;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -207,8 +206,8 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
memset(m_aes_iv, 0, sizeof(m_aes_iv));
|
||||
m_aes_iv[0] = content_info.index >> 8;
|
||||
m_aes_iv[1] = content_info.index & 0xFF;
|
||||
INFO_LOG(IOS_WFS, "%s: Content id %08x found at index %d", ioctl_name, content_id,
|
||||
content_info.index);
|
||||
INFO_LOG_FMT(IOS_WFS, "{}: Content id {:08x} found at index {}", ioctl_name, content_id,
|
||||
content_info.index);
|
||||
|
||||
m_arc_unpacker.Reset();
|
||||
break;
|
||||
|
@ -221,11 +220,11 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
"IOCTL_WFSI_IMPORT_PROFILE" :
|
||||
"IOCTL_WFSI_IMPORT_CONTENT";
|
||||
|
||||
u32 content_id = Memory::Read_U32(request.buffer_in + 0xC);
|
||||
u32 input_ptr = Memory::Read_U32(request.buffer_in + 0x10);
|
||||
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,
|
||||
input_ptr, content_id);
|
||||
const u32 content_id = Memory::Read_U32(request.buffer_in + 0xC);
|
||||
const u32 input_ptr = Memory::Read_U32(request.buffer_in + 0x10);
|
||||
const u32 input_size = Memory::Read_U32(request.buffer_in + 0x14);
|
||||
INFO_LOG_FMT(IOS_WFS, "{}: {:08x} bytes of data at {:08x} from content id {}", ioctl_name,
|
||||
input_size, input_ptr, content_id);
|
||||
|
||||
std::vector<u8> decrypted(input_size);
|
||||
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 ?
|
||||
"IOCTL_WFSI_IMPORT_PROFILE_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) {
|
||||
INFO_LOG(IOS_WFS, "Extract: %s (%zd bytes)", filename.c_str(), bytes.size());
|
||||
const auto callback = [this](const std::string& filename, const std::vector<u8>& bytes) {
|
||||
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::IOFile f(path, "wb");
|
||||
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;
|
||||
}
|
||||
f.WriteBytes(bytes.data(), bytes.size());
|
||||
|
@ -321,7 +320,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
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)
|
||||
FinalizePatchInstall();
|
||||
break;
|
||||
|
@ -331,13 +330,13 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
// Bytes 0-4: ??
|
||||
// Bytes 4-8: game 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;
|
||||
|
||||
case IOCTL_WFSI_CHANGE_TITLE:
|
||||
{
|
||||
u64 title_id = Memory::Read_U64(request.buffer_in);
|
||||
u16 group_id = Memory::Read_U16(request.buffer_in + 0x1C);
|
||||
const u64 title_id = Memory::Read_U64(request.buffer_in);
|
||||
const u16 group_id = Memory::Read_U16(request.buffer_in + 0x1C);
|
||||
|
||||
// TODO: Handle permissions
|
||||
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,
|
||||
m_current_group_id_str, m_current_title_id_str);
|
||||
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(),
|
||||
homedir_path_len);
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_CHANGE_TITLE: {} (path_len: {:#x})", homedir_path,
|
||||
homedir_path_len);
|
||||
|
||||
return_error_code = -3;
|
||||
if (homedir_path_len > 0x1FD)
|
||||
|
@ -361,15 +360,15 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
}
|
||||
|
||||
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);
|
||||
break;
|
||||
|
||||
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)
|
||||
return_error_code = CancelTitleImport(continue_install);
|
||||
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:
|
||||
{
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_INIT");
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_INIT");
|
||||
u64 tid;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
IOS::ES::TMDReader tmd = GetIOS()->GetES()->FindInstalledTMD(tid);
|
||||
const IOS::ES::TMDReader tmd = GetIOS()->GetES()->FindInstalledTMD(tid);
|
||||
SetCurrentTitleIdAndGroupId(tmd.GetTitleId(), tmd.GetGroupId());
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
break;
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -443,9 +442,9 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
case IOCTL_WFSI_GET_TMD:
|
||||
{
|
||||
u64 subtitle_id = Memory::Read_U64(request.buffer_in);
|
||||
u32 address = Memory::Read_U32(request.buffer_in + 24);
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_GET_TMD: subtitle ID %016" PRIx64, subtitle_id);
|
||||
const u64 subtitle_id = Memory::Read_U64(request.buffer_in);
|
||||
const u32 address = Memory::Read_U32(request.buffer_in + 24);
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_GET_TMD: subtitle ID {:016x}", subtitle_id);
|
||||
|
||||
u32 tmd_size;
|
||||
return_error_code =
|
||||
|
@ -456,12 +455,13 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
case IOCTL_WFSI_GET_TMD_ABSOLUTE:
|
||||
{
|
||||
u64 subtitle_id = Memory::Read_U64(request.buffer_in);
|
||||
u32 address = Memory::Read_U32(request.buffer_in + 24);
|
||||
u16 group_id = Memory::Read_U16(request.buffer_in + 36);
|
||||
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,
|
||||
title_id, group_id, subtitle_id);
|
||||
const u64 subtitle_id = Memory::Read_U64(request.buffer_in);
|
||||
const u32 address = Memory::Read_U32(request.buffer_in + 24);
|
||||
const u16 group_id = Memory::Read_U16(request.buffer_in + 36);
|
||||
const u32 title_id = Memory::Read_U32(request.buffer_in + 32);
|
||||
INFO_LOG_FMT(IOS_WFS,
|
||||
"IOCTL_WFSI_GET_TMD_ABSOLUTE: tid {:08x}, gid {:04x}, subtitle ID {:016x}",
|
||||
title_id, group_id, subtitle_id);
|
||||
|
||||
u32 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:
|
||||
{
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFSI_SET_FST_BUFFER: address %08x, size %08x", request.buffer_in,
|
||||
request.buffer_in_size);
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_SET_FST_BUFFER: address {:08x}, size {:08x}",
|
||||
request.buffer_in, request.buffer_in_size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -497,18 +497,18 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
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(),
|
||||
dol_addr, max_dol_size);
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFSI_LOAD_DOL: loading {} at address {:08x} (size {})", path,
|
||||
dol_addr, max_dol_size);
|
||||
|
||||
File::IOFile fp(WFS::NativePath(path), "rb");
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
u32 real_dol_size = fp.GetSize();
|
||||
const auto real_dol_size = static_cast<u32>(fp.GetSize());
|
||||
if (dol_addr == 0)
|
||||
{
|
||||
// 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:
|
||||
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.
|
||||
// 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");
|
||||
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;
|
||||
}
|
||||
if (address)
|
||||
|
|
|
@ -41,18 +41,18 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
{
|
||||
case IOCTL_WFS_INIT:
|
||||
// TODO(wfs): Implement.
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_INIT");
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_INIT");
|
||||
break;
|
||||
|
||||
case IOCTL_WFS_UNKNOWN_8:
|
||||
// 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::CopyToEmu(request.buffer_out + 1, "msc01\x00\x00\x00", 8);
|
||||
break;
|
||||
|
||||
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.
|
||||
for (auto address : m_hanging)
|
||||
|
@ -66,14 +66,14 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
break;
|
||||
|
||||
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_U8(4, request.buffer_out + 8);
|
||||
break;
|
||||
|
||||
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::CopyToEmu(request.buffer_out + 1, m_device_name.data(), m_device_name.size());
|
||||
break;
|
||||
|
@ -81,14 +81,14 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
case IOCTL_WFS_ATTACH_DETACH_2:
|
||||
// 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(0, request.buffer_out + 4); // device id?
|
||||
Memory::Write_U32(0, request.buffer_out + 8);
|
||||
break;
|
||||
|
||||
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.
|
||||
m_hanging.push_back(request.address);
|
||||
|
@ -96,28 +96,28 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
case IOCTL_WFS_FLUSH:
|
||||
// Nothing to do.
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_FLUSH: doing nothing");
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_FLUSH: doing nothing");
|
||||
break;
|
||||
|
||||
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)));
|
||||
std::string native_path = WFS::NativePath(path);
|
||||
const std::string native_path = WFS::NativePath(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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -125,59 +125,60 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
// TODO(wfs): Globbing is not really implemented, we just fake the one case
|
||||
// (listing /vol/*) which is required to get the installer to work.
|
||||
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::CopyToEmu(request.buffer_out + 0x14, m_device_name.data(), m_device_name.size());
|
||||
break;
|
||||
|
||||
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;
|
||||
break;
|
||||
|
||||
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);
|
||||
break;
|
||||
|
||||
case IOCTL_WFS_SET_HOMEDIR:
|
||||
m_home_directory =
|
||||
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;
|
||||
|
||||
case IOCTL_WFS_CHDIR:
|
||||
m_current_directory =
|
||||
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;
|
||||
|
||||
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::CopyToEmu(request.buffer_out + 2, m_home_directory.data(), m_home_directory.size());
|
||||
break;
|
||||
|
||||
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)));
|
||||
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);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 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);
|
||||
const auto size = static_cast<u32>(File::GetSize(native_path));
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GET_ATTRIBUTES({}): file with size {}", path, size);
|
||||
Memory::Write_U32(size, request.buffer_out);
|
||||
}
|
||||
break;
|
||||
|
@ -199,13 +200,13 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
{
|
||||
const char* ioctl_name =
|
||||
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;
|
||||
u16 path_len = Memory::Read_U16(request.buffer_in + 0x20);
|
||||
const u32 mode = request.request == IOCTL_WFS_OPEN ? Memory::Read_U32(request.buffer_in) : 2;
|
||||
const u16 path_len = Memory::Read_U16(request.buffer_in + 0x20);
|
||||
std::string path = Memory::GetString(request.buffer_in + 0x22, path_len);
|
||||
|
||||
path = NormalizePath(path);
|
||||
|
||||
u16 fd = GetNewFileDescriptor();
|
||||
const u16 fd = GetNewFileDescriptor();
|
||||
FileDescriptor* fd_obj = &m_fds[fd];
|
||||
fd_obj->in_use = true;
|
||||
fd_obj->path = path;
|
||||
|
@ -214,13 +215,13 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
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);
|
||||
return_error_code = WFS_ENOENT;
|
||||
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)
|
||||
{
|
||||
Memory::Write_U16(fd, request.buffer_out + 0x14);
|
||||
|
@ -234,21 +235,21 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
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);
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
u64 size = fd_obj->file.GetSize();
|
||||
u32 truncated_size = static_cast<u32>(size);
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_GET_SIZE(%d) -> %d", fd, truncated_size);
|
||||
const u64 size = fd_obj->file.GetSize();
|
||||
const u32 truncated_size = static_cast<u32>(size);
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_GET_SIZE({}) -> {}", fd, 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);
|
||||
break;
|
||||
|
@ -256,8 +257,8 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
|
||||
case IOCTL_WFS_CLOSE:
|
||||
{
|
||||
u16 fd = Memory::Read_U16(request.buffer_in + 0x4);
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_CLOSE(%d)", fd);
|
||||
const u16 fd = Memory::Read_U16(request.buffer_in + 0x4);
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_CLOSE({})", fd);
|
||||
ReleaseFileDescriptor(fd);
|
||||
break;
|
||||
}
|
||||
|
@ -266,8 +267,8 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
{
|
||||
// TODO(wfs): Figure out the exact semantics difference from the other
|
||||
// close.
|
||||
u16 fd = Memory::Read_U16(request.buffer_in + 0x4);
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_CLOSE_2(%d)", fd);
|
||||
const u16 fd = Memory::Read_U16(request.buffer_in + 0x4);
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_CLOSE_2({})", fd);
|
||||
ReleaseFileDescriptor(fd);
|
||||
break;
|
||||
}
|
||||
|
@ -275,22 +276,22 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
case IOCTL_WFS_READ:
|
||||
case IOCTL_WFS_READ_ABSOLUTE:
|
||||
{
|
||||
u32 addr = Memory::Read_U32(request.buffer_in);
|
||||
u32 position = Memory::Read_U32(request.buffer_in + 4); // Only for absolute.
|
||||
u16 fd = Memory::Read_U16(request.buffer_in + 0xC);
|
||||
u32 size = Memory::Read_U32(request.buffer_in + 8);
|
||||
const u32 addr = Memory::Read_U32(request.buffer_in);
|
||||
const u32 position = Memory::Read_U32(request.buffer_in + 4); // Only for absolute.
|
||||
const u16 fd = Memory::Read_U16(request.buffer_in + 0xC);
|
||||
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);
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
u64 previous_position = fd_obj->file.Tell();
|
||||
const u64 previous_position = fd_obj->file.Tell();
|
||||
if (absolute)
|
||||
{
|
||||
fd_obj->file.Seek(position, SEEK_SET);
|
||||
|
@ -307,8 +308,8 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
fd_obj->position += read_bytes;
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_READ: read %zd bytes from FD %d (%s)", read_bytes, fd,
|
||||
fd_obj->path.c_str());
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_READ: read {} bytes from FD {} ({})", read_bytes, fd,
|
||||
fd_obj->path);
|
||||
return_error_code = static_cast<int>(read_bytes);
|
||||
break;
|
||||
}
|
||||
|
@ -316,22 +317,22 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
case IOCTL_WFS_WRITE:
|
||||
case IOCTL_WFS_WRITE_ABSOLUTE:
|
||||
{
|
||||
u32 addr = Memory::Read_U32(request.buffer_in);
|
||||
u32 position = Memory::Read_U32(request.buffer_in + 4); // Only for absolute.
|
||||
u16 fd = Memory::Read_U16(request.buffer_in + 0xC);
|
||||
u32 size = Memory::Read_U32(request.buffer_in + 8);
|
||||
const u32 addr = Memory::Read_U32(request.buffer_in);
|
||||
const u32 position = Memory::Read_U32(request.buffer_in + 4); // Only for absolute.
|
||||
const u16 fd = Memory::Read_U16(request.buffer_in + 0xC);
|
||||
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);
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
u64 previous_position = fd_obj->file.Tell();
|
||||
const u64 previous_position = fd_obj->file.Tell();
|
||||
if (absolute)
|
||||
{
|
||||
fd_obj->file.Seek(position, SEEK_SET);
|
||||
|
@ -347,8 +348,8 @@ IPCCommandResult WFSSRV::IOCtl(const IOCtlRequest& request)
|
|||
fd_obj->position += size;
|
||||
}
|
||||
|
||||
INFO_LOG(IOS_WFS, "IOCTL_WFS_WRITE: written %d bytes from FD %d (%s)", size, fd,
|
||||
fd_obj->path.c_str());
|
||||
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_WRITE: written {} bytes from FD {} ({})", size, fd,
|
||||
fd_obj->path);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -368,7 +369,7 @@ s32 WFSSRV::Rename(std::string source, std::string dest) const
|
|||
source = NormalizePath(source);
|
||||
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 auto& fd) { return fd.in_use && fd.path == source; });
|
||||
|
@ -480,7 +481,7 @@ bool WFSSRV::FileDescriptor::Open()
|
|||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(IOS_WFS, "WFSOpen: invalid mode %d", mode);
|
||||
ERROR_LOG_FMT(IOS_WFS, "WFSOpen: invalid mode {}", mode);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue