summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2022-06-06 09:34:25 -0700
committerH. Peter Anvin <hpa@zytor.com>2022-06-06 09:34:25 -0700
commit1b9f666c8ed7e53d0f48a76dbed350df76616689 (patch)
tree1728ffec95a8fd8de351c4873ad2fc2428648763
parentc15e74f601276421573e4c46ac7448f93d742a5e (diff)
downloadblinktest-1b9f666c8ed7e53d0f48a76dbed350df76616689.tar.gz
blinktest-1b9f666c8ed7e53d0f48a76dbed350df76616689.tar.xz
blinktest-1b9f666c8ed7e53d0f48a76dbed350df76616689.zip
Create a common directory for sources between esp32 and rv32
-rw-r--r--common/compiler.h (renamed from esp32/max80/compiler.h)26
-rw-r--r--common/esplink.h (renamed from esp32/max80/esplink.h)0
-rw-r--r--esp32/Makefile2
-rw-r--r--esp32/output/max80.ino.binbin774352 -> 774352 bytes
-rw-r--r--fpga/max80.qpf4
-rw-r--r--fpga/output/v1.fwbin735803 -> 735805 bytes
-rw-r--r--fpga/output/v1.jicbin16777443 -> 16777443 bytes
-rw-r--r--fpga/output/v1.rbf.gzbin160741 -> 160748 bytes
-rw-r--r--fpga/output/v1.rpd.gzbin217825 -> 217827 bytes
-rw-r--r--fpga/output/v1.sofbin509098 -> 509098 bytes
-rw-r--r--fpga/output/v1.svf.gzbin183559 -> 183570 bytes
-rw-r--r--fpga/output/v1.xsvf.gzbin165028 -> 165030 bytes
-rw-r--r--fpga/output/v2.fwbin735134 -> 735212 bytes
-rw-r--r--fpga/output/v2.jicbin16777443 -> 16777443 bytes
-rw-r--r--fpga/output/v2.rbf.gzbin160562 -> 160570 bytes
-rw-r--r--fpga/output/v2.rpd.gzbin217793 -> 217788 bytes
-rw-r--r--fpga/output/v2.sofbin509098 -> 509098 bytes
-rw-r--r--fpga/output/v2.svf.gzbin183310 -> 183315 bytes
-rw-r--r--fpga/output/v2.xsvf.gzbin164647 -> 164649 bytes
-rw-r--r--rv32/Makefile2
-rw-r--r--rv32/common.h45
-rw-r--r--rv32/compiler.h115
-rw-r--r--rv32/esp.c2
-rw-r--r--rv32/esp.h (renamed from rv32/esplink.h)8
-rw-r--r--rv32/head.S1
-rw-r--r--rv32/include/compiler.h7
-rw-r--r--rv32/irqasm.S1
-rw-r--r--rv32/irqtable.S1
-rw-r--r--rv32/sections.h29
-rw-r--r--rv32/spiflash.c2
-rw-r--r--rv32/system.c2
31 files changed, 93 insertions, 154 deletions
diff --git a/esp32/max80/compiler.h b/common/compiler.h
index 048292f..a3de2f4 100644
--- a/esp32/max80/compiler.h
+++ b/common/compiler.h
@@ -3,11 +3,13 @@
#ifndef __ASSEMBLY__
-#include <stdlib.h>
-#include <stdarg.h>
+#include <stddef.h>
+#include <errno.h>
#include <inttypes.h>
-#include <stdbool.h>
#include <limits.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdlib.h>
#ifdef __cplusplus
# define extern_c extern "C"
@@ -40,6 +42,23 @@ typedef union xcptr {
size_t a;
} xcptr_t;
+/* Subword types */
+typedef union {
+ uint8_t b[8];
+ uint16_t h[4];
+ uint32_t l[2];
+ uint64_t q;
+} qword_t;
+typedef union {
+ uint8_t b[4];
+ uint16_t h[2];
+ uint32_t l;
+} lword_t;
+typedef union {
+ uint8_t b[2];
+ uint16_t h;
+} hword_t;
+
/* The container_of construct: if p is a pointer to member m of
container class c, then return a pointer to the container of which
*p is a member. */
@@ -50,6 +69,7 @@ typedef union xcptr {
#define offset_diff(c, m1, m2) ((ptrdiff_t)offsetof(c,m2) - \
(ptrdiff_t)offsetof(c,m1))
+/* Type-safeish comparison macros */
#define Min(a,b) ({ \
__typeof__((a)*(b)) __a = (a); \
__typeof__((a)*(b)) __b = (b); \
diff --git a/esp32/max80/esplink.h b/common/esplink.h
index e0cb242..e0cb242 100644
--- a/esp32/max80/esplink.h
+++ b/common/esplink.h
diff --git a/esp32/Makefile b/esp32/Makefile
index 33f0ad3..2f12197 100644
--- a/esp32/Makefile
+++ b/esp32/Makefile
@@ -9,7 +9,7 @@ GENFILES = www.zip
WWW = www
PORT ?= /dev/ttyACM2
-build_defines = -DBOARD_HAS_PSRAM
+build_defines = -DBOARD_HAS_PSRAM -I$(realpath ../common)
BOARD = esp32:esp32:esp32s2usb
ARDUINO_OPTS = -b $(BOARD) \
diff --git a/esp32/output/max80.ino.bin b/esp32/output/max80.ino.bin
index ca258df..a392487 100644
--- a/esp32/output/max80.ino.bin
+++ b/esp32/output/max80.ino.bin
Binary files differ
diff --git a/fpga/max80.qpf b/fpga/max80.qpf
index 54026e6..0d54578 100644
--- a/fpga/max80.qpf
+++ b/fpga/max80.qpf
@@ -19,12 +19,12 @@
#
# Quartus Prime
# Version 21.1.0 Build 842 10/21/2021 SJ Lite Edition
-# Date created = 01:03:43 June 05, 2022
+# Date created = 09:33:44 June 06, 2022
#
# -------------------------------------------------------------------------- #
QUARTUS_VERSION = "21.1"
-DATE = "01:03:43 June 05, 2022"
+DATE = "09:33:44 June 06, 2022"
# Revisions
diff --git a/fpga/output/v1.fw b/fpga/output/v1.fw
index ca04e7b..d6dbd0b 100644
--- a/fpga/output/v1.fw
+++ b/fpga/output/v1.fw
Binary files differ
diff --git a/fpga/output/v1.jic b/fpga/output/v1.jic
index 1e18b6d..afe75e0 100644
--- a/fpga/output/v1.jic
+++ b/fpga/output/v1.jic
Binary files differ
diff --git a/fpga/output/v1.rbf.gz b/fpga/output/v1.rbf.gz
index 33d6ad0..8de7c88 100644
--- a/fpga/output/v1.rbf.gz
+++ b/fpga/output/v1.rbf.gz
Binary files differ
diff --git a/fpga/output/v1.rpd.gz b/fpga/output/v1.rpd.gz
index 77638c2..ce19f8a 100644
--- a/fpga/output/v1.rpd.gz
+++ b/fpga/output/v1.rpd.gz
Binary files differ
diff --git a/fpga/output/v1.sof b/fpga/output/v1.sof
index b2108fb..8726871 100644
--- a/fpga/output/v1.sof
+++ b/fpga/output/v1.sof
Binary files differ
diff --git a/fpga/output/v1.svf.gz b/fpga/output/v1.svf.gz
index 7fc722d..8a02706 100644
--- a/fpga/output/v1.svf.gz
+++ b/fpga/output/v1.svf.gz
Binary files differ
diff --git a/fpga/output/v1.xsvf.gz b/fpga/output/v1.xsvf.gz
index 4d4cbc4..1b5bd89 100644
--- a/fpga/output/v1.xsvf.gz
+++ b/fpga/output/v1.xsvf.gz
Binary files differ
diff --git a/fpga/output/v2.fw b/fpga/output/v2.fw
index 8efb21e..0b9ec50 100644
--- a/fpga/output/v2.fw
+++ b/fpga/output/v2.fw
Binary files differ
diff --git a/fpga/output/v2.jic b/fpga/output/v2.jic
index 56a6986..8f433aa 100644
--- a/fpga/output/v2.jic
+++ b/fpga/output/v2.jic
Binary files differ
diff --git a/fpga/output/v2.rbf.gz b/fpga/output/v2.rbf.gz
index feb7d1f..9d996b1 100644
--- a/fpga/output/v2.rbf.gz
+++ b/fpga/output/v2.rbf.gz
Binary files differ
diff --git a/fpga/output/v2.rpd.gz b/fpga/output/v2.rpd.gz
index 523cbbe..429fc42 100644
--- a/fpga/output/v2.rpd.gz
+++ b/fpga/output/v2.rpd.gz
Binary files differ
diff --git a/fpga/output/v2.sof b/fpga/output/v2.sof
index f5b9ea3..4c90ccd 100644
--- a/fpga/output/v2.sof
+++ b/fpga/output/v2.sof
Binary files differ
diff --git a/fpga/output/v2.svf.gz b/fpga/output/v2.svf.gz
index 862a0aa..82200f6 100644
--- a/fpga/output/v2.svf.gz
+++ b/fpga/output/v2.svf.gz
Binary files differ
diff --git a/fpga/output/v2.xsvf.gz b/fpga/output/v2.xsvf.gz
index 76869dc..17039d7 100644
--- a/fpga/output/v2.xsvf.gz
+++ b/fpga/output/v2.xsvf.gz
Binary files differ
diff --git a/rv32/Makefile b/rv32/Makefile
index 2a02495..f04ec8f 100644
--- a/rv32/Makefile
+++ b/rv32/Makefile
@@ -11,7 +11,7 @@ NM = $(CROSS)nm
PERL = perl
GZIP = gzip
-INCLUDE = -I. -I./include -I./zlib -I./fatfs/source
+INCLUDE = -I. -I./include -I../common -I./zlib -I./fatfs/source
include ../riscv-opts.mk
CPPFLAGS = $(INCLUDE) $(riscv_flags)
CFLAGS = $(CPPFLAGS) -W -Wextra
diff --git a/rv32/common.h b/rv32/common.h
index 1012539..bca3e70 100644
--- a/rv32/common.h
+++ b/rv32/common.h
@@ -1,26 +1,35 @@
-#ifndef FW_H
-#define FW_H
+#ifndef COMMON_H
+#define COMMON_H
#include "compiler.h"
+#include "sections.h"
#include "picorv32.h"
#include "irq.h"
-/* Sometimes useful combination types */
-typedef union {
- uint8_t b[8];
- uint16_t h[4];
- uint32_t l[2];
- uint64_t q;
-} qword_t;
-typedef union {
- uint8_t b[4];
- uint16_t h[2];
- uint32_t l;
-} lword_t;
-typedef union {
- uint8_t b[2];
- uint16_t h;
-} hword_t;
+#define min(a,b) Min(a,b)
+#define max(a,b) Max(a,b)
+
+/* memcpy() variants */
+
+/* Use builtin memcpy and memset optimizations */
+#define memset(s,c,n) __builtin_memset(s,c,n)
+#define memcpy(d,s,n) __builtin_memcpy(d,s,n)
+#define mempcpy(d,s,n) __builtin_mempcpy(d,s,n)
+#define memmove(d,s,n) __builtin_memmove(d,s,n)
+
+extern volatile void *memcpy_bytewise(volatile void *dst,
+ const volatile void *src, size_t len);
+/*
+ * The odd argument order allows memcpy() and mempcpy() to be implemented
+ * as tail calls
+ */
+extern void *__memxcpy_aligned(void *retval,
+ const void * restrict src, size_t len,
+ void * restrict dst);
+extern void *__memxcpy_bytewise(void *retval,
+ const volatile void * restrict src, size_t len,
+ void * restrict dst);
+
extern const size_t __rom_offset;
extern const uint32_t __dram_checksum;
diff --git a/rv32/compiler.h b/rv32/compiler.h
deleted file mode 100644
index 7320baf..0000000
--- a/rv32/compiler.h
+++ /dev/null
@@ -1,115 +0,0 @@
-#ifndef COMPILER_H
-#define COMPILER_H
-
-#ifndef __ASSEMBLY__
-
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <errno.h>
-
-/* Use builtin memcpy and memset optimizations */
-#define memset(s,c,n) __builtin_memset(s,c,n)
-#define memcpy(d,s,n) __builtin_memcpy(d,s,n)
-#define mempcpy(d,s,n) __builtin_mempcpy(d,s,n)
-#define memmove(d,s,n) __builtin_memmove(d,s,n)
-
-extern volatile void *memcpy_bytewise(volatile void *dst,
- const volatile void *src, size_t len);
-
-/*
- * The odd argument order allows memcpy() and mempcpy() to be implemented
- * as tail calls
- */
-extern void *__memxcpy_aligned(void *retval,
- const void * restrict src, size_t len,
- void * restrict dst);
-extern void *__memxcpy_bytewise(void *retval,
- const volatile void * restrict src, size_t len,
- void * restrict dst);
-
-#define likely(x) __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
-
-/* Handy composite pointer types */
-typedef union xptr {
- uint32_t *l;
- uint16_t *w;
- uint8_t *b;
- void *v;
- size_t a;
-} xptr_t;
-typedef union xcptr {
- const uint32_t *l;
- const uint16_t *w;
- const uint8_t *b;
- const void *v;
- size_t a;
-} xcptr_t;
-
-/* The container_of construct: if p is a pointer to member m of
- container class c, then return a pointer to the container of which
- *p is a member. */
-#ifndef container_of
-# define container_of(p, c, m) ((c *)((char *)(p) - offsetof(c,m)))
-#endif
-
-#define offset_diff(c, m1, m2) ((ptrdiff_t)offsetof(c,m2) - \
- (ptrdiff_t)offsetof(c,m1))
-
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-
-#define ARRAY_SIZE (sizeof(a)/sizeof(a[0]))
-
-#define alignof(a) __alignof__(a)
-
-#define no_return void __attribute__((noreturn))
-
-#define ___section(s,a,...) __attribute__((__section__(s)))
-
-#define __hot __attribute__((__hot__))
-#define __cold __attribute__((__cold__))
-#define __aligned(x) __attribute__((__aligned__(x)))
-#define __unused __attribute__((__unused__))
-#define __must_inline __attribute__((__always_inline__))
-#define __noinline __attribute__ ((__noinline__))
-#define __constfunc __attribute__((__const__))
-#define __purefunc __attribute__((__pure__))
-
-#define __fmt_printf(fstr,farg) __attribute__((__format__(__printf__,fstr,farg)))
-
-#define __is_constant(expr) __builtin_constant_p(expr)
-
-#else /* __ASSEMBLY__ */
-
-#define ___section(s,a,...) .pushsection s, a, ## __VA_ARGS__
-
-#endif /* __ASSEMBLY__ */
-
-#define __text_hot ___section(".text.hot","ax")
-#define __rodata_hot ___section(".rodata.hot","a")
-#define __data_hot ___section(".data.hot","aw")
-#define __rwtext ___section(".rwtext","awx")
-#define __sdata ___section(".sdata","aw")
-#define __string_hot ___section(".rodata.hot.str","aMS")
-#define __sbss ___section(".sbss.hot","aw",@nobits)
-#define __bss_hot ___section(".bss.hot","aw",@nobits)
-#define __esplink_head ___section(".dram.esplink.head","aw",@nobits)
-#define __esplink ___section(".dram.bss.esplink","aw",@nobits)
-#define __dram_text ___section(".dram.text","ax")
-#define __dram_rodata ___section(".dram.rodata","a")
-#define __dram_string ___section(".dram.rodata.str","aMS")
-#define __dram_data ___section(".dram.data","aw")
-#define __dram_bss ___section(".dram.bss","aw",@nobits)
-#define __dram_noinit ___section(".dram.noinit","aw",@nobits)
-
-#ifndef __ASSEMBLY__
-
-#define hotstr(x) ({ static __string_hot const char _str[] = (x); _str; })
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* COMPILER_H */
diff --git a/rv32/esp.c b/rv32/esp.c
index 262d6e3..a675725 100644
--- a/rv32/esp.c
+++ b/rv32/esp.c
@@ -2,7 +2,7 @@
#include "common.h"
#include "io.h"
#include "console.h"
-#include "esplink.h"
+#include "esp.h"
struct esplink_head __esplink_head esplink_head;
static volatile __esplink struct esplink_timesync tsync;
diff --git a/rv32/esplink.h b/rv32/esp.h
index c9edad4..6aaa7b1 100644
--- a/rv32/esplink.h
+++ b/rv32/esp.h
@@ -1,8 +1,8 @@
-#ifndef RV32_ESPLINK_H
-#define RV32_ESPLINK_H
+#ifndef RV32_ESP_H
+#define RV32_ESP_H
#include "compiler.h"
-#include "../esp32/max80/esplink.h"
+#include "esplink.h"
extern void esp_init(void);
extern void esp_ota(const void *, size_t);
@@ -13,4 +13,4 @@ extern size_t esp_rb_write(enum esplink_ringbuf_user ring,
extern int esp_rb_getc(enum esplink_ringbuf_user ring);
extern int esp_rb_putc(enum esplink_ringbuf_user ring, uint8_t data);
-#endif /* RV32_ESPLINK_H */
+#endif /* RV32_ESP_H */
diff --git a/rv32/head.S b/rv32/head.S
index dd3fc83..7eb2b7e 100644
--- a/rv32/head.S
+++ b/rv32/head.S
@@ -1,4 +1,5 @@
#include "sys.h"
+#include "sections.h"
#include "picorv32.h"
#define GP_IS_ZERO 1
diff --git a/rv32/include/compiler.h b/rv32/include/compiler.h
deleted file mode 100644
index 4d6af0b..0000000
--- a/rv32/include/compiler.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef COMPILER_H
-#define COMPILER_H
-
-#define likely(x) __builtin_expect(!!(x),1)
-#define unlikely(x) __builtin_expect(!!(x),0)
-
-#endif /* COMPILER_H */
diff --git a/rv32/irqasm.S b/rv32/irqasm.S
index 71a3c1b..2a2e89e 100644
--- a/rv32/irqasm.S
+++ b/rv32/irqasm.S
@@ -1,4 +1,5 @@
#include "compiler.h"
+#include "sections.h"
#include "picorv32.h"
#include "ioregs.h"
diff --git a/rv32/irqtable.S b/rv32/irqtable.S
index 5dbfb4d..9bb975b 100644
--- a/rv32/irqtable.S
+++ b/rv32/irqtable.S
@@ -1,4 +1,5 @@
#include "compiler.h"
+#include "sections.h"
#include "picorv32.h"
#include "iodevs.h"
diff --git a/rv32/sections.h b/rv32/sections.h
new file mode 100644
index 0000000..f0945d2
--- /dev/null
+++ b/rv32/sections.h
@@ -0,0 +1,29 @@
+#ifndef SECTIONS_H
+#define SECTIONS_H
+
+#include "compiler.h"
+
+#define __text_hot ___section(".text.hot","ax")
+#define __rodata_hot ___section(".rodata.hot","a")
+#define __data_hot ___section(".data.hot","aw")
+#define __rwtext ___section(".rwtext","awx")
+#define __sdata ___section(".sdata","aw")
+#define __string_hot ___section(".rodata.hot.str","aMS")
+#define __sbss ___section(".sbss.hot","aw",@nobits)
+#define __bss_hot ___section(".bss.hot","aw",@nobits)
+#define __esplink_head ___section(".dram.esplink.head","aw",@nobits)
+#define __esplink ___section(".dram.bss.esplink","aw",@nobits)
+#define __dram_text ___section(".dram.text","ax")
+#define __dram_rodata ___section(".dram.rodata","a")
+#define __dram_string ___section(".dram.rodata.str","aMS")
+#define __dram_data ___section(".dram.data","aw")
+#define __dram_bss ___section(".dram.bss","aw",@nobits)
+#define __dram_noinit ___section(".dram.noinit","aw",@nobits)
+
+#ifndef __ASSEMBLY__
+
+#define hotstr(x) ({ static __string_hot const char _str[] = (x); _str; })
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* SECTIONS_H */
diff --git a/rv32/spiflash.c b/rv32/spiflash.c
index a07b73f..8dc7e5d 100644
--- a/rv32/spiflash.c
+++ b/rv32/spiflash.c
@@ -1,4 +1,4 @@
-#include "compiler.h"
+#include "common.h"
#include "zlib.h"
#include "spiflash.h"
diff --git a/rv32/system.c b/rv32/system.c
index 1cd4385..434a2c3 100644
--- a/rv32/system.c
+++ b/rv32/system.c
@@ -4,7 +4,7 @@
#include "abcio.h"
#include "sys.h"
#include "console.h"
-#include "esplink.h"
+#include "esp.h"
#define DEBUG 0
#define MINITESTS 1