Revert "Use Chihiro memory size & Attempt recovery for missing KPCR"

This reverts commit 7a84ece451.
This commit is contained in:
Luke Usher 2018-02-10 17:11:41 +00:00
parent 3493207447
commit f488a05cdc
8 changed files with 15 additions and 16 deletions

View File

@ -115,7 +115,7 @@ std::string EIPToString(xbaddr EIP)
{ {
char buffer[256]; char buffer[256];
if (EIP < CHIHIRO_MEMORY_SIZE) { if (EIP < XBOX_MEMORY_SIZE) {
int symbolOffset = 0; int symbolOffset = 0;
std::string symbolName = GetDetectedSymbolName(EIP, &symbolOffset); std::string symbolName = GetDetectedSymbolName(EIP, &symbolOffset);
sprintf(buffer, "0x%.08X(=%s+0x%x)", EIP, symbolName.c_str(), symbolOffset); sprintf(buffer, "0x%.08X(=%s+0x%x)", EIP, symbolName.c_str(), symbolOffset);

View File

@ -92,7 +92,10 @@ void EmuKeSetPcr(xboxkrnl::KPCR *Pcr)
// the user data-slot of each Windows thread Cxbx uses for an // the user data-slot of each Windows thread Cxbx uses for an
// Xbox thread. // Xbox thread.
// //
__writefsdword(TIB_ArbitraryDataSlot, (DWORD)Pcr); __asm {
mov eax, Pcr
mov fs : [TIB_ArbitraryDataSlot], eax
}
} }
__declspec(naked) void EmuFS_CmpEsiFs00() __declspec(naked) void EmuFS_CmpEsiFs00()

View File

@ -138,16 +138,12 @@ BOOLEAN KiInsertTreeTimer(
// ****************************************************************** // ******************************************************************
xboxkrnl::KPCR* KeGetPcr() xboxkrnl::KPCR* KeGetPcr()
{ {
xboxkrnl::PKPCR Pcr; xboxkrnl::KPCR* Pcr;
// See EmuKeSetPcr() // See EmuKeSetPcr()
Pcr = (xboxkrnl::PKPCR)__readfsdword(TIB_ArbitraryDataSlot); __asm {
mov eax, fs : [TIB_ArbitraryDataSlot]
if (Pcr == nullptr) { mov Pcr, eax
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);
} }
return Pcr; return Pcr;

View File

@ -110,7 +110,7 @@ void SetupXboxDeviceTypes()
printf("DeviceTable Entires: %u\n", deviceTableEntryCount); printf("DeviceTable Entires: %u\n", deviceTableEntryCount);
// Sanity check: Where all these device offsets within Xbox memory // 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"); CxbxKrnlCleanup("XAPI DeviceTable Location is outside of Xbox Memory range");
} }

View File

@ -237,7 +237,7 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
{ {
output << "\t*ADDRESS TOO LOW!*"; output << "\t*ADDRESS TOO LOW!*";
} }
else if (location > CHIHIRO_MEMORY_SIZE) else if (location > XBOX_MEMORY_SIZE)
{ {
output << "\t*ADDRESS TOO HIGH!*"; output << "\t*ADDRESS TOO HIGH!*";
} }

View File

@ -92,7 +92,7 @@ class PhysicalMemory
// amount of physical memory in use // amount of physical memory in use
size_t m_PhysicalMemoryInUse = 0; size_t m_PhysicalMemoryInUse = 0;
// max physical memory available on the Xbox/Chihiro // 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 // map tracking the physical memory currently in use
std::map<PAddr, size_t> m_Mem_map; std::map<PAddr, size_t> m_Mem_map;
// map tracking the blocks allocated with VirtualAlloc // map tracking the blocks allocated with VirtualAlloc
@ -102,7 +102,7 @@ class PhysicalMemory
// current error status code of the PhysicalMemory class // current error status code of the PhysicalMemory class
PMEMORY_STATUS m_Status = PMEMORY_SUCCESS; PMEMORY_STATUS m_Status = PMEMORY_SUCCESS;
// highest address available for contiguous allocations // 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 // protected constructor so PhysicalMemory can only be inherited from
PhysicalMemory() {}; PhysicalMemory() {};

View File

@ -138,7 +138,7 @@ void VMManager::Initialize(HANDLE file_view)
upper_mem_vma.vma_type = VMAType::Allocated; upper_mem_vma.vma_type = VMAType::Allocated;
upper_mem_vma.page_type = PageType::SystemMemory; upper_mem_vma.page_type = PageType::SystemMemory;
upper_mem_vma.permissions = PAGE_READWRITE; 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); UpdatePageTableForVMA(upper_mem_vma);
// Allocate memory for the dummy kernel // Allocate memory for the dummy kernel

View File

@ -58,7 +58,7 @@ void NV2ADevice::Init()
// Register physical memory on bar 1 // Register physical memory on bar 1
r.Memory.address = 0; 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 /* 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 ;) This is not right: I should have done a better review ;)