discover and dump 8 MB RAM on fx-CG 50

This commit is contained in:
Lephenixnoir 2021-09-18 16:04:57 +02:00
parent f59cc41490
commit 063386dcd2
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 54 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -3,6 +3,8 @@
#include <gint/bfile.h>
#include <gint/gint.h>
#include <gint/hardware.h>
#include <gint/usb.h>
#include <gint/usb-ff-bulk.h>
#include <gintctl/util.h>
#include <gintctl/gint.h>
@ -25,7 +27,8 @@ static struct region const regs[] = {
#ifdef FXCG50
{ "ROM", 0x80000000, 0x81ffffff, 32 },
{ "RAM", 0x88000000, 0x881fffff, 2 },
{ "RAM_88", 0x88000000, 0x881fffff, 2 },
{ "RAM_8C", 0x8c000000, 0x8c7fffff, 8 },
{ "RS", 0xfd800000, 0xfd8007ff, 1 },
#endif
};
@ -65,7 +68,7 @@ static void switch_dump(int region, int segment, char *filename, int *retcode)
BFile_Close(fd);
}
static int do_dump(int region, int segment)
static int do_dump_smem(int region, int segment)
{
char filename[30];
int retcode = 0;
@ -76,6 +79,29 @@ static int do_dump(int region, int segment)
return retcode;
}
static void do_dump_usb(int region)
{
bool open = usb_is_open();
if(!open) {
usb_interface_t const *interfaces[] = { &usb_ff_bulk, NULL };
usb_open(interfaces, GINT_CALL_NULL);
usb_open_wait();
}
int size = regs[region].end - regs[region].start + 1;
usb_fxlink_header_t header;
usb_fxlink_fill_header(&header, "gintctl", "dump", size);
int pipe = usb_ff_bulk_output();
usb_write_sync(pipe, &header, sizeof header, 4, false);
usb_write_sync(pipe, (void *)regs[region].start, size, 4, false);
usb_commit_sync(pipe);
/* Close the USB link if it wasn't open before */
if(!open) usb_close();
}
/* gintctl_gint_dump(): Dump memory to filesystem */
void gintctl_gint_dump(void)
{
@ -121,9 +147,11 @@ void gintctl_gint_dump(void)
if(retcode < 0) row_print(5, 1, "Error %d", retcode);
fkey_button(1, "ROM");
fkey_button(2, "RAM");
fkey_button(3, "RS");
fkey_action(6, "DUMP");
fkey_button(2, "RAM_88");
fkey_button(3, "RAM_8C");
fkey_button(4, "RS");
fkey_action(5, "USB");
fkey_action(6, "SMEM");
#endif
dupdate();
@ -134,6 +162,7 @@ void gintctl_gint_dump(void)
if(key == KEY_F1) select = 0;
if(key == KEY_F2) select = 1;
if(key == KEY_F3) select = 2;
if(key == KEY_F4 && _(0,1)) select = 3;
if(select >= 0 && select == region)
{
@ -146,6 +175,7 @@ void gintctl_gint_dump(void)
}
retcode = 0;
if(key == KEY_F6) retcode = do_dump(region, segment);
if(key == KEY_F5) do_dump_usb(region);
if(key == KEY_F6) retcode = do_dump_smem(region, segment);
}
}

View File

@ -86,6 +86,8 @@ struct region {
uint32_t mem;
/* Whether region supports only 32-bit access [input] */
bool use_lword;
/* How often to probe memory (1 in step_size bytes will be tested) */
int step_size;
/* Size of region [output] */
uint32_t size;
/* Reason why region is not larger [output] */
@ -97,7 +99,7 @@ static void explore_region(struct region *r)
uint8_t volatile *mem = (void *)r->mem;
r->size = 0;
while(r->size < (1 << 20))
while(r->size < (16 << 20))
{
int x = r->use_lword
? writable_lword(mem + r->size)
@ -115,8 +117,7 @@ static void explore_region(struct region *r)
if(y) return;
}
/* In PXYRAM, skip some longwords to go faster */
r->size += r->use_lword ? 32 : 4;
r->size += r->step_size;
}
r->reason = 3;
@ -200,7 +201,7 @@ static void show_region(int y, struct region *r)
row_print(y, 2, "%s", r->name);
row_print(y, 9, "%08X", r->mem);
row_print(y, 18, "%d", r->use_lword ? 32 : 8);
row_print(y, 22, "%d bytes", r->size);
row_print(y, 22, "%d %s", r->size, r->size >= (1000000) ? "B" : "bytes");
row_print(y, 35, reasons[r->reason]);
}
#endif
@ -209,17 +210,18 @@ static void show_region(int y, struct region *r)
void gintctl_gint_ram(void)
{
struct region r[] = {
{ "ILRAM", 0xe5200000, false, 0, 0 },
{ "XRAM", 0xe5007000, false, 0, 0 },
{ "YRAM", 0xe5017000, false, 0, 0 },
{ "PRAM0", 0xfe200000, true, 0, 0 },
{ "XRAM0", 0xfe240000, true, 0, 0 },
{ "YRAM0", 0xfe280000, true, 0, 0 },
{ "PRAM1", 0xfe300000, true, 0, 0 },
{ "XRAM1", 0xfe340000, true, 0, 0 },
{ "YRAM1", 0xfe380000, true, 0, 0 },
{ "X_P2", 0xa5007000, false, 0, 0 },
{ "URAM", 0xa55f0000, false, 0, 0 },
{ "ILRAM", 0xe5200000, false, 4, /**/ 0, 0 },
{ "XRAM", 0xe5007000, false, 4, /**/ 0, 0 },
{ "YRAM", 0xe5017000, false, 4, /**/ 0, 0 },
{ "PRAM0", 0xfe200000, true, 32, /**/ 0, 0 },
{ "XRAM0", 0xfe240000, true, 32, /**/ 0, 0 },
{ "YRAM0", 0xfe280000, true, 32, /**/ 0, 0 },
{ "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 },
{ "URAM", 0xa55f0000, false, 4, /**/ 0, 0 },
{ "RAM", 0xac000000, false, 1024, /**/ 0, 0 },
{ NULL },
};
@ -307,6 +309,7 @@ void gintctl_gint_ram(void)
{
explore_region(&r[9]);
explore_region(&r[10]);
explore_region(&r[11]);
}
#ifdef FX9860G