summaryrefslogtreecommitdiff
path: root/src/lisp/ao_lisp.h
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-11-11 21:16:09 -0800
committerKeith Packard <keithp@keithp.com>2016-11-17 22:18:39 -0800
commit0fd008d75ca451ba68ad8ae773ea8a5ebc1785c5 (patch)
tree98485dc6304efce6c96774613fba5bf352cbd32a /src/lisp/ao_lisp.h
parentc8d2b9acf4b118f36a114de2af4db42ae04426ed (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.h39
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