diff --git a/Makefile b/Makefile index 3e48ba9..58872d8 100644 --- a/Makefile +++ b/Makefile @@ -253,16 +253,20 @@ POSIX_BOOT = $(COMMON_PHASE1) \ $(GEN)/posix_boot.h: tools/source_to_string.js $(POSIX_BOOT) | $(GEN) $< boot $(VERSION) $(REVISION) $(POSIX_BOOT) >$@ +WINDOWS_BOOT_EXTRA = windows/windows_user.fs \ + windows/windows_gdi.fs \ + windows/windows_messages.fs \ + windows/graphics.fs +$(GEN)/windows_boot_extra.h: tools/source_to_string.js $(WINDOWS_BOOT_EXTRA) | $(GEN) + $< -win boot_extra $(VERSION) $(REVISION) $(WINDOWS_BOOT_EXTRA) >$@ + WINDOWS_BOOT = $(COMMON_PHASE1) \ windows/windows_core.fs \ windows/windows_files.fs \ windows/windows_console.fs \ - windows/windows_user.fs \ - windows/windows_gdi.fs \ - windows/windows_messages.fs \ windows/allocation.fs \ $(COMMON_PHASE2) $(COMMON_FILETOOLS) $(COMMON_DESKTOP) \ - windows/graphics.fs \ + windows/load_extra.fs \ posix/autoboot.fs \ common/fini.fs $(GEN)/windows_boot.h: tools/source_to_string.js $(WINDOWS_BOOT) | $(GEN) @@ -404,6 +408,7 @@ $(WINDOWS)/uEf32.obj: \ common/bits.h \ common/core.h \ windows/interp.h \ + $(GEN)/windows_boot_extra.h \ $(GEN)/windows_boot.h | $(WINDOWS) $(CL32) /c /Fo$@ $(WIN_CFLAGS) $< @@ -423,6 +428,7 @@ $(WINDOWS)/uEf64.obj: \ common/bits.h \ common/core.h \ windows/interp.h \ + $(GEN)/windows_boot_extra.h \ $(GEN)/windows_boot.h | $(WINDOWS) $(CL64) /c /Fo$@ $(WIN_CFLAGS) $< diff --git a/common/forth_namespace_tests.fs b/common/forth_namespace_tests.fs index e43823a..e3515a9 100644 --- a/common/forth_namespace_tests.fs +++ b/common/forth_namespace_tests.fs @@ -467,6 +467,7 @@ e: check-args ;e e: check-imports + out: file-exists? out: needs out: required out: included? diff --git a/common/including.fs b/common/including.fs index 609999b..dc0abf6 100644 --- a/common/including.fs +++ b/common/including.fs @@ -78,11 +78,12 @@ forth definitions internals : included ( a n -- ) sourcefilename >r >r >r >r sourcedirname r> r> path-join 2dup sourcefilename! - ['] raw-included catch - dup if ." Error including: " sourcefilename type cr then + ['] raw-included catch if + ." Error including: " sourcefilename type cr + -38 throw + then sourcefilename& include+ - r> r> sourcefilename! - throw ; + r> r> sourcefilename! ; : include ( "name" -- ) bl parse included ; @@ -98,4 +99,6 @@ forth definitions internals : required ( a n -- ) 2dup included? if 2drop else included then ; : needs ( "name" -- ) bl parse required ; +: file-exists? ( "name" -- f ) r/o open-file if drop 0 else close-file throw -1 then ; + forth diff --git a/esp32/autoboot.fs b/esp32/autoboot.fs index 179c56c..a4054a6 100644 --- a/esp32/autoboot.fs +++ b/esp32/autoboot.fs @@ -25,8 +25,10 @@ internals definitions ( Check for autoexec.fs and run if present. Failing that, try to revive save image. ) : autoexec - 300 for key? if rdrop exit then 10 ms next - s" /spiffs/autoexec.fs" ['] included catch 2drop drop + ( Allow skip start files if key hit within 100 ms ) + 10 for key? if rdrop exit then 10 ms next + s" /spiffs/autoexec.fs" 2dup file-exists? + if included else 2drop then ['] revive catch drop ; ' autoexec ( leave on the stack for fini.fs ) diff --git a/posix/posix.fs b/posix/posix.fs index fd01cfd..d206dac 100644 --- a/posix/posix.fs +++ b/posix/posix.fs @@ -26,11 +26,11 @@ internals ' call10 , ' call11 , ' call12 , ' call13 , ' call14 , ' call15 , posix : sofunc ( z n a "name" -- ) - swap >r swap dlsym dup 0= throw create , r> cells calls + @ , + swap >r swap dlsym dup 0= -38 and throw create , r> cells calls + @ , does> dup @ swap cell+ @ execute ; : sysfunc ( z n "name" -- ) 0 sofunc ; : shared-library ( z "name" -- ) - RTLD_NOW dlopen dup 0= throw create , does> @ sofunc ; + RTLD_NOW dlopen dup 0= -38 and throw create , does> @ sofunc ; : sign-extend ( n -- n ) >r rp@ sl@ rdrop ; ( Major Syscalls ) diff --git a/windows/load_extra.fs b/windows/load_extra.fs new file mode 100644 index 0000000..485f17a --- /dev/null +++ b/windows/load_extra.fs @@ -0,0 +1,16 @@ +\ 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. + +( Load extra things that didn't fit in main boot string. ) +windows boot_extra forth evaluate diff --git a/windows/main.c b/windows/main.c index 8935133..5896f17 100644 --- a/windows/main.c +++ b/windows/main.c @@ -38,6 +38,7 @@ static LRESULT WindowProcShim(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); static void SetupCtrlBreakHandler(void); +static cell_t GetBootExtra(cell_t *start); #define PLATFORM_OPCODE_LIST \ YV(windows, GetProcAddress, \ @@ -45,6 +46,7 @@ static void SetupCtrlBreakHandler(void); YV(windows, LoadLibraryA, tos = (cell_t) LoadLibraryA((LPCSTR) tos)) \ YV(windows, WindowProcShim, DUP; tos = (cell_t) &WindowProcShim) \ YV(windows, SetupCtrlBreakHandler, SetupCtrlBreakHandler()) \ + YV(windows, boot_extra, DUP; DUP; tos = GetBootExtra(sp)) \ CALLING_OPCODE_LIST \ FLOATING_POINT_LIST @@ -56,6 +58,7 @@ static void SetupCtrlBreakHandler(void); #include "windows/interp.h" #include "gen/windows_boot.h" +#include "gen/windows_boot_extra.h" static DWORD forth_main_thread_id; static uintptr_t forth_main_thread_resume_sp; @@ -108,6 +111,11 @@ static void SetupCtrlBreakHandler(void) { #endif } +static cell_t GetBootExtra(cell_t *start) { + *start = (cell_t) boot_extra; + return (cell_t) sizeof(boot_extra) - 1; +} + static LRESULT WindowProcShim(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_NCCREATE) { SetWindowLongPtr(