aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Reber <adrian@lisas.de>2008-11-21 12:07:42 +0100
committerAdrian Reber <adrian@lisas.de>2008-11-21 12:07:42 +0100
commit304e8fb00330e84481ac71a466053bf5fefea721 (patch)
tree0f0f3b2650647d3ee0be2bd531661a1c8560be9f
downloadSLOF-304e8fb00330e84481ac71a466053bf5fefea721.zip
SLOF-304e8fb00330e84481ac71a466053bf5fefea721.tar.gz
SLOF-304e8fb00330e84481ac71a466053bf5fefea721.tar.bz2
Initial commit
-rw-r--r--INSTALL228
-rw-r--r--JS20.obin0 -> 45912 bytes
-rw-r--r--License.txt8
-rw-r--r--Makefile65
-rw-r--r--README336
-rw-r--r--engine.in490
-rw-r--r--entry.S195
-rw-r--r--fs/.#main.fs.1.3170
-rw-r--r--fs/accept.fs52
-rw-r--r--fs/alloc-mem.fs19
-rw-r--r--fs/client.fs123
-rw-r--r--fs/dump.fs26
-rw-r--r--fs/elf.fs209
-rw-r--r--fs/envvar.fs93
-rw-r--r--fs/find-hash.fs30
-rw-r--r--fs/hw/8111.fs114
-rw-r--r--fs/hw/8131.fs111
-rw-r--r--fs/hw/cpu.fs31
-rw-r--r--fs/hw/dart.fs27
-rw-r--r--fs/hw/disk.fs78
-rw-r--r--fs/hw/enet.fs46
-rw-r--r--fs/hw/freq.fs40
-rw-r--r--fs/hw/ht.fs62
-rw-r--r--fs/hw/io.fs49
-rw-r--r--fs/hw/memory.fs36
-rw-r--r--fs/hw/mpic.fs28
-rw-r--r--fs/hw/serial.fs33
-rw-r--r--fs/hw/sio.fs63
-rw-r--r--fs/instance.fs94
-rw-r--r--fs/js20-tree.fs86
-rw-r--r--fs/main.fs187
-rw-r--r--fs/package.fs141
-rw-r--r--fs/property.fs67
-rw-r--r--fs/search.fs87
-rw-r--r--incs.pl26
-rw-r--r--linux.config.js20921
-rw-r--r--loader.S88
-rwxr-xr-xpackage-firmwarebin0 -> 16245 bytes
-rw-r--r--paflof.c43
-rw-r--r--paflof.h53
-rw-r--r--paflof.lds29
-rwxr-xr-xpayload0
-rw-r--r--ppc64.code177
-rw-r--r--ppc64.h18
-rw-r--r--ppc64.in70
-rw-r--r--prim.code349
-rw-r--r--prim.h47
-rw-r--r--prim.in81
-rw-r--r--ref.pl106
-rw-r--r--slof.lds24
-rw-r--r--types.h49
51 files changed, 5505 insertions, 0 deletions
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..2e8c7f5
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,228 @@
+Slimline Open Firmware for JS20
+
+Copyright (C) 2005, IBM Corporation
+
+
+In order to use SLOF, there are certain requirements on the build and
+target system.
+
+ Target system:
+
+ - IBM BladeCenter JS20 1.6GHz or 2.2GHz machine
+ - MAKE SURE you have the latest firmware revision
+ installed, ALSO on the permanent side of the flash!
+ - Linux 2.6.10 or newer
+ - Older versions will not run correctly.
+ - An example configuration file is provided.
+ - ppc64-utils installed
+ - Suitable Low Level Firmware. See BUILD for requirements.
+
+ - Specific configuration
+ - The blade server needs to have an ATA harddisk
+ installed on the first connector; the disk needs
+ to be partitioned with a PReP boot partition as
+ the first physical partition on the system, i.e.,
+ starting at sector 63. The root partition of your
+ Linux system should be /dev/hda3. For example:
+
+ Disk /dev/hda: 16 heads, 63 sectors, 77520 cylinders
+ Units = cylinders of 1008 * 512 bytes
+
+ Device Boot Start End Blocks Id System
+ /dev/hda1 * 1 7 3496+ 41 PPC PReP Boot
+ /dev/hda2 8 2088 1048824 82 Linux swap
+ /dev/hda3 2089 77520 38017728 83 Linux
+
+ Build system:
+
+ - Recent GNU tools, configured for powerpc64-linux
+ - GCC: 3.3.3 and newer are known to work, but GCC 4.0
+ and later do _not_ work.
+ - Binutils: use a version as new as possible.
+
+
+BUILD
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ On the build system:
+
+ - Edit the Makefile or set CROSS and/or CC in the environment to
+ the right path to the tools, if the default tools do not satisfy
+ the requirements mentioned above.
+
+ - Two more files are required to build a boot-able image:
+ + startup.o: Low Level Firmware
+ + oco.o: Contains functions for reboot, halt, boot watchdog
+ and other board specific functions.
+ There is a description in the README file, how to implement your
+ own board specific oco.o and startup.o.
+ This files might be provided for test purposes on a JS20 board
+ from a website which have to be defined.
+
+ - make
+
+
+INSTALL
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ Read [1] and [2] for documentation of flash handling and console support.
+ The convention in this section for the commands to issue are:
+ - 0 > : Firmware prompt
+ - $ : Linux prompt
+ - boot: : yaboot prompt
+
+ On the target system:
+
+ - make sure you are using the latest IBM provided firmware updates.
+ This can be done on Linux by issuing
+
+ $ cat /proc/device-tree/openprom/ibm,fw-temp-bank
+ $ cat /proc/device-tree/openprom/ibm,fw-perm-bank
+ $ cat /proc/device-tree/openprom/ibm,fw-bank
+
+ The temp and perm bank should the same and the fw-bank need
+ to be 'T'.
+ If not, read the User's guide [1] how to achieve this state and see (1).
+ This point is very important, since you might end with a broken
+ firmware on the PERM side and SLOF on the TEMP side and no way
+ to restore ther PERM side, since SLOF provides no flashing capability.
+
+ - install a recent kernel (as discribed above) into /boot; a sample
+ .config is included as linux.config.js20 in the SLOF distribution.
+
+ To build a reference kernel boot-able with slof, download a kernel
+ source tree from http://www.kernel.org/ and copy the linux.config.js20
+ to the unpacked kernel source tree as .config as shown here:
+
+ cp linux.config.js20 /usr/src/linux-2.6.XX/.config
+ (NOTE: You have to set the right path to your kernel sources and
+ the right revision number)
+
+ Then compile the kernel as described in Linux Kernel Documentation
+ and install it on a primary partition on the first hard drive.
+
+ - change /etc/yaboot.conf appropriately
+ The default yaboot.conf contains Open Firmware paths that can not be
+ interpreted correctly by SLOF, so you have to make changes in
+ /etc/yaboot.conf.
+
+ Example:
+ # header section
+ timeout = 100 # set boot timeout to 10 seconds
+ default = linux # set default bootimage to linux
+
+ # image section
+ image = disk:3,/boot/vmlinux # Specify correct kernel image here
+ # as disk:(partno),(path)
+ label = linux # Name of image
+ root = /dev/hda3 # Set root device
+ append = "selinux=0 elevator=cfq" # Kernel command line
+ initrd = disk:3,/boot/initrd # Initrd if needed
+
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ ! !
+ ! WITH THE FOLLOWING STEPS YOU MIGHT DESTROY YOUR FIRMWARE !
+ ! IMAGE AND LOOSE YOUR WARRANTY ! !
+ ! YOU MAY NEED TO CALL SERVICE, IF THE FIRMWARE IMAGE IS !
+ ! DESTROYED ! !
+ ! !
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ $ update_flash -f slof.img
+
+ This will put SLOF on the temp side of the flash and reboot the
+ system to the firmware boot prompt. You will need to use a console
+ connection (like, serial-over-lan) to interact with SLOF or yaboot.
+
+ - After power up or reset, SLOF prints out a startup message and then
+ enters the firmware prompt. Here you have to enter
+
+ yaboot
+
+ to start the secondary bootloader yaboot.
+ (NOTE: SLOF does not start yaboot automatically due to lack of NVRAM
+ support.)
+
+ - On the SOL console (see [2]):
+
+ 0 > boot
+
+ otherwise type
+
+ 0 > set-bootpart <partn>
+ 0 > boot
+
+ where <partn> is the number of the partition, yaboot.conf resides on.
+
+ - On yaboot prompt choose the right kernel
+
+ boot: linux-slof
+
+ - have a lot of fun...
+
+ SLOF is a slimline Open Firmware and provides only a minimalistic
+ device-tree and has no RTAS support. For example, you cannot
+ check the flash-side or use update flash or reboot the system.
+
+Trouble-shooting
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ - update_flash does not end at the boot prompt
+ -> It may take a couple minutes, if for some reason
+ the SLOF image has a problem. In this case, the
+ boot timer will start from the PERM side.
+
+ $ update_flash -r
+
+ will restore your system to the initial state. see (1)
+
+ - boot does start yaboot, but does not find the config file.
+ -> on the console type after yaboot / firmware prompt.
+ boot: bye
+ 0 > set-bootpart <partn>
+
+ - Linux does not boot
+ -> Compile the right kernel
+ Reboot the blade
+ 0 > other-firmware
+
+ This will boot into the original firmware and OS
+ In Linux start over again (building linux kernel, etc. ) see (1)
+
+ Pull out blade out of the blade center to force the
+ blade to boot from the TEMP side again
+
+Uninstall
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+If you want to boot the original firmware again, you need to
+boot the blade from the management module.
+On the SLOF command line, type:
+
+ 0 > other-firmware
+
+and it should get you back to running the original firmware.
+To permanently get it back, after booting Linux from there,
+type
+
+ $ update_flash -r
+ $ halt
+
+(1) You will boot on the PERM side. To boot from the TEMP side
+ again, you need to restart the Blade System MGMT Processor.
+
+ Following steps are needed on
+ Management Module -> Blade Tasks -> Power/Restart
+
+ Power Off Blade
+ Restart Blade System Mgmt Processor
+ Power On Blade
+
+Documentation
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+[1] Installation and User's Guide - IBM eServer BladeCenter JS20 :
+
+[2] IBM eServer BladeCenter JS20 quick set up guide : http://www-128.ibm.com/developerworks/linux/library/l-pow-js20quickstart/
diff --git a/JS20.o b/JS20.o
new file mode 100644
index 0000000..638d7f9
--- /dev/null
+++ b/JS20.o
Binary files differ
diff --git a/License.txt b/License.txt
new file mode 100644
index 0000000..71d06c0
--- /dev/null
+++ b/License.txt
@@ -0,0 +1,8 @@
+Copyright (c) 2004, 2005 IBM Corporation
+All rights reserved.
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+Neither the name of IBM nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ff967f5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,65 @@
+# =============================================================================
+# * Copyright (c) 2004, 2005 IBM Corporation
+# * All rights reserved.
+# * This program and the accompanying materials
+# * are made available under the terms of the BSD License
+# * which accompanies this distribution, and is available at
+# * http://www.opensource.org/licenses/bsd-license.php
+# *
+# * Contributors:
+# * IBM Corporation - initial implementation
+# =============================================================================
+
+
+CROSS ?= powerpc64-linux-
+
+ifeq ($(origin CC), default)
+ CC = $(CROSS)gcc
+endif
+ifeq ($(origin LD), default)
+ LD = $(CROSS)ld
+endif
+OBJCOPY ?= $(CROSS)objcopy
+
+TARG = ppc64
+
+CFLAGS = -g -DTARG=$(TARG) -static -Wall -W -std=gnu99 -O2 -fno-gcse \
+ -fno-crossjumping -fomit-frame-pointer -mcpu=970 -msoft-float
+LDFLAGS = -g -static -nostdlib
+
+DICT = prim.in engine.in $(TARG).in
+
+all: slof.img
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $< -o $@ && $(OBJCOPY) -R .note.GNU-stack $@
+
+dict.xt: $(DICT) ref.pl
+ cat $(DICT) | perl ref.pl > dict.xt
+
+$(TARG).fs: fs/*.fs
+ perl incs.pl main.fs > $@ || rm $@
+
+$(TARG).o: $(TARG).fs
+ $(LD) -o $@ -r -bbinary $<
+
+payload-obj.o: payload
+ $(LD) -o $@ -r -bbinary $<
+
+paflof.o: paflof.c prim.h prim.code $(TARG).h $(TARG).code dict.xt
+
+paflof: paflof.lds paflof.o entry.o oco.o payload-obj.o $(TARG).o
+ $(LD) $(LDFLAGS) -T $^ -o $@
+
+slof: slof.lds startup.o loader.o paflof
+ $(LD) -T $^ -o $@
+
+slof.bin: slof
+ $(OBJCOPY) $< $@ -O binary
+
+slof.img: slof.bin
+ ./package-firmware -l $^ -o $@
+
+clean:
+ -rm -f paflof.o entry.o loader.o payload-obj.o $(TARG).fs $(TARG).o \
+ dict.xt paflof slof slof.bin slof.img
diff --git a/README b/README
new file mode 100644
index 0000000..fee3f50
--- /dev/null
+++ b/README
@@ -0,0 +1,336 @@
+Slimline Open Firmware for JS20
+
+Copyright (C) 2004,2005 IBM Corporation
+
+
+Index
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+1.0 Introduction to Open Firmware
+1.1 Slimline Open Firmware
+1.2 Build process
+1.3 Load process
+2.0 Extension
+3.0 Limitations
+
+1.0 Introduction to Open Firmware
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+The IEEE Standard 1275-1994 [1], Standard for Boot (Initialization Configuration)
+Firmware, Core Requirements and Practices, is the first non-proprietary open
+standard for boot firmware that is usable on different processors and buses.
+Firmware which complies with this standard (also known as Open Firmware)
+includes a processor-independent device interface that allows add-in devices
+to identify itself and to supply a single boot driver that can be used,
+unchanged, on any CPU. In addition, Open Firmware includes a user interface
+with powerful scripting and debugging support and a client interface that
+allows an operating system and its loaders to use Open Firmware services
+during the configuration and initialization process. Open Firmware stores
+information about the hardware in a tree structure called the
+``device tree''. This device tree supports multiple interconnected system
+buses and offers a framework for ``plug and play''-type auto configuration
+across different buses. It was designed to support a variety of different
+processor Instruction Set Architectures (ISAs) and buses.
+
+The full documentation of this Standard can be found in [1].
+
+1.1 Overview
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+The Slimline Open Firmware (SLOF) is an implementation of the
+Open Firmware standard. Since the Open Firmware standard is
+quite extensive, the decision was made to keep focus on those
+parts of the standard which are required for booting Linux.
+As of today, it is possible to boot a recent Linux kernel (2.6.10)
+on a JS20 board and on a cell workstation. Booting SLOF on a
+machine requires a hardware-specific Low Level Firmware for
+doing the basic setup of the system which is not part of this
+package. The LLFW package as object code might be provided on
+a separate purposes for test purposes.
+
+The current restrictions and shortcomings regarding the
+Open Firmware Standard are listed here:
+
++ User Interface
+ - Command line editing: only the most basic command line editing
+ (enter, backspace) is supported.
+ - The assembler support words are not implemented. This is by design.
+ - None of the administration group is provided; instead, there are some
+ more minimalistic facilities.
+ - There is no direct support for debugging client programs.
++ Client Interface
+ - "test" and "canon" are missing.
+ - "boot", "enter", and "chain" are missing.
+ - "interpret" doesn't actually do anything.
+ - "set-callback" and "set-symbol-lookup" are missing.
+ - "milliseconds" doesn't use anything resembling a real clock.
++ Device Interface
+ - FCode evaluator is under development and not available so-far.
+ - Finding device nodes does not use the proper algorithm; instead, first
+ all nodes are tried for an exact match on the full path; if that fails,
+ all nodes are tried for an exact match on the short name.
+ Arguments to a node are ignored. Nodes do not really have an address.
+ - There is no terminal emulator. But then again, there is no graphics
+ hardware either.
+
+
+As boot device currently only ATA disk is supported, by using yaboot
+as secondary boot loader. Netboot and USB boot support will not be made
+available and is not part of this package. It is possible to port external
+available secondary boot loader to the PowerPC64 architecture to support
+network boot based on existing Linux device drivers.
+
+
+
+1.2 Build process
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+Open Firmware (OF) is based on the programming language Forth.
+SLOF use Paflof as the Forth engine, which was developed by
+Segher Boessenkool. Most parts of the Forth engine are implemented in
+C, by using GNU extensions of ANSI C, (e.g. assigned goto, often misnamed "computed goto"),
+resulting in a very efficient yet still quite portable engine.
+
+The basic Forth words, so-called primitives, are implemented with
+a set of C macros. A set of .in and .code files are provided, which
+define the semantic of the Forth primitives. A Perl script translates
+these files into valid C code, which will be compiled into the Forth engine.
+The complete Forth system composes of the basic Forth primitives and
+a set of Forth words, which are compiled during the start of the Forth
+system.
+
+Example:
+Forth primitive 'dup'
+
+ dup ( a -- a a) \ Duplicate top of stack element
+
+
+prim.in:
+ cod(DUP)
+
+prim.code:
+ PRIM(DUP) cell x = TOS; PUSH; TOS = x; MIRP
+
+Generated code:
+
+static cell xt_DUP[] = { { .a = xt_DOTICK }, { .c = "\000\003DUP" },
+ { .a = &&code_DUP }, };
+
+code_DUP: { asm("#### " "DUP"); void *w = (cfa = (++ip)->a)->a;
+ cell x = (*dp); dp++; (*dp) = x; goto *w; }
+
+Without going into detail, it can be seen, that the data stack is
+implemented in C as an array of cells, where dp is the pointer to the top of
+stack.
+
+For the implementation of the Open Firmware, most of the
+code is added as Forth code and bound to the engine. Also
+the system vector for reset and all kinds of exceptions
+will be part of the image. Additionally a secondary boot-loader
+or any other client application can be bound to the code as payload,
+e.g. diagnostics and test programs.
+
+The Open Firmware image will be put together by the build
+process, with a loader at the start of the image. This loader
+is called by Low Level Firmware and loads at boot time the Open
+Firmware to it's location in memory (see 1.3 Load process). Additionally
+a secondary boot loader or any other client application can be bound
+to the code as payload.
+
+The Open Firmware image will be bound together with the Low Level
+Firmware to the final slof.img.
+
+The Low Level Firmware (LLFW) is responsible for setting up the
+system in an initial state. This task includes the setup of the
+CPUs, the system memory and all the buses as well as the serial port
+itself. The current distribution does not contain a LLFW image,
+which is hardware specific and has to be implemented for the each
+board SLOF should run on. Publication of an object code only LLFW
+for the JS20 board might be available in the future.
+
+Firmware image:
+
+0x2000000 +----------+
+ | LLFW |
+X +----------+
+ | Loader |
+X + 0x100 +----------+
+ | Vector |
+X + 0x4100 +----------+
+ | |
+ | OF code |
+ | |
+X + 0x6100 +----------+
+ | |
+ | OF data |
+ | |
+ +----------+
+
+
+1.3 Load process
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+This chapter describes the load process on the JS20 board.
+The whole firmware image resides in the flash. The reset is
+triggered by the service processor and both CPUs will jump into
+the LLFW code. After appropriate system setup, the LLFW will load the
+whole image into L2 cache at the link address of the image.
+The LLFW will jump into the OF loader in L2 cache, after it has
+ended it's task of doing base initialization of the system
+(e.g. probing memory and setting up the memory controller).
+The loader code will then move the system vectors, the OF
+core engine and the OF data to the location those parts are
+linked at.
+
+The current addresses and offsets are listed in the following table:
+
+ | Runtime address | Link address | Offset in Image |
+-------+-----------------+--------------+-----------------+
+LLFW | 0x2000000 | 0x2000000 | 0 |
+Loader | 0x200xxxx | any | + sizeof(LLFW) |
+Vector | 0x100 | 0x100 | + 0x100 |
+OFW | 0x1110000 | 0x1110000 | + 0x4000 |
+Dict | 0x1120000 | 0x1120000 | + 0x2000 |
+-------+-----------------+--------------+-----------------+
+
+
+
+
+
+
+2.0 Extension
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+In the following paragraphs it will be shown how to add
+new primitive words (i.e., words implemented not by building
+pre-existing Forth words together, but instead implemented in
+C or assembler). With this, it is possible to adapt SLOF to
+the specific needs of different hardware and architectures.
+We'll also discuss how to add an extra payload, and what is
+required of the LLFW to successfully run SLOF.
+
+
+To add primitives:
+
+ For a new primitive, following steps have to be done:
+
+ + Definition of primitive name in <arch>.in
+ - cod(ABC) defines primitive ABC
+
+ You can also use the following in a .in file, see existing
+ code for how to use these:
+ - con(ABC) defines constant ABC
+ - col(ABC) defines colon definition ABC
+ - dfr(ABC) defines defer definition ABC
+
+ + Definition of the primitives effects in <arch>.code
+ - PRIM(ABC) ... MIRP
+
+ The code for the primitive body is any C-code. With
+ the macros of prim.code the data and return stack of
+ the Forth engine can be appropriately manipulated.
+
+
+To add an extra payload:
+
+ It is possible to add client code (secondary boot loader, OS kernel)
+ into the data section of SLOF. This will allow to execute a client
+ without the need to load it from a device. Any client is required to
+ be an ELF executable, and to adhere to the client interface as
+ described in the standard, plus the PowerPC binding to the standard.
+
+ The steps to add a new payload to SLOF are:
+
+ + Add a rule in the SLOF Makefile to convert the client executable into
+ a binary.
+
+ - payloadbin.o: payload
+ $(LD) -o $@ -r -bbinary $<
+ paflof: .... payloadbin.o
+ $(LD) .... payloadbin.o
+
+
+ + Add in <arch>.h a line defining the entry point of the client.
+ The name is generated by the linker by surrounding the input
+ filename with "_binary_" and "_start".
+
+ - extern char _binary_payload_start[];
+
+ + Add in <arch>.in a line defining the Forth constant to access the
+ start of the client.
+
+ - con(PAYLOAD (type_u)_binary_payload_start)
+
+ + Add in the main Forth file a colon definition to load and start
+ the client.
+
+ - : payload-exec payload dup load-elf-file start-elf ;
+
+
+Change Low Level Firmware:
+
+ The low level firmware needs to setup the basic execution environment
+ required by the rest of the system. The only link from
+ LLFW to SLOF is the call to the SLOF loader, which itself is
+ position independent. The last thing the LLFW should do is jump to
+ the first instruction in the loader image. SLOF also has calls into
+ code, that provides certain system specific information like the memory
+ size or triggers for board specific actions, like reboot of the board.
+ This code is currently implemented for JS20 as object code only module
+ and not part of this distribution. For any different board this code
+ needs to be provided.
+
+Change oco module:
+
+ This file encapsulates functions supposed to be
+ confidential and not made public.
+ The prototype for this interface is
+ type_u oco(cell p0, cell p1)
+ p0 is the token and p1 the argument passed to the specific function.
+ Current functions for the JS20 board are:
+ Token 0: Start slave cpu
+ Token 1: Reboot system
+ Token 2: Halt system
+ Token 3: Watchdog command
+ Token 4: Get memory size
+ Token 5: Enable ht apic space
+ Token 6: Enable MPIC
+ Token 7: Get own cpu number
+ For other boards this might be different depending on the board
+ specific requierements.
+
+3.0 Limitations of this package
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ - RTAS is not available in this package. The client application
+ has to manage hardware on its own. It is also not possible to
+ power down the machine from linux. RTAS calls can be added if
+ required.
+
+ - SLOF has no support for NVRAM, so it is not possible to start the
+ operating system without user interaction.
+
+ - The hardware real time clock is not correctly updated after system
+ shutdown. That leads to problems restoring the right system time
+ after booting. One possible solution is to set the system time early
+ after the OS bootup from a network time server via the NTP protocol.
+
+ - It is sometimes possible, that the "other-firmware" switchback
+ function does not work properly. This is due to hardware limitations.
+ The work around is to issue the command to the firmware until the
+ original firmware starts. (Should take at most 3 tries to reactivate
+ the old firmware)
+
+ - The /etc/yaboot.conf file must reside on the 3rd partiton on the 1st
+ hard drive in the system. If /etc/yaboot.conf is on another partition
+ in fs/main.fs the line
+ s" disk:3" encode-string s" bootpath" set-chosen
+ has to be change accordanly. This also can be done temporaly by typing
+ "set-bootpath x", where x is the partition number.
+
+
+Documentation
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+[1] IEEE 1275-1994 Standard, Standard for Boot (Initialization Configuration)
+ Firmware: Core Requierements and Practices
+
diff --git a/engine.in b/engine.in
new file mode 100644
index 0000000..7b9dc82
--- /dev/null
+++ b/engine.in
@@ -0,0 +1,490 @@
+// ============================================================================
+// * Copyright (c) 2004, 2005 IBM Corporation
+// * All rights reserved.
+// * This program and the accompanying materials
+// * are made available under the terms of the BSD License
+// * which accompanies this distribution, and is available at
+// * http://www.opensource.org/licenses/bsd-license.php
+// *
+// * Contributors:
+// * IBM Corporation - initial implementation
+// ============================================================================
+
+
+//
+// Copyright 2002,2003,2004 Segher Boessenkool <segher@kernel.crashing.org>
+//
+
+// This is the core engine of Paflof. It is almost ANS Forth compatible.
+// There are two possibilities why an aspect would not be:
+// a) Open Firmware requires different semantics;
+// b) bugs.
+// Most of the "extended" semantics defined in the OF specification are
+// not implemented; just the bare essentials. For example, you can't
+// use structural words (IF, THEN, BEGIN, etc.) or return-stack
+// manipulation words (R> etc.) in the interpreter.
+
+
+// The data stack pointer.
+raw(HERE DOVAL _A(the_mem))
+
+// Some common constant numbers; smaller and faster if they are defined
+// as constants, than when inlined as a literal.
+con(-1 -1)
+con(0 0)
+con(1 1)
+con(2 2)
+con(3 3)
+con(4 4)
+con(8 8)
+con(H#10 0x10)
+con(H#FF 0xff)
+con(H#FFFF 0xffff)
+con(D#10 0x0a)
+
+
+// Manipulating different kinds of addresses.
+con(/C 1)
+con(/W 2)
+con(/L 4)
+con(/N CELLSIZE)
+con(CELL CELLSIZE)
+col(/C* /C *)
+col(/W* /W *)
+col(/L* /L *)
+col(/N* /N *)
+col(CA+ /C* +)
+col(WA+ /W* +)
+col(LA+ /L* +)
+col(NA+ /N* +)
+col(CA1+ /C +)
+col(WA1+ /W +)
+col(LA1+ /L +)
+col(NA1+ /N +)
+col(CHAR+ CA1+)
+col(CELL+ NA1+)
+col(CHAR- /C -)
+col(CELL- /N -)
+col(CHARS /C*)
+col(CELLS /N*)
+col(CHARS+ CA+)
+col(CELLS+ NA+)
+
+
+// Run-time words for TO and for string literals.
+col(DOTO R> CELL+ DUP >R @ CELL+ !)
+col(SLITERAL R> CELL+ DUP DUP C@ + LIT(-CELLSIZE) AND >R)
+
+
+// Stack manipulation.
+col(?DUP DUP 0BRANCH(1) DUP)
+col(TUCK SWAP OVER)
+col(2DUP OVER OVER)
+col(3DUP 2 PICK 2 PICK 2 PICK)
+col(2OVER 3 PICK 3 PICK)
+col(2DROP DROP DROP)
+col(3DROP DROP DROP DROP)
+col(NIP SWAP DROP)
+col(CLEAR 0 DEPTH!)
+col(ROT >R SWAP R> SWAP)
+col(-ROT SWAP >R SWAP R>)
+col(2SWAP >R -ROT R> -ROT)
+col(2ROT >R >R 2SWAP R> R> 2SWAP)
+col(ROLL DUP ?DUP 0BRANCH(6) ROT >R 1 - BRANCH(-9) ?DUP 0BRANCH(6) R> -ROT 1 - BRANCH(-9))
+
+
+// Arithmetic.
+col(2* 1 LSHIFT)
+col(U2/ 1 RSHIFT)
+col(2/ 1 ASHIFT)
+col(<< LSHIFT)
+col(>> RSHIFT)
+col(>>A ASHIFT)
+col(INVERT -1 XOR)
+col(NOT INVERT)
+
+
+// Booleans.
+con(TRUE -1)
+con(FALSE 0)
+
+
+// Comparisons.
+col(> SWAP <)
+col(U> SWAP U<)
+col(<= > 0=)
+col(<> = 0=)
+col(>= < 0=)
+col(0<= 0 <=)
+col(0<> 0 <>)
+col(0> 0 >)
+col(0>= 0 >=)
+col(U<= U> 0=)
+col(U>= U< 0=)
+col(WITHIN ROT DUP ROT >= 0BRANCH(3) 2DROP FALSE EXIT > 0BRANCH(2) FALSE EXIT TRUE)
+col(BETWEEN 1 + WITHIN)
+
+
+// Double-cell single-bit shifts.
+col(D2* 2* OVER 0< - >R 2* R>)
+col(UD2/ >R U2/ R@ LIT(8*CELLSIZE-1) LSHIFT OR R> U2/)
+col(D2/ >R U2/ R@ LIT(8*CELLSIZE-1) LSHIFT OR R> 2/)
+
+
+// More arithmetic.
+col(NEGATE 0 SWAP -)
+col(ABS DUP 0< 0BRANCH(1) NEGATE)
+col(MAX 2DUP < 0BRANCH(1) SWAP DROP)
+col(MIN 2DUP > 0BRANCH(1) SWAP DROP)
+col(U* *)
+col(1+ 1 +)
+col(1- 1 -)
+col(2+ 2 +)
+col(2- 2 -)
+col(EVEN 1+ -1 AND)
+col(BOUNDS OVER + SWAP)
+
+
+// Double-cell and mixed-size arithmetic.
+col(S>D DUP 0<)
+col(DNEGATE INVERT >R NEGATE DUP 0= R> SWAP -)
+col(DABS DUP 0< 0BRANCH(1) DNEGATE)
+col(M+ SWAP >R DUP >R + DUP R> U< R> SWAP -)
+col(D+ >R M+ R> +)
+col(D- DNEGATE D+)
+col(*' >R DUP 0< >R D2* R> 0BRANCH(2) R@ M+ R>)
+col(UM* 0 -ROT LIT(8*CELLSIZE) 0 DODO *' DOLOOP(-3) DROP)
+col(M* 2DUP XOR >R >R ABS R> ABS UM* R> 0BRANCH(1) DNEGATE)
+col(/' >R DUP 0< >R D2* R> OVER R@ U>= OR 0BRANCH(6) >R 1 OR R> R@ - R>)
+col(UM/MOD LIT(8*CELLSIZE) 0 DODO /' DOLOOP(-3) DROP SWAP)
+col(SM/REM OVER >R >R DABS R@ ABS UM/MOD R> 0< 0BRANCH(1) NEGATE R> 0< 0BRANCH(4) NEGATE SWAP NEGATE SWAP)
+col(FM/MOD DUP >R 2DUP XOR 0< >R SM/REM OVER 0<> R> AND 0BRANCH(6) 1- SWAP R> + SWAP EXIT R> DROP)
+
+
+// Division.
+col(U/MOD 0 SWAP UM/MOD)
+col(/MOD >R S>D R> FM/MOD)
+col(/ /MOD NIP)
+col(MOD /MOD DROP)
+col(*/MOD >R M* R> FM/MOD)
+col(*/ */MOD NIP)
+
+
+// Splitting, joining, flipping the components of a number.
+col(WBSPLIT DUP H#FF AND SWAP 8 RSHIFT)
+col(LWSPLIT DUP H#FFFF AND SWAP H#10 RSHIFT)
+col(LBSPLIT LWSPLIT >R WBSPLIT R> WBSPLIT)
+col(BWJOIN 8 LSHIFT OR)
+col(WLJOIN H#10 LSHIFT OR)
+col(BLJOIN BWJOIN >R BWJOIN R> WLJOIN)
+col(WBFLIP WBSPLIT SWAP BWJOIN)
+col(LWFLIP LWSPLIT SWAP WLJOIN)
+col(LBFLIP LBSPLIT SWAP 2SWAP SWAP BLJOIN)
+
+
+// Aligning to cell size.
+col(ALIGNED /N 1- + /N NEGATE AND)
+
+
+// Counted loop stuff.
+col(I R> R@ SWAP >R)
+col(J R> R> R> R@ SWAP >R SWAP >R SWAP >R)
+col(UNLOOP R> R> R> 2DROP >R)
+
+
+// Memory accesses.
+col(+! TUCK @ + SWAP !)
+col(COMP 0 DO?DO(27) OVER I + C@ OVER I + C@ 2DUP < 0BRANCH(6) 2DROP UNLOOP 2DROP LIT(-1) EXIT > 0BRANCH(4) UNLOOP 2DROP 1 EXIT DOLOOP(-27) 2DROP 0)
+col(OFF FALSE SWAP !)
+col(ON TRUE SWAP !)
+col(<W@ W@ DUP LIT(0x8000) >= 0BRANCH(3) LIT(0x10000) -)
+col(2@ DUP @ SWAP CELL+ @)
+col(2! DUP >R CELL+ ! R> !)
+col(WBFLIPS BOUNDS DO?DO(8) I W@ WBFLIP I W! /W DO+LOOP(-8))
+col(LWFLIPS BOUNDS DO?DO(8) I L@ LWFLIP I L! /L DO+LOOP(-8))
+col(LBFLIPS BOUNDS DO?DO(8) I L@ LBFLIP I L! /L DO+LOOP(-8))
+col(FILL -ROT BOUNDS DO?DO(5) DUP I C! DOLOOP(-5) DROP)
+col(BLANK LIT(0x20) FILL)
+col(ERASE LIT(0x00) FILL)
+
+
+// Exception handling.
+var(CATCHER 0)
+var(ABORT"-STR 0)
+col(CATCH DEPTH >R CATCHER @ >R RDEPTH CATCHER ! EXECUTE R> CATCHER ! R> DROP 0)
+col(THROW ?DUP 0BRANCH(12) CATCHER @ RDEPTH! R> CATCHER ! R> SWAP >R DEPTH! DROP R>)
+col(ABORT -1 THROW)
+
+
+// Text input.
+var(#TIB TIBSIZE)
+val(IB 0)
+var(#IB 0)
+val(SOURCE-ID 0)
+col(SOURCE IB #IB @)
+var(>IN 0)
+col(TERMINAL TIB DOTO IB #TIB @ #IB ! 0 DOTO SOURCE-ID)
+
+
+// ASCII codes.
+con(BL 0x20)
+con(BELL 7)
+con(BS 8)
+con(CARRET 0x0d)
+con(LINEFEED 0x0a)
+
+
+// Text output.
+dfr(EMIT)
+col(TYPE BOUNDS DO?DO(5) I C@ EMIT DOLOOP(-5))
+col(CR CARRET EMIT LINEFEED EMIT)
+col(SPACE BL EMIT)
+col(SPACES 0 DO?DO(3) SPACE DOLOOP(-3))
+
+
+// Text manipulation.
+col(COUNT DUP CHAR+ SWAP C@)
+col(UPC DUP LIT('a') LIT('z') BETWEEN 0BRANCH(3) LIT(0x20) - )
+col(LCC DUP LIT('A') LIT('Z') BETWEEN 0BRANCH(3) LIT(0x20) + )
+
+
+// Text input.
+dfr(KEY)
+dfr(KEY?)
+dfr(ACCEPT)
+var(SPAN 0)
+col(EXPECT ACCEPT SPAN !)
+col(REFILL SOURCE-ID 0= 0BRANCH(7) SOURCE EXPECT 0 >IN ! TRUE EXIT SOURCE-ID -1 = 0BRANCH(2) FALSE EXIT LIT(0x6502) THROW)
+
+
+// Number base.
+var(BASE 16)
+col(DECIMAL D#10 BASE !)
+col(HEX H#10 BASE !)
+col(OCTAL 8 BASE !)
+
+
+// Pictured numeric output.
+col(PAD HERE LIT(256) +)
+col(TODIGIT DUP LIT(9) > 0BRANCH(3) LIT(0x27) + LIT(0x30) +)
+col(MU/MOD DUP >R U/MOD R> SWAP >R UM/MOD R>)
+col(<# PAD DUP !)
+col(HOLD PAD DUP @ 1- TUCK SWAP ! C!)
+col(SIGN 0< 0BRANCH(3) LIT('-') HOLD)
+col(# BASE @ MU/MOD ROT TODIGIT HOLD)
+col(#S # 2DUP OR 0BRANCH(2) BRANCH(-7))
+col(#> 2DROP PAD DUP @ TUCK -)
+col((.) <# DUP >R ABS 0 #S R> SIGN #>)
+col(U# BASE @ U/MOD SWAP TODIGIT HOLD)
+col(U#S U# DUP 0BRANCH(2) BRANCH(-6))
+col(U#> DROP PAD DUP @ TUCK -)
+col((U.) <# U#S U#>)
+col(. (.) TYPE SPACE)
+col(S. .)
+col(U. (U.) TYPE SPACE)
+col(.R SWAP (.) ROT 2DUP < 0BRANCH(5) OVER - SPACES BRANCH(1) DROP TYPE)
+col(U.R SWAP (U.) ROT 2DUP < 0BRANCH(5) OVER - SPACES BRANCH(1) DROP TYPE)
+col(.D BASE @ SWAP DECIMAL . BASE !)
+col(.H BASE @ SWAP HEX . BASE !)
+col(.S DEPTH 0 DO?DO(8) DEPTH I - 1- PICK . DOLOOP(-8))
+col(? @ .)
+
+
+// Numeric input.
+col(DIGIT OVER UPC DUP LIT('A') LIT('Z') BETWEEN 0BRANCH(3) LIT(7) - LIT(0x30) - DUP ROT 0 SWAP WITHIN 0BRANCH(4) NIP TRUE BRANCH(2) DROP FALSE)
+col(>NUMBER DUP 0= 0BRANCH(1) EXIT OVER C@ BASE @ DIGIT 0BRANCH(23) SWAP >R SWAP >R >R BASE @ U* SWAP BASE @ UM* ROT + R> 0 D+ R> CHAR+ R> 1- BRANCH(-35) DROP)
+col($NUMBER DUP 0= 0BRANCH(4) DROP DROP TRUE EXIT >R DUP >R C@ LIT('-') = DUP 0BRANCH(15) R> CHAR+ R> 1- DUP 0= 0BRANCH(5) DROP DROP DROP TRUE EXIT >R >R 0 0 R> R> >NUMBER NIP 0= 0BRANCH(7) DROP SWAP 0BRANCH(1) NEGATE FALSE EXIT DROP DROP DROP TRUE)
+
+
+// Data space allocation.
+col(ALLOT HERE + DOTO HERE)
+col(, HERE ! /N ALLOT)
+col(C, HERE C! /C ALLOT)
+col(W, HERE W! /W ALLOT)
+col(L, HERE L! /L ALLOT)
+col(ALIGN HERE /N 1- AND 0BRANCH(4) 0 C, BRANCH(-10))
+col(PLACE 2DUP C! CHAR+ SWAP CHARS BOUNDS DO?DO(9) DUP C@ I C! CHAR+ 1 CHARS DO+LOOP(-9) DROP)
+col(STRING, HERE OVER 1+ CHARS ALLOT PLACE)
+
+
+// Every language needs a no-op.
+col(NOOP)
+
+
+// Now it gets ugly: search-order and word-lisst infrastructure.
+
+
+// LASTWORD must be the last thing in our dictionary!
+extern cell xt_LASTWORD[];
+
+raw(FORTH-WORDLIST DODOES _A(xt_NOOP+3) _A(0) _A(xt_LASTWORD))
+ // +4 for 32-bit, +3 for 64-bit
+
+raw(CURRENT DOVAL _A(xt_FORTH_X2d_WORDLIST+5))
+ // +7 for 32-bit, +5 for 64-bit
+
+col(LAST CURRENT CELL+)
+
+raw(SEARCH-ORDER DOVAR _A(xt_FORTH_X2d_WORDLIST+5) _A(0) _A(0) _A(0) _A(0) _A(0) _A(0) _A(0) _A(0) _A(0) _A(0) _A(0) _A(0) _A(0) _A(0) _A(0))
+ // +7 for 32-bit, +5 for 64-bit
+raw(CONTEXT DOVAL _A(xt_SEARCH_X2d_ORDER+4))
+ // +6 for 32-bit, +4 for 64-bit
+
+
+// Dictionary structure.
+col(LINK>NAME CELL+)
+col(NAME> CHAR+ DUP C@ 1+ CHARS+ ALIGNED)
+col(LINK> LINK>NAME NAME>)
+col(NAME>STRING CHAR+ COUNT)
+
+// Creating word headers.
+var(LATEST 0)
+dfr((REVEAL))
+col(HEADER ALIGN HERE LAST @ , LATEST ! 0 C, STRING, ALIGN)
+col(REVEAL LATEST @ LINK>NAME NAME>STRING (REVEAL) LATEST @ LAST !)
+
+// Finding words.
+col(STRING=CI >R SWAP DUP R> <> 0BRANCH(3) 3DROP FALSE EXIT CHARS BOUNDS DO?DO(18) DUP C@ UPC I C@ UPC <> 0BRANCH(4) DROP UNLOOP FALSE EXIT CHAR+ 1 CHARS DO+LOOP(-18) DROP TRUE)
+// (find) ( str len head -- 0 | link )
+dfr((FIND))
+col(((FIND)) DUP 0BRANCH(15) >R 2DUP R@ LINK>NAME NAME>STRING STRING=CI 0BRANCH(3) 2DROP R> EXIT R> @ BRANCH(-18) 3DROP FALSE)
+col((FIND-ORDER) CONTEXT DUP >R SEARCH-ORDER U>= 0BRANCH(18) 2DUP R@ @ CELL+ @ (FIND) ?DUP 0BRANCH(5) NIP NIP R> DROP EXIT R> CELL- BRANCH(-24) R> 3DROP 0)
+col($FIND (FIND-ORDER) DUP 0BRANCH(6) LINK>NAME DUP NAME> SWAP C@ TRUE)
+
+// Flags on words.
+con('IMMEDIATE 1)
+col(IMMEDIATE? 'IMMEDIATE AND 0<>)
+col(IMMEDIATE LAST @ CELL+ DUP C@ 'IMMEDIATE OR SWAP C!)
+
+// Utility -- list all words in compilation wordlist.
+col(WORDS LAST @ ?DUP 0BRANCH(9) DUP CELL+ CHAR+ COUNT TYPE SPACE @ BRANCH(-12))
+
+// Parsing.
+col(FINDCHAR SWAP 0 DO?DO(24) OVER I + C@ OVER DUP BL = 0BRANCH(3) <= BRANCH(1) = 0BRANCH(6) I UNLOOP NIP NIP TRUE EXIT DOLOOP(-24) DROP DROP FALSE)
+col(PARSE >R IB >IN @ + SPAN @ >IN @ - 2DUP R> FINDCHAR 0BRANCH(6) NIP DUP 1 + BRANCH(1) DUP >IN +!)
+col(SKIPWS IB SPAN @ DUP >IN @ > 0BRANCH(14) OVER >IN @ + C@ BL <= 0BRANCH(5) 1 >IN +! BRANCH(-20) DROP DROP)
+col(PARSE-WORD SKIPWS BL PARSE)
+var(WHICHPOCKET 0)
+col(POCKET LIT(POCKETSIZE) WHICHPOCKET @ * POCKETS + 1 WHICHPOCKET @ - WHICHPOCKET !)
+col(WORD POCKET >R PARSE DUP R@ C! BOUNDS R> DUP 2SWAP DO?DO(7) CHAR+ I C@ OVER C! DOLOOP(-7) DROP)
+
+// Some simple parsing words.
+col(CHAR PARSE-WORD DROP C@)
+imm(( LIT(')') PARSE 2DROP)
+imm(\ LINEFEED PARSE 2DROP)
+
+// The compiler infrastructure.
+var(STATE 0)
+imm([ STATE OFF)
+col(] STATE ON)
+col(COMPILE, ,)
+col(: PARSE-WORD HEADER DOTICK DOCOL COMPILE, ])
+col(:NONAME ALIGN HERE DOTICK DOCOL COMPILE, ])
+imm(; DOTICK EXIT COMPILE, REVEAL [)
+
+// Compiling strings.
+imm(C" LIT('"') PARSE DOTICK SLITERAL COMPILE, DUP C, BOUNDS DO?DO(5) I C@ C, DOLOOP(-5) ALIGN)
+imm(S" STATE @ 0BRANCH(5) C" DOTICK COUNT COMPILE, EXIT LIT('"') PARSE DUP >R POCKET DUP >R SWAP MOVE R> R>)
+imm(." S" DOTICK TYPE COMPILE,)
+imm(.( LIT(')') PARSE TYPE)
+
+// Structure words.
+col(RESOLVE-ORIG HERE OVER CELL+ - SWAP !)
+imm(AHEAD DOTICK DOBRANCH COMPILE, HERE 0 COMPILE,)
+imm(IF DOTICK DO0BRANCH COMPILE, HERE 0 COMPILE,)
+imm(THEN RESOLVE-ORIG)
+imm(ELSE DOTICK DOBRANCH COMPILE, HERE 0 COMPILE, SWAP RESOLVE-ORIG)
+imm(CASE 0)
+imm(ENDCASE DOTICK DROP COMPILE, ?DUP 0BRANCH(5) 1- SWAP THEN BRANCH(-8))
+imm(OF 1+ >R DOTICK OVER COMPILE, DOTICK = COMPILE, IF DOTICK DROP COMPILE, R>)
+imm(ENDOF >R ELSE R>)
+col(RESOLVE-DEST HERE CELL+ - COMPILE,)
+imm(BEGIN HERE)
+imm(AGAIN DOTICK DOBRANCH COMPILE, RESOLVE-DEST)
+imm(UNTIL DOTICK DO0BRANCH COMPILE, RESOLVE-DEST)
+imm(WHILE IF SWAP)
+imm(REPEAT AGAIN THEN)
+
+// Counted loops.
+var(LEAVES 0)
+col(RESOLVE-LOOP LEAVES @ ?DUP 0BRANCH(10) DUP @ SWAP HERE OVER - SWAP ! BRANCH(-13) HERE - COMPILE, LEAVES !)
+imm(DO LEAVES @ HERE DOTICK DODO COMPILE, 0 LEAVES !)
+imm(?DO LEAVES @ DOTICK DODO?DO COMPILE, HERE HERE LEAVES ! 0 COMPILE,)
+imm(LOOP DOTICK DODOLOOP COMPILE, RESOLVE-LOOP)
+imm(+LOOP DOTICK DODO+LOOP COMPILE, RESOLVE-LOOP)
+imm(LEAVE DOTICK DODOLEAVE COMPILE, LEAVES @ HERE LEAVES ! COMPILE,)
+imm(?LEAVE DOTICK DODO?LEAVE COMPILE, LEAVES @ HERE LEAVES ! COMPILE,)
+
+// Interpreter nesting.
+col(SAVE-SOURCE R> IB >R #IB @ >R SOURCE-ID >R SPAN @ >R >IN @ >R >R)
+col(RESTORE-SOURCE R> R> >IN ! R> SPAN ! R> DOTO SOURCE-ID R> #IB ! R> DOTO IB >R)
+
+// System replies.
+str(OK-STR "ok")
+str(ABORTED-STR "Aborted")
+str(EXCEPTION-STR "Exception #")
+col(PRINT-STATUS SPACE DUP 0= 0BRANCH(4) DOTICK OK-STR BRANCH(7) DUP -1 = 0BRANCH(6) DOTICK ABORTED-STR COUNT TYPE BRANCH(10) DUP LIT(-2) = 0BRANCH(7) ABORT"-STR @ COUNT TYPE DROP BRANCH(5) DOTICK EXCEPTION-STR COUNT TYPE . CR)
+
+// The compiler and interpreter.
+col(COMPILE-WORD 2DUP $FIND 0BRANCH(10) IMMEDIATE? 0BRANCH(4) NIP NIP EXECUTE EXIT COMPILE, 2DROP EXIT 2DUP $NUMBER 0BRANCH(4) TYPE LIT(-99) THROW DOTICK DOLIT COMPILE, COMPILE, 2DROP)
+col(INTERPRET-WORD 2DUP $FIND 0BRANCH(5) DROP NIP NIP EXECUTE EXIT 2DUP $NUMBER 0BRANCH(4) TYPE LIT(-99) THROW >R 2DROP R>)
+col(INTERPRET 0 >IN ! PARSE-WORD DUP 0BRANCH(10) STATE @ 0BRANCH(3) COMPILE-WORD BRANCH(1) INTERPRET-WORD BRANCH(-14) 2DROP)
+
+// Evaluate, the one word to rule them all. It is evil, btw.
+col(EVALUATE SAVE-SOURCE -1 DOTO SOURCE-ID DUP #IB ! SPAN ! DOTO IB INTERPRET RESTORE-SOURCE)
+col(EVAL EVALUATE)
+
+// Abort with a message.
+col(DOABORT" SWAP 0BRANCH(5) ABORT"-STR ! LIT(-2) THROW DROP)
+imm(ABORT" C" DOTICK DOABORT" COMPILE,)
+
+// Tick.
+str(UNDEFINED-STR "undefined word")
+col(' PARSE-WORD $FIND 0= DOTICK UNDEFINED-STR DOABORT" DROP)
+
+// The outer interpreter.
+col(QUIT 0 RDEPTH! [ TERMINAL DEPTH . LIT('>') EMIT SPACE REFILL 0BRANCH(10) SPACE DOTICK INTERPRET CATCH DUP PRINT-STATUS 0BRANCH(-17) BRANCH(-23))
+
+// Reading and writing to/from file; including files.
+dfr(MAP-FILE)
+dfr(UNMAP-FILE)
+dfr(WRITE-FILE)
+col(INCLUDED MAP-FILE 2DUP >R >R BOUNDS DO?DO(21) R> R@ SWAP >R R@ - R@ SWAP 2DUP LINEFEED FINDCHAR 0BRANCH(1) NIP DUP >R EVALUATE R> 1+ DO+LOOP(-21) R> R> UNMAP-FILE)
+col(INCLUDE PARSE-WORD INCLUDED)
+
+// CREATE ... DOES> ...
+col($CREATE HEADER DOTICK DODOES COMPILE, DOTICK NOOP CELL+ COMPILE, REVEAL)
+col(CREATE PARSE-WORD $CREATE)
+col(DODOES> R> CELL+ LATEST @ LINK> CELL+ !)
+imm(DOES> DOTICK DODOES> COMPILE,)
+
+// Defining words.
+col(CONSTANT PARSE-WORD HEADER DOTICK DOCON COMPILE, COMPILE, REVEAL)
+col(VALUE PARSE-WORD HEADER DOTICK DOVAL COMPILE, COMPILE, REVEAL)
+col(VARIABLE PARSE-WORD HEADER DOTICK DOVAR COMPILE, 0 COMPILE, REVEAL)
+col(BUFFER: PARSE-WORD HEADER DOTICK DOBUFFER: COMPILE, ALLOT REVEAL)
+col(DEFER PARSE-WORD HEADER DOTICK DODEFER COMPILE, DOTICK ABORT COMPILE, REVEAL)
+col(ALIAS PARSE-WORD HEADER DOTICK DOALIAS COMPILE, ' COMPILE, REVEAL)
+col(STRUCT 0)
+col(FIELD PARSE-WORD HEADER DOTICK DOFIELD COMPILE, OVER , + REVEAL)
+
+// Words with (mostly) non-standard compilation behaviour.
+imm(LITERAL DOTICK DOLIT COMPILE, COMPILE,)
+col(COMPILE R> CELL+ DUP @ COMPILE, >R)
+imm([COMPILE] ' COMPILE,)
+imm(POSTPONE PARSE-WORD $FIND 0= DOTICK UNDEFINED-STR DOABORT" IMMEDIATE? 0= 0BRANCH(6) DOTICK DOTICK COMPILE, COMPILE, DOTICK COMPILE, COMPILE,)
+imm([CHAR] CHAR LITERAL)
+imm(['] ' DOTICK DOTICK COMPILE, COMPILE,)
+
+// FIND.
+col(FIND DUP COUNT $FIND 0BRANCH(9) ROT DROP TRUE SWAP IMMEDIATE? 0BRANCH(1) NEGATE EXIT FALSE EXIT)
+
+// Accessing data in CREATE'd words.
+imm(TO ' STATE @ 0BRANCH(5) DOTICK DOTO COMPILE, COMPILE, EXIT CELL+ !)
+col(BEHAVIOR CELL+ @)
+col(>BODY 2 CELLS +)
+col(BODY> 2 CELLS -)
+
+// Making words recursive.
+imm(RECURSIVE REVEAL)
+imm(RECURSE LATEST @ LINK> COMPILE,)
diff --git a/entry.S b/entry.S
new file mode 100644
index 0000000..86e7680
--- /dev/null
+++ b/entry.S
@@ -0,0 +1,195 @@
+# =============================================================================
+# * Copyright (c) 2004, 2005 IBM Corporation
+# * All rights reserved.
+# * This program and the accompanying materials
+# * are made available under the terms of the BSD License
+# * which accompanies this distribution, and is available at
+# * http://www.opensource.org/licenses/bsd-license.php
+# *
+# * Contributors:
+# * IBM Corporation - initial implementation
+# =============================================================================
+
+
+#
+# The entry points into the engine, as well as everything else in low memory.
+#
+
+ .section ".slof.vectors","ax"
+
+ . = 0
+
+ .asciz "SLOF, the SlimLine Open Firmware"
+
+
+ #
+ # The reset exception.
+ #
+
+ . = 0x0100
+ mtsprg 0,0
+ li 0,0x0100
+ b handler
+
+
+
+ #
+ # All other exceptions.
+ #
+
+ .irp i, 0x0200,0x0300,0x0380,0x0400,0x0480,0x0500,0x0600,0x0700, \
+ 0x0800,0x0900,0x0a00,0x0b00,0x0c00,0x0d00,0x0e00,0x0f00, \
+ 0x1000,0x1100,0x1200,0x1300,0x1400,0x1500,0x1600,0x1700, \
+ 0x1800,0x1900,0x1a00,0x1b00,0x1c00,0x1d00,0x1e00,0x1f00, \
+ 0x2000,0x2100,0x2200,0x2300,0x2400,0x2500,0x2600,0x2700, \
+ 0x2800,0x2900,0x2a00,0x2b00,0x2c00,0x2d00,0x2e00,0x2f00
+ . = \i
+ mtsprg 0,0 ; li 0,\i ; b handler
+ .endr
+
+
+
+ #
+ # The generic exception code.
+ #
+ # Enter with GPR0 = vector, SPRG0 = saved GPR0.
+ #
+
+ . = 0x3000
+
+handler:
+ mtsprg 1,1 # SPRG1 = saved GPR1
+ lis 1,0x0110 # GPR1 = address of register save area
+
+ .irp i, 2,3,4,5,6,7,8,9,10,11,12,13,14,15, \
+ 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
+ std \i,\i*8(1)
+ .endr # save GPR2..GPR31
+
+ mr 3,0 # GPR3 = vector
+
+ mfsprg 0,0 ; std 0,0(1) # save GPR0
+ mfsprg 0,1 ; std 0,8(1) # save GPR1
+
+ mfcr 0 ; std 0,0x100(1)
+ mfxer 0 ; std 0,0x108(1)
+ mflr 0 ; std 0,0x110(1)
+ mfctr 0 ; std 0,0x118(1)
+ mfsrr0 0 ; std 0,0x120(1)
+ mfsrr1 0 ; std 0,0x128(1)
+ mfdar 0 ; std 0,0x130(1)
+ mfdsisr 0 ; std 0,0x138(1) # save special regs
+
+ addi 1,1,0x7000 ; li 0,0 ; stdu 0,-16(1) # set up stack
+ lis 2,engine@ha ; ld 2,8+engine@l(2) # set up TOC pointer
+ b .engine # ...and go!
+
+
+
+
+ #
+ # Swap non-volatile client interface regs, plus GPR3..GPR7.
+ #
+
+swap_ci_regs:
+ lis 8,0x0110
+ addi 8,8,0x0400
+
+ .irp i, 1,2,3,4,5,6,7, \
+ 13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
+ ld 0,\i*8(8)
+ std \i,\i*8(8)
+ mr \i,0
+ .endr # swap GPR1..7, GPR13..31
+
+ ld 0,0x100(8) ; mfcr 9 ; mtcrf 0xff,0 ; std 9,0x100(8) # swap CR
+ ld 0,0x128(8) ; mfmsr 9 ; mtmsrd 0 ; sync ; isync ; std 9,0x128(8)
+ # swap MSR
+ blr
+
+
+ #
+ # Entry point for the OF client interface.
+ #
+
+ .globl client_entry_point
+ .section ".opd","aw"
+ .align 3
+client_entry_point:
+ .quad .client_entry_point,.TOC.@tocbase,0
+ .previous
+ .type .client_entry_point,@function
+ .globl .client_entry_point
+.client_entry_point:
+ mflr 4 ; bl swap_ci_regs ; mtlr 4 ; li 3,0 ; blr
+
+
+ #
+ # Start the client.
+ #
+
+ .globl call_client
+ .section ".opd","aw"
+ .align 3
+call_client:
+ .quad .call_client,.TOC.@tocbase,0
+ .previous
+ .type .call_client,@function
+ .globl .call_client
+
+.call_client: # called with GPR3 = address, returns GPR3
+ mflr 4 ; mtctr 3 ; bl swap_ci_regs ; bctrl
+ bl swap_ci_regs ; mtlr 4 ; li 3,-1 ; blr
+
+
+ .globl flush_cache
+ .section ".opd","aw"
+ .align 3
+flush_cache:
+ .quad .flush_cache,.TOC.@tocbase,0
+ .previous
+ .type .flush_cache,@function
+ .globl .flush_cache
+.flush_cache: # flush at GPR3 size GPR4
+ add 4,4,3
+ addi 4,4,127
+ rlwinm 3,3,0,0,24
+ rlwinm 4,4,0,0,24
+ sub 4,4,3
+ srwi 4,4,7
+ mtctr 4
+0:
+ dcbst 0,3
+ sync
+ icbi 0,3
+ sync
+ isync
+ addi 3,3,128
+ bdnz 0b
+
+ blr
+
+
+ #
+ # This is where the secondary CPUs sit and wait.
+ #
+
+ . = 0x3f00
+slaveloop:
+ lis 0,10
+ mtctr 0
+ bdnz $ # do some waiting, to prevent flooding the buses
+ lwz 0,0x3f40(0)
+ and. 0,0,0
+ beq $-20 # wait for our flag
+
+ lwz 0,0x3f80(0)
+ lwz 3,0x3fc0(0)
+ mtctr 0
+ bctr # jump to specified address, with specified GPR3
+
+
+
+
+. = 0x3fff
+.byte 0x36 # to fill out to exactly 16kB
diff --git a/fs/.#main.fs.1.3 b/fs/.#main.fs.1.3
new file mode 100644
index 0000000..1db2bbd
--- /dev/null
+++ b/fs/.#main.fs.1.3
@@ -0,0 +1,170 @@
+\ The master file. Everything else is included into here.
+
+hex
+
+\ Speed up compiling.
+INCLUDE find-hash.fs
+
+\ Enable use of multiple wordlists and vocabularies.
+INCLUDE search.fs
+
+\ Heap memory allocation.
+INCLUDE alloc-mem.fs
+
+\ First some very generic code.
+: d# parse-word base @ >r decimal evaluate r> base ! ; immediate
+: END-STRUCT drop ;
+: 0.r 0 swap <# 0 ?DO # LOOP #> type ;
+
+: zcount ( zstr -- str len ) dup BEGIN dup c@ WHILE char+ REPEAT over - ;
+: zplace ( str len buf -- ) 2dup + 0 swap c! swap move ;
+
+CREATE $catpad 100 allot
+\ First input string is allowed to already be on the pad; second is not.
+: $cat ( str1 len1 str2 len2 -- str3 len3 )
+ >r >r dup >r $catpad swap move
+ r> dup $catpad + r> swap r@ move
+ r> + $catpad swap ;
+
+: 2CONSTANT CREATE swap , , DOES> 2@ ;
+: $2CONSTANT $CREATE swap , , DOES> 2@ ;
+
+\ Memory and I/O hexdump.
+INCLUDE dump.fs
+
+\ I/O accesses.
+INCLUDE io.fs
+
+\ Start the serial console.
+INCLUDE serial.fs
+
+\ Input line editing.
+INCLUDE accept.fs
+
+\ Register frame layout.
+STRUCT
+ cell FIELD >r0 cell FIELD >r1 cell FIELD >r2 cell FIELD >r3
+ cell FIELD >r4 cell FIELD >r5 cell FIELD >r6 cell FIELD >r7
+ cell FIELD >r8 cell FIELD >r9 cell FIELD >r10 cell FIELD >r11
+ cell FIELD >r12 cell FIELD >r13 cell FIELD >r14 cell FIELD >r15
+ cell FIELD >r16 cell FIELD >r17 cell FIELD >r18 cell FIELD >r19
+ cell FIELD >r20 cell FIELD >r21 cell FIELD >r22 cell FIELD >r23
+ cell FIELD >r24 cell FIELD >r25 cell FIELD >r26 cell FIELD >r27
+ cell FIELD >r28 cell FIELD >r29 cell FIELD >r30 cell FIELD >r31
+ cell FIELD >cr cell FIELD >xer cell FIELD >lr cell FIELD >ctr
+ cell FIELD >srr0 cell FIELD >srr1 cell FIELD >dar cell FIELD >dsisr
+END-STRUCT
+
+1100000 CONSTANT eregs \ Exception register frame.
+1100400 CONSTANT ciregs \ Client (interface) register frame.
+
+\ Print out an exception frame, e.g., eregs .regs
+: .16 10 0.r 3 spaces ;
+: .8 8 spaces 8 0.r 3 spaces ;
+: .4regs cr 4 0 DO dup @ .16 8 cells+ LOOP drop ;
+: .fixed-regs
+ cr ." R0 .. R7 R8 .. R15 R16 .. R23 R24 .. R31"
+ dup 8 0 DO dup .4regs cell+ LOOP drop ;
+: .special-regs
+ cr ." CR / XER LR / CTR SRR0 / SRR1 DAR / DSISR"
+ cr dup >cr @ .8 dup >lr @ .16 dup >srr0 @ .16 dup >dar @ .16
+ cr dup >xer @ .16 dup >ctr @ .16 dup >srr1 @ .16 >dsisr @ .8 ;
+: .regs
+ cr .fixed-regs
+ cr .special-regs
+ cr cr ;
+
+\ Some low-level functions -- no source code provided, sorry.
+: reboot 0 1 oco ;
+: halt 0 2 oco ;
+: watchdog 3 oco ;
+: other-firmware 1 watchdog ;
+
+\ Get the second CPU into our own spinloop.
+0 VALUE slave?
+: get-slave ( addr -- ) 0 oco 0= IF true to slave? THEN ;
+: slave-report cr slave? IF ." Second CPU is running." ELSE
+ ." Second CPU is NOT running!" THEN ;
+3f00 get-slave slave-report
+
+\ Packages, instances, properties, devices, methods -- the whole shebang.
+INCLUDE package.fs
+
+\ Environment variables. Not actually used right now.
+INCLUDE envvar.fs
+
+\ Hook to help loading our secondary boot loader.
+DEFER disk-read ( lba cnt addr -- )
+
+\ The device tree.
+INCLUDE js20-tree.fs
+
+\ The client interface.
+INCLUDE client.fs
+
+\ ELF binary file format.
+INCLUDE elf.fs
+
+\ Give our client a stack.
+111f000 ciregs >r1 !
+
+\ Run the client program.
+: start-elf ( entry-addr -- ) msr@ 7fffffffffffffff and 2000 or ciregs >srr1 !
+ 0 0 rot call-client ;
+: start-elf64 ( entry-addr -- ) msr@ 2000 or ciregs >srr1 !
+ 0 0 rot call-client ;
+
+\ Where files are loaded. Not the same as where they are executed.
+10000 CONSTANT load-base
+\ Load secondary boot loader from disk @ sector 63. 512kB should be enough.
+: read-yaboot 3f 400 load-base disk-read ;
+
+: yaboot
+ cr ." Reading..." read-yaboot
+ ." relocating..." load-base load-elf-file
+ ." go!" start-elf ;
+
+: set-bootpart ( -- )
+ skipws 0 parse s" disk:" 2swap $cat
+ encode-string s" bootpath" set-chosen ;
+
+: set-bootargs
+ skipws 0 parse dup 0= IF 2drop ELSE
+ encode-string s" bootargs" set-chosen THEN ;
+: etherboot s" enet:" set-bootargs payload dup load-elf-file start-elf ;
+: go etherboot ;
+
+\ Default bootpath
+
+s" disk:3" encode-string s" bootpath" set-chosen
+
+: boot set-bootargs yaboot ;
+
+: auto
+ key? IF clear c emit key drop QUIT THEN
+ cr ." Netboot -- to drop into GUI instead, please hold a key while starting"
+ cr
+ payload dup load-elf-file start-elf ;
+
+: disable-boot-watchdog
+ 0 watchdog IF cr ." Failed to disable boot watchdog." THEN ;
+
+disable-boot-watchdog
+
+cr
+cr
+cr .( SLOF version 0.0 Copyright 2004,2005 IBM Corporation)
+cr .( Paflof Forth engine Copyright 2003,2004,2005 Segher Boessenkool)
+cr
+cr .( Parts of this code are:)
+cr
+cr .( Licensed Internal Code - Property of IBM)
+cr .( JS20 Licensed Internal Code)
+cr .( (C) char ) emit .( Copyright IBM Corp. 2004, 2005 All Rights Reserved.)
+cr .( US Government Users Restricted Rights - Use, duplication or)
+cr .( disclosure restricted by GSA ADP Schedule Contract with IBM)
+cr
+cr
+
+\ Enable this if you want your system to automatically boot by default:
+\ auto
diff --git a/fs/accept.fs b/fs/accept.fs
new file mode 100644
index 0000000..ad361fd
--- /dev/null
+++ b/fs/accept.fs
@@ -0,0 +1,52 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Implementation of ACCEPT. Nothing fancy for now; just handles CR and BS.
+
+: TABLE-EXECUTE CREATE DOES> swap cells+ @ ?dup IF execute ELSE false THEN ;
+
+0 VALUE accept-adr
+0 VALUE accept-max
+0 VALUE accept-len
+
+: handle-backspace accept-len ?dup IF 1- TO accept-len
+ bs emit space bs emit THEN false ;
+
+: handle-enter space true ;
+
+TABLE-EXECUTE handle-control
+0 , 0 , 0 , 0 ,
+0 , 0 , 0 , 0 ,
+' handle-backspace , 0 , 0 , 0 ,
+0 , ' handle-enter , 0 , 0 ,
+0 , 0 , 0 , 0 ,
+0 , 0 , 0 , 0 ,
+0 , 0 , 0 , 0 ,
+0 , 0 , 0 , 0 ,
+
+: handle-normal
+ dup emit
+ accept-len accept-max < IF
+ accept-adr accept-len chars+ c!
+ accept-len 1+ TO accept-len
+ ELSE drop THEN ;
+
+: (accept) ( adr len -- len' )
+ TO accept-max TO accept-adr 0 TO accept-len
+ BEGIN key
+ dup 7f = IF drop 8 THEN \ Handle DEL as if it was BS.
+ dup bl < IF handle-control IF accept-len exit THEN
+ ELSE handle-normal THEN
+ AGAIN ;
+
+' (accept) TO accept
diff --git a/fs/alloc-mem.fs b/fs/alloc-mem.fs
new file mode 100644
index 0000000..7dc7bd4
--- /dev/null
+++ b/fs/alloc-mem.fs
@@ -0,0 +1,19 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Memory "heap" (de-)allocation.
+
+\ For now, just allocate from the data space, and never take space back.
+
+: alloc-mem ( len -- a-addr ) align here swap allot ;
+: free-mem ( a-addr len -- ) 2drop ;
diff --git a/fs/client.fs b/fs/client.fs
new file mode 100644
index 0000000..25715ba
--- /dev/null
+++ b/fs/client.fs
@@ -0,0 +1,123 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Client interface.
+
+\ First, the machinery.
+
+VOCABULARY client-voc \ We store all client-interface callable words here.
+
+: client-data ciregs >r3 @ ;
+: nargs client-data la1+ l@ ;
+: nrets client-data la1+ la1+ l@ ;
+: client-data-to-stack
+ client-data 3 la+ nargs 0 ?DO dup l@ swap la1+ LOOP drop ;
+: stack-to-client-data
+ client-data nargs nrets + 2 + la+ nrets 0 ?DO tuck l! /l - LOOP drop ;
+
+: call-client ( p0 p1 client-entry -- )
+ >r ciregs >r7 ! ciregs >r6 ! client-entry-point @ ciregs >r5 !
+ r> jump-client drop
+ BEGIN
+ client-data-to-stack
+ client-data l@ zcount
+ \ XXX: Should only look in client-voc...
+ ALSO client-voc $find PREVIOUS dup 0= >r
+ IF drop
+ \ XXX: 6789 is magic...
+ CATCH ?dup IF dup 6789 = IF drop r> drop EXIT THEN THROW THEN
+ stack-to-client-data
+ ELSE cr client-data l@ zcount type ." NOT FOUND" THEN
+ r> ciregs >r3 ! ciregs >r4 @ jump-client
+ UNTIL ;
+
+: flip-stack ( a1 ... an n -- an ... a1 ) ?dup IF 1 ?DO i roll LOOP THEN ;
+
+
+
+\ Now come the actual client interface words.
+
+ALSO client-voc DEFINITIONS
+
+: exit 6789 THROW ;
+
+: finddevice ( zstr -- phandle )
+ zcount find-package 0= IF -1 THEN ;
+
+: getprop ( phandle zstr buf len -- len' )
+ >r >r zcount rot get-property IF ( data dlen R: buf blen )
+ r> swap dup r> min swap >r move r> ELSE r> r> 2drop -1 THEN ;
+
+: getproplen ( phandle zstr -- len )
+ zcount rot get-property IF nip ELSE -1 THEN ;
+
+: setprop ( phandle zstr buf len -- size|-1 )
+ dup >r here dup >r swap dup allot move r> r>
+ dup >r 2swap swap current-package @ >r set-package
+ zcount property r> set-package r> ;
+
+
+: nextprop ( phandle zstr buf -- flag ) \ -1 invalid, 0 end, 1 ok
+ >r zcount rot next-property IF r> zplace 1 ELSE r> drop 0 THEN ;
+
+: open ( zstr -- ihandle ) zcount open-dev ;
+: close ( ihandle -- ) close-dev ;
+
+\ XXX: should return -1 if no such method exists in that node
+: write ( ihandle str len -- len' ) rot s" write" rot $call-method ;
+: read ( ihandle str len -- len' ) rot s" read" rot $call-method ;
+: seek ( ihandle hi lo -- status ) swap rot s" seek" rot $call-method ;
+
+: claim ( virt size align -- addr )
+ \ We don't do any assigned-addresses bookkeeping; furthermore, we're
+ \ running with translations off, so just tell the client it can have it.
+ \ XXX: doesn't work if client doesn't ask for a specific address.
+ 2drop ;
+: release ( virt size -- )
+ 2drop ;
+
+: instance-to-package ( ihandle -- phandle )
+ ihandle>phandle ;
+
+: instance-to-path ( ihandle buf len -- len' )
+ \ XXX: we do no buffer overflow checking!
+ drop >r ihandle>phandle s" full_name" rot get-property drop
+ r> swap dup >r move r> 1- ;
+
+: package-to-path ( phandle buf len -- len' )
+ \ XXX: we do no overflow checking!
+ drop >r s" full_name" rot get-property IF r> swap dup >r move r> 1-
+ ELSE true ABORT" No full_name property?!?" THEN ;
+
+: call-method ( str ihandle arg ... arg -- result return ... return )
+ nargs flip-stack zcount rot ['] $call-method CATCH
+ dup IF nrets 1 ?DO -444 LOOP THEN
+ nrets flip-stack ;
+
+: interpret ( ... zstr -- result ... )
+ \ XXX: we just throw away the arguments.
+ nargs 0 ?DO drop LOOP nrets 1 ?DO -555 LOOP -667 ;
+
+\ XXX: no real clock, but monotonically increasing, at least ;-)
+VARIABLE milliseconds
+: milliseconds milliseconds @ 1 milliseconds +! ;
+
+: start-cpu ( phandle addr r3 -- )
+ \ phandle isn't actually used, but that's no problem on a 2-CPU system.
+ 3fc0 l! 3f80 l! 3f40 l! ;
+
+\ Just to shut up warnings resulting from Linux calling this whether it
+\ exists or not. It isn't even standard, but hey.
+: quiesce ;
+
+PREVIOUS DEFINITIONS
diff --git a/fs/dump.fs b/fs/dump.fs
new file mode 100644
index 0000000..1b9e883
--- /dev/null
+++ b/fs/dump.fs
@@ -0,0 +1,26 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Hexdump thingy. A bit simplistic, always prints full lines.
+
+hex
+
+DEFER dump-c@
+: .2 ( u -- ) 0 <# # # #> type space ;
+: .char ( c -- ) dup bl 7e between 0= IF drop [char] . THEN emit ;
+: dumpline ( addr -- )
+ cr dup 8 u.r ." : " dup 10 bounds DO i dump-c@ .2 LOOP
+ space space 10 bounds DO i dump-c@ .char LOOP ;
+: (dump) ( addr size -- ) bounds DO i dumpline 10 +LOOP ;
+: dump ['] c@ to dump-c@ (dump) ;
+: rdump ['] rb@ to dump-c@ (dump) ;
diff --git a/fs/elf.fs b/fs/elf.fs
new file mode 100644
index 0000000..997774d
--- /dev/null
+++ b/fs/elf.fs
@@ -0,0 +1,209 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ ELF loader.
+
+\ Author: Hartmut Penner <hpenner@de.ibm.com>
+
+\ ELF 32 bit header
+
+STRUCT
+ /l field ehdr>e_ident
+ /c field ehdr>e_class
+ /c field ehdr>e_data
+ /c field ehdr>e_version
+ /c field ehdr>e_pad
+ /l field ehdr>e_ident_2
+ /l field ehdr>e_ident_3
+ /w field ehdr>e_type
+ /w field ehdr>e_machine
+ /l field ehdr>e_version
+ /l field ehdr>e_entry
+ /l field ehdr>e_phoff
+ /l field ehdr>e_shoff
+ /l field ehdr>e_flags
+ /w field ehdr>e_ehsize
+ /w field ehdr>e_phentsize
+ /w field ehdr>e_phnum
+ /w field ehdr>e_shentsize
+ /w field ehdr>e_shnum
+ /w field ehdr>e_shstrndx
+END-STRUCT
+
+
+\ ELF 32 bit program header
+
+STRUCT
+ /l field phdr>p_type
+ /l field phdr>p_offset
+ /l field phdr>p_vaddr
+ /l field phdr>p_paddr
+ /l field phdr>p_filesz
+ /l field phdr>p_memsz
+ /l field phdr>p_flags
+ /l field phdr>p_align
+END-STRUCT
+
+\ ELF 64 bit header
+
+STRUCT
+ /l field ehdr64>e_ident
+ /c field ehdr64>e_class
+ /c field ehdr64>e_data
+ /c field ehdr64>e_version
+ /c field ehdr64>e_pad
+ /l field ehdr64>e_ident_2
+ /l field ehdr64>e_ident_3
+ /w field ehdr64>e_type
+ /w field ehdr64>e_machine
+ /l field ehdr64>e_version
+ cell field ehdr64>e_entry
+ cell field ehdr64>e_phoff
+ cell field ehdr64>e_shoff
+ /l field ehdr64>e_flags
+ /w field ehdr64>e_ehsize
+ /w field ehdr64>e_phentsize
+ /w field ehdr64>e_phnum
+ /w field ehdr64>e_shentsize
+ /w field ehdr64>e_shnum
+ /w field ehdr64>e_shstrndx
+END-STRUCT
+
+
+\ ELF 64 bit program header
+
+STRUCT
+ /l field phdr64>p_type
+ /l field phdr64>p_flags
+ cell field phdr64>p_offset
+ cell field phdr64>p_vaddr
+ cell field phdr64>p_paddr
+ cell field phdr64>p_filesz
+ cell field phdr64>p_memsz
+ cell field phdr64>p_align
+END-STRUCT
+
+: load-segment ( file-addr program-header-addr -- )
+
+ ( file-addr program-header-addr )
+ dup >r phdr>p_vaddr l@ r@ phdr>p_memsz l@ erase
+
+ ( file-addr R: programm-header-addr )
+ r@ phdr>p_vaddr l@ r@ phdr>p_memsz l@ dup 0= IF 2drop ELSE flushcache THEN
+
+ ( file-addr R: programm-header-addr )
+ r@ phdr>p_offset l@ + r@ phdr>p_vaddr l@ r> phdr>p_filesz l@ move
+;
+
+
+: load-segments ( file-addr -- )
+ ( file-addr )
+ dup dup ehdr>e_phoff l@ + \ Calculate program header address
+
+ ( file-addr program-header-addr )
+ over ehdr>e_phnum w@ 0 ?DO \ loop e_phnum times
+
+ ( file-addr program-header-addr )
+ dup phdr>p_type l@ 1 = IF \ PT_LOAD ?
+
+ ( file-addr program-header-addr )
+ 2dup load-segment THEN \ copy segment
+
+ ( file-addr program-header-addr )
+ over ehdr>e_phentsize w@ + LOOP \ step to next header
+
+ ( file-addr program-header-addr )
+ over ehdr>e_entry l@
+
+ ( file-addr program-header-addr )
+ nip nip \ cleanup
+;
+
+: load-segment64 ( file-addr program-header-addr -- )
+
+ ( file-addr program-header-addr )
+ dup >r phdr64>p_vaddr @ r@ phdr64>p_memsz @ erase
+
+ ( file-addr R: programm-header-addr )
+ r@ phdr64>p_vaddr @ r@ phdr64>p_memsz @ dup 0= IF 2drop ELSE flushcache THEN
+
+ ( file-addr R: programm-header-addr )
+ r@ phdr64>p_offset @ + r@ phdr64>p_vaddr @ r> phdr64>p_filesz @ move
+;
+
+
+: load-segments64 ( file-addr -- entry )
+ ( file-addr )
+ dup dup ehdr64>e_phoff @ + \ Calculate program header address
+
+ ( file-addr program-header-addr )
+ over ehdr64>e_phnum w@ 0 ?DO \ loop e_phnum times
+
+ ( file-addr program-header-addr )
+ dup phdr64>p_type l@ 1 = IF \ PT_LOAD ?
+
+ ( file-addr program-header-addr )
+ 2dup load-segment64 THEN \ copy segment
+
+ ( file-addr program-header-addr )
+ over ehdr64>e_phentsize w@ + LOOP \ step to next header
+
+ ( file-addr program-header-addr )
+ over ehdr64>e_entry @
+
+ ( file-addr program-header-addr entry )
+ nip nip \ cleanup
+;
+
+: elf-check-file ( file-addr -- 1 : 32, 2 : 64, else bad )
+ ( file-addr )
+ dup ehdr>e_ident l@ 7f454c46 <> ABORT" Not an ELF file"
+
+ ( file-addr )
+ dup ehdr>e_data c@ 2 <> ABORT" Not a Big Endian ELF file"
+
+ ( file-addr )
+ dup ehdr>e_type w@ 2 <> ABORT" Not an ELF executable"
+
+ ( file-addr )
+ dup ehdr>e_machine w@ dup 14 <> swap 15 <> and ABORT" Not a PPC ELF executable"
+
+ ( file-addr)
+ ehdr>e_class c@
+;
+
+: load-elf32 ( file-addr -- )
+
+ ( file-addr)
+ load-segments
+;
+
+: load-elf64 ( file-addr -- )
+
+ ( file-addr)
+ load-segments64
+;
+
+: load-elf-file ( file-addr -- entry )
+
+ ( file-addr )
+ dup elf-check-file
+
+ ( file-addr 1|2|x )
+
+ CASE
+ 1 OF load-elf32 ENDOF
+ 2 OF load-elf64 ENDOF
+ dup OF true ABORT" Neither 32- nor 64-bit ELF file" ENDOF
+ ENDCASE
+;
diff --git a/fs/envvar.fs b/fs/envvar.fs
new file mode 100644
index 0000000..0cdb9f6
--- /dev/null
+++ b/fs/envvar.fs
@@ -0,0 +1,93 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Configuration variables. Not actually used yet, nor shown in /options.
+
+wordlist CONSTANT envvars
+
+: listenv get-current envvars set-current words set-current ;
+
+: create-env ( "name" -- )
+ get-current >r envvars set-current CREATE r> set-current ;
+
+: env-int ( n -- ) 1 c, align , DOES> char+ aligned @ ;
+: env-bytes ( a len -- ) 2 c, align dup , here swap dup allot move
+ DOES> char+ aligned dup @ >r cell+ r> ;
+: env-string ( a len -- ) 3 c, string, DOES> char+ count ;
+: env-flag ( f -- ) 4 c, c, DOES> char+ c@ 0<> ;
+: env-secmode ( sm -- ) 5 c, c, DOES> char+ c@ ;
+
+: default-int ( n "name" -- ) create-env env-int ;
+: default-bytes ( a len "name" -- ) create-env env-bytes ;
+: default-string ( a len "name" -- ) create-env env-string ;
+: default-flag ( f "name" -- ) create-env env-flag ;
+: default-secmode ( sm "name" -- ) create-env env-secmode ;
+
+: findenv ( name len -- adr def-adr type )
+ 2dup envvars voc-find dup 0= ABORT" not a configuration variable"
+ link> >body char+ >r (find-order) link> >body dup char+ swap c@ r> swap ;
+: $setenv ( param len name len -- )
+ 2dup findenv nip nip -rot $CREATE CASE
+ 1 OF evaluate env-int ENDOF \ XXX: wants decimal and 0x...
+ 2 OF env-bytes ENDOF
+ 3 OF env-string ENDOF
+ 4 OF evaluate env-flag ENDOF
+ 5 OF evaluate env-secmode ENDOF \ XXX: recognize none, command, full
+ ENDOF ENDCASE ;
+: setenv parse-word skipws 0 parse 2swap $setenv ;
+
+: (printenv) ( adr type -- )
+ CASE
+ 1 OF aligned @ . ENDOF
+ 2 OF aligned dup cell+ swap @ dump ENDOF
+ 3 OF count type ENDOF
+ 4 OF c@ IF ." true" ELSE ." false" THEN ENDOF
+ 5 OF c@ . ENDOF \ XXX: print symbolically
+ ENDCASE ;
+: printenv parse-word findenv rot over cr ." Current: " (printenv)
+ cr ." Default: " (printenv) ;
+: (set-default) ( def-xt -- )
+ dup >name name>string $CREATE dup >body c@ >r execute r> CASE
+ 1 OF env-int ENDOF
+ 2 OF env-bytes ENDOF
+ 3 OF env-string ENDOF
+ 4 OF env-flag ENDOF
+ 5 OF env-secmode ENDOF ENDCASE ;
+: set-default parse-word envvars voc-find
+ dup 0= ABORT" not a configuration variable" link> (set-default) ;
+: set-defaults envvars cell+ BEGIN @ dup WHILE dup link> (set-default) REPEAT
+ drop ;
+
+true default-flag auto-boot?
+s" " default-string boot-device
+s" " default-string boot-file
+s" " default-string diag-device
+s" " default-string diag-file
+false default-flag diag-switch?
+true default-flag fcode-debug?
+s" " default-string input-device
+s" 1 2 3 * + ." default-string nvramrc
+s" " default-string oem-banner
+false default-flag oem-banner?
+0 0 default-bytes oem-logo
+false default-flag oem-logo?
+s" " default-string output-device
+50 default-int screen-#columns
+18 default-int screen-#rows
+0 default-int security-#badlogins
+0 default-secmode security-mode
+s" " default-string security-password
+0 default-int selftest-#megs
+false default-flag use-nvramrc?
+
+set-defaults
diff --git a/fs/find-hash.fs b/fs/find-hash.fs
new file mode 100644
index 0000000..31ee66f
--- /dev/null
+++ b/fs/find-hash.fs
@@ -0,0 +1,30 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ A simple little hash table, to speed up compiling. Quite important if
+\ running on a CPU emulator; on real hardware, not so.
+
+CREATE name-hash 20 cells allot
+: clean-hash name-hash 20 cells erase ;
+clean-hash
+
+: hash ( str len -- hash ) swap c@ xor 1f and cells name-hash + ;
+: hash-find ( str len head -- 0 | link )
+ >r 2dup 2dup hash
+ dup >r @ dup IF link>name name>string string=ci ELSE nip nip THEN
+ IF 2drop r> @ r> drop exit THEN
+ r> r> swap >r ((find))
+ dup IF dup r> ! ELSE r> drop THEN ;
+: hash-reveal hash off ;
+' hash-reveal to (reveal)
+' hash-find to (find)
diff --git a/fs/hw/8111.fs b/fs/hw/8111.fs
new file mode 100644
index 0000000..a570419
--- /dev/null
+++ b/fs/hw/8111.fs
@@ -0,0 +1,114 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ AMD 8111 I/O hub.
+
+\ See the documentation at http://www.amd.com ; the datasheet for this chip is
+\ document #24674.
+
+
+\ First, some master config. Not all of this logically belongs to just
+\ one function, and certainly not to the LPC bridge; also, we'll
+\ initialize all functions in "downstream" order, and this code has to be
+\ run first. So do it now.
+
+00 2042 config-b!
+03 2048 config-b! \ Enable LPC, IDE; disable I2C, SMM, AC'97 functions.
+00 2049 config-b! \ Disable everything on second bus (USB, 100Mb enet).
+
+01 204b config-b! \ Enable IO-APIC.
+30 fec00000 rb! 0000a010 fec00010 rl!-le
+31 fec00000 rb! ff000000 fec00010 rl!-le
+32 fec00000 rb! 0000a011 fec00010 rl!-le
+33 fec00000 rb! ff000000 fec00010 rl!-le
+34 fec00000 rb! 0000a012 fec00010 rl!-le
+35 fec00000 rb! ff000000 fec00010 rl!-le
+36 fec00000 rb! 0000a013 fec00010 rl!-le
+37 fec00000 rb! ff000000 fec00010 rl!-le \ Set PCI IRQs as 10..13.
+ \ Leave ISA IRQs disabled.
+
+
+\ Device A, function 0: PCI bridge.
+
+\ We show this bridge in the device-tree, for completeness, as it is
+\ impossible to completely disable this device; we don't assign any
+\ address space to it though, or enable any transactions through it.
+\ Maybe later we want to support the USB functions on its secondary
+\ side; but not now.
+
+new-device s" /ht/pci@3" full-name
+
+s" pci" 2dup device-name device-type
+
+: open true ;
+: close ;
+
+finish-device
+
+
+\ Device B, function 0: LPC bridge.
+
+new-device s" /ht/isa@4" full-name
+
+\ See the "ISA/EISA/ISA-PnP" OF binding document.
+
+s" isa" 2dup device-name device-type
+\ We have to say it's ISA i.s.o. LPC, as otherwise Linux can't find
+\ the serial port for its console. Linux uses the name instead of the
+\ device type (and it completely ignores any "compatible" property).
+
+\ 64kB of ISA I/O space, at PCI devfn 4:0.
+1 encode-int 0 encode-int+
+01002000 encode-int+ 0 encode-int+ 0 encode-int+
+10000 encode-int+ s" ranges" property
+
+: open true ;
+: close ;
+
+\ There's a SIO chip on the LPC bus.
+INCLUDE hw/sio.fs
+
+finish-device
+
+
+\ Device B, function 1: ATA controller.
+
+new-device s" /ht/ata@4,1" full-name
+
+s" ata" 2dup device-name device-type
+s" ide" compatible
+
+2108 dup config-l@ 500 or swap config-l! \ Enable native PCI mode.
+2104 dup config-l@ 5 or swap config-l! \ Enable I/O, bus master.
+2140 dup config-l@ 03 or swap config-l! \ Enable both ports.
+10 213c config-b! \ Set IRQ#.
+
+: open true ;
+: close ;
+
+\ Just assume there is always one disk.
+INCLUDE hw/disk.fs
+
+\ Enable HPET at address fe000000.
+fe000001 20a0 config-l!
+
+: >hpet fe000000 + ;
+: hpet@ >hpet rl@-le ;
+: hpet! >hpet rl!-le ;
+
+INCLUDE hw/freq.fs
+
+\ Disable HPET.
+0 20a0 config-l!
+
+finish-device
diff --git a/fs/hw/8131.fs b/fs/hw/8131.fs
new file mode 100644
index 0000000..3cc1d51
--- /dev/null
+++ b/fs/hw/8131.fs
@@ -0,0 +1,111 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ AMD 8131 dual PCI-X bridge with tunnel.
+
+\ See the documentation at http://www.amd.com ; the datasheet for this chip is
+\ document #24637.
+
+
+\ Device A, function 0: PCI-X bridge.
+
+new-device s" /ht/pci-x@1" full-name
+
+s" pci-x" 2dup device-name device-type
+s" pci" compatible
+
+07 0804 config-b! \ Enable master, memory, I/O.
+00 0818 config-b! \ Set primary bus#.
+10 0819 config-b! \ Set secondary bus#.
+1f 081a config-b! \ Set subordinate bus#.
+f000 081c config-l! 00010001 0830 config-l! \ Set I/O space: 64kB @ 10000.
+9ff09000 0820 config-l! \ Set memory space: 256MB @ 90000000.
+
+: open true ;
+: close ;
+
+\ This is the JS20 extension card slot; we assume there is nothing there.
+
+finish-device
+
+
+\ Device A, function 1: IO-APIC.
+
+new-device s" /ht/io-apic@1,1" full-name
+
+s" io-apic" 2dup device-name device-type
+
+03 0944 config-b! \ Enable IO-APIC.
+06 0904 config-b! \ Enable IRQ generation and memory space.
+fec01000 0948 config-l! 0 094c config-l! \ Set APIC address.
+10 fec01000 rb! 0000a018 fec01010 rl!-le
+11 fec01000 rb! ff000000 fec01010 rl!-le
+12 fec01000 rb! 0000a019 fec01010 rl!-le
+13 fec01000 rb! ff000000 fec01010 rl!-le
+14 fec01000 rb! 0000a01a fec01010 rl!-le
+15 fec01000 rb! ff000000 fec01010 rl!-le
+16 fec01000 rb! 0000a01b fec01010 rl!-le
+17 fec01000 rb! ff000000 fec01010 rl!-le \ Set IRQs as 18..1b.
+
+: open true ;
+: close ;
+
+finish-device
+
+
+\ Device B, function 0: PCI-X bridge.
+
+new-device s" /ht/pci-x@2" full-name
+
+s" pci-x" 2dup device-name device-type
+s" pci" compatible
+
+07 1004 config-b! \ Enable master, memory, I/O.
+00 1018 config-b! \ Set primary bus#.
+20 1019 config-b! \ Set secondary bus#.
+2f 101a config-b! \ Set subordinate bus#.
+f000 101c config-l! 00020002 1030 config-l! \ Set I/O space: 64kB @ 20000.
+aff0a000 1020 config-l! \ Set memory space: 256MB @ a0000000.
+
+: open true ;
+: close ;
+
+\ This PCI-X bus is where the dual Gb ethernet is connected.
+
+INCLUDE hw/enet.fs
+
+finish-device
+
+
+\ Device B, function 1: IO-APIC.
+
+new-device s" /ht/io-apic@2,1" full-name
+
+s" io-apic" 2dup device-name device-type
+
+03 1144 config-b! \ Enable IO-APIC.
+06 1104 config-b! \ Enable IRQ generation and memory space.
+fec02000 1148 config-l! 0 114c config-l! \ Set APIC address.
+10 fec02000 rb! 0000a01c fec02010 rl!-le
+11 fec02000 rb! ff000000 fec02010 rl!-le
+12 fec02000 rb! 0000a01d fec02010 rl!-le
+13 fec02000 rb! ff000000 fec02010 rl!-le
+14 fec02000 rb! 0000a01e fec02010 rl!-le
+15 fec02000 rb! ff000000 fec02010 rl!-le
+16 fec02000 rb! 0000a01f fec02010 rl!-le
+17 fec02000 rb! ff000000 fec02010 rl!-le \ Set IRQs as 1c..1f.
+
+: open true ;
+: close ;
+
+finish-device
diff --git a/fs/hw/cpu.fs b/fs/hw/cpu.fs
new file mode 100644
index 0000000..a73dec4
--- /dev/null
+++ b/fs/hw/cpu.fs
@@ -0,0 +1,31 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ CPU node. Pretty minimal...
+
+: create-cpu-node ( cpu# -- )
+ new-device
+ dup s" /cpus/cpu@" rot (u.) $cat full-name
+
+ s" cpu" 2dup device-name device-type
+ encode-int s" reg" property
+
+ tb-frequency encode-int s" timebase-frequency" property
+ cpu-frequency encode-int s" clock-frequency" property
+
+ 8000 encode-int s" d-cache-size" property
+ 80 encode-int s" d-cache-line-size" property
+ 10000 encode-int s" i-cache-size" property
+ 80 encode-int s" i-cache-line-size" property
+
+ finish-device ;
diff --git a/fs/hw/dart.fs b/fs/hw/dart.fs
new file mode 100644
index 0000000..405d33e
--- /dev/null
+++ b/fs/hw/dart.fs
@@ -0,0 +1,27 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ CPC925 DART.
+
+new-device s" /dart" full-name
+
+s" dart" 2dup device-name device-type
+s" u3-dart" compatible
+
+0 encode-int f8033000 encode-int+
+0 encode-int+ 7000 encode-int+ s" reg" property
+
+: open true ;
+: close ;
+
+finish-device
diff --git a/fs/hw/disk.fs b/fs/hw/disk.fs
new file mode 100644
index 0000000..addb885
--- /dev/null
+++ b/fs/hw/disk.fs
@@ -0,0 +1,78 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ ATA disk.
+
+\ We run it at PIO mode 0; this is a) not too slow for the sizes we have to
+\ handle, and b) works with all disks.
+\ We assume there is a disk drive connected; however, if not, nothing will
+\ crash.
+
+new-device s" /ht/ata@4,1/disk" full-name
+
+s" disk" device-name s" block" device-type
+
+: open true ;
+: close ;
+
+\ Some register access helpers.
+: ata-ctrl! 3f6 io-c! ; \ device control reg
+: ata-data@ 1f0 io-w@ ; \ data reg
+: ata-cnt! 1f2 io-c! ; \ sector count reg
+: ata-lbal! 1f3 io-c! ; \ lba low reg
+: ata-lbam! 1f4 io-c! ; \ lba mid reg
+: ata-lbah! 1f5 io-c! ; \ lba high reg
+: ata-dev! 1f6 io-c! ; \ device reg
+: ata-cmd! 1f7 io-c! ; \ command reg
+: ata-stat@ 1f7 io-c@ ; \ status reg
+
+\ Init controller; we use the master device only.
+02 ata-ctrl!
+00 ata-dev!
+
+CREATE sector 200 allot
+
+: wait-for-ready BEGIN ata-stat@ 80 and WHILE REPEAT ;
+: pio-sector ( addr -- ) 100 0 DO ata-data@ over w! wa1+ LOOP drop ;
+: pio-sector ( addr -- ) wait-for-ready pio-sector ;
+: pio-sectors ( n addr -- ) swap 0 ?DO dup pio-sector 200 + LOOP drop ;
+: read-ident ec ata-cmd! 1 sector pio-sectors ;
+
+read-ident sector d# 54 + d# 40 wbflips
+cr .( Disk drive identifies as: ) sector d# 54 + d# 40 type
+
+: lba! lbsplit f and 40 or ata-dev! ata-lbah! ata-lbam! ata-lbal! ;
+: read-sectors ( lba count addr -- )
+ >r dup >r ata-cnt! lba! 20 ata-cmd! r> r> pio-sectors ;
+: read-sectors ( lba count addr -- )
+ BEGIN >r dup 100 > WHILE
+ over 100 R@ read-sectors
+ >r 100 + r> 100 - r> 20000 + REPEAT
+ r> read-sectors ;
+
+' read-sectors to disk-read
+200 CONSTANT block-size
+0 VALUE disk-offset
+CREATE deblock 20000 allot
+
+: seek ( lo hi -- status ) 20 lshift or to disk-offset 1 ;
+
+: read ( str len -- len' ) \ max 20000 bytes
+ disk-offset 200 / over disk-offset + 1ff + 200 / over - deblock disk-read
+ >r deblock disk-offset 1ff and + swap r@ move r>
+ disk-offset over + to disk-offset ;
+
+: read ( str len -- len' )
+ dup >r BEGIN dup WHILE 2dup 20000 min read tuck - >r + r> REPEAT 2drop r> ;
+
+finish-device
diff --git a/fs/hw/enet.fs b/fs/hw/enet.fs
new file mode 100644
index 0000000..4472c25
--- /dev/null
+++ b/fs/hw/enet.fs
@@ -0,0 +1,46 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Dual Gb Ethernet controller.
+
+\ Function 0.
+
+new-device s" /ht/pci-x@2/enet@1" full-name
+
+s" enet" 2dup device-name device-type
+
+07 200804 config-b! \ Enable master, memory, I/O.
+a0000000 200810 config-l! 0 200814 config-l!
+a0010000 200818 config-l! 0 20081c config-l! \ Set memory ranges: twice 64kB
+ \ @ a0000000 and @ a0010000.
+1c 20083c config-b! \ Set IRQ#.
+
+: open true ;
+: close ;
+
+finish-device
+
+
+\ Function 1.
+
+new-device s" /ht/pci-x@2/enet@1,1" full-name
+
+s" enet" 2dup device-name device-type
+
+07 200904 config-b! \ Enable master, memory, I/O.
+a0020000 200910 config-l! 0 200914 config-l!
+a0030000 200918 config-l! 0 20091c config-l! \ Set memory ranges: twice 64kB
+ \ @ a0020000 and @ a0030000.
+1d 20093c config-b! \ Set IRQ#.
+
+finish-device
diff --git a/fs/hw/freq.fs b/fs/hw/freq.fs
new file mode 100644
index 0000000..38a0033
--- /dev/null
+++ b/fs/hw/freq.fs
@@ -0,0 +1,40 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Use the HPET to calculate various frequencies.
+
+\ Make HPET run.
+1 10 hpet!
+
+\ Set PMC1 to count CPU cycles.
+f00 mmcr0!
+
+d# 1000000000000000 4 hpet@ / CONSTANT hpet-freq
+
+: get-times tbl@ pmc1@ f0 hpet@ ;
+
+\ Calculate the CPU and TB frequencies.
+: calibrate get-times dup >r swap >r swap >r hpet-freq d# 100 / + >r
+ BEGIN get-times dup r@ < WHILE 3drop REPEAT r> drop
+ rot r> - ffffffff and \ TB
+ rot r> - ffffffff and \ CPU
+ rot r> - >r \ HPET
+ hpet-freq * r@ / swap
+ hpet-freq * r> / ;
+
+: round-to tuck 2/ + over / * ;
+calibrate ( d# 1000000 round-to) TO tb-frequency
+ ( d# 10000000 round-to) TO cpu-frequency
+
+\ Stop HPET.
+0 10 hpet!
diff --git a/fs/hw/ht.fs b/fs/hw/ht.fs
new file mode 100644
index 0000000..837280b
--- /dev/null
+++ b/fs/hw/ht.fs
@@ -0,0 +1,62 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Hypertransport.
+
+\ See the PCI OF binding document.
+
+new-device s" /ht" full-name
+
+s" ht" 2dup device-name device-type
+s" u3-ht" compatible
+s" U3" encode-string s" model" property
+
+3 encode-int s" #address-cells" property
+2 encode-int s" #size-cells" property
+
+\ 16MB of configuration space, seperate for type 0 and type 1.
+00000000 encode-int f2000000 encode-int+
+00000000 encode-int+ 02000000 encode-int+ s" reg" property
+
+\ 4MB of I/O space.
+01000000 encode-int 00000000 encode-int+ 00000000 encode-int+
+00000000 encode-int+ f4000000 encode-int+
+00000000 encode-int+ 00400000 encode-int+
+
+\ 1.75GB of memory space @ 80000000.
+02000000 encode-int+ 00000000 encode-int+ 80000000 encode-int+
+00000000 encode-int+ 80000000 encode-int+
+00000000 encode-int+ 70000000 encode-int+ s" ranges" property
+
+\ Host bridge, so full bus range.
+0 encode-int ff encode-int+ s" bus-range" property
+
+: enable-ht-apic-space 0 5 oco drop ;
+enable-ht-apic-space
+
+\ This works for the AMD devices; should walk PCI capabilities list
+\ to be more portable.
+: assign-buid ( this -- next )
+ 00c2 config-w@ 5 rshift over 00c2 config-w! + ;
+: assign-buids
+ 1 BEGIN 0 config-l@ ffffffff <> WHILE assign-buid REPEAT drop ;
+assign-buids
+
+: open true ;
+: close ;
+
+\ The devices on our HT chain
+INCLUDE hw/8131.fs
+INCLUDE hw/8111.fs
+
+finish-device
diff --git a/fs/hw/io.fs b/fs/hw/io.fs
new file mode 100644
index 0000000..3d55493
--- /dev/null
+++ b/fs/hw/io.fs
@@ -0,0 +1,49 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ I/O accesses.
+
+\ Little-endian accesses. Also known as `wrong-endian'.
+: l!-le >r lbflip r> l! ;
+: l@-le l@ lbflip ;
+
+: w!-le >r wbflip r> w! ;
+: w@-le w@ wbflip ;
+
+: rl!-le >r lbflip r> rl! ;
+: rl@-le rl@ lbflip ;
+
+: rw!-le >r wbflip r> rw! ;
+: rw@-le rw@ wbflip ;
+
+\ Legacy I/O accesses.
+: >io f4000000 + ;
+
+: io-c! >io rb! ;
+: io-c@ >io rb@ ;
+
+: io-w! >io rw! ;
+: io-w@ >io rw@ ;
+
+\ Accessing the SIO config registers.
+: siocfg! 2e io-c! 2f io-c! ;
+: siocfg@ 2e io-c! 2f io-c@ ;
+
+\ Configuration space accesses.
+: >config dup ffff > IF 1000000 + THEN f2000000 + ;
+: config-l! >config rl!-le ;
+: config-l@ >config rl@-le ;
+: config-w! >config rw!-le ;
+: config-w@ >config rw@-le ;
+: config-b! >config rb! ;
+: config-b@ >config rb@ ;
diff --git a/fs/hw/memory.fs b/fs/hw/memory.fs
new file mode 100644
index 0000000..b9383da
--- /dev/null
+++ b/fs/hw/memory.fs
@@ -0,0 +1,36 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ The /memory node.
+
+\ See 3.7.6.
+new-device s" /memory" full-name
+
+s" memory" 2dup device-name device-type
+
+: mem-size 0 4 oco ;
+
+: encode-our-reg
+ 0 encode-int 0 encode-int+
+ mem-size dup >r 80000000 > IF
+ 0 encode-int+ 80000000 encode-int+
+ 1 encode-int+ 0 encode-int+ r> 80000000 - >r THEN
+ r@ 20 rshift encode-int+ r> ffffffff and encode-int+ ;
+encode-our-reg s" reg" property
+
+: mem-report
+ base @ decimal cr mem-size 1e rshift 0 .r
+ mem-size 3fffffff and IF ." .5" THEN ." GB of RAM detected." base ! ;
+mem-report
+
+finish-device
diff --git a/fs/hw/mpic.fs b/fs/hw/mpic.fs
new file mode 100644
index 0000000..5b46004
--- /dev/null
+++ b/fs/hw/mpic.fs
@@ -0,0 +1,28 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+new-device s" /mpic" full-name
+
+s" mpic" device-name s" interrupt-controller" device-type
+s" open-pic" compatible
+
+0 encode-int f8040000 encode-int+
+0 encode-int+ 30000 encode-int+ s" reg" property
+
+: enable-mpic 0 6 oco drop ;
+enable-mpic
+
+: open true ;
+: close ;
+
+finish-device
diff --git a/fs/hw/serial.fs b/fs/hw/serial.fs
new file mode 100644
index 0000000..b794a1c
--- /dev/null
+++ b/fs/hw/serial.fs
@@ -0,0 +1,33 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Serial console. Enabled very early.
+
+: >serial 3f8 + ;
+: serial! >serial io-c! ;
+: serial@ >serial io-c@ ;
+
+: serial-init 0 1 serial! 0 2 serial!
+ 80 3 serial! d# 115200 swap / 0 serial! 0 1 serial!
+ 3 3 serial! 3 4 serial! ;
+: serial-emit BEGIN 5 serial@ 20 and UNTIL 0 serial! ;
+: serial-key BEGIN 5 serial@ 1 and UNTIL 0 serial@ ;
+: serial-key? 5 serial@ 1 and 0<> ;
+
+d# 19200 serial-init
+' serial-emit to emit
+' serial-key to key
+' serial-key? to key?
+
+( .( SLOF)
+.( has started execution, serial console enabled.)
diff --git a/fs/hw/sio.fs b/fs/hw/sio.fs
new file mode 100644
index 0000000..c7fa2fe
--- /dev/null
+++ b/fs/hw/sio.fs
@@ -0,0 +1,63 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ National Semiconductor SIO.
+\ See http://www.national.com/pf/PC/PC87417.html for the datasheet.
+
+\ We only use the first serial port, and the RTC.
+
+\ See 3.7.5.
+new-device s" /ht/isa@4/serial" full-name
+
+s" serial" 2dup device-name device-type
+
+\ 8 bytes of ISA I/O space
+1 encode-int 0 >serial encode-int+ 8 encode-int+ s" reg" property
+d# 19200 encode-int s" current-speed" property
+
+: open true ;
+: close ;
+: write ( adr len -- actual ) tuck type ;
+: read ( adr len -- actual ) IF key swap c! 1 ELSE 0 THEN ;
+
+finish-device
+
+
+
+\ See the "Device Support Extensions" OF Recommended Practice document.
+new-device s" /ht/isa@4/rtc" full-name
+
+s" rtc" 2dup device-name device-type
+\ Following is for Linux, to recognize this RTC:
+s" pnpPNP,b00" compatible
+
+\ Enable the RTC, set its address at 1070.
+10 7 siocfg! 1 30 siocfg! 10 60 siocfg! 10 62 siocfg!
+
+: rtc! 1070 io-c! 1071 io-c! ;
+: rtc@ 1070 io-c! 1071 io-c@ ;
+
+\ 10 bytes of ISA I/O space, at 1070.
+1 encode-int 1070 encode-int+ 10 encode-int+ s" reg" property
+
+\ Set sane configuration; BCD mode is required by Linux.
+20 0a rtc! 02 0b rtc! 00 0c rtc!
+
+: open true ;
+: close ;
+
+\ XXX: dummy methods.
+: get-time ( -- sec min hr day mth yr ) 0 0 0 1 1 d# 1973 ;
+: set-time ( sec min hr day mth yr -- ) 3drop 3drop ;
+
+finish-device
diff --git a/fs/instance.fs b/fs/instance.fs
new file mode 100644
index 0000000..f5b480b
--- /dev/null
+++ b/fs/instance.fs
@@ -0,0 +1,94 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Support for device node instances.
+
+0 VALUE my-self
+
+\ Instance-init is a linked list, before finish-package.
+\ entry format: offset in instance, link, initial value.
+\ after finish-package it's a pointer to a memory block
+\ that is copied verbatim for every instance.
+\ This will have to be revisited, as it is not quite right:
+\ an instance variable can be used before the package is
+\ completed.
+
+: (create-instance-var) ( "name" initial-value link-addr size-addr -- )
+ CREATE dup @ , 1 cells swap +! linked , ;
+
+: create-instance-var ( "name" initial-value -- )
+ current-package @ dup pkg>instance-init swap pkg>instance-size
+ (create-instance-var) PREVIOUS DEFINITIONS ;
+
+: >instance my-self + ;
+
+VOCABULARY instance-words ALSO instance-words DEFINITIONS
+
+: VARIABLE 0 create-instance-var DOES> @ >instance ;
+: VALUE create-instance-var DOES> @ >instance @ ;
+: DEFER 0 create-instance-var DOES> @ >instance @ execute ;
+\ No support for BUFFER: yet.
+
+PREVIOUS DEFINITIONS
+
+: INSTANCE current-package @ 0= ABORT" No current package"
+ ALSO instance-words ;
+
+VARIABLE shared-instance-link
+VARIABLE shared-instance-size
+
+: SIVARIABLE 0 shared-instance-link shared-instance-size (create-instance-var)
+ DOES> @ >instance ;
+
+VOCABULARY shared-instance-vars ALSO shared-instance-vars DEFINITIONS
+
+SIVARIABLE the-package \ needs to be first!
+SIVARIABLE the-parent
+SIVARIABLE the-addr
+SIVARIABLE the-addr1
+SIVARIABLE the-addr2
+SIVARIABLE the-args
+SIVARIABLE the-args-len
+
+PREVIOUS DEFINITIONS
+: shared-instance-words ['] shared-instance-vars >body cell+ @ ;
+
+
+ALSO shared-instance-vars
+
+: my-parent the-parent @ ;
+: my-args the-args 2@ ;
+: set-my-args dup alloc-mem swap 2dup the-args 2! move ;
+
+\ Current package has already been set, when this is called.
+: create-instance-data ( -- instance )
+ current-package @ dup pkg>instance-init @ swap pkg>instance-size @
+ dup alloc-mem dup >r swap move r> ;
+: create-instance my-self create-instance-data to my-self the-parent !
+ current-package @ the-package ! ;
+: destroy-instance ( instance -- )
+ dup @ pkg>instance-size @ free-mem ;
+
+PREVIOUS
+
+
+: ihandle>phandle @ ;
+
+: push-my-self ( ihandle -- ) r> my-self >r >r to my-self ;
+: pop-my-self ( -- ) r> r> to my-self >r ;
+: call-package push-my-self execute pop-my-self ;
+: $call-my-method ( str len -- ) my-self ihandle>phandle find-method
+ 0= ABORT" no such method" execute ;
+: $call-method push-my-self $call-my-method pop-my-self ;
+: $call-parent my-parent $call-method ;
+
diff --git a/fs/js20-tree.fs b/fs/js20-tree.fs
new file mode 100644
index 0000000..6063637
--- /dev/null
+++ b/fs/js20-tree.fs
@@ -0,0 +1,86 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ The root of the device tree and some of its kids.
+
+new-device s" /" full-name
+
+s" /" device-name
+2 encode-int s" #address-cells" property
+2 encode-int s" #size-cells" property
+
+\ XXX: what requires this? Linux?
+0 encode-int f8040000 encode-int+
+0 encode-int+ f8050000 encode-int+ s" platform-open-pic" property
+
+\ Yaboot is stupid. Without this, it can't/won't find /etc/yaboot.conf.
+s" chrp we are not, but smart yaboot is not" device-type
+
+\ To get linux-2.6.10 and later to work out-of-the-box.
+s" Momentum,Maple" compatible
+
+: open true ;
+: close ;
+
+\ See 3.5.
+new-device s" /openprom" full-name
+s" openprom" device-name
+s" SlimLine Open Firmware (SLOF) version 0.0" encode-string s" model" property
+0 0 s" relative-addressing" property
+finish-device
+
+\ See 3.5.
+new-device s" /chosen" full-name
+s" chosen" device-name
+finish-device
+
+\ See 3.6.5, and the PowerPC OF binding document.
+new-device s" /mmu" full-name
+s" mmu" 2dup device-name device-type
+0 0 s" translations" property
+finish-device
+
+INCLUDE hw/memory.fs
+INCLUDE hw/mpic.fs
+INCLUDE hw/dart.fs
+INCLUDE hw/ht.fs
+
+\ See the PowerPC OF binding document.
+new-device s" /cpus" full-name
+s" cpus" device-name
+1 encode-int s" #address-cells" property
+0 encode-int s" #size-cells" property
+
+INCLUDE hw/cpu.fs
+: create-cpu-nodes
+ master-cpu create-cpu-node
+ slave? IF master-cpu 1 xor create-cpu-node THEN ;
+create-cpu-nodes
+
+finish-device
+
+finish-device
+
+
+
+: set-chosen ( prop len name len -- )
+ s" /chosen" find-package drop set-property ;
+
+master-cpu s" /cpus/cpu@" rot (u.) $cat open-dev encode-int s" cpu" set-chosen
+s" /memory" open-dev encode-int s" memory" set-chosen
+s" /mmu" open-dev encode-int s" mmu" set-chosen
+
+: io open-dev dup encode-int s" stdout" set-chosen
+ encode-int s" stdin" set-chosen ;
+
+s" /ht/isa@4/serial" io
diff --git a/fs/main.fs b/fs/main.fs
new file mode 100644
index 0000000..3bfd90a
--- /dev/null
+++ b/fs/main.fs
@@ -0,0 +1,187 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ The master file. Everything else is included into here.
+
+hex
+
+\ Speed up compiling.
+INCLUDE find-hash.fs
+
+\ Enable use of multiple wordlists and vocabularies.
+INCLUDE search.fs
+
+\ Heap memory allocation.
+INCLUDE alloc-mem.fs
+
+\ First some very generic code.
+: d# parse-word base @ >r decimal evaluate r> base ! ; immediate
+: END-STRUCT drop ;
+: 0.r 0 swap <# 0 ?DO # LOOP #> type ;
+
+: zcount ( zstr -- str len ) dup BEGIN dup c@ WHILE char+ REPEAT over - ;
+: zplace ( str len buf -- ) 2dup + 0 swap c! swap move ;
+
+CREATE $catpad 100 allot
+\ First input string is allowed to already be on the pad; second is not.
+: $cat ( str1 len1 str2 len2 -- str3 len3 )
+ >r >r dup >r $catpad swap move
+ r> dup $catpad + r> swap r@ move
+ r> + $catpad swap ;
+
+: 2CONSTANT CREATE swap , , DOES> 2@ ;
+: $2CONSTANT $CREATE swap , , DOES> 2@ ;
+
+\ Memory and I/O hexdump.
+INCLUDE dump.fs
+
+\ I/O accesses.
+INCLUDE hw/io.fs
+
+\ Start the serial console.
+INCLUDE hw/serial.fs
+
+\ Input line editing.
+INCLUDE accept.fs
+
+\ Register frame layout.
+STRUCT
+ cell FIELD >r0 cell FIELD >r1 cell FIELD >r2 cell FIELD >r3
+ cell FIELD >r4 cell FIELD >r5 cell FIELD >r6 cell FIELD >r7
+ cell FIELD >r8 cell FIELD >r9 cell FIELD >r10 cell FIELD >r11
+ cell FIELD >r12 cell FIELD >r13 cell FIELD >r14 cell FIELD >r15
+ cell FIELD >r16 cell FIELD >r17 cell FIELD >r18 cell FIELD >r19
+ cell FIELD >r20 cell FIELD >r21 cell FIELD >r22 cell FIELD >r23
+ cell FIELD >r24 cell FIELD >r25 cell FIELD >r26 cell FIELD >r27
+ cell FIELD >r28 cell FIELD >r29 cell FIELD >r30 cell FIELD >r31
+ cell FIELD >cr cell FIELD >xer cell FIELD >lr cell FIELD >ctr
+ cell FIELD >srr0 cell FIELD >srr1 cell FIELD >dar cell FIELD >dsisr
+END-STRUCT
+
+1100000 CONSTANT eregs \ Exception register frame.
+1100400 CONSTANT ciregs \ Client (interface) register frame.
+
+\ Print out an exception frame, e.g., eregs .regs
+: .16 10 0.r 3 spaces ;
+: .8 8 spaces 8 0.r 3 spaces ;
+: .4regs cr 4 0 DO dup @ .16 8 cells+ LOOP drop ;
+: .fixed-regs
+ cr ." R0 .. R7 R8 .. R15 R16 .. R23 R24 .. R31"
+ dup 8 0 DO dup .4regs cell+ LOOP drop ;
+: .special-regs
+ cr ." CR / XER LR / CTR SRR0 / SRR1 DAR / DSISR"
+ cr dup >cr @ .8 dup >lr @ .16 dup >srr0 @ .16 dup >dar @ .16
+ cr dup >xer @ .16 dup >ctr @ .16 dup >srr1 @ .16 >dsisr @ .8 ;
+: .regs
+ cr .fixed-regs
+ cr .special-regs
+ cr cr ;
+
+\ Some low-level functions -- no source code provided, sorry.
+: reboot 0 1 oco ;
+: halt 0 2 oco ;
+: watchdog 3 oco ;
+: other-firmware 1 watchdog ;
+
+\ Get the second CPU into our own spinloop.
+0 VALUE slave?
+0 7 oco CONSTANT master-cpu
+cr .( The master cpu is #) master-cpu .
+: get-slave ( addr -- ) 0 oco 1 = IF true to slave? THEN ;
+: slave-report cr slave? IF ." Second CPU is running." ELSE
+ ." Second CPU is NOT running!" THEN ;
+3f00 get-slave slave-report
+
+\ Packages, instances, properties, devices, methods -- the whole shebang.
+INCLUDE package.fs
+
+\ Environment variables. Not actually used right now.
+INCLUDE envvar.fs
+
+\ Hook to help loading our secondary boot loader.
+DEFER disk-read ( lba cnt addr -- )
+
+\ Timebase frequency, in Hz.
+-1 VALUE tb-frequency
+-1 VALUE cpu-frequency
+
+\ The device tree.
+INCLUDE js20-tree.fs
+
+\ The client interface.
+INCLUDE client.fs
+
+\ ELF binary file format.
+INCLUDE elf.fs
+
+\ Give our client a stack.
+111f000 ciregs >r1 !
+
+\ Run the client program.
+: start-elf ( entry-addr -- ) msr@ 7fffffffffffffff and 2000 or ciregs >srr1 !
+ 0 0 rot call-client ;
+: start-elf64 ( entry-addr -- ) msr@ 2000 or ciregs >srr1 !
+ 0 0 rot call-client ;
+
+\ Where files are loaded. Not the same as where they are executed.
+10000 CONSTANT load-base
+\ Load secondary boot loader from disk @ sector 63. 512kB should be enough.
+: read-yaboot 3f 400 load-base disk-read ;
+
+: yaboot
+ cr ." Reading..." read-yaboot
+ ." relocating..." load-base load-elf-file
+ ." go!" start-elf ;
+
+: set-bootpart ( -- )
+ skipws 0 parse s" disk:" 2swap $cat
+ encode-string s" bootpath" set-chosen ;
+
+: set-bootargs
+ skipws 0 parse dup 0= IF 2drop ELSE
+ encode-string s" bootargs" set-chosen THEN ;
+: etherboot s" enet:" set-bootargs payload dup load-elf-file start-elf ;
+: go etherboot ;
+
+\ Default bootpath
+
+s" disk:3" encode-string s" bootpath" set-chosen
+
+: boot set-bootargs yaboot ;
+
+: auto
+ key? IF clear c emit key drop QUIT THEN
+ cr ." Netboot -- to drop into GUI instead, please hold a key while starting"
+ cr
+ payload dup load-elf-file start-elf ;
+
+: disable-boot-watchdog
+ 0 watchdog IF cr ." Failed to disable boot watchdog." THEN ;
+
+disable-boot-watchdog
+
+cr
+cr
+cr .( SLOF version 0.0 Copyright 2004,2005 IBM Corporation)
+cr .( Part of this code is:)
+cr
+cr .( Licensed Internal Code - Property of IBM)
+cr .( JS20 Licensed Internal Code)
+cr .( (C) char ) emit .( Copyright IBM Corp. 2004, 2005 All Rights Reserved.)
+cr .( US Government Users Restricted Rights - Use, duplication or)
+cr .( disclosure restricted by GSA ADP Schedule Contract with IBM)
+cr
+cr
+
+\ Enable this if you want your system to automatically boot by default:
+\ auto
diff --git a/fs/package.fs b/fs/package.fs
new file mode 100644
index 0000000..9a26fda
--- /dev/null
+++ b/fs/package.fs
@@ -0,0 +1,141 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Packages.
+
+VARIABLE device-tree
+VARIABLE current-package
+
+STRUCT
+ cell FIELD pkg>peer
+ cell FIELD pkg>parent
+ cell FIELD pkg>child
+ cell FIELD pkg>properties
+ cell FIELD pkg>words
+ cell FIELD pkg>instance-init
+ cell FIELD pkg>instance-size
+END-STRUCT
+
+: find-method ( str len phandle -- false | xt true )
+ pkg>words @ voc-find dup IF link> true THEN ;
+
+\ Instances.
+INCLUDE instance.fs
+
+: create-package ( parent -- new )
+ align wordlist >r wordlist >r
+ here 0 , swap , 0 , r> , r@ ,
+ shared-instance-link @ , shared-instance-size @ ,
+ shared-instance-words r> cell+ ! ;
+
+: peer pkg>peer @ ;
+: parent pkg>parent @ ;
+: child pkg>child @ ;
+: peer dup IF peer ELSE drop device-tree @ THEN ;
+
+
+: link ( new head -- ) \ link a new node at the end of a linked list
+ BEGIN dup @ WHILE @ REPEAT ! ;
+: link-package ( parent child -- )
+ swap dup IF pkg>child link ELSE drop device-tree ! THEN ;
+
+\ Set a package as active package.
+: set-package ( phandle -- )
+ current-package @ IF previous THEN
+ dup current-package !
+ ?dup IF pkg>words @ also context ! THEN
+ definitions ;
+
+: new-package ( -- phandle ) \ active package becomes new package's parent;
+ \ new package becomes active package
+ current-package @ dup create-package
+ tuck link-package dup set-package ;
+
+\ This will have to be rewritten, as mentioned in instance.fs.
+: init-instance-template ( link mem -- )
+ BEGIN over WHILE 2dup >r dup cell+ @ swap cell- @ r> + ! >r @ r> REPEAT
+ 2drop ;
+: finish-package ( -- )
+ current-package @ dup dup
+ pkg>instance-init swap pkg>instance-size @ alloc-mem
+ over @ over init-instance-template swap !
+ parent set-package ;
+
+: device-end ( -- ) 0 set-package ;
+
+
+\ Properties.
+INCLUDE property.fs
+
+
+\ Display the device tree.
+defer (ls)
+: (ls-node) ( pkg -- )
+ cr dup pkg>path type space child (ls) ;
+: ((ls)) ( pkg -- )
+ BEGIN dup WHILE dup (ls-node) peer REPEAT drop ;
+' ((ls)) to (ls)
+: ls ( -- ) \ XXX FIXME: should list nodes under current package only
+ device-tree @ (ls) ;
+
+
+\ Iterate over the tree, depth-first order.
+: next-in-dfw-up ( phandle -- phandle | 0 )
+ dup peer ?dup IF nip EXIT THEN
+ parent dup IF recurse THEN ; \ XXX FIXME: tail recurse this by hand
+: next-in-dfw ( phandle -- phandle | 0 )
+ dup child ?dup IF nip exit THEN
+ dup peer ?dup IF nip exit THEN
+ parent dup IF next-in-dfw-up THEN ;
+
+
+\ This could use some refactoring. Or a complete rewrite.
+: comp_pname ( pstr plen str len -- true | false )
+ 2 pick 1- <> IF 2drop drop false ELSE
+ swap 1- comp 0= THEN ;
+: find-package ( str len -- false | phandle true )
+ \ CHEAT: if len == 1, use the root node
+ dup 1 = IF 2drop device-tree @ true exit THEN
+ \ CHEAT: ignore everything after a colon
+ 2dup [char] : findchar IF nip THEN
+
+ device-tree @ BEGIN dup WHILE
+ s" full_name" 2 pick get-property IF
+ 4 pick 4 pick comp_pname IF nip nip true EXIT THEN THEN
+ s" name" 2 pick get-property IF
+ 4 pick 4 pick comp_pname IF nip nip true EXIT THEN THEN
+ next-in-dfw
+ REPEAT nip nip ;
+
+: open-package ( arg len phandle -- ihandle | 0 )
+ current-package @ >r set-package create-instance set-my-args
+ ( now call open, returning error code, etc )
+ my-self my-parent to my-self r> set-package ;
+: close-package ( ihandle -- )
+ ( call the close method here )
+ destroy-instance ;
+
+: open-dev ( name len -- ihandle | 0 )
+ find-package 0= IF 0 EXIT THEN my-self >r 0 to my-self
+ 0 swap BEGIN dup parent dup WHILE REPEAT drop
+ BEGIN dup WHILE >r 0 0 r> open-package to my-self REPEAT drop
+ my-self r> to my-self ;
+: close-dev ( ihandle -- )
+ my-self >r to my-self
+ BEGIN my-self WHILE my-parent my-self close-package to my-self REPEAT
+ r> to my-self ;
+
+: new-device ( -- ) new-package >r 0 0 r> open-package to my-self ;
+: finish-device ( -- )
+ ( check for "name" property here, delete this node if not there )
+ finish-package my-parent my-self close-package to my-self ;
diff --git a/fs/property.fs b/fs/property.fs
new file mode 100644
index 0000000..16ea308
--- /dev/null
+++ b/fs/property.fs
@@ -0,0 +1,67 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Properties.
+
+\ Words on the property list for a package are actually executable words,
+\ that return the address and length of the property's data. Special
+\ nodes like /options can have their properties use specialized code to
+\ dynamically generate their data; most nodes just use a 2CONSTANT.
+
+: encode-int here swap lbsplit c, c, c, c, /l ;
+: encode-bytes dup >r here >r bounds ?DO i c@ c, LOOP r> r> ;
+: encode-string encode-bytes 0 c, char+ ;
+
+: encode+ nip + ;
+: encode-int+ encode-int encode+ ;
+
+\ Remove a word from a wordlist.
+: (prune) ( name len head -- )
+ dup >r (find) ?dup IF r> BEGIN dup @ WHILE 2dup @ = IF
+ >r @ r> ! EXIT THEN @ REPEAT 2drop ELSE r> drop THEN ;
+: prune ( name len -- ) last (prune) ;
+
+: set-property ( data dlen name nlen phandle -- )
+ get-current >r pkg>properties @ set-current
+ 2dup prune $2CONSTANT r> set-current ;
+: property ( data dlen name nlen -- ) current-package @ set-property ;
+: get-property ( str len phandle -- false | data dlen true )
+ pkg>properties @ voc-find dup IF link> execute true THEN ;
+
+\ Print out properties. Just a hexdump, nothing fancy for strings etc.
+: .propbytes ( xt -- )
+ execute bounds ?DO space i c@ 2 0.r LOOP ;
+: .property ( lfa -- )
+ cr link> dup >name name>string type space .propbytes ;
+: (.properties) ( phandle -- )
+ pkg>properties @ cell+ @ BEGIN dup WHILE dup .property @ REPEAT drop ;
+: .properties ( -- )
+ current-package @ (.properties) ;
+
+: next-property ( str len phandle -- false | str' len' true )
+ ?dup 0= IF device-tree @ THEN \ XXX: is this line required?
+ pkg>properties @
+ >r 2dup 0= swap 0= or IF 2drop r> cell+ ELSE r> voc-find THEN
+ @ dup IF link>name name>string true THEN ;
+
+
+\ Helpers for common nodes. Should perhaps remove "compatible", as it's
+\ not typically a single string.
+: device-name encode-string s" name" property ;
+: device-type encode-string s" device_type" property ;
+: compatible encode-string s" compatible" property ;
+: full-name encode-string s" full_name" property ;
+
+\ Getting basic info about a package.
+: pkg>name dup >r s" name" rot get-property IF 1- r> drop ELSE r> (u.) THEN ;
+: pkg>path dup >r s" full_name" rot get-property drop 1- r> drop ;
diff --git a/fs/search.fs b/fs/search.fs
new file mode 100644
index 0000000..bacf53b
--- /dev/null
+++ b/fs/search.fs
@@ -0,0 +1,87 @@
+\ =============================================================================
+\ * Copyright (c) 2004, 2005 IBM Corporation
+\ * All rights reserved.
+\ * This program and the accompanying materials
+\ * are made available under the terms of the BSD License
+\ * which accompanies this distribution, and is available at
+\ * http://www.opensource.org/licenses/bsd-license.php
+\ *
+\ * Contributors:
+\ * IBM Corporation - initial implementation
+\ =============================================================================
+
+
+\ Copyright 2002,2003,2004 Segher Boessenkool <segher@kernel.crashing.org>
+
+\ stuff we should already have:
+
+: linked ( var -- ) here over @ , swap ! ;
+
+HEX
+
+\ \ \
+\ \ \ Wordlists
+\ \ \
+
+VARIABLE wordlists forth-wordlist wordlists !
+
+\ create a new wordlist
+: wordlist ( -- wid ) here wordlists linked 0 , ;
+
+
+\ \ \
+\ \ \ Search order
+\ \ \
+
+10 CONSTANT max-in-search-order \ should define elsewhere
+
+: also ( -- ) clean-hash context dup cell+ dup to context >r @ r> ! ;
+: previous ( -- ) clean-hash context cell- to context ;
+: only ( -- ) clean-hash search-order to context ;
+: seal ( -- ) clean-hash context @ search-order dup to context ! ;
+
+: get-order ( -- wid_n .. wid_1 n )
+ context >r search-order BEGIN dup r@ u<= WHILE
+ dup @ swap cell+ REPEAT r> drop
+ search-order - cell / ;
+: set-order ( wid_n .. wid_1 n -- ) \ XXX: special cases for 0, -1
+ clean-hash 1- cells search-order + dup to context
+ BEGIN dup search-order u>= WHILE
+ dup >r ! r> cell- REPEAT drop ;
+
+
+\ \ \
+\ \ \ Compilation wordlist
+\ \ \
+
+: get-current ( -- wid ) current ;
+: set-current ( wid -- ) to current ;
+
+: definitions ( -- ) context @ set-current ;
+
+
+\ \ \
+\ \ \ Vocabularies
+\ \ \
+
+: VOCABULARY ( C: "name" -- ) ( -- ) CREATE wordlist drop
+ DOES> clean-hash context ! ;
+\ : VOCABULARY ( C: "name" -- ) ( -- ) wordlist CREATE , DOES> @ context ! ;
+: FORTH ( -- ) clean-hash forth-wordlist context ! ;
+
+: >name ( xt -- nfa )
+ BEGIN char- dup c@ UNTIL
+ dup dup aligned - cell+ char-
+ dup >r - BEGIN dup c@ r@ <> WHILE
+ cell- r> cell+ >r REPEAT r> drop char- ;
+: .voc ( wid -- ) \ display name for wid
+ dup cell- @ ['] vocabulary ['] forth within IF
+ 2 cells - >name name>string type ELSE u. THEN space ;
+: vocs ( -- ) \ display all wordlist names
+ cr wordlists BEGIN @ dup WHILE dup .voc REPEAT drop ;
+: order ( -- )
+ cr ." context: " get-order 0 ?DO .voc LOOP
+ cr ." current: " get-current .voc ;
+
+\ Find word in specific wordlist.
+: voc-find ( wid -- 0 | link ) clean-hash cell+ @ (find) clean-hash ;
diff --git a/incs.pl b/incs.pl
new file mode 100644
index 0000000..b823fb5
--- /dev/null
+++ b/incs.pl
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+# =============================================================================
+# * Copyright (c) 2004, 2005 IBM Corporation
+# * All rights reserved.
+# * This program and the accompanying materials
+# * are made available under the terms of the BSD License
+# * which accompanies this distribution, and is available at
+# * http://www.opensource.org/licenses/bsd-license.php
+# *
+# * Contributors:
+# * IBM Corporation - initial implementation
+# =============================================================================
+
+sub one {
+ open my $f, "<fs/@_" or die "Can't open @_: $!";
+ while (<$f>) {
+ if (/^INCLUDE (.*)/) {
+ one($1);
+ } else {
+ print $_;
+ }
+ }
+ close $f;
+}
+
+one $ARGV[0];
diff --git a/linux.config.js20 b/linux.config.js20
new file mode 100644
index 0000000..24909d9
--- /dev/null
+++ b/linux.config.js20
@@ -0,0 +1,921 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.12-rc3
+# Mon May 9 12:12:54 2005
+#
+CONFIG_64BIT=y
+CONFIG_MMU=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_HAVE_DEC_LOCK=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_COMPAT=y
+CONFIG_FORCE_MAX_ZONEORDER=13
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+CONFIG_HOTPLUG=y
+CONFIG_KOBJECT_UEVENT=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+# CONFIG_CPUSETS is not set
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_OBSOLETE_MODPARM=y
+# CONFIG_MODVERSIONS is not set
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+CONFIG_SYSVIPC_COMPAT=y
+
+#
+# Platform support
+#
+# CONFIG_PPC_ISERIES is not set
+CONFIG_PPC_MULTIPLATFORM=y
+CONFIG_PPC_PSERIES=y
+# CONFIG_PPC_PMAC is not set
+CONFIG_PPC_MAPLE=y
+CONFIG_PPC=y
+CONFIG_PPC64=y
+CONFIG_PPC_OF=y
+CONFIG_ALTIVEC=y
+# CONFIG_PPC_SPLPAR is not set
+CONFIG_IBMVIO=y
+CONFIG_U3_DART=y
+CONFIG_MPIC_BROKEN_U3=y
+# CONFIG_BOOTX_TEXT is not set
+CONFIG_POWER4_ONLY=y
+CONFIG_IOMMU_VMERGE=y
+CONFIG_SMP=y
+CONFIG_NR_CPUS=2
+CONFIG_DISCONTIGMEM=y
+# CONFIG_NUMA is not set
+# CONFIG_SCHED_SMT is not set
+# CONFIG_PREEMPT is not set
+CONFIG_EEH=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_PPC_RTAS=y
+CONFIG_RTAS_PROC=y
+CONFIG_RTAS_FLASH=y
+# CONFIG_SCANLOG is not set
+# CONFIG_LPARCFG is not set
+CONFIG_SECCOMP=y
+
+#
+# General setup
+#
+CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+# CONFIG_PCI_LEGACY_PROC is not set
+CONFIG_PCI_NAMES=y
+# CONFIG_PCI_DEBUG is not set
+# CONFIG_HOTPLUG_CPU is not set
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# PCI Hotplug Support
+#
+# CONFIG_HOTPLUG_PCI is not set
+CONFIG_PROC_DEVICETREE=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="root=/dev/hda3"
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CDROM_PKTCDVD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+CONFIG_IDEDISK_MULTI_MODE=y
+# CONFIG_BLK_DEV_IDECD is not set
+# CONFIG_BLK_DEV_IDETAPE is not set
+# CONFIG_BLK_DEV_IDEFLOPPY is not set
+# CONFIG_BLK_DEV_IDESCSI is not set
+# CONFIG_IDE_TASK_IOCTL is not set
+
+#
+# IDE chipset support/bugfixes
+#
+# CONFIG_IDE_GENERIC is not set
+CONFIG_BLK_DEV_IDEPCI=y
+# CONFIG_IDEPCI_SHARE_IRQ is not set
+# CONFIG_BLK_DEV_OFFBOARD is not set
+# CONFIG_BLK_DEV_GENERIC is not set
+# CONFIG_BLK_DEV_OPTI621 is not set
+# CONFIG_BLK_DEV_SL82C105 is not set
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+CONFIG_IDEDMA_PCI_AUTO=y
+# CONFIG_IDEDMA_ONLYDISK is not set
+# CONFIG_BLK_DEV_AEC62XX is not set
+# CONFIG_BLK_DEV_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=y
+# CONFIG_BLK_DEV_CMD64X is not set
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CY82C693 is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+# CONFIG_BLK_DEV_HPT34X is not set
+# CONFIG_BLK_DEV_HPT366 is not set
+# CONFIG_BLK_DEV_SC1200 is not set
+# CONFIG_BLK_DEV_PIIX is not set
+# CONFIG_BLK_DEV_NS87415 is not set
+# CONFIG_BLK_DEV_PDC202XX_OLD is not set
+# CONFIG_BLK_DEV_PDC202XX_NEW is not set
+# CONFIG_BLK_DEV_SVWKS is not set
+# CONFIG_BLK_DEV_SIIMAGE is not set
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+# CONFIG_BLK_DEV_VIA82CXXX is not set
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+CONFIG_IDEDMA_AUTO=y
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_SCSI=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+# CONFIG_BLK_DEV_SD is not set
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_3W_9XXX is not set
+# CONFIG_SCSI_ACARD is not set
+# CONFIG_SCSI_AACRAID is not set
+# CONFIG_SCSI_AIC7XXX is not set
+# CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_AIC79XX is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+# CONFIG_SCSI_GDTH is not set
+# CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_IBMVSCSI is not set
+# CONFIG_SCSI_INITIO is not set
+# CONFIG_SCSI_INIA100 is not set
+# CONFIG_SCSI_SYM53C8XX_2 is not set
+# CONFIG_SCSI_IPR is not set
+# CONFIG_SCSI_QLOGIC_FC is not set
+# CONFIG_SCSI_QLOGIC_1280 is not set
+CONFIG_SCSI_QLA2XXX=y
+# CONFIG_SCSI_QLA21XX is not set
+# CONFIG_SCSI_QLA22XX is not set
+# CONFIG_SCSI_QLA2300 is not set
+# CONFIG_SCSI_QLA2322 is not set
+# CONFIG_SCSI_QLA6312 is not set
+# CONFIG_SCSI_LPFC is not set
+# CONFIG_SCSI_DC395x is not set
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+
+#
+# Macintosh device drivers
+#
+
+#
+# Networking support
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_IP_TCPDIAG is not set
+# CONFIG_IP_TCPDIAG_IPV6 is not set
+CONFIG_IPV6=y
+# CONFIG_IPV6_PRIVACY is not set
+# CONFIG_INET6_AH is not set
+# CONFIG_INET6_ESP is not set
+# CONFIG_INET6_IPCOMP is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_IPV6_TUNNEL is not set
+# CONFIG_NETFILTER is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+# CONFIG_NET_CLS_ROUTE is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+# CONFIG_NET_ETHERNET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SK98LIN is not set
+CONFIG_TIGON3=y
+# CONFIG_MV643XX_ETH is not set
+
+#
+# Ethernet (10000 Mbit)
+#
+# CONFIG_IXGB is not set
+# CONFIG_S2IO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NET_FC is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1600
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=1200
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+CONFIG_SOUND_GAMEPORT=y
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=4
+# CONFIG_SERIAL_8250_EXTENDED is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_ICOM is not set
+# CONFIG_SERIAL_JSM is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_HVC_CONSOLE=y
+# CONFIG_HVCS is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+CONFIG_RTC=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_AGP is not set
+# CONFIG_DRM is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+# CONFIG_USB_DEVICEFS is not set
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_EHCI_HCD=y
+# CONFIG_USB_EHCI_SPLIT_ISO is not set
+# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
+CONFIG_USB_OHCI_HCD=y
+# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+# CONFIG_USB_UHCI_HCD is not set
+# CONFIG_USB_SL811_HCD is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_BLUETOOTH_TTY is not set
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=y
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_ISD200 is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_USBAT is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=y
+CONFIG_USB_HIDINPUT=y
+# CONFIG_HID_FF is not set
+# CONFIG_USB_HIDDEV is not set
+# CONFIG_USB_AIPTEK is not set
+# CONFIG_USB_WACOM is not set
+# CONFIG_USB_KBTAB is not set
+# CONFIG_USB_POWERMATE is not set
+# CONFIG_USB_MTOUCH is not set
+# CONFIG_USB_EGALAX is not set
+# CONFIG_USB_XPAD is not set
+# CONFIG_USB_ATI_REMOTE is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+
+#
+# USB Multimedia devices
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# Video4Linux support is needed for USB Multimedia device support
+#
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET is not set
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETKIT is not set
+# CONFIG_USB_PHIDGETSERVO is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_SISUSBVGA is not set
+
+#
+# USB ATM/DSL drivers
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# InfiniBand support
+#
+# CONFIG_INFINIBAND is not set
+
+#
+# File systems
+#
+# CONFIG_EXT2_FS is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_REISERFS_FS=y
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_REISERFS_FS_XATTR is not set
+# CONFIG_JFS_FS is not set
+
+#
+# XFS support
+#
+# CONFIG_XFS_FS is not set
+# CONFIG_MINIX_FS is not set
+CONFIG_ROMFS_FS=y
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+# CONFIG_JOLIET is not set
+# CONFIG_ZISOFS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+# CONFIG_VFAT_FS is not set
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+# CONFIG_PROC_KCORE is not set
+CONFIG_SYSFS=y
+# CONFIG_DEVFS_FS is not set
+# CONFIG_DEVPTS_FS_XATTR is not set
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_XATTR is not set
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_RAMFS=y
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+# CONFIG_OSF_PARTITION is not set
+# CONFIG_AMIGA_PARTITION is not set
+# CONFIG_ATARI_PARTITION is not set
+# CONFIG_MAC_PARTITION is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_BSD_DISKLABEL is not set
+# CONFIG_MINIX_SUBPARTITION is not set
+# CONFIG_SOLARIS_X86_PARTITION is not set
+# CONFIG_UNIXWARE_DISKLABEL is not set
+# CONFIG_LDM_PARTITION is not set
+# CONFIG_SGI_PARTITION is not set
+# CONFIG_ULTRIX_PARTITION is not set
+# CONFIG_SUN_PARTITION is not set
+# CONFIG_EFI_PARTITION is not set
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+
+#
+# Profiling support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+CONFIG_PRINTK_TIME=y
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_MAGIC_SYSRQ is not set
+CONFIG_LOG_BUF_SHIFT=15
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_FS is not set
+# CONFIG_DEBUG_STACKOVERFLOW is not set
+# CONFIG_KPROBES is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUGGER is not set
+# CONFIG_PPCDBG is not set
+# CONFIG_IRQSTACKS is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Hardware crypto devices
+#
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC32 is not set
+# CONFIG_LIBCRC32C is not set
diff --git a/loader.S b/loader.S
new file mode 100644
index 0000000..a0e3e80
--- /dev/null
+++ b/loader.S
@@ -0,0 +1,88 @@
+# =============================================================================
+# * Copyright (c) 2004, 2005 IBM Corporation
+# * All rights reserved.
+# * This program and the accompanying materials
+# * are made available under the terms of the BSD License
+# * which accompanies this distribution, and is available at
+# * http://www.opensource.org/licenses/bsd-license.php
+# *
+# * Contributors:
+# * IBM Corporation - initial implementation
+# =============================================================================
+
+
+#
+# The loader. This is position-independent code.
+#
+
+ .section ".slof.loader","ax"
+
+. = 0
+
+ # Get our address.
+
+ bcl 20,31,$+4
+ mflr 31
+
+ # Copy exception vectors.
+
+ addi 1,31,0x200-4-8
+ li 0,0x3f00/8
+ mtctr 0
+ li 2,0x100-8
+0:
+ ldu 0,8(1)
+ stdu 0,8(2)
+ bdnz 0b
+
+ # Copy Paflof text.
+
+ addi 1,31,0x4100-4-8
+ li 0,0x2000/8
+ mtctr 0
+ lis 2,0x111
+ subi 2,2,8
+0:
+ ldu 0,8(1)
+ stdu 0,8(2)
+ bdnz 0b
+
+ # Copy paflof data.
+
+ addi 1,31,0x6100-4-8
+ lis 0,1
+ mtctr 0
+ lis 2,0x112
+ subi 2,2,8
+0:
+ ldu 0,8(1)
+ stdu 0,8(2)
+ bdnz 0b
+
+ # Flush L1-D cache.
+
+ sync
+
+ # Flush L1-I cache for Paflof and exception vector code.
+
+ li 0,0x4000/128
+ mtctr 0
+ li 1,0
+0:
+ icbi 0,1
+ addi 1,1,128
+ bdnz 0b
+
+ li 0,0x2000/128
+ mtctr 0
+ lis 1,0x111
+0:
+ icbi 0,1
+ addi 1,1,128
+ bdnz 0b
+
+ isync
+
+ # Go!
+
+ ba 0x100
diff --git a/package-firmware b/package-firmware
new file mode 100755
index 0000000..f174dd2
--- /dev/null
+++ b/package-firmware
Binary files differ
diff --git a/paflof.c b/paflof.c
new file mode 100644
index 0000000..3f193da
--- /dev/null
+++ b/paflof.c
@@ -0,0 +1,43 @@
+// ============================================================================
+// * Copyright (c) 2004, 2005 IBM Corporation
+// * All rights reserved.
+// * This program and the accompanying materials
+// * are made available under the terms of the BSD License
+// * which accompanies this distribution, and is available at
+// * http://www.opensource.org/licenses/bsd-license.php
+// *
+// * Contributors:
+// * IBM Corporation - initial implementation
+// ============================================================================
+
+
+//
+// Copyright 2002,2003,2004 Segher Boessenkool <segher@kernel.crashing.org>
+//
+
+#define XSTR(x) #x
+#define ISTR(x,y) XSTR(x.y)
+#undef unix
+
+#include "paflof.h"
+#include ISTR(TARG,h)
+
+void engine(long error)
+{
+ cell *restrict dp;
+ cell *restrict rp;
+ cell *restrict ip;
+ cell *restrict cfa;
+ cell handler_stack[16];
+
+ #include "prim.h"
+ #include "dict.xt"
+
+ dp = the_data_stack;
+ rp = handler_stack - 1;
+ dp->n = error;
+ ip = xt_SYSTHROW;
+
+ #include "prim.code"
+ #include ISTR(TARG,code)
+}
diff --git a/paflof.h b/paflof.h
new file mode 100644
index 0000000..ea6dbfc
--- /dev/null
+++ b/paflof.h
@@ -0,0 +1,53 @@
+// ============================================================================
+// * Copyright (c) 2004, 2005 IBM Corporation
+// * All rights reserved.
+// * This program and the accompanying materials
+// * are made available under the terms of the BSD License
+// * which accompanies this distribution, and is available at
+// * http://www.opensource.org/licenses/bsd-license.php
+// *
+// * Contributors:
+// * IBM Corporation - initial implementation
+// ============================================================================
+
+
+//
+// Copyright 2002,2003,2004 Segher Boessenkool <segher@kernel.crashing.org>
+//
+
+#include "types.h"
+
+#define TIBSIZE 256
+#define POCKETSIZE 256
+
+// Where we put the exception save areas, and the stacks.
+// Stacks grow upwards, just like in real life. You should see my desk.
+#define the_exception_frame ((cell *)0x1100000)
+#define the_client_frame ((cell *)0x1100400)
+#define the_data_stack ((cell *)0x1102000)
+#define the_return_stack ((cell *)0x1104000)
+#define the_system_stack ((cell *)0x1106000)
+
+// These buffers are allocated in C code to ease implementation.
+#define the_tib ((cell *)0x1108000)
+#define the_pockets ((cell *)0x1109000)
+
+// This is where the run-time data space starts.
+#define the_mem ((cell *)0x1200000)
+
+
+// Some binary blob that is linked in to the image. Use an ELF file
+// for example; we can execute that as a client program, then.
+// You could use yaboot or a (small enough) Linux kernel, for example.
+extern char _binary_payload_start[];
+
+// Assembler glue routine for switching context between the client
+// program and SLOF itself.
+extern void client_entry_point();
+extern unsigned long call_client(cell);
+
+// Magic function to perform stuff that we don't give source for.
+extern type_u oco(cell, cell);
+
+// Synchronize instruction cache with data cache.
+extern void flush_cache (void*, long);
diff --git a/paflof.lds b/paflof.lds
new file mode 100644
index 0000000..133cb8b
--- /dev/null
+++ b/paflof.lds
@@ -0,0 +1,29 @@
+/* ============================================================================= */
+/* * Copyright (c) 2004, 2005 IBM Corporation
+/* * All rights reserved.
+/* * This program and the accompanying materials
+/* * are made available under the terms of the BSD License
+/* * which accompanies this distribution, and is available at
+/* * http://www.opensource.org/licenses/bsd-license.php
+/* *
+/* * Contributors:
+/* * IBM Corporation - initial implementation
+/* ============================================================================= */
+
+
+OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc")
+OUTPUT_ARCH(powerpc:common64)
+
+SECTIONS
+{
+ .slof.vectors 0 : { *(.slof.vectors) }
+
+ .slof.text 0x1110000 : { *(.text) } = 0x60000000
+
+ .slof.data 0x1120000 : {
+ KEEP (*(.opd))
+ . = ALIGN(8);
+ *(.got .toc)
+ *(.data .data.*)
+ }
+}
diff --git a/payload b/payload
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/payload
diff --git a/ppc64.code b/ppc64.code
new file mode 100644
index 0000000..1fe1d2f
--- /dev/null
+++ b/ppc64.code
@@ -0,0 +1,177 @@
+// ============================================================================
+// * Copyright (c) 2004, 2005 IBM Corporation
+// * All rights reserved.
+// * This program and the accompanying materials
+// * are made available under the terms of the BSD License
+// * which accompanies this distribution, and is available at
+// * http://www.opensource.org/licenses/bsd-license.php
+// *
+// * Contributors:
+// * IBM Corporation - initial implementation
+// ============================================================================
+
+
+// This file contains the implementation of the Forth code words specific
+// to PowerPC64. Some of this is 970-only.
+
+// Set and clear the RM_CI bit in HID4. Needed for all I/O accesses.
+#define SET_CI do { \
+ unsigned long hid4; \
+ asm volatile("mfspr %0,1012" : "=r"(hid4)); \
+ hid4 |= 0x0000010000000000UL; \
+ asm volatile("slbia ; sync ; mtspr 1012,%0 ; isync" : "+r"(hid4)); \
+} while (0)
+
+#define CLR_CI do { \
+ unsigned long hid4; \
+ asm volatile("mfspr %0,1012" : "=r"(hid4)); \
+ hid4 &= ~0x0000010000000000UL; \
+ asm volatile("sync ; mtspr 1012,%0 ; isync" : "+r"(hid4)); \
+} while (0)
+
+// The I/O accesses themselves.
+PRIM(RB_X40) GET_CHAR1; SET_CI; GET_CHAR2; CLR_CI; GET_CHAR3; MIRP
+PRIM(RB_X21) PUT_CHAR1; SET_CI; PUT_CHAR2; CLR_CI; MIRP
+PRIM(RW_X40) GET_WORD1; SET_CI; GET_WORD2; CLR_CI; GET_WORD3; MIRP
+PRIM(RW_X21) PUT_WORD1; SET_CI; PUT_WORD2; CLR_CI; MIRP
+PRIM(RL_X40) GET_LONG1; SET_CI; GET_LONG2; CLR_CI; GET_LONG3; MIRP
+PRIM(RL_X21) PUT_LONG1; SET_CI; PUT_LONG2; CLR_CI; MIRP
+
+// 970-specific CPU registers.
+PRIM(HID0_X21)
+ unsigned long hid0 = TOS.u;
+ asm volatile("sync ; mtspr 1008,%0 ; mfspr %0,1008 ; mfspr %0,1008 ; mfspr %0,1008 ; mfspr %0,1008 ; mfspr %0,1008 ; mfspr %0,1008" : "+r"(hid0));
+ POP;
+MIRP
+
+PRIM(HID0_X40)
+ PUSH;
+ asm volatile("mfspr %0,1008" : "=r"(TOS));
+MIRP
+
+PRIM(HID1_X21)
+ unsigned long hid1 = TOS.u;
+ asm volatile("mtspr 1009,%0 ; mtspr 1009,%0 ; isync" : "+r"(hid1));
+ POP;
+MIRP
+
+PRIM(HID1_X40)
+ PUSH;
+ asm volatile("mfspr %0,1009" : "=r"(TOS));
+MIRP
+
+PRIM(HID4_X21)
+ unsigned long hid4 = TOS.u;
+ asm volatile("sync ; mtspr 1012,%0 ; isync" : "+r"(hid4));
+ POP;
+MIRP
+
+PRIM(HID4_X40)
+ PUSH;
+ asm volatile("mfspr %0,1012" : "=r"(TOS));
+MIRP
+
+PRIM(HID5_X21)
+ unsigned long hid5 = TOS.u;
+ asm volatile("mtspr 1014,%0" : "+r"(hid5));
+ POP;
+MIRP
+
+PRIM(HID5_X40)
+ PUSH;
+ asm volatile("mfspr %0,1014" : "=r"(TOS));
+MIRP
+
+// PowerPC special registers.
+PRIM(MSR_X21)
+ unsigned long msr = TOS.u;
+ asm volatile("mtmsrd %0" : "+r"(msr));
+ POP;
+MIRP
+
+PRIM(MSR_X40)
+ PUSH;
+ asm volatile("mfmsr %0" : "=r"(TOS));
+MIRP
+
+PRIM(SDR1_X21)
+ unsigned long sdr1 = TOS.u;
+ asm volatile("mtsdr1 %0" : "+r"(sdr1));
+ POP;
+MIRP
+
+PRIM(SDR1_X40)
+ PUSH;
+ asm volatile("mfsdr1 %0" : "=r"(TOS));
+MIRP
+
+PRIM(PVR_X40)
+ PUSH;
+ asm volatile("mfpvr %0" : "=r"(TOS));
+MIRP
+
+PRIM(PIR_X40)
+ PUSH;
+ asm volatile("mfspr %0,1023" : "=r"(TOS));
+MIRP
+
+PRIM(TBL_X40)
+ PUSH;
+ asm volatile("mftbl %0" : "=r"(TOS));
+MIRP
+
+PRIM(TBU_X40)
+ PUSH;
+ asm volatile("mftbu %0" : "=r"(TOS));
+MIRP
+
+PRIM(DABR_X21)
+ unsigned long dabr = TOS.u;
+ asm volatile("mtspr 1013,%0" : "+r"(dabr));
+ POP;
+MIRP
+
+PRIM(DABR_X40)
+ PUSH;
+ asm volatile("mfspr %0,1013" : "=r"(TOS));
+MIRP
+
+PRIM(HIOR_X21)
+ unsigned long dabr = TOS.u;
+ asm volatile("mtspr 311,%0" : "+r"(dabr));
+ POP;
+MIRP
+
+PRIM(HIOR_X40)
+ PUSH;
+ asm volatile("mfspr %0,311" : "=r"(TOS));
+MIRP
+
+PRIM(MMCR0_X21)
+ unsigned long mmcr0 = TOS.u;
+ asm volatile("sync ; mtspr 795,%0 ; isync" : "+r"(mmcr0));
+ POP;
+MIRP
+
+PRIM(PMC1_X40)
+ PUSH;
+ asm volatile("sync ; mfspr %0,787" : "=r"(TOS));
+MIRP
+
+
+// Call into the client program.
+PRIM(JUMP_X2d_CLIENT)
+ TOS.u = call_client(TOS);
+MIRP
+
+// Call an object-code only routine.
+PRIM(OCO)
+ cell p0 = TOS; POP;
+ cell p1 = TOS;
+ TOS.u = oco(p0, p1);
+MIRP
+
+// Hang. Useful for debugging, believe it or not.
+PRIM(CRASH)
+ for (;;) ;
+MIRP
diff --git a/ppc64.h b/ppc64.h
new file mode 100644
index 0000000..fa1d10d
--- /dev/null
+++ b/ppc64.h
@@ -0,0 +1,18 @@
+// ============================================================================
+// * Copyright (c) 2004, 2005 IBM Corporation
+// * All rights reserved.
+// * This program and the accompanying materials
+// * are made available under the terms of the BSD License
+// * which accompanies this distribution, and is available at
+// * http://www.opensource.org/licenses/bsd-license.php
+// *
+// * Contributors:
+// * IBM Corporation - initial implementation
+// ============================================================================
+
+
+// The big Forth source file that contains everything but the core engine.
+// We include it as a hunk of data into the C part of SLOF; at startup
+// time, this will be EVALUATE'd.
+
+extern char _binary_ppc64_fs_start[], _binary_ppc64_fs_end[];
diff --git a/ppc64.in b/ppc64.in
new file mode 100644
index 0000000..993f096
--- /dev/null
+++ b/ppc64.in
@@ -0,0 +1,70 @@
+// ============================================================================
+// * Copyright (c) 2004, 2005 IBM Corporation
+// * All rights reserved.
+// * This program and the accompanying materials
+// * are made available under the terms of the BSD License
+// * which accompanies this distribution, and is available at
+// * http://www.opensource.org/licenses/bsd-license.php
+// *
+// * Contributors:
+// * IBM Corporation - initial implementation
+// ============================================================================
+
+
+// The Forth code words (primitives) that are specific to PowerPC64.
+
+// I/O accesses.
+cod(RB@)
+cod(RB!)
+cod(RW@)
+cod(RW!)
+cod(RL@)
+cod(RL!)
+
+// CPU register accesses.
+cod(HID0!)
+cod(HID0@)
+cod(HID1!)
+cod(HID1@)
+cod(HID4!)
+cod(HID4@)
+cod(HID5!)
+cod(HID5@)
+cod(MSR@)
+cod(MSR!)
+cod(SDR1@)
+cod(SDR1!)
+cod(PVR@)
+cod(PIR@)
+cod(TBL@)
+cod(TBU@)
+cod(DABR@)
+cod(DABR!)
+cod(HIOR@)
+cod(HIOR!)
+
+cod(MMCR0!)
+cod(PMC1@)
+
+
+// The start address of a binary payload.
+con(PAYLOAD (type_u)_binary_payload_start)
+
+// Calling the client program.
+con(CLIENT-ENTRY-POINT (type_u)client_entry_point)
+cod(JUMP-CLIENT)
+dfr(CLIENTINTERFACE)
+
+// Calling binary-only code.
+cod(OCO)
+
+// Hang.
+cod(CRASH)
+
+var(DAAR 0x10000000)
+col(DUMBER DAAR @ C! LIT(1) DAAR +!)
+
+// Engine startup.
+col(NICEINIT DOTICK DUMBER DOTO EMIT DOTICK ((FIND)) DOTO (FIND) DOTICK 2DROP DOTO (REVEAL) LIT((type_u)_binary_ppc64_fs_start) LIT((type_u)_binary_ppc64_fs_end) OVER - DOTICK EVALUATE CATCH ?DUP 0BRANCH(2) PRINT-STATUS CLEAR)
+static cell xt_SYSTHROW[] = { DUP LIT(0x100) _X3d _0BRANCH(3) DROP NICEINIT QUIT PRINT_X2d_STATUS QUIT };
+col(LASTWORD )
diff --git a/prim.code b/prim.code
new file mode 100644
index 0000000..7df46fa
--- /dev/null
+++ b/prim.code
@@ -0,0 +1,349 @@
+// ============================================================================
+// * Copyright (c) 2004, 2005 IBM Corporation
+// * All rights reserved.
+// * This program and the accompanying materials
+// * are made available under the terms of the BSD License
+// * which accompanies this distribution, and is available at
+// * http://www.opensource.org/licenses/bsd-license.php
+// *
+// * Contributors:
+// * IBM Corporation - initial implementation
+// ============================================================================
+
+
+//
+// Copyright 2002,2003,2004 Segher Boessenkool <segher@kernel.crashing.org>
+//
+
+#define NEXT00 goto *cfa->a
+#define NEXT0 cfa = ip->a; NEXT00
+#define NEXT ip++; NEXT0
+
+#define PRIM(name) code_##name: { \
+ asm("#### " #name); \
+ void *w = (cfa = (++ip)->a)->a;
+#define MIRP goto *w; }
+
+
+
+ // start interpreting
+ NEXT0;
+
+
+
+// These macros could be replaced to allow for TOS caching etc.
+#define TOS (*dp)
+#define NOS (*(dp-1))
+#define POP dp--
+#define PUSH dp++
+
+#define RTOS (*rp)
+#define RNOS (*(rp-1))
+#define RPOP rp--
+#define RPUSH rp++
+
+
+
+
+// For terminal input.
+PRIM(TIB) PUSH; TOS.a = the_tib; MIRP
+
+// For pockets (temporary string buffers).
+PRIM(POCKETS) PUSH; TOS.a = the_pockets; MIRP
+
+
+
+// Codefields.
+code_DOCOL:
+ {
+ RPUSH; RTOS.a = ip;
+ ip = cfa;
+ NEXT;
+ }
+code_DODOES:
+ {
+ RPUSH; RTOS.a = ip;
+ ip = (cfa + 1)->a;
+ PUSH; TOS.a = cfa + 2;
+ NEXT0;
+ }
+code_DODEFER:
+code_DOALIAS:
+ {
+ cfa = (cfa + 1)->a;
+ NEXT00;
+ }
+code_DOCON:
+code_DOVAL:
+ {
+ PUSH;
+ TOS = *(cfa + 1);
+ NEXT;
+ }
+code_DOFIELD:
+ {
+ dp->n += (cfa + 1)->n;
+ NEXT;
+ }
+code_DOVAR:
+code_DOBUFFER_X3a:
+ {
+ (++dp)->a = cfa + 1;
+ NEXT;
+ }
+
+
+
+
+
+// branching
+code_BRANCH:
+ {
+ type_n dis = (++ip)->n;
+ ip = (cell *)((type_u)ip + dis);
+ NEXT;
+ }
+code_0BRANCH:
+ {
+ type_n dis = (++ip)->n;
+ if (TOS.u == 0)
+ ip = (cell *)((type_u)ip + dis);
+ POP;
+ NEXT;
+ }
+
+
+
+// literals
+code_LIT:
+code_DOTICK:
+ {
+ PUSH;
+ TOS = *++ip;
+ NEXT;
+ }
+
+
+
+// 1.1
+PRIM(DUP) cell x = TOS; PUSH; TOS = x; MIRP
+PRIM(OVER) cell x = NOS; PUSH; TOS = x; MIRP
+PRIM(PICK) TOS = *(dp - TOS.n - 1); MIRP
+
+// 1.2
+PRIM(DROP) POP; MIRP
+
+// 1.3
+PRIM(SWAP) cell x = NOS; NOS = TOS; TOS = x; MIRP
+
+// 1.4
+PRIM(_X3e_R) RPUSH; RTOS = TOS; POP; MIRP
+PRIM(R_X3e) PUSH; TOS = RTOS; RPOP; MIRP
+PRIM(R_X40) PUSH; TOS = RTOS; MIRP
+
+// 1.5
+PRIM(DEPTH) PUSH; TOS.u = dp - the_data_stack; MIRP
+PRIM(DEPTH_X21) dp = the_data_stack + TOS.u - 1; MIRP
+PRIM(RDEPTH) PUSH; TOS.u = rp - the_return_stack + 1; MIRP
+PRIM(RDEPTH_X21) rp = the_return_stack + TOS.u - 1; POP; MIRP
+
+// 2.1
+PRIM(_X2b) NOS.u += TOS.u; POP; MIRP
+PRIM(_X2d) NOS.u -= TOS.u; POP; MIRP
+PRIM(_X2a) NOS.u *= TOS.u; POP; MIRP
+
+// 2.2
+PRIM(LSHIFT) NOS.u <<= TOS.u; POP; MIRP
+PRIM(RSHIFT) NOS.u >>= TOS.u; POP; MIRP
+PRIM(ASHIFT) NOS.n >>= TOS.u; POP; MIRP
+PRIM(AND) NOS.u &= TOS.u; POP; MIRP
+PRIM(OR) NOS.u |= TOS.u; POP; MIRP
+PRIM(XOR) NOS.u ^= TOS.u; POP; MIRP
+
+// 3.1
+#define GET_TYPE1(t) { \
+ t *restrict a = (t *restrict)(TOS.a); \
+ t b;
+
+#define GET_TYPE2(t) \
+ b = *a;
+
+#define GET_TYPE3(t) \
+ TOS.u = b; \
+}
+
+#define PUT_TYPE1(t) { \
+ t *restrict a = TOS.a; \
+ t b = NOS.u; \
+ POP; \
+ POP;
+
+#define PUT_TYPE2(t) \
+ *a = b; \
+}
+
+#define GET_CELL1 GET_TYPE1(type_u)
+#define PUT_CELL1 PUT_TYPE1(type_u)
+#define GET_CHAR1 GET_TYPE1(type_c)
+#define PUT_CHAR1 PUT_TYPE1(type_c)
+#define GET_WORD1 GET_TYPE1(type_w)
+#define PUT_WORD1 PUT_TYPE1(type_w)
+#define GET_LONG1 GET_TYPE1(type_l)
+#define PUT_LONG1 PUT_TYPE1(type_l)
+#define GET_XONG1 GET_TYPE1(type_u)
+#define PUT_XONG1 PUT_TYPE1(type_u)
+
+#define GET_CELL2 GET_TYPE2(type_u)
+#define PUT_CELL2 PUT_TYPE2(type_u)
+#define GET_CHAR2 GET_TYPE2(type_c)
+#define PUT_CHAR2 PUT_TYPE2(type_c)
+#define GET_WORD2 GET_TYPE2(type_w)
+#define PUT_WORD2 PUT_TYPE2(type_w)
+#define GET_LONG2 GET_TYPE2(type_l)
+#define PUT_LONG2 PUT_TYPE2(type_l)
+#define GET_XONG2 GET_TYPE2(type_u)
+#define PUT_XONG2 PUT_TYPE2(type_u)
+
+#define GET_CELL3 GET_TYPE3(type_u)
+#define GET_CHAR3 GET_TYPE3(type_c)
+#define GET_WORD3 GET_TYPE3(type_w)
+#define GET_LONG3 GET_TYPE3(type_l)
+#define GET_XONG3 GET_TYPE3(type_u)
+
+#define GET_CELL GET_CELL1 GET_CELL2 GET_CELL3
+#define PUT_CELL PUT_CELL1 PUT_CELL2
+#define GET_CHAR GET_CHAR1 GET_CHAR2 GET_CHAR3
+#define PUT_CHAR PUT_CHAR1 PUT_CHAR2
+#define GET_WORD GET_WORD1 GET_WORD2 GET_WORD3
+#define PUT_WORD PUT_WORD1 PUT_WORD2
+#define GET_LONG GET_LONG1 GET_LONG2 GET_LONG3
+#define PUT_LONG PUT_LONG1 PUT_LONG2
+#define GET_XONG GET_XONG1 GET_XONG2 GET_XONG3
+#define PUT_XONG PUT_XONG1 PUT_XONG2
+
+ PRIM(_X40) GET_CELL; MIRP
+ PRIM(_X21) PUT_CELL; MIRP
+ PRIM(C_X40) GET_CHAR; MIRP
+ PRIM(C_X21) PUT_CHAR; MIRP
+ PRIM(W_X40) GET_WORD; MIRP
+ PRIM(W_X21) PUT_WORD; MIRP
+ PRIM(L_X40) GET_LONG; MIRP
+ PRIM(L_X21) PUT_LONG; MIRP
+ PRIM(X_X40) GET_XONG; MIRP
+ PRIM(X_X21) PUT_XONG; MIRP
+
+
+
+// 6
+PRIM(_X3c) NOS.n = -(NOS.n < TOS.n); POP; MIRP
+PRIM(U_X3c) NOS.n = -(NOS.u < TOS.u); POP; MIRP
+PRIM(0_X3c) TOS.n = -(TOS.n < 0); MIRP
+PRIM(_X3d) NOS.n = -(NOS.u == TOS.u); POP; MIRP
+PRIM(0_X3d) TOS.n = -(TOS.u == 0); MIRP
+
+
+
+
+
+
+// 8.4
+PRIM(DODO) RPUSH; RTOS = NOS; RPUSH; RTOS = TOS; POP; POP; MIRP
+code_DO_X3f_DO:
+ {
+ cell i = *dp--;
+ cell n = *dp--;
+ type_n dis = (++ip)->n;
+ if (i.n == n.n)
+ ip = (cell *restrict)((type_c *restrict)ip + dis);
+ else {
+ *(rp + 1) = n;
+ *(rp += 2) = i;
+ }
+ NEXT;
+ }
+code_DOLOOP:
+ {
+ type_n dis = (++ip)->n;
+ rp->n++;
+ if (rp->n == (rp - 1)->n)
+ rp -= 2;
+ else
+ ip = (cell *restrict)((type_c *restrict)ip + dis);
+ NEXT;
+ }
+code_DO_X2b_LOOP:
+ {
+ type_u lo, hi;
+ type_n inc;
+ type_n dis = (++ip)->n;
+ lo = rp->u;
+ inc = (dp--)->n;
+ rp->n += inc;
+ if (inc >= 0)
+ hi = rp->u;
+ else {
+ hi = lo;
+ lo = rp->u;
+ }
+ if ((type_u)((rp - 1)->n - 1 - lo) < hi - lo)
+ rp -= 2;
+ else
+ ip = (cell *restrict)((type_c *restrict)ip + dis);
+ NEXT;
+ }
+code_DOLEAVE:
+ {
+ type_n dis = (++ip)->n;
+ rp -= 2;
+ ip = (cell *restrict)((type_c *restrict)ip + dis);
+ NEXT;
+ }
+code_DO_X3f_LEAVE:
+ {
+ type_n dis = (++ip)->n;
+ if ((dp--)->n) {
+ rp -= 2;
+ ip = (cell *restrict)((type_c *restrict)ip + dis);
+ }
+ NEXT;
+ }
+
+
+
+
+
+
+// 8.5
+code_EXIT:
+ {
+ ip = (rp--)->a;
+ NEXT;
+ }
+code_EXECUTE: // don't need this as prim
+ {
+ cfa = (dp--)->a;
+ NEXT00;
+ }
+
+
+
+
+// 3.1
+PRIM(MOVE)
+ type_u n = TOS.u; POP;
+ unsigned char *q = TOS.a; POP;
+ unsigned char *p = TOS.a; POP;
+ if (p >= q || q >= p + n)
+ for (p--, q--; n--; )
+ *++q = *++p;
+ else
+ for (p += n, q += n ; n--; )
+ *--q = *--p;
+MIRP
+
+
+PRIM(FLUSHCACHE)
+ type_u n = TOS.u; POP;
+ unsigned char* p = TOS.a; POP;
+ flush_cache(p, n);
+MIRP
diff --git a/prim.h b/prim.h
new file mode 100644
index 0000000..1fc7486
--- /dev/null
+++ b/prim.h
@@ -0,0 +1,47 @@
+// ============================================================================
+// * Copyright (c) 2004, 2005 IBM Corporation
+// * All rights reserved.
+// * This program and the accompanying materials
+// * are made available under the terms of the BSD License
+// * which accompanies this distribution, and is available at
+// * http://www.opensource.org/licenses/bsd-license.php
+// *
+// * Contributors:
+// * IBM Corporation - initial implementation
+// ============================================================================
+
+
+//
+// Copyright 2002,2003,2004 Segher Boessenkool <segher@kernel.crashing.org>
+//
+
+#define _N(_n) { .n = _n },
+#define _O(_n) { .n = CELLSIZE * (_n) },
+#define _C(_c) { .c = _c },
+#define _A(_a) { .a = _a },
+
+#define ref(_xt, _nname) _A(xt_ ## _xt + _nname)
+#define header(_xt, _header...) static cell xt_ ## _xt[] = { _header
+#define def(_xts...) _xts };
+#define lab(_xt) _A(&&code_ ## _xt)
+
+#define DOCOL lab(DOCOL)
+#define DODOES lab(DODOES)
+#define DODEFER lab(DODEFER)
+#define DOALIAS lab(DOALIAS)
+#define DOCON lab(DOCON)
+#define DOVAL lab(DOVAL)
+#define DOFIELD lab(DOFIELD)
+#define DOVAR lab(DOVAR)
+#define DOBUFFER_X3a lab(DOBUFFER_X3a)
+
+#define cod(_xt) def(lab(_xt))
+#define col(_xt, _def...) def(DOCOL _def EXIT)
+#define con(_xt, _def) def(DOCON _N(_def))
+#define dfr(_xt) def(DODEFER _N(0))
+#define val(_xt, _def) def(DOVAL _N(_def))
+#define var(_xt, _def) def(DOVAR _N(_def))
+
+
+#define raw(_xt, _def) def(_def)
+#define str(_xt, _def...) def(_def)
diff --git a/prim.in b/prim.in
new file mode 100644
index 0000000..ff39f95
--- /dev/null
+++ b/prim.in
@@ -0,0 +1,81 @@
+// ============================================================================
+// * Copyright (c) 2004, 2005 IBM Corporation
+// * All rights reserved.
+// * This program and the accompanying materials
+// * are made available under the terms of the BSD License
+// * which accompanies this distribution, and is available at
+// * http://www.opensource.org/licenses/bsd-license.php
+// *
+// * Contributors:
+// * IBM Corporation - initial implementation
+// ============================================================================
+
+
+//
+// Copyright 2002,2003,2004 Segher Boessenkool <segher@kernel.crashing.org>
+//
+
+cod(TIB)
+cod(POCKETS)
+
+cod(BRANCH) _ADDING _O
+cod(0BRANCH) _ADDING _O
+
+cod(LIT) _ADDING _N
+cod(DOTICK)
+
+cod(DUP)
+cod(OVER)
+cod(PICK)
+cod(DROP)
+cod(SWAP)
+
+cod(>R)
+cod(R>)
+cod(R@)
+
+cod(DEPTH)
+cod(DEPTH!)
+cod(RDEPTH)
+cod(RDEPTH!)
+
+cod(+)
+cod(-)
+cod(*)
+cod(LSHIFT)
+cod(RSHIFT)
+cod(ASHIFT)
+cod(AND)
+cod(OR)
+cod(XOR)
+
+cod(@)
+cod(!)
+cod(C@)
+cod(C!)
+cod(W@)
+cod(W!)
+cod(L@)
+cod(L!)
+cod(X@)
+cod(X!)
+
+cod(<)
+cod(U<)
+cod(0<)
+cod(=)
+cod(0=)
+
+cod(DODO)
+cod(DO?DO) _ADDING _O
+cod(DOLOOP) _ADDING _O
+cod(DO+LOOP) _ADDING _O
+cod(DOLEAVE) _ADDING _O
+cod(DO?LEAVE) _ADDING _O
+
+cod(EXIT)
+cod(EXECUTE)
+
+cod(MOVE)
+
+cod(FLUSHCACHE)
diff --git a/ref.pl b/ref.pl
new file mode 100644
index 0000000..0cfe10a
--- /dev/null
+++ b/ref.pl
@@ -0,0 +1,106 @@
+#!/usr/bin/perl
+# =============================================================================
+# * Copyright (c) 2004, 2005 IBM Corporation
+# * All rights reserved.
+# * This program and the accompanying materials
+# * are made available under the terms of the BSD License
+# * which accompanies this distribution, and is available at
+# * http://www.opensource.org/licenses/bsd-license.php
+# *
+# * Contributors:
+# * IBM Corporation - initial implementation
+# =============================================================================
+
+#
+# Copyright 2002,2003,2004 Segher Boessenkool <segher@kernel.crashing.org>
+#
+
+use Data::Dumper;
+
+$CELLSIZE = length(sprintf "%x", ~0) / 2;
+$CELLSIZE = 8; # Hard code for cross-compiling to a different size ABI.
+
+sub string
+{
+ my ($s, $extra) = @_;
+
+ $s = sprintf "%s%c%s", $extra, length($s), $s;
+ @s = ($s =~ /(.{1,$CELLSIZE})/gs);
+ do { s/([\x00-\x1f\x22\x5c\x7f-\xff])/sprintf "\\%03o", ord $1/egs } for @s;
+ my @reut = ("{ .c = \"" . (join "\" }, { .c = \"", @s) . "\" },", scalar @s);
+ return @reut;
+}
+
+sub forth_to_c_name
+{
+ ($_, my $numeric) = @_;
+ s/([^a-zA-Z0-9])/sprintf("_X%02x_", ord($1))/ge;
+ s/__/_/g;
+ s/_$//;
+ s/^(\d)/_$1/ if $numeric;
+ return $_;
+}
+
+sub special_forth_to_c_name
+{
+ ($_, my $numeric) = @_;
+
+ my ($name, $arg) = (/^([^(]+)(.*)$/);
+ if ($special{$name} == 1) {
+ $_ = forth_to_c_name($name, $numeric) . $arg;
+ } elsif ($special{$name} != 2) {
+ $_ = forth_to_c_name($_, $numeric);
+ }
+ return $_;
+}
+
+$link = "0";
+%special = ( _N => 2, _O => 2, _C => 2, _A => 2 );
+
+while ($line = <>) {
+ if ($line =~ /^([a-z]{3})\(([^ ]+)./) {
+ $typ = $1;
+ $name = $2;
+ $name =~ s/\)$// if $line =~ /\)\s+_ADDING.*$/;
+ $cname = forth_to_c_name($name, 1);
+ $par = '';
+ $add = '';
+ $extra = "\0";
+ if ($typ eq "imm") {
+ $typ = "col";
+ $extra = "\1";
+ }
+ ($str, $strcells) = (string $name, $extra);
+ if ($line =~ /^str\([^"]*"([^"]*)"/) {
+ ($s) = (string $1);
+ $line =~ s/"[^"]*"/$s/;
+ }
+ if ($line =~ /_ADDING +(.*)$/) {
+ $special{$name} = 1;
+ @typ = (split /\s+/, $1);
+ $count = 0;
+ $par = "(" . (join ", ", map { $count++; "_x$count" } @typ) . ")";
+ $count = 0;
+ $add = join " ", map { $count++; "$_(_x$count)" } @typ;
+ $line =~ s/\s+_ADDING.*$//;
+ }
+ ($body) = ($line =~ /^...\((.*)\)$/);
+ @body = split " ", $body;
+ if ($typ ne "str" and $typ ne "con") {
+ @body = map { special_forth_to_c_name($_, $typ eq "col") } @body;
+ } else {
+ $body[0] = special_forth_to_c_name($body[0]);
+ }
+ $body = join " ", @body;
+ $body =~ s/ /, /;
+
+ print "header($cname, { .a = $link }, $str) ";
+ $link = "xt_$cname";
+ print "$typ($body)\n";
+ print "#define $cname$par ref($cname, $strcells+1) $add\n";
+ (my $xxcname) = ($cname =~ /^_?(.*)/);
+ $add and print "#define DO$xxcname ref($cname, $strcells+1)\n";
+ } else {
+ print $line;
+ }
+}
diff --git a/slof.lds b/slof.lds
new file mode 100644
index 0000000..d77a17e
--- /dev/null
+++ b/slof.lds
@@ -0,0 +1,24 @@
+/* ============================================================================= */
+/* * Copyright (c) 2004, 2005 IBM Corporation
+/* * All rights reserved.
+/* * This program and the accompanying materials
+/* * are made available under the terms of the BSD License
+/* * which accompanies this distribution, and is available at
+/* * http://www.opensource.org/licenses/bsd-license.php
+/* *
+/* * Contributors:
+/* * IBM Corporation - initial implementation
+/* ============================================================================= */
+
+
+OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc")
+OUTPUT_ARCH(powerpc:common64)
+
+SECTIONS {
+ .startup 0x2000000 : { startup.o }
+ image = ALIGN(128);
+ .slof.loader image : { loader.o }
+ .slof.vectors image + 0x100 : { *(.slof.vectors) }
+ .slof.text image + 0x4100 : { *(.slof.text) }
+ .slof.data image + 0x6100 : { *(.slof.data) }
+}
diff --git a/types.h b/types.h
new file mode 100644
index 0000000..7cb2c8d
--- /dev/null
+++ b/types.h
@@ -0,0 +1,49 @@
+// ============================================================================
+// * Copyright (c) 2004, 2005 IBM Corporation
+// * All rights reserved.
+// * This program and the accompanying materials
+// * are made available under the terms of the BSD License
+// * which accompanies this distribution, and is available at
+// * http://www.opensource.org/licenses/bsd-license.php
+// *
+// * Contributors:
+// * IBM Corporation - initial implementation
+// ============================================================================
+
+
+//
+// Copyright 2002,2003,2004 Segher Boessenkool <segher@kernel.crashing.org>
+//
+
+#ifndef _TYPES_H
+#define _TYPES_H
+
+#if 0
+#include <stdint.h>
+
+typedef uint8_t type_c; // 1 byte
+typedef uint16_t type_w; // 2 bytes
+typedef uint32_t type_l; // 4 bytes
+typedef intptr_t type_n; // cell size
+typedef uintptr_t type_u; // cell size
+#else
+typedef unsigned char type_c; // 1 byte
+typedef unsigned short type_w; // 2 bytes
+typedef unsigned int type_l; // 4 bytes
+typedef long type_n; // cell size
+typedef unsigned long type_u; // cell size
+#endif
+
+#define CELLSIZE sizeof(type_u)
+
+typedef union cell {
+ type_n n;
+ type_u u;
+ void *a;
+ type_c c[CELLSIZE];
+ type_w w[CELLSIZE/2];
+ type_l l[CELLSIZE/4];
+} cell;
+
+
+#endif /* _TYPES_H */