From 655576011e9cc648c7c4bbf51179744a427ff237 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 10 Dec 2017 18:21:01 -0800 Subject: [PATCH] altos/lambdakey-v1.0: Switch to newlib, get things compiling again scheme is now way too large to fit on this device; some subsetting is clearly indicated. Signed-off-by: Keith Packard --- src/lambdakey-v1.0/Makefile | 35 ++++++++----------- src/lambdakey-v1.0/ao_lambdakey.c | 8 ++--- .../{ao_lisp_os.h => ao_scheme_os.h} | 33 ++++++++++++----- ...{ao_lisp_os_save.c => ao_scheme_os_save.c} | 22 ++++++------ 4 files changed, 55 insertions(+), 43 deletions(-) rename src/lambdakey-v1.0/{ao_lisp_os.h => ao_scheme_os.h} (68%) rename src/lambdakey-v1.0/{ao_lisp_os_save.c => ao_scheme_os_save.c} (63%) diff --git a/src/lambdakey-v1.0/Makefile b/src/lambdakey-v1.0/Makefile index 2609bea3..6b819ffb 100644 --- a/src/lambdakey-v1.0/Makefile +++ b/src/lambdakey-v1.0/Makefile @@ -5,6 +5,12 @@ include ../stmf0/Makefile.defs +include ../scheme/Makefile-inc + +NEWLIB_FULL=-lm -lc -lgcc + +LIBS=$(NEWLIB_FULL) + INC = \ ao.h \ ao_arch.h \ @@ -13,9 +19,7 @@ INC = \ ao_pins.h \ ao_product.h \ ao_task.h \ - ao_lisp.h \ - ao_lisp_const.h \ - ao_lisp_os.h \ + $(SCHEME_HDRS) \ stm32f0.h \ Makefile @@ -35,23 +39,8 @@ ALTOS_SRC = \ ao_timer.c \ ao_usb_stm.c \ ao_flash_stm.c \ - ao_lisp_lex.c \ - ao_lisp_mem.c \ - ao_lisp_cons.c \ - ao_lisp_eval.c \ - ao_lisp_string.c \ - ao_lisp_atom.c \ - ao_lisp_int.c \ - ao_lisp_poly.c \ - ao_lisp_builtin.c \ - ao_lisp_read.c \ - ao_lisp_rep.c \ - ao_lisp_frame.c \ - ao_lisp_error.c \ - ao_lisp_lambda.c \ - ao_lisp_save.c \ - ao_lisp_stack.c \ - ao_lisp_os_save.c + $(SCHEME_SRCS) \ + ao_scheme_os_save.c PRODUCT=LambdaKey-v1.0 PRODUCT_DEF=-DLAMBDAKEY @@ -61,6 +50,12 @@ CFLAGS = $(PRODUCT_DEF) -I. $(STMF0_CFLAGS) -Os -g LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stmf0 -Wl,-Tlambda.ld +MAP=$(PROG).map +NEWLIB=/local/newlib-mini +MAPFILE=-Wl,-M=$(MAP) +LDFLAGS=-L../stmf0 -L$(NEWLIB)/arm-none-eabi/lib/thumb/v6-m/ -Wl,-Tlambda.ld $(MAPFILE) -nostartfiles +AO_CFLAGS=-I. -I../stmf0 -I../kernel -I../drivers -I.. -I../scheme -isystem $(NEWLIB)/arm-none-eabi/include + PROGNAME=lambdakey-v1.0 PROG=$(PROGNAME)-$(VERSION).elf HEX=$(PROGNAME)-$(VERSION).ihx diff --git a/src/lambdakey-v1.0/ao_lambdakey.c b/src/lambdakey-v1.0/ao_lambdakey.c index 8bd344cf..d0996eb4 100644 --- a/src/lambdakey-v1.0/ao_lambdakey.c +++ b/src/lambdakey-v1.0/ao_lambdakey.c @@ -13,14 +13,14 @@ */ #include -#include +#include -static void lisp_cmd() { - ao_lisp_read_eval_print(); +static void scheme_cmd() { + ao_scheme_read_eval_print(); } static const struct ao_cmds blink_cmds[] = { - { lisp_cmd, "l\0Run lisp interpreter" }, + { scheme_cmd, "l\0Run scheme interpreter" }, { 0, 0 } }; diff --git a/src/lambdakey-v1.0/ao_lisp_os.h b/src/lambdakey-v1.0/ao_scheme_os.h similarity index 68% rename from src/lambdakey-v1.0/ao_lisp_os.h rename to src/lambdakey-v1.0/ao_scheme_os.h index 1993ac44..a620684f 100644 --- a/src/lambdakey-v1.0/ao_lisp_os.h +++ b/src/lambdakey-v1.0/ao_scheme_os.h @@ -15,13 +15,23 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef _AO_LISP_OS_H_ -#define _AO_LISP_OS_H_ +#ifndef _AO_SCHEME_OS_H_ +#define _AO_SCHEME_OS_H_ #include "ao.h" +#define AO_SCHEME_SAVE 1 + +#define AO_SCHEME_POOL_TOTAL 2048 + +#ifndef __BYTE_ORDER +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __BYTE_ORDER __LITTLE_ENDIAN +#endif + static inline int -ao_lisp_getc() { +ao_scheme_getc() { static uint8_t at_eol; int c; @@ -36,27 +46,34 @@ ao_lisp_getc() { } static inline void -ao_lisp_os_flush(void) +ao_scheme_os_flush(void) { flush(); } static inline void -ao_lisp_abort(void) +ao_scheme_abort(void) { ao_panic(1); } static inline void -ao_lisp_os_led(int led) +ao_scheme_os_led(int led) { ao_led_set(led); } +#define AO_SCHEME_JIFFIES_PER_SECOND AO_HERTZ + static inline void -ao_lisp_os_delay(int delay) +ao_scheme_os_delay(int delay) { - ao_delay(AO_MS_TO_TICKS(delay)); + ao_delay(delay); } +static inline int +ao_scheme_os_jiffy(void) +{ + return ao_tick_count; +} #endif diff --git a/src/lambdakey-v1.0/ao_lisp_os_save.c b/src/lambdakey-v1.0/ao_scheme_os_save.c similarity index 63% rename from src/lambdakey-v1.0/ao_lisp_os_save.c rename to src/lambdakey-v1.0/ao_scheme_os_save.c index 44138398..184ddb8d 100644 --- a/src/lambdakey-v1.0/ao_lisp_os_save.c +++ b/src/lambdakey-v1.0/ao_scheme_os_save.c @@ -13,25 +13,25 @@ */ #include -#include +#include #include extern uint8_t __flash__[]; /* saved variables to rebuild the heap - ao_lisp_atoms - ao_lisp_frame_global + ao_scheme_atoms + ao_scheme_frame_global */ int -ao_lisp_os_save(void) +ao_scheme_os_save(void) { int i; - for (i = 0; i < AO_LISP_POOL_TOTAL; i += 256) { - uint32_t *dst = (uint32_t *) &__flash__[i]; - uint32_t *src = (uint32_t *) &ao_lisp_pool[i]; + for (i = 0; i < AO_SCHEME_POOL_TOTAL; i += 256) { + void *dst = &__flash__[i]; + void *src = &ao_scheme_pool[i]; ao_flash_page(dst, src); } @@ -39,15 +39,15 @@ ao_lisp_os_save(void) } int -ao_lisp_os_restore_save(struct ao_lisp_os_save *save, int offset) +ao_scheme_os_restore_save(struct ao_scheme_os_save *save, int offset) { - memcpy(save, &__flash__[offset], sizeof (struct ao_lisp_os_save)); + memcpy(save, &__flash__[offset], sizeof (struct ao_scheme_os_save)); return 1; } int -ao_lisp_os_restore(void) +ao_scheme_os_restore(void) { - memcpy(ao_lisp_pool, __flash__, AO_LISP_POOL_TOTAL); + memcpy(ao_scheme_pool, __flash__, AO_SCHEME_POOL_TOTAL); return 1; } -- 2.30.2