Add the Ficl (Forth Inspired Command Language) interpreter.  If all goes well,
this will allow us to manage bloat in the loader by using a bytecoded HLL
rather than lots of C code.  It also offers an opportunity for vendors
or others with special applications to significantly customise the boot
process without having to commit to a divergent code branch.

This early commit is to allow others to experiment with the most effective
mechanisms for integrating FICL with the loader as it currently stands.

Ficl is distributed with the following license conditions:

"Ficl is freeware.  Use it in any way that you like, with the understanding
 that the code is not supported."

All source files contain authorship attributions.

Obtained from:	John Sadler (john_sadler@alum.mit.edu)


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40843 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Make this work in the libstand environment; don't use stdio/stdlib headers.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40876 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix includes; we were still pulling in <stdlib.h> in some places.
Support building a standalone interpreter with 'make testmain', remove
win32 and egregious gets() in testmain.c


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40883 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Improve the assertion testing for successful softword compilation.
The excessive use of assert() vs. robust error checking is annoying.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40890 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Explicitly invoke perl to run the softwords.pl script in case the
script is not executable.
Submitted by:	Don Lewis <Don.Lewis@tsc.tdk.com>


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40924 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
1. rebuild all elements of testmain properly for safety.
2. add fload and key prims for doing simple file and terminal I/O, respectively


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40927 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Remember a bit more of my forth and do:

o Add fexists word to check for the presence of a file
o make fexists and fload immediate words which DTRT both interpreted
  and compiled (doh!)
o add an init word which gets run at bootstrapping time to do extra
  post-coldload initialization (in the default implementation, we
  look for /boot/boot.4th and load it if found).


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40929 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Don't not print the prompt string; not doing this has funny side-effects.
Make the prompt an empty string instead.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40949 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Use proper literal names.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40951 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Argh, I had this right[er] before.  More commits to follow.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40971 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Make fexists/fload work with existing string literals instead.  Doing
my own string literal handling is just too wonky.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40976 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Submit better fix to the prompt bug.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40977 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
switch words to default mode.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40978 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
OK, fload/fexec work properly when both compiling and interpreting
now.  Gack.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40982 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Take init out of here - it's a layering violation.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40987 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Eliminate much code cruft by extending simple file I/O API to include
fopen and fclose.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40989 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
o Add proper stack checking to all file words
o add fkey and fread
o eliminate fexists now that this can be expressed in HLL forth
  ( : fexists fopen dup -1 <> if fclose 1 else drop 0 then ; ) :-)

Once we get the ability to write files, it should be possible to do
stand-alone rescue work from the 3rd stage boot. :)


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@40995 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add new word ".#" which acts like "." but doesn't output a space separator.
I found it impossible to output parametrized strings like "\033[%d;%dH"
without building them first in pad area.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@42001 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add support for some FACILITY words:

key? ( -- flag)  \ check to see if there's a key to be read from input
ms   ( u -- )    \ wait that many milliseconds
seconds ( -- u ) \ get number of seconds from midnight.

'words' now outputs the list page by page - this probably should go
through libstand's pager, but will have to wait for closer integration of
built-ins with Forth...

Submitted partially by:	W Gerald Hicks <wghicks@bellsouth.net>


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@42209 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add words "pc!" and "pc@" which allow to manipulate I/O ports. This can
be helpful when directly fiddling with PC hardware.

Also, define "arch-i386" appropriately, as suggested by Daniel C. Sobral.


git-svn-id: svn://svn.freebsd.org/base/head/sys/boot/ficl@42634 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f