From owner-p4-projects@FreeBSD.ORG Sat Feb 16 21:41:43 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7BE5516A46B; Sat, 16 Feb 2008 21:41:43 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40F6116A420 for ; Sat, 16 Feb 2008 21:41:43 +0000 (UTC) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2319613C467 for ; Sat, 16 Feb 2008 21:41:43 +0000 (UTC) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m1GLfhrR048220 for ; Sat, 16 Feb 2008 21:41:43 GMT (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m1GLfgkj048217 for perforce@freebsd.org; Sat, 16 Feb 2008 21:41:42 GMT (envelope-from marcel@freebsd.org) Date: Sat, 16 Feb 2008 21:41:42 GMT Message-Id: <200802162141.m1GLfgkj048217@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Cc: Subject: PERFORCE change 135517 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Feb 2008 21:41:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=135517 Change 135517 by marcel@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 - 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 - .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 - -.if ${MK_UBOOT} != "no" -SUBDIR= uboot -.else -SUBDIR= ofw -.endif +SUBDIR= ofw uboot .include ==== //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@ha addi %r1, %r1, stack@l addi %r1, %r1, (STACK_SIZE - 32) + /* Save U-Boot's r14 and r29 */ + lis %r11, saved_regs@ha + addi %r11, %r11, saved_regs@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@ha + addi %r11, %r11, saved_regs@l + lwz %r14, 0(%r11) + lwz %r29, 4(%r11) + /* Call into u-Boot */ lis %r11, syscall_ptr@ha addi %r11, %r11, syscall_ptr@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