.include "macros.inc"
.section .text, "ax"
.global TRKLoadContext
TRKLoadContext:
lwz r0, 0(r3)
lwz r1, 4(r3)
lwz r2, 8(r3)
lhz r5, 0x1a2(r3)
rlwinm. r6, r5, 0, 0x1e, 0x1e
beq lbl_8008C03C
rlwinm r5, r5, 0, 0x1f, 0x1d
sth r5, 0x1a2(r3)
lmw r5, 0x14(r3)
b lbl_8008C040
lbl_8008C03C:
lmw r13, 0x34(r3)
lbl_8008C040:
mr r31, r3
mr r3, r4
lwz r4, 0x80(r31)
mtcrf 0xff, r4
lwz r4, 0x84(r31)
mtlr r4
lwz r4, 0x88(r31)
mtctr r4
lwz r4, 0x8c(r31)
mtxer r4
mfmsr r4
rlwinm r4, r4, 0, 0x11, 0xf
rlwinm r4, r4, 0, 0x1f, 0x1d
mtmsr r4
mtspr 0x111, r2
lwz r4, 0xc(r31)
mtspr 0x112, r4
lwz r4, 0x10(r31)
mtspr 0x113, r4
lwz r2, 0x198(r31)
lwz r4, 0x19c(r31)
lwz r31, 0x7c(r31)
b TRKInterruptHandler
.global TRKEXICallBack
TRKEXICallBack:
mflr r0
stw r0, 4(r1)
stwu r1, -0x10(r1)
stw r31, 0xc(r1)
mr r31, r4
bl OSEnableScheduler
mr r3, r31
li r4, 0x500
bl TRKLoadContext
lwz r31, 0xc(r1)
addi r1, r1, 0x10
lwz r0, 4(r1)
mtlr r0
blr
.global InitMetroTRKCommTable
InitMetroTRKCommTable:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
cmpwi r3, 1
bne lbl_8008C14C
bl Hu_IsStub
lis r5, DBInitComm@ha
lis r4, gDBCommTable@ha
addi r0, r5, DBInitComm@l
addi r5, r4, gDBCommTable@l
lis r4, DBInitInterrupts@ha
stw r0, 0(r5)
addi r0, r4, DBInitInterrupts@l
lis r4, DBQueryData@ha
stw r0, 4(r5)
addi r0, r4, DBQueryData@l
lis r4, DBRead@ha
stw r0, 8(r5)
addi r0, r4, DBRead@l
lis r4, DBWrite@ha
stw r0, 0xc(r5)
addi r0, r4, DBWrite@l
lis r4, DBOpen@ha
stw r0, 0x10(r5)
addi r0, r4, DBOpen@l
lis r4, DBClose@ha
stw r0, 0x14(r5)
addi r0, r4, DBClose@l
stw r0, 0x18(r5)
b lbl_8008C1AC
lbl_8008C14C:
bl AMC_IsStub
lis r5, EXI2_Init@ha
lis r4, gDBCommTable@ha
addi r0, r5, EXI2_Init@l
addi r5, r4, gDBCommTable@l
lis r4, EXI2_EnableInterrupts@ha
stw r0, 0(r5)
addi r0, r4, EXI2_EnableInterrupts@l
lis r4, EXI2_Poll@ha
stw r0, 4(r5)
addi r0, r4, EXI2_Poll@l
lis r4, EXI2_ReadN@ha
stw r0, 8(r5)
addi r0, r4, EXI2_ReadN@l
lis r4, EXI2_WriteN@ha
stw r0, 0xc(r5)
addi r0, r4, EXI2_WriteN@l
lis r4, EXI2_Reserve@ha
stw r0, 0x10(r5)
addi r0, r4, EXI2_Reserve@l
lis r4, EXI2_Unreserve@ha
stw r0, 0x14(r5)
addi r0, r4, EXI2_Unreserve@l
stw r0, 0x18(r5)
lbl_8008C1AC:
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global TRKUARTInterruptHandler
TRKUARTInterruptHandler:
blr
.global TRKInitializeIntDrivenUART
TRKInitializeIntDrivenUART:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
lis r3, gDBCommTable@ha
addi r3, r3, gDBCommTable@l
lis r4, TRKEXICallBack@ha
lwz r12, 0(r3)
addi r4, r4, TRKEXICallBack@l
mr r3, r6
mtlr r12
blrl
li r3, 0
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global EnableEXI2Interrupts
EnableEXI2Interrupts:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
lis r3, gDBCommTable@ha
addi r3, r3, gDBCommTable@l
lwz r12, 4(r3)
mtlr r12
blrl
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global TRKPollUART
TRKPollUART:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
lis r3, gDBCommTable@ha
addi r3, r3, gDBCommTable@l
lwz r12, 8(r3)
mtlr r12
blrl
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global TRKReadUARTN
TRKReadUARTN:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
lis r5, gDBCommTable@ha
addi r5, r5, gDBCommTable@l
lwz r12, 0xc(r5)
mtlr r12
blrl
cmpwi r3, 0
bne lbl_8008C290
li r3, 0
b lbl_8008C294
lbl_8008C290:
li r3, -1
lbl_8008C294:
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global TRKWriteUARTN
TRKWriteUARTN:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
lis r5, gDBCommTable@ha
addi r5, r5, gDBCommTable@l
lwz r12, 0x10(r5)
mtlr r12
blrl
cmpwi r3, 0
bne lbl_8008C2D4
li r3, 0
b lbl_8008C2D8
lbl_8008C2D4:
li r3, -1
lbl_8008C2D8:
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global ReserveEXI2Port
ReserveEXI2Port:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
lis r3, gDBCommTable@ha
addi r3, r3, gDBCommTable@l
lwz r12, 0x14(r3)
mtlr r12
blrl
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global UnreserveEXI2Port
UnreserveEXI2Port:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
lis r3, gDBCommTable@ha
addi r3, r3, gDBCommTable@l
lwz r12, 0x18(r3)
mtlr r12
blrl
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.global TRK_board_display
TRK_board_display:
mflr r0
stw r0, 4(r1)
stwu r1, -8(r1)
crclr 6
bl OSReport
addi r1, r1, 8
lwz r0, 4(r1)
mtlr r0
blr
.section .data, "wa"
gDBCommTable:
.4byte 0
.4byte 0
.4byte 0
.4byte 0
.4byte 0
.4byte 0
.4byte 0
.4byte 0