Code: Select all
/* Install a V_DEBUG handler in place of the kernel one */
static void install_debug_handler(void)
{
u32 data;
/* Build a 'j level2ExceptionHandler' instruction */
data = (u32) level2ExceptionHandler & 0xFFFFFFF;
data = 0x8000000 | (data >> 2);
_sw(data, 0x80000100);
_sw(0, 0x80000104);
FlushCache(0);
}
.global _level2SavedRegs
.global _level2ExceptionStack
.global level2ExceptionHandler
.ent level2ExceptionHandler
level2ExceptionHandler:
sq $k0, -0x20($0)
la $k0, _level2SavedRegs
#lui k1, 0x8000
# or $k0, $k0, k1
sq $0, 0x00($k0)
sq $1, 0x10($k0)
sq $2, 0x20($k0)
sq $3, 0x30($k0)
sq $4, 0x40($k0)
sq $5, 0x50($k0)
sq $6, 0x60($k0)
sq $7, 0x70($k0)
sq $8, 0x80($k0)
sq $9, 0x90($k0)
sq $10, 0xa0($k0)
sq $11, 0xb0($k0)
sq $12, 0xc0($k0)
sq $13, 0xd0($k0)
sq $14, 0xe0($k0)
sq $15, 0xf0($k0)
sq $16, 0x100($k0)
sq $17, 0x110($k0)
sq $18, 0x120($k0)
sq $19, 0x130($k0)
sq $20, 0x140($k0)
sq $21, 0x150($k0)
sq $22, 0x160($k0)
sq $23, 0x170($k0)
sq $24, 0x180($k0)
sq $25, 0x190($k0)
# Restore $k0 and save
lq $1, -0x20($0)
sq $1, 0x1a0($k0) # zero instead of $k0
sq $27, 0x1b0($k0) # $k1
sq $28, 0x1c0($k0)
sq $29, 0x1d0($k0) # $sp
sq $30, 0x1e0($k0)
sq $31, 0x1f0($k0) # $ra
# Return from exception and start 'debugger'
#jal sio_shell_level2
# nop
la $k0, _level2SavedRegs
lq $0, 0x00($k0)
lq $1, 0x10($k0)
lq $2, 0x20($k0)
lq $3, 0x30($k0)
lq $4, 0x40($k0)
lq $5, 0x50($k0)
lq $6, 0x60($k0)
lq $7, 0x70($k0)
lq $8, 0x80($k0)
lq $9, 0x90($k0)
lq $10, 0xa0($k0)
lq $11, 0xb0($k0)
lq $12, 0xc0($k0)
lq $13, 0xd0($k0)
lq $14, 0xe0($k0)
lq $15, 0xf0($k0)
lq $16, 0x100($k0)
lq $17, 0x110($k0)
lq $18, 0x120($k0)
lq $19, 0x130($k0)
lq $20, 0x140($k0)
lq $21, 0x150($k0)
lq $22, 0x160($k0)
lq $23, 0x170($k0)
lq $24, 0x180($k0)
lq $25, 0x190($k0)
# no $k0
lq $27, 0x1b0($k0) # $k1
lq $28, 0x1c0($k0)
lq $29, 0x1d0($k0) # $sp
lq $30, 0x1e0($k0)
lq $31, 0x1f0($k0) # $ra
lq $k0, -0x20($0)
sync
eret
nop
jr $ra
nop
.end level2ExceptionHandler
.bss
.align 4
.ent _level2SavedRegs
_level2SavedRegs:
.space 0x240, 0
.end _level2SavedRegs
u32 test;
u32 memory_location = 0x0;
int main(void)
{
SifInitRpc(0);
init_scr();
ee_kmode_enter();
install_debug_handler();
ee_kmode_exit();
scr_printf(" Handler on\n");
InitBPC();
scr_printf(" BPC on\n");
SetDataAddrBP(&test, 0xfffffffc,BPC_DWE | BPC_DUE | BPC_BED);
scr_printf(" BP SET on\n");
scr_printf(" test = %8.8x\n",test);
scr_printf(" Done\n");
test++;
scr_printf(" test = %0x\n",test);
scr_printf(" memory_location = %8.8x\n",memory_location);
while(1)
{
}
return 0;
}
In my level 1 handler i have to increase the EPC to the next address so the break doesn't happen again, am i supposed to do this with a level 2 exception as well?