forked from Lephenixnoir/PythonExtra
ports/fx9860g3: memory info view on SHIFT+VARS
This commit is contained in:
parent
bcdb3b74ca
commit
c84caa533d
|
@ -5,7 +5,7 @@ SH_LDFLAGS := -T fx9860g.ld -ljustui-fx -lm -lgint-fx -lc -lgint-fx -lgcc
|
|||
|
||||
SH_ASSETS := \
|
||||
img_fkeys_main.png img_modifier_states.png \
|
||||
font_5x7.png font_4x4.png font_4x6.png
|
||||
font_5x7.png font_4x4.png font_4x6.png font_3x5.png
|
||||
SH_METADATA := fxconv-metadata.txt
|
||||
SH_CONVFLAGS := --fx
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
|
@ -10,14 +10,12 @@ font_*.png:
|
|||
grid.border: 0
|
||||
|
||||
font_5x7.png:
|
||||
type: font
|
||||
charset: print
|
||||
grid.size: 5x7
|
||||
grid.padding: 1
|
||||
grid.border: 0
|
||||
|
||||
font_4x4.png:
|
||||
type: font
|
||||
charset: print
|
||||
grid.size: 4x4
|
||||
grid.padding: 1
|
||||
|
@ -25,9 +23,15 @@ font_4x4.png:
|
|||
proportional: true
|
||||
|
||||
font_4x6.png:
|
||||
type: font
|
||||
charset: print
|
||||
grid.size: 5x6
|
||||
grid.padding: 1
|
||||
grid.border: 0
|
||||
proportional: true
|
||||
|
||||
font_3x5.png:
|
||||
charset: ascii
|
||||
height: 5
|
||||
grid.size: 5x6
|
||||
grid.padding: 1
|
||||
proportional: true
|
||||
|
|
|
@ -23,6 +23,79 @@ void pe_debug_panic(char const *msg)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
struct pe_debug_meminfo pe_debug_startup_meminfo[PE_DEBUG_STARTUP_N];
|
||||
|
||||
void pe_debug_get_meminfo(struct pe_debug_meminfo *info)
|
||||
{
|
||||
kmalloc_gint_stats_t *s;
|
||||
|
||||
#ifdef FX9860G
|
||||
s = kmalloc_get_gint_stats(kmalloc_get_arena("_uram"));
|
||||
info->_uram_used = s->used_memory;
|
||||
info->_uram_free = s->free_memory;
|
||||
|
||||
s = kmalloc_get_gint_stats(kmalloc_get_arena("pram0"));
|
||||
info->pram0_used = s->used_memory;
|
||||
info->pram0_free = s->free_memory;
|
||||
#endif
|
||||
|
||||
#ifdef FXCG50
|
||||
s = kmalloc_get_gint_stats(kmalloc_get_arena("_uram"));
|
||||
info->_uram_used = s->used_memory;
|
||||
|
||||
s = kmalloc_get_gint_stats(kmalloc_get_arena("_ostk"));
|
||||
info->_ostk_used = s->used_memory;
|
||||
#endif
|
||||
}
|
||||
|
||||
void pe_debug_browse_meminfo(void)
|
||||
{
|
||||
dclear(C_WHITE);
|
||||
struct pe_debug_meminfo infonow;
|
||||
pe_debug_get_meminfo(&infonow);
|
||||
|
||||
#ifdef FX9860G
|
||||
static char const * const names[] = {
|
||||
"main", "cons.", "upy", "prom.", "ui",
|
||||
"now", /* extra element compared to original enum */
|
||||
};
|
||||
dprint(1, 0, C_BLACK, "Memory info");
|
||||
|
||||
extern font_t font_3x5, font_4x6;
|
||||
font_t const *old_font = dfont(&font_4x6);
|
||||
dtext(33, 9, C_BLACK, "_uram");
|
||||
dtext(75, 9, C_BLACK, "pram0");
|
||||
dline(2, 16, DWIDTH-3, 16, C_BLACK);
|
||||
|
||||
for(int i = 0; i < PE_DEBUG_STARTUP_N + 1; i++) {
|
||||
int y = 7 * i + 18;
|
||||
struct pe_debug_meminfo *info = &pe_debug_startup_meminfo[i];
|
||||
if(i >= PE_DEBUG_STARTUP_N) {
|
||||
dline(2, y, DWIDTH-3, y, C_BLACK);
|
||||
y += 2;
|
||||
info = &infonow;
|
||||
}
|
||||
|
||||
dtext(2, y, C_BLACK, names[i]);
|
||||
dfont(&font_3x5);
|
||||
dprint(33, y+1, C_BLACK,
|
||||
"%d,%d", info->_uram_used, info->_uram_free);
|
||||
dprint(75, y+1, C_BLACK,
|
||||
"%d,%d", info->pram0_used, info->pram0_free);
|
||||
dfont(&font_4x6);
|
||||
}
|
||||
|
||||
dfont(old_font);
|
||||
#endif
|
||||
|
||||
#ifdef FXCG50
|
||||
dprint(1, 1, C_BLACK, "TODO");
|
||||
#endif
|
||||
|
||||
dupdate();
|
||||
while((getkey().key) != KEY_EXIT);
|
||||
}
|
||||
|
||||
#if PE_DEBUG
|
||||
|
||||
#if 0 // Timeout fxlink not supported yet
|
||||
|
|
|
@ -23,6 +23,51 @@ void pe_debug_init(void);
|
|||
void pe_debug_panic(char const *msg)
|
||||
__attribute__((noreturn));
|
||||
|
||||
/*** Memory watch utilities (enabled even when PE_DEBUG=0) ***/
|
||||
|
||||
#ifdef FX9860G
|
||||
struct pe_debug_meminfo {
|
||||
uint16_t _uram_used, _uram_free;
|
||||
uint32_t pram0_used, pram0_free;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef FXCG50
|
||||
struct pe_debug_meminfo {
|
||||
uint32_t _uram_used;
|
||||
uint32_t _ostk_used;
|
||||
};
|
||||
#endif
|
||||
|
||||
enum {
|
||||
/* Just after entering main() */
|
||||
PE_DEBUG_STARTUP_MAIN,
|
||||
/* After allocating console */
|
||||
PE_DEBUG_STARTUP_CONSOLE,
|
||||
/* After initializing MicroPython */
|
||||
PE_DEBUG_STARTUP_UPY,
|
||||
/* After printing the first prompt */
|
||||
PE_DEBUG_STARTUP_PROMPT,
|
||||
/* After allocating and initializing the GUI */
|
||||
PE_DEBUG_STARTUP_UI,
|
||||
|
||||
PE_DEBUG_STARTUP_N,
|
||||
};
|
||||
|
||||
/* Fetch data about current memory statistics. */
|
||||
void pe_debug_get_meminfo(struct pe_debug_meminfo *info);
|
||||
|
||||
/* Buffer for storing meminfo during startup. */
|
||||
extern struct pe_debug_meminfo pe_debug_startup_meminfo[PE_DEBUG_STARTUP_N];
|
||||
|
||||
#define pe_debug_get_startup_meminfo(NAME) \
|
||||
pe_debug_get_meminfo(&pe_debug_startup_meminfo[PE_DEBUG_STARTUP_ ## NAME])
|
||||
|
||||
/* Browse memory info through a GUI. */
|
||||
void pe_debug_browse_meminfo(void);
|
||||
|
||||
/*** Debugging functions enabled only when PE_DEBUG=1 ***/
|
||||
|
||||
/* Print to the debug stream. This function is also called DEBUG_printf in
|
||||
MicroPython code. */
|
||||
int pe_debug_printf(char const *fmt, ...);
|
||||
|
|
|
@ -321,6 +321,10 @@ static char *pe_handle_event(jevent e, bool shell_bound)
|
|||
jscene_show_and_focus(PE.scene, PE.shell);
|
||||
jwidget_set_visible(PE.title, PE.show_title_in_shell);
|
||||
}
|
||||
if(!shell_bound && key == KEY_VARS && e.key.shift) {
|
||||
pe_debug_browse_meminfo();
|
||||
PE.scene->widget.update = true;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -361,7 +365,7 @@ int main(int argc, char **argv)
|
|||
|
||||
pe_debug_init();
|
||||
pe_debug_printf("---\n");
|
||||
pe_debug_kmalloc("main");
|
||||
pe_debug_get_startup_meminfo(MAIN);
|
||||
|
||||
//=== Init sequence ===//
|
||||
|
||||
|
@ -376,7 +380,7 @@ int main(int argc, char **argv)
|
|||
|
||||
PE.console = console_create(8192, 200);
|
||||
|
||||
pe_debug_kmalloc("console");
|
||||
pe_debug_get_startup_meminfo(CONSOLE);
|
||||
|
||||
/* Set up standard streams */
|
||||
close(STDOUT_FILENO);
|
||||
|
@ -437,12 +441,12 @@ int main(int argc, char **argv)
|
|||
MP_OBJ_NEW_QSTR(qstr_from_str("."));
|
||||
#endif
|
||||
|
||||
pe_debug_kmalloc("upy");
|
||||
pe_debug_get_startup_meminfo(UPY);
|
||||
|
||||
pyexec_event_repl_init();
|
||||
pe_print_prompt(1);
|
||||
|
||||
pe_debug_kmalloc("prompt");
|
||||
pe_debug_get_startup_meminfo(PROMPT);
|
||||
|
||||
//=== GUI setup ===//
|
||||
|
||||
|
@ -481,7 +485,7 @@ int main(int argc, char **argv)
|
|||
jwidget_set_padding(stack, 0, 6, 0, 6);
|
||||
#endif
|
||||
|
||||
pe_debug_kmalloc("ui");
|
||||
pe_debug_get_startup_meminfo(UI);
|
||||
|
||||
/* Initial state */
|
||||
jfileselect_browse(PE.fileselect, "/");
|
||||
|
|
Loading…
Reference in New Issue