svn commit: r209975 - in head: . sys/conf sys/powerpc/aim sys/powerpc/booke sys/powerpc/conf sys/powerpc/cpufreq sys/powerpc/include sys/powerpc/powerpc

Nathan Whitehorn nwhitehorn at FreeBSD.org
Tue Jul 13 05:32:20 UTC 2010


Author: nwhitehorn
Date: Tue Jul 13 05:32:19 2010
New Revision: 209975
URL: http://svn.freebsd.org/changeset/base/209975

Log:
  MFppc64:
  
  Kernel sources for 64-bit PowerPC, along with build-system changes to keep
  32-bit kernels compiling (build system changes for 64-bit kernels are
  coming later). Existing 32-bit PowerPC kernel configurations must be
  updated after this change to specify their architecture.

Added:
  head/sys/powerpc/aim/locore32.S
     - copied, changed from r209910, head/sys/powerpc/aim/locore.S
  head/sys/powerpc/aim/locore64.S
     - copied, changed from r209910, head/sys/powerpc/aim/locore.S
  head/sys/powerpc/aim/slb.c   (contents, props changed)
  head/sys/powerpc/aim/swtch32.S
     - copied, changed from r209910, head/sys/powerpc/aim/swtch.S
  head/sys/powerpc/aim/swtch64.S
     - copied, changed from r209910, head/sys/powerpc/aim/swtch.S
  head/sys/powerpc/aim/trap_subr32.S
     - copied, changed from r209910, head/sys/powerpc/aim/trap_subr.S
  head/sys/powerpc/aim/trap_subr64.S
     - copied, changed from r209910, head/sys/powerpc/aim/trap_subr.S
  head/sys/powerpc/include/slb.h   (contents, props changed)
  head/sys/powerpc/powerpc/elf32_machdep.c
     - copied, changed from r209910, head/sys/powerpc/powerpc/elf_machdep.c
  head/sys/powerpc/powerpc/elf64_machdep.c
     - copied, changed from r209910, head/sys/powerpc/powerpc/elf_machdep.c
  head/sys/powerpc/powerpc/sigcode32.S
     - copied, changed from r209910, head/sys/powerpc/powerpc/sigcode.S
  head/sys/powerpc/powerpc/sigcode64.S
     - copied, changed from r209910, head/sys/powerpc/powerpc/sigcode.S
Deleted:
  head/sys/powerpc/aim/swtch.S
  head/sys/powerpc/powerpc/elf_machdep.c
  head/sys/powerpc/powerpc/sigcode.S
Modified:
  head/UPDATING
  head/sys/conf/Makefile.powerpc
  head/sys/conf/files.powerpc
  head/sys/conf/options.powerpc
  head/sys/powerpc/aim/copyinout.c
  head/sys/powerpc/aim/locore.S
  head/sys/powerpc/aim/machdep.c
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/mp_cpudep.c
  head/sys/powerpc/aim/ofw_machdep.c
  head/sys/powerpc/aim/trap.c
  head/sys/powerpc/aim/vm_machdep.c
  head/sys/powerpc/booke/locore.S
  head/sys/powerpc/booke/machdep.c
  head/sys/powerpc/booke/swtch.S
  head/sys/powerpc/booke/vm_machdep.c
  head/sys/powerpc/conf/DEFAULTS
  head/sys/powerpc/conf/GENERIC
  head/sys/powerpc/conf/MPC85XX
  head/sys/powerpc/conf/NOTES
  head/sys/powerpc/cpufreq/pcr.c
  head/sys/powerpc/include/_align.h
  head/sys/powerpc/include/_bus.h
  head/sys/powerpc/include/_inttypes.h
  head/sys/powerpc/include/_limits.h
  head/sys/powerpc/include/_stdint.h
  head/sys/powerpc/include/_types.h
  head/sys/powerpc/include/asm.h
  head/sys/powerpc/include/atomic.h
  head/sys/powerpc/include/bus.h
  head/sys/powerpc/include/cpufunc.h
  head/sys/powerpc/include/db_machdep.h
  head/sys/powerpc/include/frame.h
  head/sys/powerpc/include/hid.h
  head/sys/powerpc/include/md_var.h
  head/sys/powerpc/include/param.h
  head/sys/powerpc/include/pcb.h
  head/sys/powerpc/include/pcpu.h
  head/sys/powerpc/include/pmap.h
  head/sys/powerpc/include/proc.h
  head/sys/powerpc/include/profile.h
  head/sys/powerpc/include/psl.h
  head/sys/powerpc/include/pte.h
  head/sys/powerpc/include/reg.h
  head/sys/powerpc/include/runq.h
  head/sys/powerpc/include/smp.h
  head/sys/powerpc/include/spr.h
  head/sys/powerpc/include/sr.h
  head/sys/powerpc/include/trap_aim.h
  head/sys/powerpc/include/ucontext.h
  head/sys/powerpc/include/vmparam.h
  head/sys/powerpc/powerpc/cpu.c
  head/sys/powerpc/powerpc/db_interface.c
  head/sys/powerpc/powerpc/db_trace.c
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/powerpc/powerpc/genassym.c
  head/sys/powerpc/powerpc/in_cksum.c
  head/sys/powerpc/powerpc/mp_machdep.c
  head/sys/powerpc/powerpc/setjmp.S
  head/sys/powerpc/powerpc/stack_machdep.c
  head/sys/powerpc/powerpc/syncicache.c
  head/sys/powerpc/powerpc/sys_machdep.c

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Tue Jul 13 05:12:14 2010	(r209974)
+++ head/UPDATING	Tue Jul 13 05:32:19 2010	(r209975)
@@ -24,6 +24,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.
 
 
 20100713:
+	Due to the import of powerpc64 support, all existing powerpc kernel
+	configuration files must be updated with a machine directive like this:
+	    machine powerpc powerpc
+
+	In addition, an updated config(8) is required to build powerpc kernels
+	after this change.
+
+20100713:
 	A new version of ZFS (version 15) has been merged to -HEAD.
 	This version uses a python library for the following subcommands:
 	zfs allow, zfs unallow, zfs groupspace, zfs userspace.

Modified: head/sys/conf/Makefile.powerpc
==============================================================================
--- head/sys/conf/Makefile.powerpc	Tue Jul 13 05:12:14 2010	(r209974)
+++ head/sys/conf/Makefile.powerpc	Tue Jul 13 05:32:19 2010	(r209975)
@@ -17,7 +17,7 @@
 #
 
 # Which version of config(8) is required.
-%VERSREQ=	600004
+%VERSREQ=	600010
 
 STD8X16FONT?=	iso
 
@@ -28,6 +28,9 @@ S=	./@
 S=	../../..
 .endif
 .endif
+
+LDSCRIPT_NAME?= ldscript.${MACHINE_ARCH}
+
 .include "$S/conf/kern.pre.mk"
 
 INCLUDES+= -I$S/contrib/libfdt

Modified: head/sys/conf/files.powerpc
==============================================================================
--- head/sys/conf/files.powerpc	Tue Jul 13 05:12:14 2010	(r209974)
+++ head/sys/conf/files.powerpc	Tue Jul 13 05:32:19 2010	(r209975)
@@ -36,7 +36,7 @@ dev/ofw/ofw_console.c		optional	aim
 dev/ofw/ofw_disk.c		optional	ofwd aim
 dev/ofw/ofw_fdt.c		optional	fdt
 dev/ofw/ofw_iicbus.c		optional	iicbus aim
-dev/ofw/ofw_standard.c		optional	aim
+dev/ofw/ofw_standard.c		optional	aim powerpc
 dev/powermac_nvram/powermac_nvram.c optional	powermac_nvram powermac
 dev/quicc/quicc_bfe_fdt.c	optional	quicc mpc85xx
 dev/scc/scc_bfe_macio.c		optional	scc powermac
@@ -53,37 +53,39 @@ dev/tsec/if_tsec.c		optional	tsec
 dev/tsec/if_tsec_fdt.c		optional	tsec fdt
 dev/uart/uart_cpu_powerpc.c	optional	uart aim
 kern/syscalls.c			optional	ktr
-libkern/ashldi3.c		standard
-libkern/ashrdi3.c		standard
+libkern/ashldi3.c		optional	powerpc
+libkern/ashrdi3.c		optional	powerpc
 libkern/bcmp.c			standard
-libkern/cmpdi2.c		standard
-libkern/divdi3.c		standard
+libkern/cmpdi2.c		optional	powerpc
+libkern/divdi3.c		optional	powerpc
 libkern/ffs.c			standard
 libkern/ffsl.c			standard
 libkern/fls.c			standard
 libkern/flsl.c			standard
-libkern/lshrdi3.c		standard
+libkern/lshrdi3.c		optional	powerpc
 libkern/memchr.c		optional	fdt
 libkern/memmove.c		standard
 libkern/memset.c		standard
-libkern/moddi3.c		standard
-libkern/qdivrem.c		standard
-libkern/ucmpdi2.c		standard
-libkern/udivdi3.c		standard
-libkern/umoddi3.c		standard
+libkern/moddi3.c		optional	powerpc
+libkern/qdivrem.c		optional	powerpc
+libkern/ucmpdi2.c		optional	powerpc
+libkern/udivdi3.c		optional	powerpc
+libkern/umoddi3.c		optional	powerpc
 powerpc/aim/clock.c		optional	aim
 powerpc/aim/copyinout.c		optional	aim
 powerpc/aim/interrupt.c		optional	aim
 powerpc/aim/locore.S		optional	aim no-obj
 powerpc/aim/machdep.c		optional	aim
-powerpc/aim/mmu_oea.c		optional	aim
+powerpc/aim/mmu_oea.c		optional	aim powerpc
 powerpc/aim/mmu_oea64.c		optional	aim
 powerpc/aim/mp_cpudep.c		optional	aim smp
 powerpc/aim/nexus.c		optional	aim
 powerpc/aim/ofw_machdep.c	optional	aim
 powerpc/aim/ofwmagic.S		optional	aim
 powerpc/aim/platform_chrp.c	optional	aim
-powerpc/aim/swtch.S		optional	aim
+powerpc/aim/slb.c		optional	aim powerpc64
+powerpc/aim/swtch32.S		optional	aim powerpc
+powerpc/aim/swtch64.S		optional	aim powerpc64
 powerpc/aim/trap.c		optional	aim
 powerpc/aim/uma_machdep.c	optional	aim
 powerpc/aim/vm_machdep.c	optional	aim
@@ -156,7 +158,8 @@ powerpc/powerpc/db_hwwatch.c	optional	dd
 powerpc/powerpc/db_interface.c	optional	ddb
 powerpc/powerpc/db_trace.c	optional	ddb
 powerpc/powerpc/dump_machdep.c	standard
-powerpc/powerpc/elf_machdep.c	standard
+powerpc/powerpc/elf32_machdep.c	optional	powerpc | compat_freebsd32
+powerpc/powerpc/elf64_machdep.c	optional	powerpc64
 powerpc/powerpc/exec_machdep.c	standard
 powerpc/powerpc/fpu.c		optional	aim
 powerpc/powerpc/fuswintr.c	standard
@@ -173,7 +176,8 @@ powerpc/powerpc/platform.c	standard
 powerpc/powerpc/platform_if.m	standard
 powerpc/powerpc/sc_machdep.c	optional	sc
 powerpc/powerpc/setjmp.S	standard
-powerpc/powerpc/sigcode.S	standard
+powerpc/powerpc/sigcode32.S	optional	powerpc | compat_freebsd32
+powerpc/powerpc/sigcode64.S	optional	powerpc64
 powerpc/powerpc/stack_machdep.c	optional	ddb | stack
 powerpc/powerpc/suswintr.c	standard
 powerpc/powerpc/syncicache.c	standard
@@ -183,3 +187,10 @@ powerpc/psim/iobus.c 		optional	psim
 powerpc/psim/ata_iobus.c	optional	ata psim
 powerpc/psim/openpic_iobus.c	optional	psim
 powerpc/psim/uart_iobus.c	optional	uart psim
+
+compat/freebsd32/freebsd32_ioctl.c	optional	compat_freebsd32
+compat/freebsd32/freebsd32_misc.c	optional	compat_freebsd32
+compat/freebsd32/freebsd32_syscalls.c	optional	compat_freebsd32
+compat/freebsd32/freebsd32_sysent.c	optional	compat_freebsd32
+kern/imgact_elf32.c			optional	compat_freebsd32
+

Modified: head/sys/conf/options.powerpc
==============================================================================
--- head/sys/conf/options.powerpc	Tue Jul 13 05:12:14 2010	(r209974)
+++ head/sys/conf/options.powerpc	Tue Jul 13 05:32:19 2010	(r209975)
@@ -4,8 +4,13 @@
 AIM			opt_global.h
 E500			opt_global.h
 
+POWERPC
+POWERPC64
+
 FPU_EMU
 
+COMPAT_FREEBSD32	opt_compat.h
+
 GFB_DEBUG		opt_gfb.h
 GFB_NO_FONT_LOADING	opt_gfb.h
 GFB_NO_MODE_CHANGE	opt_gfb.h

Modified: head/sys/powerpc/aim/copyinout.c
==============================================================================
--- head/sys/powerpc/aim/copyinout.c	Tue Jul 13 05:12:14 2010	(r209974)
+++ head/sys/powerpc/aim/copyinout.c	Tue Jul 13 05:32:19 2010	(r209975)
@@ -57,6 +57,8 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
 
@@ -66,20 +68,45 @@ __FBSDID("$FreeBSD$");
 
 #include <machine/pcb.h>
 #include <machine/sr.h>
+#include <machine/slb.h>
 
 int	setfault(faultbuf);	/* defined in locore.S */
 
 /*
  * Makes sure that the right segment of userspace is mapped in.
  */
+
+#ifdef __powerpc64__
+static __inline void
+set_user_sr(pmap_t pm, const void *addr)
+{
+	register_t esid, vsid, slb1, slb2;
+
+	esid = USER_ADDR >> ADDR_SR_SHFT;
+	PMAP_LOCK(pm);
+	vsid = va_to_vsid(pm, (vm_offset_t)addr);
+	PMAP_UNLOCK(pm);
+
+	slb1 = vsid << SLBV_VSID_SHIFT;
+	slb2 = (esid << SLBE_ESID_SHIFT) | SLBE_VALID | USER_SR;
+
+	__asm __volatile ("slbie %0; slbmte %1, %2" :: "r"(esid << 28),
+	    "r"(slb1), "r"(slb2));
+	isync();
+}
+#else
 static __inline void
-set_user_sr(register_t vsid)
+set_user_sr(pmap_t pm, const void *addr)
 {
+	register_t vsid;
+
+	vsid = va_to_vsid(pm, (vm_offset_t)addr);
 
 	isync();
 	__asm __volatile ("mtsr %0,%1" :: "n"(USER_SR), "r"(vsid));
 	isync();
 }
+#endif
 
 int
 copyout(const void *kaddr, void *udaddr, size_t len)
@@ -103,13 +130,13 @@ copyout(const void *kaddr, void *udaddr,
 	up = udaddr;
 
 	while (len > 0) {
-		p = (char *)USER_ADDR + ((u_int)up & ~SEGMENT_MASK);
+		p = (char *)USER_ADDR + ((uintptr_t)up & ~SEGMENT_MASK);
 
 		l = ((char *)USER_ADDR + SEGMENT_LENGTH) - p;
 		if (l > len)
 			l = len;
 
-		set_user_sr(pm->pm_sr[(u_int)up >> ADDR_SR_SHFT]);
+		set_user_sr(pm,up);
 
 		bcopy(kp, p, l);
 
@@ -144,13 +171,13 @@ copyin(const void *udaddr, void *kaddr, 
 	up = udaddr;
 
 	while (len > 0) {
-		p = (char *)USER_ADDR + ((u_int)up & ~SEGMENT_MASK);
+		p = (char *)USER_ADDR + ((uintptr_t)up & ~SEGMENT_MASK);
 
 		l = ((char *)USER_ADDR + SEGMENT_LENGTH) - p;
 		if (l > len)
 			l = len;
 
-		set_user_sr(pm->pm_sr[(u_int)up >> ADDR_SR_SHFT]);
+		set_user_sr(pm,up);
 
 		bcopy(p, kp, l);
 
@@ -218,14 +245,14 @@ subyte(void *addr, int byte)
 
 	td = PCPU_GET(curthread);
 	pm = &td->td_proc->p_vmspace->vm_pmap;
-	p = (char *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK));
+	p = (char *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK));
 
 	if (setfault(env)) {
 		td->td_pcb->pcb_onfault = NULL;
 		return (-1);
 	}
 
-	set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]);
+	set_user_sr(pm,addr);
 
 	*p = (char)byte;
 
@@ -233,6 +260,33 @@ subyte(void *addr, int byte)
 	return (0);
 }
 
+#ifdef __powerpc64__
+int
+suword32(void *addr, int word)
+{
+	struct		thread *td;
+	pmap_t		pm;
+	faultbuf	env;
+	int		*p;
+
+	td = PCPU_GET(curthread);
+	pm = &td->td_proc->p_vmspace->vm_pmap;
+	p = (int *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK));
+
+	if (setfault(env)) {
+		td->td_pcb->pcb_onfault = NULL;
+		return (-1);
+	}
+
+	set_user_sr(pm,addr);
+
+	*p = word;
+
+	td->td_pcb->pcb_onfault = NULL;
+	return (0);
+}
+#endif
+
 int
 suword(void *addr, long word)
 {
@@ -243,14 +297,14 @@ suword(void *addr, long word)
 
 	td = PCPU_GET(curthread);
 	pm = &td->td_proc->p_vmspace->vm_pmap;
-	p = (long *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK));
+	p = (long *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK));
 
 	if (setfault(env)) {
 		td->td_pcb->pcb_onfault = NULL;
 		return (-1);
 	}
 
-	set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]);
+	set_user_sr(pm,addr);
 
 	*p = word;
 
@@ -258,12 +312,19 @@ suword(void *addr, long word)
 	return (0);
 }
 
+#ifdef __powerpc64__
+int
+suword64(void *addr, int64_t word)
+{
+	return (suword(addr, (long)word));
+}
+#else
 int
 suword32(void *addr, int32_t word)
 {
 	return (suword(addr, (long)word));
 }
-
+#endif
 
 int
 fubyte(const void *addr)
@@ -276,20 +337,47 @@ fubyte(const void *addr)
 
 	td = PCPU_GET(curthread);
 	pm = &td->td_proc->p_vmspace->vm_pmap;
-	p = (u_char *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK));
+	p = (u_char *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK));
+
+	if (setfault(env)) {
+		td->td_pcb->pcb_onfault = NULL;
+		return (-1);
+	}
+
+	set_user_sr(pm,addr);
+
+	val = *p;
+
+	td->td_pcb->pcb_onfault = NULL;
+	return (val);
+}
+
+#ifdef __powerpc64__
+int32_t
+fuword32(const void *addr)
+{
+	struct		thread *td;
+	pmap_t		pm;
+	faultbuf	env;
+	int32_t		*p, val;
+
+	td = PCPU_GET(curthread);
+	pm = &td->td_proc->p_vmspace->vm_pmap;
+	p = (int32_t *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK));
 
 	if (setfault(env)) {
 		td->td_pcb->pcb_onfault = NULL;
 		return (-1);
 	}
 
-	set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]);
+	set_user_sr(pm,addr);
 
 	val = *p;
 
 	td->td_pcb->pcb_onfault = NULL;
 	return (val);
 }
+#endif
 
 long
 fuword(const void *addr)
@@ -301,14 +389,14 @@ fuword(const void *addr)
 
 	td = PCPU_GET(curthread);
 	pm = &td->td_proc->p_vmspace->vm_pmap;
-	p = (long *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK));
+	p = (long *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK));
 
 	if (setfault(env)) {
 		td->td_pcb->pcb_onfault = NULL;
 		return (-1);
 	}
 
-	set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]);
+	set_user_sr(pm,addr);
 
 	val = *p;
 
@@ -316,18 +404,59 @@ fuword(const void *addr)
 	return (val);
 }
 
+#ifndef __powerpc64__
 int32_t
 fuword32(const void *addr)
 {
 	return ((int32_t)fuword(addr));
 }
+#endif
 
 uint32_t
-casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval)
+casuword32(volatile uint32_t *addr, uint32_t old, uint32_t new)
 {
-	return (casuword((volatile u_long *)base, oldval, newval));
+	struct thread *td;
+	pmap_t pm;
+	faultbuf env;
+	uint32_t *p, val;
+
+	td = PCPU_GET(curthread);
+	pm = &td->td_proc->p_vmspace->vm_pmap;
+	p = (uint32_t *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK));
+
+	set_user_sr(pm,(const void *)(vm_offset_t)addr);
+
+	if (setfault(env)) {
+		td->td_pcb->pcb_onfault = NULL;
+		return (-1);
+	}
+
+	__asm __volatile (
+		"1:\tlwarx %0, 0, %2\n\t"	/* load old value */
+		"cmplw %3, %0\n\t"		/* compare */
+		"bne 2f\n\t"			/* exit if not equal */
+		"stwcx. %4, 0, %2\n\t"      	/* attempt to store */
+		"bne- 1b\n\t"			/* spin if failed */
+		"b 3f\n\t"			/* we've succeeded */
+		"2:\n\t"
+		"stwcx. %0, 0, %2\n\t"       	/* clear reservation (74xx) */
+		"3:\n\t"
+		: "=&r" (val), "=m" (*p)
+		: "r" (p), "r" (old), "r" (new), "m" (*p)
+		: "cc", "memory");
+
+	td->td_pcb->pcb_onfault = NULL;
+
+	return (val);
 }
 
+#ifndef __powerpc64__
+u_long
+casuword(volatile u_long *addr, u_long old, u_long new)
+{
+	return (casuword32((volatile uint32_t *)addr, old, new));
+}
+#else
 u_long
 casuword(volatile u_long *addr, u_long old, u_long new)
 {
@@ -338,9 +467,9 @@ casuword(volatile u_long *addr, u_long o
 
 	td = PCPU_GET(curthread);
 	pm = &td->td_proc->p_vmspace->vm_pmap;
-	p = (u_long *)((u_int)USER_ADDR + ((u_int)addr & ~SEGMENT_MASK));
+	p = (u_long *)(USER_ADDR + ((uintptr_t)addr & ~SEGMENT_MASK));
 
-	set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]);
+	set_user_sr(pm,(const void *)(vm_offset_t)addr);
 
 	if (setfault(env)) {
 		td->td_pcb->pcb_onfault = NULL;
@@ -348,14 +477,14 @@ casuword(volatile u_long *addr, u_long o
 	}
 
 	__asm __volatile (
-		"1:\tlwarx %0, 0, %2\n\t"	/* load old value */
-		"cmplw %3, %0\n\t"		/* compare */
+		"1:\tldarx %0, 0, %2\n\t"	/* load old value */
+		"cmpld %3, %0\n\t"		/* compare */
 		"bne 2f\n\t"			/* exit if not equal */
-		"stwcx. %4, 0, %2\n\t"      	/* attempt to store */
+		"stdcx. %4, 0, %2\n\t"      	/* attempt to store */
 		"bne- 1b\n\t"			/* spin if failed */
 		"b 3f\n\t"			/* we've succeeded */
 		"2:\n\t"
-		"stwcx. %0, 0, %2\n\t"       	/* clear reservation (74xx) */
+		"stdcx. %0, 0, %2\n\t"       	/* clear reservation (74xx) */
 		"3:\n\t"
 		: "=&r" (val), "=m" (*p)
 		: "r" (p), "r" (old), "r" (new), "m" (*p)
@@ -365,3 +494,5 @@ casuword(volatile u_long *addr, u_long o
 
 	return (val);
 }
+#endif
+

Modified: head/sys/powerpc/aim/locore.S
==============================================================================
--- head/sys/powerpc/aim/locore.S	Tue Jul 13 05:12:14 2010	(r209974)
+++ head/sys/powerpc/aim/locore.S	Tue Jul 13 05:32:19 2010	(r209975)
@@ -1,209 +1,8 @@
 /* $FreeBSD$ */
-/* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */
 
-/*-
- * Copyright (C) 2001 Benno Rice
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY Benno Rice ``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 TOOLS GMBH 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.
- */
-/*-
- * Copyright (C) 1995, 1996 Wolfgang Solfrank.
- * Copyright (C) 1995, 1996 TooLs GmbH.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
+#ifdef __powerpc64__
+#include <powerpc/aim/locore64.S>
+#else
+#include <powerpc/aim/locore32.S>
+#endif
 
-#include "assym.s"
-
-#include <sys/syscall.h>
-
-#include <machine/trap.h>
-#include <machine/param.h>
-#include <machine/sr.h>
-#include <machine/spr.h>
-#include <machine/psl.h>
-#include <machine/asm.h>
-
-/* Locate the per-CPU data structure */
-#define GET_CPUINFO(r)  \
-        mfsprg0  r
-
-/*
- * Compiled KERNBASE location and the kernel load address
- */
-        .globl  kernbase
-        .set    kernbase, KERNBASE
-
-#define	TMPSTKSZ	8192		/* 8K temporary stack */
-
-/*
- * Globals
- */
-	.data
-	.align	4
-GLOBAL(tmpstk)
-	.space	TMPSTKSZ
-GLOBAL(esym)
-	.long	0			/* end of symbol table */
-
-GLOBAL(ofmsr)
-	.long	0, 0, 0, 0, 0		/* msr/sprg0-3 used in Open Firmware */
-
-#define	INTRCNT_COUNT	256		/* max(HROWPIC_IRQMAX,OPENPIC_IRQMAX) */
-GLOBAL(intrnames)
-	.space	INTRCNT_COUNT * (MAXCOMLEN + 1) * 2
-GLOBAL(eintrnames)
-	.align 4
-GLOBAL(intrcnt)
-	.space	INTRCNT_COUNT * 4 * 2
-GLOBAL(eintrcnt)
-
-/*
- * File-scope for locore.S
- */
-idle_u:
-	.long	0			/* fake uarea during idle after exit */
-openfirmware_entry:
-	.long	0			/* Open Firmware entry point */
-srsave:
-	.long	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
-
-	.text
-	.globl	btext
-btext:
-
-/*
- * This symbol is here for the benefit of kvm_mkdb, and is supposed to
- * mark the start of kernel text.
- */
-	.globl	kernel_text
-kernel_text:
-
-/*
- * Startup entry.  Note, this must be the first thing in the text
- * segment!
- */
-	.text
-	.globl	__start
-__start:
-	li	8,0
-	li	9,0x100
-	mtctr	9
-1:
-	dcbf	0,8
-	icbi	0,8
-	addi	8,8,0x20
-	bdnz	1b
-	sync
-	isync
-
-	/* Save the argument pointer and length */
-	mr	20,6
-	mr	21,7
-
-	lis	8,openfirmware_entry at ha
-	stw	5,openfirmware_entry at l(8) /* save client interface handler */
-
-	lis	1,(tmpstk+TMPSTKSZ-16)@ha
-	addi	1,1,(tmpstk+TMPSTKSZ-16)@l
-
-	mfmsr	0
-	lis	9,ofmsr at ha
-	stwu	0,ofmsr at l(9)
-
-	mfsprg0	0			/* save SPRG0-3 */
-	stw	0,4(9)			/* ofmsr[1] = sprg0 */
-	mfsprg1 0
-	stw	0,8(9)			/* ofmsr[2] = sprg1 */
-	mfsprg2 0
-	stw	0,12(9)			/* ofmsr[3] = sprg2 */
-	mfsprg3 0
-	stw	0,16(9)			/* ofmsr[4] = sprg3 */
-	
-	bl	OF_initial_setup
-
-	lis	4,end at ha
-	addi	4,4,end at l
-	mr	5,4
-
-	lis	3,kernel_text at ha
-	addi	3,3,kernel_text at l
-
-	/* Restore the argument pointer and length */
-	mr	6,20
-	mr	7,21
-
-	bl	powerpc_init
-	mr	%r1, %r3
-	li	%r3, 0
-	stw	%r3, 0(%r1)
-	bl	mi_startup
-	b	OF_exit
-
-/*
- * int setfault()
- *
- * Similar to setjmp to setup for handling faults on accesses to user memory.
- * Any routine using this may only call bcopy, either the form below,
- * or the (currently used) C code optimized, so it doesn't use any non-volatile
- * registers.
- */
-	.globl	setfault
-setfault:
-	mflr	0
-	mfcr	12
-	mfsprg	4,0
-	lwz	4,PC_CURTHREAD(4)
-	lwz	4,TD_PCB(4)
-	stw	3,PCB_ONFAULT(4)
-	stw	0,0(3)
-	stw	1,4(3)
-	stw	2,8(3)
-	stmw	12,12(3)
-	xor	3,3,3
-	blr
-
-#include <powerpc/aim/trap_subr.S>

Copied and modified: head/sys/powerpc/aim/locore32.S (from r209910, head/sys/powerpc/aim/locore.S)
==============================================================================
--- head/sys/powerpc/aim/locore.S	Sun Jul 11 21:12:42 2010	(r209910, copy source)
+++ head/sys/powerpc/aim/locore32.S	Tue Jul 13 05:32:19 2010	(r209975)
@@ -62,9 +62,7 @@
 
 #include <machine/trap.h>
 #include <machine/param.h>
-#include <machine/sr.h>
 #include <machine/spr.h>
-#include <machine/psl.h>
 #include <machine/asm.h>
 
 /* Locate the per-CPU data structure */
@@ -206,4 +204,4 @@ setfault:
 	xor	3,3,3
 	blr
 
-#include <powerpc/aim/trap_subr.S>
+#include <powerpc/aim/trap_subr32.S>

Copied and modified: head/sys/powerpc/aim/locore64.S (from r209910, head/sys/powerpc/aim/locore.S)
==============================================================================
--- head/sys/powerpc/aim/locore.S	Sun Jul 11 21:12:42 2010	(r209910, copy source)
+++ head/sys/powerpc/aim/locore64.S	Tue Jul 13 05:32:19 2010	(r209975)
@@ -62,9 +62,7 @@
 
 #include <machine/trap.h>
 #include <machine/param.h>
-#include <machine/sr.h>
 #include <machine/spr.h>
-#include <machine/psl.h>
 #include <machine/asm.h>
 
 /* Locate the per-CPU data structure */
@@ -78,6 +76,7 @@
         .set    kernbase, KERNBASE
 
 #define	TMPSTKSZ	8192		/* 8K temporary stack */
+#define	OFWSTKSZ	4096		/* 4K Open Firmware stack */
 
 /*
  * Globals
@@ -86,11 +85,13 @@
 	.align	4
 GLOBAL(tmpstk)
 	.space	TMPSTKSZ
+GLOBAL(ofwstk)
+	.space	OFWSTKSZ
 GLOBAL(esym)
-	.long	0			/* end of symbol table */
+	.llong	0			/* end of symbol table */
 
 GLOBAL(ofmsr)
-	.long	0, 0, 0, 0, 0		/* msr/sprg0-3 used in Open Firmware */
+	.llong	0, 0, 0, 0, 0		/* msr/sprg0-3 used in Open Firmware */
 
 #define	INTRCNT_COUNT	256		/* max(HROWPIC_IRQMAX,OPENPIC_IRQMAX) */
 GLOBAL(intrnames)
@@ -105,11 +106,11 @@ GLOBAL(eintrcnt)
  * File-scope for locore.S
  */
 idle_u:
-	.long	0			/* fake uarea during idle after exit */
+	.llong	0			/* fake uarea during idle after exit */
 openfirmware_entry:
-	.long	0			/* Open Firmware entry point */
+	.llong	0			/* Open Firmware entry point */
 srsave:
-	.long	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+	.llong	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 
 	.text
 	.globl	btext
@@ -127,8 +128,7 @@ kernel_text:
  * segment!
  */
 	.text
-	.globl	__start
-__start:
+ASENTRY(__start)
 	li	8,0
 	li	9,0x100
 	mtctr	9
@@ -145,43 +145,183 @@ __start:
 	mr	21,7
 
 	lis	8,openfirmware_entry at ha
-	stw	5,openfirmware_entry at l(8) /* save client interface handler */
+	std	5,openfirmware_entry at l(8) /* save client interface handler */
 
-	lis	1,(tmpstk+TMPSTKSZ-16)@ha
-	addi	1,1,(tmpstk+TMPSTKSZ-16)@l
+	/* Set up the stack pointer */
+	lis	1,(tmpstk+TMPSTKSZ-48)@ha
+	addi	1,1,(tmpstk+TMPSTKSZ-48)@l
+
+	/* Set up the TOC pointer */
+	lis	2,tocbase at ha
+	ld	2,tocbase at l(2)
 
 	mfmsr	0
 	lis	9,ofmsr at ha
-	stwu	0,ofmsr at l(9)
+	stdu	0,ofmsr at l(9)
 
 	mfsprg0	0			/* save SPRG0-3 */
-	stw	0,4(9)			/* ofmsr[1] = sprg0 */
+	std	0,8(9)			/* ofmsr[1] = sprg0 */
 	mfsprg1 0
-	stw	0,8(9)			/* ofmsr[2] = sprg1 */
+	std	0,16(9)			/* ofmsr[2] = sprg1 */
 	mfsprg2 0
-	stw	0,12(9)			/* ofmsr[3] = sprg2 */
+	std	0,24(9)			/* ofmsr[3] = sprg2 */
 	mfsprg3 0
-	stw	0,16(9)			/* ofmsr[4] = sprg3 */
+	std	0,32(9)			/* ofmsr[4] = sprg3 */
+
+	/* Switch to 64-bit mode */
+	mfmsr	9
+	li	8,1
+	insrdi	9,8,1,0
+	mtmsrd	9
 	
-	bl	OF_initial_setup
+	bl	.OF_initial_setup
+	nop
 
 	lis	4,end at ha
 	addi	4,4,end at l
 	mr	5,4
 
-	lis	3,kernel_text at ha
-	addi	3,3,kernel_text at l
+	lis	3,kernbase at ha
+	addi	3,3,kernbase at l
 
 	/* Restore the argument pointer and length */
 	mr	6,20
 	mr	7,21
 
-	bl	powerpc_init
+	bl	.powerpc_init
+	nop
 	mr	%r1, %r3
 	li	%r3, 0
-	stw	%r3, 0(%r1)
-	bl	mi_startup
-	b	OF_exit
+	std	%r3, 0(%r1)
+	bl	.mi_startup
+	nop
+	b	.OF_exit
+	nop
+
+/*
+ * PPC64 ABI TOC base
+ */
+
+        .align  3
+	.globl	tocbase
+tocbase:
+        .llong  .TOC. at tocbase
+
+/*
+ * Open Firmware Real-mode Entry Point. This is a huge pain.
+ */
+
+ASENTRY(ofw_32bit_mode_entry)
+	mflr	%r0
+	std	%r0,16(%r1)
+	stdu	%r1,-208(%r1)
+
+	/*
+	 * We need to save the following, because OF's register save/
+	 * restore code assumes that the contents of registers are
+	 * at most 32 bits wide: lr, cr, r2, r13-r31, the old MSR. These
+	 * get placed in that order in the stack.
+	 */
+
+	mfcr	%r4
+	std	%r4,48(%r1)
+	std	%r13,56(%r1)
+	std	%r14,64(%r1)
+	std	%r15,72(%r1)
+	std	%r16,80(%r1)
+	std	%r17,88(%r1)
+	std	%r18,96(%r1)
+	std	%r19,104(%r1)
+	std	%r20,112(%r1)
+	std	%r21,120(%r1)
+	std	%r22,128(%r1)
+	std	%r23,136(%r1)
+	std	%r24,144(%r1)
+	std	%r25,152(%r1)
+	std	%r26,160(%r1)
+	std	%r27,168(%r1)
+	std	%r28,176(%r1)
+	std	%r29,184(%r1)
+	std	%r30,192(%r1)
+	std	%r31,200(%r1)
+
+	/* Record the old MSR */
+	mfmsr	%r6
+
+	/* read client interface handler */
+	lis	%r4,openfirmware_entry at ha
+	ld	%r4,openfirmware_entry at l(%r4)
+
+	/*
+	 * Set the MSR to the OF value. This has the side effect of disabling
+	 * exceptions, which is important for the next few steps.
+	 */
+
+	lis	%r5,ofmsr at ha
+	ld	%r5,ofmsr at l(%r5)
+	mtmsrd	%r5
+	isync
+
+	/*
+	 * Set up OF stack. This needs to be accessible in real mode and
+	 * use the 32-bit ABI stack frame format. The pointer to the current
+	 * kernel stack is placed at the very top of the stack along with
+	 * the old MSR so we can get them back later.
+	 */
+	mr	%r5,%r1
+	lis	%r1,(ofwstk+OFWSTKSZ-32)@ha
+	addi	%r1,%r1,(ofwstk+OFWSTKSZ-32)@l
+	std	%r5,8(%r1)	/* Save real stack pointer */
+	std	%r2,16(%r1)	/* Save old TOC */
+	std	%r6,24(%r1)	/* Save old MSR */
+	li	%r5,0
+	stw	%r5,4(%r1)
+	stw	%r5,0(%r1)
+
+	/* Finally, branch to OF */
+	mtctr	%r4
+	bctrl
+
+	/* Reload stack pointer and MSR from the OFW stack */
+	ld	%r6,24(%r1)
+	ld	%r2,16(%r1)
+	ld	%r1,8(%r1)
+
+	/* Now set the real MSR */
+	mtmsrd	%r6
+	isync
+
+	/* Sign-extend the return value from OF */
+	extsw	%r3,%r3
+
+	/* Restore all the non-volatile registers */
+	ld	%r5,48(%r1)
+	mtcr	%r5
+	ld	%r13,56(%r1)
+	ld	%r14,64(%r1)
+	ld	%r15,72(%r1)
+	ld	%r16,80(%r1)
+	ld	%r17,88(%r1)
+	ld	%r18,96(%r1)
+	ld	%r19,104(%r1)
+	ld	%r20,112(%r1)
+	ld	%r21,120(%r1)
+	ld	%r22,128(%r1)
+	ld	%r23,136(%r1)
+	ld	%r24,144(%r1)
+	ld	%r25,152(%r1)
+	ld	%r26,160(%r1)
+	ld	%r27,168(%r1)
+	ld	%r28,176(%r1)
+	ld	%r29,184(%r1)
+	ld	%r30,192(%r1)
+	ld	%r31,200(%r1)
+
+	/* Restore the stack and link register */
+	ld	%r1,0(%r1)
+	ld	%r0,16(%r1)
+	mtlr 	%r0
+	blr
 
 /*
  * int setfault()
@@ -191,19 +331,39 @@ __start:
  * or the (currently used) C code optimized, so it doesn't use any non-volatile
  * registers.
  */
-	.globl	setfault
-setfault:
+ASENTRY(setfault)
 	mflr	0
 	mfcr	12
 	mfsprg	4,0
-	lwz	4,PC_CURTHREAD(4)
-	lwz	4,TD_PCB(4)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list