summaryrefslogtreecommitdiff
path: root/includes/mips.h
blob: 814120f51bd7345127993de742ed5e6888be0c93 (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
#ifndef __MIPS_H__
#define __MIPS_H__
#include <Exceptions.h>
#include <generic.h>
#include <Handle.h>

class mips : public Base {
  public:
    Uint8 Read8(Uint32);
    Uint16 Read16(Uint32);
    Uint32 Read32(Uint32);
    void Write8(Uint32, Uint8);
    void Write16(Uint32, Uint16);
    void Write32(Uint32, Uint32);
    void unpatch8(Uint32);
    void unpatch16(Uint32);
    void unpatch32(Uint32);
    bool IsPatched(Uint32);
    void LoadPSYQ(Handle *);
    void SavePSYQ(Handle *);
    Uint32 GetPC();
    void disassemble(Uint32);
  private:
    void patch(Uint32, int);
    void unpatch(Uint32, int);
    Uint8 psyqhead[0x800];
    Uint8 plainmemory[0x200000];
    Uint8 patches[0x200000];
    Uint8 patchesmap[0x200000 / 8];
    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;
    };
};

class TDis : public Base {
  public:
      TDis(Uint32);
    void setInstruction(String);
    void setAddress(Uint32);
    void addArgReg(int);
    void addArgImm(Uint32);
    void addArgRelative(Uint32);
    void addArgAbsolute(Uint32);
  private:
    Uint32 pc;
};

#endif