Peel off assemblers into optional module.

Not sufficiently tested.
This commit is contained in:
Brad Nelson
2023-07-05 15:00:59 -07:00
parent 2a673c7378
commit 6884898cb1
9 changed files with 148 additions and 10 deletions

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
VERSION=7.0.7.12
VERSION=7.0.7.13
STABLE_VERSION=7.0.6.19
OLD_STABLE_VERSION=7.0.5.4
REVISION=$(shell git rev-parse HEAD | head -c 20)
@ -276,15 +276,31 @@ ESP32_BOOT = $(COMMON_PHASE1) \
esp32/allocation.fs esp32/bindings.fs \
$(COMMON_PHASE2) $(COMMON_FILETOOLS) \
esp32/platform.fs \
common/assembler.fs esp32/xtensa-assembler.fs esp32/riscv-assembler.fs \
posix/httpd.fs posix/web_interface.fs esp32/web_interface.fs \
esp32/registers.fs esp32/timers.fs \
esp32/bterm.fs posix/telnetd.fs \
esp32/camera.fs esp32/camera_server.fs \
esp32/optionals.fs \
esp32/autoboot.fs common/fini.fs
$(GEN)/esp32_boot.h: tools/source_to_string.js $(ESP32_BOOT) | $(GEN)
$< boot $(VERSION) $(REVISION) $(ESP32_BOOT) >$@
ESP32_ASSEMBLERS = common/assembler.fs \
esp32/xtensa-assembler.fs \
esp32/riscv-assembler.fs
$(GEN)/esp32_assemblers.h: tools/source_to_string.js $(ESP32_ASSEMBLERS) | $(GEN)
$< assemblers_source $(VERSION) $(REVISION) $(ESP32_ASSEMBLERS) >$@
OPTIONAL_MODULES = $(ESP32)/ESP32forth/assemblers.h
add-optional: $(OPTIONAL_MODULES)
drop-optional:
rm -f $(OPTIONAL_MODULES)
$(ESP32)/ESP32forth/assemblers.h: $(ESP32)/ESP32forth/optional/assemblers.h
cp $< $@
$(GEN)/dump_web_opcodes: \
web/dump_web_opcodes.c \
common/tier0_opcodes.h \
@ -492,13 +508,16 @@ $(ESP32_SIM)/Esp32forth-sim: \
# ---- ESP32 ----
esp32: esp32_target esp32_sim esp32_tests esp32_sim_tests
esp32_target: $(ESP32)/ESP32forth/ESP32forth.ino
esp32_target: $(ESP32)/ESP32forth.zip
$(ESP32)/ESP32forth:
mkdir -p $@
$(ESP32)/ESP32forth/optional:
mkdir -p $@
ESP32_PARTS = tools/replace.js \
esp32/template.ino \
esp32/ESP32forth.ino \
common/tier0_opcodes.h \
common/tier1_opcodes.h \
common/tier2_opcodes.h \
@ -517,7 +536,7 @@ ESP32_PARTS = tools/replace.js \
$(GEN)/esp32_boot.h
$(ESP32)/ESP32forth/ESP32forth.ino: $(ESP32_PARTS) | $(ESP32)/ESP32forth
cat esp32/template.ino | tools/replace.js \
cat esp32/ESP32forth.ino | tools/replace.js \
VERSION=$(VERSION) \
REVISION=$(REVISION) \
tier0_opcodes=@common/tier0_opcodes.h \
@ -538,6 +557,27 @@ $(ESP32)/ESP32forth/ESP32forth.ino: $(ESP32_PARTS) | $(ESP32)/ESP32forth
boot=@$(GEN)/esp32_boot.h \
>$@
$(ESP32)/ESP32forth/README.txt: esp32/README.txt | $(ESP32)/ESP32forth
cat esp32/README.txt | tools/replace.js \
VERSION=$(VERSION) \
REVISION=$(REVISION) \
>$@
$(ESP32)/ESP32forth/optional/README-optional.txt: \
esp32/README-optional.txt | $(ESP32)/ESP32forth/optional
cat esp32/README-optional.txt | tools/replace.js \
VERSION=$(VERSION) \
REVISION=$(REVISION) \
>$@
$(ESP32)/ESP32forth/optional/assemblers.h: \
esp32/assemblers.h $(GEN)/esp32_assemblers.h | $(ESP32)/ESP32forth/optional
cat esp32/assemblers.h | tools/replace.js \
VERSION=$(VERSION) \
REVISION=$(REVISION) \
assemblers=@$(GEN)/esp32_assemblers.h \
>$@
# ---- ESP32 ARDUINO BUILD AND FLASH ----
ARDUINO_BUILDER="/mnt/c/Program Files (x86)/Arduino/arduino-builder.exe"
@ -623,9 +663,16 @@ CHIP_esp32cam=esp32
0xe000 ${ARDUINO_APP}/packages/esp32/hardware/esp32/2.0.5/tools/partitions/boot_app0.bin \
0x10000 $(ESP32)/$(subst -flash,,$@)_build/ESP32forth.ino.bin
%-build: $(ESP32)/%_build/ESP32forth.ino.bin
echo "done"
# ---- PACKAGE ----
$(ESP32)/ESP32forth.zip: $(ESP32)/ESP32forth/ESP32forth.ino
$(ESP32)/ESP32forth.zip: \
$(ESP32)/ESP32forth/ESP32forth.ino \
$(ESP32)/ESP32forth/README.txt \
$(ESP32)/ESP32forth/optional/README-optional.txt \
$(ESP32)/ESP32forth/optional/assemblers.h
cd $(ESP32) && rm -f ESP32forth.zip && zip -r ESP32forth.zip ESP32forth
# ---- Publish to Archive ----

View File

@ -644,9 +644,6 @@ e: test-esp32-forth-voclist
;e
e: check-esp32-platform
out: riscv-assembler
out: xtensa-assembler
out: assembler
out: ok
out: LED
out: OUTPUT

20
esp32/README-optional.txt Normal file
View File

@ -0,0 +1,20 @@
+----------------------------------+
| ESP32forth - Optional Packages |
+----------------------------------+
ESPforth supports a number of optional packages, included in this directory.
By default ESPforth will only include core functionality.
To include one or more of these modules, move them from this directory
into the parent directory, next to the ESPforth.ino file.
These are the current optional modules:
* assemblers.h - Assemblers for ESP32 Xtensa and ESP32 RISC-V
Initially ESP32forth focused on a minimal C kernel, with most functionality
built in Forth code loaded at boot. Eventually, as support for more capabilities
were added to ESPforth, this became unsustainable.
Optional modules demonstrate good patterns for use in your own extensions
to ESP32forth. You can add you own modules by #including them from
an optional userwords.h file placed next to ESPforth.ino

20
esp32/README.txt Normal file
View File

@ -0,0 +1,20 @@
+--------------+
| ESP32forth |
+--------------+
This is ESP32forth v{{VERSION}} (Revision {{REVISION}}).
ESP32forth is an indirect threaded Forth for the ESP32 family of microcontrollers.
It uses a small C "kernel" that boots via inline Forth code.
The use of C allows developers to leverage C/C++ ESP32 libraries with minimal effort.
To compile and flash with the Arduino tools, load ESP32forth.ino.
Documentation and the latest version of ESP32forth are available at:
https://esp32forth.appspot.com/
Full unexpanded source code and an issue tracker are available at:
https://github.com/flagxor/ueforth
There are several optional components that you can add into ESP32forth.
See: optional/README-optional.txt

26
esp32/assemblers.h Normal file
View File

@ -0,0 +1,26 @@
/*
* Copyright 2023 Bradley D. Nelson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* ESP32forth Assemblers v{{VERSION}}
* Revision: {{REVISION}}
*/
{{assemblers}}
#define OPTIONAL_ASSEMBLERS_SUPPORT \
XV(internals, "assemblers-source", ASSEMBLERS_SOURCE, \
PUSH assemblers_source; PUSH sizeof(assemblers_source))

View File

@ -22,19 +22,27 @@
# include <sys/stat.h>
# include <sys/select.h>
// Optional hook to pull in words for userwords.h
// Hook to pull in words from optional userwords.h
# if __has_include("userwords.h")
# include "userwords.h"
# else
# define USER_WORDS
# endif
// Hook to pull in words from optional assemblers.h
# if __has_include("assemblers.h")
# include "assemblers.h"
# else
# define OPTIONAL_ASSEMBLERS_SUPPORT
# endif
static cell_t ResizeFile(cell_t fd, cell_t size);
#endif
#define PLATFORM_OPCODE_LIST \
USER_WORDS \
OPTIONAL_ASSEMBLERS_SUPPORT \
REQUIRED_PLATFORM_SUPPORT \
REQUIRED_ESP_SUPPORT \
REQUIRED_MEMORY_SUPPORT \

19
esp32/optionals.fs Normal file
View File

@ -0,0 +1,19 @@
\ Copyright 2023 Bradley D. Nelson
\
\ Licensed under the Apache License, Version 2.0 (the "License");
\ you may not use this file except in compliance with the License.
\ You may obtain a copy of the License at
\
\ http://www.apache.org/licenses/LICENSE-2.0
\
\ Unless required by applicable law or agreed to in writing, software
\ distributed under the License is distributed on an "AS IS" BASIS,
\ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\ See the License for the specific language governing permissions and
\ limitations under the License.
internals
DEFINED? assemblers-source [IF] assemblers-source evaluate [THEN]
forth

View File

@ -23,6 +23,7 @@
#define CALLING_OPCODE_LIST
#define FLOATING_POINT_LIST
#define USER_WORDS
#define OPTIONAL_ASSEMBLERS_SUPPORT
#include "builtins.h"
#define XV(flags, name, op, code) Z(flags, name, op, code)