This commit is contained in:
parent
3e20e9cf7e
commit
329465176d
2 changed files with 439 additions and 309 deletions
|
@ -1,24 +1,67 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
paul.cpp
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2000 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
|
||||||
|
#include "except.h"
|
||||||
|
|
||||||
|
#ifdef __INSTALL_EXCEPTION_HANDLER__
|
||||||
|
|
||||||
|
#ifndef _GLOBAL_HEADER_
|
||||||
|
#include "global.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GFX_FONT_H__
|
||||||
|
#include "gfx\font.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __VID_HEADER_
|
||||||
|
#include "system\vid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SYSTEM_LNKOPT_H__
|
||||||
|
#include "system\lnkopt.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <libetc.h>
|
#include <libetc.h>
|
||||||
#include <libgte.h>
|
#include <libgte.h>
|
||||||
#include <libgpu.h>
|
#include <libgpu.h>
|
||||||
#include "system\global.h"
|
|
||||||
#include "except.h"
|
|
||||||
#include "pad\pads.h"
|
|
||||||
|
|
||||||
#define NTSC_PAL 1
|
|
||||||
|
|
||||||
|
/* Data
|
||||||
|
---- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
// Offsets in the register dump list
|
||||||
enum {
|
enum {
|
||||||
OFS_AT,OFS_V0,OFS_V1,OFS_A0,OFS_A1,OFS_A2,OFS_A3,OFS_T0,OFS_T1,OFS_T2,OFS_T3,
|
OFS_AT,OFS_V0,OFS_V1,OFS_A0,OFS_A1,OFS_A2,OFS_A3,OFS_T0,OFS_T1,OFS_T2,OFS_T3,
|
||||||
OFS_T4,OFS_T5,OFS_T6,OFS_T7,OFS_S0,OFS_S1,OFS_S2,OFS_S3,OFS_S4,OFS_S5,OFS_S6,
|
OFS_T4,OFS_T5,OFS_T6,OFS_T7,OFS_S0,OFS_S1,OFS_S2,OFS_S3,OFS_S4,OFS_S5,OFS_S6,
|
||||||
OFS_S7,OFS_T8,OFS_T9,OFS_GP,OFS_SP,OFS_FP,OFS_RA,OFS_HI,OFS_LO,OFS_SR,OFS_CA,
|
OFS_S7,OFS_T8,OFS_T9,OFS_GP,OFS_SP,OFS_FP,OFS_RA,OFS_HI,OFS_LO,OFS_SR,OFS_CA,
|
||||||
OFS_EPC};
|
OFS_EPC
|
||||||
|
};
|
||||||
typedef struct {
|
|
||||||
DRAWENV draw;
|
|
||||||
DISPENV disp;
|
|
||||||
} EXC_DB;
|
|
||||||
|
|
||||||
|
// Pages
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PAGE_REGS,
|
PAGE_REGS,
|
||||||
|
@ -28,209 +71,154 @@ enum
|
||||||
NUM_PAGES
|
NUM_PAGES
|
||||||
};
|
};
|
||||||
|
|
||||||
static void exc_swap(void);
|
|
||||||
static void print_adr(int *adr);
|
|
||||||
|
|
||||||
static void cls();
|
/*----------------------------------------------------------------------
|
||||||
static void print(char *_string);
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
// Used by displayRegisters to define page layout
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char *m_name;
|
||||||
|
int m_offset;
|
||||||
|
} RegDef;
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function Prototypes
|
||||||
|
------------------- */
|
||||||
|
|
||||||
static void displayTitle();
|
static void displayTitle();
|
||||||
static void displayCause();
|
static void displayCause();
|
||||||
static void displayRegs();
|
static void displayRegs();
|
||||||
|
static void displayDump();
|
||||||
|
static void displayValues();
|
||||||
|
static void displayKeys();
|
||||||
|
|
||||||
|
static void cls();
|
||||||
|
static void print(char *_string);
|
||||||
|
static void printAdr(int *_adr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static EXC_DB exc_db[2];
|
/*----------------------------------------------------------------------
|
||||||
static int padWait;
|
Vars
|
||||||
int number=0;
|
---- */
|
||||||
static int mem_size;
|
|
||||||
static int exc_id;
|
|
||||||
|
|
||||||
static char *exc_txt[]={
|
|
||||||
"external interrupt",
|
|
||||||
"tlb modification exception",
|
|
||||||
"tlb miss (load or fetch)",
|
|
||||||
"tlb miss (store)",
|
|
||||||
"address error (load or fetch)",
|
|
||||||
"address error (store)",
|
|
||||||
"bus error (fetch)",
|
|
||||||
"bus error (load or store)",
|
|
||||||
"syscall",
|
|
||||||
"break",
|
|
||||||
"reserved instruction",
|
|
||||||
"coprocessor unusable",
|
|
||||||
"arithmetic overflow",
|
|
||||||
"unknown exception",
|
|
||||||
"unknown exception",
|
|
||||||
"unknown exception"};
|
|
||||||
|
|
||||||
static char *break_txt[]={
|
|
||||||
"6 (overflow)",
|
|
||||||
"7 (div by zero)"};
|
|
||||||
|
|
||||||
static char str_reg[1200];
|
|
||||||
static char str_dump[1200];
|
|
||||||
static char *p_sr;
|
|
||||||
static char *p_sd;
|
|
||||||
|
|
||||||
|
// Exception description strings
|
||||||
|
static char *s_exceptionText[]={
|
||||||
|
"external interrupt", "tlb modification exception", "tlb miss (load or fetch)",
|
||||||
|
"tlb miss (store)", "address error (load or fetch)", "address error (store)",
|
||||||
|
"bus error (fetch)", "bus error (load or store)", "syscall",
|
||||||
|
"break", "reserved instruction", "coprocessor unusable",
|
||||||
|
"arithmetic overflow", "unknown exception", "unknown exception",
|
||||||
|
"unknown exception"
|
||||||
|
};
|
||||||
|
static char *s_breakText[]={
|
||||||
|
"6 (overflow)", "7 (div by zero)"
|
||||||
|
};
|
||||||
|
|
||||||
|
// Font stuff
|
||||||
|
static FontBank *excFont;
|
||||||
|
static int fontx;
|
||||||
|
static int fonty;
|
||||||
|
static const int LEFTMARGIN=20;
|
||||||
|
static const int TOPMARGIN=20;
|
||||||
|
static const int CHARWIDTH=11;
|
||||||
|
static const int CHARHEIGHT=10;
|
||||||
|
|
||||||
static int currentPage=PAGE_REGS;
|
static int currentPage=PAGE_REGS;
|
||||||
|
|
||||||
#include "gfx\font.h"
|
|
||||||
FontBank *excFont;
|
// Layout for displayRegs()
|
||||||
|
static RegDef s_regDefs[]=
|
||||||
|
{
|
||||||
|
{"at",OFS_AT},{"v0",OFS_V0},{"v1",OFS_V1},{NULL,0},
|
||||||
|
{"a0",OFS_A0},{"a1",OFS_A1},{"a2",OFS_A2},{NULL,0},
|
||||||
|
{"a3",OFS_A3},{"t0",OFS_T0},{"t1",OFS_T1},{NULL,0},
|
||||||
|
{"t2",OFS_T2},{"t3",OFS_T3},{"t4",OFS_T4},{NULL,0},
|
||||||
|
{"t5",OFS_T5},{"t6",OFS_T6},{"t7",OFS_T7},{NULL,0},
|
||||||
|
{"s0",OFS_S0},{"s1",OFS_S1},{"s2",OFS_S2},{NULL,0},
|
||||||
|
{"s3",OFS_S3},{"s4",OFS_S4},{"s5",OFS_S5},{NULL,0},
|
||||||
|
{"s6",OFS_S6},{"s7",OFS_S7},{"t8",OFS_T8},{NULL,0},
|
||||||
|
{"t9",OFS_T9},{"gp",OFS_GP},{"sp",OFS_SP},{NULL,0},
|
||||||
|
{"fp",OFS_FP},{"ra",OFS_RA},{"hi",OFS_HI},{NULL,0},
|
||||||
|
{"lo",OFS_LO},{"sr",OFS_SR},{"ca",OFS_CA},{NULL,0},
|
||||||
|
{"epc",OFS_EPC},
|
||||||
|
};
|
||||||
|
static int s_numRegs=sizeof(s_regDefs)/sizeof(RegDef);
|
||||||
|
|
||||||
|
// Pointers for displayDump();
|
||||||
|
static int *s_viewSp;
|
||||||
|
static int *s_viewPc;
|
||||||
|
|
||||||
|
// Various externs for displayValues()
|
||||||
|
extern sLList MainRam;
|
||||||
|
extern int MemNodeCount;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
extern void installExceptionHandler()
|
extern void installExceptionHandler()
|
||||||
{
|
{
|
||||||
install_exc();
|
install_exc();
|
||||||
excFont=new ("ExcFont") FontBank();
|
excFont=new ("ExcFont") FontBank();
|
||||||
excFont->initialise( &standardFont );
|
excFont->initialise( &standardFont );
|
||||||
excFont->setColour( 255, 255 , 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void exc_c(void)
|
||||||
|
{
|
||||||
|
static int s_padDelay=50;
|
||||||
|
|
||||||
/* --------------------------------- exc_c ---------------------------------- */
|
|
||||||
extern void exc_c(void) {
|
|
||||||
|
|
||||||
int i,*p_exc,*cur_exc,*p_sp,*cur_sp;//,pad;
|
|
||||||
|
|
||||||
ResetCallback();
|
|
||||||
ResetGraph(0);
|
|
||||||
PadInit(0);
|
PadInit(0);
|
||||||
SetGraphDebug(0);
|
s_viewSp=(int *)reg_lst[OFS_SP];
|
||||||
SetVideoMode(NTSC_PAL==0 ? MODE_NTSC: MODE_PAL);
|
s_viewPc=(int *)reg_lst[OFS_EPC];
|
||||||
SetDispMask(1);
|
|
||||||
|
|
||||||
FntLoad(640,0);
|
while(1)
|
||||||
SetDumpFnt(FntOpen(8,8,320-8,240-8,0,1024));
|
{
|
||||||
|
// Think
|
||||||
SetDefDispEnv(&exc_db[0].disp, 0, 0,512,256);
|
if(s_padDelay)
|
||||||
SetDefDrawEnv(&exc_db[0].draw, 0,256,512,256);
|
|
||||||
SetDefDispEnv(&exc_db[1].disp, 0,256,512,256);
|
|
||||||
SetDefDrawEnv(&exc_db[1].draw, 0, 0,512,256);
|
|
||||||
|
|
||||||
exc_db[0].draw.isbg=exc_db[1].draw.isbg=1;
|
|
||||||
exc_db[0].disp.screen.x=exc_db[1].disp.screen.x=4;
|
|
||||||
exc_db[0].disp.screen.y=exc_db[1].disp.screen.y=24;
|
|
||||||
setRGB0(&exc_db[0].draw,104,0,0);
|
|
||||||
setRGB0(&exc_db[1].draw,104,0,0);
|
|
||||||
|
|
||||||
if(dev_kit==1)
|
|
||||||
mem_size=0x800000;
|
|
||||||
else
|
|
||||||
mem_size=0x200000;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*---- cause ----*/
|
|
||||||
/*
|
|
||||||
p_sr=str_reg;
|
|
||||||
|
|
||||||
p_exc=(int *)reg_lst[OFS_EPC];
|
|
||||||
|
|
||||||
p_sr+=sprintf(p_sr," %s",exc_txt[reg_lst[OFS_CA]>>2&0x1f]);
|
|
||||||
|
|
||||||
if((reg_lst[OFS_CA]>>2&0x1f)==9) {
|
|
||||||
i=(*p_exc>>16)-6;
|
|
||||||
if(i==0||i==1)
|
|
||||||
p_sr+=sprintf(p_sr," %s",break_txt[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
p_sr+=sprintf(p_sr,"\n at %08x",(int)p_exc);
|
|
||||||
|
|
||||||
if((reg_lst[OFS_CA]&0x80000000)==0x80000000)
|
|
||||||
p_sr+=sprintf(p_sr," in branch delay slot\n\n");
|
|
||||||
else
|
|
||||||
p_sr+=sprintf(p_sr,"\n\n");
|
|
||||||
|
|
||||||
*/
|
|
||||||
/*---- mem-dump ----*/
|
|
||||||
/*
|
|
||||||
#define NR_DUMP 9
|
|
||||||
|
|
||||||
exc_id=1;
|
|
||||||
|
|
||||||
p_sp=(int *)reg_lst[OFS_SP];
|
|
||||||
cur_sp=p_sp+(NR_DUMP-1);
|
|
||||||
cur_exc=p_exc+(-NR_DUMP/2);
|
|
||||||
*/
|
|
||||||
|
|
||||||
padWait=100;
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
|
|
||||||
while(DrawSync(1));
|
|
||||||
// DrawSync(0);
|
|
||||||
// while(DrawSync(1));
|
|
||||||
VSync(0);
|
|
||||||
exc_id=exc_id? 0: 1;
|
|
||||||
exc_swap();
|
|
||||||
cls();
|
|
||||||
|
|
||||||
/*
|
|
||||||
if(padWait>0)
|
|
||||||
{
|
{
|
||||||
padWait--;
|
s_padDelay--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int pad=PadRead(1);
|
int pad=PadRead(1);
|
||||||
if(pad&PADRup)currentPage=PAGE_REGS;
|
|
||||||
if(pad&PADRdown)currentPage=PAGE_DUMP;
|
|
||||||
if(pad&PADRleft)currentPage=PAGE_VALUES;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// PadUpdate();
|
|
||||||
/*
|
|
||||||
if(wait_pad==0) {
|
|
||||||
pad=PadRead(1);
|
|
||||||
|
|
||||||
if(pad&PADRdown&&++currentPage==NUM_PAGES)currentPage=0;
|
|
||||||
|
|
||||||
#define STEP_MEM 256
|
if(pad&PADRdown)
|
||||||
|
{
|
||||||
if(pad&PADL1) cur_exc+=STEP_MEM;
|
if(++currentPage==NUM_PAGES)currentPage=0;
|
||||||
if(pad&PADL2) cur_exc-=STEP_MEM;
|
s_padDelay=15;
|
||||||
if(pad&PADLup) cur_exc--;
|
}
|
||||||
if(pad&PADLdown) cur_exc++;
|
if(currentPage==PAGE_DUMP)
|
||||||
if(pad&PADR1) cur_sp-=STEP_MEM;
|
{
|
||||||
if(pad&PADR2) cur_sp+=STEP_MEM;
|
if(pad&PADL1) s_viewSp-=8;
|
||||||
if(pad&PADRup) cur_sp++;
|
if(pad&PADL2) s_viewSp+=8;
|
||||||
if(pad&PADRdown) cur_sp--;
|
if(pad&PADR1) s_viewPc-=8;
|
||||||
|
if(pad&PADR2) s_viewPc+=8;
|
||||||
if(pad&PADstart) {
|
if(pad&PADstart)
|
||||||
cur_sp=p_sp+(NR_DUMP-1);
|
{
|
||||||
cur_exc=p_exc+(-NR_DUMP/2);
|
s_viewSp=(int *)reg_lst[OFS_SP];
|
||||||
|
s_viewPc=(int *)reg_lst[OFS_EPC];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
wait_pad--;
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
p_sd=str_dump;
|
|
||||||
|
|
||||||
p_sd+=sprintf(p_sd,"\n pc: stack:\n\n");
|
|
||||||
for(i=0;i<NR_DUMP;i++) {
|
|
||||||
// pc-dump
|
|
||||||
if(cur_exc+i==p_exc)
|
|
||||||
p_sd+=sprintf(p_sd,">");
|
|
||||||
else
|
|
||||||
p_sd+=sprintf(p_sd," ");
|
|
||||||
print_adr(cur_exc+i);
|
|
||||||
p_sd+=sprintf(p_sd," ");
|
|
||||||
// stack-dump
|
|
||||||
print_adr(cur_sp-i);
|
|
||||||
if(cur_sp-i==p_sp)
|
|
||||||
p_sd+=sprintf(p_sd,"<\n");
|
|
||||||
else
|
|
||||||
p_sd+=sprintf(p_sd," \n");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
p_sd+=sprintf(p_sd,"\n");
|
|
||||||
|
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
cls();
|
||||||
displayTitle();
|
displayTitle();
|
||||||
displayCause();
|
displayCause();
|
||||||
switch(currentPage)
|
switch(currentPage)
|
||||||
|
@ -239,72 +227,42 @@ extern void exc_c(void) {
|
||||||
displayRegs();
|
displayRegs();
|
||||||
break;
|
break;
|
||||||
case PAGE_DUMP:
|
case PAGE_DUMP:
|
||||||
|
displayDump();
|
||||||
break;
|
break;
|
||||||
case PAGE_VALUES:
|
case PAGE_VALUES:
|
||||||
|
displayValues();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
displayKeys();
|
||||||
//int len=0;
|
|
||||||
//len+=strlen(str_reg);
|
// Swap
|
||||||
//len+=strlen(str_dump);
|
while(DrawSync(1));
|
||||||
// FntPrint(str_reg);
|
VSync(0);
|
||||||
// print(str_reg);
|
VidSwapDraw();
|
||||||
// FntPrint(str_dump);
|
|
||||||
// print(str_dump);
|
|
||||||
// if(wait_pad==0)
|
|
||||||
// FntPrint(" scroll through mem with pad");
|
|
||||||
// print(" scroll through mem with pad");
|
|
||||||
// FntFlush(-1);
|
|
||||||
PrimDisplay();
|
PrimDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------ print_adr ------------------------------- */
|
|
||||||
static void print_adr(int *adr) {
|
|
||||||
|
|
||||||
int chk,dummy_mem,error;
|
|
||||||
|
|
||||||
chk=(int)adr;
|
|
||||||
|
|
||||||
dummy_mem=chk&0xf0000000;
|
|
||||||
chk&=0x0ffffffc;
|
|
||||||
error=1;
|
|
||||||
if(chk<mem_size)
|
|
||||||
error=0;
|
|
||||||
if(chk>0x1f800000&&chk<0x1f800400)
|
|
||||||
error=0;
|
|
||||||
adr=(int *)(chk|dummy_mem);
|
|
||||||
|
|
||||||
if(error==0)
|
|
||||||
p_sd+=sprintf(p_sd,"%08x=%08x",(int)(adr),*adr);
|
|
||||||
else
|
|
||||||
p_sd+=sprintf(p_sd,"%08x=XXXXXXXX",(int)(adr));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------- exc_swap ------------------------------ */
|
|
||||||
static void exc_swap(void) {
|
|
||||||
|
|
||||||
PutDrawEnv(&exc_db[exc_id].draw);
|
|
||||||
PutDispEnv(&exc_db[exc_id].disp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
static int fontx;
|
Returns:
|
||||||
static int fonty;
|
---------------------------------------------------------------------- */
|
||||||
static const int LEFTMARGIN=5;
|
|
||||||
static const int TOPMARGIN=5;
|
|
||||||
static const int CHARWIDTH=11;
|
|
||||||
static const int CHARHEIGHT=10;
|
|
||||||
static void cls()
|
static void cls()
|
||||||
{
|
{
|
||||||
fontx=LEFTMARGIN;
|
fontx=LEFTMARGIN;
|
||||||
fonty=TOPMARGIN;
|
fonty=TOPMARGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
static void print(char *_string)
|
static void print(char *_string)
|
||||||
{
|
{
|
||||||
char text[2]="?";
|
char text[2]="?";
|
||||||
|
@ -327,17 +285,48 @@ static void print(char *_string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
static void printAdr(int *_adr)
|
||||||
|
{
|
||||||
|
int chk,dummy_mem,error;
|
||||||
|
char textBuf[64];
|
||||||
|
|
||||||
|
chk=(int)_adr;
|
||||||
|
dummy_mem=chk&0xf0000000;
|
||||||
|
chk&=0x0ffffffc;
|
||||||
|
error=1;
|
||||||
|
if(chk<(int)OPT_LinkerOpts.RamSize)
|
||||||
|
error=0;
|
||||||
|
if(chk>0x1f800000&&chk<0x1f800400)
|
||||||
|
error=0;
|
||||||
|
_adr=(int *)(chk|dummy_mem);
|
||||||
|
if(error==0)
|
||||||
|
sprintf(textBuf,"%08x=%08x",(int)(_adr),*_adr);
|
||||||
|
else
|
||||||
|
sprintf(textBuf,"%08x=XXXXXXXX",(int)(_adr));
|
||||||
|
print(textBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
static void displayTitle()
|
static void displayTitle()
|
||||||
{
|
{
|
||||||
|
static int r=0,g=0,b=0;
|
||||||
|
char textBuf[10];
|
||||||
|
|
||||||
|
excFont->setColour(r,g,b);
|
||||||
print("[");
|
print("[");
|
||||||
|
excFont->setColour(255,255,255);
|
||||||
switch(currentPage)
|
switch(currentPage)
|
||||||
{
|
{
|
||||||
case PAGE_REGS:
|
case PAGE_REGS:
|
||||||
|
@ -350,22 +339,37 @@ static void displayTitle()
|
||||||
print("Values");
|
print("Values");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
print("]\n");
|
excFont->setColour(r,g,b);
|
||||||
|
print("]\n\n");
|
||||||
|
|
||||||
|
r+=8;
|
||||||
|
g+=16;
|
||||||
|
b+=32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
static void displayCause()
|
static void displayCause()
|
||||||
{
|
{
|
||||||
char textBuf[100];
|
char textBuf[100];
|
||||||
int *exc;
|
int *exc;
|
||||||
|
|
||||||
|
excFont->setColour(255,0,0);
|
||||||
|
|
||||||
exc=(int*)reg_lst[OFS_EPC];
|
exc=(int*)reg_lst[OFS_EPC];
|
||||||
sprintf(textBuf,"%s",exc_txt[reg_lst[OFS_CA]>>2&0x1f]);
|
sprintf(textBuf,"%s",s_exceptionText[reg_lst[OFS_CA]>>2&0x1f]);
|
||||||
print(textBuf);
|
print(textBuf);
|
||||||
|
|
||||||
if((reg_lst[OFS_CA]>>2&0x1f)==9)
|
if((reg_lst[OFS_CA]>>2&0x1f)==9)
|
||||||
{
|
{
|
||||||
int i=(*exc>>16)-6;
|
int i=(*exc>>16)-6;
|
||||||
if(i==0||i==1)
|
if(i==0||i==1)
|
||||||
sprintf(textBuf," %s",break_txt[i]);
|
sprintf(textBuf," %s",s_breakText[i]);
|
||||||
print(textBuf);
|
print(textBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,68 +379,150 @@ static void displayCause()
|
||||||
if((reg_lst[OFS_CA]&0x80000000)==0x80000000)
|
if((reg_lst[OFS_CA]&0x80000000)==0x80000000)
|
||||||
print(" in branch delay slot");
|
print(" in branch delay slot");
|
||||||
print("\n\n");
|
print("\n\n");
|
||||||
|
|
||||||
sprintf(textBuf,"(%d)\n",number++);
|
|
||||||
print(textBuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
static void displayRegs()
|
static void displayRegs()
|
||||||
{
|
{
|
||||||
char textBuf[100];
|
char textBuf[20];
|
||||||
/* ---- reg-dump ---- */
|
|
||||||
/*
|
excFont->setColour(255,255,255);
|
||||||
zr t0 s0 t8 hi
|
RegDef *regs=s_regDefs;
|
||||||
at t1 s1 t9 lo
|
for(int i=0;i<s_numRegs;i++)
|
||||||
v0 t2 s2 k0
|
{
|
||||||
v1 t3 s3 k1 SR
|
if(regs->m_name)
|
||||||
a0 t4 s4 gp
|
{
|
||||||
a1 t5 s5 sp Ca
|
sprintf(textBuf,"%s=%08x ",regs->m_name,reg_lst[regs->m_offset]);
|
||||||
a2 t6 s6 fp
|
}
|
||||||
a3 t7 s7 ra
|
else
|
||||||
|
{
|
||||||
pc
|
sprintf(textBuf,"\n");
|
||||||
*/
|
}
|
||||||
|
print(textBuf);
|
||||||
sprintf(textBuf,"zr=%08x t0=%08x s0=%08x t8=%08x hi=%08x\n", 0,reg_lst[OFS_T0],reg_lst[OFS_S0],reg_lst[OFS_T8],reg_lst[OFS_HI]);
|
regs++;
|
||||||
print(textBuf);
|
}
|
||||||
sprintf(textBuf,"at=%08x t1=%08x s1=%08x t9=%08x lo=%08x\n",reg_lst[OFS_AT],reg_lst[OFS_T1],reg_lst[OFS_S1],reg_lst[OFS_T9],reg_lst[OFS_LO]);
|
|
||||||
print(textBuf);
|
|
||||||
sprintf(textBuf,"v0=%08x t2=%08x s2=%08x ko=%08x" ,reg_lst[OFS_V0],reg_lst[OFS_T2],reg_lst[OFS_S2], 0);
|
|
||||||
print(textBuf);
|
|
||||||
sprintf(textBuf,"v1=%08x t3=%08x s3=%08x k1=%08x SR=%08x\n",reg_lst[OFS_V1],reg_lst[OFS_T3],reg_lst[OFS_S3], 0,reg_lst[OFS_SR]);
|
|
||||||
print(textBuf);
|
|
||||||
sprintf(textBuf,"a0=%08x t4=%08x s4=%08x gp=%08x" ,reg_lst[OFS_A0],reg_lst[OFS_T4],reg_lst[OFS_S4],reg_lst[OFS_GP]);
|
|
||||||
print(textBuf);
|
|
||||||
sprintf(textBuf,"a1=%08x t5=%08x s5=%08x sp=%08x Ca=%08x\n",reg_lst[OFS_A1],reg_lst[OFS_T5],reg_lst[OFS_S5],reg_lst[OFS_SP],reg_lst[OFS_CA]);
|
|
||||||
print(textBuf);
|
|
||||||
sprintf(textBuf,"a2=%08x t6=%08x s6=%08x fp=%08x" ,reg_lst[OFS_A2],reg_lst[OFS_T6],reg_lst[OFS_S6],reg_lst[OFS_FP]);
|
|
||||||
print(textBuf);
|
|
||||||
sprintf(textBuf,"a3=%08x t7=%08x s7=%08x ra=%08x" ,reg_lst[OFS_A3],reg_lst[OFS_T7],reg_lst[OFS_S7],reg_lst[OFS_RA]);
|
|
||||||
print(textBuf);
|
|
||||||
|
|
||||||
/*
|
|
||||||
p_sr+=sprintf(p_sr," at=%08x t4=%08x s7=%08x\n",
|
|
||||||
reg_lst[OFS_AT],reg_lst[OFS_T4],reg_lst[OFS_S7]);
|
|
||||||
p_sr+=sprintf(p_sr," v0=%08x t5=%08x t8=%08x\n",
|
|
||||||
reg_lst[OFS_V0],reg_lst[OFS_T5],reg_lst[OFS_T8]);
|
|
||||||
p_sr+=sprintf(p_sr," v1=%08x t6=%08x t9=%08x\n",
|
|
||||||
reg_lst[OFS_V1],reg_lst[OFS_T6],reg_lst[OFS_T9]);
|
|
||||||
p_sr+=sprintf(p_sr," a0=%08x t7=%08x gp=%08x\n",
|
|
||||||
reg_lst[OFS_A0],reg_lst[OFS_T7],reg_lst[OFS_GP]);
|
|
||||||
p_sr+=sprintf(p_sr," a1=%08x s0=%08x sp=%08x\n",
|
|
||||||
reg_lst[OFS_A1],reg_lst[OFS_S0],reg_lst[OFS_SP]);
|
|
||||||
p_sr+=sprintf(p_sr," a2=%08x s1=%08x fp=%08x\n",
|
|
||||||
reg_lst[OFS_A2],reg_lst[OFS_S1],reg_lst[OFS_FP]);
|
|
||||||
p_sr+=sprintf(p_sr," a3=%08x s2=%08x ra=%08x\n",
|
|
||||||
reg_lst[OFS_A3],reg_lst[OFS_S2],reg_lst[OFS_RA]);
|
|
||||||
p_sr+=sprintf(p_sr," t0=%08x s3=%08x hi=%08x\n",
|
|
||||||
reg_lst[OFS_T0],reg_lst[OFS_S3],reg_lst[OFS_HI]);
|
|
||||||
p_sr+=sprintf(p_sr," t1=%08x s4=%08x lo=%08x\n",
|
|
||||||
reg_lst[OFS_T1],reg_lst[OFS_S4],reg_lst[OFS_LO]);
|
|
||||||
p_sr+=sprintf(p_sr," t2=%08x s5=%08x sr=%08x\n",
|
|
||||||
reg_lst[OFS_T2],reg_lst[OFS_S5],reg_lst[OFS_SR]);
|
|
||||||
p_sr+=sprintf(p_sr," t3=%08x s6=%08x ca=%08x\n",
|
|
||||||
reg_lst[OFS_T3],reg_lst[OFS_S6],reg_lst[OFS_CA]);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
static void displayDump()
|
||||||
|
{
|
||||||
|
char textBuf[100];
|
||||||
|
int *sp,*pc;
|
||||||
|
|
||||||
|
excFont->setColour(255,255,255);
|
||||||
|
|
||||||
|
sp=s_viewSp;
|
||||||
|
pc=s_viewPc;
|
||||||
|
print("SP PC\n");
|
||||||
|
for(int i=0;i<10;i++)
|
||||||
|
{
|
||||||
|
// SP
|
||||||
|
if(sp==(int*)reg_lst[OFS_SP])
|
||||||
|
{
|
||||||
|
print(">");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print(" ");
|
||||||
|
}
|
||||||
|
printAdr(sp);
|
||||||
|
print(" ");
|
||||||
|
sp+=8;
|
||||||
|
|
||||||
|
// PC
|
||||||
|
if(pc==(int*)reg_lst[OFS_EPC])
|
||||||
|
{
|
||||||
|
print(">");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print(" ");
|
||||||
|
}
|
||||||
|
printAdr(pc);
|
||||||
|
print("\n");
|
||||||
|
pc+=8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
static void displayValues()
|
||||||
|
{
|
||||||
|
char textBuf[256];
|
||||||
|
|
||||||
|
excFont->setColour(255,255,255);
|
||||||
|
|
||||||
|
print("Memory:\n");
|
||||||
|
sprintf(textBuf," %ld used in %d nodes (%ld available)\n",MainRam.RamUsed,MemNodeCount,MainRam.TotalRam);
|
||||||
|
print(textBuf);
|
||||||
|
sprintf(textBuf," %dk ram size set in link options\n",(int)(OPT_LinkerOpts.RamSize/1024));
|
||||||
|
print(textBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
static void displayKeys()
|
||||||
|
{
|
||||||
|
char textBuf[256];
|
||||||
|
|
||||||
|
excFont->setColour(64,32,128);
|
||||||
|
|
||||||
|
sprintf(textBuf,"\n\nX=Next page\n");
|
||||||
|
print(textBuf);
|
||||||
|
|
||||||
|
textBuf[0]='\0';
|
||||||
|
switch(currentPage)
|
||||||
|
{
|
||||||
|
case PAGE_REGS:
|
||||||
|
break;
|
||||||
|
case PAGE_DUMP:
|
||||||
|
sprintf(textBuf,"L1/L2=Scroll SP, R1/R2=Scroll PC\nSTART=Reset");
|
||||||
|
break;
|
||||||
|
case PAGE_VALUES:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
print(textBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
extern void installExceptionHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
extern void exc_c()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __INSTALL_EXCEPTION_HANDLER__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
|
@ -1,16 +1,60 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
except.h
|
||||||
|
|
||||||
|
Author: PKG
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2000 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
#ifndef __SYSTEM_EXCEPT_H__
|
#ifndef __SYSTEM_EXCEPT_H__
|
||||||
#define __SYSTEM_EXCEPT_H__
|
#define __SYSTEM_EXCEPT_H__
|
||||||
|
|
||||||
extern void installExceptionHandler();
|
/*----------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
-------- */
|
||||||
|
|
||||||
|
/* Std Lib
|
||||||
|
------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Tyepdefs && Defines
|
||||||
|
------------------- */
|
||||||
|
|
||||||
|
#ifdef __USER_CDBUILD__
|
||||||
|
#define __INSTALL_EXCEPTION_HANDLER__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Structure defintions
|
||||||
|
-------------------- */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Globals
|
||||||
|
------- */
|
||||||
|
|
||||||
|
extern int *reg_lst;
|
||||||
|
extern int dev_kit;
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Functions
|
||||||
|
--------- */
|
||||||
|
extern void installExceptionHandler();
|
||||||
|
|
||||||
extern "C" void exc_c(void);
|
extern "C" void exc_c(void);
|
||||||
extern "C" void install_exc(void);
|
extern "C" void install_exc(void);
|
||||||
extern "C" void uninstall_exc(void);
|
extern "C" void uninstall_exc(void);
|
||||||
|
|
||||||
extern int *reg_lst;
|
|
||||||
extern int dev_kit;
|
|
||||||
|
|
||||||
#endif
|
/*---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#endif /* __SYSTEM_EXCEPT_H__ */
|
||||||
|
|
||||||
|
/*===========================================================================
|
||||||
|
end */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue