Index: boot/Makefile
===================================================================
--- boot/Makefile	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/Makefile	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -48,5 +48,5 @@
 endif
 ifeq ($(RDFMT),fat)
-	$(MKFAT) $(DIST_PATH) $@
+	$(MKFAT) 1048576 $(DIST_PATH) $@
 endif
 
Index: boot/Makefile.build
===================================================================
--- boot/Makefile.build	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/Makefile.build	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -61,4 +61,11 @@
 	GCC_CFLAGS += -Werror
 	ICC_CFLAGS += -Werror
+endif
+
+ifeq ($(CONFIG_LINE_DEBUG),y)
+	GCC_CFLAGS += -g
+	ICC_CFLAGS += -g
+	SUNCC_CFLAGS += -g
+	CLANG_CFLAGS += -g
 endif
 
Index: boot/arch/arm32/Makefile.inc
===================================================================
--- boot/arch/arm32/Makefile.inc	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/arch/arm32/Makefile.inc	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -55,4 +55,5 @@
 	$(COMPS_C) \
 	genarch/src/division.c \
+	generic/src/memstr.c \
 	generic/src/printf_core.c \
 	generic/src/vprintf.c \
Index: boot/arch/arm32/src/asm.S
===================================================================
--- boot/arch/arm32/src/asm.S	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/arch/arm32/src/asm.S	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -35,5 +35,4 @@
 .global boot_stack
 .global halt
-.global memcpy
 .global jump_to_kernel
 
@@ -55,63 +54,4 @@
 	b halt
 
-memcpy:
-	add r3, r1, #3
-	bic r3, r3, #3
-	cmp r1, r3
-	stmdb sp!, {r4, r5, lr}
-	mov r5, r0
-	beq 4f
-	
-	1:
-		cmp r2, #0
-		movne ip, #0
-		beq 3f
-	
-	2:
-		ldrb r3, [ip, r1]
-		strb r3, [ip, r0]
-		add ip, ip, #1
-		cmp ip, r2
-		bne 2b
-	
-	3:
-		mov r0, r5
-		ldmia sp!, {r4, r5, pc}
-	
-	4:
-		add r3, r0, #3
-		bic r3, r3, #3
-		cmp r0, r3
-		bne 1b
-		movs r4, r2, lsr #2
-		moveq lr, r4
-		beq 6f
-		mov lr, #0
-		mov ip, lr
-	
-	5:
-		ldr r3, [ip, r1]
-		add lr, lr, #1
-		cmp lr, r4
-		str r3, [ip, r0]
-		add ip, ip, #4
-		bne 5b
-	
-	6:
-		ands r4, r2, #3
-		beq 3b
-		mov r3, lr, lsl #2
-		add r0, r3, r0
-		add ip, r3, r1
-		mov r2, #0
-	
-	7:
-		ldrb r3, [r2, ip]
-		strb r3, [r2, r0]
-		add r2, r2, #1
-		cmp r2, r4
-		bne 7b
-		b 3b
-
 jump_to_kernel:
 	#
Index: boot/arch/ia64/Makefile.inc
===================================================================
--- boot/arch/ia64/Makefile.inc	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/arch/ia64/Makefile.inc	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -49,4 +49,5 @@
 	genarch/src/division.c \
 	generic/src/balloc.c \
+	generic/src/memstr.c \
 	generic/src/printf_core.c \
 	generic/src/vprintf.c \
Index: boot/arch/ia64/src/asm.S
===================================================================
--- boot/arch/ia64/src/asm.S	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/arch/ia64/src/asm.S	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -1,5 +1,5 @@
 #
 # Copyright (c) 2006 Martin Decky
-# Copyright (c) 2006 Jakub Jermar 
+# Copyright (c) 2006 Jakub Jermar
 # All rights reserved.
 #
@@ -39,76 +39,4 @@
 	br halt
 
-memcpy:
-	alloc loc0 = ar.pfs, 3, 1, 0, 0
-
-	adds r14 = 7, in1
-	mov r2 = ar.lc
-	mov r8 = in0 ;;
-	and r14 = -8, r14 ;;
-	cmp.ne p6, p7 = r14, in1
-(p7)	br.cond.dpnt 3f ;;
-0:
-	cmp.ne p6, p7 = 0, in2
-(p7)	br.cond.dpnt 2f ;;
-(p6)	adds r14 = -1, in2
-(p6)	mov r16 = r0
-(p6)	mov r17 = r0 ;;
-(p6)	mov ar.lc = r14
-1:
-	add r14 = r16, in1 
-	add r15 = r16, in0
-	adds r17 = 1, r17 ;;
-	ld1 r14 = [r14]
-	mov r16 = r17 ;;
-	st1 [r15] = r14
-	br.cloop.sptk.few 1b ;;
-2:
-	mov ar.lc = r2
-	mov ar.pfs = loc0
-	br.ret.sptk.many rp
-3:
-	adds r14 = 7, in0 ;;
-	and r14 = -8, r14 ;;
-	cmp.eq p6, p7 = r14, in0
-(p7)	br.cond.dptk 0b
-	shr.u r18 = in2, 3 ;;
-	cmp.ne p6, p7 = 0, r18
-(p7)	br.cond.dpnt 5f	;;
-(p6)	adds r14 = -1, r18
-(p6)	mov r16 = r0
-(p6)	mov r17 = r0 ;;
-(p6)	mov ar.lc = r14
-4:
-	shladd r14 = r16, 3, r0
-	adds r16 = 1, r17 ;;
-	add r15 = in1, r14
-	add r14 = in0, r14
-	mov r17 = r16 ;;
-	ld8 r15 = [r15] ;;
-	st8 [r14] = r15
-	br.cloop.sptk.few 4b
-5:
-	and r15 = 7, in2
-	shladd r14 = r18, 3, r0
-	mov r16 = r0
-	mov r18 = r0 ;;
-	cmp.eq p6, p7 = 0, r15
-	add in0 = r14, in0
-	adds r15 = -1, r15
-	add r17 = r14, in1 
-(p6)	br.cond.dpnt 2b ;;
-	mov ar.lc = r15
-6:
-	add r14 = r16, r17
-	add r15 = r16, in0
-	adds r16 = 1, r18 ;;
-	ld1 r14 = [r14]
-	mov r18 = r16 ;;
-	st1 [r15] = r14
-	br.cloop.sptk.few 6b ;;
-	mov ar.lc = r2
-	mov ar.pfs = loc0
-	br.ret.sptk.many rp
-
 jump_to_kernel:
 	alloc loc0 = ar.pfs, 1, 1, 0, 0
Index: boot/arch/mips32/Makefile.inc
===================================================================
--- boot/arch/mips32/Makefile.inc	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/arch/mips32/Makefile.inc	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -61,4 +61,5 @@
 	genarch/src/division.c \
 	genarch/src/multiplication.c \
+	generic/src/memstr.c \
 	generic/src/printf_core.c \
 	generic/src/vprintf.c \
Index: boot/arch/mips32/src/asm.S
===================================================================
--- boot/arch/mips32/src/asm.S	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/arch/mips32/src/asm.S	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -36,5 +36,4 @@
 .global start
 .global halt
-.global memcpy
 .global jump_to_kernel
 
@@ -127,70 +126,4 @@
 	nop
 
-memcpy:
-	addiu $v0, $a1, 3
-	li $v1, -4
-	and $v0, $v0, $v1
-	beq $a1, $v0, 3f
-	move $t0, $a0
-	move $t2, $a0
-	
-	0:
-		beq $a2, $zero, 2f
-		move $a3, $zero
-	
-	1:
-		addu $v0, $a1, $a3
-		lbu $a0, 0($v0)
-		addu $v1, $t0, $a3
-		addiu $a3, $a3, 1
-		bne $a3, $a2, 1b
-		sb $a0, 0($v1)
-	
-	2:
-		jr $ra
-		move $v0, $t2
-	
-	3:
-		addiu $v0, $a0, 3
-		and $v0, $v0, $v1
-		bne $a0, $v0, 0b
-		srl $t1, $a2, 2
-		
-		beq $t1, $zero, 5f
-		move $a3, $zero
-		
-		move $a3, $zero
-		move $a0, $zero
-	
-	4:
-		addu $v0, $a1, $a0
-		lw $v1, 0($v0)
-		addiu $a3, $a3, 1
-		addu $v0, $t0, $a0
-		sw $v1, 0($v0)
-		bne $a3, $t1, 4b
-		addiu $a0, $a0, 4
-	
-	5:
-		andi $a2, $a2, 0x3
-		beq $a2, $zero, 2b
-		nop
-		
-		sll $v0, $a3, 2
-		addu $t1, $v0, $t0
-		move $a3, $zero
-		addu $t0, $v0, $a1
-	
-	6:
-		addu $v0, $t0, $a3
-		lbu $a0, 0($v0)
-		addu $v1, $t1, $a3
-		addiu $a3, $a3, 1
-		bne $a3, $a2, 6b
-		sb $a0, 0($v1)
-		
-		jr $ra
-		move $v0, $t2
-
 jump_to_kernel:
 	#
Index: boot/arch/ppc32/Makefile.inc
===================================================================
--- boot/arch/ppc32/Makefile.inc	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/arch/ppc32/Makefile.inc	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -56,4 +56,5 @@
 	genarch/src/multiplication.c \
 	generic/src/balloc.c \
+	generic/src/memstr.c \
 	generic/src/printf_core.c \
 	generic/src/vprintf.c \
Index: boot/arch/ppc32/src/asm.S
===================================================================
--- boot/arch/ppc32/src/asm.S	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/arch/ppc32/src/asm.S	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -60,5 +60,4 @@
 .global start
 .global halt
-.global memcpy
 .global jump_to_kernel
 .global real_mode
@@ -78,60 +77,4 @@
 halt:
 	b halt
-
-memcpy:
-	srwi. r7, r5, 3
-	addi r6, r3, -4
-	addi r4, r4, -4
-	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)
-		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
 
 jump_to_kernel:
Index: boot/arch/sparc64/Makefile.inc
===================================================================
--- boot/arch/sparc64/Makefile.inc	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/arch/sparc64/Makefile.inc	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -54,4 +54,5 @@
 	genarch/src/ofw_tree.c \
 	generic/src/balloc.c \
+	generic/src/memstr.c \
 	generic/src/printf_core.c \
 	generic/src/vprintf.c \
Index: boot/arch/sparc64/src/asm.S
===================================================================
--- boot/arch/sparc64/src/asm.S	(revision 527298a2333d7b6963d6547e3f3c42f0bea1e8af)
+++ boot/arch/sparc64/src/asm.S	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -42,5 +42,4 @@
 .global start
 .global halt
-.global memcpy
 .global jump_to_kernel
 
@@ -98,73 +97,4 @@
 	ba %xcc, halt
 	nop
-
-memcpy:
-	! Save dst
-	
-	mov %o0, %o3
-	add %o1, 7, %g1
-	and %g1, -8, %g1
-	cmp %o1, %g1
-	be,pn %xcc, 3f
-	add %o0, 7, %g1
-	mov 0, %g3
-	
-	0:
-		brz,pn %o2, 2f
-		mov 0, %g2
-	
-	1:
-		ldub [%g3 + %o1], %g1
-		add %g2, 1, %g2
-		cmp %o2, %g2
-		stb %g1, [%g3 + %o0]
-		bne,pt %xcc, 1b
-		mov %g2, %g3
-	
-	2:
-		! Exit point
-		
-		jmp %o7 + 8
-		mov %o3, %o0
-	
-	3:
-		and %g1, -8, %g1
-		cmp %o0, %g1
-		bne,pt %xcc, 0b
-		mov 0, %g3
-		srlx %o2, 3, %g4
-		brz,pn %g4, 5f
-		mov 0, %g5
-	
-	4:
-		sllx %g3, 3, %g2
-		add %g5, 1, %g3
-		ldx [%o1 + %g2], %g1
-		mov %g3, %g5
-		cmp %g4, %g3
-		bne,pt %xcc, 4b
-		stx %g1, [%o0 + %g2]
-	
-	5:
-		and %o2, 7, %o2
-		brz,pn %o2, 2b
-		sllx %g4, 3, %g1
-		mov 0, %g2
-		add %g1, %o0, %o0
-		add %g1, %o1, %g4
-		mov 0, %g3
-	
-	6:
-		ldub [%g2 + %g4], %g1
-		stb %g1, [%g2 + %o0]
-		add %g3, 1, %g2
-		cmp %o2, %g2
-		bne,pt %xcc, 6b
-		mov %g2, %g3
-	
-	! Exit point
-	
-	jmp %o7 + 8
-	mov %o3, %o0
 
 jump_to_kernel:
Index: boot/generic/src/memstr.c
===================================================================
--- boot/generic/src/memstr.c	(revision 2fa10f640409c06070df4329491173719b3e824c)
+++ boot/generic/src/memstr.c	(revision 2fa10f640409c06070df4329491173719b3e824c)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <memstr.h>
+#include <typedefs.h>
+
+/** Copy block of memory.
+ *
+ * Copy cnt bytes from src address to dst address.The source and destination
+ * memory areas cannot overlap.
+ *
+ * @param src		Source address to copy from.
+ * @param dst		Destination address to copy to.
+ * @param cnt		Number of bytes to copy.
+ *
+ * @return		Destination address.
+ */
+void *memcpy(void *dst, const void *src, size_t cnt)
+{
+	size_t i;
+
+	for (i = 0; i < cnt; i++)
+		((uint8_t *) dst)[i] = ((uint8_t *) src)[i];
+
+	return dst;
+}
+
+/** @}
+ */
