2006-06-15 04:19:30 +00:00
|
|
|
#ifndef _MEMORYMAP_H_
|
|
|
|
#define _MEMORYMAP_H_
|
|
|
|
|
|
|
|
#include "Types.h"
|
2007-12-01 04:08:34 +00:00
|
|
|
#include <functional>
|
2012-01-08 06:04:48 +00:00
|
|
|
#include <vector>
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
enum MEMORYMAP_ENDIANESS
|
|
|
|
{
|
|
|
|
MEMORYMAP_ENDIAN_LSBF,
|
|
|
|
MEMORYMAP_ENDIAN_MSBF,
|
|
|
|
};
|
|
|
|
|
|
|
|
class CMemoryMap
|
|
|
|
{
|
|
|
|
public:
|
2018-04-30 20:01:23 +00:00
|
|
|
typedef std::function<uint32(uint32, uint32)> MemoryMapHandlerType;
|
2006-12-26 05:43:34 +00:00
|
|
|
|
2012-06-25 18:49:17 +00:00
|
|
|
enum MEMORYMAP_TYPE
|
|
|
|
{
|
|
|
|
MEMORYMAP_TYPE_MEMORY,
|
|
|
|
MEMORYMAP_TYPE_FUNCTION
|
|
|
|
};
|
2007-11-22 19:49:28 +00:00
|
|
|
|
2012-06-25 18:49:17 +00:00
|
|
|
struct MEMORYMAPELEMENT
|
|
|
|
{
|
2018-04-30 20:01:23 +00:00
|
|
|
uint32 nStart;
|
|
|
|
uint32 nEnd;
|
|
|
|
void* pPointer;
|
|
|
|
MemoryMapHandlerType handler;
|
|
|
|
MEMORYMAP_TYPE nType;
|
2012-06-25 18:49:17 +00:00
|
|
|
};
|
2007-11-22 19:49:28 +00:00
|
|
|
|
2018-04-30 20:01:23 +00:00
|
|
|
virtual ~CMemoryMap() = default;
|
|
|
|
uint8 GetByte(uint32);
|
|
|
|
virtual uint16 GetHalf(uint32) = 0;
|
|
|
|
virtual uint32 GetWord(uint32) = 0;
|
|
|
|
virtual uint32 GetInstruction(uint32) = 0;
|
|
|
|
virtual void SetByte(uint32, uint8);
|
|
|
|
virtual void SetHalf(uint32, uint16) = 0;
|
|
|
|
virtual void SetWord(uint32, uint32) = 0;
|
|
|
|
void InsertReadMap(uint32, uint32, void*, unsigned char);
|
|
|
|
void InsertReadMap(uint32, uint32, const MemoryMapHandlerType&, unsigned char);
|
|
|
|
void InsertWriteMap(uint32, uint32, void*, unsigned char);
|
|
|
|
void InsertWriteMap(uint32, uint32, const MemoryMapHandlerType&, unsigned char);
|
|
|
|
void InsertInstructionMap(uint32, uint32, void*, unsigned char);
|
|
|
|
const MEMORYMAPELEMENT* GetReadMap(uint32) const;
|
|
|
|
const MEMORYMAPELEMENT* GetWriteMap(uint32) const;
|
2008-07-20 17:26:08 +00:00
|
|
|
|
|
|
|
protected:
|
2012-01-08 06:04:48 +00:00
|
|
|
typedef std::vector<MEMORYMAPELEMENT> MemoryMapListType;
|
|
|
|
|
2018-04-30 20:01:23 +00:00
|
|
|
static const MEMORYMAPELEMENT* GetMap(const MemoryMapListType&, uint32);
|
2008-06-15 19:55:28 +00:00
|
|
|
|
2018-04-30 20:01:23 +00:00
|
|
|
MemoryMapListType m_instructionMap;
|
|
|
|
MemoryMapListType m_readMap;
|
|
|
|
MemoryMapListType m_writeMap;
|
2006-12-26 05:43:34 +00:00
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
private:
|
2018-04-30 20:01:23 +00:00
|
|
|
static void InsertMap(MemoryMapListType&, uint32, uint32, void*, unsigned char);
|
|
|
|
static void InsertMap(MemoryMapListType&, uint32, uint32, const MemoryMapHandlerType&, unsigned char);
|
2006-06-15 04:19:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CMemoryMap_LSBF : public CMemoryMap
|
|
|
|
{
|
|
|
|
public:
|
2018-04-30 20:01:23 +00:00
|
|
|
uint16 GetHalf(uint32);
|
|
|
|
uint32 GetWord(uint32);
|
|
|
|
uint32 GetInstruction(uint32);
|
|
|
|
void SetHalf(uint32, uint16);
|
|
|
|
void SetWord(uint32, uint32);
|
2006-06-15 04:19:30 +00:00
|
|
|
};
|
|
|
|
|
2006-12-26 05:43:34 +00:00
|
|
|
#endif
|