summaryrefslogtreecommitdiffstats
path: root/qemu/roms/SLOF/board-js2x/slof
diff options
context:
space:
mode:
authorYang Zhang <yang.z.zhang@intel.com>2015-08-28 09:58:54 +0800
committerYang Zhang <yang.z.zhang@intel.com>2015-09-01 12:44:00 +0800
commite44e3482bdb4d0ebde2d8b41830ac2cdb07948fb (patch)
tree66b09f592c55df2878107a468a91d21506104d3f /qemu/roms/SLOF/board-js2x/slof
parent9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (diff)
Add qemu 2.4.0
Change-Id: Ic99cbad4b61f8b127b7dc74d04576c0bcbaaf4f5 Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
Diffstat (limited to 'qemu/roms/SLOF/board-js2x/slof')
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/Makefile111
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/OF.fs557
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/attu.fs101
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/bcm57xx.fs75
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/citrine-disk.fs79
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/citrine-flash.fs36
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/citrine.fs245
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/copyright-oss.fs16
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/cpu.fs44
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/dart.fs31
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/flash.fs43
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/freq.fs39
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/header.fs19
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/helper.fs28
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/ht.fs189
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/i2c.fs77
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/io.fs26
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/ioapic.fs36
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/ipmi-kcs.fs57
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/ipmi-vpd.fs98
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/memory.fs52
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/mpic.fs31
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-aliases.fs85
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-bridge_1022_7460.fs203
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-capabilities.fs23
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-class_03.fs55
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-device_1002_515e.fs501
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-device_1014_028c.fs25
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-device_1014_02bd.fs23
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7451.fs34
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7468.fs50
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7469.fs23
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-device_14e4_16a8.fs23
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/pci-interrupts.fs235
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/rtas.fs240
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/rtc.fs59
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/serial.fs48
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/sio.fs85
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/tpm.fs63
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/tree.fs225
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/u4-mem.fs313
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/version.c0
-rw-r--r--qemu/roms/SLOF/board-js2x/slof/vga-display.fs157
43 files changed, 4460 insertions, 0 deletions
diff --git a/qemu/roms/SLOF/board-js2x/slof/Makefile b/qemu/roms/SLOF/board-js2x/slof/Makefile
new file mode 100644
index 000000000..ab3e683a4
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/Makefile
@@ -0,0 +1,111 @@
+# *****************************************************************************
+# * Copyright (c) 2004, 2008 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
+# ****************************************************************************/
+
+
+include ../Makefile.dirs
+
+include $(TOPBRDDIR)/config
+include $(TOPCMNDIR)/make.rules
+
+
+all: Makefile.dep OF.ffs paflof $(SLOFCMNDIR)/xvect.bin
+
+CPPFLAGS = -I$(LIBCMNDIR)/libbootmsg -I$(LIBCMNDIR)/libnvram \
+ -I$(LIBCMNDIR)/libusb -I$(LIBCMNDIR)/libbcm
+SLOF_LIBS = \
+ $(LIBCMNDIR)/libbootmsg.a \
+ $(LIBCMNDIR)/libelf.a \
+ $(LIBCMNDIR)/libusb.a \
+ $(LIBCMNDIR)/libnvram.a \
+ $(LIBCMNDIR)/libbcm.a
+BOARD_SLOF_IN = \
+ $(LIBCMNDIR)/libbootmsg/bootmsg.in \
+ $(LIBCMNDIR)/libelf/libelf.in \
+ $(LIBCMNDIR)/libusb/usb.in \
+ $(LIBCMNDIR)/libbases/libbases.in \
+ $(LIBCMNDIR)/libnvram/libnvram.in \
+ $(LIBCMNDIR)/libnativeio/nativeio.in \
+ $(LIBCMNDIR)/libbcm/bcm.in
+BOARD_SLOF_CODE = $(BOARD_SLOF_IN:%.in=%.code)
+
+include $(SLOFCMNDIR)/Makefile.inc
+
+FPPINCLUDES = -I. -I$(SLOFCMNDIR)/fs -I$(SLOFCMNDIR)
+
+USB_FFS_FILES = \
+ $(SLOFCMNDIR)/fs/devices/pci-class_0c.fs \
+ $(SLOFCMNDIR)/fs/usb/dev-hci.fs \
+ $(SLOFCMNDIR)/fs/usb/slofdev.fs \
+ $(SLOFCMNDIR)/fs/usb/dev-parent-calls.fs \
+ $(SLOFCMNDIR)/fs/usb/dev-keyb.fs \
+ $(SLOFCMNDIR)/fs/usb/dev-mouse.fs \
+ $(SLOFCMNDIR)/fs/usb/dev-storage.fs \
+ $(SLOFCMNDIR)/fs/usb/dev-hub.fs
+
+# Files that should go into the ROM fs (and so have to be listed in OF.ffs):
+OF_FFS_FILES = \
+ $(SLOFBRDDIR)/u4-mem.fs \
+ $(SLOFBRDDIR)/attu.fs \
+ $(SLOFBRDDIR)/cpu.fs \
+ $(SLOFBRDDIR)/ioapic.fs \
+ $(SLOFBRDDIR)/pci-bridge_1022_7460.fs \
+ $(SLOFBRDDIR)/pci-device_1014_028c.fs \
+ $(SLOFBRDDIR)/pci-device_1014_02bd.fs \
+ $(SLOFBRDDIR)/pci-device_1022_7468.fs \
+ $(SLOFBRDDIR)/pci-device_1022_7469.fs \
+ $(SLOFBRDDIR)/pci-device_1022_7451.fs \
+ $(SLOFBRDDIR)/pci-device_14e4_16a8.fs \
+ $(SLOFBRDDIR)/bcm57xx.fs \
+ $(SLOFBRDDIR)/pci-class_03.fs \
+ $(SLOFBRDDIR)/vga-display.fs \
+ $(SLOFBRDDIR)/freq.fs \
+ $(SLOFBRDDIR)/pci-device_1002_515e.fs \
+ $(SLOFBRDDIR)/citrine.fs \
+ $(SLOFBRDDIR)/citrine-disk.fs \
+ $(SLOFBRDDIR)/sio.fs \
+ $(SLOFBRDDIR)/tpm.fs \
+ $(SLOFBRDDIR)/ipmi-kcs.fs \
+ $(SLOFCMNDIR)/fs/ide.fs \
+ $(SLOFCMNDIR)/fs/fbuffer.fs \
+ $(SLOFCMNDIR)/fs/graphics.fs \
+ $(SLOFCMNDIR)/fs/generic-disk.fs \
+ $(SLOFCMNDIR)/fs/scsi-disk.fs \
+ $(SLOFCMNDIR)/fs/scsi-host-helpers.fs \
+ $(SLOFCMNDIR)/fs/scsi-probe-helpers.fs \
+ $(SLOFCMNDIR)/fs/scsi-support.fs \
+ $(SLOFCMNDIR)/fs/pci-device.fs \
+ $(SLOFCMNDIR)/fs/pci-bridge.fs \
+ $(SLOFCMNDIR)/fs/pci-properties.fs \
+ $(SLOFCMNDIR)/fs/pci-config-bridge.fs \
+ $(SLOFCMNDIR)/fs/update_flash.fs \
+ $(SLOFCMNDIR)/fs/xmodem.fs \
+ $(SLOFCMNDIR)/fs/devices/pci-device_10de_0141.fs \
+ $(SLOFCMNDIR)/fs/devices/pci-class_02.fs \
+ $(SLOFBRDDIR)/default-font.bin
+
+# Uncomment the following line to enable the USB code:
+OF_FFS_FILES += $(USB_FFS_FILES)
+
+OF_FFS_FILES := $(OF_FFS_FILES:%.fs=%.fsi)
+
+OF.ffs: Makefile $(SLOFCMNDIR)/Makefile.inc $(OF_FFS_FILES)
+ $(MAKE) create_OF_ffs
+
+# Rules for cleaning up:
+.PHONY: clean_here clean distclean
+
+clean_here:
+ rm -f *.o OF.fsi OF.ffs
+
+clean: clean_here clean_slof
+
+distclean: clean_here distclean_slof
diff --git a/qemu/roms/SLOF/board-js2x/slof/OF.fs b/qemu/roms/SLOF/board-js2x/slof/OF.fs
new file mode 100644
index 000000000..3e3773580
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/OF.fs
@@ -0,0 +1,557 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+
+' ll-cr to cr
+
+\ as early as possible we want to know if it is js20, js21 or bimini
+\ u3 = js20; u4 = js21/bimini
+\ the difference if bimini or js21 will be done later depending if
+\ obsidian or citrine is found
+\ f8000000 is probably the place of the u3/u4 version
+f8000000 rl@ CONSTANT uni-n-version
+uni-n-version 4 rshift dup 3 = CONSTANT u3? 4 = CONSTANT u4?
+\ if (f4000682 >> 4) == 1... it is a bimini...
+f4000682 rb@ 4 rshift 1 = CONSTANT bimini?
+
+\ to decide wether vga initialisation using bios emulation should be attempted,
+\ we need to know wether a vga-device was found during pci-scan.
+\ If it is found, this value will be set to the device's phandle
+0 value vga-device-node?
+
+\ planar-id reads back GPIO 29 30 31 and returns it as one value
+\ if planar-id >= 5 it should be GA2 else it is GA1 (JS20 only)
+defer planar-id ( -- planar-id )
+
+: (planar-id) ( -- planar-id)
+ \ default implementation of planar-id just returns 8
+ \ the highest possible planar id for JS20 is 7
+ 8
+;
+
+' (planar-id) to planar-id
+
+#include "header.fs"
+
+\ I/O accesses.
+#include "io.fs"
+
+\ XXX: Enable first UART on JS20, scripts forget to do this. Sigh.
+3 7 siocfg! 1 30 siocfg!
+
+#include "serial.fs"
+
+cr
+
+#include "base.fs"
+
+\ Little-endian accesses. Also known as `wrong-endian'.
+#include <little-endian.fs>
+
+\ do not free-mem if address is not within the heap
+\ workaround for NVIDIA card
+: free-mem ( addr len -- )
+ over heap-start heap-end within IF
+ free-mem
+ ELSE
+ 2drop
+ THEN
+;
+
+: #join ( lo hi #bits -- x ) lshift or ;
+: #split ( x #bits -- lo hi ) 2dup rshift dup >r swap lshift xor r> ;
+
+: blink ;
+
+: reset-dual-emit ;
+
+: console-clean-fifo ;
+
+: bootmsg-nvupdate ;
+
+: asm-cout 2drop drop ;
+
+#include "logging.fs"
+
+: log-string 2drop ;
+
+#include "bootmsg.fs"
+
+000 cp
+
+\ disable the nvram logging until we know if we are
+\ running from ram/takeover/js20 or in normal mode on js21
+: (nvramlog-write-byte) drop ;
+' (nvramlog-write-byte) to nvramlog-write-byte
+
+#include "exception.fs"
+
+: mm-log-warning 2drop ;
+
+: write-mm-log ( data length type -- status )
+ 3drop 0
+;
+
+080 cp
+
+#include "rtc.fs"
+
+100 cp
+
+\ Input line editing.
+#include "accept.fs"
+
+120 cp
+
+#include "dump.fs"
+
+cistack ciregs >r1 ! \ kernel wants a stack :-)
+
+#include "romfs.fs"
+
+140 cp
+#include "flash.fs"
+
+\ 1 temp; 0 perm; let's default to temp
+1 VALUE flashside?
+
+\ claim the memory used by copy of the flash
+flash-header IF
+ romfs-base dup flash-image-size 0 claim drop
+THEN
+
+s" bootinfo" romfs-lookup drop c + l@ CONSTANT start-addr
+start-addr flash-addr <> CONSTANT takeover?
+
+takeover? u3? or 0= IF
+ \ we want nvram logging to work
+ ['] .nvramlog-write-byte to nvramlog-write-byte
+THEN
+
+160 cp
+
+u4? IF f8002100 rl@ 0= ELSE false THEN ?INCLUDE u4-mem.fs
+u3? IF
+ planar-id 5 >= IF
+ 40000 to nvram-size
+ ELSE
+ \ change nvram-size to 8000 for GA1 blades
+ 8000 to nvram-size
+ THEN
+THEN
+
+
+takeover? IF
+ \ potentially coming from phype
+ u4? IF
+ \ takeover on JS21 is using some nvram area
+ \ which might be available
+ \ on JS20 the nvram is too small and
+ \ we just overwrite the nvram
+ sec-nvram-base to nvram-base
+ THEN
+ sec-nvram-size to nvram-size
+ \ in takeover mode the nvram is probably not mapped
+ \ to the exact location where the nvram starts
+ \ doing a small check to see if we have a partition
+ \ starting with 70; this test is far from perfect but
+ \ takeover is not the most common mode of running slof
+ nvram-base rb@ 70 <> IF 0 nvram-base rb! THEN
+THEN
+
+200 cp
+
+#include <slof-logo.fs>
+#include <banner.fs>
+
+: .banner .slof-logo .banner ;
+
+\ Get the secondary CPUs into our own spinloop.
+f8000050 rl@ CONSTANT master-cpu
+\ cr .( The master cpu is #) master-cpu .
+
+VARIABLE cpu-mask
+: get-slave ( n -- online? )
+ 0 3ff8 ! 18 lshift 30000000 or 48003f02 over l! icbi 10000 0 DO LOOP 3ff8 @ ;
+: mark-online ( n -- ) 1 swap lshift cpu-mask @ or cpu-mask ! ;
+: get-slaves 40 0 DO i get-slave IF i mark-online THEN LOOP ;
+: cpu-report ( -- )
+ cpu-mask @ 40 0 DO dup 1 and IF ." #" i . THEN 1 rshift LOOP drop
+;
+
+220 cp
+master-cpu mark-online get-slaves
+
+DEFER disable-watchdog ( -- )
+DEFER find-boot-sector ( -- )
+
+
+240 cp
+\ Timebase frequency, in Hz.
+\ -1 VALUE tb-frequency
+d# 14318378 VALUE tb-frequency \ default value - needed for "ms" to work
+-1 VALUE cpu-frequency
+
+#include "helper.fs"
+260 cp
+
+#include <timebase.fs>
+
+270 cp
+
+#include <fcode/evaluator.fs>
+
+280 cp
+
+\ rtas-config is not used
+0 CONSTANT rtas-config
+
+#include "rtas.fs"
+290 cp
+s" update_flash.fs" included
+2a0 cp
+cpu-mask @ rtas-fetch-cpus drop
+
+: of-start-cpu rtas-start-cpu ;
+
+' power-off to halt
+' rtas-system-reboot to reboot
+
+: other-firmware rtas-get-flashside 0= IF 1 ELSE 0 THEN rtas-set-flashside reboot ;
+: disable-boot-watchdog rtas-stop-bootwatchdog drop ;
+' disable-boot-watchdog to disable-watchdog
+
+true value bmc?
+false value debug-boot?
+
+\ for JS21/Bimini try to detect BMC... if kcs (io @ca8) status is not ff...
+u4? IF ca8 4 + io-c@ ff = IF false to bmc? true to debug-boot? THEN THEN
+
+VARIABLE memnode
+
+\ Hook to help loading our secondary boot loader.
+DEFER disk-read ( lba cnt addr -- )
+0 VALUE disk-off
+
+create vpd-cb 24 allot
+create vpd-bootlist 4 allot
+2c0 cp
+#include "ipmi-vpd.fs"
+2e0 cp
+#include <quiesce.fs>
+300 cp
+#include <usb/usb-static.fs>
+320 cp
+#include <scsi-loader.fs>
+#include <root.fs>
+360 cp
+#include "tree.fs"
+
+: .system-information ( -- )
+ s" " type cr
+ s" SYSTEM INFORMATION" type cr
+ s" Processor = " type s" cpu" get-chosen IF
+ drop l@ >r pvr@ s" pvr>name" r> $call-method type
+ s" @ " type cpu-frequency d# 1000000 /
+ decimal . hex s" MHz" type
+ THEN cr s" I/O Bridge = " type u3? IF
+ s" U3" ELSE s" U4" THEN type
+ f8000000 rl@ 4 rshift s" (" type 1 0.r s" ." type
+ f8000000 rl@ f and 1 0.r s" )" type cr
+ s" SMP Size = " type cpu-mask @ cnt-bits 1 0.r
+ s" (" type cpu-report 8 emit s" )" type
+ cr s" Boot-Date = " type .date cr
+ s" Memory = " type s" memory" get-chosen IF
+ drop l@ s" mem-report" rot $call-method THEN
+ cr s" Board Type = " type u3? IF
+ s" JS20(GA" type planar-id 5 >= IF
+ s" 2)" ELSE s" 1)" THEN type
+ ELSE bimini? IF s" Bimini" ELSE s" JS21" THEN type THEN
+ s" (" type .vpd-machine-type [char] / emit
+ .vpd-machine-serial [char] / emit
+ .vpd-hw-revision 8 emit s" )" type cr
+ s" MFG Date = " type .vpd-manufacturer-date cr
+ s" Part No. = " type .vpd-part-number cr
+ s" FRU No. = " type .vpd-fru-number cr
+ s" FRU Serial = " type .vpd-cardprefix-serial .vpd-card-serial cr
+ s" UUID = " type .vpd-uuid cr
+ s" Flashside = " type rtas-get-flashside 0= IF
+ ." 0 (permanent)"
+ ELSE
+ ." 1 (temporary)" THEN cr
+ s" Version = " type
+ takeover? IF
+ romfs-base 38 + a type
+ ELSE
+ slof-build-id here swap rmove
+ here slof-build-id nip type cr
+ s" Build Date = " type bdate2human type
+ THEN
+ cr cr
+;
+
+800 cp
+
+#include "nvram.fs"
+takeover? not u4? and IF
+ \ if were are not in takeover mode the nvram should look
+ \ something like this:
+ \ type size name
+ \ ========================
+ \ 51 20000 ibm,CPU0log
+ \ 51 5000 ibm,CPU1log
+ \ 70 1000 common
+ \ 7f da000 <free-space>
+ \ the partition with the type 51 should have been added
+ \ by LLFW... if it does not exist then something went
+ \ wrong and we just destroy the whole thing
+ 51 get-nvram-partition IF 0 0 nvram-c! ELSE 2drop THEN
+THEN
+
+880 cp
+
+\ dmesg/dmesg2 not available if running in takeover/ram mode or on js20
+: dmesg ( -- ) u3? takeover? or 0= IF dmesg THEN ;
+: dmesg2 ( -- ) u3? takeover? or 0= IF dmesg2 THEN ;
+
+#include "envvar.fs"
+check-for-nvramrc
+
+8a0 cp
+\ The client interface.
+#include "client.fs"
+\ ELF binary file format.
+#include "elf.fs"
+#include <loaders.fs>
+
+8a8 cp
+
+\ check wether a VGA device was found during pci scan, if it was
+\ try to initialize it and create the needed device-nodes
+0 value biosemu-vmem
+100000 value biosemu-vmem-size
+0 value screen-info
+
+: init-vga-devices ( -- )
+ vga-device-node? 0= use-biosemu? 0= OR IF
+ EXIT
+ THEN
+ s" VGA Device found: " type vga-device-node? node>path type s" initializing..." type cr
+ \ claim virtual memory for biosemu of 1MB
+ biosemu-vmem-size 4 claim to biosemu-vmem
+ \ claim memory for screen-info struct (140 bytes)
+ d# 140 4 claim to screen-info
+ \ remember current-node (it might be node 0 so we cannot use get-node)
+ current-node @
+ \ change into vga device node
+ vga-device-node? set-node
+ \ run biosemu to initialize the vga card
+ \ s" Time before biosemu:" type .date cr
+ vga-device-node? node>path ( pathstr len )
+ s" biosemu " biosemu-vmem $cathex ( pathstr len paramstr len )
+ 20 char-cat \ add a space ( pathstr len paramstr len )
+ biosemu-vmem-size $cathex \ add VMEM Size ( pathstr len paramstr len )
+ 20 char-cat \ add a space ( pathstr len paramstr len )
+ 2swap $cat ( paramstr+path len )
+ biosemu-debug 0<> IF
+ 20 char-cat biosemu-debug $cathex \ add biosemu-debug as param
+ ( paramstr+path+biosemu-debug len )
+ THEN
+ .(client-exec) IF
+ ." biosemu client exec failed!" cr
+ set-node \ restore old current-node
+ EXIT
+ THEN
+ \ s" Time after biosemu:" type .date cr
+ s" VGA initialization: detecting displays..." type cr
+ \ try to get info for two monitors
+ 2 0 DO
+ \ setup screen-info struct as input to get_vbe_info
+ s" DDC" 0 char-cat screen-info swap move \ null-terminated "DDC" as signature
+ d# 140 screen-info 4 + w! \ reserved size in bytes (see claim above)
+ i screen-info 6 + c! \ monitor number
+ \ 320 screen-info 7 + w! \ max. screen width (800)
+ 500 screen-info 7 + w! \ max. screen width (1280)
+ \ following line would be the right thing to do, however environment seems not setup yet...
+ \ screen-#columns char-width * 500 min 280 max screen-info 7 + w! \ max. screen width, calculated from environment variable screen-#columns, but max. 1280, min. 640...
+ 8 screen-info 9 + c! \ requested color depth (8bpp)
+ \ d# 16 screen-info 9 + c! \ requested color depth (16bpp)
+ \ execute get_vbe_info from load-base
+ \ s" Time before client exec:" type .date cr
+ \ since node>path overwrites strings created with s"
+ \ we need to call it before assembling the parameter string
+ vga-device-node? node>path ( pathstr len )
+ s" get_vbe_info " biosemu-vmem $cathex ( pathstr len paramstr len )
+ 20 char-cat \ add a space ( pathstr len paramstr len )
+ biosemu-vmem-size $cathex \ add VMEM Size ( pathstr len paramstr len )
+ 20 char-cat \ add a space ( pathstr len paramstr len )
+ 2swap $cat ( paramstr+path len )
+ 20 char-cat
+ screen-info $cathex
+ .(client-exec) 0=
+ \ s" Time after client exec:" type .date cr
+ screen-info c@ 0<> AND IF
+ s" display " type i . s" found..." type
+ \ screen found
+ \ create device entry
+ get-node node>name \ get current nodes name (e.g. "vga") ( str len )
+ i \ put display-num on the stack ( str len displaynum )
+ new-device \ create new device
+ s" vga-display.fs" included
+ finish-device
+ s" created." type cr
+ THEN
+ LOOP
+ \ return to where we were before changing to vga device node
+ set-node
+ \ release the claimed memory
+ screen-info d# 140 release
+ biosemu-vmem biosemu-vmem-size release
+
+ s" VGA initialization done." type cr
+;
+
+init-vga-devices
+
+: enable-framebuffer-output ( -- )
+\ enable output on framebuffer
+ s" screen" find-alias ?dup IF
+ \ we need to open/close the screen device once
+ \ before "ticking" display-emit to emit
+ open-dev close-node
+ s" display-emit" $find IF
+ to emit
+ ELSE
+ 2drop
+ THEN
+ THEN
+;
+
+enable-framebuffer-output
+
+8b0 cp
+
+\ do not let the usb scan overwrite the atapi cdrom alias
+\ pci-cdrom-num TO cdrom-alias-num
+usb-scan
+
+: create-aliases ( -- )
+ s" net" s" net1" find-alias ?dup IF set-alias ELSE 2drop THEN
+ s" disk" s" disk0" find-alias ?dup IF set-alias ELSE 2drop THEN
+ s" cdrom" s" cdrom0" find-alias ?dup IF set-alias ELSE 2drop THEN
+;
+
+create-aliases
+
+8ff cp
+
+.system-information
+
+: directserial
+u3? IF
+ s" /ht/isa/serial@3f8" io
+ELSE
+ s" direct-serial?" evaluate IF s" /ht/isa/serial@2f8" io ELSE s" /ht/isa/serial@3f8" io THEN
+THEN
+;
+
+directserial
+
+\ on bimini we want to automatically enable screen and keyboard, if they are detected...
+bimini? IF
+ key? IF
+ cr ." input available on current console input device, not switching input / output." cr
+ ELSE
+ \ this enables the framebuffer as primary output device
+ s" screen" find-alias IF drop
+ s" screen" output
+ \ at this point serial output is theoretically disabled
+ ." screen detected and set as default output device" cr
+ THEN
+ \ enable USB keyboard
+ s" keyboard" find-alias IF drop
+ s" keyboard" input
+ \ at this point serial input is disabled
+ ." keyboard detected and set as default input device" cr cr cr
+ s" Press 's' to enter Open Firmware." type cr
+ 500 ms
+ THEN
+ THEN
+THEN
+
+: .flashside
+ cr ." The currently active flashside is: "
+ rtas-get-flashside 0= IF ." 0 (permanent)" ELSE
+ ." 1 (temporary)" THEN
+;
+
+bmc? IF disable-watchdog THEN
+
+: flashsave ( "{filename}" -- rc )
+ (parse-line) dup 0> IF
+ s" netsave " \ command
+ get-flash-base $cathex \ Flash base addr
+ s" 400000 " $cat \ Flash size (4MB)
+ 2swap $cat \ add parameters from (parse-line)
+ evaluate
+ ELSE
+ cr
+ ." Usage: flashsave [bootp|dhcp,]filename[,siaddr][,ciaddr][,giaddr][,bootp-retries][,tftp-retries][,use_ci]"
+ cr 2drop
+ THEN
+;
+
+#include <vpd-bootlist.fs>
+
+\ for the blades we read the bootlist from the VPD
+bimini? takeover? or 0= IF ['] vpd-boot-import to read-bootlist THEN
+
+\ for the bimini, we try to boot from disk, if it exists,
+\ only if "boot-device" is not set in the nvram
+: bimini-bootlist
+ \ check nvram
+ s" boot-device" evaluate swap drop ( boot-device-strlen )
+ 0= IF
+ \ no boot-device set in NVRAM, check if disk is available and set it...
+ \ clear boot-device list
+ 0 0 set-boot-device
+ s" disk" find-alias ?dup IF
+ \ alias found, use it as default
+ add-boot-device
+ THEN
+ THEN
+;
+
+bimini? IF ['] bimini-bootlist to read-bootlist THEN
+
+#include <start-up.fs>
+
+#include <boot.fs>
+
+cr .( Welcome to Open Firmware)
+cr
+#include "copyright-oss.fs"
+cr
+
+\ this CATCH is to ensure the code bellow always executes: boot may ABORT!
+' start-it CATCH drop
+
+#include <history.fs>
+nvram-history? [IF]
+." loading shell history .. "
+history-load
+." done" cr
+[THEN]
+
diff --git a/qemu/roms/SLOF/board-js2x/slof/attu.fs b/qemu/roms/SLOF/board-js2x/slof/attu.fs
new file mode 100644
index 000000000..cc1225296
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/attu.fs
@@ -0,0 +1,101 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+\ U4 "Attu" PCIe root complex.
+
+\ See the PCI OF binding document.
+
+new-device
+
+s" pciex" device-name s" pci" device-type
+s" U4-pcie" compatible
+s" U4" encode-string s" model" property
+
+\ spare out 0xc0000000-0xefffffff for pcie
+f8070200 rl@ fffffff0 and f8070200 rl!
+\ enable io memory for pcie @ c0000000-efffffff
+70000003 f80903f0 rl!-le
+
+3 encode-int s" #address-cells" property
+2 encode-int s" #size-cells" property
+
+s" /mpic" find-node encode-int s" interrupt-parent" property
+\ XXX should have interrupt map, etc. this works for now though.
+
+: decode-unit 2 hex-decode-unit 3 #join 8 lshift 0 0 rot F00000 + ;
+: encode-unit nip nip ff00 and 8 rshift 3 #split
+ over IF 2 ELSE nip 1 THEN hex-encode-unit ;
+
+f1000000 CONSTANT my-puid
+\ Configuration space accesses.
+: >config f1000000 + ;
+: 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@ ;
+
+: config-dump ( addr size -- ) ['] config-l@ 4 (dump) ;
+
+\ 16MB of configuration space
+f1000000 encode-64 1000000 encode-64+ s" reg" property
+
+\ 4MB of I/O space.
+01000000 encode-int 00000000 encode-int+ 00000000 encode-int+
+00000000 encode-int+ f0000000 encode-int+
+00000000 encode-int+ 00400000 encode-int+
+
+\ 1.75GB of memory space @ c0000000.
+02000000 encode-int+ c0000000 encode-64+
+c0000000 encode-64+ 30000000 encode-64+ s" ranges" property
+
+\ Host bridge, so full bus range.
+f0 encode-int ff encode-int+ s" bus-range" property
+
+: open true ;
+: close ;
+
+\ : probe-pci-host-bridge ( bus-max bus-min mmio-max mmio-base mem-max mem-base io-max io-base my-puid -- )
+s" /mpic" find-node my-puid pci-irq-init drop
+
+00fff1f0 18 config-l!
+
+ff F0 f0000000 e8000000 e8000000 c0000000 100000000 f000
+my-puid probe-pci-host-bridge
+
+\ \ PCIe debug / fixup
+: find-pcie-cap ( devfn -- offset | 0 )
+ >r 34 BEGIN r@ + config-b@ dup ff <> over and WHILE
+ dup r@ + config-b@ 10 = IF
+ r> drop EXIT
+ THEN 1+
+ REPEAT r> 2drop 0
+;
+
+ : (set-ps) ( ps addr -- )
+ 8 + >r 5 lshift r@ config-w@ ff1f and or r> config-w! ;
+ : set-ps ( ps -- )
+ log2 7 -
+ 10000 0 DO i 8 lshift dup find-pcie-cap ?dup IF
+ + 2dup (set-ps) THEN drop LOOP drop ;
+
+ : (set-rr) ( rr addr -- )
+ 8 + >r c lshift r@ config-w@ 8fff and or r> config-w! ;
+ : set-rr ( rr -- )
+ log2 7 -
+ 10000 0 DO i 8 lshift dup find-pcie-cap ?dup IF
+ + 2dup (set-rr) THEN drop LOOP drop ;
+
+80 set-ps 80 set-rr
+
+finish-device
diff --git a/qemu/roms/SLOF/board-js2x/slof/bcm57xx.fs b/qemu/roms/SLOF/board-js2x/slof/bcm57xx.fs
new file mode 100644
index 000000000..c8e6f5aa9
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/bcm57xx.fs
@@ -0,0 +1,75 @@
+\ *****************************************************************************
+\ * Copyright (c) 2013 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
+\ ****************************************************************************/
+
+\ Handle bcm57xx device
+
+s" network" device-type
+
+my-space pci-alias-net
+
+VARIABLE obp-tftp-package
+
+0 VALUE bcm57xx-priv
+0 VALUE open-count
+
+: open ( -- okay? )
+ open-count 0= IF
+ open IF
+ bcm57xx-open dup not IF ." bcm57xx-open failed" EXIT THEN
+ drop dup TO bcm57xx-priv
+ 6 encode-bytes s" local-mac-address" property
+ true
+ ELSE
+ false
+ THEN
+ ELSE
+ true
+ THEN
+ my-args s" obp-tftp" $open-package obp-tftp-package !
+ open-count 1 + to open-count
+;
+
+
+: close ( -- )
+ open-count 0> IF
+ open-count 1 - dup to open-count
+ 0= IF
+ bcm57xx-priv bcm57xx-close
+ close
+ THEN
+ THEN
+ s" close" obp-tftp-package @ $call-method
+;
+
+: read ( buf len -- actual )
+ dup IF
+ bcm57xx-read
+ ELSE
+ nip
+ THEN
+;
+
+: write ( buf len -- actual )
+ dup IF
+ bcm57xx-write
+ ELSE
+ nip
+ THEN
+;
+
+: load ( addr -- len )
+ s" load" obp-tftp-package @ $call-method
+;
+
+: ping ( -- )
+ s" ping" obp-tftp-package @ $call-method
+;
diff --git a/qemu/roms/SLOF/board-js2x/slof/citrine-disk.fs b/qemu/roms/SLOF/board-js2x/slof/citrine-disk.fs
new file mode 100644
index 000000000..146e7ece3
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/citrine-disk.fs
@@ -0,0 +1,79 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+
+( max-#blocks rsrc id -- )
+
+new-device
+
+lwsplit swap wbsplit rot set-unit
+
+s" disk" device-name s" block" device-type
+
+CONSTANT resource-id
+CONSTANT max-#blocks
+get-parent CONSTANT ppack
+
+
+: our-disk-read ( lba count addr -- )
+ >r >r >r resource-id r> r> r> s" do-read" ppack $call-static ;
+
+0 pci-alias-disk
+
+\ Requiered interface for deblocker
+
+200 CONSTANT block-size
+40000 CONSTANT max-transfer
+
+: read-blocks ( addr block# #blocks -- #read )
+\ my-unit s" dev-read-blocks" $call-parent
+ \ check if the read is within max-#blocks
+ 2dup + max-#blocks 1 + > IF
+ \ 2drop drop 0 \ return 0
+ \ returning 0 would be correct (maybe?) but it confuses the deblocker...
+ \ so i erase whatever would have been read and return the "expected" #read
+ dup >r
+ swap drop \ drop block# (not needed)
+ block-size * erase \ erase at addr #blocks * block-size
+ r> \ return #read
+ ELSE
+ dup >r rot our-disk-read r>
+ THEN
+;
+
+INSTANCE VARIABLE deblocker
+
+: open ( -- okay? )
+ 0 0 s" deblocker" $open-package dup deblocker ! dup IF
+ s" disk-label" find-package IF
+ my-args rot interpose
+ THEN
+ THEN 0<> ;
+
+: close ( -- )
+ deblocker @ close-package ;
+
+: seek ( pos.lo pos.hi -- status )
+ 2dup lxjoin max-#blocks 1 + block-size * > IF
+ \ illegal seek, return -1
+ 2drop -1
+ ELSE
+ s" seek" deblocker @ $call-method
+ THEN
+;
+
+: read ( addr len -- actual )
+ s" read" deblocker @ $call-method ;
+
+
+finish-device
+
diff --git a/qemu/roms/SLOF/board-js2x/slof/citrine-flash.fs b/qemu/roms/SLOF/board-js2x/slof/citrine-flash.fs
new file mode 100644
index 000000000..5842b07c9
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/citrine-flash.fs
@@ -0,0 +1,36 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+
+\ we do all flash accesses as 8-bit
+
+9f000000 CONSTANT citrine-flash-addr
+
+: >citrine-flash citrine-flash-addr + ;
+: citrine-flash@ >citrine-flash rb@ ;
+: citrine-flash! >citrine-flash rb! ;
+: wait-for-citrine-flash-ready BEGIN 0 citrine-flash@ 80 and UNTIL ;
+: erase-citrine-flash-block ( offset -- )
+ cr dup 8 .r ." Erasing..."
+ 20 over citrine-flash! d0 swap citrine-flash! wait-for-citrine-flash-ready ;
+: write-citrine-flash ( data offset -- )
+ over ff = IF 2drop EXIT THEN
+ 40 over citrine-flash! citrine-flash! wait-for-citrine-flash-ready ;
+: write-citrine-flash-block ( addr offset -- ) \ always writes 128kB!
+ ." Writing..."
+ 20000 0 DO over i + c@ over i + write-citrine-flash LOOP 2drop
+ ." Done." ;
+: citrine-flash ( addr offset size -- )
+ BEGIN dup 0 > WHILE >r dup erase-citrine-flash-block
+ 2dup write-citrine-flash-block >r 20000 + r> 20000 + r> 20000 - REPEAT
+ drop 2drop -1 0 citrine-flash! ;
+
diff --git a/qemu/roms/SLOF/board-js2x/slof/citrine.fs b/qemu/roms/SLOF/board-js2x/slof/citrine.fs
new file mode 100644
index 000000000..ad6777699
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/citrine.fs
@@ -0,0 +1,245 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+
+\ Citrine storage controller.
+2dup type
+
+device-name s" ide" device-type
+
+
+3 encode-int s" #address-cells" property
+0 encode-int s" #size-cells" property
+
+: decode-unit 3 hex-decode-unit ;
+: encode-unit 3 hex-encode-unit ;
+
+
+: >ioa [ 10 config-l@ -10 and ] LITERAL + ;
+: ioa@ >ioa rl@-le ;
+: ioa! >ioa rl!-le ;
+
+
+\ Clear request completion doorbell.
+2 228 ioa!
+
+\ status
+CREATE ioasa 200 allot ioasa 200 erase \ can reduce to 8 later
+
+\ request/response queue
+CREATE rrq 100 allot rrq 100 erase \ can be smaller
+
+\ data descriptor
+CREATE ioadl 8 allot
+
+\ control block
+CREATE ioarcb 80 allot ioarcb 80 erase
+ioarcb dup l!
+60708090 ioarcb c + l! \ user handle
+ioadl ioarcb 2c + l! \ read ioadl
+ioasa ioarcb 34 + l! 200 ioarcb 38 + w!
+
+\ ioa config data (max. 16 devices)
+CREATE ioacfg 404 allot ioacfg 404 erase
+CREATE setsupbuff 2c allot
+ setsupbuff 2c erase
+ 2c setsupbuff w!
+ 1 setsupbuff 3 + c!
+
+: wait-ready ( -- )
+ 82800000 214 ioa!
+ 80000000 BEGIN dup 224 ioa@ cr .s dup 8000000 and IF
+ cr ." Unit check on SAS-Controller detected"
+ cr 42c ioa@ .
+ 8 110 ioa!
+ BEGIN cr 0 config-l@ dup . ffffffff <> UNTIL
+\ ABORT" Unit check on SAS-Controller detected"
+ THEN
+ and
+ UNTIL drop
+;
+
+\ wait-ready
+
+: wait-ioa ( int-mask -- ) BEGIN dup 224 ioa@ and UNTIL drop ;
+: init-ioa ( -- ) 82800000 214 ioa! 80000000 wait-ioa ;
+: do-request ( -- ) ioasa 20 erase ioarcb 404 ioa!
+ 2 wait-ioa 2 228 ioa!
+;
+
+: setup-ioarcb ( rsrc type addr len -- )
+ tuck 49000000 or ioadl l! ioadl 4 + l! \ setup ioadl
+ ioarcb 20 + l! ioadl ioarcb 2c + l! 8 ioarcb 30 + l! \ set len, ioadl addr
+ ioarcb 3e + c! ioarcb 8 + l! \ set type and resource
+ ioarcb 40 + 40 erase ;
+
+: setup-wrioarcb ( rsrc type addr len -- )
+ tuck 49000000 or ioadl l! ioadl 4 + l! \ setup ioadl
+ ioarcb 1C + l! ioadl ioarcb 24 + l! 8 ioarcb 28 + l! \ set len, ioadl addr
+ ioarcb 3e + c! ioarcb 8 + l! \ set type and resource
+ ioarcb 40 + 40 erase ;
+
+: setup-idrrq ( rrq len -- )
+ c4 ioarcb 42 + c! 8 lshift ioarcb 48 + l! ioarcb 44 + l! ;
+: do-idrrq ( -- ) -1 1 0 0 setup-ioarcb rrq 100 setup-idrrq do-request ;
+
+: setup-query ( len -- ) c5 ioarcb 42 + c! 8 lshift ioarcb 48 + l! ;
+: do-query ( -- ) -1 1 ioacfg 404 setup-ioarcb 404 setup-query do-request ;
+
+: setup-startUnit ( -- ) 1b ioarcb 42 + c! 3 ioarcb 46 + c! ;
+: do-startUnit ( hndl -- ) 0 0 0 setup-ioarcb setup-startUnit do-request ;
+
+: setup-setsupported ( len -- ) 80 ioarcb 40 + c! fb ioarcb 42 + c! 8 lshift ioarcb 48 + l! ;
+: do-setsupported ( -- ) -1 1 setsupbuff 2c setup-wrioarcb 2c setup-setsupported do-request ;
+
+\ ********************************
+\ read capacity
+\ ********************************
+CREATE cap 8 allot
+
+: setup-cap ( -- ) 25 ioarcb 42 + c! cap 8 erase ;
+: do-cap ( rsrc addr -- )
+ >r 0 r> 8 setup-ioarcb setup-cap do-request ;
+
+: .id ( id -- ) ." @" lwsplit 2 0.r ." ," wbsplit 2 0.r ." ," 2 0.r ;
+
+: .cap ( rsrc -- )
+ cap do-cap cap l@ cap 4 + l@ * d# 50000000 + d# 100000000 /
+ base @ >r decimal d# 10 /mod 4 .r ." ." 0 .r ." GB" r> base ! ;
+
+\ ********************************
+\ Test Unit Ready
+\ ********************************
+: setup-test-unit-ready ( -- )
+ 00 ioarcb 42 + c! \ SCSI cmd: Test-Unit-Ready
+;
+
+: do-test-unit-ready ( rsrc -- )
+ 0 0 0 setup-ioarcb ( rsrc type addr len -- )
+ setup-test-unit-ready
+ do-request
+;
+
+\ ********************************
+\ Check devices
+\ ********************************
+: check-device ( ioacfg-entry -- )
+ dup 2 + w@ 2001 and 0<> \ generic or raid disk
+ IF \ is an IOA resource ?
+ dup 8 + l@ ( ioacfg-entry rsrc ) \ get resource handle
+ 8 0
+ DO ( ioacfg-entry rsrc )
+ dup do-test-unit-ready ( ioacfg-entry rsrc )
+ ioasa l@ 0= \ read returned status
+ IF
+ LEAVE
+ THEN
+ LOOP
+ drop ( ioacfg-entry )
+ THEN
+ drop ( )
+;
+
+: check-devices ( -- )
+ ioacfg 4 + ( ioacfg-entry ) \ config block for 16 devices
+ ioacfg c@ 0 \ amount of detected devices
+ ?DO
+ dup
+ check-device ( ioacfg-entry )
+ 40 +
+ LOOP
+ drop
+;
+
+\ ********************************
+\ Show Devices
+\ ********************************
+: show-device ( ioacfg-entry -- )
+ cr ." " dup 2 + w@
+ dup 8000 and IF ." Controller :" THEN
+ dup 2000 and IF ." Disk (RAID Member):" THEN
+ dup 0002 and IF ." Disk (Volume Set) :" THEN
+ 0001 and IF ." Disk (Generic) :" THEN
+ space dup 4 + l@ ffffff and dup ffffff <> IF
+ .id
+ ELSE drop 9 spaces THEN space
+ dup 1c + 8 type space dup 24 + 10 type
+ dup 2 + w@ 8000 and 0= IF
+ space dup 8 + l@ .cap
+ THEN drop
+;
+
+: show-devices ( -- )
+ ioacfg 4 + ioacfg c@ 0
+ ?DO dup show-device 40 + LOOP drop
+;
+
+: setup-read ( lba len -- ) \ len is in blocks
+ 28 ioarcb 42 + c!
+ swap ioarcb 44 + l!
+ 8 lshift ioarcb 48 + l!
+;
+
+: do-read ( hndl lba len addr -- ) \ len is in blocks
+ over >r rot >r swap 0 -rot 200 * ( 0 hndl addr len* )
+ setup-ioarcb r> r> ( lba len )
+ setup-read do-request
+;
+
+: make-subnode ( rsrc-type rsrc-handle id -- )
+ rot 2 and IF \ only device which are part of a RAID should be started
+ over do-startUnit \ at least on citrine there are problems starting
+ \ Generic SCSI devices
+ THEN do-setsupported
+ dup ffffff <> IF
+ \ we need max-#blocks for citrine-disk.fs
+ ( rsrc id )
+ over cap do-cap cap l@ ( rsrc id max-#blocks )
+ swap rot swap ( max-#block rsrc id ) \ this is what citrine-disk.fs expects...
+ s" citrine-disk.fs" included
+ ELSE
+ 2drop
+ THEN
+;
+
+: make-subnodes ( -- )
+ ioacfg 4 + ioacfg c@ 0 ?DO dup 2 + w@ dup ( ioacfg rsrc-type rsrc-type )
+ A000 \ 8000 = Resource Subtype is IOA Focal Point.
+ \ 2000 = Device is a member of a data redundancy group (eg. RAID).
+ \ (1000 = Device is designated for use as a hot spare.
+ \ Unfortunately obsidian reports disk which are not part of
+ \ of a RAID also as hot space even if they are not.)
+ \ all these devices should not appeat in DT
+ \ SIS40 page 60
+ and 0= IF
+ swap dup ( rsrc-type ioacfg ioacfg )
+ 8 + l@ over 4 + l@ ( rsrc-type ioacfg rsrc-handle rsrc-addr )
+ ffffff and 2swap swap 2swap ( ioacfg rsrc-type rsrc-handle rsrc-addr )
+ make-subnode ELSE drop THEN 40 + LOOP drop ;
+
+: do-it ( -- )
+ init-ioa do-idrrq
+ do-query
+ check-devices
+ show-devices
+;
+
+: setup-shutdown ( -- )
+ f7 ioarcb 42 + c! 0 ioarcb 48 + l! 0 ioarcb 44 + l! ;
+: do-shutdown ( -- ) -1 1 0 0 setup-ioarcb setup-shutdown do-request ;
+
+: open true ;
+: close ;
+
+: start ['] do-it CATCH IF cr ." Citrine disabled" ELSE make-subnodes THEN ;
+
+cr start cr cr
diff --git a/qemu/roms/SLOF/board-js2x/slof/copyright-oss.fs b/qemu/roms/SLOF/board-js2x/slof/copyright-oss.fs
new file mode 100644
index 000000000..06f9a3ada
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/copyright-oss.fs
@@ -0,0 +1,16 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+cr .( Copyright (c) char ) emit .( 2004, 2008 IBM Corporation All rights reserved.)
+cr .( This program and the accompanying materials are made available)
+cr .( under the terms of the BSD License available at)
+cr .( http://www.opensource.org/licenses/bsd-license.php)
diff --git a/qemu/roms/SLOF/board-js2x/slof/cpu.fs b/qemu/roms/SLOF/board-js2x/slof/cpu.fs
new file mode 100644
index 000000000..bee07d108
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/cpu.fs
@@ -0,0 +1,44 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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...
+
+( cpu# -- )
+new-device set-space
+
+: pvr>name s" PowerPC," rot 10 rshift CASE
+ 39 OF s" 970" ENDOF
+ 3c OF s" 970FX" ENDOF
+ 44 OF 1 my-space 1 xor lshift cpu-mask @ and IF
+ s" 970MP" ELSE s" 970GX" THEN ENDOF
+ \ On GX CPUs, the sibling is missing, numbering is the same.
+ dup dup OF 0 <# # # # # [char] # hold #> ENDOF ENDCASE $cat ;
+
+pvr@ pvr>name device-name
+s" cpu" device-type
+
+my-space 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
+
+: open true ;
+: close ;
+
+
+finish-device
diff --git a/qemu/roms/SLOF/board-js2x/slof/dart.fs b/qemu/roms/SLOF/board-js2x/slof/dart.fs
new file mode 100644
index 000000000..8fdac83f9
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/dart.fs
@@ -0,0 +1,31 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+
+\ CPC9x5 DART.
+
+new-device
+
+s" dart" 2dup device-name device-type
+u3? IF s" u3-dart" compatible THEN
+u4? IF s" u4-dart" compatible THEN
+
+0 encode-int f8033000 encode-int+
+0 encode-int+ 7000 encode-int+ s" reg" property
+
+: open true ;
+: close ;
+
+\ Now clear and disable the DART.
+20000000 f8033000 rl!
+
+finish-device
diff --git a/qemu/roms/SLOF/board-js2x/slof/flash.fs b/qemu/roms/SLOF/board-js2x/slof/flash.fs
new file mode 100644
index 000000000..110f5c86b
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/flash.fs
@@ -0,0 +1,43 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+
+\ we do all flash accesses as 8-bit
+
+ff000000 CONSTANT flash-addr
+
+: >flash flash-addr + ;
+: flash@ >flash rb@ ;
+: flash! >flash rb! ;
+: wait-for-flash-ready BEGIN 0 flash@ 80 and UNTIL ;
+: erase-flash-block ( offset -- )
+ cr dup 8 .r ." Erasing..."
+ 20 over flash! d0 swap flash! wait-for-flash-ready ;
+: write-flash ( data offset -- )
+ 40 over flash! flash! wait-for-flash-ready ;
+: write-flash-buffer ( addr offset -- )
+ e8 over flash! wait-for-flash-ready 1f over flash!
+ 20 0 DO over i + c@ over i + flash! LOOP
+ d0 over flash! wait-for-flash-ready 2drop ;
+: write-flash-block ( addr offset -- ) \ always writes 128kB!
+ ." Writing..."
+ 20000 0 DO over i + over i + write-flash-buffer 20 +LOOP 2drop
+ ." Done." ;
+: flash ( addr offset size -- )
+ BEGIN dup 0 > WHILE >r dup erase-flash-block 2dup write-flash-block
+ >r 20000 + r> 20000 + r> 20000 - REPEAT drop 2drop -1 0 flash! ;
+
+: flash-it get-load-base 0 e0000 flash ;
+: flash4 get-load-base 0 400000 flash ;
+
+\ for update-flash
+: flash-image-size ( addr -- size ) 30 + rx@ ;
diff --git a/qemu/roms/SLOF/board-js2x/slof/freq.fs b/qemu/roms/SLOF/board-js2x/slof/freq.fs
new file mode 100644
index 000000000..9f1d36d78
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/freq.fs
@@ -0,0 +1,39 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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 TO tb-frequency d# 100000000 round-to TO cpu-frequency
+
+\ Stop HPET.
+0 10 hpet!
diff --git a/qemu/roms/SLOF/board-js2x/slof/header.fs b/qemu/roms/SLOF/board-js2x/slof/header.fs
new file mode 100644
index 000000000..be2b7221c
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/header.fs
@@ -0,0 +1,19 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+
+get-flash-base VALUE flash-addr
+
+get-nvram-base CONSTANT nvram-base
+get-nvram-size CONSTANT nvram-size
+ff8f9000 CONSTANT sec-nvram-base \ save area from phype.... not really known
+2000 CONSTANT sec-nvram-size
diff --git a/qemu/roms/SLOF/board-js2x/slof/helper.fs b/qemu/roms/SLOF/board-js2x/slof/helper.fs
new file mode 100644
index 000000000..34d60da1f
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/helper.fs
@@ -0,0 +1,28 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+: slof-build-id ( -- str len )
+ flash-header 10 + a
+;
+
+: slof-revision s" 001" ;
+
+: read-version-and-date
+ flash-header 0= IF
+ s" " encode-string
+ ELSE
+ flash-header 10 + 10
+ here swap rmove
+ here 10
+ s" , " $cat
+ bdate2human $cat encode-string THEN
+;
diff --git a/qemu/roms/SLOF/board-js2x/slof/ht.fs b/qemu/roms/SLOF/board-js2x/slof/ht.fs
new file mode 100644
index 000000000..8f818a825
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/ht.fs
@@ -0,0 +1,189 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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" 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
+
+s" /mpic" find-node encode-int s" interrupt-parent" property
+
+4000 encode-int 0 encode-int+ 0 encode-int+
+1 encode-int+ s" /mpic" find-node encode-int+
+10 encode-int+ 0 encode-int+
+s" interrupt-map" property
+
+f800 encode-int 0 encode-int+ 0 encode-int+
+7 encode-int+ s" interrupt-map-mask" property
+
+: decode-unit 2 hex-decode-unit 3 lshift or
+ 8 lshift 0 0 rot ;
+: encode-unit nip nip ff00 and 8 rshift dup 7 and swap 3 rshift
+ over IF 2 ELSE nip 1 THEN hex-encode-unit ;
+
+f2000000 CONSTANT my-puid
+\ Configuration space accesses.
+: >config dup ffff > IF 1000000 + THEN f2000000 + ;
+
+\ : config-l! >config cr ." config-l! " 2dup . space . rl!-le ;
+\ : config-l@ >config cr ." config-l@ " dup . rl@-le space dup . ;
+\ : config-w! >config cr ." config-w! " 2dup . space . rw!-le ;
+\ : config-w@ >config cr ." config-w@ " dup . rw@-le space dup . ;
+\ : config-b! >config cr ." config-b! " 2dup . space . rb! ;
+\ : config-b@ >config cr ." config-b@ " dup . rb@ space dup . ;
+
+: 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@ ;
+
+: config-dump ( addr size -- ) ['] config-l@ 4 (dump) ;
+
+
+\ 16MB of configuration space, separate 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 GB of memory space @ 80000000
+02000000 encode-int+ 00000000 encode-int+ 80000000 encode-int+
+00000000 encode-int+ 80000000 encode-int+
+00000000 encode-int+ 40000000 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 3c0300fe f8070200 rl! ;
+enable-ht-apic-space
+
+\ spare out 0xc0000000-0xefffffff for pcie
+f8070200 rl@ fffffff0 and f8070200 rl!
+\ enable io memory for pcie @ c0000000-efffffff
+70000003 f80903f0 rl!-le
+
+
+\ Workaround for "takeover" boot on JS20: the top 8131 is programmed to be
+\ device #1f, while it should be #01.
+u3? IF f800 config-l@ 74501022 = IF 41 f8c2 config-w! THEN THEN
+
+\ Assign BUIDs.
+
+: find-ht-primary
+ 34 BEGIN config-b@ dup 0= ABORT" No HT capability block found!"
+ dup config-l@ e00000ff and 8 = IF 2 + EXIT THEN 1 + AGAIN ;
+
+: assign-buid ( this -- next )
+ find-ht-primary dup >r config-w@ 5 rshift 1f and over r> config-b! + ;
+
+: assign-buids ( -- )
+ 1 BEGIN 0 config-l@ ffffffff <> WHILE assign-buid REPEAT drop ;
+
+assign-buids
+
+: ldtstop f8000840 rl@ 40000 or f8000840 rl! ;
+: delay 100000 0 DO LOOP ;
+: wait-for-done BEGIN f8070110 rl@ 30 and UNTIL
+ BEGIN 8b4 config-l@ 30 and UNTIL ;
+: ldtstop1 f8000840 rl@ dup 20000 or f8000840 rl! delay
+ f8000840 rl! wait-for-done ;
+: warm 400000 f8070300 rl! 0 f8070300 rl! ;
+
+: dumpht cr f8070110 rl@ 8 0.r space 8b4 config-l@ 8 0.r
+ space f8070122 rb@ 2 0.r space 8bd config-b@ 2 0.r ;
+
+: clearht f8070110 dup rl@ swap rl!
+ f8070120 dup rl@ swap rl!
+ 08b4 dup config-l@ swap config-l!
+ 08bc dup config-l@ swap config-l! ;
+
+: setwidth dup f8070110 rb! 8b7 config-b! ;
+: set8 00 setwidth ;
+: set16 11 setwidth ;
+
+: setfreq dup f8070122 rb! 8bd config-b! ;
+: set200 0 setfreq ;
+: set300 1 setfreq ;
+: set400 2 setfreq ;
+: set500 3 setfreq ;
+: set600 4 setfreq ;
+: set800 5 setfreq ;
+: set1000 6 setfreq ;
+: set1200 7 setfreq ;
+: set1400 8 setfreq ;
+: set1600 9 setfreq ;
+
+: ht>freq 2 + dup 6 > IF 2* 6 - THEN d# 100 * ;
+\ XXX: looks only at the U3/U4 side for max. link speed and width.
+clearht f8070111 rb@ setwidth
+f8070120 rw@ 2log dup .( Switching top HT bus to ) ht>freq 0 d# .r .( MHz...) cr
+setfreq u3? IF ldtstop THEN u4? IF ldtstop1 THEN
+
+: open true ;
+: close ;
+
+\ : probe-pci-host-bridge ( bus-max bus-min mmio-max mmio-base mem-max mem-base io-max io-base my-puid -- )
+s" /mpic" find-node my-puid pci-irq-init drop
+1f 0 c0000000 b8000000 b8000000 80000000 100000000 10000
+my-puid probe-pci-host-bridge
+
+: msi
+ f80040f0 010854 config-l! 0 010858 config-l!
+ ffff 01085c config-w! 81 010852 config-b!
+;
+
+\ This works. Needs cleaning up though; and we need to communicate the
+\ MSI address range to the client program. (We keep the default range
+\ at fee00000 for now).
+: msi-on 7 1 DO 10000 i 800 * a0 + config-l! LOOP ;
+msi-on
+
+\ PCIe debug / fixup
+: find-pcie-cap ( devfn -- offset | 0 )
+ >r 34 BEGIN r@ + config-b@ dup ff <> over and WHILE
+ dup r@ + config-b@ 10 = IF
+ r> drop EXIT
+ THEN 1+
+ REPEAT r> 2drop 0
+;
+
+: (set-ps) ( ps addr -- )
+ 8 + >r 5 lshift r@ config-w@ ff1f and or r> config-w! ;
+: set-ps ( ps -- )
+ log2 7 -
+ 10000 0 DO i 8 lshift dup find-pcie-cap ?dup IF
+ + 2dup (set-ps) THEN drop LOOP drop ;
+
+: (set-rr) ( rr addr -- )
+ 8 + >r c lshift r@ config-w@ 8fff and or r> config-w! ;
+: set-rr ( rr -- )
+ log2 7 -
+ 10000 0 DO i 8 lshift dup find-pcie-cap ?dup IF
+ + 2dup (set-rr) THEN drop LOOP drop ;
+
+100 set-ps 200 set-rr
+100 set-ps 200 set-rr
+
+finish-device
diff --git a/qemu/roms/SLOF/board-js2x/slof/i2c.fs b/qemu/roms/SLOF/board-js2x/slof/i2c.fs
new file mode 100644
index 000000000..044bde92d
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/i2c.fs
@@ -0,0 +1,77 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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" i2c" 2dup device-name device-type
+s" u4-i2c" compatible
+
+0 encode-int f8001000 encode-int+
+0 encode-int+ 1000 encode-int+ s" reg" property
+
+: >i2c f8001000 + ;
+: i2c@ >i2c rl@ ;
+: i2c! >i2c rl! ;
+
+: .i2c 80 0 DO i i2c@ . 10 +LOOP ;
+
+\ 0 mode 1 ctrl 2 stat 3 isr 4 ier 5 addr 6 suba 7 data
+\ 8 rev 9 risetime a bittime
+
+\ 0 mode: 08
+\ 1 ctrl: 8 = start 4 = stop 2 = xaddr 1 = aak
+\ 2 stat: 2 = lastaak 1 = busy
+\ 3 isr: 8 = istart 4 = istop 2 = iaddr 1 = idata
+\ 4 ier: --
+\ 5 addr: a1..a7
+\ 6 suba: offset
+\ 7 data: data
+
+: i2c-addr ( addr -- ) 50 i2c! 2 10 i2c! BEGIN 30 i2c@ 2 and UNTIL ;
+: i2c-subaddr ( suba -- ) 60 i2c! ;
+: i2c-stop ( -- ) BEGIN 30 i2c@ dup 30 i2c! 4 and UNTIL ;
+: i2c-nak? ( -- failed? ) 20 i2c@ 2 and 0= dup IF i2c-stop THEN ;
+: i2c-short? ( -- failed? ) 30 i2c@ 4 and 0<> dup IF 0 10 i2c! i2c-stop THEN ;
+: i2c-aak-if-more ( n -- ) 1 <> 1 and 10 i2c! ;
+
+: (read) ( buf len addr -- error? )
+ 1 or i2c-addr i2c-nak? IF 2drop true EXIT THEN
+ dup i2c-aak-if-more 2 30 i2c!
+ BEGIN
+ 30 i2c@ 1 and IF
+ 1- >r 70 i2c@ over c! char+ r>
+ dup 0= IF i2c-stop 2drop false EXIT THEN
+ dup i2c-aak-if-more 1 30 i2c! THEN
+ i2c-short? IF 2drop true EXIT THEN
+ AGAIN ;
+
+: i2c-read ( buf len addr -- error? )
+ 4 0 i2c! (read) ;
+: i2c-sub-read ( buf len addr suba -- error? )
+ c 0 i2c! i2c-subaddr (read) ;
+
+: i2c-write ( buf len addr -- error? )
+ 4 0 i2c! i2c-addr i2c-nak? IF 2drop true EXIT THEN
+ over c@ 70 i2c! 2 30 i2c!
+ BEGIN
+ 30 i2c@ 1 and IF
+ 1- >r char+ r> i2c-nak? IF 2drop true EXIT THEN
+ dup 0= IF 4 10 i2c! i2c-stop nip EXIT THEN
+ over c@ 70 i2c! 1 30 i2c! THEN
+ i2c-short? IF 2drop true EXIT THEN
+ AGAIN ;
+
+: open true ;
+: close ;
+
+finish-device
diff --git a/qemu/roms/SLOF/board-js2x/slof/io.fs b/qemu/roms/SLOF/board-js2x/slof/io.fs
new file mode 100644
index 000000000..f3889840c
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/io.fs
@@ -0,0 +1,26 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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.
+
+\ 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@ ;
diff --git a/qemu/roms/SLOF/board-js2x/slof/ioapic.fs b/qemu/roms/SLOF/board-js2x/slof/ioapic.fs
new file mode 100644
index 000000000..685d6dfed
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/ioapic.fs
@@ -0,0 +1,36 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+\ ( ioapic-addr -- )
+\ IO-APIC setup.
+
+CONSTANT ioapic
+
+: ioapic@ ( offset -- x ) ioapic rb! ioapic 10 + rl@-le ;
+: ioapic! ( x offset -- ) ioapic rb! ioapic 10 + rl!-le ;
+
+: init-ioapic ( irq# -- )
+ 1a000 or 1 ioapic@ 10 rshift 1+ 0 ?DO
+ 0 i 2* 11 + ioapic! dup
+ \ move all ISA IRQs to 40 and higher,
+ \ as to not conflict with U3/U4 internal
+ \ IRQs. ISA IRQs are positive edge.
+ dup ff and 0c < IF a000 - 40 + THEN
+ i 2* 10 + ioapic! 1+ LOOP drop
+;
+
+: dump-ioapic ( -- )
+ 1 ioapic@ 10 rshift 1+
+ dup cr . ." irqs" 0 ?DO
+ cr i 2 0.r space i 2* 11 + ioapic@ 8 0.r
+ i 2* 10 + ioapic@ 8 0.r LOOP
+;
diff --git a/qemu/roms/SLOF/board-js2x/slof/ipmi-kcs.fs b/qemu/roms/SLOF/board-js2x/slof/ipmi-kcs.fs
new file mode 100644
index 000000000..cf9d5af5a
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/ipmi-kcs.fs
@@ -0,0 +1,57 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+
+\ IPMI KCS interface to the BMC.
+
+new-device
+ ca8 1 set-unit
+
+ : open true ;
+ : close ;
+
+ create descr-buf 100 allot
+
+ : rtas-get-bmc-version ( -- adr len )
+ descr-buf 100 rtas-get-blade-descr ( len status )
+ IF
+ drop 0 0
+ ELSE
+ descr-buf 9 + swap 11 - ( adr len )
+ THEN
+ ;
+
+ ' rtas-get-bmc-version to bmc-version
+
+ s" system-controller" 2dup device-name device-type
+ \ s" IBM,BMC." get-build-name $cat encode-string s" model" property
+ \ s" IBM,BMC.12345" encode-string s" model" property
+ s" IBM,BMC." bmc-version $cat encode-string s" model" property
+ 0 0 s" ranges" property
+
+ new-device
+
+ : open true ;
+ : close ;
+
+ s" ipmi" 2dup device-name device-type
+ s" ipmi-kcs" compatible
+
+ 1 encode-int ca8 encode-int+ 1 encode-int+ s" reg" property
+ 4 encode-int s" reg-spacing" property
+ s" IBM,BMC." bmc-version $cat encode-string s" model" property
+
+ s" ipmi" get-node node>path set-alias
+
+ finish-device
+
+finish-device
diff --git a/qemu/roms/SLOF/board-js2x/slof/ipmi-vpd.fs b/qemu/roms/SLOF/board-js2x/slof/ipmi-vpd.fs
new file mode 100644
index 000000000..bfb3e5014
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/ipmi-vpd.fs
@@ -0,0 +1,98 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+: vpd-read-bootlist ( -- )
+ 837 4 vpd-bootlist rtas-read-vpd IF vpd-bootlist 4 erase THEN
+;
+
+: vpd-write-bootlist ( offset len data -- )
+ 837 4 vpd-bootlist rtas-write-vpd
+;
+
+: .vpd-machine-type
+ e 7 vpd-cb rtas-read-vpd drop
+ 0 vpd-cb 7 + c!
+ vpd-cb zcount type
+;
+
+: .vpd-machine-serial
+ 15 7 vpd-cb rtas-read-vpd drop
+ 0 vpd-cb 7 + c!
+ vpd-cb zcount type
+;
+
+: .vpd-card-serial
+ 54 6 vpd-cb rtas-read-vpd drop
+ 0 vpd-cb 6 + c!
+ vpd-cb zcount type
+;
+: .vpd-cardprefix-serial
+ 5a 6 vpd-cb rtas-read-vpd drop
+ 0 vpd-cb 6 + c!
+ vpd-cb zcount type
+;
+
+: .vpd-hw-revision
+ 65 1 vpd-cb rtas-read-vpd drop
+ vpd-cb c@ .
+;
+
+: .vpd-part-number
+ 3c c vpd-cb rtas-read-vpd drop
+ vpd-cb c type
+;
+
+: .vpd-fru-number
+ 48 c vpd-cb rtas-read-vpd drop
+ vpd-cb c type
+;
+
+: .vpd-manufacturer-date
+ 6b 4 vpd-cb rtas-read-vpd drop
+ 0 vpd-cb 4 + c!
+ vpd-cb zcount type
+;
+
+: .vpd-uuid
+ 9f 10 vpd-cb rtas-read-vpd drop
+ 10 0 do i vpd-cb + c@ 2 0.r loop
+;
+
+: vpd-read-model ( -- addr len )
+ 60 4 vpd-cb rtas-read-vpd drop vpd-cb 4 -leading s" ," $cat
+ e 7 vpd-cb rtas-read-vpd drop vpd-cb 4 $cat s" -" $cat vpd-cb 4 + 3 $cat
+;
+
+: .vpd
+ ." ===================== VPD ====================="
+ cr ." Machine Type : " .vpd-machine-type
+ cr ." Machine Serial No. : " .vpd-machine-serial
+ cr ." Hardware Revision : " .vpd-hw-revision
+ cr ." Manuf. Date : " .vpd-manufacturer-date
+ cr ." Part Number : " .vpd-part-number
+ cr ." FRU Number : " .vpd-fru-number
+ cr ." FRU Serial No. : " .vpd-cardprefix-serial .vpd-card-serial
+ cr ." UUID : " .vpd-uuid
+;
+
+: vpd-write-revision-and-build-id ( -- )
+ 406 24 vpd-cb rtas-read-vpd drop 0
+ vpd-cb 1a + zcount bdate2human drop a string=ci 0=
+ IF bdate2human drop a vpd-cb 1a + zplace drop 1 THEN
+ vpd-cb zcount slof-revision string=ci 0=
+ IF slof-revision vpd-cb zplace drop 1 THEN
+ vpd-cb 4 + zcount slof-build-id string=ci 0=
+ IF slof-build-id vpd-cb 4 + rzplace drop 1 THEN
+ 1 = IF 406 24 vpd-cb rtas-write-vpd drop THEN
+;
+
+vpd-write-revision-and-build-id
diff --git a/qemu/roms/SLOF/board-js2x/slof/memory.fs b/qemu/roms/SLOF/board-js2x/slof/memory.fs
new file mode 100644
index 000000000..b1b7aaa91
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/memory.fs
@@ -0,0 +1,52 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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" 2dup device-name device-type
+
+: mem-size-u3 20000000 ;
+: (mem-size-u4) ( # -- size )
+ 4 lshift f8002200 + rl@ dup 1 and 0= IF drop 0 EXIT THEN
+ dup c000 and e rshift over 3000 and c rshift + 10000000 swap lshift
+ swap 2 and 0= IF 2* THEN ;
+: mem-size-u4 0 4 0 DO i (mem-size-u4) + LOOP ;
+: mem-size u3? IF mem-size-u3 THEN u4? IF mem-size-u4 THEN ;
+: mem-speed-u4 f8000800 rl@ 12 rshift 7 and 4 + d# 200 * 3 / ;
+: mem-speed-u3 f8000f60 rl@ c rshift f and d# 100 * 3 / ;
+: mem-speed u3? IF mem-speed-u3 THEN u4? IF mem-speed-u4 THEN ;
+
+
+: 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
+0 mem-size release \ Make our memory available
+
+
+: mem-report
+ base @ decimal mem-size 1e rshift 0 .r
+ mem-size 3fffffff and IF ." .5" THEN ." GB of RAM @ "
+ mem-speed . ." MHz" base ! ;
+
+get-node memnode !
+
+: open true ;
+: close ;
+
+finish-device
diff --git a/qemu/roms/SLOF/board-js2x/slof/mpic.fs b/qemu/roms/SLOF/board-js2x/slof/mpic.fs
new file mode 100644
index 000000000..a9523445d
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/mpic.fs
@@ -0,0 +1,31 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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" device-name s" interrupt-controller" device-type
+s" open-pic" compatible
+0 0 s" interrupt-controller" property
+
+2 encode-int s" #interrupt-cells" property
+
+0 encode-int f8040000 encode-int+
+0 encode-int+ 30000 encode-int+ s" reg" property
+
+: enable-mpic 6 f80000e0 rl! ;
+enable-mpic
+
+: open true ;
+: close ;
+
+finish-device
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-aliases.fs b/qemu/roms/SLOF/board-js2x/slof/pci-aliases.fs
new file mode 100644
index 000000000..f017e4a55
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-aliases.fs
@@ -0,0 +1,85 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+\ Starting alias number for net devices after the onboard devices.
+2 VALUE pci-net-num
+\ Starting alias number for disks after the onboard devices.
+0 VALUE pci-disk-num
+\ Starting alias number for cdroms after the onboard devices.
+0 VALUE pci-cdrom-num
+
+\ define a new alias for this device
+: pci-set-alias ( str-addr str-len num -- )
+ $cathex strdup \ create alias name
+ get-node node>path \ get path string
+ set-alias \ and set the alias
+;
+
+\ define a new net alias
+: unknown-enet ( -- pci-net-num )
+ pci-net-num dup 1+ TO pci-net-num
+;
+: pci-alias-net ( config-addr -- )
+ u3? IF
+ pci-device-vec c@ CASE
+ 2 OF pci-device-vec-len 1 >= IF
+ pci-device-vec 1+ c@ CASE
+ 1 OF dup pci-addr2fn 1 >= IF 1 ELSE 0 THEN ENDOF
+ dup OF unknown-enet ENDOF
+ ENDCASE
+ ELSE
+ unknown-enet
+ THEN
+ ENDOF
+ dup OF unknown-enet ENDOF
+ ENDCASE
+ ELSE
+ pci-device-vec c@ CASE
+ 2 OF pci-device-vec-len 1 >= IF
+ pci-device-vec 1+ c@ CASE
+ 4 OF dup pci-addr2fn 1 >= IF 1 ELSE 0 THEN ENDOF
+ dup OF unknown-enet ENDOF
+ ENDCASE
+ ELSE
+ unknown-enet
+ THEN
+ ENDOF
+ dup OF unknown-enet ENDOF
+ ENDCASE
+ THEN
+ swap drop \ forget the config address
+
+ s" net" rot pci-set-alias \ create the alias
+;
+
+\ define a new disk alias
+: pci-alias-disk ( config-addr -- )
+ drop \ forget the config address
+ pci-disk-num dup 1+ TO pci-disk-num \ increase the pci-disk-num
+ s" disk" rot pci-set-alias \ create the alias
+;
+\ define a new cdrom alias
+: pci-alias-cdrom ( config-addr -- )
+ drop \ forget the config address
+ pci-cdrom-num dup 1+ TO pci-cdrom-num \ increase the pci-cdrom-num
+ s" cdrom" rot pci-set-alias \ create the alias
+;
+
+\ define the alias for the calling device
+: pci-alias ( config-addr -- )
+ dup pci-class@
+ 10 rshift CASE
+ 01 OF pci-alias-disk ENDOF
+ 02 OF pci-alias-net ENDOF
+ dup OF drop ENDOF
+ ENDCASE
+;
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-bridge_1022_7460.fs b/qemu/roms/SLOF/board-js2x/slof/pci-bridge_1022_7460.fs
new file mode 100644
index 000000000..87b583088
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-bridge_1022_7460.fs
@@ -0,0 +1,203 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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.
+
+\ Config space access functions - we're touching multiple device numbers and
+\ device functions below, so we've got to add our own my-space base here:
+: config-b@ dup 1000 < IF my-space + THEN config-b@ ;
+: config-w@ dup 1000 < IF my-space + THEN config-w@ ;
+: config-l@ dup 1000 < IF my-space + THEN config-l@ ;
+: config-b! dup 1000 < IF my-space + THEN config-b! ;
+: config-w! dup 1000 < IF my-space + THEN config-w! ;
+: config-l! dup 1000 < IF my-space + THEN config-l! ;
+
+\ 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 842 config-b! \ Disable 8237 & 8254 & 8259's. We're not a PC.
+u3? IF
+ 80 847 config-b! \ Disable EHCI, as it is terminally broken.
+THEN
+03 848 config-b! \ Enable LPC, IDE; disable I2C, SMM, AC'97 functions.
+01 849 config-b! \ Enable USB, disable 100Mb enet.
+01 84b config-b! \ Enable IO-APIC.
+
+fec00000 s" ioapic.fs" included
+00 init-ioapic
+
+\ Program PNPIRQ[0,1,2] as IRQ #D,E,F; switch those GPIOs to low-active.
+ 0b 848 config-b! \ enable devB:3
+7000 b58 config-l! \ map PMxx at pci i/o 7000
+ d1 b41 config-b! \ enable access to PMxx space
+
+\ on JS20 the planar id is encoded in GPIO 29, 30 and 31
+\ >=5 is GA2 else it is GA1
+: (planar-id) ( -- planar-id)
+ [ 70dd io-c@ 5 rshift 1 and ] LITERAL
+ [ 70de io-c@ 5 rshift 2 and ] LITERAL
+ [ 70df io-c@ 5 rshift 4 and ] LITERAL
+ + + 7 xor
+;
+
+u3? IF ['] (planar-id) to planar-id THEN
+
+8 70d3 io-c! 8 70d4 io-c! 8 70d5 io-c! \ set the pins to low-active
+ bimini? IF 5 70c4 io-c! THEN \ on bimini set gpio4 as output and high to power up USB
+ fec b44 config-w! \ set PNPIRQ pnpirq2 -> f , pnpirq1 -> e pnpirq0 -> c
+ 51 b41 config-b! \ disable access to PMxx space
+ 03 848 config-b! \ disable devB:3
+
+\ The function of the PCI controller BARs change depending on the mode the
+\ controller is in.
+\ And the default is legacy mode. Gross.
+05 909 config-b! \ Enable native PCI mode.
+03 940 config-b! \ Enable both ports.
+
+\ Enable HPET on 8111, at address fe000000.
+fe000001 8a0 config-l!
+
+: >hpet fe000000 + ;
+: hpet@ >hpet rl@-le ;
+: hpet! >hpet rl!-le ;
+
+INCLUDE freq.fs
+
+\ Disable HPET.
+0 8a0 config-l!
+
+\ 8111 has only 16 bits of PCI I/O space. Get the address in range.
+8000 next-pci-io !
+
+\ before disabling EHCI it needs to be reset
+
+\ first we are setting up the BAR0, so that we can talk to the
+\ memory mapped controller; not using the PCI scan because we just
+\ want a temporary setup
+
+: really-disable-broken-amd8111-ehci ( -- )
+ \ this word only works on U4 systems (JS21/Bimini)
+ \ yeah, hardcoded!
+ f2000000 to puid
+
+ \ the PCI scan would assign pci-next-mmio to that device
+ \ let's just take that address
+ pci-next-mmio @ 100000 #aligned
+ \ pci-bus-number 10 lshift 210 or could be something like 70210
+ \ 7: pci-bus-number
+ \ 2: device function
+ \ 10: offset 10 (bar 0)
+ pci-bus-number 10 lshift 210 or rtas-config-l!
+
+ \ enable memory space
+ pci-bus-number 10 lshift 204 or dup rtas-config-l@ 2 or swap rtas-config-l!
+
+ pci-next-mmio @ 100000 #aligned ( base )
+
+ \ Sequence prescribed for resetting the EHCI contoller
+
+ \ If Run/Stop bit (ECAP30 bit 0) is 1
+ \ Set Run/Stop bit to 0
+ \ wait 2ms
+
+ dup 30 + rl@ 1 and 1 = IF
+ dup 30 + rl@ 1 or
+ over 30 + rl!
+ 2 ms
+ THEN
+
+ \ While HCHalted bit (ECAP34 bit 12) is 0 (still running, wait forever)
+ \ wait 2ms
+
+ BEGIN dup 34 + rl@ 1000 and 0= 2 ms UNTIL
+
+ \ Set HCReset bit (ECAP30 bit 1)
+
+ dup 30 + 2 swap rl!
+
+ \ While HCReset bit is 1 (wait forever for reset to complete)
+ \ wait 2ms
+
+ BEGIN dup 30 + rl@ 2 and 0= 2 ms UNTIL drop
+
+ \ now it is really disabled
+
+ \ disable memory space access again
+ 2100000 pci-bus-number 10 lshift 204 or rtas-config-l!
+
+ 80 847 config-b! \ Disable EHCI, as it is terminally broken.
+;
+
+my-space pci-class-name type cr
+
+\ copied from pci-properties.fs and pci-scan.fs
+\ changed to disable the EHCI completely just before the scan
+\ and after mem/IO transactions have been enabled
+
+\ Setup the Base and Limits in the Bridge
+\ and scan the bus(es) beyond that Bridge
+: pci-bridge-probe-amd8111 ( addr -- )
+ dup pci-bridge-set-bases \ SetUp all Base Registers
+ dup pci-bridge-range-props \ Setup temporary "range
+ pci-bus-number 1+ TO pci-bus-number \ increase number of busses found
+ pci-device-vec-len 1+ TO pci-device-vec-len \ increase the device-slot vector depth
+ dup \ stack config-addr for pci-bus!
+ FF swap \ Subordinate Bus Number ( for now to max to open all subbusses )
+ pci-bus-number swap \ Secondary Bus Number ( the new busnumber )
+ dup pci-addr2bus swap \ Primary Bus Number ( the current bus )
+ pci-bus! \ and set them into the bridge
+ pci-enable \ enable mem/IO transactions
+
+ \ at this point we can talk to the broken EHCI controller
+ really-disable-broken-amd8111-ehci
+
+ dup pci-bus-scnd@ func-pci-probe-bus \ and probe the secondary bus
+ dup pci-bus-number swap pci-bus-subo! \ set SubOrdinate Bus Number to current number of busses
+ pci-device-vec-len 1- TO pci-device-vec-len \ decrease the device-slot vector depth
+ dup pci-bridge-set-limits \ SetUp all Limit Registers
+ drop \ forget the config-addr
+;
+
+\ used to set up all unknown Bridges.
+\ If a Bridge has no special handling for setup
+\ the device file (pci-bridge_VENDOR_DEVICE.fs) can call
+\ this word to setup busses and scan beyond.
+: pci-bridge-generic-setup-amd8111 ( addr -- )
+ pci-device-slots >r \ save the slot array on return stack
+ dup pci-common-props \ set the common properties before scanning the bus
+ s" pci" device-type \ the type is allways "pci"
+ dup pci-bridge-probe-amd8111 \ find all device connected to it
+ dup assign-all-bridge-bars \ set up all memory access BARs
+ dup pci-set-irq-line \ set the interrupt pin
+ dup pci-set-capabilities \ set up the capabilities
+ pci-bridge-props \ and generate all properties
+ r> TO pci-device-slots \ and reset the slot array
+;
+
+: amd8111-bridge-setup
+ my-space
+ u3? takeover? or IF
+ \ if it is js20 or we are coming from takeover
+ \ we just do the normal setup
+ pci-bridge-generic-setup
+ ELSE
+ pci-bridge-generic-setup-amd8111
+ THEN
+ s" pci" device-name
+;
+
+amd8111-bridge-setup
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-capabilities.fs b/qemu/roms/SLOF/board-js2x/slof/pci-capabilities.fs
new file mode 100644
index 000000000..a50714a6b
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-capabilities.fs
@@ -0,0 +1,23 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+\ -----------------------------------------------------------------------------
+\ Set the msi address for a device
+: pci-set-msi ( cap-addr -- )
+ drop
+;
+
+\ Set up all known capabilities for this board to the plugged devices
+: pci-set-capabilities ( config-addr -- )
+ dup 05 pci-cap-find ?dup IF pci-set-msi THEN
+ drop
+;
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-class_03.fs b/qemu/roms/SLOF/board-js2x/slof/pci-class_03.fs
new file mode 100644
index 000000000..05c8eb62d
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-class_03.fs
@@ -0,0 +1,55 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+my-space pci-class-name type
+
+my-space pci-device-generic-setup
+
+my-space pci-class-name device-type
+
+\ add legacy I/O Ports / Memory regions to assigned-addresses
+\ see PCI Bus Binding Revision 2.1 Section 7.
+s" reg" get-my-property
+IF
+ \ "reg" does not exist, create new
+ encode-start
+ELSE
+ \ "reg" does exist, copy it
+ encode-bytes
+THEN
+\ I/O Range 0x3B0-0x3BB
+my-space a1000000 or encode-int+ \ non-relocatable, aliased I/O space
+3b0 encode-64+ \ addr
+c encode-64+ \ size
+\ I/O Range 0x3C0-0x3DF
+my-space a1000000 or encode-int+ \ non-relocatable, aliased I/O space
+3c0 encode-64+ \ addr
+20 encode-64+ \ size
+\ the U4 does not support memory accesses to this region... so we dont put it into "reg"
+\ maybe with some clever hacking of the address map registers it will be possible to access
+\ these regions??
+\ Memory Range 0xA0000-0xBFFFF
+\ my-space a2000000 or encode-int+ \ non-relocatable, <1MB Memory space
+\ a0000 encode-64+ \ addr
+\ 20000 encode-64+ \ size
+
+s" reg" property \ store "reg" property
+
+\ check wether we have already found a vga-device (vga-device-node? != 0) and if
+\ this device has Expansion ROM
+vga-device-node? 0= 30 config-l@ 0<> AND IF
+ \ remember this vga device's phandle
+ get-node to vga-device-node?
+THEN
+
+cr
+
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-device_1002_515e.fs b/qemu/roms/SLOF/board-js2x/slof/pci-device_1002_515e.fs
new file mode 100644
index 000000000..39a02ded0
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-device_1002_515e.fs
@@ -0,0 +1,501 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+my-space pci-class-name type
+
+my-space assign-all-device-bars
+my-space pci-device-props
+my-space pci-set-irq-line
+
+7 4 config-w!
+
+\ Special notice from ATI:
+\ ATI TECHNOLOGIES INC. ("ATI") HAS NOT ASSISTED IN THE CREATION OF,
+\ AND DOES NOT ENDORSE THE USE OF, THIS SOFTWARE. ATI WILL NOT BE
+\ RESPONSIBLE OR LIABLE FOR ANY ACTUAL OR ALLEGED DAMAGE OR LOSS
+\ CAUSED BY OR IN CONNECTION WITH THE USE OF, OR RELIANCE ON,
+\ THIS SOFTWARE.
+
+\ Description: This FCODE driver initializes the RN50 (ES1000) ATI
+\ adaptor.
+
+-1 value mem-addr
+-1 value regs-addr
+false value is_installed
+
+: reg-rl@ regs-addr + rl@-le ;
+: reg-rl! regs-addr + rl!-le ;
+: map-in " map-in" $call-parent ;
+: map-out " map-out" $call-parent ;
+: pc@ ( offset -- byte ) regs-addr + rb@ ;
+: pc! ( byte offset -- ) regs-addr + rb! ;
+
+0 value phys_low
+0 value phys_mid
+0 value phys_high
+0 value phys_len
+
+: MAP-CSR-BASE ( -- )
+ " assigned-addresses" get-my-property 0= if
+ begin dup 0> while ( prop-addr len )
+ \ Get the phys-hi mid low and the low order 32 bits of the length
+
+ decode-phys to phys_high to phys_mid to phys_low decode-int drop decode-int to phys_len
+
+ phys_high H# FF and \ See which BAR this refers to
+ case
+ h# 10 of phys_low phys_mid phys_high h# 1000000 map-in to mem-addr endof
+ h# 18 of phys_low phys_mid phys_high phys_len map-in to regs-addr endof
+ endcase
+ repeat
+ ( prop-addr 0 ) 2drop
+ then
+
+ ;
+
+: enable-card my-space 4 + dup config-b@ 3 or swap config-b! ;
+
+: EARLY-MAP ( -- )
+
+ " reg" get-my-property 0= if
+ begin dup 0> while ( prop-addr len )
+
+ \ Get the phys-hi mid low and the low order 32 bits of the length
+
+ decode-phys to phys_high to phys_mid to phys_low decode-int drop decode-int to phys_len
+
+ phys_high H# FF and \ See which BAR this refers to
+ case
+ h# 10 of phys_low phys_mid phys_high H# 1000000 map-in to mem-addr endof
+ h# 18 of phys_low phys_mid phys_high h# 1000 map-in to regs-addr endof
+ endcase
+ repeat
+ ( prop-addr 0 ) 2drop
+ then
+ ;
+
+: EARLY-UNMAP ( -- )
+
+ mem-addr -1 <> if
+ mem-addr h# 1000000 map-out
+ -1 to mem-addr
+ then
+
+ regs-addr -1 <> if
+ regs-addr h# 1000 map-out
+ -1 to regs-addr
+ then
+
+ ;
+
+CREATE INIT1_ARRAY
+H# 0F8 ( CONFIG_MEMSIZE ) L, H# 00000000 L, H# 01000000 L,
+H# 1C0 ( MPP_TB_CONFIG ) L, H# 00FFFFFF L, H# 07000000 L,
+H# 030 ( BUS_CNTL ) L, H# 00000000 L, H# 5133A3B0 L,
+H# 0EC ( RBBM_CNTL ) L, H# 00000000 L, h# 00004443 L,
+H# 1D0 ( DEBUG_CNTL ) L, H# FFFFFFFD L, H# 00000002 L,
+H# 050 ( CRTC_GEN_CNTL ) L, H# 00000000 L, H# 04000000 L,
+H# 058 ( DAC_CNTL ) L, H# 00000000 L, H# FF604102 L,
+H# 168 ( PAD_CTLR_STRENGTH ) L, H# FFFEFFFF L, H# 00001200 L,
+H# 178 ( MEM_REFRESH_CNTL ) L, H# 00000000 L, H# 88888888 L,
+H# 17C ( MEM_READ_CNTL ) L, H# 00000000 L, H# B7C20000 L,
+H# 188 ( MC_DEBUG ) L, H# FFFFFFFF L, H# 00000000 L,
+H# D00 ( DISP_MISC_CNTL) L, H# 00FFFFFF L, H# 5B000000 L,
+H# 88C ( TV_DAC_CNTL ) L, H# F800FCEF L, H# 00490200 L,
+H# D04 ( DAC_MACRO_CNTL) L, H# 00000000 L, H# 00000905 L,
+H# 284 ( FP_GEN_CNTL ) L, H# FFFFFFFF L, H# 00000008 L,
+H# 030 ( BUS_CNTL ) L, H# FFFFFFEF L, H# 00000000 L,
+
+here INIT1_ARRAY - /L / CONSTANT INIT1_LENGTH
+
+
+CREATE INIT2_ARRAY
+
+H# 140 ( MEM_CNTL ) L, H# 00000000 L, H# 38001A01 L, 0 L,
+H# 158 ( MEM_SDRAM_MODE_REG ) L, H# E0000000 L, H# 08320032 L, 0 L,
+H# 144 ( MEM_TIMING_CNTL ) L, H# 00000000 L, H# 20123833 L, 0 L,
+H# 14C ( MC_AGP_LOCATION ) L, H# 00000000 L, H# 000FFFF0 L, 0 L,
+H# 148 ( MC_FB_LOCATION ) L, H# 00000000 L, H# FFFF0000 L, 0 L,
+H# 154 ( MEM_INIT_LAT_TIMER ) L, H# 00000000 L, H# 34444444 L, 0 L,
+H# 18C ( MC_CHP_IO_OE_CNTL ) L, H# 00000000 L, H# 0A540002 L, 0 L,
+H# 910 ( FCP_CNTL ) L, H# 00000000 L, H# 00000004 L, 0 L,
+H# 010 ( BIOS_0_SCRATCH ) L, H# FFFFFFFB L, H# 00000004 L, 0 L,
+H# D64 ( DISP_OUTPUT_CNTL ) L, H# FFFFFBFF L, H# 00000000 L, 0 L,
+H# 2A8 ( TMDS_PLL_CNTL ) L, H# 00000000 L, H# 00000A1B L, 0 L,
+H# 800 ( TV_MASTER_CNTL ) L, H# BFFFFFFF L, H# 40000000 L, 0 L,
+H# D10 ( DISP_TEST_DBUG_CTL ) L, H# EFFFFFFF L, H# 10000000 L, 0 L,
+H# 4DC ( OV0_FLAG_CNTRL ) L, H# FFFFFEFF L, H# 00000100 L, 0 L,
+H# 034 ( BUS_CNTL1 ) L, H# 73FFFFFF L, H# 84000000 L, 0 L,
+H# 174 ( AGP_CNTL ) L, H# FFEFFF00 L, H# 001E0000 L, 0 L,
+H# 18C ( MC_CHP_IO_OE_CNTL ) L, H# FFFFFFF9 L, H# 00000006 L, h# 000A L,
+H# 18C ( MC_CHP_IO_OE_CNTL ) L, H# FFFFFFFB L, H# 00000000 L, H# 000A L,
+H# 18C ( MC_CHP_IO_OE_CNTL ) L, H# FFFFFFFD L, H# 00000000 L, 0 L,
+
+here INIT2_ARRAY - /L / CONSTANT INIT2_LENGTH
+
+CREATE PLLINIT_ARRAY
+
+H# 0D L, H# FFFFFFFF L, H# FFFF8000 L, 0 L,
+H# 12 L, H# FFFFFFFF L, H# 00350000 L, 0 L,
+H# 08 L, H# FFFFFFFF L, H# 00000000 L, 0 L,
+H# 2D L, H# FFFFFFFF L, H# 00000000 L, 0 L,
+H# 1F L, H# FFFFFFFF L, H# 0000000A L, 5 L,
+H# 03 L, H# FFFFFFFF L, H# 0000003C L, 0 L,
+H# 0A L, H# FFFFFFFF L, H# 00252504 L, 0 L,
+H# 25 L, H# FFFFFFFF L, H# 00000005 L, 0 L,
+H# 0E L, H# FFFFFFFF L, H# 04756400 L, 0 L,
+H# 0C L, H# FFFFFFFF L, H# 04006401 L, 0 L,
+H# 02 L, H# FFFFFFFF L, H# 0000A703 L, 0 L,
+H# 0F L, H# FFFFFFFF L, H# 0000051C L, 0 L,
+H# 10 L, H# FFFFFFFF L, H# 04000400 L, 5 L,
+H# 0E L, H# FFFFFFFD L, H# 00000000 L, 5 L,
+H# 0E L, H# FFFFFFFE L, H# 00000000 L, 5 L,
+H# 12 L, H# FFFFFFFF L, H# 00350012 L, 5 L,
+H# 0F L, H# FFFFFFFE L, H# 00000000 L, 6 L,
+H# 10 L, H# FFFFFFFE L, H# 00000000 L, 5 L,
+H# 10 L, H# FFFEFFFF L, H# 00000000 L, 6 L,
+H# 0F L, H# FFFFFFFD L, H# 00000000 L, 5 L,
+H# 10 L, H# FFFFFFFD L, H# 00000000 L, 5 L,
+H# 10 L, H# FFFDFFFF L, H# 00000000 L, d# 10 L,
+H# 0C L, H# FFFFFFFE L, H# 00000000 L, 6 L,
+H# 0C L, H# FFFFFFFD L, H# 00000000 L, 5 L,
+h# 0D L, H# FFFFFFFF L, H# FFFF8007 L, 5 L,
+H# 08 L, H# FFFFFF3C L, H# 00000000 L, 0 L,
+H# 02 L, H# FFFFFFFF L, H# 00000003 L, 0 L,
+H# 04 L, H# FFFFFFFF L, H# 000381C0 L, 0 L,
+H# 05 L, H# FFFFFFFF L, H# 000381F7 L, 0 L,
+H# 06 L, H# FFFFFFFF L, H# 000381C0 L, 0 L,
+H# 07 L, H# FFFFFFFF L, H# 000381F7 L, 0 L,
+H# 02 L, H# FFFFFFFD L, H# 00000000 L, 6 L,
+H# 02 L, H# FFFFFFFE L, H# 00000000 L, 5 L,
+h# 08 L, H# FFFFFF3C L, H# 00000003 L, 5 L,
+H# 0B L, H# FFFFFFFF L, H# 78000800 L, 0 L,
+H# 0B L, H# FFFFFFFF L, H# 00004000 L, 0 L,
+h# 01 L, h# FFFFFFFF L, H# 00000010 L, 0 L,
+
+here PLLINIT_ARRAY - /L / CONSTANT PLLINIT_LENGTH
+
+CREATE MEMINIT_ARRAY
+h# 6FFF0000 L, H# 00004000 L, H# 6FFF0000 L, H# 80004000 L,
+h# 6FFF0000 L, H# 00000132 L, H# 6FFF0000 L, H# 80000132 L,
+h# 6FFF0000 L, H# 00000032 L, H# 6FFF0000 L, H# 80000032 L,
+h# 6FFF0000 L, H# 10000032 L,
+here MEMINIT_ARRAY - /L / CONSTANT MEMINIT_LENGTH
+: L@+ ( addr -- value addr' )
+
+dup l@ swap la1+
+;
+
+0 VALUE _len
+
+: ENCODE-ARRAY ( array len -- )
+ dup to _len 0 do l@+ swap encode-int rot loop
+ drop _len 1 - 0 ?do encode+ loop
+;
+
+: andorset ( reg and or -- )
+ 2 pick dup reg-rl@
+ 3 pick AND 2 pick OR swap reg-rl! 3drop
+;
+
+: INIT1
+H# 0F8 ( CONFIG_MEMSIZE ) H# 00000000 H# 01000000 andorset \ Set 16Mb memory size
+H# 1C0 ( MPP_TB_CONFIG ) H# 00FFFFFF H# 07000000 andorset
+H# 030 ( BUS_CNTL ) H# 00000000 H# 5133A3B0 andorset
+H# 0EC ( RBBM_CNTL ) H# 00000000 h# 00004443 andorset
+H# 1D0 ( DEBUG_CNTL ) H# FFFFFFFD H# 00000002 andorset
+H# 050 ( CRTC_GEN_CNTL ) H# 00000000 H# 04000000 andorset
+H# 058 ( DAC_CNTL ) H# 00000000 H# FF604102 andorset
+H# 168 ( PAD_CTLR_STRENGTH ) H# FFFEFFFF H# 00001200 andorset
+H# 178 ( MEM_REFRESH_CNTL ) H# 00000000 H# 88888888 andorset
+H# 17C ( MEM_READ_CNTL ) H# 00000000 H# B7C20000 andorset
+H# 188 ( MC_DEBUG ) H# FFFFFFFF H# 00000000 andorset
+H# D00 ( DISP_MISC_CNTL) H# 00FFFFFF H# 5B000000 andorset
+H# 88C ( TV_DAC_CNTL ) H# F800FCEF H# 00490200 andorset
+H# D04 ( DAC_MACRO_CNTL) H# 00000000 H# 00000905 andorset
+H# 284 ( FP_GEN_CNTL ) H# FFFFFFFF H# 00000008 andorset
+H# 030 ( BUS_CNTL ) H# FFFFFFEF H# 00000000 andorset
+;
+
+
+: INIT2
+H# 140 ( MEM_CNTL ) H# 00000000 H# 38001A01 andorset
+H# 158 ( MEM_SDRAM_MODE_REG ) H# E0000000 H# 08320032 andorset
+H# 144 ( MEM_TIMING_CNTL ) H# 00000000 H# 20123833 andorset
+H# 14C ( MC_AGP_LOCATION ) H# 00000000 H# 000FFFF0 andorset
+H# 148 ( MC_FB_LOCATION ) H# 00000000 H# FFFF0000 andorset
+H# 154 ( MEM_INIT_LAT_TIMER ) H# 00000000 H# 34444444 andorset
+H# 18C ( MC_CHP_IO_OE_CNTL ) H# 00000000 H# 0A540002 andorset
+H# 910 ( FCP_CNTL ) H# 00000000 H# 00000004 andorset
+H# 010 ( BIOS_0_SCRATCH ) H# FFFFFFFB H# 00000004 andorset
+H# D64 ( DISP_OUTPUT_CNTL ) H# FFFFFBFF H# 00000000 andorset
+H# 2A8 ( TMDS_PLL_CNTL ) H# 00000000 H# 00000A1B andorset
+H# 800 ( TV_MASTER_CNTL ) H# BFFFFFFF H# 40000000 andorset
+H# D10 ( DISP_TEST_DEBUG_CTL ) H# EFFFFFFF H# 10000000 andorset
+H# 4DC ( OV0_FLAG_CNTRL ) H# FFFFFEFF H# 00000100 andorset
+H# 034 ( BUS_CNTL1 ) H# 73FFFFFF H# 84000000 andorset
+H# 174 ( AGP_CNTL ) H# FFEFFF00 H# 001E0000 andorset
+H# 18C ( MC_CHP_IO_OE_CNTL ) H# FFFFFFF9 H# 00000006 andorset h# 000A ms
+H# 18C ( MC_CHP_IO_OE_CNTL ) H# FFFFFFFB H# 00000000 andorset H# 000A ms
+H# 18C ( MC_CHP_IO_OE_CNTL ) H# FFFFFFFD H# 00000000 andorset
+;
+
+: CLK-CNTL-INDEX! 8 ( CLK_CNTL_INDEX ) reg-rl! ;
+
+: CLK-CNTL-INDEX@ 8 ( CLK_CNTL_INDEX ) reg-rl@ ;
+
+: PLLWRITEON clk-cntl-index@ H# 80 ( PLL_WR_ENABLE ) or clk-cntl-index! ;
+
+: PLLWRITEOFF clk-cntl-index@ H# 80 ( PLL_WR_ENABLE ) not and clk-cntl-index! ; \ Remove PLL_WR_ENABLE
+
+: CLKDATA! h# 0c ( CLK_CNTL_DATA ) reg-rl! ;
+
+: CLKDATA@ h# 0c ( CLK_CNTL_DATA ) reg-rl@ ;
+
+: PLLINDEXSET clk-cntl-index@ h# FFFFFFC0 and or clk-cntl-index! ;
+
+: PLLSET swap pllindexset clkdata! ;
+
+: pllandorset ( index and or -- )
+ 2 pick pllindexset clkdata@
+ 2 pick AND over OR clkdata! 3drop
+;
+
+: PLLINIT
+pllwriteon
+H# 0D H# FFFF8000 pllset
+H# 12 H# 00350000 pllset
+H# 08 H# 00000000 pllset
+H# 2D H# 00000000 pllset
+H# 1F H# 0000000A pllset 5 ms
+
+H# 03 H# 0000003C pllset
+H# 0A H# 00252504 pllset
+H# 25 H# 00000005 pllset
+H# 0E H# 04756400 pllset
+H# 0C H# 04006401 pllset
+H# 02 H# 0000A703 pllset
+H# 0F H# 0000051C pllset
+H# 10 H# 04000400 pllset 5 ms
+
+H# 0E H# FFFFFFFD 00 pllandorset 5 ms
+H# 0E H# FFFFFFFE 00 pllandorset 5 ms
+H# 12 H# 00350012 pllset 5 ms
+H# 0F H# FFFFFFFE 00 pllandorset 6 ms
+H# 10 H# FFFFFFFE 00 pllandorset 5 ms
+H# 10 H# FFFEFFFF 00 pllandorset 6 ms
+H# 0F H# FFFFFFFD 00 pllandorset 5 ms
+H# 10 H# FFFFFFFD 00 pllandorset 5 ms
+H# 10 H# FFFDFFFF 00 pllandorset d# 10 ms
+H# 0C H# FFFFFFFE 00 pllandorset 6 ms
+H# 0C H# FFFFFFFD 00 pllandorset 5 ms
+h# 0D h# FFFF8007 pllset 5 ms
+H# 08 H# FFFFFF3C 00 pllandorset
+H# 02 h# FFFFFFFF 03 pllandorset
+H# 04 H# 000381C0 pllset
+H# 05 H# 000381F7 pllset
+H# 06 H# 000381C0 pllset
+H# 07 H# 000381F7 pllset
+H# 02 H# FFFFFFFD 00 pllandorset 6 ms
+H# 02 h# FFFFFFFE 00 pllandorset 5 ms
+h# 08 H# FFFFFF3C 03 pllandorset 5 ms
+H# 0B h# 78000800 pllset
+H# 0B H# FFFFFFFF h# 4000 pllandorset
+h# 01 h# FFFFFFFF h# 0010 pllandorset
+
+pllwriteoff
+;
+
+: DYNCKE
+pllwriteon
+H# 14 H# FFFF3FFF H# 30 pllandorset
+H# 14 H# FF1FFFFF H# 00 pllandorset
+H# 01 h# FFFFFFFF h# 80 pllandorset
+H# 0D H# 00000007 pllset 5 ms
+h# 2D H# 0000F8C0 pllset
+h# 08 H# FFFFFFFF h# C0 pllandorset 5 ms
+pllwriteoff
+;
+
+: MEM-MODE@
+ h# 158 ( MEM_SDRAM_MODE_REG ) reg-rl@ ;
+
+: MEM-MODE!
+ h# 158 ( MEM_SDRAM_MODE_REG ) reg-rl! ;
+
+: MEM-STATUS@
+ H# 150 reg-rl@ ;
+
+: WAIT-MEM-CMPLT
+ h# 8000 0 do mem-status@ 3 and 3 = if leave then loop ;
+
+: INITMEM
+
+ mem-mode@ h# 6FFF0000 and h# 4000 or mem-mode!
+ mem-mode@ h# 6FFF0000 and h# 80004000 or mem-mode!
+ wait-mem-cmplt
+ mem-mode@ h# 6FFF0000 and h# 0132 or mem-mode!
+ mem-mode@ h# 6FFF0000 and h# 80000132 or mem-mode!
+ wait-mem-cmplt
+ mem-mode@ h# 6FFF0000 and h# 0032 or mem-mode!
+ mem-mode@ h# 6FFF0000 and h# 80000032 or mem-mode!
+ wait-mem-cmplt
+ mem-mode@ h# 6FFF0000 and h# 10000032 or mem-mode!
+;
+
+
+
+: CLR-REG ( reg -- )
+ 0 swap reg-rl!
+
+;
+: SET-PALETTE ( -- )
+ h# 0 h# b0 pc! \ Reset PALETTE_INDEX
+
+ d# 16 0 do
+ H# 000000 h# B4 reg-rl! \ Write the PALETTE_DATA ( Auto increments)
+ H# aa0000 H# B4 reg-rl!
+ H# 00aa00 H# B4 reg-rl!
+ H# aa5500 H# B4 reg-rl!
+ H# 0000aa H# B4 reg-rl!
+ H# aa00aa H# B4 reg-rl!
+ H# 00aaaa H# B4 reg-rl!
+ H# aaaaaa H# B4 reg-rl!
+ H# 555555 H# B4 reg-rl!
+ H# ff5555 H# B4 reg-rl!
+ H# 55ff55 H# B4 reg-rl!
+ H# ffff55 H# B4 reg-rl!
+ H# 5555ff H# B4 reg-rl!
+ H# ff55ff H# B4 reg-rl!
+ H# 55ffff H# B4 reg-rl!
+ H# ffffff H# B4 reg-rl!
+ loop
+
+ ;
+
+0 VALUE _addr
+0 VALUE _color
+
+: DO-COLOR ( color-addr addr color -- )
+ to _color to _addr 0 to _color
+ 3 0 do _addr i + c@ 2 i - 8 * << _color + to _color loop
+ _color h# B4 reg-rl!
+;
+
+: SET-COLORS ( addr index #indices -- )
+
+ swap h# B0 pc!
+ ( addr #indices ) 0 ?do dup ( index ) i 3 * + DO-COLOR loop
+ ( addr ) drop ;
+
+: init-card
+
+ h# FF h# 58 3 + pc! \
+ h# 59 pc@ h# FE and h# 59 pc! \
+ h# 50 reg-rl@ H# FEFFFFFF AND h# 02000200 or \ Clear 24 set 25 and 8-11 to 2
+ h# 50 reg-rl!
+ h# 4F0063 h# 200 reg-rl!
+ H# 8C02A2 h# 204 reg-rl!
+ H# 1Df020C h# 208 reg-rl!
+ h# 8201EA h# 20C reg-rl!
+ h# 50 reg-rl@ H# F8FFFFFF AND h# 03000000 or h# 50 reg-rl!
+ h# 50 h# 22C reg-rl!
+ set-palette
+
+ \ at this point for some reason mem-addr does not point
+ \ to the right address and therefore the following command
+ \ which should probably clean the frame buffer just
+ \ overwrites everything starting from 0 including the
+ \ exception vectors
+
+ \ mem-addr h# F0000 0 fill
+ ;
+
+: DO-INIT
+ early-map
+ enable-card
+ init1
+ pllinit
+ init2
+ initmem
+ init-card
+ h# 8020 h# 54 reg-rl!
+ early-unmap
+;
+
+d# 640 constant /scanline
+d# 480 constant #scanlines
+/scanline #scanlines * constant /fb
+
+" okay" encode-string " status" property
+
+: display-install ( -- )
+ is_installed not if
+ map-csr-base
+ enable-card
+ mem-addr to frame-buffer-adr
+ h# 8020 h# 54 reg-rl!
+ default-font set-font
+ /scanline #scanlines d# 100 d# 40 fb8-install
+ true to is_installed
+ then
+;
+
+: display-remove ( -- ) ;
+
+do-init \ Set up the card
+\ clear at least 640x480
+10 config-l@ 8 - F0000 0 rfill
+init1_array init1_length encode-array " ibm,init1" property
+init2_array init2_length encode-array " ibm,init2" property
+pllinit_array pllinit_length encode-array " ibm,pllinit" property
+meminit_array meminit_length encode-array " ibm,meminit" property
+0 0 encode-bytes " iso6429-1983-colors" property
+s" display" device-type
+/scanline encode-int " width" property
+ #scanlines encode-int " height" property
+8 encode-int " depth" property
+/scanline encode-int " linebytes" property
+
+' display-install is-install
+' display-remove is-remove
+
+: fill-rectangle ( index x y w h -- )
+ 2swap -rot /scanline * + frame-buffer-adr + ( index w h fbadr )
+ swap 0 ?do ( index w fbadr )
+ 3dup swap rot fill ( index w fbadr )
+ /scanline + ( index w fbadr' )
+ loop
+ 3drop
+;
+: draw-rectangle ( addr x y w h -- )
+ 2swap -rot /scanline * + frame-buffer-adr + ( addr w h fbadr )
+ swap 0 ?do ( addr w fbadr )
+ 3dup swap move ( addr w fbadr )
+ >r tuck + swap r> ( addr' w fbadr )
+ /scanline + ( addr' w fbadr' )
+ loop
+ 3drop
+ ;
+ : read-rectangle ( addr x y w h -- )
+ 2swap -rot /scanline * + frame-buffer-adr + ( addr w h fbadr )
+ swap 0 ?do ( addr w fbadr )
+ 3dup -rot move ( addr w fbadr )
+ >r tuck + swap r> ( addr' w fbadr )
+ /scanline + ( addr' w fbadr' )
+ loop
+ 3drop
+ ;
+
+: dimensions ( -- width height ) /scanline #scanlines ;
+
+." ( rn50 )" cr
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-device_1014_028c.fs b/qemu/roms/SLOF/board-js2x/slof/pci-device_1014_028c.fs
new file mode 100644
index 000000000..e83a4e04f
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-device_1014_028c.fs
@@ -0,0 +1,25 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+my-space assign-all-device-bars
+my-space pci-device-props
+my-space pci-set-irq-line
+
+\ set Memory Write and Invalidate Enable, SERR# Enable (see PCI 3.0 Spec Chapter 6.2.2 device control)
+
+7 4 config-w!
+
+
+\ Citrine storage controller.
+s" citrine"
+
+include citrine.fs
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-device_1014_02bd.fs b/qemu/roms/SLOF/board-js2x/slof/pci-device_1014_02bd.fs
new file mode 100644
index 000000000..1db6bdafc
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-device_1014_02bd.fs
@@ -0,0 +1,23 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+my-space assign-all-device-bars
+my-space pci-device-props
+my-space pci-set-irq-line
+
+\ set Memory Write and Invalidate Enable, SERR# Enable (see PCI 3.0 Spec Chapter 6.2.2 device control)
+7 4 config-w!
+
+\ Citrine storage controller.
+s" obsidian"
+
+include citrine.fs
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7451.fs b/qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7451.fs
new file mode 100644
index 000000000..e540cba9c
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7451.fs
@@ -0,0 +1,34 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+\ IO-APIC init
+
+s" io-apic" 2dup device-name device-type
+my-space pci-class-name type s" ( 8131 IO-APIC )" type
+
+pci-io-enable
+pci-mem-enable
+pci-master-enable
+
+my-space b rshift \ Get slot #.
+dup c lshift fec00000 or \ Calculate base address.
+dup 48 config-l! 0 4c config-l! \ Set base address.
+03 44 config-b! \ Enable IO-APIC.
+
+s" ioapic.fs" included
+
+2 lshift 14 + \ Calculate first IRQ #.
+init-ioapic \ Set IRQs.
+
+my-space pci-device-props
+
+cr
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7468.fs b/qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7468.fs
new file mode 100644
index 000000000..4126ca241
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7468.fs
@@ -0,0 +1,50 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+my-space assign-all-device-bars
+my-space pci-device-props
+my-space pci-set-irq-line
+
+\ See the "ISA/EISA/ISA-PnP" OF binding document.
+
+.( isa)
+
+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).
+
+2 encode-int s" #address-cells" property
+1 encode-int s" #size-cells" property
+
+\ We assume all ISA addresses to refer to I/O space.
+: decode-unit 1 hex-decode-unit 1 ;
+: encode-unit drop 1 hex-encode-unit ;
+
+\ 32kB of ISA I/O space.
+1 encode-int my-space 01000000 + encode-64+ 0 encode-int+ 0 encode-int+
+8000 encode-int+ s" ranges" property
+
+: open true ;
+: close ;
+
+\ There's a SIO chip on the LPC bus.
+INCLUDE sio.fs
+
+\ There's also an Atmel TPM chip on JS21
+\ removed on Bimini Pass 2 and therefore disabled on all Biminis
+u4? bimini? not and ?INCLUDE tpm.fs
+
+\ And finally there's the IPMI interface to the BMC.
+u4? ?INCLUDE ipmi-kcs.fs
+
+cr
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7469.fs b/qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7469.fs
new file mode 100644
index 000000000..fdae920c3
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-device_1022_7469.fs
@@ -0,0 +1,23 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+my-space assign-all-device-bars
+my-space pci-device-props
+my-space pci-set-irq-line
+
+7 4 config-w!
+
+s" ide" type cr
+
+include ide.fs
+
+cr
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-device_14e4_16a8.fs b/qemu/roms/SLOF/board-js2x/slof/pci-device_14e4_16a8.fs
new file mode 100644
index 000000000..ef782c948
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-device_14e4_16a8.fs
@@ -0,0 +1,23 @@
+\ *****************************************************************************
+\ * Copyright (c) 2013 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
+\ ****************************************************************************/
+
+\ Handle bcm57xx device
+
+s" bcm57xx [ net ]" type cr
+
+my-space pci-device-generic-setup
+
+pci-io-enable
+
+s" bcm57xx.fs" included
+
+pci-device-disable
diff --git a/qemu/roms/SLOF/board-js2x/slof/pci-interrupts.fs b/qemu/roms/SLOF/board-js2x/slof/pci-interrupts.fs
new file mode 100644
index 000000000..92851cd58
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/pci-interrupts.fs
@@ -0,0 +1,235 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+\ define function pointer as forward declaration for get-interrupt-line
+\ this is board wireing and southbridge dependent
+\ returns the wired interrupt line for this config addr
+\ ( config-addr -- irq-line )
+DEFER pci-get-irq-line
+
+\ define function pointer as forward declaration for get-interrupt-sense-type
+\ this is board wireing and southbridge dependent
+\ returns the wired interrupt sense type for this config addr
+\ 0 - Edge rising
+\ 1 - Level low
+\ 2 - Level high
+\ 3 - Edge falling
+\ ( config-addr -- irq-sense )
+DEFER pci-get-irq-sense
+
+
+\ *****************************************************************************
+\ Generic IRQ routines
+\ *****************************************************************************
+
+
+
+: unknown-slot ( -- 0 )
+\ cr pci-vec ABORT" Unknown slot "
+ 0
+;
+\ 0c s" /ht/@1/@2" PCI-X INTA & INTC Pnpirq0 -> irq12
+\ 0e s" /ht/@1/@2" PCI-X INTB & INTD Pnpirq1 -> irq14
+\ 10 s" /ht/@8,1" ATA
+\ 0f s" /ht/@1/@1" Obsidian Pnpirq2 -> irq15
+\ 10 s" /ht/@7/@2" Video / Exar Serial PirqA
+\ 11 s" /ht/@2/@4" Ethernet PirqB
+\ 12 s" /ht/@2/@4,1" Ethernet PirqC
+\ 13 s" /ht/@7/@0" USB PirqD
+\ 13 s" /ht/@7/@0,1" USB PirqD
+\ 13 s" /ht/@7/@0,2" USB PirqD
+
+\ 14 s" /ht/@3/@0" PCIe gpio28
+\ 15 s" /ht/@4/@0" PCIe gpio29
+\ 16 s" /ht/@5/@0" PCIe gpio30
+\ 17 s" /ht/@6/@0" PCIe gpio31
+
+
+\ -----------------------------------------------------------------------------
+\ Get the interrupt pin for a device on ht u4
+: u4-get-irq-line ( config-addr -- irq-line )
+\ cr s" u4-get-irq-line " type
+ pci-device-vec c@ CASE
+ 1 OF pci-device-vec-len 1 >= IF
+ pci-device-vec 1+ c@ CASE
+ 1 OF f ENDOF
+ 2 OF dup pci-interrupt@ CASE
+ 1 OF c ENDOF
+ 3 OF e ENDOF
+ 2 OF c ENDOF
+ 4 OF e ENDOF
+ ENDCASE
+ ENDOF
+ dup OF unknown-slot ENDOF
+ ENDCASE
+ ELSE
+ unknown-slot
+ THEN
+ ENDOF
+ 2 OF pci-device-vec-len 1 >= IF
+ pci-device-vec 1+ c@ CASE
+ 4 OF dup pci-addr2fn 1 >= IF 12 ELSE 11 THEN ENDOF
+ dup OF unknown-slot ENDOF
+ ENDCASE
+ ELSE
+ unknown-slot
+ THEN
+ ENDOF
+ 3 OF 14 ENDOF
+ 4 OF 15 ENDOF
+ 5 OF 16 ENDOF
+ 6 OF 17 ENDOF
+ 7 OF pci-device-vec-len 1 >= IF
+ pci-device-vec 1+ c@ CASE
+ 0 OF 13 ENDOF
+ 2 OF 10 ENDOF
+ dup OF unknown-slot ENDOF
+ ENDCASE
+ ELSE
+ unknown-slot
+ THEN
+ ENDOF
+ 8 OF 10 ENDOF
+ dup OF unknown-slot ENDOF
+ ENDCASE
+ swap drop
+;
+
+\ -----------------------------------------------------------------------------
+\ Get the interrupt sense type for a device on ht u4
+: u4-get-irq-sense ( config-addr -- irq-sense )
+\ cr s" u4-get-irq-sense " type
+ u4-get-irq-line CASE
+ 0c OF 00 ENDOF
+ 0e OF 00 ENDOF
+ dup OF 01 ENDOF
+ ENDCASE
+;
+
+\ 10 s" /ht/@4,1" set-pci-interrupt \ ATA
+\ 13 s" /ht/@3/@0" set-pci-interrupt \ USB
+\ 13 s" /ht/@3/@0,1" set-pci-interrupt \ USB
+\ 13 s" /ht/@3/@0,2" set-pci-interrupt \ USB
+\ 1c s" /ht/@2/@1" set-pci-interrupt \ Ethernet
+\ 1d s" /ht/@2/@1,1" set-pci-interrupt \ Ethernet
+
+\ -----------------------------------------------------------------------------
+\ Get the interrupt pin for a device on ht u3
+: u3-get-irq-line ( config-addr -- irq-line )
+\ cr s" u3-get-irq-line " type
+ pci-device-vec c@ CASE
+ 2 OF pci-device-vec-len 1 >= IF
+ pci-device-vec 1+ c@ CASE
+ 1 OF dup pci-addr2fn 1 >= IF 1d ELSE 1c THEN ENDOF
+ dup OF unknown-slot ENDOF
+ ENDCASE
+ ELSE
+ unknown-slot
+ THEN
+ ENDOF
+ 3 OF 13 ENDOF
+ 4 OF 10 ENDOF
+ dup OF unknown-slot ENDOF
+ ENDCASE
+ swap drop
+;
+
+\ -----------------------------------------------------------------------------
+\ Get the interrupt sense type for a device on ht u3
+: u3-get-irq-sense ( config-addr -- irq-sense )
+\ cr s" u3-get-irq-sense " type
+ u3-get-irq-line CASE
+ dup OF 01 ENDOF
+ ENDCASE
+;
+
+
+
+\ -----------------------------------------------------------------------------
+\ Get the interrupt pin for a device on attu
+: pcie-get-irq-line ( config-addr -- irq-line )
+\ cr s" pcie-get-irq-line " type
+ drop
+ 3
+;
+
+
+\ -----------------------------------------------------------------------------
+\ Get the interrupt sense type for a device on attu
+: pcie-get-irq-sense ( config-addr -- irq-sense )
+\ cr s" pcie-get-irq-sense " type
+ drop
+ 01
+;
+
+\ -----------------------------------------------------------------------------
+\ Set up the special routines for HT irq handling
+: ht-irq-init ( -- )
+\ cr s" ht-irq-init " type
+ u4? IF
+ ['] u4-get-irq-line TO pci-get-irq-line
+ ['] u4-get-irq-sense TO pci-get-irq-sense
+ ELSE
+ ['] u3-get-irq-line TO pci-get-irq-line
+ ['] u3-get-irq-sense TO pci-get-irq-sense
+ THEN
+;
+
+\ -----------------------------------------------------------------------------
+\ Set up the special routines for PCI-e irq handling
+: pcie-irq-init ( -- )
+\ cr s" pcie-irq-init " type
+ ['] pcie-get-irq-sense TO pci-get-irq-sense
+ ['] pcie-get-irq-line TO pci-get-irq-line
+;
+
+\ -----------------------------------------------------------------------------
+\ Set up the special routines for irq handling
+0 VALUE mpic
+: pci-irq-init ( mpic puid -- mpic )
+ over TO mpic
+ 18 rshift FF and
+ CASE
+ F1 OF pcie-irq-init ENDOF
+ F2 OF ht-irq-init ENDOF
+ dup OF ABORT" Wrong PUID! in pci-irq-init" ENDOF
+ ENDCASE
+;
+
+\ -----------------------------------------------------------------------------
+\ Set the interrupt pin for a device
+: pci-set-irq-line ( config-addr -- )
+\ cr pci-vec
+ dup pci-get-irq-line
+\ ." ->" dup .
+ swap pci-irq-line!
+;
+
+\ -----------------------------------------------------------------------------
+\ Add an irq entry for the device at config-addr into the irq map
+\ each entry consists of 7 integer values
+\ Structure of an entry:
+\ +----------+---+---+------------+--------------+---------+---------------+
+\ Number# | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
+\ +----------+---+---+------------+--------------+---------+---------------+
+\ meaning | config | | | int# | phandle | intr nr | pos edge (0) |
+\ | addr | | | (1=a, 2=b, | intr contr | | act ll (1) |
+\ +----------+---+---+------------+--------------+---------+---------------+
+\ value | pci slot | 0 | 0 | 1 | mpic | 7 | 0|1 |
+\ +----------+---+---+------------+--------------+---------+---------------+
+: pci-gen-irq-entry ( prop-addr prop-len config-addr -- prop-addr prop-len )
+ dup >r encode-int+ 0 encode-64+ \ config addr
+ r@ pci-interrupt@ encode-int+ \ interrupt type
+ mpic encode-int+ \ phandle to MPIC
+ r@ pci-irq-line@ encode-int+ \ interrupt number
+ r> pci-get-irq-sense encode-int+ \ trigger type
+;
diff --git a/qemu/roms/SLOF/board-js2x/slof/rtas.fs b/qemu/roms/SLOF/board-js2x/slof/rtas.fs
new file mode 100644
index 000000000..0a90c2903
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/rtas.fs
@@ -0,0 +1,240 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+#include <rtas/rtas-init.fs>
+#include <rtas/rtas-cpu.fs>
+#include <rtas/rtas-reboot.fs>
+#include <rtas/rtas-flash.fs>
+#include <rtas/rtas-vpd.fs>
+
+\ for update-flash
+: (get-flashside) ( -- flashside ) rtas-get-flashside ;
+
+' (get-flashside) to get-flashside
+
+\ remember the current flashside
+get-flashside to flashside?
+
+\ for update-flash
+: (set-flashside) ( flashside -- status )
+ dup rtas-set-flashside = IF 0 ELSE -1 THEN
+;
+
+' (set-flashside) to set-flashside
+
+: rtas-ibm-read-pci-config ( size puid bus devfn off -- x )
+ [ s" ibm,read-pci-config" rtas-get-token ] LITERAL rtas-cb rtas>token l!
+ 4 rtas-cb rtas>nargs l!
+ 2 rtas-cb rtas>nret l!
+ swap 8 lshift or swap 10 lshift or rtas-cb rtas>args0 l!
+ dup 20 rshift rtas-cb rtas>args1 l!
+ ffffffff and rtas-cb rtas>args2 l!
+ rtas-cb rtas>args3 l!
+ enter-rtas
+ rtas-cb rtas>args5 l@
+;
+
+: rtas-fetch-cpus ( mask -- status )
+ [ s" rtas-fetch-slaves" rtas-get-token ] LITERAL rtas-cb rtas>token l!
+ 1 rtas-cb rtas>nargs l!
+ 1 rtas-cb rtas>nret l!
+ rtas-cb rtas>args0 l!
+ 0 rtas-cb rtas>args1 l!
+ enter-rtas
+ rtas-cb rtas>args1 l@
+;
+
+: rtas-stop-bootwatchdog ( -- status )
+ [ s" rtas-stop-bootwatchdog" rtas-get-token ] LITERAL rtas-cb rtas>token l!
+ 0 rtas-cb rtas>nargs l!
+ 1 rtas-cb rtas>nret l!
+ enter-rtas
+ rtas-cb rtas>args0 l@
+;
+
+: rtas-set-bootwatchdog ( seconds -- )
+ [ s" rtas-set-bootwatchdog" rtas-get-token ] LITERAL rtas-cb rtas>token l!
+ 1 rtas-cb rtas>nargs l!
+ 0 rtas-cb rtas>nret l!
+ rtas-cb rtas>args0 l!
+ enter-rtas
+;
+
+' rtas-set-bootwatchdog to set-watchdog
+
+: rtas-dump-flash ( offset cnt -- )
+ [ s" rtas-dump-flash" rtas-get-token ] LITERAL rtas-cb rtas>token l!
+ 2 rtas-cb rtas>nargs l!
+ 0 rtas-cb rtas>nret l!
+ rtas-cb rtas>args0 l!
+ rtas-cb rtas>args1 l!
+ enter-rtas
+;
+
+create blist 50 allot
+blist 50 erase
+
+: build-blocklist_old
+ \ set version
+ 1 blist c!
+ \ set length of block list
+ 50 blist 7 + c!
+ \ no more block list
+ 0000000000000000 blist 8 + !
+ \ first block
+ get-load-base 0 + blist 10 + !
+ 80000 blist 18 + !
+ get-load-base 80000 + blist 20 + !
+ 80000 blist 28 + !
+ get-load-base 100000 + blist 30 + !
+ 80000 blist 38 + !
+ get-load-base 180000 + blist 40 + !
+ 8006C blist 48 + !
+;
+
+80000 constant _block_size
+
+: build-blocklist
+ \ set length of block list
+ \ length of flashfs at load-base is at offset 30... get it...
+ get-load-base 30 + @
+ \ calculate the number of blocks we need
+ _block_size / 1 +
+ \ total number of blocks is 2 (for header and block_list extension + (number of blocks for flashfs * 2 (1 for address 1 for length))
+ 2 * 2 + 8 * blist !
+ \ set version ( in first byte only )
+ 1 blist c!
+ \ no more block list
+ 0000000000000000 blist 8 + !
+ \ length of flashfs at load-base is at offset 30... get it...
+ get-load-base 30 + @
+ \ i define one block to be 64K, so calculate the number of blocks we need and loop over them
+ _block_size / 1 + 0 do
+ get-load-base _block_size i * + \ which position of load-base to store
+ blist 10 + \ at what offset of blist ( 0x8 + for header 0x8 + for extension )
+ i 10 * + \ for each loop we have done 0x10 +
+ ! \ store it
+ get-load-base 30 + @
+ _block_size i * - \ remaining length
+ dup _block_size >
+ IF \ is the remaining length > block size
+ drop _block_size \ then store the block size as length
+ ELSE
+ \ do nothing (store remaining length)
+ THEN
+ blist 10 + \ store the length at
+ i 10 * + \ correct blist offset
+ 8 + \ + 8 (we have stored address, now the length)
+ ! \ store it
+ loop
+;
+
+
+
+: build-blocklist-v0_old
+ \ set version
+ 0 blist c!
+ 48 blist 7 + c!
+ \ first block
+ get-load-base 0 + blist 8 + !
+ 80000 blist 10 + !
+ get-load-base 80000 + blist 18 + !
+ 80000 blist 20 + !
+ get-load-base 100000 + blist 28 + !
+ 80000 blist 30 + !
+ get-load-base 180000 + blist 38 + !
+ 8006C blist 40 + !
+;
+
+: build-blocklist-v0
+ \ set length of block list
+ \ length of flashfs at load-base is at offset 30... get it...
+ get-load-base 30 + @
+ \ calculate the number of blocks we need
+ _block_size / 1 +
+ \ total number of blocks is 1 (for header + (number of blocks for flashfs * 2 (1 for address 1 for length))
+ 2 * 1 + 8 * blist !
+ \ length of flashfs at load-base is at offset 30... get it...
+ get-load-base 30 + @
+ \ i define one block to be 64K, so calculate the number of blocks we need and loop over them
+ _block_size / 1 + 0 do
+ get-load-base _block_size i * + \ which position of load-base to store
+ blist 8 + \ at what offset of blist ( 0x8 + for header)
+ i 10 * + \ for each loop we have done 0x10 +
+ ! \ store it
+ get-load-base 30 + @
+ _block_size i * - \ remaining length
+ dup _block_size >
+ IF \ is the remaining length > block size
+ drop _block_size \ then store the block size as length
+ ELSE
+ \ do nothing (store remaining length)
+ THEN
+ blist 8 + \ store the length at
+ i 10 * + \ correct blist offset
+ 8 + \ + 8 (we have stored address, now the length)
+ ! \ store it
+ loop
+;
+
+
+: yy
+ build-blocklist
+ blist rtas-ibm-update-flash-64-and-reboot
+;
+
+: yy0
+ build-blocklist-v0
+ blist rtas-ibm-update-flash-64-and-reboot
+;
+
+: rtas-ibm-update-flash-64 ( block-list -- status )
+ [ s" ibm,update-flash-64" rtas-get-token ] LITERAL rtas-cb rtas>token l!
+ 2 rtas-cb rtas>nargs l!
+ 1 rtas-cb rtas>nret l!
+ rtas-cb rtas>args0 l!
+ \ special unofficial parameter: if this is set to 1, the rtas function will not check, wether
+ \ we are on the perm side... this is needed for "update-flash -c" to work...
+ 1 rtas-cb rtas>args1 l!
+ enter-rtas
+ rtas-cb rtas>args2 l@
+;
+
+\ for update-flash
+: flash-write ( image-address -- status)
+ load-base-override >r to load-base-override build-blocklist-v0
+ blist rtas-ibm-update-flash-64
+ r> to load-base-override 0= IF true ELSE false THEN
+;
+
+: commit 1 rtas-ibm-manage-flash-image ;
+: reject 0 rtas-ibm-manage-flash-image ;
+
+: rtas-ibm-validate-flash-image ( image-to-commit -- status )
+ [ s" ibm,validate-flash-image" rtas-get-token ] LITERAL rtas-cb rtas>token l!
+ 2 rtas-cb rtas>nargs l!
+ 2 rtas-cb rtas>nret l!
+ rtas-cb rtas>args0 l!
+ enter-rtas
+ rtas-cb rtas>args1 l@
+;
+
+: rtas-get-blade-descr ( address size -- len status )
+ [ s" rtas-get-blade-descr" rtas-get-token ] LITERAL rtas-cb rtas>token l!
+ 2 rtas-cb rtas>nargs l!
+ 2 rtas-cb rtas>nret l!
+ rtas-cb rtas>args1 l!
+ rtas-cb rtas>args0 l!
+ enter-rtas
+ rtas-cb rtas>args2 l@
+ rtas-cb rtas>args3 l@
+;
diff --git a/qemu/roms/SLOF/board-js2x/slof/rtc.fs b/qemu/roms/SLOF/board-js2x/slof/rtc.fs
new file mode 100644
index 000000000..861b3f9ff
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/rtc.fs
@@ -0,0 +1,59 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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.
+\ PC87417.pdf
+\ moved the RTC initialisation from the device tree to a much earlier point
+\ so that the RTC can be accessed before device tree is generated
+
+\ Enable the RTC, set its address at 1070
+\ see PC87417.pdf page 39 (chapter 3.2.3)
+10 7 siocfg!
+1 30 siocfg!
+1070 wbsplit nip dup 60 siocfg! 62 siocfg!
+
+: rtc@ ( offset -- value )
+ 1070 io-c! 1071 io-c@
+;
+
+: rtc! ( value offset -- )
+ 1070 io-c! 1071 io-c!
+;
+
+\ Set sane configuration; BCD mode is required by Linux.
+\ PC87417.pdf page 153 (chapter 8.3.13) - RTC Control Register A
+\ 20 - Divider Chain Control = Normal Operation
+20 0a rtc!
+\ PC87417.pdf page 155 (chapter 8.3.14) - RTC Control Register B
+\ 02 - 24-hour format enabled
+02 0b rtc!
+\ PC87417.pdf page 156 (chapter 8.3.15) - RTC Control Register C
+00 0c rtc!
+
+\ read from the rtc and do the bcd-to-bin conversion
+: rtc-bin@ ( offset -- value )
+ rtc@ bcd-to-bin
+;
+
+\ to be compatible with the cell boards we provide a .date word
+\ .date prints the current date and time on the firmware prompt
+: .date ( -- )
+ 0 rtc-bin@ ( seconds )
+ 2 rtc-bin@
+ 4 rtc-bin@
+ 7 rtc-bin@
+ 8 rtc-bin@ ( seconds minutes hours day month )
+ 9 rtc-bin@ d# 1900 + dup d# 1970 < IF d# 100 + THEN
+ decimal 4 0.r 2d emit 2 0.r 2d emit 2 0.r space
+ 2 0.r 3a emit 2 0.r 3a emit 2 0.r hex
+;
diff --git a/qemu/roms/SLOF/board-js2x/slof/serial.fs b/qemu/roms/SLOF/board-js2x/slof/serial.fs
new file mode 100644
index 000000000..98b2f2939
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/serial.fs
@@ -0,0 +1,48 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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.
+\ remember last console used
+CREATE lastser 4 allot 0 lastser l!
+
+\ On JS21, use serial port 2. Detect Maui by looking at the SIO version.
+20 siocfg@ f2 = IF 2f8 ELSE 3f8 THEN
+
+: >serial LITERAL + ;
+: js21? -2f8 >serial 0= ;
+: serial! js21? IF 2dup 2f8 + io-c! THEN 3f8 + io-c! ;
+: serial1@ 3f8 + io-c@ ;
+: serial2@ 2f8 + 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 serial1@ 20 and UNTIL
+ js21? IF BEGIN 5 serial2@ 20 and UNTIL THEN 0 serial! ;
+: serial1-key? 5 serial1@ 1 and 0<> ;
+: serial2-key? 5 serial2@ 1 and 0<> ;
+: serial1-key serial1-key? dup IF 0 serial1@ swap 0 lastser l! THEN ;
+: serial2-key serial2-key? dup IF 0 serial2@ swap 1 lastser l! THEN ;
+: serial-key BEGIN serial1-key dup IF ELSE js21? IF drop serial2-key THEN THEN UNTIL ;
+: serial-key? serial1-key? js21? IF serial2-key? or THEN ;
+
+\ : serial-key BEGIN 5 serial2@ 1 and UNTIL 0 serial2@ ;
+\ : serial-key? 5 serial2@ 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 @ ) 0 >serial .
diff --git a/qemu/roms/SLOF/board-js2x/slof/sio.fs b/qemu/roms/SLOF/board-js2x/slof/sio.fs
new file mode 100644
index 000000000..554cf83e3
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/sio.fs
@@ -0,0 +1,85 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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 use both serial ports, and the RTC.
+
+\ See 3.7.5.
+new-device 3f8 1 set-unit
+
+s" serial" 2dup device-name device-type
+
+\ Enable this UART.
+3 7 siocfg! 1 30 siocfg!
+
+\ 8 bytes of ISA I/O space
+my-unit encode-int rot encode-int+ 8 encode-int+ s" reg" property
+d# 19200 encode-int s" current-speed" property
+44 encode-int 0 encode-int+ s" interrupts" property
+
+: open true ;
+: close ;
+: write ( adr len -- actual ) tuck type ;
+: read ( adr len -- actual ) 0= IF drop 0 EXIT THEN
+ serial-key? 0= IF 0 swap c! -2 EXIT THEN
+ serial-key swap c! 1 ;
+
+finish-device
+
+
+new-device 2f8 1 set-unit
+
+s" serial" 2dup device-name device-type
+
+\ Enable this UART.
+2 7 siocfg! 1 30 siocfg!
+
+\ 8 bytes of ISA I/O space
+my-unit encode-int rot encode-int+ 8 encode-int+ s" reg" property
+d# 19200 encode-int s" current-speed" property
+43 encode-int 0 encode-int+ s" interrupts" property
+
+: open true ;
+: close ;
+: write ( adr len -- actual ) tuck type ;
+: read ( adr len -- actual ) 0= IF drop 0 EXIT THEN
+ serial-key? 0= IF 0 swap c! -2 EXIT THEN
+ serial-key swap c! 1 ;
+
+finish-device
+
+
+
+\ See the "Device Support Extensions" OF Recommended Practice document.
+new-device 1070 1 set-unit
+
+s" rtc" 2dup device-name device-type
+\ Following is for Linux, to recognize this RTC:
+s" pnpPNP,b00" compatible
+
+: rtc! my-space io-c! my-space 1+ io-c! ;
+: rtc@ my-space io-c! my-space 1+ io-c@ ;
+
+\ 10 bytes of ISA I/O space, at 1070.
+my-unit encode-int rot encode-int+ 10 encode-int+ s" reg" property
+
+: open true ;
+: close ;
+
+\ XXX: dummy methods.
+: get-time ( -- sec min hr day mth yr ) 38 22 c 1 1 d# 1973 ;
+: set-time ( sec min hr day mth yr -- ) 3drop 3drop ;
+
+finish-device
diff --git a/qemu/roms/SLOF/board-js2x/slof/tpm.fs b/qemu/roms/SLOF/board-js2x/slof/tpm.fs
new file mode 100644
index 000000000..69b9bc409
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/tpm.fs
@@ -0,0 +1,63 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+
+\ Atmel TPM.
+
+new-device 500 1 set-unit
+
+s" tpm" 2dup device-name device-type
+
+s" AT97SC3201" compatible
+
+\ 2 bytes of ISA I/O space
+my-unit encode-int rot encode-int+ 2 encode-int+ s" reg" property
+
+: >tpm 4e io-c! ;
+: tpm@ >tpm 4f io-c@ ;
+: tpm! >tpm 4f io-c! ;
+
+: dump-tpm 11 0 DO cr i 2 .r space i tpm@ 2 0.r LOOP ;
+
+my-address wbsplit 9 tpm! 8 tpm! \ set base address
+0 a tpm! \ disable serint
+
+\ Now we need to execute TPM_Startup.
+CREATE startup-cmd
+0 c, c1 c,
+0 c, 0 c, 0 c, c c,
+0 c, 0 c, 0 c, 99 c, \ TPM_ORD_Startup
+0 c, 1 c, \ TCPA_ST_CLEAR
+
+: send ( addr len -- ) bounds ?DO i c@ 500 io-c! LOOP ;
+: wait-for-ready ( -- ) BEGIN 501 io-c@ 3 and 2 = UNTIL ;
+: recv-verbose ( -- )
+ cr ." TPM result: "
+ 500 io-c@ 2 0.r 500 io-c@ 2 0.r space
+ 500 io-c@ 500 io-c@ 500 io-c@ 500 io-c@
+ bljoin lbflip 6 - dup 8 0.r space 0
+ ?DO 500 io-c@ . LOOP
+;
+
+: recv ( -- )
+ 500 io-c@ drop 500 io-c@ drop
+ 500 io-c@ 500 io-c@ 500 io-c@ 500 io-c@
+ bljoin lbflip 6 - 0
+ ?DO 500 io-c@ drop LOOP
+;
+
+startup-cmd c send wait-for-ready recv
+
+: open true ;
+: close ;
+
+finish-device
diff --git a/qemu/roms/SLOF/board-js2x/slof/tree.fs b/qemu/roms/SLOF/board-js2x/slof/tree.fs
new file mode 100644
index 000000000..040d99f09
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/tree.fs
@@ -0,0 +1,225 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+400 cp
+
+0 value puid
+
+: >conf-rtas ( config-addr -- config-addr )
+ puid f2000000 >= IF
+ ffffff AND \ Mask away highest byte for normal PCI
+ dup ffff > IF
+ 1000000 +
+ THEN
+ THEN
+ puid +
+;
+
+: rtas-config-b@ ( config-addr -- value ) >conf-rtas rb@ ;
+: rtas-config-b! ( value config-addr -- ) >conf-rtas rb! ;
+: rtas-config-w@ ( config-addr -- value ) >conf-rtas rw@-le ;
+: rtas-config-w! ( value config-addr -- ) >conf-rtas rw!-le ;
+: rtas-config-l@ ( config-addr -- value ) >conf-rtas rl@-le ;
+: rtas-config-l! ( value config-addr -- ) >conf-rtas rl!-le ;
+
+440 cp
+
+#include "pci-scan.fs"
+
+480 cp
+
+\ The root of the device tree and some of its kids.
+
+s" /" find-device
+\ read model string from VPD
+vpd-read-model ( straddr strlen )
+\ if it is a bimini, we replace the "IBM," in the model string with "TSS,"
+bimini? IF
+ 2dup drop 4 ( straddr strlen str 4 ) \ for string comparison: only first 4 bytes ("IBM,")
+ \ string comparison
+ s" IBM," str= IF
+ \ model starts with "IBM,", we replace it with "TSS,"
+ 2dup drop s" TSS," ( straddr strlen straddr replacestr len )
+ rot swap ( straddr strlen replacestr straddr len ) \ correct order for move: src dest len
+ move ( straddr strlen ) \ now we have TSS, at beginning of str...
+ THEN
+THEN
+\ store the model string
+encode-string s" model" property
+
+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 SLOF based 970 blade" device-type
+
+\ add more information to the compatible property
+js21? IF
+ bimini? IF
+ s" IBM,Bimini"
+ ELSE
+ s" IBM,JS21"
+ THEN
+ELSE
+ s" IBM,JS20"
+THEN encode-string
+\ To get linux-2.6.10 and later to work out-of-the-box.
+s" Momentum,Maple" encode-string encode+ s" compatible" property
+
+
+\ See 3.6.5, and the PowerPC OF binding document.
+new-device
+s" mmu" 2dup device-name device-type
+0 0 s" translations" property
+
+: open true ;
+: close ;
+
+finish-device
+
+new-device flash-addr set-unit-64
+ s" flash" 2dup device-name device-type
+ 0 encode-int flash-addr encode-int+
+ 0 encode-int+ get-flash-size encode-int+ s" reg" property
+ get-flash-size encode-int s" #bytes" property
+ 0 0 s" used-by-rtas" property
+ : open true ;
+ : close ;
+finish-device
+
+4a0 cp
+
+new-device nvram-base set-unit-64
+ s" nvram" 2dup device-name device-type
+ nvram-size encode-int s" #bytes" property
+ 0 encode-int nvram-base encode-int+
+ 0 encode-int+ nvram-size encode-int+ s" reg" property
+ get-node node>path s" nvram" 2swap set-alias
+ : open true ;
+ : close ;
+finish-device
+
+4c0 cp
+
+#include "memory.fs"
+
+500 cp
+
+#include "mpic.fs"
+
+580 cp
+
+#include "dart.fs"
+
+5a0 cp
+
+#include "i2c.fs"
+
+600 cp
+get-node device-end
+620 cp
+\ if it is js21/bimini the fbuffer code is included
+u4? ?include fbuffer.fs
+640 cp
+set-node
+
+690 cp
+
+#include "ht.fs"
+
+6b0 cp
+
+u4? ?include attu.fs
+6c0 cp
+
+\ See the PowerPC OF binding document.
+new-device
+s" cpus" device-name
+
+1 encode-int s" #address-cells" property
+0 encode-int s" #size-cells" property
+
+: decode-unit 1 hex-decode-unit ;
+: encode-unit 1 hex-encode-unit ;
+
+cpu-mask @ 40 0 DO dup 1 and IF
+i s" cpu.fs" INCLUDED THEN u2/ LOOP drop
+
+: open true ;
+: close ;
+
+finish-device
+
+master-cpu s" /cpus/@" rot (u.) $cat open-dev encode-int s" cpu" set-chosen
+s" /memory" open-dev encode-int s" memory" set-chosen
+
+6e0 cp
+
+new-device
+ s" rtas" device-name
+
+ rtas-size encode-int s" rtas-size" property
+ 00000001 encode-int s" ibm,flash-block-version" property
+ 00000001 encode-int s" rtas-event-scan-rate" property
+ rtas-create-token-properties
+ 00000001 encode-int s" rtas-version" property
+
+: open true ;
+: close ;
+
+: instantiate-rtas instantiate-rtas ;
+
+finish-device
+
+700 cp
+
+device-end
+
+\ Hack for AIX.
+s" /options" find-device
+ \ s" 33554432" encode-string s" load-base" property
+ s" 16384" encode-string s" load-base" property
+device-end
+
+\ See 3.5.
+s" /openprom" find-device
+ s" SLOF," slof-build-id here swap rmove here slof-build-id nip $cat encode-string s" model" property
+ 0 0 s" relative-addressing" property
+ flashside? 1 = IF s" T" ELSE s" P" THEN
+ encode-string s" ibm,fw-bank" property
+ takeover? not IF
+ 0 set-flashside drop
+ read-version-and-date s" ibm,fw-perm-bank" property
+ 1 set-flashside drop
+ read-version-and-date s" ibm,fw-temp-bank" property
+ flashside? set-flashside drop
+ THEN
+device-end
+
+s" /aliases" find-device
+ : open true ;
+ : close ;
+device-end
+
+s" /mmu" open-dev encode-int s" mmu" set-chosen
+
+#include "available.fs"
+
+#include <term-io.fs>
+
+u3? IF s" /ht/isa/serial@3f8" io
+ ELSE s" /ht/isa/serial@2f8" io THEN
+
diff --git a/qemu/roms/SLOF/board-js2x/slof/u4-mem.fs b/qemu/roms/SLOF/board-js2x/slof/u4-mem.fs
new file mode 100644
index 000000000..0f8b1eef6
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/u4-mem.fs
@@ -0,0 +1,313 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+
+\ U4 DDR2 memory controller.
+
+cr .( Setting up memory controller...)
+
+
+\ First, I2C access to the SPDs.
+
+: >i2c f8001000 + ;
+: i2c@ >i2c rl@ ;
+: i2c! >i2c rl! ;
+
+: .i2c 80 0 DO i i2c@ . 10 +LOOP ;
+
+: i2c-addr ( addr -- ) 50 i2c! 2 10 i2c! BEGIN 30 i2c@ 2 and UNTIL ;
+: i2c-addr-subaddr ( addr suba -- ) 60 i2c! i2c-addr ;
+: i2c-stop ( -- ) BEGIN 30 i2c@ dup 30 i2c! 4 and UNTIL ;
+: i2c-nak? ( -- failed? ) 20 i2c@ 2 and 0= dup IF i2c-stop THEN ;
+: i2c-short? ( -- failed? ) 30 i2c@ 4 and 0<> dup IF 0 10 i2c! i2c-stop THEN ;
+: i2c-aak-if-more ( n -- ) 1 <> 1 and 10 i2c! ;
+
+: i2c-sub-read ( buf len addr suba -- error? )
+ c 0 i2c! >r 1 or r> i2c-addr-subaddr i2c-nak? IF 2drop true EXIT THEN
+ dup i2c-aak-if-more 2 30 i2c!
+ BEGIN
+ 30 i2c@ 1 and IF
+ 1- >r 70 i2c@ over c! char+ r>
+ dup 0= IF i2c-stop 2drop false EXIT THEN
+ dup i2c-aak-if-more 1 30 i2c! THEN
+ i2c-short? IF 2drop true EXIT THEN
+ AGAIN ;
+
+
+\ What slots are filled with working memory (bitmask).
+
+f VALUE dimms-valid
+: dimm-invalid 1 swap lshift invert dimms-valid and to dimms-valid ;
+: dimm-invalid dup dimm-invalid 2 xor dimm-invalid ; \ DIMMs are paired
+: dimm-valid? 1 swap lshift dimms-valid and ;
+: dimm( +comp postpone 4 postpone 0 postpone DO
+ postpone i postpone dimm-valid? postpone IF ; immediate
+: )dimm postpone THEN postpone LOOP -comp ; immediate
+
+
+\ The data from the SPDs.
+
+CREATE spds 100 allot
+: spd@ ( dimm# off -- value ) swap 40 * + spds + c@ ;
+
+CREATE addresses a0 c, a4 c, a2 c, a6 c,
+dimm( spds i 40 * + 40 addresses i + c@ 0 i2c-sub-read IF i dimm-invalid THEN )dimm
+
+
+\ Accessors.
+
+: spd>rows 3 spd@ ;
+: spd>cols 4 spd@ ;
+: spd>ranks 5 spd@ 7 and 1+ ;
+: spd>width d spd@ ;
+: spd>banks 11 spd@ ;
+: spd>cas 12 spd@ ; \ bit mask of allowable CAS latencies
+: spd>trp 1b spd@ ; \ in units of 0.25 ns
+: spd>trrd 1c spd@ ; \ in units of 0.25 ns
+: spd>trcd 1d spd@ ; \ in units of 0.25 ns
+: spd>tras 1e spd@ ; \ in units of 1 ns
+: spd>twr 24 spd@ ; \ in units of 0.25 ns
+: spd>twtr 25 spd@ ; \ in units of 0.25 ns
+: spd>trtp 26 spd@ ; \ in units of 0.25 ns
+: spd>trc 29 spd@ ; \ in units of 1 ns XXX: should also look at byte 28
+: spd>trfc 2a spd@ ; \ in units of 1 ns XXX: should also look at byte 28
+
+cr .( rows cols ranks width banks trp trrd trcd tras twr twtr trtp trc trfc)
+cr .( =====================================================================)
+decimal
+dimm( cr
+i spd>rows 4 .r i spd>cols 5 .r i spd>ranks 6 .r i spd>width 6 .r
+i spd>banks 6 .r i spd>trp 4 .r i spd>trrd 5 .r i spd>trcd 5 .r
+i spd>tras 5 .r i spd>twr 4 .r i spd>twtr 5 .r i spd>trtp 5 .r
+i spd>trc 4 .r i spd>trfc 5 .r
+)dimm
+hex
+
+ff dimm( i spd>cas and )dimm CONSTANT cl-supported
+: max-cl -1 swap 8 0 DO dup 1 and IF nip i swap THEN u2/ LOOP drop ;
+cl-supported max-cl VALUE cl
+
+: tck>60*ns dup f and swap 4 rshift a * over + 6 * swap CASE
+ a OF 2d - ENDOF b OF 2e - ENDOF c OF 20 - ENDOF d OF 21 - ENDOF
+ ENDCASE ;
+: cl>tck 0 spd>cas max-cl swap -
+ CASE 0 OF 9 ENDOF 1 OF 17 ENDOF 2 OF 19 ENDOF
+ true ABORT" No supported CAS latency for this DIMM" ENDCASE
+ 0 swap spd@ tck>60*ns ;
+
+: spd>min-tck dup spd>cas max-cl cl -
+ CASE 0 OF 9 ENDOF 1 OF 17 ENDOF 2 OF 19 ENDOF
+ true ABORT" No supported CAS latency for this DIMM" ENDCASE
+ spd@ tck>60*ns ;
+: spd>max-tck 2b spd@ tck>60*ns ;
+
+: .tck base @ >r decimal dup d# 60 / 0 .r [char] . emit
+ d# 60 mod d# 1000 * d# 60 / 3 0.r ." ns" r> base ! ;
+
+cr .( CAS latencies supported: )
+8 0 DO cl-supported 1 i lshift and IF i . THEN LOOP
+
+\ Find the lowest CL at the highest tCK.
+8 0 DO cl-supported 1 i lshift and IF cl cl>tck i cl>tck = IF
+ i to cl LEAVE THEN THEN LOOP
+
+.( -- using ) cl .
+
+
+0 dimm( i spd>min-tck max )dimm CONSTANT tck
+dimm( i spd>max-tck tck < IF i dimm-invalid THEN )dimm
+cr .( tCK is ) tck .tck
+
+
+0 CONSTANT al
+cl al + CONSTANT rl
+rl 1- CONSTANT wl
+
+: // dup >r 1- + r> / ; \ round up
+0 spd>tras d# 60 * tck // CONSTANT tras
+0 spd>trtp d# 15 * tck // CONSTANT trtp
+0 spd>twr d# 15 * tck // CONSTANT twr
+0 spd>trp d# 15 * tck // CONSTANT trp
+0 spd>trrd d# 15 * tck // CONSTANT trrd
+0 spd>trrd d# 60 * tck // CONSTANT 4*trrd
+0 spd>trcd d# 15 * tck // CONSTANT trcd
+0 spd>trc d# 60 * tck // CONSTANT trc
+0 spd>twtr d# 15 * tck // CONSTANT twtr
+
+: spd>memmd
+ >r r@ spd>rows r@ spd>cols +
+ r@ spd>banks 2log + 4 * r> spd>width 2log 3 * + 6c - ;
+: dimm-group-size ( dimm# -- size )
+ >r r@ spd>rows r@ spd>cols + 1 swap lshift
+ r@ spd>banks * r> spd>ranks * 10 * ;
+VARIABLE start-address
+VARIABLE was-prev-big
+: assign-dimm-group ( dimm# -- config-value )
+ dup dimm-valid? 0= IF drop 0 EXIT THEN
+ \ MemMd, enable, single-sided or not
+ dup spd>memmd c lshift 1 or over spd>ranks 1 = IF 2 or THEN
+cr ." ---> " dup .
+>r
+ dimm-group-size start-address @ 2dup + rot ( start end size )
+ 80000000 > IF
+ dup 1000000000 < IF dup 4 rshift ELSE 08000000 THEN r> or >r \ Add2G
+ over 0<> IF over c rshift ELSE 00080000 THEN r> or >r \ Sub2G
+ was-prev-big on
+ ELSE
+ was-prev-big @ IF 80000000 + swap 80000000 + swap THEN r> 08080000 or >r
+ was-prev-big off
+ THEN
+ swap 18 rshift r> or >r \ start address
+ dup 80000000 = IF drop 100000000 THEN start-address ! r> ;
+
+
+\ Now set the frequency in the memory controller
+d# 1800 tck / 4 - 12 lshift 33c or f8000800 rl!
+f8000860 rl@ 80000000 or f8000860 rl! 10000 0 DO LOOP
+
+: mc! f8002000 + rl! ;
+: mc@ f8002000 + rl@ ;
+
+
+\ memory timing regs (state machine)
+
+tras 2-
+5 lshift al trtp + 2- or
+5 lshift wl twr + or
+5 lshift trp 2- or
+5 lshift trp 2- 0 spd>banks 8 = IF 1+ THEN or
+7 lshift 030 mc!
+
+al trtp + trp + 2-
+5 lshift cl al + twr + trp + 1- or
+5 lshift trrd 2- or
+5 lshift trc 2- or
+5 lshift trcd 2- or
+5 lshift 4*trrd or
+2 lshift 040 mc!
+
+0
+5 lshift 1 or
+5 lshift 1 or
+5 lshift cl 1- twtr + or
+5 lshift 1 or
+5 lshift 1 or
+2 lshift 050 mc!
+
+0
+5 lshift 1 or
+5 lshift 1 or
+5 lshift 2 or
+5 lshift 2 or
+5 lshift 2 or
+2 lshift 060 mc! \ XXX joerg has different setting
+
+cl 3 = IF 30801800 ( 30800d00 ) 070 mc! \ XXX memory refresh
+ELSE 41002000 070 mc! THEN
+
+\ memory size regs
+
+1 dimm-group-size 0 dimm-group-size > 1 0 rot IF swap THEN \ biggest first
+assign-dimm-group 200 mc!
+assign-dimm-group 210 mc!
+0 220 mc! 0 230 mc!
+
+
+
+
+
+\ arbiter tunables
+\ 40041040 270 mc!
+04041040 270 mc!
+50000000 280 mc!
+\ a0a00000 290 mc! \ a0000000 might be faster
+00000000 290 mc!
+\ 20020820 2a0 mc!
+04020822 2a0 mc!
+00000000 2b0 mc!
+\ 30413cc7 2c0 mc! \ have to calculate the low five bits
+30413dc5 2c0 mc!
+\ cl 3 = IF 76000050 2d0 mc! 70000000 2e0 mc! ELSE
+cl 3 = IF 75000050 2d0 mc! 70000000 2e0 mc! ELSE
+ b8002080 2d0 mc! b0000000 2e0 mc! THEN
+\ Should test for something else really
+
+
+
+cl 3 = IF 00006000 890 mc! 00006000 8a0 mc! ELSE
+ 00006500 890 mc! 00006500 8a0 mc! THEN
+
+cl 3 = IF 1e008a8a ELSE 31000000 THEN
+dup 800 mc! dup 810 mc! dup 820 mc! dup 830 mc!
+dup 900 mc! dup 910 mc! dup 920 mc! dup 930 mc! dup 980 mc!
+dup a00 mc! dup a10 mc! dup a20 mc! dup a30 mc!
+dup b00 mc! dup b10 mc! dup b20 mc! dup b30 mc! b80 mc!
+
+\ 0 8d0 mc! 0 9d0 mc! 0 ad0 mc! 0 bd0 mc!
+61630000 8d0 mc!
+61630000 9d0 mc!
+52510000 ad0 mc!
+434e0000 bd0 mc!
+
+a0200400 100 mc!
+80020000 110 mc!
+80030000 120 mc!
+80010404 130 mc!
+cl 3 = IF
+8000153a 140 mc! ELSE
+8000174a 140 mc! THEN
+a0200400 150 mc!
+\ 92000000 160 mc!
+\ 92000000 170 mc!
+\ 91300000 160 mc!
+\ 91300000 170 mc!
+91800000 160 mc!
+91800000 170 mc!
+cl 3 = IF
+8ff0143a 180 mc! ELSE
+8ff0164a 180 mc! THEN
+80010784 190 mc!
+80010404 1a0 mc!
+0 1b0 mc! 0 1c0 mc! 0 1d0 mc! 0 1e0 mc! 0 1f0 mc!
+
+cl 3 = IF
+143a 0c0 mc! ELSE
+164a 0c0 mc! THEN
+0404 0d0 mc!
+
+\ after this point, setup is common for all speeds and sizes of dimms (sort of)
+
+60000000 3a0 mc!
+
+0 840 mc! 0 850 mc! 0 860 mc! 0 870 mc!
+0 940 mc! 0 950 mc! 0 960 mc! 0 970 mc! 0 990 mc!
+0 a40 mc! 0 a50 mc! 0 a60 mc! 0 a70 mc!
+0 b40 mc! 0 b50 mc! 0 b60 mc! 0 b70 mc! 0 b90 mc!
+
+0 880 mc!
+
+001a4000 9a0 mc!
+
+84800000 500 mc!
+
+10000 0 DO LOOP
+
+80000000 b0 mc! BEGIN b0 mc@ 40000000 and UNTIL
+
+0 300 mc! 0 310 mc!
+
+80000000 440 mc!
+0 410 mc! 27fffffc 420 mc!
+fedcba98 430 mc!
+c0000000 400 mc! BEGIN 400 mc@ c0000000 and 0= UNTIL
+
+cr .( mem done)
diff --git a/qemu/roms/SLOF/board-js2x/slof/version.c b/qemu/roms/SLOF/board-js2x/slof/version.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/version.c
diff --git a/qemu/roms/SLOF/board-js2x/slof/vga-display.fs b/qemu/roms/SLOF/board-js2x/slof/vga-display.fs
new file mode 100644
index 000000000..96417e2d3
--- /dev/null
+++ b/qemu/roms/SLOF/board-js2x/slof/vga-display.fs
@@ -0,0 +1,157 @@
+\ *****************************************************************************
+\ * Copyright (c) 2004, 2008 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
+\ ****************************************************************************/
+
+\ included by pci-class_03.fs
+
+( str len display_num ) \ name prefix
+
+false value is-installed?
+value display_num ( str len )
+
+s" ,Display-" $cat 41 display_num + char-cat \ add ", Display-A" or "-B" to name ( str len )
+encode-string s" name" property \ store as name property
+
+s" display" device-type
+
+\ screen-info is set by pci-class_03.fs contains output of get_vbe_info bios-snk call
+CASE screen-info c@ \ ( display-type )
+ 0 OF s" NONE" ENDOF \ No display
+ 1 OF s" Analog" ENDOF
+ 2 OF s" Digital" ENDOF
+ENDCASE
+encode-string s" display-type" property
+
+screen-info 8 + l@ value mem-adr
+screen-info 1 + w@ value width
+screen-info 3 + w@ value height
+
+screen-info c@ IF
+ \ if screen-info is not 0, we have some screen attached, add needed properties...
+ width encode-int s" width" property
+ height encode-int s" height" property
+ screen-info 5 + w@ encode-int s" linebytes" property
+ screen-info 7 + c@ encode-int s" depth" property
+ mem-adr encode-int s" address" property
+ \ the EDID property breaks the boot... so i leave it out for now,
+ \ maybe encode-bytes does s.th. wrong???
+ \ screen-info c + 80 encode-bytes s" EDID" property
+ s" ISO8859-1" encode-string s" character-set" property \ i hope this is ok...
+THEN
+
+\ words for installation/removal, needed by is-install/is-remove, see display.fs
+: display-remove ( -- )
+;
+: display-install ( -- )
+ is-installed? NOT IF
+ mem-adr to frame-buffer-adr
+ default-font
+ set-font
+ width height width char-width / height char-height / ( width height #lines #cols )
+ fb8-install
+ true to is-installed?
+ THEN
+;
+
+: color! ( r g b number -- )
+ \ 3c8 is RAMDAC write mode select palette entry register
+ \ 3c9 is RAMDAC write mode write palette entry register ( 3 consecutive writes set new entry )
+ vga-device-node? 3c8 translate-address ( r g b number address )
+ swap 1 pick ( r g b address number address )
+ rb! \ write palette entry number ( r g b address )
+ 1 + \ select next register (3c9)
+ dup 4 pick swap rb! \ write red ( r g b address )
+ dup 3 pick swap rb! \ write green ( r g b address )
+ dup 2 pick swap rb! \ write blue ( r g b address )
+ 4drop
+;
+
+: color@ ( number -- r g b )
+ \ 3c7 is RAMDAC read mode select palette entry register
+ \ 3c9 is RAMDAC read mode read palette entry register ( 3 consecutive reads read entry )
+ vga-device-node? 3c7 translate-address ( number address )
+ swap 1 pick ( address number address )
+ rb! \ write palette entry number ( address )
+ 2 + >r \ select next register (3c9) ( R: address )
+ r@ rb@ \ read red ( r R: address )
+ r@ rb@ \ read green ( r g R: address )
+ r@ rb@ \ write blue ( r g b R: address )
+ r> drop ( r g b )
+;
+
+: set-colors ( adr number #numbers -- )
+ \ 3c8 is RAMDAC write mode select palette entry register
+ \ 3c9 is RAMDAC write mode write palette entry register ( 3 consecutive writes set new entry )
+ \ since after writing 3 entries, the palette entry is automagically incremented,
+ \ we can just continue writing...
+ vga-device-node? 3c8 translate-address ( adr number #numbers )
+ dup 3 pick swap ( adr number #numbers address number address )
+ rb! \ write palette entry number ( adr number #numbers address )
+ 1 + \ select next register (3c9)
+ -rot swap drop ( adr address #numbers )
+ -rot swap rot ( address adr #numbers )
+ 0 ?DO
+ ( address adr )
+ dup rb@ \ read red value from adr ( address adr r )
+ 2 pick rb! \ write to register ( address adr )
+ 1 + \ next adr
+ dup rb@ \ read green value from adr ( address adr g )
+ 2 pick rb! \ write to register ( address adr )
+ 1 + \ next adr
+ dup rb@ \ read blue value from adr ( address adr r )
+ 2 pick rb! \ write to register ( address adr )
+ 1 + \ next adr
+ LOOP
+ 2drop
+;
+
+: get-colors ( adr number #numbers -- )
+ \ 3c7 is RAMDAC read mode select palette entry register
+ \ 3c9 is RAMDAC read mode read palette entry register ( 3 consecutive reads get entry )
+ \ since after reading 3 entries, the palette entry is automagically incremented,
+ \ we can just continue reading...
+ vga-device-node? 3c7 translate-address ( adr number #numbers )
+ dup 3 pick swap ( adr number #numbers address number address )
+ rb! \ write palette entry number ( adr number #numbers address )
+ 2 + \ select next register (3c9)
+ -rot swap drop ( adr address #numbers )
+ -rot swap rot ( address adr #numbers )
+ 0 ?DO
+ ( address adr )
+ 1 pick rb@ \ read red value from register ( address adr r )
+ 1 pick rb! \ write to adr ( address adr )
+ 1 + \ next adr
+ 1 pick rb@ \ read green value from register ( address adr g )
+ 1 pick rb! \ write to adr ( address adr )
+ 1 + \ next adr
+ 1 pick rb@ \ read blue value from register ( address adr b )
+ 1 pick rb! \ write to adr ( address adr )
+ 1 + \ next adr
+ LOOP
+ 2drop
+;
+
+include graphics.fs
+
+\ clear screen
+mem-adr width height * 0 rfill
+
+\ call is-install and is-remove
+' display-install is-install
+
+' display-remove is-remove
+
+s" screen" find-alias 0= IF
+ \ no previous screen alias defined, define it...
+ s" screen" get-node node>path set-alias
+ELSE
+ drop
+THEN