Compare commits

...

9 Commits
master ... dev

42 changed files with 486 additions and 229 deletions

2
.gitignore vendored
View File

@ -2,10 +2,12 @@
build-fx/
build-cg/
build-cg-push/
build-fxg3a/
# Targets
gintctl.g1a
gintctl.g3a
gintctl-fx.g3a
# Development files
*.sublime-*

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
@ -75,6 +77,7 @@ set(ASSETS_fx
assets-fx/img/opt_gint_cpumem.png
assets-fx/img/opt_gint_dma.png
assets-fx/img/opt_gint_drivers.png
assets-fx/img/opt_gint_gdb.png
assets-fx/img/opt_gint_gray.png
assets-fx/img/opt_gint_keyboard.png
assets-fx/img/opt_gint_kmalloc.png
@ -122,7 +125,7 @@ fxconv_declare_assets(${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)
add_executable(gintctl ${SOURCES} ${ASSETS_${FXSDK_PLATFORM}})
target_compile_options(gintctl PRIVATE
-Wall -Wextra -Os)
-Wall -Wextra -Os -g)
target_link_options(gintctl PRIVATE
-Wl,-Map=map -Wl,--print-memory-usage)
target_include_directories(gintctl PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
@ -143,4 +146,7 @@ elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
add_custom_command(TARGET gintctl POST_BUILD
COMMAND echo -n "g3a file size: "
COMMAND stat -c %s "${CMAKE_CURRENT_SOURCE_DIR}/gintctl.g3a")
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G_G3A)
generate_g3a(TARGET gintctl OUTPUT "gintctl-fx.g3a"
NAME "" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
endif()

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -5,7 +5,9 @@
#ifndef _GINTCTL_ASSETS
#define _GINTCTL_ASSETS
#ifdef FX9860G
#include <gint/config.h>
#if GINT_RENDER_MONO
#include <libimg.h>
@ -26,6 +28,7 @@ extern bopti_image_t
img_opt_gint_bopti,
img_opt_gint_cpumem,
img_opt_gint_drivers,
img_opt_gint_gdb,
img_opt_gint_gray,
img_opt_gint_keyboard,
img_opt_gint_kmalloc,
@ -56,9 +59,9 @@ extern bopti_image_t
extern img_t
img_libimg_swords;
#endif /* FX9860G */
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
extern bopti_image_t
img_kbd_events,
@ -74,6 +77,6 @@ extern bopti_image_t
img_libimg_sq_odd,
img_libimg_train;
#endif /* FXCG50 */
#endif
#endif /* _GINTCTL_ASSETS */

View File

@ -5,6 +5,8 @@
#ifndef GINTCTL_GINT
#define GINTCTL_GINT
#include <gint/config.h>
/* gintctl_gint_cpumem(): Detected CPU and memory configuration */
void gintctl_gint_cpumem(void);
@ -62,14 +64,14 @@ void gintctl_gint_usb(void);
/* gintctl_gint_usbtrace(): A detailed USB troubleshooter */
void gintctl_gint_usbtrace(void);
#ifdef FX9860G
/* gintctl_gint_gray(): Gray engine tuning */
void gintctl_gint_gray(void);
/* gintctl_gint_grayrender(): Gray rendering functions */
void gintctl_gint_grayrender(void);
#endif /* FX9860G */
/* gintctl_gint_gdb(): GDB remote serial protocol */
void gintctl_gint_gdb(void);
#endif /* GINTCTL_GINT */

View File

@ -9,17 +9,16 @@
#include <stdint.h>
#include <gint/keyboard.h>
#include <gint/usb-ff-bulk.h>
#include <gint/config.h>
//---
// Platform disambiguation functions
//---
#ifdef FX9860G
#define _(fx,cg) fx
#endif
#ifdef FXCG50
#define _(fx,cg) cg
#if GINT_HW_FX || GINT_FX9860G_G3A
# define _(fx,cg) fx
#else
# define _(fx,cg) cg
#endif
//---
@ -84,7 +83,7 @@ void scrollbar_px(int view_top, int view_bottom, int range_min, int range_max,
// F-key rendering
//---
#ifdef FXCG50
#if GINT_RENDER_RGB
/* fkey_action(): A black-on-white F-key */
void fkey_action(int position, char const *text);
@ -95,12 +94,12 @@ void fkey_button(int position, char const *text);
/* fkey_menu(): A rectangular F-key with the bottom right corner removed */
void fkey_menu(int position, char const *text);
#endif /* FXCG50 */
//---
// USB commands
//---
void gintctl_handle_usb_command(usb_fxlink_header_t const *header);
#endif /* FXCG50 */
#endif /* GINTCTL_UTIL */

View File

@ -47,12 +47,12 @@ struct gscreen_tab {
function bar. To show a title/function bar on some tabs but not all, create
one here and use gscreen_set_tab_{title,fkeys}_visible(). */
#ifdef FX9860G
#if GINT_RENDER_MONO
gscreen *gscreen_create(char const *title, bopti_image_t const *fkeys);
#define gscreen_create2(short, img, long, fkeys) gscreen_create(short, img)
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
gscreen *gscreen_create(char const *title, char const *fkeys);
#define gscreen_create2(short, img, long, fkeys) gscreen_create(long, fkeys)
#endif

View File

@ -2,6 +2,7 @@
#include <gint/keyboard.h>
#include <gint/display.h>
#include <gint/mmu.h>
#include <gint/config.h>
#include <gintctl/gint.h>
#include <gintctl/util.h>
@ -15,23 +16,21 @@ extern uint32_t cpu_getVBR(void);
extern uint32_t
brom, srom, /* Limits of ROM mappings */
sdata, rdata, /* User's data section */
sbss, rbss; /* User's BSS section */
#ifdef FX9860G
extern uint32_t sgmapped; /* Permanently mapped functions */
#endif
sbss, rbss, /* User's BSS section */
sgmapped; /* Permanently mapped functions */
/* MPU type and processor version */
void show_mpucpu(void)
{
char const *mpu_names[] = {
#ifdef FX9860G
#if GINT_RENDER_MONO
"Unknown",
"SH-3 SH7337",
"SH-4A SH7305",
"SH-3 SH7355",
"SH-4A SH7724",
#else
#elif GINT_RENDER_RGB
"Unknown MPU product",
"SH-3-based SH7337",
"SH-4A-based SH7305",
@ -83,7 +82,7 @@ void show_mpucpu(void)
__asm__("stc sr, %0" : "=r"(SR));
__asm__("mov r15, %0" : "=r"(r15));
#ifdef FX9860G
#if GINT_RENDER_MONO
extern font_t font_mini;
font_t const *old_font = dfont(&font_mini);
@ -110,7 +109,7 @@ void show_mpucpu(void)
dfont(old_font);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(1, 1, "Calculator model: %s", str_calc);
row_print(3, 1, "MPU: %s", str_mpu);
row_print(4, 1, " Status Register: %08x", SR);
@ -127,7 +126,7 @@ void show_mpucpu(void)
/* Memory */
static void show_memory(void)
{
#ifdef FX9860G
#if GINT_RENDER_MONO
extern font_t font_mini;
font_t const *old_font = dfont(&font_mini);
print_prefix(28, 10, "brom", "%08X", &brom);
@ -147,7 +146,7 @@ static void show_memory(void)
dfont(old_font);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
uint32_t base_ram = 0x88000000;
if(gint[HWCALC] == HWCALC_FXCG50) base_ram = 0x8c000000;
@ -219,13 +218,13 @@ void gintctl_gint_cpumem(void)
if(tab == 0) show_mpucpu();
if(tab == 1) show_memory();
#ifdef FX9860G
#if GINT_RENDER_MONO
row_title("CPU and memory");
extern bopti_image_t img_opt_gint_cpumem;
dimage(0, 56, &img_opt_gint_cpumem);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Processor and memory");
fkey_menu(1, "MPU/CPU");
fkey_menu(2, "MEMORY");

View File

@ -14,7 +14,7 @@
void show_dma(int x, int y, GUNUSED int channel, sh7305_dma_channel_t *dma)
{
#ifdef FX9860G
#if GINT_RENDER_MONO
int dx=60, dy=8;
dprint(x, y, "SAR:");
dprint(x, y+1*dy, "DAR:");
@ -26,7 +26,7 @@ void show_dma(int x, int y, GUNUSED int channel, sh7305_dma_channel_t *dma)
dprint(x+dx, y+3*dy, "%08X", dma->CHCR);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
int dx=45, dy=14;
dprint(x, y, "DMA%d:", channel);
dprint(x, y+1*dy, "SAR");
@ -64,7 +64,7 @@ void gintctl_gint_dma(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
show_dma(1, 0, channel, addr[channel]);
dprint(1, 32, "Channel DMA%d", channel);
dprint(1, 40, "Interrupts %s", interrupts ? "Yes" : "No");
@ -75,7 +75,7 @@ void gintctl_gint_dma(void)
dimage(0, 56, &img_opt_gint_dma);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Direct Memory Access status");
show_dma(6, 24, 0, addr[0]);

View File

@ -20,7 +20,7 @@
static void draw_list(int offset, int maximum)
{
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(1, 2, "Id");
row_print(1, 5, "Name");
row_print(1, 13, "Size");
@ -97,7 +97,7 @@ static void draw_state(gint_world_t world, int i)
{
dma_state_t const *s = world[i];
#ifdef FX9860G
#if GINT_RENDER_MONO
for(int i = 0; i < 6; i++) {
dprint(1, 1+6*i, C_BLACK, "%d: %08X->%08X %08X",
i, s->ch[i].SAR, s->ch[i].DAR, s->ch[i].CHCR);
@ -105,7 +105,7 @@ static void draw_state(gint_world_t world, int i)
dprint(1, 43, C_BLACK, "OR: %08X", s->OR);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
for(int i = 0; i < 6; i++) {
int y=3+5*(i/3), x=1+16*(i%3);
row_print(y, x, "%d:", i);
@ -125,7 +125,7 @@ static void draw_state(gint_world_t world, int i)
{
intc_state_t const *s = world[i];
#ifdef FX9860G
#if GINT_RENDER_MONO
for(int i = 0; i < 12; i++) {
dprint(1+32*(i%4),1+6*(i/4), C_BLACK, "%c:%04X", 'A'+i, s->IPR[i]);
}
@ -134,7 +134,7 @@ static void draw_state(gint_world_t world, int i)
}
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
for(int i = 0; i < 12; i++) {
row_print(3+i/4, 1+11*(i%4), "IPR%c:", 'A'+i);
row_print(3+i/4, 6+11*(i%4), "%04X", s->IPR[i]);
@ -170,14 +170,14 @@ static void draw_state(gint_world_t world, int i)
{
spu_state_t const *s = world[i];
#ifdef FX9860G
#if GINT_RENDER_MONO
dprint(1, 1, C_BLACK, "PBANKC0: %08X", s->PBANKC0);
dprint(1, 7, C_BLACK, "PBANKC1: %08X", s->PBANKC1);
dprint(1, 13, C_BLACK, "XBANKC0: %08X", s->XBANKC0);
dprint(1, 19, C_BLACK, "XBANKC1: %08X", s->XBANKC1);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(3,1, "PBANKC0: %08X PBANKC1: %08X", s->PBANKC0, s->PBANKC1);
row_print(4,1, "XBANKC0: %08X XBANKC1: %08X", s->XBANKC0, s->XBANKC1);
#endif
@ -196,14 +196,14 @@ static void draw_state(gint_world_t world, int i)
tmu_state_t const *s = world[i];
for(int k = 0; k < 9; k++) {
#ifdef FX9860G
#if GINT_RENDER_MONO
if(k < 3) dprint(1, 6*k, C_BLACK, "TMU%d: CNT:%08X TCR:%04X %s",
k, s->t[k].TCNT, s->t[k].TCR, (s->TSTR & (1<<k) ? "STR" : ""));
else dprint(1, 6*k, C_BLACK, "E%d: TCNT:%08X TCR:%02X TSTR:%02X",
k-3, s->t[k].TCNT, s->t[k].TCR, s->t[k].TSTR);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(k+3, 1, "%sTMU%d:", (k<3 ? "" : "E"), (k<3 ? k : k-3));
if(k < 3) row_print(k+3, 8, "%08X/%08X TCR:%04X",
s->t[k].TCNT, s->t[k].TCOR, s->t[k].TCR);
@ -234,7 +234,7 @@ struct switch_stats {
static void draw_manual(struct switch_stats *stats)
{
#ifdef FX9860G
#if GINT_RENDER_MONO
row_print(2, 1, "World switches: %d", stats->world_switch_count);
row_print(3, 1, "Return-to-menu: %d", stats->return_to_menu_count);
// row_print(4, 1, "Switch time: %d µs", stats->world_switch_time);
@ -243,7 +243,7 @@ static void draw_manual(struct switch_stats *stats)
row_print(7, 1, "[3]: Measure perf");
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(1, 1, "World switches performed: %d",
stats->world_switch_count);
row_print(2, 1, "Return-to-menu performed: %d",
@ -269,12 +269,12 @@ void gintctl_gint_drivers(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
if(tab == 0 || tab == 3) row_print(1, 1, "Drivers and worlds");
dimage(0, 56, &img_opt_gint_drivers);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Drivers and world switches");
fkey_menu(1, "DRIVERS");
fkey_menu(2, "OS");

View File

@ -4,7 +4,7 @@
#include <gintctl/gint.h>
#include <gintctl/util.h>
#ifdef FXCG50
#if GINT_HW_CG && GINT_RENDER_RGB
extern void dsp_ldrc(void);
extern int dsp_padd(int x, int y);

View File

@ -19,17 +19,15 @@ struct region {
};
static struct region const regs[] = {
#ifdef FX9860G
#if GINT_HW_FX
{ "ROM", 0x80000000, 0x807fffff, 8 },
{ "RAM", 0x88000000, 0x88040000, 1 },
{ "RS", 0xfd800000, 0xfd8007ff, 1 },
#endif
#ifdef FXCG50
{ "RS", 0xfd800000, 0xfd803fff, 1 },
#elif GINT_HW_CG
{ "ROM", 0x80000000, 0x81ffffff, 32 },
{ "RAM_88", 0x88000000, 0x881fffff, 2 },
{ "RAM_8C", 0x8c000000, 0x8c7fffff, 8 },
{ "RS", 0xfd800000, 0xfd8007ff, 1 },
{ "RS", 0xfd800000, 0xfd803fff, 1 },
#endif
};
@ -116,7 +114,7 @@ void gintctl_gint_dump(void)
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
row_print(1, 1, "Memory dump");
row_print(3, 1, "Region: %s", regs[region].name);
@ -131,7 +129,7 @@ void gintctl_gint_dump(void)
if(retcode < 0) dprint(77, 56, C_BLACK, "E%d",retcode);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Memory dump to filesystem");
row_print(1, 1, "Region:");

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)

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

@ -0,0 +1,106 @@
#include <gint/display.h>
#include <gint/gdb.h>
#include <gint/mpu/power.h>
#include <gint/mpu/ubc.h>
#include <gint/ubc.h>
#include <gint/config.h>
#include <gintctl/assets.h>
#include <gintctl/gint.h>
#include <gintctl/util.h>
#include <stdio.h>
#ifdef FXCG50
static void val(int y, const char *name, uint32_t value)
{
dtext(4, 20 + y*12, C_BLACK, name);
dprint(92, 20 + y*12, C_BLACK, "%08X", value);
}
#else
static void val(int y, const char *name, uint32_t value)
{
int px = 64 * (y / 8);
int py = 8 + 6 * (y % 8);
dtext(px, py, C_BLACK, name);
dprint(px+30, py, 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_gdb_dbgprint(void)
{
fprintf(stderr, "debug=%d\n", 73);
}
void gintctl_gint_gdb(void)
{
int key = 0;
int ret = -1;
gdb_start_on_exception();
gdb_redirect_streams(false, true);
while (key != KEY_EXIT) {
dclear(C_WHITE);
row_title(GINT_HW_SWITCH("GDB", "GDB remote serial protocol"));
#if GINT_RENDER_MONO
dimage(0, 56, &img_opt_gint_gdb);
#elif GINT_RENDER_RGB
fkey_action(6, "TRAP");
fkey_action(5, "PANICR");
fkey_action(4, "PANICW");
fkey_action(3, "I/O");
fkey_action(1, "BANK 1");
#endif
font_t const *old_font = dfont(_(&font_mini, dfont_default()));
reg(0, _("MSTP...", "MSTPCR0"), SH7305_POWER.MSTPCR0);
reg(1, "CBR0", SH7305_UBC.CBR0);
reg(2, "CRR0", SH7305_UBC.CRR0);
val(3, "CAR0", SH7305_UBC.CAR0);
val(4, "CAMR0", SH7305_UBC.CAMR0);
reg(5, "CBR1", SH7305_UBC.CBR1);
reg(6, "CRR1", SH7305_UBC.CRR1);
val(7, "CAR1", SH7305_UBC.CAR1);
val(8, "CAMR1", SH7305_UBC.CAMR1);
val(9, "CDR1", SH7305_UBC.CDR1);
val(10, "CDMR1", SH7305_UBC.CDMR1);
reg(11, "CETR1", SH7305_UBC.CETR1);
reg(12, "CCMFR", SH7305_UBC.CCMFR);
reg(13, "CBCR", SH7305_UBC.CBCR);
val(14, "DBR", (uint32_t) ubc_getDBR());
#ifdef FX9860G
val(15, "ret", ret);
#endif
#ifdef FXCG50
dprint(176, 20, C_BLACK, "ret: %d", ret);
dprint(176, 32, C_BLACK, "exc_catcher: %p", gint_exc_catcher);
#endif
dfont(old_font);
dupdate();
key_event_t ev = gintctl_getkey();
key = ev.key;
volatile uint32_t* miss = (void*)0x41414140;
if (key == KEY_F6) {
__asm__("trapa #42");
} else if (key == KEY_F5) {
ret = *miss;
} else if (key == KEY_F4) {
*miss = 0x1337;
} else if (key == KEY_F3) {
fprintf(stderr, "debug=%d\n", 42);
} else if (key == KEY_F1) {
ret = gintctl_gint_gdb_bank1_test();
}
}
}

View File

@ -1,13 +1,14 @@
#ifdef FX9860G
#include <gint/gray.h>
#include <gint/keyboard.h>
#include <gint/hardware.h>
#include <gint/config.h>
#include <gintctl/gint.h>
#include <string.h>
#include <stdio.h>
#if GINT_HW_FX
/* gintctl_gint_gray(): Gray engine tuning */
void gintctl_gint_gray(void)
{
@ -83,6 +84,10 @@ void gintctl_gint_gray(void)
dgray(DGRAY_OFF);
}
#endif
#if GINT_RENDER_MONO
/* gintctl_gint_grayrender(): Gray rendering functions */
void gintctl_gint_grayrender(void)
{
@ -154,4 +159,4 @@ void gintctl_gint_grayrender(void)
dgray(DGRAY_OFF);
}
#endif /* FX9860G */
#endif

View File

@ -1,10 +1,11 @@
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/config.h>
#include <gintctl/gint.h>
#include <gintctl/util.h>
#ifdef FXCG50
#if GINT_RENDER_RGB
static void scene_1(void)
{
dclear(0x5555);
@ -196,7 +197,7 @@ void gintctl_gint_image(void)
}
#endif
#ifdef FX9860G
#if GINT_RENDER_MONO
static void img(int x, int y, bopti_image_t *img, int sub, int flags)
{
int ix = 0;

View File

@ -9,7 +9,7 @@
static void position(int row, int col, int *x, int *y, int *w, int *h)
{
#ifdef FX9860G
#if GINT_RENDER_MONO
*x = 1 + (5 + (row>=5)) * col;
*y = 1 + 4 * row + (row >= 1) + (row >= 3);
*w = 4;
@ -23,7 +23,7 @@ static void position(int row, int col, int *x, int *y, int *w, int *h)
}
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
if(row == 0) *y=2, *x=7+29*col, *w=16, *h=16;
if(row >= 5) *y=108+23*(row-5), *x=2+35*col, *w=30, *h=17;
if(row >= 1 && row <= 4)
@ -103,13 +103,13 @@ static void render(keydev_t *d, key_event_t *last_events, int counter)
key_event_t ev;
dclear(C_WHITE);
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Keyboard state visualizer");
int y0=190, dy=14, maxev=12;
int x1=290, x2=350;
#endif
#ifdef FX9860G
#if GINT_RENDER_MONO
row_print(1, 1, "Keyboard state");
dimage(0, 56, &img_opt_gint_keyboard);
int y0=47, dy=7, maxev=6;
@ -134,7 +134,7 @@ static void render(keydev_t *d, key_event_t *last_events, int counter)
render_keyboard(d, _(2,10), _(6,21));
int tr = d->tr.enabled;
#ifdef FX9860G
#if GINT_RENDER_MONO
dtext(35, 10, C_BLACK, "Shift:");
render_option(35, 16, "Del", (tr & KEYDEV_TR_DELAYED_SHIFT) != 0);
render_option(47, 16, "Ins", (tr & KEYDEV_TR_INSTANT_SHIFT) != 0);
@ -153,7 +153,7 @@ static void render(keydev_t *d, key_event_t *last_events, int counter)
dfont(old_font);
#endif /* FX9860G */
#ifdef FXCG50
#if GINT_RENDER_RGB
dtext(200, 30, C_BLACK, "Shift:");
render_icon(245, 30, d->delayed_shift ? 7 : (d->pressed_shift ? 6 : 5));
render_option(205, 42, "Del", (tr & KEYDEV_TR_DELAYED_SHIFT) != 0);

View File

@ -20,7 +20,7 @@ static void draw_info(kmalloc_arena_t *arena)
{
int expected_os_heap_kB = _(48, 128);
#ifdef FX9860G
#if GINT_RENDER_MONO
dimage(0, 56, &img_opt_gint_kmalloc);
row_title("Heap allocators");
font_t const *old_font = dfont(&font_mini);
@ -43,7 +43,7 @@ static void draw_info(kmalloc_arena_t *arena)
dfont(old_font);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(1, 1, "Arena details:");
fkey_action(6, "ARENA");
@ -105,7 +105,7 @@ static void m_clear(void *ptr[MANUAL_COUNT], uint16_t size[MANUAL_COUNT])
static void draw_manual(void *ptr[MANUAL_COUNT], uint16_t size[MANUAL_COUNT],
int cursor)
{
#ifdef FX9860G
#if GINT_RENDER_MONO
row_title("Manual allocation");
font_t const *old_font = dfont(&font_mini);
#endif
@ -130,14 +130,14 @@ static void draw_manual(void *ptr[MANUAL_COUNT], uint16_t size[MANUAL_COUNT],
for(int c = 0; c < 6; c++) dprint(_(88,275), _(15+6*c,row_y(c+2)), C_BLACK,
"%c: %d", 'A'+c, m_classes[c]);
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(1, 1, "Manual allocation test:");
dprint(265, row_y(1), C_BLACK, "Allocate:");
dprint(265, row_y(8), C_BLACK, "Free:");
dprint(275, row_y(9), C_BLACK, "AC/ON");
#endif
#ifdef FX9860G
#if GINT_RENDER_MONO
dprint(88, 9, C_BLACK, "ON: 0");
dfont(old_font);
#endif
@ -181,14 +181,14 @@ static void run_fill(char const *arena, uint8_t classes[FILL_CLASSES])
static void draw_fill(uint8_t classes[FILL_CLASSES])
{
#ifdef FX9860G
#if GINT_RENDER_MONO
row_title("Heap filler");
#endif
font_t const *old_font = dfont(_(&font_mini, dfont_default()));
int total = 0;
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(1, 1, "Blocks allocated to fill, by size:");
#endif
@ -237,7 +237,7 @@ struct mass_test
static void draw_mass(struct mass_test *test)
{
#ifdef FX9860G
#if GINT_RENDER_MONO
row_title("Random operations");
font_t const *old_font = dfont(&font_mini);
dprint(1, 9, C_BLACK, "Filled %d (all blocks < %d)",
@ -254,7 +254,7 @@ static void draw_mass(struct mass_test *test)
dfont(old_font);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
if(!test->done)
{
row_print(1, 1, "Mass allocation in a small space");
@ -349,7 +349,7 @@ static void draw_stats(kmalloc_arena_t *arena)
struct kmalloc_stats *s = &arena->stats;
kmalloc_gint_stats_t *S = kmalloc_get_gint_stats(arena);
#ifdef FX9860G
#if GINT_RENDER_MONO
row_title("Statistics");
font_t const *old_font = dfont(&font_mini);
@ -374,7 +374,7 @@ static void draw_stats(kmalloc_arena_t *arena)
dfont(old_font);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(1, 1, "General arena statistics:");
row_print(2, 2, "Live blocks: %d (peak: %d)",
s->live_blocks, s->peak_live_blocks);
@ -442,7 +442,9 @@ static void draw_integrity(kmalloc_arena_t *arena)
#endif /* GINT_KMALLOC_DEBUG */
}
static char const *arena_names[] = { NULL, "_uram", "_ostk", "_os" };
static char const *arena_names[] = {
NULL, "_uram", "_ostk", "_os", "pram0",
};
static kmalloc_arena_t *next_arena(int *current)
{
@ -468,6 +470,17 @@ void gintctl_gint_kmalloc(void)
kmalloc_arena_t *arena = next_arena(&current_arena);
int tab=0, key=0;
kmalloc_arena_t arena_pram0 = { 0 };
if(isSH4())
{
arena_pram0.name = "pram0";
arena_pram0.is_default = false;
arena_pram0.start = (void *)0xfe200000;
arena_pram0.end = arena_pram0.start + (1 << 16);
kmalloc_init_arena(&arena_pram0, true);
kmalloc_add_arena(&arena_pram0);
}
/* Data for the manual allocation test */
void *m_ptr[MANUAL_COUNT];
uint16_t m_size[MANUAL_COUNT];
@ -484,7 +497,7 @@ void gintctl_gint_kmalloc(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
dimage(0, 56, &img_opt_gint_kmalloc);
font_t const *old_font = dfont(&font_mini);
dprint_opt(DWIDTH-2, 54, C_BLACK, C_NONE, DTEXT_RIGHT, DTEXT_BOTTOM,
@ -499,7 +512,7 @@ void gintctl_gint_kmalloc(void)
if(tab == 4) draw_stats(arena);
draw_integrity(arena);
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Integrity and stress tests for heap allocators");
fkey_menu(1, "INFO");
fkey_menu(2, "MANUAL");
@ -575,5 +588,7 @@ void gintctl_gint_kmalloc(void)
if(tab == 3 && key == KEY_EXE) run_mass(&mass_test, arena->name);
}
if(isSH4())
kmalloc_remove_arena(&arena_pram0);
m_clear(m_ptr, m_size);
}

View File

@ -11,7 +11,7 @@
#include <libprof.h>
#include <stdio.h>
#ifdef FXCG50
#if GINT_HW_CG && GINT_RENDER_RGB
#define CPG SH7305_CPG
#define BSC SH7305_BSC

View File

@ -1,5 +1,6 @@
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/cpu.h>
#include <gintctl/util.h>
#include <gintctl/gint.h>
@ -98,29 +99,39 @@ static void explore_region(struct region *r)
{
uint8_t volatile *mem = (void *)r->mem;
r->size = 0;
r->reason = 0;
cpu_atomic_start();
while(r->size < (16 << 20))
{
int x = r->use_lword
? writable_lword(mem + r->size)
: writable(mem + r->size);
r->reason = 1;
if(!x) return;
if(!x)
{
r->reason = 1;
break;
}
if(r->size > 0)
{
int y = r->use_lword
? same_location_lword(mem, mem+r->size)
: same_location(mem, mem+r->size);
r->reason = 2;
if(y) return;
if(y)
{
r->reason = 2;
break;
}
}
r->size += r->step_size;
}
r->reason = 3;
if(r->reason == 0)
r->reason = 3;
cpu_atomic_end();
}
/* Detailed 0xe50[01]xxxx search
@ -143,7 +154,7 @@ static void e500_search(int e500_pages[32])
}
}
#ifdef FX9860G
#if GINT_RENDER_MONO
static void show_region(int row, struct region *r)
{
/* Out-of-bounds rows */
@ -178,7 +189,7 @@ static void show_region(int row, struct region *r)
}
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
static void show_region(int y, struct region *r)
{
char const *reasons[] = {
@ -219,7 +230,7 @@ void gintctl_gint_ram(void)
{ "PRAM1", 0xfe300000, true, 32, /**/ 0, 0 },
{ "XRAM1", 0xfe340000, true, 32, /**/ 0, 0 },
{ "YRAM1", 0xfe380000, true, 32, /**/ 0, 0 },
{ "X_P2", 0xa5007000, false, 4, /**/ 0, 0 },
{ "RSRAM", 0xfd800000, false, 4, /**/ 0, 0 },
{ "URAM", 0xa55f0000, false, 4, /**/ 0, 0 },
{ "RAM", 0xac000000, false, 1024, /**/ 0, 0 },
{ NULL },
@ -243,7 +254,7 @@ void gintctl_gint_ram(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
if(tab == 0) {
show_region(1, NULL);
dhline(6, C_BLACK);
@ -258,7 +269,7 @@ void gintctl_gint_ram(void)
}
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("On-chip memory discovery");
if(tab == 0) {
@ -312,7 +323,7 @@ void gintctl_gint_ram(void)
explore_region(&r[11]);
}
#ifdef FX9860G
#ifdef GINT_RENDER_MONO
int scroll_max = region_count - 8;
if(tab == 0 && key == KEY_UP)
{

View File

@ -1,6 +1,8 @@
#define __BSD_VISIBLE 1
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/config.h>
#include <gint/video.h>
#include <gintctl/util.h>
#include <math.h>
@ -29,7 +31,7 @@ void gintctl_gint_render(void)
dclear(C_WHITE);
drect_border(1, 1, DWIDTH-2, DHEIGHT-2, C_NONE, 1, C_BLACK);
#ifdef FXCG50
#if GINT_RENDER_RGB
drect_border(3, 3, DWIDTH-4, DHEIGHT-4, C_NONE, 1, C_BLACK);
#endif
@ -47,6 +49,44 @@ void gintctl_gint_render(void)
}
dupdate();
if(getkey().key == KEY_EXIT)
return;
while(getkey().key != KEY_EXIT) {}
dclear(C_WHITE);
int fill1 = _(C_NONE, C_RGB(24, 24, 24));
int fill2 = _(C_BLACK, C_RGB(24, 24, 24));
int x1 = _(5,20), x2 = _(40,90), x3 = _(64,120), x4 = _(97,220);
int y1 = _(2,20), y2 = _(19,60);
int w1 = _(26,60), h1 = _(15,30);
dellipse(x1, y1, x1+w1, y1+h1, fill1, C_BLACK);
dellipse(x1, y2, x1+w1, y2+4, fill1, C_BLACK);
dellipse(x1, y2+_(6,10), x1+w1, y2+_(6,10), fill1, C_BLACK);
dellipse(x2, y1, x2+4, y1+h1, fill1, C_BLACK);
dellipse(x2+10, y1, x2+20, y1+h1, fill1, C_BLACK);
dellipse(x3, y1, x3+w1, y1+h1, C_NONE, C_BLACK);
dellipse(x4, y1, x4+w1, y1+h1, fill2, C_NONE);
int y3 = _(40,135), y4 = _(55,170);
int r = _(10,20);
x1 += w1 / 2;
dcircle(x1, y3, w1/2, fill1, C_BLACK);
dcircle(x1, y4+2, 2, fill1, C_BLACK);
dcircle(x1, y4+_(6,10), 0, fill1, C_BLACK);
dcircle(x2+r, y3, r, fill1, C_BLACK);
dcircle(x3+w1/2, y3, r, C_NONE, C_BLACK);
dcircle(x4+w1/2, y3, r, fill2, C_NONE);
dupdate();
#if GINT_HW_CG
extern image_t gint_gdb_icons_rgb565;
video_update(0, 0, &gint_gdb_icons_rgb565, 0);
#endif
if(getkey().key == KEY_EXIT)
return;
}

View File

@ -18,7 +18,7 @@
extern bopti_image_t img_rtc_segments;
#ifdef FX9860G
#if GINT_RENDER_MONO
char const *days[7] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
@ -33,7 +33,7 @@ static int x0=20, y0=8, dx=13;
static int yd=36, eyd=12;
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
char const *days[7] = {
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
"Saturday"
@ -80,14 +80,14 @@ static void draw_time(rtc_time_t *time, int edit_field)
int x = x0 + (2 * dx + cw) * edit_field - 1;
int y = y0 - 1;
#ifdef FX9860G
#if GINT_RENDER_MONO
drect(x, y, x + 2*dx - 1, y + sh+1, C_INVERT);
row_print(6, 1, "EXE: Set time");
row_print(7, 1, "EXIT: Cancel");
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
for(int a = y - 1; a <= y + sh + 2; a++)
for(int b = x - 1; b <= x + 2*dx - 2; b++)
{
@ -134,14 +134,14 @@ static void draw_date(rtc_time_t *time, int edit_field)
for(int i = 0; i < edit_field; i++)
x += w[i] + space_width + 2;
#ifdef FX9860G
#if GINT_RENDER_MONO
drect(xd+x-1, y-1, xd+x+w[edit_field], y+h, C_INVERT);
row_print(6, 1, "EXE: Set date");
row_print(7, 1, "EXIT: Cancel");
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
for(int a = y-2; a <= y+h; a++)
for(int b = xd+x-2; b <= xd+x+w[edit_field]+1; b++)
{
@ -167,12 +167,12 @@ static void draw_rtc(rtc_time_t *time)
draw_time(time, -1);
draw_date(time, -1);
#ifdef FX9860G
#if GINT_RENDER_MONO
extern bopti_image_t img_opt_gint_rtc;
dsubimage(0, 56, &img_opt_gint_rtc, 0, 0, 128, 8, DIMAGE_NONE);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Real-Time Clock");
fkey_menu(1, "RTC");
fkey_menu(2, "TIMER");
@ -191,7 +191,7 @@ static void draw_speed(rtc_time_t *time, uint32_t elapsed)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
extern bopti_image_t img_opt_gint_rtc;
row_print(1, 1, "Speed of RTC vs TMU");
dsubimage(0, 56, &img_opt_gint_rtc, 0, 9, 128, 8, DIMAGE_NONE);
@ -200,7 +200,7 @@ static void draw_speed(rtc_time_t *time, uint32_t elapsed)
row_print(4, 1, "TMU time: %d us", elapsed);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Speed comparison of RTC and timers");
fkey_menu(1, "RTC");
fkey_menu(2, "TIMER");
@ -335,7 +335,7 @@ static void edit_time(void)
{
dclear(C_WHITE);
draw_time(&time, edit_field);
#ifdef FXCG50
#if GINT_RENDER_RGB
draw_date(&time, -1);
row_title("Real-Time Clock");
#endif
@ -403,13 +403,13 @@ static void edit_date(void)
while(key != KEY_EXE && key != KEY_EXIT)
{
dclear(C_WHITE);
#ifdef FXCG50
#if GINT_RENDER_RGB
draw_time(&time, -1);
row_title("Real-Time Clock");
#endif
draw_date(&time, edit_field);
#ifdef FX9860G
#if GINT_RENDER_MONO
extern bopti_image_t img_opt_gint_rtc;
if(edit_field == 0)
dsubimage(0, 56, &img_opt_gint_rtc, 0, option_tab*9+18,
@ -419,7 +419,7 @@ static void edit_date(void)
128, 8, DIMAGE_NONE);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
char const *fkey_days[] = {
"SUN", "MON", "TUE", "WED", "THUR", "FRI", "SAT"
};

View File

@ -40,7 +40,7 @@ static void restore(volatile uint32_t *area, uint32_t *save, int pages)
}
}
#ifdef FX9860G
#if GINT_RENDER_MONO
static void render_header(int y, GUNUSED int bank_count)
{
y = 9 + 6*y;
@ -88,7 +88,7 @@ static void render_bank(int y, char const *name, volatile uint32_t *bank,
}
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
static void render_header(int y, int bank_count)
{
dtext(row_x(2), row_y(y), C_BLACK, "Area:");
@ -168,7 +168,7 @@ void gintctl_gint_spuram(void)
int switch_key = _(KEY_F6, KEY_F1);
#ifdef FX9860G
#if GINT_RENDER_MONO
int tab = 0;
#endif
@ -176,7 +176,7 @@ void gintctl_gint_spuram(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
row_title("SPU memory banking");
extern font_t font_hexa;
@ -210,7 +210,7 @@ void gintctl_gint_spuram(void)
(tab == 1 ? 128 : 107), 8, DIMAGE_NONE);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("SPU memory: PRAM0, XRAM0, YRAM0, YRAM");
row_print(1, 1, "Pages layout in memory (offsets in kiB):");
@ -258,7 +258,7 @@ void gintctl_gint_spuram(void)
SPU.XBANKC1 ^= (1 << cur_page);
}
#ifdef FX9860G
#if GINT_RENDER_MONO
if(key == KEY_F1) tab = 0;
if(key == KEY_F2) tab = 1;
#endif

View File

@ -16,7 +16,7 @@ void timer_print(int x, int y, char const *name, uint32_t TCOR, uint32_t TCNT,
int dy = _(8,14);
dprint(x, y, C_BLACK, "%s:", name);
#ifdef FXCG50
#if GINT_RENDER_RGB
dprint(x, y+dy, C_BLACK, "TCOR");
dprint(x, y+2*dy, C_BLACK, "TCNT");
#endif
@ -46,7 +46,7 @@ void etmu_print(int x, int y, char const *name, etmu_t *etmu)
}
#ifdef FX9860G
#if GINT_RENDER_MONO
static int x[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
static int y[] = { 0, 16, 32, 0, 16, 32, 0, 16, 32 };
#else
@ -100,7 +100,7 @@ void gintctl_gint_timer(void)
int key=0, tid=0;
GUNUSED int timeout=1;
#ifdef FX9860G
#if GINT_RENDER_MONO
int tab = 1;
#endif
@ -108,7 +108,7 @@ void gintctl_gint_timer(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
if(tab == 1) show_tmu();
if(tab == 2) show_etmu_1();
if(tab == 3) show_etmu_2();
@ -123,7 +123,7 @@ void gintctl_gint_timer(void)
dfont(old_font);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Timer status");
show_tmu();
@ -151,7 +151,7 @@ void gintctl_gint_timer(void)
if(free == tid) timer_start(tid);
}
#ifdef FX9860G
#if GINT_RENDER_MONO
/* On F4, F5 and F6, switch tabs */
if(key == KEY_F4) tab = 1;
if(key == KEY_F5) tab = 2;

View File

@ -53,7 +53,7 @@ void gintctl_gint_timer_callbacks(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
row_title("Timer callbacks");
row_print(3, 1, "F1:Simple callback");
@ -68,7 +68,7 @@ void gintctl_gint_timer_callbacks(void)
dprint(86, 56, C_BLACK, "Done:%d", tests);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Interrupt management in timer callbacks");
row_print(1, 1,

View File

@ -11,7 +11,7 @@
#define PAGE_MAPPED 0x02
#define TLB_VIEW_MAX (64 - TLB_VIEW)
#ifdef FXCG50
#if GINT_RENDER_RGB
#define PAGE_COUNT 0x200
#define SQUARE_WIDTH 8
#define SQUARE_HEIGHT 8
@ -36,7 +36,7 @@ static void draw_rom_cell(int x, int y, int status)
}
#endif
#ifdef FX9860G
#if GINT_RENDER_MONO
#define PAGE_COUNT 0x80
#define SQUARE_WIDTH 5
#define SQUARE_HEIGHT 5
@ -110,7 +110,7 @@ static void explore_pages(uint8_t *pages, uint32_t *next_miss)
}
}
#ifdef FXCG50
#if GINT_RENDER_RGB
void show_utlb(int row, int E)
{
if(E == -1)
@ -198,7 +198,7 @@ void show_itlb(int row, int E)
}
#endif
#ifdef FX9860G
#if GINT_RENDER_MONO
void show_utlb(int row, int E)
{
extern font_t font_mini;
@ -305,7 +305,6 @@ void show_itlb(int row, int E)
uint32_t src = addr.VPN << 10;
uint32_t dst = data.PPN << 10;
int valid = (addr.V != 0) && (data.V != 0);
int size = (data.SZ1 << 1) | data.SZ0;
dprint( 1, y, C_BLACK, "%d", E);
@ -330,19 +329,19 @@ static void draw(int tab, uint8_t *pages, uint32_t next_miss, int tlb_scroll)
uint32_t rom_size = (uint32_t)&srom;
int rom_pages = (rom_size + (1 << 12)-1) >> 12;
#ifdef FX9860G
#if GINT_RENDER_MONO
if(tab != 2 && tab != 3)
#endif
row_title(_("TLB management", "TLB miss handler and TLB management"));
#ifdef FX9860G
#if GINT_RENDER_MONO
extern font_t font_mini;
font_t const *old_font = dfont(&font_mini);
#endif
if(tab == 0)
{
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(1, 1, "Size of ROM sections: %08X (%d pages of 4k)",
rom_size, rom_pages);
#endif
@ -360,7 +359,7 @@ static void draw(int tab, uint8_t *pages, uint32_t next_miss, int tlb_scroll)
_(11,36) + rom_cell_y(p), pages[p]);
}
#ifdef FXCG50
#if GINT_RENDER_RGB
if(next_miss != 0xffffffff)
{
uint p = (next_miss - 0x00300000) >> 12;
@ -392,7 +391,7 @@ static void draw(int tab, uint8_t *pages, uint32_t next_miss, int tlb_scroll)
dprint(_(72,212), _(22,50), C_BLACK,
_("Mapped", "Currently mapped"));
#ifdef FXCG50
#if GINT_RENDER_RGB
draw_rom_cell(18, 64, -1);
dprint(30, 64, C_BLACK, "Next page to load");
@ -410,7 +409,7 @@ static void draw(int tab, uint8_t *pages, uint32_t next_miss, int tlb_scroll)
"data before the intended TLB miss occurs.");
#endif
#ifdef FX9860G
#if GINT_RENDER_MONO
dprint(1, 30, C_BLACK, "Size of ROM text: %X (%d pages)",
rom_size, rom_pages);
@ -430,11 +429,11 @@ static void draw(int tab, uint8_t *pages, uint32_t next_miss, int tlb_scroll)
for(int i = 0; i < TLB_VIEW; i++)
show_utlb(i+2, tlb_scroll+i);
#ifdef FX9860G
#if GINT_RENDER_MONO
dhline(6, C_BLACK);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
dline(12, 34, 363, 34, C_BLACK);
#endif
@ -450,23 +449,23 @@ static void draw(int tab, uint8_t *pages, uint32_t next_miss, int tlb_scroll)
for(int E = 0; E < 4; E++)
show_itlb(E+2, E);
#ifdef FX9860G
#if GINT_RENDER_MONO
dhline(6, C_BLACK);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
dline(12, 34, 363, 34, C_BLACK);
#endif
}
#ifdef FX9860G
#if GINT_RENDER_MONO
dfont(old_font);
extern bopti_image_t img_opt_gint_tlb;
dimage(0, 56, &img_opt_gint_tlb);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
fkey_menu(1, "ROM");
fkey_menu(2, "INFO");
fkey_menu(3, "TLB");
@ -485,6 +484,8 @@ static int generate_tlb_miss(volatile void *arg)
static int test_function(int x, int y)
{
(void)x;
(void)y;
return 0;
}

View File

@ -174,14 +174,14 @@ static void draw_registers(GUNUSED int scroll)
val(40, "MSELCRA", *MSELCRA);
val(41, "MSELCRB", *MSELCRB);
#ifdef FX9860G
#if GINT_RENDER_MONO
if(scroll >= 14) dprint(3, 50 - 6 * (scroll - 14), C_BLACK,
"USBCLKCR:%08X", SH7305_CPG.USBCLKCR.lword);
if(scroll >= 15) dprint(3, 50 - 6 * (scroll - 15), C_BLACK,
"MSTPCR2: %08X", SH7305_POWER.MSTPCR2.lword);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
dprint(row_x(1), 188, C_BLACK, "USBCLKCR:%08X MSTPCR2:%08X",
SH7305_CPG.USBCLKCR.lword, SH7305_POWER.MSTPCR2.lword);
#endif
@ -301,7 +301,7 @@ static int draw_log(int offset)
static void draw_pipes(void)
{
#ifdef FXCG50
#if GINT_RENDER_RGB
char const *PID[4] = { "NAK", "BUF", "STALL0", "STALL1" };
char const *BSTS[2] = { "Disabled", "Enabled" };
char const *FRDY[2] = { "NotReady", "Ready" };
@ -347,7 +347,7 @@ static void draw_pipes(void)
static void draw_tests(GUNUSED struct alignment_write_data *data)
{
#ifdef FX9860G
#if GINT_RENDER_MONO
dprint(1, 8, C_BLACK, "1: Screenshot");
dprint(1, 14, C_BLACK, "2: Async screenshot");
dprint(1, 20, C_BLACK, "3: Send text");
@ -355,7 +355,7 @@ static void draw_tests(GUNUSED struct alignment_write_data *data)
dprint(1, 32, C_BLACK, "5: FIFO alignm. test");
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(1, 1, "[1]: Take screenshot (fxlink API)");
row_print(2, 1, "[2]: Take screenshot (asynchronous)");
row_print(3, 1, "[3]: Send some text (fxlink API)");
@ -473,7 +473,7 @@ void gintctl_gint_usb(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
row_title("USB 2.0 communication");
dsubimage(0, 56, &img_opt_gint_usb, 0, open * 9, 128, 9, DIMAGE_NONE);
if(tab == 0) scrollbar_px(8, 52, 0, 22, scroll0, 8);
@ -487,7 +487,7 @@ void gintctl_gint_usb(void)
if(tab == 3) draw_pipes();
if(tab == 4) draw_tests(&awd);
#ifdef FXCG50
#if GINT_RENDER_RGB
if(tab == 2)
row_title("USB logs (SHIFT+7: Save to file, SHIFT+8: Clear)");
else
@ -532,7 +532,7 @@ void gintctl_gint_usb(void)
if(keydown(KEY_SHIFT)) scroll_speed = 4;
if(keydown(KEY_ALPHA)) scroll_speed = 16;
#ifdef FX9860G
#if GINT_RENDER_MONO
if(tab == 0 && key == KEY_UP && scroll0 > 0) scroll0--;
if(tab == 0 && key == KEY_DOWN && scroll0 < 15) scroll0++;
#endif

View File

@ -14,7 +14,7 @@
#include <string.h>
#include <stdio.h>
#ifdef FXCG50
#if GINT_RENDER_RGB
#define USB SH7305_USB

View File

@ -5,10 +5,8 @@
#include <gint/hardware.h>
#include <gint/usb.h>
#include <gint/usb-ff-bulk.h>
#ifdef FX9860G
#include <gint/config.h>
#include <gint/gray.h>
#endif
#include <gintctl/util.h>
#include <gintctl/menu.h>
@ -34,14 +32,14 @@ struct menu menu_gint = {
{ "CPU and memory", gintctl_gint_cpumem, 0 },
{ "RAM discovery", gintctl_gint_ram, MENU_SH4_ONLY },
#ifdef FXCG50
#if GINT_HW_CG && GINT_RENDER_RGB
{ "DSP processors", gintctl_gint_dsp, 0 },
#endif
{ "SPU memory", gintctl_gint_spuram, MENU_SH4_ONLY },
{ "Memory dump", gintctl_gint_dump, 0 },
{ "Drivers and worlds", gintctl_gint_drivers, 0 },
{ "TLB management", gintctl_gint_tlb, 0 },
#ifdef FXCG50
#if GINT_HW_CG && GINT_RENDER_RGB
{ "Overclocking", gintctl_gint_overclock, MENU_SH4_ONLY },
#endif
{ "Memory allocation", gintctl_gint_kmalloc, 0 },
@ -51,16 +49,19 @@ struct menu menu_gint = {
{ "DMA control", gintctl_gint_dma, MENU_SH4_ONLY },
{ "Real-time clock", gintctl_gint_rtc, 0 },
{ "USB communication", gintctl_gint_usb, MENU_SH4_ONLY },
#ifdef FXCG50
#if GINT_HW_CG && GINT_RENDER_RGB
{ "USB tracer", gintctl_gint_usbtrace, MENU_SH4_ONLY },
#endif
{ "Basic rendering", gintctl_gint_render, 0 },
{ "Image rendering", gintctl_gint_image, 0 },
{ "Text rendering", gintctl_gint_topti, 0 },
#ifdef FX9860G
#if GINT_HW_FX
{ "Gray engine", gintctl_gint_gray, 0 },
#endif
#if GINT_RENDER_MONO
{ "Gray rendering", gintctl_gint_grayrender, 0 },
#endif
{ "GDB", gintctl_gint_gdb, MENU_SH4_ONLY },
{ NULL, NULL, 0 },
}};
@ -73,7 +74,7 @@ struct menu menu_perf = {
{ _("CPU parallelism", "Superscalar and pipeline parallelism"),
gintctl_perf_cpu, 0 },
{ "Interrupt stress", gintctl_perf_interrupts, 0 },
#ifdef FXCG50
#if GINT_RENDER_RGB
{ "Memory read/write speed",
gintctl_perf_memory, 0 },
#endif
@ -206,7 +207,7 @@ key_event_t gintctl_getkey(void)
/* gintctl_main(): Show the main tab */
void gintctl_main(void)
{
#ifdef FX9860G
#if GINT_RENDER_MONO
row_title("gint %s %07x", GINT_VERSION, GINT_HASH);
row_print(3, 1, "F2:gint tests");
@ -214,9 +215,9 @@ void gintctl_main(void)
row_print(5, 1, "F4:Libraries");
row_print(6, 1, "F5:MPU registers");
row_print(7, 1, "F6:Memory map/dump");
#endif /* FX9860G */
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("gint %s (@%07x) for fx-CG 50", GINT_VERSION, GINT_HASH);
row_print(1,1, "F2: gint features and driver tests");
row_print(2,1, "F3: Performance benchmarks");
@ -227,7 +228,7 @@ void gintctl_main(void)
row_print(7,1, "This add-in is running a unikernel called gint by");
row_print(8,1, "Lephe'. Information about the project is available");
row_print(9,1, "on planet-casio.com.");
#endif /* FXCG50 */
#endif
}
static void draw(struct menu *menu)
@ -237,11 +238,11 @@ static void draw(struct menu *menu)
if(menu) menu_show(menu);
else gintctl_main();
#ifdef FX9860G
#if GINT_RENDER_MONO
dimage(0, 56, &img_opt_main);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
fkey_action(1, "INFO");
fkey_menu(2, "GINT");
fkey_menu(3, "PERF");
@ -272,7 +273,7 @@ int main(GUNUSED int isappli, GUNUSED int optnum)
/* Enable fixed-point formatters */
__printf_enable_fixed();
#ifdef FX9860G
#if GINT_RENDER_MONO
/* Use the Unicode font uf5x7 on fx-9860G */
dfont(&font_uf5x7);
#endif

View File

@ -77,6 +77,14 @@ static void table_gen(gtable *t, int row)
gtable_provide(t, c1, c2, c3);
}
static uint32_t keymap_function(int key, bool shift, bool alpha)
{
if(key == KEY_7 && shift)
return '@';
else
return keymap_translate(key, shift, alpha);
}
/* gintctl_libs_justui(): Just User Interfaces */
void gintctl_libs_justui(void)
{
@ -113,6 +121,7 @@ void gintctl_libs_justui(void)
jinput *input = jinput_create("Prompt:" _(," "), 12, tab1);
jwidget_set_stretch(input, 1, 0, false);
jinput_set_font(input, _(&font_uf5x7, dfont_default()));
jinput_set_keymap_function(input, keymap_function);
// Widget tree visualisation
@ -163,10 +172,6 @@ void gintctl_libs_justui(void)
if(key == KEY_F1) gscreen_show_tab(scr, 0);
if(key == KEY_F2) gscreen_show_tab(scr, 1);
#ifdef FX9860G
if(key == KEY_F6) screen_mono(u"\\\\fls0\\justui.bin");
#endif
}
gscreen_destroy(scr);

View File

@ -22,7 +22,7 @@ void gintctl_libs_openlibm(void)
dclear(C_WHITE);
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("OpenLibm floating-point functions");
row_print(1, 1, "Basic sine curve:");

View File

@ -96,14 +96,14 @@ static void paint_mem(int x, int y, struct view *v)
{
GUNUSED int status = line(mem, header, bytes, ascii, 8);
#ifdef FX9860G
#if GINT_RENDER_MONO
font_t const *old_font = dfont(&font_hexa);
dtext(x, y + 6*i, C_BLACK, v->ascii ? ascii : header);
dtext(x + 40, y + 6*i, C_BLACK, bytes);
dfont(old_font);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
dtext(x, y + 12*i, C_BLACK, header);
dtext(x + 85, y + 12*i, status ? C_RED : C_BLACK, bytes);
@ -182,7 +182,7 @@ void gintctl_mem(void)
gscreen_focus(s, input);
}
#ifdef FX9860G
#if GINT_RENDER_MONO
if(key == KEY_F2 && !input_focus)
{
v.ascii = !v.ascii;

View File

@ -349,6 +349,32 @@ bench raw_LS_LS_addr, 1024
2: mov.l @r5, r6
end
/* [Multiplication]
This section investigates pipeline delays in the multiplier. */
/* mul.l occupies the multiplier for 2 cycles -> 2 cycles /i */
bench mul_single_32, 1024
1: mul.l r4, r5
2: nop
end
/* The computed value can be retrieved on cycle #2 -> 2 cycles /i */
bench mul_single_32_sts, 1024
1: mul.l r4, r5
2: sts macl, r0
end
/* However it takes an incredibly long time to actually arrive, requiring 2
tempo cycles, even more than a memory load! -> 5 cycles /i */
bench mul_single_32_sts_EX, 1024
1: mul.l r4, r5
nop
sts macl, r0
2: add #1, r0
end
/* [Branching]
In this section, we investigate the cost of conditional execution and

View File

@ -46,6 +46,9 @@
MACRO(raw_EX_LS_addr, 1024, "RAW on address: EX/LS") \
MACRO(raw_EX_LS_index, 1024, "RAW on index: EX/LS") \
MACRO(raw_LS_LS_addr, 1024, "RAW on address: LS/LS") \
MACRO(mul_single_32, 1024, "Pipeline: mul.l/mul.l") \
MACRO(mul_single_32_sts, 1024, "Pipeline: mul.l/sts") \
MACRO(mul_single_32_sts_EX, 1024, "Pipeline: mul.l/sts/EX") \
MACRO(branch_bra, 1024, "Branching: bra") \
MACRO(branch_bra_cpuloop, 1024, "Branching: bra (CPU loop)") \
MACRO(darken_1, 512, "Darken: 32-bit #1") \

View File

@ -44,7 +44,7 @@ uint32_t test_cpucache_rounds(uint8_t const *buf, size_t len, int rounds)
return PLL_cycles / freq->Iphi_div;
}
#ifdef FX9860G
#if GINT_RENDER_MONO
static void tick_formatter(char *str, size_t size, int32_t v)
{
if(v == 0) snprintf(str, size, "0");
@ -72,12 +72,34 @@ void gintctl_perf_cpucache(void)
.data_y = y_time,
.data_len = SAMPLES,
#ifdef FX9860G
#if GINT_RENDER_MONO
.area = {
.x = 0, .y = 18,
.w = 128, .h = 44,
},
.color = C_BLACK,
.grid = {
.level = PLOT_MAINGRID,
.primary_color = C_BLACK,
.dotted = 1,
},
#endif
#if GINT_RENDER_RGB
.area = {
.x = 24, .y = 51,
.w = 340, .h = 120,
},
.color = C_RED,
.grid = {
.level = PLOT_FULLGRID,
.primary_color = C_RGB(20, 20, 20),
.secondary_color = C_RGB(28, 28, 28),
.dotted = 1,
},
#endif
#if GINT_HW_FX
.ticks_x = {
.multiples = 250,
.subtick_divisions = 4,
@ -88,35 +110,24 @@ void gintctl_perf_cpucache(void)
.subtick_divisions = 2,
.formatter = tick_formatter,
},
.grid = {
.level = PLOT_MAINGRID,
.primary_color = C_BLACK,
.dotted = 1,
},
#endif
#ifdef FXCG50
.area = {
.x = 24, .y = 51,
.w = 340, .h = 120,
},
.color = C_RED,
#if GINT_HW_CG
.ticks_x = {
.multiples = CACHE_MAX / 16,
.subtick_divisions = 4,
#if GINT_RENDER_MONO
.formatter = tick_formatter,
#endif
},
.ticks_y = {
.multiples = 125000,
.subtick_divisions = 2,
},
.grid = {
.level = PLOT_FULLGRID,
.primary_color = C_RGB(20, 20, 20),
.secondary_color = C_RGB(28, 28, 28),
.dotted = 1,
#if GINT_RENDER_MONO
.formatter = tick_formatter,
#endif
},
#endif
};
int y_min = -1;
@ -136,7 +147,7 @@ void gintctl_perf_cpucache(void)
dclear(C_WHITE);
row_title(_("CPU and cache", "CPU speed and cache size"));
#ifdef FX9860G
#if GINT_RENDER_MONO
row_print(2, 1, "4096 nop: %d Iϕ", nop4096);
extern font_t font_hexa;
font_t const *old = dfont(&font_hexa);
@ -144,7 +155,7 @@ void gintctl_perf_cpucache(void)
dfont(old);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_print(1, 1, "Time for 4096 nop (with overhead): %d Iphi",
nop4096);
row_print(2, 1, "Time needed to read a buffer multiple times:");

View File

@ -45,7 +45,7 @@ void gintctl_perf_interrupts(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
row_title("Interrupt stress");
if(time_spent == 0)
@ -60,7 +60,7 @@ void gintctl_perf_interrupts(void)
}
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Interrupt handling stress test");
if(time_spent == 0)

View File

@ -39,7 +39,7 @@ void gintctl_perf_libprof(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
row_print(1, 1, "Measures time for");
row_print(2, 1, "10ms sleep +1us each");
row_print(3, 1, "time, and empty code.");
@ -52,9 +52,9 @@ void gintctl_perf_libprof(void)
extern bopti_image_t img_opt_perf_libprof;
dimage(0, 56, &img_opt_perf_libprof);
#endif /* FX9860G */
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("libprof basics");
row_print(1, 1, "This program shows the execution time "
"measured");
@ -71,7 +71,7 @@ void gintctl_perf_libprof(void)
}
fkey_button(1, "START");
#endif /* FXCG50 */
#endif
dupdate();
key = getkey().key;

View File

@ -12,7 +12,7 @@
#include <string.h>
#include <stdlib.h>
#ifdef FXCG50
#if GINT_RENDER_RGB
//---
// Functions for read/write access patterns
@ -405,4 +405,4 @@ void gintctl_perf_memory(void)
free(info);
}
#endif /* FXCG50 */
#endif

View File

@ -30,7 +30,7 @@ static void run_test(struct elapsed *time)
drect(0, 0, _(127,395), _(63,223), C_WHITE);
});
#ifdef FXCG50
#if GINT_RENDER_RGB
extern bopti_image_t img_swift;
time->fs_r5g6b5 = prof_exec({
dimage(0, 0, &img_swift);
@ -58,7 +58,7 @@ void gintctl_perf_render(void)
{
dclear(C_WHITE);
#ifdef FX9860G
#if GINT_RENDER_MONO
row_print(1, 1, "Rendering functions");
if(test)
@ -74,7 +74,7 @@ void gintctl_perf_render(void)
dimage(0, 56, &img_opt_perf_render);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
row_title("Rendering functions");
row_print(1, 1, "This program measures the execution time of");
row_print(2, 1, "common drawing functions.");

View File

@ -13,6 +13,7 @@ void gintctl_regs(void)
dclear(C_WHITE);
row_title("Register browser");
#if GINT_HW_FX
if(isSH3())
{
#define IPR(X) (*SH7705_INTC._.IPR##X).word
@ -27,6 +28,7 @@ void gintctl_regs(void)
#undef IPR
}
else
#endif
{
#define IPR(X) SH7305_INTC._->IPR##X.word
row_print(2,1, "A:%04x B:%04x C:%04x", IPR(A), IPR(B), IPR(C));

View File

@ -1,6 +1,7 @@
#include <gint/display.h>
#include <gint/gint.h>
#include <gint/bfile.h>
#include <gint/config.h>
#include <gintctl/util.h>
@ -18,23 +19,23 @@
// Row manipulation functions
//---
#ifdef FX9860G
#if GINT_RENDER_MONO
#define ROW_X 1
#define ROW_W 6
#define ROW_Y 0
#define ROW_YPAD 0
#define ROW_H 8
#define ROW_COUNT 8
#endif /* FX9860G */
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
#define ROW_X 6
#define ROW_W 8
#define ROW_Y 20
#define ROW_YPAD 2
#define ROW_H 14
#define ROW_COUNT 14
#endif /* FXCG50 */
#endif
/* row_title(): Render the main title */
void row_title(char const *format, ...)
@ -42,11 +43,9 @@ void row_title(char const *format, ...)
char str[80];
shortprint(str, format);
#ifdef FX9860G
#if GINT_RENDER_MONO
dtext(1, 0, C_BLACK, str);
#endif
#ifdef FXCG50
#elif GINT_RENDER_RGB
dtext(ROW_X, 3, C_BLACK, str);
drect(0, 0, DWIDTH-1, 15, C_INVERT);
#endif
@ -82,11 +81,9 @@ void row_highlight(int row)
int y1 = ROW_Y + ROW_H * (row - 1);
int y2 = y1 + ROW_H;
#ifdef FX9860G
#if GINT_RENDER_MONO
drect(0, y1, 125, y2 - 1, C_INVERT);
#endif
#ifdef FXCG50
#elif GINT_RENDER_RGB
drect(0, y1, DWIDTH - 1, y2 - 1, C_INVERT);
#endif
}
@ -94,11 +91,9 @@ void row_highlight(int row)
/* row_right(): Print at the last column of a row */
void row_right(int row, char const *character)
{
#ifdef FX9860G
#if GINT_RENDER_MONO
row_print(row, 21, character);
#endif
#ifdef FXCG50
#elif GINT_RENDER_RGB
dtext(370, ROW_Y + ROW_H * (row - 1) + ROW_YPAD, C_BLACK, character);
#endif
}
@ -160,7 +155,7 @@ void scrollbar_px(int view_top, int view_bottom, int range_min, int range_max,
// Other drawing utilities
//---
#ifdef FXCG50
#if GINT_RENDER_RGB
/* fkey_action(): A black-on-white F-key */
void fkey_action(int position, char const *text)

View File

@ -8,10 +8,10 @@
#include <stdlib.h>
#ifdef FX9860G
#if GINT_RENDER_MONO
gscreen *gscreen_create(char const *name, bopti_image_t const *img)
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
gscreen *gscreen_create(char const *name, char const *labels)
#endif
{
@ -46,17 +46,17 @@ gscreen *gscreen_create(char const *name, char const *labels)
jlabel_set_font(title, _(&font_title, dfont_default()));
jwidget_set_stretch(title, 1, 0, false);
#ifdef FX9860G
#if GINT_RENDER_MONO
jwidget_set_padding(title, 1, 1, 0, 1);
jwidget_set_margin(title, 0, 0, 1, 0);
#endif
#ifdef FXCG50
#if GINT_RENDER_RGB
jwidget_set_padding(title, 3, 6, 3, 6);
#endif
}
#ifdef FXCG50
#if GINT_RENDER_RGB
jwidget_set_padding(stack, 1, 3, 1, 3);
#endif