summaryrefslogtreecommitdiff
path: root/includes/mipsmem.h
diff options
context:
space:
mode:
Diffstat (limited to 'includes/mipsmem.h')
-rw-r--r--includes/mipsmem.h114
1 files changed, 114 insertions, 0 deletions
diff --git a/includes/mipsmem.h b/includes/mipsmem.h
new file mode 100644
index 0000000..f763af8
--- /dev/null
+++ b/includes/mipsmem.h
@@ -0,0 +1,114 @@
+#ifndef __MIPSMEM_H__
+#define __MIPSMEM_H__
+#define PSXMEM 0x200000
+
+#include <Exceptions.h>
+#include <Handle.h>
+
+enum tags_t {
+ CODE,
+ DATA,
+ STOP,
+ INVALID,
+};
+
+class memdata;
+
+class func_t : public Base {
+ public:
+ func_t();
+ virtual ~func_t();
+ Uint32 endpc;
+ Uint8 stacksize;
+};
+
+class refto_t;
+class reffrom_t : public Base {
+ public:
+ reffrom_t(refto_t *, memdata *);
+ virtual ~reffrom_t();
+ memdata * getref();
+ memdata * getmem();
+ reffrom_t * getnext();
+ private:
+ refto_t * refto;
+ reffrom_t * next, * prev;
+ memdata * header;
+};
+
+class refto_t : public Base {
+ public:
+ refto_t(Uint32, memdata *);
+ virtual ~refto_t();
+ memdata * getref();
+ memdata * getmem();
+ private:
+ reffrom_t * reffrom;
+ memdata * mem;
+};
+
+class mipsmem;
+class memdata : public Base {
+ public:
+ memdata(Uint32, mipsmem *);
+ virtual ~memdata();
+ Uint32 getaddress();
+ memdata * getmem(Uint32);
+ static memdata * getmem(Uint32, mipsmem *);
+ func_t * getfunc();
+ refto_t * getrefto();
+ reffrom_t * getreffrom();
+ void setfunc(func_t *);
+ void setrefto(refto_t *);
+ void setreffrom(reffrom_t *);
+ private:
+ void checkdestroy();
+ Uint32 address;
+ mipsmem * mm;
+ func_t * func;
+ refto_t * refto;
+ reffrom_t * reffrom;
+};
+
+class mipsmem : public Base {
+ public:
+ mipsmem();
+ Uint8 Read8(Uint32 addr);
+ Uint16 Read16(Uint32 addr);
+ Uint32 Read32(Uint32 addr);
+ void Write8(Uint32 addr, Uint8);
+ void Write16(Uint32 addr, Uint16);
+ void Write32(Uint32 addr, Uint32);
+ void unpatch8(Uint32 addr);
+ void unpatch16(Uint32 addr);
+ void unpatch32(Uint32 addr);
+ bool IsPatched(Uint32 addr);
+ void LoadPSYQ(Handle *);
+ void SavePSYQ(Handle *);
+ bool GetTag(Uint32 addr, char tag);
+ void SetTag(Uint32 addr, char tag, bool);
+ memdata * GetDatas(Uint32 addr);
+ void SetDatas(Uint32 addr, memdata * p);
+ Uint32 GetPC();
+ Uint32 GetLower();
+ Uint32 GetUpper();
+ private:
+ void patch(Uint32, int);
+ void unpatch(Uint32, int);
+ Uint8 psyqhead[0x800];
+ Uint8 plainmemory[PSXMEM];
+ Uint8 patches[PSXMEM];
+ Uint8 patchesmap[PSXMEM / 8];
+ Uint8 tags[PSXMEM];
+ memdata * datas[PSXMEM];
+ Uint32 paddr, psize, startpc;
+
+ struct psyq {
+ Uint8 id[8];
+ Uint32 text, data, pc0, gp0, t_addr, t_size;
+ Uint32 d_addr, d_size, b_addr, b_size, s_addr, s_size;
+ Uint32 sp, fp, gp, ra, s0;
+ };
+};
+
+#endif