aboutsummaryrefslogtreecommitdiffstats
path: root/roms/u-boot-sam460ex/tools/multiplier
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/u-boot-sam460ex/tools/multiplier
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/u-boot-sam460ex/tools/multiplier')
-rw-r--r--roms/u-boot-sam460ex/tools/multiplier/Makefile97
-rw-r--r--roms/u-boot-sam460ex/tools/multiplier/ctype.c56
-rw-r--r--roms/u-boot-sam460ex/tools/multiplier/dummy.c1
-rw-r--r--roms/u-boot-sam460ex/tools/multiplier/junk1
-rw-r--r--roms/u-boot-sam460ex/tools/multiplier/memio.h121
-rw-r--r--roms/u-boot-sam460ex/tools/multiplier/ppcstring.S204
-rw-r--r--roms/u-boot-sam460ex/tools/multiplier/short_types.h36
-rw-r--r--roms/u-boot-sam460ex/tools/multiplier/string.c340
-rw-r--r--roms/u-boot-sam460ex/tools/multiplier/update.c129
-rw-r--r--roms/u-boot-sam460ex/tools/multiplier/utils.c82
10 files changed, 1067 insertions, 0 deletions
diff --git a/roms/u-boot-sam460ex/tools/multiplier/Makefile b/roms/u-boot-sam460ex/tools/multiplier/Makefile
new file mode 100644
index 000000000..f038b6da2
--- /dev/null
+++ b/roms/u-boot-sam460ex/tools/multiplier/Makefile
@@ -0,0 +1,97 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+LOAD_ADDR = 0x1000000
+
+include $(TOPDIR)/config.mk
+
+PROG = $(obj)multiplier
+IMAGE = $(obj)multiplier.image
+
+COBJS = update.o utils.o string.o ctype.o dummy.o
+COBJS_LINKS = stubs.o
+AOBJS = ppcstring.o
+AOBJS_LINKS =
+
+OBJS := $(addprefix $(obj),$(COBJS) $(COBJS_LINKS) $(AOBJS) $(AOBJS_LINKS))
+SRCS := $(COBJS:.o=.c) $(AOBJS:.o=.S) $(addprefix $(obj), $(COBJS_LINKS:.o:.c) $(AOBJS_LINKS:.o:.S))
+
+CPPFLAGS += -I$(TOPDIR) -I$(TOPDIR)/board/ACube/Sam460ex
+CFLAGS += -I$(TOPDIR)/board/ACube/Sam460ex
+AFLAGS += -I$(TOPDIR)/board/ACube/Sam460ex
+
+DEPS = $(OBJTREE)/u-boot.bin $(OBJTREE)/tools/mkimage
+ifneq ($(DEPS),$(wildcard $(DEPS)))
+$(error "updater: Missing required objects, please run regular build first")
+endif
+
+all: $(obj).depend $(PROG) $(IMAGE)
+
+#########################################################################
+
+$(obj)%.srec: %.o $(LIB)
+ $(LD) -g -Ttext $(LOAD_ADDR) -o $(<:.o=) -e $(<:.o=) $< $(LIB)
+ $(OBJCOPY) -O srec $(<:.o=) $@
+
+$(obj)%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(obj)%.o: %.S
+ $(CC) $(AFLAGS) -c -o $@ $<
+
+$(obj)memio.o: $(obj)memio.S
+ $(CC) $(AFLAGS) -c -o $@ $<
+
+$(obj)memio.S:
+ rm -f $(obj)memio.c
+ ln -s $(SRCTREE)/board/ACube/Sam460ex/memio.S $(obj)memio.S
+
+$(obj)stubs.o: $(obj)stubs.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(obj)stubs.c:
+ rm -f $(obj)stubs.c
+ ln -s $(SRCTREE)/examples/stubs.c $(obj)stubs.c
+
+#########################################################################
+
+$(obj)multiplier: $(OBJS)
+ $(LD) -g -Ttext $(LOAD_ADDR) -o $(obj)multiplier -e _main $(OBJS)
+ $(OBJCOPY) -O binary $(obj)multiplier $(obj)multiplier.bin
+
+$(obj)multiplier.image: $(obj)multiplier $(OBJTREE)/u-boot.bin
+ cat >/tmp/tempimage $(obj)multiplier.bin junk $(OBJTREE)/u-boot.bin
+ $(OBJTREE)/tools/mkimage -A ppc -O u-boot -T standalone -C none -a $(LOAD_ADDR) \
+ -e `$(NM) $(obj)multiplier | grep _main | cut --bytes=1-8` \
+ -n "Multiplier" -d /tmp/tempimage $(obj)multiplier.image
+ rm /tmp/tempimage
+ cp $(obj)multiplier.image /boot/multiplier
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/roms/u-boot-sam460ex/tools/multiplier/ctype.c b/roms/u-boot-sam460ex/tools/multiplier/ctype.c
new file mode 100644
index 000000000..6ed0468a2
--- /dev/null
+++ b/roms/u-boot-sam460ex/tools/multiplier/ctype.c
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * linux/lib/ctype.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#include <linux/ctype.h>
+
+unsigned char _ctype[] = {
+_C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */
+_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */
+_C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */
+_C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */
+_S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */
+_P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */
+_D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */
+_D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */
+_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */
+_U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */
+_U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */
+_U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */
+_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */
+_L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */
+_L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */
+_L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
+_S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */
+_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */
+_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */
+_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */
+_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */
+_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */
diff --git a/roms/u-boot-sam460ex/tools/multiplier/dummy.c b/roms/u-boot-sam460ex/tools/multiplier/dummy.c
new file mode 100644
index 000000000..9fe5ac1b1
--- /dev/null
+++ b/roms/u-boot-sam460ex/tools/multiplier/dummy.c
@@ -0,0 +1 @@
+volatile int __dummy = 0xDEADBEEF;
diff --git a/roms/u-boot-sam460ex/tools/multiplier/junk b/roms/u-boot-sam460ex/tools/multiplier/junk
new file mode 100644
index 000000000..f73285a83
--- /dev/null
+++ b/roms/u-boot-sam460ex/tools/multiplier/junk
@@ -0,0 +1 @@
+................................................................................................................................................................................................................................................................ \ No newline at end of file
diff --git a/roms/u-boot-sam460ex/tools/multiplier/memio.h b/roms/u-boot-sam460ex/tools/multiplier/memio.h
new file mode 100644
index 000000000..f637df85c
--- /dev/null
+++ b/roms/u-boot-sam460ex/tools/multiplier/memio.h
@@ -0,0 +1,121 @@
+/*
+ * Memory mapped IO
+ *
+ * (C) Copyright 2002
+ * Hyperion Entertainment, ThomasF@hyperion-entertainment.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ * You may also use this under a BSD license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#ifndef _MEMIO_H
+#define _MEMIO_H
+
+#include "short_types.h"
+
+#define IOBASE 0xE8000000
+
+#define in_byte(from) read_byte( (uint8 *)(IOBASE | (from)))
+#define in_word(from) read_word_little((uint16 *)(IOBASE | (from)))
+#define in_long(from) read_long_little((uint32 *)(IOBASE | (from)))
+#define out_byte(to, val) write_byte((uint8 *)(IOBASE | (to)), val)
+#define out_word(to, val) write_word_little((uint16 *)(IOBASE | (to)), val)
+#define out_long(to, val) write_long_little((uint32 *)(IOBASE | (to)), val)
+
+
+static inline uint8 read_byte(volatile uint8 *from)
+{
+ int x;
+ asm volatile ("lbz %0,%1\n eieio\n sync" : "=r" (x) : "m" (*from));
+ return (uint8)x;
+}
+
+
+static inline void write_byte(volatile uint8 *to, uint8 x)
+{
+ asm volatile ("stb %1,%0\n eieio\n sync" : "=m" (*to) : "r" (x));
+}
+
+static inline uint16 read_word_little(volatile uint16 *from)
+{
+ int x;
+ asm volatile ("lhbrx %0,0,%1\n eieio\n sync" : "=r" (x) : "r" (from), "m" (*from));
+ return (uint16)x;
+}
+
+static inline uint16 read_word_big(volatile uint16 *from)
+{
+ int x;
+ asm volatile ("lhz %0,%1\n eieio\n sync" : "=r" (x) : "m" (*from));
+ return (uint16)x;
+}
+
+static inline void write_word_little(volatile uint16 *to, int x)
+{
+ asm volatile ("sthbrx %1,0,%2\n eieio\n sync" : "=m" (*to) : "r" (x), "r" (to));
+}
+
+static inline void write_word_big(volatile uint16 *to, int x)
+{
+ asm volatile ("sth %1,%0\n eieio\n sync" : "=m" (*to) : "r" (x));
+}
+
+static inline uint32 read_long_little(volatile uint32 *from)
+{
+ unsigned long x;
+ asm volatile ("lwbrx %0,0,%1\n eieio\n sync" : "=r" (x) : "r" (from), "m"(*from));
+ return (uint32)x;
+}
+
+static inline uint32 read_long_big(volatile uint32 *from)
+{
+ unsigned long x;
+ asm volatile ("lwz %0,%1\n eieio\n sync" : "=r" (x) : "m" (*from));
+ return (uint32)x;
+}
+
+static inline void write_long_little(volatile uint32 *to, uint32 x)
+{
+ asm volatile ("stwbrx %1,0,%2\n eieio\n sync" : "=m" (*to) : "r" (x), "r" (to));
+}
+
+static inline void write_long_big(volatile uint32 *to, uint32 x)
+{
+ asm volatile ("stw %1,%0\n eieio\n sync" : "=m" (*to) : "r" (x));
+}
+
+#define CONFIG_ADDR(bus, devfn, offset) \
+ write_long_big((uint32 *)0xEEC00000, \
+ ((offset & 0xEC)<<24) | (devfn << 16) \
+ | (bus<<8) | 0x80);
+#define CONFIG_DATA(offset,mask) ((void *)(0xEEC00004+(offset & mask)))
+
+/*
+#define CONFIG_ADDR(bus, devfn, offset) \
+ write_long_big((uint32 *)0xFEC00CF8, \
+ ((offset & 0xFC)<<24) | (devfn << 16) \
+ | (bus<<8) | 0x80);
+#define CONFIG_DATA(offset,mask) ((void *)(0xFEE00CFC+(offset & mask)))
+*/
+
+uint8 pci_read_cfg_byte(int32 bus, int32 devfn, int32 offset);
+void pci_write_cfg_byte(int32 bus, int32 devfn, int32 offset, uint8 x);
+uint16 pci_read_cfg_word(int32 bus, int32 devfn, int32 offset);
+void pci_write_cfg_word(int32 bus, int32 devfn, int32 offset, uint16 x);
+uint32 pci_read_cfg_long(int32 bus, int32 devfn, int32 offset);
+void pci_write_cfg_long(int32 bus, int32 devfn, int32 offset, uint32 x);
+
+#define POST_CODE(x) out_byte(0x80, (x))
+
+#endif
diff --git a/roms/u-boot-sam460ex/tools/multiplier/ppcstring.S b/roms/u-boot-sam460ex/tools/multiplier/ppcstring.S
new file mode 100644
index 000000000..7ed43639e
--- /dev/null
+++ b/roms/u-boot-sam460ex/tools/multiplier/ppcstring.S
@@ -0,0 +1,204 @@
+/*
+ * String handling functions for PowerPC.
+ *
+ * Copyright (C) 1996 Paul Mackerras.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#include <ppc_asm.tmpl>
+#include <asm/errno.h>
+
+ .globl strcpy
+strcpy:
+ addi r5,r3,-1
+ addi r4,r4,-1
+1: lbzu r0,1(r4)
+ cmpwi 0,r0,0
+ stbu r0,1(r5)
+ bne 1b
+ blr
+
+ .globl strncpy
+strncpy:
+ cmpwi 0,r5,0
+ beqlr
+ mtctr r5
+ addi r6,r3,-1
+ addi r4,r4,-1
+1: lbzu r0,1(r4)
+ cmpwi 0,r0,0
+ stbu r0,1(r6)
+ bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */
+ blr
+
+ .globl strcat
+strcat:
+ addi r5,r3,-1
+ addi r4,r4,-1
+1: lbzu r0,1(r5)
+ cmpwi 0,r0,0
+ bne 1b
+ addi r5,r5,-1
+1: lbzu r0,1(r4)
+ cmpwi 0,r0,0
+ stbu r0,1(r5)
+ bne 1b
+ blr
+
+ .globl strlen
+strlen:
+ addi r4,r3,-1
+1: lbzu r0,1(r4)
+ cmpwi 0,r0,0
+ bne 1b
+ subf r3,r3,r4
+ blr
+
+ .globl memset
+memset:
+ rlwimi r4,r4,8,16,23
+ rlwimi r4,r4,16,0,15
+ addi r6,r3,-4
+ cmplwi 0,r5,4
+ blt 7f
+ stwu r4,4(r6)
+ beqlr
+ andi. r0,r6,3
+ add r5,r0,r5
+ subf r6,r0,r6
+ rlwinm r0,r5,32-2,2,31
+ mtctr r0
+ bdz 6f
+1: stwu r4,4(r6)
+ bdnz 1b
+6: andi. r5,r5,3
+7: cmpwi 0,r5,0
+ beqlr
+ mtctr r5
+ addi r6,r6,3
+8: stbu r4,1(r6)
+ bdnz 8b
+ blr
+
+ .globl bcopy
+bcopy:
+ mr r6,r3
+ mr r3,r4
+ mr r4,r6
+ b memcpy
+
+ .globl memmove
+memmove:
+ cmplw 0,r3,r4
+ bgt backwards_memcpy
+ /* fall through */
+
+ .globl memcpy
+memcpy:
+ rlwinm. r7,r5,32-3,3,31 /* r0 = r5 >> 3 */
+ addi r6,r3,-4
+ addi r4,r4,-4
+ beq 2f /* if less than 8 bytes to do */
+ andi. r0,r6,3 /* get dest word aligned */
+ mtctr r7
+ bne 5f
+1: lwz r7,4(r4)
+ lwzu r8,8(r4)
+ stw r7,4(r6)
+ stwu r8,8(r6)
+ bdnz 1b
+ andi. r5,r5,7
+2: cmplwi 0,r5,4
+ blt 3f
+ lwzu r0,4(r4)
+ addi r5,r5,-4
+ stwu r0,4(r6)
+3: cmpwi 0,r5,0
+ beqlr
+ mtctr r5
+ addi r4,r4,3
+ addi r6,r6,3
+4: lbzu r0,1(r4)
+ stbu r0,1(r6)
+ bdnz 4b
+ blr
+5: subfic r0,r0,4
+ mtctr r0
+6: lbz r7,4(r4)
+ addi r4,r4,1
+ stb r7,4(r6)
+ addi r6,r6,1
+ bdnz 6b
+ subf r5,r0,r5
+ rlwinm. r7,r5,32-3,3,31
+ beq 2b
+ mtctr r7
+ b 1b
+
+ .globl backwards_memcpy
+backwards_memcpy:
+ rlwinm. r7,r5,32-3,3,31 /* r0 = r5 >> 3 */
+ add r6,r3,r5
+ add r4,r4,r5
+ beq 2f
+ andi. r0,r6,3
+ mtctr r7
+ bne 5f
+1: lwz r7,-4(r4)
+ lwzu r8,-8(r4)
+ stw r7,-4(r6)
+ stwu r8,-8(r6)
+ bdnz 1b
+ andi. r5,r5,7
+2: cmplwi 0,r5,4
+ blt 3f
+ lwzu r0,-4(r4)
+ subi r5,r5,4
+ stwu r0,-4(r6)
+3: cmpwi 0,r5,0
+ beqlr
+ mtctr r5
+4: lbzu r0,-1(r4)
+ stbu r0,-1(r6)
+ bdnz 4b
+ blr
+5: mtctr r0
+6: lbzu r7,-1(r4)
+ stbu r7,-1(r6)
+ bdnz 6b
+ subf r5,r0,r5
+ rlwinm. r7,r5,32-3,3,31
+ beq 2b
+ mtctr r7
+ b 1b
+
+ .globl memcmp
+memcmp:
+ cmpwi 0,r5,0
+ ble- 2f
+ mtctr r5
+ addi r6,r3,-1
+ addi r4,r4,-1
+1: lbzu r3,1(r6)
+ lbzu r0,1(r4)
+ subf. r3,r0,r3
+ bdnzt 2,1b
+ blr
+2: li r3,0
+ blr
+
+ .global memchr
+memchr:
+ cmpwi 0,r5,0
+ ble- 2f
+ mtctr r5
+ addi r3,r3,-1
+1: lbzu r0,1(r3)
+ cmpw 0,r0,r4
+ bdnzf 2,1b
+ beqlr
+2: li r3,0
+ blr
diff --git a/roms/u-boot-sam460ex/tools/multiplier/short_types.h b/roms/u-boot-sam460ex/tools/multiplier/short_types.h
new file mode 100644
index 000000000..22df3c92c
--- /dev/null
+++ b/roms/u-boot-sam460ex/tools/multiplier/short_types.h
@@ -0,0 +1,36 @@
+/*
+ * short type names
+ *
+ * (C) Copyright 2002
+ * Hyperion Entertainment, ThomasF@hyperion-entertainment.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _SHORT_TYPES_H
+#define _SHORT_TYPES_H
+
+typedef unsigned long uint32;
+typedef long int32;
+typedef unsigned short uint16;
+typedef short int16;
+typedef unsigned char uint8;
+typedef signed char int8;
+
+#endif
diff --git a/roms/u-boot-sam460ex/tools/multiplier/string.c b/roms/u-boot-sam460ex/tools/multiplier/string.c
new file mode 100644
index 000000000..954fb01e2
--- /dev/null
+++ b/roms/u-boot-sam460ex/tools/multiplier/string.c
@@ -0,0 +1,340 @@
+/*
+ * linux/lib/string.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+/*
+ * stupid library routines.. The optimized versions should generally be found
+ * as inline code in <asm-xx/string.h>
+ *
+ * These are buggy as well..
+ */
+
+#include <linux/types.h>
+#include <linux/string.h>
+#include <malloc.h>
+
+#define __HAVE_ARCH_BCOPY
+#define __HAVE_ARCH_MEMCMP
+#define __HAVE_ARCH_MEMCPY
+#define __HAVE_ARCH_MEMMOVE
+#define __HAVE_ARCH_MEMSET
+#define __HAVE_ARCH_STRCAT
+#define __HAVE_ARCH_STRCMP
+#define __HAVE_ARCH_STRCPY
+#define __HAVE_ARCH_STRLEN
+#define __HAVE_ARCH_STRNCPY
+
+char * ___strtok = NULL;
+
+#ifndef __HAVE_ARCH_STRCPY
+char * strcpy(char * dest,const char *src)
+{
+ char *tmp = dest;
+
+ while ((*dest++ = *src++) != '\0')
+ /* nothing */;
+ return tmp;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRNCPY
+char * strncpy(char * dest,const char *src,size_t count)
+{
+ char *tmp = dest;
+
+ while (count-- && (*dest++ = *src++) != '\0')
+ /* nothing */;
+
+ return tmp;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRCAT
+char * strcat(char * dest, const char * src)
+{
+ char *tmp = dest;
+
+ while (*dest)
+ dest++;
+ while ((*dest++ = *src++) != '\0')
+ ;
+
+ return tmp;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRNCAT
+char * strncat(char *dest, const char *src, size_t count)
+{
+ char *tmp = dest;
+
+ if (count) {
+ while (*dest)
+ dest++;
+ while ((*dest++ = *src++)) {
+ if (--count == 0) {
+ *dest = '\0';
+ break;
+ }
+ }
+ }
+
+ return tmp;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRCMP
+int strcmp(const char * cs,const char * ct)
+{
+ register signed char __res;
+
+ while (1) {
+ if ((__res = *cs - *ct++) != 0 || !*cs++)
+ break;
+ }
+
+ return __res;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRNCMP
+int strncmp(const char * cs,const char * ct,size_t count)
+{
+ register signed char __res = 0;
+
+ while (count) {
+ if ((__res = *cs - *ct++) != 0 || !*cs++)
+ break;
+ count--;
+ }
+
+ return __res;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRCHR
+char * strchr(const char * s, int c)
+{
+ for(; *s != (char) c; ++s)
+ if (*s == '\0')
+ return NULL;
+ return (char *) s;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRRCHR
+char * strrchr(const char * s, int c)
+{
+ const char *p = s + strlen(s);
+ do {
+ if (*p == (char)c)
+ return (char *)p;
+ } while (--p >= s);
+ return NULL;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRLEN
+size_t strlen(const char * s)
+{
+ const char *sc;
+
+ for (sc = s; *sc != '\0'; ++sc)
+ /* nothing */;
+ return sc - s;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRNLEN
+size_t strnlen(const char * s, size_t count)
+{
+ const char *sc;
+
+ for (sc = s; count-- && *sc != '\0'; ++sc)
+ /* nothing */;
+ return sc - s;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRDUP
+char * strdup(const char *s)
+{
+ char *new;
+
+ if ((s == NULL) ||
+ ((new = malloc (strlen(s) + 1)) == NULL) ) {
+ return NULL;
+ }
+
+ strcpy (new, s);
+ return new;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRSPN
+size_t strspn(const char *s, const char *accept)
+{
+ const char *p;
+ const char *a;
+ size_t count = 0;
+
+ for (p = s; *p != '\0'; ++p) {
+ for (a = accept; *a != '\0'; ++a) {
+ if (*p == *a)
+ break;
+ }
+ if (*a == '\0')
+ return count;
+ ++count;
+ }
+
+ return count;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRPBRK
+char * strpbrk(const char * cs,const char * ct)
+{
+ const char *sc1,*sc2;
+
+ for( sc1 = cs; *sc1 != '\0'; ++sc1) {
+ for( sc2 = ct; *sc2 != '\0'; ++sc2) {
+ if (*sc1 == *sc2)
+ return (char *) sc1;
+ }
+ }
+ return NULL;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRTOK
+char * strtok(char * s,const char * ct)
+{
+ char *sbegin, *send;
+
+ sbegin = s ? s : ___strtok;
+ if (!sbegin) {
+ return NULL;
+ }
+ sbegin += strspn(sbegin,ct);
+ if (*sbegin == '\0') {
+ ___strtok = NULL;
+ return( NULL );
+ }
+ send = strpbrk( sbegin, ct);
+ if (send && *send != '\0')
+ *send++ = '\0';
+ ___strtok = send;
+ return (sbegin);
+}
+#endif
+
+#ifndef __HAVE_ARCH_MEMSET
+void * memset(void * s,char c,size_t count)
+{
+ char *xs = (char *) s;
+
+ while (count--)
+ *xs++ = c;
+
+ return s;
+}
+#endif
+
+#ifndef __HAVE_ARCH_BCOPY
+char * bcopy(const char * src, char * dest, int count)
+{
+ char *tmp = dest;
+
+ while (count--)
+ *tmp++ = *src++;
+
+ return dest;
+}
+#endif
+
+#ifndef __HAVE_ARCH_MEMCPY
+void * memcpy(void * dest,const void *src,size_t count)
+{
+ char *tmp = (char *) dest, *s = (char *) src;
+
+ while (count--)
+ *tmp++ = *s++;
+
+ return dest;
+}
+#endif
+
+#ifndef __HAVE_ARCH_MEMMOVE
+void * memmove(void * dest,const void *src,size_t count)
+{
+ char *tmp, *s;
+
+ if (dest <= src) {
+ tmp = (char *) dest;
+ s = (char *) src;
+ while (count--)
+ *tmp++ = *s++;
+ }
+ else {
+ tmp = (char *) dest + count;
+ s = (char *) src + count;
+ while (count--)
+ *--tmp = *--s;
+ }
+
+ return dest;
+}
+#endif
+
+#ifndef __HAVE_ARCH_MEMCMP
+int memcmp(const void * cs,const void * ct,size_t count)
+{
+ const unsigned char *su1, *su2;
+ signed char res = 0;
+
+ for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
+ if ((res = *su1 - *su2) != 0)
+ break;
+ return res;
+}
+#endif
+
+/*
+ * find the first occurrence of byte 'c', or 1 past the area if none
+ */
+#ifndef __HAVE_ARCH_MEMSCAN
+void * memscan(void * addr, int c, size_t size)
+{
+ unsigned char * p = (unsigned char *) addr;
+
+ while (size) {
+ if (*p == c)
+ return (void *) p;
+ p++;
+ size--;
+ }
+ return (void *) p;
+}
+#endif
+
+#ifndef __HAVE_ARCH_STRSTR
+char * strstr(const char * s1,const char * s2)
+{
+ int l1, l2;
+
+ l2 = strlen(s2);
+ if (!l2)
+ return (char *) s1;
+ l1 = strlen(s1);
+ while (l1 >= l2) {
+ l1--;
+ if (!memcmp(s1,s2,l2))
+ return (char *) s1;
+ s1++;
+ }
+ return NULL;
+}
+#endif
diff --git a/roms/u-boot-sam460ex/tools/multiplier/update.c b/roms/u-boot-sam460ex/tools/multiplier/update.c
new file mode 100644
index 000000000..876889792
--- /dev/null
+++ b/roms/u-boot-sam460ex/tools/multiplier/update.c
@@ -0,0 +1,129 @@
+#include <common.h>
+#include <exports.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+extern unsigned long __dummy;
+
+int do_updater(void);
+
+void _main(void)
+{
+ char *version = getenv("ver");
+
+ if (!version)
+ {
+ printf("\nAttention ! You need first to update U-Boot to version 2010.06.02 !!!\n\n");
+ return;
+ }
+
+ if (strcmp(version,"U-Boot 2010.06.02 (Dec 31 2010 - 11:14:01)") != 0)
+ {
+ printf("\nAttention ! You need first to update U-Boot to version 2010.06.02 !!!\n\n");
+ return;
+ }
+
+ printf("\n------ Sam460ex Hardware Configuration Updater -----\n\n");
+
+ printf("****************************************************\n");
+ printf("* ATTENTION!! PLEASE READ THIS NOTICE CAREFULLY! *\n");
+ printf("****************************************************\n\n");
+ printf("This program will update your Sam460 configuration\n");
+ printf("Do NOT remove the disk, reset the machine, or do\n");
+ printf("anything that might disrupt functionality. If this\n");
+ printf("Program fails, your computer might be unusable, and\n");
+ printf("you will need to return your board for reflashing.\n");
+ printf("If you find this too risky, remove the diskette and\n");
+ printf("switch off your machine now. Otherwise press the \n");
+ printf("SPACE key now to start the process\n\n");
+
+ do
+ {
+ char x;
+ while (!tstc());
+ x = getc();
+ if (x == ' ') break;
+ } while (1);
+
+ int ret = do_updater();
+
+ if (ret == 0)
+ {
+ printf("\nUpdate done. Please remove the cdrom.\n");
+ printf("You can switch off/reset now when the cdrom is removed\n\n");
+
+ while (1);
+ }
+ else
+ {
+ printf("\nUnable to update the hardware configuration\n");
+ printf("Please contact support@acube-systems.com to\n");
+ printf("correct the problem\n\n");
+ }
+}
+
+int do_updater(void)
+{
+ int ii;
+ unsigned char arr[16] = { 0 };
+ unsigned char bkp[16] = { 0 };
+ unsigned char upd[8] = { 0x86, 0x86, 0xb5, 0x19, 0xb9, 0x85, 0x00, 0x00 };
+ bd_t *bd = gd->bd;
+
+ // read 16 bytes of the boot eeprom --------------------------------------
+
+ puts("Now reading hardware configuration registers...\n");
+ i2c_read(0x52, 0x00, 1, &arr, 16);
+ for (ii=0;ii<16;ii++)
+ printf ("%02x ",arr[ii]);
+ puts("\n\n");
+
+ // backup 16 bytes of the boot eeprom ------------------------------------
+
+ puts("Now creating backup... ");
+ i2c_write(0x53, 0x00, 1, &arr, 16);
+ udelay(100000);
+ puts("Done\n");
+
+ // checking backup -------------------------------------------------------
+
+ puts("Checking backup... ");
+ i2c_read(0x53, 0x00, 1, &bkp, 16);
+ udelay(100000);
+ for (ii=0;ii<16;ii++)
+ {
+ if (arr[ii] != bkp[ii]) break;
+ }
+
+ if (ii < 16)
+ {
+ puts("\nUnable to create a backup... abort\n");
+ return 1;
+ }
+ puts("Done\n");
+
+ // change config ---------------------------------------------------------
+
+ puts("Writing new config... ");
+ i2c_write(0x52, 0x00, 1, &upd, 8);
+ puts("Done\n");
+
+ // check new config ------------------------------------------------------
+
+ puts("Checking new config... ");
+ i2c_read(0x52, 0x00, 1, &bkp, 8);
+ udelay(100000);
+ for (ii=0;ii<8;ii++)
+ {
+ if (upd[ii] != bkp[ii]) break;
+ }
+
+ if (ii < 8)
+ {
+ puts("\nError verifing new config... abort\n");
+ return 1;
+ }
+ puts("Done\n");
+
+ return 0;
+}
diff --git a/roms/u-boot-sam460ex/tools/multiplier/utils.c b/roms/u-boot-sam460ex/tools/multiplier/utils.c
new file mode 100644
index 000000000..ef6dd6c15
--- /dev/null
+++ b/roms/u-boot-sam460ex/tools/multiplier/utils.c
@@ -0,0 +1,82 @@
+#include <common.h>
+#include <asm/processor.h>
+#include <linux/ctype.h>
+#include "memio.h"
+
+static __inline__ unsigned long
+get_msr(void)
+{
+ unsigned long msr;
+
+ asm volatile("mfmsr %0" : "=r" (msr) :);
+ return msr;
+}
+
+static __inline__ void
+set_msr(unsigned long msr)
+{
+ asm volatile("mtmsr %0" : : "r" (msr));
+}
+
+static __inline__ unsigned long
+get_dec(void)
+{
+ unsigned long val;
+
+ asm volatile("mfdec %0" : "=r" (val) :);
+ return val;
+}
+
+
+static __inline__ void
+set_dec(unsigned long val)
+{
+ asm volatile("mtdec %0" : : "r" (val));
+}
+
+
+void
+enable_interrupts(void)
+{
+ set_msr (get_msr() | MSR_EE);
+}
+
+/* returns flag if MSR_EE was set before */
+int
+disable_interrupts(void)
+{
+ ulong msr;
+
+ msr = get_msr();
+ set_msr (msr & ~MSR_EE);
+ return ((msr & MSR_EE) != 0);
+}
+
+u8 in8(u32 port)
+{
+ return in_byte(port);
+}
+
+void out8(u32 port, u8 val)
+{
+ out_byte(port, val);
+}
+
+unsigned long in32(u32 port)
+{
+ return in_long(port);
+}
+
+static inline void
+soft_restart(unsigned long addr)
+{
+ /* SRR0 has system reset vector, SRR1 has default MSR value */
+ /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
+
+ __asm__ __volatile__ ("mtspr 26, %0" :: "r" (addr));
+ __asm__ __volatile__ ("li 4, (1 << 6)" ::: "r4");
+ __asm__ __volatile__ ("mtspr 27, 4");
+ __asm__ __volatile__ ("rfi");
+
+ while(1); /* not reached */
+}