Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Jul 2009 20:52:13 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r195900 - in projects/ppc64/sys: conf powerpc/aim powerpc/aim64 powerpc/include powerpc/powerpc
Message-ID:  <200907262052.n6QKqDm6080109@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Sun Jul 26 20:52:12 2009
New Revision: 195900
URL: http://svn.freebsd.org/changeset/base/195900

Log:
  Add in some more missing bits, and a few beginning corrections for the
  dot symbol function descriptor business in the PowerPC64 ABI. This produces
  a kernel that compiles, links, and even manages to make it into
  powerpc_init().

Added:
  projects/ppc64/sys/powerpc/aim64/copyinout.c
     - copied, changed from r195651, projects/ppc64/sys/powerpc/aim/copyinout.c
  projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c
     - copied, changed from r195651, projects/ppc64/sys/powerpc/powerpc/elf_machdep.c
Modified:
  projects/ppc64/sys/conf/files.powerpc64
  projects/ppc64/sys/powerpc/aim/mmu_oea.c
  projects/ppc64/sys/powerpc/aim64/locore.S
  projects/ppc64/sys/powerpc/aim64/mmu_oea64.c
  projects/ppc64/sys/powerpc/aim64/trap_subr.S
  projects/ppc64/sys/powerpc/include/asm.h
  projects/ppc64/sys/powerpc/powerpc/in_cksum.c
  projects/ppc64/sys/powerpc/powerpc/setjmp.S

Modified: projects/ppc64/sys/conf/files.powerpc64
==============================================================================
--- projects/ppc64/sys/conf/files.powerpc64	Sun Jul 26 20:47:48 2009	(r195899)
+++ projects/ppc64/sys/conf/files.powerpc64	Sun Jul 26 20:52:12 2009	(r195900)
@@ -47,22 +47,13 @@ dev/syscons/scvtb.c		optional	sc
 dev/syscons/teken/teken.c	optional sc
 dev/uart/uart_cpu_powerpc.c	optional	uart
 kern/syscalls.c			optional	ktr
-libkern/ashldi3.c		standard
-libkern/ashrdi3.c		standard
 libkern/bcmp.c			standard
-libkern/cmpdi2.c		standard
-libkern/divdi3.c		standard
 libkern/ffs.c			standard
 libkern/ffsl.c			standard
 libkern/fls.c			standard
 libkern/flsl.c			standard
-libkern/lshrdi3.c		standard
 libkern/memmove.c		standard
 libkern/memset.c		standard
-libkern/moddi3.c		standard
-libkern/ucmpdi2.c		standard
-libkern/udivdi3.c		standard
-libkern/umoddi3.c		standard
 powerpc/aim/clock.c		optional	aim
 powerpc/aim/interrupt.c		optional	aim
 powerpc/aim/mp_cpudep.c		optional	aim smp
@@ -73,7 +64,7 @@ powerpc/aim/platform_chrp.c	optional	aim
 powerpc/aim/trap.c		optional	aim
 powerpc/aim/uma_machdep.c	optional	aim
 powerpc/aim/vm_machdep.c	optional	aim
-#powerpc/aim64/copyinout.c	optional	aim
+powerpc/aim64/copyinout.c	optional	aim
 powerpc/aim64/locore.S		optional	aim no-obj
 powerpc/aim64/machdep.c		optional	aim
 powerpc/aim64/mmu_oea64.c	optional	aim
@@ -112,7 +103,7 @@ 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/elf64_machdep.c	standard
 powerpc/powerpc/fpu.c		optional	aim
 powerpc/powerpc/fuswintr.c	standard
 powerpc/powerpc/gdb_machdep.c	optional	gdb

Modified: projects/ppc64/sys/powerpc/aim/mmu_oea.c
==============================================================================
--- projects/ppc64/sys/powerpc/aim/mmu_oea.c	Sun Jul 26 20:47:48 2009	(r195899)
+++ projects/ppc64/sys/powerpc/aim/mmu_oea.c	Sun Jul 26 20:52:12 2009	(r195900)
@@ -193,8 +193,8 @@ struct ofw_map {
  */
 static struct	mem_region *regions;
 static struct	mem_region *pregions;
-u_int           phys_avail_count;
-int		regions_sz, pregions_sz;
+static u_int    phys_avail_count;
+static int	regions_sz, pregions_sz;
 static struct	ofw_map *translations;
 
 extern struct pmap ofw_pmap;

Copied and modified: projects/ppc64/sys/powerpc/aim64/copyinout.c (from r195651, projects/ppc64/sys/powerpc/aim/copyinout.c)
==============================================================================
--- projects/ppc64/sys/powerpc/aim/copyinout.c	Mon Jul 13 01:37:48 2009	(r195651, copy source)
+++ projects/ppc64/sys/powerpc/aim64/copyinout.c	Sun Jul 26 20:52:12 2009	(r195900)
@@ -103,13 +103,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->pm_sr[(uintptr_t)up >> ADDR_SR_SHFT]);
 
 		bcopy(kp, p, l);
 
@@ -144,13 +144,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->pm_sr[(uintptr_t)up >> ADDR_SR_SHFT]);
 
 		bcopy(p, kp, l);
 
@@ -218,14 +218,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 *)((uintptr_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->pm_sr[(uintptr_t)addr >> ADDR_SR_SHFT]);
 
 	*p = (char)byte;
 
@@ -234,6 +234,31 @@ subyte(void *addr, int byte)
 }
 
 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 *)((uintptr_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[(uintptr_t)addr >> ADDR_SR_SHFT]);
+
+	*p = word;
+
+	td->td_pcb->pcb_onfault = NULL;
+	return (0);
+}
+
+int
 suword(void *addr, long word)
 {
 	struct		thread *td;
@@ -243,14 +268,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 *)((uintptr_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->pm_sr[(uintptr_t)addr >> ADDR_SR_SHFT]);
 
 	*p = word;
 
@@ -259,12 +284,11 @@ suword(void *addr, long word)
 }
 
 int
-suword32(void *addr, int32_t word)
+suword64(void *addr, int64_t word)
 {
 	return (suword(addr, (long)word));
 }
 
-
 int
 fubyte(const void *addr)
 {
@@ -276,14 +300,15 @@ 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 *)((uintptr_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->pm_sr[(uintptr_t)addr >> ADDR_SR_SHFT]);
 
 	val = *p;
 
@@ -301,14 +326,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 *)((uintptr_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->pm_sr[(uintptr_t)addr >> ADDR_SR_SHFT]);
 
 	val = *p;
 
@@ -338,9 +363,10 @@ 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 *)((uintptr_t)USER_ADDR +
+	    ((uintptr_t)addr & ~SEGMENT_MASK));
 
-	set_user_sr(pm->pm_sr[(u_int)addr >> ADDR_SR_SHFT]);
+	set_user_sr(pm->pm_sr[(uintptr_t)addr >> ADDR_SR_SHFT]);
 
 	if (setfault(env)) {
 		td->td_pcb->pcb_onfault = NULL;

Modified: projects/ppc64/sys/powerpc/aim64/locore.S
==============================================================================
--- projects/ppc64/sys/powerpc/aim64/locore.S	Sun Jul 26 20:47:48 2009	(r195899)
+++ projects/ppc64/sys/powerpc/aim64/locore.S	Sun Jul 26 20:52:12 2009	(r195900)
@@ -127,8 +127,7 @@ kernel_text:
  * segment!
  */
 	.text
-	.globl	__start
-__start:
+ASENTRY(__start)
 	li	8,0
 	li	9,0x100
 	mtctr	9
@@ -163,7 +162,8 @@ __start:
 	mfsprg3 0
 	stw	0,16(9)			/* ofmsr[4] = sprg3 */
 	
-	bl	OF_initial_setup
+	bl	.OF_initial_setup
+	nop
 
 	lis	4,end@ha
 	addi	4,4,end@l
@@ -176,12 +176,15 @@ __start:
 	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
+	bl	.mi_startup
+	nop
+	b	.OF_exit
+	nop
 
 /*
  * int setfault()
@@ -191,8 +194,7 @@ __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
@@ -206,4 +208,4 @@ setfault:
 	xor	3,3,3
 	blr
 
-#include <powerpc/aim/trap_subr.S>
+#include <powerpc/aim64/trap_subr.S>

Modified: projects/ppc64/sys/powerpc/aim64/mmu_oea64.c
==============================================================================
--- projects/ppc64/sys/powerpc/aim64/mmu_oea64.c	Sun Jul 26 20:47:48 2009	(r195899)
+++ projects/ppc64/sys/powerpc/aim64/mmu_oea64.c	Sun Jul 26 20:52:12 2009	(r195900)
@@ -268,9 +268,9 @@ struct ofw_map {
  */
 static struct	mem_region *regions;
 static struct	mem_region *pregions;
-extern u_int	phys_avail_count;
-extern int	regions_sz, pregions_sz;
-extern int	ofw_real_mode;
+static u_int	phys_avail_count;
+static int	regions_sz, pregions_sz;
+static int	ofw_real_mode;
 static struct	ofw_map translations[64];
 
 extern struct pmap ofw_pmap;
@@ -732,11 +732,13 @@ moea64_bridge_bootstrap(mmu_t mmup, vm_o
 	/* We don't have a direct map since there is no BAT */
 	hw_direct_map = 0;
 
+#ifndef __powerpc64__
 	/* Make sure battable is zero, since we have no BAT */
 	for (i = 0; i < 16; i++) {
 		battable[i].batu = 0;
 		battable[i].batl = 0;
 	}
+#endif
 
 	/* Get physical memory regions from firmware */
 	mem_regions(&pregions, &pregions_sz, &regions, &regions_sz);

Modified: projects/ppc64/sys/powerpc/aim64/trap_subr.S
==============================================================================
--- projects/ppc64/sys/powerpc/aim64/trap_subr.S	Sun Jul 26 20:47:48 2009	(r195899)
+++ projects/ppc64/sys/powerpc/aim64/trap_subr.S	Sun Jul 26 20:52:12 2009	(r195900)
@@ -478,8 +478,7 @@ CNAME(asttrapexit):
 /*
  * Deliberate entry to dbtrap
  */
-	.globl	CNAME(breakpoint)
-CNAME(breakpoint):
+ASENTRY(breakpoint)
 	mtsprg1	%r1
 	mfmsr	%r3
 	mtsrr1	%r3

Modified: projects/ppc64/sys/powerpc/include/asm.h
==============================================================================
--- projects/ppc64/sys/powerpc/include/asm.h	Sun Jul 26 20:47:48 2009	(r195899)
+++ projects/ppc64/sys/powerpc/include/asm.h	Sun Jul 26 20:52:12 2009	(r195900)
@@ -60,8 +60,16 @@
 #define	_GLOBAL(x) \
 	.data; .align 2; .globl x; x:
 
+#ifdef __powerpc64__ 
+#define _ENTRY(x) \
+	.text; .align 2; .globl x; .section ".opd","aw"; \
+	.align 3; x: \
+	    .quad .x,.TOC.@tocbase,0; .previous; \
+	.align 4; .globl .x; .type .x,@function; .x:
+#else
 #define	_ENTRY(x) \
 	.text; .align 4; .globl x; .type x,@function; x:
+#endif
 
 #ifdef GPROF
 # define	_PROF_PROLOGUE	mflr 0; stw 0,4(1); bl _mcount

Copied and modified: projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c (from r195651, projects/ppc64/sys/powerpc/powerpc/elf_machdep.c)
==============================================================================
--- projects/ppc64/sys/powerpc/powerpc/elf_machdep.c	Mon Jul 13 01:37:48 2009	(r195651, copy source)
+++ projects/ppc64/sys/powerpc/powerpc/elf64_machdep.c	Sun Jul 26 20:52:12 2009	(r195900)
@@ -48,7 +48,7 @@
 #include <machine/elf.h>
 #include <machine/md_var.h>
 
-struct sysentvec elf32_freebsd_sysvec = {
+struct sysentvec elf64_freebsd_sysvec = {
 	.sv_size	= SYS_MAXSYSCALL,
 	.sv_table	= sysent,
 	.sv_mask	= 0,
@@ -62,7 +62,7 @@ struct sysentvec elf32_freebsd_sysvec = 
 	.sv_sigcode	= sigcode,
 	.sv_szsigcode	= &szsigcode,
 	.sv_prepsyscall	= NULL,
-	.sv_name	= "FreeBSD ELF32",
+	.sv_name	= "FreeBSD ELF64",
 	.sv_coredump	= __elfN(coredump),
 	.sv_imgact_try	= NULL,
 	.sv_minsigstksz	= MINSIGSTKSZ,
@@ -76,44 +76,44 @@ struct sysentvec elf32_freebsd_sysvec = 
 	.sv_setregs	= exec_setregs,
 	.sv_fixlimit	= NULL,
 	.sv_maxssiz	= NULL,
-	.sv_flags	= SV_ABI_FREEBSD | SV_ILP32
+	.sv_flags	= SV_ABI_FREEBSD | SV_LP64
 };
 
-static Elf32_Brandinfo freebsd_brand_info = {
+static Elf64_Brandinfo freebsd_brand_info = {
 	.brand		= ELFOSABI_FREEBSD,
-	.machine	= EM_PPC,
+	.machine	= EM_PPC64,
 	.compat_3_brand	= "FreeBSD",
 	.emul_path	= NULL,
 	.interp_path	= "/libexec/ld-elf.so.1",
-	.sysvec		= &elf32_freebsd_sysvec,
+	.sysvec		= &elf64_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.brand_note	= &elf32_freebsd_brandnote,
+	.brand_note	= &elf64_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
 
-SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
-    (sysinit_cfunc_t) elf32_insert_brand_entry,
+SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
+    (sysinit_cfunc_t) elf64_insert_brand_entry,
     &freebsd_brand_info);
 
-static Elf32_Brandinfo freebsd_brand_oinfo = {
+static Elf64_Brandinfo freebsd_brand_oinfo = {
 	.brand		= ELFOSABI_FREEBSD,
-	.machine	= EM_PPC,
+	.machine	= EM_PPC64,
 	.compat_3_brand	= "FreeBSD",
 	.emul_path	= NULL,
 	.interp_path	= "/usr/libexec/ld-elf.so.1",
-	.sysvec		= &elf32_freebsd_sysvec,
+	.sysvec		= &elf64_freebsd_sysvec,
 	.interp_newpath	= NULL,
-	.brand_note	= &elf32_freebsd_brandnote,
+	.brand_note	= &elf64_freebsd_brandnote,
 	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
 };
 
-SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_ANY,
-	(sysinit_cfunc_t) elf32_insert_brand_entry,
+SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,
+	(sysinit_cfunc_t) elf64_insert_brand_entry,
 	&freebsd_brand_oinfo);
 
 
 void
-elf32_dump_thread(struct thread *td __unused, void *dst __unused,
+elf64_dump_thread(struct thread *td __unused, void *dst __unused,
     size_t *off __unused)
 {
 }

Modified: projects/ppc64/sys/powerpc/powerpc/in_cksum.c
==============================================================================
--- projects/ppc64/sys/powerpc/powerpc/in_cksum.c	Sun Jul 26 20:47:48 2009	(r195899)
+++ projects/ppc64/sys/powerpc/powerpc/in_cksum.c	Sun Jul 26 20:52:12 2009	(r195900)
@@ -228,7 +228,7 @@ skip_start:
 		if (len < mlen)
 			mlen = len;
 
-		if ((clen ^ (int) addr) & 1)
+		if ((clen ^ (long) addr) & 1)
 		    sum += in_cksumdata(addr, mlen) << 8;
 		else
 		    sum += in_cksumdata(addr, mlen);

Modified: projects/ppc64/sys/powerpc/powerpc/setjmp.S
==============================================================================
--- projects/ppc64/sys/powerpc/powerpc/setjmp.S	Sun Jul 26 20:47:48 2009	(r195899)
+++ projects/ppc64/sys/powerpc/powerpc/setjmp.S	Sun Jul 26 20:52:12 2009	(r195900)
@@ -4,6 +4,8 @@
 /* kernel version of this file, does not have signal goop */
 /* int setjmp(jmp_buf env) */
 
+#include <machine/asm.h>
+
 #define JMP_r1	0x04
 #define JMP_r14	0x08
 #define JMP_r15	0x0c
@@ -29,9 +31,7 @@
 #define JMP_xer	0x5c
 #define JMP_sig	0x60
 
-
-.globl setjmp
-setjmp:
+ASENTRY(setjmp)
 	stw 31, JMP_r31(3)
 	/* r1, r14-r30 */
 	stw 1,  JMP_r1 (3)
@@ -67,8 +67,7 @@ setjmp:
 
 
 .extern sigsetmask
-.globl longjmp
-longjmp:
+ASENTRY(longjmp)
 	lwz 31, JMP_r31(3)
 	/* r1, r14-r30 */
 	lwz 1,  JMP_r1 (3)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907262052.n6QKqDm6080109>