gint/gdb: add half-baked GDB menu (display half of the values on mono)

This commit is contained in:
redoste 2023-06-04 19:41:17 +02:00 committed by Lephenixnoir
parent 15757c40c7
commit 21b261d0c9
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
5 changed files with 125 additions and 0 deletions

View File

@ -26,6 +26,8 @@ set(SOURCES
src/gint/dsp.c
src/gint/dsp.s
src/gint/dump.c
src/gint/gdb.S
src/gint/gdb.c
src/gint/gray.c
src/gint/image.c
src/gint/keyboard.c

View File

@ -71,4 +71,7 @@ void gintctl_gint_gray(void);
void gintctl_gint_grayrender(void);
/* gintctl_gint_gdb(): GDB remote serial protocol */
void gintctl_gint_gdb(void);
#endif /* GINTCTL_GINT */

26
src/gint/gdb.S Normal file
View File

@ -0,0 +1,26 @@
.text
.global _gintctl_gint_gdb_bank1_test
_gintctl_gint_gdb_bank1_test:
// SR.RB = 0
stc sr, r2
mov r2, r1
mov.l .sr_mask, r0
or r0, r1
ldc r1, sr
// Now SR.RB = 1
mov #0x13, r3
mov #0x37, r4
shll8 r3
or r3, r4
ldc r4, R0_BANK
stc R2_BANK, r2
ldc r2, sr
// Now SR.RB = 0
rts
nop
.align 4
.sr_mask: .long (1 << 29)

93
src/gint/gdb.c Normal file
View File

@ -0,0 +1,93 @@
#include <gint/display.h>
#include <gint/gdb.h>
#include <gint/mpu/power.h>
#include <gint/mpu/ubc.h>
#include <gint/ubc.h>
#include <gintctl/assets.h>
#include <gintctl/gint.h>
#include <gintctl/util.h>
#ifdef FXCG50
static void val(int y, const char *name, uint32_t value)
{
dtext(0, 20 + y*12, C_BLACK, name);
dprint(88, 20 + y*12, C_BLACK, "%08X", value);
}
#else
static void val(int y, const char *name, uint32_t value)
{
dtext(0, 8 + y*6, C_BLACK, name);
dprint(40, 8 + y*6, C_BLACK, "%08X", value);
}
#endif
#define reg(y,n,v) val(y,n,v.lword)
extern int (*gint_exc_catcher)(uint32_t code);
int gintctl_gint_gdb_bank1_test(void);
void gintctl_gint_gdb(void)
{
int key = 0;
int ret = -1;
while (key != KEY_EXIT) {
dclear(C_WHITE);
#ifdef FXCG50
row_title("GDB remote serial protocol");
#else
row_title("GDB");
#endif
#ifdef FXCG50
fkey_action(6, "START");
fkey_action(5, "PANICR");
fkey_action(4, "PANICW");
fkey_action(1, "BANK 1");
#endif
#ifdef FX9860G
font_t const *old_font = dfont(&font_mini);
#endif
val(0, "ret", ret);
reg(1, "MSTPCR0", SH7305_POWER.MSTPCR0);
reg(2, "CBR0", SH7305_UBC.CBR0);
reg(3, "CRR0", SH7305_UBC.CRR0);
val(4, "CAR0", SH7305_UBC.CAR0);
val(5, "CAMR0", SH7305_UBC.CAMR0);
reg(6, "CBR1", SH7305_UBC.CBR1);
reg(7, "CRR1", SH7305_UBC.CRR1);
val(8, "CAR1", SH7305_UBC.CAR1);
val(9, "CAMR1", SH7305_UBC.CAMR1);
val(10, "CDR1", SH7305_UBC.CDR1);
val(11, "CDMR1", SH7305_UBC.CDMR1);
reg(12, "CETR1", SH7305_UBC.CETR1);
reg(13, "CCMFR", SH7305_UBC.CCMFR);
reg(14, "CBCR", SH7305_UBC.CBCR);
val(15, "DBR", (uint32_t) ubc_getDBR());
#ifdef FXCG50
dprint(176, 20, C_BLACK, "exc_catcher: %p", gint_exc_catcher);
#endif
#ifdef FX9860G
dfont(old_font);
#endif
dupdate();
key_event_t ev = gintctl_getkey();
key = ev.key;
volatile uint32_t* miss = (void*)0x41414140;
if (key == KEY_F6) {
ret = gdb_start();
} else if (key == KEY_F5) {
ret = *miss;
} else if (key == KEY_F4) {
*miss = 0x1337;
} else if (key == KEY_F1) {
ret = gintctl_gint_gdb_bank1_test();
}
}
}

View File

@ -61,6 +61,7 @@ struct menu menu_gint = {
#if GINT_RENDER_MONO
{ "Gray rendering", gintctl_gint_grayrender, 0 },
#endif
{ "GDB", gintctl_gint_gdb, 0},
{ NULL, NULL, 0 },
}};