Skip to content

Commit

Permalink
Consitently hitting KeBugCheck in alloc\ initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
google0101-ryan committed Jan 6, 2024
1 parent 48993e2 commit 502501b
Show file tree
Hide file tree
Showing 9 changed files with 448 additions and 43 deletions.
42 changes: 42 additions & 0 deletions src/cpu/CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,22 @@ void CPUThread::Run()
{
ori(instr);
}
else if (((instr >> 26) & 0x3F) == 25)
{
oris(instr);
}
else if (((instr >> 26) & 0x3F) == 28)
{
andi(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 0)
{
cmp(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 8)
{
subfc(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 20)
{
lwarx(instr);
Expand All @@ -119,6 +131,10 @@ void CPUThread::Run()
{
lwzx(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 28)
{
and_(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 32)
{
cmpl(instr);
Expand All @@ -143,10 +159,22 @@ void CPUThread::Run()
{
stwcx(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 151)
{
stwx(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 178)
{
mtmsrd(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 200)
{
subfze(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 202)
{
addze(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 235)
{
mullw(instr);
Expand Down Expand Up @@ -183,6 +211,10 @@ void CPUThread::Run()
{
mtspr(instr);
}
else if (((instr >> 26) & 0x3F) == 31 && ((instr >> 1) & 0x3FF) == 824)
{
srawi(instr);
}
else if (((instr >> 26) & 0x3F) == 32)
{
lwz(instr);
Expand Down Expand Up @@ -211,6 +243,14 @@ void CPUThread::Run()
{
sth(instr);
}
else if (((instr >> 26) & 0x3F) == 48)
{
lfs(instr);
}
else if (((instr >> 26) & 0x3F) == 52)
{
stfs(instr);
}
else if (((instr >> 26) & 0x3F) == 58)
{
ld(instr);
Expand All @@ -230,6 +270,8 @@ void CPUThread::Dump()
{
for (int i = 0; i < 32; i++)
printf("r%d\t->\t0x%08lx\n", i, state.regs[i]);
for (int i = 0; i < 32; i++)
printf("fr%d\t->\t%0.2f\n", i, state.fr[i].f);
for (int i = 0; i < 7; i++)
printf("cr%d\t->\t%d\n", i, state.GetCR(i));
printf("[%s]\n", state.xer.ca ? "c" : ".");
Expand Down
18 changes: 17 additions & 1 deletion src/cpu/CPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ class XexLoader;
typedef struct
{
uint64_t pc;
uint64_t regs[32]; // These are mostly accessed as single uint32_t registers
uint64_t regs[32];
uint64_t ctr;
uint64_t lr;
uint64_t msr;

union
{
uint32_t u;
float f;
} fr[32];

struct
{
uint32_t cr0;
Expand Down Expand Up @@ -115,16 +121,23 @@ class CPUThread
void rlwimi(uint32_t instruction); // 20
void rlwinm(uint32_t instruction); // 21
void ori(uint32_t instruction); // 24
void oris(uint32_t instruction); // 25
void andi(uint32_t instruction); // 28
void cmp(uint32_t instruction); // 31 0
void subfc(uint32_t instruction); // 31 8
void lwarx(uint32_t instruction); // 31 20
void lwzx(uint32_t instruction); // 31 23
void and_(uint32_t instruction); // 31 28
void cmpl(uint32_t instruction); // 31 32
void subf(uint32_t instruction); // 31 40
void andc(uint32_t instruction); // 31 60
void mfmsr(uint32_t instruction); // 31 83
void subfe(uint32_t instruction); // 31 136
void stwcx(uint32_t instruction); // 31 150
void stwx(uint32_t instruction); // 31 151
void mtmsrd(uint32_t instruction); // 31 178
void subfze(uint32_t instruction); // 31 200
void addze(uint32_t instruction); // 31 202
void mullw(uint32_t instruction); // 31 235
void add(uint32_t instruction); // 31 266
void dcbt(uint32_t instruction); // 31 278
Expand All @@ -133,13 +146,16 @@ class CPUThread
void or_(uint32_t instruction); // 31 444
void divwu(uint32_t instruction); // 31 459
void mtspr(uint32_t instruction); // 31 467
void srawi(uint32_t instruction); // 31 824
void lwz(uint32_t instruction); // 32
void lbz(uint32_t instruction); // 34
void stw(uint32_t instruction); // 36
void stwu(uint32_t instruction); // 37
void stb(uint32_t instruction); // 38
void lhz(uint32_t instruction); // 40
void sth(uint32_t instruction); // 44
void lfs(uint32_t instruction); // 48
void stfs(uint32_t instruction); // 52
void ld(uint32_t instruction); // 58
void std(uint32_t instruction); // 62
private:
Expand Down
Loading

0 comments on commit 502501b

Please sign in to comment.