.include "macros.inc"
.section .text, "ax"
.global __TRK_get_MSR
__TRK_get_MSR:
mfmsr r3
blr
.global __TRK_set_MSR
__TRK_set_MSR:
mtmsr r3
blr
.global TRKValidMemory32
TRKValidMemory32:
mflr r0
stw r0, 4(r1)
stwu r1, -0x18(r1)
stw r31, 0x14(r1)
stw r30, 0x10(r1)
stw r29, 0xc(r1)
mr r30, r5
add r31, r4, r3
addi r31, r31, -1
cmplw r31, r3
li r5, 0x700
bge lbl_8008A480
li r3, 0x700
b lbl_8008A564
lbl_8008A480:
lis r4, gTRKMemMap@ha
addi r4, r4, gTRKMemMap@l
li r6, 0
b lbl_8008A490
lbl_8008A490:
b lbl_8008A494
lbl_8008A494:
lwz r0, 4(r4)
cmplw r3, r0
bgt lbl_8008A560
lwz r0, 0(r4)
cmplw r31, r0
blt lbl_8008A560
clrlwi r0, r30, 0x18
cmplwi r0, 0
bne lbl_8008A4CC
slwi r0, r6, 4
add r4, r4, r0
lwz r0, 8(r4)
cmpwi r0, 0
beq lbl_8008A4F4
lbl_8008A4CC:
clrlwi r0, r30, 0x18
cmplwi r0, 1
bne lbl_8008A4FC
lis r4, gTRKMemMap@ha
addi r4, r4, gTRKMemMap@l
slwi r0, r6, 4
add r4, r4, r0
lwz r0, 0xc(r4)
cmpwi r0, 0
bne lbl_8008A4FC
lbl_8008A4F4:
li r5, 0x700
b lbl_8008A560
lbl_8008A4FC:
lis r4, gTRKMemMap@ha
slwi r29, r6, 4
addi r0, r4, gTRKMemMap@l
add r4, r0, r29
lwz r0, 0(r4)
li r5, 0
cmplw r3, r0
bge lbl_8008A52C
mr r5, r30
subf r4, r3, r0
bl TRKValidMemory32
mr r5, r3
lbl_8008A52C:
cmpwi r5, 0
bne lbl_8008A560
lis r3, gTRKMemMap@ha
addi r0, r3, gTRKMemMap@l
add r3, r0, r29
lwz r3, 4(r3)
cmplw r31, r3
ble lbl_8008A560
mr r5, r30
subf r4, r3, r31
bl TRKValidMemory32
mr r5, r3
b lbl_8008A560
lbl_8008A560:
mr r3, r5
lbl_8008A564:
lwz r31, 0x14(r1)
lwz r30, 0x10(r1)
lwz r29, 0xc(r1)
addi r1, r1, 0x18
lwz r0, 4(r1)
mtlr r0
blr
.global TRK_ppc_memcpy
TRK_ppc_memcpy:
mfmsr r8
li r10, 0
lbl_8008A588:
cmpw r10, r5
beq lbl_8008A5B0
mtmsr r7
sync 0
lbzx r9, r10, r4
mtmsr r6
sync 0
stbx r9, r10, r3
addi r10, r10, 1
b lbl_8008A588
lbl_8008A5B0:
mtmsr r8
sync 0
blr
.global TRKTargetAccessMemory
TRKTargetAccessMemory:
mflr r0
stw r0, 4(r1)
stwu r1, -0x38(r1)
stmw r25, 0x1c(r1)
mr r26, r3
mr r27, r4
mr r28, r5
mr r29, r7
lis r3, gTRKExceptionStatus@ha
addi r5, r3, gTRKExceptionStatus@l
lwz r4, 0(r5)
addi r31, r5, 0xd
lwz r0, 4(r5)
li r30, 0
mr r3, r27
stw r4, 8(r1)
stw r0, 0xc(r1)
lwz r4, 8(r5)
lwz r0, 0xc(r5)
stw r4, 0x10(r1)
stw r0, 0x14(r1)
stb r30, 0(r31)
bl TRKTargetTranslate
cmpwi r29, 0
mr r25, r3
beq lbl_8008A628
b lbl_8008A62C
lbl_8008A628:
li r30, 1
lbl_8008A62C:
lwz r4, 0(r28)
mr r3, r25
mr r5, r30
bl TRKValidMemory32
mr r30, r3
cmpwi r30, 0
beq lbl_8008A654
li r0, 0
stw r0, 0(r28)
b lbl_8008A6C8
lbl_8008A654:
bl __TRK_get_MSR
lis r4, gTRKCPUState@ha
cmpwi r29, 0
addi r4, r4, gTRKCPUState@l
lwz r0, 0x1f8(r4)
mr r8, r3
rlwinm r0, r0, 0, 0x1b, 0x1b
or r7, r8, r0
beq lbl_8008A690
lwz r5, 0(r28)
mr r3, r26
mr r4, r25
mr r6, r8
bl TRK_ppc_memcpy
b lbl_8008A6C8
lbl_8008A690:
lwz r5, 0(r28)
mr r3, r25
mr r4, r26
mr r6, r7
mr r7, r8
bl TRK_ppc_memcpy
mr r3, r25
lwz r4, 0(r28)
bl TRK_flush_cache
cmplw r27, r25
beq lbl_8008A6C8
mr r3, r27
lwz r4, 0(r28)
bl TRK_flush_cache
lbl_8008A6C8:
lbz r0, 0(r31)
cmplwi r0, 0
beq lbl_8008A6E0
li r0, 0
stw r0, 0(r28)
li r30, 0x702
lbl_8008A6E0:
lis r3, gTRKExceptionStatus@ha
lwz r4, 8(r1)
lwz r0, 0xc(r1)
addi r5, r3, gTRKExceptionStatus@l
mr r3, r30
stw r4, 0(r5)
stw r0, 4(r5)
lwz r4, 0x10(r1)
lwz r0, 0x14(r1)
stw r4, 8(r5)
stw r0, 0xc(r5)
lmw r25, 0x1c(r1)
addi r1, r1, 0x38
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetReadInstruction
TRKTargetReadInstruction:
mflr r0
stw r0, 4(r1)
stwu r1, -0x10(r1)
li r0, 4
addi r5, r1, 8
stw r0, 8(r1)
li r6, 0
li r7, 1
bl TRKTargetAccessMemory
cmpwi r3, 0
bne lbl_8008A75C
lwz r0, 8(r1)
cmplwi r0, 4
beq lbl_8008A75C
li r3, 0x700
lbl_8008A75C:
addi r1, r1, 0x10
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetAccessDefault
TRKTargetAccessDefault:
mflr r0
stw r0, 4(r1)
stwu r1, -0x20(r1)
stw r31, 0x1c(r1)
stw r30, 0x18(r1)
mr r31, r6
cmplwi r4, 0x24
ble lbl_8008A794
li r3, 0x701
b lbl_8008A850
lbl_8008A794:
lis r6, gTRKExceptionStatus@ha
cmpwi r7, 0
addi r8, r6, gTRKExceptionStatus@l
lwz r0, 0(r8)
subf r4, r3, r4
lwz r7, 4(r8)
addi r9, r4, 1
lis r4, gTRKCPUState@ha
stw r0, 8(r1)
addi r0, r4, gTRKCPUState@l
slwi r3, r3, 2
addi r30, r8, 0xd
stw r7, 0xc(r1)
add r4, r0, r3
lwz r7, 8(r8)
li r6, 0
lwz r3, 0xc(r8)
slwi r0, r9, 2
stw r7, 0x10(r1)
mr r7, r9
stw r3, 0x14(r1)
stb r6, 0(r30)
stw r0, 0(r31)
beq lbl_8008A804
mr r3, r5
mr r5, r7
bl TRKAppendBuffer_ui32
b lbl_8008A810
lbl_8008A804:
mr r3, r5
mr r5, r7
bl TRKReadBuffer_ui32
lbl_8008A810:
lbz r0, 0(r30)
cmplwi r0, 0
beq lbl_8008A828
li r0, 0
stw r0, 0(r31)
li r3, 0x702
lbl_8008A828:
lis r5, gTRKExceptionStatus@ha
lwz r4, 8(r1)
lwz r0, 0xc(r1)
addi r5, r5, gTRKExceptionStatus@l
stw r4, 0(r5)
stw r0, 4(r5)
lwz r4, 0x10(r1)
lwz r0, 0x14(r1)
stw r4, 8(r5)
stw r0, 0xc(r5)
lbl_8008A850:
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
addi r1, r1, 0x20
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetAccessFP
TRKTargetAccessFP:
mflr r0
stw r0, 4(r1)
stwu r1, -0x40(r1)
stmw r25, 0x24(r1)
mr r25, r3
mr r28, r4
mr r29, r5
mr r30, r6
mr r31, r7
cmplwi r28, 0x21
ble lbl_8008A89C
li r3, 0x701
b lbl_8008A99C
lbl_8008A89C:
lis r3, gTRKExceptionStatus@ha
addi r4, r3, gTRKExceptionStatus@l
lwz r3, 0(r4)
addi r26, r4, 0xd
lwz r0, 4(r4)
li r27, 0
stw r3, 8(r1)
stw r0, 0xc(r1)
lwz r3, 8(r4)
lwz r0, 0xc(r4)
stw r3, 0x10(r1)
stw r0, 0x14(r1)
stb r27, 0(r26)
bl __TRK_get_MSR
ori r3, r3, 0x2000
bl __TRK_set_MSR
stw r27, 0(r30)
mr r27, r25
li r3, 0
b lbl_8008A8EC
lbl_8008A8EC:
b lbl_8008A8F0
lbl_8008A8F0:
b lbl_8008A94C
lbl_8008A8F4:
cmpwi r31, 0
beq lbl_8008A920
mr r4, r27
addi r3, r1, 0x18
mr r5, r31
bl TRKPPCAccessFPRegister
lwz r5, 0x18(r1)
mr r3, r29
lwz r6, 0x1c(r1)
bl TRKAppendBuffer1_ui64
b lbl_8008A93C
lbl_8008A920:
mr r3, r29
addi r4, r1, 0x18
bl TRKReadBuffer1_ui64
mr r4, r27
addi r3, r1, 0x18
mr r5, r31
bl TRKPPCAccessFPRegister
lbl_8008A93C:
lwz r4, 0(r30)
addi r27, r27, 1
addi r0, r4, 8
stw r0, 0(r30)
lbl_8008A94C:
cmplw r27, r28
bgt lbl_8008A95C
cmpwi r3, 0
beq lbl_8008A8F4
lbl_8008A95C:
lbz r0, 0(r26)
cmplwi r0, 0
beq lbl_8008A974
li r0, 0
stw r0, 0(r30)
li r3, 0x702
lbl_8008A974:
lis r5, gTRKExceptionStatus@ha
lwz r4, 8(r1)
lwz r0, 0xc(r1)
addi r5, r5, gTRKExceptionStatus@l
stw r4, 0(r5)
stw r0, 4(r5)
lwz r4, 0x10(r1)
lwz r0, 0x14(r1)
stw r4, 8(r5)
stw r0, 0xc(r5)
lbl_8008A99C:
lmw r25, 0x24(r1)
addi r1, r1, 0x40
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetAccessExtended1
TRKTargetAccessExtended1:
mflr r0
stw r0, 4(r1)
stwu r1, -0x20(r1)
stw r31, 0x1c(r1)
stw r30, 0x18(r1)
mr r30, r6
cmplwi r4, 0x60
ble lbl_8008A9D8
li r3, 0x701
b lbl_8008AB10
lbl_8008A9D8:
lis r6, gTRKExceptionStatus@ha
cmplw r3, r4
addi r9, r6, gTRKExceptionStatus@l
lwz r8, 0(r9)
addi r31, r9, 0xd
lwz r6, 4(r9)
li r0, 0
stw r8, 8(r1)
stw r6, 0xc(r1)
lwz r8, 8(r9)
lwz r6, 0xc(r9)
stw r8, 0x10(r1)
stw r6, 0x14(r1)
stb r0, 0(r31)
stw r0, 0(r30)
bgt lbl_8008AAD0
subf r4, r3, r4
lwz r0, 0(r30)
addi r8, r4, 1
cmpwi r7, 0
slwi r6, r8, 2
lis r4, gTRKCPUState@ha
add r0, r0, r6
stw r0, 0(r30)
addi r7, r4, gTRKCPUState@l
slwi r0, r3, 2
add r4, r7, r0
addi r4, r4, 0x1a8
beq lbl_8008AA5C
mr r3, r5
mr r5, r8
bl TRKAppendBuffer_ui32
b lbl_8008AAD0
lbl_8008AA5C:
addi r0, r7, 0x1ec
cmplw r4, r0
bgt lbl_8008AA8C
addi r3, r6, -4
addi r0, r7, 0x1e8
add r3, r4, r3
cmplw r3, r0
blt lbl_8008AA8C
lis r3, gTRKRestoreFlags@ha
addi r3, r3, gTRKRestoreFlags@l
li r0, 1
stb r0, 0(r3)
lbl_8008AA8C:
lis r3, gTRKCPUState@ha
addi r3, r3, gTRKCPUState@l
addi r6, r3, 0x278
cmplw r4, r6
bgt lbl_8008AAC4
slwi r3, r8, 2
addi r0, r3, -4
add r0, r4, r0
cmplw r0, r6
blt lbl_8008AAC4
lis r3, gTRKRestoreFlags@ha
addi r3, r3, gTRKRestoreFlags@l
li r0, 1
stb r0, 1(r3)
lbl_8008AAC4:
mr r3, r5
mr r5, r8
bl TRKReadBuffer_ui32
lbl_8008AAD0:
lbz r0, 0(r31)
cmplwi r0, 0
beq lbl_8008AAE8
li r0, 0
stw r0, 0(r30)
li r3, 0x702
lbl_8008AAE8:
lis r5, gTRKExceptionStatus@ha
lwz r4, 8(r1)
lwz r0, 0xc(r1)
addi r5, r5, gTRKExceptionStatus@l
stw r4, 0(r5)
stw r0, 4(r5)
lwz r4, 0x10(r1)
lwz r0, 0x14(r1)
stw r4, 8(r5)
stw r0, 0xc(r5)
lbl_8008AB10:
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
addi r1, r1, 0x20
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetAccessExtended2
TRKTargetAccessExtended2:
mflr r0
stw r0, 4(r1)
stwu r1, -0x40(r1)
stmw r25, 0x24(r1)
mr r25, r3
mr r27, r4
mr r28, r5
mr r29, r6
mr r30, r7
cmplwi r27, 0x1f
ble lbl_8008AB5C
li r3, 0x701
b lbl_8008AC90
lbl_8008AB5C:
lis r4, gTRKExceptionStatus@ha
addi r3, r1, 8
addi r7, r4, gTRKExceptionStatus@l
lwz r5, 0(r7)
addi r31, r7, 0xd
lwz r0, 4(r7)
li r26, 0
li r4, 0x398
stw r5, 0xc(r1)
li r5, 1
stw r0, 0x10(r1)
lwz r6, 8(r7)
lwz r0, 0xc(r7)
stw r6, 0x14(r1)
stw r0, 0x18(r1)
stb r26, 0(r31)
bl TRKPPCAccessSPR
lwz r0, 8(r1)
addi r3, r1, 8
li r4, 0x398
oris r0, r0, 0xa000
stw r0, 8(r1)
li r5, 0
bl TRKPPCAccessSPR
stw r26, 8(r1)
addi r3, r1, 8
li r4, 0x390
li r5, 0
bl TRKPPCAccessSPR
stw r26, 0(r29)
mr r26, r25
li r3, 0
b lbl_8008ABE0
lbl_8008ABE0:
b lbl_8008ABE4
lbl_8008ABE4:
b lbl_8008AC40
lbl_8008ABE8:
cmpwi r30, 0
beq lbl_8008AC14
mr r4, r26
addi r3, r1, 0x1c
mr r5, r30
bl TRKPPCAccessPairedSingleRegister
lwz r5, 0x1c(r1)
mr r3, r28
lwz r6, 0x20(r1)
bl TRKAppendBuffer1_ui64
b lbl_8008AC30
lbl_8008AC14:
mr r3, r28
addi r4, r1, 0x1c
bl TRKReadBuffer1_ui64
mr r4, r26
addi r3, r1, 0x1c
mr r5, r30
bl TRKPPCAccessPairedSingleRegister
lbl_8008AC30:
lwz r4, 0(r29)
addi r26, r26, 1
addi r0, r4, 8
stw r0, 0(r29)
lbl_8008AC40:
cmplw r26, r27
bgt lbl_8008AC50
cmpwi r3, 0
beq lbl_8008ABE8
lbl_8008AC50:
lbz r0, 0(r31)
cmplwi r0, 0
beq lbl_8008AC68
li r0, 0
stw r0, 0(r29)
li r3, 0x702
lbl_8008AC68:
lis r5, gTRKExceptionStatus@ha
lwz r4, 0xc(r1)
lwz r0, 0x10(r1)
addi r5, r5, gTRKExceptionStatus@l
stw r4, 0(r5)
stw r0, 4(r5)
lwz r4, 0x14(r1)
lwz r0, 0x18(r1)
stw r4, 8(r5)
stw r0, 0xc(r5)
lbl_8008AC90:
lmw r25, 0x24(r1)
addi r1, r1, 0x40
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetVersions
TRKTargetVersions:
li r0, 0
stb r0, 0(r3)
li r0, 8
li r4, 1
stb r0, 1(r3)
li r0, 0xa
stb r4, 2(r3)
stb r0, 3(r3)
li r3, 0
blr
.global TRKTargetSupportMask
TRKTargetSupportMask:
li r0, 0x7a
stb r0, 0(r3)
li r7, 0
li r0, 0x4f
stb r7, 1(r3)
li r6, 7
li r5, 1
stb r0, 2(r3)
li r4, 3
li r0, 0x80
stb r6, 3(r3)
stb r7, 4(r3)
stb r7, 5(r3)
stb r7, 6(r3)
stb r7, 7(r3)
stb r7, 8(r3)
stb r7, 9(r3)
stb r7, 0xa(r3)
stb r7, 0xb(r3)
stb r7, 0xc(r3)
stb r7, 0xd(r3)
stb r7, 0xe(r3)
stb r7, 0xf(r3)
stb r5, 0x10(r3)
stb r7, 0x11(r3)
stb r4, 0x12(r3)
stb r7, 0x13(r3)
stb r7, 0x14(r3)
stb r7, 0x15(r3)
stb r7, 0x16(r3)
stb r7, 0x17(r3)
stb r7, 0x18(r3)
stb r7, 0x19(r3)
stb r4, 0x1a(r3)
stb r7, 0x1b(r3)
stb r7, 0x1c(r3)
stb r7, 0x1d(r3)
stb r7, 0x1e(r3)
stb r0, 0x1f(r3)
li r3, 0
blr
.global TRKTargetCPUType
TRKTargetCPUType:
mflr r0
stw r0, 4(r1)
stwu r1, -0x10(r1)
stw r31, 0xc(r1)
mr r31, r3
li r0, 0
stb r0, 0(r31)
bl TRKTargetCPUMinorType
stb r3, 1(r31)
lis r3, gTRKBigEndian@ha
addi r3, r3, gTRKBigEndian@l
lwz r3, 0(r3)
li r4, 4
li r0, 8
clrlwi r3, r3, 0x18
stb r3, 2(r31)
li r3, 0
stb r4, 3(r31)
stb r0, 4(r31)
stb r4, 5(r31)
stb r0, 6(r31)
lwz r31, 0xc(r1)
addi r1, r1, 0x10
lwz r0, 4(r1)
mtlr r0
blr
.global TRKInterruptHandler
TRKInterruptHandler:
mtspr 0x1a, r2
mtspr 0x1b, r4
mfspr r4, 0x113
mfcr r2
mtspr 0x113, r2
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
lwz r2, 0x8c(r2)
ori r2, r2, 0x8002
xori r2, r2, 0x8002
sync 0
mtmsr r2
sync 0
lis r2, TRK_saved_exceptionID@h
ori r2, r2, TRK_saved_exceptionID@l
sth r3, 0x0(r2)
cmpwi r3, 0x500
bne lbl_8008AEA0
lis r2, gTRKCPUState@h
ori r2, r2, gTRKCPUState@l
mflr r3
stw r3, 0x42c(r2)
bl TRKUARTInterruptHandler
lis r2, gTRKCPUState@h
ori r2, r2, gTRKCPUState@l
lwz r3, 0x42c(r2)
mtlr r3
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
lwz r2, 0xa0(r2)
lbz r2, 0x0(r2)
cmpwi r2, 0
beq lbl_8008AE84
lis r2, gTRKExceptionStatus@h
ori r2, r2, gTRKExceptionStatus@l
lbz r2, 0xc(r2)
cmpwi r2, 1
beq lbl_8008AE84
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
li r3, 1
stb r3, 0x9c(r2)
b lbl_8008AEA0
lbl_8008AE84:
lis r2, gTRKSaveState@h
ori r2, r2, gTRKSaveState@l
lwz r3, 0x88(r2)
mtcrf 0xff, r3
lwz r3, 0xc(r2)
lwz r2, 0x8(r2)
rfi
lbl_8008AEA0:
lis r2, TRK_saved_exceptionID@h
ori r2, r2, TRK_saved_exceptionID@l
lhz r3, 0x0(r2)
lis r2, gTRKExceptionStatus@h
ori r2, r2, gTRKExceptionStatus@l
lbz r2, 0xc(r2)
cmpwi r2, 0
bne TRKExceptionHandler
lis r2, gTRKCPUState@h
ori r2, r2, gTRKCPUState@l
stw r0, 0x0(r2)
stw r1, 0x4(r2)
mfspr r0, 0x111
stw r0, 0x8(r2)
sth r3, 0x2f8(r2)
sth r3, 0x2fa(r2)
mfspr r0, 0x112
stw r0, 0xc(r2)
stmw r4, 0x10(r2)
mfspr r27, 0x1a
mflr r28
mfspr r29, 0x113
mfctr r30
mfxer r31
stmw r27, 0x80(r2)
bl TRKSaveExtended1Block
lis r2, gTRKExceptionStatus@h
ori r2, r2, gTRKExceptionStatus@l
li r3, 1
stb r3, 0xc(r2)
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
lwz r0, 0x8c(r2)
sync 0
mtmsr r0
sync 0
lwz r0, 0x80(r2)
mtlr r0
lwz r0, 0x84(r2)
mtctr r0
lwz r0, 0x88(r2)
mtxer r0
lwz r0, 0x94(r2)
mtdsisr r0
lwz r0, 0x90(r2)
mtdar r0
lmw r3, 0xc(r2)
lwz r0, 0x0(r2)
lwz r1, 0x4(r2)
lwz r2, 0x8(r2)
b TRKPostInterruptEvent
.global TRKExceptionHandler
TRKExceptionHandler:
lis r2, gTRKExceptionStatus@h
ori r2, r2, gTRKExceptionStatus@l
sth r3, 0x8(r2)
mfspr r3, 0x1a
stw r3, 0x0(r2)
lhz r3, 0x8(r2)
cmpwi r3, 0x200
beq lbl_8008AFD8
cmpwi r3, 0x300
beq lbl_8008AFD8
cmpwi r3, 0x400
beq lbl_8008AFD8
cmpwi r3, 0x600
beq lbl_8008AFD8
cmpwi r3, 0x700
beq lbl_8008AFD8
cmpwi r3, 0x800
beq lbl_8008AFD8
cmpwi r3, 0x1000
beq lbl_8008AFD8
cmpwi r3, 0x1100
beq lbl_8008AFD8
cmpwi r3, 0x1200
beq lbl_8008AFD8
cmpwi r3, 0x1300
beq lbl_8008AFD8
b lbl_8008AFE4
lbl_8008AFD8:
mfspr r3, 0x1a
addi r3, r3, 4
mtspr 0x1a, r3
lbl_8008AFE4:
lis r2, gTRKExceptionStatus@h
ori r2, r2, gTRKExceptionStatus@l
li r3, 1
stb r3, 0xd(r2)
mfspr r3, 0x113
mtcrf 0xff, r3
mfspr r2, 0x111
mfspr r3, 0x112
rfi
.global TRKPostInterruptEvent
TRKPostInterruptEvent:
mflr r0
stw r0, 4(r1)
stwu r1, -0x18(r1)
lis r3, gTRKState@ha
addi r3, r3, gTRKState@l
addi r3, r3, 0x9c
lwz r0, 0(r3)
cmpwi r0, 0
beq lbl_8008B038
li r0, 0
stw r0, 0(r3)
b lbl_8008B0A8
lbl_8008B038:
lis r3, gTRKCPUState@ha
addi r3, r3, gTRKCPUState@l
lwz r0, 0x2f8(r3)
clrlwi r0, r0, 0x10
cmpwi r0, 0xd00
beq lbl_8008B060
bge lbl_8008B094
cmpwi r0, 0x700
beq lbl_8008B060
b lbl_8008B094
lbl_8008B060:
lis r4, gTRKCPUState@ha
addi r3, r1, 8
addi r4, r4, gTRKCPUState@l
lwz r4, 0x80(r4)
bl TRKTargetReadInstruction
lwz r3, 8(r1)
addis r0, r3, 0xf020
cmplwi r0, 0
bne lbl_8008B08C
li r4, 5
b lbl_8008B098
lbl_8008B08C:
li r4, 3
b lbl_8008B098
lbl_8008B094:
li r4, 4
lbl_8008B098:
addi r3, r1, 0xc
bl TRKConstructEvent
addi r3, r1, 0xc
bl TRKPostEvent
lbl_8008B0A8:
addi r1, r1, 0x18
lwz r0, 4(r1)
mtlr r0
blr
.global TRKSwapAndGo
TRKSwapAndGo:
lis r3, gTRKState@h
ori r3, r3, gTRKState@l
stmw r0, 0(r3)
mfmsr r0
stw r0, 0x8c(r3)
mflr r0
stw r0, 0x80(r3)
mfctr r0
stw r0, 0x84(r3)
mfxer r0
stw r0, 0x88(r3)
mfdsisr r0
stw r0, 0x94(r3)
mfdar r0
stw r0, 0x90(r3)
li r1, -32766
nor r1, r1, r1
mfmsr r3
and r3, r3, r1
mtmsr r3
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
lwz r2, 0xa0(r2)
lbz r2, 0x0(r2)
cmpwi r2, 0
beq lbl_8008B134
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
li r3, 1
stb r3, 0x9c(r2)
b TRKInterruptHandlerEnableInterrupts
lbl_8008B134:
lis r2, gTRKExceptionStatus@h
ori r2, r2, gTRKExceptionStatus@l
li r3, 0
stb r3, 0xc(r2)
bl TRKRestoreExtended1Block
lis r2, gTRKCPUState@h
ori r2, r2, gTRKCPUState@l
lmw r27, 0x80(r2)
mtspr 0x1a, r27
mtlr r28
mtcrf 0xff, r29
mtctr r30
mtxer r31
lmw r3, 0xc(r2)
lwz r0, 0x0(r2)
lwz r1, 0x4(r2)
lwz r2, 0x8(r2)
rfi
.global TRKInterruptHandlerEnableInterrupts
TRKInterruptHandlerEnableInterrupts:
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
lwz r0, 0x8c(r2)
sync 0
mtmsr r0
sync 0
lwz r0, 0x80(r2)
mtlr r0
lwz r0, 0x84(r2)
mtctr r0
lwz r0, 0x88(r2)
mtxer r0
lwz r0, 0x94(r2)
mtdsisr r0
lwz r0, 0x90(r2)
mtdar r0
lmw r3, 0xc(r2)
lwz r0, 0x0(r2)
lwz r1, 0x4(r2)
lwz r2, 0x8(r2)
b TRKPostInterruptEvent
.global TRKTargetInterrupt
TRKTargetInterrupt:
mflr r0
stw r0, 4(r1)
stwu r1, -0x10(r1)
stw r31, 0xc(r1)
lbz r0, 0(r3)
li r31, 0
cmpwi r0, 5
bge lbl_8008B21C
cmpwi r0, 3
bge lbl_8008B1FC
b lbl_8008B21C
lbl_8008B1FC:
bl TRKTargetCheckStep
cmpwi r3, 0
bne lbl_8008B21C
li r3, 1
bl TRKTargetSetStopped
li r3, 0x90
bl TRKDoNotifyStopped
mr r31, r3
lbl_8008B21C:
mr r3, r31
lwz r31, 0xc(r1)
addi r1, r1, 0x10
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetAddStopInfo
TRKTargetAddStopInfo:
mflr r0
stw r0, 4(r1)
stwu r1, -0x18(r1)
stw r31, 0x14(r1)
stw r30, 0x10(r1)
mr r30, r3
lis r3, gTRKCPUState@ha
addi r3, r3, gTRKCPUState@l
addi r31, r3, 0x80
lwz r4, 0(r31)
mr r3, r30
bl TRKAppendBuffer1_ui32
cmpwi r3, 0
bne lbl_8008B278
addi r3, r1, 8
lwz r4, 0(r31)
bl TRKTargetReadInstruction
lbl_8008B278:
cmpwi r3, 0
bne lbl_8008B28C
mr r3, r30
lwz r4, 8(r1)
bl TRKAppendBuffer1_ui32
lbl_8008B28C:
cmpwi r3, 0
bne lbl_8008B2AC
lis r3, gTRKCPUState@ha
addi r3, r3, gTRKCPUState@l
lwz r0, 0x2f8(r3)
mr r3, r30
clrlwi r4, r0, 0x10
bl TRKAppendBuffer1_ui16
lbl_8008B2AC:
lwz r31, 0x14(r1)
lwz r30, 0x10(r1)
addi r1, r1, 0x18
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetAddExceptionInfo
TRKTargetAddExceptionInfo:
mflr r0
stw r0, 4(r1)
stwu r1, -0x18(r1)
stw r31, 0x14(r1)
stw r30, 0x10(r1)
mr r30, r3
lis r3, gTRKExceptionStatus@ha
addi r31, r3, gTRKExceptionStatus@l
lwz r4, 0(r31)
mr r3, r30
bl TRKAppendBuffer1_ui32
cmpwi r3, 0
bne lbl_8008B304
addi r3, r1, 8
lwz r4, 0(r31)
bl TRKTargetReadInstruction
lbl_8008B304:
cmpwi r3, 0
bne lbl_8008B318
mr r3, r30
lwz r4, 8(r1)
bl TRKAppendBuffer1_ui32
lbl_8008B318:
cmpwi r3, 0
bne lbl_8008B334
lis r3, gTRKExceptionStatus@ha
addi r3, r3, gTRKExceptionStatus@l
lhz r4, 8(r3)
mr r3, r30
bl TRKAppendBuffer1_ui16
lbl_8008B334:
lwz r31, 0x14(r1)
lwz r30, 0x10(r1)
addi r1, r1, 0x18
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetEnableTrace
TRKTargetEnableTrace:
cmpwi r3, 0
beq lbl_8008B36C
lis r3, gTRKCPUState@ha
addi r3, r3, gTRKCPUState@l
lwz r0, 0x1f8(r3)
ori r0, r0, 0x400
stw r0, 0x1f8(r3)
b lbl_8008B380
lbl_8008B36C:
lis r3, gTRKCPUState@ha
addi r3, r3, gTRKCPUState@l
lwz r0, 0x1f8(r3)
rlwinm r0, r0, 0, 0x16, 0x14
stw r0, 0x1f8(r3)
lbl_8008B380:
li r3, 0
blr
.global TRKTargetStepDone
TRKTargetStepDone:
lis r3, gTRKStepStatus@ha
addi r5, r3, gTRKStepStatus@l
lwz r0, 0(r5)
li r3, 1
cmpwi r0, 0
beq lbl_8008B408
lis r4, gTRKCPUState@ha
addi r4, r4, gTRKCPUState@l
lwz r0, 0x2f8(r4)
clrlwi r0, r0, 0x10
cmplwi r0, 0xd00
bne lbl_8008B408
lbz r0, 4(r5)
cmpwi r0, 1
beq lbl_8008B3E8
bge lbl_8008B408
cmpwi r0, 0
bge lbl_8008B3D4
b lbl_8008B408
lbl_8008B3D4:
lwz r0, 8(r5)
cmplwi r0, 0
beq lbl_8008B408
li r3, 0
b lbl_8008B408
lbl_8008B3E8:
lwz r4, 0x80(r4)
lwz r0, 0xc(r5)
cmplw r4, r0
blt lbl_8008B408
lwz r0, 0x10(r5)
cmplw r4, r0
bgt lbl_8008B408
li r3, 0
lbl_8008B408:
blr
.global TRKTargetDoStep
TRKTargetDoStep:
mflr r0
stw r0, 4(r1)
stwu r1, -0x10(r1)
stw r31, 0xc(r1)
lis r3, gTRKStepStatus@ha
addi r31, r3, gTRKStepStatus@l
li r0, 1
stw r0, 0(r31)
li r3, 1
bl TRKTargetEnableTrace
lbz r0, 4(r31)
cmplwi r0, 0
beq lbl_8008B448
cmplwi r0, 0x10
bne lbl_8008B45C
lbl_8008B448:
lis r3, gTRKStepStatus@ha
addi r4, r3, gTRKStepStatus@l
lwz r3, 8(r4)
addi r0, r3, -1
stw r0, 8(r4)
lbl_8008B45C:
li r3, 0
bl TRKTargetSetStopped
li r3, 0
lwz r31, 0xc(r1)
addi r1, r1, 0x10
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetCheckStep
TRKTargetCheckStep:
mflr r0
stw r0, 4(r1)
stwu r1, -0x10(r1)
stw r31, 0xc(r1)
lis r3, gTRKStepStatus@ha
addi r31, r3, gTRKStepStatus@l
lwz r0, 0(r31)
cmpwi r0, 0
beq lbl_8008B4C4
li r3, 0
bl TRKTargetEnableTrace
bl TRKTargetStepDone
cmpwi r3, 0
beq lbl_8008B4C0
li r0, 0
stw r0, 0(r31)
b lbl_8008B4C4
lbl_8008B4C0:
bl TRKTargetDoStep
lbl_8008B4C4:
lis r3, gTRKStepStatus@ha
addi r3, r3, gTRKStepStatus@l
lwz r3, 0(r3)
lwz r31, 0xc(r1)
addi r1, r1, 0x10
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetSingleStep
TRKTargetSingleStep:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
cmpwi r4, 0
beq lbl_8008B500
li r3, 0x703
b lbl_8008B518
lbl_8008B500:
lis r4, gTRKStepStatus@ha
addi r4, r4, gTRKStepStatus@l
li r0, 0
stb r0, 4(r4)
stw r3, 8(r4)
bl TRKTargetDoStep
lbl_8008B518:
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetStepOutOfRange
TRKTargetStepOutOfRange:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
cmpwi r5, 0
beq lbl_8008B544
li r3, 0x703
b lbl_8008B560
lbl_8008B544:
lis r5, gTRKStepStatus@ha
addi r5, r5, gTRKStepStatus@l
li r0, 1
stb r0, 4(r5)
stw r3, 0xc(r5)
stw r4, 0x10(r5)
bl TRKTargetDoStep
lbl_8008B560:
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetGetPC
TRKTargetGetPC:
lis r3, gTRKCPUState@ha
addi r3, r3, gTRKCPUState@l
lwz r3, 0x80(r3)
blr
.global TRKTargetSupportRequest
TRKTargetSupportRequest:
mflr r0
stw r0, 4(r1)
stwu r1, -0x30(r1)
stmw r27, 0x1c(r1)
lis r3, gTRKCPUState@ha
addi r3, r3, gTRKCPUState@l
addi r31, r3, 0xc
lwz r0, 0(r31)
clrlwi r27, r0, 0x18
cmplwi r27, 0xd1
beq lbl_8008B5D0
cmplwi r27, 0xd0
beq lbl_8008B5D0
addi r3, r1, 0xc
li r4, 4
bl TRKConstructEvent
addi r3, r1, 0xc
bl TRKPostEvent
li r3, 0
b lbl_8008B65C
lbl_8008B5D0:
lis r3, gTRKCPUState@ha
addi r6, r1, 8
addi r4, r3, gTRKCPUState@l
lwz r3, 0x10(r4)
subfic r0, r27, 0xd1
lwz r28, 0x14(r4)
addi r30, r4, 0x18
cntlzw r0, r0
lwz r4, 0(r30)
clrlwi r3, r3, 0x18
mr r5, r28
srwi r8, r0, 5
li r7, 1
bl TRKSuppAccessFile
lbz r0, 8(r1)
mr r29, r3
cmplwi r0, 0
bne lbl_8008B628
cmpwi r29, 0
beq lbl_8008B628
li r0, 1
stb r0, 8(r1)
lbl_8008B628:
lbz r0, 8(r1)
cmplwi r27, 0xd1
stw r0, 0(r31)
bne lbl_8008B644
lwz r3, 0(r30)
lwz r4, 0(r28)
bl TRK_flush_cache
lbl_8008B644:
lis r3, gTRKCPUState@ha
addi r5, r3, gTRKCPUState@l
lwz r4, 0x80(r5)
mr r3, r29
addi r0, r4, 4
stw r0, 0x80(r5)
lbl_8008B65C:
lmw r27, 0x1c(r1)
addi r1, r1, 0x30
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetFlushCache
TRKTargetFlushCache:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
cmplw r4, r5
bge lbl_8008B698
mr r3, r4
subf r4, r4, r5
bl TRK_flush_cache
li r3, 0
b lbl_8008B69C
lbl_8008B698:
li r3, 0x700
lbl_8008B69C:
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetStopped
TRKTargetStopped:
lis r3, gTRKState@ha
addi r3, r3, gTRKState@l
lwz r3, 0x98(r3)
blr
.global TRKTargetSetStopped
TRKTargetSetStopped:
lis r4, gTRKState@ha
addi r4, r4, gTRKState@l
stw r3, 0x98(r4)
blr
.global TRKTargetStop
TRKTargetStop:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
li r3, 1
bl TRKTargetSetStopped
li r3, 0
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global TRKPPCAccessSPR
TRKPPCAccessSPR:
mflr r0
stw r0, 4(r1)
stwu r1, -0x20(r1)
lis r6, "@233"@ha
cmpwi r5, 0
addi r7, r6, "@233"@l
lwz r6, 0(r7)
lwz r0, 4(r7)
stw r6, 8(r1)
stw r0, 0xc(r1)
lwz r6, 8(r7)
lwz r0, 0xc(r7)
stw r6, 0x10(r1)
stw r0, 0x14(r1)
lwz r0, 0x10(r7)
stw r0, 0x18(r1)
beq lbl_8008B764
rlwinm r0, r4, 0, 0x14, 0x1a
slwi r6, r0, 6
clrlwi r0, r4, 0x1b
oris r4, r6, 0x7c80
slwi r0, r0, 0x10
or r0, r4, r0
ori r0, r0, 0x2a6
stw r0, 8(r1)
lis r0, 0x9083
stw r0, 0xc(r1)
b lbl_8008B78C
lbl_8008B764:
rlwinm r0, r4, 0, 0x14, 0x1a
slwi r6, r0, 6
clrlwi r0, r4, 0x1b
lis r7, 0x8083
oris r4, r6, 0x7c80
stw r7, 8(r1)
slwi r0, r0, 0x10
or r0, r4, r0
ori r0, r0, 0x3a6
stw r0, 0xc(r1)
lbl_8008B78C:
addi r4, r1, 8
bl TRKPPCAccessSpecialReg
addi r1, r1, 0x20
lwz r0, 4(r1)
mtlr r0
blr
.global TRKPPCAccessPairedSingleRegister
TRKPPCAccessPairedSingleRegister:
mflr r0
stw r0, 4(r1)
stwu r1, -0x20(r1)
lis r6, "@238"@ha
cmpwi r5, 0
addi r7, r6, "@238"@l
lwz r6, 0(r7)
lwz r0, 4(r7)
stw r6, 8(r1)
stw r0, 0xc(r1)
lwz r6, 8(r7)
lwz r0, 0xc(r7)
stw r6, 0x10(r1)
stw r0, 0x14(r1)
lwz r0, 0x10(r7)
stw r0, 0x18(r1)
beq lbl_8008B7F8
slwi r0, r4, 0x15
oris r0, r0, 0xf003
stw r0, 8(r1)
b lbl_8008B804
lbl_8008B7F8:
slwi r0, r4, 0x15
oris r0, r0, 0xe003
stw r0, 8(r1)
lbl_8008B804:
addi r4, r1, 8
bl TRKPPCAccessSpecialReg
addi r1, r1, 0x20
lwz r0, 4(r1)
mtlr r0
blr
.global TRKPPCAccessFPRegister
TRKPPCAccessFPRegister:
mflr r0
stw r0, 4(r1)
stwu r1, -0x28(r1)
stw r31, 0x24(r1)
stw r30, 0x20(r1)
mr r30, r3
mr r31, r5
lis r3, "@243"@ha
cmplwi r4, 0x20
addi r6, r3, "@243"@l
lwz r5, 0(r6)
li r3, 0
lwz r0, 4(r6)
stw r5, 8(r1)
stw r0, 0xc(r1)
lwz r5, 8(r6)
lwz r0, 0xc(r6)
stw r5, 0x10(r1)
stw r0, 0x14(r1)
lwz r0, 0x10(r6)
stw r0, 0x18(r1)
bge lbl_8008B8AC
cmpwi r31, 0
beq lbl_8008B88C
slwi r0, r4, 0x15
oris r0, r0, 0xd803
stw r0, 8(r1)
b lbl_8008B898
lbl_8008B88C:
slwi r0, r4, 0x15
oris r0, r0, 0xc803
stw r0, 8(r1)
lbl_8008B898:
mr r3, r30
addi r4, r1, 8
mr r5, r31
bl TRKPPCAccessSpecialReg
b lbl_8008B984
lbl_8008B8AC:
bne lbl_8008B938
cmpwi r31, 0
beq lbl_8008B8E0
lis r0, 0xd824
lis r3, 0xFC20048E@ha
stw r0, 8(r1)
addi r0, r3, 0xFC20048E@l
stw r0, 0xc(r1)
lis r3, 0xd823
lis r0, 0xc824
stw r3, 0x10(r1)
stw r0, 0x14(r1)
b lbl_8008B904
lbl_8008B8E0:
lis r0, 0xd824
stw r0, 8(r1)
lis r0, 0xc823
lis r3, 0xFDFE0D8E@ha
stw r0, 0xc(r1)
addi r3, r3, 0xFDFE0D8E@l
lis r0, 0xc824
stw r3, 0x10(r1)
stw r0, 0x14(r1)
lbl_8008B904:
mr r3, r30
addi r4, r1, 8
mr r5, r31
bl TRKPPCAccessSpecialReg
lwz r6, 4(r30)
li r0, -1
lwz r5, 0(r30)
li r4, 0
and r0, r6, r0
stw r0, 4(r30)
and r0, r5, r4
stw r0, 0(r30)
b lbl_8008B984
lbl_8008B938:
cmplwi r4, 0x21
bne lbl_8008B984
cmpwi r31, 0
bne lbl_8008B950
lwz r0, 4(r30)
stw r0, 0(r30)
lbl_8008B950:
mr r3, r30
mr r5, r31
li r4, 0x3fe
bl TRKPPCAccessSPR
cmpwi r31, 0
beq lbl_8008B984
lwz r5, 0(r30)
li r0, -1
li r4, 0
and r0, r5, r0
stw r0, 4(r30)
and r0, r4, r4
stw r0, 0(r30)
lbl_8008B984:
lwz r31, 0x24(r1)
lwz r30, 0x20(r1)
addi r1, r1, 0x28
lwz r0, 4(r1)
mtlr r0
blr
.global TRKPPCAccessSpecialReg
TRKPPCAccessSpecialReg:
mflr r0
stw r0, 4(r1)
stwu r1, -0x10(r1)
stw r31, 0xc(r1)
stw r30, 8(r1)
mr r30, r3
mr r31, r4
lis r3, 0x4E800020@ha
addi r0, r3, 0x4E800020@l
stw r0, 0x10(r31)
mr r3, r31
li r4, 0x14
bl TRK_flush_cache
lis r3, TRKvalue128_temp@ha
addi r4, r3, TRKvalue128_temp@l
mr r3, r30
mr r12, r31
mtlr r12
blrl
li r3, 0
lwz r31, 0xc(r1)
lwz r30, 8(r1)
addi r1, r1, 0x10
lwz r0, 4(r1)
mtlr r0
blr
.global TRKTargetSetInputPendingPtr
TRKTargetSetInputPendingPtr:
lis r4, gTRKState@ha
addi r4, r4, gTRKState@l
stw r3, 0xa0(r4)
blr
.section .rodata, "a"
.balign 8
.global gTRKMemMap
gTRKMemMap:
.4byte 0
.4byte 0xFFFFFFFF
.4byte 0x00000001
.4byte 0x00000001
"@233":
.4byte 0x60000000
.4byte 0x60000000
.4byte 0x60000000
.4byte 0x60000000
.4byte 0x60000000
"@238":
.4byte 0x60000000
.4byte 0x60000000
.4byte 0x60000000
.4byte 0x60000000
.4byte 0x60000000
"@243":
.4byte 0x60000000
.4byte 0x60000000
.4byte 0x60000000
.4byte 0x60000000
.4byte 0x60000000
.4byte 0
.section .data, "wa"
.global gTRKRestoreFlags
gTRKRestoreFlags:
.4byte 0
.4byte 0
.4byte 0
.global gTRKExceptionStatus
gTRKExceptionStatus:
.4byte 0
.4byte 0
.4byte 0
.4byte 0x01000000
.global gTRKStepStatus
gTRKStepStatus:
.4byte 0
.4byte 0
.4byte 0
.4byte 0
.4byte 0
.section .bss, "wa"
TRK_saved_exceptionID:
.skip 0x4
.global gTRKSaveState
gTRKSaveState:
.skip 0x94
TRKvalue128_temp:
.skip 0x10
.global gTRKState
gTRKState:
.skip 0xA8
.global gTRKCPUState
gTRKCPUState:
.skip 0x430