diff options
author | Keith Packard <keithp@keithp.com> | 2016-11-11 21:16:09 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-02-20 11:16:50 -0800 |
commit | dba374516ed396633659dec571b6a44b03da8ad1 (patch) | |
tree | 623d48c9ea938db3788ee96f9827ae13389108cd /src/lisp/ao_lisp.h | |
parent | 29c890b4599b3bbdbd09a5915ea68a63f4e0a9ac (diff) |
altos/lisp: Add save/restore infrastructure. Needs OS support to work.
This sticks a few globals past the end of the heap and then asks the
OS to save the heap. On restore, the heap is re-populated by the OS
and then various global variables reset.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp.h')
-rw-r--r-- | src/lisp/ao_lisp.h | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/lisp/ao_lisp.h b/src/lisp/ao_lisp.h index 7a165cd8..44838a34 100644 --- a/src/lisp/ao_lisp.h +++ b/src/lisp/ao_lisp.h @@ -20,6 +20,26 @@ //#include <stdio.h> #include <ao_lisp_os.h> +typedef uint16_t ao_poly; +typedef int16_t ao_signed_poly; + +#ifdef AO_LISP_SAVE + +struct ao_lisp_os_save { + ao_poly ao_lisp_atoms; + ao_poly ao_lisp_globals; +}; + +#define AO_LISP_POOL (AO_LISP_POOL_TOTAL - sizeof (struct ao_lisp_os_save)) + +int +ao_lisp_os_save(void); + +int +ao_lisp_os_restore(void); + +#endif + #ifdef AO_LISP_MAKE_CONST #define AO_LISP_POOL_CONST 16384 extern uint8_t ao_lisp_const[AO_LISP_POOL_CONST]; @@ -85,9 +105,6 @@ extern uint16_t ao_lisp_top; extern uint8_t ao_lisp_exception; -typedef uint16_t ao_poly; -typedef int16_t ao_signed_poly; - static inline int ao_lisp_is_const(ao_poly poly) { return poly & AO_LISP_CONST; @@ -228,6 +245,8 @@ enum ao_lisp_builtin_id { builtin_flush, builtin_delay, builtin_led, + builtin_save, + builtin_restore, _builtin_last }; @@ -468,6 +487,12 @@ ao_lisp_poly_move(ao_poly *p, uint8_t note_cons); /* eval */ +void +ao_lisp_eval_clear_globals(void); + +int +ao_lisp_eval_restart(void); + ao_poly ao_lisp_eval(ao_poly p); @@ -542,6 +567,14 @@ ao_lisp_macro(struct ao_lisp_cons *cons); ao_poly ao_lisp_lambda_eval(void); +/* save */ + +ao_poly +ao_lisp_save(struct ao_lisp_cons *cons); + +ao_poly +ao_lisp_restore(struct ao_lisp_cons *cons); + /* error */ void |