File: RAM_ROM.h

package info (click to toggle)
pose 3.0a3-3
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 15,500 kB
  • ctags: 20,548
  • sloc: ansic: 72,579; cpp: 50,198; perl: 1,336; python: 1,242; sh: 363; makefile: 290
file content (150 lines) | stat: -rw-r--r-- 4,374 bytes parent folder | download
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* -*- mode: C++; tab-width: 4 -*- */
/* ================================================================================== */
/* Copyright (c) 1998-1999 3Com Corporation or its subsidiaries. All rights reserved. */
/* ================================================================================== */

#ifndef _RAM_ROM_H_
#define _RAM_ROM_H_

#include "EmulatorTypes.h"		// RAMSizeType
#include "ErrorHandling.h"		// Errors::EAccessType

class StreamHandle;


// Types.

// This struct is used to control access to memory.  The first set of fields
// are booleans which, when set to true, turn on address validation for the
// various ranges of memory.  The second second set of fields are booleans
// which, when set to true, prevent access by user applications to the various
// ranges of memory.

struct MemAccessFlags
{
	Bool				fValidate_DummyGet;
	Bool				fValidate_DummySet;
	Bool				fValidate_RegisterGet;
	Bool				fValidate_RegisterSet;
	Bool				fValidate_DRAMGet;
	Bool				fValidate_DRAMSet;
	Bool				fValidate_SRAMGet;
	Bool				fValidate_SRAMSet;
	Bool				fValidate_ROMGet;
	Bool				fValidate_ROMSet;

//	Bool				fProtect_LowMemGet;
//	Bool				fProtect_LowMemSet;
//	Bool				fProtect_GlobalGet;
//	Bool				fProtect_GlobalSet;
//	Bool				fProtect_ScreenGet;
//	Bool				fProtect_ScreenSet;
	Bool				fProtect_SRAMGet;
	Bool				fProtect_SRAMSet;
	Bool				fProtect_ROMGet;
	Bool				fProtect_ROMSet;
	Bool				fProtect_RegisterGet;
	Bool				fProtect_RegisterSet;

//	Bool				fCheck_UserChunkGet;
//	Bool				fCheck_UserChunkSet;
//	Bool				fCheck_SysChunkGet;
//	Bool				fCheck_SysChunkSet;

//	Bool				fProtect_SysLowMemGet;
//	Bool				fProtect_SysLowMemSet;
//	Bool				fProtect_SysGlobalGet;
//	Bool				fProtect_SysGlobalSet;
//	Bool				fProtect_SysScreenGet;
//	Bool				fProtect_SysScreenSet;
//	Bool				fProtect_SysSRAMGet;
//	Bool				fProtect_SysSRAMSet;
	Bool				fProtect_SysROMGet;
	Bool				fProtect_SysROMSet;
//	Bool				fProtect_SysRegisterGet;
//	Bool				fProtect_SysRegisterSet;
};


// Globals.

extern MemAccessFlags	gMemAccessFlags;

#if PROFILE_MEMORY
enum
{
	kDRAMLongRead,	kDRAMLongRead2,		kDRAMWordRead,	kDRAMByteRead,
	kDRAMLongWrite,	kDRAMLongWrite2,	kDRAMWordWrite,	kDRAMByteWrite,
	kSRAMLongRead,	kSRAMLongRead2,		kSRAMWordRead,	kSRAMByteRead,
	kSRAMLongWrite,	kSRAMLongWrite2,	kSRAMWordWrite,	kSRAMByteWrite,
	kROMLongRead,	kROMLongRead2,		kROMWordRead,	kROMByteRead,
	kROMLongWrite,	kROMLongWrite2,		kROMWordWrite,	kROMByteWrite,
	kREGLongRead,	kREGLongRead2,		kREGWordRead,	kREGByteRead,
	kREGLongWrite,	kREGLongWrite2,		kREGWordWrite,	kREGByteWrite,

	
	kLastEnum
};
extern long				gMemoryAccess[];
#endif

// Function prototypes.

class Memory
{
	public:
		static void				Initialize			(StreamHandle& hROM,
													 RAMSizeType iRAMSize);
		static void				Reset				(void);
		static void				Save				(SessionFile&);
		static void				Load				(SessionFile&);
		static void				Dispose				(void);

		static void				InitializeBanks		(AddressBank& iBankInitializer,
													 uae_s32 iStartingBankIndex,
													 uae_s32 iNumberOfBanks);

		static void				ResetRAMBankHandlers(void);

		static void				MapPhysicalMemory	(const void*, uae_u32);
		static void				UnmapPhysicalMemory	(const void*);
		static void				GetMappingInfo		(const void*, void**, uae_u32*);

		static void				PreventedAccess		(uaecptr iAddress,
													 long size,
													 Bool forRead,
													 Errors::EAccessType kind);
};


// There are places within the emulator where we'd like to access low-memory
// and/or Dragonball registers.  If the PC happens to be in RAM, then
// the checks implied by the above booleans and switches will flag our
// access as an error.  Before making such accesses, create an instance
// of CEnableFullAccess to suspend and restore the checks.
//
// Since such accesses are typically "meta" accesses where the emulator is
// accessing memory outside the normal execution of an opcode, we also
// turn off the profiling variable that controls whether or not cycles
// spent accessing memory are counted.

class CEnableFullAccess
{
	public:
								CEnableFullAccess (void);
								~CEnableFullAccess (void);

		static Bool				AccessOK (void);

	private:
		MemAccessFlags			fOldMemAccessFlags;

#if HAS_PROFILING
		Bool					fOldProfilingCounted;
#endif

		static long				fgAccessCount;
};

#endif /* _RAM_ROM_H_ */