dolphin/Source/Core/Common/MemArena.h
magumagu d557310371 Support for dynamic BAT modification (dynamic-bat).
Fundamentally, all this does is enforce the invariant that we always
translate effective addresses based on the current BAT registers and
page table before we do anything else with them.

This change can be logically divided into three parts.  The first part is
creating a table to represent the current BAT state, and keeping it up to
date (PowerPC::IBATUpdated, PowerPC::DBATUpdated, etc.).  This does
nothing by itself, but it's necessary for the other parts.

The second part (mostly in MMU.cpp) is simply removing all the hardcoded
checks for specific untranslated addresses, and consistently translating
addresses using the current BAT configuration. Very straightforward, but a
lot of code changes because we hardcoded assumptions all over the place.

The third part (mostly in Memmap.cpp) is making the fastmem arena reflect
the current BAT configuration.  We do this by redoing the mapping (calling
memmap()) based on the BAT table whenever it changes.

One additional minor change is that translation can fail in two ways:
either the segment is a direct store segment, or page table lookup failed.
The difference doesn't usually matter, but the difference affects cache
instructions, like dcbz.
2016-09-06 08:43:22 +02:00

38 lines
803 B
C++

// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <cstddef>
#ifdef _WIN32
#include <windows.h>
#endif
#include "Common/CommonTypes.h"
// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it.
// Multiple views can mirror the same section of the block, which makes it very convenient for
// emulating
// memory mirrors.
class MemArena
{
public:
void GrabSHMSegment(size_t size);
void ReleaseSHMSegment();
void* CreateView(s64 offset, size_t size, void* base = nullptr);
void ReleaseView(void* view, size_t size);
// This finds 1 GB in 32-bit, 16 GB in 64-bit.
static u8* FindMemoryBase();
private:
#ifdef _WIN32
HANDLE hMemoryMapping;
#else
int fd;
#endif
};