PERFORCE change 135517 for review
Marcel Moolenaar
marcel at FreeBSD.org
Sat Feb 16 13:41:43 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=135517
Change 135517 by marcel at marcel_jnpr on 2008/02/16 21:41:02
Save U-Boot's registers at startup and restore them when
performing a syscall. This way we don't have to compile
code specially to avoid using those registers. Otherwise
we have to encode knowledge of those registers in at least
4 makefiles and introduce a build knob to enable it all.
This does not allow us to build everything with a single
build world.
Affected files ...
.. //depot/projects/e500/lib/libstand/Makefile#7 edit
.. //depot/projects/e500/sys/boot/Makefile#4 edit
.. //depot/projects/e500/sys/boot/ficl/Makefile#5 edit
.. //depot/projects/e500/sys/boot/powerpc/Makefile#5 edit
.. //depot/projects/e500/sys/boot/powerpc/uboot/Makefile#5 edit
.. //depot/projects/e500/sys/boot/powerpc/uboot/start.S#3 edit
.. //depot/projects/e500/sys/boot/uboot/lib/Makefile#6 edit
Differences ...
==== //depot/projects/e500/lib/libstand/Makefile#7 (text+ko) ====
@@ -6,8 +6,6 @@
# quite large.
#
-.include <bsd.own.mk>
-
LIB= stand
NO_PROFILE=
NO_PIC=
@@ -29,9 +27,6 @@
.endif
.if ${MACHINE_ARCH} == "powerpc"
CFLAGS+= -msoft-float -D_STANDALONE
-. if ${MK_UBOOT} != "no"
-CFLAGS+= -ffixed-r14 -ffixed-r29
-. endif
.endif
.if ${MACHINE_ARCH} == "amd64"
CFLAGS+= -m32 -I.
==== //depot/projects/e500/sys/boot/Makefile#4 (text+ko) ====
@@ -13,18 +13,13 @@
.endif
# Build Open Firmware library.
-.if ${MACHINE_ARCH} == "sparc64"
+.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "sparc64"
SUBDIR+= ofw
.endif
+# Build U-Boot library.
.if ${MACHINE_ARCH} == "powerpc"
-. if ${MK_UBOOT} != "no"
-# Build U-Boot library.
SUBDIR+= uboot
-. else
-# Build Open Firmware library.
-SUBDIR+= ofw
-. endif
.endif
# Pick the machine-dependent subdir based on the target architecture.
==== //depot/projects/e500/sys/boot/ficl/Makefile#5 (text+ko) ====
@@ -1,8 +1,6 @@
# $FreeBSD: src/sys/boot/ficl/Makefile,v 1.45 2007/10/15 14:20:24 nyan Exp $
#
-.include <bsd.own.mk>
-
.PATH: ${.CURDIR}/${MACHINE_ARCH:S/amd64/i386/}
BASE_SRCS= dict.c ficl.c fileaccess.c float.c loader.c math64.c \
prefix.c search.c stack.c tools.c vm.c words.c
@@ -19,15 +17,6 @@
.endif
.if ${MACHINE_ARCH} == "powerpc"
CFLAGS+= -msoft-float
-. if ${MK_UBOOT} != "no"
-#
-# Important notice: registers dedicated for U-Boot must NOT be used by the
-# loader code, as we are going to jump between loader(8) and U-Boot code back
-# and forth safely. For PowerPC these are r14 and r29, but always make
-# sure in the U-Boot cpu/{CPU}/config.mk, e.g. cpu/mpc85xx/config.mk
-#
-CFLAGS+= -ffixed-r14 -ffixed-r29
-. endif
.endif
.if ${MACHINE} == "pc98"
CFLAGS+= -Os -DPC98
==== //depot/projects/e500/sys/boot/powerpc/Makefile#5 (text+ko) ====
@@ -1,11 +1,5 @@
# $FreeBSD: src/sys/boot/powerpc/Makefile,v 1.2 2007/12/17 22:19:44 marcel Exp $
-.include <bsd.own.mk>
-
-.if ${MK_UBOOT} != "no"
-SUBDIR= uboot
-.else
-SUBDIR= ofw
-.endif
+SUBDIR= ofw uboot
.include <bsd.subdir.mk>
==== //depot/projects/e500/sys/boot/powerpc/uboot/Makefile#5 (text+ko) ====
@@ -61,13 +61,7 @@
CLEANFILES+= vers.c loader.help
-#
-# Important notice: registers dedicated for U-Boot must NOT be used by the
-# loader code, as we are going to jump between loader(8) and U-Boot code back
-# and forth safely. For PowerPC these are r14 and r29, but always make
-# sure in the U-Boot cpu/{CPU}/config.mk, e.g. cpu/mpc85xx/config.mk
-#
-CFLAGS+= -ffreestanding -ffixed-r14 -ffixed-r29
+CFLAGS+= -ffreestanding
LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.powerpc
==== //depot/projects/e500/sys/boot/powerpc/uboot/start.S#3 (text+ko) ====
@@ -38,17 +38,41 @@
lis %r1, stack at ha
addi %r1, %r1, stack at l
addi %r1, %r1, (STACK_SIZE - 32)
+ /* Save U-Boot's r14 and r29 */
+ lis %r11, saved_regs at ha
+ addi %r11, %r11, saved_regs at l
+ stw %r14, 0(%r11)
+ stw %r29, 4(%r11)
b main
/*
* syscall()
*/
ENTRY(syscall)
+ stwu %r1, -16(%r1)
+ mflr %r0
+ stw %r14, 8(%r1)
+ stw %r29, 12(%r1)
+ stw %r0, 20(%r1)
+ /* Restore U-Boot's r14 and r29 */
+ lis %r11, saved_regs at ha
+ addi %r11, %r11, saved_regs at l
+ lwz %r14, 0(%r11)
+ lwz %r29, 4(%r11)
+ /* Call into u-Boot */
lis %r11, syscall_ptr at ha
addi %r11, %r11, syscall_ptr at l
lwz %r11, 0(%r11)
mtctr %r11
- bctr
+ bctrl
+ /* Epilogue */
+ lwz %r11, 0(%r1)
+ lwz %r0, 4(%r11)
+ mtlr %r0
+ lwz %r14, 8(%r1)
+ lwz %r29, 12(%r1)
+ mr %r1, %r11
+ blr
/*
* Data section
@@ -60,3 +84,7 @@
GLOBAL(syscall_ptr)
.long 0
+GLOBAL(saved_regs)
+ .long 0 /* R14 */
+ .long 0 /* R29 */
+
==== //depot/projects/e500/sys/boot/uboot/lib/Makefile#6 (text+ko) ====
@@ -12,16 +12,6 @@
CFLAGS+= -ffreestanding
-.if ${MACHINE_ARCH} == "powerpc"
-#
-# Important notice: registers dedicated for U-Boot must NOT be used by the
-# loader code, as we are going to jump between loader(8) and U-Boot code back
-# and forth safely. For PowerPC these are r14 and r29, but always make
-# sure in the U-Boot cpu/{CPU}/config.mk, e.g. cpu/mpc85xx/config.mk
-#
-CFLAGS+= -ffixed-r14 -ffixed-r29
-.endif
-
.ifdef(BOOT_DISK_DEBUG)
# Make the disk code more talkative
CFLAGS+= -DDISK_DEBUG
More information about the p4-projects
mailing list