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: xsrc/external/mit/xf86-video-suncg14/dist/src

2024-04-24 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Wed Apr 24 11:42:06 UTC 2024

Modified Files:
xsrc/external/mit/xf86-video-suncg14/dist/src: cg14_driver.c

Log Message:
don't enable xrender support unless we have 24bit colour


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 \
xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_driver.c

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

Modified files:

Index: xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_driver.c
diff -u xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_driver.c:1.20 xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_driver.c:1.21
--- xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_driver.c:1.20	Sun Jan  8 22:03:02 2023
+++ xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_driver.c	Wed Apr 24 11:42:06 2024
@@ -395,6 +395,12 @@ CG14PreInit(ScrnInfoPtr pScrn, int flags
 pCg14->use_xrender = xf86ReturnOptValBool(pCg14->Options, OPTION_XRENDER,
 FALSE);
 
+if (pScrn->depth < 24) {
+	if (pCg14->use_xrender)
+	xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling xrender on depth < 24\n");
+	pCg14->use_xrender = FALSE;
+}
+
 /*
  * This must happen after pScrn->display has been set because
  * xf86SetWeight references it.



CVS commit: xsrc/external/mit/xf86-video-suncg14/dist/src

2024-04-24 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Wed Apr 24 11:42:06 UTC 2024

Modified Files:
xsrc/external/mit/xf86-video-suncg14/dist/src: cg14_driver.c

Log Message:
don't enable xrender support unless we have 24bit colour


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 \
xsrc/external/mit/xf86-video-suncg14/dist/src/cg14_driver.c

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



CVS commit: src/sys/dev/pckbport

2024-04-18 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Apr 18 17:35:53 UTC 2024

Modified Files:
src/sys/dev/pckbport: synaptics.c

Log Message:
Renamed border/boundary variables to better describe their use.
Fix edge default values, factor out percentage calculation for more consistent
values. Use device_printf/DPRINTF to show errors instead of aprint variants.
Print raw input for debugging.

Correct capability parsing. Old devices were probed with nonexistent
commands and then used undefined boundary values that made them unusuable.

Fixes PR 57874.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/pckbport/synaptics.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/dev/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.82 src/sys/dev/pckbport/synaptics.c:1.83
--- src/sys/dev/pckbport/synaptics.c:1.82	Tue Sep  5 05:55:12 2023
+++ src/sys/dev/pckbport/synaptics.c	Thu Apr 18 17:35:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.82 2023/09/05 05:55:12 mrg Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.83 2024/04/18 17:35:53 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.82 2023/09/05 05:55:12 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.83 2024/04/18 17:35:53 mlelstv Exp $");
 
 #include 
 #include 
@@ -112,10 +112,10 @@ static int synaptics_edge_bottom = SYNAP
 static int synaptics_edge_motion_delta = 32;
 static u_int synaptics_finger_high = SYNAPTICS_FINGER_LIGHT + 5;
 static u_int synaptics_finger_low = SYNAPTICS_FINGER_LIGHT - 10;
-static int synaptics_horiz_pct = 0;
-static int synaptics_vert_pct = 0;
-static int synaptics_button_pct = 30;
-static int synaptics_button_boundary;
+static int synaptics_hscroll_pct = 0;
+static int synaptics_vscroll_pct = 0;
+static int synaptics_button_pct = 0;
+static int synaptics_button_boundary = SYNAPTICS_EDGE_BOTTOM;
 static int synaptics_button2;
 static int synaptics_button3;
 static int synaptics_two_fingers_emul = 0;
@@ -166,23 +166,26 @@ static int synaptics_movement_threshold_
 static int synaptics_movement_enable_nodenum;
 static int synaptics_button_region_movement_nodenum;
 static int synaptics_aux_mid_button_scroll_nodenum;
-static int synaptics_horiz_pct_nodenum;
-static int synaptics_vert_pct_nodenum;
+static int synaptics_hscroll_pct_nodenum;
+static int synaptics_vscroll_pct_nodenum;
 static int synaptics_button_pct_nodenum;
 
 /*
  * copy of edges so we can recalculate edge limit if there is 
  * vertical scroll region
  */
-static int synaptics_actual_edge_right;
-static int synaptics_actual_edge_bottom;
+static int synaptics_true_edge_right;
+static int synaptics_true_edge_bottom;
 
-static int synaptics_old_vert_pct = 0;
-static int synaptics_old_horiz_pct = 0;
-static int synaptics_old_button_pct = 0;
-static int synaptics_old_button_boundary = SYNAPTICS_EDGE_BOTTOM;
-static int synaptics_old_horiz_edge = SYNAPTICS_EDGE_BOTTOM;
-static int synaptics_old_vert_edge = SYNAPTICS_EDGE_RIGHT;
+/*
+ * invalid old values, recalculate everything
+ */
+static int synaptics_old_vscroll_pct = -1;
+static int synaptics_old_hscroll_pct = -1;
+static int synaptics_old_button_pct = -1;
+static int synaptics_old_button_boundary = -1;
+static int synaptics_old_edge_right = -1;
+static int synaptics_old_edge_bottom = -1;
 
 /*
  * This holds the processed packet data, it is global because multiple
@@ -208,7 +211,7 @@ synaptics_poll_cmd(struct pms_softc *psc
 	int res = pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot, cmd, i, 0,
 	NULL, 0);
 	if (res)
-		aprint_error_dev(psc->sc_dev, "command error %#x\n", cmd[0]);
+		device_printf(psc->sc_dev, "command error %#x\n", cmd[0]);
 	return res;
 }
 
@@ -221,7 +224,7 @@ synaptics_poll_reset(struct pms_softc *p
 	u_char cmd[1] = { PMS_RESET };
 	res = pckbport_poll_cmd(psc->sc_kbctag, psc->sc_kbcslot, cmd, 1, 2,
 	resp, 1);
-	aprint_debug_dev(psc->sc_dev, "reset %d 0x%02x 0x%02x\n",
+	DPRINTF(10, >u.synaptics, "reset %d 0x%02x 0x%02x\n",
 	res, resp[0], resp[1]);
 	return res;
 }
@@ -251,80 +254,90 @@ synaptics_special_write(struct pms_softc
 	return res;
 }
 
+static int
+synaptics_value(int pct, int low, int high)
+{
+	return low + pct * (high - low) / 100UL;
+}
+
+static int
+synaptics_percentage(int val, int low, int high)
+{
+	return ((val - low) * 100UL + high - low - 1) / (high - low);
+}
+
 static void
 pms_synaptics_set_boundaries(void)
 {
-	if (synaptics_vert_pct != synaptics_old_vert_pct ) {
-		synaptics_edge_right = synaptics_actual_edge_right -
-		((unsigned long) synaptics_vert_pct *
-		(synaptics_actual_edge_right - synaptics_edge_left)) / 100;
-		synaptics_old_vert_pct = synaptics_vert_pct;
-		synaptics_old_vert_edge = synaptics_edge_right;
+	if (synaptics_vscroll_pct != synaptics_old_vscroll_pct ) {
+		

CVS commit: src/sys/dev/pckbport

2024-04-18 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Apr 18 17:35:53 UTC 2024

Modified Files:
src/sys/dev/pckbport: synaptics.c

Log Message:
Renamed border/boundary variables to better describe their use.
Fix edge default values, factor out percentage calculation for more consistent
values. Use device_printf/DPRINTF to show errors instead of aprint variants.
Print raw input for debugging.

Correct capability parsing. Old devices were probed with nonexistent
commands and then used undefined boundary values that made them unusuable.

Fixes PR 57874.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/pckbport/synaptics.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/hppa

2024-04-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Apr 17 07:47:48 UTC 2024

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

Log Message:
turn LEDs off when shutting down


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/hppa/hppa/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/hppa/hppa/machdep.c
diff -u src/sys/arch/hppa/hppa/machdep.c:1.20 src/sys/arch/hppa/hppa/machdep.c:1.21
--- src/sys/arch/hppa/hppa/machdep.c:1.20	Tue Mar  5 14:15:32 2024
+++ src/sys/arch/hppa/hppa/machdep.c	Wed Apr 17 07:47:48 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.20 2024/03/05 14:15:32 thorpej Exp $	*/
+/*	$NetBSD: machdep.c,v 1.21 2024/04/17 07:47:48 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.20 2024/03/05 14:15:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.21 2024/04/17 07:47:48 macallan Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -1415,6 +1415,8 @@ cpu_reboot(int howto, char *user_boot_st
 	if (cold_hook)
 		(*cold_hook)(HPPA_COLD_COLD);
 
+	hppa_led_ctl(0xf, 0, 0);
+
 	if (howto & RB_HALT) {
 		if ((howto & RB_POWERDOWN) == RB_POWERDOWN && cold_hook) {
 			printf("Powering off...");



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

2024-04-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Apr 17 07:47:48 UTC 2024

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

Log Message:
turn LEDs off when shutting down


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

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



CVS commit: xsrc/external/mit/xf86-input-ws/dist/src

2024-04-14 Thread Michael van Elst
Module Name:xsrc
Committed By:   mlelstv
Date:   Sun Apr 14 20:10:29 UTC 2024

Modified Files:
xsrc/external/mit/xf86-input-ws/dist/src: ws.c

Log Message:
Only limit the scroll warning, but continue to send the scroll events.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 xsrc/external/mit/xf86-input-ws/dist/src/ws.c

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

Modified files:

Index: xsrc/external/mit/xf86-input-ws/dist/src/ws.c
diff -u xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.17 xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.18
--- xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.17	Wed Feb  7 18:01:48 2024
+++ xsrc/external/mit/xf86-input-ws/dist/src/ws.c	Sun Apr 14 20:10:29 2024
@@ -747,11 +747,13 @@ wsReadInput(InputInfoPtr pInfo)
 			dw = 0;
 		}
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 14
-		static int warned = 0;
-		if ((hscroll || vscroll) && !warned) {
-			warned = 1;
-			xf86Msg(X_WARNING, "%s: hscroll=%d, vscroll=%d\n",
-			pInfo->name, hscroll, vscroll);
+		if (hscroll || vscroll) {
+			static int warned = 0;
+			if (!warned) {
+warned = 1;
+xf86Msg(X_WARNING, "%s: hscroll=%d, vscroll=%d\n",
+pInfo->name, hscroll, vscroll);
+			}
 			valuator_mask_zero(priv->scroll_mask);
 			valuator_mask_set_double(priv->scroll_mask,
 			HSCROLL_AXIS, (double) hscroll);



CVS commit: xsrc/external/mit/xf86-input-ws/dist/src

2024-04-14 Thread Michael van Elst
Module Name:xsrc
Committed By:   mlelstv
Date:   Sun Apr 14 20:10:29 UTC 2024

Modified Files:
xsrc/external/mit/xf86-input-ws/dist/src: ws.c

Log Message:
Only limit the scroll warning, but continue to send the scroll events.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 xsrc/external/mit/xf86-input-ws/dist/src/ws.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/conf

2024-03-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Mar 14 13:18:36 UTC 2024

Modified Files:
src/sys/arch/hppa/conf: GENERIC

Log Message:
add gftfb


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/hppa/conf/GENERIC

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/conf/GENERIC
diff -u src/sys/arch/hppa/conf/GENERIC:1.43 src/sys/arch/hppa/conf/GENERIC:1.44
--- src/sys/arch/hppa/conf/GENERIC:1.43	Mon Jan 29 18:27:12 2024
+++ src/sys/arch/hppa/conf/GENERIC	Thu Mar 14 13:18:35 2024
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.43 2024/01/29 18:27:12 christos Exp $
+# $NetBSD: GENERIC,v 1.44 2024/03/14 13:18:35 macallan Exp $
 #
 # GENERIC machine description file
 #
@@ -23,7 +23,7 @@ include 	"arch/hppa/conf/std.hppa"
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
 
-#ident 		"GENERIC-$Revision: 1.43 $"
+#ident 		"GENERIC-$Revision: 1.44 $"
 
 maxusers	32		# estimated number of users
 
@@ -283,6 +283,7 @@ sti*	at mainbus0		# [H]CRX-{8,24,48}[Z] 
 sti*	at phantomas?		# [H]CRX-{8,24,48}[Z] and Visualize graphics
 sti*	at uturn?
 sti*	at pci?			# EG-PCI, FX*
+gftfb* 	at pci?			# PCI Visualize EG
 
 # Human Interface Loop
 hil*		at gsc? irq 1	# Human Interface Loop, kbd and mouse
@@ -298,7 +299,9 @@ wskbd*		at pckbd? console ?
 wsmouse*	at pms? mux 0
 wskbd*		at hilkbd? console ?
 wsmouse*	at hilms? mux 0
-wsdisplay*	at sti?
+# make sure the console display is always wsdisplay0
+wsdisplay0	at wsemuldisplaydev? console 1
+wsdisplay*	at wsemuldisplaydev?
 
 # Serial Devices
 



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

2024-03-14 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Mar 14 13:18:36 UTC 2024

Modified Files:
src/sys/arch/hppa/conf: GENERIC

Log Message:
add gftfb


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/hppa/conf/GENERIC

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



CVS commit: xsrc/local/programs/bdfload

2024-03-12 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Tue Mar 12 09:42:55 UTC 2024

Modified Files:
xsrc/local/programs/bdfload: bdfload.c

Log Message:
remove accidentally left in debug goop


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 xsrc/local/programs/bdfload/bdfload.c

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



CVS commit: xsrc/local/programs/bdfload

2024-03-12 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Tue Mar 12 09:42:55 UTC 2024

Modified Files:
xsrc/local/programs/bdfload: bdfload.c

Log Message:
remove accidentally left in debug goop


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 xsrc/local/programs/bdfload/bdfload.c

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

Modified files:

Index: xsrc/local/programs/bdfload/bdfload.c
diff -u xsrc/local/programs/bdfload/bdfload.c:1.22 xsrc/local/programs/bdfload/bdfload.c:1.23
--- xsrc/local/programs/bdfload/bdfload.c:1.22	Tue Mar 12 09:36:06 2024
+++ xsrc/local/programs/bdfload/bdfload.c	Tue Mar 12 09:42:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdfload.c,v 1.22 2024/03/12 09:36:06 macallan Exp $	*/
+/*	$NetBSD: bdfload.c,v 1.23 2024/03/12 09:42:55 macallan Exp $	*/
 
 /*
  * Copyright (c) 2018 Michael Lorenz
@@ -520,21 +520,6 @@ interpret(FILE *foo)
 		f.stride = stride;
 		f.data = [first * charsize];
 	}
-if (0) {
-	int i;
-	uint16_t pixbuf[16];
-	double_pixels([charsize * 'Q'], pixbuf, charsize);
-	fill_dup(pixbuf, charsize);
-	for (i = 0; i < charsize * 2; i++) {	
-		printf("%2d: ", i);
-		dump_line((char *)[i], 2); 
-	}
-	smoothe_pixels(pixbuf, charsize * 2);
-	for (i = 0; i < charsize * 2; i++) {	
-		printf("%2d: ", i);
-		dump_line((char *)[i], 2); 
-	}
-}
 
 	if (ofile == NULL) {
 		int fdev = open("/dev/wsfont", O_RDWR, 0);



CVS commit: xsrc/local/programs/bdfload

2024-03-12 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Tue Mar 12 09:36:06 UTC 2024

Modified Files:
xsrc/local/programs/bdfload: README bdfload.c

Log Message:
use uint8_t for all 8bit masks and data to avoid sign extending weirdness
found by running this on hppa with gcc12


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 xsrc/local/programs/bdfload/README
cvs rdiff -u -r1.21 -r1.22 xsrc/local/programs/bdfload/bdfload.c

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

Modified files:

Index: xsrc/local/programs/bdfload/README
diff -u xsrc/local/programs/bdfload/README:1.2 xsrc/local/programs/bdfload/README:1.3
--- xsrc/local/programs/bdfload/README:1.2	Thu Jul 27 08:30:02 2023
+++ xsrc/local/programs/bdfload/README	Tue Mar 12 09:36:06 2024
@@ -15,6 +15,8 @@ Command line options:
  -d dump glyph shapes to the console, mostly for font debugging
  -e  override the font's encoding
  -N  override the font's name for both file output and wsdisplay
+ -2 double the size of a font
+ -s smoothe pixel staircases when enlarging
 
 Caveats:
 - fonts wider than 16 pixels won't work yet

Index: xsrc/local/programs/bdfload/bdfload.c
diff -u xsrc/local/programs/bdfload/bdfload.c:1.21 xsrc/local/programs/bdfload/bdfload.c:1.22
--- xsrc/local/programs/bdfload/bdfload.c:1.21	Mon Jan  8 18:09:33 2024
+++ xsrc/local/programs/bdfload/bdfload.c	Tue Mar 12 09:36:06 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdfload.c,v 1.21 2024/01/08 18:09:33 macallan Exp $	*/
+/*	$NetBSD: bdfload.c,v 1.22 2024/03/12 09:36:06 macallan Exp $	*/
 
 /*
  * Copyright (c) 2018 Michael Lorenz
@@ -168,9 +168,10 @@ int
 write_header(const char *filename, struct wsdisplay_font *f)
 {
 	FILE *output;
-	char *buffer = f->data;
+	uint8_t *buffer = f->data;
+	uint8_t c, msk;
 	int i, j, x, y, idx, pxls, left;
-	char name[64], c, msk;
+	char name[64];
 	
 	/* now output as a header file */
 	snprintf(name, sizeof(name), "%s_%dx%d", f->name, 



CVS commit: xsrc/local/programs/bdfload

2024-03-12 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Tue Mar 12 09:36:06 UTC 2024

Modified Files:
xsrc/local/programs/bdfload: README bdfload.c

Log Message:
use uint8_t for all 8bit masks and data to avoid sign extending weirdness
found by running this on hppa with gcc12


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 xsrc/local/programs/bdfload/README
cvs rdiff -u -r1.21 -r1.22 xsrc/local/programs/bdfload/bdfload.c

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



CVS commit: src/lib/libcrypt

2024-03-09 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  9 13:48:50 UTC 2024

Modified Files:
src/lib/libcrypt: crypt-argon2.c

Log Message:
Don't use uninitialized variable.
Fixes PR 57895.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libcrypt/crypt-argon2.c

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

Modified files:

Index: src/lib/libcrypt/crypt-argon2.c
diff -u src/lib/libcrypt/crypt-argon2.c:1.19 src/lib/libcrypt/crypt-argon2.c:1.20
--- src/lib/libcrypt/crypt-argon2.c:1.19	Sun May 29 12:15:00 2022
+++ src/lib/libcrypt/crypt-argon2.c	Sat Mar  9 13:48:50 2024
@@ -207,7 +207,7 @@ estimate_argon2_params(argon2_type atype
 
 		if (clock_gettime(CLOCK_MONOTONIC, ) == -1)
 			goto error;
-		for (; delta.tv_sec < 1 && time < ARGON2_MAX_TIME; ++time) {
+		for (; time < ARGON2_MAX_TIME; ++time) {
 			if (argon2_hash(time, memory, threads,
 			tmp_pwd, sizeof(tmp_pwd), 
 			tmp_salt, sizeof(tmp_salt), 
@@ -221,6 +221,8 @@ estimate_argon2_params(argon2_type atype
 			if (timespeccmp(, , >))
 break; /* broken system... */
 			timespecsub(, , );
+			if (delta.tv_sec >= 1)
+break;
 		}
 	} else {
 		time = *etime;



CVS commit: src/lib/libcrypt

2024-03-09 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  9 13:48:50 UTC 2024

Modified Files:
src/lib/libcrypt: crypt-argon2.c

Log Message:
Don't use uninitialized variable.
Fixes PR 57895.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libcrypt/crypt-argon2.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.



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

2024-03-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Mar  4 10:19:14 UTC 2024

Modified Files:
src/distrib/sets/lists/comp: mi
src/sys/dev/ic: Makefile

Log Message:
install stireg.h


To generate a diff of this commit:
cvs rdiff -u -r1.2455 -r1.2456 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/Makefile

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

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2455 src/distrib/sets/lists/comp/mi:1.2456
--- src/distrib/sets/lists/comp/mi:1.2455	Fri Mar  1 15:48:24 2024
+++ src/distrib/sets/lists/comp/mi	Mon Mar  4 10:19:13 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2455 2024/03/01 15:48:24 christos Exp $
+#	$NetBSD: mi,v 1.2456 2024/03/04 10:19:13 macallan Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -645,6 +645,7 @@
 ./usr/include/dev/ic/smc91cxxvar.h		comp-obsolete		obsolete
 ./usr/include/dev/ic/smc93cx6var.h		comp-obsolete		obsolete
 ./usr/include/dev/ic/st16650reg.h		comp-obsolete		obsolete
+./usr/include/dev/ic/stireg.h			comp-c-include
 ./usr/include/dev/ic/tms320av110reg.h		comp-obsolete		obsolete
 ./usr/include/dev/ic/tms320av110var.h		comp-obsolete		obsolete
 ./usr/include/dev/ic/uhareg.h			comp-obsolete		obsolete

Index: src/sys/dev/ic/Makefile
diff -u src/sys/dev/ic/Makefile:1.28 src/sys/dev/ic/Makefile:1.29
--- src/sys/dev/ic/Makefile:1.28	Tue Dec  7 17:39:54 2021
+++ src/sys/dev/ic/Makefile	Mon Mar  4 10:19:14 2024
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.28 2021/12/07 17:39:54 brad Exp $
+#	$NetBSD: Makefile,v 1.29 2024/03/04 10:19:14 macallan Exp $
 
 INCSDIR= /usr/include/dev/ic
 
 # Only install includes which are used by userland
 INCS=	athioctl.h bt8xx.h hd44780var.h icpreg.h icp_ioctl.h isp_ioctl.h \
-	mlxreg.h mlxio.h nvmeio.h nvmereg.h qemufwcfgio.h scmdreg.h wdcreg.h \
-	wi_ieee.h
+	mlxreg.h mlxio.h nvmeio.h nvmereg.h qemufwcfgio.h scmdreg.h stireg.h \
+	wdcreg.h wi_ieee.h
 
 .include 



CVS commit: src

2024-03-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Mar  4 10:19:14 UTC 2024

Modified Files:
src/distrib/sets/lists/comp: mi
src/sys/dev/ic: Makefile

Log Message:
install stireg.h


To generate a diff of this commit:
cvs rdiff -u -r1.2455 -r1.2456 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/Makefile

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



CVS commit: src/sys/kern

2024-03-02 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  2 08:59:47 UTC 2024

Modified Files:
src/sys/kern: sysv_shm.c

Log Message:
Avoid overflow when computing kern.ipc.shmmax. Keep shmmax (bytes) and
shmall (pages) values aligned and use arithmetic everywhere instead
of shifts.
Should fix PR 57979


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/kern/sysv_shm.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/kern/sysv_shm.c
diff -u src/sys/kern/sysv_shm.c:1.141 src/sys/kern/sysv_shm.c:1.142
--- src/sys/kern/sysv_shm.c:1.141	Wed Oct  9 17:47:13 2019
+++ src/sys/kern/sysv_shm.c	Sat Mar  2 08:59:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysv_shm.c,v 1.141 2019/10/09 17:47:13 chs Exp $	*/
+/*	$NetBSD: sysv_shm.c,v 1.142 2024/03/02 08:59:47 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.141 2019/10/09 17:47:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.142 2024/03/02 08:59:47 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sysv.h"
@@ -961,10 +961,10 @@ shminit(void)
 	ALIGN(shminfo.shmmni * sizeof(struct shmid_ds)));
 
 	if (shminfo.shmmax == 0)
-		shminfo.shmmax = uimax(physmem / 4, 1024) * PAGE_SIZE;
+		shminfo.shmall = uimax(physmem / 4, 1024);
 	else
-		shminfo.shmmax *= PAGE_SIZE;
-	shminfo.shmall = shminfo.shmmax / PAGE_SIZE;
+		shminfo.shmall = shminfo.shmmax / PAGE_SIZE;
+	shminfo.shmmax = (uint64_t)shminfo.shmall * PAGE_SIZE;
 
 	for (i = 0; i < shminfo.shmmni; i++) {
 		cv_init(_cv[i], "shmwait");
@@ -1083,7 +1083,7 @@ sysctl_ipc_shmmax(SYSCTLFN_ARGS)
 		return EINVAL;
 
 	shminfo.shmmax = round_page(newsize);
-	shminfo.shmall = shminfo.shmmax >> PAGE_SHIFT;
+	shminfo.shmall = shminfo.shmmax / PAGE_SIZE;
 
 	return 0;
 }



CVS commit: src/sys/kern

2024-03-02 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  2 08:59:47 UTC 2024

Modified Files:
src/sys/kern: sysv_shm.c

Log Message:
Avoid overflow when computing kern.ipc.shmmax. Keep shmmax (bytes) and
shmall (pages) values aligned and use arithmetic everywhere instead
of shifts.
Should fix PR 57979


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sys/kern/sysv_shm.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 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/virt68k/virt68k

2024-02-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Feb 25 14:35:31 UTC 2024

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

Log Message:
Don't crash in copyin/copyout when a NULL pointer is passed.


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

2024-02-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Feb 25 14:35:31 UTC 2024

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

Log Message:
Don't crash in copyin/copyout when a NULL pointer is passed.


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

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

Modified files:

Index: src/sys/arch/virt68k/virt68k/trap.c
diff -u src/sys/arch/virt68k/virt68k/trap.c:1.2 src/sys/arch/virt68k/virt68k/trap.c:1.3
--- src/sys/arch/virt68k/virt68k/trap.c:1.2	Sat Jan 20 00:15:33 2024
+++ src/sys/arch/virt68k/virt68k/trap.c	Sun Feb 25 14:35:31 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.2 2024/01/20 00:15:33 thorpej Exp $	*/
+/*	$NetBSD: trap.c,v 1.3 2024/02/25 14:35:31 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.2 2024/01/20 00:15:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.3 2024/02/25 14:35:31 mlelstv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -554,7 +554,7 @@ trap(struct frame *fp, int type, unsigne
 
 		va = trunc_page((vaddr_t)v);
 
-		if (map == kernel_map && va == 0) {
+		if (map == kernel_map && va == 0 && onfault == 0) {
 			printf("trap: bad kernel %s access at 0x%x\n",
 			(ftype & VM_PROT_WRITE) ? "read/write" :
 			"read", v);



CVS commit: src/sys/dev/scsipi

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 22:06:50 UTC 2024

Modified Files:
src/sys/dev/scsipi: sd.c

Log Message:
Don't try to discover wedges when the unit isn't online.


To generate a diff of this commit:
cvs rdiff -u -r1.335 -r1.336 src/sys/dev/scsipi/sd.c

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



CVS commit: src/sys/dev/scsipi

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 22:06:50 UTC 2024

Modified Files:
src/sys/dev/scsipi: sd.c

Log Message:
Don't try to discover wedges when the unit isn't online.


To generate a diff of this commit:
cvs rdiff -u -r1.335 -r1.336 src/sys/dev/scsipi/sd.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/dev/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.335 src/sys/dev/scsipi/sd.c:1.336
--- src/sys/dev/scsipi/sd.c:1.335	Sun Aug 28 10:26:37 2022
+++ src/sys/dev/scsipi/sd.c	Sat Feb 24 22:06:49 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.335 2022/08/28 10:26:37 mlelstv Exp $	*/
+/*	$NetBSD: sd.c,v 1.336 2024/02/24 22:06:49 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.335 2022/08/28 10:26:37 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.336 2024/02/24 22:06:49 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -351,8 +351,9 @@ sdattach(device_t parent, device_t self,
 	}
 	aprint_normal("\n");
 
-	/* Discover wedges on this disk. */
-	dkwedge_discover(>sc_dkdev);
+	/* Discover wedges on this disk if it is online */
+	if (result == SDGP_RESULT_OK)
+		dkwedge_discover(>sc_dkdev);
 
 	/*
 	 * Establish a shutdown hook so that we can ensure that



CVS commit: src/sys/netinet6

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 21:41:13 UTC 2024

Modified Files:
src/sys/netinet6: icmp6.c raw_ip6.c

Log Message:
Deliver timestamps also to raw sockets.
Fixes PR 57955


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.183 -r1.184 src/sys/netinet6/raw_ip6.c

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



CVS commit: src/sys/netinet6

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 21:41:13 UTC 2024

Modified Files:
src/sys/netinet6: icmp6.c raw_ip6.c

Log Message:
Deliver timestamps also to raw sockets.
Fixes PR 57955


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/netinet6/icmp6.c
cvs rdiff -u -r1.183 -r1.184 src/sys/netinet6/raw_ip6.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/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.255 src/sys/netinet6/icmp6.c:1.256
--- src/sys/netinet6/icmp6.c:1.255	Sat Dec  9 15:21:02 2023
+++ src/sys/netinet6/icmp6.c	Sat Feb 24 21:41:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.255 2023/12/09 15:21:02 pgoyette Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.256 2024/02/24 21:41:13 mlelstv Exp $	*/
 /*	$KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.255 2023/12/09 15:21:02 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.256 2024/02/24 21:41:13 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1987,7 +1987,8 @@ icmp6_rip6_input(struct mbuf **mp, int o
 		}
 #endif
 		else if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {
-			if (last->inp_flags & IN6P_CONTROLOPTS)
+			if (last->inp_flags & IN6P_CONTROLOPTS ||
+			SOOPT_TIMESTAMP(last->inp_socket->so_options))
 ip6_savecontrol(last, , ip6, n);
 			/* strip intermediate headers */
 			m_adj(n, off);
@@ -2014,7 +2015,8 @@ icmp6_rip6_input(struct mbuf **mp, int o
 	} else
 #endif
 	if (last) {
-		if (last->inp_flags & IN6P_CONTROLOPTS)
+		if (last->inp_flags & IN6P_CONTROLOPTS ||
+		SOOPT_TIMESTAMP(last->inp_socket->so_options))
 			ip6_savecontrol(last, , ip6, m);
 		/* strip intermediate headers */
 		m_adj(m, off);

Index: src/sys/netinet6/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.183 src/sys/netinet6/raw_ip6.c:1.184
--- src/sys/netinet6/raw_ip6.c:1.183	Wed Mar 22 03:17:18 2023
+++ src/sys/netinet6/raw_ip6.c	Sat Feb 24 21:41:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.183 2023/03/22 03:17:18 ozaki-r Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.184 2024/02/24 21:41:13 mlelstv Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.183 2023/03/22 03:17:18 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.184 2024/02/24 21:41:13 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -140,7 +140,8 @@ rip6_sbappendaddr(struct inpcb *last, st
 {
 	struct mbuf *opts = NULL;
 
-	if (last->inp_flags & IN6P_CONTROLOPTS)
+	if (last->inp_flags & IN6P_CONTROLOPTS ||
+	SOOPT_TIMESTAMP(last->inp_socket->so_options))
 		ip6_savecontrol(last, , ip6, n);
 
 	m_adj(n, hlen);



CVS commit: src/sys/netinet

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 21:39:05 UTC 2024

Modified Files:
src/sys/netinet: if_arp.c

Log Message:
Attribute debug message.
Fixes PR 57959


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/sys/netinet/if_arp.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/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.311 src/sys/netinet/if_arp.c:1.312
--- src/sys/netinet/if_arp.c:1.311	Tue Nov 15 10:47:39 2022
+++ src/sys/netinet/if_arp.c	Sat Feb 24 21:39:05 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.311 2022/11/15 10:47:39 roy Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.312 2024/02/24 21:39:05 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.311 2022/11/15 10:47:39 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.312 2024/02/24 21:39:05 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1355,8 +1355,8 @@ arp_llinfo_output(struct ifnet *ifp, __u
 		if (sip.s_addr == INADDR_ANY) {
 			char ipbuf[INET_ADDRSTRLEN];
 
-			log(LOG_DEBUG, "source can't be "
-			"determined: dst=%s\n",
+			log(LOG_DEBUG, "%s: source can't be "
+			"determined: dst=%s\n", __func__,
 			IN_PRINT(ipbuf, ));
 			return;
 		}



CVS commit: src/sys/netinet

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 21:39:05 UTC 2024

Modified Files:
src/sys/netinet: if_arp.c

Log Message:
Attribute debug message.
Fixes PR 57959


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/sys/netinet/if_arp.c

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



CVS commit: src/usr.bin/seq

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 10:10:05 UTC 2024

Modified Files:
src/usr.bin/seq: seq.c

Log Message:
Chose better number format.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/seq/seq.c

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

Modified files:

Index: src/usr.bin/seq/seq.c
diff -u src/usr.bin/seq/seq.c:1.12 src/usr.bin/seq/seq.c:1.13
--- src/usr.bin/seq/seq.c:1.12	Sat Mar 20 22:10:17 2021
+++ src/usr.bin/seq/seq.c	Sat Feb 24 10:10:04 2024
@@ -31,7 +31,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2005\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: seq.c,v 1.12 2021/03/20 22:10:17 cheusov Exp $");
+__RCSID("$NetBSD: seq.c,v 1.13 2024/02/24 10:10:04 mlelstv Exp $");
 #endif /* not lint */
 
 #include 
@@ -56,6 +56,8 @@ __RCSID("$NetBSD: seq.c,v 1.12 2021/03/2
 
 const char *decimal_point = ".";	/* default */
 char default_format[] = { "%g" };	/* default */
+char default_format_fmt[] = { "%%.%uf" };
+#define MAXPRECISION 40
 
 /* Prototypes */
 
@@ -65,9 +67,29 @@ int decimal_places(const char *);
 int numeric(const char *);
 int valid_format(const char *);
 
-char *generate_format(double, double, double, int, char);
+unsigned get_precision(const char *, unsigned);
+char *generate_format(double, double, double, int, char, char *);
 char *unescape(char *);
 
+unsigned
+get_precision(const char *number, unsigned minprec)
+{
+	const char *p;
+	unsigned prec;
+
+	p = strstr(number, decimal_point);
+	if (p) {
+		prec = strlen(number) - (p - number);
+		if (prec > 0)
+			prec -= 1;
+		if (prec > MAXPRECISION)
+			prec = MAXPRECISION;
+	} else
+		prec = 0;
+
+	return prec < minprec ? minprec : prec;
+}
+
 /*
  * The seq command will print out a numeric sequence from 1, the default,
  * to a user specified upper limit by 1.  The lower bound and increment
@@ -79,6 +101,7 @@ main(int argc, char *argv[])
 {
 	int c = 0, errflg = 0;
 	int equalize = 0;
+	unsigned prec;
 	double first = 1.0;
 	double last = 0.0;
 	double incr = 0.0;
@@ -87,6 +110,8 @@ main(int argc, char *argv[])
 	const char *sep = "\n";
 	const char *term = "\n";
 	char pad = ZERO;
+	char buf[6]; /* %.MAXPRECISIONf */
+
 
 	/* Determine the locale's decimal point. */
 	locale = localeconv();
@@ -136,12 +161,16 @@ main(int argc, char *argv[])
 	}
 
 	last = e_atof(argv[argc - 1]);
+	prec = get_precision(argv[argc - 1], 0);
 
-	if (argc > 1)
+	if (argc > 1) {
 		first = e_atof(argv[0]);
+		prec = get_precision(argv[0], prec);
+	}
 	
 	if (argc > 2) {
 		incr = e_atof(argv[1]);
+		prec = get_precision(argv[1], prec);
 		/* Plan 9/GNU don't do zero */
 		if (incr == 0.0)
 			errx(1, "zero %screment", (first < last)? "in" : "de");
@@ -167,8 +196,15 @@ main(int argc, char *argv[])
 	 * XXX to be bug for bug compatible with Plan 9 add a
 		 * newline if none found at the end of the format string.
 		 */
-	} else
-		fmt = generate_format(first, incr, last, equalize, pad);
+	} else {
+		if (prec == 0)
+			fmt = default_format;
+		else {
+			sprintf(buf, default_format_fmt, prec);
+			fmt = buf;
+		}
+		fmt = generate_format(first, incr, last, equalize, pad, fmt);
+	}
 
 	if (incr > 0) {
 		printf(fmt, first);
@@ -428,14 +464,15 @@ decimal_places(const char *number)
  * when "%g" prints as "%e" (this way no width adjustments are made)
  */
 char *
-generate_format(double first, double incr, double last, int equalize, char pad)
+generate_format(double first, double incr, double last,
+int equalize, char pad, char *deffmt)
 {
 	static char buf[256];
 	char cc = '\0';
 	int precision, width1, width2, places;
 
 	if (equalize == 0)
-		return (default_format);
+		return deffmt;
 
 	/* figure out "last" value printed */
 	if (first > last)
@@ -443,12 +480,12 @@ generate_format(double first, double inc
 	else
 		last = first + incr * floor((last - first) / incr);
 
-	sprintf(buf, "%g", incr);
+	sprintf(buf, deffmt, incr);
 	if (strchr(buf, 'e'))
 		cc = 'e';
 	precision = decimal_places(buf);
 
-	width1 = sprintf(buf, "%g", first);
+	width1 = sprintf(buf, deffmt, first);
 	if (strchr(buf, 'e'))
 		cc = 'e';
 	if ((places = decimal_places(buf)))
@@ -456,7 +493,7 @@ generate_format(double first, double inc
 
 	precision = MAX(places, precision);
 
-	width2 = sprintf(buf, "%g", last);
+	width2 = sprintf(buf, deffmt, last);
 	if (strchr(buf, 'e'))
 		cc = 'e';
 	if ((places = decimal_places(buf)))



CVS commit: src/usr.bin/seq

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 10:10:05 UTC 2024

Modified Files:
src/usr.bin/seq: seq.c

Log Message:
Chose better number format.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/seq/seq.c

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



CVS commit: src/usr.bin/netstat

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 09:53:26 UTC 2024

Modified Files:
src/usr.bin/netstat: mbuf.c

Log Message:
Don't truncate mo_descr output and protect against missing terminating NUL.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/netstat/mbuf.c

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

Modified files:

Index: src/usr.bin/netstat/mbuf.c
diff -u src/usr.bin/netstat/mbuf.c:1.35 src/usr.bin/netstat/mbuf.c:1.36
--- src/usr.bin/netstat/mbuf.c:1.35	Thu Sep  1 10:10:20 2022
+++ src/usr.bin/netstat/mbuf.c	Sat Feb 24 09:53:26 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.c,v 1.35 2022/09/01 10:10:20 msaitoh Exp $	*/
+/*	$NetBSD: mbuf.c,v 1.36 2024/02/24 09:53:26 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)mbuf.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: mbuf.c,v 1.35 2022/09/01 10:10:20 msaitoh Exp $");
+__RCSID("$NetBSD: mbuf.c,v 1.36 2024/02/24 09:53:26 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -225,7 +225,7 @@ dump_drain:
 
 	for (mo = (void *) data, lines = 0; len >= sizeof(*mo);
 	len -= sizeof(*mo), mo++) {
-		char buf[32];
+		char buf[34];
 		if (vflag == 1 &&
 		mo->mo_counter[MOWNER_COUNTER_CLAIMS] == 0 &&
 		mo->mo_counter[MOWNER_COUNTER_EXT_CLAIMS] == 0 &&
@@ -239,7 +239,7 @@ dump_drain:
 		mo->mo_counter[MOWNER_COUNTER_CLUSTER_CLAIMS] ==
 		mo->mo_counter[MOWNER_COUNTER_CLUSTER_RELEASES])
 			continue;
-		snprintf(buf, sizeof(buf), "%16.16s %-13s",
+		snprintf(buf, sizeof(buf), "%16.16s %-13.16s",
 		mo->mo_name, mo->mo_descr);
 		if ((lines % 24) == 0 || lines > 24) {
 			printf("%30s %-8s %10s %10s %10s\n",



CVS commit: src/usr.bin/netstat

2024-02-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 24 09:53:26 UTC 2024

Modified Files:
src/usr.bin/netstat: mbuf.c

Log Message:
Don't truncate mo_descr output and protect against missing terminating NUL.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/netstat/mbuf.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: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/dev/wscons

2024-02-20 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Feb 20 09:53:16 UTC 2024

Modified Files:
src/sys/dev/wscons: wsdisplay_glyphcache.c

Log Message:
remove check for unused bits in attr2idx() - this really wasn't helpful


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/wscons/wsdisplay_glyphcache.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/dev/wscons/wsdisplay_glyphcache.c
diff -u src/sys/dev/wscons/wsdisplay_glyphcache.c:1.12 src/sys/dev/wscons/wsdisplay_glyphcache.c:1.13
--- src/sys/dev/wscons/wsdisplay_glyphcache.c:1.12	Thu Jun  8 05:48:41 2023
+++ src/sys/dev/wscons/wsdisplay_glyphcache.c	Tue Feb 20 09:53:16 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_glyphcache.c,v 1.12 2023/06/08 05:48:41 macallan Exp $	*/
+/*	$NetBSD: wsdisplay_glyphcache.c,v 1.13 2024/02/20 09:53:16 macallan Exp $	*/
 
 /*
  * Copyright (c) 2012 Michael Lorenz
@@ -53,9 +53,6 @@
 static inline int
 attr2idx(long attr)
 {
-	if ((attr & 0xf0f00ff8) != 0)
-		return -1;
-	
 	return (((attr >> 16) & 0x0f) | ((attr >> 20) & 0xf0));
 }
 



CVS commit: src/sys/dev/wscons

2024-02-20 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Feb 20 09:53:16 UTC 2024

Modified Files:
src/sys/dev/wscons: wsdisplay_glyphcache.c

Log Message:
remove check for unused bits in attr2idx() - this really wasn't helpful


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

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



CVS commit: src/sys/ufs/lfs

2024-02-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 17 09:08:21 UTC 2024

Modified Files:
src/sys/ufs/lfs: ulfs_inode.h

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/ulfs_inode.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/ufs/lfs/ulfs_inode.h
diff -u src/sys/ufs/lfs/ulfs_inode.h:1.24 src/sys/ufs/lfs/ulfs_inode.h:1.25
--- src/sys/ufs/lfs/ulfs_inode.h:1.24	Sat Jun 10 05:29:36 2017
+++ src/sys/ufs/lfs/ulfs_inode.h	Sat Feb 17 09:08:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ulfs_inode.h,v 1.24 2017/06/10 05:29:36 maya Exp $	*/
+/*	$NetBSD: ulfs_inode.h,v 1.25 2024/02/17 09:08:21 mlelstv Exp $	*/
 /*  from NetBSD: inode.h,v 1.72 2016/06/03 15:36:03 christos Exp  */
 
 /*
@@ -147,7 +147,7 @@ struct ulfs_ufid {
 	uint16_t ufid_len;	/* Length of structure. */
 	uint16_t ufid_pad;	/* Force 32-bit alignment. */
 	uint32_t ufid_ino;	/* File number (ino). XXX should be 64 */
-	int32_t	  ufid_gen;	/* Generation number. */
+	int32_t  ufid_gen;	/* Generation number. */
 };
 /* Filehandle structure for exported LFSes */
 struct lfid {



CVS commit: src/sys/ufs/lfs

2024-02-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Feb 17 09:08:21 UTC 2024

Modified Files:
src/sys/ufs/lfs: ulfs_inode.h

Log Message:
Whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/ulfs_inode.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/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

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

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

Log Message:
crude beginning of a native driver for PCI Visualize EG cards
so far it supports:
- colour
- virtual consoles
todo:
- mmap
- hardware acceleration
- STI refactoring


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/hppa/conf/files.hppa
cvs rdiff -u -r0 -r1.1 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/conf/files.hppa
diff -u src/sys/arch/hppa/conf/files.hppa:1.24 src/sys/arch/hppa/conf/files.hppa:1.25
--- src/sys/arch/hppa/conf/files.hppa:1.24	Wed Mar 23 17:35:41 2022
+++ src/sys/arch/hppa/conf/files.hppa	Tue Feb 13 13:40:13 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: files.hppa,v 1.24 2022/03/23 17:35:41 macallan Exp $
+#	$NetBSD: files.hppa,v 1.25 2024/02/13 13:40:13 macallan Exp $
 #
 #	$OpenBSD: files.hppa,v 1.31 2001/06/26 02:41:25 mickey Exp $
 #
@@ -271,6 +271,10 @@ file	arch/hppa/gsc/com_harmony.c	com_har
 #attach	myri at pci
 #file	dev/pci/myri.c			myri
 
+# PCI Visualize EG 
+device	gftfb: wsemuldisplaydev, rasops8, vcons, glyphcache, sti_pci, sti
+attach	gftfb at pci
+file	arch/hppa/dev/gftfb.c		gftfb
 
 # Memory Disk
 file dev/md_root.c			memory_disk_hooks

Added files:

Index: src/sys/arch/hppa/dev/gftfb.c
diff -u /dev/null src/sys/arch/hppa/dev/gftfb.c:1.1
--- /dev/null	Tue Feb 13 13:40:13 2024
+++ src/sys/arch/hppa/dev/gftfb.c	Tue Feb 13 13:40:13 2024
@@ -0,0 +1,895 @@
+/*	$NetBSD: gftfb.c,v 1.1 2024/02/13 13:40:13 macallan Exp $	*/
+
+/*	$OpenBSD: sti_pci.c,v 1.7 2009/02/06 22:51:04 miod Exp $	*/
+
+/*
+ * Copyright (c) 2006, 2007 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice, this permission notice, and the disclaimer below
+ * appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#ifdef STIDEBUG
+#define	DPRINTF(s)	do {	\
+	if (stidebug)		\
+		printf s;	\
+} while(0)
+
+extern int stidebug;
+#else
+#define	DPRINTF(s)	/* */
+#endif
+
+int	gftfb_match(device_t, cfdata_t, void *);
+void	gftfb_attach(device_t, device_t, void *);
+
+struct	gftfb_softc {
+	device_t		sc_dev;
+	pci_chipset_tag_t	sc_pc;
+	pcitag_t		sc_tag;
+
+	/* stuff we need in order to use the STI ROM */
+	struct sti_softc	sc_base;
+	struct sti_screen 	sc_scr;
+	bus_space_handle_t	sc_romh;
+
+	int sc_width, sc_height;
+	int sc_locked;
+	struct vcons_screen sc_console_screen;
+	struct wsscreen_descr sc_defaultscreen_descr;
+	const struct wsscreen_descr *sc_screens[1];
+	struct wsscreen_list sc_screenlist;
+	struct vcons_data vd;
+	int sc_mode;
+	u_char sc_cmap_red[256];
+	u_char sc_cmap_green[256];
+	u_char sc_cmap_blue[256];
+	glyphcache sc_gc;
+};
+
+CFATTACH_DECL_NEW(gftfb, sizeof(struct gftfb_softc),
+gftfb_match, gftfb_attach, NULL, NULL);
+
+int	gftfb_readbar(struct sti_softc *, struct pci_attach_args *, u_int, int);
+int	gftfb_check_rom(struct gftfb_softc *, struct pci_attach_args *);
+void	gftfb_enable_rom(struct sti_softc *);
+void	gftfb_disable_rom(struct sti_softc *);
+void	gftfb_enable_rom_internal(struct gftfb_softc *);
+void	gftfb_disable_rom_internal(struct gftfb_softc *);
+
+void 	gftfb_setup(struct gftfb_softc *);
+void 	gftfb_wait(struct gftfb_softc *);
+
+#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 */
+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);
+int	sti_screen_setup(struct sti_screen *, int);
+void	sti_describe_screen(struct sti_softc *, struct sti_screen *);
+
+#define PCI_ROM_SIZE(mr)\
+(PCI_MAPREG_ROM_ADDR(mr) & -PCI_MAPREG_ROM_ADDR(mr))
+
+/* wsdisplay stuff */
+static int	gftfb_ioctl(void *, void *, u_long, void *, int,
+			 struct lwp *);

CVS commit: src/sys/arch/hppa

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

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

Log Message:
crude beginning of a native driver for PCI Visualize EG cards
so far it supports:
- colour
- virtual consoles
todo:
- mmap
- hardware acceleration
- STI refactoring


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/hppa/conf/files.hppa
cvs rdiff -u -r0 -r1.1 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/dev/ic

2024-02-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Feb 13 13:17:51 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
in sti_screen_setup() don't bother looking for fonts if STI_FBMODE is requested


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/ic/sti.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/dev/ic/sti.c
diff -u src/sys/dev/ic/sti.c:1.34 src/sys/dev/ic/sti.c:1.35
--- src/sys/dev/ic/sti.c:1.34	Thu Feb  1 06:50:36 2024
+++ src/sys/dev/ic/sti.c	Tue Feb 13 13:17:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti.c,v 1.34 2024/02/01 06:50:36 skrll Exp $	*/
+/*	$NetBSD: sti.c,v 1.35 2024/02/13 13:17:51 macallan Exp $	*/
 
 /*	$OpenBSD: sti.c,v 1.61 2009/09/05 14:09:35 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.34 2024/02/01 06:50:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.35 2024/02/13 13:17:51 macallan Exp $");
 
 #include "wsdisplay.h"
 
@@ -556,6 +556,12 @@ sti_screen_setup(struct sti_screen *scr,
 	scr->owidth = cfg.owidth;
 	memcpy(scr->name, cfg.name, sizeof(scr->name));
 
+	if (flags & STI_FBMODE) {
+		/* we're done here */
+		sti_init(scr, STI_FBMODE);
+		return 0;
+	}
+
 	if ((error = sti_init(scr, STI_TEXTMODE | flags))) {
 		aprint_error(": cannot initialize (%d)\n", error);
 		goto fail;



CVS commit: src/sys/dev/ic

2024-02-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Feb 13 13:17:51 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
in sti_screen_setup() don't bother looking for fonts if STI_FBMODE is requested


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/ic/sti.c

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



CVS commit: src/distrib/utils/embedded

2024-02-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Feb 12 11:30:33 UTC 2024

Modified Files:
src/distrib/utils/embedded: mkimage

Log Message:
Quote argument to -n as required. [ -n ] is not a syntax error but
evaluates to true.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/distrib/utils/embedded/mkimage

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

Modified files:

Index: src/distrib/utils/embedded/mkimage
diff -u src/distrib/utils/embedded/mkimage:1.80 src/distrib/utils/embedded/mkimage:1.81
--- src/distrib/utils/embedded/mkimage:1.80	Sun Feb 11 17:29:50 2024
+++ src/distrib/utils/embedded/mkimage	Mon Feb 12 11:30:33 2024
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: mkimage,v 1.80 2024/02/11 17:29:50 christos Exp $
+# $NetBSD: mkimage,v 1.81 2024/02/12 11:30:33 mlelstv Exp $
 #
 # Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -190,7 +190,7 @@ do
 	*)	usage;;
 	esac
 done
-if [ -n ${MKREPRO_TIMESTAMP} ]; then
+if [ -n "${MKREPRO_TIMESTAMP}" ]; then
 	timestamp_opt="-T ${MKREPRO_TIMESTAMP}"
 	volume_opt=",volume_id=$((${MKREPRO_TIMESTAMP} & 0x))"
 fi



CVS commit: src/distrib/utils/embedded

2024-02-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Feb 12 11:30:33 UTC 2024

Modified Files:
src/distrib/utils/embedded: mkimage

Log Message:
Quote argument to -n as required. [ -n ] is not a syntax error but
evaluates to true.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/distrib/utils/embedded/mkimage

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



CVS commit: src/sys/dev/pci

2024-02-08 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Feb  9 06:01:03 UTC 2024

Modified Files:
src/sys/dev/pci: if_iwm.c

Log Message:
Fix DMA sync sizes.
Don't panic for inconsistent queue counter, just print an error to console.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/dev/pci/if_iwm.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/dev/pci/if_iwm.c
diff -u src/sys/dev/pci/if_iwm.c:1.88 src/sys/dev/pci/if_iwm.c:1.89
--- src/sys/dev/pci/if_iwm.c:1.88	Thu Sep 21 09:31:50 2023
+++ src/sys/dev/pci/if_iwm.c	Fri Feb  9 06:01:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwm.c,v 1.88 2023/09/21 09:31:50 msaitoh Exp $	*/
+/*	$NetBSD: if_iwm.c,v 1.89 2024/02/09 06:01:03 mlelstv Exp $	*/
 /*	OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp	*/
 #define IEEE80211_NO_HT
 /*
@@ -106,7 +106,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.88 2023/09/21 09:31:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.89 2024/02/09 06:01:03 mlelstv Exp $");
 
 #include 
 #include 
@@ -1262,8 +1262,9 @@ iwm_free_rx_ring(struct iwm_softc *sc, s
 		struct iwm_rx_data *data = >data[i];
 
 		if (data->m != NULL) {
+			bus_size_t sz = data->m->m_pkthdr.len;
 			bus_dmamap_sync(sc->sc_dmat, data->map, 0,
-			data->map->dm_mapsize, BUS_DMASYNC_POSTREAD);
+			sz, BUS_DMASYNC_POSTREAD);
 			bus_dmamap_unload(sc->sc_dmat, data->map);
 			m_freem(data->m);
 			data->m = NULL;
@@ -1405,8 +1406,9 @@ iwm_reset_tx_ring(struct iwm_softc *sc, 
 		struct iwm_tx_data *data = >data[i];
 
 		if (data->m != NULL) {
+			bus_size_t sz = data->m->m_pkthdr.len;
 			bus_dmamap_sync(sc->sc_dmat, data->map, 0,
-			data->map->dm_mapsize, BUS_DMASYNC_POSTWRITE);
+			sz, BUS_DMASYNC_POSTWRITE);
 			bus_dmamap_unload(sc->sc_dmat, data->map);
 			m_freem(data->m);
 			data->m = NULL;
@@ -1436,8 +1438,9 @@ iwm_free_tx_ring(struct iwm_softc *sc, s
 		struct iwm_tx_data *data = >data[i];
 
 		if (data->m != NULL) {
+			bus_size_t sz = data->m->m_pkthdr.len;
 			bus_dmamap_sync(sc->sc_dmat, data->map, 0,
-			data->map->dm_mapsize, BUS_DMASYNC_POSTWRITE);
+			sz, BUS_DMASYNC_POSTWRITE);
 			bus_dmamap_unload(sc->sc_dmat, data->map);
 			m_freem(data->m);
 			data->m = NULL;
@@ -1517,7 +1520,7 @@ iwm_ict_reset(struct iwm_softc *sc)
 	iwm_disable_interrupts(sc);
 
 	memset(sc->ict_dma.vaddr, 0, IWM_ICT_SIZE);
-	bus_dmamap_sync(sc->sc_dmat, sc->ict_dma.map, 0, IWM_ICT_SIZE,
+	bus_dmamap_sync(sc->sc_dmat, sc->ict_dma.map, 0, sc->ict_dma.size,
 	BUS_DMASYNC_PREWRITE);
 	sc->ict_cur = 0;
 
@@ -3766,7 +3769,7 @@ iwm_rx_addbuf(struct iwm_softc *sc, int 
 	if (size <= MCLBYTES) {
 		MCLGET(m, M_DONTWAIT);
 	} else {
-		MEXTMALLOC(m, IWM_RBUF_SIZE, M_DONTWAIT);
+		MEXTMALLOC(m, size, M_DONTWAIT);
 	}
 	if ((m->m_flags & M_EXT) == 0) {
 		m_freem(m);
@@ -3778,7 +3781,7 @@ iwm_rx_addbuf(struct iwm_softc *sc, int 
 		fatal = 1;
 	}
 
-	m->m_len = m->m_pkthdr.len = m->m_ext.ext_size;
+	m->m_len = m->m_pkthdr.len = size;
 	err = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m,
 	BUS_DMA_READ|BUS_DMA_NOWAIT);
 	if (err) {
@@ -4452,12 +4455,17 @@ iwm_cmd_done(struct iwm_softc *sc, int q
 	wakeup(>desc[idx]);
 
 	if (((idx + ring->queued) % IWM_TX_RING_COUNT) != ring->cur) {
-		aprint_error_dev(sc->sc_dev,
+		device_printf(sc->sc_dev,
 		"Some HCMDs skipped?: idx=%d queued=%d cur=%d\n",
 		idx, ring->queued, ring->cur);
 	}
 
-	KASSERT(ring->queued > 0);
+	if (ring->queued == 0) {
+		splx(s);
+		device_printf(sc->sc_dev, "cmd_done with empty ring\n");
+		return;
+	}
+
 	if (--ring->queued == 0)
 		iwm_clear_cmd_in_flight(sc);
 
@@ -4785,7 +4793,7 @@ iwm_tx(struct iwm_softc *sc, struct mbuf
 		| ((seg->ds_len) << 4);
 	}
 
-	bus_dmamap_sync(sc->sc_dmat, data->map, 0, data->map->dm_mapsize,
+	bus_dmamap_sync(sc->sc_dmat, data->map, 0, m->m_pkthdr.len,
 	BUS_DMASYNC_PREWRITE);
 	bus_dmamap_sync(sc->sc_dmat, ring->cmd_dma.map,
 	(uint8_t *)cmd - (uint8_t *)ring->cmd, sizeof(*cmd),



CVS commit: src/sys/dev/pci

2024-02-08 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Feb  9 06:01:03 UTC 2024

Modified Files:
src/sys/dev/pci: if_iwm.c

Log Message:
Fix DMA sync sizes.
Don't panic for inconsistent queue counter, just print an error to console.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/dev/pci/if_iwm.c

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



CVS commit: src/sys/dev/ic

2024-01-31 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan 31 08:15:00 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
Make this work properly on PCI Visualize EG:
- use bus_space_*_stream() for all register accesses in order to avoid
  byte order conversion on PCI devices
- when switching to framebuffer mode, request as many text planes as STI allows
- request access to both text and non-text planes in fb mode
With this and the bus_space commit a few days ago I have usable X on my C360
and a PCI Visualize EG.
This needs testing on quite literally everything else.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/ic/sti.c

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



CVS commit: src/sys/dev/ic

2024-01-31 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jan 31 08:15:00 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
Make this work properly on PCI Visualize EG:
- use bus_space_*_stream() for all register accesses in order to avoid
  byte order conversion on PCI devices
- when switching to framebuffer mode, request as many text planes as STI allows
- request access to both text and non-text planes in fb mode
With this and the bus_space commit a few days ago I have usable X on my C360
and a PCI Visualize EG.
This needs testing on quite literally everything else.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/ic/sti.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/dev/ic/sti.c
diff -u src/sys/dev/ic/sti.c:1.31 src/sys/dev/ic/sti.c:1.32
--- src/sys/dev/ic/sti.c:1.31	Sat Aug  7 16:19:12 2021
+++ src/sys/dev/ic/sti.c	Wed Jan 31 08:15:00 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti.c,v 1.31 2021/08/07 16:19:12 thorpej Exp $	*/
+/*	$NetBSD: sti.c,v 1.32 2024/01/31 08:15:00 macallan Exp $	*/
 
 /*	$OpenBSD: sti.c,v 1.61 2009/09/05 14:09:35 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.31 2021/08/07 16:19:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.32 2024/01/31 08:15:00 macallan Exp $");
 
 #include "wsdisplay.h"
 
@@ -926,17 +926,30 @@ sti_init(struct sti_screen *scr, int mod
 	KASSERT(rom != NULL);
 	memset(, 0, sizeof(a));
 
-	a.flags.flags = STI_INITF_WAIT | STI_INITF_EBET;
+	a.flags.flags = STI_INITF_WAIT | STI_INITF_PBET | STI_INITF_PBETI;
 	if ((mode & STI_TEXTMODE) != 0) {
 		a.flags.flags |= STI_INITF_TEXT | STI_INITF_CMB |
 		STI_INITF_PBET | STI_INITF_PBETI | STI_INITF_ICMT;
+		a.in.text_planes = 1;
 	} else {
-		a.flags.flags |= STI_INITF_NTEXT;
+		a.flags.flags |= STI_INITF_TEXT | STI_INITF_NTEXT;
+		/* 
+		 * Request as many text palnes as STI will allow. 
+		 * The reason to do this - when switching to framebuffer mode
+		 * for X we need access to all planes. In theory STI should do
+		 * just that when we request access to both text and non-text
+		 * planes as above.
+		 * In reality though, at least on my PCI Visualize EG, some
+		 * planes and/or colour registers remain inaccessible if we
+		 * request only one text plane.
+		 * Clearly we're missing a register write or two here, but so
+		 * far I haven't found it.
+		 */
+		a.in.text_planes = 3;
 	}
 	if ((mode & STI_CLEARSCR) != 0)
 		a.flags.flags |= STI_INITF_CLEAR;
 
-	a.in.text_planes = 1;
 	a.in.ext_in = 
 
 	DPRINTF(("%s: init,%p(%x, %p, %p, %p)\n",
@@ -1060,7 +1073,7 @@ sti_ioctl(void *v, void *vs, u_long cmd,
 			break;
 		case WSDISPLAYIO_MODE_DUMBFB:
 			if (scr->scr_wsmode != WSDISPLAYIO_MODE_DUMBFB) {
-sti_init(scr, 0);
+ret = sti_init(scr, 0);
 if (scr->setupfb != NULL)
 	scr->setupfb(scr);
 else
@@ -1487,7 +1500,7 @@ void	ngle_setup_attr_planes(struct sti_s
 void	ngle_setup_bt458(struct sti_screen *scr);
 
 #define	ngle_bt458_write(memt, memh, r, v) \
-	bus_space_write_4(memt, memh, NGLE_REG_RAMDAC + ((r) << 2), (v) << 24)
+	bus_space_write_stream_4(memt, memh, NGLE_REG_RAMDAC + ((r) << 2), (v) << 24)
 
 void
 ngle_artist_setupfb(struct sti_screen *scr)
@@ -1504,10 +1517,10 @@ ngle_artist_setupfb(struct sti_screen *s
 	ngle_setup_attr_planes(scr);
 
 	ngle_setup_hw(memt, memh);
-	bus_space_write_4(memt, memh, NGLE_REG_21,
-	bus_space_read_4(memt, memh, NGLE_REG_21) | 0x0a00);
-	bus_space_write_4(memt, memh, NGLE_REG_27,
-	bus_space_read_4(memt, memh, NGLE_REG_27) | 0x0080);
+	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);
 }
 
 void
@@ -1566,19 +1579,19 @@ ngle_setup_attr_planes(struct sti_screen
 	bus_space_handle_t memh = rom->regh[2];
 
 	ngle_setup_hw(memt, memh);
-	bus_space_write_4(memt, memh, NGLE_REG_11, 0x2ea0d000);
-	bus_space_write_4(memt, memh, NGLE_REG_14, 0x23000302);
-	bus_space_write_4(memt, memh, NGLE_REG_12, scr->reg12_value);
-	bus_space_write_4(memt, memh, NGLE_REG_8, 0x);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_11, 0x2ea0d000);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_14, 0x23000302);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_12, scr->reg12_value);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_8, 0x);
 
-	bus_space_write_4(memt, memh, NGLE_REG_6, 0x);
-	bus_space_write_4(memt, memh, NGLE_REG_9,
+	bus_space_write_stream_4(memt, memh, NGLE_REG_6, 0x);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_9,
 	(scr->scr_cfg.scr_width << 16) | scr->scr_cfg.scr_height);
-	bus_space_write_4(memt, memh, NGLE_REG_6, 0x0500);
-	bus_space_write_4(memt, memh, NGLE_REG_9, 0x00040001);
+	bus_space_write_stream_4(memt, 

CVS commit: src/sys/arch/hppa

2024-01-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Jan 28 09:03:22 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: dino.c elroy.c
src/sys/arch/hppa/hppa: mainbus.c
src/sys/arch/hppa/include: bus_defs.h bus_funcs.h

Log Message:
add missing bus_space_*_stream() methods instead of quietly aliasing them
to their potentially byte-swapping regular counterparts

ok skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/hppa/dev/dino.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/dev/elroy.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/hppa/hppa/mainbus.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hppa/include/bus_defs.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hppa/include/bus_funcs.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/hppa/dev/dino.c
diff -u src/sys/arch/hppa/dev/dino.c:1.16 src/sys/arch/hppa/dev/dino.c:1.17
--- src/sys/arch/hppa/dev/dino.c:1.16	Thu Sep 29 06:39:58 2022
+++ src/sys/arch/hppa/dev/dino.c	Sun Jan 28 09:03:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: dino.c,v 1.16 2022/09/29 06:39:58 skrll Exp $ */
+/*	$NetBSD: dino.c,v 1.17 2024/01/28 09:03:22 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.16 2022/09/29 06:39:58 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.17 2024/01/28 09:03:22 macallan Exp $");
 
 /* #include "cardbus.h" */
 
@@ -177,10 +177,16 @@ uint8_t dino_r1(void *, bus_space_handle
 uint16_t dino_r2(void *, bus_space_handle_t, bus_size_t);
 uint32_t dino_r4(void *, bus_space_handle_t, bus_size_t);
 uint64_t dino_r8(void *, bus_space_handle_t, bus_size_t);
+uint16_t dino_rs2(void *, bus_space_handle_t, bus_size_t);
+uint32_t dino_rs4(void *, bus_space_handle_t, bus_size_t);
+uint64_t dino_rs8(void *, bus_space_handle_t, bus_size_t);
 void dino_w1(void *, bus_space_handle_t, bus_size_t, uint8_t);
 void dino_w2(void *, bus_space_handle_t, bus_size_t, uint16_t);
 void dino_w4(void *, bus_space_handle_t, bus_size_t, uint32_t);
 void dino_w8(void *, bus_space_handle_t, bus_size_t, uint64_t);
+void dino_ws2(void *, bus_space_handle_t, bus_size_t, uint16_t);
+void dino_ws4(void *, bus_space_handle_t, bus_size_t, uint32_t);
+void dino_ws8(void *, bus_space_handle_t, bus_size_t, uint64_t);
 void dino_rm_1(void *, bus_space_handle_t, bus_size_t, uint8_t *, bus_size_t);
 void dino_rm_2(void *, bus_space_handle_t, bus_size_t, uint16_t *, bus_size_t);
 void dino_rm_4(void *, bus_space_handle_t, bus_size_t, uint32_t *, bus_size_t);
@@ -413,7 +419,7 @@ dino_intr_map(const struct pci_attach_ar
 	if (line == 0xff)
 		return 1;
 
-	*ihp = line;
+	*ihp = line ;
 
 	return 0;
 }
@@ -695,6 +701,59 @@ dino_r8(void *v, bus_space_handle_t h, b
 	return le64toh(data);
 }
 
+uint16_t
+dino_rs2(void *v, bus_space_handle_t h, bus_size_t o)
+{
+	volatile uint16_t *p;
+
+	h += o;
+	if (h & HPPA_IOSPACE)
+		p = (volatile uint16_t *)h;
+	else {
+		struct dino_softc *sc = v;
+		volatile struct dino_regs *r = sc->sc_regs;
+
+		r->pci_addr = h;
+		p = (volatile uint16_t *)>pci_io_data;
+		if (h & 2)
+			p++;
+	}
+	return *p;
+}
+
+uint32_t
+dino_rs4(void *v, bus_space_handle_t h, bus_size_t o)
+{
+	uint32_t data;
+
+	h += o;
+	if (h & HPPA_IOSPACE)
+		data = *(volatile uint32_t *)h;
+	else {
+		struct dino_softc *sc = v;
+		volatile struct dino_regs *r = sc->sc_regs;
+
+		r->pci_addr = h;
+		data = r->pci_io_data;
+	}
+
+	return data;
+}
+
+uint64_t
+dino_rs8(void *v, bus_space_handle_t h, bus_size_t o)
+{
+	uint64_t data;
+
+	h += o;
+	if (h & HPPA_IOSPACE)
+		data = *(volatile uint64_t *)h;
+	else
+		panic("dino_r8: not implemented");
+
+	return data;
+}
+
 void
 dino_w1(void *v, bus_space_handle_t h, bus_size_t o, uint8_t vv)
 {
@@ -757,6 +816,51 @@ dino_w8(void *v, bus_space_handle_t h, b
 		panic("dino_w8: not implemented");
 }
 
+void
+dino_ws2(void *v, bus_space_handle_t h, bus_size_t o, uint16_t vv)
+{
+	volatile uint16_t *p;
+
+	h += o;
+	if (h & HPPA_IOSPACE)
+		p = (volatile uint16_t *)h;
+	else {
+		struct dino_softc *sc = v;
+		volatile struct dino_regs *r = sc->sc_regs;
+
+		r->pci_addr = h;
+		p = (volatile uint16_t *)>pci_io_data;
+		if (h & 2)
+			p++;
+	}
+
+	*p = vv;
+}
+
+void
+dino_ws4(void *v, bus_space_handle_t h, bus_size_t o, uint32_t vv)
+{
+	h += o;
+	if (h & HPPA_IOSPACE)
+		*(volatile uint32_t *)h = vv;
+	else {
+		struct dino_softc *sc = v;
+		volatile struct dino_regs *r = sc->sc_regs;
+
+		r->pci_addr = h;
+		r->pci_io_data = vv;
+	}
+}
+
+void
+dino_ws8(void *v, bus_space_handle_t h, bus_size_t o, uint64_t vv)
+{
+	h += o;
+	if (h & HPPA_IOSPACE)
+		*(volatile uint64_t *)h = vv;
+	else
+		panic("dino_w8: not implemented");
+}
 
 void
 dino_rm_1(void *v, bus_space_handle_t h, bus_size_t o, uint8_t *a, bus_size_t c)
@@ -1454,7 +1558,9 @@ const struct hppa_bus_space_tag dino_iom
 	NULL, dino_unmap, dino_subregion, 

CVS commit: src/sys/arch/hppa

2024-01-28 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Jan 28 09:03:22 UTC 2024

Modified Files:
src/sys/arch/hppa/dev: dino.c elroy.c
src/sys/arch/hppa/hppa: mainbus.c
src/sys/arch/hppa/include: bus_defs.h bus_funcs.h

Log Message:
add missing bus_space_*_stream() methods instead of quietly aliasing them
to their potentially byte-swapping regular counterparts

ok skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/hppa/dev/dino.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hppa/dev/elroy.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/hppa/hppa/mainbus.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hppa/include/bus_defs.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hppa/include/bus_funcs.h

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



CVS commit: src/bin/dd

2024-01-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jan 26 07:10:04 UTC 2024

Modified Files:
src/bin/dd: args.c

Log Message:
Don't use the signal handler to terminate when nothing is to do (count=0, 
files=0).

The signal handler tries to raise the signal again, so that a parent can 
retrieve
the signal from the exit code. Calling the terminate handler with signal code 0
doesn't raise a signal and dd continues with exit(127) making this case an 
error.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/bin/dd/args.c

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



CVS commit: src/bin/dd

2024-01-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jan 26 07:10:04 UTC 2024

Modified Files:
src/bin/dd: args.c

Log Message:
Don't use the signal handler to terminate when nothing is to do (count=0, 
files=0).

The signal handler tries to raise the signal again, so that a parent can 
retrieve
the signal from the exit code. Calling the terminate handler with signal code 0
doesn't raise a signal and dd continues with exit(127) making this case an 
error.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/bin/dd/args.c

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

Modified files:

Index: src/bin/dd/args.c
diff -u src/bin/dd/args.c:1.42 src/bin/dd/args.c:1.43
--- src/bin/dd/args.c:1.42	Fri Jan 14 23:55:16 2022
+++ src/bin/dd/args.c	Fri Jan 26 07:10:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.42 2022/01/14 23:55:16 christos Exp $	*/
+/*	$NetBSD: args.c,v 1.43 2024/01/26 07:10:04 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)args.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: args.c,v 1.42 2022/01/14 23:55:16 christos Exp $");
+__RCSID("$NetBSD: args.c,v 1.43 2024/01/26 07:10:04 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -248,8 +248,10 @@ f_count(char *arg)
 {
 
 	cpy_cnt = strsuftoll("block count", arg, 0, LLONG_MAX);
-	if (!cpy_cnt)
-		terminate(0);
+	if (!cpy_cnt) {
+		summary();
+		exit(0);
+	}
 }
 
 static void
@@ -257,8 +259,10 @@ f_files(char *arg)
 {
 
 	files_cnt = (u_int)strsuftoll("file count", arg, 0, UINT_MAX);
-	if (!files_cnt)
-		terminate(0);
+	if (!files_cnt) {
+		summary();
+		exit(0);
+	}
 }
 
 static void



CVS commit: src/sys/dev/stbi

2024-01-20 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jan 20 13:33:03 UTC 2024

Modified Files:
src/sys/dev/stbi: stb_image.c

Log Message:
Don't put big structures on stack.
Should fix PR 57859.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/stbi/stb_image.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/dev/stbi/stb_image.c
diff -u src/sys/dev/stbi/stb_image.c:1.11 src/sys/dev/stbi/stb_image.c:1.12
--- src/sys/dev/stbi/stb_image.c:1.11	Sat Aug 26 21:03:53 2023
+++ src/sys/dev/stbi/stb_image.c	Sat Jan 20 13:33:03 2024
@@ -430,7 +430,7 @@ extern int  stbi_gif_info_from_file 
 #endif
 #ifdef _KERNEL
 #include 
-__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.11 2023/08/26 21:03:53 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.12 2024/01/20 13:33:03 mlelstv Exp $");
 #include 
 #include 
 #include 
@@ -2144,16 +2144,28 @@ int stbi_jpeg_info(char const *filename,
 
 int stbi_jpeg_test_memory(stbi_uc const *buffer, int len)
 {
-   jpeg j;
-   start_mem(, buffer,len);
-   return decode_jpeg_header(, SCAN_type);
+jpeg *j;
+int res;
+
+j = MALLOC(sizeof(*j));
+if (j == NULL) return 0;
+start_mem(>s, buffer,len);
+res = decode_jpeg_header(j, SCAN_type);
+FREE(j);
+return res;
 }
 
 int stbi_jpeg_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp)
 {
-jpeg j;
-start_mem(, buffer, len);
-return stbi_jpeg_info_raw(, x, y, comp);
+jpeg *j;
+int res;
+
+j = MALLOC(sizeof(*j));
+if (j == NULL) return 0;
+start_mem(>s, buffer, len);
+res = stbi_jpeg_info_raw(j, x, y, comp);
+FREE(j);
+return res;
 }
 
 #ifndef STBI_NO_STDIO
@@ -2523,18 +2535,25 @@ static int do_zlib(zbuf *a, char *obuf, 
 
 char *stbi_zlib_decode_malloc_guesssize(const char * buffer, int len, int initial_size, int *outlen)
 {
-   zbuf a;
-   char *p = MALLOC(initial_size);
-   if (p == NULL) return NULL;
-   a.zbuffer = (uint8 const *) buffer;
-   a.zbuffer_end = (uint8 const *) buffer + len;
-   if (do_zlib(, p, initial_size, 1, 1)) {
-  if (outlen) *outlen = (int) (a.zout - a.zout_start);
-  return a.zout_start;
+   zbuf *a;
+   char *p;
+   char *res = NULL;
+
+   a = MALLOC(sizeof(*a));
+   if (a == NULL) return NULL;
+   p = MALLOC(initial_size);
+   if (p == NULL) goto fail;
+   a->zbuffer = (uint8 const *) buffer;
+   a->zbuffer_end = (uint8 const *) buffer + len;
+   if (do_zlib(a, p, initial_size, 1, 1)) {
+  if (outlen) *outlen = (int) (a->zout - a->zout_start);
+  res = a->zout_start;
} else {
-  FREE(a.zout_start);
-  return NULL;
+  FREE(a->zout_start);
}
+fail:
+   FREE(a);
+   return res;
 }
 
 char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen)
@@ -2544,56 +2563,81 @@ char *stbi_zlib_decode_malloc(char const
 
 char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header)
 {
-   zbuf a;
-   char *p = MALLOC(initial_size);
-   if (p == NULL) return NULL;
-   a.zbuffer = (uint8 const *) buffer;
-   a.zbuffer_end = (uint8 const *) buffer + len;
-   if (do_zlib(, p, initial_size, 1, parse_header)) {
-  if (outlen) *outlen = (int) (a.zout - a.zout_start);
-  return a.zout_start;
+   zbuf *a;
+   char *p;
+   char *res = NULL;
+
+   a = MALLOC(sizeof(*a));
+   if (a == NULL) return NULL;
+   p = MALLOC(initial_size);
+   if (p == NULL) goto fail;
+   a->zbuffer = (uint8 const *) buffer;
+   a->zbuffer_end = (uint8 const *) buffer + len;
+   if (do_zlib(a, p, initial_size, 1, parse_header)) {
+  if (outlen) *outlen = (int) (a->zout - a->zout_start);
+  res = a->zout_start;
} else {
-  FREE(a.zout_start);
-  return NULL;
+  FREE(a->zout_start);
}
+fail:
+   FREE(a);
+   return res;
 }
 
 int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen)
 {
-   zbuf a;
-   a.zbuffer = (uint8 const *) ibuffer;
-   a.zbuffer_end = (uint8 const *) ibuffer + ilen;
-   if (do_zlib(, obuffer, olen, 0, 1))
-  return (int) (a.zout - a.zout_start);
+   zbuf *a;
+   int res;
+
+   a = MALLOC(sizeof(*a));
+   if (a == NULL) return -1;
+   a->zbuffer = (uint8 const *) ibuffer;
+   a->zbuffer_end = (uint8 const *) ibuffer + ilen;
+   if (do_zlib(a, obuffer, olen, 0, 1))
+  res = (int) (a->zout - a->zout_start);
else
-  return -1;
+  res = -1;
+   FREE(a);
+   return res;
 }
 
 char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen)
 {
-   zbuf a;
-   char *p = MALLOC(16384);
-   if (p == NULL) return NULL;
-   a.zbuffer = (uint8 const *) buffer;
-   a.zbuffer_end = (uint8 const *) buffer+len;
-   if (do_zlib(, p, 16384, 1, 0)) {
-  if (outlen) *outlen = (int) (a.zout - a.zout_start);
-  return a.zout_start;
-   } else {
-  FREE(a.zout_start);
-  return NULL;
-   }
+   

CVS commit: src/sys/dev/stbi

2024-01-20 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jan 20 13:33:03 UTC 2024

Modified Files:
src/sys/dev/stbi: stb_image.c

Log Message:
Don't put big structures on stack.
Should fix PR 57859.


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

2024-01-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 18 10:34:29 UTC 2024

Modified Files:
src/sys/arch/hppa/hppa: mainbus.c

Log Message:
rearrange things so we:
- find machine_ledaddr on Cxxx and the like without lcd at mainbus
- build without options USELEDS


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

2024-01-18 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Jan 18 10:34:29 UTC 2024

Modified Files:
src/sys/arch/hppa/hppa: mainbus.c

Log Message:
rearrange things so we:
- find machine_ledaddr on Cxxx and the like without lcd at mainbus
- build without options USELEDS


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/hppa/hppa/mainbus.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/hppa/mainbus.c
diff -u src/sys/arch/hppa/hppa/mainbus.c:1.11 src/sys/arch/hppa/hppa/mainbus.c:1.12
--- src/sys/arch/hppa/hppa/mainbus.c:1.11	Tue Oct 11 22:03:37 2022
+++ src/sys/arch/hppa/hppa/mainbus.c	Thu Jan 18 10:34:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.11 2022/10/11 22:03:37 andvar Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.12 2024/01/18 10:34:29 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,11 +58,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.11 2022/10/11 22:03:37 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.12 2024/01/18 10:34:29 macallan Exp $");
 
 #include "locators.h"
 #include "power.h"
 #include "lcd.h"
+#include "opt_useleds.h"
 
 #include 
 #include 
@@ -83,9 +84,7 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 
 #include 
 #include 
 
-#if NLCD > 0
 static struct pdc_chassis_info pdc_chassis_info;
-#endif
 
 #ifdef MBUSDEBUG
 
@@ -1362,9 +1361,7 @@ mbattach(device_t parent, device_t self,
 	struct mainbus_softc *sc = device_private(self);
 	struct confargs nca;
 	bus_space_handle_t ioh;
-#if NLCD > 0
 	int err;
-#endif
 
 	sc->sc_dv = self;
 	mb_attached = 1;
@@ -1409,11 +1406,11 @@ mbattach(device_t parent, device_t self,
 	config_found(self, , mbprint, CFARGS_NONE);
 #endif
 
-#if NLCD > 0
 	memset(, 0, sizeof(nca));
 	err = pdcproc_chassis_info(_chassis_info, _pcl);
 	if (!err) {
 		if (nca.ca_pcl.enabled) {
+#if NLCD > 0
 			nca.ca_name = "lcd";
 			nca.ca_dp.dp_bc[0] = nca.ca_dp.dp_bc[1] = nca.ca_dp.dp_bc[2] =
 			nca.ca_dp.dp_bc[3] = nca.ca_dp.dp_bc[4] = nca.ca_dp.dp_bc[5] = -1;
@@ -1423,13 +1420,15 @@ mbattach(device_t parent, device_t self,
 			nca.ca_hpa = nca.ca_pcl.cmd_addr;
 
 			config_found(self, , mbprint, CFARGS_NONE);
+#endif
 		} else if (nca.ca_pcl.model == 2) {
+#ifdef USELEDS
 			bus_space_map(_bustag, nca.ca_pcl.cmd_addr,
 		  	  4, 0, (bus_space_handle_t *)_ledaddr);
 		  	machine_ledword = 1;
+#endif
 		}
 	}
-#endif
 
 	hppa_modules_scan();
 



CVS commit: src/sys/dev/dm

2024-01-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 14 07:56:53 UTC 2024

Modified Files:
src/sys/dev/dm: dm_ioctl.c

Log Message:
Avoid leaving a configured device without resources.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/dm/dm_ioctl.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/dev/dm/dm_ioctl.c
diff -u src/sys/dev/dm/dm_ioctl.c:1.56 src/sys/dev/dm/dm_ioctl.c:1.57
--- src/sys/dev/dm/dm_ioctl.c:1.56	Thu Oct 13 06:10:48 2022
+++ src/sys/dev/dm/dm_ioctl.c	Sun Jan 14 07:56:53 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_ioctl.c,v 1.56 2022/10/13 06:10:48 andvar Exp $  */
+/* $NetBSD: dm_ioctl.c,v 1.57 2024/01/14 07:56:53 mlelstv Exp $  */
 
 /*
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.56 2022/10/13 06:10:48 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_ioctl.c,v 1.57 2024/01/14 07:56:53 mlelstv Exp $");
 
 /*
  * Locking is used to synchronise between ioctl calls and between dm_table's
@@ -209,18 +209,21 @@ dm_dev_create_ioctl(prop_dictionary_t dm
 		dm_dev_unbusy(dmv);
 		return EEXIST;
 	}
+
+	if ((dmv = dm_dev_alloc()) == NULL)
+		return ENOMEM;
+
 	cf = kmem_alloc(sizeof(*cf), KM_SLEEP);
 	cf->cf_name = dm_cd.cd_name;
 	cf->cf_atname = dm_ca.ca_name;
 	cf->cf_unit = atomic_inc_32_nv(_minor_num);
 	cf->cf_fstate = FSTATE_NOTFOUND;
 	if ((devt = config_attach_pseudo(cf)) == NULL) {
+		dm_dev_free(dmv);
 		kmem_free(cf, sizeof(*cf));
 		aprint_error("Unable to attach pseudo device dm/%s\n", name);
 		return (ENOMEM);
 	}
-	if ((dmv = dm_dev_alloc()) == NULL)
-		return ENOMEM;
 
 	if (uuid)
 		strncpy(dmv->uuid, uuid, DM_UUID_LEN);
@@ -247,7 +250,7 @@ dm_dev_create_ioctl(prop_dictionary_t dm
 
 	prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
 
-	disk_init(dmv->diskp, dmv->name, );
+	disk_init(dmv->diskp, device_xname(devt), );
 	disk_attach(dmv->diskp);
 
 	dmv->diskp->dk_info = NULL;



CVS commit: src/sys/dev/dm

2024-01-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 14 07:56:53 UTC 2024

Modified Files:
src/sys/dev/dm: dm_ioctl.c

Log Message:
Avoid leaving a configured device without resources.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/dm/dm_ioctl.c

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



CVS commit: src/sys/dev/fdt

2024-01-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 14 07:53:38 UTC 2024

Modified Files:
src/sys/dev/fdt: fdt_memory.c

Log Message:
Handle multiple memory nodes by type, but still allow an untyped
(non-standard) node named /memory.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/fdt_memory.c

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



CVS commit: src/sys/dev/fdt

2024-01-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 14 07:53:38 UTC 2024

Modified Files:
src/sys/dev/fdt: fdt_memory.c

Log Message:
Handle multiple memory nodes by type, but still allow an untyped
(non-standard) node named /memory.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/fdt/fdt_memory.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/dev/fdt/fdt_memory.c
diff -u src/sys/dev/fdt/fdt_memory.c:1.9 src/sys/dev/fdt/fdt_memory.c:1.10
--- src/sys/dev/fdt/fdt_memory.c:1.9	Fri Jan 12 18:06:18 2024
+++ src/sys/dev/fdt/fdt_memory.c	Sun Jan 14 07:53:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_memory.c,v 1.9 2024/01/12 18:06:18 skrll Exp $ */
+/* $NetBSD: fdt_memory.c,v 1.10 2024/01/14 07:53:38 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "opt_fdt.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.9 2024/01/12 18:06:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_memory.c,v 1.10 2024/01/14 07:53:38 mlelstv Exp $");
 
 #include 
 #include 
@@ -77,26 +77,43 @@ fdt_memory_range_free(struct fdt_memory_
 void
 fdt_memory_get(uint64_t *pstart, uint64_t *pend)
 {
-	const int memory = OF_finddevice("/memory");
+	const void *fdt_data = fdtbus_get_data();
 	uint64_t cur_addr, cur_size;
-	int index, nadd;
+	int index, nadd = 0, off, memory;
 
-	for (index = 0, nadd = 0;
-	 fdtbus_get_reg64(memory, index, _addr, _size) == 0;
-	 index++) {
-		if (cur_size == 0)
-			continue;
-		fdt_memory_add_range(cur_addr, cur_size);
+	off = fdt_node_offset_by_prop_value(fdt_data, -1,
+	"device_type", "memory", sizeof("memory"));
 
-		if (nadd++ == 0) {
-			*pstart = cur_addr;
-			*pend = cur_addr + cur_size;
-			continue;
+	/*
+	 * Device Tree Specification 3.2 says that memory
+	 * nodes are named "memory" and have device_type
+	 * "memory", but if the device_type is missing, try
+	 * to find the (then single) node by name.
+	 */
+	if (off == -FDT_ERR_NOTFOUND)
+		off = fdt_path_offset(fdt_data, "/memory");
+
+	while (off != -FDT_ERR_NOTFOUND) {
+		memory = fdtbus_offset2phandle(off);
+		for (index = 0;
+		 fdtbus_get_reg64(memory, index, _addr, _size) == 0;
+		 index++) {
+			if (cur_size == 0)
+continue;
+			fdt_memory_add_range(cur_addr, cur_size);
+
+			if (nadd++ == 0) {
+*pstart = cur_addr;
+*pend = cur_addr + cur_size;
+continue;
+			}
+			if (cur_addr < *pstart)
+*pstart = cur_addr;
+			if (cur_addr + cur_size > *pend)
+*pend = cur_addr + cur_size;
 		}
-		if (cur_addr < *pstart)
-			*pstart = cur_addr;
-		if (cur_addr + cur_size > *pend)
-			*pend = cur_addr + cur_size;
+		off = fdt_node_offset_by_prop_value(fdt_data, off,
+		"device_type", "memory", sizeof("memory"));
 	}
 	if (nadd == 0)
 		panic("Cannot determine memory size");



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

2024-01-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jan 12 06:23:20 UTC 2024

Modified Files:
src/sys/arch/virt68k/dev: gfrtc_mainbus.c

Log Message:
The interrupt handler needs to clear the interrupt condition
before re-arming the timer. Otherwise the timer could expire
again before clearing the interrupt, the interrupt gets lost
and the clock stops.

On real hardware that could only occur if the timer interval
is extremely short or if there is a higher-than-clock interrupt
that delays processing. In the emulated world however, time
can progress non-continously and this happens often under load.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/dev/gfrtc_mainbus.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/virt68k/dev/gfrtc_mainbus.c
diff -u src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.1 src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.2
--- src/sys/arch/virt68k/dev/gfrtc_mainbus.c:1.1	Tue Jan  2 07:40:59 2024
+++ src/sys/arch/virt68k/dev/gfrtc_mainbus.c	Fri Jan 12 06:23:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gfrtc_mainbus.c,v 1.1 2024/01/02 07:40:59 thorpej Exp $	*/
+/*	$NetBSD: gfrtc_mainbus.c,v 1.2 2024/01/12 06:23:20 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2023, 2024 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gfrtc_mainbus.c,v 1.1 2024/01/02 07:40:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gfrtc_mainbus.c,v 1.2 2024/01/12 06:23:20 mlelstv Exp $");
 
 #include 
 #include 
@@ -65,12 +65,12 @@ struct gfrtc_mainbus_softc {
 
 #define	CLOCK_HANDLER()			\
 do {	\
-	/* Get the next alarm set ASAP. */\
-	gfrtc_set_alarm(>sc_gfrtc, sc->sc_interval_ns);		\
-	\
 	/* Clear the interrupt condition. */\
 	gfrtc_clear_interrupt(>sc_gfrtc);\
 	\
+	/* Get the next alarm set ASAP. */\
+	gfrtc_set_alarm(>sc_gfrtc, sc->sc_interval_ns);		\
+	\
 	/* Increment the counter and call the handler. */		\
 	sc->sc_evcnt->ev_count++;	\
 	sc->sc_handler((struct clockframe *)v);\



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

2024-01-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Jan 12 06:23:20 UTC 2024

Modified Files:
src/sys/arch/virt68k/dev: gfrtc_mainbus.c

Log Message:
The interrupt handler needs to clear the interrupt condition
before re-arming the timer. Otherwise the timer could expire
again before clearing the interrupt, the interrupt gets lost
and the clock stops.

On real hardware that could only occur if the timer interval
is extremely short or if there is a higher-than-clock interrupt
that delays processing. In the emulated world however, time
can progress non-continously and this happens often under load.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/virt68k/dev/gfrtc_mainbus.c

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



CVS commit: xsrc/local/programs/bdfload

2024-01-08 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Mon Jan  8 18:09:33 UTC 2024

Modified Files:
xsrc/local/programs/bdfload: bdfload.c

Log Message:
add support for doubling a font's size, with optional smoothing
- works only on fonts up to 8 pixels wide for now
- smoothing attempts to detect pixel staircases and add pixels to smooth
  them out


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 xsrc/local/programs/bdfload/bdfload.c

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

Modified files:

Index: xsrc/local/programs/bdfload/bdfload.c
diff -u xsrc/local/programs/bdfload/bdfload.c:1.20 xsrc/local/programs/bdfload/bdfload.c:1.21
--- xsrc/local/programs/bdfload/bdfload.c:1.20	Thu Jul 27 08:44:42 2023
+++ xsrc/local/programs/bdfload/bdfload.c	Mon Jan  8 18:09:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdfload.c,v 1.20 2023/07/27 08:44:42 macallan Exp $	*/
+/*	$NetBSD: bdfload.c,v 1.21 2024/01/08 18:09:33 macallan Exp $	*/
 
 /*
  * Copyright (c) 2018 Michael Lorenz
@@ -103,6 +103,8 @@ int verbose = 0;
 int dump = 0;
 int header = 0;
 int force = 0;
+int scale = 0;
+int smoothe = 0;
 char commentbuf[2048] = "";
 int commentptr = 0;
 char fontname[64] = "";
@@ -125,9 +127,11 @@ dump_line(char *gptr, int stride)
 }
  
 void
-write_wsf(const char *oname, struct wsdisplay_font *f, char *buffer, int buflen)
+write_wsf(const char *oname, struct wsdisplay_font *f)
 {
 	struct wsfthdr h;
+	uint8_t *buffer = f->data;
+	int buflen = f->numchars * f->stride * f->fontheight;
 
 	memset(, 0, sizeof(h));
 	strncpy(h.magic, "WSFT", sizeof(h.magic));
@@ -161,10 +165,10 @@ write_wsf(const char *oname, struct wsdi
 }
 
 int
-write_header(const char *filename, struct wsdisplay_font *f, 
- char *buffer, int buflen)
+write_header(const char *filename, struct wsdisplay_font *f)
 {
 	FILE *output;
+	char *buffer = f->data;
 	int i, j, x, y, idx, pxls, left;
 	char name[64], c, msk;
 	
@@ -200,11 +204,11 @@ write_header(const char *filename, struc
 	fprintf(output, "\t%s_data\t\t/* data */\n", name);
 	fprintf(output, "};\n\n");
 	fprintf(output, "static u_char %s_data[] = {\n", name);
-	for (i = f->firstchar; i < f->firstchar + f->numchars; i++) {
+	for (i = 0; i < f->numchars; i++) {
 		if (names[i] != NULL) {
-			fprintf(output, "\t/* %d %s */\n", i, names[i]);
+			fprintf(output, "\t/* %d %s */\n", i + f->firstchar, names[i]);
 		} else			
-			fprintf(output, "\t/* %d */\n", i);
+			fprintf(output, "\t/* %d */\n", i + f->firstchar);
 		idx = i * f->stride * f->fontheight;
 		for (y = 0; y < f->fontheight; y++) {
 			for (x = 0; x < f->stride; x++) {
@@ -234,6 +238,79 @@ write_header(const char *filename, struc
 }
 
 void
+double_pixels(uint8_t *inbuf, uint16_t *outbuf, int bytes)
+{
+	int i, j;
+	uint16_t outmask, out;
+	uint8_t in, inmask;
+
+	for (i = 0; i < bytes; i++) {
+		inmask = 0x80;
+		outmask = 0xc000;
+		out = 0;
+		in = inbuf[i];
+		for (j = 0; j < 8; j++) {
+			if (in & inmask) {
+out |= outmask;
+			}
+			inmask = inmask >> 1;
+			outmask = outmask >> 2;
+		}
+		outbuf[i * 2] = htobe16(out);
+	}
+}
+
+void fill_dup(uint16_t *buf, int lines)
+{
+	int i;
+	for (i = 0; i < lines; i++) {
+		buf[2 * i + 1] = buf[2 * i];
+	}
+}
+
+void smoothe_pixels(uint16_t *buf, int lines)
+{
+	int i, j, topright, topleft, botright, botleft;
+	uint16_t pmask, in, prev, next, out;
+	for (i = 0; i < lines; i++) {
+		pmask = 0xc000;
+		in = be16toh(buf[i]);
+		out = in;
+		prev = next = 0;
+		if (i > 1) prev = be16toh(buf[i - 2]);
+		if (i < (lines - 2)) next = be16toh(buf[i + 2]);
+		for (j = 0; j < 8; j++) {
+			if ((in & pmask) == 0) {
+/* empty pixel, check surroundings */
+topright = topleft = botright = botleft = 0;
+if (((i & 1) == 0) && (j < 6))
+	topright = (((prev & pmask) == pmask) &&
+		((prev & (pmask >> 2)) != 0) &&
+		((in & (pmask >> 2)) != 0));
+if (((i & 1) == 0) && (j > 0))
+	topleft = (((prev & pmask) == pmask) &&
+		((prev & (pmask << 2)) != 0) &&
+		((in & (pmask << 2)) != 0));
+if ((i & 1) && (j < 6))
+	botright = (((next & pmask) == pmask) &&
+		((next & (pmask >> 2)) != 0) &&
+		((in & (pmask >> 2)) != 0));
+if ((i & 1) && (j > 0))
+	botleft = (((next & pmask) == pmask) &&
+		((next & (pmask << 2)) != 0) &&
+		((in & (pmask << 2)) != 0));
+if ((topright + topleft + botright + botleft) == 1) {
+	if (topleft || botleft) out |= pmask << 1;
+	if (topright || botright) out |

CVS commit: xsrc/local/programs/bdfload

2024-01-08 Thread Michael Lorenz
Module Name:xsrc
Committed By:   macallan
Date:   Mon Jan  8 18:09:33 UTC 2024

Modified Files:
xsrc/local/programs/bdfload: bdfload.c

Log Message:
add support for doubling a font's size, with optional smoothing
- works only on fonts up to 8 pixels wide for now
- smoothing attempts to detect pixel staircases and add pixels to smooth
  them out


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 xsrc/local/programs/bdfload/bdfload.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/i386/stand

2024-01-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jan  6 21:26:43 UTC 2024

Modified Files:
src/sys/arch/i386/stand/efiboot: efidisk.c efidisk.h
src/sys/arch/i386/stand/lib: biosdisk.c exec.c

Log Message:
In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
  hard drives (with geom) and CD-ROM (without).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/efidisk.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/efidisk.h
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/i386/stand/lib/exec.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/i386/stand/efiboot/efidisk.c
diff -u src/sys/arch/i386/stand/efiboot/efidisk.c:1.10 src/sys/arch/i386/stand/efiboot/efidisk.c:1.11
--- src/sys/arch/i386/stand/efiboot/efidisk.c:1.10	Sun May 14 09:07:54 2023
+++ src/sys/arch/i386/stand/efiboot/efidisk.c	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.c,v 1.10 2023/05/14 09:07:54 riastradh Exp $	*/
+/*	$NetBSD: efidisk.c,v 1.11 2024/01/06 21:26:43 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -38,9 +38,12 @@
 #include "biosdisk_ll.h"
 #include "devopen.h"
 #include "efidisk.h"
+#include "bootinfo.h"
 
 static struct efidiskinfo_lh efi_disklist;
 static int nefidisks;
+static struct btinfo_biosgeom *bibg;
+static size_t bibg_len;
 
 #define MAXDEVNAME 39 /* "NAME=" + 34 char part_name */
 
@@ -158,6 +161,23 @@ next:
 		if (edi->bootdev)
 			boot_biosdev = edi->dev;
 	}
+
+	bibg_len = sizeof(*bibg) + nefidisks * sizeof(struct bi_biosgeom_entry);
+	bibg = alloc(bibg_len);
+	if (bibg == NULL)
+		return;
+
+	bibg->num = nefidisks;
+
+	i = 0;
+	TAILQ_FOREACH(edi, _disklist, list) {
+		if (edi->type == BIOSDISK_TYPE_HD) {
+			memset(>disk[i], 0, sizeof(bibg->disk[i]));
+			bibg->disk[i].dev = edi->dev;
+			bibg->disk[i].flags = BI_GEOM_INVALID;
+		}
+		++i;
+	}
 }
 
 static void
@@ -383,3 +403,10 @@ efidisk_get_efi_system_partition(int dev
 	*partition = i;
 	return 0;
 }
+
+void
+efidisk_getbiosgeom()
+{
+	BI_ADD(bibg, BTINFO_BIOSGEOM, bibg_len);
+}
+

Index: src/sys/arch/i386/stand/efiboot/efidisk.h
diff -u src/sys/arch/i386/stand/efiboot/efidisk.h:1.3 src/sys/arch/i386/stand/efiboot/efidisk.h:1.4
--- src/sys/arch/i386/stand/efiboot/efidisk.h:1.3	Mon Apr  2 09:44:18 2018
+++ src/sys/arch/i386/stand/efiboot/efidisk.h	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.h,v 1.3 2018/04/02 09:44:18 nonaka Exp $	*/
+/*	$NetBSD: efidisk.h,v 1.4 2024/01/06 21:26:43 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -41,3 +41,4 @@ TAILQ_HEAD(efidiskinfo_lh, efidiskinfo);
 
 const struct efidiskinfo *efidisk_getinfo(int);
 int efidisk_get_efi_system_partition(int, int *);
+void efidisk_getbiosgeom(void);

Index: src/sys/arch/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.60 src/sys/arch/i386/stand/lib/biosdisk.c:1.61
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.60	Mon Oct  2 00:02:33 2023
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.60 2023/10/02 00:02:33 manu Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.61 2024/01/06 21:26:43 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -1198,11 +1198,13 @@ out:
 static void
 add_biosdisk_bootinfo(void)
 {
+#ifndef EFIBOOT
 	if (bootinfo == NULL) {
 		return;
 	}
 	BI_ADD(_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
 	BI_ADD(_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
+#endif
 	return;
 }
 #endif

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.79 src/sys/arch/i386/stand/lib/exec.c:1.80
--- src/sys/arch/i386/stand/lib/exec.c:1.79	Thu Apr 20 00:42:24 2023
+++ src/sys/arch/i386/stand/lib/exec.c	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.79 2023/04/20 00:42:24 manu Exp $	 */
+/*	$NetBSD: exec.c,v 1.80 2024/01/06 21:26:43 mlelstv Exp $	 */
 
 /*
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -108,6 +108,8 @@
 #endif
 #ifdef EFIBOOT
 #include "efiboot.h"
+#include "biosdisk.h"
+#include "efidisk.h"
 #undef DEBUG	/* XXX */
 #endif
 
@@ -498,6 +500,10 @@ exec_netbsd(const char *file, physaddr_t
 		goto out;
 	}
 #ifdef EFIBOOT
+	BI_ADD(_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
+	BI_ADD(_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
+	efidisk_getbiosgeom();
+
 	efi_load_start = marks[MARK_START];
 
 	/* adjust to the real load address */



CVS commit: src/sys/arch/i386/stand

2024-01-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jan  6 21:26:43 UTC 2024

Modified Files:
src/sys/arch/i386/stand/efiboot: efidisk.c efidisk.h
src/sys/arch/i386/stand/lib: biosdisk.c exec.c

Log Message:
In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
  hard drives (with geom) and CD-ROM (without).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/efidisk.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/efidisk.h
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/i386/stand/lib/exec.c

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



CVS commit: src/sys/kern

2024-01-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jan  4 11:18:20 UTC 2024

Modified Files:
src/sys/kern: subr_cpu.c

Log Message:
dump topology information with aprint_debug instead of requiring to build
a DEBUG kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/kern/subr_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/kern

2024-01-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jan  4 11:18:20 UTC 2024

Modified Files:
src/sys/kern: subr_cpu.c

Log Message:
dump topology information with aprint_debug instead of requiring to build
a DEBUG kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/kern/subr_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/kern/subr_cpu.c
diff -u src/sys/kern/subr_cpu.c:1.19 src/sys/kern/subr_cpu.c:1.20
--- src/sys/kern/subr_cpu.c:1.19	Sat Jul  8 13:59:05 2023
+++ src/sys/kern/subr_cpu.c	Thu Jan  4 11:18:19 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cpu.c,v 1.19 2023/07/08 13:59:05 riastradh Exp $	*/
+/*	$NetBSD: subr_cpu.c,v 1.20 2024/01/04 11:18:19 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019, 2020
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.19 2023/07/08 13:59:05 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.20 2024/01/04 11:18:19 mlelstv Exp $");
 
 #include 
 #include 
@@ -223,7 +223,6 @@ cpu_topology_link(struct cpu_info *ci, s
 static void
 cpu_topology_dump(void)
 {
-#ifdef DEBUG
 	CPU_INFO_ITERATOR cii;
 	struct cpu_info *ci, *ci2;
 	const char *names[] = { "core", "pkg", "1st" };
@@ -237,25 +236,24 @@ cpu_topology_dump(void)
 
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		if (cpu_topology_haveslow)
-			printf("%s ", ci->ci_is_slow ? "slow" : "fast");
+			aprint_debug("%s ", ci->ci_is_slow ? "slow" : "fast");
 		for (rel = 0; rel < __arraycount(ci->ci_sibling); rel++) {
-			printf("%s has %d %s siblings:", cpu_name(ci),
+			aprint_debug("%s has %d %s siblings:", cpu_name(ci),
 			ci->ci_nsibling[rel], names[rel]);
 			ci2 = ci->ci_sibling[rel];
 			i = 0;
 			do {
-printf(" %s", cpu_name(ci2));
+aprint_debug(" %s", cpu_name(ci2));
 ci2 = ci2->ci_sibling[rel];
 			} while (++i < 64 && ci2 != ci->ci_sibling[rel]);
 			if (i == 64) {
-printf(" GAVE UP");
+aprint_debug(" GAVE UP");
 			}
-			printf("\n");
+			aprint_debug("\n");
 		}
-		printf("%s first in package: %s\n", cpu_name(ci),
+		aprint_debug("%s first in package: %s\n", cpu_name(ci),
 		cpu_name(ci->ci_package1st));
 	}
-#endif	/* DEBUG */
 }
 
 /*



CVS commit: src/sys/dev/iscsi

2023-12-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Dec 28 15:58:24 UTC 2023

Modified Files:
src/sys/dev/iscsi: iscsi_main.c

Log Message:
Use correct status value SCSI_BUSY (0x08) instead of XS_BUSY (7) when running
out of sessions. The bug had no impact as scsipi was only comparing
against SCSI_CHECK (0x02) and SCSI_QUEUE_FULL (0x28).


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/iscsi/iscsi_main.c

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



CVS commit: src/sys/dev/iscsi

2023-12-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Dec 28 15:58:24 UTC 2023

Modified Files:
src/sys/dev/iscsi: iscsi_main.c

Log Message:
Use correct status value SCSI_BUSY (0x08) instead of XS_BUSY (7) when running
out of sessions. The bug had no impact as scsipi was only comparing
against SCSI_CHECK (0x02) and SCSI_QUEUE_FULL (0x28).


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/iscsi/iscsi_main.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/dev/iscsi/iscsi_main.c
diff -u src/sys/dev/iscsi/iscsi_main.c:1.41 src/sys/dev/iscsi/iscsi_main.c:1.42
--- src/sys/dev/iscsi/iscsi_main.c:1.41	Tue Sep 13 13:09:16 2022
+++ src/sys/dev/iscsi/iscsi_main.c	Thu Dec 28 15:58:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_main.c,v 1.41 2022/09/13 13:09:16 mlelstv Exp $	*/
+/*	$NetBSD: iscsi_main.c,v 1.42 2023/12/28 15:58:24 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -490,7 +490,7 @@ iscsi_scsipi_request(struct scsipi_chann
 			DEB(9, ("ISCSI: refcount too high: %d, winsize %d\n",
 sess->s_refcount, sess->s_send_window));
 			xs->error = XS_BUSY;
-			xs->status = XS_BUSY;
+			xs->status = SCSI_BUSY;
 			scsipi_done(xs);
 			return;
 		}



CVS commit: src/sbin/iscsid

2023-12-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Dec 27 18:07:30 UTC 2023

Modified Files:
src/sbin/iscsid: iscsid_driverif.c

Log Message:
Treat port 0 (unset) as ISCSI_DEFAULT_PORT like before.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/iscsid/iscsid_driverif.c

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

Modified files:

Index: src/sbin/iscsid/iscsid_driverif.c
diff -u src/sbin/iscsid/iscsid_driverif.c:1.9 src/sbin/iscsid/iscsid_driverif.c:1.10
--- src/sbin/iscsid/iscsid_driverif.c:1.9	Sat Nov 25 08:06:02 2023
+++ src/sbin/iscsid/iscsid_driverif.c	Wed Dec 27 18:07:30 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsid_driverif.c,v 1.9 2023/11/25 08:06:02 mlelstv Exp $	*/
+/*	$NetBSD: iscsid_driverif.c,v 1.10 2023/12/27 18:07:30 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
@@ -285,7 +285,8 @@ make_connection(session_t * sess, iscsid
 	memset(, 0, sizeof(hints));
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_STREAM;
-	snprintf(portnum, sizeof(portnum), "%u", addr->port);
+	snprintf(portnum, sizeof(portnum), "%u", addr->port
+	? addr->port : ISCSI_DEFAULT_PORT);
 	ret = getaddrinfo((char *)addr->address, portnum, , );
 	switch (ret) {
 	case 0:
@@ -553,7 +554,8 @@ event_recover_connection(uint32_t sid, u
 	memset(, 0, sizeof(hints));
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_STREAM;
-	snprintf(portnum, sizeof(portnum), "%u", addr->port);
+	snprintf(portnum, sizeof(portnum), "%u", addr->port
+	? addr->port : ISCSI_DEFAULT_PORT);
 	ret = getaddrinfo((char *)addr->address, portnum, , );
 	if (ret) {
 		DEB(1, ("getaddrinfo failed (%s)", gai_strerror(ret)));



CVS commit: src/sbin/iscsid

2023-12-27 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Dec 27 18:07:30 UTC 2023

Modified Files:
src/sbin/iscsid: iscsid_driverif.c

Log Message:
Treat port 0 (unset) as ISCSI_DEFAULT_PORT like before.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/iscsid/iscsid_driverif.c

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



CVS commit: src/sys/dev/pci

2023-12-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Dec 16 16:35:49 UTC 2023

Modified Files:
src/sys/dev/pci: if_rge.c

Log Message:
- handle stuck transmitter (descriptor still owned)
- restart send queue after transmit
- count output packets
- use deferred start

Should fix PR 57694


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/if_rge.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/dev/pci/if_rge.c
diff -u src/sys/dev/pci/if_rge.c:1.28 src/sys/dev/pci/if_rge.c:1.29
--- src/sys/dev/pci/if_rge.c:1.28	Thu Oct 19 23:43:40 2023
+++ src/sys/dev/pci/if_rge.c	Sat Dec 16 16:35:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_rge.c,v 1.28 2023/10/19 23:43:40 mrg Exp $	*/
+/*	$NetBSD: if_rge.c,v 1.29 2023/12/16 16:35:49 mlelstv Exp $	*/
 /*	$OpenBSD: if_rge.c,v 1.9 2020/12/12 11:48:53 jan Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_rge.c,v 1.28 2023/10/19 23:43:40 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rge.c,v 1.29 2023/12/16 16:35:49 mlelstv Exp $");
 
 #include 
 
@@ -351,6 +351,7 @@ rge_attach(device_t parent, device_t sel
 	sc->sc_media.ifm_media = sc->sc_media.ifm_cur->ifm_media;
 
 	if_attach(ifp);
+	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, eaddr);
 
 	if (pmf_device_register(self, NULL, NULL))
@@ -1385,10 +1386,14 @@ rge_txeof(struct rge_softc *sc)
 		m_freem(txq->txq_mbuf);
 		txq->txq_mbuf = NULL;
 
+		net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 		if (txstat & (RGE_TDCMDSTS_EXCESSCOLL | RGE_TDCMDSTS_COLL))
-			if_statinc(ifp, if_collisions);
+			if_statinc_ref(nsr, if_collisions);
 		if (txstat & RGE_TDCMDSTS_TXERR)
-			if_statinc(ifp, if_oerrors);
+			if_statinc_ref(nsr, if_oerrors);
+		else
+			if_statinc_ref(nsr, if_opackets);
+		IF_STAT_PUTREF(ifp);
 
 		bus_dmamap_sync(sc->sc_dmat, sc->rge_ldata.rge_tx_list_map,
 		idx * sizeof(struct rge_tx_desc),
@@ -1404,24 +1409,12 @@ rge_txeof(struct rge_softc *sc)
 
 	sc->rge_ldata.rge_txq_considx = cons;
 
-#if 0
-	if (ifq_is_oactive(>if_snd))
-		ifq_restart(>if_snd);
-	else if (free == 2)
-		ifq_serialize(>if_snd, >sc_task);
-	else
-		ifp->if_timer = 0;
-#else
-#if 0
-	if (!IF_IS_EMPTY(>if_snd))
-		rge_start(ifp);
-	else
 	if (free == 2)
-		if (0) { rge_txstart(>sc_task, sc); }
-	else
-#endif
-		ifp->if_timer = 0;
-#endif
+		rge_txstart(>sc_task, sc);
+
+	CLR(ifp->if_flags, IFF_OACTIVE);
+	ifp->if_timer = 0;
+	if_schedule_deferred_start(ifp);
 
 	return (1);
 }



CVS commit: src/sys/dev/pci

2023-12-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Dec 16 16:35:49 UTC 2023

Modified Files:
src/sys/dev/pci: if_rge.c

Log Message:
- handle stuck transmitter (descriptor still owned)
- restart send queue after transmit
- count output packets
- use deferred start

Should fix PR 57694


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/if_rge.c

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



  1   2   3   4   5   6   7   8   9   10   >