Dear Squeakers,
Please consider this as my little contribution to the NRTF.
At least to me, for now, I can enjoy the idea that I have a Headless Pure Kernel (tm) image with a VM stuckin. (all in 40 'forthy' KB ;-)
My hope is that this will become a topic when the future is going to be invented ;-)
Cheers,
SmallSqueak.
----- Original Message ----- From: "PhiHo Hoang" <phihoDOThoang(AT)rogersDOTcom> Newsgroups: comp.lang.forth Sent: Thursday, November 25, 2004 11:20 PM Subject: [ANN] IA32FVM + HPK (Headless Pure Kernel) image
Greetings,
This was posted last weekend and it seems it was burried under the old thread "Forth VM + microKernel" .
Since I really like to get feedback on the exercise I started several weeks ago and just barely finished last weekend, I am reposting this under a new thread in the hope that it can draw some attention hence feedback.
Please accept my apologies if anyone find this reposting offended.
[SNIP]
Only recently he thinks he found an interesting use for Forth so he is trying to do a more serious exercise, turning Win32Forth kernel into a pure STC kernel for IA32 architecture and the wrapper into a thin wrapper with minimal C code to support system interface through dlfcn interface and some other things.
The changes to STC will come later. I may reconsider this .
This release of IA32FVM is still ITC.
The 5 system calls were
0 EQU SysLoadLibrary 1 EQU SysGetProcAddress
These are the backbone for the FFI
2 EQU SysGetProcessHeap 3 EQU SysHeapAlloc
Needed to initialize buffers in the image.
4 EQU SysVirtualAlloc
I am not quite sure that this is really needed.
Let's call the pure kernel IA32FVM (in need of a better name).
Any suggestion ?
IA32FVM must not have IO words (including QUIT), but it must have support for dlfcn interface (with help from the thin wrapper) and be capable of compiling new words into the dictionary.
Done.
The pure kernel can now be extended into an SDK with inspecting words like WORDS, SEE, DIS
The thin wrapper will provide :
1/- Memory allocations 2/- Supports for dlfcn interface 3/- Loading an image (-I option) 4/- Reading a source file to fill the terminal input buffer so
that the compiler can compile them into the dictionary (-L option).
See below.
All the IO words (including FLOAD and FSAVE) and outer text interpreter will be implemented in a platform specific file <Platform>IO.f so that on Windows platforms, one can invoke :
ThisThinWrapper.exe -I IA32FVM.img -L Win32IO.f
someone else on, say IA32 Linux, can invoke:
ThatThinWrapper -I IA32FVM.img -L Lin32IO.f
For simplicity, in this release, just double click IA32FVM.exe to bring up a DOS console then :
FLOAD src\sdk.f
The DOS console is still slow and buggy. It was noticed that pressing SPACE while displaying WORDS, CONSTANTS and DIS does not work as expected.
It is interesting to note that this kernel not only pure, but also headless.
To switch head, using a kernel GUI console instead, edit IA32FVM.ini :
[LOAD] Comments.f =src\FKernel\Utils Maths.f =src\FKernel\Utils Tools.f =src\FKernel\Utils LastWords.f =src\FKernel\Utils ModUtil.f =src\FKernel\Utils dthread.f =src\FKernel\Module order.f =src\FKernel\Module module.f =src\FKernel\Module interpif.f =src\FKernel\Module InitWinLib.f =src\FKernel\Platform winlib.f =src\FKernel\Platform GetLastError.f =src\FKernel\Platform MemMan.f =src\FKernel\Platform ANSFile0.f =src\FKernel\Platform FileLoading.f =src\FKernel\Platform CurrentDir.f =src\FKernel\Platform LoadFile.f =src\FKernel\Platform DOSConsole.f =src\FKernel\Platform Startup.f =src\Boot ;3+4.f =src\Test
Replace DOSConsole.f with GUIConsole.f
The display is much faster and pressing SPACE works properly with DIS, WORDS, CONSTANTS
That Startup.f in src\Boot directory is also worth a look.
In there one will find that _QUIT, the outer interpreter.
If one does not like it, just go ahead and change it without having to recompile the kernel.
Isn't this cool ;-)
The word COLD is now a VM primitive ;-)
Also, take a look at IA32FVM.f (previously Fkernel.f) , all forward reference resolutions were eliminated, except one (left as an exericse for the experts ;-)
fload VM.f fload Nucleus.f fload uKernel.f
\ -------------------- The End -------------------- \ Forward reference resolutions.
\ ' THROW RESOLVES THROW \ ' NFA-COUNT RESOLVES NFA-COUNT \ ' NALIGNED RESOLVES NALIGNED \ ' _LOCALALLOC RESOLVES _LOCALALLOC \ ' _LOCALFREE RESOLVES _LOCALFREE \ ' LINK, RESOLVES LINK, \ ' START/STOP RESOLVES START/STOP \ ' LOADFILE RESOLVES LOADFILE \ ' INIT-K32 RESOLVES INIT-K32 \ ' LOAD-WINLIBRARY RESOLVES LOAD-WINLIBRARY \ ' RES-LOADCALL RESOLVES RES-LOADCALL \ ' .NAME RESOLVES .NAME
' PARMFIND RESOLVES PARMFIND
Note that IA32FVM.img is the same in both cases.
Are there anything wrong with these specs ? Is it doable ?
He is soliciting constructive critcisms and helps for this exercise.
Please feel free to email him directly.
I got help from nice people on W32F and W32FX lists.
The Wincon.dll with nearly 30 thousand Windows constants was stolen from W32FX 3.03.
The innovation in the Upper/Lower case in W32F 6.09.12 found its way into IA32FVM Pure Kernel too ;-)
The rest of IA32FVM is based on Win32Forth 6.09.
I really like to upload this preliminary release of IA32FVM to Yahoo file area but my problem was that I cannot decide if it should be uploaded to W32F or W32FX file area !
I really wish that these 2 groups will merge and W32F, W32FX and IA32FVM can share a common code base.
One guy from SqueakDev list also came to help. and I must say that I wouldn't get this far without his commitment;-)
He also offered to host IA32FVM.zip :
http://members.rogers.com/smallsqueak/FVM/IA32FVM.zip
Please bear in mind that this is a preliminary release for comments at a temporary home. It's just a proof of concept.
The primary goal of this exercise is to have a pure kernel image. This seems to be achievable.
Your feedback and constructive criticism is more that welcome.
Is it worth to go the path of converting ITC into STC ? What are the pros and cons of STC vs ITC ? What's the best route to get there from here ?
My ultimate goal is a Native Compiled Code image.
It would be interesting if someone will try to port this IA32FVM to Linux to see if the kernel is really pure and can be used as is cross IA32 platforms that support dlfcn interface .
Cheers,
PhiHo.
P.S: This posting is cc squeak-dev@lists.squeakfoundation.org at SmallSqueak request. ;-)
squeak-dev@lists.squeakfoundation.org