summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZephyron <zephyron@citron-emu.org>2025-04-25 14:38:28 +1000
committerMike Lothian <mike@fireburn.co.uk>2025-05-12 12:46:19 +0100
commit932e0132263218d3177c647e18e5f1f9d8e41dfc (patch)
tree4605dcc7e97197faaf54fae3cff993414be1530a
parent0763567da88670440d86f2eb416bbbf25e66af26 (diff)
socket: Implement missing errno values and improve network error handling
Add support for missing errno values needed by TOTK: - Add BUSY (16) for "Device or resource busy" errors - Add NOTSOCK (88) for "Socket operation on non-socket" errors Improvements: - Update TranslateNativeError on both Windows and Unix to handle new error codes - Change socket error logging for NOTSOCK from WARNING to DEBUG level - Fix formatting in Unix errno translation code - Update shader storage buffer tracking range to accommodate TOTK buffers - Add hex format to storage buffer logging for easier comparison with bias range - Change storage buffer tracking log level from WARNING to DEBUG These changes help prevent error messages in games that use network features not fully implemented in the emulator yet. Signed-off-by: Zephyron <zephyron@citron-emu.org>
-rw-r--r--src/core/hle/service/sockets/sockets.h3
-rw-r--r--src/core/hle/service/sockets/sockets_translate.cpp5
-rw-r--r--src/core/internal_network/network.cpp25
-rw-r--r--src/core/internal_network/network.h3
-rw-r--r--src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp6
5 files changed, 36 insertions, 6 deletions
diff --git a/src/core/hle/service/sockets/sockets.h b/src/core/hle/service/sockets/sockets.h
index 23c4fd640..17649149e 100644
--- a/src/core/hle/service/sockets/sockets.h
+++ b/src/core/hle/service/sockets/sockets.h
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -17,9 +18,11 @@ enum class Errno : u32 {
BADF = 9,
AGAIN = 11,
NOMEM = 12,
+ BUSY = 16,
INVAL = 22,
MFILE = 24,
PIPE = 32,
+ NOTSOCK = 88,
MSGSIZE = 90,
CONNABORTED = 103,
CONNRESET = 104,
diff --git a/src/core/hle/service/sockets/sockets_translate.cpp b/src/core/hle/service/sockets/sockets_translate.cpp
index b9a3ba029..448c5f135 100644
--- a/src/core/hle/service/sockets/sockets_translate.cpp
+++ b/src/core/hle/service/sockets/sockets_translate.cpp
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <utility>
@@ -39,6 +40,10 @@ Errno Translate(Network::Errno value) {
return Errno::INPROGRESS;
case Network::Errno::NOMEM:
return Errno::NOMEM;
+ case Network::Errno::BUSY:
+ return Errno::BUSY;
+ case Network::Errno::NOTSOCK:
+ return Errno::NOTSOCK;
default:
UNIMPLEMENTED_MSG("Unimplemented errno={}", value);
return Errno::SUCCESS;
diff --git a/src/core/internal_network/network.cpp b/src/core/internal_network/network.cpp
index 42ad4dc5a..6a2a1d93f 100644
--- a/src/core/internal_network/network.cpp
+++ b/src/core/internal_network/network.cpp
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
@@ -156,6 +157,10 @@ Errno TranslateNativeError(int e, CallType call_type = CallType::Other) {
return Errno::TIMEDOUT;
case WSAEINPROGRESS:
return Errno::INPROGRESS;
+ case WSAENOTSOCK:
+ return Errno::NOTSOCK;
+ case WSAEBUSY:
+ return Errno::BUSY;
default:
UNIMPLEMENTED_MSG("Unimplemented errno={}", e);
return Errno::OTHER;
@@ -273,14 +278,14 @@ Errno TranslateNativeError(int e, CallType call_type = CallType::Other) {
return Errno::MFILE;
case EPIPE:
return Errno::PIPE;
- case ECONNABORTED:
- return Errno::CONNABORTED;
case ENOTCONN:
return Errno::NOTCONN;
case EAGAIN:
return Errno::AGAIN;
case ECONNREFUSED:
return Errno::CONNREFUSED;
+ case ECONNABORTED:
+ return Errno::CONNABORTED;
case ECONNRESET:
return Errno::CONNRESET;
case EHOSTUNREACH:
@@ -295,8 +300,14 @@ Errno TranslateNativeError(int e, CallType call_type = CallType::Other) {
return Errno::TIMEDOUT;
case EINPROGRESS:
return Errno::INPROGRESS;
+ case ENOMEM:
+ return Errno::NOMEM;
+ case EBUSY:
+ return Errno::BUSY;
+ case ENOTSOCK:
+ return Errno::NOTSOCK;
default:
- UNIMPLEMENTED_MSG("Unimplemented errno={} ({})", e, strerror(e));
+ UNIMPLEMENTED_MSG("Unimplemented errno={}", e);
return Errno::OTHER;
}
}
@@ -315,6 +326,14 @@ Errno GetAndLogLastError(CallType call_type = CallType::Other) {
LOG_DEBUG(Network, "Socket operation error: {}", Common::NativeErrorToString(e));
return err;
}
+
+ if (err == Errno::NOTSOCK) {
+ // This is a common error when network functionality is not fully implemented
+ LOG_DEBUG(Network, "Socket operation error: An operation was attempted on something that is not a socket. "
+ "This may indicate the game is using network features not fully supported. ");
+ return err;
+ }
+
LOG_ERROR(Network, "Socket operation error: {}", Common::NativeErrorToString(e));
return err;
}
diff --git a/src/core/internal_network/network.h b/src/core/internal_network/network.h
index 015e2b42a..250f74e37 100644
--- a/src/core/internal_network/network.h
+++ b/src/core/internal_network/network.h
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
+// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -47,6 +48,8 @@ enum class Errno {
INPROGRESS,
OTHER,
NOMEM,
+ BUSY,
+ NOTSOCK,
};
enum class GetAddrInfoError {
diff --git a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
index 67fae7f19..8849a7a73 100644
--- a/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
+++ b/src/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp
@@ -381,7 +381,7 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageInfo& info)
static constexpr Bias nvn_bias{
.index = 0,
.offset_begin = 0x100, // Expanded from 0x110 to catch more potential storage buffers
- .offset_end = 0x800, // Expanded from 0x610 to include a wider range
+ .offset_end = 0x1000, // Substantially expanded to include all TOTK storage buffers
.alignment = 32, // Increased from 16 to optimize memory access patterns
};
// Track the low address of the instruction
@@ -402,8 +402,8 @@ void CollectStorageBuffers(IR::Block& block, IR::Inst& inst, StorageInfo& info)
LOG_WARNING(Shader, "Storage buffer failed to track, using global memory fallbacks");
return;
}
- LOG_WARNING(Shader, "Storage buffer tracked without bias, index {} offset {}",
- storage_buffer->index, storage_buffer->offset);
+ LOG_DEBUG(Shader, "Storage buffer tracked without bias, index {} offset 0x{:X}",
+ storage_buffer->index, storage_buffer->offset);
}
// Collect storage buffer and the instruction
if (IsGlobalMemoryWrite(inst)) {