summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/memory.cpp58
1 files changed, 6 insertions, 52 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 778d152dd..51c4dea26 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -5,10 +5,6 @@
5#include <algorithm> 5#include <algorithm>
6#include <cstring> 6#include <cstring>
7 7
8#define BOOST_HANA_CONFIG_ENABLE_STRING_UDL
9#include <boost/hana/string.hpp>
10#undef BOOST_HANA_CONFIG_ENABLE_STRING_UDL
11
12#include "common/assert.h" 8#include "common/assert.h"
13#include "common/atomic_ops.h" 9#include "common/atomic_ops.h"
14#include "common/common_types.h" 10#include "common/common_types.h"
@@ -23,8 +19,6 @@
23#include "core/memory.h" 19#include "core/memory.h"
24#include "video_core/gpu.h" 20#include "video_core/gpu.h"
25 21
26using namespace boost::hana::literals;
27
28namespace Core::Memory { 22namespace Core::Memory {
29 23
30// Implementation class used to keep the specifics of the memory subsystem hidden 24// Implementation class used to keep the specifics of the memory subsystem hidden
@@ -446,42 +440,6 @@ struct Memory::Impl {
446 } 440 }
447 } 441 }
448 442
449 /**
450 * Returns a message like "Unmapped NameBits @ 0x{:016X}Suffix".
451 *
452 * @tparam NAME The caller name like "Read"_s or "Write"_s.
453 * @tparam BYTES The number of bits written. 0 is for read and sizeof(T) is for write.
454 * @tparam SUFFIX A suffix. ""_s is for read and " = 0x{:016X}" is for write.
455 */
456 template <boost::hana::string NAME, int BYTES, boost::hana::string SUFFIX>
457 static consteval const char* GetPointerImplError() {
458 constexpr auto unmapped_fmt = ([]() {
459 constexpr auto prefix = "Unmapped "_s + NAME;
460 constexpr auto suffix = " @ 0x{:016X}"_s + SUFFIX;
461 const char* result = nullptr;
462 switch (BYTES * 8) {
463 case 0:
464 result = (prefix + suffix).c_str();
465 break;
466#define BITS_CASE(x) \
467 case x: \
468 result = (prefix + BOOST_HANA_STRING(#x) + suffix).c_str(); \
469 break;
470 BITS_CASE(8)
471 BITS_CASE(16)
472 BITS_CASE(32)
473 BITS_CASE(64)
474 BITS_CASE(128)
475#undef BITS_CASE
476 default:
477 break;
478 }
479 return result;
480 })();
481 static_assert(unmapped_fmt);
482 return unmapped_fmt;
483 }
484
485 [[nodiscard]] u8* GetPointerImpl(VAddr vaddr, auto on_unmapped, auto on_rasterizer) const { 443 [[nodiscard]] u8* GetPointerImpl(VAddr vaddr, auto on_unmapped, auto on_rasterizer) const {
486 // AARCH64 masks the upper 16 bit of all memory accesses 444 // AARCH64 masks the upper 16 bit of all memory accesses
487 vaddr &= 0xffffffffffffLL; 445 vaddr &= 0xffffffffffffLL;
@@ -516,10 +474,7 @@ struct Memory::Impl {
516 474
517 [[nodiscard]] u8* GetPointer(const VAddr vaddr) const { 475 [[nodiscard]] u8* GetPointer(const VAddr vaddr) const {
518 return GetPointerImpl( 476 return GetPointerImpl(
519 vaddr, 477 vaddr, [vaddr]() { LOG_ERROR(HW_Memory, "Unmapped GetPointer @ 0x{:016X}", vaddr); },
520 [vaddr]() {
521 LOG_ERROR(HW_Memory, GetPointerImplError<"GetPointer"_s, 0, ""_s>(), vaddr);
522 },
523 []() {}); 478 []() {});
524 } 479 }
525 480
@@ -540,7 +495,7 @@ struct Memory::Impl {
540 const u8* const ptr = GetPointerImpl( 495 const u8* const ptr = GetPointerImpl(
541 vaddr, 496 vaddr,
542 [vaddr]() { 497 [vaddr]() {
543 LOG_ERROR(HW_Memory, GetPointerImplError<"Read"_s, sizeof(T), ""_s>(), vaddr); 498 LOG_ERROR(HW_Memory, "Unmapped Read{} @ 0x{:016X}", sizeof(T) * 8, vaddr);
544 }, 499 },
545 [&system = system, vaddr]() { system.GPU().FlushRegion(vaddr, sizeof(T)); }); 500 [&system = system, vaddr]() { system.GPU().FlushRegion(vaddr, sizeof(T)); });
546 if (ptr) { 501 if (ptr) {
@@ -563,7 +518,7 @@ struct Memory::Impl {
563 u8* const ptr = GetPointerImpl( 518 u8* const ptr = GetPointerImpl(
564 vaddr, 519 vaddr,
565 [vaddr, data]() { 520 [vaddr, data]() {
566 LOG_ERROR(HW_Memory, GetPointerImplError<"Write"_s, sizeof(T), " = 0x{:016X}"_s>(), 521 LOG_ERROR(HW_Memory, "Unmapped Write{} @ 0x{:016X} = 0x{:016X}", sizeof(T) * 8,
567 vaddr, static_cast<u64>(data)); 522 vaddr, static_cast<u64>(data));
568 }, 523 },
569 [&system = system, vaddr]() { system.GPU().InvalidateRegion(vaddr, sizeof(T)); }); 524 [&system = system, vaddr]() { system.GPU().InvalidateRegion(vaddr, sizeof(T)); });
@@ -577,8 +532,8 @@ struct Memory::Impl {
577 u8* const ptr = GetPointerImpl( 532 u8* const ptr = GetPointerImpl(
578 vaddr, 533 vaddr,
579 [vaddr, data]() { 534 [vaddr, data]() {
580 LOG_ERROR(HW_Memory, GetPointerImplError<"Write"_s, sizeof(T), " = 0x{:016X}"_s>(), 535 LOG_ERROR(HW_Memory, "Unmapped WriteExclusive{} @ 0x{:016X} = 0x{:016X}",
581 vaddr, static_cast<u64>(data)); 536 sizeof(T) * 8, vaddr, static_cast<u64>(data));
582 }, 537 },
583 [&system = system, vaddr]() { system.GPU().InvalidateRegion(vaddr, sizeof(T)); }); 538 [&system = system, vaddr]() { system.GPU().InvalidateRegion(vaddr, sizeof(T)); });
584 if (ptr) { 539 if (ptr) {
@@ -592,8 +547,7 @@ struct Memory::Impl {
592 u8* const ptr = GetPointerImpl( 547 u8* const ptr = GetPointerImpl(
593 vaddr, 548 vaddr,
594 [vaddr, data]() { 549 [vaddr, data]() {
595 LOG_ERROR(HW_Memory, 550 LOG_ERROR(HW_Memory, "Unmapped WriteExclusive128 @ 0x{:016X} = 0x{:016X}{:016X}",
596 GetPointerImplError<"Write"_s, sizeof(u128), " = 0x{:016X}{:016X}"_s>(),
597 vaddr, static_cast<u64>(data[1]), static_cast<u64>(data[0])); 551 vaddr, static_cast<u64>(data[1]), static_cast<u64>(data[0]));
598 }, 552 },
599 [&system = system, vaddr]() { system.GPU().InvalidateRegion(vaddr, sizeof(u128)); }); 553 [&system = system, vaddr]() { system.GPU().InvalidateRegion(vaddr, sizeof(u128)); });