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

2024-07-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jul 12 08:45:05 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
STIDEBUG -> GFTFB_DEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.14 src/sys/arch/hppa/dev/gftfb.c:1.15
--- src/sys/arch/hppa/dev/gftfb.c:1.14	Thu Apr 18 04:52:43 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Fri Jul 12 08:45:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.14 2024/04/18 04:52:43 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.15 2024/07/12 08:45:05 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -47,15 +47,12 @@
 #include 
 #include 
 
-#ifdef STIDEBUG
-#define	DPRINTF(s)	do {	\
-	if (stidebug)		\
-		printf s;	\
-} while(0)
+#include "opt_gftfb.h"
 
-extern int stidebug;
+#ifdef GFTFB_DEBUG
+#define	DPRINTF(s) printf(s)
 #else
-#define	DPRINTF(s)	/* */
+#define	DPRINTF(s) /* */
 #endif
 
 int	gftfb_match(device_t, cfdata_t, void *);
@@ -425,7 +422,7 @@ gftfb_check_rom(struct gftfb_softc *spc,
 		offs + 0x0c);
 		subsize <<= 9;
 
-#ifdef STIDEBUG
+#ifdef GFTFB_DEBUG
 		gftfb_disable_rom_internal(spc);
 		DPRINTF(("ROM offset %08x size %08x type %08x",
 		(u_int)offs, (u_int)subsize, tmp));
@@ -473,7 +470,7 @@ gftfb_check_rom(struct gftfb_softc *spc,
 			break;
 #endif
 		default:
-#ifdef STIDEBUG
+#ifdef GFTFB_DEBUG
 			DPRINTF((" (wrong architecture)"));
 #endif
 			break;



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

2024-07-12 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jul 12 08:45:05 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
STIDEBUG -> GFTFB_DEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-04-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 18 04:52:43 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
allow mapping of blitter registers


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.13 src/sys/arch/hppa/dev/gftfb.c:1.14
--- src/sys/arch/hppa/dev/gftfb.c:1.13	Mon Apr  1 09:48:58 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Thu Apr 18 04:52:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.13 2024/04/01 09:48:58 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.14 2024/04/18 04:52:43 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -237,7 +237,8 @@ gftfb_attach(device_t parent, device_t s
 	}
 	rom = (struct sti_rom *)kmem_zalloc(sizeof(*rom), KM_SLEEP);
 	rom->rom_softc = >sc_base;
-	ret = sti_rom_setup(rom, paa->pa_iot, paa->pa_memt, sc->sc_romh, sc->sc_base.bases, STI_CODEBASE_MAIN);
+	ret = sti_rom_setup(rom, paa->pa_iot, paa->pa_memt, sc->sc_romh,
+	sc->sc_base.bases, STI_CODEBASE_MAIN);
 	if (ret != 0) {
 		kmem_free(rom, sizeof(*rom));
 		return;
@@ -889,16 +890,22 @@ gftfb_mmap(void *v, void *vs, off_t offs
 	struct vcons_data *vd = v;
 	struct gftfb_softc *sc = vd->cookie;
 	struct sti_rom *rom = sc->sc_base.sc_rom;
-	paddr_t pa;
+	paddr_t pa = -1;
 
-	if (offset < 0 || offset >= sc->sc_scr.fblen)
-		return -1;
 
-	if (sc->sc_mode != WSDISPLAYIO_MODE_DUMBFB)
+	if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL)
 		return -1;
 
-	pa = bus_space_mmap(rom->memt, sc->sc_scr.fbaddr, offset, prot,
-	BUS_SPACE_MAP_LINEAR);
+	if (offset >= 0 || offset < sc->sc_scr.fblen) {
+		/* framebuffer */
+		pa = bus_space_mmap(rom->memt, sc->sc_scr.fbaddr, offset,
+		prot, BUS_SPACE_MAP_LINEAR);
+	} else if (offset >= 0x8000 && offset < 0x804) {
+		/* blitter registers etc. */
+		pa = bus_space_mmap(rom->memt, rom->regh[2],
+		offset - 0x8000, prot, BUS_SPACE_MAP_LINEAR);
+	}
+
 	return pa;
 }
 



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

2024-04-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 18 04:52:43 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
allow mapping of blitter registers


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-04-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Apr  1 09:48:58 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
make gftfb_restore_palette() grab the default colour map from rasops instead
of just writing the driver's map into the hardware ( which may have been
modified by the likes of wsfb )
With this we get a readable console even when exiting X in a less than
graceful manner.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.12 src/sys/arch/hppa/dev/gftfb.c:1.13
--- src/sys/arch/hppa/dev/gftfb.c:1.12	Thu Mar 28 12:50:31 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Mon Apr  1 09:48:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.12 2024/03/28 12:50:31 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.13 2024/04/01 09:48:58 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -212,8 +212,7 @@ gftfb_attach(device_t parent, device_t s
 	struct rasops_info *ri;
 	struct wsemuldisplaydev_attach_args aa;
 	unsigned long defattr = 0;
-	int ret, is_console = 0, i, j;
-	uint8_t cmap[768];
+	int ret, is_console = 0;
 
 	sc->sc_dev = self;
 
@@ -329,15 +328,7 @@ gftfb_attach(device_t parent, device_t s
 defattr);
 	}
 
-	j = 0;
-	rasops_get_cmap(ri, cmap, sizeof(cmap));
-	for (i = 0; i < 256; i++) {
-		sc->sc_cmap_red[i] = cmap[j];
-		sc->sc_cmap_green[i] = cmap[j + 1];
-		sc->sc_cmap_blue[i] = cmap[j + 2];
-		gftfb_putpalreg(sc, i, cmap[j], cmap[j + 1], cmap[j + 2]);
-		j += 3;
-	}
+	gftfb_restore_palette(sc);
 
 	/* no suspend/resume support yet */
 	if (!pmf_device_register(sc->sc_dev, NULL, NULL))
@@ -1008,11 +999,17 @@ gftfb_getcmap(struct gftfb_softc *sc, st
 static void
 gftfb_restore_palette(struct gftfb_softc *sc)
 {
-	int i;
+	uint8_t cmap[768];
+	int i, j;
 
+	j = 0;
+	rasops_get_cmap(>sc_console_screen.scr_ri, cmap, sizeof(cmap));
 	for (i = 0; i < 256; i++) {
-		gftfb_putpalreg(sc, i, sc->sc_cmap_red[i],
-		sc->sc_cmap_green[i], sc->sc_cmap_blue[i]);
+		sc->sc_cmap_red[i] = cmap[j];
+		sc->sc_cmap_green[i] = cmap[j + 1];
+		sc->sc_cmap_blue[i] = cmap[j + 2];
+		gftfb_putpalreg(sc, i, cmap[j], cmap[j + 1], cmap[j + 2]);
+		j += 3;
 	}
 }
 



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

2024-04-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Apr  1 09:48:58 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
make gftfb_restore_palette() grab the default colour map from rasops instead
of just writing the driver's map into the hardware ( which may have been
modified by the likes of wsfb )
With this we get a readable console even when exiting X in a less than
graceful manner.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-03-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Mar 28 12:50:31 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
For some reason the drawing engine occasionally scribbles past the right
boundary when filling rectangles, especially annoying when we draw whitespaces
As a workaround we draw all rectangles less than 50 pixels wide by drawing
a 50 pixel rectangle into off-screen memory to the right of the visible fb and
then copy the portion we want. Keeps track of the colour and size of the
off-screen rectangle so we can avoid redrawing it whenever possible.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-03-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Mar 28 12:50:31 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
For some reason the drawing engine occasionally scribbles past the right
boundary when filling rectangles, especially annoying when we draw whitespaces
As a workaround we draw all rectangles less than 50 pixels wide by drawing
a 50 pixel rectangle into off-screen memory to the right of the visible fb and
then copy the portion we want. Keeps track of the colour and size of the
off-screen rectangle so we can avoid redrawing it whenever possible.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.11 src/sys/arch/hppa/dev/gftfb.c:1.12
--- src/sys/arch/hppa/dev/gftfb.c:1.11	Wed Mar 27 09:08:38 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Thu Mar 28 12:50:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.11 2024/03/27 09:08:38 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.12 2024/03/28 12:50:31 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -88,6 +88,7 @@ struct	gftfb_softc {
 #define HW_FB	0
 #define HW_FILL	1
 #define HW_BLIT	2
+	uint32_t sc_rect_colour, sc_rect_height;
 	/* cursor stuff */
 	int sc_cursor_x, sc_cursor_y;
 	int sc_hot_x, sc_hot_y, sc_enabled;
@@ -250,7 +251,9 @@ gftfb_attach(device_t parent, device_t s
 
 	sc->sc_width = sc->sc_scr.scr_cfg.scr_width;
 	sc->sc_height = sc->sc_scr.scr_cfg.scr_height;
-	
+	sc->sc_rect_colour = 0xf000;
+	sc->sc_rect_height = 0;
+
 	aprint_normal_dev(sc->sc_dev, "%s at %dx%d\n", sc->sc_scr.name, 
 	sc->sc_width, sc->sc_height);
 	gftfb_setup(sc);
@@ -687,6 +690,9 @@ gftfb_setup(struct gftfb_softc *sc)
 	sc->sc_enabled = 0;
 	sc->sc_video_on = 1;
 
+	sc->sc_rect_colour = 0xf000;
+	sc->sc_rect_height = 0;
+
 	/* set Bt458 read mask register to all planes */
 	gftfb_wait(sc);
 	ngle_bt458_write(memt, memh, 0x08, 0x04);
@@ -1051,7 +1057,7 @@ gftfb_wait_fifo(struct gftfb_softc *sc, 
 }
 
 static void
-gftfb_rectfill(struct gftfb_softc *sc, int x, int y, int wi, int he,
+gftfb_real_rectfill(struct gftfb_softc *sc, int x, int y, int wi, int he,
 		  uint32_t bg)
 {
 	struct sti_rom *rom = sc->sc_base.sc_rom;
@@ -1081,6 +1087,30 @@ gftfb_rectfill(struct gftfb_softc *sc, i
 
 }
 
+static void
+gftfb_rectfill(struct gftfb_softc *sc, int x, int y, int wi, int he,
+		  uint32_t bg)
+{
+	/*
+	 * For some reason my 4MB VisEG always draws rectangles at least 32
+	 * pixels wide - no idea why, the bitblt command doesn't have this
+	 * problem.
+	 * So, as a workaround, we draw a 50xFontHeight rectangle to the right
+	 * of the visible fb, keep track of the colour so we don't need to
+	 * redraw every time, and bitblt the portion we need
+	 */
+	if (wi < 50) {
+		if ((bg != sc->sc_rect_colour) ||
+		(he > sc->sc_rect_height)) {
+			gftfb_real_rectfill(sc, sc->sc_width + 10, 0, 50, 
+			he, bg);
+			sc->sc_rect_colour = bg;
+			sc->sc_rect_height = he;
+		}
+		gftfb_bitblt(sc, sc->sc_width + 10, 0, x, y, wi, he, RopSrc);
+	} else
+		gftfb_real_rectfill(sc, x, y, wi, he, bg);
+}
 
 static void
 gftfb_bitblt(void *cookie, int xs, int ys, int xd, int yd, int wi,
@@ -1161,9 +1191,8 @@ gftfb_putchar(void *cookie, int row, int
 	struct vcons_screen *scr = ri->ri_hw;
 	struct gftfb_softc *sc = scr->scr_cookie;
 	int x, y, wi, he, rv = GC_NOPE;
-#if 0
 	uint32_t bg;
-#endif
+
 	if (sc->sc_mode != WSDISPLAYIO_MODE_EMUL)
 		return;
 
@@ -1179,20 +1208,14 @@ gftfb_putchar(void *cookie, int row, int
 
 	x = ri->ri_xorigin + col * wi;
 	y = ri->ri_yorigin + row * he;
-#if 0
+
 	bg = ri->ri_devcmap[(attr >> 16) & 0xf];
 
-	/* XXX
-	 * rectfill currently draws rectangles less than 32 pixels wide as
-	 * 32 pixels wide, no idea why. So until I figure that one out we 
-	 * draw blanks by software
-	 * bitblt doesn't seem to have this problem
-	 */
 	if (c == 0x20) {
 		gftfb_rectfill(sc, x, y, wi, he, bg);
 		return;
 	}
-#endif
+
 	rv = glyphcache_try(>sc_gc, c, x, y, attr);
 	if (rv == GC_OK)
 		return;



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

2024-03-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Mar 27 09:08:38 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
fix brainfart - only update fbi_fbsize, not the size of the visible fb...


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-03-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Mar 27 09:08:38 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
fix brainfart - only update fbi_fbsize, not the size of the visible fb...


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.10 src/sys/arch/hppa/dev/gftfb.c:1.11
--- src/sys/arch/hppa/dev/gftfb.c:1.10	Wed Mar 27 06:52:03 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Wed Mar 27 09:08:38 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.10 2024/03/27 06:52:03 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.11 2024/03/27 09:08:38 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -839,7 +839,6 @@ gftfb_ioctl(void *v, void *vs, u_long cm
 			int ret;
 
 			ret = wsdisplayio_get_fbinfo(>scr_ri, fbi);
-			fbi->fbi_height = sc->sc_scr.fbheight;
 			fbi->fbi_fbsize = sc->sc_scr.fbheight * 2048;
 			return ret;
 		}



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

2024-03-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Mar 27 06:52:03 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
in gftfb_ioctl():
- identify ourselves as WSDISPLAY_TYPE_STI
- return full fb geometry in WSDISPLAYIO_GET_FBINFO


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-03-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Mar 27 06:52:03 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
in gftfb_ioctl():
- identify ourselves as WSDISPLAY_TYPE_STI
- return full fb geometry in WSDISPLAYIO_GET_FBINFO


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.9 src/sys/arch/hppa/dev/gftfb.c:1.10
--- src/sys/arch/hppa/dev/gftfb.c:1.9	Wed Mar  6 08:19:44 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Wed Mar 27 06:52:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.9 2024/03/06 08:19:44 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.10 2024/03/27 06:52:03 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -780,7 +780,7 @@ gftfb_ioctl(void *v, void *vs, u_long cm
 
 	switch (cmd) {
 	case WSDISPLAYIO_GTYPE:
-		*(u_int *)data = WSDISPLAY_TYPE_PCIMISC;
+		*(u_int *)data = WSDISPLAY_TYPE_STI;
 		return 0;
 
 	/* PCI config read/write passthrough. */
@@ -834,11 +834,15 @@ gftfb_ioctl(void *v, void *vs, u_long cm
 		return 0;
 
 	case WSDISPLAYIO_GET_FBINFO:
-	{
+		{
 			struct wsdisplayio_fbinfo *fbi = data;
+			int ret;
 
-		return wsdisplayio_get_fbinfo(>scr_ri, fbi);
-	}
+			ret = wsdisplayio_get_fbinfo(>scr_ri, fbi);
+			fbi->fbi_height = sc->sc_scr.fbheight;
+			fbi->fbi_fbsize = sc->sc_scr.fbheight * 2048;
+			return ret;
+		}
 
 	case WSDISPLAYIO_GCURPOS:
 		{



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

2024-03-06 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Mar  6 08:19:44 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
if the framebuffer is wider than the visible area, use the full width for the
glyphcache


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-03-06 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Mar  6 08:19:44 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
if the framebuffer is wider than the visible area, use the full width for the
glyphcache


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.8 src/sys/arch/hppa/dev/gftfb.c:1.9
--- src/sys/arch/hppa/dev/gftfb.c:1.8	Wed Feb 28 14:12:12 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Wed Mar  6 08:19:44 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.8 2024/02/28 14:12:12 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.9 2024/03/06 08:19:44 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -294,7 +294,7 @@ gftfb_attach(device_t parent, device_t s
 
 		glyphcache_init(>sc_gc, sc->sc_height + 5,
 sc->sc_scr.fbheight - sc->sc_height - 5,
-sc->sc_width,
+sc->sc_scr.fbwidth,
 ri->ri_font->fontwidth,
 ri->ri_font->fontheight,
 defattr);
@@ -320,7 +320,7 @@ gftfb_attach(device_t parent, device_t s
 
 		glyphcache_init(>sc_gc, sc->sc_height + 5,
 sc->sc_scr.fbheight - sc->sc_height - 5,
-sc->sc_width,
+sc->sc_scr.fbwidth,
 ri->ri_font->fontwidth,
 ri->ri_font->fontheight,
 defattr);



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

2024-02-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Feb 28 14:12:12 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
support WSDISPLAYIO_SVIDEO so X can turn the monitor off
so far I only know how to turn off video output, not sync(s). Better than
nothing though.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.7 src/sys/arch/hppa/dev/gftfb.c:1.8
--- src/sys/arch/hppa/dev/gftfb.c:1.7	Wed Feb 28 10:25:36 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Wed Feb 28 14:12:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.7 2024/02/28 10:25:36 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.8 2024/02/28 14:12:12 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -91,7 +91,7 @@ struct	gftfb_softc {
 	/* cursor stuff */
 	int sc_cursor_x, sc_cursor_y;
 	int sc_hot_x, sc_hot_y, sc_enabled;
-	uint32_t sc_pos;
+	int sc_video_on;
 	glyphcache sc_gc;
 };
 
@@ -148,6 +148,8 @@ static void	gftfb_eraserows(void *, int,
 static void	gftfb_move_cursor(struct gftfb_softc *, int, int);
 static int	gftfb_do_cursor(struct gftfb_softc *, struct wsdisplay_cursor *);
 
+static void	gftfb_set_video(struct gftfb_softc *, int);
+
 struct wsdisplay_accessops gftfb_accessops = {
 	gftfb_ioctl,
 	gftfb_mmap,
@@ -683,6 +685,7 @@ gftfb_setup(struct gftfb_softc *sc)
 	sc->sc_hot_x = 0;
 	sc->sc_hot_y = 0;
 	sc->sc_enabled = 0;
+	sc->sc_video_on = 1;
 
 	/* set Bt458 read mask register to all planes */
 	gftfb_wait(sc);
@@ -824,6 +827,7 @@ gftfb_ioctl(void *v, void *vs, u_long cm
 sc->sc_height, ms->scr_ri.ri_devcmap[
 (ms->scr_defattr >> 16) & 0xff]);
 vcons_redraw_screen(ms);
+gftfb_set_video(sc, 1);
 			}
 		}
 		}
@@ -868,8 +872,14 @@ gftfb_ioctl(void *v, void *vs, u_long cm
 
 			return gftfb_do_cursor(sc, cursor);
 		}
-	}
 
+	case WSDISPLAYIO_SVIDEO:
+		gftfb_set_video(sc, *(int *)data);
+		return 0;
+	case WSDISPLAYIO_GVIDEO:
+		return sc->sc_video_on ? 
+		WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF;
+	}
 	return EPASSTHROUGH;
 }
 
@@ -1464,3 +1474,29 @@ gftfb_do_cursor(struct gftfb_softc *sc, 
 
 	return 0;
 }
+
+static void
+gftfb_set_video(struct gftfb_softc *sc, int on)
+{
+	struct sti_rom *rom = sc->sc_base.sc_rom;
+	bus_space_tag_t memt = rom->memt;
+	bus_space_handle_t memh = rom->regh[2];
+
+	if (sc->sc_video_on == on)
+		return;
+		
+	sc->sc_video_on = on;
+
+	gftfb_wait(sc);
+	if (on) {
+		bus_space_write_stream_4(memt, memh, NGLE_REG_21,
+		bus_space_read_stream_4(memt, memh, NGLE_REG_21) | 0x0a00);
+		bus_space_write_stream_4(memt, memh, NGLE_REG_27,
+		bus_space_read_stream_4(memt, memh, NGLE_REG_27) | 0x0080);
+	} else {
+		bus_space_write_stream_4(memt, memh, NGLE_REG_21,
+		bus_space_read_stream_4(memt, memh, NGLE_REG_21) &  ~0x0a00);
+		bus_space_write_stream_4(memt, memh, NGLE_REG_27,
+		bus_space_read_stream_4(memt, memh, NGLE_REG_27) & ~0x0080);
+	}
+}



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

2024-02-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Feb 28 14:12:12 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
support WSDISPLAYIO_SVIDEO so X can turn the monitor off
so far I only know how to turn off video output, not sync(s). Better than
nothing though.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-02-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Feb 28 10:25:36 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
add hardware cursor support, mostly for X


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-02-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Feb 28 10:25:36 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
add hardware cursor support, mostly for X


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.6 src/sys/arch/hppa/dev/gftfb.c:1.7
--- src/sys/arch/hppa/dev/gftfb.c:1.6	Wed Feb 21 13:24:40 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Wed Feb 28 10:25:36 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.6 2024/02/21 13:24:40 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.7 2024/02/28 10:25:36 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -82,10 +83,15 @@ struct	gftfb_softc {
 	u_char sc_cmap_red[256];
 	u_char sc_cmap_green[256];
 	u_char sc_cmap_blue[256];
+	kmutex_t sc_hwlock;
 	uint32_t sc_hwmode;
 #define HW_FB	0
 #define HW_FILL	1
 #define HW_BLIT	2
+	/* cursor stuff */
+	int sc_cursor_x, sc_cursor_y;
+	int sc_hot_x, sc_hot_y, sc_enabled;
+	uint32_t sc_pos;
 	glyphcache sc_gc;
 };
 
@@ -139,6 +145,9 @@ static void	gftfb_erasecols(void *, int,
 static void	gftfb_copyrows(void *, int, int, int);
 static void	gftfb_eraserows(void *, int, int, long);
 
+static void	gftfb_move_cursor(struct gftfb_softc *, int, int);
+static int	gftfb_do_cursor(struct gftfb_softc *, struct wsdisplay_cursor *);
+
 struct wsdisplay_accessops gftfb_accessops = {
 	gftfb_ioctl,
 	gftfb_mmap,
@@ -175,6 +184,8 @@ struct wsdisplay_accessops gftfb_accesso
 #define	MaskDynamic	1	/* Mask register reloaded by direct access */
 #define	MaskOtc	0	/* Mask contains Object Count valid bits */
 
+static inline void gftfb_wait_fifo(struct gftfb_softc *, uint32_t);
+
 int
 gftfb_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -209,6 +220,9 @@ gftfb_attach(device_t parent, device_t s
 	sc->sc_base.sc_enable_rom = gftfb_enable_rom;
 	sc->sc_base.sc_disable_rom = gftfb_disable_rom;
 
+	/* we can *not* be interrupted when doing colour map accesses */
+	mutex_init(>sc_hwlock, MUTEX_DEFAULT, IPL_HIGH);
+
 	aprint_normal("\n");
 
 	if (gftfb_check_rom(sc, paa) != 0)
@@ -663,8 +677,12 @@ gftfb_setup(struct gftfb_softc *sc)
 	struct sti_rom *rom = sc->sc_base.sc_rom;
 	bus_space_tag_t memt = rom->memt;
 	bus_space_handle_t memh = rom->regh[2];
+	int i;	
 
 	sc->sc_hwmode = HW_FB;
+	sc->sc_hot_x = 0;
+	sc->sc_hot_y = 0;
+	sc->sc_enabled = 0;
 
 	/* set Bt458 read mask register to all planes */
 	gftfb_wait(sc);
@@ -702,6 +720,50 @@ gftfb_setup(struct gftfb_softc *sc)
 	bus_space_read_stream_4(memt, memh, NGLE_REG_21) | 0x0a00);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_27,
 	bus_space_read_stream_4(memt, memh, NGLE_REG_27) | 0x0080);
+
+	/* initialize cursor sprite */
+	gftfb_wait(sc);
+	
+	/* cursor mask */
+	gftfb_wait(sc);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_14, 0x300);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_13, 0x);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_11, 0x28A07000);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_3, 0);
+	for (i = 0; i < 64; i++) {
+		bus_space_write_stream_4(memt, memh, NGLE_REG_4, 0x);
+		bus_space_write_stream_4(memt, memh, NGLE_REG_5, 0x);
+	}
+
+	/* cursor image */
+	gftfb_wait(sc);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_14, 0x300);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_13, 0x);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_11, 0x28A06000);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_3, 0);
+	for (i = 0; i < 64; i++) {
+		bus_space_write_stream_4(memt, memh, NGLE_REG_4, 0xff00ff00);
+		bus_space_write_stream_4(memt, memh, NGLE_REG_5, 0xff00ff00);
+	}
+
+	/* colour map */
+	gftfb_wait(sc);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_10, 0xBBE0F000);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_14, 0x03000300);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_13, 0x);
+	gftfb_wait(sc);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_3, 0);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_4, 0);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_4, 0);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_4, 0x00ff);	/* BG */
+	bus_space_write_stream_4(memt, memh, NGLE_REG_4, 0x00ff);	/* FG */
+	gftfb_wait(sc);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_2, 0);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_26, 0x80008004);
+	gftfb_setup_fb(sc);	
+
+	gftfb_move_cursor(sc, 100, 100);
+
 }
 
 static int
@@ -773,7 +835,41 @@ gftfb_ioctl(void *v, void *vs, u_long cm
 
 		return wsdisplayio_get_fbinfo(>scr_ri, fbi);
 	}
+
+	case WSDISPLAYIO_GCURPOS:
+		{
+			struct wsdisplay_curpos *cp = (void *)data;
+
+			cp->x = sc->sc_cursor_x;
+			cp->y = sc->sc_cursor_y;
+		}
+		return 

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

2024-02-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Feb 21 13:24:40 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
avoid one more instance of unnecessary blitter stalling


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.5 src/sys/arch/hppa/dev/gftfb.c:1.6
--- src/sys/arch/hppa/dev/gftfb.c:1.5	Wed Feb 21 13:04:01 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Wed Feb 21 13:24:40 2024
@@ -1,9 +1,10 @@
-/*	$NetBSD: gftfb.c,v 1.5 2024/02/21 13:04:01 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.6 2024/02/21 13:24:40 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
 /*
  * Copyright (c) 2006, 2007 Miodrag Vallat.
+ ^ 2024 Michael Lorenz
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -19,6 +20,11 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+/*
+ * a native driver for HP Visualize EG PCI graphics cards
+ * STI portions are from Miodrag Vallat's sti_pci.c
+ */
+
 #include 
 #include 
 #include 
@@ -974,15 +980,17 @@ gftfb_bitblt(void *cookie, int xs, int y
 	bus_space_tag_t memt = rom->memt;
 	bus_space_handle_t memh = rom->regh[2];
 
-	gftfb_wait(sc);
-	bus_space_write_stream_4(memt, memh, NGLE_REG_10, 0x13a01000);
+	if (sc->sc_hwmode != HW_BLIT) {
+		gftfb_wait(sc);
+		bus_space_write_stream_4(memt, memh, NGLE_REG_10, 0x13a01000);
+		sc->sc_hwmode = HW_BLIT;
+	}
 	gftfb_wait_fifo(sc, 5);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_14, ((rop << 8) & 0xf00) | 0x2300);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_13, 0xff);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_24, (xs << 16) | ys);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_7, (wi << 16) | he);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_25, (xd << 16) | yd);
-	sc->sc_hwmode = HW_BLIT;
 }
 
 static void



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

2024-02-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Feb 21 13:24:40 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
avoid one more instance of unnecessary blitter stalling


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-02-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Feb 21 13:04:01 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
keep track of hw settings for blitter, fill of fb access to avoid unnecessary
register writes
while there, remove some accidentially left in debug goop


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.4 src/sys/arch/hppa/dev/gftfb.c:1.5
--- src/sys/arch/hppa/dev/gftfb.c:1.4	Tue Feb 20 15:54:44 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Wed Feb 21 13:04:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.4 2024/02/20 15:54:44 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.5 2024/02/21 13:04:01 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -76,7 +76,10 @@ struct	gftfb_softc {
 	u_char sc_cmap_red[256];
 	u_char sc_cmap_green[256];
 	u_char sc_cmap_blue[256];
-	uint32_t sc_reg10;
+	uint32_t sc_hwmode;
+#define HW_FB	0
+#define HW_FILL	1
+#define HW_BLIT	2
 	glyphcache sc_gc;
 };
 
@@ -645,6 +648,7 @@ gftfb_setup_fb(struct gftfb_softc *sc)
 	bus_space_write_stream_4(memt, memh, NGLE_REG_14, 0x83000300);
 	gftfb_wait(sc);
 	bus_space_write_1(memt, memh, NGLE_REG_16b1, 1);
+	sc->sc_hwmode = HW_FB;
 }
 
 void
@@ -654,7 +658,7 @@ gftfb_setup(struct gftfb_softc *sc)
 	bus_space_tag_t memt = rom->memt;
 	bus_space_handle_t memh = rom->regh[2];
 
-	sc->sc_reg10 = 0;
+	sc->sc_hwmode = HW_FB;
 
 	/* set Bt458 read mask register to all planes */
 	gftfb_wait(sc);
@@ -674,6 +678,10 @@ gftfb_setup(struct gftfb_softc *sc)
 	bus_space_write_stream_4(memt, memh, NGLE_REG_6, 0x);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_9,
 	(sc->sc_scr.scr_cfg.scr_width << 16) | sc->sc_scr.scr_cfg.scr_height);
+	/*
+	 * blit into offscreen memory to force flush previous - apparently 
+	 * some chips have a bug this works around
+	 */
 	bus_space_write_stream_4(memt, memh, NGLE_REG_6, 0x0500);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_9, 0x00040001);
 
@@ -682,6 +690,7 @@ gftfb_setup(struct gftfb_softc *sc)
 
 	gftfb_setup_fb(sc);
 
+	/* make sure video output is enabled */
 	gftfb_wait(sc);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_21,
 	bus_space_read_stream_4(memt, memh, NGLE_REG_21) | 0x0a00);
@@ -741,7 +750,7 @@ gftfb_ioctl(void *v, void *vs, u_long cm
 			sc->sc_mode = new_mode;
 			if(new_mode == WSDISPLAYIO_MODE_EMUL) {
 gftfb_setup(sc);
-if (0) gftfb_restore_palette(sc);
+gftfb_restore_palette(sc);
 glyphcache_wipe(>sc_gc);
 gftfb_rectfill(sc, 0, 0, sc->sc_width,
 sc->sc_height, ms->scr_ri.ri_devcmap[
@@ -932,19 +941,22 @@ gftfb_rectfill(struct gftfb_softc *sc, i
 	bus_space_tag_t memt = rom->memt;
 	bus_space_handle_t memh = rom->regh[2];
 
-	gftfb_wait_fifo(sc, 5);
-	/* transfer data */
-	bus_space_write_stream_4(memt, memh, NGLE_REG_8, 0x);
+	if (sc->sc_hwmode != HW_FILL) {
+		gftfb_wait_fifo(sc, 4);
+		/* transfer data */
+		bus_space_write_stream_4(memt, memh, NGLE_REG_8, 0x);
+		/* plane mask */
+		bus_space_write_stream_4(memt, memh, NGLE_REG_13, 0xff);
+		/* bitmap op */
+		bus_space_write_stream_4(memt, memh, NGLE_REG_14, 
+		IBOvals(RopSrc, 0, BitmapExtent08, 0, DataDynamic, MaskOtc, 0, 0));
+		/* dst bitmap access */
+		bus_space_write_stream_4(memt, memh, NGLE_REG_11,
+		BA(IndexedDcd, Otc32, OtsIndirect, AddrLong, 0, BINapp0I, 0));
+		sc->sc_hwmode = HW_FILL;
+	}
+	gftfb_wait_fifo(sc, 3);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_35, bg);
-	/* plane mask */
-	bus_space_write_stream_4(memt, memh, NGLE_REG_13, 0xff);
-	/* bitmap op */
-	bus_space_write_stream_4(memt, memh, NGLE_REG_14, 
-	IBOvals(RopSrc, 0, BitmapExtent08, 0, DataDynamic, MaskOtc, 0, 0));
-	/* dst bitmap access */
-	bus_space_write_stream_4(memt, memh, NGLE_REG_11,
-	BA(IndexedDcd, Otc32, OtsIndirect, AddrLong, 0, BINapp0I, 0));
-	gftfb_wait_fifo(sc, 2);
 	/* dst XY */
 	bus_space_write_stream_4(memt, memh, NGLE_REG_6, (x << 16) | y);
 	/* len XY start */
@@ -970,6 +982,7 @@ gftfb_bitblt(void *cookie, int xs, int y
 	bus_space_write_stream_4(memt, memh, NGLE_REG_24, (xs << 16) | ys);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_7, (wi << 16) | he);
 	bus_space_write_stream_4(memt, memh, NGLE_REG_25, (xd << 16) | yd);
+	sc->sc_hwmode = HW_BLIT;
 }
 
 static void
@@ -1065,7 +1078,7 @@ gftfb_putchar(void *cookie, int row, int
 	if (rv == GC_OK)
 		return;
 
-	gftfb_setup_fb(sc);
+	if (sc->sc_hwmode != HW_FB) gftfb_setup_fb(sc);
 	sc->sc_putchar(cookie, row, col, c, attr);
 
 	if (rv == GC_ADD)



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

2024-02-21 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Feb 21 13:04:01 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
keep track of hw settings for blitter, fill of fb access to avoid unnecessary
register writes
while there, remove some accidentially left in debug goop


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-02-20 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Feb 20 15:54:44 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
play the same lazy cursor (un)draw trick as cgsix and friends
visible speedup in things like systat


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.3 src/sys/arch/hppa/dev/gftfb.c:1.4
--- src/sys/arch/hppa/dev/gftfb.c:1.3	Tue Feb 20 11:37:43 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Tue Feb 20 15:54:44 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.3 2024/02/20 11:37:43 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.4 2024/02/20 15:54:44 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -973,6 +973,23 @@ gftfb_bitblt(void *cookie, int xs, int y
 }
 
 static void
+gftfb_nuke_cursor(struct rasops_info *ri)
+{
+	struct vcons_screen *scr = ri->ri_hw;
+	struct gftfb_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;
+		gftfb_bitblt(sc, x, y, x, y, wi, he, RopInv);
+		ri->ri_flg &= ~RI_CURSOR;
+	}
+}
+
+static void
 gftfb_cursor(void *cookie, int on, int row, int col)
 {
 	struct rasops_info *ri = cookie;
@@ -984,24 +1001,22 @@ gftfb_cursor(void *cookie, int on, int r
 	he = ri->ri_font->fontheight;
 	
 	if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
-		if (ri->ri_flg & RI_CURSOR) {
-			x = ri->ri_ccol * wi + ri->ri_xorigin;
-			y = ri->ri_crow * he + ri->ri_yorigin;
-			gftfb_bitblt(sc, x, y, x, y, wi, he, RopInv);
-			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) {
+gftfb_nuke_cursor(ri);
+			}
+			x = col * wi + ri->ri_xorigin;
+			y = row * he + ri->ri_yorigin;
 			gftfb_bitblt(sc, x, y, x, y, wi, he, RopInv);
 			ri->ri_flg |= RI_CURSOR;
 		}
-	} else {
-		scr->scr_ri.ri_crow = row;
-		scr->scr_ri.ri_ccol = col;
-		scr->scr_ri.ri_flg &= ~RI_CURSOR;
+		ri->ri_crow = row;
+		ri->ri_ccol = col;
+	} else
+	{
+		ri->ri_crow = row;
+		ri->ri_ccol = col;
+		ri->ri_flg &= ~RI_CURSOR;
 	}
 
 }
@@ -1023,6 +1038,10 @@ gftfb_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;
 
@@ -1062,12 +1081,21 @@ gftfb_copycols(void *cookie, int row, in
 	int32_t xs, xd, y, width, height;
 	
 	if ((sc->sc_locked == 0) && (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)) {
+			gftfb_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;
 		gftfb_bitblt(sc, xs, y, xd, y, width, height, RopSrc);
+		if (ri->ri_crow == row && 
+		   (ri->ri_ccol >= dstcol && ri->ri_ccol < (dstcol + ncols)))
+			ri->ri_flg &= ~RI_CURSOR;
 	}
 }
 
@@ -1087,6 +1115,9 @@ gftfb_erasecols(void *cookie, int row, i
 		rasops_unpack_attr(fillattr, , , );
 
 		gftfb_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;
 	}
 }
 
@@ -1099,12 +1130,18 @@ gftfb_copyrows(void *cookie, int srcrow,
 	int32_t x, ys, yd, width, height;
 
 	if ((sc->sc_locked == 0) && (sc->sc_mode == WSDISPLAYIO_MODE_EMUL)) {
+		if ((ri->ri_crow >= srcrow && ri->ri_crow < (srcrow + nrows)) &&
+		   (ri->ri_flg & RI_CURSOR)) {
+			gftfb_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;
 		gftfb_bitblt(sc, x, ys, x, yd, width, height, RopSrc);
+		if (ri->ri_crow >= dstrow && ri->ri_crow < (dstrow + nrows))
+			ri->ri_flg &= ~RI_CURSOR;
 	}
 }
 
@@ -1124,5 +1161,8 @@ gftfb_eraserows(void *cookie, int row, i
 		rasops_unpack_attr(fillattr, , , );
 
 		gftfb_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/hppa/dev

2024-02-20 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Feb 20 15:54:44 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
play the same lazy cursor (un)draw trick as cgsix and friends
visible speedup in things like systat


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-02-20 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Feb 20 11:37:43 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
enable glyph cache, anti-aliased fonts etc.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2024-02-20 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Feb 20 11:37:43 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
enable glyph cache, anti-aliased fonts etc.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.2 src/sys/arch/hppa/dev/gftfb.c:1.3
--- src/sys/arch/hppa/dev/gftfb.c:1.2	Thu Feb 15 16:17:32 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Tue Feb 20 11:37:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.2 2024/02/15 16:17:32 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.3 2024/02/20 11:37:43 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -76,6 +76,7 @@ struct	gftfb_softc {
 	u_char sc_cmap_red[256];
 	u_char sc_cmap_green[256];
 	u_char sc_cmap_blue[256];
+	uint32_t sc_reg10;
 	glyphcache sc_gc;
 };
 
@@ -90,15 +91,12 @@ void	gftfb_enable_rom_internal(struct gf
 void	gftfb_disable_rom_internal(struct gftfb_softc *);
 
 void 	gftfb_setup(struct gftfb_softc *);
-void 	gftfb_wait(struct gftfb_softc *);
-void	gftfb_wait_fifo(struct gftfb_softc *, uint32_t);
 
 #define	ngle_bt458_write(memt, memh, r, v) \
 	bus_space_write_stream_4(memt, memh, NGLE_REG_RAMDAC + ((r) << 2), (v) << 24)
 
-void gftfb_setup_fb(struct gftfb_softc *);
 
-/* XXX these really need o go into their own header */
+/* XXX these really need to go into their own header */
 int	sti_pci_is_console(struct pci_attach_args *, bus_addr_t *);
 int	sti_rom_setup(struct sti_rom *, bus_space_tag_t, bus_space_tag_t,
 	bus_space_handle_t, bus_addr_t *, u_int);
@@ -143,6 +141,31 @@ struct wsdisplay_accessops gftfb_accesso
 	NULL	/* scroll */
 };
 
+#define BA(F,C,S,A,J,B,I)		\
+	(((F)<<31)|((C)<<27)|((S)<<24)|((A)<<21)|((J)<<16)|((B)<<12)|(I))
+
+#define IBOvals(R,M,X,S,D,L,B,F)	\
+	(((R)<<8)|((M)<<16)|((X)<<24)|((S)<<29)|((D)<<28)|((L)<<31)|((B)<<1)|(F))
+
+#define	IndexedDcd	0	/* Pixel data is indexed (pseudo) color */
+#define	Otc04	2	/* Pixels in each longword transfer (4) */
+#define	Otc32	5	/* Pixels in each longword transfer (32) */
+#define	Ots08	3	/* Each pixel is size (8)d transfer (1) */
+#define	OtsIndirect	6	/* Each bit goes through FG/BG color(8) */
+#define	AddrLong	5	/* FB address is Long aligned (pixel) */
+#define	BINovly	0x2	/* 8 bit overlay */
+#define	BINapp0I	0x0	/* Application Buffer 0, Indexed */
+#define	BINapp1I	0x1	/* Application Buffer 1, Indexed */
+#define	BINapp0F8	0xa	/* Application Buffer 0, Fractional 8-8-8 */
+#define	BINattr	0xd	/* Attribute Bitmap */
+#define	RopSrc 	0x3
+#define	RopInv 	0xc
+#define	BitmapExtent08  3	/* Each write hits ( 8) bits in depth */
+#define	BitmapExtent32  5	/* Each write hits (32) bits in depth */
+#define	DataDynamic	0	/* Data register reloaded by direct access */
+#define	MaskDynamic	1	/* Mask register reloaded by direct access */
+#define	MaskOtc	0	/* Mask contains Object Count valid bits */
+
 int
 gftfb_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -165,7 +188,7 @@ gftfb_attach(device_t parent, device_t s
 	struct sti_rom *rom;
 	struct rasops_info *ri;
 	struct wsemuldisplaydev_attach_args aa;
-	unsigned long defattr;
+	unsigned long defattr = 0;
 	int ret, is_console = 0, i, j;
 	uint8_t cmap[768];
 
@@ -230,11 +253,10 @@ gftfb_attach(device_t parent, device_t s
 
 	ri = >sc_console_screen.scr_ri;
 
-#if 0
 	sc->sc_gc.gc_bitblt = gftfb_bitblt;
 	sc->sc_gc.gc_blitcookie = sc;
-	sc->sc_gc.gc_rop = 0x0c;
-#endif
+	sc->sc_gc.gc_rop = RopSrc;
+
 	if (is_console) {
 		vcons_init_screen(>vd, >sc_console_screen, 1,
 		);
@@ -244,14 +266,14 @@ gftfb_attach(device_t parent, device_t 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;
-#if 0
+
 		glyphcache_init(>sc_gc, sc->sc_height + 5,
-(0x80 / sc->sc_stride) - sc->sc_height - 5,
+sc->sc_scr.fbheight - sc->sc_height - 5,
 sc->sc_width,
 ri->ri_font->fontwidth,
 ri->ri_font->fontheight,
 defattr);
-#endif
+
 		wsdisplay_cnattach(>sc_defaultscreen_descr, ri, 0, 0,
 		defattr);
 
@@ -270,14 +292,13 @@ gftfb_attach(device_t parent, device_t s
 			);
 		} else
 			(*ri->ri_ops.allocattr)(ri, 0, 0, 0, );
-#if 0
+
 		glyphcache_init(>sc_gc, sc->sc_height + 5,
-(0x80 / sc->sc_stride) - sc->sc_height - 5,
+sc->sc_scr.fbheight - sc->sc_height - 5,
 sc->sc_width,
 ri->ri_font->fontwidth,
 ri->ri_font->fontheight,
 defattr);
-#endif
 	}
 
 	j = 0;
@@ -597,7 +618,7 @@ gftfb_disable_rom(struct sti_softc *sc)
 	CLR(sc->sc_flags, STI_ROM_ENABLED);
 }
 
-void
+static inline void
 gftfb_wait(struct gftfb_softc *sc)
 {
 	struct sti_rom *rom = 

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

2024-02-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Feb 15 16:17:32 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
blitter time!
everything except drawing characters i now done by hardware
next step - glyphcache


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hppa/dev/gftfb.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/hppa/dev/gftfb.c
diff -u src/sys/arch/hppa/dev/gftfb.c:1.1 src/sys/arch/hppa/dev/gftfb.c:1.2
--- src/sys/arch/hppa/dev/gftfb.c:1.1	Tue Feb 13 13:40:13 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Thu Feb 15 16:17:32 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gftfb.c,v 1.1 2024/02/13 13:40:13 macallan Exp $	*/
+/*	$NetBSD: gftfb.c,v 1.2 2024/02/15 16:17:32 macallan Exp $	*/
 
 /*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -72,6 +72,7 @@ struct	gftfb_softc {
 	struct wsscreen_list sc_screenlist;
 	struct vcons_data vd;
 	int sc_mode;
+	void (*sc_putchar)(void *, int, int, u_int, long);
 	u_char sc_cmap_red[256];
 	u_char sc_cmap_green[256];
 	u_char sc_cmap_blue[256];
@@ -90,6 +91,7 @@ void	gftfb_disable_rom_internal(struct g
 
 void 	gftfb_setup(struct gftfb_softc *);
 void 	gftfb_wait(struct gftfb_softc *);
+void	gftfb_wait_fifo(struct gftfb_softc *, uint32_t);
 
 #define	ngle_bt458_write(memt, memh, r, v) \
 	bus_space_write_stream_4(memt, memh, NGLE_REG_RAMDAC + ((r) << 2), (v) << 24)
@@ -118,7 +120,6 @@ static void	gftfb_restore_palette(struct
 static int 	gftfb_putpalreg(struct gftfb_softc *, uint8_t, uint8_t,
 			uint8_t, uint8_t);
 
-#if 0
 static void	gftfb_rectfill(struct gftfb_softc *, int, int, int, int,
 			uint32_t);
 static void	gftfb_bitblt(void *, int, int, int, int, int,
@@ -126,12 +127,10 @@ static void	gftfb_bitblt(void *, int, in
 
 static void	gftfb_cursor(void *, int, int, int);
 static void	gftfb_putchar(void *, int, int, u_int, long);
-static void	gftfb_putchar_aa(void *, int, int, u_int, long);
 static void	gftfb_copycols(void *, int, int, int, int);
 static void	gftfb_erasecols(void *, int, int, int, long);
 static void	gftfb_copyrows(void *, int, int, int);
 static void	gftfb_eraserows(void *, int, int, long);
-#endif
 
 struct wsdisplay_accessops gftfb_accessops = {
 	gftfb_ioctl,
@@ -241,10 +240,6 @@ gftfb_attach(device_t parent, device_t s
 		);
 		sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
 
-#if 0
-		gftfb_rectfill(sc, 0, 0, sc->sc_width, sc->sc_height,
-		ri->ri_devcmap[(defattr >> 16) & 0xff]);
-#endif
 		sc->sc_defaultscreen_descr.textops = >ri_ops;
 		sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
 		sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
@@ -259,6 +254,10 @@ gftfb_attach(device_t parent, device_t s
 #endif
 		wsdisplay_cnattach(>sc_defaultscreen_descr, ri, 0, 0,
 		defattr);
+
+		gftfb_rectfill(sc, 0, 0, sc->sc_width, sc->sc_height,
+		ri->ri_devcmap[(defattr >> 16) & 0xff]);
+
 		vcons_replay_msgbuf(>sc_console_screen);
 	} else {
 		/*
@@ -718,12 +717,12 @@ gftfb_ioctl(void *v, void *vs, u_long cm
 		if (new_mode != sc->sc_mode) {
 			sc->sc_mode = new_mode;
 			if(new_mode == WSDISPLAYIO_MODE_EMUL) {
-//r128fb_init(sc);
-gftfb_restore_palette(sc);
+gftfb_setup(sc);
+if (0) gftfb_restore_palette(sc);
 //glyphcache_wipe(>sc_gc);
-//r128fb_rectfill(sc, 0, 0, sc->sc_width,
-//sc->sc_height, ms->scr_ri.ri_devcmap[
-//(ms->scr_defattr >> 16) & 0xff]);
+gftfb_rectfill(sc, 0, 0, sc->sc_width,
+sc->sc_height, ms->scr_ri.ri_devcmap[
+(ms->scr_defattr >> 16) & 0xff]);
 vcons_redraw_screen(ms);
 			}
 		}
@@ -743,12 +742,20 @@ gftfb_ioctl(void *v, void *vs, u_long cm
 static paddr_t
 gftfb_mmap(void *v, void *vs, off_t offset, int prot)
 {
-#if 0
 	struct vcons_data *vd = v;
 	struct gftfb_softc *sc = vd->cookie;
+	struct sti_rom *rom = sc->sc_base.sc_rom;
 	paddr_t pa;
-#endif
-	return -1;
+
+	if (offset < 0 || offset >= sc->sc_scr.fblen)
+		return -1;
+
+	if (sc->sc_mode != WSDISPLAYIO_MODE_DUMBFB)
+		return -1;
+
+	pa = bus_space_mmap(rom->memt, sc->sc_scr.fbaddr, offset, prot,
+	BUS_SPACE_MAP_LINEAR);
+	return pa;
 }
 
 static void
@@ -764,7 +771,7 @@ gftfb_init_screen(void *cookie, struct v
 	ri->ri_stride = 2048;
 	ri->ri_flg = RI_CENTER;
 	if (scr->scr_flags & VCONS_SCREEN_IS_STATIC)
-		ri->ri_flg |= RI_FULLCLEAR | RI_CLEAR;
+		ri->ri_flg |= (RI_FULLCLEAR | RI_CLEAR);
 	ri->ri_bits = (void *)sc->sc_scr.fbaddr;
 #if 0
 	if (sc->sc_depth == 8)
@@ -774,24 +781,19 @@ gftfb_init_screen(void *cookie, struct v
 	rasops_init(ri, 0, 0);
 	ri->ri_caps = WSSCREEN_WSCOLORS | WSSCREEN_HILIT | WSSCREEN_UNDERLINE |
 		  WSSCREEN_RESIZE;
-	scr->scr_flags |= VCONS_DONT_READ;
 	scr->scr_flags |= VCONS_LOADFONT;
 
 	rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
 		sc->sc_width / ri->ri_font->fontwidth);
 
 	ri->ri_hw = scr;
-#if 0
+	sc->sc_putchar = 

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

2024-02-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Feb 15 16:17:32 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: gftfb.c

Log Message:
blitter time!
everything except drawing characters i now done by hardware
next step - glyphcache


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hppa/dev/gftfb.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/hppa/dev

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 02:17:06 UTC 2023

Modified Files:
src/sys/arch/hppa/dev: uturn.c

Log Message:
Use vmem(9) rather than extent(9) to manage IOMMU mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/dev/uturn.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/hppa/dev/uturn.c
diff -u src/sys/arch/hppa/dev/uturn.c:1.6 src/sys/arch/hppa/dev/uturn.c:1.7
--- src/sys/arch/hppa/dev/uturn.c:1.6	Thu Sep 29 06:42:14 2022
+++ src/sys/arch/hppa/dev/uturn.c	Sun Dec  3 02:17:06 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: uturn.c,v 1.6 2022/09/29 06:42:14 skrll Exp $	*/
+/*	$NetBSD: uturn.c,v 1.7 2023/12/03 02:17:06 thorpej Exp $	*/
 
 /*	$OpenBSD: uturn.c,v 1.6 2007/12/29 01:26:14 kettenis Exp $	*/
 
@@ -85,7 +85,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -178,7 +178,7 @@ struct uturn_softc {
 	uint32_t sc_chainid_shift;
 
 	char sc_mapname[20];
-	struct extent *sc_map;
+	vmem_t *sc_map;
 
 	struct hppa_bus_dma_tag sc_dmatag;
 };
@@ -357,8 +357,17 @@ uturnattach(device_t parent, device_t se
 
 	snprintf(sc->sc_mapname, sizeof(sc->sc_mapname), "%s_map",
 	device_xname(sc->sc_dv));
-	sc->sc_map = extent_create(sc->sc_mapname, 0, (1 << iova_bits),
-	0, 0, EX_WAITOK);
+	sc->sc_map = vmem_create(sc->sc_mapname,
+ 0,			/* base */
+ (1 << iova_bits),	/* size */
+ PAGE_SIZE,		/* quantum */
+ NULL,			/* allocfn */
+ NULL,			/* freefn */
+ NULL,			/* source */
+ 0,			/* qcache_max */
+ VM_SLEEP,
+ IPL_VM);
+	KASSERT(sc->sc_map != NULL);
 
 	sc->sc_dmatag = uturn_dmat;
 	sc->sc_dmatag._cookie = sc;
@@ -539,18 +548,18 @@ uturn_iomap_load_map(struct uturn_softc 
 	struct uturn_map_state *ums = map->_dm_cookie;
 	struct uturn_page_map *upm = >ums_map;
 	struct uturn_page_entry *e;
-	int err, seg, s;
+	int err, seg;
 	paddr_t pa, paend;
 	vaddr_t va;
 	bus_size_t sgsize;
 	bus_size_t align, boundary;
-	u_long iovaddr;
+	vmem_addr_t iovaddr;
 	bus_addr_t iova;
 	int i;
 
 	/* XXX */
 	boundary = map->_dm_boundary;
-	align = PAGE_SIZE;
+	align = 0;	/* align to quantum */
 
 	uturn_iomap_clear_pages(ums);
 
@@ -570,12 +579,18 @@ uturn_iomap_load_map(struct uturn_softc 
 		}
 	}
 
+	const vm_flag_t vmflags = VM_BESTFIT |
+	((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
+
 	sgsize = ums->ums_map.upm_pagecnt * PAGE_SIZE;
-	/* XXXNH */
-	s = splhigh();
-	err = extent_alloc(sc->sc_map, sgsize, align, boundary,
-	EX_NOWAIT | EX_BOUNDZERO, );
-	splx(s);
+	err = vmem_xalloc(sc->sc_map, sgsize,
+			  align,		/* align */
+			  0,			/* phase */
+			  boundary,		/* nocross */
+			  VMEM_ADDR_MIN,	/* minaddr */
+			  VMEM_ADDR_MAX,	/* maxaddr */
+			  vmflags,
+			  );
 	if (err)
 		return (err);
 
@@ -653,7 +668,7 @@ uturn_dmamap_unload(void *v, bus_dmamap_
 	struct uturn_map_state *ums = map->_dm_cookie;
 	struct uturn_page_map *upm = >ums_map;
 	struct uturn_page_entry *e;
-	int err, i, s;
+	int i;
 
 	/* Remove the IOMMU entries. */
 	for (i = 0, e = upm->upm_map; i < upm->upm_pagecnt; ++i, ++e)
@@ -664,14 +679,9 @@ uturn_dmamap_unload(void *v, bus_dmamap_
 
 	bus_dmamap_unload(sc->sc_dmat, map);
 
-	s = splhigh();
-	err = extent_free(sc->sc_map, ums->ums_iovastart,
-	ums->ums_iovasize, EX_NOWAIT);
+	vmem_xfree(sc->sc_map, ums->ums_iovastart, ums->ums_iovasize);
 	ums->ums_iovastart = 0;
 	ums->ums_iovasize = 0;
-	splx(s);
-	if (err)
-		printf("warning: %ld of IOVA space lost\n", ums->ums_iovasize);
 }
 
 void



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

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 02:17:06 UTC 2023

Modified Files:
src/sys/arch/hppa/dev: uturn.c

Log Message:
Use vmem(9) rather than extent(9) to manage IOMMU mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/dev/uturn.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/hppa/dev

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 02:03:18 UTC 2023

Modified Files:
src/sys/arch/hppa/dev: astro.c

Log Message:
Use vmem(9) rather than extent(9) to manage IOMMU mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/dev/astro.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/hppa/dev/astro.c
diff -u src/sys/arch/hppa/dev/astro.c:1.5 src/sys/arch/hppa/dev/astro.c:1.6
--- src/sys/arch/hppa/dev/astro.c:1.5	Thu Sep 29 06:42:14 2022
+++ src/sys/arch/hppa/dev/astro.c	Sun Dec  3 02:03:18 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: astro.c,v 1.5 2022/09/29 06:42:14 skrll Exp $	*/
+/*	$NetBSD: astro.c,v 1.6 2023/12/03 02:03:18 thorpej Exp $	*/
 
 /*	$OpenBSD: astro.c,v 1.8 2007/10/06 23:50:54 krw Exp $	*/
 
@@ -22,7 +22,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -124,7 +124,7 @@ struct astro_softc {
 	uint64_t *sc_pdir;
 
 	char sc_dvmamapname[20];
-	struct extent *sc_dvmamap;
+	vmem_t *sc_dvmamap;
 	struct hppa_bus_dma_tag sc_dmatag;
 };
 
@@ -328,8 +328,17 @@ astro_attach(device_t parent, device_t s
 	 */
 	snprintf(sc->sc_dvmamapname, sizeof(sc->sc_dvmamapname),
 	"%s_dvma", device_xname(sc->sc_dv));
-	sc->sc_dvmamap = extent_create(sc->sc_dvmamapname, 0, (1 << iova_bits),
-	0, 0, EX_WAITOK);
+	sc->sc_dvmamap = vmem_create(sc->sc_dvmamapname,
+ 0,			/* base */
+ (1 << iova_bits),	/* size */
+ PAGE_SIZE,		/* quantum */
+ NULL,		/* allocfn */
+ NULL,		/* freefn */
+ NULL,		/* source */
+ 0,			/* qcache_max */
+ VM_SLEEP,
+ IPL_VM);
+	KASSERT(sc->sc_dvmamap != NULL);
 
 	sc->sc_dmatag = astro_dmat;
 	sc->sc_dmatag._cookie = sc;
@@ -401,18 +410,18 @@ iommu_iomap_load_map(struct astro_softc 
 	struct iommu_map_state *ims = map->_dm_cookie;
 	struct iommu_page_map *ipm = >ims_map;
 	struct iommu_page_entry *e;
-	int err, seg, s;
+	int err, seg;
 	paddr_t pa, paend;
 	vaddr_t va;
 	bus_size_t sgsize;
 	bus_size_t align, boundary;
-	u_long dvmaddr;
+	vmem_addr_t dvmaddr;
 	bus_addr_t dva;
 	int i;
 
 	/* XXX */
 	boundary = map->_dm_boundary;
-	align = PAGE_SIZE;
+	align = 0;	/* align to quantum */
 
 	iommu_iomap_clear_pages(ims);
 
@@ -432,12 +441,18 @@ iommu_iomap_load_map(struct astro_softc 
 		}
 	}
 
+	const vm_flag_t vmflags = VM_BESTFIT |
+	((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
+
 	sgsize = ims->ims_map.ipm_pagecnt * PAGE_SIZE;
-	/* XXXNH */
-	s = splhigh();
-	err = extent_alloc(sc->sc_dvmamap, sgsize, align, boundary,
-	EX_NOWAIT | EX_BOUNDZERO, );
-	splx(s);
+	err = vmem_xalloc(sc->sc_dvmamap, sgsize,
+			  align,		/* align */
+			  0,			/* phase */
+			  boundary,		/* nocross */
+			  VMEM_ADDR_MIN,	/* minaddr */
+			  VMEM_ADDR_MAX,	/* maxaddr */
+			  vmflags,
+			  );
 	if (err)
 		return (err);
 
@@ -514,7 +529,7 @@ iommu_dvmamap_unload(void *v, bus_dmamap
 	struct iommu_map_state *ims = map->_dm_cookie;
 	struct iommu_page_map *ipm = >ims_map;
 	struct iommu_page_entry *e;
-	int err, i, s;
+	int i;
 
 	/* Remove the IOMMU entries. */
 	for (i = 0, e = ipm->ipm_map; i < ipm->ipm_pagecnt; ++i, ++e)
@@ -525,14 +540,9 @@ iommu_dvmamap_unload(void *v, bus_dmamap
 
 	bus_dmamap_unload(sc->sc_dmat, map);
 
-	s = splhigh();
-	err = extent_free(sc->sc_dvmamap, ims->ims_dvmastart,
-	ims->ims_dvmasize, EX_NOWAIT);
+	vmem_xfree(sc->sc_dvmamap, ims->ims_dvmastart, ims->ims_dvmasize);
 	ims->ims_dvmastart = 0;
 	ims->ims_dvmasize = 0;
-	splx(s);
-	if (err)
-		printf("warning: %ld of DVMA space lost\n", ims->ims_dvmasize);
 }
 
 void
@@ -736,7 +746,7 @@ iommu_enter(struct astro_softc *sc, bus_
 	if (tte & IOTTE_V) {
 		printf("Overwriting valid tte entry (dva %lx pa %lx "
 		" %p tte %llx)\n", dva, pa, tte_ptr, tte);
-		extent_print(sc->sc_dvmamap);
+		/* vmem_print(sc->sc_dvmamap);		XXX */
 		panic("IOMMU overwrite");
 	}
 #endif
@@ -773,7 +783,7 @@ iommu_remove(struct astro_softc *sc, bus
 	if ((tte & IOTTE_V) == 0) {
 		printf("Removing invalid tte entry (dva %lx  %p "
 		"tte %llx)\n", dva, tte_ptr, tte);
-		extent_print(sc->sc_dvmamap);
+		/* vmem_print(sc->sc_dvmamap);		XXX */
 		panic("IOMMU remove overwrite");
 	}
 #endif



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

2023-12-02 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Dec  3 02:03:18 UTC 2023

Modified Files:
src/sys/arch/hppa/dev: astro.c

Log Message:
Use vmem(9) rather than extent(9) to manage IOMMU mappings.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/dev/astro.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/hppa/dev

2022-09-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 29 06:42:14 UTC 2022

Modified Files:
src/sys/arch/hppa/dev: astro.c uturn.c

Log Message:
malloc -> kmem


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/dev/astro.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/dev/uturn.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/hppa/dev/astro.c
diff -u src/sys/arch/hppa/dev/astro.c:1.4 src/sys/arch/hppa/dev/astro.c:1.5
--- src/sys/arch/hppa/dev/astro.c:1.4	Sat Aug  7 16:18:55 2021
+++ src/sys/arch/hppa/dev/astro.c	Thu Sep 29 06:42:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: astro.c,v 1.4 2021/08/07 16:18:55 thorpej Exp $	*/
+/*	$NetBSD: astro.c,v 1.5 2022/09/29 06:42:14 skrll Exp $	*/
 
 /*	$OpenBSD: astro.c,v 1.8 2007/10/06 23:50:54 krw Exp $	*/
 
@@ -19,10 +19,11 @@
  */
 
 #include 
+
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -185,7 +186,7 @@ paddr_t	iommu_dvmamem_mmap(void *, bus_d
 void	iommu_enter(struct astro_softc *, bus_addr_t, paddr_t, vaddr_t, int);
 void	iommu_remove(struct astro_softc *, bus_addr_t);
 
-struct iommu_map_state *iommu_iomap_create(int);
+struct iommu_map_state *iommu_iomap_create(int, int);
 void	iommu_iomap_destroy(struct iommu_map_state *);
 int	iommu_iomap_insert_page(struct iommu_map_state *, vaddr_t, paddr_t);
 bus_addr_t iommu_iomap_translate(struct iommu_map_state *, paddr_t);
@@ -362,7 +363,7 @@ iommu_dvmamap_create(void *v, bus_size_t
 	if (error)
 		return (error);
 
-	ims = iommu_iomap_create(atop(round_page(size)));
+	ims = iommu_iomap_create(atop(round_page(size)), flags);
 	if (ims == NULL) {
 		bus_dmamap_destroy(sc->sc_dmat, map);
 		return (ENOMEM);
@@ -604,7 +605,7 @@ SPLAY_GENERATE(iommu_page_tree, iommu_pa
  * Create a new iomap.
  */
 struct iommu_map_state *
-iommu_iomap_create(int n)
+iommu_iomap_create(int n, int flags)
 {
 	struct iommu_map_state *ims;
 
@@ -613,8 +614,10 @@ iommu_iomap_create(int n)
 	if (n < 16)
 		n = 16;
 
-	ims = malloc(sizeof(*ims) + (n - 1) * sizeof(ims->ims_map.ipm_map[0]),
-	M_DEVBUF, M_NOWAIT | M_ZERO);
+	const size_t sz =
+	sizeof(*ims) + (n - 1) * sizeof(ims->ims_map.ipm_map[0]);
+
+	ims = kmem_zalloc(sz, (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP);
 	if (ims == NULL)
 		return (NULL);
 
@@ -636,8 +639,11 @@ iommu_iomap_destroy(struct iommu_map_sta
 		printf("iommu_iomap_destroy: %d page entries in use\n",
 		ims->ims_map.ipm_pagecnt);
 #endif
+	const int n = ims->ims_map.ipm_maxpage;
+	const size_t sz =
+	sizeof(*ims) + (n - 1) * sizeof(ims->ims_map.ipm_map[0]);
 
-	free(ims, M_DEVBUF);
+	kmem_free(ims, sz);
 }
 
 /*

Index: src/sys/arch/hppa/dev/uturn.c
diff -u src/sys/arch/hppa/dev/uturn.c:1.5 src/sys/arch/hppa/dev/uturn.c:1.6
--- src/sys/arch/hppa/dev/uturn.c:1.5	Sat Aug  7 16:18:55 2021
+++ src/sys/arch/hppa/dev/uturn.c	Thu Sep 29 06:42:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uturn.c,v 1.5 2021/08/07 16:18:55 thorpej Exp $	*/
+/*	$NetBSD: uturn.c,v 1.6 2022/09/29 06:42:14 skrll Exp $	*/
 
 /*	$OpenBSD: uturn.c,v 1.6 2007/12/29 01:26:14 kettenis Exp $	*/
 
@@ -82,12 +82,13 @@
  */
 
 #include 
+
 #include 
 #include 
-#include 
-#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include 
@@ -240,7 +241,7 @@ static void uturn_iommu_enter(struct utu
 vaddr_t, paddr_t);
 static void uturn_iommu_remove(struct uturn_softc *, bus_addr_t, bus_size_t);
 
-struct uturn_map_state *uturn_iomap_create(int);
+struct uturn_map_state *uturn_iomap_create(int, int);
 void	uturn_iomap_destroy(struct uturn_map_state *);
 int	uturn_iomap_insert_page(struct uturn_map_state *, vaddr_t, paddr_t);
 bus_addr_t uturn_iomap_translate(struct uturn_map_state *, paddr_t);
@@ -500,7 +501,7 @@ uturn_dmamap_create(void *v, bus_size_t 
 	if (error)
 		return (error);
 
-	ums = uturn_iomap_create(atop(round_page(size)));
+	ums = uturn_iomap_create(atop(round_page(size)), flags);
 	if (ums == NULL) {
 		bus_dmamap_destroy(sc->sc_dmat, map);
 		return (ENOMEM);
@@ -743,7 +744,7 @@ SPLAY_GENERATE(uturn_page_tree, uturn_pa
  * Create a new iomap.
  */
 struct uturn_map_state *
-uturn_iomap_create(int n)
+uturn_iomap_create(int n, int flags)
 {
 	struct uturn_map_state *ums;
 
@@ -751,9 +752,9 @@ uturn_iomap_create(int n)
 	n += 4;
 	if (n < 16)
 		n = 16;
-
-	ums = malloc(sizeof(*ums) + (n - 1) * sizeof(ums->ums_map.upm_map[0]),
-	M_DEVBUF, M_NOWAIT | M_ZERO);
+	const size_t sz =
+	sizeof(*ums) + (n - 1) * sizeof(ums->ums_map.upm_map[0]);
+	ums = kmem_zalloc(sz, (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP);
 	if (ums == NULL)
 		return (NULL);
 
@@ -771,8 +772,11 @@ void
 uturn_iomap_destroy(struct uturn_map_state *ums)
 {
 	KASSERT(ums->ums_map.upm_pagecnt == 0);
+	const int n = ums->ums_map.upm_maxpage;
+	const size_t sz =
+	sizeof(*ums) + (n - 1) * sizeof(ums->ums_map.upm_map[0]);
 
-	free(ums, M_DEVBUF);
+	kmem_free(ums, 

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

2022-09-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Sep 29 06:42:14 UTC 2022

Modified Files:
src/sys/arch/hppa/dev: astro.c uturn.c

Log Message:
malloc -> kmem


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/dev/astro.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/dev/uturn.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/hppa/dev

2022-08-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 16 08:40:34 UTC 2022

Modified Files:
src/sys/arch/hppa/dev: dino.c elroy.c

Log Message:
Use designated initializers for hppa_pci_chipset_tag structs.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hppa/dev/dino.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/dev/elroy.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/hppa/dev/dino.c
diff -u src/sys/arch/hppa/dev/dino.c:1.14 src/sys/arch/hppa/dev/dino.c:1.15
--- src/sys/arch/hppa/dev/dino.c:1.14	Tue Aug 16 08:35:38 2022
+++ src/sys/arch/hppa/dev/dino.c	Tue Aug 16 08:40:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: dino.c,v 1.14 2022/08/16 08:35:38 skrll Exp $ */
+/*	$NetBSD: dino.c,v 1.15 2022/08/16 08:40:33 skrll Exp $ */
 
 /*	$OpenBSD: dino.c,v 1.5 2004/02/13 20:39:31 mickey Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.14 2022/08/16 08:35:38 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.15 2022/08/16 08:40:33 skrll Exp $");
 
 /* #include "cardbus.h" */
 
@@ -1597,15 +1597,18 @@ const struct hppa_bus_dma_tag dino_dmat 
 };
 
 const struct hppa_pci_chipset_tag dino_pc = {
-	NULL,
-	dino_attach_hook, dino_maxdevs, dino_make_tag, dino_decompose_tag,
-	dino_conf_read, dino_conf_write,
-	dino_intr_map, dino_intr_string,
-	dino_intr_establish, dino_intr_disestablish,
+	.pc_attach_hook = dino_attach_hook,
+	.pc_bus_maxdevs = dino_maxdevs,
+	.pc_make_tag = dino_make_tag,
+	.pc_decompose_tag = dino_decompose_tag,
+	.pc_conf_read = dino_conf_read,
+	.pc_conf_write = dino_conf_write,
+	.pc_intr_map = dino_intr_map,
+	.pc_intr_string = dino_intr_string,
+	.pc_intr_establish = dino_intr_establish,
+	.pc_intr_disestablish = dino_intr_disestablish,
 #if NCARDBUS > 0
-	dino_alloc_parent
-#else
-	NULL
+	.pc_alloc_parent = dino_alloc_parent,
 #endif
 };
 

Index: src/sys/arch/hppa/dev/elroy.c
diff -u src/sys/arch/hppa/dev/elroy.c:1.4 src/sys/arch/hppa/dev/elroy.c:1.5
--- src/sys/arch/hppa/dev/elroy.c:1.4	Sat Aug  7 16:18:55 2021
+++ src/sys/arch/hppa/dev/elroy.c	Tue Aug 16 08:40:33 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: elroy.c,v 1.4 2021/08/07 16:18:55 thorpej Exp $	*/
+/*	$NetBSD: elroy.c,v 1.5 2022/08/16 08:40:33 skrll Exp $	*/
 
 /*	$OpenBSD: elroy.c,v 1.5 2009/03/30 21:24:57 kettenis Exp $	*/
 
@@ -1190,15 +1190,18 @@ const struct hppa_bus_dma_tag elroy_dmat
 };
 
 const struct hppa_pci_chipset_tag elroy_pc = {
-	NULL,
-	elroy_attach_hook, elroy_maxdevs, elroy_make_tag, elroy_decompose_tag,
-	elroy_conf_read, elroy_conf_write,
-	apic_intr_map, apic_intr_string,
-	apic_intr_establish, apic_intr_disestablish,
+	.pc_attach_hook = elroy_attach_hook,
+	.pc_bus_maxdevs = elroy_maxdevs,
+	.pc_make_tag = elroy_make_tag,
+	.pc_decompose_tag = elroy_decompose_tag,
+	.pc_conf_read = elroy_conf_read,
+	.pc_conf_write = elroy_conf_write,
+	.pc_intr_map = apic_intr_map,
+	.pc_intr_string = apic_intr_string,
+	.pc_intr_establish = apic_intr_establish,
+	.pc_intr_disestablish = apic_intr_disestablish,
 #if NCARDBUS > 0
-	elroy_alloc_parent
-#else
-	NULL
+	.pc_alloc_parent = elroy_alloc_parent
 #endif
 };
 



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

2022-08-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 16 08:40:34 UTC 2022

Modified Files:
src/sys/arch/hppa/dev: dino.c elroy.c

Log Message:
Use designated initializers for hppa_pci_chipset_tag structs.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hppa/dev/dino.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/dev/elroy.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/hppa/dev

2022-08-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 16 08:35:38 UTC 2022

Modified Files:
src/sys/arch/hppa/dev: dino.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hppa/dev/dino.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/hppa/dev

2022-08-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 16 08:35:38 UTC 2022

Modified Files:
src/sys/arch/hppa/dev: dino.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hppa/dev/dino.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/hppa/dev/dino.c
diff -u src/sys/arch/hppa/dev/dino.c:1.13 src/sys/arch/hppa/dev/dino.c:1.14
--- src/sys/arch/hppa/dev/dino.c:1.13	Sat Sep 18 23:54:13 2021
+++ src/sys/arch/hppa/dev/dino.c	Tue Aug 16 08:35:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: dino.c,v 1.13 2021/09/18 23:54:13 macallan Exp $ */
+/*	$NetBSD: dino.c,v 1.14 2022/08/16 08:35:38 skrll Exp $ */
 
 /*	$OpenBSD: dino.c,v 1.5 2004/02/13 20:39:31 mickey Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.13 2021/09/18 23:54:13 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.14 2022/08/16 08:35:38 skrll Exp $");
 
 /* #include "cardbus.h" */
 
@@ -1652,7 +1652,7 @@ dinoattach(device_t parent, device_t sel
 		return;
 	}
 
-	sc->sc_regs = r = (volatile struct dino_regs *)sc->sc_bh;	
+	sc->sc_regs = r = (volatile struct dino_regs *)sc->sc_bh;
 #ifdef trust_the_firmware_to_proper_initialize_everything
 	r->io_addr_en = 0;
 	r->io_control = 0x80;



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

2022-02-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 14 08:12:48 UTC 2022

Modified Files:
src/sys/arch/hppa/dev: cpu.c

Log Message:
hppa: Membar audit in cpu.c.


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

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

Modified files:

Index: src/sys/arch/hppa/dev/cpu.c
diff -u src/sys/arch/hppa/dev/cpu.c:1.2 src/sys/arch/hppa/dev/cpu.c:1.3
--- src/sys/arch/hppa/dev/cpu.c:1.2	Thu Apr 16 05:44:44 2020
+++ src/sys/arch/hppa/dev/cpu.c	Mon Feb 14 08:12:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.2 2020/04/16 05:44:44 skrll Exp $	*/
+/*	$NetBSD: cpu.c,v 1.3 2022/02/14 08:12:48 riastradh Exp $	*/
 
 /*	$OpenBSD: cpu.c,v 1.29 2009/02/08 18:33:28 miod Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.2 2020/04/16 05:44:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.3 2022/02/14 08:12:48 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -240,11 +240,26 @@ cpu_boot_secondary_processors(void)
 		if (ci->ci_flags & CPUF_PRIMARY)
 			continue;
 
-		/* Release the specified CPU by triggering an EIR{0}. */
+		/*
+		 * Release the specified CPU by triggering an EIR{0}.
+		 *
+		 * The `load-acquire operation' matching this
+		 * store-release is somewhere inside the silicon or
+		 * firmware -- the point is that the store to
+		 * cpu_hatch_info must happen before writing EIR{0};
+		 * there is conceptually some magic inside the silicon
+		 * or firmware that effectively does
+		 *
+		 *	if (atomic_load_acquire(>io_eir) == 0) {
+		 *		hw_cpu_spinup_trampoline();
+		 *	}
+		 *
+		 * so that hw_cpu_spinup_trampoline correctly sees the
+		 * value we just stored at cpu_hatch_info.
+		 */
 		cpu_hatch_info = ci;
 		cpu = (struct iomod *)(ci->ci_hpa);
-		cpu->io_eir = 0;
-		membar_sync();
+		atomic_store_release(>io_eir, 0);
 
 		/* Wait for CPU to wake up... */
 		j = 0;
@@ -254,9 +269,12 @@ cpu_boot_secondary_processors(void)
 			printf("failed to hatch cpu %i!\n", ci->ci_cpuid);
 	}
 
-	/* Release secondary CPUs. */
-	start_secondary_cpu = 1;
-	membar_sync();
+	/*
+	 * Release secondary CPUs.
+	 *
+	 * Matches load-acquire in cpu_hatch.
+	 */
+	atomic_store_release(_secondary_cpu, 1);
 }
 
 void
@@ -282,8 +300,12 @@ cpu_hatch(void)
 
 	ci->ci_flags |= CPUF_RUNNING;
 
-	/* Wait for additional CPUs to spinup. */
-	while (!start_secondary_cpu)
+	/*
+	 * Wait for additional CPUs to spinup.
+	 *
+	 * Matches store-release in cpu_boot_secondary_processors.
+	 */
+	while (!atomic_load_acquire(_secondary_cpu))
 		;
 
 	/* Spin for now */



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

2022-02-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 14 08:12:48 UTC 2022

Modified Files:
src/sys/arch/hppa/dev: cpu.c

Log Message:
hppa: Membar audit in cpu.c.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hppa/dev/cpu.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/hppa/dev

2021-09-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Sep 18 23:54:13 UTC 2021

Modified Files:
src/sys/arch/hppa/dev: dino.c

Log Message:
explain why we skip over dev 1f func 7 in config space access functions
no functional change


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/hppa/dev/dino.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/hppa/dev/dino.c
diff -u src/sys/arch/hppa/dev/dino.c:1.12 src/sys/arch/hppa/dev/dino.c:1.13
--- src/sys/arch/hppa/dev/dino.c:1.12	Sat Aug  7 16:18:55 2021
+++ src/sys/arch/hppa/dev/dino.c	Sat Sep 18 23:54:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dino.c,v 1.12 2021/08/07 16:18:55 thorpej Exp $ */
+/*	$NetBSD: dino.c,v 1.13 2021/09/18 23:54:13 macallan Exp $ */
 
 /*	$OpenBSD: dino.c,v 1.5 2004/02/13 20:39:31 mickey Exp $	*/
 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.12 2021/08/07 16:18:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.13 2021/09/18 23:54:13 macallan Exp $");
 
 /* #include "cardbus.h" */
 
@@ -347,8 +347,18 @@ dino_conf_read(void *v, pcitag_t tag, in
 
 	/*
 	 * XXX
-	 * accessing dev 1f / func 7 on the 2nd Dino causes a machine check
-	 * exception on my C200
+	 * thus sayeth the Dino manual:
+	 * 7.7.1 Generating PCI Special Cycles thru PA I/O Space
+	 * When the PCI_CONFIG_ADDR registers BUS_NUM is the equal to the
+	 * DINO’s bus number, 8’h00, DEV_NUM and Function fields are all ones,
+	 * and the REG_NUM field is all zeros the next write to PCI_CONFIG_DATA
+	 * register will generate a special cycle on DINO’s PCI bus. If the
+	 * BUS_NUM field does not equal DINO bus number then a type 1
+	 * transaction will be forwarded to PCI as described above.
+	 * Note: Dino is using a legal PCI configuration address to generate a
+	 * PCI special cycle. System firmware and software should not attempt
+	 * to read or write to this configuration address when walking the
+	 * PCI bus through configuration address space.
 	 */
 	if ((tag & 0xff00) == 0xff00)
 		return -1;
@@ -377,9 +387,7 @@ dino_conf_write(void *v, pcitag_t tag, i
 		return;
 
 	/*
-	 * XXX
-	 * accessing dev 1f / func 7 on the 2nd Dino causes a machine check
-	 * exception on my C200
+	 * don't try to access dev 1f / func 7, see comment in dino_conf_read()
 	 */
 	if ((tag & 0xff00) == 0xff00) return;
 
@@ -1644,7 +1652,7 @@ dinoattach(device_t parent, device_t sel
 		return;
 	}
 
-	sc->sc_regs = r = (volatile struct dino_regs *)sc->sc_bh;
+	sc->sc_regs = r = (volatile struct dino_regs *)sc->sc_bh;	
 #ifdef trust_the_firmware_to_proper_initialize_everything
 	r->io_addr_en = 0;
 	r->io_control = 0x80;
@@ -1652,7 +1660,7 @@ dinoattach(device_t parent, device_t sel
 	r->papr = 0;
 	r->io_fbb_en |= 1;
 	r->damode = 0;
-	r->gmask &= ~1;	/* allow GSC bus req */
+	r->gmask &= ~1; /* allow GSC bus req */
 	r->pciror = 0;
 	r->pciwor = 0;
 	r->brdg_feat = 0xc000;



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

2021-09-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Sep 18 23:54:13 UTC 2021

Modified Files:
src/sys/arch/hppa/dev: dino.c

Log Message:
explain why we skip over dev 1f func 7 in config space access functions
no functional change


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/hppa/dev/dino.c

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