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)
|
||||
$< 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) $<
|
||||
|
||||
|
||||
@ -467,6 +467,7 @@ e: check-args
|
||||
;e
|
||||
|
||||
e: check-imports
|
||||
out: file-exists?
|
||||
out: needs
|
||||
out: required
|
||||
out: included?
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 )
|
||||
|
||||
|
||||
@ -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 )
|
||||
|
||||
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 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(
|
||||
|
||||
Reference in New Issue
Block a user