altos/lambdakey-v1.0: Switch to newlib, get things compiling again
authorKeith Packard <keithp@keithp.com>
Mon, 11 Dec 2017 02:21:01 +0000 (18:21 -0800)
committerKeith Packard <keithp@keithp.com>
Mon, 11 Dec 2017 20:20:25 +0000 (12:20 -0800)
scheme is now way too large to fit on this device; some subsetting is
clearly indicated.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/lambdakey-v1.0/Makefile
src/lambdakey-v1.0/ao_lambdakey.c
src/lambdakey-v1.0/ao_lisp_os.h [deleted file]
src/lambdakey-v1.0/ao_lisp_os_save.c [deleted file]
src/lambdakey-v1.0/ao_scheme_os.h [new file with mode: 0644]
src/lambdakey-v1.0/ao_scheme_os_save.c [new file with mode: 0644]

index 2609bea3653c5c9cd71ebff8b89863f7d361f98e..6b819ffb752fe770dd213ddb15c5450942c69104 100644 (file)
@@ -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
index 8bd344cf57139fe47f9264e7e2f6cf6514e34e2a..d0996eb429c41c0d36a6735676d18ad955675bf1 100644 (file)
  */
 
 #include <ao.h>
-#include <ao_lisp.h>
+#include <ao_scheme.h>
 
-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_lisp_os.h
deleted file mode 100644 (file)
index 1993ac4..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright © 2016 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-#ifndef _AO_LISP_OS_H_
-#define _AO_LISP_OS_H_
-
-#include "ao.h"
-
-static inline int
-ao_lisp_getc() {
-       static uint8_t  at_eol;
-       int c;
-
-       if (at_eol) {
-               ao_cmd_readline();
-               at_eol = 0;
-       }
-       c = ao_cmd_lex();
-       if (c == '\n')
-               at_eol = 1;
-       return c;
-}
-
-static inline void
-ao_lisp_os_flush(void)
-{
-       flush();
-}
-
-static inline void
-ao_lisp_abort(void)
-{
-       ao_panic(1);
-}
-
-static inline void
-ao_lisp_os_led(int led)
-{
-       ao_led_set(led);
-}
-
-static inline void
-ao_lisp_os_delay(int delay)
-{
-       ao_delay(AO_MS_TO_TICKS(delay));
-}
-
-#endif
diff --git a/src/lambdakey-v1.0/ao_lisp_os_save.c b/src/lambdakey-v1.0/ao_lisp_os_save.c
deleted file mode 100644 (file)
index 4413839..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright © 2016 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- */
-
-#include <ao.h>
-#include <ao_lisp.h>
-#include <ao_flash.h>
-
-extern uint8_t __flash__[];
-
-/* saved variables to rebuild the heap
-
-   ao_lisp_atoms
-   ao_lisp_frame_global
- */
-
-int
-ao_lisp_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];
-
-               ao_flash_page(dst, src);
-       }
-       return 1;
-}
-
-int
-ao_lisp_os_restore_save(struct ao_lisp_os_save *save, int offset)
-{
-       memcpy(save, &__flash__[offset], sizeof (struct ao_lisp_os_save));
-       return 1;
-}
-
-int
-ao_lisp_os_restore(void)
-{
-       memcpy(ao_lisp_pool, __flash__, AO_LISP_POOL_TOTAL);
-       return 1;
-}
diff --git a/src/lambdakey-v1.0/ao_scheme_os.h b/src/lambdakey-v1.0/ao_scheme_os.h
new file mode 100644 (file)
index 0000000..a620684
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2016 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#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_scheme_getc() {
+       static uint8_t  at_eol;
+       int c;
+
+       if (at_eol) {
+               ao_cmd_readline();
+               at_eol = 0;
+       }
+       c = ao_cmd_lex();
+       if (c == '\n')
+               at_eol = 1;
+       return c;
+}
+
+static inline void
+ao_scheme_os_flush(void)
+{
+       flush();
+}
+
+static inline void
+ao_scheme_abort(void)
+{
+       ao_panic(1);
+}
+
+static inline void
+ao_scheme_os_led(int led)
+{
+       ao_led_set(led);
+}
+
+#define AO_SCHEME_JIFFIES_PER_SECOND   AO_HERTZ
+
+static inline void
+ao_scheme_os_delay(int 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_scheme_os_save.c b/src/lambdakey-v1.0/ao_scheme_os_save.c
new file mode 100644 (file)
index 0000000..184ddb8
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2016 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#include <ao.h>
+#include <ao_scheme.h>
+#include <ao_flash.h>
+
+extern uint8_t __flash__[];
+
+/* saved variables to rebuild the heap
+
+   ao_scheme_atoms
+   ao_scheme_frame_global
+ */
+
+int
+ao_scheme_os_save(void)
+{
+       int 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);
+       }
+       return 1;
+}
+
+int
+ao_scheme_os_restore_save(struct ao_scheme_os_save *save, int offset)
+{
+       memcpy(save, &__flash__[offset], sizeof (struct ao_scheme_os_save));
+       return 1;
+}
+
+int
+ao_scheme_os_restore(void)
+{
+       memcpy(ao_scheme_pool, __flash__, AO_SCHEME_POOL_TOTAL);
+       return 1;
+}