mirror of
				https://git.zaroz.cloud/nintendo-back-up/yuzu/yuzu-mainline.git
				synced 2025-03-21 01:53:15 +00:00 
			
		
		
		
	Merge pull request #191 from lioncash/log
core: Silence formatting specifier warnings
This commit is contained in:
		
						commit
						d939792b9b
					
				@ -6,6 +6,7 @@
 | 
			
		||||
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <atomic>
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include <climits>
 | 
			
		||||
#include <csignal>
 | 
			
		||||
#include <cstdarg>
 | 
			
		||||
@ -360,8 +361,9 @@ static void RemoveBreakpoint(BreakpointType type, PAddr addr) {
 | 
			
		||||
 | 
			
		||||
    auto bp = p.find(static_cast<u64>(addr));
 | 
			
		||||
    if (bp != p.end()) {
 | 
			
		||||
        LOG_DEBUG(Debug_GDBStub, "gdb: removed a breakpoint: %08x bytes at %08x of type %d\n",
 | 
			
		||||
                  bp->second.len, bp->second.addr, type);
 | 
			
		||||
        LOG_DEBUG(Debug_GDBStub,
 | 
			
		||||
                  "gdb: removed a breakpoint: %016" PRIx64 " bytes at %016" PRIx64 " of type %d\n",
 | 
			
		||||
                  bp->second.len, bp->second.addr, static_cast<int>(type));
 | 
			
		||||
        p.erase(static_cast<u64>(addr));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -407,8 +409,9 @@ bool CheckBreakpoint(PAddr addr, BreakpointType type) {
 | 
			
		||||
 | 
			
		||||
        if (bp->second.active && (addr >= bp->second.addr && addr < bp->second.addr + len)) {
 | 
			
		||||
            LOG_DEBUG(Debug_GDBStub,
 | 
			
		||||
                      "Found breakpoint type %d @ %08x, range: %08x - %08x (%d bytes)\n", type,
 | 
			
		||||
                      addr, bp->second.addr, bp->second.addr + len, len);
 | 
			
		||||
                      "Found breakpoint type %d @ %016" PRIx64 ", range: %016" PRIx64
 | 
			
		||||
                      " - %016" PRIx64 " (%" PRIx64 " bytes)\n",
 | 
			
		||||
                      static_cast<int>(type), addr, bp->second.addr, bp->second.addr + len, len);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -778,8 +781,8 @@ static bool CommitBreakpoint(BreakpointType type, PAddr addr, u64 len) {
 | 
			
		||||
    breakpoint.len = len;
 | 
			
		||||
    p.insert({addr, breakpoint});
 | 
			
		||||
 | 
			
		||||
    LOG_DEBUG(Debug_GDBStub, "gdb: added %d breakpoint: %08x bytes at %08x\n", type, breakpoint.len,
 | 
			
		||||
              breakpoint.addr);
 | 
			
		||||
    LOG_DEBUG(Debug_GDBStub, "gdb: added %d breakpoint: %016" PRIx64 " bytes at %016" PRIx64 "\n",
 | 
			
		||||
              static_cast<int>(type), breakpoint.len, breakpoint.addr);
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@
 | 
			
		||||
// Refer to the license.txt file included.
 | 
			
		||||
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include <list>
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include "common/assert.h"
 | 
			
		||||
@ -379,7 +380,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
 | 
			
		||||
                                            SharedPtr<Process> owner_process) {
 | 
			
		||||
    // Check if priority is in ranged. Lowest priority -> highest priority id.
 | 
			
		||||
    if (priority > THREADPRIO_LOWEST) {
 | 
			
		||||
        LOG_ERROR(Kernel_SVC, "Invalid thread priority: %d", priority);
 | 
			
		||||
        LOG_ERROR(Kernel_SVC, "Invalid thread priority: %u", priority);
 | 
			
		||||
        return ERR_OUT_OF_RANGE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -391,7 +392,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
 | 
			
		||||
    // TODO(yuriks): Other checks, returning 0xD9001BEA
 | 
			
		||||
 | 
			
		||||
    if (!Memory::IsValidVirtualAddress(*owner_process, entry_point)) {
 | 
			
		||||
        LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name.c_str(), entry_point);
 | 
			
		||||
        LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %016" PRIx64, name.c_str(), entry_point);
 | 
			
		||||
        // TODO (bunnei): Find the correct error code to use here
 | 
			
		||||
        return ResultCode(-1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
// Licensed under GPLv2 or any later version
 | 
			
		||||
// Refer to the license.txt file included.
 | 
			
		||||
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include <iterator>
 | 
			
		||||
#include "common/assert.h"
 | 
			
		||||
#include "common/logging/log.h"
 | 
			
		||||
@ -206,7 +207,8 @@ void VMManager::RefreshMemoryBlockMappings(const std::vector<u8>* block) {
 | 
			
		||||
void VMManager::LogLayout(Log::Level log_level) const {
 | 
			
		||||
    for (const auto& p : vma_map) {
 | 
			
		||||
        const VirtualMemoryArea& vma = p.second;
 | 
			
		||||
        LOG_GENERIC(Log::Class::Kernel, log_level, "%08X - %08X  size: %8X %c%c%c %s", vma.base,
 | 
			
		||||
        LOG_GENERIC(Log::Class::Kernel, log_level,
 | 
			
		||||
                    "%016" PRIx64 " - %016" PRIx64 "  size: %16" PRIx64 " %c%c%c %s", vma.base,
 | 
			
		||||
                    vma.base + vma.size, vma.size,
 | 
			
		||||
                    (u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-',
 | 
			
		||||
                    (u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-',
 | 
			
		||||
@ -222,8 +224,8 @@ VMManager::VMAIter VMManager::StripIterConstness(const VMAHandle& iter) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u64 size) {
 | 
			
		||||
    ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x%8X", size);
 | 
			
		||||
    ASSERT_MSG((base & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x%08X", base);
 | 
			
		||||
    ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x%16" PRIx64, size);
 | 
			
		||||
    ASSERT_MSG((base & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x%016" PRIx64, base);
 | 
			
		||||
 | 
			
		||||
    VMAIter vma_handle = StripIterConstness(FindVMA(base));
 | 
			
		||||
    if (vma_handle == vma_map.end()) {
 | 
			
		||||
@ -258,8 +260,8 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u64 size) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u64 size) {
 | 
			
		||||
    ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x%8X", size);
 | 
			
		||||
    ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x%08X", target);
 | 
			
		||||
    ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x%16" PRIx64, size);
 | 
			
		||||
    ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x%016" PRIx64, target);
 | 
			
		||||
 | 
			
		||||
    VAddr target_end = target + size;
 | 
			
		||||
    ASSERT(target_end >= target);
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
// Licensed under GPLv2 or any later version
 | 
			
		||||
// Refer to the license.txt file included.
 | 
			
		||||
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include "common/assert.h"
 | 
			
		||||
#include "common/logging/log.h"
 | 
			
		||||
#include "core/core.h"
 | 
			
		||||
@ -13,8 +14,8 @@ namespace Nvidia {
 | 
			
		||||
namespace Devices {
 | 
			
		||||
 | 
			
		||||
u32 nvhost_as_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%llx, output_size=0x%llx",
 | 
			
		||||
              command, input.size(), output.size());
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%zx, output_size=0x%zx",
 | 
			
		||||
              command.raw, input.size(), output.size());
 | 
			
		||||
 | 
			
		||||
    switch (static_cast<IoctlCommand>(command.raw)) {
 | 
			
		||||
    case IoctlCommand::IocInitalizeExCommand:
 | 
			
		||||
@ -62,7 +63,8 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou
 | 
			
		||||
    std::memcpy(¶ms, input.data(), input.size());
 | 
			
		||||
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV,
 | 
			
		||||
              "called, flags=%x, nvmap_handle=%x, buffer_offset=%lx, mapping_size=%lx, offset=%lx",
 | 
			
		||||
              "called, flags=%x, nvmap_handle=%x, buffer_offset=%" PRIu64 ", mapping_size=%" PRIu64
 | 
			
		||||
              ", offset=%" PRIu64,
 | 
			
		||||
              params.flags, params.nvmap_handle, params.buffer_offset, params.mapping_size,
 | 
			
		||||
              params.offset);
 | 
			
		||||
 | 
			
		||||
@ -97,8 +99,8 @@ u32 nvhost_as_gpu::BindChannel(const std::vector<u8>& input, std::vector<u8>& ou
 | 
			
		||||
u32 nvhost_as_gpu::GetVARegions(const std::vector<u8>& input, std::vector<u8>& output) {
 | 
			
		||||
    IoctlGetVaRegions params{};
 | 
			
		||||
    std::memcpy(¶ms, input.data(), input.size());
 | 
			
		||||
    LOG_WARNING(Service_NVDRV, "(STUBBED) called, buf_addr=%lx, buf_size=%x", params.buf_addr,
 | 
			
		||||
                params.buf_size);
 | 
			
		||||
    LOG_WARNING(Service_NVDRV, "(STUBBED) called, buf_addr=%" PRIu64 ", buf_size=%x",
 | 
			
		||||
                params.buf_addr, params.buf_size);
 | 
			
		||||
 | 
			
		||||
    params.buf_size = 0x30;
 | 
			
		||||
    params.regions[0].offset = 0x04000000;
 | 
			
		||||
 | 
			
		||||
@ -11,8 +11,8 @@ namespace Nvidia {
 | 
			
		||||
namespace Devices {
 | 
			
		||||
 | 
			
		||||
u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%lx, output_size=0x%lx", command,
 | 
			
		||||
              input.size(), output.size());
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%zx, output_size=0x%zx",
 | 
			
		||||
              command.raw, input.size(), output.size());
 | 
			
		||||
 | 
			
		||||
    switch (static_cast<IoctlCommand>(command.raw)) {
 | 
			
		||||
    case IoctlCommand::IocGetConfigCommand:
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
// Licensed under GPLv2 or any later version
 | 
			
		||||
// Refer to the license.txt file included.
 | 
			
		||||
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include "common/assert.h"
 | 
			
		||||
#include "common/logging/log.h"
 | 
			
		||||
#include "core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h"
 | 
			
		||||
@ -11,8 +12,8 @@ namespace Nvidia {
 | 
			
		||||
namespace Devices {
 | 
			
		||||
 | 
			
		||||
u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%llx, output_size=0x%llx",
 | 
			
		||||
              command, input.size(), output.size());
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%zx, output_size=0x%zx",
 | 
			
		||||
              command.raw, input.size(), output.size());
 | 
			
		||||
 | 
			
		||||
    switch (static_cast<IoctlCommand>(command.raw)) {
 | 
			
		||||
    case IoctlCommand::IocGetCharacteristicsCommand:
 | 
			
		||||
@ -78,7 +79,7 @@ u32 nvhost_ctrl_gpu::GetCharacteristics(const std::vector<u8>& input, std::vecto
 | 
			
		||||
u32 nvhost_ctrl_gpu::GetTPCMasks(const std::vector<u8>& input, std::vector<u8>& output) {
 | 
			
		||||
    IoctlGpuGetTpcMasksArgs params{};
 | 
			
		||||
    std::memcpy(¶ms, input.data(), input.size());
 | 
			
		||||
    LOG_WARNING(Service_NVDRV, "(STUBBED) called, mask=0x%x, mask_buf_addr=0x%lx",
 | 
			
		||||
    LOG_WARNING(Service_NVDRV, "(STUBBED) called, mask=0x%x, mask_buf_addr=0x%" PRIx64,
 | 
			
		||||
                params.mask_buf_size, params.mask_buf_addr);
 | 
			
		||||
    std::memcpy(output.data(), ¶ms, sizeof(params));
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
// Licensed under GPLv2 or any later version
 | 
			
		||||
// Refer to the license.txt file included.
 | 
			
		||||
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include <map>
 | 
			
		||||
#include "common/assert.h"
 | 
			
		||||
#include "common/logging/log.h"
 | 
			
		||||
@ -13,8 +14,8 @@ namespace Nvidia {
 | 
			
		||||
namespace Devices {
 | 
			
		||||
 | 
			
		||||
u32 nvhost_gpu::ioctl(Ioctl command, const std::vector<u8>& input, std::vector<u8>& output) {
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%llx, output_size=0x%llx",
 | 
			
		||||
              command, input.size(), output.size());
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, command=0x%08x, input_size=0x%zx, output_size=0x%zx",
 | 
			
		||||
              command.raw, input.size(), output.size());
 | 
			
		||||
 | 
			
		||||
    switch (static_cast<IoctlCommand>(command.raw)) {
 | 
			
		||||
    case IoctlCommand::IocSetNVMAPfdCommand:
 | 
			
		||||
@ -74,7 +75,8 @@ u32 nvhost_gpu::GetClientData(const std::vector<u8>& input, std::vector<u8>& out
 | 
			
		||||
 | 
			
		||||
u32 nvhost_gpu::ZCullBind(const std::vector<u8>& input, std::vector<u8>& output) {
 | 
			
		||||
    std::memcpy(&zcull_params, input.data(), input.size());
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, gpu_va=%lx, mode=%x", zcull_params.gpu_va, zcull_params.mode);
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, gpu_va=%" PRIx64 ", mode=%x", zcull_params.gpu_va,
 | 
			
		||||
              zcull_params.mode);
 | 
			
		||||
    std::memcpy(output.data(), &zcull_params, output.size());
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
@ -82,8 +84,8 @@ u32 nvhost_gpu::ZCullBind(const std::vector<u8>& input, std::vector<u8>& output)
 | 
			
		||||
u32 nvhost_gpu::SetErrorNotifier(const std::vector<u8>& input, std::vector<u8>& output) {
 | 
			
		||||
    IoctlSetErrorNotifier params{};
 | 
			
		||||
    std::memcpy(¶ms, input.data(), input.size());
 | 
			
		||||
    LOG_WARNING(Service_NVDRV, "(STUBBED) called, offset=%lx, size=%lx, mem=%x", params.offset,
 | 
			
		||||
                params.size, params.mem);
 | 
			
		||||
    LOG_WARNING(Service_NVDRV, "(STUBBED) called, offset=%" PRIx64 ", size=%" PRIx64 ", mem=%x",
 | 
			
		||||
                params.offset, params.size, params.mem);
 | 
			
		||||
    std::memcpy(output.data(), ¶ms, output.size());
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
@ -123,7 +125,7 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& outp
 | 
			
		||||
        UNIMPLEMENTED();
 | 
			
		||||
    IoctlSubmitGpfifo params{};
 | 
			
		||||
    std::memcpy(¶ms, input.data(), sizeof(IoctlSubmitGpfifo));
 | 
			
		||||
    LOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo=%lx, num_entries=%x, flags=%x",
 | 
			
		||||
    LOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo=%" PRIx64 ", num_entries=%x, flags=%x",
 | 
			
		||||
                params.gpfifo, params.num_entries, params.flags);
 | 
			
		||||
 | 
			
		||||
    auto entries = std::vector<IoctlGpfifoEntry>();
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@
 | 
			
		||||
// Refer to the license.txt file included.
 | 
			
		||||
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
 | 
			
		||||
#include "common/assert.h"
 | 
			
		||||
#include "common/logging/log.h"
 | 
			
		||||
@ -71,7 +72,7 @@ u32 nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output) {
 | 
			
		||||
    object->addr = params.addr;
 | 
			
		||||
    object->status = Object::Status::Allocated;
 | 
			
		||||
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, addr=0x%llx", params.addr);
 | 
			
		||||
    LOG_DEBUG(Service_NVDRV, "called, addr=0x%" PRIx64, params.addr);
 | 
			
		||||
 | 
			
		||||
    std::memcpy(output.data(), ¶ms, sizeof(params));
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
// Licensed under GPLv2 or any later version
 | 
			
		||||
// Refer to the license.txt file included.
 | 
			
		||||
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include "common/logging/log.h"
 | 
			
		||||
#include "core/hle/ipc_helpers.h"
 | 
			
		||||
#include "core/hle/kernel/event.h"
 | 
			
		||||
@ -88,7 +89,7 @@ void NVDRV::SetClientPID(Kernel::HLERequestContext& ctx) {
 | 
			
		||||
    IPC::RequestParser rp{ctx};
 | 
			
		||||
    pid = rp.Pop<u64>();
 | 
			
		||||
 | 
			
		||||
    LOG_WARNING(Service_NVDRV, "(STUBBED) called, pid=0x%lx", pid);
 | 
			
		||||
    LOG_WARNING(Service_NVDRV, "(STUBBED) called, pid=0x%" PRIx64, pid);
 | 
			
		||||
    IPC::ResponseBuilder rb{ctx, 3};
 | 
			
		||||
    rb.Push(RESULT_SUCCESS);
 | 
			
		||||
    rb.Push<u32>(0);
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
// Licensed under GPLv2 or any later version
 | 
			
		||||
// Refer to the license.txt file included.
 | 
			
		||||
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include "common/common_funcs.h"
 | 
			
		||||
#include "common/common_paths.h"
 | 
			
		||||
#include "common/file_util.h"
 | 
			
		||||
@ -116,7 +117,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
 | 
			
		||||
        const VAddr load_addr = next_load_addr;
 | 
			
		||||
        next_load_addr = AppLoader_NSO::LoadModule(path, load_addr);
 | 
			
		||||
        if (next_load_addr) {
 | 
			
		||||
            LOG_DEBUG(Loader, "loaded module %s @ 0x%llx", module, load_addr);
 | 
			
		||||
            LOG_DEBUG(Loader, "loaded module %s @ 0x%" PRIx64, module, load_addr);
 | 
			
		||||
        } else {
 | 
			
		||||
            next_load_addr = load_addr;
 | 
			
		||||
        }
 | 
			
		||||
@ -158,8 +159,8 @@ ResultStatus AppLoader_DeconstructedRomDirectory::ReadRomFS(
 | 
			
		||||
    offset = 0;
 | 
			
		||||
    size = romfs_file->GetSize();
 | 
			
		||||
 | 
			
		||||
    LOG_DEBUG(Loader, "RomFS offset:           0x%08X", offset);
 | 
			
		||||
    LOG_DEBUG(Loader, "RomFS size:             0x%08X", size);
 | 
			
		||||
    LOG_DEBUG(Loader, "RomFS offset:           0x%016" PRIX64, offset);
 | 
			
		||||
    LOG_DEBUG(Loader, "RomFS size:             0x%016" PRIX64, size);
 | 
			
		||||
 | 
			
		||||
    // Reset read pointer
 | 
			
		||||
    file.Seek(0, SEEK_SET);
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
// Licensed under GPLv2 or any later version
 | 
			
		||||
// Refer to the license.txt file included.
 | 
			
		||||
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <lz4.h>
 | 
			
		||||
#include "common/common_funcs.h"
 | 
			
		||||
@ -82,7 +83,7 @@ static std::vector<u8> ReadSegment(FileUtil::IOFile& file, const NsoSegmentHeade
 | 
			
		||||
        reinterpret_cast<char*>(uncompressed_data.data()), compressed_size, header.size);
 | 
			
		||||
 | 
			
		||||
    ASSERT_MSG(bytes_uncompressed == header.size && bytes_uncompressed == uncompressed_data.size(),
 | 
			
		||||
               "%d != %d != %d", bytes_uncompressed, header.size, uncompressed_data.size());
 | 
			
		||||
               "%d != %u != %zu", bytes_uncompressed, header.size, uncompressed_data.size());
 | 
			
		||||
 | 
			
		||||
    return uncompressed_data;
 | 
			
		||||
}
 | 
			
		||||
@ -158,7 +159,8 @@ ResultStatus AppLoader_NSO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
 | 
			
		||||
 | 
			
		||||
    // Load module
 | 
			
		||||
    LoadModule(filepath, Memory::PROCESS_IMAGE_VADDR);
 | 
			
		||||
    LOG_DEBUG(Loader, "loaded module %s @ 0x%llx", filepath.c_str(), Memory::PROCESS_IMAGE_VADDR);
 | 
			
		||||
    LOG_DEBUG(Loader, "loaded module %s @ 0x%" PRIx64, filepath.c_str(),
 | 
			
		||||
              Memory::PROCESS_IMAGE_VADDR);
 | 
			
		||||
 | 
			
		||||
    process->svc_access_mask.set();
 | 
			
		||||
    process->address_mappings = default_address_mappings;
 | 
			
		||||
 | 
			
		||||
@ -4,6 +4,7 @@
 | 
			
		||||
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <array>
 | 
			
		||||
#include <cinttypes>
 | 
			
		||||
#include <cstring>
 | 
			
		||||
#include <boost/optional.hpp>
 | 
			
		||||
#include "common/assert.h"
 | 
			
		||||
@ -38,12 +39,12 @@ PageTable* GetCurrentPageTable() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) {
 | 
			
		||||
    LOG_DEBUG(HW_Memory, "Mapping %p onto %08X-%08X", memory, base * PAGE_SIZE,
 | 
			
		||||
    LOG_DEBUG(HW_Memory, "Mapping %p onto %016" PRIX64 "-%016" PRIX64, memory, base * PAGE_SIZE,
 | 
			
		||||
              (base + size) * PAGE_SIZE);
 | 
			
		||||
 | 
			
		||||
    VAddr end = base + size;
 | 
			
		||||
    while (base != end) {
 | 
			
		||||
        ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at %08X", base);
 | 
			
		||||
        ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at %016" PRIX64, base);
 | 
			
		||||
 | 
			
		||||
        page_table.attributes[base] = type;
 | 
			
		||||
        page_table.pointers[base] = memory;
 | 
			
		||||
@ -55,14 +56,14 @@ static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, Pa
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MapMemoryRegion(PageTable& page_table, VAddr base, u64 size, u8* target) {
 | 
			
		||||
    ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %08X", size);
 | 
			
		||||
    ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %08X", base);
 | 
			
		||||
    ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %016" PRIX64, size);
 | 
			
		||||
    ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %016" PRIX64, base);
 | 
			
		||||
    MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, target, PageType::Memory);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MapIoRegion(PageTable& page_table, VAddr base, u64 size, MemoryHookPointer mmio_handler) {
 | 
			
		||||
    ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %08X", size);
 | 
			
		||||
    ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %08X", base);
 | 
			
		||||
    ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %016" PRIX64, size);
 | 
			
		||||
    ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %016" PRIX64, base);
 | 
			
		||||
    MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, nullptr, PageType::Special);
 | 
			
		||||
 | 
			
		||||
    auto interval = boost::icl::discrete_interval<VAddr>::closed(base, base + size - 1);
 | 
			
		||||
@ -71,8 +72,8 @@ void MapIoRegion(PageTable& page_table, VAddr base, u64 size, MemoryHookPointer
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void UnmapRegion(PageTable& page_table, VAddr base, u64 size) {
 | 
			
		||||
    ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %08X", size);
 | 
			
		||||
    ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %08X", base);
 | 
			
		||||
    ASSERT_MSG((size & PAGE_MASK) == 0, "non-page aligned size: %016" PRIX64, size);
 | 
			
		||||
    ASSERT_MSG((base & PAGE_MASK) == 0, "non-page aligned base: %016" PRIX64, base);
 | 
			
		||||
    MapPages(page_table, base / PAGE_SIZE, size / PAGE_SIZE, nullptr, PageType::Unmapped);
 | 
			
		||||
 | 
			
		||||
    auto interval = boost::icl::discrete_interval<VAddr>::closed(base, base + size - 1);
 | 
			
		||||
@ -120,7 +121,7 @@ T Read(const VAddr vaddr) {
 | 
			
		||||
    const PageType type = current_page_table->attributes[vaddr >> PAGE_BITS];
 | 
			
		||||
    switch (type) {
 | 
			
		||||
    case PageType::Unmapped:
 | 
			
		||||
        LOG_ERROR(HW_Memory, "unmapped Read%lu @ 0x%016llX", sizeof(T) * 8, vaddr);
 | 
			
		||||
        LOG_ERROR(HW_Memory, "unmapped Read%zu @ 0x%016" PRIX64, sizeof(T) * 8, vaddr);
 | 
			
		||||
        return 0;
 | 
			
		||||
    case PageType::Special: {
 | 
			
		||||
        if (auto result = ReadSpecial<T>(vaddr))
 | 
			
		||||
@ -129,7 +130,7 @@ T Read(const VAddr vaddr) {
 | 
			
		||||
    }
 | 
			
		||||
    case PageType::Memory: {
 | 
			
		||||
        const u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS];
 | 
			
		||||
        ASSERT_MSG(page_pointer, "Mapped memory page without a pointer @ %08X", vaddr);
 | 
			
		||||
        ASSERT_MSG(page_pointer, "Mapped memory page without a pointer @ %016" PRIX64, vaddr);
 | 
			
		||||
 | 
			
		||||
        T value;
 | 
			
		||||
        std::memcpy(&value, &page_pointer[vaddr & PAGE_MASK], sizeof(T));
 | 
			
		||||
@ -148,8 +149,8 @@ void Write(const VAddr vaddr, const T data) {
 | 
			
		||||
    const PageType type = current_page_table->attributes[vaddr >> PAGE_BITS];
 | 
			
		||||
    switch (type) {
 | 
			
		||||
    case PageType::Unmapped:
 | 
			
		||||
        LOG_ERROR(HW_Memory, "unmapped Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, (u32)data,
 | 
			
		||||
                  vaddr);
 | 
			
		||||
        LOG_ERROR(HW_Memory, "unmapped Write%zu 0x%08X @ 0x%016" PRIX64, sizeof(data) * 8,
 | 
			
		||||
                  static_cast<u32>(data), vaddr);
 | 
			
		||||
        return;
 | 
			
		||||
    case PageType::Special: {
 | 
			
		||||
        if (WriteSpecial<T>(vaddr, data))
 | 
			
		||||
@ -158,7 +159,7 @@ void Write(const VAddr vaddr, const T data) {
 | 
			
		||||
    }
 | 
			
		||||
    case PageType::Memory: {
 | 
			
		||||
        u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS];
 | 
			
		||||
        ASSERT_MSG(page_pointer, "Mapped memory page without a pointer @ %08X", vaddr);
 | 
			
		||||
        ASSERT_MSG(page_pointer, "Mapped memory page without a pointer @ %016" PRIX64, vaddr);
 | 
			
		||||
        std::memcpy(&page_pointer[vaddr & PAGE_MASK], &data, sizeof(T));
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
@ -203,7 +204,7 @@ u8* GetPointer(const VAddr vaddr) {
 | 
			
		||||
        return page_pointer + (vaddr & PAGE_MASK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    LOG_ERROR(HW_Memory, "unknown GetPointer @ 0x%08x", vaddr);
 | 
			
		||||
    LOG_ERROR(HW_Memory, "unknown GetPointer @ 0x%016" PRIx64, vaddr);
 | 
			
		||||
    return nullptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -241,12 +242,13 @@ u8* GetPhysicalPointer(PAddr address) {
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
    if (area == std::end(memory_areas)) {
 | 
			
		||||
        LOG_ERROR(HW_Memory, "unknown GetPhysicalPointer @ 0x%08X", address);
 | 
			
		||||
        LOG_ERROR(HW_Memory, "unknown GetPhysicalPointer @ 0x%016" PRIX64, address);
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (area->paddr_base == IO_AREA_PADDR) {
 | 
			
		||||
        LOG_ERROR(HW_Memory, "MMIO mappings are not supported yet. phys_addr=0x%08X", address);
 | 
			
		||||
        LOG_ERROR(HW_Memory, "MMIO mappings are not supported yet. phys_addr=0x%016" PRIX64,
 | 
			
		||||
                  address);
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -321,7 +323,9 @@ void ReadBlock(const Kernel::Process& process, const VAddr src_addr, void* dest_
 | 
			
		||||
 | 
			
		||||
        switch (page_table.attributes[page_index]) {
 | 
			
		||||
        case PageType::Unmapped:
 | 
			
		||||
            LOG_ERROR(HW_Memory, "unmapped ReadBlock @ 0x%08X (start address = 0xllx, size = %zu)",
 | 
			
		||||
            LOG_ERROR(HW_Memory,
 | 
			
		||||
                      "unmapped ReadBlock @ 0x%016" PRIX64 " (start address = 0x%" PRIx64
 | 
			
		||||
                      ", size = %zu)",
 | 
			
		||||
                      current_vaddr, src_addr, size);
 | 
			
		||||
            std::memset(dest_buffer, 0, copy_amount);
 | 
			
		||||
            break;
 | 
			
		||||
@ -393,7 +397,8 @@ void WriteBlock(const Kernel::Process& process, const VAddr dest_addr, const voi
 | 
			
		||||
        switch (page_table.attributes[page_index]) {
 | 
			
		||||
        case PageType::Unmapped:
 | 
			
		||||
            LOG_ERROR(HW_Memory,
 | 
			
		||||
                      "unmapped WriteBlock @ 0x%08X (start address = 0x%08X, size = %zu)",
 | 
			
		||||
                      "unmapped WriteBlock @ 0x%016" PRIX64 " (start address = 0x%016" PRIX64
 | 
			
		||||
                      ", size = %zu)",
 | 
			
		||||
                      current_vaddr, dest_addr, size);
 | 
			
		||||
            break;
 | 
			
		||||
        case PageType::Special:
 | 
			
		||||
@ -437,7 +442,9 @@ void ZeroBlock(const VAddr dest_addr, const size_t size) {
 | 
			
		||||
 | 
			
		||||
        switch (current_page_table->attributes[page_index]) {
 | 
			
		||||
        case PageType::Unmapped:
 | 
			
		||||
            LOG_ERROR(HW_Memory, "unmapped ZeroBlock @ 0x%08X (start address = 0x%08X, size = %zu)",
 | 
			
		||||
            LOG_ERROR(HW_Memory,
 | 
			
		||||
                      "unmapped ZeroBlock @ 0x%016" PRIX64 " (start address = 0x%016" PRIX64
 | 
			
		||||
                      ", size = %zu)",
 | 
			
		||||
                      current_vaddr, dest_addr, size);
 | 
			
		||||
            break;
 | 
			
		||||
        case PageType::Special:
 | 
			
		||||
@ -474,7 +481,9 @@ void CopyBlock(VAddr dest_addr, VAddr src_addr, const size_t size) {
 | 
			
		||||
 | 
			
		||||
        switch (current_page_table->attributes[page_index]) {
 | 
			
		||||
        case PageType::Unmapped:
 | 
			
		||||
            LOG_ERROR(HW_Memory, "unmapped CopyBlock @ 0x%08X (start address = 0x%08X, size = %zu)",
 | 
			
		||||
            LOG_ERROR(HW_Memory,
 | 
			
		||||
                      "unmapped CopyBlock @ 0x%016" PRIX64 " (start address = 0x%016" PRIX64
 | 
			
		||||
                      ", size = %zu)",
 | 
			
		||||
                      current_vaddr, src_addr, size);
 | 
			
		||||
            ZeroBlock(dest_addr, copy_amount);
 | 
			
		||||
            break;
 | 
			
		||||
@ -599,7 +608,7 @@ boost::optional<PAddr> TryVirtualToPhysicalAddress(const VAddr addr) {
 | 
			
		||||
PAddr VirtualToPhysicalAddress(const VAddr addr) {
 | 
			
		||||
    auto paddr = TryVirtualToPhysicalAddress(addr);
 | 
			
		||||
    if (!paddr) {
 | 
			
		||||
        LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%08X", addr);
 | 
			
		||||
        LOG_ERROR(HW_Memory, "Unknown virtual address @ 0x%016" PRIX64, addr);
 | 
			
		||||
        // To help with debugging, set bit on address so that it's obviously invalid.
 | 
			
		||||
        return addr | 0x80000000;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user