Clean up include, autoboot, split windows, shorten start.
Drop startup timeout to 100ms. Clean up exceptions in include. Cleanup stack in autoboot. Split out windows into a second string, to work around overflow issue.
This commit is contained in:
14
Makefile
14
Makefile
@ -253,16 +253,20 @@ POSIX_BOOT = $(COMMON_PHASE1) \
|
|||||||
$(GEN)/posix_boot.h: tools/source_to_string.js $(POSIX_BOOT) | $(GEN)
|
$(GEN)/posix_boot.h: tools/source_to_string.js $(POSIX_BOOT) | $(GEN)
|
||||||
$< boot $(VERSION) $(REVISION) $(POSIX_BOOT) >$@
|
$< 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_BOOT = $(COMMON_PHASE1) \
|
||||||
windows/windows_core.fs \
|
windows/windows_core.fs \
|
||||||
windows/windows_files.fs \
|
windows/windows_files.fs \
|
||||||
windows/windows_console.fs \
|
windows/windows_console.fs \
|
||||||
windows/windows_user.fs \
|
|
||||||
windows/windows_gdi.fs \
|
|
||||||
windows/windows_messages.fs \
|
|
||||||
windows/allocation.fs \
|
windows/allocation.fs \
|
||||||
$(COMMON_PHASE2) $(COMMON_FILETOOLS) $(COMMON_DESKTOP) \
|
$(COMMON_PHASE2) $(COMMON_FILETOOLS) $(COMMON_DESKTOP) \
|
||||||
windows/graphics.fs \
|
windows/load_extra.fs \
|
||||||
posix/autoboot.fs \
|
posix/autoboot.fs \
|
||||||
common/fini.fs
|
common/fini.fs
|
||||||
$(GEN)/windows_boot.h: tools/source_to_string.js $(WINDOWS_BOOT) | $(GEN)
|
$(GEN)/windows_boot.h: tools/source_to_string.js $(WINDOWS_BOOT) | $(GEN)
|
||||||
@ -404,6 +408,7 @@ $(WINDOWS)/uEf32.obj: \
|
|||||||
common/bits.h \
|
common/bits.h \
|
||||||
common/core.h \
|
common/core.h \
|
||||||
windows/interp.h \
|
windows/interp.h \
|
||||||
|
$(GEN)/windows_boot_extra.h \
|
||||||
$(GEN)/windows_boot.h | $(WINDOWS)
|
$(GEN)/windows_boot.h | $(WINDOWS)
|
||||||
$(CL32) /c /Fo$@ $(WIN_CFLAGS) $<
|
$(CL32) /c /Fo$@ $(WIN_CFLAGS) $<
|
||||||
|
|
||||||
@ -423,6 +428,7 @@ $(WINDOWS)/uEf64.obj: \
|
|||||||
common/bits.h \
|
common/bits.h \
|
||||||
common/core.h \
|
common/core.h \
|
||||||
windows/interp.h \
|
windows/interp.h \
|
||||||
|
$(GEN)/windows_boot_extra.h \
|
||||||
$(GEN)/windows_boot.h | $(WINDOWS)
|
$(GEN)/windows_boot.h | $(WINDOWS)
|
||||||
$(CL64) /c /Fo$@ $(WIN_CFLAGS) $<
|
$(CL64) /c /Fo$@ $(WIN_CFLAGS) $<
|
||||||
|
|
||||||
|
|||||||
@ -467,6 +467,7 @@ e: check-args
|
|||||||
;e
|
;e
|
||||||
|
|
||||||
e: check-imports
|
e: check-imports
|
||||||
|
out: file-exists?
|
||||||
out: needs
|
out: needs
|
||||||
out: required
|
out: required
|
||||||
out: included?
|
out: included?
|
||||||
|
|||||||
@ -78,11 +78,12 @@ forth definitions internals
|
|||||||
: included ( a n -- )
|
: included ( a n -- )
|
||||||
sourcefilename >r >r
|
sourcefilename >r >r
|
||||||
>r >r sourcedirname r> r> path-join 2dup sourcefilename!
|
>r >r sourcedirname r> r> path-join 2dup sourcefilename!
|
||||||
['] raw-included catch
|
['] raw-included catch if
|
||||||
dup if ." Error including: " sourcefilename type cr then
|
." Error including: " sourcefilename type cr
|
||||||
|
-38 throw
|
||||||
|
then
|
||||||
sourcefilename& include+
|
sourcefilename& include+
|
||||||
r> r> sourcefilename!
|
r> r> sourcefilename! ;
|
||||||
throw ;
|
|
||||||
|
|
||||||
: include ( "name" -- ) bl parse included ;
|
: include ( "name" -- ) bl parse included ;
|
||||||
|
|
||||||
@ -98,4 +99,6 @@ forth definitions internals
|
|||||||
: required ( a n -- ) 2dup included? if 2drop else included then ;
|
: required ( a n -- ) 2dup included? if 2drop else included then ;
|
||||||
: needs ( "name" -- ) bl parse required ;
|
: needs ( "name" -- ) bl parse required ;
|
||||||
|
|
||||||
|
: file-exists? ( "name" -- f ) r/o open-file if drop 0 else close-file throw -1 then ;
|
||||||
|
|
||||||
forth
|
forth
|
||||||
|
|||||||
@ -25,8 +25,10 @@ internals definitions
|
|||||||
( Check for autoexec.fs and run if present.
|
( Check for autoexec.fs and run if present.
|
||||||
Failing that, try to revive save image. )
|
Failing that, try to revive save image. )
|
||||||
: autoexec
|
: autoexec
|
||||||
300 for key? if rdrop exit then 10 ms next
|
( Allow skip start files if key hit within 100 ms )
|
||||||
s" /spiffs/autoexec.fs" ['] included catch 2drop drop
|
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 ;
|
['] revive catch drop ;
|
||||||
' autoexec ( leave on the stack for fini.fs )
|
' autoexec ( leave on the stack for fini.fs )
|
||||||
|
|
||||||
|
|||||||
@ -26,11 +26,11 @@ internals
|
|||||||
' call10 , ' call11 , ' call12 , ' call13 , ' call14 , ' call15 ,
|
' call10 , ' call11 , ' call12 , ' call13 , ' call14 , ' call15 ,
|
||||||
posix
|
posix
|
||||||
: sofunc ( z n a "name" -- )
|
: 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 ;
|
does> dup @ swap cell+ @ execute ;
|
||||||
: sysfunc ( z n "name" -- ) 0 sofunc ;
|
: sysfunc ( z n "name" -- ) 0 sofunc ;
|
||||||
: shared-library ( z "name" -- )
|
: 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 ;
|
: sign-extend ( n -- n ) >r rp@ sl@ rdrop ;
|
||||||
|
|
||||||
( Major Syscalls )
|
( Major Syscalls )
|
||||||
|
|||||||
16
windows/load_extra.fs
Normal file
16
windows/load_extra.fs
Normal file
@ -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
|
||||||
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
static LRESULT WindowProcShim(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
static LRESULT WindowProcShim(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
static void SetupCtrlBreakHandler(void);
|
static void SetupCtrlBreakHandler(void);
|
||||||
|
static cell_t GetBootExtra(cell_t *start);
|
||||||
|
|
||||||
#define PLATFORM_OPCODE_LIST \
|
#define PLATFORM_OPCODE_LIST \
|
||||||
YV(windows, GetProcAddress, \
|
YV(windows, GetProcAddress, \
|
||||||
@ -45,6 +46,7 @@ static void SetupCtrlBreakHandler(void);
|
|||||||
YV(windows, LoadLibraryA, tos = (cell_t) LoadLibraryA((LPCSTR) tos)) \
|
YV(windows, LoadLibraryA, tos = (cell_t) LoadLibraryA((LPCSTR) tos)) \
|
||||||
YV(windows, WindowProcShim, DUP; tos = (cell_t) &WindowProcShim) \
|
YV(windows, WindowProcShim, DUP; tos = (cell_t) &WindowProcShim) \
|
||||||
YV(windows, SetupCtrlBreakHandler, SetupCtrlBreakHandler()) \
|
YV(windows, SetupCtrlBreakHandler, SetupCtrlBreakHandler()) \
|
||||||
|
YV(windows, boot_extra, DUP; DUP; tos = GetBootExtra(sp)) \
|
||||||
CALLING_OPCODE_LIST \
|
CALLING_OPCODE_LIST \
|
||||||
FLOATING_POINT_LIST
|
FLOATING_POINT_LIST
|
||||||
|
|
||||||
@ -56,6 +58,7 @@ static void SetupCtrlBreakHandler(void);
|
|||||||
#include "windows/interp.h"
|
#include "windows/interp.h"
|
||||||
|
|
||||||
#include "gen/windows_boot.h"
|
#include "gen/windows_boot.h"
|
||||||
|
#include "gen/windows_boot_extra.h"
|
||||||
|
|
||||||
static DWORD forth_main_thread_id;
|
static DWORD forth_main_thread_id;
|
||||||
static uintptr_t forth_main_thread_resume_sp;
|
static uintptr_t forth_main_thread_resume_sp;
|
||||||
@ -108,6 +111,11 @@ static void SetupCtrlBreakHandler(void) {
|
|||||||
#endif
|
#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) {
|
static LRESULT WindowProcShim(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
if (msg == WM_NCCREATE) {
|
if (msg == WM_NCCREATE) {
|
||||||
SetWindowLongPtr(
|
SetWindowLongPtr(
|
||||||
|
|||||||
Reference in New Issue
Block a user