ports/sh: start adding decent memory on fx-CG 50 (~ 350 kB)

This commit is contained in:
Lephenixnoir 2022-11-10 23:02:20 +01:00
parent c1d2ca5048
commit eeae10abc5
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
4 changed files with 42 additions and 20 deletions

View File

@ -18,6 +18,8 @@ Bugs to fix:
- Fix not world switching during filesystem accesses (very unstable)
- Fix the console not garbage collecting its lines (enable and test the feature)
- Fix not resetting the shell when importing a file from command-line
- Fix current working directory not changing during a module import (for
relative imports)
Python features:
- Compare features with existing implementations and other brands

View File

@ -3,8 +3,23 @@
#include <gint/usb-ff-bulk.h>
#include <gint/kmalloc.h>
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/cpu.h>
#include <stdio.h>
#include <stdlib.h>
void pe_debug_panic(char const *msg)
{
int dy = dfont_default()->line_height + 2;
dclear(C_BLACK);
dtext(1, 1, C_WHITE, "PythonExtra panic!");
dtext(1, 1+dy, C_WHITE, msg);
dupdate();
getkey();
exit(1);
}
#if PE_DEBUG

View File

@ -7,7 +7,7 @@
//
// Most of the debugging occurs via USB. This module also includes screenshots
// and other developer-only utilities. The interface always exists but it's
// completely no-oped if PE_DEBUG isn't set.
// almost entirely no-oped if PE_DEBUG isn't set.
//---
#ifndef __PYTHONEXTRA_DEBUG_H
@ -19,6 +19,10 @@
/* Initialize debugging resources (mostly the USB connection). */
void pe_debug_init(void);
/* Panic with a message (available even if PE_DEBUG=0). */
void pe_debug_panic(char const *msg)
__attribute__((noreturn));
/* Print to the debug stream. This function is also called DEBUG_printf in
MicroPython code. */
void pe_debug_printf(char const *fmt, ...);

View File

@ -140,26 +140,27 @@ int main(int argc, char **argv)
open_generic(&stdouterr_type, pe_shell_console, STDOUT_FILENO);
open_generic(&stdouterr_type, pe_shell_console, STDERR_FILENO);
/* Initialize MicroPython */
#define HEAP_SIZE 32768
void *heap = malloc(32768);
if(!heap) {
dclear(C_WHITE);
dtext(1, 1, C_BLACK, "No heap!");
getkey();
return 1;
}
/* Initialize the MicroPython GC with most available memory */
mp_stack_ctrl_init();
gc_init(heap, heap + HEAP_SIZE);
// TODO: gc_add(start, end) for each area we want to allocate to
// fx-9860G III:
// * (nothing? x_x)
// fx-CG 50:
// * The entirety of _uram
// * The entirety of the extra VRAM
// * Possibly memory past 2M
// * (keep the OS heap for normal malloc())
#ifdef FX9860G
/* Get *some* memory from the OS heap */
void *gc_area = malloc(32768);
if(!gc_area)
pe_debug_panic("No heap!");
gc_init(gc_area, gc_area + 32768);
#else
/* Get everything from the OS stack (~ 350 ko) */
size_t gc_area_size;
void *gc_area = kmalloc_max(&gc_area_size, "_ostk");
gc_init(gc_area, gc_area + gc_area_size);
/* Other options:
- All of _uram (leaving the OS heap for the shell/GUI/etc)
- The OS' extra VRAM
- Memory past the 2 MB boundary on tested OSes */
// gc_add(start, end)...
#endif
mp_init();
/* TODO: Add an option for the shorter prompt */