mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-27 19:25:43 -04:00
CPU/CodeCache: Fix DMA writes not invalidating code blocks
Fixes Crash Team Racing and Spyro in Cached Interpreter/Recompiler modes.
This commit is contained in:
parent
47cbe75b48
commit
519dbc818d
@ -165,6 +165,14 @@ TickCount Bus::WriteWords(PhysicalMemoryAddress address, const u32* words, u32 w
|
|||||||
return total_ticks;
|
return total_ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const u32 start_page = address / CPU_CODE_CACHE_PAGE_SIZE;
|
||||||
|
const u32 end_page = (address + word_count * sizeof(u32)) / CPU_CODE_CACHE_PAGE_SIZE;
|
||||||
|
for (u32 page = start_page; page <= end_page; page++)
|
||||||
|
{
|
||||||
|
if (m_ram_code_bits[page])
|
||||||
|
DoInvalidateCodeCache(page);
|
||||||
|
}
|
||||||
|
|
||||||
std::memcpy(&m_ram[address], words, sizeof(u32) * word_count);
|
std::memcpy(&m_ram[address], words, sizeof(u32) * word_count);
|
||||||
return static_cast<TickCount>(word_count + ((word_count + 15) / 16));
|
return static_cast<TickCount>(word_count + ((word_count + 15) / 16));
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ void CodeCache::AddBlockToPageMap(CodeBlock* block)
|
|||||||
|
|
||||||
const u32 start_page = block->GetStartPageIndex();
|
const u32 start_page = block->GetStartPageIndex();
|
||||||
const u32 end_page = block->GetEndPageIndex();
|
const u32 end_page = block->GetEndPageIndex();
|
||||||
for (u32 page = start_page; page < end_page; page++)
|
for (u32 page = start_page; page <= end_page; page++)
|
||||||
{
|
{
|
||||||
m_ram_block_map[page].push_back(block);
|
m_ram_block_map[page].push_back(block);
|
||||||
m_bus->SetRAMCodePage(page);
|
m_bus->SetRAMCodePage(page);
|
||||||
@ -371,7 +371,7 @@ void CodeCache::RemoveBlockFromPageMap(CodeBlock* block)
|
|||||||
|
|
||||||
const u32 start_page = block->GetStartPageIndex();
|
const u32 start_page = block->GetStartPageIndex();
|
||||||
const u32 end_page = block->GetEndPageIndex();
|
const u32 end_page = block->GetEndPageIndex();
|
||||||
for (u32 page = start_page; page < end_page; page++)
|
for (u32 page = start_page; page <= end_page; page++)
|
||||||
{
|
{
|
||||||
auto& page_blocks = m_ram_block_map[page];
|
auto& page_blocks = m_ram_block_map[page];
|
||||||
auto page_block_iter = std::find(page_blocks.begin(), page_blocks.end(), block);
|
auto page_block_iter = std::find(page_blocks.begin(), page_blocks.end(), block);
|
||||||
|
@ -435,10 +435,7 @@ struct CodeBlock
|
|||||||
const u32 GetPC() const { return key.GetPC(); }
|
const u32 GetPC() const { return key.GetPC(); }
|
||||||
const u32 GetSizeInBytes() const { return static_cast<u32>(instructions.size()) * sizeof(Instruction); }
|
const u32 GetSizeInBytes() const { return static_cast<u32>(instructions.size()) * sizeof(Instruction); }
|
||||||
const u32 GetStartPageIndex() const { return (key.GetPC() / CPU_CODE_CACHE_PAGE_SIZE); }
|
const u32 GetStartPageIndex() const { return (key.GetPC() / CPU_CODE_CACHE_PAGE_SIZE); }
|
||||||
const u32 GetEndPageIndex() const
|
const u32 GetEndPageIndex() const { return ((key.GetPC() + GetSizeInBytes()) / CPU_CODE_CACHE_PAGE_SIZE); }
|
||||||
{
|
|
||||||
return ((key.GetPC() + GetSizeInBytes() + (CPU_CODE_CACHE_PAGE_SIZE - 1)) / CPU_CODE_CACHE_PAGE_SIZE);
|
|
||||||
}
|
|
||||||
bool IsInRAM() const
|
bool IsInRAM() const
|
||||||
{
|
{
|
||||||
// TODO: Constant
|
// TODO: Constant
|
||||||
|
Loading…
x
Reference in New Issue
Block a user