svn commit: r195975 - in projects/ppc64/sys: conf dev/ofw powerpc/aim powerpc/aim64 powerpc/cell powerpc/include powerpc/mambo powerpc/ofw powerpc/powerpc

Nathan Whitehorn nwhitehorn at FreeBSD.org
Thu Jul 30 17:36:14 UTC 2009


Author: nwhitehorn
Date: Thu Jul 30 17:36:13 2009
New Revision: 195975
URL: http://svn.freebsd.org/changeset/base/195975

Log:
  Bring up PPC64 threading and DDB tracing, as well as fleshing out Mambo
  support with some bits from P4. Also fix a typo in aim/swtch.S that should
  be merged to head. We now boot until a WITNESS panic in the vm.

Added:
  projects/ppc64/sys/powerpc/cell/
  projects/ppc64/sys/powerpc/cell/celliic.c
  projects/ppc64/sys/powerpc/mambo/mambo.c
  projects/ppc64/sys/powerpc/mambo/mambo_disk.c
  projects/ppc64/sys/powerpc/mambo/mambo_openpic.c
Modified:
  projects/ppc64/sys/conf/files.powerpc64
  projects/ppc64/sys/conf/options.powerpc64
  projects/ppc64/sys/dev/ofw/openfirm.h
  projects/ppc64/sys/powerpc/aim/ofw_machdep.c
  projects/ppc64/sys/powerpc/aim/swtch.S
  projects/ppc64/sys/powerpc/aim/vm_machdep.c
  projects/ppc64/sys/powerpc/aim64/mmu_oea64.c
  projects/ppc64/sys/powerpc/aim64/swtch.S
  projects/ppc64/sys/powerpc/include/db_machdep.h
  projects/ppc64/sys/powerpc/include/pcb.h
  projects/ppc64/sys/powerpc/ofw/ofw_real.c
  projects/ppc64/sys/powerpc/powerpc/db_trace.c
  projects/ppc64/sys/powerpc/powerpc/genassym.c

Modified: projects/ppc64/sys/conf/files.powerpc64
==============================================================================
--- projects/ppc64/sys/conf/files.powerpc64	Thu Jul 30 14:28:56 2009	(r195974)
+++ projects/ppc64/sys/conf/files.powerpc64	Thu Jul 30 17:36:13 2009	(r195975)
@@ -68,10 +68,14 @@ powerpc/aim64/locore.S		optional	aim no-
 powerpc/aim64/machdep.c		optional	aim
 powerpc/aim64/mmu_oea64.c	optional	aim
 powerpc/aim64/swtch.S		optional	aim
+powerpc/cell/celliic.c		optional	cell
 powerpc/cpufreq/dfs.c		optional	cpufreq
 powerpc/cpufreq/pcr.c		optional	cpufreq aim
 powerpc/mambo/mambocall.S	optional	mambo
+powerpc/mambo/mambo.c		optional	mambo
 powerpc/mambo/mambo_console.c	optional	mambo
+powerpc/mambo/mambo_disk.c	optional	mambo
+powerpc/mambo/mambo_openpic.c	optional	mambo
 powerpc/ofw/ofw_cpu.c		optional	aim
 powerpc/ofw/ofw_pcibus.c	optional	pci aim
 powerpc/ofw/ofw_pcib_pci.c	optional	pci aim

Modified: projects/ppc64/sys/conf/options.powerpc64
==============================================================================
--- projects/ppc64/sys/conf/options.powerpc64	Thu Jul 30 14:28:56 2009	(r195974)
+++ projects/ppc64/sys/conf/options.powerpc64	Thu Jul 30 17:36:13 2009	(r195975)
@@ -3,6 +3,7 @@
 
 AIM			opt_global.h
 E500			opt_global.h
+CELL
 MAMBO
 
 GFB_DEBUG		opt_gfb.h

Modified: projects/ppc64/sys/dev/ofw/openfirm.h
==============================================================================
--- projects/ppc64/sys/dev/ofw/openfirm.h	Thu Jul 30 14:28:56 2009	(r195974)
+++ projects/ppc64/sys/dev/ofw/openfirm.h	Thu Jul 30 17:36:13 2009	(r195975)
@@ -91,6 +91,7 @@ void		OF_init(void *cookie);
 
 #define	OFW_STD_DIRECT	"ofw_std"	/* Standard OF interface */
 #define	OFW_STD_REAL	"ofw_real"	/* Real-mode OF interface */
+#define	OFW_STD_32BIT	"ofw_32bit"	/* 32-bit OF interface */
 #define	OFW_FDT		"ofw_fdt"	/* Flattened Device Tree */
 
 /* Generic functions */

Modified: projects/ppc64/sys/powerpc/aim/ofw_machdep.c
==============================================================================
--- projects/ppc64/sys/powerpc/aim/ofw_machdep.c	Thu Jul 30 14:28:56 2009	(r195974)
+++ projects/ppc64/sys/powerpc/aim/ofw_machdep.c	Thu Jul 30 17:36:13 2009	(r195975)
@@ -354,10 +354,15 @@ OF_bootstrap()
 	boolean_t status = FALSE;
 
 	if (ofwcall != NULL) {
-		if (ofw_real_mode)
+		if (ofw_real_mode) {
 			status = OF_install(OFW_STD_REAL, 0);
-		else
+		} else {
+			#ifdef __powerpc64__
+			status = OF_install(OFW_STD_32BIT, 0);
+			#else
 			status = OF_install(OFW_STD_DIRECT, 0);
+			#endif
+		}
 
 		if (status != TRUE)
 			return status;

Modified: projects/ppc64/sys/powerpc/aim/swtch.S
==============================================================================
--- projects/ppc64/sys/powerpc/aim/swtch.S	Thu Jul 30 14:28:56 2009	(r195974)
+++ projects/ppc64/sys/powerpc/aim/swtch.S	Thu Jul 30 17:36:13 2009	(r195975)
@@ -95,7 +95,7 @@ ENTRY(cpu_switch)
 	stw	%r16,PCB_LR(%r5)
 	mfsr	%r16,USER_SR		/* Save USER_SR for copyin/out */
 	isync
-	stw	%r16,PCB_AIM_USR(%r5)
+	stw	%r16,PCB_AIM_USR_VSID(%r5)
 	stw	%r1,PCB_SP(%r5)		/* Save the stack pointer */
 
 	mr	%r14,%r3		/* Copy the old thread ptr... */
@@ -151,7 +151,7 @@ cpu_switchin:
 	mtcr	%r5
 	lwz	%r5,PCB_LR(%r3)		/* Load the link register */
 	mtlr	%r5
-	lwz	%r5,PCB_AIM_USR(%r3)	/* Load the USER_SR segment reg */
+	lwz	%r5,PCB_AIM_USR_VSID(%r3) /* Load the USER_SR segment reg */
 	mtsr	USER_SR,%r5
 	isync
 	lwz	%r1,PCB_SP(%r3)		/* Load the stack pointer */
@@ -171,7 +171,7 @@ ENTRY(savectx)
 	mr	%r12,%r2
 	stmw	%r12,PCB_CONTEXT(%r3)	/* Save the non-volatile GP regs */
 	mfcr	%r4			/* Save the condition register */
-	stw	%r4,PCB_CONTEXT(%r3)
+	stw	%r4,PCB_CR(%r3)
 	blr
 
 /*

Modified: projects/ppc64/sys/powerpc/aim/vm_machdep.c
==============================================================================
--- projects/ppc64/sys/powerpc/aim/vm_machdep.c	Thu Jul 30 14:28:56 2009	(r195974)
+++ projects/ppc64/sys/powerpc/aim/vm_machdep.c	Thu Jul 30 17:36:13 2009	(r195975)
@@ -182,8 +182,13 @@ cpu_fork(struct thread *td1, struct proc
 	cf->cf_arg1 = (register_t)tf;
 
 	pcb->pcb_sp = (register_t)cf;
+	#ifdef __powerpc64__
+	pcb->pcb_lr = *(register_t *)fork_trampoline;
+	#else
 	pcb->pcb_lr = (register_t)fork_trampoline;
-	pcb->pcb_cpu.aim.usr = kernel_pmap->pm_sr[USER_SR];
+	#endif
+	pcb->pcb_cpu.aim.usr_vsid = 0;
+	pcb->pcb_cpu.aim.usr_esid = 0;
 
 	/* Setup to release spin count in fork_exit(). */
 	td2->td_md.md_spinlock_count = 1;
@@ -450,7 +455,8 @@ cpu_set_upcall(struct thread *td, struct
 
 	pcb2->pcb_sp = (register_t)cf;
 	pcb2->pcb_lr = (register_t)fork_trampoline;
-	pcb2->pcb_cpu.aim.usr = kernel_pmap->pm_sr[USER_SR];
+	pcb2->pcb_cpu.aim.usr_vsid = 0;
+	pcb2->pcb_cpu.aim.usr_esid = 0;
 
 	/* Setup to release spin count in fork_exit(). */
 	td->td_md.md_spinlock_count = 1;

Modified: projects/ppc64/sys/powerpc/aim64/mmu_oea64.c
==============================================================================
--- projects/ppc64/sys/powerpc/aim64/mmu_oea64.c	Thu Jul 30 14:28:56 2009	(r195974)
+++ projects/ppc64/sys/powerpc/aim64/mmu_oea64.c	Thu Jul 30 17:36:13 2009	(r195975)
@@ -930,6 +930,7 @@ moea64_bridge_bootstrap(mmu_t mmup, vm_o
 	#ifdef __powerpc64__
 	for (i = 0; i < 16; i++) 
 		kernel_pmap->pm_sr[i] = (i << 1) | 1;
+	kernel_pmap->pm_sr[USER_SR] = 0;
 	#else
 	for (i = 0; i < 16; i++) 
 		kernel_pmap->pm_sr[i] = EMPTY_SEGMENT + i;

Modified: projects/ppc64/sys/powerpc/aim64/swtch.S
==============================================================================
--- projects/ppc64/sys/powerpc/aim64/swtch.S	Thu Jul 30 14:28:56 2009	(r195974)
+++ projects/ppc64/sys/powerpc/aim64/swtch.S	Thu Jul 30 17:36:13 2009	(r195975)
@@ -81,22 +81,47 @@ ENTRY(cpu_throw)
  * Switch to a new thread saving the current state in the old thread.
  */
 ENTRY(cpu_switch)
-	stw	%r5,TD_LOCK(%r3)	/* ULE:	update old thread's lock */
+	std	%r5,TD_LOCK(%r3)	/* ULE:	update old thread's lock */
 					/* XXX needs to change for MP */
 
-	lwz	%r5,TD_PCB(%r3)		/* Get the old thread's PCB ptr */
+	ld	%r5,TD_PCB(%r3)		/* Get the old thread's PCB ptr */
 	mr	%r12,%r2	
-	stmw	%r12,PCB_CONTEXT(%r5)	/* Save the non-volatile GP regs.
+	std	%r12,PCB_CONTEXT(%r5)	/* Save the non-volatile GP regs.
 					   These can now be used for scratch */
+	std	%r13,PCB_CONTEXT+1*8(%r5)	
+	std	%r14,PCB_CONTEXT+2*8(%r5)	
+	std	%r15,PCB_CONTEXT+3*8(%r5)	
+	std	%r16,PCB_CONTEXT+4*8(%r5)	
+	std	%r17,PCB_CONTEXT+5*8(%r5)	
+	std	%r18,PCB_CONTEXT+6*8(%r5)	
+	std	%r19,PCB_CONTEXT+7*8(%r5)	
+	std	%r20,PCB_CONTEXT+8*8(%r5)	
+	std	%r21,PCB_CONTEXT+9*8(%r5)	
+	std	%r22,PCB_CONTEXT+10*8(%r5)	
+	std	%r23,PCB_CONTEXT+11*8(%r5)	
+	std	%r24,PCB_CONTEXT+12*8(%r5)	
+	std	%r25,PCB_CONTEXT+13*8(%r5)	
+	std	%r26,PCB_CONTEXT+14*8(%r5)	
+	std	%r27,PCB_CONTEXT+15*8(%r5)	
+	std	%r28,PCB_CONTEXT+16*8(%r5)	
+	std	%r29,PCB_CONTEXT+17*8(%r5)	
+	std	%r30,PCB_CONTEXT+18*8(%r5)	
+	std	%r31,PCB_CONTEXT+19*8(%r5)	
 
 	mfcr	%r16			/* Save the condition register */
 	stw	%r16,PCB_CR(%r5)
 	mflr	%r16			/* Save the link register */
-	stw	%r16,PCB_LR(%r5)
-	mfsr	%r16,USER_SR		/* Save USER_SR for copyin/out */
+	std	%r16,PCB_LR(%r5)
+	
+	li	%r14,0			/* Save USER_SR for copyin/out */
+	li	%r15,0
+	li	%r16,USER_SR
+	slbmfee %r14, %r16
+	slbmfev %r15, %r16
 	isync
-	stw	%r16,PCB_AIM_USR(%r5)
-	stw	%r1,PCB_SP(%r5)		/* Save the stack pointer */
+	std	%r14,PCB_AIM_USR_ESID(%r5)
+	std	%r15,PCB_AIM_USR_VSID(%r5)
+	std	%r1,PCB_SP(%r5)		/* Save the stack pointer */
 
 	mr	%r14,%r3		/* Copy the old thread ptr... */
 	mr	%r15,%r4		/* and the new thread ptr in scratch */
@@ -105,34 +130,39 @@ ENTRY(cpu_switch)
 	/* Save FPU context if needed */
 	andi.	%r6, %r6, PCB_FPU
 	beq	.L1
-	bl	save_fpu
+	bl	.save_fpu
+	nop
 
 .L1:
 	lwz	%r6,PCB_FLAGS(%r5)
 	/* Save Altivec context if needed */
 	andi.	%r6, %r6, PCB_VEC
 	beq	.L2
-	bl	save_vec
+	bl	.save_vec
+	nop
 	
 .L2:
 	mr	%r3,%r14		/* restore old thread ptr */
-	bl	pmap_deactivate		/* Deactivate the current pmap */
+	bl	.pmap_deactivate	/* Deactivate the current pmap */
+	nop
 
 cpu_switchin:
 	mfsprg	%r7,0			/* Get the pcpu pointer */
-	stw	%r15,PC_CURTHREAD(%r7)	/* Store new current thread */
-	lwz	%r17,TD_PCB(%r15)	/* Store new current PCB */
-	stw	%r17,PC_CURPCB(%r7)
+	std	%r15,PC_CURTHREAD(%r7)	/* Store new current thread */
+	ld	%r17,TD_PCB(%r15)	/* Store new current PCB */
+	std	%r17,PC_CURPCB(%r7)
 
 	mr	%r3,%r15		/* Get new thread ptr */
-	bl	pmap_activate		/* Activate the new address space */
+	bl	.pmap_activate		/* Activate the new address space */
+	nop
 
 	lwz	%r6, PCB_FLAGS(%r17)
 	/* Restore FPU context if needed */
 	andi.	%r6, %r6, PCB_FPU
 	beq	.L3
 	mr	%r3,%r15		/* Pass curthread to enable_fpu */
-	bl	enable_fpu
+	bl	.enable_fpu
+	nop
 
 .L3:
 	lwz	%r6, PCB_FLAGS(%r17)
@@ -140,27 +170,49 @@ cpu_switchin:
 	andi.	%r6, %r6, PCB_VEC
 	beq	.L4
 	mr	%r3,%r15		/* Pass curthread to enable_vec */
-	bl	enable_vec
+	bl	.enable_vec
+	nop
 
 	/* thread to restore is in r3 */
 .L4:
 	mr	%r3,%r17		/* Recover PCB ptr */
-	lmw	%r12,PCB_CONTEXT(%r3)	/* Load the non-volatile GP regs */
+	ld	%r12,PCB_CONTEXT(%r3)	/* Load the non-volatile GP regs. */
+	ld	%r13,PCB_CONTEXT+1*8(%r3)	
+	ld	%r14,PCB_CONTEXT+2*8(%r3)	
+	ld	%r15,PCB_CONTEXT+3*8(%r3)	
+	ld	%r16,PCB_CONTEXT+4*8(%r3)	
+	ld	%r17,PCB_CONTEXT+5*8(%r3)	
+	ld	%r18,PCB_CONTEXT+6*8(%r3)	
+	ld	%r19,PCB_CONTEXT+7*8(%r3)	
+	ld	%r20,PCB_CONTEXT+8*8(%r3)	
+	ld	%r21,PCB_CONTEXT+9*8(%r3)	
+	ld	%r22,PCB_CONTEXT+10*8(%r3)	
+	ld	%r23,PCB_CONTEXT+11*8(%r3)	
+	ld	%r24,PCB_CONTEXT+12*8(%r3)	
+	ld	%r25,PCB_CONTEXT+13*8(%r3)	
+	ld	%r26,PCB_CONTEXT+14*8(%r3)	
+	ld	%r27,PCB_CONTEXT+15*8(%r3)	
+	ld	%r28,PCB_CONTEXT+16*8(%r3)
+	ld	%r29,PCB_CONTEXT+17*8(%r3)	
+	ld	%r30,PCB_CONTEXT+18*8(%r3)	
+	ld	%r31,PCB_CONTEXT+19*8(%r3)	
 	mr	%r2,%r12
 	lwz	%r5,PCB_CR(%r3)		/* Load the condition register */
 	mtcr	%r5
-	lwz	%r5,PCB_LR(%r3)		/* Load the link register */
+	ld	%r5,PCB_LR(%r3)		/* Load the link register */
 	mtlr	%r5
-	lwz	%r5,PCB_AIM_USR(%r3)	/* Load the USER_SR segment reg */
-	mtsr	USER_SR,%r5
+	ld	%r5,PCB_AIM_USR_VSID(%r3) /* Load the USER_SR segment reg */
+	ld	%r6,PCB_AIM_USR_ESID(%r3)
+	ori	%r6,%r6,USER_SR
+	slbmte	%r5,%r6
 	isync
-	lwz	%r1,PCB_SP(%r3)		/* Load the stack pointer */
+	ld	%r1,PCB_SP(%r3)		/* Load the stack pointer */
 	/*
 	 * Perform a dummy stwcx. to clear any reservations we may have
 	 * inherited from the previous thread. It doesn't matter if the
 	 * stwcx succeeds or not. pcb_context[0] can be clobbered.
 	 */
-	stwcx.	%r1, 0, %r3
+	stdcx.	%r1, 0, %r3
 	blr
 
 /*
@@ -169,9 +221,29 @@ cpu_switchin:
  */
 ENTRY(savectx)
 	mr	%r12,%r2
-	stmw	%r12,PCB_CONTEXT(%r3)	/* Save the non-volatile GP regs */
+	std	%r12,PCB_CONTEXT(%r3)	/* Save the non-volatile GP regs. */
+	std	%r13,PCB_CONTEXT+1*8(%r3)	
+	std	%r14,PCB_CONTEXT+2*8(%r3)	
+	std	%r15,PCB_CONTEXT+3*8(%r3)	
+	std	%r16,PCB_CONTEXT+4*8(%r3)	
+	std	%r17,PCB_CONTEXT+5*8(%r3)	
+	std	%r18,PCB_CONTEXT+6*8(%r3)	
+	std	%r19,PCB_CONTEXT+7*8(%r3)	
+	std	%r20,PCB_CONTEXT+8*8(%r3)	
+	std	%r21,PCB_CONTEXT+9*8(%r3)	
+	std	%r22,PCB_CONTEXT+10*8(%r3)	
+	std	%r23,PCB_CONTEXT+11*8(%r3)	
+	std	%r24,PCB_CONTEXT+12*8(%r3)	
+	std	%r25,PCB_CONTEXT+13*8(%r3)	
+	std	%r26,PCB_CONTEXT+14*8(%r3)	
+	std	%r27,PCB_CONTEXT+15*8(%r3)	
+	std	%r28,PCB_CONTEXT+16*8(%r3)
+	std	%r29,PCB_CONTEXT+17*8(%r3)	
+	std	%r30,PCB_CONTEXT+18*8(%r3)	
+	std	%r31,PCB_CONTEXT+19*8(%r3)	
+
 	mfcr	%r4			/* Save the condition register */
-	stw	%r4,PCB_CONTEXT(%r3)
+	stw	%r4,PCB_CR(%r3)
 	blr
 
 /*
@@ -179,10 +251,11 @@ ENTRY(savectx)
  * Set up the return from cpu_fork()
  */
 ENTRY(fork_trampoline)
-	lwz	%r3,CF_FUNC(%r1)
-	lwz	%r4,CF_ARG0(%r1)
-	lwz	%r5,CF_ARG1(%r1)
-	bl	fork_exit
+	ld	%r3,CF_FUNC(%r1)
+	ld	%r4,CF_ARG0(%r1)
+	ld	%r5,CF_ARG1(%r1)
+	bl	.fork_exit
+	nop
 	addi	%r1,%r1,CF_SIZE-FSP	/* Allow 8 bytes in front of
 					   trapframe to simulate FRAME_SETUP
 					   does when allocating space for

Added: projects/ppc64/sys/powerpc/cell/celliic.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/ppc64/sys/powerpc/cell/celliic.c	Thu Jul 30 17:36:13 2009	(r195975)
@@ -0,0 +1,145 @@
+/*-
+ * Copyright 2009 by Nathan Whitehorn. 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. 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.
+ *
+ * $FreeBSD: projects/ppc64/sys/powerpc/powermac/celliic.c 183882 2008-10-14 14:54:14Z nwhitehorn $
+ */
+
+/*
+ * A driver for the Integrated Interrupt Controller found on all Cell
+ * processors.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/rman.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/openfirm.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+#include <machine/intr_machdep.h>
+#include <machine/md_var.h>
+#include <machine/pio.h>
+#include <machine/resource.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include "pic_if.h"
+
+static int	celliic_probe(device_t);
+static int	celliic_attach(device_t);
+
+static void	celliic_dispatch(device_t, struct trapframe *);
+static void	celliic_enable(device_t, u_int, u_int);
+static void	celliic_eoi(device_t, u_int);
+static void	celliic_ipi(device_t, u_int);
+static void	celliic_mask(device_t, u_int);
+static void	celliic_unmask(device_t, u_int);
+
+static device_method_t  celliic_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,         celliic_probe),
+	DEVMETHOD(device_attach,        celliic_attach),
+
+	/* PIC interface */
+	DEVMETHOD(pic_dispatch,		celliic_dispatch),
+	DEVMETHOD(pic_enable,		celliic_enable),
+	DEVMETHOD(pic_eoi,		celliic_eoi),
+	DEVMETHOD(pic_ipi,		celliic_ipi),
+	DEVMETHOD(pic_mask,		celliic_mask),
+	DEVMETHOD(pic_unmask,		celliic_unmask),
+
+	{ 0, 0 },
+};
+
+static driver_t celliic_driver = {
+	"celliic",
+	celliic_methods,
+	0
+};
+
+static devclass_t celliic_devclass;
+
+DRIVER_MODULE(celliic, nexus, celliic_driver, celliic_devclass, 0, 0);
+
+static int
+celliic_probe(device_t dev)
+{
+	const char *type = ofw_bus_get_type(dev);
+
+	if (strcmp(type, "stidc-iic") != 0)
+		return (ENXIO);
+
+	device_set_desc(dev, "Cell Integrated Interrupt Controller");
+	return (0);
+}
+
+static int
+celliic_attach(device_t dev)
+{
+	powerpc_register_pic(dev, 64);
+	return (0);
+}
+
+/*
+ * PIC I/F methods.
+ */
+
+static void
+celliic_dispatch(device_t dev, struct trapframe *tf)
+{
+}
+
+static void
+celliic_enable(device_t dev, u_int irq, u_int vector)
+{
+}
+
+static void
+celliic_eoi(device_t dev __unused, u_int irq __unused)
+{
+}
+
+static void
+celliic_ipi(device_t dev, u_int irq)
+{
+}
+
+static void
+celliic_mask(device_t dev, u_int irq)
+{
+}
+
+static void
+celliic_unmask(device_t dev, u_int irq)
+{
+}

Modified: projects/ppc64/sys/powerpc/include/db_machdep.h
==============================================================================
--- projects/ppc64/sys/powerpc/include/db_machdep.h	Thu Jul 30 14:28:56 2009	(r195974)
+++ projects/ppc64/sys/powerpc/include/db_machdep.h	Thu Jul 30 17:36:13 2009	(r195975)
@@ -35,9 +35,10 @@
 #define	_POWERPC_DB_MACHDEP_H_
 
 #include <vm/vm_param.h>
+#include <machine/elf.h>
 
 #define	DB_ELF_SYMBOLS
-#define	DB_ELFSIZE	32
+#define	DB_ELFSIZE	__ELF_WORD_SIZE
 
 #define BYTE_MSF        (1)
 

Modified: projects/ppc64/sys/powerpc/include/pcb.h
==============================================================================
--- projects/ppc64/sys/powerpc/include/pcb.h	Thu Jul 30 14:28:56 2009	(r195974)
+++ projects/ppc64/sys/powerpc/include/pcb.h	Thu Jul 30 17:36:13 2009	(r195975)
@@ -65,7 +65,8 @@ struct pcb {
 
 	union {
 		struct {
-			register_t	usr;	/* USER_SR segment */
+			register_t	usr_esid;	/* USER_SR segment */
+			register_t	usr_vsid;	/* USER_SR segment */
 		} aim;
 		struct {
 			register_t	ctr;

Added: projects/ppc64/sys/powerpc/mambo/mambo.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/ppc64/sys/powerpc/mambo/mambo.c	Thu Jul 30 17:36:13 2009	(r195975)
@@ -0,0 +1,103 @@
+/*-
+ * Copyright 2008 by Nathan Whitehorn. 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. 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/sys/powerpc/powermac/openpic_macio.c,v 1.13 2008/10/14 14:54:14 nwhitehorn Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/openfirm.h>
+
+#include <machine/bus.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <sys/rman.h>
+
+/*
+ * Mambo interface
+ */
+static int	mambobus_probe(device_t);
+static int	mambobus_attach(device_t);
+
+static device_method_t  mambobus_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,		mambobus_probe),
+	DEVMETHOD(device_attach,	mambobus_attach),
+
+	/* Bus interface */
+	DEVMETHOD(bus_driver_added,	bus_generic_driver_added),
+	DEVMETHOD(bus_add_child,	bus_generic_add_child),
+	DEVMETHOD(bus_print_child,	bus_generic_print_child),
+	DEVMETHOD(bus_read_ivar,	bus_generic_read_ivar),
+	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
+	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
+	DEVMETHOD(bus_alloc_resource,	bus_generic_alloc_resource),
+	DEVMETHOD(bus_release_resource,	bus_generic_release_resource),
+	DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
+
+	{0,0}
+};
+
+static driver_t mambobus_driver = {
+	"mambo",
+	mambobus_methods,
+	0
+};
+
+static devclass_t mambobus_devclass;
+
+DRIVER_MODULE(mambo, nexus, mambobus_driver, mambobus_devclass, 0, 0);
+
+static int
+mambobus_probe(device_t dev)
+{
+	const char *name = ofw_bus_get_name(dev);
+
+	if (name && !strcmp(name, "mambo")) {
+		device_set_desc(dev, "Mambo Simulator");
+		return (0);
+	}
+
+	return (ENXIO);
+}
+
+static int
+mambobus_attach(device_t dev)
+{
+	bus_generic_probe(dev);
+	return (bus_generic_attach(dev));
+}
+

Added: projects/ppc64/sys/powerpc/mambo/mambo_disk.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/ppc64/sys/powerpc/mambo/mambo_disk.c	Thu Jul 30 17:36:13 2009	(r195975)
@@ -0,0 +1,278 @@
+/*-
+ * Copyright (c) 2006 Bernd Walter.  All rights reserved.
+ * Copyright (c) 2006 M. Warner Losh.  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 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD: head/sys/dev/mmc/mambodisk.c 183805 2008-10-12 19:19:26Z mav $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bio.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/kthread.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <geom/geom_disk.h>
+
+#include <powerpc/mambo/mambocall.h>
+
+struct mambodisk_softc {
+	device_t dev;
+	struct mtx sc_mtx;
+	struct disk *disk;
+	struct proc *p;
+	struct bio_queue_head bio_queue;
+	int running;
+	int maxblocks;
+};
+
+#define MAMBO_DISK_READ		116
+#define	MAMBO_DISK_WRITE	117
+#define MAMBO_DISK_INFO		118
+
+#define MAMBO_INFO_STATUS	1
+#define MAMBO_INFO_BLKSZ	2
+#define MAMBO_INFO_DEVSZ	3
+
+/* bus entry points */
+static void mambodisk_identify(driver_t *driver, device_t parent);
+static int mambodisk_probe(device_t dev);
+static int mambodisk_attach(device_t dev);
+
+/* disk routines */
+static int mambodisk_open(struct disk *dp);
+static int mambodisk_close(struct disk *dp);
+static void mambodisk_strategy(struct bio *bp);
+static void mambodisk_task(void *arg);
+
+#define MBODISK_LOCK(_sc)		mtx_lock(&(_sc)->sc_mtx)
+#define	MBODISK_UNLOCK(_sc)	mtx_unlock(&(_sc)->sc_mtx)
+#define MBODISK_LOCK_INIT(_sc) \
+	mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev), \
+	    "mambodisk", MTX_DEF)
+#define MBODISK_LOCK_DESTROY(_sc)	mtx_destroy(&_sc->sc_mtx);
+#define MBODISK_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED);
+#define MBODISK_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED);
+
+static void
+mambodisk_identify(driver_t *driver, device_t parent)
+{
+	int i = 0;
+
+	for (i = 0; mambocall(MAMBO_DISK_INFO,MAMBO_INFO_DEVSZ,i) > 0; i++)
+		BUS_ADD_CHILD(parent,0,"mambodisk",i);
+}
+
+static int
+mambodisk_probe(device_t dev)
+{
+	device_set_desc(dev, "Mambo Simulated Block Device");
+	return (0);
+}
+
+static int
+mambodisk_attach(device_t dev)
+{
+	struct mambodisk_softc *sc;
+	struct disk *d;
+	intmax_t mb;
+	char unit;
+
+	sc = device_get_softc(dev);
+	sc->dev = dev;
+	MBODISK_LOCK_INIT(sc);
+
+	d = sc->disk = disk_alloc();
+	d->d_open = mambodisk_open;
+	d->d_close = mambodisk_close;
+	d->d_strategy = mambodisk_strategy;
+	// d->d_dump = mambodisk_dump;	Need polling mmc layer
+	d->d_name = "mambodisk";
+	d->d_drv1 = sc;
+	d->d_maxsize = MAXPHYS;		/* Maybe ask bridge? */
+
+	d->d_sectorsize = 512;
+	sc->maxblocks = mambocall(MAMBO_DISK_INFO,MAMBO_INFO_BLKSZ,d->d_unit)
+	    / 512;
+
+	d->d_unit = device_get_unit(dev);
+	d->d_mediasize = mambocall(MAMBO_DISK_INFO,MAMBO_INFO_DEVSZ,d->d_unit)
+	    * 1024; /* Mambo gives size in KB */
+
+	mb = d->d_mediasize >> 20;	/* 1MiB == 1 << 20 */
+	unit = 'M';
+	if (mb >= 10240) {		/* 1GiB = 1024 MiB */
+		unit = 'G';
+		mb /= 1024;
+	}
+	device_printf(dev, "%ju%cB, %d byte sectors\n", mb, unit, 
+	    d->d_sectorsize);
+	disk_create(d, DISK_VERSION);
+	bioq_init(&sc->bio_queue);
+
+	sc->running = 1;
+	kproc_create(&mambodisk_task, sc, &sc->p, 0, 0, "task: mambo hd");
+
+	return (0);
+}
+
+static int
+mambodisk_detach(device_t dev)
+{
+	struct mambodisk_softc *sc = device_get_softc(dev);
+
+	/* kill thread */
+	MBODISK_LOCK(sc);
+	sc->running = 0;
+	wakeup(sc);
+	MBODISK_UNLOCK(sc);
+
+	/* wait for thread to finish.  XXX probably want timeout.  -sorbo */
+	MBODISK_LOCK(sc);
+	while (sc->running != -1)
+		msleep(sc, &sc->sc_mtx, PRIBIO, "detach", 0);
+	MBODISK_UNLOCK(sc);
+
+	/* kill disk */
+	disk_destroy(sc->disk);
+	/* XXX destroy anything in queue */
+
+	MBODISK_LOCK_DESTROY(sc);
+
+	return (0);
+}
+
+static int
+mambodisk_open(struct disk *dp)
+{
+	return (0);
+}
+
+static int
+mambodisk_close(struct disk *dp)
+{
+	return (0);
+}
+
+static void
+mambodisk_strategy(struct bio *bp)
+{
+	struct mambodisk_softc *sc;
+
+	sc = (struct mambodisk_softc *)bp->bio_disk->d_drv1;
+	MBODISK_LOCK(sc);
+	bioq_disksort(&sc->bio_queue, bp);
+	wakeup(sc);
+	MBODISK_UNLOCK(sc);
+}
+
+static void
+mambodisk_task(void *arg)
+{
+	struct mambodisk_softc *sc = (struct mambodisk_softc*)arg;
+	struct bio *bp;
+	int sz, result;
+	daddr_t block, end;
+	device_t dev;
+	uint32_t unit;
+
+	dev = sc->dev;
+	unit = device_get_unit(dev);
+
+	while (sc->running) {
+		MBODISK_LOCK(sc);
+		do {
+			bp = bioq_first(&sc->bio_queue);
+			if (bp == NULL)
+				msleep(sc, &sc->sc_mtx, PRIBIO, "jobqueue", 0);
+		} while (bp == NULL && sc->running);
+		if (bp)
+			bioq_remove(&sc->bio_queue, bp);
+		MBODISK_UNLOCK(sc);
+		if (!sc->running)
+			break;
+		sz = sc->disk->d_sectorsize;
+		end = bp->bio_pblkno + (bp->bio_bcount / sz);
+		for (block = bp->bio_pblkno; block < end;) {
+			uint32_t numblocks;
+			char *vaddr = bp->bio_data + 
+			    (block - bp->bio_pblkno) * sz;
+
+			numblocks = end - block;
+			if (numblocks > sc->maxblocks)
+				numblocks = sc->maxblocks;
+
+			if (bp->bio_cmd == BIO_READ) {
+				result = mambocall(MAMBO_DISK_READ, vaddr, 
+				    (uint32_t)block, (numblocks << 16) | unit);
+			} else if (bp->bio_cmd == BIO_WRITE) {
+				result = mambocall(MAMBO_DISK_WRITE, vaddr, 
+				    (uint32_t)block, (numblocks << 16) | unit);
+			} else {
+				result = 1;
+			}
+		
+			if (result)
+				break;
+
+			block += numblocks;
+		}
+		if (block < end) {
+			bp->bio_error = EIO;
+			bp->bio_resid = (end - block) * sz;
+			bp->bio_flags |= BIO_ERROR;
+		}
+		biodone(bp);
+	}
+
+	/* tell parent we're done */
+	MBODISK_LOCK(sc);
+	sc->running = -1;
+	wakeup(sc);
+	MBODISK_UNLOCK(sc);
+
+	kproc_exit(0);
+}
+
+static device_method_t mambodisk_methods[] = {
+	DEVMETHOD(device_identify,	mambodisk_identify),
+	DEVMETHOD(device_probe,		mambodisk_probe),
+	DEVMETHOD(device_attach,	mambodisk_attach),
+	DEVMETHOD(device_detach,	mambodisk_detach),
+	{0, 0},
+};
+
+static driver_t mambodisk_driver = {
+	"mambodisk",
+	mambodisk_methods,
+	sizeof(struct mambodisk_softc),
+};
+static devclass_t mambodisk_devclass;
+
+DRIVER_MODULE(mambodisk, mambo, mambodisk_driver, mambodisk_devclass, 0, 0);

Added: projects/ppc64/sys/powerpc/mambo/mambo_openpic.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/ppc64/sys/powerpc/mambo/mambo_openpic.c	Thu Jul 30 17:36:13 2009	(r195975)
@@ -0,0 +1,175 @@
+/*-
+ * Copyright 2003 by Peter Grehan. 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. 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/sys/powerpc/powermac/openpic_macio.c,v 1.13 2008/10/14 14:54:14 nwhitehorn Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/openfirm.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+#include <machine/intr_machdep.h>
+#include <machine/md_var.h>
+#include <machine/pio.h>
+#include <machine/resource.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <sys/rman.h>
+
+#include <machine/openpicvar.h>
+
+#include "pic_if.h"
+
+/*
+ * Mambo interface
+ */
+static int	openpic_mambo_probe(device_t);
+static int	openpicbus_mambo_probe(device_t dev);
+static int	openpicbus_mambo_attach(device_t dev);
+static struct resource *openpicbus_alloc_resource(device_t bus, device_t dev, 
+		    int type, int *rid, u_long start, u_long end, u_long count, 
+		    u_int flags);
+
+static device_method_t  openpicbus_mambo_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,		openpicbus_mambo_probe),
+	DEVMETHOD(device_attach,	openpicbus_mambo_attach),
+
+	/* Bus interface */
+	DEVMETHOD(bus_alloc_resource,	openpicbus_alloc_resource),
+
+	{0,0}
+};
+
+struct openpicbus_softc {
+	vm_offset_t picaddr;
+};
+
+static driver_t openpicbus_mambo_driver = {
+	"openpicbus",
+	openpicbus_mambo_methods,
+	sizeof(struct openpicbus_softc),
+};
+
+static device_method_t  openpic_mambo_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,		openpic_mambo_probe),
+	DEVMETHOD(device_attach,	openpic_attach),
+
+	/* PIC interface */
+	DEVMETHOD(pic_config,		openpic_config),
+	DEVMETHOD(pic_dispatch,		openpic_dispatch),
+	DEVMETHOD(pic_enable,		openpic_enable),
+	DEVMETHOD(pic_eoi,		openpic_eoi),
+	DEVMETHOD(pic_ipi,		openpic_ipi),
+	DEVMETHOD(pic_mask,		openpic_mask),
+	DEVMETHOD(pic_unmask,		openpic_unmask),
+
+	{ 0, 0 },

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


More information about the svn-src-projects mailing list