From 7f4ee2a0704627eefc31e69bef7f2a2723e78538 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Mon, 17 Apr 2017 22:57:29 -0500 Subject: [PATCH] Fix typo in XamAlloc Few other inconsistencies in xboxkrnl_memory --- src/xenia/kernel/xam/xam_info.cc | 2 +- src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc | 20 +++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/xenia/kernel/xam/xam_info.cc b/src/xenia/kernel/xam/xam_info.cc index e46bc8657..131c1dba4 100644 --- a/src/xenia/kernel/xam/xam_info.cc +++ b/src/xenia/kernel/xam/xam_info.cc @@ -162,7 +162,7 @@ void XamLoaderTerminateTitle() { } DECLARE_XAM_EXPORT(XamLoaderTerminateTitle, ExportTag::kSketchy); -dword_result_t XamAlloc(dword_t unk, dword_t size, lpword_t out_ptr) { +dword_result_t XamAlloc(dword_t unk, dword_t size, lpdword_t out_ptr) { assert_true(unk == 0); // Allocate from the heap. Not sure why XAM does this specially, perhaps diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc index f02870337..b56cb34b1 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc @@ -301,16 +301,13 @@ dword_result_t MmAllocatePhysicalMemoryEx(dword_t flags, dword_t region_size, DECLARE_XBOXKRNL_EXPORT(MmAllocatePhysicalMemoryEx, ExportTag::kImplemented | ExportTag::kMemory); -dword_result_t MmFreePhysicalMemory(dword_t type, dword_t base_address) { +void MmFreePhysicalMemory(dword_t type, dword_t base_address) { // base_address = result of MmAllocatePhysicalMemory. assert_true((base_address & 0x1F) == 0); auto heap = kernel_state()->memory()->LookupHeap(base_address); - if (heap->Release(base_address)) { - return X_STATUS_SUCCESS; - } - return X_STATUS_UNSUCCESSFUL; + heap->Release(base_address); } DECLARE_XBOXKRNL_EXPORT(MmFreePhysicalMemory, ExportTag::kImplemented); @@ -326,14 +323,11 @@ dword_result_t MmQueryAddressProtect(dword_t base_address) { } DECLARE_XBOXKRNL_EXPORT(MmQueryAddressProtect, ExportTag::kImplemented); -dword_result_t MmSetAddressProtect(lpvoid_t base_address, dword_t region_size, - dword_t protect_bits) { +void MmSetAddressProtect(lpvoid_t base_address, dword_t region_size, + dword_t protect_bits) { uint32_t protect = FromXdkProtectFlags(protect_bits); auto heap = kernel_memory()->LookupHeap(base_address); - if (heap->Protect(base_address.guest_address(), region_size, protect)) { - return X_STATUS_SUCCESS; - } - return X_STATUS_UNSUCCESSFUL; + heap->Protect(base_address.guest_address(), region_size, protect); } DECLARE_XBOXKRNL_EXPORT(MmSetAddressProtect, ExportTag::kImplemented | ExportTag::kMemory); @@ -387,7 +381,7 @@ dword_result_t MmQueryStatistics( } // Zero out the struct. - std::memset(stats_ptr, 0, size); + stats_ptr.Zero(); // Set the constants the game is likely asking for. // These numbers are mostly guessed. If the game is just checking for @@ -478,7 +472,7 @@ dword_result_t MmMapIoSpace(dword_t unk0, lpvoid_t src_address, dword_t size, assert_true(size == 0x40); assert_true(flags == 0x404); - return 0; + return src_address.guest_address(); } DECLARE_XBOXKRNL_EXPORT(MmMapIoSpace, ExportTag::kImplemented);