summaryrefslogtreecommitdiff
path: root/src/common/mem_arena.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/mem_arena.h')
-rw-r--r--src/common/mem_arena.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/common/mem_arena.h b/src/common/mem_arena.h
new file mode 100644
index 000000000..8bdf9f189
--- /dev/null
+++ b/src/common/mem_arena.h
@@ -0,0 +1,81 @@
1// Copyright (C) 2003 Dolphin Project.
2
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, version 2.0 or later versions.
6
7// This program is distributed in the hope that it will be useful,
8// but WITHOUT ANY WARRANTY; without even the implied warranty of
9// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10// GNU General Public License 2.0 for more details.
11
12// A copy of the GPL 2.0 should have been included with the program.
13// If not, see http://www.gnu.org/licenses/
14
15// Official SVN repository and contact information can be found at
16// http://code.google.com/p/dolphin-emu/
17
18#ifndef _MEMARENA_H_
19#define _MEMARENA_H_
20
21#ifdef _WIN32
22#include <windows.h>
23#endif
24
25#ifdef __SYMBIAN32__
26#include <e32std.h>
27#endif
28
29#include "common.h"
30
31// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it.
32// Multiple views can mirror the same section of the block, which makes it very convient for emulating
33// memory mirrors.
34
35class MemArena
36{
37public:
38 void GrabLowMemSpace(size_t size);
39 void ReleaseSpace();
40 void *CreateView(s64 offset, size_t size, void *base = 0);
41 void ReleaseView(void *view, size_t size);
42
43#ifdef __SYMBIAN32__
44 RChunk* memmap;
45#else
46 // This only finds 1 GB in 32-bit
47 static u8 *Find4GBBase();
48#endif
49private:
50
51#ifdef _WIN32
52 HANDLE hMemoryMapping;
53#else
54 int fd;
55#endif
56};
57
58enum {
59 MV_MIRROR_PREVIOUS = 1,
60 // MV_FAKE_VMEM = 2,
61 // MV_WII_ONLY = 4,
62 MV_IS_PRIMARY_RAM = 0x100,
63 MV_IS_EXTRA1_RAM = 0x200,
64 MV_IS_EXTRA2_RAM = 0x400,
65};
66
67struct MemoryView
68{
69 u8 **out_ptr_low;
70 u8 **out_ptr;
71 u32 virtual_address;
72 u32 size;
73 u32 flags;
74};
75
76// Uses a memory arena to set up an emulator-friendly memory map according to
77// a passed-in list of MemoryView structures.
78u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena *arena);
79void MemoryMap_Shutdown(const MemoryView *views, int num_views, u32 flags, MemArena *arena);
80
81#endif // _MEMARENA_H_