aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Reber <adrian@lisas.de>2008-11-24 18:46:33 +0100
committerAdrian Reber <adrian@lisas.de>2008-11-24 18:46:33 +0100
commit071eca347e20696778ad22985bfd9a3598b35e59 (patch)
tree67bcbfa18461bf71bd56d9342f461739c54ce00b
parente135f70200658ca6614e05700f20a3db7ea3d580 (diff)
downloadSLOF-slof-JX-1.7.0-4.zip
SLOF-slof-JX-1.7.0-4.tar.gz
SLOF-slof-JX-1.7.0-4.tar.bz2
imported slof-JX-1.7.0-4 releaseslof-JX-1.7.0-4
-rw-r--r--Makefile.gen101
-rw-r--r--board-js2x/Makefile33
-rw-r--r--board-js2x/config1
-rw-r--r--board-js2x/llfw/Makefile9
-rw-r--r--board-js2x/llfw/u4mem.c3
-rw-r--r--board-js2x/rtas/rtas_board.c2
-rw-r--r--board-js2x/rtas/rtas_flash.c302
-rw-r--r--board-js2x/slof/OF.fs68
-rw-r--r--board-js2x/slof/helper.fs11
-rw-r--r--board-js2x/slof/ipmi-vpd.fs2
-rw-r--r--board-js2x/slof/pci-bridge_1022_7460.fs17
-rw-r--r--board-js2x/slof/pci-class_03.fs8
-rw-r--r--board-js2x/slof/rtas.fs3
-rw-r--r--board-js2x/slof/tree.fs11
-rw-r--r--clients/net-snk/app/biosemu/biosemu.c11
-rw-r--r--clients/net-snk/app/biosemu/io.c2
-rw-r--r--clients/net-snk/app/biosemu/mem.c2
-rw-r--r--clients/net-snk/kernel/init.c4
-rw-r--r--clients/takeover/Makefile6
-rw-r--r--clients/takeover/main.c4
-rw-r--r--include/ppc970/cpu.h6
-rw-r--r--other-licence/x86emu/include/x86emu/debug.h6
-rw-r--r--other-licence/x86emu/ops.c22
-rw-r--r--other-licence/x86emu/ops2.c79
-rw-r--r--other-licence/x86emu/prim_ops.c4
-rw-r--r--other-licence/x86emu/x86emu_changes.diff286
-rw-r--r--slof/OF.lds8
-rw-r--r--slof/engine.in3
-rw-r--r--slof/fs/base.fs9
-rw-r--r--slof/fs/client.fs2
-rw-r--r--slof/fs/envvar_defaults.fs4
-rw-r--r--slof/fs/find-hash.fs67
-rw-r--r--slof/fs/romfs.fs16
-rw-r--r--slof/fs/usb/usb-kbd-device-support.fs3
-rw-r--r--slof/fs/usb/usb-keyboard.fs20
-rw-r--r--slof/paflof.c5
-rw-r--r--slof/paflof.h4
-rw-r--r--slof/ppc64.c74
-rw-r--r--slof/prim.code89
-rw-r--r--slof/prim.in9
40 files changed, 926 insertions, 390 deletions
diff --git a/Makefile.gen b/Makefile.gen
index 4891944..3c5d116 100644
--- a/Makefile.gen
+++ b/Makefile.gen
@@ -19,16 +19,19 @@ include ../make.rules
ifdef DRIVER
RELEASE=$(shell cat ../VERSION)
-export DRIVER_NAME=$(shell cat ../VERSION | sed -e "s/-/./g" | awk -F . '{ printf("%s%02d%02d%1x%02x",$$1,$$2,$$3,$$4,$$5); }')
+export DRIVER_NAME=$(shell cat ../VERSION | sed -e "s/-/./g" | awk -F . '{ printf("%s%02d%02d%1s%02s",$$1,$$2,$$3,$$4,$$5); }')
else
RELEASE="$(USER)@$(HOSTNAME)(private build)"
export DRIVER_NAME=HEAD
endif
+
DRVDATE=$(shell date +%Y-%h%d)
FLASH_SIZE_MB = `echo $$[ $(FLASH_SIZE)/1024/1024 ]`
+DTB_ROMFS_FLAG ?= 0
+DTB_ROMFS_ADDR ?= 0
llfw_disassembly:
make -C $(LLFWBRDDIR) stage1.dis stage2.dis stageS.dis
@@ -56,39 +59,78 @@ romfs_build:
dtc -q -I dts -O dtb dts/$(SUBBOARD).dts > $@; \
fi
-boot_rom.bin boot_xdr.bin: $(BUILDS) ../romfs/copyright.img ../build_info.img ../$(SUBBOARD).dtb
+boot_rom.bin boot_xdr.bin: $(BUILDS) ../build_info.img ../$(SUBBOARD).dtb
+ifeq ($(DO_COMPRESS),1)
+
+ @echo " ====== Building packed $@ ======"
+ @if [ -e $(ROMFSBRDDIR)/boot_rom.$(SUBBOARD).ffs ]; then \
+ cat $(ROMFSBRDDIR)/boot_rom.$(SUBBOARD).ffs > ../.boot_rom.ffs; \
+ cat $(ROMFSBRDDIR)/boot_rom.$(SUBBOARD).pack.ffs > ../.boot_rom.pack.ffs; \
+ else \
+ cat $(ROMFSBRDDIR)/boot_rom.ffs > ../.boot_rom.ffs; \
+ cat $(ROMFSBRDDIR)/boot_rom.pack.ffs > ../.boot_rom.pack.ffs; \
+ fi
+ @if [ -e $(PCDBRDDIR)/pcdfiles.ffs ]; then \
+ cat $(PCDBRDDIR)/pcdfiles.ffs >> ../.boot_rom.ffs; \
+ cat $(PCDBRDDIR)/pcdfiles.ffs >> ../.boot_rom.pack.ffs; \
+ fi
+
+ @echo "romfs.pack boot_rom.bin.pack.nv 0 0" >> ../.boot_rom.ffs
+
+ cat $(SLOFBRDDIR)/OF.ffs >> ../.boot_rom.pack.ffs
+ @echo build_info.img build_info.img 0 0 >> ../.boot_rom.pack.ffs
+ @if [ -e ../$(SUBBOARD).dtb ]; then \
+ echo dtb $(SUBBOARD).dtb $(DTB_ROMFS_FLAG) \
+ $(DTB_ROMFS_ADDR) >> ../.boot_rom.pack.ffs; \
+ fi;
+ cd .. && ./romfs/tools/build_romfs $(ROMFS_OPTIONS) .boot_rom.pack.ffs boot_rom.bin.pack
+ cd .. && ./tools/pknova -q boot_rom.bin.pack boot_rom.bin.pack.nv;
+ cd .. && ./romfs/tools/build_romfs $(ROMFS_OPTIONS) .boot_rom.ffs $@
+ if [ "$@" = "boot_rom.bin" ]; then \
+ rm ../boot_rom.bin.pack; \
+ rm ../boot_rom.bin.pack.nv; \
+ fi;
+else
@echo " ====== Building $@ ======"
- @if [ -e $(ROMFSBRDDIR)/boot_rom.$(SUBBOARD).ffs ]; then \
- cat $(ROMFSBRDDIR)/boot_rom.$(SUBBOARD).ffs > ../.boot_rom.ffs; \
- else \
- cat $(ROMFSBRDDIR)/boot_rom.ffs > ../.boot_rom.ffs; \
- fi
- @if [ -e $(PCDBRDDIR)/pcdfiles.ffs ]; then \
- cat $(PCDBRDDIR)/pcdfiles.ffs >> ../.boot_rom.ffs; \
- fi
- cat $(SLOFBRDDIR)/OF.ffs >> ../.boot_rom.ffs
- @echo build_info.img build_info.img 0 0 >> ../.boot_rom.ffs
- @if [ -e ../$(SUBBOARD).dtb ]; then \
- echo dtb $(SUBBOARD).dtb 0 0 >> ../.boot_rom.ffs; \
- fi
- cd .. && ./romfs/tools/build_romfs .boot_rom.ffs $@
+ @if [ -e $(ROMFSBRDDIR)/boot_rom.$(SUBBOARD).ffs ]; then \
+ cat $(ROMFSBRDDIR)/boot_rom.$(SUBBOARD).ffs > ../.boot_rom.ffs; \
+ else \
+ cat $(ROMFSBRDDIR)/boot_rom.ffs > ../.boot_rom.ffs; \
+ fi
+ @if [ -e $(PCDBRDDIR)/pcdfiles.ffs ]; then \
+ cat $(PCDBRDDIR)/pcdfiles.ffs >> ../.boot_rom.ffs; \
+ fi
+ cat $(SLOFBRDDIR)/OF.ffs >> ../.boot_rom.ffs
+ @echo build_info.img build_info.img 0 0 >> ../.boot_rom.ffs
+ @if [ -e ../$(SUBBOARD).dtb ]; then \
+ echo dtb $(SUBBOARD).dtb $(DTB_ROMFS_FLAG) \
+ $(DTB_ROMFS_ADDR) >> ../.boot_rom.ffs; \
+ fi
+ @if [ -e slik.elf ]; then \
+ echo "slik.elf available ..."; \
+ echo slik board-$(BOARD)/slik.elf 0 0 >> \
+ ../.boot_rom.ffs; \
+ fi
+ cd .. && ./romfs/tools/build_romfs $(ROMFS_OPTIONS) .boot_rom.ffs $@
+endif
cd .. && if [ -f $@.gz ]; then rm -f $@.gz; gzip -9 $@ ; fi
- rm -f ../.boot_rom.ffs
+ rm -f ../.boot_rom.*ffs
rm -f ../$(SUBBOARD).dtb
../boot_l2b.bin: $(BUILDS) ../romfs/copyright.img ../$(SUBBOARD).dtb
@if [ -e $(ROMFSBRDDIR)/boot_l2.$(SUBBOARD).ffs ]; then \
- cd .. && ./romfs/tools/build_romfs $(ROMFSBRDDIR)/boot_l2.$(SUBBOARD).ffs boot_l2b.bin; \
+ cd .. && ./romfs/tools/build_romfs $(ROMFS_OPTIONS) $(ROMFSBRDDIR)/boot_l2.$(SUBBOARD).ffs boot_l2b.bin; \
else \
- cd .. && ./romfs/tools/build_romfs $(ROMFSBRDDIR)/boot_l2.ffs boot_l2b.bin; \
+ cd .. && ./romfs/tools/build_romfs $(ROMFS_OPTIONS) $(ROMFSBRDDIR)/boot_l2.ffs boot_l2b.bin; \
fi
@if [ -e ../$(SUBBOARD).dtb ]; then \
- echo dtb $(SUBBOARD).dtb 0 0 >> ../.boot_rom.ffs; \
+ echo dtb $(SUBBOARD).dtb $(DTB_ROMFS_FLAG) \
+ $(DTB_ROMFS_ADDR) >> ../.boot_rom.ffs; \
fi
rm -f ../$(SUBBOARD).dtb
-boot_l2-dd2.ad: ../boot_l2b.bin
- @cd ../tools && ./elf2l2 dd2 ../boot_l2b.bin 0 ../boot_l2-dd2.ad
+boot_l2.ad boot_l2-dd2.ad: ../boot_l2b.bin
+ @cd ../tools && ./elf2l2 dd2 ../boot_l2b.bin 0 ../$@
external_flasher: ../boot_rom.bin
../tools/make-flasher-image.sh $(FLASH_SIZE) ../boot_rom.bin \
@@ -118,8 +160,12 @@ copy_driver: copy_disassemblies external_flasher
../driver-$(RELEASE)/rom/$(RELEASE)-boot_rom-$(FLASH_SIZE_MB)MB-BigEndian.bin
mv ../boot_rom.bin \
../driver-$(RELEASE)/rom/$(RELEASE)-boot_rom.bin
- mv ../boot_l2-dd2.ad \
- ../driver-$(RELEASE)/l2b/
+ if [ -e ../boot_l2-dd2.ad ]; then \
+ mv ../boot_l2-dd2.ad \
+ ../driver-$(RELEASE)/l2b/; \
+ else \
+ mv ../boot_l2.ad \
+ ../driver-$(RELEASE)/l2b/; fi
mv ../boot_xdr.bin \
../driver-$(RELEASE)/l2b/
cp ../VERSION ../driver-$(RELEASE)
@@ -158,3 +204,10 @@ distclean_gen: clean_top
@for dir in $(COMMON_LIBS); do \
$(MAKE) -C ../lib/$$dir distclean || exit 1; \
done
+
+common-libs:
+ @echo " ====== Building common libraries ======"
+ $(MAKE) -C $(LIBCMNDIR) $(COMMON_LIBS)
+
+board-libs:
+ $(MAKE) -C lib $(MAKEARG)
diff --git a/board-js2x/Makefile b/board-js2x/Makefile
index 7021497..cf17f98 100644
--- a/board-js2x/Makefile
+++ b/board-js2x/Makefile
@@ -10,12 +10,12 @@
# * IBM Corporation - initial implementation
# ****************************************************************************/
-JS2X_TARGETS = tools_build romfs_build stage1
+JS2X_TARGETS = tools_build romfs_build clients_build bcm57xx stage1
SUBDIRS = slof rtas
-COMMON_LIBS = libc libipmi libbootmsg libbases libelf libnvram
+COMMON_LIBS = libc libipmi libbootmsg libbases libnvram libelf
-all: $(JS2X_TARGETS) subdirs clients_build bcm57xx boot_rom_js2x.bin
+all: $(JS2X_TARGETS) subdirs boot_rom.bin
.PHONY : subdirs $(SUBDIRS) clean distclean
@@ -26,49 +26,36 @@ include $(TOPCMNDIR)/Makefile.gen
subdirs: $(SUBDIRS)
-$(SUBDIRS): libraries
- @echo " ====== Building $@ ======"
- $(MAKE) -C $@ $(MAKEARG)
-
-
-libraries:
- $(MAKE) -C $(LIBCMNDIR) $(COMMON_LIBS)
+$(SUBDIRS): common-libs
+ @echo " ====== Building $@ ======"
+ $(MAKE) -C $@ $(MAKEARG)
-stage1:
+stage1: common-libs
+ @echo " ====== Building llfw ======"
make -C llfw RELEASE=-DRELEASE=\"\\\"$(RELEASE)\\\"\"
-boot_rom_js2x.bin: $(JS2X_TARGETS) subdirs clients_build bcm57xx ../build_info.img
- @echo " ====== Building $@ ======"
- cat $(ROMFSBRDDIR)/boot_rom.ffs > ../.boot_rom.ffs
- cat $(SLOFBRDDIR)/OF.ffs >> ../.boot_rom.ffs
- @echo build_info.img build_info.img 0 0 >> ../.boot_rom.ffs
- cd .. && ./romfs/tools/build_romfs .boot_rom.ffs boot_rom.bin
- cd .. && if [ -f boot_rom.bin.gz ]; then rm -f boot_rom.bin.gz; gzip -9 boot_rom.bin; fi
- rm -f ../.boot_rom.ffs
-
bcm57xx:
make -C ../other-licence/bcm
-
clean_here:
rm -f ../slof/OF.ffs
rm -f ../boot_rom.bin
clean: clean_here clean_gen
- make -C ../other-licence/bcm clean
@for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean || exit 1; \
done
rm -f ../boot_rom.bin ../js2*.img
+ make -C ../other-licence/bcm clean
@make -C llfw clean
@make -C $(TOPCMNDIR)/clients/takeover clean
distclean: clean_here distclean_gen
- make -C ../other-licence/bcm clean
@for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir distclean || exit 1; \
done
rm -f ../boot_rom.bin ../js2*.img
+ make -C ../other-licence/bcm clean
make -C llfw clean
make -C $(TOPCMNDIR)/clients/takeover distclean
diff --git a/board-js2x/config b/board-js2x/config
index 9d4ce99..addaf8e 100644
--- a/board-js2x/config
+++ b/board-js2x/config
@@ -1,5 +1,6 @@
BOARD=js2x
TARG=ppc64
+FLAG="-DBIOSEMU"
export CPUARCH=ppc970
export CPUARCHDEF=-DCPU_PPC970
export SNK_BIOSEMU_APPS=1
diff --git a/board-js2x/llfw/Makefile b/board-js2x/llfw/Makefile
index e5c687a..41cdc35 100644
--- a/board-js2x/llfw/Makefile
+++ b/board-js2x/llfw/Makefile
@@ -37,9 +37,6 @@ stageS.bin: stage_s.o
romfs.o: ../../llfw/romfs.S
$(CC) $(CFLAGS) -c ../../llfw/romfs.S
-ipmi_kcs.o: ../rtas/ipmi_kcs.c
- $(CC) $(CFLAGS) -c ../rtas/ipmi_kcs.c
-
boot_abort.o: ../../llfw/boot_abort.S
$(CC) $(CFLAGS) -c ../../llfw/boot_abort.S
@@ -57,12 +54,6 @@ Cboot.o: Cboot.S
$(CC) $(CFLAGS) -c $^
$(OBJCOPY) -O binary Cboot.o Cboot.bin
-$(LIBCMNDIR)/libc.a:
- $(MAKE) -C $(LIBCMNDIR) libc
-
-$(LIBCMNDIR)/libelf.a:
- $(MAKE) -C $(LIBCMNDIR) libelf
-
%.o: %.S
$(CC) $(CFLAGS) -c $^
diff --git a/board-js2x/llfw/u4mem.c b/board-js2x/llfw/u4mem.c
index b7eba4d..c3e6494 100644
--- a/board-js2x/llfw/u4mem.c
+++ b/board-js2x/llfw/u4mem.c
@@ -794,8 +794,7 @@ ddr2_cl2speed( dimm_t *f_dimm, uint32_t f_cl_u32, uint32_t *f_tCK_pu32 )
{
uint32_t i;
- for( i = 0; ( f_dimm->m_clval_pu32[i] != f_cl_u32 ) &&
- ( i < NUM_CL ); i++ );
+ for(i = 0; (i < NUM_CL) && (f_dimm->m_clval_pu32[i] != f_cl_u32); i++);
if( i == NUM_CL ) {
return (uint32_t) ~0;
diff --git a/board-js2x/rtas/rtas_board.c b/board-js2x/rtas/rtas_board.c
index f8b7cca..899589e 100644
--- a/board-js2x/rtas/rtas_board.c
+++ b/board-js2x/rtas/rtas_board.c
@@ -52,7 +52,7 @@ rtas_fetch_slaves(rtas_args_t * pArgs)
while (mask) {
if (mask & 0x1) {
rtas_slave_interface.id = idx | 0x100;
- *(int *) 0x3fc0 = (int) &rtas_slave_interface; // r3
+ *(int *) 0x3fc0 = (int)(unsigned long) &rtas_slave_interface; // r3
*(int *) 0x3f80 = *(uint64_t *) rtas_slave_loop; // addr
*(int *) 0x3fa0 = idx | 0x100; // pid
while (rtas_slave_interface.id);
diff --git a/board-js2x/rtas/rtas_flash.c b/board-js2x/rtas/rtas_flash.c
index 90b9c70..82c1745 100644
--- a/board-js2x/rtas/rtas_flash.c
+++ b/board-js2x/rtas/rtas_flash.c
@@ -26,9 +26,9 @@
#undef DEBUG
#ifdef DEBUG
-#define dprintf(_x...) printf(_x)
+#define dprintf(_x ...) printf(_x)
#else
-#define dprintf(_x...)
+#define dprintf(_x ...)
#endif
static uint64_t size;
@@ -39,13 +39,14 @@ unsigned long check_flash_image(unsigned long rombase, unsigned long length,
unsigned long start_crc);
#ifdef DEBUG
-void
-dump_blocklist(uint64_t * bl, int version)
+static void
+dump_blocklist(uint64_t *bl, int version)
{
uint64_t bl_size;
- uint8_t *addr = (uint8_t *) bl;
+ uint8_t *addr = (uint8_t *)bl;
+
if (version == 1) {
- // version 1 blocklist
+ /* version 1 blocklist */
bl_size = *bl & 0x00FFFFFFFFFFFFFFUL;
} else {
@@ -59,7 +60,7 @@ dump_blocklist(uint64_t * bl, int version)
if (tmpCnt > 8)
tmpCnt = 8;
printf("\n\r%08x: ", addr);
- // print hex
+ /* print hex */
while (tmpCnt--) {
set_ci();
x = *addr++;
@@ -70,15 +71,15 @@ dump_blocklist(uint64_t * bl, int version)
if (tmpCnt > 8)
tmpCnt = 8;
bl_size -= tmpCnt;
- //reset addr ptr to print ascii
+ /* reset addr ptr to print ascii */
addr = addr - tmpCnt;
- // print ascii
+ /* print ascii */
while (tmpCnt--) {
set_ci();
x = *addr++;
clr_ci();
if ((x < 32) || (x >= 127)) {
- //non-printable char
+ /* non-printable char */
x = '.';
}
printf("%c", x);
@@ -89,12 +90,13 @@ dump_blocklist(uint64_t * bl, int version)
#endif
void
-rtas_dump_flash(rtas_args_t * rtas_args)
+rtas_dump_flash(rtas_args_t *rtas_args)
{
int retVal = 0;
unsigned int size = rtas_args->args[0];
unsigned int offset = rtas_args->args[1];
- unsigned char *flash = (unsigned char *) FLASH;
+ volatile unsigned char *flash = (volatile unsigned char *)FLASH;
+
printf("\n\rflash_dump %x %x", size, offset);
flash += offset;
while (size) {
@@ -103,7 +105,7 @@ rtas_dump_flash(rtas_args_t * rtas_args)
if (tmpCnt > 16)
tmpCnt = 16;
printf("\n\r%p: ", flash);
- // print hex
+ /* print hex */
while (tmpCnt--) {
set_ci();
x = *flash++;
@@ -114,15 +116,15 @@ rtas_dump_flash(rtas_args_t * rtas_args)
if (tmpCnt > 16)
tmpCnt = 16;
size -= tmpCnt;
- //reset flash ptr to print ascii
+ /* reset flash ptr to print ascii */
flash = flash - tmpCnt;
- // print ascii
+ /* print ascii */
while (tmpCnt--) {
set_ci();
x = *flash++;
clr_ci();
if ((x < 32) || (x >= 127)) {
- //non-printable char
+ /* non-printable char */
x = '.';
}
printf("%c", x);
@@ -137,6 +139,7 @@ static void
print_block(int i)
{
int counter = 8;
+
while (counter--)
printf("\b");
printf("%08x", i);
@@ -146,10 +149,11 @@ print_block(int i)
/* To enter data mode after flash has been in programming mode
* a 0xFF has to be written */
-void
+static void
enter_data_mode(void)
{
- unsigned char *flash = (unsigned char *) FLASH;
+ volatile unsigned char *flash = (volatile unsigned char *)FLASH;
+
set_ci();
*flash = 0xFF;
eieio();
@@ -160,14 +164,15 @@ enter_data_mode(void)
static void
erase_flash_block(unsigned long offset)
{
- volatile unsigned char *flash = (unsigned char *) FLASH;
+ volatile unsigned char *flash = (volatile unsigned char *)FLASH;
+
flash += offset;
set_ci();
*flash = 0x20;
eieio();
*flash = 0xd0;
eieio();
- while (!(*flash & 0x80));
+ while (!(*flash & 0x80)) ;
clr_ci();
}
@@ -176,11 +181,12 @@ void
write_flash(unsigned long offset, unsigned char *data)
{
int cnt = 32;
- volatile unsigned char *flash = (unsigned char *) FLASH;
+ volatile unsigned char *flash = (volatile unsigned char *)FLASH;
+
flash += (offset + flashOffset);
set_ci();
while (cnt) {
- if (!((uint64_t) flash & 0x1F)) {
+ if (!((uint64_t)flash & 0x1F)) {
while (cnt) {
uint64_t tmpcnt = cnt;
if (tmpcnt > 0x20)
@@ -196,7 +202,7 @@ write_flash(unsigned long offset, unsigned char *data)
}
*flash = 0xD0;
eieio();
- while (!(*flash & 0x80));
+ while (!(*flash & 0x80)) ;
}
break;
}
@@ -204,7 +210,7 @@ write_flash(unsigned long offset, unsigned char *data)
eieio();
*flash++ = *data++;
eieio();
- while (!(*flash & 0x80));
+ while (!(*flash & 0x80)) ;
cnt--;
}
clr_ci();
@@ -214,8 +220,9 @@ void
write_flash_page(unsigned long offset, unsigned short *data)
{
int i = 0;
+
for (i = 0; i < BUFSIZE; i += 32, offset += 32) {
- write_flash(offset, ((unsigned char *) data + i));
+ write_flash(offset, ((unsigned char *)data + i));
}
}
@@ -223,13 +230,14 @@ write_flash_page(unsigned long offset, unsigned short *data)
* 0 reject temporary image
* 1 commit temporary image
* */
-int
+static int
copy_flash(short mode)
{
- unsigned char *flash = (unsigned char *) FLASH;
+ volatile unsigned char *flash = (volatile unsigned char *)FLASH;
uint64_t blockCnt;
- uint64_t hash = 0;
+ uint64_t hash = 0;
short notmode = mode ^ 0x1;
+
if (bmc_set_flashside(notmode) != notmode) {
return -1;
}
@@ -244,8 +252,8 @@ copy_flash(short mode)
print_writing();
for (blockCnt = 0; blockCnt <= FLASHSIZE; blockCnt += BUFSIZE) {
- uint64_t *srcPtr = (uint64_t *) (flash + blockCnt);
- uint64_t *destPtr = (uint64_t *)((void*) manage_flash_buffer);
+ uint64_t *srcPtr = (uint64_t *)(flash + blockCnt);
+ uint64_t *destPtr = (uint64_t *)((void*)manage_flash_buffer);
uint64_t cnt = BUFSIZE / 8;
if (bmc_set_flashside(mode) != mode) {
return -1;
@@ -261,14 +269,14 @@ copy_flash(short mode)
return -1;
}
write_flash_page(blockCnt,
- (unsigned short *) manage_flash_buffer);
-
- //progress output...
- print_progress();
- if (blockCnt > hash * progress) {
- print_hash();
- hash++;
- }
+ (unsigned short *)manage_flash_buffer);
+
+ /* progress output... */
+ print_progress();
+ if (blockCnt > hash * progress) {
+ print_hash();
+ hash++;
+ }
}
enter_data_mode();
if (bmc_set_flashside(mode) != mode) {
@@ -279,26 +287,27 @@ copy_flash(short mode)
}
/*
-Function: ibm_manage_flash_image
- Input:
- r3: rtas parm structure
- token: 46
- in: 1
- out: 1
- parm0: 0 reject temporary image
- 1 commit temporary image
- Output:
- parm1: Status (hw -1, busy -2, parameter error -3
- -9001 cannot overwrite the active firmware image)
-
-*/
+ * Function: ibm_manage_flash_image
+ * Input:
+ * r3: rtas parm structure
+ * token: 46
+ * in: 1
+ * out: 1
+ * parm0: 0 reject temporary image
+ * 1 commit temporary image
+ * Output:
+ * parm1: Status (hw -1, busy -2, parameter error -3
+ * -9001 cannot overwrite the active firmware image)
+ *
+ */
void
-rtas_ibm_manage_flash_image(rtas_args_t * rtas_args)
+rtas_ibm_manage_flash_image(rtas_args_t *rtas_args)
{
int side;
int result = 0;
short mode = rtas_args->args[0];
+
if (mode < 0 || mode > 1) {
rtas_args->args[rtas_args->nargs] = -3;
return;
@@ -325,32 +334,31 @@ rtas_ibm_manage_flash_image(rtas_args_t * rtas_args)
bmc_set_flashside(mode);
enter_data_mode();
rtas_args->args[rtas_args->nargs] = 0;
- return;
}
/**
-* check, if we find the FLASHFS_MAGIC token in bl
-**/
+ * check, if we find the FLASHFS_MAGIC token in bl
+ **/
static uint8_t
-check_magic(uint64_t * bl, int version)
+check_magic(uint64_t *bl, int version)
{
struct stH *pHeader;
if (version == 1) {
- // version 1 blocklist
- // if block list size <= 0x10, it is only block list header
- // and address of block list extension, so look at the extension...
+ /* version 1 blocklist */
+ /* if block list size <= 0x10, it is only block list header */
+ /* and address of block list extension, so look at the extension... */
while ((*bl & 0x00FFFFFFFFFFFFFFUL) <= 0x10)
- bl = (uint64_t *) bl[1];
+ bl = (uint64_t *)bl[1];
- //block list item 2 _should_ be the address of our flashfs image
- pHeader = (struct stH *) (bl[2] + 0x28);
- //printf("FlashFS Magic: \"%#s\"\r\n", pHeader->magic);
+ /* block list item 2 _should_ be the address of our flashfs image */
+ pHeader = (struct stH *)(bl[2] + 0x28);
+ /* printf("FlashFS Magic: \"%#s\"\r\n", pHeader->magic); */
return strncmp(pHeader->magic, FLASHFS_MAGIC, 8);
} else {
- //block list item 1 _should_ be the address of our flashfs image
- pHeader = (struct stH *) (bl[1] + 0x28);
- //printf("FlashFS Magic: \"%#s\"\r\n", pHeader->magic);
+ /* block list item 1 _should_ be the address of our flashfs image */
+ pHeader = (struct stH *)(bl[1] + 0x28);
+ /* printf("FlashFS Magic: \"%#s\"\r\n", pHeader->magic); */
return strncmp(pHeader->magic, FLASHFS_MAGIC, 8);
}
}
@@ -358,27 +366,26 @@ check_magic(uint64_t * bl, int version)
static void
get_image_name(char *buffer, int maxsize)
{
- struct stH *flash_header = (struct stH *) (SB_FLASH_adr + 0x28);
- //since we cannot read the fh_magic directly from flash as a string, we need to copy it to memory
+ volatile struct stH *flash_header = (volatile struct stH *)(SB_FLASH_adr + 0x28);
+ /* since we cannot read the fh_magic directly from flash as a string, we need to copy it to memory */
uint64_t magic_val = 0;
uint64_t addr;
- //copy fh_magic to magic_val since, we cannot use it as a string from flash
- magic_val = load64_ci((uint64_t) (flash_header->magic));
- if (strncmp((char *) &magic_val, FLASHFS_MAGIC, 8)) {
+ /* copy fh_magic to magic_val since, we cannot use it as a string from flash */
+ magic_val = load64_ci((uint64_t)(flash_header->magic));
+ if (strncmp((char *)&magic_val, FLASHFS_MAGIC, 8)) {
/* magic does not match */
sprintf(buffer, "Unknown");
buffer[maxsize - 1] = '\0';
return;
}
- addr = (uint64_t) flash_header->version;
+ addr = (uint64_t)flash_header->version;
while (--maxsize) {
*buffer = load8_ci(addr++);
if (!*buffer++)
return;
}
*buffer = '\0';
-
}
/**
@@ -391,16 +398,15 @@ get_image_name(char *buffer, int maxsize)
* -1 hw
* -2 busy
* -3 parameter error
- * -9002 not authorized
* @param args[3] - update result token
*/
void
-rtas_ibm_validate_flash_image(rtas_args_t * rtas_args)
+rtas_ibm_validate_flash_image(rtas_args_t *rtas_args)
{
dprintf("\nrtas_ibm_validate_flash_image\n");
unsigned long new_image = rtas_args->args[0];
- char *ret_str = (char *) new_image;
- struct stH *flash_header = (struct stH *) (new_image + 0x28);
+ char *ret_str = (char *)new_image;
+ struct stH *flash_header = (struct stH *)(new_image + 0x28);
char current_temp_version[16];
char current_perm_version[16];
char new_version[16];
@@ -414,19 +420,6 @@ rtas_ibm_validate_flash_image(rtas_args_t * rtas_args)
bmc_set_flashside(1);
get_image_name(current_temp_version, sizeof(current_temp_version));
bmc_set_flashside(side);
- /* first check if we are running on P
- * we do not flash on the permanent side */
- if (side == 0) {
- /* not authorized */
- rtas_args->args[rtas_args->nargs] = -9002;
- /* No update done, partition does not have
- * authority to perform flash update */
- rtas_args->args[rtas_args->nargs + 1] = 1;
- sprintf(ret_str, "MI %s %s\xaMI %s %s",
- current_temp_version, current_perm_version,
- current_temp_version, current_perm_version);
- return;
- }
/* check if the candidate image if valid for this platform */
if (strncmp(flash_header->magic, FLASHFS_MAGIC, 8)) {
@@ -441,7 +434,7 @@ rtas_ibm_validate_flash_image(rtas_args_t * rtas_args)
return;
}
- if (strncmp(flash_header->platform_name, (char *) sig_org, 32)) {
+ if (strncmp(flash_header->platform_name, (char *)sig_org, 32)) {
/* this image if for a different board */
rtas_args->args[rtas_args->nargs] = 0;
/* No update done, the candidate image is
@@ -466,90 +459,86 @@ rtas_ibm_validate_flash_image(rtas_args_t * rtas_args)
return;
}
memcpy(new_version, flash_header->version, 16);
- sprintf(ret_str, "MI %s %s\xaMI %s %s",
- current_temp_version, current_perm_version,
- side ? new_version : current_temp_version,
- side ? current_perm_version : new_version);
+ sprintf(ret_str, "MI %s %s\xaMI %s %s", current_temp_version,
+ current_perm_version, new_version, current_perm_version);
rtas_args->args[rtas_args->nargs] = 0;
- if (strncmp
- (new_version, side ? current_temp_version : current_perm_version,
- 16) >= 0) {
+
+ if (strncmp(new_version, current_temp_version, 16) >= 0)
rtas_args->args[rtas_args->nargs + 1] = 0;
- } else {
+ else
rtas_args->args[rtas_args->nargs + 1] = 6;
- }
- return;
}
/*
-Function: ibm_update_flash_64
- Input:
- r3: rtas parm structure
- token: 7
- in: 1
- out: 1
- parm0: A real pointer to a block list
- Output:
- parm1: Status (hw -1, bad image -3, programming failed -4)
-
-Decription: flash if addresses above 4GB have to be addressed
-*/
+ * Function: ibm_update_flash_64
+ * Input:
+ * r3: rtas parm structure
+ * token: 7
+ * in: 1
+ * out: 1
+ * parm0: A real pointer to a block list
+ * Output:
+ * parm1: Status (hw -1, bad image -3, programming failed -4)
+ *
+ * Description: flash if addresses above 4GB have to be addressed
+ */
void
-rtas_update_flash(rtas_args_t * rtas_args)
+rtas_update_flash(rtas_args_t *rtas_args)
{
- void *bl = (void *) (uint64_t) rtas_args->args[0];
- int version = get_block_list_version((unsigned char *) bl);
+ void *bl = (void *)(uint64_t)rtas_args->args[0];
+ int version = get_block_list_version((unsigned char *)bl);
uint64_t erase_size;
- uint64_t i;
+ unsigned int i;
+ int perm_check = 1;
#ifdef DEBUG
dump_blocklist(bl, version);
#endif
- // from SLOF we pass a second (unofficial) parameter, if this parameter is 1, we do not
- // check wether we are on permanent side. Needed for update-flash -c to work!
- uint8_t perm_check = 1;
- if ((rtas_args->nargs > 1) && (rtas_args->args[1] == 1)) {
- perm_check = 0;
- }
-
- //first check if we are running on P
- //we do not flash on the permanent side
- if (perm_check && (bmc_get_flashside() == 0)) {
- rtas_args->args[rtas_args->nargs] = -9002; //not authorized
- return;
- }
- //check magic string
+ /* from SLOF we pass a second (unofficial) parameter, if this parameter is 1, we do not
+ * check wether we are on permanent side. Needed for update-flash -c to work! */
+ if ((rtas_args->nargs > 1) && (rtas_args->args[1] == 1))
+ perm_check = 0;
+
+ /* check magic string */
printf("\r\nChecking magic string : ");
if (check_magic(bl, version) != 0) {
printf("failed!\n");
- rtas_args->args[rtas_args->nargs] = -3; //bad image
+ rtas_args->args[rtas_args->nargs] = -3; /* bad image */
return;
}
printf("succeeded!\n");
- //check platform
+ /* check platform */
printf("Checking platform : ");
if (check_platform(bl, 0x48, version) == -1) {
printf("failed!\n");
- rtas_args->args[rtas_args->nargs] = -3; //bad image
+ rtas_args->args[rtas_args->nargs] = -3; /* bad image */
return;
}
printf("succeeded!\n");
- //checkcrc
+ /* checkcrc */
printf("Checking CRC : ");
- // the actual CRC is included at the end of the flash image, thus the resulting CRC must be 0!
+ /* the actual CRC is included at the end of the flash image, thus the resulting CRC must be 0! */
if (image_check_crc(bl, version) != 0) {
printf("failed!\n");
- rtas_args->args[1] = -3; //bad image
+ rtas_args->args[1] = -3; /* bad image */
return;
}
printf("succeeded!\n");
+ /* check if we are running on P
+ * if so, let's switch to temp and flash temp */
+ if (bmc_get_flashside() == 0 && perm_check) {
+ printf("Set flashside: ");
+ bmc_set_flashside(1);
+ printf("Temp!\n");
+ }
+
#ifdef DEBUG
rtas_args_t ra;
- ra.args[0] = 0x100; //size;
+ ra.args[0] = 0x100; /* size; */
ra.args[1] = flashOffset;
ra.nargs = 2;
@@ -584,45 +573,42 @@ rtas_update_flash(rtas_args_t * rtas_args)
printf("\n");
#endif
- //checkcrc
+ /* checkcrc */
printf("Recheck CRC : ");
if (check_flash_image(FLASH + flashOffset, size, 0) != 0) {
- //failed
+ /* failed */
printf("failed!\n\r");
dprintf("flash_addr: %#x, flashOffset: %#x, size: %#x\n", FLASH,
flashOffset, size);
dprintf("crc: %#x\n",
check_flash_image(FLASH + flashOffset, size, 0));
- rtas_args->args[rtas_args->nargs] = -4; //programming failed
+ rtas_args->args[rtas_args->nargs] = -4; /* programming failed */
return;
}
printf("succeeded!\n");
rtas_args->args[rtas_args->nargs] = 0;
-
- return;
}
/*
-Function: ibm_update_flash_64_and_reboot
- Input:
- r3: rtas parm structure
- token: 27
- in: 1
- out: 1
- parm0: A real pointer to a block list
- Output:
- parm1: Status (hw -1, bad image -3, programming failed -4)
- Currently -4 and -1 are not returned
-
-Decription: flash and reboot if addresses above 4GB have to be addressed
-*/
+ * Function: ibm_update_flash_64_and_reboot
+ * Input:
+ * r3: rtas parm structure
+ * token: 27
+ * in: 1
+ * out: 1
+ * parm0: A real pointer to a block list
+ * Output:
+ * parm1: Status (hw -1, bad image -3, programming failed -4)
+ * Currently -4 and -1 are not returned
+ *
+ * Description: flash and reboot if addresses above 4GB have to be addressed
+ */
void
-rtas_ibm_update_flash_64_and_reboot(rtas_args_t * rtas_args)
+rtas_ibm_update_flash_64_and_reboot(rtas_args_t *rtas_args)
{
rtas_update_flash(rtas_args);
dprintf("rc: %#d\n", rtas_args->args[rtas_args->nargs]);
if (rtas_args->args[rtas_args->nargs] == 0) {
rtas_system_reboot(rtas_args);
}
- return;
}
diff --git a/board-js2x/slof/OF.fs b/board-js2x/slof/OF.fs
index 0b8a31f..908b268 100644
--- a/board-js2x/slof/OF.fs
+++ b/board-js2x/slof/OF.fs
@@ -14,6 +14,8 @@
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
@@ -122,6 +124,9 @@ cistack ciregs >r1 ! \ kernel wants a stack :-)
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
@@ -287,7 +292,16 @@ create vpd-bootlist 4 allot
s" Flashside = " type rtas-get-flashside 0= IF
." 0 (permanent)"
ELSE
- ." 1 (temporary)" THEN cr cr
+ ." 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
@@ -335,7 +349,7 @@ check-for-nvramrc
100000 value biosemu-vmem-size
0 value screen-info
-vga-device-node? 0<> IF
+vga-device-node? 0<> use-biosemu? AND IF
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
@@ -352,7 +366,12 @@ vga-device-node? 0<> IF
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 ) bios-exec
+ 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
+ bios-exec
\ s" Time after biosemu:" type .date cr
s" VGA initialization: detecting displays..." type cr
\ try to get info for two monitors
@@ -401,21 +420,36 @@ vga-device-node? 0<> IF
s" VGA initialization done." type cr
THEN \ vga-device-node?
+: 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
+ 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
-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 ( -- )
+ 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
@@ -433,23 +467,21 @@ 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
+ 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
+ ." 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
- \ if key-available? method is found, defer it to key?
-
- ." keyboard detected and set as default output device" cr
- ." Press and hold 's' to enter Open Firmware." cr
- 1000 ms \ wait, in case user wants to press 's'
+ ." 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
diff --git a/board-js2x/slof/helper.fs b/board-js2x/slof/helper.fs
index 9da396c..34d60da 100644
--- a/board-js2x/slof/helper.fs
+++ b/board-js2x/slof/helper.fs
@@ -15,3 +15,14 @@
;
: 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/board-js2x/slof/ipmi-vpd.fs b/board-js2x/slof/ipmi-vpd.fs
index a69722d..bfb3e50 100644
--- a/board-js2x/slof/ipmi-vpd.fs
+++ b/board-js2x/slof/ipmi-vpd.fs
@@ -91,7 +91,7 @@
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 + zplace drop 1 THEN
+ IF slof-build-id vpd-cb 4 + rzplace drop 1 THEN
1 = IF 406 24 vpd-cb rtas-write-vpd drop THEN
;
diff --git a/board-js2x/slof/pci-bridge_1022_7460.fs b/board-js2x/slof/pci-bridge_1022_7460.fs
index d8f0c0e..c28e0d2 100644
--- a/board-js2x/slof/pci-bridge_1022_7460.fs
+++ b/board-js2x/slof/pci-bridge_1022_7460.fs
@@ -85,14 +85,19 @@ INCLUDE freq.fs
\ yeah, hardcoded!
f2000000 to puid
- \ the PCI scan would assign b8302000 to that device
+ \ the PCI scan would assign pci-next-mmio to that device
\ let's just take that address
- b8302000 70210 rtas-config-l!
+ 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
- 70204 dup rtas-config-l@ 2 or swap rtas-config-l!
+ pci-bus-number 10 lshift 204 or dup rtas-config-l@ 2 or swap rtas-config-l!
- b8302000 ( base )
+ pci-next-mmio @ 100000 #aligned ( base )
\ Sequence prescribed for resetting the EHCI contoller
@@ -102,7 +107,7 @@ INCLUDE freq.fs
dup 30 + rl@ 1 and 1 = IF
dup 30 + rl@ 1 or
- dup 30 + rl!
+ over 30 + rl!
2 ms
THEN
@@ -123,7 +128,7 @@ INCLUDE freq.fs
\ now it is really disabled
\ disable memory space access again
- 2100000 70204 rtas-config-l!
+ 2100000 pci-bus-number 10 lshift 204 or rtas-config-l!
80 847 config-b! \ Disable EHCI, as it is terminally broken.
;
diff --git a/board-js2x/slof/pci-class_03.fs b/board-js2x/slof/pci-class_03.fs
index f95e502..05c8eb6 100644
--- a/board-js2x/slof/pci-class_03.fs
+++ b/board-js2x/slof/pci-class_03.fs
@@ -44,8 +44,12 @@ my-space a1000000 or encode-int+ \ non-relocatable, aliased I/O space
s" reg" property \ store "reg" property
-\ remember this vga device's phandle
-get-node to vga-device-node?
+\ 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/board-js2x/slof/rtas.fs b/board-js2x/slof/rtas.fs
index 6a0672c..616184f 100644
--- a/board-js2x/slof/rtas.fs
+++ b/board-js2x/slof/rtas.fs
@@ -21,6 +21,9 @@
' (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
diff --git a/board-js2x/slof/tree.fs b/board-js2x/slof/tree.fs
index 6b3150c..fe43955 100644
--- a/board-js2x/slof/tree.fs
+++ b/board-js2x/slof/tree.fs
@@ -198,8 +198,17 @@ device-end
\ See 3.5.
s" /openprom" find-device
- s" SLOF," slof-build-id $cat encode-string s" model" property
+ 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
diff --git a/clients/net-snk/app/biosemu/biosemu.c b/clients/net-snk/app/biosemu/biosemu.c
index 428f8d4..8d36de6 100644
--- a/clients/net-snk/app/biosemu/biosemu.c
+++ b/clients/net-snk/app/biosemu/biosemu.c
@@ -53,10 +53,10 @@ biosemu(char argc, char **argv)
uint8_t *biosmem;
uint32_t biosmem_size;
#ifdef DEBUG
- debug_flags = DEBUG_PRINT_INT10 | DEBUG_PNP;// | DEBUG_PMM;// | DEBUG_INTR | DEBUG_CHECK_VMEM_ACCESS | DEBUG_MEM | DEBUG_IO;// | DEBUG_TRACE_X86EMU | DEBUG_JMP;
+ //debug_flags = DEBUG_PRINT_INT10 | DEBUG_PNP;// | DEBUG_PMM;// | DEBUG_INTR | DEBUG_CHECK_VMEM_ACCESS | DEBUG_MEM | DEBUG_IO;// | DEBUG_TRACE_X86EMU | DEBUG_JMP;
#endif
- if (argc < 3) {
- printf("Usage %s <vmem_base> <device_path>\n", argv[0]);
+ if (argc < 4) {
+ printf("Usage %s <vmem_base> <vmem_size> <device_path> [<debug_flags>]\n", argv[0]);
for (i = 0; i < argc; i++) {
printf("argv[%d]: %s\n", i, argv[i]);
}
@@ -80,6 +80,11 @@ biosemu(char argc, char **argv)
printf("Error: Device Expansion ROM invalid!\n");
return -1;
}
+ // argv[4] if set, is additional debug_flags
+ if (argc >= 5) {
+ debug_flags |= strtoul(argv[4], 0, 16);
+ printf("debug_flags: %x\n", debug_flags);
+ }
rom_image = (uint8_t *) bios_device.img_addr;
DEBUG_PRINTF("executing rom_image from %p\n", rom_image);
DEBUG_PRINTF("biosmem at %p\n", biosmem);
diff --git a/clients/net-snk/app/biosemu/io.c b/clients/net-snk/app/biosemu/io.c
index 53653d3..0e46166 100644
--- a/clients/net-snk/app/biosemu/io.c
+++ b/clients/net-snk/app/biosemu/io.c
@@ -184,7 +184,7 @@ my_inl(X86EMU_pioAddr addr)
addr);
//DEBUG_PRINTF_IO("%s(%04x): translated_addr: %llx\n", __FUNCTION__, addr, translated_addr);
uint32_t rval;
- if ((translated_addr & (uint64_t) 0x2) == 0) {
+ if ((translated_addr & (uint64_t) 0x3) == 0) {
// 32 bit aligned access...
uint32_t tempval = read_io((void *) translated_addr, 4);
//little endian conversion
diff --git a/clients/net-snk/app/biosemu/mem.c b/clients/net-snk/app/biosemu/mem.c
index d9ad46d..b214a96 100644
--- a/clients/net-snk/app/biosemu/mem.c
+++ b/clients/net-snk/app/biosemu/mem.c
@@ -275,7 +275,7 @@ my_rdl(uint32_t addr)
(((uint8_t) my_rdb(addr + 2)) << 16) |
(((uint8_t) my_rdb(addr + 3)) << 24);
} else {
- if ((translated_addr & (uint64_t) 0x2) == 0) {
+ if ((translated_addr & (uint64_t) 0x3) == 0) {
// 32 bit aligned access...
set_ci();
rval = in32le((void *) translated_addr);
diff --git a/clients/net-snk/kernel/init.c b/clients/net-snk/kernel/init.c
index 8485f23..e88b4eb 100644
--- a/clients/net-snk/kernel/init.c
+++ b/clients/net-snk/kernel/init.c
@@ -118,8 +118,8 @@ _start_kernel(unsigned long p0, unsigned long p1)
}
/* this is step is e.g. resposible to initialize file descriptor 0 and 1 for STDIO */
- rc = glue_init(&snk_kernel_interface, &timebase, (size_t)&__client_start,
- (size_t)&__client_end - (size_t)&__client_start);
+ rc = glue_init(&snk_kernel_interface, &timebase, (size_t)(unsigned long)&__client_start,
+ (size_t)(unsigned long)&__client_end - (size_t)(unsigned long)&__client_start);
if(rc < 0)
return -1;
diff --git a/clients/takeover/Makefile b/clients/takeover/Makefile
index a700d32..f492234 100644
--- a/clients/takeover/Makefile
+++ b/clients/takeover/Makefile
@@ -31,9 +31,9 @@ all: takeover.elf
takeover.elf: ppc32wrap.o takeover.elf32
@echo " ====== Building $@ ======"
- $(CROSS)gcc -m32 -N -Wl,-melf32ppclinux -static -nostdlib \
- -Wl,-Ttext,0x400000 -Wl,-Tdata,0x400100 \
- $(CFLAGS) $^ -o $@
+ $(LD) -N -melf32ppclinux -static -nostdlib \
+ -Ttext=0x400000 -Tdata=0x400100 \
+ $(LDFLAGS) $^ -o $@
takeover.elf64: entry.o main.o takeover.o $(SNKDIR)/libc/time/timer.o of.elf
make -C $(LIBCMNDIR) libc
diff --git a/clients/takeover/main.c b/clients/takeover/main.c
index b785f8e..c79ea72 100644
--- a/clients/takeover/main.c
+++ b/clients/takeover/main.c
@@ -169,9 +169,9 @@ main(int argc, char *argv[])
cpu, reg);
slaveQuitt = -1;
if (takeoverFlag)
- startCpu(cpu, (int) slaveLoop, index);
+ startCpu(cpu, (int)(unsigned long)slaveLoop, index);
else
- startCpu(cpu, (int) slaveLoopNoTakeover,
+ startCpu(cpu, (int)(unsigned long)slaveLoopNoTakeover,
index);
slaveMask |= 0x1 << index;
delay = 100;
diff --git a/include/ppc970/cpu.h b/include/ppc970/cpu.h
index 772767d..f42fd48 100644
--- a/include/ppc970/cpu.h
+++ b/include/ppc970/cpu.h
@@ -36,7 +36,8 @@
sync; \
slbia; \
mtspr HID4, r; \
- isync;
+ isync; \
+ eieio;
#define CLRCI(r) sync; \
mfspr r, HID4; \
@@ -48,7 +49,8 @@
sync; \
slbia; \
mtspr HID4, r; \
- isync;
+ isync; \
+ eieio;
/* This macro uses r0 */
#define FLUSH_CACHE(r, n) add n, n, r; \
diff --git a/other-licence/x86emu/include/x86emu/debug.h b/other-licence/x86emu/include/x86emu/debug.h
index 1f172b1..ad39b9f 100644
--- a/other-licence/x86emu/include/x86emu/debug.h
+++ b/other-licence/x86emu/include/x86emu/debug.h
@@ -171,11 +171,11 @@
x86emu_dump_regs(); \
if (DEBUG_TRACECALL()) \
printk("%04x:%04x: CALL %s%04x:%04x\n", u , v, s, w, x);
-# define RETURN_TRACE(n,u,v) \
+# define RETURN_TRACE(u,v,w,x,s) \
if (DEBUG_TRACECALLREGS()) \
x86emu_dump_regs(); \
if (DEBUG_TRACECALL()) \
- printk("%04x:%04x: %s\n",u,v,n);
+ printk("%04x:%04x: RET %s %04x:%04x\n",u,v,s,w,x);
# define JMP_TRACE(u,v,w,x,s) \
if (DEBUG_TRACEJMPREGS()) \
x86emu_dump_regs(); \
@@ -183,7 +183,7 @@
printk("%04x:%04x: JMP %s%04x:%04x\n", u , v, s, w, x);
#else
# define CALL_TRACE(u,v,w,x,s)
-# define RETURN_TRACE(n,u,v)
+# define RETURN_TRACE(u,v,w,x,s)
# define JMP_TRACE(u,v,w,x,s)
#endif
diff --git a/other-licence/x86emu/ops.c b/other-licence/x86emu/ops.c
index 00376d8..772bcbb 100644
--- a/other-licence/x86emu/ops.c
+++ b/other-licence/x86emu/ops.c
@@ -1061,7 +1061,11 @@ void x86emuOp_push_byte_IMM(u8 X86EMU_UNUSED(op1))
imm = (s8)fetch_byte_imm();
DECODE_PRINTF2("PUSH\t%d\n", imm);
TRACE_AND_STEP();
- push_word(imm);
+ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
+ push_long(imm);
+ } else {
+ push_word(imm);
+ }
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
@@ -1256,8 +1260,10 @@ void x86emuOp_jump_near_cond(u8 op1)
target = (u16)(M.x86.R_IP + (s16)offset);
DECODE_PRINTF2("%x\n", target);
TRACE_AND_STEP();
- if (cond)
+ if (cond) {
M.x86.R_IP = target;
+ JMP_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, " NEAR COND ");
+ }
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
@@ -3294,9 +3300,9 @@ void x86emuOp_ret_near_IMM(u8 X86EMU_UNUSED(op1))
DECODE_PRINTF("RET\t");
imm = fetch_word_imm();
DECODE_PRINTF2("%x\n", imm);
- RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip);
TRACE_AND_STEP();
M.x86.R_IP = pop_word();
+ RETURN_TRACE(M.x86.saved_cs,M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, "NEAR");
M.x86.R_SP += imm;
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
@@ -3310,9 +3316,9 @@ void x86emuOp_ret_near(u8 X86EMU_UNUSED(op1))
{
START_OF_INSTR();
DECODE_PRINTF("RET\n");
- RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip);
TRACE_AND_STEP();
M.x86.R_IP = pop_word();
+ RETURN_TRACE(M.x86.saved_cs,M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, "NEAR");
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
@@ -3527,10 +3533,10 @@ void x86emuOp_ret_far_IMM(u8 X86EMU_UNUSED(op1))
DECODE_PRINTF("RETF\t");
imm = fetch_word_imm();
DECODE_PRINTF2("%x\n", imm);
- RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip);
TRACE_AND_STEP();
M.x86.R_IP = pop_word();
M.x86.R_CS = pop_word();
+ RETURN_TRACE(M.x86.saved_cs,M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, "FAR");
M.x86.R_SP += imm;
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
@@ -3544,10 +3550,10 @@ void x86emuOp_ret_far(u8 X86EMU_UNUSED(op1))
{
START_OF_INSTR();
DECODE_PRINTF("RETF\n");
- RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip);
TRACE_AND_STEP();
M.x86.R_IP = pop_word();
M.x86.R_CS = pop_word();
+ RETURN_TRACE(M.x86.saved_cs,M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, "FAR");
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
@@ -4150,8 +4156,10 @@ void x86emuOp_jcxz(u8 X86EMU_UNUSED(op1))
target = (u16)(M.x86.R_IP + offset);
DECODE_PRINTF2("%x\n", target);
TRACE_AND_STEP();
- if (M.x86.R_CX == 0)
+ if (M.x86.R_CX == 0) {
M.x86.R_IP = target;
+ JMP_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, " CXZ ");
+ }
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
diff --git a/other-licence/x86emu/ops2.c b/other-licence/x86emu/ops2.c
index 448d968..53a7776 100644
--- a/other-licence/x86emu/ops2.c
+++ b/other-licence/x86emu/ops2.c
@@ -149,8 +149,69 @@ void x86emuOp2_long_jump(u8 op2)
target += (s16) M.x86.R_IP;
DECODE_PRINTF2("%04x\n", target);
TRACE_AND_STEP();
- if (cond)
+ if (cond) {
M.x86.R_IP = (u16)target;
+ JMP_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, " LONG COND ");
+ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+}
+
+/****************************************************************************
+REMARKS:
+Handles opcode 0x0f,0xC8-0xCF
+****************************************************************************/
+s32 x86emu_bswap(s32 reg)
+{
+ // perform the byte swap
+ s32 temp = reg;
+ reg = (temp & 0xFF000000) >> 24;
+ reg |= (temp & 0xFF0000) >> 8;
+ reg |= (temp & 0xFF00) << 8;
+ reg |= (temp & 0xFF) << 24;
+ return reg;
+}
+
+void x86emuOp2_bswap(u8 op2)
+{
+ /* byte swap 32 bit register */
+ START_OF_INSTR();
+ DECODE_PRINTF("BSWAP\t");
+ switch (op2) {
+ case 0xc8:
+ DECODE_PRINTF("EAX\n");
+ M.x86.R_EAX = x86emu_bswap(M.x86.R_EAX);
+ break;
+ case 0xc9:
+ DECODE_PRINTF("ECX\n");
+ M.x86.R_ECX = x86emu_bswap(M.x86.R_ECX);
+ break;
+ case 0xca:
+ DECODE_PRINTF("EDX\n");
+ M.x86.R_EDX = x86emu_bswap(M.x86.R_EDX);
+ break;
+ case 0xcb:
+ DECODE_PRINTF("EBX\n");
+ M.x86.R_EBX = x86emu_bswap(M.x86.R_EBX);
+ break;
+ case 0xcc:
+ DECODE_PRINTF("ESP\n");
+ M.x86.R_ESP = x86emu_bswap(M.x86.R_ESP);
+ break;
+ case 0xcd:
+ DECODE_PRINTF("EBP\n");
+ M.x86.R_EBP = x86emu_bswap(M.x86.R_EBP);
+ break;
+ case 0xce:
+ DECODE_PRINTF("ESI\n");
+ M.x86.R_ESI = x86emu_bswap(M.x86.R_ESI);
+ break;
+ case 0xcf:
+ DECODE_PRINTF("EDI\n");
+ M.x86.R_EDI = x86emu_bswap(M.x86.R_EDI);
+ break;
+ }
+ TRACE_AND_STEP();
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
@@ -1702,14 +1763,14 @@ void (*x86emu_optab2[256])(u8) =
/* 0xc5 */ x86emuOp2_illegal_op,
/* 0xc6 */ x86emuOp2_illegal_op,
/* 0xc7 */ x86emuOp2_illegal_op,
-/* 0xc8 */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xc9 */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xca */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xcb */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xcc */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xcd */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xce */ x86emuOp2_illegal_op, /* TODO: bswap */
-/* 0xcf */ x86emuOp2_illegal_op, /* TODO: bswap */
+/* 0xc8 */ x86emuOp2_bswap,
+/* 0xc9 */ x86emuOp2_bswap,
+/* 0xca */ x86emuOp2_bswap,
+/* 0xcb */ x86emuOp2_bswap,
+/* 0xcc */ x86emuOp2_bswap,
+/* 0xcd */ x86emuOp2_bswap,
+/* 0xce */ x86emuOp2_bswap,
+/* 0xcf */ x86emuOp2_bswap,
/* 0xd0 */ x86emuOp2_illegal_op,
/* 0xd1 */ x86emuOp2_illegal_op,
diff --git a/other-licence/x86emu/prim_ops.c b/other-licence/x86emu/prim_ops.c
index a796e70..a4a46a2 100644
--- a/other-licence/x86emu/prim_ops.c
+++ b/other-licence/x86emu/prim_ops.c
@@ -1921,7 +1921,7 @@ Implements the IMUL instruction and side effects.
void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s)
{
#ifdef __HAS_LONG_LONG__
- s64 res = (s64)d * (s64)s;
+ s64 res = (s64)(s32)d * (s64)(s32)s;
*res_lo = (u32)res;
*res_hi = (u32)(res >> 32);
@@ -2013,7 +2013,7 @@ Implements the MUL instruction and side effects.
void mul_long(u32 s)
{
#ifdef __HAS_LONG_LONG__
- u64 res = (u32)M.x86.R_EAX * (u32)s;
+ u64 res = (u64)M.x86.R_EAX * s;
M.x86.R_EAX = (u32)res;
M.x86.R_EDX = (u32)(res >> 32);
diff --git a/other-licence/x86emu/x86emu_changes.diff b/other-licence/x86emu/x86emu_changes.diff
index 9f03d63..aa1a359 100644
--- a/other-licence/x86emu/x86emu_changes.diff
+++ b/other-licence/x86emu/x86emu_changes.diff
@@ -28,15 +28,141 @@ diff -u -u -r1.1 -r1.3
}
static void print_decoded_instruction (void)
-Index: ops.c
+Index: ops2.c
===================================================================
-RCS file: /cvs/osdf/cvs/host/other-licence/x86emu/ops.c,v
+RCS file: /cvs/osdf/cvs/host/other-licence/x86emu/ops2.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -u -r1.1 -r1.3
+--- ops2.c 7 Sep 2007 10:01:21 -0000 1.1
++++ ops2.c 20 Mar 2008 15:48:34 -0000 1.3
+@@ -149,8 +149,69 @@
+ target += (s16) M.x86.R_IP;
+ DECODE_PRINTF2("%04x\n", target);
+ TRACE_AND_STEP();
+- if (cond)
++ if (cond) {
+ M.x86.R_IP = (u16)target;
++ JMP_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, " LONG COND ");
++ }
++ DECODE_CLEAR_SEGOVR();
++ END_OF_INSTR();
++}
++
++/****************************************************************************
++REMARKS:
++Handles opcode 0x0f,0xC8-0xCF
++****************************************************************************/
++s32 x86emu_bswap(s32 reg)
++{
++ // perform the byte swap
++ s32 temp = reg;
++ reg = (temp & 0xFF000000) >> 24;
++ reg |= (temp & 0xFF0000) >> 8;
++ reg |= (temp & 0xFF00) << 8;
++ reg |= (temp & 0xFF) << 24;
++ return reg;
++}
++
++void x86emuOp2_bswap(u8 op2)
++{
++ /* byte swap 32 bit register */
++ START_OF_INSTR();
++ DECODE_PRINTF("BSWAP\t");
++ switch (op2) {
++ case 0xc8:
++ DECODE_PRINTF("EAX\n");
++ M.x86.R_EAX = x86emu_bswap(M.x86.R_EAX);
++ break;
++ case 0xc9:
++ DECODE_PRINTF("ECX\n");
++ M.x86.R_ECX = x86emu_bswap(M.x86.R_ECX);
++ break;
++ case 0xca:
++ DECODE_PRINTF("EDX\n");
++ M.x86.R_EDX = x86emu_bswap(M.x86.R_EDX);
++ break;
++ case 0xcb:
++ DECODE_PRINTF("EBX\n");
++ M.x86.R_EBX = x86emu_bswap(M.x86.R_EBX);
++ break;
++ case 0xcc:
++ DECODE_PRINTF("ESP\n");
++ M.x86.R_ESP = x86emu_bswap(M.x86.R_ESP);
++ break;
++ case 0xcd:
++ DECODE_PRINTF("EBP\n");
++ M.x86.R_EBP = x86emu_bswap(M.x86.R_EBP);
++ break;
++ case 0xce:
++ DECODE_PRINTF("ESI\n");
++ M.x86.R_ESI = x86emu_bswap(M.x86.R_ESI);
++ break;
++ case 0xcf:
++ DECODE_PRINTF("EDI\n");
++ M.x86.R_EDI = x86emu_bswap(M.x86.R_EDI);
++ break;
++ }
++ TRACE_AND_STEP();
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+ }
+@@ -1702,14 +1763,14 @@
+ /* 0xc5 */ x86emuOp2_illegal_op,
+ /* 0xc6 */ x86emuOp2_illegal_op,
+ /* 0xc7 */ x86emuOp2_illegal_op,
+-/* 0xc8 */ x86emuOp2_illegal_op, /* TODO: bswap */
+-/* 0xc9 */ x86emuOp2_illegal_op, /* TODO: bswap */
+-/* 0xca */ x86emuOp2_illegal_op, /* TODO: bswap */
+-/* 0xcb */ x86emuOp2_illegal_op, /* TODO: bswap */
+-/* 0xcc */ x86emuOp2_illegal_op, /* TODO: bswap */
+-/* 0xcd */ x86emuOp2_illegal_op, /* TODO: bswap */
+-/* 0xce */ x86emuOp2_illegal_op, /* TODO: bswap */
+-/* 0xcf */ x86emuOp2_illegal_op, /* TODO: bswap */
++/* 0xc8 */ x86emuOp2_bswap,
++/* 0xc9 */ x86emuOp2_bswap,
++/* 0xca */ x86emuOp2_bswap,
++/* 0xcb */ x86emuOp2_bswap,
++/* 0xcc */ x86emuOp2_bswap,
++/* 0xcd */ x86emuOp2_bswap,
++/* 0xce */ x86emuOp2_bswap,
++/* 0xcf */ x86emuOp2_bswap,
+
+ /* 0xd0 */ x86emuOp2_illegal_op,
+ /* 0xd1 */ x86emuOp2_illegal_op,
+Index: ops.c
+===================================================================
+RCS file: /cvs/osdf/cvs/host/other-licence/x86emu/ops.c,v
+retrieving revision 1.1
+diff -u -u -r1.1 ops.c
--- ops.c 7 Sep 2007 10:01:21 -0000 1.1
-+++ ops.c 15 Jan 2008 13:46:40 -0000 1.3
-@@ -2516,9 +2516,11 @@
++++ ops.c 20 Mar 2008 16:52:00 -0000
+@@ -1061,7 +1061,11 @@
+ imm = (s8)fetch_byte_imm();
+ DECODE_PRINTF2("PUSH\t%d\n", imm);
+ TRACE_AND_STEP();
+- push_word(imm);
++ if (M.x86.mode & SYSMODE_PREFIX_DATA) {
++ push_long(imm);
++ } else {
++ push_word(imm);
++ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+ }
+@@ -1256,8 +1260,10 @@
+ target = (u16)(M.x86.R_IP + (s16)offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+- if (cond)
++ if (cond) {
+ M.x86.R_IP = target;
++ JMP_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, " NEAR COND ");
++ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+ }
+@@ -2516,9 +2522,11 @@
count = 1;
if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
/* dont care whether REPE or REPNE */
@@ -50,7 +176,7 @@ diff -u -u -r1.1 -r1.3
M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
}
while (count--) {
-@@ -2526,6 +2528,8 @@
+@@ -2526,6 +2534,8 @@
store_data_byte_abs(M.x86.R_ES, M.x86.R_DI, val);
M.x86.R_SI += inc;
M.x86.R_DI += inc;
@@ -59,7 +185,7 @@ diff -u -u -r1.1 -r1.3
}
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
-@@ -2559,9 +2563,11 @@
+@@ -2559,9 +2569,11 @@
count = 1;
if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
/* dont care whether REPE or REPNE */
@@ -73,7 +199,7 @@ diff -u -u -r1.1 -r1.3
M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
}
while (count--) {
-@@ -2574,6 +2580,8 @@
+@@ -2574,6 +2586,8 @@
}
M.x86.R_SI += inc;
M.x86.R_DI += inc;
@@ -82,7 +208,7 @@ diff -u -u -r1.1 -r1.3
}
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
-@@ -2598,16 +2606,21 @@
+@@ -2598,16 +2612,21 @@
if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
/* REPE */
@@ -107,7 +233,7 @@ diff -u -u -r1.1 -r1.3
}
M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
} else {
-@@ -2644,8 +2657,8 @@
+@@ -2644,8 +2663,8 @@
TRACE_AND_STEP();
if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
/* REPE */
@@ -118,7 +244,7 @@ diff -u -u -r1.1 -r1.3
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
val1 = fetch_data_long(M.x86.R_SI);
val2 = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
-@@ -2655,11 +2668,16 @@
+@@ -2655,11 +2674,16 @@
val2 = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
cmp_word((u16)val1, (u16)val2);
}
@@ -136,7 +262,7 @@ diff -u -u -r1.1 -r1.3
}
M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
} else {
-@@ -2741,11 +2759,16 @@
+@@ -2741,11 +2765,16 @@
TRACE_AND_STEP();
if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
/* dont care whether REPE or REPNE */
@@ -156,7 +282,7 @@ diff -u -u -r1.1 -r1.3
}
M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
} else {
-@@ -2783,9 +2806,11 @@
+@@ -2783,9 +2812,11 @@
count = 1;
if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
/* dont care whether REPE or REPNE */
@@ -170,7 +296,7 @@ diff -u -u -r1.1 -r1.3
M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
}
while (count--) {
-@@ -2795,6 +2820,8 @@
+@@ -2795,6 +2826,8 @@
store_data_word_abs(M.x86.R_ES, M.x86.R_DI, M.x86.R_AX);
}
M.x86.R_DI += inc;
@@ -179,7 +305,7 @@ diff -u -u -r1.1 -r1.3
}
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
-@@ -2817,11 +2844,16 @@
+@@ -2817,11 +2850,16 @@
inc = 1;
if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
/* dont care whether REPE or REPNE */
@@ -199,7 +325,7 @@ diff -u -u -r1.1 -r1.3
}
M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
} else {
-@@ -2859,9 +2891,11 @@
+@@ -2859,9 +2897,11 @@
count = 1;
if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
/* dont care whether REPE or REPNE */
@@ -213,7 +339,7 @@ diff -u -u -r1.1 -r1.3
M.x86.mode &= ~(SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE);
}
while (count--) {
-@@ -2871,6 +2905,8 @@
+@@ -2871,6 +2911,8 @@
M.x86.R_AX = fetch_data_word(M.x86.R_SI);
}
M.x86.R_SI += inc;
@@ -222,7 +348,7 @@ diff -u -u -r1.1 -r1.3
}
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
-@@ -2894,26 +2930,36 @@
+@@ -2894,26 +2936,36 @@
inc = 1;
if (M.x86.mode & SYSMODE_PREFIX_REPE) {
/* REPE */
@@ -265,7 +391,7 @@ diff -u -u -r1.1 -r1.3
}
M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
} else {
-@@ -2951,8 +2997,8 @@
+@@ -2951,8 +3003,8 @@
TRACE_AND_STEP();
if (M.x86.mode & SYSMODE_PREFIX_REPE) {
/* REPE */
@@ -276,7 +402,7 @@ diff -u -u -r1.1 -r1.3
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
cmp_long(M.x86.R_EAX, val);
-@@ -2960,16 +3006,21 @@
+@@ -2960,16 +3012,21 @@
val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
cmp_word(M.x86.R_AX, (u16)val);
}
@@ -301,7 +427,7 @@ diff -u -u -r1.1 -r1.3
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
val = fetch_data_long_abs(M.x86.R_ES, M.x86.R_DI);
cmp_long(M.x86.R_EAX, val);
-@@ -2977,10 +3028,15 @@
+@@ -2977,10 +3034,15 @@
val = fetch_data_word_abs(M.x86.R_ES, M.x86.R_DI);
cmp_word(M.x86.R_AX, (u16)val);
}
@@ -318,7 +444,53 @@ diff -u -u -r1.1 -r1.3
}
M.x86.mode &= ~SYSMODE_PREFIX_REPNE;
} else {
-@@ -4020,8 +4076,11 @@
+@@ -3238,9 +3300,9 @@
+ DECODE_PRINTF("RET\t");
+ imm = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", imm);
+- RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip);
+ TRACE_AND_STEP();
+ M.x86.R_IP = pop_word();
++ RETURN_TRACE(M.x86.saved_cs,M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, "NEAR");
+ M.x86.R_SP += imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+@@ -3254,9 +3316,9 @@
+ {
+ START_OF_INSTR();
+ DECODE_PRINTF("RET\n");
+- RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip);
+ TRACE_AND_STEP();
+ M.x86.R_IP = pop_word();
++ RETURN_TRACE(M.x86.saved_cs,M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, "NEAR");
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+ }
+@@ -3471,10 +3533,10 @@
+ DECODE_PRINTF("RETF\t");
+ imm = fetch_word_imm();
+ DECODE_PRINTF2("%x\n", imm);
+- RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip);
+ TRACE_AND_STEP();
+ M.x86.R_IP = pop_word();
+ M.x86.R_CS = pop_word();
++ RETURN_TRACE(M.x86.saved_cs,M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, "FAR");
+ M.x86.R_SP += imm;
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+@@ -3488,10 +3550,10 @@
+ {
+ START_OF_INSTR();
+ DECODE_PRINTF("RETF\n");
+- RETURN_TRACE("RETF",M.x86.saved_cs,M.x86.saved_ip);
+ TRACE_AND_STEP();
+ M.x86.R_IP = pop_word();
+ M.x86.R_CS = pop_word();
++ RETURN_TRACE(M.x86.saved_cs,M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, "FAR");
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+ }
+@@ -4020,8 +4082,11 @@
ip += (s16) M.x86.R_IP;
DECODE_PRINTF2("%04x\n", ip);
TRACE_AND_STEP();
@@ -332,7 +504,7 @@ diff -u -u -r1.1 -r1.3
M.x86.R_IP = ip;
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
-@@ -4041,8 +4100,11 @@
+@@ -4041,8 +4106,11 @@
ip += (s16) M.x86.R_IP;
DECODE_PRINTF2("%04x\n", ip);
TRACE_AND_STEP();
@@ -346,7 +518,7 @@ diff -u -u -r1.1 -r1.3
M.x86.R_IP = ip;
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
-@@ -4062,8 +4124,11 @@
+@@ -4062,8 +4130,11 @@
ip += (s16) M.x86.R_IP;
DECODE_PRINTF2("%04x\n", ip);
TRACE_AND_STEP();
@@ -360,7 +532,19 @@ diff -u -u -r1.1 -r1.3
M.x86.R_IP = ip;
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
-@@ -4213,6 +4278,7 @@
+@@ -4085,8 +4156,10 @@
+ target = (u16)(M.x86.R_IP + offset);
+ DECODE_PRINTF2("%x\n", target);
+ TRACE_AND_STEP();
+- if (M.x86.R_CX == 0)
++ if (M.x86.R_CX == 0) {
+ M.x86.R_IP = target;
++ JMP_TRACE(M.x86.saved_cs, M.x86.saved_ip, M.x86.R_CS, M.x86.R_IP, " CXZ ");
++ }
+ DECODE_CLEAR_SEGOVR();
+ END_OF_INSTR();
+ }
+@@ -4213,6 +4286,7 @@
ip = (s16)fetch_word_imm();
ip += (s16)M.x86.R_IP;
DECODE_PRINTF2("%04x\n", ip);
@@ -368,7 +552,7 @@ diff -u -u -r1.1 -r1.3
TRACE_AND_STEP();
M.x86.R_IP = (u16)ip;
DECODE_CLEAR_SEGOVR();
-@@ -4233,6 +4299,7 @@
+@@ -4233,6 +4307,7 @@
cs = fetch_word_imm();
DECODE_PRINTF2("%04x:", cs);
DECODE_PRINTF2("%04x\n", ip);
@@ -376,7 +560,7 @@ diff -u -u -r1.1 -r1.3
TRACE_AND_STEP();
M.x86.R_IP = ip;
M.x86.R_CS = cs;
-@@ -4254,6 +4321,7 @@
+@@ -4254,6 +4329,7 @@
offset = (s8)fetch_byte_imm();
target = (u16)(M.x86.R_IP + offset);
DECODE_PRINTF2("%x\n", target);
@@ -384,7 +568,7 @@ diff -u -u -r1.1 -r1.3
TRACE_AND_STEP();
M.x86.R_IP = target;
DECODE_CLEAR_SEGOVR();
-@@ -4357,6 +4425,8 @@
+@@ -4357,6 +4433,8 @@
DECODE_PRINTF("REPNE\n");
TRACE_AND_STEP();
M.x86.mode |= SYSMODE_PREFIX_REPNE;
@@ -393,7 +577,7 @@ diff -u -u -r1.1 -r1.3
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
-@@ -4371,6 +4441,8 @@
+@@ -4371,6 +4449,8 @@
DECODE_PRINTF("REPE\n");
TRACE_AND_STEP();
M.x86.mode |= SYSMODE_PREFIX_REPE;
@@ -402,7 +586,7 @@ diff -u -u -r1.1 -r1.3
DECODE_CLEAR_SEGOVR();
END_OF_INSTR();
}
-@@ -5013,12 +5085,14 @@
+@@ -5013,12 +5093,14 @@
break;
case 4: /* jmp word ptr ... */
destval = fetch_data_word(destoffset);
@@ -421,10 +605,28 @@ Index: prim_ops.c
===================================================================
RCS file: /cvs/osdf/cvs/host/other-licence/x86emu/prim_ops.c,v
retrieving revision 1.1
-retrieving revision 1.2
-diff -u -u -r1.1 -r1.2
+retrieving revision 1.3
+diff -u -u -r1.1 -r1.3
--- prim_ops.c 7 Sep 2007 10:01:21 -0000 1.1
-+++ prim_ops.c 15 Jan 2008 13:46:40 -0000 1.2
++++ prim_ops.c 16 Jan 2008 14:18:15 -0000 1.3
+@@ -1921,7 +1921,7 @@
+ void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s)
+ {
+ #ifdef __HAS_LONG_LONG__
+- s64 res = (s64)d * (s64)s;
++ s64 res = (s64)(s32)d * (s64)(s32)s;
+
+ *res_lo = (u32)res;
+ *res_hi = (u32)(res >> 32);
+@@ -2013,7 +2013,7 @@
+ void mul_long(u32 s)
+ {
+ #ifdef __HAS_LONG_LONG__
+- u64 res = (u32)M.x86.R_EAX * (u32)s;
++ u64 res = (u64)M.x86.R_EAX * s;
+
+ M.x86.R_EAX = (u32)res;
+ M.x86.R_EDX = (u32)(res >> 32);
@@ -2312,16 +2312,15 @@
}
if (M.x86.mode & (SYSMODE_PREFIX_REPE | SYSMODE_PREFIX_REPNE)) {
@@ -547,10 +749,10 @@ Index: include/x86emu/debug.h
===================================================================
RCS file: /cvs/osdf/cvs/host/other-licence/x86emu/include/x86emu/debug.h,v
retrieving revision 1.1
-retrieving revision 1.3
-diff -u -u -r1.1 -r1.3
+retrieving revision 1.4
+diff -u -u -r1.1 -r1.4
--- include/x86emu/debug.h 7 Sep 2007 10:01:21 -0000 1.1
-+++ include/x86emu/debug.h 19 Oct 2007 08:42:15 -0000 1.3
++++ include/x86emu/debug.h 20 Mar 2008 15:25:27 -0000 1.4
@@ -40,8 +40,6 @@
#ifndef __X86EMU_DEBUG_H
#define __X86EMU_DEBUG_H
@@ -578,10 +780,17 @@ diff -u -u -r1.1 -r1.3
# define DEBUG_SYS() 0
# define DEBUG_MEM_TRACE() 0
# define DEBUG_IO_TRACE() 0
-@@ -174,9 +176,15 @@
+@@ -169,14 +171,20 @@
+ x86emu_dump_regs(); \
+ if (DEBUG_TRACECALL()) \
+ printk("%04x:%04x: CALL %s%04x:%04x\n", u , v, s, w, x);
+-# define RETURN_TRACE(n,u,v) \
++# define RETURN_TRACE(u,v,w,x,s) \
+ if (DEBUG_TRACECALLREGS()) \
x86emu_dump_regs(); \
if (DEBUG_TRACECALL()) \
- printk("%04x:%04x: %s\n",u,v,n);
+- printk("%04x:%04x: %s\n",u,v,n);
++ printk("%04x:%04x: RET %s %04x:%04x\n",u,v,s,w,x);
+# define JMP_TRACE(u,v,w,x,s) \
+ if (DEBUG_TRACEJMPREGS()) \
+ x86emu_dump_regs(); \
@@ -589,7 +798,8 @@ diff -u -u -r1.1 -r1.3
+ printk("%04x:%04x: JMP %s%04x:%04x\n", u , v, s, w, x);
#else
# define CALL_TRACE(u,v,w,x,s)
- # define RETURN_TRACE(n,u,v)
+-# define RETURN_TRACE(n,u,v)
++# define RETURN_TRACE(u,v,w,x,s)
+# define JMP_TRACE(u,v,w,x,s)
#endif
diff --git a/slof/OF.lds b/slof/OF.lds
index 3e4a8f6..5f8b2b1 100644
--- a/slof/OF.lds
+++ b/slof/OF.lds
@@ -38,7 +38,13 @@ SECTIONS
{
*(.got .toc)
}
- .data : { *(.rodata .rodata.*) *(.data .data.*) }
+
+ .data : {
+ *(.rodata .rodata.*)
+ *(.data .data.*)
+ *(.note.gnu.build-id)
+ }
+
.comment : { *(.comment) }
.branch_lt : { *(.branch_lt) }
diff --git a/slof/engine.in b/slof/engine.in
index af42eb6..2cc9d26 100644
--- a/slof/engine.in
+++ b/slof/engine.in
@@ -257,8 +257,9 @@ con(LINEFEED 0x0a)
// Text output.
dfr(EMIT)
+dfr(CR)
col(TYPE BOUNDS DO?DO(5) I C@ EMIT DOLOOP(-5))
-col(CR CARRET EMIT LINEFEED EMIT)
+col(LL-CR CARRET EMIT LINEFEED EMIT)
col(SPACE BL EMIT)
col(SPACES 0 DO?DO(3) SPACE DOLOOP(-3))
diff --git a/slof/fs/base.fs b/slof/fs/base.fs
index f05ffab..33fe7bc 100644
--- a/slof/fs/base.fs
+++ b/slof/fs/base.fs
@@ -10,6 +10,9 @@
\ * IBM Corporation - initial implementation
\ ****************************************************************************/
+\ Hash for faster lookup
+#include <find-hash.fs>
+
: >name ( xt -- nfa ) \ note: still has the "immediate" field!
BEGIN char- dup c@ UNTIL ( @lastchar )
dup dup aligned - cell+ char- ( @lastchar lenmodcell )
@@ -24,6 +27,8 @@
VARIABLE mask -1 mask !
VARIABLE huge-tftp-load 1 huge-tftp-load !
+\ Default implementation for sms-get-tftp-blocksize that return 1432 (decimal)
+: sms-get-tftp-blocksize 598 ;
: default-hw-exception s" Exception #" type . ;
@@ -104,6 +109,7 @@ CREATE $catpad 100 allot
: (is-user-word) ( name-str name-len xt -- ) -rot $CREATE , DOES> @ execute ;
: zplace ( str len buf -- ) 2dup + 0 swap c! swap move ;
+: rzplace ( str len buf -- ) 2dup + 0 swap rb! swap rmove ;
: strdup ( str len -- dupstr len ) here over allot swap 2dup 2>r move 2r> ;
@@ -245,9 +251,6 @@ CREATE "pad 100 allot
THEN \ in temp buffer
; immediate
-\ Hash for faster lookup
-#include <find-hash.fs>
-
\ Remove command old-name and all subsequent definitions
: $forget ( str len -- )
diff --git a/slof/fs/client.fs b/slof/fs/client.fs
index 78ccfdf..642d04f 100644
--- a/slof/fs/client.fs
+++ b/slof/fs/client.fs
@@ -41,6 +41,8 @@ VARIABLE client-callback \ Address of client's callback function
\ We pass the arguments for the client in R6 and R7, the client interface
\ entry point address is passed in R5.
>r ciregs >r7 ! ciregs >r6 ! client-entry-point @ ciregs >r5 !
+ \ Initialise client-stack-pointer
+ cistack ciregs >r1 !
\ jump-client maps to call_client in slof/entry.S
\ When jump-client returns, R3 holds the address of a NUL-terminated string
\ that holds the client interface word the client wants to call, R4 holds
diff --git a/slof/fs/envvar_defaults.fs b/slof/fs/envvar_defaults.fs
index a88d91b..21a26e6 100644
--- a/slof/fs/envvar_defaults.fs
+++ b/slof/fs/envvar_defaults.fs
@@ -38,3 +38,7 @@ false default-flag use-nvramrc?
false default-flag direct-serial?
true default-flag real-mode?
true default-flag use-axon-ddr?
+#ifdef BIOSEMU
+true default-flag use-biosemu?
+0 default-int biosemu-debug
+#endif
diff --git a/slof/fs/find-hash.fs b/slof/fs/find-hash.fs
index 3769673..a40ccbd 100644
--- a/slof/fs/find-hash.fs
+++ b/slof/fs/find-hash.fs
@@ -10,25 +10,68 @@
\ * IBM Corporation - initial implementation
\ ****************************************************************************/
+#ifdef HASH_DEBUG
+0 value from-hash
+0 value not-from-hash
+0 value hash-collisions
+#endif
-CREATE name-hash 200 cells allot
-: clean-hash name-hash 200 cells erase ;
clean-hash
-\ The hash algorithm (AND with 1f is necessary because of case insensitivity)
-: hash ( str len -- hash )
- f and 5 lshift swap c@ 1f and xor cells name-hash +
-;
-
: hash-find ( str len head -- 0 | link )
- >r 2dup 2dup hash
- dup >r @ dup IF link>name name>string string=ci ELSE nip nip THEN
- IF 2drop r> @ r> drop exit THEN
- r> r> swap >r ((find))
- dup IF dup r> ! ELSE r> drop THEN
+ >r 2dup 2dup hash ( str len str len hash R: head )
+ dup >r @ dup ( str len str len *hash *hash R: head hash )
+ IF ( str len str len *hash R: head hash )
+ link>name name>string string=ci ( str len true|false R: head hash )
+ dup 0=
+ IF
+#ifdef HASH_DEBUG
+ hash-collisions 1+
+ to hash-collisions
+#endif
+ THEN
+ ELSE
+ nip nip ( str len 0 R: head hash )
+ THEN
+ IF \ hash found
+ 2drop r> @ r> drop ( *hash R: )
+#ifdef HASH_DEBUG
+ from-hash 1+ to from-hash
+#endif
+ exit
+ THEN \ hash not found
+ r> r> swap >r ((find)) ( str len head R: hash=0 )
+ dup
+ IF
+#ifdef HASH_DEBUG
+ not-from-hash 1+
+ to not-from-hash
+#endif
+ dup r> ! ( link R: )
+ ELSE
+ r> drop ( 0 R: )
+ THEN
;
: hash-reveal hash off ;
' hash-reveal to (reveal)
' hash-find to (find)
+
+#ifdef HASH_DEBUG
+\ print out all entries in the hash table
+: dump-hash-table ( -- )
+ cr
+ hash-table hash-size 0 DO
+ dup @ dup 0<> IF
+ over . s" : " type link>name name>string type cr
+ ELSE
+ drop
+ THEN
+ cell+
+ LOOP drop
+ s" hash-collisions: " type hash-collisions . cr
+ s" from-hash: " type from-hash . cr
+ s" not-from-hash: " type not-from-hash . cr
+;
+#endif
diff --git a/slof/fs/romfs.fs b/slof/fs/romfs.fs
index b5210fe..7d7e463 100644
--- a/slof/fs/romfs.fs
+++ b/slof/fs/romfs.fs
@@ -32,10 +32,6 @@ romfs-lookup-cb /romfs-lookup-control-block erase
0= IF romfs-lookup-cb dup romfs>data @ swap romfs>data-size @ ELSE
false THEN ;
-: check-for-board-romfs ( -- true | false )
- s" header" romfs-lookup drop @
- 6d61676963313233 <> IF false ELSE true THEN ;
-
: ibm,romfs-lookup ( fn-str fn-len -- data-high data-low size | 0 0 false )
romfs-lookup dup
0= if drop 0 0 false else
@@ -63,13 +59,19 @@ CONSTANT /romfs-cb
( fn-str fn-len ) ( R: rom-cb-file-addr )
2drop r@ romfs>data-off @ r@ + r> romfs>size @ ;
+\ returns address of romfs-header file
: flash-header ( -- address | false )
- check-for-board-romfs 0= IF false ELSE
- s" header" romfs-lookup 0= IF 0 THEN THEN ;
+ get-flash-base 28 + \ prepare flash header file address
+ dup rx@ \ fetch "magic123"
+ 6d61676963313233 <> IF \ IF flash is not valid
+ drop \ | forget address
+ false \ | return false
+ THEN \ FI
+;
CREATE bdate-str 10 allot
: bdate2human ( -- addr len )
- flash-header 40 + @ (.)
+ flash-header 40 + rx@ (.)
drop dup 0 + bdate-str 6 + 4 move
dup 4 + bdate-str 0 + 2 move
dup 6 + bdate-str 3 + 2 move
diff --git a/slof/fs/usb/usb-kbd-device-support.fs b/slof/fs/usb/usb-kbd-device-support.fs
index 104a508..9fa4236 100644
--- a/slof/fs/usb/usb-kbd-device-support.fs
+++ b/slof/fs/usb/usb-kbd-device-support.fs
@@ -89,9 +89,6 @@ to kbd-addr
drop
s" KBDS: Set config returned" usb-debug-print
- 0 kbd-addr control-cls-set-protocol drop \ set protocol=boot mode
- s" KBDS: Set protocol returned" usb-debug-print
-
0 kbd-addr control-cls-set-idle drop \ set idle
s" KBDS: Set idle returned" usb-debug-print
diff --git a/slof/fs/usb/usb-keyboard.fs b/slof/fs/usb/usb-keyboard.fs
index 5631030..fd96e6e 100644
--- a/slof/fs/usb/usb-keyboard.fs
+++ b/slof/fs/usb/usb-keyboard.fs
@@ -89,12 +89,6 @@ s" usb-kbd-device-support.fs" included
then
;
-: open ( -- true )
- true
-;
-
-: close ;
-
: set-led ( led -- )
dup to led-state
kbd-addr control-cls-set-report drop
@@ -361,3 +355,17 @@ milliseconds to expire-ms \ Timer initialize
s" keyboard" get-node node>path set-alias
+: open ( -- true )
+ 7 set-led
+ 100 ms
+ 3 set-led
+ 100 ms
+ 1 set-led
+ 100 ms
+ \ read once from keyboard before actually using it
+ usb-kread drop
+ 0 set-led
+ true
+;
+
+: close ;
diff --git a/slof/paflof.c b/slof/paflof.c
index 895a18f..343d623 100644
--- a/slof/paflof.c
+++ b/slof/paflof.c
@@ -21,16 +21,17 @@
#include "paflof.h"
#include <string.h>
#include <stdint.h>
+#include <ctype.h>
#include ISTR(TARG,h)
#define LAST_ELEMENT(x) x[sizeof x / sizeof x[0] - 1]
-#include ISTR(TARG,c)
-
unsigned long fdt_start;
unsigned long romfs_base;
unsigned long epapr_magic;
+unsigned char hash_table[HASHSIZE*CELLSIZE];
+#include ISTR(TARG,c)
// the actual engine
long engine(int mode, long param_1, long param_2)
diff --git a/slof/paflof.h b/slof/paflof.h
index 81182cb..885c948 100644
--- a/slof/paflof.h
+++ b/slof/paflof.h
@@ -14,11 +14,15 @@
//
+extern long engine(int, long, long);
+
#define TIBSIZE 256
#define POCKETSIZE 256
#define NUMPOCKETS 16
+#define HASHSIZE 0x1000
+
// engine mode bits
#define ENGINE_MODE_PARAM_1 0x0001
#define ENGINE_MODE_PARAM_2 0x0002
diff --git a/slof/ppc64.c b/slof/ppc64.c
index ff94d3d..8ad828c 100644
--- a/slof/ppc64.c
+++ b/slof/ppc64.c
@@ -16,30 +16,30 @@
* the_exception_frame is used by the handler to store a copy of all
* registers after an exception; this copy can then be used by paflof's
* exception handler to printout a register dump */
-cell the_exception_frame[0x400/CELLSIZE] __attribute__ ((aligned(PAGE_SIZE)));;
+cell the_exception_frame[0x400 / CELLSIZE] __attribute__ ((aligned(PAGE_SIZE)));;
/* the_client_frame is the register save area when starting a client */
-cell the_client_frame[0x1000/CELLSIZE] __attribute__ ((aligned(0x100)));
-cell the_client_stack[0x2000/CELLSIZE] __attribute__ ((aligned(0x100)));
+cell the_client_frame[0x1000 / CELLSIZE] __attribute__ ((aligned(0x100)));
+cell the_client_stack[0x8000 / CELLSIZE] __attribute__ ((aligned(0x100)));
/* THE forth stack */
-cell the_data_stack[0x2000/CELLSIZE] __attribute__ ((aligned(0x100)));
+cell the_data_stack[0x2000 / CELLSIZE] __attribute__ ((aligned(0x100)));
/* the forth return stack */
-cell the_return_stack[0x2000/CELLSIZE] __attribute__ ((aligned(0x100)));
+cell the_return_stack[0x2000 / CELLSIZE] __attribute__ ((aligned(0x100)));
/* forth stack and return-stack pointers */
cell *restrict dp;
cell *restrict rp;
/* terminal input buffer */
-cell the_tib[0x1000/CELLSIZE] __attribute__ ((aligned(0x100)));
+cell the_tib[0x1000 / CELLSIZE] __attribute__ ((aligned(0x100)));
/* temporary string buffers */
-char the_pockets[NUMPOCKETS*POCKETSIZE] __attribute__ ((aligned(0x100)));
+char the_pockets[NUMPOCKETS * POCKETSIZE] __attribute__ ((aligned(0x100)));
-cell the_comp_buffer[0x1000/CELLSIZE] __attribute__ ((aligned(0x100)));
+cell the_comp_buffer[0x1000 / CELLSIZE] __attribute__ ((aligned(0x100)));
-cell the_heap[HEAP_SIZE/CELLSIZE] __attribute__ ((aligned(0x1000)));
+cell the_heap[HEAP_SIZE / CELLSIZE] __attribute__ ((aligned(0x1000)));
cell *the_heap_start = &the_heap[0];
-cell *the_heap_end = &the_heap[HEAP_SIZE/CELLSIZE];
+cell *the_heap_end = &the_heap[HEAP_SIZE / CELLSIZE];
extern void io_putchar(unsigned char);
@@ -47,23 +47,25 @@ extern void io_putchar(unsigned char);
static unsigned long __attribute__((noinline))
call_c(cell arg0, cell arg1, cell arg2, cell entry)
{
- register unsigned long r3 asm("r3") = arg0.u;
- register unsigned long r4 asm("r4") = arg1.u;
- register unsigned long r5 asm("r5") = arg2.u;
- register unsigned long r6 = entry.u ;
-
- asm volatile("mflr 31 ; mtctr %4 ; bctrl ; mtlr 31"
- : "=r"(r3)
- : "r"(r3), "r"(r4), "r"(r5), "r"(r6)
- : "ctr", "r31");
-
- return r3;
+ register unsigned long r3 asm("r3") = arg0.u;
+ register unsigned long r4 asm("r4") = arg1.u;
+ register unsigned long r5 asm("r5") = arg2.u;
+ register unsigned long r6 = entry.u ;
+
+ asm volatile("mflr 31 ; mtctr %4 ; bctrl ; mtlr 31"
+ : "=r" (r3)
+ : "r" (r3), "r" (r4), "r" (r5), "r" (r6)
+ : "ctr", "r6", "r7", "r8", "r9", "r10", "r11",
+ "r12", "r13", "r31");
+
+ return r3;
}
long
writeLogByte_wrapper(long x, long y)
{
unsigned long result;
+
set_ci();
result = writeLogByte(x, y);
clr_ci();
@@ -79,26 +81,28 @@ writeLogByte_wrapper(long x, long y)
* @param count number of bytes to be written
* @return the number of bytes that have been written successfully
*/
-int write(int fd, const void *buf, int count)
+int
+write(int fd, const void *buf, int count)
{
- int i;
- char *ptr = (char *)buf;
+ int i;
+ char *ptr = (char *)buf;
- if (fd != 1 && fd != 2)
- return 0;
+ if (fd != 1 && fd != 2)
+ return 0;
- for (i = 0; i < count; i++) {
- if (*ptr == '\n')
- io_putchar('\r');
- io_putchar(*ptr++);
- }
+ for (i = 0; i < count; i++) {
+ if (*ptr == '\n')
+ io_putchar('\r');
+ io_putchar(*ptr++);
+ }
- return i;
+ return i;
}
-/* This should probably be temporary until a better solution is fount */
-void asm_cout(long Character,long UART,long NVRAM __attribute__((unused)))
+/* This should probably be temporary until a better solution is found */
+void
+asm_cout(long Character, long UART, long NVRAM __attribute__((unused)))
{
- if(UART)
+ if (UART)
io_putchar(Character);
}
diff --git a/slof/prim.code b/slof/prim.code
index 0b9603e..d1ac61f 100644
--- a/slof/prim.code
+++ b/slof/prim.code
@@ -59,7 +59,12 @@ PRIM(EREGS) PUSH; TOS.a = the_exception_frame; MIRP
PRIM(CIREGS) PUSH; TOS.a = the_client_frame; MIRP
// Client stack
-PRIM(CISTACK) PUSH; TOS.a = the_client_stack; MIRP
+// (According to the PowerPC ABI the stack-pointer points to the
+// lowest **USED** value.
+// I.e. it is decremented before a new element is stored on the
+// stack.)
+PRIM(CISTACK) PUSH; TOS.a = the_client_stack
+ + (sizeof(the_client_stack) / CELLSIZE); MIRP
// compile-in-interpret buffer
PRIM(COMP_X2d_BUFFER) PUSH; TOS.a = the_comp_buffer; MIRP
@@ -285,6 +290,55 @@ PRIM(XOR) NOS.u ^= TOS.u; POP; MIRP
PRIM(X_X21) PUT_XONG; MIRP
+#define UGET_TYPE1(t) { \
+ type_c *restrict a = (type_c *restrict)(TOS.a); \
+ t b; \
+ type_c *restrict c = (type_c *restrict)&b;
+
+#define UGET_TYPE2(t) \
+ *c++ = *a++; \
+ *c++ = *a++;
+
+#define UGET_TYPE3(t) \
+ TOS.u = b; \
+}
+
+#define UPUT_TYPE1(t) { \
+ type_c *restrict a = (type_c *restrict)(TOS.a); \
+ t b = NOS.u; \
+ type_c *restrict c = (type_c *restrict)&b; \
+ POP; \
+ POP;
+
+#define UPUT_TYPE2(t) \
+ *a++ = *c++; \
+ *a++ = *c++;
+
+#define UPUT_TYPE3(t) }
+
+#define UGET_WORD1 UGET_TYPE1(type_w)
+#define UPUT_WORD1 UPUT_TYPE1(type_w)
+#define UGET_WORD2 UGET_TYPE2(type_w)
+#define UPUT_WORD2 UPUT_TYPE2(type_w)
+#define UGET_WORD3 UGET_TYPE3(type_w)
+#define UPUT_WORD3 UPUT_TYPE3(type_w)
+#define UGET_LONG1 UGET_TYPE1(type_l)
+#define UPUT_LONG1 UPUT_TYPE1(type_l)
+#define UGET_LONG2 UGET_TYPE2(type_l)
+#define UPUT_LONG2 UPUT_TYPE2(type_l)
+#define UGET_LONG3 UGET_TYPE3(type_l)
+#define UPUT_LONG3 UPUT_TYPE3(type_l)
+
+#define UGET_WORD UGET_WORD1 UGET_WORD2 UGET_WORD3
+#define UPUT_WORD UPUT_WORD1 UPUT_WORD2 UPUT_WORD3
+#define UGET_LONG UGET_LONG1 UGET_LONG2 UGET_LONG2 UGET_LONG3
+#define UPUT_LONG UPUT_LONG1 UPUT_LONG2 UPUT_LONG2 UPUT_LONG3
+
+ PRIM(UNALIGNED_X2d_W_X40) UGET_WORD; MIRP
+ PRIM(UNALIGNED_X2d_W_X21) UPUT_WORD; MIRP
+ PRIM(UNALIGNED_X2d_L_X40) UGET_LONG; MIRP
+ PRIM(UNALIGNED_X2d_L_X21) UPUT_LONG; MIRP
+
// 6
PRIM(_X3c) NOS.n = -(NOS.n < TOS.n); POP; MIRP
@@ -516,7 +570,6 @@ PRIM(STRING_X3d_CI)
unsigned char *p2 = TOS.a; POP;
type_u l1 = TOS.u; POP;
unsigned char *p1 = TOS.a;
- extern int toupper(int c);
if (l1 == l2) {
TOS.n = -1; /* Default to TRUE */
@@ -547,3 +600,35 @@ PRIM(ZCOUNT)
type_u len = strlen(TOS.a);
PUSH; TOS.u = len;
MIRP
+
+PRIM(CLEAN_X2d_HASH)
+ memset(hash_table, 0, sizeof(hash_table));
+MIRP
+
+PRIM(HASH_X2d_TABLE)
+ PUSH;
+ TOS.a = hash_table;
+MIRP
+
+/* hash ( str len -- hash )
+ * this word is used in find-hash.fs to create
+ * a hash to accelerate word lookup */
+PRIM(HASH)
+ type_u len = TOS.u; POP;
+ unsigned char *str = TOS.a;
+ type_u tmp = len;
+ type_u hash = 0;
+ while(len--) {
+ hash <<= 1;
+ hash ^= tolower(*str);
+ hash ^= tmp;
+ str++;
+ }
+ /* we only want hash values which size is smaller
+ * than HASHSIZE */
+ hash &= HASHSIZE - 1;
+ /* access the hash table in steps of CELLSIZE */
+ hash *= CELLSIZE;
+ /* return a pointer for this hash in the hash table */
+ TOS.a = hash_table + hash;
+MIRP
diff --git a/slof/prim.in b/slof/prim.in
index 47c09ed..b14a867 100644
--- a/slof/prim.in
+++ b/slof/prim.in
@@ -78,6 +78,11 @@ cod(L!)
cod(X@)
cod(X!)
+cod(UNALIGNED-W@)
+cod(UNALIGNED-W!)
+cod(UNALIGNED-L@)
+cod(UNALIGNED-L!)
+
cod(<)
cod(U<)
cod(0<)
@@ -99,3 +104,7 @@ cod(MOVE)
// cod(RMOVE64)
cod(RMOVE)
cod(ZCOUNT)
+con(HASH-SIZE HASHSIZE)
+cod(HASH)
+cod(CLEAN-HASH)
+cod(HASH-TABLE)