From f488a05cdce9836289c01e2d9e853468cf7a0943 Mon Sep 17 00:00:00 2001 From: Luke Usher Date: Sat, 10 Feb 2018 17:11:41 +0000 Subject: [PATCH] Revert "Use Chihiro memory size & Attempt recovery for missing KPCR" This reverts commit 7a84ece451f48357d3a88c0adffb5939c8487ddb. --- src/CxbxKrnl/Emu.cpp | 2 +- src/CxbxKrnl/EmuFS.cpp | 5 ++++- src/CxbxKrnl/EmuKrnlKe.cpp | 12 ++++-------- src/CxbxKrnl/EmuXapi.cpp | 2 +- src/CxbxKrnl/HLEIntercept.cpp | 2 +- src/CxbxKrnl/PhysicalMemory.h | 4 ++-- src/CxbxKrnl/VMManager.cpp | 2 +- src/devices/video/nv2a.cpp | 2 +- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/CxbxKrnl/Emu.cpp b/src/CxbxKrnl/Emu.cpp index 8e69444b2..8e01819fd 100644 --- a/src/CxbxKrnl/Emu.cpp +++ b/src/CxbxKrnl/Emu.cpp @@ -115,7 +115,7 @@ std::string EIPToString(xbaddr EIP) { char buffer[256]; - if (EIP < CHIHIRO_MEMORY_SIZE) { + if (EIP < XBOX_MEMORY_SIZE) { int symbolOffset = 0; std::string symbolName = GetDetectedSymbolName(EIP, &symbolOffset); sprintf(buffer, "0x%.08X(=%s+0x%x)", EIP, symbolName.c_str(), symbolOffset); diff --git a/src/CxbxKrnl/EmuFS.cpp b/src/CxbxKrnl/EmuFS.cpp index 3627de099..145d20aa9 100644 --- a/src/CxbxKrnl/EmuFS.cpp +++ b/src/CxbxKrnl/EmuFS.cpp @@ -92,7 +92,10 @@ void EmuKeSetPcr(xboxkrnl::KPCR *Pcr) // the user data-slot of each Windows thread Cxbx uses for an // Xbox thread. // - __writefsdword(TIB_ArbitraryDataSlot, (DWORD)Pcr); + __asm { + mov eax, Pcr + mov fs : [TIB_ArbitraryDataSlot], eax + } } __declspec(naked) void EmuFS_CmpEsiFs00() diff --git a/src/CxbxKrnl/EmuKrnlKe.cpp b/src/CxbxKrnl/EmuKrnlKe.cpp index 51fb5d0d2..230ee71ec 100644 --- a/src/CxbxKrnl/EmuKrnlKe.cpp +++ b/src/CxbxKrnl/EmuKrnlKe.cpp @@ -138,16 +138,12 @@ BOOLEAN KiInsertTreeTimer( // ****************************************************************** xboxkrnl::KPCR* KeGetPcr() { - xboxkrnl::PKPCR Pcr; + xboxkrnl::KPCR* Pcr; // See EmuKeSetPcr() - Pcr = (xboxkrnl::PKPCR)__readfsdword(TIB_ArbitraryDataSlot); - - if (Pcr == nullptr) { - EmuWarning("KeGetPCR returned nullptr: Was this called from a non-xbox thread?"); - // Attempt to salvage the situation by calling InitXboxThread to setup KPCR in place - InitXboxThread(g_CPUXbox); - Pcr = (xboxkrnl::PKPCR)__readfsdword(TIB_ArbitraryDataSlot); + __asm { + mov eax, fs : [TIB_ArbitraryDataSlot] + mov Pcr, eax } return Pcr; diff --git a/src/CxbxKrnl/EmuXapi.cpp b/src/CxbxKrnl/EmuXapi.cpp index be6d20c1a..432b980b7 100644 --- a/src/CxbxKrnl/EmuXapi.cpp +++ b/src/CxbxKrnl/EmuXapi.cpp @@ -110,7 +110,7 @@ void SetupXboxDeviceTypes() printf("DeviceTable Entires: %u\n", deviceTableEntryCount); // Sanity check: Where all these device offsets within Xbox memory - if (deviceTableStartOffset >= CHIHIRO_MEMORY_SIZE || deviceTableEndOffset >= CHIHIRO_MEMORY_SIZE) { + if (deviceTableStartOffset >= XBOX_MEMORY_SIZE || deviceTableEndOffset >= XBOX_MEMORY_SIZE) { CxbxKrnlCleanup("XAPI DeviceTable Location is outside of Xbox Memory range"); } diff --git a/src/CxbxKrnl/HLEIntercept.cpp b/src/CxbxKrnl/HLEIntercept.cpp index 70ce880b1..1344bb9d4 100644 --- a/src/CxbxKrnl/HLEIntercept.cpp +++ b/src/CxbxKrnl/HLEIntercept.cpp @@ -237,7 +237,7 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader) { output << "\t*ADDRESS TOO LOW!*"; } - else if (location > CHIHIRO_MEMORY_SIZE) + else if (location > XBOX_MEMORY_SIZE) { output << "\t*ADDRESS TOO HIGH!*"; } diff --git a/src/CxbxKrnl/PhysicalMemory.h b/src/CxbxKrnl/PhysicalMemory.h index daa5a3aa6..2ef8b721c 100644 --- a/src/CxbxKrnl/PhysicalMemory.h +++ b/src/CxbxKrnl/PhysicalMemory.h @@ -92,7 +92,7 @@ class PhysicalMemory // amount of physical memory in use size_t m_PhysicalMemoryInUse = 0; // max physical memory available on the Xbox/Chihiro - size_t m_MaxPhysicalMemory = CHIHIRO_MEMORY_SIZE; + size_t m_MaxPhysicalMemory = XBOX_MEMORY_SIZE; // map tracking the physical memory currently in use std::map m_Mem_map; // map tracking the blocks allocated with VirtualAlloc @@ -102,7 +102,7 @@ class PhysicalMemory // current error status code of the PhysicalMemory class PMEMORY_STATUS m_Status = PMEMORY_SUCCESS; // highest address available for contiguous allocations - PAddr m_MaxContiguousAddress = CHIHIRO_CONTIGUOUS_MEMORY_LIMIT; + PAddr m_MaxContiguousAddress = XBOX_CONTIGUOUS_MEMORY_LIMIT; // protected constructor so PhysicalMemory can only be inherited from PhysicalMemory() {}; diff --git a/src/CxbxKrnl/VMManager.cpp b/src/CxbxKrnl/VMManager.cpp index 010be3251..3ed8a5d04 100644 --- a/src/CxbxKrnl/VMManager.cpp +++ b/src/CxbxKrnl/VMManager.cpp @@ -138,7 +138,7 @@ void VMManager::Initialize(HANDLE file_view) upper_mem_vma.vma_type = VMAType::Allocated; upper_mem_vma.page_type = PageType::SystemMemory; upper_mem_vma.permissions = PAGE_READWRITE; - upper_mem_vma.backing_block = AllocatePhysicalMemoryRange(32 * PAGE_SIZE, upper_mem_vma.page_type, m_MaxContiguousAddress, CHIHIRO_MEMORY_SIZE); + upper_mem_vma.backing_block = AllocatePhysicalMemoryRange(32 * PAGE_SIZE, upper_mem_vma.page_type, m_MaxContiguousAddress, XBOX_MEMORY_SIZE); UpdatePageTableForVMA(upper_mem_vma); // Allocate memory for the dummy kernel diff --git a/src/devices/video/nv2a.cpp b/src/devices/video/nv2a.cpp index 5de9fb8d0..805e1cd8f 100644 --- a/src/devices/video/nv2a.cpp +++ b/src/devices/video/nv2a.cpp @@ -58,7 +58,7 @@ void NV2ADevice::Init() // Register physical memory on bar 1 r.Memory.address = 0; - RegisterBAR(1, CHIHIRO_MEMORY_SIZE, r.value); // TODO : Read g_PhysicalMemory->Size + RegisterBAR(1, XBOX_MEMORY_SIZE, r.value); // TODO : Read g_PhysicalMemory->Size /* LukeUsher commented at https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/pull/882#discussion_r162871029 This is not right: I should have done a better review ;)