CVS commit: src/sys/arch/sparc64/sparc64

2021-07-03 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Jul  3 19:39:07 UTC 2021

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
sun4v: request hypervisor api major version 3 for the interrupt group - should 
solve issues when setting up interrupts on S7 systems


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.232 src/sys/arch/sparc64/sparc64/autoconf.c:1.233
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.232	Sat Jul  3 19:18:55 2021
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Jul  3 19:39:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.232 2021/07/03 19:18:55 palle Exp $ */
+/*	$NetBSD: autoconf.c,v 1.233 2021/07/03 19:39:07 palle Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.232 2021/07/03 19:18:55 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.233 2021/07/03 19:39:07 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -189,9 +189,9 @@ void	sun4v_set_soft_state(int, const cha
 char sun4v_soft_state_booting[] __align32 = "NetBSD booting";
 char sun4v_soft_state_running[] __align32 = "NetBSD running";
 
+void	sun4v_interrupt_init(void);
 #if 0
 XXX notyet		
-void	sun4v_interrupt_init(void);
 void	sun4v_sdio_init(void);
 #endif
 #endif
@@ -378,9 +378,9 @@ die_old_boot_loader:
 	if (CPU_ISSUN4V) {
 		sun4v_soft_state_init();
 		sun4v_set_soft_state(SIS_TRANSITION, sun4v_soft_state_booting);
+		sun4v_interrupt_init();
 #if 0
 XXX notyet		
-		sun4v_interrupt_init();
 		sun4v_sdio_init();
 #endif 
 	}
@@ -570,8 +570,6 @@ sun4v_set_soft_state(int state, const ch
 		printf("soft_state_set: %d\n", err);
 }
 
-#if 0
-XXX notyet		
 void
 sun4v_interrupt_init(void)
 {
@@ -582,7 +580,6 @@ sun4v_interrupt_init(void)
 
 	sun4v_group_interrupt_major = 3;
 }
-#endif
 
 #if 0
 XXX notyet		



CVS commit: src/sys/arch/sparc64/sparc64

2021-05-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue May 11 03:43:30 UTC 2021

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
All of the OFW-enumerated busses now associate the OFW node with the
device at config_found() time, so we can remove all of the stuff from
device_register() that does it, leaving only the @pci case to fix that
up (similar situation with ACPI on ARM and x86).

Adapt the boot device matching code to use the devhandle from the
device_t rather than the previous mechanism, and add some comments
explaining what's going on and some assertions to validate the
comments.

Collapse the sun4v vdsk boot device detection into the normal "sd"
case because it's almost identical to the normal "sd" case anyhow.


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.229 src/sys/arch/sparc64/sparc64/autoconf.c:1.230
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.229	Mon May 10 23:53:44 2021
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Tue May 11 03:43:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.229 2021/05/10 23:53:44 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.230 2021/05/11 03:43:30 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.229 2021/05/10 23:53:44 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.230 2021/05/11 03:43:30 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -144,7 +144,6 @@ int kgdb_break_at_attach;
 #endif
 
 #define	OFPATHLEN	128
-#define	OFNODEKEY	"OFpnode"
 
 char	machine_banner[100];
 char	machine_model[100];
@@ -997,62 +996,25 @@ dev_bi_unit_drive_match(device_t dev, in
 }
 
 /*
- * Get the firmware package handle from a device_t.
- * Assuming we have previously stored it in the device properties
- * dictionary.
- */
-static int
-device_ofnode(device_t dev)
-{
-	prop_dictionary_t props;
-	prop_object_t obj;
-
-	if (dev == NULL)
-		return 0;
-	props = device_properties(dev);
-	if (props == NULL)
-		return 0;
-	obj = prop_dictionary_get(props, OFNODEKEY);
-	if (obj == NULL)
-		return 0;
-
-	return prop_number_signed_value(obj);
-}
-
-/*
- * Save the firmware package handle inside the properties dictionary
- * of a device_t.
- */
-static void
-device_setofnode(device_t dev, int node)
-{
-	prop_dictionary_t props;
-	prop_object_t obj;
-
-	if (dev == NULL)
-		return;
-	props = device_properties(dev);
-	if (props == NULL)
-		return;
-	obj = prop_number_create_signed(node);
-	if (obj == NULL)
-		return;
-	prop_dictionary_set(props, OFNODEKEY, obj);
-	prop_object_release(obj);
-	DPRINTF(ACDB_BOOTDEV, (" [device %s has node %x] ",
-	device_xname(dev), node));
-}
-
-/*
  * Called back during autoconfiguration for each device found
  */
 void
 device_register(device_t dev, void *aux)
 {
 	device_t busdev = device_parent(dev);
+	devhandle_t devhandle;
 	int ofnode = 0;
 
 	/*
+	 * If the device has a valid OpenFirmware node association,
+	 * grab it now.
+	 */
+	devhandle = device_handle(dev);
+	if (devhandle_type(devhandle) == DEVHANDLE_TYPE_OF) {
+		ofnode = devhandle_to_of(devhandle);
+	}
+
+	/*
 	 * We don't know the type of 'aux' - it depends on the
 	 * bus this device attaches to. We are only interested in
 	 * certain bus types, this only is used to find the boot
@@ -1063,23 +1025,18 @@ device_register(device_t dev, void *aux)
 		 * Ignore mainbus0 itself, it certainly is not a boot
 		 * device.
 		 */
-	} else if (device_is_a(busdev, "mainbus")) {
-		struct mainbus_attach_args *ma = aux;
-
-		ofnode = ma->ma_node;
 	} else if (device_is_a(busdev, "pci")) {
 		struct pci_attach_args *pa = aux;
 
-		ofnode = PCITAG_NODE(pa->pa_tag);
-	} else if (device_is_a(busdev, "sbus") || device_is_a(busdev, "dma")
-	|| device_is_a(busdev, "ledma")) {
-		struct sbus_attach_args *sa = aux;
-
-		ofnode = sa->sa_node;
-	} else if (device_is_a(busdev, "ebus")) {
-		struct ebus_attach_args *ea = aux;
-
-		ofnode = ea->ea_node;
+		/*
+		 * XXX PCI devices don't currently get their devhandles
+		 * set when the PCI layer attaches them, so we need to
+		 * do it here.  (It's not just us; ACPI has the same
+		 * problem...)
+		 */
+		ofnode = (int)PCITAG_NODE(pa->pa_tag);
+		devhandle = devhandle_from_of(ofnode);
+		device_set_handle(dev, devhandle);
 	} else if (device_is_a(busdev, "iic")) {
 		struct i2c_attach_args *ia = aux;
 
@@ -1098,6 +1055,7 @@ device_register(device_t dev, void *aux)
 add_gpio_props_e250(dev, aux);
 			}
 		} 
+		return;
 	} else if (device_is_a(dev, "sd") || device_is_a(dev, "cd")) {
 		struct scsipibus_attach_args *sa = aux;
 		struct scsipi_periph *periph = sa->sa_periph;
@@ -1121,9 +1079,37 @@ device_register(device_t dev, void *aux)
 

CVS commit: src/sys/arch/sparc64/sparc64

2021-04-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr  6 15:55:26 UTC 2021

Modified Files:
src/sys/arch/sparc64/sparc64: db_disasm.c

Log Message:
Fix a typo, remove a useless blank line.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc64/sparc64/db_disasm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/db_disasm.c
diff -u src/sys/arch/sparc64/sparc64/db_disasm.c:1.18 src/sys/arch/sparc64/sparc64/db_disasm.c:1.19
--- src/sys/arch/sparc64/sparc64/db_disasm.c:1.18	Sun Oct  4 08:16:14 2015
+++ src/sys/arch/sparc64/sparc64/db_disasm.c	Tue Apr  6 15:55:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.18 2015/10/04 08:16:14 joerg Exp $ */
+/*	$NetBSD: db_disasm.c,v 1.19 2021/04/06 15:55:26 simonb Exp $ */
 
 /*
  * Copyright (c) 1994 David S. Miller, da...@nadzieja.rutgers.edu
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.18 2015/10/04 08:16:14 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.19 2021/04/06 15:55:26 simonb Exp $");
 
 #include 
 #include 
@@ -223,7 +223,7 @@ struct sparc_insn sparc_i[] = {
 	/* Note: if imm22 is zero then this is actually a "nop" grrr... */
 	{(FORMAT2(0, 0x4)), "sethi", "Cd"},
 
-	/* Branch on Integer Co`ndition Codes "Bicc" */
+	/* Branch on Integer Condition Codes "Bicc" */
 	{(FORMAT2(0, 2) | COND(8)), "ba", "a,m"},
 	{(FORMAT2(0, 2) | COND(0)), "bn", "a,m"},
 	{(FORMAT2(0, 2) | COND(9)), "bne", "a,m"},
@@ -1121,4 +1121,3 @@ db_disasm(db_addr_t loc, bool altfmt)
 
 	return (loc + 4);
 }
-



CVS commit: src/sys/arch/sparc64/sparc64

2021-03-30 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Mar 30 20:03:15 UTC 2021

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: handle spill trap properly when trap level is 1 and otherwin is non-zero 
- ensure that all windows are spilled to the pcb like the sun4u winfixsave code 
path


To generate a diff of this commit:
cvs rdiff -u -r1.425 -r1.426 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.425 src/sys/arch/sparc64/sparc64/locore.s:1.426
--- src/sys/arch/sparc64/sparc64/locore.s:1.425	Mon Feb 22 09:56:42 2021
+++ src/sys/arch/sparc64/sparc64/locore.s	Tue Mar 30 20:03:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.425 2021/02/22 09:56:42 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.426 2021/03/30 20:03:14 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -234,7 +234,7 @@
 	.endm
 
 	.macro sun4v_tl1_uspill_other
-	ba,a,pt	%xcc, pcbspill_others
+	ba,a,pt	%xcc, pcbspill_other
 	 nop
 	.align 128
 	.endm
@@ -3485,6 +3485,77 @@ pcbspill_fail:
 	Debugger()
 	NOTREACHED
 
+
+pcbspill_other:
+	
+	set	CPUINFO_VA, %g6
+	ldx	[%g6 + CI_CPCB], %g6
+	
+	GET_CTXBUSY %g1
+
+	ldx	[%g1], %g1! kernel pmap is ctx 0
+	
+	srlx	%g6, STSHIFT, %g7
+	and	%g7, STMASK, %g7
+	sll	%g7, 3, %g7! byte offset into ctxbusy
+	add	%g7, %g1, %g1
+	ldxa	[%g1] ASI_PHYS_CACHED, %g1		! Load pointer to directory
+
+	srlx	%g6, PDSHIFT, %g7			! Do page directory
+	and	%g7, PDMASK, %g7
+	sll	%g7, 3, %g7
+	brz,pn	%g1, pcbspill_other_fail
+	 add	%g7, %g1, %g1
+	ldxa	[%g1] ASI_PHYS_CACHED, %g1
+	srlx	%g6, PTSHIFT, %g7			! Convert to ptab offset
+	and	%g7, PTMASK, %g7
+	brz	%g1, pcbspill_other_fail
+	 sll	%g7, 3, %g7
+	add	%g1, %g7, %g7
+	ldxa	[%g7] ASI_PHYS_CACHED, %g7		! This one is not
+	brgez	%g7, pcbspill_other_fail
+	 srlx	%g7, PGSHIFT, %g7			! Isolate PA part
+	sll	%g6, 32-PGSHIFT, %g6			! And offset
+	sllx	%g7, PGSHIFT+8, %g7			! There are 8 bits to the left of the PA in the TTE
+	srl	%g6, 32-PGSHIFT, %g6
+	srax	%g7, 8, %g7
+	or	%g7, %g6, %g6! Then combine them to form PA
+
+	wr	%g0, ASI_PHYS_CACHED, %asi		! Use ASI_PHYS_CACHED to prevent possible page faults
+
+	lduba	[%g6 + PCB_NSAVED] %asi, %g7		! Fetch current nsaved from the pcb
+	sllx	%g7, 7, %g5! 8+8 registers each 8 bytes = 128 bytes (2^7)
+	add	%g6, %g5, %g5! Offset into pcb_rw
+1:	
+	SPILL	stxa, %g5 + PCB_RW, 8, %asi		! Store the locals and ins
+
+	add	%g5, 16*8, %g5! Next location for saved register windows
+
+	stxa	%o6, [%g5 + PCB_RW + (14*8)] %asi	! Save %sp so we can write these all out
+	
+	saved		! Increments %cansave and decrements %otherwin
+	
+	rdpr	%cwp, %g1! shift register window forward
+	inc	%g1
+	wrpr	%g1, %cwp
+
+
+	inc	%g7	! increment number of saved register windows
+
+	rdpr	%otherwin, %g1! Check to see if done spill'ing otherwin
+	brnz,pt	%g1, 1b
+	 nop
+	
+	stba	%g7, [%g6 + PCB_NSAVED] %asi
+
+	retry
+	NOTREACHED
+
+pcbspill_other_fail:
+	Debugger()
+	NOTREACHED
+
+
 spill_normal_to_user_stack:
 	mov	%sp, %g6		! calculate virtual address of destination stack
 	add	%g6, BIAS, %g6



CVS commit: src/sys/arch/sparc64/sparc64

2021-02-22 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Feb 22 09:56:42 UTC 2021

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: handle spill normal user traps properly when current trap level is 1 - 
registers are spilled to the PA of the stack to avoid further mmu-related 
traps, since sun4v only has 2 trap levels


To generate a diff of this commit:
cvs rdiff -u -r1.424 -r1.425 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.424 src/sys/arch/sparc64/sparc64/locore.s:1.425
--- src/sys/arch/sparc64/sparc64/locore.s:1.424	Sun Dec 20 11:58:58 2020
+++ src/sys/arch/sparc64/sparc64/locore.s	Mon Feb 22 09:56:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.424 2020/12/20 11:58:58 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.425 2021/02/22 09:56:42 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -228,7 +228,7 @@
 	.endm
 
 	.macro sun4v_tl1_uspill_normal
-	ba,a,pt	%xcc, pcbspill_normals
+	ba,a,pt	%xcc, spill_normal_to_user_stack
 	 nop
 	.align 128
 	.endm
@@ -3485,6 +3485,58 @@ pcbspill_fail:
 	Debugger()
 	NOTREACHED
 
+spill_normal_to_user_stack:
+	mov	%sp, %g6		! calculate virtual address of destination stack
+	add	%g6, BIAS, %g6
+
+	mov	CTX_SECONDARY, %g2! Is this context ok or should it be CTX_PRIMARY? XXX
+	GET_MMU_CONTEXTID %g3, %g2, %g1
+	sllx	%g3, 3, %g3	! Make it into an offset into ctxbusy (see below)
+	
+	GET_CTXBUSY %g1
+	ldx	[%g1 + %g3], %g1! Fetch pmap for current context id
+
+	! Start of code to extract PA	
+	srlx	%g6, STSHIFT, %g7
+	and	%g7, STMASK, %g7
+	sll	%g7, 3, %g7		! byte offset into ctxbusy
+	add	%g7, %g1, %g1
+	ldxa	[%g1] ASI_PHYS_CACHED, %g1	! Load pointer to directory
+	srlx	%g6, PDSHIFT, %g7			! Do page directory
+	and	%g7, PDMASK, %g7
+	sll	%g7, 3, %g7
+	brz,pn	%g1, spill_normal_to_user_stack_fail
+	 add	%g7, %g1, %g1
+
+	ldxa	[%g1] ASI_PHYS_CACHED, %g1
+	srlx	%g6, PTSHIFT, %g7			! Convert to ptab offset
+	and	%g7, PTMASK, %g7
+	brz	%g1, spill_normal_to_user_stack_fail
+	 sll	%g7, 3, %g7
+	
+	add	%g1, %g7, %g7
+	ldxa	[%g7] ASI_PHYS_CACHED, %g7	! This one is not
+	brgez	%g7, spill_normal_to_user_stack_fail
+	 srlx	%g7, PGSHIFT, %g7			! Isolate PA part
+	
+	sll	%g6, 32-PGSHIFT, %g6			! And offset
+	sllx	%g7, PGSHIFT+8, %g7			! There are 8 bits to the left of the PA in the TTE
+	srl	%g6, 32-PGSHIFT, %g6
+	srax	%g7, 8, %g7
+	or	%g7, %g6, %g6	! Then combine them to form PA
+	! End of code to extract PA
+
+	wr	%g0, ASI_PHYS_CACHED, %asi		! Use ASI_PHYS_CACHED to prevent possible page faults
+	SPILL	stxa, %g6, 8, %asi			! Store the locals and ins
+	saved
+
+	retry
+	NOTREACHED
+
+spill_normal_to_user_stack_fail:
+	sir
+	 nop
+	
 /*
  * End of traps for sun4v.
  */



CVS commit: src/sys/arch/sparc64/sparc64

2021-02-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb  2 08:18:42 UTC 2021

Modified Files:
src/sys/arch/sparc64/sparc64: trap.c

Log Message:
Worakround for traps on invalid VAs:
uvm_fault() can not (currently) deal properly with invalid VAs (inside the
VA hole), so do not pass faults for such addresses to it, but instead
either panic (if fault is in kernel) or send a SIGSEGV to userland.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/sys/arch/sparc64/sparc64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.192 src/sys/arch/sparc64/sparc64/trap.c:1.193
--- src/sys/arch/sparc64/sparc64/trap.c:1.192	Thu Nov 21 19:24:01 2019
+++ src/sys/arch/sparc64/sparc64/trap.c	Tue Feb  2 08:18:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.192 2019/11/21 19:24:01 ad Exp $ */
+/*	$NetBSD: trap.c,v 1.193 2021/02/02 08:18:42 martin Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.192 2019/11/21 19:24:01 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.193 2021/02/02 08:18:42 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1092,6 +1092,25 @@ data_access_fault(struct trapframe64 *tf
 	sticks = p->p_sticks;
 	tstate = tf->tf_tstate;
 
+#ifdef _LP64
+	/* deal with invalid VAs early */
+	if (__predict_false(addr >= (1UL<

CVS commit: src/sys/arch/sparc64/sparc64

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:01:14 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Add GPIO pin alert definitions for the E250.
Note, that the front panel also applies to the E450.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/sparc64/ofw_patch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.6 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.7
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.6	Thu Oct 29 06:47:38 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Wed Dec 23 07:01:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.7 2020/12/23 07:01:14 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.7 2020/12/23 07:01:14 jdc Exp $");
 
 #include 
 
@@ -134,6 +134,16 @@ add_gpio_props_e250(device_t dev, void *
 	prop_array_t pins;
 
 	switch (ia->ia_addr) {
+		case 0x38:	/* interrupt status */
+			pins = prop_array_create();
+			add_gpio_pin(pins, "ALERT high_temp", 1, 0, 30);
+			add_gpio_pin(pins, "ALERT disk_event", 2, 0, 30);
+			add_gpio_pin(pins, "ALERT fan_fail", 4, 0, 30);
+			add_gpio_pin(pins, "ALERT key_event", 5, 0, 30);
+			add_gpio_pin(pins, "ALERT psu_event", 6, 0, 30);
+			prop_dictionary_set(dict, "pins", pins);
+			prop_object_release(pins);
+			break;
 		case 0x39:	/* PSU status */
 			pins = prop_array_create();
 			add_gpio_pin(pins, "INDICATOR psu0_present", 0, 0, -1);
@@ -160,7 +170,7 @@ add_gpio_props_e250(device_t dev, void *
 			prop_dictionary_set(dict, "pins", pins);
 			prop_object_release(pins);
 			break;
-		case 0x3e:	/* front panel LEDs */
+		case 0x3e:	/* front panel LEDs (E250/E450) */
 			pins = prop_array_create();
 			add_gpio_pin(pins, "LED disk_fault", 0, 0, -1);
 			add_gpio_pin(pins, "LED psu_fault", 1, 0, -1);



CVS commit: src/sys/arch/sparc64/sparc64

2020-12-20 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Dec 20 11:58:58 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: add comment in sun4v_tl1_ptbl_miss code path - no functional change


To generate a diff of this commit:
cvs rdiff -u -r1.423 -r1.424 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.423 src/sys/arch/sparc64/sparc64/locore.s:1.424
--- src/sys/arch/sparc64/sparc64/locore.s:1.423	Wed Jan  8 20:59:20 2020
+++ src/sys/arch/sparc64/sparc64/locore.s	Sun Dec 20 11:58:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.423 2020/01/08 20:59:20 skrll Exp $	*/
+/*	$NetBSD: locore.s,v 1.424 2020/12/20 11:58:58 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -3343,6 +3343,8 @@ sun4v_tl1_ptbl_miss:
 	bgeu,pt	%xcc, 1f
 	 nop
 
+	/* We had a miss inside rtf_user_fault_start/rtf_user_fault_end block (FILL)
+	
 	/* Fixup %cwp. */
 	rdpr	%cwp, %g1
 	inc	%g1



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Oct 29 06:47:39 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c ofw_patch.c ofw_patch.h

Log Message:
Add information about GPIO pin assignments and drive bays in the E250 and
v240.  Consolidate common code for v210/v240 and E250.
Modify the GPIO pin names to include a type (currently LED or INDICATOR)
which we can then handle in the driver.


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/sparc64/ofw_patch.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/sparc64/ofw_patch.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.226 src/sys/arch/sparc64/sparc64/autoconf.c:1.227
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.226	Fri Oct 23 15:18:10 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Thu Oct 29 06:47:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.226 2020/10/23 15:18:10 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.227 2020/10/29 06:47:38 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.226 2020/10/23 15:18:10 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.227 2020/10/29 06:47:38 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1089,6 +1089,11 @@ device_register(device_t dev, void *aux)
 add_gpio_props_v210(dev, aux);
 			}
 		} 
+		if (device_is_a(dev, "pcf8574io")) {
+			if (!strcmp(machine_model, "SUNW,Ultra-250")) {
+add_gpio_props_e250(dev, aux);
+			}
+		} 
 	} else if (device_is_a(dev, "sd") || device_is_a(dev, "cd")) {
 		struct scsipibus_attach_args *sa = aux;
 		struct scsipi_periph *periph = sa->sa_periph;
@@ -1117,9 +1122,7 @@ device_register(device_t dev, void *aux)
 		0, periph->periph_lun);
 		if (device_is_a(busdev, "scsibus")) {
 			/* see if we're in a known SCA drivebay */
-			if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
-add_drivebay_props_v210(dev, ofnode, aux);
-			}
+			add_drivebay_props(dev, ofnode, aux);
 		}
 		return;
 	} else if (device_is_a(dev, "wd")) {

Index: src/sys/arch/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.5 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.6
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.5	Sun Oct 25 07:46:53 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Thu Oct 29 06:47:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $");
 
 #include 
 
@@ -42,11 +42,10 @@ __KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,
 #include 
 
 static void
-add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def)
+add_gpio_pin(prop_array_t pins, const char *name, int num, int act, int def)
 {
 	prop_dictionary_t pin = prop_dictionary_create();
 	prop_dictionary_set_string(pin, "name", name);
-	prop_dictionary_set_uint32(pin, "type", 0);	/* 0 for LED, for now */
 	prop_dictionary_set_uint32(pin, "pin", num);
 	prop_dictionary_set_bool(pin, "active_high", act);
 	if (def != -1)
@@ -62,7 +61,7 @@ create_i2c_dict(device_t busdev)
 	prop_array_t cfg = NULL;
 
 	cfg = prop_dictionary_get(props, "i2c-child-devices");
- 	if (!cfg) {
+	if (!cfg) {
 		DPRINTF(ACDB_PROBE, ("\nCreating new i2c-child-devices\n"));
 		cfg = prop_array_create();
 		prop_dictionary_set(props, "i2c-child-devices", cfg);
@@ -100,18 +99,89 @@ add_gpio_props_v210(device_t dev, void *
 	switch (ia->ia_addr) {
 		case 0x38:	/* front panel LEDs */
 			pins = prop_array_create();
-			add_gpio_LED(pins, "indicator", 7, 0, -1);
-			add_gpio_LED(pins, "fault", 5, 0, 0);
-			add_gpio_LED(pins, "power", 4, 0, 1);
+			add_gpio_pin(pins, "LED indicator", 7, 0, -1);
+			add_gpio_pin(pins, "LED fault", 5, 0, 0);
+			add_gpio_pin(pins, "LED power", 4, 0, 1);
 			prop_dictionary_set(dict, "pins", pins);
 			prop_object_release(pins);
 			break;
-		case 0x23:	/* drive bay LEDs */
+		case 0x23:	/* drive bay O/1 LEDs */
 			pins = prop_array_create();
-			add_gpio_LED(pins, "bay0_fault", 10, 0, 0);
-			add_gpio_LED(pins, "bay1_fault", 11, 0, 0);
-			add_gpio_LED(pins, "bay0_remove", 12, 0, 0);
-			add_gpio_LED(pins, "bay1_remove", 13, 0, 0);
+			add_gpio_pin(pins, "LED bay0_fault", 10, 0, 0);
+			add_gpio_pin(pins, "LED bay1_fault", 11, 0, 0);
+			add_gpio_pin(pins, "LED bay0_remove", 12, 0, 0);
+			add_gpio_pin(pins, "LED bay1_remove", 13, 0, 0);
+			prop_dictionary_set(dict, "pins", pins);
+			

CVS commit: src/sys/arch/sparc64/sparc64

2020-10-25 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Oct 25 07:46:54 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Don't release the last reference to the "i2c-child-devices" dictionary in
the v210/v240 patches.
Fixes missing i2c devices there (pointed out by macallan@).
While here, add debug to show when we create the dictionary.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/sparc64/ofw_patch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.5
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4	Sat Oct 24 13:47:53 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Sun Oct 25 07:46:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $");
 
 #include 
 
@@ -63,6 +63,7 @@ create_i2c_dict(device_t busdev)
 
 	cfg = prop_dictionary_get(props, "i2c-child-devices");
  	if (!cfg) {
+		DPRINTF(ACDB_PROBE, ("\nCreating new i2c-child-devices\n"));
 		cfg = prop_array_create();
 		prop_dictionary_set(props, "i2c-child-devices", cfg);
 		prop_dictionary_set_bool(props, "i2c-indirect-config", false);
@@ -171,8 +172,6 @@ add_env_sensors_v210(device_t busdev)
 	add_i2c_device(cfg, "hardware-monitor", "i2c-adm1026", 0x2e, 0);
 	/* LM75 at 0x4e */
 	add_i2c_device(cfg, "temperature-sensor", "i2c-lm75", 0x4e, 0);
-
-	prop_object_release(cfg);
 }
 
 /* Sensors and GPIO's for E450 and E250 */



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-24 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 24 13:47:53 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Add E250 i2c devices missing from the OFW tree.
Normalise the spelling of "temperature".


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/sparc64/ofw_patch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.3 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.3	Fri Oct 23 17:53:07 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Sat Oct 24 13:47:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $");
 
 #include 
 
@@ -187,13 +187,13 @@ add_i2c_props_e450(device_t busdev, uint
 	/* Power supply 1 temperature. */
 	add_i2c_device(cfg, "PSU-1", "ecadc", 0x48, node);
 
-	/* Power supply 2 termperature. */
+	/* Power supply 2 temperature. */
 	add_i2c_device(cfg, "PSU-2", "ecadc", 0x49, node);
 
-	/* Power supply 3 tempterature. */
+	/* Power supply 3 temperature. */
 	add_i2c_device(cfg, "PSU-3", "ecadc", 0x4a, node);
 
-	/* Ambient tempterature. */
+	/* Ambient temperature. */
 	add_i2c_device(cfg, "ambient", "i2c-lm75", 0x4d, node);
 
 	/* CPU temperatures. */
@@ -206,15 +206,29 @@ void
 add_i2c_props_e250(device_t busdev, uint64_t node)
 {
 	prop_array_t cfg;
+	int i;
 
 	DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ", machine_model));
 	cfg = create_i2c_dict(busdev);
 
 	/* PSU temperature / CPU fan */
 	add_i2c_device(cfg, "PSU", "ecadc", 0x4a, node);
+
 	/* CPU & system board temperature */
 	add_i2c_device(cfg, "CPU", "ecadc", 0x4f, node);
 
+	/* GPIO's */
+	for (i = 0x38; i <= 0x39; i++)
+		add_i2c_device(cfg, "gpio", "i2c-pcf8574", i, node);
+	for (i = 0x3d; i <= 0x3f; i++)
+		add_i2c_device(cfg, "gpio", "i2c-pcf8574", i, node);
+
+	/* NVRAM */
+	add_i2c_device(cfg, "nvram", "i2c-at24c02", 0x52, node);
+
+	/* RSC clock */
+	add_i2c_device(cfg, "rscrtc", "i2c-ds1307", 0x68, node);
+
 	prop_object_release(cfg);
 }
 



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-23 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Oct 23 17:53:07 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Add missing prop_object_release() to the E250/E450 patches.
Use the recently added (in r1.2) functions for SPARCle i2c devices too.
Simplify adding "compatible" entries and handle cases where there is none.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/sparc64/ofw_patch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.2 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.3
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.2	Fri Oct 23 15:18:10 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Fri Oct 23 17:53:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.2 2020/10/23 15:18:10 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.2 2020/10/23 15:18:10 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 jdc Exp $");
 
 #include 
 
@@ -75,15 +75,14 @@ add_i2c_device(prop_array_t cfg, const c
 uint32_t addr, uint64_t node)
 {
 	prop_dictionary_t dev;
-	prop_data_t data;
 
 	DPRINTF(ACDB_PROBE, ("\nAdding i2c device: %s (%s) @ 0x%x (%lx)\n",
-	name, compat, addr, node & 0x));
+	name, compat == NULL ? "NULL" : compat, addr, node & 0x));
 	dev = prop_dictionary_create();
 	prop_dictionary_set_string(dev, "name", name);
-	data = prop_data_create_copy(compat, strlen(compat) + 1);
-	prop_dictionary_set(dev, "compatible", data);
-	prop_object_release(data);
+	if (compat != NULL)
+		prop_dictionary_set_data(dev, "compatible", compat,
+		strlen(compat) + 1);
 	prop_dictionary_set_uint32(dev, "addr", addr);
 	prop_dictionary_set_uint64(dev, "cookie", node);
 	prop_array_add(cfg, dev);
@@ -146,20 +145,14 @@ add_drivebay_props_v210(device_t dev, in
 void
 add_spdmem_props_sparcle(device_t busdev)
 {
-	prop_dictionary_t props = device_properties(busdev);
-	prop_array_t cfg = prop_array_create();
+	prop_array_t cfg;
 	int i;
 
 	DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle "));
-	for (i = 0x50; i <= 0x51; i++) {
-		prop_dictionary_t spd = prop_dictionary_create();
-		prop_dictionary_set_string(spd, "name", "dimm-spd");
-		prop_dictionary_set_uint32(spd, "addr", i);
-		prop_dictionary_set_uint64(spd, "cookie", 0);
-		prop_array_add(cfg, spd);
-		prop_object_release(spd);
-	}
-	prop_dictionary_set(props, "i2c-child-devices", cfg);
+
+	cfg = create_i2c_dict(busdev);
+	for (i = 0x50; i <= 0x51; i++)
+		add_i2c_device(cfg, "dimm-spd", NULL, i, 0);
 	prop_object_release(cfg);
 }
 
@@ -205,6 +198,8 @@ add_i2c_props_e450(device_t busdev, uint
 
 	/* CPU temperatures. */
 	add_i2c_device(cfg, "CPU", "ecadc", 0x4f, node);
+
+	prop_object_release(cfg);
 }
 
 void
@@ -219,6 +214,8 @@ add_i2c_props_e250(device_t busdev, uint
 	add_i2c_device(cfg, "PSU", "ecadc", 0x4a, node);
 	/* CPU & system board temperature */
 	add_i2c_device(cfg, "CPU", "ecadc", 0x4f, node);
+
+	prop_object_release(cfg);
 }
 
 /* Hardware specific device properties */



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-17 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 17 08:10:31 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c ofw_patch.h

Log Message:
Avoid declaring autoconf_debug twice when building with DEBUG.
Pointed out by palle@ - thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/sparc64/ofw_patch.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.224 src/sys/arch/sparc64/sparc64/autoconf.c:1.225
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.224	Fri Oct 16 07:35:16 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Oct 17 08:10:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.224 2020/10/16 07:35:16 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.225 2020/10/17 08:10:31 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.224 2020/10/16 07:35:16 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.225 2020/10/17 08:10:31 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -116,6 +116,8 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 
 #include "ksyms.h"
 
+int autoconf_debug = 0x0;
+
 struct evcnt intr_evcnts[] = {
 	EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "spur"),
 	EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev1"),

Index: src/sys/arch/sparc64/sparc64/ofw_patch.h
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.h:1.1 src/sys/arch/sparc64/sparc64/ofw_patch.h:1.2
--- src/sys/arch/sparc64/sparc64/ofw_patch.h:1.1	Fri Oct 16 07:35:16 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.h	Sat Oct 17 08:10:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.h,v 1.1 2020/10/16 07:35:16 jdc Exp $ */
+/*	$NetBSD: ofw_patch.h,v 1.2 2020/10/17 08:10:31 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #define ACDB_BOOTDEV0x1
 #define ACDB_PROBE  0x2
 #define ACDB_BOOTARGS   0x4
-int autoconf_debug = 0x0;
+extern int autoconf_debug;
 #define DPRINTF(l, s)   do { if (autoconf_debug & l) printf s; } while (0)
 #else
 #define DPRINTF(l, s)



CVS commit: src/sys/arch/sparc64/sparc64

2020-07-23 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Jul 23 16:08:03 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
Move machine-specific fixes into separate functions to improve readability.


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.221 src/sys/arch/sparc64/sparc64/autoconf.c:1.222
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.221	Sun Jul  5 09:56:06 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Thu Jul 23 16:08:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -,6 +,101 @@ add_drivebay_props_v210(device_t dev, in
 }
 
 /*
+ * Add SPARCle spdmem devices (0x50 and 0x51) that are not in the OFW tree
+ */
+static void
+add_spdmem_props_sparcle(device_t busdev)
+{
+	prop_dictionary_t props = device_properties(busdev);
+	prop_array_t cfg = prop_array_create();
+	int i;
+
+	DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle "));
+	for (i = 0x50; i <= 0x51; i++) {
+		prop_dictionary_t spd = prop_dictionary_create();
+		prop_dictionary_set_string(spd, "name", "dimm-spd");
+		prop_dictionary_set_uint32(spd, "addr", i);
+		prop_dictionary_set_uint64(spd, "cookie", 0);
+		prop_array_add(cfg, spd);
+		prop_object_release(spd);
+	}
+	prop_dictionary_set(props, "i2c-child-devices", cfg);
+	prop_object_release(cfg);
+}
+
+/*
+ * Add V210/V240 environmental sensors that are not in the OFW tree.
+ */
+static void
+add_env_sensors_v210(device_t busdev)
+{
+	prop_dictionary_t props = device_properties(busdev);
+	prop_array_t cfg = NULL;
+	prop_dictionary_t sens;
+	prop_data_t data;
+	const char name_lm[] = "i2c-lm75";
+	const char name_adm[] = "i2c-adm1026";
+
+	DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ", machine_model));
+	cfg = prop_dictionary_get(props, "i2c-child-devices");
+ 	if (!cfg) {
+		cfg = prop_array_create();
+		prop_dictionary_set(props, "i2c-child-devices", cfg);
+		prop_dictionary_set_bool(props, "i2c-indirect-config", false);
+	}
+
+	/* ADM1026 at 0x2e */
+	sens = prop_dictionary_create();
+	prop_dictionary_set_uint32(sens, "addr", 0x2e);
+	prop_dictionary_set_uint64(sens, "cookie", 0);
+	prop_dictionary_set_string(sens, "name", "hardware-monitor");
+	data = prop_data_create_copy(_adm[0], sizeof(name_adm));
+	prop_dictionary_set(sens, "compatible", data);
+	prop_object_release(data);
+	prop_array_add(cfg, sens);
+	prop_object_release(sens);
+
+	/* LM75 at 0x4e */
+	sens = prop_dictionary_create();
+	prop_dictionary_set_uint32(sens, "addr", 0x4e);
+	prop_dictionary_set_uint64(sens, "cookie", 0);
+	prop_dictionary_set_string(sens, "name", "temperature-sensor");
+	data = prop_data_create_copy(_lm[0], sizeof(name_lm));
+	prop_dictionary_set(sens, "compatible", data);
+	prop_object_release(data);
+	prop_array_add(cfg, sens);
+	prop_object_release(sens);
+}
+
+/* Hardware specific device properties */
+static void
+set_hw_props(device_t dev)
+{
+	device_t busdev = device_parent(dev);
+
+	if ((!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+	!strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
+		device_t busparent = device_parent(busdev);
+		prop_dictionary_t props = device_properties(dev);
+
+		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+		device_is_a(dev, "adm1026hm") && props != NULL) {
+			prop_dictionary_set_uint8(props, "fan_div2", 0x55);
+			prop_dictionary_set_bool(props, "multi_read", true);
+		}
+	}
+
+	if (!strcmp(machine_model, "SUNW,Sun-Fire-V440")) {
+		device_t busparent = device_parent(busdev);
+		prop_dictionary_t props = device_properties(dev);
+		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+		device_is_a(dev, "adm1026hm") && props != NULL) {
+			prop_dictionary_set_bool(props, "multi_read", true);
+		}
+	}
+}
+
+/*
  * Called back during autoconfiguration for each device found
  */
 void
@@ -1155,7 +1250,8 @@ device_register(device_t dev, void *aux)
 
 		ofnode = (int)ia->ia_cookie;
 		if (device_is_a(dev, "pcagpio")) {
-			if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
+			if (!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+			!strcmp(machine_model, "SUNW,Sun-Fire-V210")) {
 add_gpio_props_v210(dev, aux);
 			}
 		} 
@@ -1344,82 +1440,13 @@ noether:
 			}
 		}
 
-		/*
-		 * Add SPARCle spdmem devices (0x50 and 0x51) that the
-		 * firmware does not know about.
-		 */
-		if (!strcmp(machine_model, 

CVS commit: src/sys/arch/sparc64/sparc64

2020-07-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jul  5 09:56:06 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
Adapt to proplib api changes


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.220 src/sys/arch/sparc64/sparc64/autoconf.c:1.221
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.220	Sun Jul  5 09:27:11 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Jul  5 09:56:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1413,7 +1413,7 @@ noether:
 			prop_dictionary_set_uint64(sens, "cookie", 0);
 			prop_dictionary_set_string(sens, "name",
 			"temperature-sensor");
-			data = prop_data_create_data(_lm[0],
+			data = prop_data_create_copy(_lm[0],
 			sizeof(name_lm));
 			prop_dictionary_set(sens, "compatible", data);
 			prop_object_release(data);



CVS commit: src/sys/arch/sparc64/sparc64

2020-07-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jul  5 09:27:11 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
Adapt to proplib api changes


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.219 src/sys/arch/sparc64/sparc64/autoconf.c:1.220
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.219	Fri Jun 12 03:32:30 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Jul  5 09:27:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.219 2020/06/12 03:32:30 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.219 2020/06/12 03:32:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1050,7 +1050,7 @@ static void
 add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def)
 {
 	prop_dictionary_t pin = prop_dictionary_create();
-	prop_dictionary_set_cstring(pin, "name", name);
+	prop_dictionary_set_string(pin, "name", name);
 	prop_dictionary_set_uint32(pin, "type", 0);	/* 0 for LED, for now */
 	prop_dictionary_set_uint32(pin, "pin", num);
 	prop_dictionary_set_bool(pin, "active_high", act);
@@ -1106,7 +1106,7 @@ add_drivebay_props_v210(device_t dev, in
 		char name[16];
 
 		snprintf(name, sizeof(name), "bay%d", target);		
-		prop_dictionary_set_cstring(dict, "location", name);
+		prop_dictionary_set_string(dict, "location", name);
 	}
 }
 
@@ -1258,7 +1258,7 @@ device_register(device_t dev, void *aux)
 if (!prom_get_node_ether(ofnode, eaddr))
 	goto noether;
 			}
-			blob = prop_data_create_data(eaddr, ETHER_ADDR_LEN);
+			blob = prop_data_create_copy(eaddr, ETHER_ADDR_LEN);
 			prop_dictionary_set(dict, "mac-address", blob);
 			prop_object_release(blob);
 			of_to_dataprop(dict, ofnode, "shared-pins",
@@ -1357,7 +1357,7 @@ noether:
 			for (i = 0x50; i <= 0x51; i++) {
 prop_dictionary_t spd =
 prop_dictionary_create();
-prop_dictionary_set_cstring(spd, "name",
+prop_dictionary_set_string(spd, "name",
 "dimm-spd");
 prop_dictionary_set_uint32(spd, "addr", i);
 prop_dictionary_set_uint64(spd, "cookie", 0);
@@ -1398,9 +1398,9 @@ noether:
 			sens = prop_dictionary_create();
 			prop_dictionary_set_uint32(sens, "addr", 0x2e);
 			prop_dictionary_set_uint64(sens, "cookie", 0);
-			prop_dictionary_set_cstring(sens, "name",
+			prop_dictionary_set_string(sens, "name",
 			"hardware-monitor");
-			data = prop_data_create_data(_adm[0],
+			data = prop_data_create_copy(_adm[0],
 			sizeof(name_adm));
 			prop_dictionary_set(sens, "compatible", data);
 			prop_object_release(data);
@@ -1411,7 +1411,7 @@ noether:
 			sens = prop_dictionary_create();
 			prop_dictionary_set_uint32(sens, "addr", 0x4e);
 			prop_dictionary_set_uint64(sens, "cookie", 0);
-			prop_dictionary_set_cstring(sens, "name",
+			prop_dictionary_set_string(sens, "name",
 			"temperature-sensor");
 			data = prop_data_create_data(_lm[0],
 			sizeof(name_lm));
@@ -1669,7 +1669,7 @@ copyprops(device_t busdev, int node, pro
 	pos = strstr(output_device, ":r");
 	if (pos == NULL)
 		return;
-	prop_dictionary_set_cstring(dict, "videomode", pos + 2);
+	prop_dictionary_set_string(dict, "videomode", pos + 2);
 }
 
 static void



CVS commit: src/sys/arch/sparc64/sparc64

2020-06-09 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jun  9 21:57:00 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
proplib API catchup
NFCI, tested on v210


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.217 src/sys/arch/sparc64/sparc64/autoconf.c:1.218
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.217	Sun Feb 23 05:14:29 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Tue Jun  9 21:57:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.217 2020/02/23 05:14:29 macallan Exp $ */
+/*	$NetBSD: autoconf.c,v 1.218 2020/06/09 21:57:00 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.217 2020/02/23 05:14:29 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.218 2020/06/09 21:57:00 macallan Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1019,7 +1019,7 @@ device_ofnode(device_t dev)
 	if (obj == NULL)
 		return 0;
 
-	return prop_number_integer_value(obj);
+	return prop_number_signed_value(obj);
 }
 
 /*
@@ -1037,7 +1037,7 @@ device_setofnode(device_t dev, int node)
 	props = device_properties(dev);
 	if (props == NULL)
 		return;
-	obj = prop_number_create_integer(node);
+	obj = prop_number_create_signed(node);
 	if (obj == NULL)
 		return;
 	prop_dictionary_set(props, OFNODEKEY, obj);
@@ -1274,7 +1274,7 @@ noether:
 			if (OF_getprop(ofnode, "port-wwn", , sizeof(pwwn))
 			== sizeof(pwwn)) {
 pwwnd = 
-prop_number_create_unsigned_integer(pwwn);
+prop_number_create_unsigned(pwwn);
 prop_dictionary_set(dict, "port-wwn", pwwnd);
 prop_object_release(pwwnd);
 			}
@@ -1282,7 +1282,7 @@ noether:
 			if (OF_getprop(ofnode, "node-wwn", , sizeof(nwwn))
 			== sizeof(nwwn)) {
 nwwnd = 
-prop_number_create_unsigned_integer(nwwn);
+prop_number_create_unsigned(nwwn);
 prop_dictionary_set(dict, "node-wwn", nwwnd);
 prop_object_release(nwwnd);
 			}
@@ -1299,7 +1299,7 @@ noether:
 sizeof(id)) <= 0)
 	continue;
 
-idd = prop_number_create_unsigned_integer(id);
+idd = prop_number_create_unsigned(id);
 prop_dictionary_set(dict,
 		"scsi-initiator-id", idd);
 prop_object_release(idd);



CVS commit: src/sys/arch/sparc64/sparc64

2020-05-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May 31 11:28:52 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: db_trace.c

Log Message:
Avoid using excessive kernel stack.
XXX maybe we should unite all "static proc_t" and "static lwp_t" in ddb
into one global each?


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/sparc64/sparc64/db_trace.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/db_trace.c
diff -u src/sys/arch/sparc64/sparc64/db_trace.c:1.54 src/sys/arch/sparc64/sparc64/db_trace.c:1.55
--- src/sys/arch/sparc64/sparc64/db_trace.c:1.54	Tue Mar 10 15:54:52 2020
+++ src/sys/arch/sparc64/sparc64/db_trace.c	Sun May 31 11:28:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.54 2020/03/10 15:54:52 christos Exp $ */
+/*	$NetBSD: db_trace.c,v 1.55 2020/05/31 11:28:52 martin Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.54 2020/03/10 15:54:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.55 2020/05/31 11:28:52 martin Exp $");
 
 #include 
 #include 
@@ -102,9 +102,10 @@ db_stack_trace_print(db_expr_t addr, boo
 #endif
 	} else {
 		if (trace_thread) {
-			proc_t p;
-			lwp_t l;
+			static proc_t p;
+			static lwp_t l;
 			struct pcb *pcb;
+
 			if (lwpaddr) {
 db_read_bytes(addr, sizeof(l), (char *));
 db_read_bytes((db_addr_t)l.l_proc,



CVS commit: src/sys/arch/sparc64/sparc64

2020-02-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Feb 23 05:14:29 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
add location info to sd instances if we know which drive bay they live in
Sun Fire v210 only for now, others should be easy to add


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.216 src/sys/arch/sparc64/sparc64/autoconf.c:1.217
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.216	Sun Feb  2 06:38:23 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Feb 23 05:14:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.216 2020/02/02 06:38:23 macallan Exp $ */
+/*	$NetBSD: autoconf.c,v 1.217 2020/02/23 05:14:29 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.216 2020/02/02 06:38:23 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.217 2020/02/23 05:14:29 macallan Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1088,6 +1088,28 @@ add_gpio_props_v210(device_t dev, void *
 	}
 }
 
+static void
+add_drivebay_props_v210(device_t dev, int ofnode, void *aux)
+{
+	struct scsipibus_attach_args *sa = aux;
+	int target = sa->sa_periph->periph_target;
+	char path[256]= "";
+
+	OF_package_to_path(ofnode, path, sizeof(path));
+
+	/* see if we're on the onboard controller's 1st channel */
+	if (strcmp(path, "/pci@1c,60/scsi@2") != 0)
+		return;
+	/* yes, yes we are */
+	if ( target < 2) {
+		prop_dictionary_t dict = device_properties(dev);
+		char name[16];
+
+		snprintf(name, sizeof(name), "bay%d", target);		
+		prop_dictionary_set_cstring(dict, "location", name);
+	}
+}
+
 /*
  * Called back during autoconfiguration for each device found
  */
@@ -1163,6 +1185,12 @@ device_register(device_t dev, void *aux)
 		ofnode = device_ofnode(device_parent(busdev));
 		dev_bi_unit_drive_match(dev, ofnode, periph->periph_target + off,
 		0, periph->periph_lun);
+		if (device_is_a(busdev, "scsibus")) {
+			/* see if we're in a known SCA drivebay */
+			if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
+add_drivebay_props_v210(dev, ofnode, aux);
+			}
+		}
 		return;
 	} else if (device_is_a(dev, "wd")) {
 		struct ata_device *adev = aux;



CVS commit: src/sys/arch/sparc64/sparc64

2020-02-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Feb  2 06:38:24 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
pass pin info to pcagpio instances, so far for front panel LEDs on
Sun Fire v210 only


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.216 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.215 src/sys/arch/sparc64/sparc64/autoconf.c:1.216
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.215	Sat Jan  5 15:46:02 2019
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Feb  2 06:38:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.215 2019/01/05 15:46:02 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.216 2020/02/02 06:38:23 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.215 2019/01/05 15:46:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.216 2020/02/02 06:38:23 macallan Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1046,6 +1046,48 @@ device_setofnode(device_t dev, int node)
 	device_xname(dev), node));
 }
 
+static void
+add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def)
+{
+	prop_dictionary_t pin = prop_dictionary_create();
+	prop_dictionary_set_cstring(pin, "name", name);
+	prop_dictionary_set_uint32(pin, "type", 0);	/* 0 for LED, for now */
+	prop_dictionary_set_uint32(pin, "pin", num);
+	prop_dictionary_set_bool(pin, "active_high", act);
+	if (def != -1)
+		prop_dictionary_set_int32(pin, "default_state", def);
+	prop_array_add(pins, pin);
+	prop_object_release(pin);
+}
+	
+static void
+add_gpio_props_v210(device_t dev, void *aux)
+{
+	struct i2c_attach_args *ia = aux;
+	prop_dictionary_t dict = device_properties(dev);
+	prop_array_t pins;
+
+	switch (ia->ia_addr) {
+		case 0x38:	/* front panel LEDs */
+			pins = prop_array_create();
+			add_gpio_LED(pins, "indicator", 7, 0, -1);
+			add_gpio_LED(pins, "fault", 5, 0, 0);
+			add_gpio_LED(pins, "power", 4, 0, 1);
+			prop_dictionary_set(dict, "pins", pins);
+			prop_object_release(pins);
+			break;
+		case 0x23:	/* drive bay LEDs */
+			pins = prop_array_create();
+			add_gpio_LED(pins, "bay0_fault", 10, 0, 0);
+			add_gpio_LED(pins, "bay1_fault", 11, 0, 0);
+			add_gpio_LED(pins, "bay0_remove", 12, 0, 0);
+			add_gpio_LED(pins, "bay1_remove", 13, 0, 0);
+			prop_dictionary_set(dict, "pins", pins);
+			prop_object_release(pins);
+			break;
+	}
+}
+
 /*
  * Called back during autoconfiguration for each device found
  */
@@ -1090,6 +1132,11 @@ device_register(device_t dev, void *aux)
 			return;
 
 		ofnode = (int)ia->ia_cookie;
+		if (device_is_a(dev, "pcagpio")) {
+			if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
+add_gpio_props_v210(dev, aux);
+			}
+		} 
 	} else if (device_is_a(dev, "sd") || device_is_a(dev, "cd")) {
 		struct scsipibus_attach_args *sa = aux;
 		struct scsipi_periph *periph = sa->sa_periph;



CVS commit: src/sys/arch/sparc64/sparc64

2019-12-29 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Dec 30 06:54:31 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: cpu.c

Log Message:
add highly experimental NUMA support for US-IIIi machines


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/arch/sparc64/sparc64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/cpu.c
diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.136 src/sys/arch/sparc64/sparc64/cpu.c:1.137
--- src/sys/arch/sparc64/sparc64/cpu.c:1.136	Tue Oct  1 18:00:08 2019
+++ src/sys/arch/sparc64/sparc64/cpu.c	Mon Dec 30 06:54:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.136 2019/10/01 18:00:08 chs Exp $ */
+/*	$NetBSD: cpu.c,v 1.137 2019/12/30 06:54:31 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.136 2019/10/01 18:00:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.137 2019/12/30 06:54:31 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -556,7 +556,15 @@ cpu_attach(device_t parent, device_t dev
 		(u_int)GETVER_CPU_IMPL(),
 		(u_int)GETVER_CPU_MASK());
 	}
-
+#ifdef NUMA
+	if (CPU_IS_USIIIi()) {
+		uint64_t start = ci->ci_cpuid;
+		start <<= 36;
+		ci->ci_numa_id = ci->ci_cpuid;
+		printf("NUMA bucket %d %016lx\n", ci->ci_cpuid, start);
+		uvm_page_numa_load(start, 0x10, ci->ci_cpuid);
+	}
+#endif
 	if (ci->ci_system_clockrate[0] != 0) {
 		aprint_normal_dev(dev, "system tick frequency %s MHz\n",
 		clockfreq(ci->ci_system_clockrate[0]));



CVS commit: src/sys/arch/sparc64/sparc64

2019-04-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Apr  7 19:31:38 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
make trap 0x70 a TRAP() not UTRAP().  we should be able to handle
fast ECC error as a normal trap, and i saw this once a few years
ago but it never repeated so i haven't been able to test this.


To generate a diff of this commit:
cvs rdiff -u -r1.419 -r1.420 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.419 src/sys/arch/sparc64/sparc64/locore.s:1.420
--- src/sys/arch/sparc64/sparc64/locore.s:1.419	Fri Feb  8 20:34:23 2019
+++ src/sys/arch/sparc64/sparc64/locore.s	Sun Apr  7 19:31:38 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.419 2019/02/08 20:34:23 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.420 2019/04/07 19:31:38 mrg Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -763,7 +763,8 @@ ufast_DMMU_protection:			! 06c = fast da
 #endif
 	nop
 	TA32
-	UTRAP(0x070)			! Implementation dependent traps
+	TRAP(0x070)			! 0x070 fast_ECC_error
+	! Implementation dependent traps
 	UTRAP(0x071); UTRAP(0x072); UTRAP(0x073); UTRAP(0x074); UTRAP(0x075); UTRAP(0x076)
 	UTRAP(0x077); UTRAP(0x078); UTRAP(0x079); UTRAP(0x07a); UTRAP(0x07b); UTRAP(0x07c)
 	UTRAP(0x07d); UTRAP(0x07e); UTRAP(0x07f)
@@ -973,7 +974,8 @@ kfast_DMMU_protection:			! 06c = fast da
 #endif
 	nop
 	TA32
-	UTRAP(0x070)			! Implementation dependent traps
+	TRAP(0x070)			! 0x070 fast_ECC_error
+	! Implementation dependent traps
 	UTRAP(0x071); UTRAP(0x072); UTRAP(0x073); UTRAP(0x074); UTRAP(0x075); UTRAP(0x076)
 	UTRAP(0x077); UTRAP(0x078); UTRAP(0x079); UTRAP(0x07a); UTRAP(0x07b); UTRAP(0x07c)
 	UTRAP(0x07d); UTRAP(0x07e); UTRAP(0x07f)



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-15 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Feb 15 16:36:33 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: trap.c

Log Message:
Add /* FALLTHROUGH */ for DEBUG kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/sys/arch/sparc64/sparc64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.190 src/sys/arch/sparc64/sparc64/trap.c:1.191
--- src/sys/arch/sparc64/sparc64/trap.c:1.190	Thu Feb 14 20:09:40 2019
+++ src/sys/arch/sparc64/sparc64/trap.c	Fri Feb 15 16:36:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.190 2019/02/14 20:09:40 palle Exp $ */
+/*	$NetBSD: trap.c,v 1.191 2019/02/15 16:36:33 hannken Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.190 2019/02/14 20:09:40 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.191 2019/02/15 16:36:33 hannken Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -625,6 +625,7 @@ dopanic:
 		   l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm,
 		   pc, type, type < N_TRAP_TYPES ? trap_type[type] : T);
 #endif
+		/* FALLTHROUGH */
 	case T_ILLINST:
 #if defined(DDB) && defined(DEBUG)
 		if (trapdebug & TDB_STOPSIG)



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-14 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Feb 14 20:09:40 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: trap.c

Log Message:
sun4v: add debug printout for ALIGN trap


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/arch/sparc64/sparc64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.189 src/sys/arch/sparc64/sparc64/trap.c:1.190
--- src/sys/arch/sparc64/sparc64/trap.c:1.189	Wed Dec 19 13:57:50 2018
+++ src/sys/arch/sparc64/sparc64/trap.c	Thu Feb 14 20:09:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.189 2018/12/19 13:57:50 maxv Exp $ */
+/*	$NetBSD: trap.c,v 1.190 2019/02/14 20:09:40 palle Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.189 2018/12/19 13:57:50 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.190 2019/02/14 20:09:40 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -717,6 +717,10 @@ dopanic:
 #ifdef DEBUG
 		if (!CPU_ISSUN4V) {
 			isfsr = ldxa(SFSR, ASI_IMMU);
+		} else {
+		  paddr_t mmu_fsa_ifa = cpus->ci_mmufsa
+		+ offsetof(struct mmufsa, ifa);
+			isfsr = ldxa(mmu_fsa_ifa, ASI_PHYS_CACHED);
 		}
 #endif
 		/* 
@@ -731,10 +735,34 @@ dopanic:
 		
 #ifdef DEBUG
 #define fmt64(x)	(u_int)((x)>>32), (u_int)((x))
-		printf("Alignment error: pid=%d.%d comm=%s dsfsr=%08x:%08x "
-		   "dsfar=%x:%x isfsr=%08x:%08x pc=%lx\n",
-		   l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm, fmt64(dsfsr), fmt64(dsfar),
-		   fmt64(isfsr), pc);
+		if (!CPU_ISSUN4V) {
+			printf("Alignment error: pid=%d.%d comm=%s dsfsr=%08x:%08x "
+			   "dsfar=%x:%x isfsr=%08x:%08x pc=%lx\n",
+			   l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm, fmt64(dsfsr), fmt64(dsfar),
+			   fmt64(isfsr), pc);
+		} else {
+		  
+			printf("Alignment error: pid=%d.%d comm=%s pc=%lx\n",
+			   l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm, pc);
+			paddr_t mmufsa_ift_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ift);
+			paddr_t mmufsa_ifa_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ifa);
+			paddr_t mmufsa_ifc_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ifc);
+			paddr_t mmufsa_dft_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dft);
+			paddr_t mmufsa_dfa_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dfa);
+			paddr_t mmufsa_dfc_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dfc);
+			int64_t ift = ldxa(mmufsa_ift_addr, ASI_PHYS_CACHED);
+			printf("ift = %016lx\n", ift);
+			int64_t ifa = ldxa(mmufsa_ifa_addr, ASI_PHYS_CACHED);
+			printf("ifa = %016lx\n", ifa);
+			int64_t ifc = ldxa(mmufsa_ifc_addr, ASI_PHYS_CACHED);
+			printf("ifc = %016lx\n", ifc);
+			int64_t dft = ldxa(mmufsa_dft_addr, ASI_PHYS_CACHED);
+			printf("dft = %016lx\n", dft);
+			int64_t dfa = ldxa(mmufsa_dfa_addr, ASI_PHYS_CACHED);
+			printf("dfa = %016lx\n", dfa);
+			int64_t dfc = ldxa(mmufsa_dfc_addr, ASI_PHYS_CACHED);
+			printf("dfc = %016lx\n", dfc);
+		}
 #endif
 		
 #if defined(DDB) && defined(DEBUG)



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-10 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Feb 11 07:51:46 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: vm_machdep.c

Log Message:
retry timed out IPIs, complain and dump timing info into dmesg
ok martin@


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/sparc64/sparc64/vm_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/vm_machdep.c
diff -u src/sys/arch/sparc64/sparc64/vm_machdep.c:1.101 src/sys/arch/sparc64/sparc64/vm_machdep.c:1.102
--- src/sys/arch/sparc64/sparc64/vm_machdep.c:1.101	Fri Nov  6 15:30:59 2015
+++ src/sys/arch/sparc64/sparc64/vm_machdep.c	Mon Feb 11 07:51:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.101 2015/11/06 15:30:59 martin Exp $ */
+/*	$NetBSD: vm_machdep.c,v 1.102 2019/02/11 07:51:46 macallan Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.101 2015/11/06 15:30:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.102 2019/02/11 07:51:46 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -305,12 +305,13 @@ fpusave_lwp(struct lwp *l, bool save)
 	}
 
 	for (ci = cpus; ci != NULL; ci = ci->ci_next) {
-		int spincount;
+		int spincount, retrycount=0;
 
 		if (ci == curcpu() || !CPUSET_HAS(cpus_active, ci->ci_index))
 			continue;
 		if (ci->ci_fplwp != l)
 			continue;
+again:
 		sparc64_send_ipi(ci->ci_cpuid, save ?
  sparc64_ipi_save_fpstate :
  sparc64_ipi_drop_fpstate, (uintptr_t)l, 0);
@@ -319,9 +320,13 @@ fpusave_lwp(struct lwp *l, bool save)
 		while (ci->ci_fplwp == l) {
 			membar_Sync();
 			spincount++;
-			if (spincount > 1000)
-panic("fpusave_lwp ipi didn't");
+			if (spincount > 1000) {
+printf("fpusave_lwp ipi didn't (%d)\n", retrycount);
+retrycount++;
+goto again;
+			}
 		}
+		if (retrycount > 0) printf("spincount %d\n", spincount);
 		break;
 	}
 #else



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Feb  8 20:34:23 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: Improve comment for next_stick_init() - no functional changes


To generate a diff of this commit:
cvs rdiff -u -r1.418 -r1.419 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.418 src/sys/arch/sparc64/sparc64/locore.s:1.419
--- src/sys/arch/sparc64/sparc64/locore.s:1.418	Fri Feb  8 20:14:51 2019
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri Feb  8 20:34:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.418 2019/02/08 20:14:51 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.419 2019/02/08 20:34:23 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -7513,6 +7513,9 @@ Lstick_ovflw:
  * Sets the %stick_cmpr register to the value retrieved from %stick so
  * next_stick() does not spend too much time in the function when called
  * for the first time.
+ * This has been observed on (at least) a SPARC-T5 (sun4v) system where
+ * the %stick_cmpr ends up being less than the %stick value and then
+ * the stickitr() interrupt is never triggered.
  */
 ENTRY(next_stick_init)
 	rd	STICK, %o0



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Feb  8 19:45:24 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: introduce macros for handling spill traps from userlevevel @ traplevel 1 
(from OpenBSD) - spill traps at level 1 from userspace now works better


To generate a diff of this commit:
cvs rdiff -u -r1.416 -r1.417 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.416 src/sys/arch/sparc64/sparc64/locore.s:1.417
--- src/sys/arch/sparc64/sparc64/locore.s:1.416	Fri Feb  8 19:26:25 2019
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri Feb  8 19:45:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.416 2019/02/08 19:26:25 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.417 2019/02/08 19:45:24 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -227,6 +227,18 @@
 	LDPTR	[\reg + %lo(CPUINFO_VA + CI_TSB_DMMU)], \reg
 	.endm
 
+	.macro sun4v_tl1_uspill_normal
+	ba,a,pt	%xcc, pcbspill_normals
+	 nop
+	.align 128
+	.endm
+
+	.macro sun4v_tl1_uspill_other
+	ba,a,pt	%xcc, pcbspill_others
+	 nop
+	.align 128
+	.endm
+	
 #endif
 		
 #if 1
@@ -1155,17 +1167,17 @@ _C_LABEL(trapbase_sun4v):
 	sun4v_trap_entry 56	! 0x034-0x06b
 	VTRAP(T_FDMMU_PROT, sun4v_tl1_dtsb_prot)		! 0x06c
 	sun4v_trap_entry 19	! 0x06d-0x07f
-	SPILL64(uspill8_sun4vt1,ASI_AIUS)			! 0x080 spill_0_normal -- save user windows
-	SPILL32(uspill4_sun4vt1,ASI_AIUS)			! 0x084 spill_1_normal
-	SPILLBOTH(uspill8_sun4vt1,uspill4_sun4vt1,ASI_AIUS)	! 0x088 spill_2_normal
+	sun4v_tl1_uspill_normal	! 0x080 spill_0_normal -- save user windows
+	sun4v_tl1_uspill_normal	! 0x084 spill_1_normal
+	sun4v_tl1_uspill_normal	! 0x088 spill_2_normal
 	sun4v_trap_entry_spill_fill_fail 1			! 0x08c spill_3_normal
 	SPILL64(kspill8_sun4vt1,ASI_N)! 0x090 spill_4_normal -- save supervisor windows
 	SPILL32(kspill4_sun4vt1,ASI_N)! 0x094 spill_5_normal
 	SPILLBOTH(kspill8_sun4vt1,kspill4_sun4vt1,ASI_N)	! 0x098 spill_6_normal
 	sun4v_trap_entry_spill_fill_fail 1			! 0x09c spill_7_normal
-	SPILL64(uspillk8_sun4vt1,ASI_AIUS)			! 0x0a0 spill_0_other -- save user windows in nucleus mode
-	SPILL32(uspillk4_sun4vt1,ASI_AIUS)			! 0x0a4 spill_1_other
-	SPILLBOTH(uspillk8_sun4vt1,uspillk4_sun4vt1,ASI_AIUS)	! 0x0a8 spill_2_other
+	sun4v_tl1_uspill_other	! 0x0a0 spill_0_other -- save user windows in nucleus mode
+	sun4v_tl1_uspill_other	! 0x0a4 spill_1_other
+	sun4v_tl1_uspill_other	! 0x0a8 spill_2_other
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0ac spill_3_other
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0b0 spill_4_other
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0b4 spill_5_other



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Feb  8 19:26:25 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: add comment documenting the contents of the %g2 register - no functional 
changes


To generate a diff of this commit:
cvs rdiff -u -r1.415 -r1.416 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.415 src/sys/arch/sparc64/sparc64/locore.s:1.416
--- src/sys/arch/sparc64/sparc64/locore.s:1.415	Sun Nov  4 20:02:07 2018
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri Feb  8 19:26:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.415 2018/11/04 20:02:07 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.416 2019/02/08 19:26:25 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -3034,7 +3034,7 @@ sun4v_tl0_dtsb_prot:
 
 #	btst	SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4	! Is it a ref fault?
 	mov	1, %g2
-	sllx	%g2, 61, %g2
+	sllx	%g2, 61, %g2			! %g2 is now SUN4V_TLB_REAL_W
 	or	%g2, SUN4V_TLB_W, %g2
 	btst	%g2, %g4
 	bz,pn	%xcc, sun4v_datatrap			! No -- really fault
@@ -3263,7 +3263,7 @@ sun4v_tl1_dtsb_prot:
 
 #	btst	SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4	! Is it a ref fault?
 	mov	1, %g2
-	sllx	%g2, 61, %g2
+	sllx	%g2, 61, %g2			! %g2 is now SUN4V_TLB_REAL_W
 	or	%g2, SUN4V_TLB_W, %g2
 	btst	%g2, %g4
 	bz,pn	%xcc, sun4v_tl1_ptbl_miss		! No -- really fault



CVS commit: src/sys/arch/sparc64/sparc64

2019-01-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 30 10:11:11 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: netbsd32_machdep_13.c

Log Message:
Make this compile with "options DEBUG".


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.c
diff -u src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.c:1.2 src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.c:1.3
--- src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.c:1.2	Sun Jan 27 02:08:38 2019
+++ src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.c	Wed Jan 30 10:11:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep_13.c,v 1.2 2019/01/27 02:08:38 pgoyette Exp $	*/
+/*	$NetBSD: netbsd32_machdep_13.c,v 1.3 2019/01/30 10:11:11 hannken Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_13.c,v 1.2 2019/01/27 02:08:38 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_13.c,v 1.3 2019/01/30 10:11:11 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -83,6 +83,10 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mac
 #include 
 #include 
 
+#ifdef DEBUG
+#include 
+#endif
+
 int
 compat_13_netbsd32_sigreturn(struct lwp *l, const struct compat_13_netbsd32_sigreturn_args *uap, register_t *retval)
 {
@@ -108,7 +112,7 @@ compat_13_netbsd32_sigreturn(struct lwp 
 	}
 #ifdef DEBUG
 	if (sigdebug & SDB_FOLLOW) {
-		printf("%s: %s[%d], sigcntxp %p\n", __func__,
+		printf("%s: %s[%d], sigcntxp %u\n", __func__,
 		p->p_comm, p->p_pid, SCARG(uap, sigcntxp));
 		if (sigdebug & SDB_DDB) Debugger();
 	}
@@ -133,7 +137,7 @@ compat_13_netbsd32_sigreturn(struct lwp 
 	if (((sc.sc_pc | sc.sc_npc) & 3) != 0)
 #ifdef DEBUG
 	{
-		printf("%s: pc %p or npc %p invalid\n",
+		printf("%s: pc %d or npc %d invalid\n",
 		   __func__, sc.sc_pc, sc.sc_npc);
 		Debugger();
 		return (EINVAL);
@@ -150,7 +154,7 @@ compat_13_netbsd32_sigreturn(struct lwp 
 	tf->tf_out[6] = (int64_t)sc.sc_sp;
 #ifdef DEBUG
 	if (sigdebug & SDB_FOLLOW) {
-		printf("%s: return trapframe pc=%p sp=%p tstate=%x\n", __func__,
+		printf("%s: return trapframe pc=%d sp=%d tstate=%x\n", __func__,
 		   (int)tf->tf_pc, (int)tf->tf_out[6], (int)tf->tf_tstate);
 		if (sigdebug & SDB_DDB) Debugger();
 	}



CVS commit: src/sys/arch/sparc64/sparc64

2019-01-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan  9 10:42:27 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: cache.h

Log Message:
avoid function param names in prototypes.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sparc64/sparc64/cache.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/cache.h
diff -u src/sys/arch/sparc64/sparc64/cache.h:1.28 src/sys/arch/sparc64/sparc64/cache.h:1.29
--- src/sys/arch/sparc64/sparc64/cache.h:1.28	Mon Jan  5 11:40:56 2015
+++ src/sys/arch/sparc64/sparc64/cache.h	Wed Jan  9 10:42:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cache.h,v 1.28 2015/01/05 11:40:56 palle Exp $ */
+/*	$NetBSD: cache.h,v 1.29 2019/01/09 10:42:27 mrg Exp $ */
 
 /*
  * Copyright (c) 2011 Matthew R. Green
@@ -124,8 +124,8 @@ void cache_setup_funcs(void);
 extern	void	(*sp_dcache_flush_page)(paddr_t);
 
 void smp_tlb_flush_pte(vaddr_t, struct pmap *);
-void smp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t);
-void smp_dcache_flush_page_allcpu(paddr_t pa);
+void smp_dcache_flush_page_cpuset(paddr_t, sparc64_cpuset_t);
+void smp_dcache_flush_page_allcpu(paddr_t);
 void smp_blast_dcache(void);
 #define	tlb_flush_pte(va,pm)		smp_tlb_flush_pte(va, pm)
 #define	dcache_flush_page_all(pa)	smp_dcache_flush_page_cpuset(pa, cpus_active)



CVS commit: src/sys/arch/sparc64/sparc64

2019-01-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan  7 13:10:44 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: machdep.c

Log Message:
When writing a kernel core dump, display the countdown w/o timestamps.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/arch/sparc64/sparc64/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/machdep.c
diff -u src/sys/arch/sparc64/sparc64/machdep.c:1.290 src/sys/arch/sparc64/sparc64/machdep.c:1.291
--- src/sys/arch/sparc64/sparc64/machdep.c:1.290	Wed Dec 19 13:57:50 2018
+++ src/sys/arch/sparc64/sparc64/machdep.c	Mon Jan  7 13:10:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.290 2018/12/19 13:57:50 maxv Exp $ */
+/*	$NetBSD: machdep.c,v 1.291 2019/01/07 13:10:44 martin Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.290 2018/12/19 13:57:50 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.291 2019/01/07 13:10:44 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -122,6 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #define _SPARC_BUS_DMA_PRIVATE
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -755,7 +756,8 @@ dumpsys(void)
 
 			/* print out how many MBs we still have to dump */
 			if ((todo % (1024*1024)) == 0)
-printf_nolog("\r%6" PRIu64 " M ",
+printf_flags(TOCONS|NOTSTAMP, 
+"\r%6" PRIu64 " M ",
 todo / (1024*1024));
 			for (off = 0; off < n; off += PAGE_SIZE)
 pmap_kenter_pa(dumpspace+off, maddr+off,
@@ -790,7 +792,8 @@ dumpsys(void)
 		break;
 
 	case 0:
-		printf("\rdump succeeded\n");
+		printf_flags(TOCONS|NOTSTAMP, "\r   ");
+		printf("\ndump succeeded\n");
 		break;
 
 	default:



CVS commit: src/sys/arch/sparc64/sparc64

2019-01-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jan  5 15:46:02 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
Remove debugging leftover, pointed out by mrg


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.214 src/sys/arch/sparc64/sparc64/autoconf.c:1.215
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.214	Fri Jan  4 16:25:06 2019
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Jan  5 15:46:02 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.214 2019/01/04 16:25:06 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.215 2019/01/05 15:46:02 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.214 2019/01/04 16:25:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.215 2019/01/05 15:46:02 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -905,7 +905,6 @@ openbios_secondary_ata_heuristic(int par
 		   " secondary ATA bus, applying workaround target+2\n"));
 		return true;
 	} else if (strcmp(tmp, "ide") == 0) {
-		regs[0] = 42;
 		if (OF_getprop(parent, "reg", , sizeof(regs))
 		>= sizeof(regs[0])) {
 			DPRINTF(ACDB_BOOTDEV, ("parent seems to be an OpenBIOS"



CVS commit: src/sys/arch/sparc64/sparc64

2019-01-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan  4 16:25:06 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
PR port-sparc64/53830: adapt QEMU workarounds to newer OpenBIOS device
tree layout.


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.213 src/sys/arch/sparc64/sparc64/autoconf.c:1.214
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.213	Fri Sep 15 13:27:53 2017
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Fri Jan  4 16:25:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.213 2017/09/15 13:27:53 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.214 2019/01/04 16:25:06 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.213 2017/09/15 13:27:53 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.214 2019/01/04 16:25:06 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -877,13 +877,16 @@ has_child_node(int parent, int search)
 
 /*
  * The interposed pseudo-parent node in OpenBIOS has a
- * device_type = "ide" and no "vendor-id".
- * It is the secondary bus if the name is "ide1".
+ * device_type = "ide" and no "compatible" property.
+ * It is the secondary bus if the name is "ide1" or "ide"
+ * with newer OpenBIOS versions. In the latter case, read
+ * the first reg value to discriminate the two channels.
  */
 static bool
 openbios_secondary_ata_heuristic(int parent)
 {
 	char tmp[OFPATHLEN];
+	int regs[4];
 
 	if (OF_getprop(parent, "device_type", tmp, sizeof(tmp)) <= 0)
 		return false;
@@ -891,18 +894,29 @@ openbios_secondary_ata_heuristic(int par
 		return false;
 	DPRINTF(ACDB_BOOTDEV, ("parent device_type is ide\n"));
 
-	if (OF_getprop(parent, "vendor-id", tmp, sizeof(tmp)) > 0)
+	if (OF_getprop(parent, "compatible", tmp, sizeof(tmp)) > 0)
 		return false;
-	DPRINTF(ACDB_BOOTDEV, ("parent has no vendor-id\n"));
+	DPRINTF(ACDB_BOOTDEV, ("parent has no compatible property\n"));
 
 	if (OF_getprop(parent, "name", tmp, sizeof(tmp)) <= 0)
 		return false;
-	if (strcmp(tmp, "ide1") != 0)
-		return false;
-	DPRINTF(ACDB_BOOTDEV, ("parent seems to be an OpenBIOS"
-	   " secondary ATA bus, applying workaround target+2\n"));
+	if (strcmp(tmp, "ide1") == 0) {
+		DPRINTF(ACDB_BOOTDEV, ("parent seems to be an (old) OpenBIOS"
+		   " secondary ATA bus, applying workaround target+2\n"));
+		return true;
+	} else if (strcmp(tmp, "ide") == 0) {
+		regs[0] = 42;
+		if (OF_getprop(parent, "reg", , sizeof(regs))
+		>= sizeof(regs[0])) {
+			DPRINTF(ACDB_BOOTDEV, ("parent seems to be an OpenBIOS"
+			   " ATA bus #%u\n", regs[0]));
+
+			return regs[0] == 1;
+		}
 
-	return true;
+	}
+
+	return false;
 }
 
 /*



CVS commit: src/sys/arch/sparc64/sparc64

2018-11-29 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Nov 29 20:58:36 UTC 2018

Modified Files:
src/sys/arch/sparc64/sparc64: pmap.c

Log Message:
sun4v: fix incorrect calculation of phys addr for the mdesc - now the 
virtual-devices can (again) be detected (worked previously...)


To generate a diff of this commit:
cvs rdiff -u -r1.308 -r1.309 src/sys/arch/sparc64/sparc64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.308 src/sys/arch/sparc64/sparc64/pmap.c:1.309
--- src/sys/arch/sparc64/sparc64/pmap.c:1.308	Sat Jan 27 23:07:36 2018
+++ src/sys/arch/sparc64/sparc64/pmap.c	Thu Nov 29 20:58:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.308 2018/01/27 23:07:36 chs Exp $	*/
+/*	$NetBSD: pmap.c,v 1.309 2018/11/29 20:58:36 palle Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.308 2018/01/27 23:07:36 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.309 2018/11/29 20:58:36 palle Exp $");
 
 #undef	NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define	HWREF
@@ -765,7 +765,7 @@ pmap_bootstrap(u_long kernelstart, u_lon
 
 		m_len = mdesc_get_len();
 		m_va = kdata_alloc(m_len, 16);
-		m_pa = kdatap + (m_va - kdata);
+		m_pa = pmap_kextract(m_va);
 		mdesc_init(m_va, m_pa, m_len);
 	}
 



CVS commit: src/sys/arch/sparc64/sparc64

2018-11-04 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Nov  4 20:02:07 UTC 2018

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
Ensure that the 64-bit condition codes are used instead of the 32-bit condition 
codes. ok martin@


To generate a diff of this commit:
cvs rdiff -u -r1.414 -r1.415 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.414 src/sys/arch/sparc64/sparc64/locore.s:1.415
--- src/sys/arch/sparc64/sparc64/locore.s:1.414	Sat May 26 19:20:21 2018
+++ src/sys/arch/sparc64/sparc64/locore.s	Sun Nov  4 20:02:07 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.414 2018/05/26 19:20:21 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.415 2018/11/04 20:02:07 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -7453,7 +7453,7 @@ ENTRY(next_stick)
 	andn	%o1, %o3, %o1
 	andn	%o2, %o3, %o2
 	cmp	%o1, %o2	! Did we wrap?  (stick < stick_cmpr)
-	bgt,pt	%icc, 1f
+	bgt,pt	%xcc, 1f
 	 add	%o1, 1000, %o1	! Need some slack so we don't lose intrs.
 
 	/*



CVS commit: src/sys/arch/sparc64/sparc64

2018-05-26 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat May 26 19:20:21 UTC 2018

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
next_stick() - fix typy in comment: tick->stick


To generate a diff of this commit:
cvs rdiff -u -r1.413 -r1.414 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.413 src/sys/arch/sparc64/sparc64/locore.s:1.414
--- src/sys/arch/sparc64/sparc64/locore.s:1.413	Wed Apr 11 19:41:18 2018
+++ src/sys/arch/sparc64/sparc64/locore.s	Sat May 26 19:20:21 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.413 2018/04/11 19:41:18 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.414 2018/05/26 19:20:21 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -7452,7 +7452,7 @@ ENTRY(next_stick)
 	sllx	%o3, 63, %o3
 	andn	%o1, %o3, %o1
 	andn	%o2, %o3, %o2
-	cmp	%o1, %o2	! Did we wrap?  (tick < tick_cmpr)
+	cmp	%o1, %o2	! Did we wrap?  (stick < stick_cmpr)
 	bgt,pt	%icc, 1f
 	 add	%o1, 1000, %o1	! Need some slack so we don't lose intrs.
 



CVS commit: src/sys/arch/sparc64/sparc64

2018-04-11 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Wed Apr 11 19:41:18 UTC 2018

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: handle MMU-related traps properly when they occur at trap level 1. This 
fixes issues when user-level LWPs access the user-level stack


To generate a diff of this commit:
cvs rdiff -u -r1.412 -r1.413 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.412 src/sys/arch/sparc64/sparc64/locore.s:1.413
--- src/sys/arch/sparc64/sparc64/locore.s:1.412	Sat Aug 26 20:25:00 2017
+++ src/sys/arch/sparc64/sparc64/locore.s	Wed Apr 11 19:41:18 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.412 2017/08/26 20:25:00 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.413 2018/04/11 19:41:18 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1147,9 +1147,12 @@ _C_LABEL(trapbase_sun4v):
 	!
 	sun4v_trap_entry 36	! 0x000-0x023
 	CLEANWIN1		! 0x24-0x27 = clean window
-	sun4v_trap_entry 9	! 0x028-0x030
-	VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss)			! 0x031 = data MMU miss
-	sun4v_trap_entry 58	! 0x032-0x06b
+	sun4v_trap_entry 8	! 0x028-0x02F
+	VTRAP(T_DATAFAULT, sun4v_tl1_ptbl_miss)			! 0x030 = ???
+	VTRAP(T_DATA_MMU_MISS, sun4v_tl1_dtsb_miss)		! 0x031 = data MMU miss
+	VTRAP(T_DATA_ERROR, sun4v_tl1_ptbl_miss)		! 0x032 = ???
+	VTRAP(T_DATA_PROT, sun4v_tl1_ptbl_miss)			! 0x033 = ???
+	sun4v_trap_entry 56	! 0x034-0x06b
 	VTRAP(T_FDMMU_PROT, sun4v_tl1_dtsb_prot)		! 0x06c
 	sun4v_trap_entry 19	! 0x06d-0x07f
 	SPILL64(uspill8_sun4vt1,ASI_AIUS)			! 0x080 spill_0_normal -- save user windows
@@ -2858,6 +2861,79 @@ sun4v_dtsb_miss:
 	retry
 	NOTREACHED
 
+sun4v_tl1_dtsb_miss:
+	GET_MMFSA %g1! MMU Fault status area
+	add	%g1, 0x48, %g3
+	LDPTRA	[%g3] ASI_PHYS_CACHED, %g3	! Data fault address
+	add	%g1, 0x50, %g6
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g6	! Data fault context
+
+	GET_CTXBUSY %g4
+	sllx	%g6, 3, %g6			! Make it into an offset into ctxbusy
+	LDPTR	[%g4 + %g6], %g4		! Load up our page table.
+
+	srax	%g3, HOLESHIFT, %g5		! Check for valid address
+	brz,pt	%g5, 0f! Should be zero or -1
+	 inc	%g5! Make -1 -> 0
+	brnz,pn	%g5, sun4v_tl1_ptbl_miss	! Error! In hole!
+0:
+	srlx	%g3, STSHIFT, %g6
+	and	%g6, STMASK, %g6		! Index into pm_segs
+	sll	%g6, 3, %g6
+	add	%g4, %g6, %g4
+	LDPTRA	[%g4] ASI_PHYS_CACHED, %g4	! Load page directory pointer
+	srlx	%g3, PDSHIFT, %g6
+	and	%g6, PDMASK, %g6
+	sll	%g6, 3, %g6
+	brz,pn	%g4, sun4v_tl1_ptbl_miss	! NULL entry? check somewhere else
+	 add	%g4, %g6, %g4
+	LDPTRA	[%g4] ASI_PHYS_CACHED, %g4	! Load page table pointer
+
+	srlx	%g3, PTSHIFT, %g6		! Convert to ptab offset
+	and	%g6, PTMASK, %g6
+	sll	%g6, 3, %g6
+	brz,pn	%g4, sun4v_tl1_ptbl_miss	! NULL entry? check somewhere else
+	 add	%g4, %g6, %g6
+1:
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g4	! Fetch TTE
+	brgez,pn %g4, sun4v_tl1_ptbl_miss	! Entry invalid?  Punt
+	 or	%g4, SUN4V_TLB_ACCESS, %g7	! Update the access bit
+
+	btst	SUN4V_TLB_ACCESS, %g4		! Need to update access bit?
+	bne,pt	%xcc, 2f
+	 nop
+	casxa	[%g6] ASI_PHYS_CACHED, %g4, %g7	! and write it out
+	cmp	%g4, %g7
+	bne,pn	%xcc, 1b
+	 or	%g4, SUN4V_TLB_ACCESS, %g4	! Update the access bit
+2:
+	GET_TSB_DMMU %g2
+
+	/* Construct TSB tag word. */
+	add	%g1, 0x50, %g6
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g6	! Data fault context
+	mov	%g3, %g1			! Data fault address
+	srlx	%g1, 22, %g1			! 63..22 of virt addr
+	sllx	%g6, 48, %g6			! context_id in 63..48
+	or	%g1, %g6, %g1			! construct TTE tag
+	srlx	%g3, PTSHIFT, %g3
+	sethi	%hi(_C_LABEL(tsbsize)), %g5
+	mov	512, %g6
+	ld	[%g5 + %lo(_C_LABEL(tsbsize))], %g5
+	sllx	%g6, %g5, %g5			! %g5 = 512 << tsbsize = TSBENTS
+	sub	%g5, 1, %g5			! TSBENTS -> offset
+	and	%g3, %g5, %g3			! mask out TTE index
+	sllx	%g3, 4, %g3			! TTE size is 16 bytes
+	add	%g2, %g3, %g2			! location of TTE in ci_tsb_dmmu
+
+	membar	#StoreStore
+
+	STPTR	%g4, [%g2 + 8]			! store TTE data
+	STPTR	%g1, [%g2]			! store TTE tag
+
+	retry
+	NOTREACHED
+	
 sun4v_datatrap:
 	GET_MMFSA %g3! MMU Fault status area
 	add	%g3, 0x48, %g1



CVS commit: src/sys/arch/sparc64/sparc64

2018-01-19 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri Jan 19 12:47:42 UTC 2018

Modified Files:
src/sys/arch/sparc64/sparc64: cpu.c

Log Message:
sun4v doesn't have %ver register.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sys/arch/sparc64/sparc64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/cpu.c
diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.133 src/sys/arch/sparc64/sparc64/cpu.c:1.134
--- src/sys/arch/sparc64/sparc64/cpu.c:1.133	Tue Jan 16 08:23:18 2018
+++ src/sys/arch/sparc64/sparc64/cpu.c	Fri Jan 19 12:47:41 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.133 2018/01/16 08:23:18 mrg Exp $ */
+/*	$NetBSD: cpu.c,v 1.134 2018/01/19 12:47:41 nakayama Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.133 2018/01/16 08:23:18 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.134 2018/01/19 12:47:41 nakayama Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -549,8 +549,8 @@ cpu_attach(device_t parent, device_t dev
 
 	aprint_normal(": %s, CPU id %d\n", buf, ci->ci_cpuid);
 	aprint_naive("\n");
-	ci->ci_ver = getver();
 	if (CPU_ISSUN4U || CPU_ISSUN4US) {
+		ci->ci_ver = getver();
 		aprint_normal_dev(dev, "manuf %x, impl %x, mask %x\n",
 		(u_int)GETVER_CPU_MANUF(),
 		(u_int)GETVER_CPU_IMPL(),



CVS commit: src/sys/arch/sparc64/sparc64

2017-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 16 09:05:07 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: svr4_machdep.c

Log Message:
Make debug code compile


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/sparc64/sparc64/svr4_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/svr4_machdep.c
diff -u src/sys/arch/sparc64/sparc64/svr4_machdep.c:1.55 src/sys/arch/sparc64/sparc64/svr4_machdep.c:1.56
--- src/sys/arch/sparc64/sparc64/svr4_machdep.c:1.55	Fri Mar  4 22:25:29 2011
+++ src/sys/arch/sparc64/sparc64/svr4_machdep.c	Sat Sep 16 09:05:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: svr4_machdep.c,v 1.55 2011/03/04 22:25:29 joerg Exp $	 */
+/*	$NetBSD: svr4_machdep.c,v 1.56 2017/09/16 09:05:07 martin Exp $	 */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: svr4_machdep.c,v 1.55 2011/03/04 22:25:29 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_machdep.c,v 1.56 2017/09/16 09:05:07 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -236,7 +236,7 @@ svr4_setmcontext(struct lwp *l, struct s
 #endif
 
 #ifdef DEBUG_SVR4
-	svr4_printmcontext("setmcontext", uc);
+	svr4_printmcontext("setmcontext", mc);
 #endif
 
 	write_user_windows();



CVS commit: src/sys/arch/sparc64/sparc64

2017-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 16 08:46:06 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: svr4_32_machdep.c

Log Message:
Redo previous with the proper macros


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/sparc64/sparc64/svr4_32_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/svr4_32_machdep.c
diff -u src/sys/arch/sparc64/sparc64/svr4_32_machdep.c:1.40 src/sys/arch/sparc64/sparc64/svr4_32_machdep.c:1.41
--- src/sys/arch/sparc64/sparc64/svr4_32_machdep.c:1.40	Fri Sep 15 18:28:53 2017
+++ src/sys/arch/sparc64/sparc64/svr4_32_machdep.c	Sat Sep 16 08:46:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: svr4_32_machdep.c,v 1.40 2017/09/15 18:28:53 martin Exp $	 */
+/*	$NetBSD: svr4_32_machdep.c,v 1.41 2017/09/16 08:46:06 martin Exp $	 */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: svr4_32_machdep.c,v 1.40 2017/09/15 18:28:53 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_32_machdep.c,v 1.41 2017/09/16 08:46:06 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -503,9 +503,9 @@ svr4_32_sendsig(const ksiginfo_t *ksi, c
 	NETBSD32PTR32(frame.sf_ucp, >sf_uc);
 	frame.sf_handler = catcher;
 
-	DPRINTF(("svr4_32_sendsig signum=%d si = %x uc = %x handler = %p\n",
-	 frame.sf_signum, frame.sf_sip.i32,
-		 frame.sf_ucp.i32, frame.sf_handler));
+	DPRINTF(("svr4_32_sendsig signum=%d si = %p uc = %p handler = %p\n",
+	 frame.sf_signum, NETBSD32PTR64(frame.sf_sip),
+		 NETBSD32PTR64(frame.sf_ucp), frame.sf_handler));
 	/*
 	 * Modify the signal context to be used by sigreturn.
 	 */



CVS commit: src/sys/arch/sparc64/sparc64

2017-09-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 15 18:28:53 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: svr4_32_machdep.c

Log Message:
Make DEBUG code compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/sparc64/sparc64/svr4_32_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/svr4_32_machdep.c
diff -u src/sys/arch/sparc64/sparc64/svr4_32_machdep.c:1.39 src/sys/arch/sparc64/sparc64/svr4_32_machdep.c:1.40
--- src/sys/arch/sparc64/sparc64/svr4_32_machdep.c:1.39	Thu Nov 26 13:15:34 2015
+++ src/sys/arch/sparc64/sparc64/svr4_32_machdep.c	Fri Sep 15 18:28:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: svr4_32_machdep.c,v 1.39 2015/11/26 13:15:34 martin Exp $	 */
+/*	$NetBSD: svr4_32_machdep.c,v 1.40 2017/09/15 18:28:53 martin Exp $	 */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: svr4_32_machdep.c,v 1.39 2015/11/26 13:15:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_32_machdep.c,v 1.40 2017/09/15 18:28:53 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -226,7 +226,7 @@ svr4_32_setmcontext(struct lwp *l, struc
 #endif
 
 #ifdef DEBUG_SVR4
-	svr4_32_printmcontext("setmcontext", uc);
+	svr4_32_printmcontext("setmcontext", mc);
 #endif
 
 	write_user_windows();
@@ -503,9 +503,9 @@ svr4_32_sendsig(const ksiginfo_t *ksi, c
 	NETBSD32PTR32(frame.sf_ucp, >sf_uc);
 	frame.sf_handler = catcher;
 
-	DPRINTF(("svr4_32_sendsig signum=%d si = %p uc = %p handler = %p\n",
-	 frame.sf_signum, frame.sf_sip,
-		 frame.sf_ucp, frame.sf_handler));
+	DPRINTF(("svr4_32_sendsig signum=%d si = %x uc = %x handler = %p\n",
+	 frame.sf_signum, frame.sf_sip.i32,
+		 frame.sf_ucp.i32, frame.sf_handler));
 	/*
 	 * Modify the signal context to be used by sigreturn.
 	 */



CVS commit: src/sys/arch/sparc64/sparc64

2017-09-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 15 13:27:53 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
If the bootloader passes us information about the boot device lun/target/
and wwn, use those to properly match the boot device.
If the new bootinfo is not available, fall back to the old heuristic
trying to match the pathname of the boot device (which is ugly, firmware
dependend and known to fail in some QEMU configurations).


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.212 src/sys/arch/sparc64/sparc64/autoconf.c:1.213
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.212	Mon Sep 11 19:25:07 2017
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Fri Sep 15 13:27:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.212 2017/09/11 19:25:07 palle Exp $ */
+/*	$NetBSD: autoconf.c,v 1.213 2017/09/15 13:27:53 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.212 2017/09/11 19:25:07 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.213 2017/09/15 13:27:53 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -855,6 +855,136 @@ dev_path_drive_match(device_t dev, int c
 		}
 	}
 }
+ 
+ /*
+ * Recursively check for a child node.
+ */
+static bool
+has_child_node(int parent, int search)
+{
+	int child;
+
+	for (child = prom_firstchild(parent); child != 0;
+	child = prom_nextsibling(child)) {
+		if (child == search)
+			return true;
+		if (has_child_node(child, search))
+			return true;
+	}
+
+	return false;
+}
+
+/*
+ * The interposed pseudo-parent node in OpenBIOS has a
+ * device_type = "ide" and no "vendor-id".
+ * It is the secondary bus if the name is "ide1".
+ */
+static bool
+openbios_secondary_ata_heuristic(int parent)
+{
+	char tmp[OFPATHLEN];
+
+	if (OF_getprop(parent, "device_type", tmp, sizeof(tmp)) <= 0)
+		return false;
+	if (strcmp(tmp, "ide") != 0)
+		return false;
+	DPRINTF(ACDB_BOOTDEV, ("parent device_type is ide\n"));
+
+	if (OF_getprop(parent, "vendor-id", tmp, sizeof(tmp)) > 0)
+		return false;
+	DPRINTF(ACDB_BOOTDEV, ("parent has no vendor-id\n"));
+
+	if (OF_getprop(parent, "name", tmp, sizeof(tmp)) <= 0)
+		return false;
+	if (strcmp(tmp, "ide1") != 0)
+		return false;
+	DPRINTF(ACDB_BOOTDEV, ("parent seems to be an OpenBIOS"
+	   " secondary ATA bus, applying workaround target+2\n"));
+
+	return true;
+}
+
+/*
+ * Match a device_t against the controller/target/lun/wwn
+ * info passed in from the bootloader (if available),
+ * otherwise fall back to old style string matching
+ * heuristics.
+ */
+static void
+dev_bi_unit_drive_match(device_t dev, int ctrlnode, int target,
+uint64_t wwn, int lun)
+{
+	static struct btinfo_bootdev_unit *bi_unit = NULL;
+	uint32_t off = 0;
+	static bool passed = false;
+#ifdef DEBUG
+	char ctrl_path[OFPATHLEN], parent_path[OFPATHLEN], dev_path[OFPATHLEN];
+#endif
+
+	if (!passed) {
+		bi_unit = lookup_bootinfo(BTINFO_BOOTDEV_UNIT);
+		passed = true;
+	}
+
+	if (bi_unit == NULL) {
+		dev_path_drive_match(dev, ctrlnode, target, wwn, lun);
+		return;
+	}
+
+#ifdef DEBUG
+	DPRINTF(ACDB_BOOTDEV, ("dev_bi_unit_drive_match: %s, controller %x, "
+	"target %d wwn %016" PRIx64 " lun %d\n", device_xname(dev),
+	ctrlnode, target, wwn, lun));
+
+	OF_package_to_path(ctrlnode, ctrl_path, sizeof(ctrl_path));
+	OF_package_to_path(bi_unit->phandle, dev_path, sizeof(dev_path));
+	OF_package_to_path(bi_unit->parent, parent_path, sizeof(parent_path));
+	DPRINTF(ACDB_BOOTDEV, ("controller %x : %s\n", ctrlnode, ctrl_path));
+	DPRINTF(ACDB_BOOTDEV, ("phandle %x : %s\n", bi_unit->phandle, dev_path));
+	DPRINTF(ACDB_BOOTDEV, ("parent %x : %s\n", bi_unit->parent, parent_path));
+#endif
+	if (ctrlnode != bi_unit->parent
+	&& !has_child_node(ctrlnode, bi_unit->phandle)) {
+		DPRINTF(ACDB_BOOTDEV, ("controller %x : %s does not match "
+		"bootinfo: %x : %s\n",
+		ctrlnode, ctrl_path, bi_unit->parent, parent_path));
+		return;
+	}
+	if (ctrlnode == bi_unit->parent) {
+		DPRINTF(ACDB_BOOTDEV, ("controller %x : %s is bootinfo"
+		" parent\n", ctrlnode, ctrl_path));
+	} else {
+		DPRINTF(ACDB_BOOTDEV, ("controller %x : %s is parent of"
+		" %x : %s\n", ctrlnode, ctrl_path, bi_unit->parent,
+		parent_path));
+
+		/*
+		 * Our kernel and "real" OpenFirmware use a 0 .. 3 numbering
+		 * scheme for IDE devices, but OpenBIOS splits it into
+		 * two "buses" and numbers each 0..1.
+		 * Check if we are on the secondary "bus" and adjust
+		 * if needed...
+		 */
+		if (openbios_secondary_ata_heuristic(bi_unit->parent))
+			off = 2;
+	}
+
+	if (bi_unit->wwn != wwn || (bi_unit->target+off) != target
+	|| bi_unit->lun != lun) {
+		

CVS commit: src/sys/arch/sparc64/sparc64

2017-08-27 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Aug 27 19:31:44 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: cpu.c

Log Message:
sun4v: Change clk and sclk variables to unsigned type so modern faster systems 
with CPU frequencies above 2 Ghz are shown correctly. Example is a 3599.910 MHz 
SPARC T5-2 system that otherwise is shown incorrectly as -695.-57 MHz. Based on 
code from OpenBSD cpu.c rev. 1.41. Verified on sun4u using qemu and sun4v on 
SPARC T5-2


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/arch/sparc64/sparc64/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/cpu.c
diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.130 src/sys/arch/sparc64/sparc64/cpu.c:1.131
--- src/sys/arch/sparc64/sparc64/cpu.c:1.130	Fri Feb 10 23:26:23 2017
+++ src/sys/arch/sparc64/sparc64/cpu.c	Sun Aug 27 19:31:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.130 2017/02/10 23:26:23 palle Exp $ */
+/*	$NetBSD: cpu.c,v 1.131 2017/08/27 19:31:43 palle Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.130 2017/02/10 23:26:23 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.131 2017/08/27 19:31:43 palle Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -421,7 +421,7 @@ void
 cpu_attach(device_t parent, device_t dev, void *aux)
 {
 	int node;
-	long clk, sclk = 0;
+	unsigned int clk, sclk = 0;
 	struct mainbus_attach_args *ma = aux;
 	struct cpu_info *ci;
 	const char *sep;



CVS commit: src/sys/arch/sparc64/sparc64

2017-08-26 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Aug 26 20:25:00 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: Avoid touching the %tick_cmpr register which is not present on never 
systems (Oracle SPARC Architecture 2011 and beyond). Based on code from OpenBSD 
locore.s revision 1.177. Tested on both sun4u (qemu and USIII) and sun4v (qemu 
and T5-2). ok martin@


To generate a diff of this commit:
cvs rdiff -u -r1.411 -r1.412 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.411 src/sys/arch/sparc64/sparc64/locore.s:1.412
--- src/sys/arch/sparc64/sparc64/locore.s:1.411	Sat May  6 21:46:31 2017
+++ src/sys/arch/sparc64/sparc64/locore.s	Sat Aug 26 20:25:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.411 2017/05/06 21:46:31 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.412 2017/08/26 20:25:00 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -5119,9 +5119,6 @@ _C_LABEL(endtrapcode):
 	.align	8
 start:
 dostart:
-	mov	1, %g1
-	sllx	%g1, 63, %g1
-	wr	%g1, TICK_CMPR	! XXX clear and disable %tick_cmpr for now
 	/*
 	 * Startup.
 	 *



CVS commit: src/sys/arch/sparc64/sparc64

2017-08-22 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Aug 22 09:12:49 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: compat_13_machdep.c

Log Message:
Apply only CCR. Otherwise userland could set PSTATE_PRIV in %pstate and get
kernel privileges on the hardware.

ok martin


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sparc64/sparc64/compat_13_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/compat_13_machdep.c
diff -u src/sys/arch/sparc64/sparc64/compat_13_machdep.c:1.23 src/sys/arch/sparc64/sparc64/compat_13_machdep.c:1.24
--- src/sys/arch/sparc64/sparc64/compat_13_machdep.c:1.23	Sat Nov 21 04:16:52 2009
+++ src/sys/arch/sparc64/sparc64/compat_13_machdep.c	Tue Aug 22 09:12:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_13_machdep.c,v 1.23 2009/11/21 04:16:52 rmind Exp $	*/
+/*	$NetBSD: compat_13_machdep.c,v 1.24 2017/08/22 09:12:49 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.23 2009/11/21 04:16:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_13_machdep.c,v 1.24 2017/08/22 09:12:49 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -129,7 +129,7 @@ compat_13_sys_sigreturn(struct lwp *l, c
 		return (EINVAL);
 	/* take only psr ICC field */
 #ifdef __arch64__
-	tf->tf_tstate = (int64_t)(tf->tf_tstate & ~TSTATE_CCR) | scp->sc_tstate;
+	tf->tf_tstate = (int64_t)(tf->tf_tstate & ~TSTATE_CCR) | (scp->sc_tstate & TSTATE_CCR);
 #else
 	tf->tf_tstate = (int64_t)(tf->tf_tstate & ~TSTATE_CCR) | PSRCC_TO_TSTATE(scp->sc_psr);
 #endif



CVS commit: src/sys/arch/sparc64/sparc64

2017-05-06 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat May  6 21:46:31 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: The %ver register is not available on sun4v - use GET_MAXCWP introduced 
in rev. 1.361. Verified using qemu (sun4u and sun4v) and on real sun4v hw 
(t2000)


To generate a diff of this commit:
cvs rdiff -u -r1.410 -r1.411 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.410 src/sys/arch/sparc64/sparc64/locore.s:1.411
--- src/sys/arch/sparc64/sparc64/locore.s:1.410	Tue Apr 18 20:02:50 2017
+++ src/sys/arch/sparc64/sparc64/locore.s	Sat May  6 21:46:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.410 2017/04/18 20:02:50 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.411 2017/05/06 21:46:31 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -4936,9 +4936,8 @@ rft_user:
 	bgu,pt	%xcc, 3b! Next one?
 	 dec	8*16, %g5
 
-	rdpr	%ver, %g5
 	stb	%g0, [%g6 + PCB_NSAVED]			! Clear them out so we won't do this again
-	and	%g5, CWP, %g5
+	GET_MAXCWP %g5
 	add	%g5, %g7, %g4
 	dec	1, %g5	! NWINDOWS-1-1
 	wrpr	%g5, 0, %cansave



CVS commit: src/sys/arch/sparc64/sparc64

2017-04-18 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Apr 18 20:02:50 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: Add handling of trap 0x06c @ trap level 1 - based on code from OpenBSD, 
but slightly adapted to NetBSD. verified using qemu


To generate a diff of this commit:
cvs rdiff -u -r1.409 -r1.410 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.409 src/sys/arch/sparc64/sparc64/locore.s:1.410
--- src/sys/arch/sparc64/sparc64/locore.s:1.409	Sun Feb 19 18:25:45 2017
+++ src/sys/arch/sparc64/sparc64/locore.s	Tue Apr 18 20:02:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.409 2017/02/19 18:25:45 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.410 2017/04/18 20:02:50 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1102,7 +1102,7 @@ _C_LABEL(trapbase_sun4v):
 	HARDINT4V(14)		! 0x04e = level 14 interrupt
 	HARDINT4V(15)		! 0x04f = level 15 interrupt
 	sun4v_trap_entry 28	! 0x050-0x06b
-	VTRAP(T_FDMMU_PROT, sun4v_tl0_dtsb_prot)		! 0x6c
+	VTRAP(T_FDMMU_PROT, sun4v_tl0_dtsb_prot)		! 0x06c
 	sun4v_trap_entry 15	! 0x06d-0x07b
 	VTRAP(T_CPU_MONDO, sun4v_cpu_mondo)			! 0x07c = cpu mondo
 	VTRAP(T_DEV_MONDO, sun4v_dev_mondo)			! 0x07d = dev mondo
@@ -1149,7 +1149,9 @@ _C_LABEL(trapbase_sun4v):
 	CLEANWIN1		! 0x24-0x27 = clean window
 	sun4v_trap_entry 9	! 0x028-0x030
 	VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss)			! 0x031 = data MMU miss
-	sun4v_trap_entry 78	! 0x032-0x07f
+	sun4v_trap_entry 58	! 0x032-0x06b
+	VTRAP(T_FDMMU_PROT, sun4v_tl1_dtsb_prot)		! 0x06c
+	sun4v_trap_entry 19	! 0x06d-0x07f
 	SPILL64(uspill8_sun4vt1,ASI_AIUS)			! 0x080 spill_0_normal -- save user windows
 	SPILL32(uspill4_sun4vt1,ASI_AIUS)			! 0x084 spill_1_normal
 	SPILLBOTH(uspill8_sun4vt1,uspill4_sun4vt1,ASI_AIUS)	! 0x088 spill_2_normal
@@ -2952,8 +2954,7 @@ sun4v_tl0_dtsb_prot:
 1:
 	LDPTRA	[%g6] ASI_PHYS_CACHED, %g4	! Fetch TTE
 	brgez,pn %g4, sun4v_datatrap		! Entry invalid?  Punt
-	 or	%g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g7
-	! Update the modified bit
+	 or	%g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g7 ! Update the modified bit
 
 #	btst	SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4	! Is it a ref fault?
 	mov	1, %g2
@@ -2965,8 +2966,7 @@ sun4v_tl0_dtsb_prot:
 	casxa	[%g6] ASI_PHYS_CACHED, %g4, %g7		!  and write it out
 	cmp	%g4, %g7
 	bne,pn	%xcc, 1b
-	 or	%g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g4
-		! Update the modified bit
+	 or	%g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g4 ! Update the modified bit
 2:
 	GET_TSB_DMMU %g2
 
@@ -3146,6 +3146,253 @@ sun4v_texttrap:
 	 nop
 	NOTREACHED
 
+sun4v_tl1_dtsb_prot:
+	GET_MMFSA %g1! MMU Fault status area
+	add	%g1, 0x48, %g3
+	LDPTRA	[%g3] ASI_PHYS_CACHED, %g3	! Data fault address
+	add	%g1, 0x50, %g6
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g6	! Data fault context
+	
+	GET_CTXBUSY %g4
+	sllx	%g6, 3, %g6			! Make it into an offset into ctxbusy
+	LDPTR	[%g4 + %g6], %g4		! Load up our page table.
+
+	srax	%g3, HOLESHIFT, %g5		! Check for valid address
+	brz,pt	%g5, 0f! Should be zero or -1
+	 inc	%g5! Make -1 -> 0
+	brnz,pn	%g5, sun4v_tl1_ptbl_miss	! Error! In hole!
+0:
+	srlx	%g3, STSHIFT, %g6
+	and	%g6, STMASK, %g6		! Index into pm_segs
+	sll	%g6, 3, %g6
+	add	%g4, %g6, %g4
+	LDPTRA	[%g4] ASI_PHYS_CACHED, %g4	! Load page directory pointer
+
+	srlx	%g3, PDSHIFT, %g6
+	and	%g6, PDMASK, %g6
+	sll	%g6, 3, %g6
+	brz,pn	%g4, sun4v_tl1_ptbl_miss	! NULL entry? check somewhere else
+	 add	%g4, %g6, %g4
+	LDPTRA	[%g4] ASI_PHYS_CACHED, %g4	! Load page table pointer
+
+	srlx	%g3, PTSHIFT, %g6		! Convert to ptab offset
+	and	%g6, PTMASK, %g6
+	sll	%g6, 3, %g6
+	brz,pn	%g4, sun4v_tl1_ptbl_miss	! NULL entry? check somewhere else
+	 add	%g4, %g6, %g6
+1:
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g4	! Fetch TTE
+	brgez,pn %g4, sun4v_tl1_ptbl_miss	! Entry invalid?  Punt
+	 or	%g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g7 ! Update the modified bit
+
+#	btst	SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4	! Is it a ref fault?
+	mov	1, %g2
+	sllx	%g2, 61, %g2
+	or	%g2, SUN4V_TLB_W, %g2
+	btst	%g2, %g4
+	bz,pn	%xcc, sun4v_tl1_ptbl_miss		! No -- really fault
+	 nop
+	casxa	[%g6] ASI_PHYS_CACHED, %g4, %g7		!  and write it out
+	cmp	%g4, %g7
+	bne,pn	%xcc, 1b
+	 or	%g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g4 ! Update the modified bit
+2:
+	GET_TSB_DMMU %g2
+
+	mov	%g1, %g7			! save MMFSA
+
+	/* Construct TSB tag word. */
+	add	%g1, 0x50, %g6
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g6	! Data fault context
+	mov	%g3, %g1			! Data fault address
+	srlx	%g1, 22, %g1			! 63..22 of virt addr
+	sllx	%g6, 48, %g6			! context_id in 63..48
+	or	%g1, %g6, %g1			! construct TTE tag
+
+	srlx	%g3, PTSHIFT, %g3
+	sethi	%hi(_C_LABEL(tsbsize)), %g5
+	mov	512, %g6
+	ld	[%g5 + 

CVS commit: src/sys/arch/sparc64/sparc64

2017-03-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 26 12:59:29 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
Simplify boot device detection for ld @ virtio


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.210 src/sys/arch/sparc64/sparc64/autoconf.c:1.211
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.210	Sun Mar 26 10:36:46 2017
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Mar 26 12:59:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.210 2017/03/26 10:36:46 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.211 2017/03/26 12:59:29 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.210 2017/03/26 10:36:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.211 2017/03/26 12:59:29 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -97,7 +97,6 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -932,12 +931,6 @@ device_register(device_t dev, void *aux)
 		struct pci_attach_args *pa = aux;
 
 		ofnode = PCITAG_NODE(pa->pa_tag);
-	} else if (device_is_a(busdev, "virtio")) {
-		struct virtio_softc *va = aux;
-		struct pci_attach_args *pa = virtio_pci_attach_args(va);
-
-		if (pa)
-			ofnode = PCITAG_NODE(pa->pa_tag);
 	} else if (device_is_a(busdev, "sbus") || device_is_a(busdev, "dma")
 	|| device_is_a(busdev, "ledma")) {
 		struct sbus_attach_args *sa = aux;
@@ -988,6 +981,8 @@ device_register(device_t dev, void *aux)
 		dev_path_drive_match(dev, ofnode, adev->adev_channel*2+
 		adev->adev_drv_data->drive, 0, 0);
 		return;
+	} else if (device_is_a(dev, "ld")) {
+		ofnode = device_ofnode(busdev);
 	} else if (device_is_a(dev, "vdsk")) {
 		struct cbus_attach_args *ca = aux;
 		ofnode = ca->ca_node;



CVS commit: src/sys/arch/sparc64/sparc64

2017-03-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar 26 10:36:46 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
Use new accessor to get the PCI attach args from a virtio device.


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.209 src/sys/arch/sparc64/sparc64/autoconf.c:1.210
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.209	Sat Mar 25 13:08:38 2017
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Mar 26 10:36:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.209 2017/03/25 13:08:38 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.210 2017/03/26 10:36:46 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.209 2017/03/25 13:08:38 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.210 2017/03/26 10:36:46 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -934,8 +934,10 @@ device_register(device_t dev, void *aux)
 		ofnode = PCITAG_NODE(pa->pa_tag);
 	} else if (device_is_a(busdev, "virtio")) {
 		struct virtio_softc *va = aux;
+		struct pci_attach_args *pa = virtio_pci_attach_args(va);
 
-		ofnode = PCITAG_NODE(va->sc_pa.pa_tag);
+		if (pa)
+			ofnode = PCITAG_NODE(pa->pa_tag);
 	} else if (device_is_a(busdev, "sbus") || device_is_a(busdev, "dma")
 	|| device_is_a(busdev, "ledma")) {
 		struct sbus_attach_args *sa = aux;



CVS commit: src/sys/arch/sparc64/sparc64

2017-03-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 25 13:08:38 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
Add boot device recognition for ld @ virtio.


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.208 src/sys/arch/sparc64/sparc64/autoconf.c:1.209
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.208	Fri Aug 19 19:02:07 2016
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Mar 25 13:08:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.208 2016/08/19 19:02:07 palle Exp $ */
+/*	$NetBSD: autoconf.c,v 1.209 2017/03/25 13:08:38 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.208 2016/08/19 19:02:07 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.209 2017/03/25 13:08:38 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -97,6 +97,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -931,6 +932,10 @@ device_register(device_t dev, void *aux)
 		struct pci_attach_args *pa = aux;
 
 		ofnode = PCITAG_NODE(pa->pa_tag);
+	} else if (device_is_a(busdev, "virtio")) {
+		struct virtio_softc *va = aux;
+
+		ofnode = PCITAG_NODE(va->sc_pa.pa_tag);
 	} else if (device_is_a(busdev, "sbus") || device_is_a(busdev, "dma")
 	|| device_is_a(busdev, "ledma")) {
 		struct sbus_attach_args *sa = aux;



CVS commit: src/sys/arch/sparc64/sparc64

2017-02-19 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Feb 19 18:25:45 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: rft_user needs special handling (a manual fill) since the restore 
instruction may cause the number of trap levels to exceed the maximum for sun4v 
- inspired by code from the the openbsd rft_user code path - verified using 
qemu for both sun4u and sun4v


To generate a diff of this commit:
cvs rdiff -u -r1.408 -r1.409 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.408 src/sys/arch/sparc64/sparc64/locore.s:1.409
--- src/sys/arch/sparc64/sparc64/locore.s:1.408	Fri Feb 10 23:26:23 2017
+++ src/sys/arch/sparc64/sparc64/locore.s	Sun Feb 19 18:25:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.408 2017/02/10 23:26:23 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.409 2017/02/19 18:25:45 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -3145,7 +3145,7 @@ sun4v_texttrap:
 	ba,a,pt	%icc, return_from_trap
 	 nop
 	NOTREACHED
-	
+
 /*
  * End of traps for sun4v.
  */
@@ -4747,6 +4747,36 @@ rft_user:
 	wrpr	%g2, 0, %tpc
 	wrpr	%g3, 0, %tnpc
 	wrpr	%g1, %g0, %tstate
+
+	/*
+	 * The restore instruction further down may cause the trap level
+	 * to exceede the maximum trap level on sun4v, so a manual fill
+	 * may be necessary.
+	*/
+	
+#ifdef SUN4V
+	sethi	%hi(cputyp), %g5
+	ld	[%g5 + %lo(cputyp)], %g5
+	cmp	%g5, CPU_SUN4V
+	bne,pt	%icc, 1f
+	 nop
+
+	! Only manual fill if the restore instruction will cause a fill trap
+	rdpr	%canrestore, %g5
+	brnz	%g5, 1f
+	 nop
+
+	! Do a manual fill
+	wr	%g0, ASI_AIUS, %asi
+	rdpr	%cwp, %g4
+	dec	%g4
+	wrpr	%g4, 0, %cwp
+	FILL	ldxa, %sp+BIAS, 8, %asi
+	restored
+	inc	%g4
+	wrpr	%g4, 0, %cwp
+1:	
+#endif
 	restore
 6:
 	rdpr	%canrestore, %g5



CVS commit: src/sys/arch/sparc64/sparc64

2017-02-12 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Feb 12 19:35:54 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: trap.c

Log Message:
sun4v: Revert previous - paddr_t is not a pointer... noted by nakayama@


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/sys/arch/sparc64/sparc64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.187 src/sys/arch/sparc64/sparc64/trap.c:1.188
--- src/sys/arch/sparc64/sparc64/trap.c:1.187	Sat Feb 11 23:41:36 2017
+++ src/sys/arch/sparc64/sparc64/trap.c	Sun Feb 12 19:35:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.187 2017/02/11 23:41:36 palle Exp $ */
+/*	$NetBSD: trap.c,v 1.188 2017/02/12 19:35:54 palle Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.187 2017/02/11 23:41:36 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.188 2017/02/12 19:35:54 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -738,8 +738,8 @@ badtrap:
 			if (dsfsr & SFSR_FV)
 dsfar = ldxa(SFAR, ASI_DMMU);
 		} else {
-			paddr_t mmu_fsa_dfa = cpus->ci_mmufsa +
-			  (offsetof(struct mmufsa, dfa) / sizeof(paddr_t));
+			paddr_t mmu_fsa_dfa = cpus->ci_mmufsa
+			  + offsetof(struct mmufsa, dfa);
 			dsfar = ldxa(mmu_fsa_dfa, ASI_PHYS_CACHED);
 		}
 #ifdef DEBUG



CVS commit: src/sys/arch/sparc64/sparc64

2017-02-11 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Feb 11 23:41:36 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: trap.c

Log Message:
sun4v: Fix calculation of mmu data fault address (pointer arithmetic)


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/sys/arch/sparc64/sparc64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.186 src/sys/arch/sparc64/sparc64/trap.c:1.187
--- src/sys/arch/sparc64/sparc64/trap.c:1.186	Sat Feb 11 21:04:29 2017
+++ src/sys/arch/sparc64/sparc64/trap.c	Sat Feb 11 23:41:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.186 2017/02/11 21:04:29 christos Exp $ */
+/*	$NetBSD: trap.c,v 1.187 2017/02/11 23:41:36 palle Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.186 2017/02/11 21:04:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.187 2017/02/11 23:41:36 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -738,8 +738,8 @@ badtrap:
 			if (dsfsr & SFSR_FV)
 dsfar = ldxa(SFAR, ASI_DMMU);
 		} else {
-		  	paddr_t mmu_fsa_dfa = cpus->ci_mmufsa
-			+ offsetof(struct mmufsa, dfa);
+			paddr_t mmu_fsa_dfa = cpus->ci_mmufsa +
+			  (offsetof(struct mmufsa, dfa) / sizeof(paddr_t));
 			dsfar = ldxa(mmu_fsa_dfa, ASI_PHYS_CACHED);
 		}
 #ifdef DEBUG



CVS commit: src/sys/arch/sparc64/sparc64

2017-02-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 11 21:04:29 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: trap.c

Log Message:
make this compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 src/sys/arch/sparc64/sparc64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.185 src/sys/arch/sparc64/sparc64/trap.c:1.186
--- src/sys/arch/sparc64/sparc64/trap.c:1.185	Fri Feb 10 18:26:23 2017
+++ src/sys/arch/sparc64/sparc64/trap.c	Sat Feb 11 16:04:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.185 2017/02/10 23:26:23 palle Exp $ */
+/*	$NetBSD: trap.c,v 1.186 2017/02/11 21:04:29 christos Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.185 2017/02/10 23:26:23 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.186 2017/02/11 21:04:29 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -738,8 +738,9 @@ badtrap:
 			if (dsfsr & SFSR_FV)
 dsfar = ldxa(SFAR, ASI_DMMU);
 		} else {
-		  uint8_t* mmu_fsa_dfa = (uint8_t*)cpus->ci_mmufsa + offsetof(struct mmufsa, dfa);
-		  dsfar = ldxa((paddr_t)mmu_fsa_dfa, ASI_PHYS_CACHED);
+		  	paddr_t mmu_fsa_dfa = cpus->ci_mmufsa
+			+ offsetof(struct mmufsa, dfa);
+			dsfar = ldxa(mmu_fsa_dfa, ASI_PHYS_CACHED);
 		}
 #ifdef DEBUG
 		if (!CPU_ISSUN4V) {



CVS commit: src/sys/arch/sparc64/sparc64

2017-01-30 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Jan 30 21:24:33 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: Hook up syscall handling to the trap table. Verified using qemu for both 
sun4u and sun4v.


To generate a diff of this commit:
cvs rdiff -u -r1.406 -r1.407 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.406 src/sys/arch/sparc64/sparc64/locore.s:1.407
--- src/sys/arch/sparc64/sparc64/locore.s:1.406	Fri Jan 27 21:35:38 2017
+++ src/sys/arch/sparc64/sparc64/locore.s	Mon Jan 30 21:24:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.406 2017/01/27 21:35:38 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.407 2017/01/30 21:24:33 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1137,7 +1137,7 @@ _C_LABEL(trapbase_sun4v):
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0f4 fill_5_other
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0f8 fill_6_other
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0fc fill_7_other
-	sun4v_trap_entry 1	! 0x100
+	SYSCALL			! 0x100 = syscall
 	BPT			! 0x101 = pseudo breakpoint instruction
 	sun4v_trap_entry 254	! 0x102-0x1ff
 	!
@@ -3676,7 +3676,21 @@ syscall_setup:
 	sth	%o1, [%sp + CC64FSZ + STKB + TF_TT]! debug
 #endif
 
-	wrpr	%g0, PSTATE_KERN, %pstate	! Get back to normal globals
+	! Get back to normal globals
+#ifdef SUN4V
+	sethi	%hi(cputyp), %g5
+	ld	[%g5 + %lo(cputyp)], %g5
+	cmp	%g5, CPU_SUN4V
+	bne,pt	%icc, 1f
+	 nop
+	NORMAL_GLOBALS_SUN4V
+	ba	2f
+	 nop
+1:	
+#endif	
+	NORMAL_GLOBALS_SUN4U
+2:
+	
 	stx	%g1, [%sp + CC64FSZ + STKB + TF_G + ( 1*8)]
 	mov	%g1, %o1			! code
 	rdpr	%tpc, %o2			! (pc)



CVS commit: src/sys/arch/sparc64/sparc64

2017-01-27 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Jan 27 21:35:38 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: genassym.cf locore.s

Log Message:
sun4v: implement missing handling of itsb traps 0x008 and 0x009. Based on code 
from OpenBSD. Tested using qemu.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/sparc64/sparc64/genassym.cf
cvs rdiff -u -r1.405 -r1.406 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/genassym.cf
diff -u src/sys/arch/sparc64/sparc64/genassym.cf:1.79 src/sys/arch/sparc64/sparc64/genassym.cf:1.80
--- src/sys/arch/sparc64/sparc64/genassym.cf:1.79	Tue May 17 19:43:28 2016
+++ src/sys/arch/sparc64/sparc64/genassym.cf	Fri Jan 27 21:35:38 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.79 2016/05/17 19:43:28 palle Exp $
+#	$NetBSD: genassym.cf,v 1.80 2017/01/27 21:35:38 palle Exp $
 
 #
 # Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -149,6 +149,7 @@ export SUN4U_TTE_P
 export SUN4U_TTE_EXEC
 export SUN4V_TLB_ACCESS
 export SUN4V_TLB_MODIFY
+export SUN4V_TLB_EXEC
 export SUN4V_TLB_W
 export SUN4V_TLB_TSB_LOCK
 

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.405 src/sys/arch/sparc64/sparc64/locore.s:1.406
--- src/sys/arch/sparc64/sparc64/locore.s:1.405	Sat Jan  7 20:19:09 2017
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri Jan 27 21:35:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.405 2017/01/07 20:19:09 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.406 2017/01/27 21:35:38 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1076,7 +1076,10 @@ _C_LABEL(trapbase_sun4v):
 	!
 	! trap level 0
 	!
-	sun4v_trap_entry 36	! 0x000-0x023
+	sun4v_trap_entry 8	! 0x000-0x007
+	VTRAP(T_INST_EXCEPT, sun4v_tl0_itsb_miss)		! 0x008 - inst except
+	VTRAP(T_TEXTFAULT, sun4v_tl0_itsb_miss)			! 0x009 - inst MMU miss
+	sun4v_trap_entry 26	! 0x00a-0x023
 	CLEANWIN0		! 0x24-0x27 = clean window
 	sun4v_trap_entry 9	! 0x028-0x030			
 	VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss)			! 0x031 = data MMU miss
@@ -2819,7 +2822,7 @@ sun4v_dtsb_miss:
 	btst	SUN4V_TLB_ACCESS, %g4		! Need to update access bit?
 	bne,pt	%xcc, 2f
 	 nop
-	casxa	[%g6] ASI_PHYS_CACHED, %g4, %g7	!  and write it out
+	casxa	[%g6] ASI_PHYS_CACHED, %g4, %g7	! and write it out
 	cmp	%g4, %g7
 	bne,pn	%xcc, 1b
 	 or	%g4, SUN4V_TLB_ACCESS, %g4	! Update the access bit
@@ -2845,8 +2848,8 @@ sun4v_dtsb_miss:
 
 	membar	#StoreStore
 
-	STPTR	%g4, [%g2 + 8]		! store TTE data
-	STPTR	%g1, [%g2]		! store TTE tag
+	STPTR	%g4, [%g2 + 8]			! store TTE data
+	STPTR	%g1, [%g2]			! store TTE tag
 
 	retry
 	NOTREACHED
@@ -3007,6 +3010,139 @@ sun4v_tl0_dtsb_prot:
 
 	retry
 	NOTREACHED
+
+sun4v_tl0_itsb_miss:
+	GET_MMFSA %g1! MMU Fault status area
+	add	%g1, 0x8, %g3
+	LDPTRA	[%g3] ASI_PHYS_CACHED, %g3	! Instruction fault address
+	add	%g1, 0x10, %g6
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g6	! Data fault context
+	
+	GET_CTXBUSY %g4
+	sllx	%g6, 3, %g6			! Make it into an offset into ctxbusy
+	LDPTR	[%g4 + %g6], %g4		! Load up our page table.
+
+	srax	%g3, HOLESHIFT, %g5		! Check for valid address
+	brz,pt	%g5, 0f! Should be zero or -1
+	 inc	%g5! Make -1 -> 0
+	brnz,pn	%g5, sun4v_texttrap		! Error! In hole!
+0:
+	srlx	%g3, STSHIFT, %g6
+	and	%g6, STMASK, %g6		! Index into pm_segs
+	sll	%g6, 3, %g6
+	add	%g4, %g6, %g4
+	LDPTRA	[%g4] ASI_PHYS_CACHED, %g4	! Load page directory pointer
+
+	srlx	%g3, PDSHIFT, %g6
+	and	%g6, PDMASK, %g6
+	sll	%g6, 3, %g6
+	brz,pn	%g4, sun4v_texttrap		! NULL entry? check somewhere else
+	 add	%g4, %g6, %g4
+	LDPTRA	[%g4] ASI_PHYS_CACHED, %g4	! Load page table pointer
+
+	srlx	%g3, PTSHIFT, %g6		! Convert to ptab offset
+	and	%g6, PTMASK, %g6
+	sll	%g6, 3, %g6
+	brz,pn	%g4, sun4v_texttrap		! NULL entry? check somewhere else
+	 add	%g4, %g6, %g6
+1:
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g4	! Fetch TTE
+	brgez,pn %g4, sun4v_texttrap		! Entry invalid?  Punt
+	 or	%g4, SUN4V_TLB_ACCESS, %g7	! Update the access bit
+
+	btst	SUN4V_TLB_EXEC, %g4		! Need to update exec bit?
+	bz,pn	%xcc, sun4v_texttrap
+	 nop
+	btst	SUN4V_TLB_ACCESS, %g4		! Need to update access bit?
+	bne,pt	%xcc, 2f
+	 nop
+	casxa	[%g6] ASI_PHYS_CACHED, %g4, %g7	! and write it out
+	cmp	%g4, %g7
+	bne,pn	%xcc, 1b
+	 or	%g4, SUN4V_TLB_ACCESS, %g4	! Update the modified bit
+2:
+	GET_TSB_DMMU %g2
+
+	mov	%g1, %g7
+	/* Construct TSB tag word. */
+	add	%g1, 0x10, %g6
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g6	! Instruction fault context
+	mov	%g3, %g1			! Instruction fault address
+	srlx	%g1, 22, %g1			! 63..22 of virt addr
+	sllx	%g6, 48, %g6			! context_id in 63..48
+	or	%g1, %g6, %g1			! construct TTE tag
+
+	srlx	%g3, PTSHIFT, %g3
+	sethi	%hi(_C_LABEL(tsbsize)), %g5
+	mov	512, %g6
+	ld	[%g5 + %lo(_C_LABEL(tsbsize))], %g5
+	sllx	%g6, %g5, %g5			! %g5 = 512 << tsbsize = TSBENTS
+	sub	%g5, 1, %g5	

CVS commit: src/sys/arch/sparc64/sparc64

2017-01-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan  9 12:24:38 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: process_machdep.c

Log Message:
Do not use kmem_zalloc() to allocate an FP state - we have a special pool
for that.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/sparc64/sparc64/process_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/process_machdep.c
diff -u src/sys/arch/sparc64/sparc64/process_machdep.c:1.25 src/sys/arch/sparc64/sparc64/process_machdep.c:1.26
--- src/sys/arch/sparc64/sparc64/process_machdep.c:1.25	Fri Dec 30 18:30:19 2016
+++ src/sys/arch/sparc64/sparc64/process_machdep.c	Mon Jan  9 12:24:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.25 2016/12/30 18:30:19 christos Exp $ */
+/*	$NetBSD: process_machdep.c,v 1.26 2017/01/09 12:24:38 martin Exp $ */
 
 /*
  * Copyright (c) 1993 The Regents of the University of California.
@@ -95,7 +95,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.25 2016/12/30 18:30:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.26 2017/01/09 12:24:38 martin Exp $");
 
 #include 
 #include 
@@ -231,7 +231,8 @@ process_write_fpregs(struct lwp *l, cons
 	struct fpstate64	*fs;
 
 	if ((fs = l->l_md.md_fpstate) == NULL) {
-		fs = kmem_zalloc(sizeof(*fs), KM_SLEEP);
+		fs = pool_cache_get(fpstate_cache, PR_WAITOK);
+		memcpy(fs, , sizeof *fs);
 		l->l_md.md_fpstate = fs;
 	} else
 		fs->fs_qsize = 0;



CVS commit: src/sys/arch/sparc64/sparc64

2017-01-07 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Jan  7 20:19:09 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: slowtrap() now selects normal globals properly on both sun4u and sun4v 
platforms. Verified using qemu for both sun4u and sun4v systems


To generate a diff of this commit:
cvs rdiff -u -r1.404 -r1.405 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.404 src/sys/arch/sparc64/sparc64/locore.s:1.405
--- src/sys/arch/sparc64/sparc64/locore.s:1.404	Thu Jan  5 20:37:06 2017
+++ src/sys/arch/sparc64/sparc64/locore.s	Sat Jan  7 20:19:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.404 2017/01/05 20:37:06 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.405 2017/01/07 20:19:09 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -3151,7 +3151,20 @@ Lslowtrap_reenter:
 	mov	%g2, %o2		! (pc)
 	sth	%o1, [%sp + CC64FSZ + STKB + TF_TT]! debug
 
-	wrpr	%g0, PSTATE_KERN, %pstate		! Get back to normal globals
+	! Get back to normal globals
+#ifdef SUN4V
+	sethi	%hi(cputyp), %g5
+	ld	[%g5 + %lo(cputyp)], %g5
+	cmp	%g5, CPU_SUN4V
+	bne,pt	%icc, 1f
+	 nop
+	NORMAL_GLOBALS_SUN4V
+	ba	2f
+	 nop
+1:	
+#endif	
+	NORMAL_GLOBALS_SUN4U
+2:
 	stx	%g1, [%sp + CC64FSZ + STKB + TF_G + (1*8)]
 	stx	%g2, [%sp + CC64FSZ + STKB + TF_G + (2*8)]
 	add	%sp, CC64FSZ + STKB, %o0		! ()



CVS commit: src/sys/arch/sparc64/sparc64

2017-01-05 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Jan  5 20:37:06 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: TRAP_SETUP() updated to set mmu context id properly for both sun4v and 
sun4u platforms. Verified using qemu for both sun4u and sun4v systems


To generate a diff of this commit:
cvs rdiff -u -r1.403 -r1.404 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.403 src/sys/arch/sparc64/sparc64/locore.s:1.404
--- src/sys/arch/sparc64/sparc64/locore.s:1.403	Wed Jan  4 20:19:29 2017
+++ src/sys/arch/sparc64/sparc64/locore.s	Thu Jan  5 20:37:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.403 2017/01/04 20:19:29 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.404 2017/01/05 20:37:06 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1461,7 +1461,7 @@ intr_setup_msg:
 	wrpr	%g0, %g5, %otherwin; \
 	wrpr	%g0, WSTATE_KERN, %wstate;			/* Enable kernel mode window traps -- now we can trap again */ \
 \
-	stxa	%g0, [%g7] ASI_DMMU; /* Switch MMU to kernel primary context */ \
+	SET_MMU_CONTEXTID %g0, %g7,%g5; 			/* Switch MMU to kernel primary context */ \
 	sethi	%hi(KERNBASE), %g5; \
 	flush	%g5;		/* Some convenient address that won't trap */ \
 1:
@@ -1577,7 +1577,7 @@ intr_setup_msg:
 	wrpr	%g0, %g5, %otherwin; \
 	wrpr	%g0, WSTATE_KERN, %wstate;			/* Enable kernel mode window traps -- now we can trap again */ \
 	\
-	stxa	%g0, [%g7] ASI_DMMU; /* Switch MMU to kernel primary context */ \
+	SET_MMU_CONTEXTID %g0, %g7, %g5;			/* Switch MMU to kernel primary context */ \
 	sethi	%hi(KERNBASE), %g5; \
 	flush	%g5;		/* Some convenient address that won't trap */ \
 1:



CVS commit: src/sys/arch/sparc64/sparc64

2017-01-04 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Wed Jan  4 20:19:29 UTC 2017

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: make debugging kernel bringup a bit easier by using the slowtrap code 
path for currently unhandled trap level 1 trap entries 0x00-0x23 and 0x28-0x30


To generate a diff of this commit:
cvs rdiff -u -r1.402 -r1.403 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.402 src/sys/arch/sparc64/sparc64/locore.s:1.403
--- src/sys/arch/sparc64/sparc64/locore.s:1.402	Thu Dec 29 20:59:31 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Wed Jan  4 20:19:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.402 2016/12/29 20:59:31 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.403 2017/01/04 20:19:29 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1140,9 +1140,9 @@ _C_LABEL(trapbase_sun4v):
 	!
 	! trap level 1
 	!
-	sun4v_trap_entry_fail 36! 0x000-0x023
+	sun4v_trap_entry 36	! 0x000-0x023
 	CLEANWIN1		! 0x24-0x27 = clean window
-	sun4v_trap_entry_fail 9	! 0x028-0x030			
+	sun4v_trap_entry 9	! 0x028-0x030
 	VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss)			! 0x031 = data MMU miss
 	sun4v_trap_entry 78	! 0x032-0x07f
 	SPILL64(uspill8_sun4vt1,ASI_AIUS)			! 0x080 spill_0_normal -- save user windows



CVS commit: src/sys/arch/sparc64/sparc64

2016-12-29 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Dec 29 20:59:31 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: make debugging kernel bringup a bit easier by using the slowtrap code 
path for currently unhandled trap level 1 trap entries 0x32-0x7f


To generate a diff of this commit:
cvs rdiff -u -r1.401 -r1.402 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.401 src/sys/arch/sparc64/sparc64/locore.s:1.402
--- src/sys/arch/sparc64/sparc64/locore.s:1.401	Tue Sep 20 08:56:34 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Thu Dec 29 20:59:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.401 2016/09/20 08:56:34 nakayama Exp $	*/
+/*	$NetBSD: locore.s,v 1.402 2016/12/29 20:59:31 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1144,7 +1144,7 @@ _C_LABEL(trapbase_sun4v):
 	CLEANWIN1		! 0x24-0x27 = clean window
 	sun4v_trap_entry_fail 9	! 0x028-0x030			
 	VTRAP(T_DATA_MMU_MISS, sun4v_dtsb_miss)			! 0x031 = data MMU miss
-	sun4v_trap_entry_fail 78! 0x032-0x07f
+	sun4v_trap_entry 78	! 0x032-0x07f
 	SPILL64(uspill8_sun4vt1,ASI_AIUS)			! 0x080 spill_0_normal -- save user windows
 	SPILL32(uspill4_sun4vt1,ASI_AIUS)			! 0x084 spill_1_normal
 	SPILLBOTH(uspill8_sun4vt1,uspill4_sun4vt1,ASI_AIUS)	! 0x088 spill_2_normal



CVS commit: src/sys/arch/sparc64/sparc64

2016-11-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Nov  4 18:09:14 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: machdep.c

Log Message:
allow BUS_SPACE_MAP_PREFETCHABLE with bus_space_map() as well


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 src/sys/arch/sparc64/sparc64/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/machdep.c
diff -u src/sys/arch/sparc64/sparc64/machdep.c:1.286 src/sys/arch/sparc64/sparc64/machdep.c:1.287
--- src/sys/arch/sparc64/sparc64/machdep.c:1.286	Fri Nov  4 05:41:01 2016
+++ src/sys/arch/sparc64/sparc64/machdep.c	Fri Nov  4 18:09:14 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.286 2016/11/04 05:41:01 macallan Exp $ */
+/*	$NetBSD: machdep.c,v 1.287 2016/11/04 18:09:14 macallan Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.286 2016/11/04 05:41:01 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.287 2016/11/04 18:09:14 macallan Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -2293,6 +2293,9 @@ sparc_bus_map(bus_space_tag_t t, bus_add
 	if (!(flags & BUS_SPACE_MAP_CACHEABLE))
 		pm_flags |= PMAP_NC;
 
+	if ((flags & BUS_SPACE_MAP_PREFETCHABLE))
+		pm_flags |= PMAP_WC;
+
 	if ((err = extent_alloc(io_space, size, PAGE_SIZE,
 		0, EX_NOWAIT|EX_BOUNDZERO, (u_long *
 			panic("sparc_bus_map: cannot allocate io_space: %d", err);



CVS commit: src/sys/arch/sparc64/sparc64

2016-09-20 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Tue Sep 20 08:56:34 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
Fix RAS for 32-bit kernels.  trapframe is always 64-bit.


To generate a diff of this commit:
cvs rdiff -u -r1.400 -r1.401 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.400 src/sys/arch/sparc64/sparc64/locore.s:1.401
--- src/sys/arch/sparc64/sparc64/locore.s:1.400	Tue Aug 23 19:57:01 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Tue Sep 20 08:56:34 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.400 2016/08/23 19:57:01 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.401 2016/09/20 08:56:34 nakayama Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -6060,12 +6060,12 @@ ENTRY(cpu_switchto)
 	brz,pt	%o1, Lsw_noras		! no, skip RAS check
 	 LDPTR	[%i1 + L_TF], %l3	! pointer to trap frame
 	call	_C_LABEL(ras_lookup)
-	 LDPTR	[%l3 + TF_PC], %o1
+	 ldx	[%l3 + TF_PC], %o1
 	cmp	%o0, -1
-	be,pt	%xcc, Lsw_noras
+	be,pt	CCCR, Lsw_noras
 	 add	%o0, 4, %o1
-	STPTR	%o0, [%l3 + TF_PC]	! store rewound %pc
-	STPTR	%o1, [%l3 + TF_NPC]	! and %npc
+	stx	%o0, [%l3 + TF_PC]	! store rewound %pc
+	stx	%o1, [%l3 + TF_NPC]	! and %npc
 
 Lsw_noras:
 



CVS commit: src/sys/arch/sparc64/sparc64

2016-08-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 29 15:57:07 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: kobj_machdep.c

Log Message:
The target of the OLO10 relocation is the simd13 field of the instruction,
so use a 13 bit target mask.
Fixes PR kern/51436 (I broke this myself in rev 1.4)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/sparc64/kobj_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/kobj_machdep.c
diff -u src/sys/arch/sparc64/sparc64/kobj_machdep.c:1.5 src/sys/arch/sparc64/sparc64/kobj_machdep.c:1.6
--- src/sys/arch/sparc64/sparc64/kobj_machdep.c:1.5	Sat Feb  1 11:19:04 2014
+++ src/sys/arch/sparc64/sparc64/kobj_machdep.c	Mon Aug 29 15:57:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: kobj_machdep.c,v 1.5 2014/02/01 11:19:04 nakayama Exp $	*/
+/*	$NetBSD: kobj_machdep.c,v 1.6 2016/08/29 15:57:07 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 Jake Burkholder.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.5 2014/02/01 11:19:04 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kobj_machdep.c,v 1.6 2016/08/29 15:57:07 martin Exp $");
 
 #define	ELFSIZE		ARCH_ELFSIZE
 
@@ -164,7 +164,7 @@ static const long reloc_target_bitmask[]
 	_BM(22), _BM(10),		/* _HIPLT22, LOPLT10 */
 	_BM(32), _BM(22), _BM(10),	/* _PCPLT32, _PCPLT22, _PCPLT10 */
 	_BM(10), _BM(11), -1,		/* _10, _11, _64 */
-	_BM(10), _BM(22),		/* _OLO10, _HH22 */
+	_BM(13), _BM(22),		/* _OLO10, _HH22 */
 	_BM(10), _BM(22),		/* _HM10, _LM22 */
 	_BM(22), _BM(10), _BM(22),	/* _PC_HH22, _PC_HM10, _PC_LM22 */
 	_BM(16), _BM(19),		/* _WDISP16, _WDISP19 */



CVS commit: src/sys/arch/sparc64/sparc64

2016-08-23 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Aug 23 19:57:01 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: rework sun4v_datatrap so it works properly when running on a T2-based 
system like T5120 - for some reason %tl is 0 when entering sun4v_datatrap 
causing a crash (sir instruction), so ignore the %tl value for now upon entry 
to sun4v_datatrap - with this fix both T1 and T2 based systems reach the same 
point - hangs in rft_user after the init process is started


To generate a diff of this commit:
cvs rdiff -u -r1.399 -r1.400 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.399 src/sys/arch/sparc64/sparc64/locore.s:1.400
--- src/sys/arch/sparc64/sparc64/locore.s:1.399	Mon Jul 18 19:51:06 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Tue Aug 23 19:57:01 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.399 2016/07/18 19:51:06 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.400 2016/08/23 19:57:01 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -2851,15 +2851,7 @@ sun4v_dtsb_miss:
 	retry
 	NOTREACHED
 
-sun4v_datatrap:			! branch further based on trap level
-	rdpr	%tl, %g1
-	dec	%g1
-	beq	sun4v_datatrap_tl0
-	 nop
-	ba	sun4v_datatrap_tl1
-	 nop
-
-sun4v_datatrap_tl0:
+sun4v_datatrap:
 	GET_MMFSA %g3! MMU Fault status area
 	add	%g3, 0x48, %g1
 	LDPTRA	[%g1] ASI_PHYS_CACHED, %g1	! Data fault address
@@ -2918,10 +2910,6 @@ sun4v_datatrap_tl0:
 	 nop
 	NOTREACHED
 	
-sun4v_datatrap_tl1:
-	/* XXX missing implementaion */
-	sir
-
 sun4v_tl0_dtsb_prot:
 	GET_MMFSA %g1! MMU Fault status area
 	add	%g1, 0x48, %g3



CVS commit: src/sys/arch/sparc64/sparc64

2016-08-07 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Aug  7 19:35:43 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: copy.S

Log Message:
Make comment more readable - no functional changes


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/sparc64/copy.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/copy.S
diff -u src/sys/arch/sparc64/sparc64/copy.S:1.6 src/sys/arch/sparc64/sparc64/copy.S:1.7
--- src/sys/arch/sparc64/sparc64/copy.S:1.6	Sun Nov 22 10:18:14 2015
+++ src/sys/arch/sparc64/sparc64/copy.S	Sun Aug  7 19:35:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: copy.S,v 1.6 2015/11/22 10:18:14 martin Exp $	*/
+/*	$NetBSD: copy.S,v 1.7 2016/08/07 19:35:43 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -432,7 +432,7 @@ Lcopyout_start:
 	 .empty
 0:
 	inc	%o0
-	ldsb	[%o0 - 1], %o4!	(++dst)[-1] = *src++;
+	ldsb	[%o0 - 1], %o4	! (++dst)[-1] = *src++;
 	stba	%o4, [%o1] %asi
 	deccc	%o2
 	bge	0b



CVS commit: src/sys/arch/sparc64/sparc64

2016-07-18 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Jul 18 19:51:06 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: handle device interrupts properly - both legacy (sysino) and cookies


To generate a diff of this commit:
cvs rdiff -u -r1.398 -r1.399 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.398 src/sys/arch/sparc64/sparc64/locore.s:1.399
--- src/sys/arch/sparc64/sparc64/locore.s:1.398	Sat Jun  4 21:24:41 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Mon Jul 18 19:51:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.398 2016/06/04 21:24:41 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.399 2016/07/18 19:51:06 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -3826,9 +3826,9 @@ sun4v_dev_mondo:
 	stxa	%g2, [%g1] ASI_QUEUE		 ! ajust head index value
 	membar	#Sync
 
-	cmp	%g5, MAXINTNUM			! out of bounds?
-	bgeu,pn	%xcc, 2f
-	 nop	! no just continue
+	cmp	%g5, MAXINTNUM			! Handle both sun4v legacy (sysino) and cookies.
+	bgeu,pn	%xcc, 1f			! See UltraSPARC Virtual Machine Specification
+	 nop	! version 3 chapter 6 (Interrupt model)
 
 	sethi	%hi(_C_LABEL(intrlev)), %g3
 	sllx	%g5, PTRSHFT, %g5	! Calculate entry number
@@ -3840,8 +3840,7 @@ sun4v_dev_mondo:
 
 	ba,a	3b			! log if invalid handle
 	 nop
-2:
-	sir! out of bounds - crash
+
 /*
  * Ultra1 and Ultra2 CPUs use soft interrupts for everything.  What we do
  * on a soft interrupt, is we should check which bits in SOFTINT(%asr22)
@@ -4646,7 +4645,6 @@ badregs:
 	rdpr	%cwp, %g7			! Find our cur window
 	andn	%g1, CWP, %g1			! Clear it from %tstate
 	wrpr	%g1, %g7, %tstate		! Set %tstate with %cwp
-
 	mov	CTX_SECONDARY, %g1		! Restore the user context
 	GET_MMU_CONTEXTID %g4, %g1, %g3
 	mov	CTX_PRIMARY, %g2



CVS commit: src/sys/arch/sparc64/sparc64

2016-06-04 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Jun  4 21:24:41 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: rtf_user now uses macros GET_MMU_CONTEXTID and SET_MMU_CONTEXTID. Tested 
on sun4u (QEMU) and sun4v (T2000). Parts from OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.397 -r1.398 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.397 src/sys/arch/sparc64/sparc64/locore.s:1.398
--- src/sys/arch/sparc64/sparc64/locore.s:1.397	Wed May 18 15:14:08 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Sat Jun  4 21:24:41 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.397 2016/05/18 15:14:08 nakayama Exp $	*/
+/*	$NetBSD: locore.s,v 1.398 2016/06/04 21:24:41 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -150,6 +150,34 @@
 3:
 	.endm
 
+	.macro	GET_MMU_CONTEXTID_SUN4U ctxid,ctx
+	ldxa	[\ctx] ASI_DMMU, \ctxid
+	.endm
+
+#ifdef SUN4V
+	.macro	GET_MMU_CONTEXTID_SUN4V ctxid,ctx
+	ldxa	[\ctx] ASI_MMU_CONTEXTID, \ctxid
+	.endm
+#endif	
+		
+	.macro	GET_MMU_CONTEXTID ctxid,ctx,scratch
+#ifdef SUN4V
+	sethi	%hi(cputyp), \scratch
+	ld	[\scratch + %lo(cputyp)], \scratch
+	cmp	\scratch, CPU_SUN4V
+	bne,pt	%icc, 2f
+	 nop
+	/* sun4v */
+	GET_MMU_CONTEXTID_SUN4V \ctxid,\ctx
+	ba	3f
+	 nop
+2:		
+#endif	
+	/* sun4u */
+	GET_MMU_CONTEXTID_SUN4U \ctxid,\ctx
+3:
+	.endm
+	
 #ifdef SUN4V
 	.macro	NORMAL_GLOBALS_SUN4V
 	 wrpr	%g0, 0, %gl! Set globals to level 0
@@ -4619,12 +4647,14 @@ badregs:
 	andn	%g1, CWP, %g1			! Clear it from %tstate
 	wrpr	%g1, %g7, %tstate		! Set %tstate with %cwp
 
-	wr	%g0, ASI_DMMU, %asi		! restore the user context
-	ldxa	[CTX_SECONDARY] %asi, %g4
+	mov	CTX_SECONDARY, %g1		! Restore the user context
+	GET_MMU_CONTEXTID %g4, %g1, %g3
+	mov	CTX_PRIMARY, %g2
+	SET_MMU_CONTEXTID %g4, %g2, %g3
 	sethi	%hi(KERNBASE), %g7		! Should not be needed due to retry
-	stxa	%g4, [CTX_PRIMARY] %asi
 	membar	#Sync! Should not be needed due to retry
 	flush	%g7! Should not be needed due to retry
+
 	CLRTT
 #ifdef TRAPSTATS
 	set	_C_LABEL(rftudone), %g1



CVS commit: src/sys/arch/sparc64/sparc64

2016-05-18 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Wed May 18 15:14:08 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
Decrement %tl in trap handler not to make it zero unconditionally
for the nested trap, and remove useless mov.


To generate a diff of this commit:
cvs rdiff -u -r1.396 -r1.397 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.396 src/sys/arch/sparc64/sparc64/locore.s:1.397
--- src/sys/arch/sparc64/sparc64/locore.s:1.396	Tue May 17 19:43:28 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Wed May 18 15:14:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.396 2016/05/17 19:43:28 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.397 2016/05/18 15:14:08 nakayama Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -7147,7 +7147,6 @@ ENTRY(sparc64_ipi_ccall)
 
 	wrpr	%g0, PSTATE_KERN, %pstate	! Get back to normal globals
 	stx	%g1, [%sp + CC64FSZ + STKB + TF_G + ( 1*8)]
-	mov	%g1, %o1			! code
 	rdpr	%tpc, %o2			! (pc)
 	stx	%g2, [%sp + CC64FSZ + STKB + TF_G + ( 2*8)]
 	rdpr	%tstate, %g1
@@ -7157,7 +7156,6 @@ ENTRY(sparc64_ipi_ccall)
 	rd	%y, %o4
 	stx	%g5, [%sp + CC64FSZ + STKB + TF_G + ( 5*8)]
 	stx	%g6, [%sp + CC64FSZ + STKB + TF_G + ( 6*8)]
-	wrpr	%g0, 0, %tl			! return to tl=0
 	stx	%g7, [%sp + CC64FSZ + STKB + TF_G + ( 7*8)]
 
 	stx	%g1, [%sp + CC64FSZ + STKB + TF_TSTATE]
@@ -7169,6 +7167,10 @@ ENTRY(sparc64_ipi_ccall)
 	stb	%g5, [%sp + CC64FSZ + STKB + TF_PIL]
 	stb	%g5, [%sp + CC64FSZ + STKB + TF_OLDPIL]
 
+	rdpr	%tl, %g7
+	dec	%g7
+	movrlz	%g7, %g0, %g7
+	wrpr	%g0, %g7, %tl
 	!! In the EMBEDANY memory model %g4 points to the start of the data segment.
 	!! In our case we need to clear it before calling any C-code
 	clr	%g4



CVS commit: src/sys/arch/sparc64/sparc64

2016-05-17 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue May 17 19:43:28 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: genassym.cf locore.s

Log Message:
sun4v: Implement missng MMU protection trap handling - mostly from OpenBSD


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/sparc64/sparc64/genassym.cf
cvs rdiff -u -r1.395 -r1.396 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/genassym.cf
diff -u src/sys/arch/sparc64/sparc64/genassym.cf:1.78 src/sys/arch/sparc64/sparc64/genassym.cf:1.79
--- src/sys/arch/sparc64/sparc64/genassym.cf:1.78	Mon May 16 20:03:07 2016
+++ src/sys/arch/sparc64/sparc64/genassym.cf	Tue May 17 19:43:28 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.78 2016/05/16 20:03:07 palle Exp $
+#	$NetBSD: genassym.cf,v 1.79 2016/05/17 19:43:28 palle Exp $
 
 #
 # Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -148,6 +148,8 @@ export SUN4U_TTE_CV
 export SUN4U_TTE_P
 export SUN4U_TTE_EXEC
 export SUN4V_TLB_ACCESS
+export SUN4V_TLB_MODIFY
+export SUN4V_TLB_W
 export SUN4V_TLB_TSB_LOCK
 
 export PG_SHIFT4U

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.395 src/sys/arch/sparc64/sparc64/locore.s:1.396
--- src/sys/arch/sparc64/sparc64/locore.s:1.395	Mon May 16 20:03:07 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Tue May 17 19:43:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.395 2016/05/16 20:03:07 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.396 2016/05/17 19:43:28 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1068,7 +1068,9 @@ _C_LABEL(trapbase_sun4v):
 	HARDINT4V(13)		! 0x04d = level 13 interrupt
 	HARDINT4V(14)		! 0x04e = level 14 interrupt
 	HARDINT4V(15)		! 0x04f = level 15 interrupt
-	sun4v_trap_entry 44	! 0x050-0x07b
+	sun4v_trap_entry 28	! 0x050-0x06b
+	VTRAP(T_FDMMU_PROT, sun4v_tl0_dtsb_prot)		! 0x6c
+	sun4v_trap_entry 15	! 0x06d-0x07b
 	VTRAP(T_CPU_MONDO, sun4v_cpu_mondo)			! 0x07c = cpu mondo
 	VTRAP(T_DEV_MONDO, sun4v_dev_mondo)			! 0x07d = dev mondo
 	sun4v_trap_entry 2	! 0x07e-0x07f
@@ -2891,7 +2893,105 @@ sun4v_datatrap_tl0:
 sun4v_datatrap_tl1:
 	/* XXX missing implementaion */
 	sir
-			
+
+sun4v_tl0_dtsb_prot:
+	GET_MMFSA %g1! MMU Fault status area
+	add	%g1, 0x48, %g3
+	LDPTRA	[%g3] ASI_PHYS_CACHED, %g3	! Data fault address
+	add	%g1, 0x50, %g6
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g6	! Data fault context
+
+	GET_CTXBUSY %g4
+	sllx	%g6, 3, %g6			! Make it into an offset into ctxbusy
+	LDPTR	[%g4 + %g6], %g4		! Load up our page table.
+
+	srax	%g3, HOLESHIFT, %g5		! Check for valid address
+	brz,pt	%g5, 0f! Should be zero or -1
+	 inc	%g5! Make -1 -> 0
+	brnz,pn	%g5, sun4v_datatrap		! Error! In hole!
+0:
+	srlx	%g3, STSHIFT, %g6
+	and	%g6, STMASK, %g6		! Index into pm_segs
+	sll	%g6, 3, %g6
+	add	%g4, %g6, %g4
+	LDPTRA	[%g4] ASI_PHYS_CACHED, %g4	! Load page directory pointer
+
+	srlx	%g3, PDSHIFT, %g6
+	and	%g6, PDMASK, %g6
+	sll	%g6, 3, %g6
+	brz,pn	%g4, sun4v_datatrap		! NULL entry? check somewhere else
+	 add	%g4, %g6, %g4
+	LDPTRA	[%g4] ASI_PHYS_CACHED, %g4	! Load page table pointer
+
+	srlx	%g3, PTSHIFT, %g6		! Convert to ptab offset
+	and	%g6, PTMASK, %g6
+	sll	%g6, 3, %g6
+	brz,pn	%g4, sun4v_datatrap		! NULL entry? check somewhere else
+	 add	%g4, %g6, %g6
+1:
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g4	! Fetch TTE
+	brgez,pn %g4, sun4v_datatrap		! Entry invalid?  Punt
+	 or	%g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g7
+	! Update the modified bit
+
+#	btst	SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4	! Is it a ref fault?
+	mov	1, %g2
+	sllx	%g2, 61, %g2
+	or	%g2, SUN4V_TLB_W, %g2
+	btst	%g2, %g4
+	bz,pn	%xcc, sun4v_datatrap			! No -- really fault
+	 nop
+	casxa	[%g6] ASI_PHYS_CACHED, %g4, %g7		!  and write it out
+	cmp	%g4, %g7
+	bne,pn	%xcc, 1b
+	 or	%g4, SUN4V_TLB_MODIFY|SUN4V_TLB_ACCESS|SUN4V_TLB_W, %g4
+		! Update the modified bit
+2:
+	GET_TSB_DMMU %g2
+
+	mov	%g1, %g7			! save MMFSA
+
+	/* Construct TSB tag word. */
+	add	%g1, 0x50, %g6
+	LDPTRA	[%g6] ASI_PHYS_CACHED, %g6	! Data fault context
+	mov	%g3, %g1			! Data fault address
+	srlx	%g1, 22, %g1			! 63..22 of virt addr
+	sllx	%g6, 48, %g6			! context_id in 63..48
+	or	%g1, %g6, %g1			! construct TTE tag
+
+	srlx	%g3, PTSHIFT, %g3
+	sethi	%hi(_C_LABEL(tsbsize)), %g5
+	mov	512, %g6
+	ld	[%g5 + %lo(_C_LABEL(tsbsize))], %g5
+	sllx	%g6, %g5, %g5			! %g5 = 512 << tsbsize = TSBENTS
+	sub	%g5, 1, %g5			! TSBENTS -> offset
+	and	%g3, %g5, %g3			! mask out TTE index
+	sllx	%g3, 4, %g3			! TTE size is 16 bytes
+	add	%g2, %g3, %g2			! location of TTE in ci_tsb_dmmu
+
+	membar	#StoreStore
+	
+	STPTR	%g4, [%g2 + 8]		! store TTE data
+	STPTR	%g1, [%g2]		! store TTE tag
+
+	mov	%o0, %g1
+	mov	%o1, %g2
+	mov	%o2, %g3
+
+	add	%g7, 0x48, %o0
+	ldxa	[%o0] ASI_PHYS_CACHED, %o0	! Data fault address
+	add	%g7, 0x50, %o1
+	ldxa	

CVS commit: src/sys/arch/sparc64/sparc64

2016-05-16 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon May 16 20:03:07 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: genassym.cf locore.s mp_subr.S

Log Message:
Avoid assembler-specific defines by using the export keyword in genassym.cf 
instead


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/sparc64/sparc64/genassym.cf
cvs rdiff -u -r1.394 -r1.395 src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc64/sparc64/mp_subr.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/genassym.cf
diff -u src/sys/arch/sparc64/sparc64/genassym.cf:1.77 src/sys/arch/sparc64/sparc64/genassym.cf:1.78
--- src/sys/arch/sparc64/sparc64/genassym.cf:1.77	Tue May 10 19:24:00 2016
+++ src/sys/arch/sparc64/sparc64/genassym.cf	Mon May 16 20:03:07 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.77 2016/05/10 19:24:00 palle Exp $
+#	$NetBSD: genassym.cf,v 1.78 2016/05/16 20:03:07 palle Exp $
 
 #
 # Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -136,12 +136,23 @@ define	PM_PHYS		offsetof(struct pmap, pm
 define	PM_RESIDENT	offsetof(struct pmap, pm_stats.resident_count)
 define	PM_WIRED	offsetof(struct pmap, pm_stats.wired_count)
 
-# the assembler doesn't grok C constants with LL suffix
-define	A_SUN4U_TLB_TSB_LOCK	SUN4U_TLB_TSB_LOCK
-ifdef SUN4V
-define	A_SUN4V_TLB_ACCESS	SUN4V_TLB_ACCESS
-define	A_SUN4V_TLB_TSB_LOCK	SUN4V_TLB_TSB_LOCK
-endif
+# TLB/TTE defines
+export SUN4U_TLB_TSB_LOCK
+export SUN4U_TTE_MODIFY
+export SUN4U_TTE_ACCESS
+export SUN4U_TTE_REAL_W
+export SUN4U_TTE_W
+export SUN4U_TTE_L
+export SUN4U_TTE_CP
+export SUN4U_TTE_CV
+export SUN4U_TTE_P
+export SUN4U_TTE_EXEC
+export SUN4V_TLB_ACCESS
+export SUN4V_TLB_TSB_LOCK
+
+export PG_SHIFT4U
+
+export CTX_MASK
 
 # CPU info structure
 define	CI_SELF		offsetof(struct cpu_info, ci_self)

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.394 src/sys/arch/sparc64/sparc64/locore.s:1.395
--- src/sys/arch/sparc64/sparc64/locore.s:1.394	Sun May 15 23:54:58 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Mon May 16 20:03:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.394 2016/05/15 23:54:58 nakayama Exp $	*/
+/*	$NetBSD: locore.s,v 1.395 2016/05/16 20:03:07 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -83,7 +83,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -2785,15 +2784,15 @@ sun4v_dtsb_miss:
 1:
 	LDPTRA	[%g6] ASI_PHYS_CACHED, %g4	! Fetch TTE
 	brgez,pn %g4, sun4v_datatrap		! Entry invalid?  Punt
-	 or	%g4, A_SUN4V_TLB_ACCESS, %g7	! Update the access bit
+	 or	%g4, SUN4V_TLB_ACCESS, %g7	! Update the access bit
 
-	btst	A_SUN4V_TLB_ACCESS, %g4		! Need to update access bit?
+	btst	SUN4V_TLB_ACCESS, %g4		! Need to update access bit?
 	bne,pt	%xcc, 2f
 	 nop
 	casxa	[%g6] ASI_PHYS_CACHED, %g4, %g7	!  and write it out
 	cmp	%g4, %g7
 	bne,pn	%xcc, 1b
-	 or	%g4, A_SUN4V_TLB_ACCESS, %g4	! Update the access bit
+	 or	%g4, SUN4V_TLB_ACCESS, %g4	! Update the access bit
 2:
 	GET_TSB_DMMU %g2
 
@@ -6441,13 +6440,13 @@ ENTRY(pseg_set_real)
 	cmp	%g5, CPU_SUN4V
 	bne,pt	%icc, 0f
 	 nop
-	sethi	%hh(A_SUN4V_TLB_TSB_LOCK), %g5
+	sethi	%hh(SUN4V_TLB_TSB_LOCK), %g5
 	sllx	%g5, 32, %g5
 	ba	1f
 	 nop
 0:		
 #endif		
-	set	A_SUN4U_TLB_TSB_LOCK, %g5
+	set	SUN4U_TLB_TSB_LOCK, %g5
 1:		
 	xor	%o2, %o5, %o3			! %o3 - what changed
 

Index: src/sys/arch/sparc64/sparc64/mp_subr.S
diff -u src/sys/arch/sparc64/sparc64/mp_subr.S:1.9 src/sys/arch/sparc64/sparc64/mp_subr.S:1.10
--- src/sys/arch/sparc64/sparc64/mp_subr.S:1.9	Mon Jun 15 07:48:08 2015
+++ src/sys/arch/sparc64/sparc64/mp_subr.S	Mon May 16 20:03:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mp_subr.S,v 1.9 2015/06/15 07:48:08 martin Exp $	*/
+/*	$NetBSD: mp_subr.S,v 1.10 2016/05/16 20:03:07 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -72,7 +72,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/arch/sparc64/sparc64

2016-05-15 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Sun May 15 23:54:58 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
%g1 is not preserved across function call, so load it before
return_from_trap.


To generate a diff of this commit:
cvs rdiff -u -r1.393 -r1.394 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.393 src/sys/arch/sparc64/sparc64/locore.s:1.394
--- src/sys/arch/sparc64/sparc64/locore.s:1.393	Fri May 13 21:48:15 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Sun May 15 23:54:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.393 2016/05/13 21:48:15 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.394 2016/05/15 23:54:58 nakayama Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -7078,8 +7078,8 @@ ENTRY(sparc64_ipi_ccall)
 	call %o5	! call function
 	 nop
 
-	ba,a	return_from_trap			! and return from IPI
-	 nop
+	b	return_from_trap			! and return from IPI
+	 ldx	[%sp + CC64FSZ + STKB + TF_TSTATE], %g1	! Load this for return_from_trap
 
 #endif
 



CVS commit: src/sys/arch/sparc64/sparc64

2016-05-13 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri May 13 21:48:15 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: add missing implementation of sun4v_datatrap_tl0 so data_access_fault() 
is called - mostly from OpenBSD


To generate a diff of this commit:
cvs rdiff -u -r1.392 -r1.393 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.392 src/sys/arch/sparc64/sparc64/locore.s:1.393
--- src/sys/arch/sparc64/sparc64/locore.s:1.392	Fri May 13 21:21:25 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri May 13 21:48:15 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.392 2016/05/13 21:21:25 nakayama Exp $	*/
+/*	$NetBSD: locore.s,v 1.393 2016/05/13 21:48:15 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -2829,9 +2829,66 @@ sun4v_datatrap:			! branch further based
 	 nop
 	ba	sun4v_datatrap_tl1
 	 nop
+
 sun4v_datatrap_tl0:
-	/* XXX missing implementaion */
-	sir
+	GET_MMFSA %g3! MMU Fault status area
+	add	%g3, 0x48, %g1
+	LDPTRA	[%g1] ASI_PHYS_CACHED, %g1	! Data fault address
+	add	%g3, 0x50, %g2
+	LDPTRA	[%g2] ASI_PHYS_CACHED, %g2	! Data fault context
+
+	TRAP_SETUP(-CC64FSZ-TF_SIZE)
+	or	%g1, %g2, %o3
+	mov	%g1, %o4
+
+	rdpr	%tt, %g4
+	rdpr	%tstate, %g1
+	rdpr	%tpc, %g2
+	rdpr	%tnpc, %g3
+
+	stx	%g1, [%sp + CC64FSZ + BIAS + TF_TSTATE]
+	mov	%g4, %o1		! (type)
+	stx	%g2, [%sp + CC64FSZ + BIAS + TF_PC]
+	rd	%y, %g5
+	stx	%g3, [%sp + CC64FSZ + BIAS + TF_NPC]
+	st	%g5, [%sp + CC64FSZ + BIAS + TF_Y]
+	mov	%g2, %o2		! (pc)
+	sth	%o1, [%sp + CC64FSZ + BIAS + TF_TT]! debug
+
+	cmp	%o1, T_FDMMU_PROT
+	bne,pn	%icc, 1f
+	 mov	SFSR_FV, %o5
+	or	%o5, SFSR_W, %o5
+
+1:
+	NORMAL_GLOBALS_SUN4V
+
+	stx	%g1, [%sp + CC64FSZ + BIAS + TF_G + (1*8)]
+	stx	%g2, [%sp + CC64FSZ + BIAS + TF_G + (2*8)]
+	add	%sp, CC64FSZ + BIAS, %o0		! ()
+	stx	%g3, [%sp + CC64FSZ + BIAS + TF_G + (3*8)]
+	stx	%g4, [%sp + CC64FSZ + BIAS + TF_G + (4*8)]
+	stx	%g5, [%sp + CC64FSZ + BIAS + TF_G + (5*8)]
+	rdpr	%pil, %g5
+	stx	%g6, [%sp + CC64FSZ + BIAS + TF_G + (6*8)]
+	stx	%g7, [%sp + CC64FSZ + BIAS + TF_G + (7*8)]
+	stb	%g5, [%sp + CC64FSZ + BIAS + TF_PIL]
+	stb	%g5, [%sp + CC64FSZ + BIAS + TF_OLDPIL]
+
+	/*
+	 * Phew, ready to enable traps and call C code.
+	 */
+	wrpr	%g0, 0, %tl
+
+	wr	%g0, ASI_PRIMARY_NOFAULT, %asi	! Restore default ASI
+	wrpr	%g0, PSTATE_INTR, %pstate	! traps on again
+	call	_C_LABEL(data_access_fault)	! data_acces_fault(tf, type, ...)
+	 nop
+
+	ba,a,pt	%icc, return_from_trap
+	 nop
+	NOTREACHED
+	
 sun4v_datatrap_tl1:
 	/* XXX missing implementaion */
 	sir



CVS commit: src/sys/arch/sparc64/sparc64

2016-05-13 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri May 13 21:24:11 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: intr.c

Log Message:
Interrupt handlers are now allocated by kmem_zalloc(9), so free
them by kmem_free(9).


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/sparc64/sparc64/intr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/intr.c
diff -u src/sys/arch/sparc64/sparc64/intr.c:1.68 src/sys/arch/sparc64/sparc64/intr.c:1.69
--- src/sys/arch/sparc64/sparc64/intr.c:1.68	Tue May 10 19:24:00 2016
+++ src/sys/arch/sparc64/sparc64/intr.c	Fri May 13 21:24:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.68 2016/05/10 19:24:00 palle Exp $ */
+/*	$NetBSD: intr.c,v 1.69 2016/05/13 21:24:11 nakayama Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.68 2016/05/10 19:24:00 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.69 2016/05/13 21:24:11 nakayama Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -50,7 +50,6 @@ __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.6
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
@@ -309,7 +308,7 @@ void
 sparc_softintr_disestablish(void *cookie)
 {
 
-	free(cookie, M_DEVBUF);
+	kmem_free(cookie, sizeof(struct intrhand));
 }
 
 void



CVS commit: src/sys/arch/sparc64/sparc64

2016-05-13 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri May 13 21:23:30 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: clock.c

Log Message:
Allocate interrupt handlers for clockintr and statintr dynamically.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/arch/sparc64/sparc64/clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/clock.c
diff -u src/sys/arch/sparc64/sparc64/clock.c:1.118 src/sys/arch/sparc64/sparc64/clock.c:1.119
--- src/sys/arch/sparc64/sparc64/clock.c:1.118	Sun Dec 13 18:41:09 2015
+++ src/sys/arch/sparc64/sparc64/clock.c	Fri May 13 21:23:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.118 2015/12/13 18:41:09 christos Exp $ */
+/*	$NetBSD: clock.c,v 1.119 2016/05/13 21:23:30 nakayama Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.118 2015/12/13 18:41:09 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.119 2016/05/13 21:23:30 nakayama Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -72,7 +72,6 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #ifdef GPROF
@@ -129,11 +128,6 @@ int statmin;			/* statclock interval - 1
 int timerok;
 #ifndef MULTIPROCESSOR
 static int statscheddiv;
-#endif
-
-static struct intrhand level10 = { .ih_fun = clockintr, .ih_pil = PIL_CLOCK };
-#ifndef MULTIPROCESSOR
-static struct intrhand level14 = { .ih_fun = statintr, .ih_pil = PIL_STATCLOCK };
 static struct intrhand *schedint;
 #endif
 
@@ -293,18 +287,24 @@ timerattach(device_t parent, device_t se
 	 (CPU_UPAID << INTMAP_TID_SHIFT));
 
 	/* Install the appropriate interrupt vector here */
-	level10.ih_number = INTVEC(ma->ma_interrupts[0]);
-	level10.ih_clr = _4u.t_clrintr[0];
-	intr_establish(PIL_CLOCK, true, );
-	printf(" irq vectors %lx", (u_long)level10.ih_number);
+	struct intrhand *level10 = intrhand_alloc();
+	level10->ih_fun = clockintr;
+	level10->ih_pil = PIL_CLOCK;
+	level10->ih_number = INTVEC(ma->ma_interrupts[0]);
+	level10->ih_clr = _4u.t_clrintr[0];
+	intr_establish(PIL_CLOCK, true, level10);
+	printf(" irq vectors %lx", (u_long)level10->ih_number);
 #ifndef MULTIPROCESSOR
 	/*
 	 * On SMP kernel, don't establish interrupt to use it as timecounter.
 	 */
-	level14.ih_number = INTVEC(ma->ma_interrupts[1]);
-	level14.ih_clr = _4u.t_clrintr[1];
-	intr_establish(PIL_STATCLOCK, true, );
-	printf(" and %lx", (u_long)level14.ih_number);
+	struct intrhand *level14 = intrhand_alloc();
+	level14->ih_fun = statintr;
+	level14->ih_pil = PIL_STATCLOCK;
+	level14->ih_number = INTVEC(ma->ma_interrupts[1]);
+	level14->ih_clr = _4u.t_clrintr[1];
+	intr_establish(PIL_STATCLOCK, true, level14);
+	printf(" and %lx", (u_long)level14->ih_number);
 #endif
 
 #if 0



CVS commit: src/sys/arch/sparc64/sparc64

2016-05-13 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri May 13 21:21:43 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: trap.c

Log Message:
Fixed typo in comment + reorder parameters for trap debug output to match 
function prototype for data_access_fault()


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/arch/sparc64/sparc64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.182 src/sys/arch/sparc64/sparc64/trap.c:1.183
--- src/sys/arch/sparc64/sparc64/trap.c:1.182	Sun May  1 19:57:55 2016
+++ src/sys/arch/sparc64/sparc64/trap.c	Fri May 13 21:21:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.182 2016/05/01 19:57:55 palle Exp $ */
+/*	$NetBSD: trap.c,v 1.183 2016/05/13 21:21:43 palle Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.182 2016/05/01 19:57:55 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.183 2016/05/13 21:21:43 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -438,7 +438,7 @@ print_trapframe(struct trapframe64 *tf)
 
 /*
  * Called from locore.s trap handling, for non-MMU-related traps.
- * (MMU-related traps go through mem_access_fault, below.)
+ * (MMU-related traps go through data_access_fault, below.)
  */
 void
 trap(struct trapframe64 *tf, unsigned int type, vaddr_t pc, long tstate)
@@ -1053,7 +1053,7 @@ data_access_fault(struct trapframe64 *tf
 		printf("%ld: data_access_fault(%p, %x, %p, %p, %lx, %lx) "
 			"nsaved=%d\n",
 			(long)(curproc?curproc->p_pid:-1), tf, type,
-			(void *)addr, (void *)pc,
+			(void *)pc, (void *)addr, 
 			sfva, sfsr, (int)curpcb->pcb_nsaved);
 #ifdef DDB
 		if ((trapdebug & TDB_NSAVED && curpcb->pcb_nsaved))



CVS commit: src/sys/arch/sparc64/sparc64

2016-05-13 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri May 13 21:21:25 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
- ci_paddr is always 64-bit.
- intrlev is array of pointer.
- ih_ack is pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.391 -r1.392 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.391 src/sys/arch/sparc64/sparc64/locore.s:1.392
--- src/sys/arch/sparc64/sparc64/locore.s:1.391	Tue May 10 19:24:00 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri May 13 21:21:25 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.391 2016/05/10 19:24:00 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.392 2016/05/13 21:21:25 nakayama Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -3598,7 +3598,7 @@ sun4v_cpu_mondo:
 	mov	0x3c0, %g1			 ! CPU Mondo Queue Head
 	ldxa	[%g1] ASI_QUEUE, %g2		 ! fetch index value for head
 	set	CPUINFO_VA, %g3
-	LDPTR	[%g3 + CI_PADDR], %g3
+	ldx	[%g3 + CI_PADDR], %g3
 	add	%g3, CI_CPUMQ, %g3	
 	ldxa	[%g3] ASI_PHYS_CACHED, %g3	 ! fetch head element
 	ldxa	[%g3 + %g2] ASI_PHYS_CACHED, %g4 ! fetch func 
@@ -3630,7 +3630,7 @@ sun4v_dev_mondo:
 	retry	! unlikely, ingnore interrupt
 2:	
 	set	CPUINFO_VA, %g3			 ! fetch cpuinfo pa
-	LDPTR	[%g3 + CI_PADDR], %g3		 ! fetch intstack pa
+	ldx	[%g3 + CI_PADDR], %g3		 ! fetch intstack pa
 	set	CPUINFO_VA-INTSTACK, %g4	 ! offset to cpuinfo
 	add	%g4, %g3, %g3			 ! %g3 is now cpuifo
 	add	%g3, CI_DEVMQ, %g3		 ! calc offset to devmq
@@ -3647,9 +3647,9 @@ sun4v_dev_mondo:
 	 nop	! no just continue
 
 	sethi	%hi(_C_LABEL(intrlev)), %g3
+	sllx	%g5, PTRSHFT, %g5	! Calculate entry number
 	or	%g3, %lo(_C_LABEL(intrlev)), %g3
-	sllx	%g5, 3, %g5		! Calculate entry number
-	ldx	[%g3 + %g5], %g5	! We have a pointer to the handler
+	LDPTR	[%g3 + %g5], %g5	! We have a pointer to the handler
 1:
 	brnz,pt	%g5, setup_sparcintr	! branch if valid handle
 	 nop
@@ -3951,7 +3951,7 @@ sparc_intr_retry:
 	stx	%g0, [%l1]		! Clear intr source
 	membar	#Sync			! Should not be needed
 0:
-	ldx	[%l2 + IH_ACK], %l1	! ih->ih_ack
+	LDPTR	[%l2 + IH_ACK], %l1	! ih->ih_ack
 	brz,pn	%l1, 1f
 	 nop
 	jmpl	%l1, %o7		! (*ih->ih_ack)(ih)



CVS commit: src/sys/arch/sparc64/sparc64

2016-05-01 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun May  1 20:12:55 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: db_interface.c

Log Message:
fill_ddb_regs_from_tf() now fetches Local and In registers as well.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/arch/sparc64/sparc64/db_interface.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/db_interface.c
diff -u src/sys/arch/sparc64/sparc64/db_interface.c:1.132 src/sys/arch/sparc64/sparc64/db_interface.c:1.133
--- src/sys/arch/sparc64/sparc64/db_interface.c:1.132	Thu Sep 12 19:38:59 2013
+++ src/sys/arch/sparc64/sparc64/db_interface.c	Sun May  1 20:12:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.132 2013/09/12 19:38:59 martin Exp $ */
+/*	$NetBSD: db_interface.c,v 1.133 2016/05/01 20:12:54 palle Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.132 2013/09/12 19:38:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.133 2016/05/01 20:12:54 palle Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -232,7 +232,7 @@ fill_ddb_regs_from_tf(struct trapframe64
 	}
 	/* We should do a proper copyin and xlate 64-bit stack frames, but... */
 /*	if (tf->tf_tstate & TSTATE_PRIV) { .. } */
-	
+
 #if 0
 	/* make sure this is not causing ddb problems. */
 	if (tf->tf_out[6] & 1) {
@@ -257,6 +257,13 @@ fill_ddb_regs_from_tf(struct trapframe64
 		DDB_REGS->db_fr.fr_fp = (long)tfr.fr_fp;
 		DDB_REGS->db_fr.fr_pc = tfr.fr_pc;
 	}
+#else
+	int i;
+	for (i=0; i<8; i++)
+	  DDB_REGS->db_fr.fr_local[i] = tf->tf_local[i];
+	for (i=0; i<6; i++)
+	  DDB_REGS->db_fr.fr_arg[i] = tf->tf_in[i];
+	/* XXX tp and pc are missing */
 #endif
 	DDB_REGS->db_tl = savetstate(_REGS->db_ts[0]);
 }



CVS commit: src/sys/arch/sparc64/sparc64

2016-05-01 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun May  1 19:57:55 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: trap.c

Log Message:
print_trapframe() should print out Local and In registers as well


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/sys/arch/sparc64/sparc64/trap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.181 src/sys/arch/sparc64/sparc64/trap.c:1.182
--- src/sys/arch/sparc64/sparc64/trap.c:1.181	Sat Feb 28 21:44:33 2015
+++ src/sys/arch/sparc64/sparc64/trap.c	Sun May  1 19:57:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.181 2015/02/28 21:44:33 martin Exp $ */
+/*	$NetBSD: trap.c,v 1.182 2016/05/01 19:57:55 palle Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.181 2015/02/28 21:44:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.182 2016/05/01 19:57:55 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -388,14 +388,14 @@ print_trapframe(struct trapframe64 *tf)
 	   tf, (u_long)tf->tf_tstate, (u_long)tf->tf_pc, (u_long)tf->tf_npc);
 	printf("fault: %p\ty: %x\t", 
 	   (void *)(u_long)tf->tf_fault, (int)tf->tf_y);
-	printf("pil: %d\toldpil: %d\ttt: %x\tGlobals:\n", 
+	printf("pil: %d\toldpil: %d\ttt: %x\nGlobals:\n", 
 	   (int)tf->tf_pil, (int)tf->tf_oldpil, (int)tf->tf_tt);
 	printf("%08x%08x %08x%08x %08x%08x %08x%08x\n",
 	   (u_int)(tf->tf_global[0]>>32), (u_int)tf->tf_global[0],
 	   (u_int)(tf->tf_global[1]>>32), (u_int)tf->tf_global[1],
 	   (u_int)(tf->tf_global[2]>>32), (u_int)tf->tf_global[2],
 	   (u_int)(tf->tf_global[3]>>32), (u_int)tf->tf_global[3]);
-	printf("%08x%08x %08x%08x %08x%08x %08x%08x\nouts:\n",
+	printf("%08x%08x %08x%08x %08x%08x %08x%08x\nOuts:\n",
 	   (u_int)(tf->tf_global[4]>>32), (u_int)tf->tf_global[4],
 	   (u_int)(tf->tf_global[5]>>32), (u_int)tf->tf_global[5],
 	   (u_int)(tf->tf_global[6]>>32), (u_int)tf->tf_global[6],
@@ -406,11 +406,31 @@ print_trapframe(struct trapframe64 *tf)
 	   (u_int)(tf->tf_out[1]>>32), (u_int)tf->tf_out[1],
 	   (u_int)(tf->tf_out[2]>>32), (u_int)tf->tf_out[2],
 	   (u_int)(tf->tf_out[3]>>32), (u_int)tf->tf_out[3]);
-	printf("%08x%08x %08x%08x %08x%08x %08x%08x\n",
+	printf("%08x%08x %08x%08x %08x%08x %08x%08x\nLocals:\n",
 	   (u_int)(tf->tf_out[4]>>32), (u_int)tf->tf_out[4],
 	   (u_int)(tf->tf_out[5]>>32), (u_int)tf->tf_out[5],
 	   (u_int)(tf->tf_out[6]>>32), (u_int)tf->tf_out[6],
 	   (u_int)(tf->tf_out[7]>>32), (u_int)tf->tf_out[7]);
+	printf("%08x%08x %08x%08x %08x%08x %08x%08x\n",
+	   (u_int)(tf->tf_local[0]>>32), (u_int)tf->tf_local[0],
+	   (u_int)(tf->tf_local[1]>>32), (u_int)tf->tf_local[1],
+	   (u_int)(tf->tf_local[2]>>32), (u_int)tf->tf_local[2],
+	   (u_int)(tf->tf_local[3]>>32), (u_int)tf->tf_local[3]);
+	printf("%08x%08x %08x%08x %08x%08x %08x%08x\nIns:\n",
+	   (u_int)(tf->tf_local[4]>>32), (u_int)tf->tf_local[4],
+	   (u_int)(tf->tf_local[5]>>32), (u_int)tf->tf_local[5],
+	   (u_int)(tf->tf_local[6]>>32), (u_int)tf->tf_local[6],
+	   (u_int)(tf->tf_local[7]>>32), (u_int)tf->tf_local[7]);
+	printf("%08x%08x %08x%08x %08x%08x %08x%08x\n",
+	   (u_int)(tf->tf_in[0]>>32), (u_int)tf->tf_in[0],
+	   (u_int)(tf->tf_in[1]>>32), (u_int)tf->tf_in[1],
+	   (u_int)(tf->tf_in[2]>>32), (u_int)tf->tf_in[2],
+	   (u_int)(tf->tf_in[3]>>32), (u_int)tf->tf_in[3]);
+	printf("%08x%08x %08x%08x %08x%08x %08x%08x\n",
+	   (u_int)(tf->tf_in[4]>>32), (u_int)tf->tf_in[4],
+	   (u_int)(tf->tf_in[5]>>32), (u_int)tf->tf_in[5],
+	   (u_int)(tf->tf_in[6]>>32), (u_int)tf->tf_in[6],
+	   (u_int)(tf->tf_in[7]>>32), (u_int)tf->tf_in[7]);
 #endif
 
 }



CVS commit: src/sys/arch/sparc64/sparc64

2016-04-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr 17 14:32:03 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: cpu.c pmap.c

Log Message:
Move the SMP-disabled hack for SUN4V a bit earlier


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/arch/sparc64/sparc64/cpu.c
cvs rdiff -u -r1.301 -r1.302 src/sys/arch/sparc64/sparc64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/cpu.c
diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.127 src/sys/arch/sparc64/sparc64/cpu.c:1.128
--- src/sys/arch/sparc64/sparc64/cpu.c:1.127	Sun Sep  6 23:48:39 2015
+++ src/sys/arch/sparc64/sparc64/cpu.c	Sun Apr 17 14:32:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.127 2015/09/06 23:48:39 nakayama Exp $ */
+/*	$NetBSD: cpu.c,v 1.128 2016/04/17 14:32:03 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.127 2015/09/06 23:48:39 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.128 2016/04/17 14:32:03 martin Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -670,10 +670,6 @@ cpu_boot_secondary_processors(void)
 		return;
 	}
 
-	/* No MP for SUN4V yet */
-	if (CPU_ISSUN4V)
-		return;
-	
 	for (ci = cpus; ci != NULL; ci = ci->ci_next) {
 		if (ci->ci_cpuid == cpu_myid())
 			continue;

Index: src/sys/arch/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.301 src/sys/arch/sparc64/sparc64/pmap.c:1.302
--- src/sys/arch/sparc64/sparc64/pmap.c:1.301	Wed Feb  3 20:33:52 2016
+++ src/sys/arch/sparc64/sparc64/pmap.c	Sun Apr 17 14:32:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.301 2016/02/03 20:33:52 palle Exp $	*/
+/*	$NetBSD: pmap.c,v 1.302 2016/04/17 14:32:03 martin Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.301 2016/02/03 20:33:52 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.302 2016/04/17 14:32:03 martin Exp $");
 
 #undef	NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define	HWREF
@@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.3
 #include 
 
 #include 	/* for MID_* */
+#include 
 
 #include 
 
@@ -728,6 +729,10 @@ pmap_bootstrap(u_long kernelstart, u_lon
 
 	BDPRINTF(PDB_BOOT, ("Entered pmap_bootstrap.\n"));
 
+	/* XXX - incomplete spinup code for SUN4V */
+	if (CPU_ISSUN4V)
+		boothowto |= RB_MD1;
+
 	cache_setup_funcs();
 
 	/*



CVS commit: src/sys/arch/sparc64/sparc64

2016-03-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Mar 11 18:31:03 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: compat_16_machdep.c

Log Message:
PR/50945: David Binderman: sprinkle parens


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sparc64/sparc64/compat_16_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/compat_16_machdep.c
diff -u src/sys/arch/sparc64/sparc64/compat_16_machdep.c:1.15 src/sys/arch/sparc64/sparc64/compat_16_machdep.c:1.16
--- src/sys/arch/sparc64/sparc64/compat_16_machdep.c:1.15	Fri Nov 20 23:16:52 2009
+++ src/sys/arch/sparc64/sparc64/compat_16_machdep.c	Fri Mar 11 13:31:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_16_machdep.c,v 1.15 2009/11/21 04:16:52 rmind Exp $ */
+/*	$NetBSD: compat_16_machdep.c,v 1.16 2016/03/11 18:31:03 christos Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.15 2009/11/21 04:16:52 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.16 2016/03/11 18:31:03 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -288,7 +288,8 @@ compat_16_sys___sigreturn14(struct lwp *
 	}
 #endif
 	scp = SCARG(uap, sigcntxp);
- 	if ((vaddr_t)scp & 3 || (error = copyin((void *)scp, , sizeof sc) != 0))
+ 	if (((vaddr_t)scp & 3) != 0 ||
+	(error = copyin((void *)scp, , sizeof sc)) != 0)
 #ifdef DEBUG
 	{
 		printf("sigreturn14: copyin failed: scp=%p\n", scp);



CVS commit: src/sys/arch/sparc64/sparc64

2016-03-09 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Wed Mar  9 12:20:21 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
32-bit kernels use 32-bit stack.


To generate a diff of this commit:
cvs rdiff -u -r1.389 -r1.390 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.389 src/sys/arch/sparc64/sparc64/locore.s:1.390
--- src/sys/arch/sparc64/sparc64/locore.s:1.389	Thu Mar  3 20:45:45 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Wed Mar  9 12:20:20 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.389 2016/03/03 20:45:45 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.390 2016/03/09 12:20:20 nakayama Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -4123,7 +4123,11 @@ rft_kernel:
 	rdpr	%cwp, %g1
 	dec	%g1
 	wrpr	%g1, %cwp
+#ifdef _LP64
 	FILL	ldxa, %sp+BIAS, 8, %asi
+#else
+	FILL	lda, %sp, 4, %asi
+#endif
 	restored
 	inc	%g1
 	wrpr	%g1, %cwp



CVS commit: src/sys/arch/sparc64/sparc64

2016-03-03 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Mar  3 20:45:45 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: rft_kernel should pay attention to the number of register windows that 
can be restored. We cannot rely on fill traps to occur, since sun4v only has 
two trap levels available in privileged mode. Based on code from OpenBSD. ok 
martin@


To generate a diff of this commit:
cvs rdiff -u -r1.388 -r1.389 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.388 src/sys/arch/sparc64/sparc64/locore.s:1.389
--- src/sys/arch/sparc64/sparc64/locore.s:1.388	Sun Feb 14 21:13:33 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Thu Mar  3 20:45:45 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.388 2016/02/14 21:13:33 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.389 2016/03/03 20:45:45 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -355,6 +355,35 @@ cputyp:	.word	CPU_SUN4U ! Default to sun
 #define CLRTT
 #endif
 
+
+/*
+ * Some macros to load and store a register window
+ */
+
+	.macro	SPILL storer,base,size,asi
+
+	.irpc n,01234567
+		\storer %l\n, [\base + (\n * \size)] \asi
+	.endr
+	.irpc n,01234567
+		\storer %i\n, [\base + ((8+\n) * \size)] \asi
+	.endr
+
+	.endm
+
+	
+	.macro FILL loader, base, size, asi
+	
+	.irpc n,01234567
+		\loader [\base + (\n * \size)] \asi, %l\n
+	.endr
+
+	.irpc n,01234567
+		\loader [\base + ((8+\n) * \size)] \asi, %i\n
+	.endr
+	
+	.endm
+	
 /*
  * Here are some oft repeated traps as macros.
  */
@@ -4079,12 +4108,26 @@ return_from_trap:
  *
  */
 rft_kernel:
-	rdpr	%tl, %g4! Grab a set of trap registers
+	rdpr	%tl, %g4			! Grab a set of trap registers
 	inc	%g4
 	wrpr	%g4, %g0, %tl
 	wrpr	%g3, 0, %tnpc
 	wrpr	%g2, 0, %tpc
 	wrpr	%g1, 0, %tstate
+
+	rdpr	%canrestore, %g2
+	brnz	%g2, 1f
+	 nop
+
+	wr	%g0, ASI_NUCLEUS, %asi
+	rdpr	%cwp, %g1
+	dec	%g1
+	wrpr	%g1, %cwp
+	FILL	ldxa, %sp+BIAS, 8, %asi
+	restored
+	inc	%g1
+	wrpr	%g1, %cwp
+1:
 	restore
 	rdpr	%tstate, %g1			! Since we may have trapped our regs may be toast
 	rdpr	%cwp, %g2



CVS commit: src/sys/arch/sparc64/sparc64

2016-02-14 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Feb 14 21:13:34 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: add breakpoint trap entry to the sun4v trap table


To generate a diff of this commit:
cvs rdiff -u -r1.387 -r1.388 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.387 src/sys/arch/sparc64/sparc64/locore.s:1.388
--- src/sys/arch/sparc64/sparc64/locore.s:1.387	Wed Feb  3 20:33:52 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Sun Feb 14 21:13:33 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.387 2016/02/03 20:33:52 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.388 2016/02/14 21:13:33 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1075,7 +1075,9 @@ _C_LABEL(trapbase_sun4v):
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0f4 fill_5_other
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0f8 fill_6_other
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0fc fill_7_other
-	sun4v_trap_entry 256	! 0x100-0x1ff
+	sun4v_trap_entry 1	! 0x100
+	BPT			! 0x101 = pseudo breakpoint instruction
+	sun4v_trap_entry 254	! 0x102-0x1ff
 	!
 	! trap level 1
 	!



CVS commit: src/sys/arch/sparc64/sparc64

2016-01-30 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Jan 30 22:47:06 UTC 2016

Modified Files:
src/sys/arch/sparc64/sparc64: ipifuncs.c

Log Message:
Fixed typo in sparc64_send_ipi_sun4u(): sun4v -> sun4u


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/sparc64/sparc64/ipifuncs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/ipifuncs.c
diff -u src/sys/arch/sparc64/sparc64/ipifuncs.c:1.55 src/sys/arch/sparc64/sparc64/ipifuncs.c:1.56
--- src/sys/arch/sparc64/sparc64/ipifuncs.c:1.55	Sun Jan  4 15:24:18 2015
+++ src/sys/arch/sparc64/sparc64/ipifuncs.c	Sat Jan 30 22:47:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipifuncs.c,v 1.55 2015/01/04 15:24:18 palle Exp $ */
+/*	$NetBSD: ipifuncs.c,v 1.56 2016/01/30 22:47:06 palle Exp $ */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.55 2015/01/04 15:24:18 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipifuncs.c,v 1.56 2016/01/30 22:47:06 palle Exp $");
 
 #include "opt_ddb.h"
 
@@ -237,7 +237,7 @@ sparc64_broadcast_ipi(ipifunc_t func, ui
 }
 
 /*
- * Send an interprocessor interrupt - sun4v.
+ * Send an interprocessor interrupt - sun4u.
  */
 void
 sparc64_send_ipi_sun4u(int upaid, ipifunc_t func, uint64_t arg1, uint64_t arg2)



CVS commit: src/sys/arch/sparc64/sparc64

2015-12-30 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 30 09:16:17 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_machdep.c

Log Message:
Restrict the check for fully specified interrupts to machines with psycho
controllers only, and adjust comments to note this.

See also the mail thread starting at:
  http://mail-index.NetBSD.org/port-sparc64/2015/12/03/msg002488.html


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/sparc64/sparc64/ofw_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/ofw_machdep.c
diff -u src/sys/arch/sparc64/sparc64/ofw_machdep.c:1.44 src/sys/arch/sparc64/sparc64/ofw_machdep.c:1.45
--- src/sys/arch/sparc64/sparc64/ofw_machdep.c:1.44	Mon Mar  2 14:17:06 2015
+++ src/sys/arch/sparc64/sparc64/ofw_machdep.c	Wed Dec 30 09:16:17 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_machdep.c,v 1.44 2015/03/02 14:17:06 nakayama Exp $	*/
+/*	$NetBSD: ofw_machdep.c,v 1.45 2015/12/30 09:16:17 jdc Exp $	*/
 
 /*
  * Copyright (C) 1996 Wolfgang Solfrank.
@@ -34,7 +34,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_machdep.c,v 1.44 2015/03/02 14:17:06 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_machdep.c,v 1.45 2015/12/30 09:16:17 jdc Exp $");
 
 #include 
 #include 
@@ -738,22 +738,22 @@ OF_mapintr(int node, int *interrupt, int
 	int phc_node;
 	int rc = -1;
 
+	phc_node = find_pci_host_node(node);
+
 	/* 
-	 * Don't try to map interrupts for onboard devices, or if the
-	 * interrupt is already fully specified.
-	 * XXX This should be done differently (i.e. by matching
-	 * the node name) - but we need access to a machine where
-	 * a change is testable - hence the printf below.
+	 * On machines with psycho PCI controllers, we don't need to map
+	 * interrupts if they are already fully specified (0x20 to 0x3f
+	 * for onboard devices and IGN 0x7c0 for psycho0/psycho1).
 	 */
 	if (*interrupt & 0x20 || *interrupt & 0x7c0) {
-		char name[40];
-
-		OF_getprop(node, "name", , sizeof(name));
-		printf("\nATTENTION: if you see this message, please mail "
-		"the output of \"dmesg\" and \"ofctl -p\" to "
-		"port-spar...@netbsd.org!\n"
-		"Not mapping interrupt for node %s (%x)\n", name, node);
-		return validlen;
+		char model[40];
+		
+		if (OF_getprop(phc_node, "model", , sizeof(model)) > 10
+		&& !strcmp(model, "SUNW,psycho")) {
+			DPRINTF(("OF_mapintr: interrupt %x already mapped\n",
+			*interrupt));
+			return validlen;
+		}
 	}
 
 	/*
@@ -775,8 +775,6 @@ OF_mapintr(int node, int *interrupt, int
 		return (-1);
 	}
 
-	phc_node = find_pci_host_node(node);
-
 	while (node) {
 #ifdef DEBUG
 		char name[40];



CVS commit: src/sys/arch/sparc64/sparc64

2015-12-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 16 08:01:19 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
Add V210/V240 environmental sensors that are not in the OFW tree.
Add device properties for adm1026hm on V210, V240, and V440.


To generate a diff of this commit:
cvs rdiff -u -r1.206 -r1.207 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.206 src/sys/arch/sparc64/sparc64/autoconf.c:1.207
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.206	Sun Dec 13 11:51:37 2015
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Wed Dec 16 08:01:19 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.206 2015/12/13 11:51:37 jmcneill Exp $ */
+/*	$NetBSD: autoconf.c,v 1.207 2015/12/16 08:01:19 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.206 2015/12/13 11:51:37 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.207 2015/12/16 08:01:19 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1142,6 +1142,58 @@ noether:
 			prop_object_release(cfg);
 			
 		}
+
+		/*
+		 * Add V210/V240 environmental sensors that are not in
+		 * the OFW tree.
+		 */
+		if (device_is_a(busdev, "pcfiic") &&
+		(!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+		!strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
+			prop_dictionary_t props = device_properties(busdev);
+			prop_array_t cfg = NULL;
+			prop_dictionary_t sens;
+			prop_data_t data;
+			const char name_lm[] = "i2c-lm75";
+			const char name_adm[] = "i2c-adm1026";
+
+			DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ",
+			machine_model));
+			cfg = prop_dictionary_get(props, "i2c-child-devices");
+ 			if (!cfg) {
+cfg = prop_array_create();
+prop_dictionary_set(props, "i2c-child-devices",
+cfg);
+prop_dictionary_set_bool(props,
+"i2c-indirect-config", false);
+			}
+
+			/* ADM1026 at 0x2e */
+			sens = prop_dictionary_create();
+			prop_dictionary_set_uint32(sens, "addr", 0x2e);
+			prop_dictionary_set_uint64(sens, "cookie", 0);
+			prop_dictionary_set_cstring(sens, "name",
+			"hardware-monitor");
+			data = prop_data_create_data(_adm[0],
+			sizeof(name_adm));
+			prop_dictionary_set(sens, "compatible", data);
+			prop_object_release(data);
+			prop_array_add(cfg, sens);
+			prop_object_release(sens);
+
+			/* LM75 at 0x4e */
+			sens = prop_dictionary_create();
+			prop_dictionary_set_uint32(sens, "addr", 0x4e);
+			prop_dictionary_set_uint64(sens, "cookie", 0);
+			prop_dictionary_set_cstring(sens, "name",
+			"temperature-sensor");
+			data = prop_data_create_data(_lm[0],
+			sizeof(name_lm));
+			prop_dictionary_set(sens, "compatible", data);
+			prop_object_release(data);
+			prop_array_add(cfg, sens);
+			prop_object_release(sens);
+		}
 	}
 
 	/* set properties for PCI framebuffers */
@@ -1205,6 +1257,27 @@ noether:
 instance = OF_open(name);
 #endif
 	}
+
+	/* Hardware specific device properties */
+	if ((!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+	!strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
+		device_t busparent = device_parent(busdev);
+		prop_dictionary_t props = device_properties(dev);
+
+		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+		device_is_a(dev, "adm1026hm") && props != NULL) {
+			prop_dictionary_set_uint8(props, "fan_div2", 0x55);
+			prop_dictionary_set_bool(props, "multi_read", true);
+		}
+	}
+	if (!strcmp(machine_model, "SUNW,Sun-Fire-V440")) {
+		device_t busparent = device_parent(busdev);
+		prop_dictionary_t props = device_properties(dev);
+		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+		device_is_a(dev, "adm1026hm") && props != NULL) {
+			prop_dictionary_set_bool(props, "multi_read", true);
+		}
+	}
 }
 
 /*



CVS commit: src/sys/arch/sparc64/sparc64

2015-12-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec 13 11:51:37 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c

Log Message:
pass addr_shift 1 to of_enter_i2c_devs


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/sys/arch/sparc64/sparc64/autoconf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.205 src/sys/arch/sparc64/sparc64/autoconf.c:1.206
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.205	Sun Sep  6 16:45:09 2015
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Dec 13 11:51:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.205 2015/09/06 16:45:09 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.206 2015/12/13 11:51:37 jmcneill Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.205 2015/09/06 16:45:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.206 2015/12/13 11:51:37 jmcneill Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1114,7 +1114,7 @@ noether:
 }
 
 of_enter_i2c_devs(props, busnode,
-sizeof(cell_t));
+sizeof(cell_t), 1);
 			}
 		}
 



CVS commit: src/sys/arch/sparc64/sparc64

2015-12-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 13 18:41:09 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: clock.c

Log Message:
PR/50531: David Binderman: Add missing printf args


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/sparc64/sparc64/clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/clock.c
diff -u src/sys/arch/sparc64/sparc64/clock.c:1.117 src/sys/arch/sparc64/sparc64/clock.c:1.118
--- src/sys/arch/sparc64/sparc64/clock.c:1.117	Fri Jul 25 13:54:50 2014
+++ src/sys/arch/sparc64/sparc64/clock.c	Sun Dec 13 13:41:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.117 2014/07/25 17:54:50 nakayama Exp $ */
+/*	$NetBSD: clock.c,v 1.118 2015/12/13 18:41:09 christos Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.117 2014/07/25 17:54:50 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.118 2015/12/13 18:41:09 christos Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -723,7 +723,8 @@ statintr(void *cap)
 
 #ifdef NOT_DEBUG
 	printf("statclock: count %x:%x, limit %x:%x\n", 
-	   timerreg_4u.t_timer[1].t_count, timerreg_4u.t_timer[1].t_limit);
+	timerreg_4u.t_timer[0].t_count, timerreg_4u.t_timer[1].t_count,
+	timerreg_4u.t_timer[0].t_limit, timerreg_4u.t_timer[1].t_limit);
 #endif
 #ifdef NOT_DEBUG
 	prom_printf("!");



CVS commit: src/sys/arch/sparc64/sparc64

2015-11-27 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Nov 27 13:51:24 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: pmap.c

Log Message:
Left-shift of negative values is UB.


To generate a diff of this commit:
cvs rdiff -u -r1.299 -r1.300 src/sys/arch/sparc64/sparc64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.299 src/sys/arch/sparc64/sparc64/pmap.c:1.300
--- src/sys/arch/sparc64/sparc64/pmap.c:1.299	Tue Sep  8 13:18:06 2015
+++ src/sys/arch/sparc64/sparc64/pmap.c	Fri Nov 27 13:51:24 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.299 2015/09/08 13:18:06 nakayama Exp $	*/
+/*	$NetBSD: pmap.c,v 1.300 2015/11/27 13:51:24 joerg Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.299 2015/09/08 13:18:06 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.300 2015/11/27 13:51:24 joerg Exp $");
 
 #undef	NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define	HWREF
@@ -1418,7 +1418,7 @@ pmap_growkernel(vaddr_t maxkvaddr)
 	}
 	DPRINTF(PDB_GROW, ("pmap_growkernel(%lx...%lx)\n", kbreak, maxkvaddr));
 	/* Align with the start of a page table */
-	for (kbreak &= (-1 << PDSHIFT); kbreak < maxkvaddr;
+	for (kbreak &= ((~0ULL) << PDSHIFT); kbreak < maxkvaddr;
 	 kbreak += (1 << PDSHIFT)) {
 		if (pseg_get(pm, kbreak) & TLB_V)
 			continue;



CVS commit: src/sys/arch/sparc64/sparc64

2015-11-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Nov 22 11:24:08 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: netbsd32_machdep.c

Log Message:
Use NETBSD32PTR32I() for pointer-to-32bit value conversion, requested
by mrg.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/arch/sparc64/sparc64/netbsd32_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/netbsd32_machdep.c
diff -u src/sys/arch/sparc64/sparc64/netbsd32_machdep.c:1.107 src/sys/arch/sparc64/sparc64/netbsd32_machdep.c:1.108
--- src/sys/arch/sparc64/sparc64/netbsd32_machdep.c:1.107	Sun Nov 22 09:32:34 2015
+++ src/sys/arch/sparc64/sparc64/netbsd32_machdep.c	Sun Nov 22 11:24:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.107 2015/11/22 09:32:34 martin Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.108 2015/11/22 11:24:08 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.107 2015/11/22 09:32:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.108 2015/11/22 11:24:08 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -249,7 +249,7 @@ netbsd32_sendsig_sigcontext(const ksigin
 	printf("sendsig: saving sf to %p, setting stack pointer %p to %p\n",
 		   fp, &(((struct rwindow32 *)newsp)->rw_in[6]), oldsp);
 #endif
-	sp = (register32_t)(uintptr_t)oldsp;
+	sp = NETBSD32PTR32I(oldsp);
 	error = (rwindow_save(l) || 
 	copyout(, fp, sizeof sf) || 
 	copyout(, &(((struct rwindow32 *)newsp)->rw_in[6]),
@@ -368,7 +368,7 @@ netbsd32_sendsig_siginfo(const ksiginfo_
 	netbsd32_si_to_si32(, (const siginfo_t *)>ksi_info);
 	ucsz = (int)(intptr_t)__uc_pad - (int)(intptr_t)
 	newsp = (struct rwindow32*)((intptr_t)fp - sizeof(struct frame32));
-	sp = (register32_t)(uintptr_t)oldsp;
+	sp = NETBSD32PTR32I(oldsp);
 	error = (copyout(, >sf_si, sizeof si32) ||
 	copyout(, >sf_uc, ucsz) ||
 	copyout(, >rw_in[6], sizeof(sp)));



CVS commit: src/sys/arch/sparc64/sparc64

2015-11-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov  9 20:26:15 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: syscall.c

Log Message:
Use PRIx64 and %# requested by phone@


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/sparc64/sparc64/syscall.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/syscall.c
diff -u src/sys/arch/sparc64/sparc64/syscall.c:1.45 src/sys/arch/sparc64/sparc64/syscall.c:1.46
--- src/sys/arch/sparc64/sparc64/syscall.c:1.45	Sun Nov  8 21:13:41 2015
+++ src/sys/arch/sparc64/sparc64/syscall.c	Mon Nov  9 15:26:15 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: syscall.c,v 1.45 2015/11/09 02:13:41 christos Exp $ */
+/*	$NetBSD: syscall.c,v 1.46 2015/11/09 20:26:15 christos Exp $ */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.45 2015/11/09 02:13:41 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.46 2015/11/09 20:26:15 christos Exp $");
 
 #include 
 #include 
@@ -312,15 +312,14 @@ syscall(struct trapframe64 *tf, register
 #ifdef DIAGNOSTIC
 	KASSERT(p->p_pid != 0);
 	KASSERTMSG(!(tf->tf_tstate & TSTATE_PRIV),
-	"syscall %ld, pid %d trap frame %p tstate 0x%jx is privileged %s\n",
-	code, p->p_pid, tf, (uintmax_t)tf->tf_tstate,
-	(tf->tf_tstate & TSTATE_PRIV)?"yes":"no");
+	"syscall %ld, pid %d trap frame %p tstate %#" PRIx64
+	" is privileged %s\n", code, p->p_pid, tf, tf->tf_tstate,
+	(tf->tf_tstate & TSTATE_PRIV) ? "yes" : "no");
 	if (p->p_flag & PK_32) {
 		KASSERTMSG(tf->tf_tstate & TSTATE_AM,
-		"32bit syscall %ld, pid %d trap frame %p tstate 0x%jx "
-			"has AM %s\n",
-		code, p->p_pid, tf, (uintmax_t)tf->tf_tstate,
-		(tf->tf_tstate & TSTATE_AM)?"yes":"no");
+		"32bit syscall %ld, pid %d trap frame %p tstate %#" PRIx64
+		" has AM %s\n", code, p->p_pid, tf, tf->tf_tstate,
+		(tf->tf_tstate & TSTATE_AM) ? "yes" : "no");
 	}
 #endif
 



CVS commit: src/sys/arch/sparc64/sparc64

2015-11-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov  9 02:13:41 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: syscall.c

Log Message:
fix printf formats.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/sparc64/sparc64/syscall.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/syscall.c
diff -u src/sys/arch/sparc64/sparc64/syscall.c:1.44 src/sys/arch/sparc64/sparc64/syscall.c:1.45
--- src/sys/arch/sparc64/sparc64/syscall.c:1.44	Fri Nov  6 10:25:42 2015
+++ src/sys/arch/sparc64/sparc64/syscall.c	Sun Nov  8 21:13:41 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: syscall.c,v 1.44 2015/11/06 15:25:42 martin Exp $ */
+/*	$NetBSD: syscall.c,v 1.45 2015/11/09 02:13:41 christos Exp $ */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.44 2015/11/06 15:25:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.45 2015/11/09 02:13:41 christos Exp $");
 
 #include 
 #include 
@@ -312,14 +312,14 @@ syscall(struct trapframe64 *tf, register
 #ifdef DIAGNOSTIC
 	KASSERT(p->p_pid != 0);
 	KASSERTMSG(!(tf->tf_tstate & TSTATE_PRIV),
-	"syscall %ld, pid %d trap frame %p tstate %lx is privileged %s\n",
-	code, p->p_pid, tf, tf->tf_tstate,
+	"syscall %ld, pid %d trap frame %p tstate 0x%jx is privileged %s\n",
+	code, p->p_pid, tf, (uintmax_t)tf->tf_tstate,
 	(tf->tf_tstate & TSTATE_PRIV)?"yes":"no");
 	if (p->p_flag & PK_32) {
 		KASSERTMSG(tf->tf_tstate & TSTATE_AM,
-		"32bit syscall %ld, pid %d trap frame %p tstate %lx "
+		"32bit syscall %ld, pid %d trap frame %p tstate 0x%jx "
 			"has AM %s\n",
-		code, p->p_pid, tf, tf->tf_tstate,
+		code, p->p_pid, tf, (uintmax_t)tf->tf_tstate,
 		(tf->tf_tstate & TSTATE_AM)?"yes":"no");
 	}
 #endif



CVS commit: src/sys/arch/sparc64/sparc64

2015-11-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov  7 11:47:09 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: netbsd32_machdep.c

Log Message:
Fix kmem_free() size mismatch


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/sparc64/sparc64/netbsd32_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/netbsd32_machdep.c
diff -u src/sys/arch/sparc64/sparc64/netbsd32_machdep.c:1.104 src/sys/arch/sparc64/sparc64/netbsd32_machdep.c:1.105
--- src/sys/arch/sparc64/sparc64/netbsd32_machdep.c:1.104	Sat Oct 31 02:36:17 2015
+++ src/sys/arch/sparc64/sparc64/netbsd32_machdep.c	Sat Nov  7 11:47:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.104 2015/10/31 02:36:17 nakayama Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.105 2015/11/07 11:47:09 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.104 2015/10/31 02:36:17 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.105 2015/11/07 11:47:09 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1324,7 +1324,8 @@ startlwp32(void *arg)
 	error = cpu_setmcontext32(l, >uc_mcontext, uc->uc_flags);
 	KASSERT(error == 0);
 
-	kmem_free(uc, sizeof(ucontext32_t));
+	/* Note: we are freeing ucontext_t, not ucontext32_t. */
+	kmem_free(arg, sizeof(ucontext_t));
 	userret(l, 0, 0);
 }
 



CVS commit: src/sys/arch/sparc64/sparc64

2015-11-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov  7 21:07:19 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: netbsd32_machdep.c

Log Message:
Convert siginfo to 32bit version before copying it out to 32bit userland.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/sparc64/sparc64/netbsd32_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/netbsd32_machdep.c
diff -u src/sys/arch/sparc64/sparc64/netbsd32_machdep.c:1.105 src/sys/arch/sparc64/sparc64/netbsd32_machdep.c:1.106
--- src/sys/arch/sparc64/sparc64/netbsd32_machdep.c:1.105	Sat Nov  7 11:47:09 2015
+++ src/sys/arch/sparc64/sparc64/netbsd32_machdep.c	Sat Nov  7 21:07:18 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep.c,v 1.105 2015/11/07 11:47:09 martin Exp $	*/
+/*	$NetBSD: netbsd32_machdep.c,v 1.106 2015/11/07 21:07:18 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.105 2015/11/07 11:47:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.106 2015/11/07 21:07:18 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -316,6 +316,7 @@ netbsd32_sendsig_siginfo(const ksiginfo_
 	int sig = ksi->ksi_signo;
 	ucontext32_t uc;
 	struct sparc32_sigframe_siginfo *fp;
+	siginfo32_t si32;	
 	netbsd32_intptr_t catcher;
 	struct trapframe64 *tf = l->l_md.md_tf;
 	struct rwindow32 *oldsp, *newsp;
@@ -336,15 +337,16 @@ netbsd32_sendsig_siginfo(const ksiginfo_
 	else
 		fp = (struct sparc32_sigframe_siginfo *)oldsp;
 	fp = (struct sparc32_sigframe_siginfo*)((u_long)(fp - 1) & ~7);
+
 	/*
 	 * Build the signal context to be used by sigreturn.
 	 */
+	memset(, 0, sizeof uc);
 	uc.uc_flags = _UC_SIGMASK |
 		((l->l_sigstk.ss_flags & SS_ONSTACK)
 			? _UC_SETSTACK : _UC_CLRSTACK);
 	uc.uc_sigmask = *mask;
 	uc.uc_link = (uint32_t)(uintptr_t)l->l_ctxlink;
-	memset(_stack, 0, sizeof(uc.uc_stack));
 
 	sendsig_reset(l, sig);
 
@@ -359,9 +361,10 @@ netbsd32_sendsig_siginfo(const ksiginfo_
 	 */
 	mutex_exit(p->p_lock);
 	cpu_getmcontext32(l, _mcontext, _flags);
+	netbsd32_si_to_si32(, (const siginfo_t *)>ksi_info);
 	ucsz = (int)(intptr_t)__uc_pad - (int)(intptr_t)
 	newsp = (struct rwindow32*)((intptr_t)fp - sizeof(struct frame32));
-	error = (copyout(>ksi_info, >sf_si, sizeof ksi->ksi_info) ||
+	error = (copyout(, >sf_si, sizeof si32) ||
 	copyout(, >sf_uc, ucsz) ||
 	suword(>rw_in[6], (intptr_t)oldsp));
 	mutex_enter(p->p_lock);



CVS commit: src/sys/arch/sparc64/sparc64

2015-11-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov  6 15:25:42 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: syscall.c

Log Message:
Add a few assertions to verify non-privileged processor state for userland
and 32bit address mapping for 32bit processes.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/sparc64/sparc64/syscall.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/syscall.c
diff -u src/sys/arch/sparc64/sparc64/syscall.c:1.43 src/sys/arch/sparc64/sparc64/syscall.c:1.44
--- src/sys/arch/sparc64/sparc64/syscall.c:1.43	Fri Mar  7 22:51:27 2014
+++ src/sys/arch/sparc64/sparc64/syscall.c	Fri Nov  6 15:25:42 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: syscall.c,v 1.43 2014/03/07 22:51:27 nakayama Exp $ */
+/*	$NetBSD: syscall.c,v 1.44 2015/11/06 15:25:42 martin Exp $ */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.43 2014/03/07 22:51:27 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.44 2015/11/06 15:25:42 martin Exp $");
 
 #include 
 #include 
@@ -309,6 +309,21 @@ syscall(struct trapframe64 *tf, register
 	rval[0] = 0;
 	rval[1] = tf->tf_out[1];
 
+#ifdef DIAGNOSTIC
+	KASSERT(p->p_pid != 0);
+	KASSERTMSG(!(tf->tf_tstate & TSTATE_PRIV),
+	"syscall %ld, pid %d trap frame %p tstate %lx is privileged %s\n",
+	code, p->p_pid, tf, tf->tf_tstate,
+	(tf->tf_tstate & TSTATE_PRIV)?"yes":"no");
+	if (p->p_flag & PK_32) {
+		KASSERTMSG(tf->tf_tstate & TSTATE_AM,
+		"32bit syscall %ld, pid %d trap frame %p tstate %lx "
+			"has AM %s\n",
+		code, p->p_pid, tf, tf->tf_tstate,
+		(tf->tf_tstate & TSTATE_AM)?"yes":"no");
+	}
+#endif
+
 	error = sy_invoke(callp, l, args.r, rval, code);
 
 	switch (error) {



CVS commit: src/sys/arch/sparc64/sparc64

2015-11-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov  6 15:30:59 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s vm_machdep.c

Log Message:
Basically revert r1.246 of locore.s and r1.73 of vm_machdep.c:

Remove special case handling for userland lwps from cpu_lwp_fork,
instead do it in lwp_trampoline when we first return to userland.

which was a stupid idea - since we did now set all fork child's %tstate
(and thus %pstate when back in userland) to the current kernel's userland
default. This meant we lost the address mask bit for 32bit processes and
all memory model details for 64bit ones.

Move it back to cpu_lwp_fork and fix the condition to only do it once when
forking init.


To generate a diff of this commit:
cvs rdiff -u -r1.385 -r1.386 src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.100 -r1.101 src/sys/arch/sparc64/sparc64/vm_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.385 src/sys/arch/sparc64/sparc64/locore.s:1.386
--- src/sys/arch/sparc64/sparc64/locore.s:1.385	Thu Nov  5 10:11:51 2015
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri Nov  6 15:30:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.385 2015/11/05 10:11:51 martin Exp $	*/
+/*	$NetBSD: locore.s,v 1.386 2015/11/06 15:30:59 martin Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -5958,12 +5958,6 @@ ENTRY(lwp_trampoline)
 	 mov	%l1, %o0
 
 	/*
-	 * Going to userland - set proper tstate in trap frame
-	 */
-	set	(ASI_PRIMARY_NO_FAULT<tf_out[6] = (uint64_t)(u_long)stack + stacksize;
 
 	/*
+	 * Need to create a %tstate if we are forking our first userland
+	 * process - in all other cases we inherit from the parent.
+	 */
+	if (l2->l_proc->p_pid == 1)
+		tf2->tf_tstate = (ASI_PRIMARY_NO_FAULT<

CVS commit: src/sys/arch/sparc64/sparc64

2015-11-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Nov  5 10:11:51 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: locore.s

Log Message:
Most of the time return_from_trap already got called with tf->tf_tstate
loaded in register %g1 - make it so for two more callers and remove
the reload of that value.


To generate a diff of this commit:
cvs rdiff -u -r1.384 -r1.385 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.384 src/sys/arch/sparc64/sparc64/locore.s:1.385
--- src/sys/arch/sparc64/sparc64/locore.s:1.384	Sun Apr  5 20:34:00 2015
+++ src/sys/arch/sparc64/sparc64/locore.s	Thu Nov  5 10:11:51 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.384 2015/04/05 20:34:00 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.385 2015/11/05 10:11:51 martin Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -1954,7 +1954,7 @@ winfixfill:
 #if 0 /* Need to switch over to new stuff to fix WDR bug */
 	wrpr	%g5, %cwp! Restore cwp from before fill trap -- regs should now be consisent
 	wrpr	%g2, %g0, %tl! Restore trap level -- we need to reuse it
-	set	return_from_trap, %g4
+	set	return_from_trap, %g4			! XXX - need to set %g1 to tstate
 	set	CTX_PRIMARY, %g7
 	wrpr	%g4, 0, %tpc
 	stxa	%g0, [%g7] ASI_DMMU
@@ -2975,8 +2975,8 @@ Lslowtrap_reenter:
 	call	_C_LABEL(trap)			! trap(tf, type, pc, pstate)
 	 nop
 
-	ba,a,pt	%icc, return_from_trap
-	 nop
+	b	return_from_trap
+	 ldx	[%sp + CC64FSZ + STKB + TF_TSTATE], %g1	! Load this for return_from_trap
 	NOTREACHED
 #if 1
 /*
@@ -3364,7 +3364,7 @@ syscall_setup:
 return_from_syscall:
 	wrpr	%g0, PSTATE_KERN, %pstate	! Disable intterrupts
 	wrpr	%g0, 0, %tl			! Return to tl==0
-	ba,a,pt	%icc, return_from_trap
+	b	return_from_trap
 	 nop
 	NOTREACHED
 
@@ -3928,8 +3928,8 @@ intrcmplt:
 	ldub	[%sp + CC64FSZ + STKB + TF_OLDPIL], %l3	! restore old %pil
 	wrpr	%l3, 0, %pil
 
-	ba,a,pt	%icc, return_from_trap
-	 nop
+	b	return_from_trap
+	 ldx	[%sp + CC64FSZ + STKB + TF_TSTATE], %g1	! Load this for return_from_trap
 
 #ifdef notyet
 /*
@@ -3962,6 +3962,7 @@ zshard:
  * registers are:
  *
  *	[%sp + CC64FSZ + STKB] => trap frame
+ *  %g1 => tstate from trap frame
  *
  * We must load all global, out, and trap registers from the trap frame.
  *
@@ -3987,7 +3988,7 @@ return_from_trap:
 	!!
 	!! We'll make sure we flush our pcb here, rather than later.
 	!!
-	ldx	[%sp + CC64FSZ + STKB + TF_TSTATE], %g1
+!	ldx	[%sp + CC64FSZ + STKB + TF_TSTATE], %g1	! already passed in, no need to reload
 	btst	TSTATE_PRIV, %g1			! returning to userland?
 
 	!!
@@ -5965,7 +5966,7 @@ ENTRY(lwp_trampoline)
 	/*
 	 * Here we finish up as in syscall, but simplified.
 	 */
-	ba,a,pt	%icc, return_from_trap
+	b	return_from_trap
 	 nop
 
 /*



CVS commit: src/sys/arch/sparc64/sparc64

2015-10-17 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Sat Oct 17 18:51:32 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: cpu_in_cksum.S

Log Message:
LDPTR is defined in machine/asm.h.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/sparc64/cpu_in_cksum.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/cpu_in_cksum.S
diff -u src/sys/arch/sparc64/sparc64/cpu_in_cksum.S:1.3 src/sys/arch/sparc64/sparc64/cpu_in_cksum.S:1.4
--- src/sys/arch/sparc64/sparc64/cpu_in_cksum.S:1.3	Sat Dec 22 20:08:08 2012
+++ src/sys/arch/sparc64/sparc64/cpu_in_cksum.S	Sat Oct 17 18:51:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_in_cksum.S,v 1.3 2012/12/22 20:08:08 nakayama Exp $ */
+/*	$NetBSD: cpu_in_cksum.S,v 1.4 2015/10/17 18:51:32 nakayama Exp $ */
 
 /*
  * Copyright (c) 2001 Eduardo Horvath
@@ -27,12 +27,6 @@
 #include "assym.h"
 #include 
 
-#ifdef __arch64__
-#define	LDPTR	ldx
-#else
-#define	LDPTR	lduw
-#endif
-
 /*
  * int cpu_in_cksum(struct mbuf *m, int len, int off, uint32_t initial_sum);
  *



CVS commit: src/sys/arch/sparc64/sparc64

2015-09-08 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Tue Sep  8 13:18:06 UTC 2015

Modified Files:
src/sys/arch/sparc64/sparc64: pmap.c

Log Message:
Fix build w/o options SUN4V.

mdesc_get_len() and mdesc_init() are used outside of #ifdef SUN4V,
and eliminated by optimization if SUN4V isn't defined.


To generate a diff of this commit:
cvs rdiff -u -r1.298 -r1.299 src/sys/arch/sparc64/sparc64/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.298 src/sys/arch/sparc64/sparc64/pmap.c:1.299
--- src/sys/arch/sparc64/sparc64/pmap.c:1.298	Sun Sep  6 23:48:39 2015
+++ src/sys/arch/sparc64/sparc64/pmap.c	Tue Sep  8 13:18:06 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.298 2015/09/06 23:48:39 nakayama Exp $	*/
+/*	$NetBSD: pmap.c,v 1.299 2015/09/08 13:18:06 nakayama Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.298 2015/09/06 23:48:39 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.299 2015/09/08 13:18:06 nakayama Exp $");
 
 #undef	NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define	HWREF
@@ -60,8 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.2
 #include 
 #ifdef SUN4V
 #include 
-#include 
 #endif
+#include 
 
 #include 
 



  1   2   3   >