CVS commit: src/sys/arch/sparc/dev

2024-05-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun May 12 13:43:27 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add simple 16bit load and store ops


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.21 src/sys/arch/sparc/dev/sxreg.h:1.22
--- src/sys/arch/sparc/dev/sxreg.h:1.21	Fri Dec 10 20:36:03 2021
+++ src/sys/arch/sparc/dev/sxreg.h	Sun May 12 13:43:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.21 2021/12/10 20:36:03 andvar Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.22 2024/05/12 13:43:27 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -195,6 +195,8 @@
 SX_LONG | (dreg << 7) | (o))
 #define SX_LDB(dreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_LOAD | \
 SX_UBYTE_0 | (dreg << 7) | (o))
+#define SX_LDW(dreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_LOAD | \
+SX_USHORT_0 | (dreg << 7) | (o))
 #define SX_LDP(dreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_LOAD | \
 SX_PACKED | (dreg << 7) | (o))
 #define SX_LDUQ0(dreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_LOAD | \
@@ -223,6 +225,8 @@
 SX_UBYTE_0 | (sreg << 7) | (o))
 #define SX_STBC(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE_CLAMP | \
 SX_UBYTE_0 | (sreg << 7) | (o))
+#define SX_STW(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE | \
+SX_USHORT_0 | (sreg << 7) | (o))
 #define SX_STP(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE | \
 SX_PACKED | (sreg << 7) | (o))
 #define SX_STPS(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE_SELECT | \



CVS commit: src/sys/arch/sparc/dev

2024-05-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun May 12 13:43:27 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add simple 16bit load and store ops


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2024-05-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun May 12 11:48:05 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
support 16bit / RGB565 colour


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.97 src/sys/arch/sparc/dev/cgfourteen.c:1.98
--- src/sys/arch/sparc/dev/cgfourteen.c:1.97	Wed Apr 24 11:49:58 2024
+++ src/sys/arch/sparc/dev/cgfourteen.c	Sun May 12 11:48:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.97 2024/04/24 11:49:58 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.98 2024/05/12 11:48:05 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -385,6 +385,7 @@ cgfourteenattach(device_t parent, device
 
 	/* Attach to /dev/fb */
 	fb_attach(>sc_fb, isconsole);
+
 }
 
 /*
@@ -493,6 +494,7 @@ cgfourteenioctl(dev_t dev, u_long cmd, v
 			return EINVAL;
 
 		cg14_set_depth(sc, depth);
+		cg14_init_cmap(sc);
 		}
 		break;
 	default:
@@ -608,7 +610,8 @@ cgfourteenpoll(dev_t dev, int events, st
 static void
 cg14_init(struct cgfourteen_softc *sc)
 {
-	cg14_set_depth(sc, 32);
+	cg14_set_depth(sc, 32);	
+	cg14_init_cmap(sc);
 }
 
 static void
@@ -616,6 +619,7 @@ static void
 cg14_reset(struct cgfourteen_softc *sc)
 {
 	cg14_set_depth(sc, 8);
+	cg14_init_cmap(sc);
 }
 
 /* Enable/disable video display; power down monitor if DPMS-capable */
@@ -736,7 +740,9 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 		WSSCREEN_RESIZE,
 		NULL
 	};
+
 	cg14_set_depth(sc, 8);
+
 	sc->sc_screens[0] = >sc_defaultscreen_descr;
 	sc->sc_screenlist = (struct wsscreen_list){1, sc->sc_screens};
 	sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
@@ -753,45 +759,50 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 	sc->sc_gc.gc_rectfill = cg14_rectfill_a;
 	sc->sc_gc.gc_rop = 0xc;
 
-		vcons_init_screen(>sc_vd, >sc_console_screen, 1,
-		);
+	vcons_init_screen(>sc_vd, >sc_console_screen, 1,
+	);
+
+	/* clear the screen with the default background colour */
+	if (sc->sc_sx != NULL) {
+		cg14_rectfill(sc, 0, 0, ri->ri_width, ri->ri_height,
+			ri->ri_devcmap[(defattr >> 16) & 0xf]);
+	} else {
+		memset(sc->sc_fb.fb_pixels,
+		   ri->ri_devcmap[(defattr >> 16) & 0xf],
+		   ri->ri_stride * ri->ri_height);
+	}
+	sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
+
+	sc->sc_defaultscreen_descr.textops = >ri_ops;
+	sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
+	sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
+	sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
+	glyphcache_init_align(>sc_gc, sc->sc_fb.fb_type.fb_height + 5,
+		(sc->sc_vramsize / sc->sc_fb.fb_type.fb_width) - 
+		 sc->sc_fb.fb_type.fb_height - 5,
+		sc->sc_fb.fb_type.fb_width,
+		ri->ri_font->fontwidth,
+		ri->ri_font->fontheight,
+		defattr, 4);
 
-		/* clear the screen with the default background colour */
-		if (sc->sc_sx != NULL) {
-			cg14_rectfill(sc, 0, 0, ri->ri_width, ri->ri_height,
-ri->ri_devcmap[(defattr >> 16) & 0xf]);
-		} else {
-			memset(sc->sc_fb.fb_pixels,
-			   ri->ri_devcmap[(defattr >> 16) & 0xf],
-			   ri->ri_stride * ri->ri_height);
-		}
-		sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
-
-		sc->sc_defaultscreen_descr.textops = >ri_ops;
-		sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
-		sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
-		sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
-		glyphcache_init_align(>sc_gc, sc->sc_fb.fb_type.fb_height + 5,
-			(sc->sc_vramsize / sc->sc_fb.fb_type.fb_width) - 
-			 sc->sc_fb.fb_type.fb_height - 5,
-			sc->sc_fb.fb_type.fb_width,
-			ri->ri_font->fontwidth,
-			ri->ri_font->fontheight,
-			defattr, 4);
 	if (is_cons) {
 		wsdisplay_cnattach(>sc_defaultscreen_descr, ri, 0, 0,
 		defattr);
 		vcons_replay_msgbuf(>sc_console_screen);
 	}
 
-	cg14_init_cmap(sc);
-
 	aa.console = is_cons;
 	aa.scrdata = >sc_screenlist;
 	aa.accessops = _accessops;
 	aa.accesscookie = >sc_vd;
 
 	config_found(sc->sc_dev, , wsemuldisplaydevprint, CFARGS_NONE);
+
+	/*
+	 * do this here since any output through firmware calls will mess
+	 * with XLUT settings
+	 */
+	cg14_init_cmap(sc);
 }
 
 static void
@@ -799,18 +810,74 @@ cg14_init_cmap(struct cgfourteen_softc *
 {
 	struct rasops_info *ri = >sc_console_screen.scr_ri;
 	int i, j = 0;
+	uint32_t r, g, b, c;
 	uint8_t cmap[768];
 
-	rasops_get_cmap(ri, cmap, sizeof(cmap));
-
-	for (i = 0; i < 256; i++) {
-
-		sc->sc_cmap.cm_map[i][3] = cmap[j];
-		sc->sc_cmap.cm_map[i][2] = cmap[j + 1];
-		sc->sc_cmap.cm_map[i][1] = cmap[j + 2];
-		j += 3;
+	if (sc->sc_depth == 16) {
+		/* construct an R5G6B5 palette in CLUT1/2 */
+		for (i = 0; i < 0x100; i++) {
+			/* upper byte first */
+			r = (i & 0xf8);	/* red component */
+			r |= r >> 5;		/* fill lower bits so 0xf8 */
+			c = 0x4000 | r;	/* becomes 0xff */
+			g = i 

CVS commit: src/sys/arch/sparc/dev

2024-05-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun May 12 11:48:05 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
support 16bit / RGB565 colour


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2024-05-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun May 12 07:22:13 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: cgfourteenreg.h

Log Message:
moar registers
in particular, document XLUT bits


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc/dev/cgfourteenreg.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/sparc/dev/cgfourteenreg.h
diff -u src/sys/arch/sparc/dev/cgfourteenreg.h:1.7 src/sys/arch/sparc/dev/cgfourteenreg.h:1.8
--- src/sys/arch/sparc/dev/cgfourteenreg.h:1.7	Sat Jun 12 21:25:56 2010
+++ src/sys/arch/sparc/dev/cgfourteenreg.h	Sun May 12 07:22:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteenreg.h,v 1.7 2010/06/12 21:25:56 macallan Exp $ */
+/*	$NetBSD: cgfourteenreg.h,v 1.8 2024/05/12 07:22:13 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -91,6 +91,39 @@ struct cg14ctl {
 #define CG14_RSR_REVMASK	0xf0 		/*  mask to get revision */
 #define CG14_RSR_IMPLMASK	0x0f		/*  mask to get impl. code */
 	volatile uint8_t	ctl_ccr;	/* clock control register */
+#define CCR_SCL		0x01
+#define CCR_SDA		0x02
+#define CCR_SDA_DIR	0x04
+#define CCR_ASXSEL	0x08	/* the ICS1562 has 4 data/address lines and a */
+#define CCR_DATA	0xf0	/* toggle input - I suspect this is it */
+	volatile uint32_t	ctl_tmr;	/* test mode readback */
+	volatile uint8_t	ctl_mod;	/* monitor data register */
+	/* reads 0x4 on mine, other bits in the lower half can be written with
+	   no obvious effect ( I suspect monitor ID ), upper half is hard zero 
+	 */
+	volatile uint8_t	ctl_acr;	/* aux control register */	
+#define ACR_BYTE_PIXEL	0x01	/* if unset pixels are 32bit */
+/* other bits are hard zero */	
+uint8_t 	m_pad0[6];  /* Reserved */
+uint16_t	m_hct;  /* Horizontal Counter   */
+uint16_t	m_vct;  /* Vertical Counter */
+uint16_t	m_hbs;  /* Horizontal Blank Start   */
+uint16_t	m_hbc;  /* Horizontal Blank Clear   */
+uint16_t	m_hss;  /* Horizontal Sync Set  */
+uint16_t	m_hsc;  /* Horizontal Sync Set  */
+uint16_t	m_csc;  /* Composite sync clear */
+uint16_t	m_vbs;  /* Vertical blank start */
+uint16_t	m_vbc;  /* Vertical Blank Clear */
+uint16_t	m_vss;  /* Verical Sync Set */
+uint16_t	m_vsc;  /* Verical Sync Clear   */
+uint16_t	m_xcs;  /* XXX Gone in VSIMM 2 */
+uint16_t	m_xcc;  /* XXX Gone in VSIMM 2 */
+uint16_t	m_fsa;  /* Fault status address */
+uint16_t	m_adr;  /* Address register (autoincrements) */
+uint8_t		m_pad2[0xce];   /* Reserved */
+
+/* PCG registers */
+uint8_t		m_pcg[0x100];   /* Pixel Clock generator regs   */
 	/* XXX etc. */
 };
 
@@ -134,6 +167,35 @@ struct cg14xlut {
 	volatile uint8_t	xlut_lutincd[CG14_CLUT_SIZE];
 };
 
+/* 
+ * The XLUT and ctl_ppr bits are the same - in 8bit ppr is used, in 16bit and
+ * 24bit XLUT
+ * here we select two colours, either RGB or a component passed through a
+ * CLUT, and blend them together. The alpha value is taken from the right 
+ * source's CLUT's upper byte, with 0x80 being 1.0 and 0x00 being 0.0
+*/
+
+#define CG14_LEFT_PASSTHROUGH	0x00
+#define CG14_LEFT_CLUT1		0x40
+#define CG14_LEFT_CLUT2		0x80
+#define CG14_LEFT_CLUT3		0xc0
+
+#define CG14_RIGHT_PASSTHROUGH	0x00
+#define CG14_RIGHT_CLUT1	0x10
+#define CG14_RIGHT_CLUT2	0x20
+#define CG14_RIGHT_CLUT3	0x30
+
+/* 0 is passthrough again */
+#define CG14_LEFT_B   0x04
+#define CG14_LEFT_G   0x08
+#define CG14_LEFT_R   0x0c
+
+/* except here 0 selects the X channel */
+#define CG14_RIGHT_X  0x00
+#define CG14_RIGHT_B  0x01
+#define CG14_RIGHT_G  0x02
+#define CG14_RIGHT_R  0x03
+
 /* Color Look-Up Table (CLUT) */
 struct cg14clut {
 	volatile uint32_t	clut_lut[CG14_CLUT_SIZE];	/* the LUT */



CVS commit: src/sys/arch/sparc/dev

2024-05-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun May 12 07:22:13 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: cgfourteenreg.h

Log Message:
moar registers
in particular, document XLUT bits


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc/dev/cgfourteenreg.h

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



CVS commit: src/sys/arch/sparc/dev

2024-04-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Apr 24 11:49:58 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
allow userland to switch to 16bit colour


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.96 src/sys/arch/sparc/dev/cgfourteen.c:1.97
--- src/sys/arch/sparc/dev/cgfourteen.c:1.96	Wed Dec 20 05:33:18 2023
+++ src/sys/arch/sparc/dev/cgfourteen.c	Wed Apr 24 11:49:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.96 2023/12/20 05:33:18 thorpej Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.97 2024/04/24 11:49:58 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -1072,22 +1072,28 @@ cg14_set_depth(struct cgfourteen_softc *
 			CG14_MCTL, CG14_MCTL_ENABLEVID | 
 			CG14_MCTL_PIXMODE_8 | CG14_MCTL_POWERCTL);
 			sc->sc_depth = 8;
-			/* everything is CLUT1 */
-			for (i = 0; i < CG14_CLUT_SIZE; i++)
-			 sc->sc_xlut->xlut_lut[i] = 0;
+			break;
+		case 16:
+			bus_space_write_1(sc->sc_bustag, sc->sc_regh,
+			CG14_MCTL, CG14_MCTL_ENABLEVID | 
+			CG14_MCTL_PIXMODE_16 | CG14_MCTL_POWERCTL);
+			sc->sc_depth = 16;
 			break;
 		case 32:
 			bus_space_write_1(sc->sc_bustag, sc->sc_regh,
 			CG14_MCTL, CG14_MCTL_ENABLEVID | 
 			CG14_MCTL_PIXMODE_32 | CG14_MCTL_POWERCTL);
 			sc->sc_depth = 32;
-			for (i = 0; i < CG14_CLUT_SIZE; i++)
-			 sc->sc_xlut->xlut_lut[i] = 0;
 			break;
 		default:
 			printf("%s: can't change to depth %d\n",
 			device_xname(sc->sc_dev), depth);
+			return;
 	}
+	/* everything is CLUT1 */
+	for (i = 0; i < CG14_CLUT_SIZE; i++)
+	 sc->sc_xlut->xlut_lut[i] = 0;
+
 }
 
 static void
@@ -1432,7 +1438,7 @@ cg14_bitblt_gc(void *cookie, int xs, int
 
 	saddr = sc->sc_fb_paddr + xs + stride * ys;
 	daddr = sc->sc_fb_paddr + xd + stride * yd;
-
+		
 	if (saddr & 3) {
 		swi += saddr & 3;
 		dreg += saddr & 3;



CVS commit: src/sys/arch/sparc/dev

2024-04-24 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Apr 24 11:49:58 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
allow userland to switch to 16bit colour


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:02:24 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: sbusreg.h

Log Message:
sparc/sbusreg: fix snprintb format for SBUS_AFSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc/dev/sbusreg.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/sparc/dev/sbusreg.h
diff -u src/sys/arch/sparc/dev/sbusreg.h:1.6 src/sys/arch/sparc/dev/sbusreg.h:1.7
--- src/sys/arch/sparc/dev/sbusreg.h:1.6	Wed Nov 16 00:49:03 2005
+++ src/sys/arch/sparc/dev/sbusreg.h	Sun Mar 10 17:02:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sbusreg.h,v 1.6 2005/11/16 00:49:03 uwe Exp $ */
+/*	$NetBSD: sbusreg.h,v 1.7 2024/03/10 17:02:24 rillig Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -94,7 +94,7 @@ struct sbusreg {
 #define SBUS_AFSR_ERR	0x8000	/* Summary bit: one of LE,TO,BERR */
 #define SBUS_AFSR_BITS	"\177\020"	\
 			"f\0\4PAH\0b\10WM\0f\11\3SSIZ\0f\14\5SA\0"	\
-			"b\11FAV\0b\12RD\0b\13ME\0f\14\4MID\0b\30S\0"	\
+			"b\21FAV\0b\22RD\0b\23ME\0f\24\4MID\0b\30S\0"	\
 			"f\31\3SIZ\0b\34BERR\0b\35TO\0b\36LE\0b\37ERR\0"
 
 /* Arbiter Enable register */



CVS commit: src/sys/arch/sparc/dev

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:02:24 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: sbusreg.h

Log Message:
sparc/sbusreg: fix snprintb format for SBUS_AFSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc/dev/sbusreg.h

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



CVS commit: src/sys/arch/sparc/dev

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 16:58:08 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: vmereg.h

Log Message:
sparc/vmereg: fix snprintb format VMEBUS_AFSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc/dev/vmereg.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/sparc/dev/vmereg.h
diff -u src/sys/arch/sparc/dev/vmereg.h:1.7 src/sys/arch/sparc/dev/vmereg.h:1.8
--- src/sys/arch/sparc/dev/vmereg.h:1.7	Mon Apr 28 20:23:36 2008
+++ src/sys/arch/sparc/dev/vmereg.h	Sun Mar 10 16:58:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmereg.h,v 1.7 2008/04/28 20:23:36 martin Exp $ */
+/*	$NetBSD: vmereg.h,v 1.8 2024/03/10 16:58:08 rillig Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@ struct vmebusreg {
 #define VMEBUS_AFSR_ME	0x0080	/* Multiple error */
 #define VMEBUS_AFSR_RSVD 0x007f	/* reserved */
 #define VMEBUS_AFSR_BITS "\177\020"	\
-			 "b\27ME\0b\30S\0b\31ERR\0b\32WB\0\33TO\0f\34\3SZ\0"
+	"b\27ME\0b\30S\0b\31ERR\0b\32WB\0b\33BERR\0b\34TO\0f\35\3SZ\0"
 
 struct vmebusvec {
 	volatile uint8_t	vmebusvec[16];



CVS commit: src/sys/arch/sparc/dev

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 16:58:08 UTC 2024

Modified Files:
src/sys/arch/sparc/dev: vmereg.h

Log Message:
sparc/vmereg: fix snprintb format VMEBUS_AFSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc/dev/vmereg.h

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



CVS commit: src/sys/arch/sparc/dev

2023-12-11 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Dec 11 22:29:39 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: fd.c

Log Message:
Surround fdc declaration and definition with FD_DEBUG blocks.

FD_DEBUG is defined by default, thus build passes, however would fail otherwise
since it is only used in debug block.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sys/arch/sparc/dev/fd.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/sparc/dev/fd.c
diff -u src/sys/arch/sparc/dev/fd.c:1.163 src/sys/arch/sparc/dev/fd.c:1.164
--- src/sys/arch/sparc/dev/fd.c:1.163	Sat Aug  7 16:19:05 2021
+++ src/sys/arch/sparc/dev/fd.c	Mon Dec 11 22:29:39 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.163 2021/08/07 16:19:05 thorpej Exp $	*/
+/*	$NetBSD: fd.c,v 1.164 2023/12/11 22:29:39 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.163 2021/08/07 16:19:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.164 2023/12/11 22:29:39 andvar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -1948,7 +1948,9 @@ int
 fdioctl(dev_t dev, u_long cmd, void *addr, int flag, struct lwp *l)
 {
 	struct fd_softc *fd;
+#ifdef FD_DEBUG
 	struct fdc_softc *fdc;
+#endif
 	struct fdformat_parms *form_parms;
 	struct fdformat_cmd *form_cmd;
 	struct ne7_fd_formb *fd_formb;
@@ -1962,7 +1964,9 @@ fdioctl(dev_t dev, u_long cmd, void *add
 		return (ENXIO);
 
 	fd = device_lookup_private(_cd, FDUNIT(dev));
+#ifdef FD_DEBUG
 	fdc = device_private(device_parent(fd->sc_dv));
+#endif
 
 	switch (cmd) {
 	case DIOCGDINFO:



CVS commit: src/sys/arch/sparc/dev

2023-12-11 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Dec 11 22:29:39 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: fd.c

Log Message:
Surround fdc declaration and definition with FD_DEBUG blocks.

FD_DEBUG is defined by default, thus build passes, however would fail otherwise
since it is only used in debug block.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sys/arch/sparc/dev/fd.c

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



CVS commit: src/sys/arch/sparc/dev

2023-06-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jun 13 10:11:17 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
- use sx_wait() to avoid stalling the MBus
- request 32bit alignment for glyphcache cells


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2023-06-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jun 13 10:11:17 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
- use sx_wait() to avoid stalling the MBus
- request 32bit alignment for glyphcache cells


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.94 src/sys/arch/sparc/dev/cgfourteen.c:1.95
--- src/sys/arch/sparc/dev/cgfourteen.c:1.94	Tue May 23 10:20:12 2023
+++ src/sys/arch/sparc/dev/cgfourteen.c	Tue Jun 13 10:11:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.94 2023/05/23 10:20:12 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.95 2023/06/13 10:11:17 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -173,7 +173,9 @@ static void cg14_eraserows(void *, int, 
  * issue ALU instruction:
  * sxi(OPCODE, srcA, srcB, dest, count)
  */
-#define sxi(inst, a, b, d, cnt) sx_write(sc->sc_sx, SX_INSTRUCTIONS, inst((a), (b), (d), (cnt)))
+#define sxi(inst, a, b, d, cnt) \
+	sx_wait(sc->sc_sx); \
+	sx_write(sc->sc_sx, SX_INSTRUCTIONS, inst((a), (b), (d), (cnt)))
 
 /*
  * issue memory referencing instruction:
@@ -770,13 +772,13 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 		sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
 		sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
 		sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
-		glyphcache_init(>sc_gc, sc->sc_fb.fb_type.fb_height + 5,
+		glyphcache_init_align(>sc_gc, sc->sc_fb.fb_type.fb_height + 5,
 			(sc->sc_vramsize / sc->sc_fb.fb_type.fb_width) - 
 			 sc->sc_fb.fb_type.fb_height - 5,
 			sc->sc_fb.fb_type.fb_width,
 			ri->ri_font->fontwidth,
 			ri->ri_font->fontheight,
-			defattr);
+			defattr, 4);
 	if (is_cons) {
 		wsdisplay_cnattach(>sc_defaultscreen_descr, ri, 0, 0,
 		defattr);



CVS commit: src/sys/arch/sparc/dev

2023-06-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jun 13 10:09:32 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: sx.c sxvar.h

Log Message:
add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations
adapted from xf86-video-suncg14


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc/dev/sx.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc/dev/sxvar.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/sparc/dev/sx.c
diff -u src/sys/arch/sparc/dev/sx.c:1.6 src/sys/arch/sparc/dev/sx.c:1.7
--- src/sys/arch/sparc/dev/sx.c:1.6	Thu Apr 13 13:07:48 2023
+++ src/sys/arch/sparc/dev/sx.c	Tue Jun 13 10:09:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sx.c,v 1.6 2023/04/13 13:07:48 macallan Exp $	*/
+/*	$NetBSD: sx.c,v 1.7 2023/06/13 10:09:31 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sx.c,v 1.6 2023/04/13 13:07:48 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sx.c,v 1.7 2023/06/13 10:09:31 macallan Exp $");
 
 #include "locators.h"
 
@@ -84,6 +84,7 @@ sx_attach(device_t parent, device_t self
 	sc->sc_dev = self;
 	sc->sc_tag = ma->ma_bustag;
 	sc->sc_uregs = ma->ma_paddr + 0x1000;
+	sc->sc_cnt = 0;
 
 	if (bus_space_map(sc->sc_tag, ma->ma_paddr, 0x1000, 0, >sc_regh)) {
 		aprint_error_dev(self, "failed to map registers\n");

Index: src/sys/arch/sparc/dev/sxvar.h
diff -u src/sys/arch/sparc/dev/sxvar.h:1.4 src/sys/arch/sparc/dev/sxvar.h:1.5
--- src/sys/arch/sparc/dev/sxvar.h:1.4	Fri Mar  1 02:30:42 2019
+++ src/sys/arch/sparc/dev/sxvar.h	Tue Jun 13 10:09:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxvar.h,v 1.4 2019/03/01 02:30:42 macallan Exp $	*/
+/*	$NetBSD: sxvar.h,v 1.5 2023/06/13 10:09:31 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,11 +32,14 @@
 #ifndef SXVAR_H
 #define SXVAR_H
 
+#include 
+
 struct sx_softc {
 	device_t		sc_dev;
 	bus_addr_t		sc_uregs;
 	bus_space_tag_t		sc_tag;
 	bus_space_handle_t	sc_regh;
+	int			sc_cnt;
 };
 
 static inline void
@@ -51,6 +54,26 @@ sx_read(struct sx_softc *sc, int addr)
 	return bus_space_read_4(sc->sc_tag, sc->sc_regh, addr);
 }
 
+/*
+ * to be used before issuing SX instructions
+ * this will periodically allow the instruction queue to drain in order
+ * to avoid excessive MBus relinquish & retry cycles during long SX ops
+ * which may cause us to lose interrupts
+ */
+static inline void
+sx_wait(struct sx_softc *sc)
+{
+	uint32_t reg;
+	if (sc->sc_cnt > 6) {
+		do {
+			reg = bus_space_read_4(sc->sc_tag, sc->sc_regh,
+		 SX_CONTROL_STATUS);
+		} while ((reg & SX_MT) == 0);
+		sc->sc_cnt = 0;
+	} else
+		sc->sc_cnt++;
+}
+
 void sx_dump(void);
 
 #endif



CVS commit: src/sys/arch/sparc/dev

2023-06-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jun 13 10:09:32 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: sx.c sxvar.h

Log Message:
add counter to periodically drain the instruction queue in order to avoid
stalling the MBus during long SX operations
adapted from xf86-video-suncg14


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc/dev/sx.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc/dev/sxvar.h

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



CVS commit: src/sys/arch/sparc/dev

2023-05-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May 23 10:20:12 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.93 src/sys/arch/sparc/dev/cgfourteen.c:1.94
--- src/sys/arch/sparc/dev/cgfourteen.c:1.93	Wed May 25 21:01:04 2022
+++ src/sys/arch/sparc/dev/cgfourteen.c	Tue May 23 10:20:12 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.93 2022/05/25 21:01:04 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.94 2023/05/23 10:20:12 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -168,6 +168,19 @@ static void cg14_copycols(void *, int, i
 static void cg14_erasecols(void *, int, int, int, long);
 static void cg14_copyrows(void *, int, int, int);
 static void cg14_eraserows(void *, int, int, long);
+
+/* 
+ * issue ALU instruction:
+ * sxi(OPCODE, srcA, srcB, dest, count)
+ */
+#define sxi(inst, a, b, d, cnt) sx_write(sc->sc_sx, SX_INSTRUCTIONS, inst((a), (b), (d), (cnt)))
+
+/*
+ * issue memory referencing instruction:
+ * sxm(OPCODE, address, start register, count)
+ */
+#define sxm(inst, addr, reg, count) sta((addr) & ~7, ASI_SX, inst((reg), (count), (addr) & 7))
+
 #endif /* NSX > 0 */
 
 #endif
@@ -358,7 +371,7 @@ cgfourteenattach(device_t parent, device
 		sc->sc_fbaddr, 0, 0, 0) & 0xf000;
 		aprint_normal_dev(sc->sc_dev, "using %s\n", 
 		device_xname(sc->sc_sx->sc_dev));
-		aprint_debug_dev(sc->sc_dev, "fb paddr: %08x\n",
+		aprint_normal_dev(sc->sc_dev, "fb paddr: %08x\n",
 		sc->sc_fb_paddr);
 		sx_write(sc->sc_sx, SX_PAGE_BOUND_LOWER, sc->sc_fb_paddr);
 		sx_write(sc->sc_sx, SX_PAGE_BOUND_UPPER,
@@ -379,7 +392,7 @@ cgfourteenattach(device_t parent, device
  * the last close. This kind of nonsense is needed to give screenblank
  * a fighting chance of working.
  */
-
+ 
 int
 cgfourteenopen(dev_t dev, int flags, int mode, struct lwp *l)
 {
@@ -567,8 +580,9 @@ cgfourteenmmap(dev_t dev, off_t off, int
 			0, prot, BUS_SPACE_MAP_LINEAR));
 	} else if (off >= CG14_SXIO_VOFF &&
 		   off < (CG14_SXIO_VOFF + 0x03ff)) {
+		off -= CG14_SXIO_VOFF;
 		return (bus_space_mmap(sc->sc_sx->sc_tag, 0x8LL,
-			sc->sc_fb_paddr + (off - CG14_SXIO_VOFF),
+			sc->sc_fb_paddr + off,
 			prot, BUS_SPACE_MAP_LINEAR));
 #endif
 	} else
@@ -1204,20 +1218,20 @@ cg14_rectfill(struct cgfourteen_softc *s
 		pptr = addr;
 		cnt = wi;
 		if (pre) {
-			sta(pptr & ~7, ASI_SX, SX_STBS(8, pre - 1, pptr & 7));
+			sxm(SX_STBS, pptr, 8, pre - 1);
 			pptr += pre;
 			cnt -= pre;
 		}
 		/* now do the aligned pixels in 32bit chunks */
 		while(cnt > 3) {
 			words = uimin(32, cnt >> 2);
-			sta(pptr & ~7, ASI_SX, SX_STS(8, words - 1, pptr & 7));
+			sxm(SX_STS, pptr, 8, words - 1);
 			pptr += words << 2;
 			cnt -= words << 2;
 		}
 		/* do any remaining pixels byte-wise again */
 		if (cnt > 0)
-			sta(pptr & ~7, ASI_SX, SX_STBS(8, cnt - 1, pptr & 7));
+			sxm(SX_STBS, pptr, 8, cnt - 1);
 		addr += stride;
 	}
 }
@@ -1275,28 +1289,25 @@ cg14_invert(struct cgfourteen_softc *sc,
 	for (line = 0; line < he; line++) {
 		pptr = addr;
 		/* load a whole scanline */
-		sta(pptr & ~7, ASI_SX, SX_LD(8, words - 1, pptr & 7));
+		sxm(SX_LD, pptr, 8, words - 1);
 		reg = 8;
 		if (pre) {
 			cg14_set_mask(sc, lmask);
-			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
-			SX_ROPB(8, 8, 40, 0));
+			sxi(SX_ROPB, 8, 8, 40, 0);
 			reg++;
 		}
 		if (cnt > 0) {
 			cg14_set_mask(sc, 0x);
 			/* XXX handle cnt > 16 */
-			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
-			SX_ROP(reg, reg, reg + 32, cnt - 1));
+			sxi(SX_ROP, reg, reg, reg + 32, cnt - 1);
 			reg += cnt;
 		}
 		if (post) {
 			cg14_set_mask(sc, rmask);
-			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
-			SX_ROPB(reg, 7, reg + 32, 0));
+			sxi(SX_ROPB, reg, 7, reg + 32, 0);
 			reg++;
 		}
-		sta(pptr & ~7, ASI_SX, SX_ST(40, words - 1, pptr & 7));		
+		sxm(SX_ST, pptr, 40, words - 1);		
 		addr += stride;
 	}
 }
@@ -1307,7 +1318,7 @@ cg14_slurp(int reg, uint32_t addr, int c
 	int num;
 	while (cnt > 0) {
 		num = uimin(32, cnt);
-		sta(addr & ~7, ASI_SX, SX_LD(reg, num - 1, addr & 7));
+		sxm(SX_LD, addr, reg, num - 1);
 		cnt -= num;
 		reg += num;
 		addr += (num << 2);
@@ -1320,7 +1331,7 @@ cg14_spit(int reg, uint32_t addr, int cn
 	int num;
 	while (cnt > 0) {
 		num = uimin(32, cnt);
-		sta(addr & ~7, ASI_SX, SX_ST(reg, num - 1, addr & 7));
+		sxm(SX_ST, addr, reg, num - 1);
 		cnt -= num;
 		reg += num;
 		addr += (num << 2);
@@ -1355,10 +1366,8 @@ cg14_bitblt(void *cookie, int xs, int ys
 			dptr = daddr;
 			cnt = wi;
 			if (pre > 

CVS commit: src/sys/arch/sparc/dev

2023-05-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue May 23 10:20:12 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
use macros compatible with xf86-video-suncg14 to issue SX instructions
much more readable, alignment weirdness is handled automatically and code is
interchangable


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2023-04-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 13 13:07:48 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: sx.c

Log Message:
initialize the diagnostic register with the value suggested by the SunOS
header. This sets a bunch of undocumented bits and yields a 10% speed increase
when rendering antialiased text.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc/dev/sx.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/sparc/dev/sx.c
diff -u src/sys/arch/sparc/dev/sx.c:1.5 src/sys/arch/sparc/dev/sx.c:1.6
--- src/sys/arch/sparc/dev/sx.c:1.5	Sat Sep 11 20:28:05 2021
+++ src/sys/arch/sparc/dev/sx.c	Thu Apr 13 13:07:48 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sx.c,v 1.5 2021/09/11 20:28:05 andvar Exp $	*/
+/*	$NetBSD: sx.c,v 1.6 2023/04/13 13:07:48 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sx.c,v 1.5 2021/09/11 20:28:05 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sx.c,v 1.6 2023/04/13 13:07:48 macallan Exp $");
 
 #include "locators.h"
 
@@ -104,7 +104,7 @@ sx_attach(device_t parent, device_t self
 	sx_write(sc, SX_PAGE_BOUND_LOWER, 0xfc00);
 	/* cg14 takes up the whole 64MB chunk */
 	sx_write(sc, SX_PAGE_BOUND_UPPER, 0x);
-	sx_write(sc, SX_DIAGNOSTICS, 0);
+	sx_write(sc, SX_DIAGNOSTICS, SX_DIAG_INIT);
 	sx_write(sc, SX_PLANEMASK, 0x);
 
 	/*



CVS commit: src/sys/arch/sparc/dev

2023-04-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 13 13:07:48 UTC 2023

Modified Files:
src/sys/arch/sparc/dev: sx.c

Log Message:
initialize the diagnostic register with the value suggested by the SunOS
header. This sets a bunch of undocumented bits and yields a 10% speed increase
when rendering antialiased text.


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

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



CVS commit: src/sys/arch/sparc/dev

2022-05-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed May 25 21:01:04 UTC 2022

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
be lazy about clearing the cursor since most likely we're going to overwrite
it anyway. Same logic as in cgsix.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.92 src/sys/arch/sparc/dev/cgfourteen.c:1.93
--- src/sys/arch/sparc/dev/cgfourteen.c:1.92	Fri Dec 17 19:27:57 2021
+++ src/sys/arch/sparc/dev/cgfourteen.c	Wed May 25 21:01:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.92 2021/12/17 19:27:57 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.93 2022/05/25 21:01:04 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -1485,6 +1485,10 @@ cg14_putchar(void *cookie, int row, int 
 	if (!CHAR_IN_FONT(c, font))
 		return;
 
+	if (row == ri->ri_crow && col == ri->ri_ccol) {
+		ri->ri_flg &= ~RI_CURSOR;
+	}
+
 	wi = font->fontwidth;
 	he = font->fontheight;
 
@@ -1538,6 +1542,23 @@ cg14_putchar(void *cookie, int row, int 
 }
 
 static void
+cg14_nuke_cursor(struct rasops_info *ri)
+{
+	struct vcons_screen *scr = ri->ri_hw;
+	struct cgfourteen_softc *sc = scr->scr_cookie;
+	int wi, he, x, y;
+		
+	if (ri->ri_flg & RI_CURSOR) {
+		wi = ri->ri_font->fontwidth;
+		he = ri->ri_font->fontheight;
+		x = ri->ri_ccol * wi + ri->ri_xorigin;
+		y = ri->ri_crow * he + ri->ri_yorigin;
+		cg14_invert(sc, x, y, wi, he);
+		ri->ri_flg &= ~RI_CURSOR;
+	}
+}
+
+static void
 cg14_cursor(void *cookie, int on, int row, int col)
 {
 	struct rasops_info *ri = cookie;
@@ -1549,20 +1570,17 @@ cg14_cursor(void *cookie, int on, int ro
 	he = ri->ri_font->fontheight;
 	
 	if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
-		x = ri->ri_ccol * wi + ri->ri_xorigin;
-		y = ri->ri_crow * he + ri->ri_yorigin;
-		if (ri->ri_flg & RI_CURSOR) {
-			cg14_invert(sc, x, y, wi, he);
-			ri->ri_flg &= ~RI_CURSOR;
-		}
-		ri->ri_crow = row;
-		ri->ri_ccol = col;
 		if (on) {
-			x = ri->ri_ccol * wi + ri->ri_xorigin;
-			y = ri->ri_crow * he + ri->ri_yorigin;
+			if (ri->ri_flg & RI_CURSOR) {
+cg14_nuke_cursor(ri);
+			}
+			x = col * wi + ri->ri_xorigin;
+			y = row * he + ri->ri_yorigin;
 			cg14_invert(sc, x, y, wi, he);
 			ri->ri_flg |= RI_CURSOR;
 		}
+		ri->ri_crow = row;
+		ri->ri_ccol = col;
 	} else {
 		scr->scr_ri.ri_crow = row;
 		scr->scr_ri.ri_ccol = col;
@@ -1590,6 +1608,10 @@ cg14_putchar_aa(void *cookie, int row, i
 	if (!CHAR_IN_FONT(c, font))
 		return;
 
+	if (row == ri->ri_crow && col == ri->ri_ccol) {
+		ri->ri_flg &= ~RI_CURSOR;
+	}
+
 	wi = font->fontwidth;
 	he = font->fontheight;
 
@@ -1692,12 +1714,20 @@ cg14_copycols(void *cookie, int row, int
 	int32_t xs, xd, y, width, height;
 	
 	if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
+		if (ri->ri_crow == row && 
+		   (ri->ri_ccol >= srccol && ri->ri_ccol < (srccol + ncols)) &&
+		   (ri->ri_flg & RI_CURSOR)) {
+			cg14_nuke_cursor(ri);
+		}
 		xs = ri->ri_xorigin + ri->ri_font->fontwidth * srccol;
 		xd = ri->ri_xorigin + ri->ri_font->fontwidth * dstcol;
 		y = ri->ri_yorigin + ri->ri_font->fontheight * row;
 		width = ri->ri_font->fontwidth * ncols;
 		height = ri->ri_font->fontheight;
 		cg14_bitblt(sc, xs, y, xd, y, width, height, 0x0c);
+		if (ri->ri_crow == row && 
+		   (ri->ri_ccol >= dstcol && ri->ri_ccol < (dstcol + ncols)))
+			ri->ri_flg &= ~RI_CURSOR;
 	}
 }
 
@@ -1715,8 +1745,11 @@ cg14_erasecols(void *cookie, int row, in
 		width = ri->ri_font->fontwidth * ncols;
 		height = ri->ri_font->fontheight;
 		rasops_unpack_attr(fillattr, , , );
-
 		cg14_rectfill(sc, x, y, width, height, ri->ri_devcmap[bg]);
+		if (ri->ri_crow == row && 
+		   (ri->ri_ccol >= startcol && ri->ri_ccol < (startcol + ncols)))
+			ri->ri_flg &= ~RI_CURSOR;
+
 	}
 }
 
@@ -1729,12 +1762,18 @@ cg14_copyrows(void *cookie, int srcrow, 
 	int32_t x, ys, yd, width, height;
 
 	if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
+		if ((ri->ri_crow >= srcrow && ri->ri_crow < (srcrow + nrows)) &&
+		   (ri->ri_flg & RI_CURSOR)) {
+			cg14_nuke_cursor(ri);
+		}
 		x = ri->ri_xorigin;
 		ys = ri->ri_yorigin + ri->ri_font->fontheight * srcrow;
 		yd = ri->ri_yorigin + ri->ri_font->fontheight * dstrow;
 		width = ri->ri_emuwidth;
 		height = ri->ri_font->fontheight * nrows;
 		cg14_bitblt(sc, x, ys, x, yd, width, height, 0x0c);
+		if (ri->ri_crow >= dstrow && ri->ri_crow < (dstrow + nrows))
+			ri->ri_flg &= ~RI_CURSOR;
 	}
 }
 
@@ -1752,8 +1791,9 @@ cg14_eraserows(void *cookie, int row, in
 		width = ri->ri_emuwidth;
 		height = ri->ri_font->fontheight * nrows;
 		rasops_unpack_attr(fillattr, , , );
-
 		cg14_rectfill(sc, x, y, width, height, ri->ri_devcmap[bg]);
+		if (ri->ri_crow >= row && ri->ri_crow < (row + nrows))
+			ri->ri_flg &= ~RI_CURSOR;
 	}
 }
 



CVS commit: src/sys/arch/sparc/dev

2022-05-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed May 25 21:01:04 UTC 2022

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
be lazy about clearing the cursor since most likely we're going to overwrite
it anyway. Same logic as in cgsix.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2022-01-21 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jan 21 19:22:56 UTC 2022

Modified Files:
src/sys/arch/sparc/dev: vme_machdep.c

Log Message:
Don't bother with prom_node_to_devhandle() if we're just forwarding along
our own node; use device_handle(self) instead.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/sparc/dev/vme_machdep.c

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



CVS commit: src/sys/arch/sparc/dev

2022-01-21 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jan 21 19:22:56 UTC 2022

Modified Files:
src/sys/arch/sparc/dev: vme_machdep.c

Log Message:
Don't bother with prom_node_to_devhandle() if we're just forwarding along
our own node; use device_handle(self) instead.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/sparc/dev/vme_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/sparc/dev/vme_machdep.c
diff -u src/sys/arch/sparc/dev/vme_machdep.c:1.75 src/sys/arch/sparc/dev/vme_machdep.c:1.76
--- src/sys/arch/sparc/dev/vme_machdep.c:1.75	Sun Dec  5 04:21:31 2021
+++ src/sys/arch/sparc/dev/vme_machdep.c	Fri Jan 21 19:22:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: vme_machdep.c,v 1.75 2021/12/05 04:21:31 msaitoh Exp $	*/
+/*	$NetBSD: vme_machdep.c,v 1.76 2022/01/21 19:22:56 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vme_machdep.c,v 1.75 2021/12/05 04:21:31 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vme_machdep.c,v 1.76 2022/01/21 19:22:56 thorpej Exp $");
 
 #include 
 #include 
@@ -432,7 +432,7 @@ vmeattach_iommu(device_t parent, device_
 	   sc->sc_reg->vmebus_cr & VMEBUS_CR_IMPL);
 
 	(void)config_found(self, , 0,
-	CFARGS(.devhandle = prom_node_to_devhandle(node)));
+	CFARGS(.devhandle = device_handle(self)));
 #endif /* SUN4M */
 }
 



CVS commit: src/sys/arch/sparc/dev

2021-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Dec 17 19:27:57 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c cgfourteenvar.h

Log Message:
only write the mask register if we're actually changing it


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/sparc/dev/cgfourteen.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc/dev/cgfourteenvar.h

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



CVS commit: src/sys/arch/sparc/dev

2021-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Dec 17 19:27:57 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c cgfourteenvar.h

Log Message:
only write the mask register if we're actually changing it


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/sparc/dev/cgfourteen.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc/dev/cgfourteenvar.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.91 src/sys/arch/sparc/dev/cgfourteen.c:1.92
--- src/sys/arch/sparc/dev/cgfourteen.c:1.91	Fri Dec 17 18:51:02 2021
+++ src/sys/arch/sparc/dev/cgfourteen.c	Fri Dec 17 19:27:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.91 2021/12/17 18:51:02 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.92 2021/12/17 19:27:57 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -1042,6 +1042,12 @@ cg14_set_depth(struct cgfourteen_softc *
 {
 	int i;
 
+	/* init mask */
+	if (sc->sc_sx != NULL) {
+		sc->sc_mask = 0x;
+		sx_write(sc->sc_sx, SX_QUEUED(R_MASK), sc->sc_mask);
+	}
+
 	if (sc->sc_depth == depth)
 		return;
 
@@ -1226,6 +1232,13 @@ cg14_rectfill_a(void *cookie, int dstx, 
 	sc->sc_vd.active->scr_ri.ri_devcmap[(attr >> 24 & 0xf)]);
 }
 
+static inline void
+cg14_set_mask(struct cgfourteen_softc *sc, uint32_t mask)
+{
+	if (mask == sc->sc_mask) return;
+	sc->sc_mask = mask;
+	sx_write(sc->sc_sx, SX_QUEUED(R_MASK), mask);
+}
 /*
  * invert a rectangle, used only to (un)draw the cursor.
  * - does a scanline at a time
@@ -1258,27 +1271,27 @@ cg14_invert(struct cgfourteen_softc *sc,
 	}
 	words = (wi + pre + 3) >> 2;
 	cnt = words - pwrds;
-	sx_write(sc->sc_sx, SX_QUEUED(7), 0xe0e0e0e0); /* four red pixels */
+
 	for (line = 0; line < he; line++) {
 		pptr = addr;
 		/* load a whole scanline */
 		sta(pptr & ~7, ASI_SX, SX_LD(8, words - 1, pptr & 7));
 		reg = 8;
 		if (pre) {
-			sx_write(sc->sc_sx, SX_QUEUED(R_MASK), lmask);
+			cg14_set_mask(sc, lmask);
 			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
 			SX_ROPB(8, 8, 40, 0));
 			reg++;
 		}
 		if (cnt > 0) {
-			sx_write(sc->sc_sx, SX_QUEUED(R_MASK), 0x);
+			cg14_set_mask(sc, 0x);
 			/* XXX handle cnt > 16 */
 			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
 			SX_ROP(reg, reg, reg + 32, cnt - 1));
 			reg += cnt;
 		}
 		if (post) {
-			sx_write(sc->sc_sx, SX_QUEUED(R_MASK), rmask);
+			cg14_set_mask(sc, rmask);
 			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
 			SX_ROPB(reg, 7, reg + 32, 0));
 			reg++;
@@ -1500,8 +1513,7 @@ cg14_putchar(void *cookie, int row, int 
 			uint32_t reg;
 			for (i = 0; i < he; i++) {
 reg = *data8;
-sx_write(sc->sc_sx, SX_QUEUED(R_MASK),
-reg << 24);
+cg14_set_mask(sc, reg << 24);
 sta(addr & ~7, ASI_SX, SX_STBS(8, wi - 1, addr & 7));
 data8++;
 addr += stride;
@@ -1513,8 +1525,7 @@ cg14_putchar(void *cookie, int row, int 
 			uint32_t reg;
 			for (i = 0; i < he; i++) {
 reg = *data16;
-sx_write(sc->sc_sx, SX_QUEUED(R_MASK),
-reg << 16);
+cg14_set_mask(sc, reg << 16);
 sta(addr & ~7, ASI_SX, SX_STBS(8, wi - 1, addr & 7));
 data16++;
 addr += stride;

Index: src/sys/arch/sparc/dev/cgfourteenvar.h
diff -u src/sys/arch/sparc/dev/cgfourteenvar.h:1.18 src/sys/arch/sparc/dev/cgfourteenvar.h:1.19
--- src/sys/arch/sparc/dev/cgfourteenvar.h:1.18	Sat Apr 30 05:23:03 2016
+++ src/sys/arch/sparc/dev/cgfourteenvar.h	Fri Dec 17 19:27:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteenvar.h,v 1.18 2016/04/30 05:23:03 macallan Exp $ */
+/*	$NetBSD: cgfourteenvar.h,v 1.19 2021/12/17 19:27:57 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -98,6 +98,7 @@ struct cgfourteen_softc {
 #if NSX > 0
 	struct sx_softc *sc_sx;
 	uint32_t sc_fb_paddr;
+	uint32_t sc_mask;
 	glyphcache sc_gc;
 #endif /* NSX > 0 */
 #endif



CVS commit: src/sys/arch/sparc/dev

2021-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Dec 17 18:51:02 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
cg14_invert():
- use only 32bit accesses
- use byte mask / ROPs for partial writes


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.90 src/sys/arch/sparc/dev/cgfourteen.c:1.91
--- src/sys/arch/sparc/dev/cgfourteen.c:1.90	Sat Aug  7 16:19:05 2021
+++ src/sys/arch/sparc/dev/cgfourteen.c	Fri Dec 17 18:51:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.90 2021/08/07 16:19:05 thorpej Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.91 2021/12/17 18:51:02 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -1226,50 +1226,64 @@ cg14_rectfill_a(void *cookie, int dstx, 
 	sc->sc_vd.active->scr_ri.ri_devcmap[(attr >> 24 & 0xf)]);
 }
 
+/*
+ * invert a rectangle, used only to (un)draw the cursor.
+ * - does a scanline at a time
+ * - does not handle wi > 64 or wi < 4, not that we need it for our fonts
+ * - uses all 32bit accesses
+ */ 
 static void
 cg14_invert(struct cgfourteen_softc *sc, int x, int y, int wi, int he)
 {
-	uint32_t addr, pptr;
-	int line, cnt, pre, words;
+	uint32_t addr, pptr, lmask, rmask;
+	int line, cnt, pre, words, pwrds = 0, post, reg;
 	int stride = sc->sc_fb.fb_type.fb_width;
 
-	addr = sc->sc_fb_paddr + x + stride * y;
-	sx_write(sc->sc_sx, SX_ROP_CONTROL, 0x33); /* ~src a */
+	addr = (sc->sc_fb_paddr + x + stride * y) & ~3;
+	sx_write(sc->sc_sx, SX_ROP_CONTROL, 0x3C); /* ~src a / src a */
 	/*
-	 * Calculate the number of pixels we need to do one by one
-	 * until we're 32bit aligned, then do the rest in 32bit
-	 * mode. Assumes that stride is always a multiple of 4. 
-	 */ 
-	/* TODO: use 32bit writes with byte mask instead */
-	pre = addr & 3;
-	if (pre != 0) pre = 4 - pre;
+	 * Calculate the number of pixels we need to mask on each end of the
+	 * scanline and how many we can do without mask, if any
+	 */
+	pre = x & 3;
+	if (pre != 0) {
+		lmask = 0x >> pre;
+		pre = 4 - pre;
+		pwrds++;
+	}
+	post = (x + wi) & 3;
+	if (post != 0) {
+		rmask = ~(0x >> post);
+		pwrds++;
+	}
+	words = (wi + pre + 3) >> 2;
+	cnt = words - pwrds;
+	sx_write(sc->sc_sx, SX_QUEUED(7), 0xe0e0e0e0); /* four red pixels */
 	for (line = 0; line < he; line++) {
 		pptr = addr;
-		cnt = wi;
+		/* load a whole scanline */
+		sta(pptr & ~7, ASI_SX, SX_LD(8, words - 1, pptr & 7));
+		reg = 8;
 		if (pre) {
-			sta(pptr & ~7, ASI_SX, SX_LDB(8, pre - 1, pptr & 7));
+			sx_write(sc->sc_sx, SX_QUEUED(R_MASK), lmask);
 			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
-			SX_ROP(8, 8, 32, pre - 1));
-			sta(pptr & ~7, ASI_SX, SX_STB(32, pre - 1, pptr & 7));
-			pptr += pre;
-			cnt -= pre;
+			SX_ROPB(8, 8, 40, 0));
+			reg++;
 		}
-		/* now do the aligned pixels in 32bit chunks */
-		while(cnt > 15) {
-			words = uimin(16, cnt >> 2);
-			sta(pptr & ~7, ASI_SX, SX_LD(8, words - 1, pptr & 7));
+		if (cnt > 0) {
+			sx_write(sc->sc_sx, SX_QUEUED(R_MASK), 0x);
+			/* XXX handle cnt > 16 */
 			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
-			SX_ROP(8, 8, 32, words - 1));
-			sta(pptr & ~7, ASI_SX, SX_ST(32, words - 1, pptr & 7));
-			pptr += words << 2;
-			cnt -= words << 2;
+			SX_ROP(reg, reg, reg + 32, cnt - 1));
+			reg += cnt;
 		}
-		/* do any remaining pixels byte-wise again */
-		if (cnt > 0)
-			sta(pptr & ~7, ASI_SX, SX_LDB(8, cnt - 1, pptr & 7));
+		if (post) {
+			sx_write(sc->sc_sx, SX_QUEUED(R_MASK), rmask);
 			sx_write(sc->sc_sx, SX_INSTRUCTIONS,
-			SX_ROP(8, 8, 32, cnt - 1));
-			sta(pptr & ~7, ASI_SX, SX_STB(32, cnt - 1, pptr & 7));
+			SX_ROPB(reg, 7, reg + 32, 0));
+			reg++;
+		}
+		sta(pptr & ~7, ASI_SX, SX_ST(40, words - 1, pptr & 7));		
 		addr += stride;
 	}
 }



CVS commit: src/sys/arch/sparc/dev

2021-12-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Dec 17 18:51:02 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
cg14_invert():
- use only 32bit accesses
- use byte mask / ROPs for partial writes


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2021-12-08 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec  8 17:03:38 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
be more consistent with underscores in instruction names


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.19 src/sys/arch/sparc/dev/sxreg.h:1.20
--- src/sys/arch/sparc/dev/sxreg.h:1.19	Wed Dec  8 16:40:14 2021
+++ src/sys/arch/sparc/dev/sxreg.h	Wed Dec  8 17:03:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.19 2021/12/08 16:40:14 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.20 2021/12/08 17:03:38 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -253,18 +253,18 @@
 SX_UCHAN_24 | (sreg << 7) | (o))
 
 /* ROP and SELECT instructions */
-#define SX_ROPB	(0x0 << 21)	/* mask bits apply to bytes */
-#define SX_ROPM	(0x1 << 21)	/* mask bits apply to each bit */
-#define SX_ROPL	(0x2 << 21)	/* mask bits apply per register */
-#define SX_SELB	(0x4 << 21)	/* byte select scalar */
-#define SX_SELV (0x6 << 21)	/* register select vector */
-#define SX_SELS (0x7 << 21)	/* register select scalar */
+#define SX_ROP_B	(0x0 << 21)	/* mask bits apply to bytes */
+#define SX_ROP_M	(0x1 << 21)	/* mask bits apply to each bit */
+#define SX_ROP_L	(0x2 << 21)	/* mask bits apply per register */
+#define SX_SEL_B	(0x4 << 21)	/* byte select scalar */
+#define SX_SEL_V	(0x6 << 21)	/* register select vector */
+#define SX_SEL_S	(0x7 << 21)	/* register select scalar */
 
-#define SX_ROP(sa, sb, d, cnt) (0x9000 | ((cnt) << 24) | SX_ROPL | \
+#define SX_ROP(sa, sb, d, cnt) (0x9000 | ((cnt) << 24) | SX_ROP_L | \
 		((sa) << 14) | (sb) | ((d) << 7))
-#define SX_ROPB(sa, sb, d, cnt) (0x9000 | ((cnt) << 24) | SX_ROPB | \
+#define SX_ROPB(sa, sb, d, cnt) (0x9000 | ((cnt) << 24) | SX_ROP_B | \
 		((sa) << 14) | (sb) | ((d) << 7))
-#define SX_SELECT_S(sa, sb, d, cnt) (0x9000 | ((cnt) << 24) | SX_SELS | \
+#define SX_SELECT_S(sa, sb, d, cnt) (0x9000 | ((cnt) << 24) | SX_SEL_S | \
 		((sa) << 14) | (sb) | ((d) << 7))
 
 /* multiply group */
@@ -350,30 +350,30 @@
 		 ((sa) << 14) | ((d) << 7) | (sb))
 		 
 /* shift group */
-#define SX_SRLV 	(0 << 21)	/* shift right logical, by vector */
-#define SX_SRLI 	(1 << 21)	/* shift right logical, by immediate */
-#define SX_SRAV 	(2 << 21)	/* shift right arithmetic, by vector */
-#define SX_SRAI 	(3 << 21)	/* shift right arithmetic, by immediate */
-#define SX_SLLV 	(4 << 21)	/* shift left logical, by vector */
-#define SX_SLLI 	(5 << 21)	/* shift left logical, by immediate */
-#define SX_SLFS 	(6 << 21)	/* shift left funnel, by SRCB */
-#define SX_SLFI 	(7 << 21)	/* shift left funnel, by immediate */
+#define SX_SRL_V 	(0 << 21)	/* shift right logical, by vector */
+#define SX_SRL_I 	(1 << 21)	/* shift right logical, by immediate */
+#define SX_SRA_V 	(2 << 21)	/* shift right arithmetic, by vector */
+#define SX_SRA_I 	(3 << 21)	/* shift right arithmetic, by immediate */
+#define SX_SLL_V 	(4 << 21)	/* shift left logical, by vector */
+#define SX_SLL_I 	(5 << 21)	/* shift left logical, by immediate */
+#define SX_SLF_S 	(6 << 21)	/* shift left funnel, by SRCB */
+#define SX_SLF_I 	(7 << 21)	/* shift left funnel, by immediate */
 
-#define SX_SRL_V(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRLV | \
+#define SX_SRLV(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRL_V | \
 		  ((sa) << 14) | ((d) << 7) | (sb))
-#define SX_SRL_I(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRLI | \
+#define SX_SRLI(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRL_I | \
 		  ((sa) << 14) | ((d) << 7) | (sb))
-#define SX_SRA_V(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRAV | \
+#define SX_SRAV(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRA_V | \
 		  ((sa) << 14) | ((d) << 7) | (sb))
-#define SX_SRA_I(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRAI | \
+#define SX_SRAI(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRA_I | \
 		  ((sa) << 14) | ((d) << 7) | (sb))
-#define SX_SLL_V(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLLV | \
+#define SX_SLLV(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLL_V | \
 		  ((sa) << 14) | ((d) << 7) | (sb))
-#define SX_SLL_I(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLLI | \
+#define SX_SLLI(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLL_I | \
 		  ((sa) << 14) | ((d) << 7) | (sb))
-#define SX_FUNNEL_S(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLFS | \
+#define SX_FUNNEL_S(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLF_S | \
 		  ((sa) << 14) | ((d) << 7) | (sb))
-#define SX_FUNNEL_I(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLFI | \
+#define SX_FUNNEL_I(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLF_I | \
 		  ((sa) << 14) | ((d) << 7) | 

CVS commit: src/sys/arch/sparc/dev

2021-12-08 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec  8 17:03:38 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
be more consistent with underscores in instruction names


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2021-12-08 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec  8 16:40:14 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add SX_ROPB instruction


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.18 src/sys/arch/sparc/dev/sxreg.h:1.19
--- src/sys/arch/sparc/dev/sxreg.h:1.18	Fri Dec  3 22:41:18 2021
+++ src/sys/arch/sparc/dev/sxreg.h	Wed Dec  8 16:40:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.18 2021/12/03 22:41:18 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.19 2021/12/08 16:40:14 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -262,6 +262,8 @@
 
 #define SX_ROP(sa, sb, d, cnt) (0x9000 | ((cnt) << 24) | SX_ROPL | \
 		((sa) << 14) | (sb) | ((d) << 7))
+#define SX_ROPB(sa, sb, d, cnt) (0x9000 | ((cnt) << 24) | SX_ROPB | \
+		((sa) << 14) | (sb) | ((d) << 7))
 #define SX_SELECT_S(sa, sb, d, cnt) (0x9000 | ((cnt) << 24) | SX_SELS | \
 		((sa) << 14) | (sb) | ((d) << 7))
 



CVS commit: src/sys/arch/sparc/dev

2021-12-08 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Dec  8 16:40:14 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add SX_ROPB instruction


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2021-12-04 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Dec  4 13:34:35 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: pckbc_js.c

Log Message:
s/establised/established/ in struct variable name. Also fixed typos in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sparc/dev/pckbc_js.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/sparc/dev/pckbc_js.c
diff -u src/sys/arch/sparc/dev/pckbc_js.c:1.20 src/sys/arch/sparc/dev/pckbc_js.c:1.21
--- src/sys/arch/sparc/dev/pckbc_js.c:1.20	Sun Nov 22 03:55:33 2020
+++ src/sys/arch/sparc/dev/pckbc_js.c	Sat Dec  4 13:34:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pckbc_js.c,v 1.20 2020/11/22 03:55:33 thorpej Exp $ */
+/*	$NetBSD: pckbc_js.c,v 1.21 2021/12/04 13:34:35 andvar Exp $ */
 
 /*
  * Copyright (c) 2002 Valeriy E. Ushakov
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pckbc_js.c,v 1.20 2020/11/22 03:55:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbc_js.c,v 1.21 2021/12/04 13:34:35 andvar Exp $");
 
 #include 
 #include 
@@ -52,7 +52,7 @@ struct pckbc_js_softc {
 
 	/* kbd and mouse share interrupt in both mr.coffee and krups */
 	uint32_t jsc_intr;
-	int jsc_establised;
+	int jsc_established;
 	void *jsc_int_cookie;
 };
 
@@ -165,7 +165,7 @@ pckbc_js_attach_common(struct pckbc_js_s
 
 	jsc->jsc_pckbc.intr_establish = pckbc_js_intr_establish;
 	jsc->jsc_intr = intr;
-	jsc->jsc_establised = 0;
+	jsc->jsc_established = 0;
 
 	if (isconsole) {
 		int status;
@@ -238,7 +238,7 @@ pckbc_js_intr_establish(struct pckbc_sof
 	struct pckbc_js_softc *jsc = (struct pckbc_js_softc *)sc;
 	void *res;
 
-	if (jsc->jsc_establised) {
+	if (jsc->jsc_established) {
 #ifdef DEBUG
 		aprint_verbose_dev(sc->sc_dv,
 		"%s slot shares interrupt (already established)\n",
@@ -248,7 +248,7 @@ pckbc_js_intr_establish(struct pckbc_sof
 	}
 
 	/*
-	 * We can not choose the devic class interruptlevel freely,
+	 * We can not choose the device class interrupt level freely,
 	 * so we debounce via a softinterrupt.
 	 */
 	jsc->jsc_int_cookie = softint_establish(SOFTINT_SERIAL,
@@ -266,7 +266,7 @@ pckbc_js_intr_establish(struct pckbc_sof
 		"unable to establish %s slot interrupt\n",
 		pckbc_slot_names[slot]);
 	else
-		jsc->jsc_establised = 1;
+		jsc->jsc_established = 1;
 }
 
 static int



CVS commit: src/sys/arch/sparc/dev

2021-12-04 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Dec  4 13:34:35 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: pckbc_js.c

Log Message:
s/establised/established/ in struct variable name. Also fixed typos in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sparc/dev/pckbc_js.c

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



CVS commit: src/sys/arch/sparc/dev

2021-12-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Dec  3 22:41:18 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add shift instructions


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.17 src/sys/arch/sparc/dev/sxreg.h:1.18
--- src/sys/arch/sparc/dev/sxreg.h:1.17	Fri Feb 22 23:01:25 2019
+++ src/sys/arch/sparc/dev/sxreg.h	Fri Dec  3 22:41:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.17 2019/02/22 23:01:25 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.18 2021/12/03 22:41:18 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -225,6 +225,8 @@
 SX_UBYTE_0 | (sreg << 7) | (o))
 #define SX_STP(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE | \
 SX_PACKED | (sreg << 7) | (o))
+#define SX_STPS(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE_SELECT | \
+SX_PACKED | (sreg << 7) | (o))
 #define SX_STS(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE_SELECT \
 | SX_LONG | (sreg << 7) | (o))
 #define SX_STBS(reg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE_SELECT \
@@ -344,5 +346,32 @@
 		 ((sa) << 14) | ((d) << 7) | (sb))
 #define SX_SCATTER(sa, sb, d, cnt) (0xe000 | ((cnt) << 24) | SX_SCTR | \
 		 ((sa) << 14) | ((d) << 7) | (sb))
+		 
+/* shift group */
+#define SX_SRLV 	(0 << 21)	/* shift right logical, by vector */
+#define SX_SRLI 	(1 << 21)	/* shift right logical, by immediate */
+#define SX_SRAV 	(2 << 21)	/* shift right arithmetic, by vector */
+#define SX_SRAI 	(3 << 21)	/* shift right arithmetic, by immediate */
+#define SX_SLLV 	(4 << 21)	/* shift left logical, by vector */
+#define SX_SLLI 	(5 << 21)	/* shift left logical, by immediate */
+#define SX_SLFS 	(6 << 21)	/* shift left funnel, by SRCB */
+#define SX_SLFI 	(7 << 21)	/* shift left funnel, by immediate */
+
+#define SX_SRL_V(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRLV | \
+		  ((sa) << 14) | ((d) << 7) | (sb))
+#define SX_SRL_I(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRLI | \
+		  ((sa) << 14) | ((d) << 7) | (sb))
+#define SX_SRA_V(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRAV | \
+		  ((sa) << 14) | ((d) << 7) | (sb))
+#define SX_SRA_I(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SRAI | \
+		  ((sa) << 14) | ((d) << 7) | (sb))
+#define SX_SLL_V(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLLV | \
+		  ((sa) << 14) | ((d) << 7) | (sb))
+#define SX_SLL_I(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLLI | \
+		  ((sa) << 14) | ((d) << 7) | (sb))
+#define SX_FUNNEL_S(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLFS | \
+		  ((sa) << 14) | ((d) << 7) | (sb))
+#define SX_FUNNEL_I(sa, sb, d, cnt) (0xc000 | ((cnt) << 24) | SX_SLFI | \
+		  ((sa) << 14) | ((d) << 7) | (sb))
 
 #endif /* SXREG_H */



CVS commit: src/sys/arch/sparc/dev

2021-12-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Dec  3 22:41:18 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add shift instructions


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2021-06-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Jun 11 04:58:30 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: ts102.c

Log Message:
During slot enable and disable, make sure that the card Access and VCC
controls are enabled and disabled at the same time.
Also remove the software reset during slot enable (we are already in
reset because of the earlier Access and VCC changes).
While here, convert DELAY() to delay() and tsleep(), like nell(4).


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/dev/ts102.c

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



CVS commit: src/sys/arch/sparc/dev

2021-06-10 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Jun 11 04:58:30 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: ts102.c

Log Message:
During slot enable and disable, make sure that the card Access and VCC
controls are enabled and disabled at the same time.
Also remove the software reset during slot enable (we are already in
reset because of the earlier Access and VCC changes).
While here, convert DELAY() to delay() and tsleep(), like nell(4).


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/dev/ts102.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/sparc/dev/ts102.c
diff -u src/sys/arch/sparc/dev/ts102.c:1.19 src/sys/arch/sparc/dev/ts102.c:1.20
--- src/sys/arch/sparc/dev/ts102.c:1.19	Sat Apr 24 23:36:49 2021
+++ src/sys/arch/sparc/dev/ts102.c	Fri Jun 11 04:58:30 2021
@@ -1,5 +1,5 @@
 /*	$OpenBSD: ts102.c,v 1.14 2005/01/27 17:03:23 millert Exp $	*/
-/*	$NetBSD: ts102.c,v 1.19 2021/04/24 23:36:49 thorpej Exp $ */
+/*	$NetBSD: ts102.c,v 1.20 2021/06/11 04:58:30 jdc Exp $ */
 /*
  * Copyright (c) 2003, 2004, Miodrag Vallat.
  * Copyright (c) 2005, Michael Lorenz.
@@ -182,6 +182,7 @@ static void tslot_slot_intr(struct tslot
 static void tslot_slot_settype(pcmcia_chipset_handle_t, int);
 static void tslot_update_lcd(struct tslot_softc *, int, int);
 static void tslot_intr_dispatch(void *arg);
+void tslot_delay(struct tslot_softc *sc, unsigned int ms);
 
 CFATTACH_DECL_NEW(tslot, sizeof(struct tslot_softc),
 tslot_match, tslot_attach, NULL, NULL);
@@ -620,22 +621,35 @@ static void
 tslot_slot_disable(pcmcia_chipset_handle_t pch)
 {
 	struct tslot_data *td = (struct tslot_data *)pch;
+	int status;
+
 #ifdef TSLOT_DEBUG
 	printf("%s: disable slot %d\n",
 	device_xname(td->td_parent->sc_dev), td->td_slot);
 #endif
 
-	/*
-	 * Disable card access.
-	 */
-	TSLOT_WRITE(td, TS102_REG_CARD_A_STS,
-	TSLOT_READ(td, TS102_REG_CARD_A_STS) & ~TS102_CARD_STS_ACEN);
+	status = TSLOT_READ(td, TS102_REG_CARD_A_STS);
+
+	status &= ~TS102_CARD_STS_ACEN;
 
 	/*
 	 * Disable interrupts, except for insertion.
 	 */
 	TSLOT_WRITE(td, TS102_REG_CARD_A_INT,
 	TS102_CARD_INT_MASK_CARDDETECT_STATUS);
+
+	/*
+	 * Power down the socket and disable access
+	 */
+	status &= ~TS102_CARD_STS_ACEN;
+	status &= ~(TS102_CARD_STS_VPP1_MASK | TS102_CARD_STS_VPP2_MASK);
+	status |= TS102_CARD_STS_VCCEN;
+	TSLOT_WRITE(td, TS102_REG_CARD_A_STS, status);
+	
+	/*
+	 * wait 300ms until power fails (Tpf).
+	 */
+	tslot_delay(td->td_parent, 300);
 }
 
 static void
@@ -652,18 +666,23 @@ tslot_slot_enable(pcmcia_chipset_handle_
 	/* Power down the socket to reset it */
 	status = TSLOT_READ(td, TS102_REG_CARD_A_STS);
 	TSPRINTF("status: %x\n", status);
-	TSLOT_WRITE(td, TS102_REG_CARD_A_STS, status | TS102_CARD_STS_VCCEN);
+
+	status &= ~TS102_CARD_STS_ACEN;
+	status &= ~(TS102_CARD_STS_VPP1_MASK | TS102_CARD_STS_VPP2_MASK);
+	status |= TS102_CARD_STS_VCCEN;
+	TSLOT_WRITE(td, TS102_REG_CARD_A_STS, status);
 
 	/*
 	 * wait 300ms until power fails (Tpf).  Then, wait 100ms since we
 	 * are changing Vcc (Toff).
 	 */
-	DELAY((300 + 100) * 1000);
+	tslot_delay(td->td_parent, 300 + 100);
 
 	/*
 	 * Power on the card if not already done, and enable card access
 	 */
 	status |= TS102_CARD_STS_ACEN;
+	status |= TS102_CARD_STS_VPP1_VCC;
 	status &= ~TS102_CARD_STS_VCCEN;
 	TSLOT_WRITE(td, TS102_REG_CARD_A_STS, status);
 
@@ -671,22 +690,18 @@ tslot_slot_enable(pcmcia_chipset_handle_
 	 * wait 100ms until power raise (Tpr) and 20ms to become
 	 * stable (Tsu(Vcc)).
 	 */
-	DELAY((100 + 20) * 1000);
-
-	status &= ~TS102_CARD_STS_VPP1_MASK;
-	status |= TS102_CARD_STS_VPP1_VCC;
-	TSLOT_WRITE(td, TS102_REG_CARD_A_STS, status);
+	tslot_delay(td->td_parent, 100 + 20);
 
 	/*
 	 * hold RESET at least 20us.
 	 */
 	intr = TSLOT_READ(td, TS102_REG_CARD_A_INT);
-	TSLOT_WRITE(td, TS102_REG_CARD_A_INT, TS102_CARD_INT_SOFT_RESET);
-	DELAY(20);
-	TSLOT_WRITE(td, TS102_REG_CARD_A_INT, intr);
+	delay(20);
+	TSLOT_WRITE(td, TS102_REG_CARD_A_INT,
+	intr & ~TS102_CARD_INT_SOFT_RESET);
 
 	/* wait 20ms as per pc card standard (r2.01) section 4.3.6 */
-	DELAY(20 * 1000);
+	tslot_delay(td->td_parent, 20);
 
 	/* We need level-triggered interrupts for PC Card hardware */
 	TSLOT_WRITE(td, TS102_REG_CARD_A_STS,
@@ -709,7 +724,7 @@ tslot_slot_enable(pcmcia_chipset_handle_
 		if (status & TS102_CARD_STS_RDY)
 			break;
 		else
-			DELAY(100);
+			delay(100);
 	}
 
 	if (i == 0) {
@@ -1020,3 +1035,24 @@ tslot_update_lcd(struct tslot_softc *sc,
 	}
 #endif
 }
+
+/*
+ * Delay and possibly yield CPU.
+ * XXX - assumes a context
+ */
+void
+tslot_delay(struct tslot_softc *sc, unsigned int ms)
+{
+	unsigned int ticks = mstohz(ms);
+
+	if (cold || ticks == 0) {
+		delay(ms);
+		return;
+	}
+
+#ifdef DIAGNOSTIC
+	if (ticks > 60*hz)
+		panic("tslot: preposterous delay: %u", ticks);
+#endif
+	tsleep(sc, 0, "tslotdel", ticks);

CVS commit: src/sys/arch/sparc/dev

2021-01-04 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  4 15:29:34 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: tctrl.c

Log Message:
Use sel{record,remove}_knote().


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/sparc/dev/tctrl.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/sparc/dev/tctrl.c
diff -u src/sys/arch/sparc/dev/tctrl.c:1.62 src/sys/arch/sparc/dev/tctrl.c:1.63
--- src/sys/arch/sparc/dev/tctrl.c:1.62	Sat Jun 13 05:31:28 2020
+++ src/sys/arch/sparc/dev/tctrl.c	Mon Jan  4 15:29:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tctrl.c,v 1.62 2020/06/13 05:31:28 jdc Exp $	*/
+/*	$NetBSD: tctrl.c,v 1.63 2021/01/04 15:29:34 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.62 2020/06/13 05:31:28 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.63 2021/01/04 15:29:34 thorpej Exp $");
 
 #include 
 #include 
@@ -1218,7 +1218,7 @@ filt_tctrlrdetach(struct knote *kn)
 	int s;
 
 	s = splts102();
-	SLIST_REMOVE(>sc_rsel.sel_klist, kn, knote, kn_selnext);
+	selremove_knote(>sc_rsel, kn);
 	splx(s);
 }
 
@@ -1243,12 +1243,10 @@ tctrlkqfilter(dev_t dev, struct knote *k
 {
 	struct tctrl_softc *sc = device_lookup_private(_cd,
 		   TCTRL_STD_DEV);
-	struct klist *klist;
 	int s;
 
 	switch (kn->kn_filter) {
 	case EVFILT_READ:
-		klist = >sc_rsel.sel_klist;
 		kn->kn_fop = _filtops;
 		break;
 
@@ -1259,7 +1257,7 @@ tctrlkqfilter(dev_t dev, struct knote *k
 	kn->kn_hook = sc;
 
 	s = splts102();
-	SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+	selrecord_knote(>sc_rsel, kn);
 	splx(s);
 
 	return (0);



CVS commit: src/sys/arch/sparc/dev

2021-01-04 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  4 15:29:34 UTC 2021

Modified Files:
src/sys/arch/sparc/dev: tctrl.c

Log Message:
Use sel{record,remove}_knote().


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/sparc/dev/tctrl.c

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



CVS commit: src/sys/arch/sparc/dev

2020-06-12 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Jun 13 05:31:29 UTC 2020

Modified Files:
src/sys/arch/sparc/dev: tctrl.c

Log Message:
Initialise the mutex before we use it.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sparc/dev/tctrl.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/sparc/dev/tctrl.c
diff -u src/sys/arch/sparc/dev/tctrl.c:1.61 src/sys/arch/sparc/dev/tctrl.c:1.62
--- src/sys/arch/sparc/dev/tctrl.c:1.61	Wed Oct 25 08:12:37 2017
+++ src/sys/arch/sparc/dev/tctrl.c	Sat Jun 13 05:31:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tctrl.c,v 1.61 2017/10/25 08:12:37 maya Exp $	*/
+/*	$NetBSD: tctrl.c,v 1.62 2020/06/13 05:31:28 jdc Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.61 2017/10/25 08:12:37 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.62 2020/06/13 05:31:28 jdc Exp $");
 
 #include 
 #include 
@@ -260,6 +260,8 @@ tctrl_attach(device_t parent, device_t s
 
 	sc->sc_tft_on = 1;
 
+	mutex_init(>sc_requestlock, MUTEX_DEFAULT, IPL_NONE);
+
 	/* clear any pending data.
 	 */
 	for (i = 0; i < 1; i++) {
@@ -312,7 +314,6 @@ tctrl_attach(device_t parent, device_t s
 	sc->sc_ext_pending = 0;
 		sc->sc_ext_pending = 0;
 
-	mutex_init(>sc_requestlock, MUTEX_DEFAULT, IPL_NONE);
 	selinit(>sc_rsel);
 
 	/* setup sensors and register the power button */



CVS commit: src/sys/arch/sparc/dev

2020-06-12 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Jun 13 05:31:29 UTC 2020

Modified Files:
src/sys/arch/sparc/dev: tctrl.c

Log Message:
Initialise the mutex before we use it.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sparc/dev/tctrl.c

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



CVS commit: src/sys/arch/sparc/dev

2020-01-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jan  2 22:32:20 UTC 2020

Modified Files:
src/sys/arch/sparc/dev: rtc.c

Log Message:
- Use todr_gettime_ymdhms / todr_settime_ymdhms.
- Allocate the todr_handle with the softc, not separately.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/dev/rtc.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/sparc/dev/rtc.c
diff -u src/sys/arch/sparc/dev/rtc.c:1.19 src/sys/arch/sparc/dev/rtc.c:1.20
--- src/sys/arch/sparc/dev/rtc.c:1.19	Sun Nov 10 21:16:32 2019
+++ src/sys/arch/sparc/dev/rtc.c	Thu Jan  2 22:32:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtc.c,v 1.19 2019/11/10 21:16:32 chs Exp $ */
+/*	$NetBSD: rtc.c,v 1.20 2020/01/02 22:32:20 thorpej Exp $ */
 
 /*
  * Copyright (c) 2001 Valeriy E. Ushakov
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.19 2019/11/10 21:16:32 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.20 2020/01/02 22:32:20 thorpej Exp $");
 
 #include 
 #include 
@@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.19
 struct rtc_ebus_softc {
 	bus_space_tag_t		sc_bt;	/* parent bus tag */
 	bus_space_handle_t	sc_bh;	/* handle for registers */
+	struct todr_chip_handle	sc_todr;/* TODR handle */
 };
 
 static int	rtcmatch_ebus(device_t, cfdata_t, void *);
@@ -65,16 +66,12 @@ static void	rtcattach_ebus(device_t, dev
 CFATTACH_DECL_NEW(rtc_ebus, sizeof(struct rtc_ebus_softc),
 rtcmatch_ebus, rtcattach_ebus, NULL, NULL);
 
-/* XXX: global TOD clock handle (sparc/clock.c) */
-extern todr_chip_handle_t todr_handle;
-
 /* todr(9) methods */
-static int rtc_gettime(todr_chip_handle_t, struct timeval *);
-static int rtc_settime(todr_chip_handle_t, struct timeval *);
+static int rtc_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
+static int rtc_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
 
 int rtc_auto_century_adjust = 1; /* XXX: do we ever want not to? */
 
-
 /*
  * MD read/write functions declared in mc146818reg.h
  */
@@ -134,27 +131,23 @@ rtcattach_ebus(device_t parent, device_t
 	mc146818_write(sc, MC_REGB, MC_REGB_BINARY | MC_REGB_24HR);
 
 	/* setup our todr_handle */
-	handle = malloc(ALIGN(sizeof(struct todr_chip_handle)),
-			M_DEVBUF, M_WAITOK);
+	handle = >sc_todr;
 	handle->cookie = sc;
 	handle->bus_cookie = NULL; /* unused */
-	handle->todr_gettime = rtc_gettime;
-	handle->todr_settime = rtc_settime;
+	handle->todr_gettime = NULL;
+	handle->todr_settime = NULL;
+	handle->todr_gettime_ymdhms = rtc_gettime_ymdhms;
+	handle->todr_settime_ymdhms = rtc_settime_ymdhms;
 	handle->todr_setwen = NULL; /* not necessary, no idprom to protect */
 
 	todr_attach(handle);
 }
 
 
-/*
- * Get time-of-day and convert to a `struct timeval'
- * Return 0 on success; an error number otherwise.
- */
 static int
-rtc_gettime(todr_chip_handle_t handle, struct timeval *tv)
+rtc_gettime_ymdhms(todr_chip_handle_t handle, struct clock_ymdhms *dt)
 {
 	struct rtc_ebus_softc *sc = handle->cookie;
-	struct clock_ymdhms dt;
 	u_int year;
 
 	/* update in progress; spin loop */
@@ -166,12 +159,12 @@ rtc_gettime(todr_chip_handle_t handle, s
 		   (mc146818_read(sc, MC_REGB) | MC_REGB_SET));
 
 	/* read time */
-	dt.dt_sec  = mc146818_read(sc, MC_SEC);
-	dt.dt_min  = mc146818_read(sc, MC_MIN);
-	dt.dt_hour = mc146818_read(sc, MC_HOUR);
-	dt.dt_day  = mc146818_read(sc, MC_DOM);
-	dt.dt_mon  = mc146818_read(sc, MC_MONTH);
-	year   = mc146818_read(sc, MC_YEAR);
+	dt->dt_sec  = mc146818_read(sc, MC_SEC);
+	dt->dt_min  = mc146818_read(sc, MC_MIN);
+	dt->dt_hour = mc146818_read(sc, MC_HOUR);
+	dt->dt_day  = mc146818_read(sc, MC_DOM);
+	dt->dt_mon  = mc146818_read(sc, MC_MONTH);
+	year= mc146818_read(sc, MC_YEAR);
 
 	/* reenable updates */
 	mc146818_write(sc, MC_REGB,
@@ -181,32 +174,18 @@ rtc_gettime(todr_chip_handle_t handle, s
 	year += 1900;
 	if (year < POSIX_BASE_YEAR && rtc_auto_century_adjust != 0)
 		year += 100;
-	dt.dt_year = year;
+	dt->dt_year = year;
 
-	/* simple sanity checks */
-	if (dt.dt_mon > 12 || dt.dt_day > 31
-	|| dt.dt_hour >= 24 || dt.dt_min >= 60 || dt.dt_sec >= 60)
-		return (ERANGE);
-
-	tv->tv_sec = clock_ymdhms_to_secs();
-	tv->tv_usec = 0;
 	return (0);
 }
 
-/*
- * Set the time-of-day clock based on the value of the `struct timeval' arg.
- * Return 0 on success; an error number otherwise.
- */
 static int
-rtc_settime(todr_chip_handle_t handle, struct timeval *tv)
+rtc_settime_ymdhms(todr_chip_handle_t handle, struct clock_ymdhms *dt)
 {
 	struct rtc_ebus_softc *sc = handle->cookie;
-	struct clock_ymdhms dt;
 	u_int year;
 
-	clock_secs_to_ymdhms(tv->tv_sec, );
-
-	year = dt.dt_year - 1900;
+	year = dt->dt_year - 1900;
 	if (year >= 100 && rtc_auto_century_adjust != 0)
 		year -= 100;
 
@@ -214,12 +193,12 @@ rtc_settime(todr_chip_handle_t handle, s
 	mc146818_write(sc, MC_REGB,
 		   (mc146818_read(sc, 

CVS commit: src/sys/arch/sparc/dev

2020-01-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jan  2 22:32:20 UTC 2020

Modified Files:
src/sys/arch/sparc/dev: rtc.c

Log Message:
- Use todr_gettime_ymdhms / todr_settime_ymdhms.
- Allocate the todr_handle with the softc, not separately.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/dev/rtc.c

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



CVS commit: src/sys/arch/sparc/dev

2019-08-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Aug 11 06:04:16 UTC 2019

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
remove orphaned comment


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2019-08-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Aug 11 06:04:16 UTC 2019

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
remove orphaned comment


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.87 src/sys/arch/sparc/dev/cgfourteen.c:1.88
--- src/sys/arch/sparc/dev/cgfourteen.c:1.87	Thu Jan 17 23:05:15 2019
+++ src/sys/arch/sparc/dev/cgfourteen.c	Sun Aug 11 06:04:16 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.87 2019/01/17 23:05:15 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.88 2019/08/11 06:04:16 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -59,13 +59,6 @@
  * XXX should defer colormap updates to vertical retrace interrupts
  */
 
-/*
- * The following is for debugging only; it opens up a security hole
- * enabled by allowing any user to map the control registers for the
- * cg14 into their space.
- */
-#undef CG14_MAP_REGS
-
 #include "opt_wsemul.h"
 #include "sx.h"
 



CVS commit: src/sys/arch/sparc/dev

2019-02-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Mar  1 02:30:42 UTC 2019

Modified Files:
src/sys/arch/sparc/dev: sx.c sxvar.h

Log Message:
adapt to changes in sxreg.h


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc/dev/sx.c \
src/sys/arch/sparc/dev/sxvar.h

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



CVS commit: src/sys/arch/sparc/dev

2019-02-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Mar  1 02:30:42 UTC 2019

Modified Files:
src/sys/arch/sparc/dev: sx.c sxvar.h

Log Message:
adapt to changes in sxreg.h


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc/dev/sx.c \
src/sys/arch/sparc/dev/sxvar.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/sparc/dev/sx.c
diff -u src/sys/arch/sparc/dev/sx.c:1.3 src/sys/arch/sparc/dev/sx.c:1.4
--- src/sys/arch/sparc/dev/sx.c:1.3	Tue Apr 15 10:24:54 2014
+++ src/sys/arch/sparc/dev/sx.c	Fri Mar  1 02:30:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sx.c,v 1.3 2014/04/15 10:24:54 macallan Exp $	*/
+/*	$NetBSD: sx.c,v 1.4 2019/03/01 02:30:42 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sx.c,v 1.3 2014/04/15 10:24:54 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sx.c,v 1.4 2019/03/01 02:30:42 macallan Exp $");
 
 #include "locators.h"
 
@@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: sx.c,v 1.3 2
 #include 
 #include 
 #include 
+#include "opt_sx.h"
 
 /* autoconfiguration driver */
 static	int sx_match(device_t, struct cfdata *, void *);
@@ -57,6 +58,8 @@ static	void sx_attach(device_t, device_t
 CFATTACH_DECL_NEW(sx, sizeof(struct sx_softc),
 sx_match, sx_attach, NULL, NULL);
 
+static struct sx_softc *sx0 = NULL;
+
 static int
 sx_match(device_t parent, struct cfdata *cf, void *aux)
 {
@@ -90,7 +93,7 @@ sx_attach(device_t parent, device_t self
 	id = sx_read(sc, SX_ID);
 	aprint_normal_dev(self, "architecture rev. %d chip rev. %d\n",
 	(id & SX_ARCHITECTURE_MASK),
-	(id & SX_CHIP_REVISION) >> 8);
+	(id & SX_CHIP_REVISION) >> 3);
 
 	/* stop the processor */
 	sx_write(sc, SX_CONTROL_STATUS, 0);
@@ -114,6 +117,8 @@ sx_attach(device_t parent, device_t self
 	/* ... and start the processor again */
 	sx_write(sc, SX_CONTROL_STATUS, SX_PB | SX_GO);
 
+	sx0 = sc;
+
 #ifdef SX_DEBUG
 	sta(0xfc00, ASI_SX, SX_LD(8, 31, 0));
 	for (i = 1; i < 60; i++)
@@ -143,3 +148,15 @@ sx_attach(device_t parent, device_t self
 #endif
 }
 
+void
+sx_dump(void)
+{
+	if (sx0 == NULL)
+		return;
+	printf("SX STATUS: %08x\n",
+	bus_space_read_4(sx0->sc_tag, sx0->sc_regh, SX_CONTROL_STATUS));
+	printf("SX ERROR : %08x\n",
+	bus_space_read_4(sx0->sc_tag, sx0->sc_regh, SX_ERROR));
+	printf("SX DIAG  : %08x\n",
+	bus_space_read_4(sx0->sc_tag, sx0->sc_regh, SX_DIAGNOSTICS));
+}
Index: src/sys/arch/sparc/dev/sxvar.h
diff -u src/sys/arch/sparc/dev/sxvar.h:1.3 src/sys/arch/sparc/dev/sxvar.h:1.4
--- src/sys/arch/sparc/dev/sxvar.h:1.3	Sun Jun 29 03:57:10 2014
+++ src/sys/arch/sparc/dev/sxvar.h	Fri Mar  1 02:30:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxvar.h,v 1.3 2014/06/29 03:57:10 tsutsui Exp $	*/
+/*	$NetBSD: sxvar.h,v 1.4 2019/03/01 02:30:42 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -51,4 +51,6 @@ sx_read(struct sx_softc *sc, int addr)
 	return bus_space_read_4(sc->sc_tag, sc->sc_regh, addr);
 }
 
+void sx_dump(void);
+
 #endif



CVS commit: src/sys/arch/sparc/dev

2019-02-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Feb 22 23:01:25 UTC 2019

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
some register bits are defined differently by SunOS's sxreg.h and the SPAM
manual, upon investigation the hardware appears to agree with the SunOS header,
so adapt accordingly


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2019-02-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Feb 22 23:01:25 UTC 2019

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
some register bits are defined differently by SunOS's sxreg.h and the SPAM
manual, upon investigation the hardware appears to agree with the SunOS header,
so adapt accordingly


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.16 src/sys/arch/sparc/dev/sxreg.h:1.17
--- src/sys/arch/sparc/dev/sxreg.h:1.16	Fri Dec  8 22:28:54 2017
+++ src/sys/arch/sparc/dev/sxreg.h	Fri Feb 22 23:01:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.16 2017/12/08 22:28:54 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.17 2019/02/22 23:01:25 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -47,6 +47,8 @@
 #define SX_ID			0x0028
 #define SX_R0_INIT		0x002c
 #define SX_SOFTRESET		0x0030
+#define SX_SYNC			0x0034	/* write will stall CPU until */
+		/* SX is idle		  */
 /* write registers directly, only when processor is stopped */
 #define SX_DIRECT_R0		0x0100
 #define SX_DIRECT_R1		0x0104	/* and so on until R127 */
@@ -73,10 +75,39 @@
 #define SX_EE5		0x0010	/* alignment violation */
 #define SX_EE6		0x0020	/* illegal instruction queue write */
 #define SX_EI		0x0080	/* interrupt on error */
+/*
+ * XXX
+ * the following bit definitions are from the SX manual. They're defined in a
+ * different way in SunOS's sxreg.h, the hardware seems to follow the latter.
+ */
+#if 0
 #define SX_PB		0x1000	/* enable page bound checking */
 #define SX_WO		0x2000	/* write occured ( by SX ) */
 #define SX_GO		0x4000	/* start/stop the processor */
 #define SX_MT		0x8000	/* instruction queue is empty */
+#endif
+
+#define SX_PB		0x0400	/* enable page bound checking */
+#define SX_WO		0x0800	/* write occured ( by SX ) */
+#define SX_GO		0x1000	/* start/stop the processor */
+#define SX_JB		0x2000	/* Jammed/Busy specifies the type of events */
+	/* which increment the SX timer */
+#define SX_MT		0x4000	/* instruction queue is empty */
+#define SX_BZ		0x8000	/* Busy bit. When set it indicates that SX */
+	/* is processing an instruction or an */
+	/* instruction is pending in the Q  */
+#define SX_B0MOD	0x0001	/* When set by SX it indicates that a write */
+	/* to bank zero of the SX registers (0-31) */
+	/* occured */
+#define SX_B1MOD	0x0002	/* When set by SX it indicates that a write */
+	/* to bank 1 of the SX registers (32-63) */
+	/* occured */
+#define SX_B2MOD	0x0004	/* When set by SX it indicates that a write */
+	/* to bank 2 of the SX registers (64-95) */
+	/* occured */
+#define SX_B3MOD	0x0008	/* When set by SX it indicates that a write */
+	/* to bank 3 of the SX registers (96-127) */
+	/* occured */
 
 /* SX_ERROR */
 #define SX_SE1		0x0001	/* illegal instruction */
@@ -87,13 +118,29 @@
 #define SX_SE6		0x0020	/* illegal instruction queue write */
 #define SX_SI		0x0080	/* interrupt on error */
 
-/* SX_ID */
+/* SX_ID from the manual */
+#if 0
 #define SX_ARCHITECTURE_MASK	0x00ff
 #define SX_CHIP_REVISION	0xff00
+#endif
+
+#define SX_ARCHITECTURE_MASK	0x0003
+#define SX_CHIP_REVISION	0x00f8
 
 /* SX_DIAGNOSTICS */
 #define SX_IQ_FIFO_ACCESS	0x0001	/* allow memory instructions
 		 * in SX_INSTRUCTIONS */
+#define SX_SERIAL_INSTRUCTIONS	0x0002	/* force inst. serializing */
+#define SX_RAM_PAGE_CROSS	0x0004	/* indicates page crossing */
+#define SX_ARRAY_CONSTRAINING	0x0008	/* When set constrains VRAM */
+		/* array offset effective */
+		/* address calculation  */
+#define SX_UPG_MPG_DISABLE	0x0010	/* When set, disables page */
+		/* cross input into ld/st */
+		/* state machines */
+#define SX_DIAG_INIT		0x4804		/* Setting of the diag reg */
+		/* upon reset */
+
 
 /*
  * memory referencing instructions are written to 0x8 + PA



CVS commit: src/sys/arch/sparc/dev

2019-01-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 17 23:05:15 UTC 2019

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
don't crash when we're not the console


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.86 src/sys/arch/sparc/dev/cgfourteen.c:1.87
--- src/sys/arch/sparc/dev/cgfourteen.c:1.86	Mon Sep  3 16:29:27 2018
+++ src/sys/arch/sparc/dev/cgfourteen.c	Thu Jan 17 23:05:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.86 2018/09/03 16:29:27 riastradh Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.87 2019/01/17 23:05:15 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -284,7 +284,7 @@ cgfourteenattach(device_t parent, device
 	if (sbus_bus_map(sa->sa_bustag, sa->sa_slot,
 			 sa->sa_offset,
 			 sa->sa_size,
-			 0 /*BUS_SPACE_MAP_LINEAR*/,
+			 BUS_SPACE_MAP_LINEAR,
 			 ) != 0) {
 		printf("%s: cannot map control registers\n",
 		device_xname(self));
@@ -744,7 +744,7 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 	sc->sc_gc.gc_blitcookie = sc;
 	sc->sc_gc.gc_rectfill = cg14_rectfill_a;
 	sc->sc_gc.gc_rop = 0xc;
-	if (is_cons) {
+
 		vcons_init_screen(>sc_vd, >sc_console_screen, 1,
 		);
 
@@ -770,21 +770,10 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 			ri->ri_font->fontwidth,
 			ri->ri_font->fontheight,
 			defattr);
+	if (is_cons) {
 		wsdisplay_cnattach(>sc_defaultscreen_descr, ri, 0, 0,
 		defattr);
 		vcons_replay_msgbuf(>sc_console_screen);
-	} else {
-		/*
-		 * since we're not the console we can postpone the rest
-		 * until someone actually allocates a screen for us
-		 */
-		glyphcache_init(>sc_gc, sc->sc_fb.fb_type.fb_height + 5,
-			(sc->sc_vramsize / sc->sc_fb.fb_type.fb_width) -
-			 sc->sc_fb.fb_type.fb_height - 5,
-			sc->sc_fb.fb_type.fb_width,
-			ri->ri_font->fontwidth,
-			ri->ri_font->fontheight,
-			DEFATTR);
 	}
 
 	cg14_init_cmap(sc);



CVS commit: src/sys/arch/sparc/dev

2019-01-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 17 23:05:15 UTC 2019

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
don't crash when we're not the console


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2018-01-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 25 14:45:58 UTC 2018

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
do boundary checks when writing cursor sprite colour registers


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2018-01-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 25 14:45:58 UTC 2018

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
do boundary checks when writing cursor sprite colour registers


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.84 src/sys/arch/sparc/dev/cgfourteen.c:1.85
--- src/sys/arch/sparc/dev/cgfourteen.c:1.84	Fri Jan 12 23:38:24 2018
+++ src/sys/arch/sparc/dev/cgfourteen.c	Thu Jan 25 14:45:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.84 2018/01/12 23:38:24 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.85 2018/01/25 14:45:58 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -1120,7 +1120,11 @@ cg14_do_cursor(struct cgfourteen_softc *
 	if (cur->which & WSDISPLAY_CURSOR_DOCMAP) {
 		int i;
 		uint32_t val;
-	
+
+		if ((cur->cmap.index > 2) || (cur->cmap.count > 3) ||
+		(cur->cmap.index + cur->cmap.count > 3))
+			return EINVAL;
+
 		for (i = 0; i < min(cur->cmap.count, 3); i++) {
 			val = (cur->cmap.red[i] ) |
 			  (cur->cmap.green[i] << 8) |



CVS commit: src/sys/arch/sparc/dev

2018-01-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jan 12 23:38:24 UTC 2018

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
enable font loading


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2018-01-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jan 12 23:38:24 UTC 2018

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
enable font loading


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.83 src/sys/arch/sparc/dev/cgfourteen.c:1.84
--- src/sys/arch/sparc/dev/cgfourteen.c:1.83	Sat Jan  6 07:26:54 2018
+++ src/sys/arch/sparc/dev/cgfourteen.c	Fri Jan 12 23:38:24 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.83 2018/01/06 07:26:54 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.84 2018/01/12 23:38:24 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -724,7 +724,8 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 		0, 0,
 		NULL,
 		8, 16,
-		WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE,
+		WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE |
+		WSSCREEN_RESIZE,
 		NULL
 	};
 	cg14_set_depth(sc, 8);
@@ -734,6 +735,8 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 	vcons_init(>sc_vd, sc, >sc_defaultscreen_descr,
 	_accessops);
 	sc->sc_vd.init_screen = cg14_init_screen;
+	sc->sc_vd.show_screen_cookie = >sc_gc;
+	sc->sc_vd.show_screen_cb = glyphcache_adapt;
 
 	ri = >sc_console_screen.scr_ri;
 
@@ -1009,6 +1012,8 @@ cg14_init_screen(void *cookie, struct vc
 	ri->ri_flg = RI_CENTER | RI_FULLCLEAR;
 
 	ri->ri_bits = (char *)sc->sc_fb.fb_pixels;
+
+	scr->scr_flags |= VCONS_LOADFONT;
 #if NSX > 0
 	ri->ri_flg |= RI_8BIT_IS_RGB | RI_ENABLE_ALPHA | RI_PREFER_ALPHA;
 
@@ -1020,14 +1025,15 @@ cg14_init_screen(void *cookie, struct vc
 		scr->scr_flags |= VCONS_NO_COPYCOLS;
 	} else
 #endif
-	scr->scr_flags |= VCONS_DONT_READ;
+		scr->scr_flags |= VCONS_DONT_READ;
 
 	if (existing) {
 		ri->ri_flg |= RI_CLEAR;
 	}
 
 	rasops_init(ri, 0, 0);
-	ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE;
+	ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE |
+		  WSSCREEN_RESIZE;
 
 	rasops_reconfig(ri,
 	sc->sc_fb.fb_type.fb_height / ri->ri_font->fontheight,



CVS commit: src/sys/arch/sparc/dev

2018-01-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Jan  6 07:26:54 UTC 2018

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
support underlines


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.82 src/sys/arch/sparc/dev/cgfourteen.c:1.83
--- src/sys/arch/sparc/dev/cgfourteen.c:1.82	Fri Sep 16 22:39:35 2016
+++ src/sys/arch/sparc/dev/cgfourteen.c	Sat Jan  6 07:26:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.82 2016/09/16 22:39:35 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.83 2018/01/06 07:26:54 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -163,6 +163,7 @@ static int  cg14_do_cursor(struct cgfour
 static void cg14_wait_idle(struct cgfourteen_softc *);
 static void cg14_rectfill(struct cgfourteen_softc *, int, int, int, int,
 uint32_t);
+static void cg14_rectfill_a(void *, int, int, int, int, long);
 static void cg14_invert(struct cgfourteen_softc *, int, int, int, int);
 static void cg14_bitblt(void *, int, int, int, int, int, int, int);
 static void cg14_bitblt_gc(void *, int, int, int, int, int, int, int);
@@ -723,7 +724,7 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 		0, 0,
 		NULL,
 		8, 16,
-		WSSCREEN_WSCOLORS | WSSCREEN_HILIT,
+		WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE,
 		NULL
 	};
 	cg14_set_depth(sc, 8);
@@ -738,6 +739,7 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 
 	sc->sc_gc.gc_bitblt = cg14_bitblt_gc;
 	sc->sc_gc.gc_blitcookie = sc;
+	sc->sc_gc.gc_rectfill = cg14_rectfill_a;
 	sc->sc_gc.gc_rop = 0xc;
 	if (is_cons) {
 		vcons_init_screen(>sc_vd, >sc_console_screen, 1,
@@ -1008,7 +1010,7 @@ cg14_init_screen(void *cookie, struct vc
 
 	ri->ri_bits = (char *)sc->sc_fb.fb_pixels;
 #if NSX > 0
-	ri->ri_flg |= RI_8BIT_IS_RGB | RI_ENABLE_ALPHA;
+	ri->ri_flg |= RI_8BIT_IS_RGB | RI_ENABLE_ALPHA | RI_PREFER_ALPHA;
 
 	/*
 	 * unaligned copies with horizontal overlap are slow, so don't bother
@@ -1025,7 +1027,7 @@ cg14_init_screen(void *cookie, struct vc
 	}
 
 	rasops_init(ri, 0, 0);
-	ri->ri_caps = WSSCREEN_WSCOLORS;
+	ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE;
 
 	rasops_reconfig(ri,
 	sc->sc_fb.fb_type.fb_height / ri->ri_font->fontheight,
@@ -1209,7 +1211,7 @@ cg14_rectfill(struct cgfourteen_softc *s
 			cnt -= pre;
 		}
 		/* now do the aligned pixels in 32bit chunks */
-		while(cnt > 31) {
+		while(cnt > 3) {
 			words = min(32, cnt >> 2);
 			sta(pptr & ~7, ASI_SX, SX_STS(8, words - 1, pptr & 7));
 			pptr += words << 2;
@@ -1223,6 +1225,16 @@ cg14_rectfill(struct cgfourteen_softc *s
 }
 
 static void
+cg14_rectfill_a(void *cookie, int dstx, int dsty,
+int width, int height, long attr)
+{
+	struct cgfourteen_softc *sc = cookie;
+
+	cg14_rectfill(sc, dstx, dsty, width, height,
+	sc->sc_vd.active->scr_ri.ri_devcmap[(attr >> 24 & 0xf)]);
+}
+
+static void
 cg14_invert(struct cgfourteen_softc *sc, int x, int y, int wi, int he)
 {
 	uint32_t addr, pptr;
@@ -1459,17 +1471,20 @@ cg14_putchar(void *cookie, int row, int 
 
 	bg = ri->ri_devcmap[(attr >> 16) & 0xf];
 	fg = ri->ri_devcmap[(attr >> 24) & 0xf];
-	sx_write(sc->sc_sx, SX_QUEUED(8), bg);
-	sx_write(sc->sc_sx, SX_QUEUED(9), fg);
 
 	x = ri->ri_xorigin + col * wi;
 	y = ri->ri_yorigin + row * he;
 
 	if (c == 0x20) {
 		cg14_rectfill(sc, x, y, wi, he, bg);
+		if (attr & 1)
+			cg14_rectfill(sc, x, y + he - 2, wi, 1, fg);
 		return;
 	}
 
+	sx_write(sc->sc_sx, SX_QUEUED(8), bg);
+	sx_write(sc->sc_sx, SX_QUEUED(9), fg);
+
 	data = WSFONT_GLYPH(c, font);
 	addr = sc->sc_fb_paddr + x + stride * y;
 
@@ -1501,6 +1516,8 @@ cg14_putchar(void *cookie, int row, int 
 			break;
 		}
 	}
+	if (attr & 1)
+		cg14_rectfill(sc, x, y + he - 2, wi, 1, fg);
 }
 
 static void
@@ -1545,7 +1562,7 @@ cg14_putchar_aa(void *cookie, int row, i
 	struct vcons_screen *scr = ri->ri_hw;
 	struct cgfourteen_softc *sc = scr->scr_cookie;
 	int stride = sc->sc_fb.fb_type.fb_width;
-	uint32_t bg, addr, bg8, fg8, pixel, in, q, next;
+	uint32_t bg, fg, addr, bg8, fg8, pixel, in, q, next;
 	int i, j, x, y, wi, he, r, g, b, aval, cnt, reg;
 	int r1, g1, b1, r0, g0, b0, fgo, bgo, rv;
 	uint8_t *data8;
@@ -1560,10 +1577,13 @@ cg14_putchar_aa(void *cookie, int row, i
 	he = font->fontheight;
 
 	bg = ri->ri_devcmap[(attr >> 16) & 0xf];
+	fg = ri->ri_devcmap[(attr >> 24) & 0xf];
 	x = ri->ri_xorigin + col * wi;
 	y = ri->ri_yorigin + row * he;
 	if (c == 0x20) {
 		cg14_rectfill(sc, x, y, wi, he, bg);
+		if (attr & 1)
+			cg14_rectfill(sc, x, y + he - 2, wi, 1, fg);
 		return;
 	}
 
@@ -1641,7 +1661,9 @@ cg14_putchar_aa(void *cookie, int row, i
 
 	if (rv == GC_ADD) {
 		glyphcache_add(>sc_gc, c, x, y);
-	}
+	} else if (attr & 1)
+		cg14_rectfill(sc, x, y + he - 2, wi, 1, fg);
+
 }
 
 static void



CVS commit: src/sys/arch/sparc/dev

2018-01-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Jan  6 07:26:54 UTC 2018

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
support underlines


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2017-12-08 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Dec  8 22:28:54 UTC 2017

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
fix tpyos and pastos


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.15 src/sys/arch/sparc/dev/sxreg.h:1.16
--- src/sys/arch/sparc/dev/sxreg.h:1.15	Thu Dec  7 19:15:56 2017
+++ src/sys/arch/sparc/dev/sxreg.h	Fri Dec  8 22:28:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.15 2017/12/07 19:15:56 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.16 2017/12/08 22:28:54 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -293,9 +293,9 @@
 /* MISC group */
 #define SX_GTHR		(3 << 21)	/* sa with spacing sb -> d */
 #define SX_SCTR		(2 << 21)	/* sa -> d with spacing sb */
-#define SX_GATHER(sa, sb, d, cnt) (0xe000 | ((cnt << 24) | SX_GTHR | \
-		((sa) << 14) | ((d << 7) | (sb))
-#define SX_SCATTER(sa, sb, d, cnt) (0xe000 | ((cnt << 24) | SX_SCRT | \
-		((sa) << 14) | ((d << 7) | (sb))
+#define SX_GATHER(sa, sb, d, cnt) (0xe000 | ((cnt) << 24) | SX_GTHR | \
+		 ((sa) << 14) | ((d) << 7) | (sb))
+#define SX_SCATTER(sa, sb, d, cnt) (0xe000 | ((cnt) << 24) | SX_SCTR | \
+		 ((sa) << 14) | ((d) << 7) | (sb))
 
 #endif /* SXREG_H */



CVS commit: src/sys/arch/sparc/dev

2017-12-08 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Dec  8 22:28:54 UTC 2017

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
fix tpyos and pastos


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2017-12-07 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Dec  7 19:15:56 UTC 2017

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add SCATTER/GATHER instructions


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.14 src/sys/arch/sparc/dev/sxreg.h:1.15
--- src/sys/arch/sparc/dev/sxreg.h:1.14	Mon Oct 30 21:41:39 2017
+++ src/sys/arch/sparc/dev/sxreg.h	Thu Dec  7 19:15:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.14 2017/10/30 21:41:39 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.15 2017/12/07 19:15:56 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -290,4 +290,12 @@
 #define SX_ADDV(sa, sb, d, cnt) (0xa000 | ((cnt) << 24) | SX_ADD_V | \
 		((sa) << 14) | ((d) << 7) | (sb))
 
+/* MISC group */
+#define SX_GTHR		(3 << 21)	/* sa with spacing sb -> d */
+#define SX_SCTR		(2 << 21)	/* sa -> d with spacing sb */
+#define SX_GATHER(sa, sb, d, cnt) (0xe000 | ((cnt << 24) | SX_GTHR | \
+		((sa) << 14) | ((d << 7) | (sb))
+#define SX_SCATTER(sa, sb, d, cnt) (0xe000 | ((cnt << 24) | SX_SCRT | \
+		((sa) << 14) | ((d << 7) | (sb))
+
 #endif /* SXREG_H */



CVS commit: src/sys/arch/sparc/dev

2017-12-07 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Dec  7 19:15:56 UTC 2017

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add SCATTER/GATHER instructions


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2017-10-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Oct 30 21:41:39 UTC 2017

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add load & store instructions for channel data type
mostly for Xorg


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2017-10-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Oct 30 21:41:39 UTC 2017

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add load & store instructions for channel data type
mostly for Xorg


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.13 src/sys/arch/sparc/dev/sxreg.h:1.14
--- src/sys/arch/sparc/dev/sxreg.h:1.13	Fri Jan 13 21:49:46 2017
+++ src/sys/arch/sparc/dev/sxreg.h	Mon Oct 30 21:41:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.13 2017/01/13 21:49:46 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.14 2017/10/30 21:41:39 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -158,6 +158,14 @@
 SX_UQUAD_16 | (dreg << 7) | (o))
 #define SX_LDUQ24(dreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_LOAD | \
 SX_UQUAD_24 | (dreg << 7) | (o))
+#define SX_LDUC0(dreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_LOAD | \
+SX_UCHAN_0 | (dreg << 7) | (o))
+#define SX_LDUC8(dreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_LOAD | \
+SX_UCHAN_8 | (dreg << 7) | (o))
+#define SX_LDUC16(dreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_LOAD | \
+SX_UCHAN_16 | (dreg << 7) | (o))
+#define SX_LDUC24(dreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_LOAD | \
+SX_UCHAN_24 | (dreg << 7) | (o))
 #define SX_ST(sreg, cnt, o)  (0x8000 | ((cnt) << 23) | SX_STORE | \
 SX_LONG | (sreg << 7) | (o))
 #define SX_STM(sreg, cnt, o)  (0x8000 | ((cnt) << 23) | SX_STORE_MASK | \
@@ -184,6 +192,16 @@
 SX_UQUAD_16 | (sreg << 7) | (o))
 #define SX_STUQ24(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE | \
 SX_UQUAD_24 | (sreg << 7) | (o))
+#define SX_STUC0(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE | \
+SX_UCHAN_0 | (sreg << 7) | (o))
+#define SX_STUC0C(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE_CLAMP | \
+SX_UCHAN_0 | (sreg << 7) | (o))
+#define SX_STUC8(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE | \
+SX_UCHAN_8 | (sreg << 7) | (o))
+#define SX_STUC16(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE | \
+SX_UCHAN_16 | (sreg << 7) | (o))
+#define SX_STUC24(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE | \
+SX_UCHAN_24 | (sreg << 7) | (o))
 
 /* ROP and SELECT instructions */
 #define SX_ROPB	(0x0 << 21)	/* mask bits apply to bytes */



CVS commit: src/sys/arch/sparc/dev

2017-01-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jan 13 21:49:46 UTC 2017

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add SX_STBM ( STore Byte Masked ) instruction


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.12 src/sys/arch/sparc/dev/sxreg.h:1.13
--- src/sys/arch/sparc/dev/sxreg.h:1.12	Sat Apr 30 05:22:19 2016
+++ src/sys/arch/sparc/dev/sxreg.h	Fri Jan 13 21:49:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.12 2016/04/30 05:22:19 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.13 2017/01/13 21:49:46 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -164,6 +164,8 @@
 SX_LONG | (sreg << 7) | (o))
 #define SX_STB(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE | \
 SX_UBYTE_0 | (sreg << 7) | (o))
+#define SX_STBM(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE_MASK | \
+SX_UBYTE_0 | (sreg << 7) | (o))
 #define SX_STBC(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE_CLAMP | \
 SX_UBYTE_0 | (sreg << 7) | (o))
 #define SX_STP(sreg, cnt, o) (0x8000 | ((cnt) << 23) | SX_STORE | \



CVS commit: src/sys/arch/sparc/dev

2017-01-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jan 13 21:49:46 UTC 2017

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add SX_STBM ( STore Byte Masked ) instruction


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2016-12-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 11 16:25:54 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: tctrl.c

Log Message:
catch up with sd changes.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/sparc/dev/tctrl.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/sparc/dev/tctrl.c
diff -u src/sys/arch/sparc/dev/tctrl.c:1.59 src/sys/arch/sparc/dev/tctrl.c:1.60
--- src/sys/arch/sparc/dev/tctrl.c:1.59	Fri Jul 25 04:10:34 2014
+++ src/sys/arch/sparc/dev/tctrl.c	Sun Dec 11 11:25:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tctrl.c,v 1.59 2014/07/25 08:10:34 dholland Exp $	*/
+/*	$NetBSD: tctrl.c,v 1.60 2016/12/11 16:25:54 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.59 2014/07/25 08:10:34 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tctrl.c,v 1.60 2016/12/11 16:25:54 christos Exp $");
 
 #include 
 #include 
@@ -1447,42 +1447,43 @@ tctrl_event_thread(void *v)
 {
 	struct tctrl_softc *sc = v;
 	device_t dv;
-	struct sd_softc *sd = NULL;
-	struct lance_softc *le = NULL;
-	int ticks = hz/2;
-	int rcount, wcount;
-	int s;
+	struct sd_softc *sd;
 	
-	while (sd == NULL) {
+	for (sd = NULL; sd == NULL;) {
 		dv = device_find_by_xname("sd0");
 		if (dv != NULL)
 			sd = device_private(dv);
 		else
 			tsleep(>sc_events, PWAIT, "probe_disk", hz);
 	}			
+
 	dv = device_find_by_xname("le0");
-	if (dv != NULL)
-		le = device_private(dv);
-	printf("found %s\n", device_xname(sd->sc_dev));
-	rcount = sd->sc_dk.dk_stats->io_rxfer;
-	wcount = sd->sc_dk.dk_stats->io_wxfer;
+
+	struct lance_softc *le = dv != NULL ? device_private(dv) : NULL;
+	struct dk_softc *dk = >sc_dksc;
+	printf("found %s\n", device_xname(dk->sc_dev));
+
+	struct io_stats *io = dk->sc_dkdev.dk_stats;
+	int rcount = io->io_rxfer;
+	int wcount = io->io_wxfer;
 
 	tctrl_read_event_status(sc);
 	
-	while (1) {
+	int ticks = hz / 2;
+	for (;;) {
 		tsleep(>sc_events, PWAIT, "tctrl_event", ticks);
-		s = splhigh();
-		if ((rcount != sd->sc_dk.dk_stats->io_rxfer) || 
-		(wcount != sd->sc_dk.dk_stats->io_wxfer)) {
-			rcount = sd->sc_dk.dk_stats->io_rxfer;
-			wcount = sd->sc_dk.dk_stats->io_wxfer;
+		int s = splhigh();
+		if ((rcount != io->io_rxfer) || (wcount != io->io_wxfer)) {
+			rcount = io->io_rxfer;
+			wcount = io->io_wxfer;
 			sc->sc_lcdwanted |= TS102_LCD_DISK_ACTIVE;
 		} else
 			sc->sc_lcdwanted &= ~TS102_LCD_DISK_ACTIVE;
+
 		if (le != NULL) {
-			if (le->sc_havecarrier != 0) {
+			if (le->sc_havecarrier != 0)
 sc->sc_lcdwanted |= TS102_LCD_LAN_ACTIVE;
-			} else
+			else
 sc->sc_lcdwanted &= ~TS102_LCD_LAN_ACTIVE;
 		}
 		splx(s);



CVS commit: src/sys/arch/sparc/dev

2016-12-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 11 16:25:54 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: tctrl.c

Log Message:
catch up with sd changes.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/sparc/dev/tctrl.c

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



CVS commit: src/sys/arch/sparc/dev

2016-09-16 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Sep 16 22:39:36 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
wipe glyph cache as needed when re-entering text mode
now the console is readable again when leaving X


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.81 src/sys/arch/sparc/dev/cgfourteen.c:1.82
--- src/sys/arch/sparc/dev/cgfourteen.c:1.81	Thu Jun  2 21:19:24 2016
+++ src/sys/arch/sparc/dev/cgfourteen.c	Fri Sep 16 22:39:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.81 2016/06/02 21:19:24 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.82 2016/09/16 22:39:35 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -418,9 +418,13 @@ cgfourteenclose(dev_t dev, int flags, in
 	/*
 	 * Restore video state to make the PROM happy, on last close.
 	 */
-	if (opens == 0)
+	if (opens == 0) {
 		cg14_reset(sc);
-
+#if NSX > 0
+		if (sc->sc_sx)
+			glyphcache_wipe(>sc_gc);
+#endif
+	}
 	return (0);
 }
 
@@ -918,6 +922,10 @@ cg14_ioctl(void *v, void *vs, u_long cmd
 
 		cg14_set_depth(sc, 8);
 		cg14_init_cmap(sc);
+#if NSX > 0
+		if (sc->sc_sx)
+			glyphcache_wipe(>sc_gc);
+#endif
 		vcons_redraw_screen(ms);
 	} else {
 



CVS commit: src/sys/arch/sparc/dev

2016-09-16 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Sep 16 22:39:36 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
wipe glyph cache as needed when re-entering text mode
now the console is readable again when leaving X


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2016-06-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jun  2 21:19:24 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
use DEFATTR if we're not the console and can't init defattr.
should appease clang
TODO: we should really init the glyphcache whith the first screen


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.80 src/sys/arch/sparc/dev/cgfourteen.c:1.81
--- src/sys/arch/sparc/dev/cgfourteen.c:1.80	Sat Apr 30 05:23:03 2016
+++ src/sys/arch/sparc/dev/cgfourteen.c	Thu Jun  2 21:19:24 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.80 2016/04/30 05:23:03 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.81 2016/06/02 21:19:24 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -775,7 +775,7 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 			sc->sc_fb.fb_type.fb_width,
 			ri->ri_font->fontwidth,
 			ri->ri_font->fontheight,
-			defattr);
+			DEFATTR);
 	}
 
 	cg14_init_cmap(sc);



CVS commit: src/sys/arch/sparc/dev

2016-06-02 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jun  2 21:19:24 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
use DEFATTR if we're not the console and can't init defattr.
should appease clang
TODO: we should really init the glyphcache whith the first screen


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2016-04-29 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Apr 30 05:23:03 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c cgfourteenvar.h

Log Message:
support anti-aliased fonts, glyphcache etc.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/sparc/dev/cgfourteen.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc/dev/cgfourteenvar.h

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



CVS commit: src/sys/arch/sparc/dev

2016-04-29 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Apr 30 05:23:03 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c cgfourteenvar.h

Log Message:
support anti-aliased fonts, glyphcache etc.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/sparc/dev/cgfourteen.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc/dev/cgfourteenvar.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.79 src/sys/arch/sparc/dev/cgfourteen.c:1.80
--- src/sys/arch/sparc/dev/cgfourteen.c:1.79	Fri Jul 25 08:10:34 2014
+++ src/sys/arch/sparc/dev/cgfourteen.c	Sat Apr 30 05:23:03 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.79 2014/07/25 08:10:34 dholland Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.80 2016/04/30 05:23:03 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -96,6 +96,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -164,10 +165,9 @@ static void cg14_rectfill(struct cgfourt
 uint32_t);
 static void cg14_invert(struct cgfourteen_softc *, int, int, int, int);
 static void cg14_bitblt(void *, int, int, int, int, int, int, int);
+static void cg14_bitblt_gc(void *, int, int, int, int, int, int, int);
 
-#if 0
 static void cg14_putchar_aa(void *, int, int, u_int, long);
-#endif
 static void cg14_cursor(void *, int, int, int);
 static void cg14_putchar(void *, int, int, u_int, long);
 static void cg14_copycols(void *, int, int, int, int);
@@ -595,74 +595,14 @@ cgfourteenpoll(dev_t dev, int events, st
 static void
 cg14_init(struct cgfourteen_softc *sc)
 {
-#if 0
-	volatile uint32_t *clut;
-	volatile uint8_t  *xlut;
-	int i;
-
-	/*
-	 * We stash away the following to restore on close:
-	 *
-	 * 	color look-up table 1 	(sc->sc_saveclut)
-	 *	x look-up table		(sc->sc_savexlut)
-	 *	control register	(sc->sc_savectl)
-	 *	cursor control register (sc->sc_savehwc)
-	 */
-	sc->sc_savectl = sc->sc_ctl->ctl_mctl;
-	sc->sc_savehwc = sc->sc_hwc->curs_ctl;
-
-	clut = (volatile uint32_t *) sc->sc_clut1->clut_lut;
-	xlut = (volatile uint8_t *) sc->sc_xlut->xlut_lut;
-	for (i = 0; i < CG14_CLUT_SIZE; i++) {
-		sc->sc_saveclut.cm_chip[i] = clut[i];
-		sc->sc_savexlut[i] = xlut[i];
-	}
-
-	/*
-	 * Enable the video and put it in 8 bit mode
-	 */
-	sc->sc_ctl->ctl_mctl = CG14_MCTL_ENABLEVID | CG14_MCTL_PIXMODE_8 |
-		CG14_MCTL_POWERCTL;
-#else
 	cg14_set_depth(sc, 32);
-#endif
 }
 
 static void
 /* Restore the state saved on cg14_init */
 cg14_reset(struct cgfourteen_softc *sc)
 {
-#if 0
-	volatile uint32_t *clut;
-	volatile uint8_t  *xlut;
-	int i;
-
-	/*
-	 * We restore the following, saved in cg14_init:
-	 *
-	 * 	color look-up table 1 	(sc->sc_saveclut)
-	 *	x look-up table		(sc->sc_savexlut)
-	 *	control register	(sc->sc_savectl)
-	 *	cursor control register (sc->sc_savehwc)
-	 *
-	 * Note that we don't touch the video enable bits in the
-	 * control register; otherwise, screenblank wouldn't work.
-	 */
-	sc->sc_ctl->ctl_mctl = (sc->sc_ctl->ctl_mctl & (CG14_MCTL_ENABLEVID |
-			CG14_MCTL_POWERCTL)) |
-(sc->sc_savectl & ~(CG14_MCTL_ENABLEVID |
-		CG14_MCTL_POWERCTL));
-	sc->sc_hwc->curs_ctl = sc->sc_savehwc;
-
-	clut = sc->sc_clut1->clut_lut;
-	xlut = sc->sc_xlut->xlut_lut;
-	for (i = 0; i < CG14_CLUT_SIZE; i++) {
-		clut[i] = sc->sc_saveclut.cm_chip[i];
-		xlut[i] = sc->sc_savexlut[i];
-	}
-#else
 	cg14_set_depth(sc, 8);
-#endif
 }
 
 /* Enable/disable video display; power down monitor if DPMS-capable */
@@ -767,7 +707,6 @@ cg14_load_hwcmap(struct cgfourteen_softc
 		*lutp++ = *colp++;
 }
 
-#if NWSDISPLAY > 0
 static void
 cg14_setup_wsdisplay(struct cgfourteen_softc *sc, int is_cons)
 {
@@ -793,20 +732,35 @@ cg14_setup_wsdisplay(struct cgfourteen_s
 
 	ri = >sc_console_screen.scr_ri;
 
+	sc->sc_gc.gc_bitblt = cg14_bitblt_gc;
+	sc->sc_gc.gc_blitcookie = sc;
+	sc->sc_gc.gc_rop = 0xc;
 	if (is_cons) {
 		vcons_init_screen(>sc_vd, >sc_console_screen, 1,
 		);
 
 		/* clear the screen with the default background colour */
-		memset(sc->sc_fb.fb_pixels,
-		   (defattr >> 16) & 0xff,
-		   ri->ri_stride * ri->ri_height);
+		if (sc->sc_sx != NULL) {
+			cg14_rectfill(sc, 0, 0, ri->ri_width, ri->ri_height,
+ri->ri_devcmap[(defattr >> 16) & 0xf]);
+		} else {
+			memset(sc->sc_fb.fb_pixels,
+			   ri->ri_devcmap[(defattr >> 16) & 0xf],
+			   ri->ri_stride * ri->ri_height);
+		}
 		sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
 
 		sc->sc_defaultscreen_descr.textops = >ri_ops;
 		sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
 		sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
 		sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
+		glyphcache_init(>sc_gc, sc->sc_fb.fb_type.fb_height + 5,
+			(sc->sc_vramsize / sc->sc_fb.fb_type.fb_width) - 
+			 sc->sc_fb.fb_type.fb_height - 5,
+			sc->sc_fb.fb_type.fb_width,
+			ri->ri_font->fontwidth,
+			

CVS commit: src/sys/arch/sparc/dev

2016-04-29 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Apr 30 05:22:19 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
sprinkle ()s in macros


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.11 src/sys/arch/sparc/dev/sxreg.h:1.12
--- src/sys/arch/sparc/dev/sxreg.h:1.11	Wed Jun 19 00:41:16 2013
+++ src/sys/arch/sparc/dev/sxreg.h	Sat Apr 30 05:22:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.11 2013/06/19 00:41:16 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.12 2016/04/30 05:22:19 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
 /* write registers via pseudo instructions */
 #define SX_QUEUED_R0		0x0300
 #define SX_QUEUED_R1		0x0304	/* and so on until R127 */
-#define SX_QUEUED(r)		(0x300 + (r << 2))
+#define SX_QUEUED(r)		(0x300 + ((r) << 2))
 
 /* special purpose registers */
 #define R_ZERO	0



CVS commit: src/sys/arch/sparc/dev

2016-04-29 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Apr 30 05:22:19 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
sprinkle ()s in macros


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2016-04-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 21 17:59:18 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: cgsix_obio.c

Log Message:
RASTERCONSOLE is no more


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/sparc/dev/cgsix_obio.c

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



CVS commit: src/sys/arch/sparc/dev

2016-04-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 21 17:59:18 UTC 2016

Modified Files:
src/sys/arch/sparc/dev: cgsix_obio.c

Log Message:
RASTERCONSOLE is no more


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/sparc/dev/cgsix_obio.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/sparc/dev/cgsix_obio.c
diff -u src/sys/arch/sparc/dev/cgsix_obio.c:1.26 src/sys/arch/sparc/dev/cgsix_obio.c:1.27
--- src/sys/arch/sparc/dev/cgsix_obio.c:1.26	Sat Oct 27 17:18:11 2012
+++ src/sys/arch/sparc/dev/cgsix_obio.c	Thu Apr 21 17:59:18 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgsix_obio.c,v 1.26 2012/10/27 17:18:11 chs Exp $ */
+/*	$NetBSD: cgsix_obio.c,v 1.27 2016/04/21 17:59:18 macallan Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgsix_obio.c,v 1.26 2012/10/27 17:18:11 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgsix_obio.c,v 1.27 2016/04/21 17:59:18 macallan Exp $");
 
 #include 
 #include 
@@ -204,17 +204,15 @@ cgsixattach(device_t parent, device_t se
 	else
 		isconsole = 0;
 
-	if (isconsole && cgsix_use_rasterconsole) {
-		if (bus_space_map(oba->oba_bustag,
-  oba->oba_paddr + CGSIX_RAM_OFFSET,
-  sc->sc_ramsize,
-  BUS_SPACE_MAP_LINEAR,
-  ) != 0) {
-			printf("%s: cannot map pixels\n", device_xname(self));
-			return;
-		}
-		sc->sc_fb.fb_pixels = (void *)bh;
+	if (bus_space_map(oba->oba_bustag,
+			  oba->oba_paddr + CGSIX_RAM_OFFSET,
+			  sc->sc_ramsize,
+			  BUS_SPACE_MAP_LINEAR,
+			  ) != 0) {
+		printf("%s: cannot map pixels\n", device_xname(self));
+		return;
 	}
+	sc->sc_fb.fb_pixels = (void *)bh;
 
 	cg6attach(sc, name, isconsole);
 }



CVS commit: src/sys/arch/sparc/dev

2014-08-19 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Aug 19 14:43:41 UTC 2014

Modified Files:
src/sys/arch/sparc/dev: fd.c

Log Message:
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().

I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).

Should be pulled up to netbsd-7.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/arch/sparc/dev/fd.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/sparc/dev/fd.c
diff -u src/sys/arch/sparc/dev/fd.c:1.154 src/sys/arch/sparc/dev/fd.c:1.155
--- src/sys/arch/sparc/dev/fd.c:1.154	Fri Jul 25 08:10:34 2014
+++ src/sys/arch/sparc/dev/fd.c	Tue Aug 19 14:43:41 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.154 2014/07/25 08:10:34 dholland Exp $	*/
+/*	$NetBSD: fd.c,v 1.155 2014/08/19 14:43:41 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.154 2014/07/25 08:10:34 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.155 2014/08/19 14:43:41 tsutsui Exp $);
 
 #include opt_ddb.h
 #include opt_md.h
@@ -2244,7 +2244,7 @@ fdgetdisklabel(dev_t dev)
 	struct cpu_disklabel *clp = fd-sc_dk.dk_cpulabel;
 
 	memset(lp, 0, sizeof(struct disklabel));
-	memset(lp, 0, sizeof(struct cpu_disklabel));
+	memset(clp, 0, sizeof(struct cpu_disklabel));
 
 	lp-d_type = DTYPE_FLOPPY;
 	lp-d_secsize = FD_BSIZE(fd);



CVS commit: src/sys/arch/sparc/dev

2014-08-19 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Aug 19 14:43:41 UTC 2014

Modified Files:
src/sys/arch/sparc/dev: fd.c

Log Message:
Fix panic() on opening fd(4), caused by a wrong pointer passed to memset().

I'm not sure why this 18 year old bug didn't cause problem before
(at least my old 5.99.23 kernel worked), but probably it's triggered
by new gcc 4.8 which might do more aggressive memory allocation.
The problem is found by Nobuyoshi Sato on trying eject(1) against fd(4).

Should be pulled up to netbsd-7.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/arch/sparc/dev/fd.c

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



CVS commit: src/sys/arch/sparc/dev

2014-06-28 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jun 29 03:57:10 UTC 2014

Modified Files:
src/sys/arch/sparc/dev: sxvar.h

Log Message:
Add a newline at end of file.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc/dev/sxvar.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/sparc/dev/sxvar.h
diff -u src/sys/arch/sparc/dev/sxvar.h:1.2 src/sys/arch/sparc/dev/sxvar.h:1.3
--- src/sys/arch/sparc/dev/sxvar.h:1.2	Tue Apr 15 10:24:54 2014
+++ src/sys/arch/sparc/dev/sxvar.h	Sun Jun 29 03:57:10 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxvar.h,v 1.2 2014/04/15 10:24:54 macallan Exp $	*/
+/*	$NetBSD: sxvar.h,v 1.3 2014/06/29 03:57:10 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -51,4 +51,4 @@ sx_read(struct sx_softc *sc, int addr)
 	return bus_space_read_4(sc-sc_tag, sc-sc_regh, addr);
 }
 
-#endif
\ No newline at end of file
+#endif



CVS commit: src/sys/arch/sparc/dev

2014-06-28 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jun 29 03:57:10 UTC 2014

Modified Files:
src/sys/arch/sparc/dev: sxvar.h

Log Message:
Add a newline at end of file.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc/dev/sxvar.h

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



CVS commit: src/sys/arch/sparc/dev

2014-04-23 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Apr 23 16:54:21 UTC 2014

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
rev. 27 SX needs memory referencing instructions written to 64bit aligned
addresses ( my rev. 25 just ignores the lower 3 bits )
so, we zero these bits now


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2014-04-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Apr 15 10:24:54 UTC 2014

Modified Files:
src/sys/arch/sparc/dev: sx.c sxvar.h

Log Message:
print chip revision on attach


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc/dev/sx.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc/dev/sxvar.h

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



CVS commit: src/sys/arch/sparc/dev

2013-08-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Aug 14 01:53:27 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
comments  whitespace police


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.75 src/sys/arch/sparc/dev/cgfourteen.c:1.76
--- src/sys/arch/sparc/dev/cgfourteen.c:1.75	Tue Jun  4 22:31:30 2013
+++ src/sys/arch/sparc/dev/cgfourteen.c	Wed Aug 14 01:53:27 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.75 2013/06/04 22:31:30 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.76 2013/08/14 01:53:27 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -110,7 +110,7 @@ static void	cgfourteenunblank(device_t);
 
 CFATTACH_DECL_NEW(cgfourteen, sizeof(struct cgfourteen_softc),
 cgfourteenmatch, cgfourteenattach, NULL, NULL);
-
+
 extern struct cfdriver cgfourteen_cd;
 
 dev_type_open(cgfourteenopen);
@@ -191,14 +191,6 @@ cgfourteenmatch(device_t parent, struct 
 	return (strcmp(cf-cf_name, sa-sa_name) == 0);
 }
 
-/*
- * Set COLOUR_OFFSET to the offset of the video RAM.  This is to provide
- *  space for faked overlay junk for the cg8 emulation.
- *
- * As it happens, this value is correct for both cg3 and cg8 emulation!
- */
-#define COLOUR_OFFSET (256*1024)
-
 #if NWSDISPLAY  0
 static int	cg14_ioctl(void *, void *, u_long, void *, int, struct lwp *);
 static paddr_t	cg14_mmap(void *, void *, off_t, int);
@@ -554,6 +546,11 @@ cgfourteenmmap(dev_t dev, off_t off, int
 		offset = sc-sc_fbaddr + CG14_FB_PR32;
 		off -= CG14_R32_VOFF;
 #if NSX  0
+	/*
+	 * for convenience we also map the SX ranges here:
+	 * - one page userland registers
+	 * - CG14-sized IO space at 0x8 ( not a typo, it's above 4GB )
+	 */
 	} else if (sc-sc_sx == NULL) {
 		return -1;
 	} else if (off = CG14_SXREG_VOFF 
@@ -568,12 +565,7 @@ cgfourteenmmap(dev_t dev, off_t off, int
 #endif
 	} else
 		return -1;
-	/*
-	 * for convenience we also map the SX ranges here:
-	 * - one page userland registers
-	 * - CG14-sized IO space at 0x8 ( not a typo, it's above 4GB )
-	 * bus_space_mmap() should accept 64bit bus_addr_t's by the look of it
-	 */
+	
 	return (bus_space_mmap(sc-sc_bustag, offset, off, prot,
 		BUS_SPACE_MAP_LINEAR));
 }



CVS commit: src/sys/arch/sparc/dev

2013-08-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Aug 14 01:53:27 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
comments  whitespace police


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/sparc/dev/cgfourteen.c

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



CVS commit: src/sys/arch/sparc/dev

2013-06-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 19 00:41:16 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add store-with-clamp instructions


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.10 src/sys/arch/sparc/dev/sxreg.h:1.11
--- src/sys/arch/sparc/dev/sxreg.h:1.10	Wed Jun 12 20:44:20 2013
+++ src/sys/arch/sparc/dev/sxreg.h	Wed Jun 19 00:41:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.10 2013/06/12 20:44:20 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.11 2013/06/19 00:41:16 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -164,6 +164,8 @@
 SX_LONG | (sreg  7) | (o))
 #define SX_STB(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \
 SX_UBYTE_0 | (sreg  7) | (o))
+#define SX_STBC(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE_CLAMP | \
+SX_UBYTE_0 | (sreg  7) | (o))
 #define SX_STP(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \
 SX_PACKED | (sreg  7) | (o))
 #define SX_STS(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE_SELECT \
@@ -172,6 +174,8 @@
 | SX_UBYTE_0 | (reg  7) | (o))
 #define SX_STUQ0(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \
 SX_UQUAD_0 | (sreg  7) | (o))
+#define SX_STUQ0C(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE_CLAMP | \
+SX_UQUAD_0 | (sreg  7) | (o))
 #define SX_STUQ8(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \
 SX_UQUAD_8 | (sreg  7) | (o))
 #define SX_STUQ16(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \



CVS commit: src/sys/arch/sparc/dev

2013-06-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 19 00:41:16 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add store-with-clamp instructions


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2013-06-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 12 20:43:22 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
document arithmetics instructions


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.8 src/sys/arch/sparc/dev/sxreg.h:1.9
--- src/sys/arch/sparc/dev/sxreg.h:1.8	Wed Jun 12 04:23:46 2013
+++ src/sys/arch/sparc/dev/sxreg.h	Wed Jun 12 20:43:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.8 2013/06/12 04:23:46 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.9 2013/06/12 20:43:21 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -253,14 +253,15 @@
 		((sa)  14) | ((d)  7) | (sb))
 
 /* arithmetic group */
-#define SX_ADD_V	(0x00  21)
-#define SX_ADD_S	(0x01  21)
-#define SX_ADD_I	(0x02  21)
-#define SX_SUM		(0x03  21)
-#define SX_SUB_V	(0x04  21)
-#define SX_SUB_S	(0x05  21)
-#define SX_SUB_I	(0x06  21)
-#define SX_ABS		(0x07  21)
+#define SX_ADD_V	(0x00  21)	/* vector + vector */
+#define SX_ADD_S	(0x01  21)	/* vector + scalar */
+#define SX_ADD_I	(0x02  21)	/* vector + immediate */
+#define SX_SUM		(0x03  21)	/* sum of vector and scalar */
+#define SX_SUB_V	(0x04  21)	/* vector - veector */
+#define SX_SUB_S	(0x05  21)	/* vector - scalar */
+#define SX_SUB_I	(0x06  21)	/* vector - immediate */
+#define SX_ABS		(0x07  21)	/* abs(sb) with sa=R0 */
+/* hardware does sa - sb for sb  0 and sa + sb if sb  0 */
 
 #define SX_ADDV(sa, sb, d, cnt) (0xa000 | ((cnt)  24) | SX_ADD_V | \
 		((sa)  14) | ((d)  7) | (sb))



CVS commit: src/sys/arch/sparc/dev

2013-06-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 12 20:44:20 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.9 src/sys/arch/sparc/dev/sxreg.h:1.10
--- src/sys/arch/sparc/dev/sxreg.h:1.9	Wed Jun 12 20:43:21 2013
+++ src/sys/arch/sparc/dev/sxreg.h	Wed Jun 12 20:44:20 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.9 2013/06/12 20:43:21 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.10 2013/06/12 20:44:20 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -257,7 +257,7 @@
 #define SX_ADD_S	(0x01  21)	/* vector + scalar */
 #define SX_ADD_I	(0x02  21)	/* vector + immediate */
 #define SX_SUM		(0x03  21)	/* sum of vector and scalar */
-#define SX_SUB_V	(0x04  21)	/* vector - veector */
+#define SX_SUB_V	(0x04  21)	/* vector - vector */
 #define SX_SUB_S	(0x05  21)	/* vector - scalar */
 #define SX_SUB_I	(0x06  21)	/* vector - immediate */
 #define SX_ABS		(0x07  21)	/* abs(sb) with sa=R0 */



CVS commit: src/sys/arch/sparc/dev

2013-06-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 12 20:43:22 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
document arithmetics instructions


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2013-06-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 12 20:44:20 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2013-06-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 12 04:23:46 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
fix serial typepasto, while there add SX_ADD instructions


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.7 src/sys/arch/sparc/dev/sxreg.h:1.8
--- src/sys/arch/sparc/dev/sxreg.h:1.7	Wed Jun  5 18:15:06 2013
+++ src/sys/arch/sparc/dev/sxreg.h	Wed Jun 12 04:23:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.7 2013/06/05 18:15:06 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.8 2013/06/12 04:23:46 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -207,22 +207,22 @@
 #define SX_ROUND	(0x1  23)	/* round results */
 
 #define SX_MUL16X16(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt)  24) | \
-		SX_MULTIPLY | ((sa)  14) | ((sb)  7) | (d))	
+		SX_MULTIPLY | ((sa)  14) | ((d)  7) | (sb))	
 #define SX_MUL16X16R(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt)  24) | \
-		SX_MULTIPLY | ((sa)  14) | ((sb)  7) | (d) | SX_ROUND)	
+		SX_MULTIPLY | ((sa)  14) | ((d)  7) | (sb) | SX_ROUND)	
 #define SX_MUL16X16SR8(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt)  24) | \
-		SX_MULTIPLY | ((sa)  14) | ((sb)  7) | (d))	
+		SX_MULTIPLY | ((sa)  14) | ((d)  7) | (sb))	
 #define SX_MUL16X16SR8R(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt)  24) | \
-		SX_MULTIPLY | ((sa)  14) | ((sb)  7) | (d) | SX_ROUND)	
+		SX_MULTIPLY | ((sa)  14) | ((d)  7) | (sb) | SX_ROUND)	
 
 #define SX_SAXP16X16(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt)  24) | \
-		SX_SAXP | ((sa)  14) | ((sb)  7) | (d))	
+		SX_SAXP | ((sa)  14) | ((d)  7) | (sb))	
 #define SX_SAXP16X16R(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt)  24) | \
-		SX_SAXP | ((sa)  14) | ((sb)  7) | (d) | SX_ROUND)	
+		SX_SAXP | ((sa)  14) | ((d)  7) | (sb) | SX_ROUND)	
 #define SX_SAXP16X16SR8(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt)  24) | \
-		SX_SAXP | ((sa)  14) | ((sb)  7) | (d))	
+		SX_SAXP | ((sa)  14) | ((d)  7) | (sb))	
 #define SX_SAXP16X16SR8R(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt)  24) | \
-		SX_SAXP | ((sa)  14) | ((sb)  7) | (d) | SX_ROUND)	
+		SX_SAXP | ((sa)  14) | ((d)  7) | (sb) | SX_ROUND)	
 
 /* logic group */
 #define SX_AND_V	(0x0  21)	/* vector AND vector */
@@ -236,20 +236,33 @@
 /* immediates are 7bit sign extended to 32bit */
 
 #define SX_ANDV(sa, sb, d, cnt) (0xb000 | ((cnt)  24) | SX_AND_V | \
-		((sa)  14) | ((sb)  7) | (d))
+		((sa)  14) | ((d)  7) | (sb))
 #define SX_ANDS(sa, sb, d, cnt) (0xb000 | ((cnt)  24) | SX_AND_S | \
-		((sa)  14) | ((sb)  7) | (d))
+		((sa)  14) | ((d)  7) | (sb))
 #define SX_ANDI(sa, sb, d, cnt) (0xb000 | ((cnt)  24) | SX_AND_I | \
-		((sa)  14) | ((sb)  7) | (d))
+		((sa)  14) | ((d)  7) | (sb))
 #define SX_XORV(sa, sb, d, cnt) (0xb000 | ((cnt)  24) | SX_XOR_V | \
-		((sa)  14) | ((sb)  7) | (d))
+		((sa)  14) | ((d)  7) | (sb))
 #define SX_XORS(sa, sb, d, cnt) (0xb000 | ((cnt)  24) | SX_XOR_S | \
-		((sa)  14) | ((sb)  7) | (d))
+		((sa)  14) | ((d)  7) | (sb))
 #define SX_XORI(sa, sb, d, cnt) (0xb000 | ((cnt)  24) | SX_XOR_I | \
-		((sa)  14) | ((sb)  7) | (d))
+		((sa)  14) | ((d)  7) | (sb))
 #define SX_ORV(sa, sb, d, cnt) (0xb000 | ((cnt)  24) | SX_OR_V | \
-		((sa)  14) | ((sb)  7) | (d))
+		((sa)  14) | ((d)  7) | (sb))
 #define SX_ORS(sa, sb, d, cnt) (0xb000 | ((cnt)  24) | SX_OR_S | \
-		((sa)  14) | ((sb)  7) | (d))
+		((sa)  14) | ((d)  7) | (sb))
+
+/* arithmetic group */
+#define SX_ADD_V	(0x00  21)
+#define SX_ADD_S	(0x01  21)
+#define SX_ADD_I	(0x02  21)
+#define SX_SUM		(0x03  21)
+#define SX_SUB_V	(0x04  21)
+#define SX_SUB_S	(0x05  21)
+#define SX_SUB_I	(0x06  21)
+#define SX_ABS		(0x07  21)
+
+#define SX_ADDV(sa, sb, d, cnt) (0xa000 | ((cnt)  24) | SX_ADD_V | \
+		((sa)  14) | ((d)  7) | (sb))
 
 #endif /* SXREG_H */



CVS commit: src/sys/arch/sparc/dev

2013-06-11 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun 12 04:23:46 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
fix serial typepasto, while there add SX_ADD instructions


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2013-06-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun  5 18:15:06 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add a bunch more instructions ( still not complete but we're getting there )


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.6 src/sys/arch/sparc/dev/sxreg.h:1.7
--- src/sys/arch/sparc/dev/sxreg.h:1.6	Tue Jun  4 22:30:30 2013
+++ src/sys/arch/sparc/dev/sxreg.h	Wed Jun  5 18:15:06 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.6 2013/06/04 22:30:30 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.7 2013/06/05 18:15:06 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -150,6 +150,14 @@
 SX_UBYTE_0 | (dreg  7) | (o))
 #define SX_LDP(dreg, cnt, o) (0x8000 | ((cnt)  23) | SX_LOAD | \
 SX_PACKED | (dreg  7) | (o))
+#define SX_LDUQ0(dreg, cnt, o) (0x8000 | ((cnt)  23) | SX_LOAD | \
+SX_UQUAD_0 | (dreg  7) | (o))
+#define SX_LDUQ8(dreg, cnt, o) (0x8000 | ((cnt)  23) | SX_LOAD | \
+SX_UQUAD_8 | (dreg  7) | (o))
+#define SX_LDUQ16(dreg, cnt, o) (0x8000 | ((cnt)  23) | SX_LOAD | \
+SX_UQUAD_16 | (dreg  7) | (o))
+#define SX_LDUQ24(dreg, cnt, o) (0x8000 | ((cnt)  23) | SX_LOAD | \
+SX_UQUAD_24 | (dreg  7) | (o))
 #define SX_ST(sreg, cnt, o)  (0x8000 | ((cnt)  23) | SX_STORE | \
 SX_LONG | (sreg  7) | (o))
 #define SX_STM(sreg, cnt, o)  (0x8000 | ((cnt)  23) | SX_STORE_MASK | \
@@ -162,8 +170,16 @@
 | SX_LONG | (sreg  7) | (o))
 #define SX_STBS(reg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE_SELECT \
 | SX_UBYTE_0 | (reg  7) | (o))
+#define SX_STUQ0(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \
+SX_UQUAD_0 | (sreg  7) | (o))
+#define SX_STUQ8(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \
+SX_UQUAD_8 | (sreg  7) | (o))
+#define SX_STUQ16(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \
+SX_UQUAD_16 | (sreg  7) | (o))
+#define SX_STUQ24(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \
+SX_UQUAD_24 | (sreg  7) | (o))
 
-/* ROP instruction */
+/* ROP and SELECT instructions */
 #define SX_ROPB	(0x0  21)	/* mask bits apply to bytes */
 #define SX_ROPM	(0x1  21)	/* mask bits apply to each bit */
 #define SX_ROPL	(0x2  21)	/* mask bits apply per register */
@@ -175,4 +191,65 @@
 		((sa)  14) | (sb) | ((d)  7))
 #define SX_SELECT_S(sa, sb, d, cnt) (0x9000 | ((cnt)  24) | SX_SELS | \
 		((sa)  14) | (sb) | ((d)  7))
+
+/* multiply group */
+#define SX_M16X16SR0	(0x0  28)	/* 16bit multiply, no shift */
+#define SX_M16X16SR8	(0x1  28)	/* 16bit multiply, shift right 8 */
+#define SX_M16X16SR16	(0x2  28)	/* 16bit multiply, shift right 16 */
+#define SX_M32X16SR0	(0x4  28)	/* 32x16bit multiply, no shift */
+#define SX_M32X16SR8	(0x5  28)	/* 32x16bit multiply, shift right 8 */
+#define SX_M32X16SR16	(0x6  28)	/* 32x16bit multiply, shift right 16 */
+
+#define SX_MULTIPLY	(0x0  21)	/* normal multiplication */
+#define SX_DOT		(0x1  21)	/* dot product of A and B */
+#define SX_SAXP		(0x2  21)	/* A * SCAM + B */
+
+#define SX_ROUND	(0x1  23)	/* round results */
+
+#define SX_MUL16X16(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt)  24) | \
+		SX_MULTIPLY | ((sa)  14) | ((sb)  7) | (d))	
+#define SX_MUL16X16R(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt)  24) | \
+		SX_MULTIPLY | ((sa)  14) | ((sb)  7) | (d) | SX_ROUND)	
+#define SX_MUL16X16SR8(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt)  24) | \
+		SX_MULTIPLY | ((sa)  14) | ((sb)  7) | (d))	
+#define SX_MUL16X16SR8R(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt)  24) | \
+		SX_MULTIPLY | ((sa)  14) | ((sb)  7) | (d) | SX_ROUND)	
+
+#define SX_SAXP16X16(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt)  24) | \
+		SX_SAXP | ((sa)  14) | ((sb)  7) | (d))	
+#define SX_SAXP16X16R(sa, sb, d, cnt) (SX_M16X16SR0 | ((cnt)  24) | \
+		SX_SAXP | ((sa)  14) | ((sb)  7) | (d) | SX_ROUND)	
+#define SX_SAXP16X16SR8(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt)  24) | \
+		SX_SAXP | ((sa)  14) | ((sb)  7) | (d))	
+#define SX_SAXP16X16SR8R(sa, sb, d, cnt) (SX_M16X16SR8 | ((cnt)  24) | \
+		SX_SAXP | ((sa)  14) | ((sb)  7) | (d) | SX_ROUND)	
+
+/* logic group */
+#define SX_AND_V	(0x0  21)	/* vector AND vector */
+#define SX_AND_S	(0x1  21)	/* vector AND scalar */
+#define SX_AND_I	(0x2  21)	/* vector AND immediate */
+#define SX_XOR_V	(0x3  21)	/* vector XOR vector */
+#define SX_XOR_S	(0x4  21)	/* vector XOR scalar */
+#define SX_XOR_I	(0x5  21)	/* vector XOR immediate */
+#define SX_OR_V		(0x6  21)	/* vector OR vector */
+#define SX_OR_S		(0x7  21)	/* vector OR scalar */
+/* immediates are 7bit sign extended to 32bit */
+
+#define SX_ANDV(sa, sb, d, cnt) (0xb000 | ((cnt)  24) | SX_AND_V | \
+		((sa)  14) | ((sb)  7) | (d))
+#define SX_ANDS(sa, sb, d, cnt) (0xb000 | ((cnt)  24) | SX_AND_S | \
+		

CVS commit: src/sys/arch/sparc/dev

2013-06-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jun  5 18:15:06 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add a bunch more instructions ( still not complete but we're getting there )


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc/dev/sxreg.h

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



CVS commit: src/sys/arch/sparc/dev

2013-06-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jun  4 13:42:37 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: cgfourteen.c

Log Message:
actually map the whole SX IO space instead of just the first page over and
over again (doh)


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/sparc/dev/cgfourteen.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/sparc/dev/cgfourteen.c
diff -u src/sys/arch/sparc/dev/cgfourteen.c:1.73 src/sys/arch/sparc/dev/cgfourteen.c:1.74
--- src/sys/arch/sparc/dev/cgfourteen.c:1.73	Wed May 29 22:26:39 2013
+++ src/sys/arch/sparc/dev/cgfourteen.c	Tue Jun  4 13:42:37 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgfourteen.c,v 1.73 2013/05/29 22:26:39 macallan Exp $ */
+/*	$NetBSD: cgfourteen.c,v 1.74 2013/06/04 13:42:37 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -564,7 +564,8 @@ cgfourteenmmap(dev_t dev, off_t off, int
 	} else if (off = CG14_SXIO_VOFF 
 		   off  (CG14_SXIO_VOFF + 0x03ff)) {
 		return (bus_space_mmap(sc-sc_sx-sc_tag, 0x8LL,
-			sc-sc_fb_paddr, prot, BUS_SPACE_MAP_LINEAR));
+			sc-sc_fb_paddr + (off - CG14_SXIO_VOFF),
+			prot, BUS_SPACE_MAP_LINEAR));
 #endif
 	} else
 		return -1;



CVS commit: src/sys/arch/sparc/dev

2013-06-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jun  4 22:30:30 UTC 2013

Modified Files:
src/sys/arch/sparc/dev: sxreg.h

Log Message:
add STore with (plane) Mask instruction


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc/dev/sxreg.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/sparc/dev/sxreg.h
diff -u src/sys/arch/sparc/dev/sxreg.h:1.5 src/sys/arch/sparc/dev/sxreg.h:1.6
--- src/sys/arch/sparc/dev/sxreg.h:1.5	Thu May 30 20:09:23 2013
+++ src/sys/arch/sparc/dev/sxreg.h	Tue Jun  4 22:30:30 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sxreg.h,v 1.5 2013/05/30 20:09:23 macallan Exp $	*/
+/*	$NetBSD: sxreg.h,v 1.6 2013/06/04 22:30:30 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -152,6 +152,8 @@
 SX_PACKED | (dreg  7) | (o))
 #define SX_ST(sreg, cnt, o)  (0x8000 | ((cnt)  23) | SX_STORE | \
 SX_LONG | (sreg  7) | (o))
+#define SX_STM(sreg, cnt, o)  (0x8000 | ((cnt)  23) | SX_STORE_MASK | \
+SX_LONG | (sreg  7) | (o))
 #define SX_STB(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \
 SX_UBYTE_0 | (sreg  7) | (o))
 #define SX_STP(sreg, cnt, o) (0x8000 | ((cnt)  23) | SX_STORE | \



  1   2   >