aboutsummaryrefslogtreecommitdiff
path: root/src/ARMJIT.h
blob: cab385f0f15585b29e30dd1ad74b33f23aedfc20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef ARMJIT_H
#define ARMJIT_H

#include "types.h"

#include "ARM.h"
#include "ARM_InstrInfo.h"

namespace ARMJIT
{

enum ExeMemKind
{
	exeMem_Unmapped = 0,
	exeMem_ITCM,
	exeMem_MainRAM,
	exeMem_SWRAM,
	exeMem_LCDC,
	exeMem_ARM9_BIOS,
	exeMem_ARM7_BIOS,
	exeMem_ARM7_WRAM,
	exeMem_ARM7_WVRAM,
	exeMem_Count
};

extern const u32 ExeMemRegionOffsets[];
extern const u32 ExeMemRegionSizes[];

typedef u32 (*JitBlockEntry)();

extern u32 AddrTranslate9[0x2000];
extern u32 AddrTranslate7[0x4000];

const u32 ExeMemSpaceSize = 0x518000; // I hate you C++, sometimes I really hate you...

template <u32 num>
inline bool IsMapped(u32 addr)
{
	if (num == 0)
		return AddrTranslate9[(addr & 0xFFFFFFF) >> 15] >= ExeMemRegionSizes[exeMem_Unmapped];
	else
		return AddrTranslate7[(addr & 0xFFFFFFF) >> 14] >= ExeMemRegionSizes[exeMem_Unmapped];
}

template <u32 num>
inline u32 TranslateAddr(u32 addr)
{
	if (num == 0)
		return AddrTranslate9[(addr & 0xFFFFFFF) >> 15] + (addr & 0x7FFF);
	else
		return AddrTranslate7[(addr & 0xFFFFFFF) >> 14] + (addr & 0x3FFF);
}

JitBlockEntry LookUpBlockEntry(u32 addr);


void Init();
void DeInit();

void InvalidateByAddr(u32 pseudoPhysical, bool mayRestore = true);
void InvalidateAll();

void InvalidateITCM(u32 addr);
void InvalidateByAddr7(u32 addr);

void CompileBlock(ARM* cpu);

void ResetBlockCache();

}

extern "C" void ARM_Dispatch(ARM* cpu, ARMJIT::JitBlockEntry entry);

#endif