CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/HLE/KernelThreadDebugInterface.h
Views: 1401
1
// Copyright (c) 2018- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include <cstdio>
21
#include "Core/HLE/sceKernelThread.h"
22
#include "Core/MIPS/MIPSDebugInterface.h"
23
24
class KernelThreadDebugInterface : public MIPSDebugInterface {
25
public:
26
KernelThreadDebugInterface(MIPSState *c, PSPThreadContext &t) : MIPSDebugInterface(c), ctx(t) {
27
}
28
29
unsigned int getPC() override { return ctx.pc; }
30
void setPC(unsigned int address) override { ctx.pc = address; }
31
32
u32 GetGPR32Value(int reg) override { return ctx.r[reg]; }
33
u32 GetPC() override { return ctx.pc; }
34
u32 GetLR() override { return ctx.r[MIPS_REG_RA]; }
35
void SetPC(u32 _pc) override { ctx.pc = _pc; }
36
37
void PrintRegValue(int cat, int index, char *out, size_t outSize) override {
38
switch (cat) {
39
case 0: snprintf(out, outSize, "%08X", ctx.r[index]); break;
40
case 1: snprintf(out, outSize, "%f", ctx.f[index]); break;
41
case 2: snprintf(out, outSize, "N/A"); break;
42
}
43
}
44
45
u32 GetHi() override {
46
return ctx.hi;
47
}
48
49
u32 GetLo() override {
50
return ctx.lo;
51
}
52
53
void SetHi(u32 val) override {
54
ctx.hi = val;
55
}
56
57
void SetLo(u32 val) override {
58
ctx.lo = val;
59
}
60
61
u32 GetRegValue(int cat, int index) override {
62
switch (cat) {
63
case 0: return ctx.r[index];
64
case 1: return ctx.fi[index];
65
case 2: return ctx.vi[voffset[index]];
66
default: return 0;
67
}
68
}
69
70
void SetRegValue(int cat, int index, u32 value) override {
71
switch (cat) {
72
case 0:
73
if (index != 0)
74
ctx.r[index] = value;
75
break;
76
77
case 1:
78
ctx.fi[index] = value;
79
break;
80
81
case 2:
82
ctx.vi[voffset[index]] = value;
83
break;
84
85
default:
86
break;
87
}
88
}
89
90
protected:
91
PSPThreadContext &ctx;
92
};
93
94