Added crude save/restore.
This commit is contained in:
@ -124,13 +124,15 @@ $(GEN):
|
||||
POSIX_BOOT = common/boot.fs common/vocabulary.fs common/hide_calls.fs common/ansi.fs \
|
||||
posix/posix.fs posix/posix_highlevel.fs posix/termios.fs common/locals.fs \
|
||||
common/utils.fs common/highlevel.fs common/filetools.fs posix/posix_desktop.fs \
|
||||
common/tasks.fs common/streams.fs common/blocks.fs posix/args.fs
|
||||
common/tasks.fs common/streams.fs common/blocks.fs posix/args.fs \
|
||||
common/fini.fs
|
||||
$(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN)
|
||||
echo "ok" | cat $(POSIX_BOOT) - | $< boot $(VERSION) $(REVISION) >$@
|
||||
|
||||
WINDOWS_BOOT = common/boot.fs common/vocabulary.fs common/hide_calls.fs common/ansi.fs \
|
||||
windows/windows.fs windows/windows_highlevel.fs common/highlevel.fs \
|
||||
common/utils.fs common/tasks.fs common/streams.fs common/blocks.fs common/locals.fs
|
||||
common/utils.fs common/tasks.fs common/streams.fs common/blocks.fs common/locals.fs \
|
||||
common/fini.fs
|
||||
$(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN)
|
||||
echo "ok" | cat $(WINDOWS_BOOT) - | $< boot $(VERSION) $(REVISION) >$@
|
||||
|
||||
@ -141,7 +143,8 @@ ARDUINO_BOOT = common/boot.fs common/vocabulary.fs \
|
||||
common/tasks.fs common/streams.fs arduino/arduino_server.fs \
|
||||
arduino/arduino_bterm.fs \
|
||||
arduino/esp_camera.fs common/blocks.fs \
|
||||
arduino/autoboot.fs
|
||||
arduino/autoboot.fs \
|
||||
common/fini.fs
|
||||
$(GEN)/arduino_boot.h: common/source_to_string.js $(ARDUINO_BOOT) | $(GEN)
|
||||
echo "ok" | cat $(ARDUINO_BOOT) - | $< boot $(VERSION) $(REVISION) >$@
|
||||
|
||||
|
||||
@ -5,6 +5,5 @@ internals definitions
|
||||
|
||||
( Check for autoexec.fs and run if present )
|
||||
: autoexec ( a n -- ) s" /spiffs/autoexec.fs" ['] included catch 2drop drop ;
|
||||
' autoexec
|
||||
' autoexec ( leave on the stack for fini.fs )
|
||||
forth definitions
|
||||
execute
|
||||
|
||||
@ -130,7 +130,7 @@ static cell_t *forth_run(cell_t *initrp);
|
||||
|
||||
static void forth_init(int argc, char *argv[], void *heap,
|
||||
const char *src, cell_t src_len) {
|
||||
g_sys.heap = (cell_t *) heap + 4; // Leave a little room.
|
||||
g_sys.heap = ((cell_t *) heap) + 4; // Leave a little room.
|
||||
cell_t *sp = g_sys.heap + 1; g_sys.heap += STACK_SIZE;
|
||||
cell_t *rp = g_sys.heap + 1; g_sys.heap += STACK_SIZE;
|
||||
|
||||
|
||||
@ -3,3 +3,27 @@
|
||||
>r r@ write-file if r> drop ." failed write-file" exit then
|
||||
r> close-file drop
|
||||
;
|
||||
|
||||
internals definitions
|
||||
( Leave some room for growth of starting system. )
|
||||
$4000 constant growth-gap
|
||||
here growth-gap + growth-gap 1- + growth-gap 1- invert and constant saving-base
|
||||
: park-heap ( -- a ) saving-base ;
|
||||
: park-forth ( -- a ) saving-base cell+ ;
|
||||
forth definitions also internals
|
||||
|
||||
: save ( "name" -- )
|
||||
'heap @ park-heap !
|
||||
forth-wordlist @ park-forth !
|
||||
bl parse w/o create-file throw >r
|
||||
saving-base here over - r@ write-file throw
|
||||
r> close-file throw ;
|
||||
|
||||
: restore ( "name" -- )
|
||||
bl parse r/o open-file throw >r
|
||||
saving-base r@ file-size throw r@ read-file throw drop
|
||||
r> close-file throw
|
||||
park-heap @ 'heap !
|
||||
park-forth @ forth-wordlist ! ;
|
||||
|
||||
only forth definitions
|
||||
|
||||
7
ueforth/common/fini.fs
Normal file
7
ueforth/common/fini.fs
Normal file
@ -0,0 +1,7 @@
|
||||
internals
|
||||
( Bring a forth to the top of the vocabulary. )
|
||||
transfer forth
|
||||
( Move heap to save point, with a gap. )
|
||||
saving-base 16 cells + 'heap !
|
||||
forth
|
||||
execute ( assumes an xt for autoboot is on the dstack )
|
||||
@ -1,6 +1,5 @@
|
||||
( Include first argument if any )
|
||||
internals definitions
|
||||
: optional-args argc 2 < if exit then 1 argv included ;
|
||||
' optional-args
|
||||
' optional-args ( leave on dstack for fini.fs )
|
||||
forth definitions
|
||||
execute
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
#include "common/calls.h"
|
||||
|
||||
#define HEAP_SIZE (10 * 1024 * 1024)
|
||||
#define STACK_SIZE (16 * 1024)
|
||||
#define STACK_SIZE (64 * 1024)
|
||||
|
||||
#define PLATFORM_OPCODE_LIST \
|
||||
Y(DLSYM, tos = (cell_t) dlsym(a1, a0); --sp) \
|
||||
|
||||
@ -147,3 +147,4 @@ forth
|
||||
|
||||
( Setup entry )
|
||||
: ok ." uEforth v{{VERSION}} - rev {{REVISION}}" cr prompt refill drop quit ;
|
||||
' forth ( leave on stack for fini.fs )
|
||||
|
||||
Reference in New Issue
Block a user