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

2024-05-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat May  4 16:06:57 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Add comments about quirks of 98542/98543 framebuffers with 1024x400 pixels.


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

2024-05-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat May  4 16:06:57 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Add comments about quirks of 98542/98543 framebuffers with 1024x400 pixels.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/hp300/dev/topcat.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/hp300/dev/topcat.c
diff -u src/sys/arch/hp300/dev/topcat.c:1.11 src/sys/arch/hp300/dev/topcat.c:1.12
--- src/sys/arch/hp300/dev/topcat.c:1.11	Wed May  1 19:28:33 2024
+++ src/sys/arch/hp300/dev/topcat.c	Sat May  4 16:06:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: topcat.c,v 1.11 2024/05/01 19:28:33 tsutsui Exp $	*/
+/*	$NetBSD: topcat.c,v 1.12 2024/05/04 16:06:57 tsutsui Exp $	*/
 /*	$OpenBSD: topcat.c,v 1.15 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -351,11 +351,24 @@ topcat_reset(struct diofb *fb, int scode
 	/*
 	 * Some displays, such as the HP332 and HP340 internal video
 	 * and HP98542/98543 appear to return a display width of 1024
-	 * instead of 512.
+	 * instead of 512. It looks these boards have actually have
+	 * enough 64KB (1bpp) or 256KB (4bpp) VRAM and RAMDAC capabilities
+	 * to display 1024x400 pixels.
 	 * 
-	 * It looks these boards have VRAM with sparse address layout,
-	 * i.e. 1 bit or 4 bits per pixel but 2 bytes per pixel, so
-	 * we have to handle 512 pixels per line with 1024 bytes per line.
+	 * However HP's officlal "Service Information Manual" for
+	 * "HP 900 Series 300 Computers Models 330/350" says:
+	 *  "The medium-resolution board uses eight memory chips per plane.
+	 *   This is enough to display 512 doubled pixels by 400 scan lines."
+	 *
+	 * This "512 doubled pixels" implies that the native HP-UX treated
+	 * these 1024x400 framebuffers as pseudo 512x400 ones because
+	 * ancient 1980s CRTs (such as 35741) didn't display such higher
+	 * resolution. Furthermore, even modern LCDs can only handle
+	 * upto 720 pixels in the "400 line" as VGA compatible mode.
+	 *
+	 * As mentioned above, we treat these 1024x400 1 bit or 4 bit
+	 * framebuffers as "2 bytes per pixel" ones, so we have to handle
+	 * 512 pixels per line with 1024 bytes per line.
 	 */
 	if (fb->planes <= 4 && fb->dwidth == 1024 && fb->dheight == 400) {
 		fb->dwidth = 512;
@@ -580,7 +593,8 @@ topcat_putchar8(void *cookie, int row, i
 }
 
 /*
- * Put a single character on 1 bpp or 4 bpp variants with sparse VRAM addresses
+ * Put a single character on 1 bpp (98542) or 4 bpp (98543) variants
+ * with 1024x400 VRAM to treat them as a pseudo 512x400 bitmap.
  */
 static void
 topcat_putchar1_4(void *cookie, int row, int col, u_int uc, long attr)
@@ -612,8 +626,8 @@ topcat_putchar1_4(void *cookie, int row,
 	tc_waitbusy(tc, diofb->planemask);
 
 	/*
-	 * At least HP98543 requires to write 4 bpp data onto
-	 * both odd and even addresses.
+	 * We have to put pixel data to both odd and even addresses
+	 * to handle "doubled pixels" as noted above.
 	 */
 	if (uc == ' ') {
 		uint16_t c = clr[0];



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

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 19:28:33 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: diofb.c diofbvar.h topcat.c

Log Message:
Fix topcat(4) problems on some models that cause garbages on screen.

- Make sure that windowmove (hardware BITBLT) ops complete by checking
  tc_busywait() before calling putchar functions by MI rasops(9).
  It looks CPU accesses against VRAM during windowmove (copy, erase,
  and cursor) ops causes unexpected garbages at least on 98543 on HP360,
  98547 on HP370, and also on 98543 on 040 HP380 (but not on 98549).

- Handle 'sparse VRAM' on 98543 (and probably 98542) properly:
 - Prepare and use own topcat_putchar1_4() function for sparse VRAM.
 - Pass proper 'VRAM width' rather than actuall font width to all
   windowmove (copycols, erasecols, copyrows, eraserows, and do_cursor)
   operation functions.

Now all topcat(4) consoles on 98543 on HP360/HP380 and 98547 on HP370
work fine, and no visible regression on 98549 on HP380 and 98544 on HP360.

Worth to pullup netbsd-10.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hp300/dev/diofb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hp300/dev/diofbvar.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/hp300/dev/topcat.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/hp300/dev/diofb.c
diff -u src/sys/arch/hp300/dev/diofb.c:1.9 src/sys/arch/hp300/dev/diofb.c:1.10
--- src/sys/arch/hp300/dev/diofb.c:1.9	Mon Apr 29 17:25:11 2024
+++ src/sys/arch/hp300/dev/diofb.c	Wed May  1 19:28:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: diofb.c,v 1.9 2024/04/29 17:25:11 tsutsui Exp $	*/
+/*	$NetBSD: diofb.c,v 1.10 2024/05/01 19:28:33 tsutsui Exp $	*/
 /*	$OpenBSD: diofb.c,v 1.18 2010/12/26 15:40:59 miod Exp $	*/
 
 /*
@@ -361,10 +361,11 @@ diofb_copycols(void *cookie, int row, in
 {
 	struct rasops_info *ri = cookie;
 	struct diofb *fb = ri->ri_hw;
+	int fontwidth = fb->wsd.fontwidth;
 
-	n *= ri->ri_font->fontwidth;
-	src *= ri->ri_font->fontwidth;
-	dst *= ri->ri_font->fontwidth;
+	n *= fontwidth;
+	src *= fontwidth;
+	dst *= fontwidth;
 	row *= ri->ri_font->fontheight;
 
 	(*fb->bmv)(fb, ri->ri_xorigin + src, ri->ri_yorigin + row,
@@ -394,11 +395,12 @@ diofb_erasecols(void *cookie, int row, i
 	struct diofb *fb = ri->ri_hw;
 	int fg, bg;
 	int snum, scol, srow;
+	int fontwidth = fb->wsd.fontwidth;
 
 	rasops_unpack_attr(attr, &fg, &bg, NULL);
 
-	snum = num * ri->ri_font->fontwidth;
-	scol = col * ri->ri_font->fontwidth + ri->ri_xorigin;
+	snum = num * fontwidth;
+	scol = col * fontwidth + ri->ri_xorigin;
 	srow = row * ri->ri_font->fontheight + ri->ri_yorigin;
 
 	/*
@@ -423,7 +425,7 @@ diofb_eraserows(void *cookie, int row, i
 	bg ^= 0xff;
 
 	if (num == ri->ri_rows && (ri->ri_flg & RI_FULLCLEAR)) {
-		rc = (*fb->bmv)(fb, 0, 0, 0, 0, ri->ri_width, ri->ri_height,
+		rc = (*fb->bmv)(fb, 0, 0, 0, 0, fb->fbwidth, ri->ri_height,
 		RR_CLEAR, bg);
 	} else {
 		srow = row * ri->ri_font->fontheight + ri->ri_yorigin;
@@ -440,10 +442,11 @@ diofb_do_cursor(struct rasops_info *ri)
 {
 	struct diofb *fb = ri->ri_hw;
 	int x, y;
+	int fontwidth = fb->wsd.fontwidth;
 
-	x = ri->ri_ccol * ri->ri_font->fontwidth + ri->ri_xorigin;
+	x = ri->ri_ccol * fontwidth + ri->ri_xorigin;
 	y = ri->ri_crow * ri->ri_font->fontheight + ri->ri_yorigin;
-	(*fb->bmv)(fb, x, y, x, y, ri->ri_font->fontwidth,
+	(*fb->bmv)(fb, x, y, x, y, fontwidth,
 	ri->ri_font->fontheight, RR_INVERT, 0xff);
 }
 

Index: src/sys/arch/hp300/dev/diofbvar.h
diff -u src/sys/arch/hp300/dev/diofbvar.h:1.4 src/sys/arch/hp300/dev/diofbvar.h:1.5
--- src/sys/arch/hp300/dev/diofbvar.h:1.4	Sun Jan 15 06:19:45 2023
+++ src/sys/arch/hp300/dev/diofbvar.h	Wed May  1 19:28:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: diofbvar.h,v 1.4 2023/01/15 06:19:45 tsutsui Exp $	*/
+/*	$NetBSD: diofbvar.h,v 1.5 2024/05/01 19:28:33 tsutsui Exp $	*/
 /*	$OpenBSD: diofbvar.h,v 1.10 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -105,6 +105,9 @@ struct diofb {
 	/* blockmove routine */
 	int	(*bmv)(struct diofb *, uint16_t, uint16_t, uint16_t,
 		uint16_t, uint16_t, uint16_t, int16_t, int16_t);
+
+	/* putchar routine to handle rasops; MD busywait might be required */
+	void	(*wsputchar)(void *, int, int, u_int, long);
 };
 
 /* Replacement Rules (rops) */

Index: src/sys/arch/hp300/dev/topcat.c
diff -u src/sys/arch/hp300/dev/topcat.c:1.10 src/sys/arch/hp300/dev/topcat.c:1.11
--- src/sys/arch/hp300/dev/topcat.c:1.10	Wed May  1 08:58:34 2024
+++ src/sys/arch/hp300/dev/topcat.c	Wed May  1 19:28:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: topcat.c,v 1.10 2024/05/01 08:58:34 tsutsui Exp $	*/
+/*	$NetBSD: topcat.c,v 1.11 2024/05/01 19:28:33 tsutsui Exp $	*/
 /*	$OpenBSD: topcat.c,v 1.15 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -149,6 +149,8 @@ static int	topcat_windowmove(struct diof
 		uint16_t, uint16_t, uint16_t, int16_t, int16_t);
 
 static int	topcat_ioctl(void *, void *, 

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

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 19:28:33 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: diofb.c diofbvar.h topcat.c

Log Message:
Fix topcat(4) problems on some models that cause garbages on screen.

- Make sure that windowmove (hardware BITBLT) ops complete by checking
  tc_busywait() before calling putchar functions by MI rasops(9).
  It looks CPU accesses against VRAM during windowmove (copy, erase,
  and cursor) ops causes unexpected garbages at least on 98543 on HP360,
  98547 on HP370, and also on 98543 on 040 HP380 (but not on 98549).

- Handle 'sparse VRAM' on 98543 (and probably 98542) properly:
 - Prepare and use own topcat_putchar1_4() function for sparse VRAM.
 - Pass proper 'VRAM width' rather than actuall font width to all
   windowmove (copycols, erasecols, copyrows, eraserows, and do_cursor)
   operation functions.

Now all topcat(4) consoles on 98543 on HP360/HP380 and 98547 on HP370
work fine, and no visible regression on 98549 on HP380 and 98544 on HP360.

Worth to pullup netbsd-10.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hp300/dev/diofb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hp300/dev/diofbvar.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/hp300/dev/topcat.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/hp300/dev

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 08:58:34 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Add DELAY(9) to make palette register settings stable on 98543 in HP360.

Note 98547 (6 bpp variant) on HP370 (68030 33MHz) doesn't need these
DELAYs so maybe only some old variants (98543 and 98545?) on 020/030
have such restriction (actually only one nop seems enough.)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hp300/dev/topcat.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/hp300/dev/topcat.c
diff -u src/sys/arch/hp300/dev/topcat.c:1.9 src/sys/arch/hp300/dev/topcat.c:1.10
--- src/sys/arch/hp300/dev/topcat.c:1.9	Mon Apr 29 17:47:27 2024
+++ src/sys/arch/hp300/dev/topcat.c	Wed May  1 08:58:34 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: topcat.c,v 1.9 2024/04/29 17:47:27 tsutsui Exp $	*/
+/*	$NetBSD: topcat.c,v 1.10 2024/05/01 08:58:34 tsutsui Exp $	*/
 /*	$OpenBSD: topcat.c,v 1.15 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -474,7 +474,9 @@ topcat_setcolor(struct diofb *fb, u_int 
 		tc->rdata  = fb->cmap.r[index];
 		tc->gdata  = fb->cmap.g[index];
 		tc->bdata  = fb->cmap.b[index];
+		DELAY(1);	/* necessary for at least old HP98543 */
 		tc->cindex = ~index;
+		DELAY(1);	/* necessary for at least old HP98543 */
 		tc->strobe = 0xff;
 		/* XXX delay required on 68020/30 to avoid bus error */
 		DELAY(100);



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

2024-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  1 08:58:34 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Add DELAY(9) to make palette register settings stable on 98543 in HP360.

Note 98547 (6 bpp variant) on HP370 (68030 33MHz) doesn't need these
DELAYs so maybe only some old variants (98543 and 98545?) on 020/030
have such restriction (actually only one nop seems enough.)


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

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



Re: CVS commit: src/sys/arch/hp300/dev

2024-04-30 Thread Roland Illig
Am 30.04.2024 um 11:55 schrieb Izumi Tsutsui:
> Module Name:  src
> Committed By: tsutsui
> Date: Tue Apr 30 09:55:46 UTC 2024
>
> Modified Files:
>   src/sys/arch/hp300/dev: dma.c
>
> Log Message:
> Fix another fatal typo that prevents dma(4) interrupts.

The buggy code was:
>   if ((sc->sc_ipl == ipl) == 0) {

The typo in the first '==' can be found by treating bool as a data type
incompatible with any other scalar type, and this is what lint does in
its "strict bool mode".

Lint is not yet ready for the whole kernel source, as it errors out on
232 of the 3223 source files. But it can check hp300/dma.c, and running
it with the extra flag -T finds the bug, among several false positives.

If you want to play around a bit, the attached patch allows you to
suppress the uninteresting lint warnings in the kernel source, and to
configure per-file lint flags. To detect the above bug in dma.c 1.47, run:

cd OBJDIR/sys/arch/hp300/compile/GENERIC
make dma.ln KERNLINTFLAGS.dma.c=-T

Roland
Index: sys/conf/lint.mk
===
RCS file: /cvsroot/src/sys/conf/lint.mk,v
retrieving revision 1.5
diff -u -r1.5 lint.mk
--- sys/conf/lint.mk27 Aug 2022 21:49:33 -  1.5
+++ sys/conf/lint.mk30 Apr 2024 22:50:59 -
@@ -5,11 +5,25 @@
 ##
 
 .if !target(lint)
+DEFKERNLINTFLAGS=  -bceghnxzFS
+DEFKERNLINTFLAGS+= -X 0# empty declaration
+DEFKERNLINTFLAGS+= -X 2# empty declaration
+DEFKERNLINTFLAGS+= -X 56   # integral constant too large
+DEFKERNLINTFLAGS+= -X 129  # expression with null effect
+DEFKERNLINTFLAGS+= -X 161  # constant in conditional context
+DEFKERNLINTFLAGS+= -X 226  # static variable unused
+DEFKERNLINTFLAGS+= -X 231  # unused parameter
+DEFKERNLINTFLAGS+= -X 236  # unused static function
+DEFKERNLINTFLAGS+= -X 247  # pointer cast may be troublesome
+DEFKERNLINTFLAGS+= -X 309  # lossy bitwise '&'
+DEFKERNLINTFLAGS+= -X 351  # missing header declaration
+DEFKERNLINTFLAGS+= -X 352  # nested 'extern' declaration
+
 .PATH: $S
 ALLSFILES?=${MD_SFILES} ${SFILES}
 LINTSTUBS?=${ALLSFILES:T:R:%=LintStub_%.c}
-KERNLINTFLAGS?=-bceghnxzFS
-NORMAL_LN?=${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} -o $@ -i $<
+KERNLINTFLAGS?=${DEFKERNLINTFLAGS}
+NORMAL_LN?=${LINT} ${KERNLINTFLAGS} ${KERNLINTFLAGS.${.IMPSRC:T}} 
${CPPFLAGS:M-[IDU]*} -o $@ -i $<
 
 _lsrc= ${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
 LOBJS?=${_lsrc:T:.c=.ln} ${LIBKERNLN} ${SYSLIBCOMPATLN}


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

2024-04-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Apr 30 09:55:46 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: dma.c

Log Message:
Fix another fatal typo that prevents dma(4) interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/hp300/dev/dma.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/hp300/dev/dma.c
diff -u src/sys/arch/hp300/dev/dma.c:1.47 src/sys/arch/hp300/dev/dma.c:1.48
--- src/sys/arch/hp300/dev/dma.c:1.47	Tue Jan 16 07:06:59 2024
+++ src/sys/arch/hp300/dev/dma.c	Tue Apr 30 09:55:45 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: dma.c,v 1.47 2024/01/16 07:06:59 thorpej Exp $	*/
+/*	$NetBSD: dma.c,v 1.48 2024/04/30 09:55:45 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 #include "opt_m68k_arch.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dma.c,v 1.47 2024/01/16 07:06:59 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dma.c,v 1.48 2024/04/30 09:55:45 tsutsui Exp $");
 
 #include 	/* XXX param.h includes cpu.h */
 
@@ -276,7 +276,7 @@ dmaupdateipl(int ipl)
 		intr_disestablish(sc->sc_ih);
 	}
 
-	if ((sc->sc_ipl == ipl) == 0) {
+	if ((sc->sc_ipl = ipl) == 0) {
 		/* Don't hook up a new handler. */
 		return;
 	}



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

2024-04-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Apr 30 09:55:46 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: dma.c

Log Message:
Fix another fatal typo that prevents dma(4) interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/hp300/dev/dma.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/hp300/dev

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Apr 30 05:06:09 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: intio.c

Log Message:
Fix fatal typo that prevents all intio devices probed.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/hp300/dev/intio.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/hp300/dev/intio.c
diff -u src/sys/arch/hp300/dev/intio.c:1.32 src/sys/arch/hp300/dev/intio.c:1.33
--- src/sys/arch/hp300/dev/intio.c:1.32	Sun Jan 28 17:31:40 2024
+++ src/sys/arch/hp300/dev/intio.c	Tue Apr 30 05:06:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: intio.c,v 1.32 2024/01/28 17:31:40 thorpej Exp $	*/
+/*	$NetBSD: intio.c,v 1.33 2024/04/30 05:06:08 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1998, 2001 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.32 2024/01/28 17:31:40 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.33 2024/04/30 05:06:08 tsutsui Exp $");
 
 #include 
 #include 
@@ -68,9 +68,9 @@ CFATTACH_DECL_NEW(intio, sizeof(struct i
 #endif
 
 #define	INTIO_3xx_BUILTINS		\
-	(__BIT(HP_320) | __BIT(HP_330) | __BIT(HP_340) ||		\
-	 __BIT(HP_345) | __BIT(HP_345) | __BIT(HP_350) ||		\
-	 __BIT(HP_360) | __BIT(HP_370) | __BIT(HP_375) ||		\
+	(__BIT(HP_320) | __BIT(HP_330) | __BIT(HP_340) |		\
+	 __BIT(HP_345) | __BIT(HP_345) | __BIT(HP_350) |		\
+	 __BIT(HP_360) | __BIT(HP_370) | __BIT(HP_375) |		\
 	 __BIT(HP_380) | __BIT(HP_385))
 
 #define	INTIO_362_BUILTINS	__BIT(HP_362)



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

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Apr 30 05:06:09 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: intio.c

Log Message:
Fix fatal typo that prevents all intio devices probed.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/hp300/dev/intio.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/hp300/dev

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Apr 29 17:47:27 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Check tc_waitbusy() before writing palette registers in topcat_setcolor().

This seems to make palette operations more stable on my HP360 with HP98543.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hp300/dev/topcat.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/hp300/dev/topcat.c
diff -u src/sys/arch/hp300/dev/topcat.c:1.8 src/sys/arch/hp300/dev/topcat.c:1.9
--- src/sys/arch/hp300/dev/topcat.c:1.8	Mon Apr 29 17:39:59 2024
+++ src/sys/arch/hp300/dev/topcat.c	Mon Apr 29 17:47:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: topcat.c,v 1.8 2024/04/29 17:39:59 tsutsui Exp $	*/
+/*	$NetBSD: topcat.c,v 1.9 2024/04/29 17:47:27 tsutsui Exp $	*/
 /*	$OpenBSD: topcat.c,v 1.15 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -453,6 +453,8 @@ topcat_setcolor(struct diofb *fb, u_int 
 	if (fb->planemask == 1)
 		return;
 
+	tc_waitbusy(tc, fb->planemask);
+
 	if (tc->regs.fbid != GID_TOPCAT) {
 		tccm_waitbusy(tc);
 		tc->plane_mask = fb->planemask;
@@ -542,8 +544,6 @@ topcat_windowmove(struct diofb *fb, uint
 	tc->wwidth = cx;
 	tc->wmove = fb->planemask;
 
-	tc_waitbusy(tc, fb->planemask);
-
 	return 0;
 }
 



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

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Apr 29 17:47:27 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Check tc_waitbusy() before writing palette registers in topcat_setcolor().

This seems to make palette operations more stable on my HP360 with HP98543.


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

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Apr 29 17:39:59 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Use proper planemask per a vaild number of planes.


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

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Apr 29 17:39:59 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Use proper planemask per a vaild number of planes.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hp300/dev/topcat.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/hp300/dev/topcat.c
diff -u src/sys/arch/hp300/dev/topcat.c:1.7 src/sys/arch/hp300/dev/topcat.c:1.8
--- src/sys/arch/hp300/dev/topcat.c:1.7	Mon Apr 29 15:34:57 2024
+++ src/sys/arch/hp300/dev/topcat.c	Mon Apr 29 17:39:59 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: topcat.c,v 1.7 2024/04/29 15:34:57 tsutsui Exp $	*/
+/*	$NetBSD: topcat.c,v 1.8 2024/04/29 17:39:59 tsutsui Exp $	*/
 /*	$OpenBSD: topcat.c,v 1.15 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -395,7 +395,7 @@ topcat_restore(struct diofb *fb)
 	tc->prr  = RR_COPY;
 
 	/* Enable display */
-	tc->nblank = 0xff;
+	tc->nblank = fb->planemask;
 }
 
 int
@@ -455,7 +455,7 @@ topcat_setcolor(struct diofb *fb, u_int 
 
 	if (tc->regs.fbid != GID_TOPCAT) {
 		tccm_waitbusy(tc);
-		tc->plane_mask = 0xff;
+		tc->plane_mask = fb->planemask;
 		tc->cindex = ~index;
 		tc->rdata  = fb->cmap.r[index];
 		tc->gdata  = fb->cmap.g[index];
@@ -468,7 +468,7 @@ topcat_setcolor(struct diofb *fb, u_int 
 		tc->cindex = 0;
 	} else {
 		tccm_waitbusy(tc);
-		tc->plane_mask = 0xff;
+		tc->plane_mask = fb->planemask;
 		tc->rdata  = fb->cmap.r[index];
 		tc->gdata  = fb->cmap.g[index];
 		tc->bdata  = fb->cmap.b[index];
@@ -526,12 +526,13 @@ topcat_windowmove(struct diofb *fb, uint
 
 	tc_waitbusy(tc, fb->planemask);
 
-	tc->wen = planemask;
-	tc->wmrr = rop;
 	if (planemask != 0xff) {
 		tc->wen = planemask ^ 0xff;
 		tc->wmrr = rop ^ 0x0f;
 		tc->wen = fb->planemask;
+	} else {
+		tc->wen = planemask;
+		tc->wmrr = rop;
 	}
 	tc->source_y = sy;
 	tc->source_x = sx;



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

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Apr 29 17:25:11 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: diofb.c

Log Message:
Fix MD allocattr to return proper attributes what MI rasops(9) expects.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hp300/dev/diofb.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/hp300/dev/diofb.c
diff -u src/sys/arch/hp300/dev/diofb.c:1.8 src/sys/arch/hp300/dev/diofb.c:1.9
--- src/sys/arch/hp300/dev/diofb.c:1.8	Mon Apr 29 15:34:57 2024
+++ src/sys/arch/hp300/dev/diofb.c	Mon Apr 29 17:25:11 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: diofb.c,v 1.8 2024/04/29 15:34:57 tsutsui Exp $	*/
+/*	$NetBSD: diofb.c,v 1.9 2024/04/29 17:25:11 tsutsui Exp $	*/
 /*	$OpenBSD: diofb.c,v 1.18 2010/12/26 15:40:59 miod Exp $	*/
 
 /*
@@ -351,9 +351,7 @@ diofb_allocattr(void *cookie, int fg, in
 		bg = swap;
 	}
 
-	flg = ((flg & WSATTR_UNDERLINE) ? 1 : 0);
-
-	*attr = (bg << 16) | (fg << 24) | flg;
+	*attr = (bg << 16) | (fg << 24) | (flg & WSATTR_UNDERLINE);
 
 	return 0;
 }



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

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Apr 29 17:25:11 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: diofb.c

Log Message:
Fix MD allocattr to return proper attributes what MI rasops(9) expects.


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

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Apr 29 15:34:57 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: diofb.c topcat.c

Log Message:
Move a check of topcat(4) specific fb width quirks to topcat.c.

We need to check fb->planes but it's propbed in topcat.c after
common diofb_fbinquire() is called.

Also add a comment that it looks these 1 bpp and 4 bpp boards have
VRAM with sparse address layout and we have to handle
512 pixels per line with 1024 bytes per line.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hp300/dev/diofb.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hp300/dev/topcat.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/hp300/dev/diofb.c
diff -u src/sys/arch/hp300/dev/diofb.c:1.7 src/sys/arch/hp300/dev/diofb.c:1.8
--- src/sys/arch/hp300/dev/diofb.c:1.7	Sat Aug  7 16:18:53 2021
+++ src/sys/arch/hp300/dev/diofb.c	Mon Apr 29 15:34:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: diofb.c,v 1.7 2021/08/07 16:18:53 thorpej Exp $	*/
+/*	$NetBSD: diofb.c,v 1.8 2024/04/29 15:34:57 tsutsui Exp $	*/
 /*	$OpenBSD: diofb.c,v 1.18 2010/12/26 15:40:59 miod Exp $	*/
 
 /*
@@ -146,15 +146,6 @@ diofb_fbinquire(struct diofb *fb, int sc
 	if (fb->dheight > fb->fbheight)
 		fb->dheight = fb->fbheight;
 
-	/*
-	 * Some displays, such as the HP332 and HP340 internal video
-	 * appear to return a display width of 1024 instead of 512.
-	 */
-	if (fbr->num_planes == 1 || fbr->num_planes == 4) {
-		if (fb->dwidth == 1024 && fb->dheight == 400)
-			fb->dwidth = 512;
-	}
-
 	fb->planes = fbr->num_planes;
 	if (fb->planes > 8)
 		fb->planes = 8;

Index: src/sys/arch/hp300/dev/topcat.c
diff -u src/sys/arch/hp300/dev/topcat.c:1.6 src/sys/arch/hp300/dev/topcat.c:1.7
--- src/sys/arch/hp300/dev/topcat.c:1.6	Wed Nov 30 11:36:50 2022
+++ src/sys/arch/hp300/dev/topcat.c	Mon Apr 29 15:34:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: topcat.c,v 1.6 2022/11/30 11:36:50 tsutsui Exp $	*/
+/*	$NetBSD: topcat.c,v 1.7 2024/04/29 15:34:57 tsutsui Exp $	*/
 /*	$OpenBSD: topcat.c,v 1.15 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -344,6 +344,19 @@ topcat_reset(struct diofb *fb, int scode
 		fb->planemask = (1 << fb->planes) - 1;
 	}
 
+	/*
+	 * Some displays, such as the HP332 and HP340 internal video
+	 * and HP98542/98543 appear to return a display width of 1024
+	 * instead of 512.
+	 * 
+	 * It looks these boards have VRAM with sparse address layout,
+	 * i.e. 1 bit or 4 bits per pixel but 2 bytes per pixel, so
+	 * we have to handle 512 pixels per line with 1024 bytes per line.
+	 */
+	if (fb->planes <= 4 && fb->dwidth == 1024 && fb->dheight == 400) {
+		fb->dwidth = 512;
+	}
+
 	fb->bmv = topcat_windowmove;
 	topcat_restore(fb);
 	diofb_fbsetup(fb);



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

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Apr 29 15:34:57 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: diofb.c topcat.c

Log Message:
Move a check of topcat(4) specific fb width quirks to topcat.c.

We need to check fb->planes but it's propbed in topcat.c after
common diofb_fbinquire() is called.

Also add a comment that it looks these 1 bpp and 4 bpp boards have
VRAM with sparse address layout and we have to handle
512 pixels per line with 1024 bytes per line.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hp300/dev/diofb.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/hp300/dev/topcat.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/hp300/dev

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Apr 29 14:58:32 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcatreg.h

Log Message:
Increase DELAY() for waitbusy macroes as pre-wscons and 4.4BSD did.

It looks necessary for sane palette ops at least on HP98543 topcat
on 68030 HP 9000/360.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hp300/dev/topcatreg.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/hp300/dev/topcatreg.h
diff -u src/sys/arch/hp300/dev/topcatreg.h:1.4 src/sys/arch/hp300/dev/topcatreg.h:1.5
--- src/sys/arch/hp300/dev/topcatreg.h:1.4	Fri Feb  2 22:19:13 2024
+++ src/sys/arch/hp300/dev/topcatreg.h	Mon Apr 29 14:58:32 2024
@@ -1,5 +1,5 @@
 /*	$OpenBSD: topcatreg.h,v 1.2 2005/01/24 21:36:39 miod Exp $	*/
-/*	$NetBSD: topcatreg.h,v 1.4 2024/02/02 22:19:13 andvar Exp $	*/
+/*	$NetBSD: topcatreg.h,v 1.5 2024/04/29 14:58:32 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -42,13 +42,13 @@
 #define tccm_waitbusy(regaddr) \
 do { \
 	while (((volatile struct tcboxfb *)(regaddr))->cmap_busy & 0x04) \
-		DELAY(10); \
+		DELAY(100); \
 } while (/* CONSTCOND */0)
 
 #define tc_waitbusy(regaddr,planes) \
 do { \
 	while (((volatile struct tcboxfb *)(regaddr))->busy & planes) \
-		DELAY(10); \
+		DELAY(100); \
 } while (/* CONSTCOND */0)
 
 struct tcboxfb {



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

2024-04-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Apr 29 14:58:32 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: topcatreg.h

Log Message:
Increase DELAY() for waitbusy macroes as pre-wscons and 4.4BSD did.

It looks necessary for sane palette ops at least on HP98543 topcat
on 68030 HP 9000/360.


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

2024-01-28 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 28 17:31:40 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: intio.c intiovar.h

Log Message:
Rather than having different "builtin" tables (3xx, 362, 382, 4xx),
just have a single "builtin" table with a mask indicating which of
those groups of machines have a particular built-in device.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/hp300/dev/intio.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hp300/dev/intiovar.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/hp300/dev/intio.c
diff -u src/sys/arch/hp300/dev/intio.c:1.31 src/sys/arch/hp300/dev/intio.c:1.32
--- src/sys/arch/hp300/dev/intio.c:1.31	Sat Aug  7 16:18:53 2021
+++ src/sys/arch/hp300/dev/intio.c	Sun Jan 28 17:31:40 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: intio.c,v 1.31 2021/08/07 16:18:53 thorpej Exp $	*/
+/*	$NetBSD: intio.c,v 1.32 2024/01/28 17:31:40 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1998, 2001 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.31 2021/08/07 16:18:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.32 2024/01/28 17:31:40 thorpej Exp $");
 
 #include 
 #include 
@@ -60,47 +60,53 @@ CFATTACH_DECL_NEW(intio, sizeof(struct i
 #if defined(HP320) || defined(HP330) || defined(HP340) || defined(HP345) || \
 defined(HP350) || defined(HP360) || defined(HP370) || defined(HP375) || \
 defined(HP380) || defined(HP385)
-static const struct intio_builtins intio_3xx_builtins[] = {
-	{ "rtc",	RTC_BASE,	-1},
-	{ "hil",	HIL_BASE,	1},
-	{ "hpib",	HPIB_BASE,	3},
-	{ "dma",	DMA_BASE,	1},
-	{ "fb",		FB_BASE,	-1},
-};
-#define nintio_3xx_builtins	__arraycount(intio_3xx_builtins)
+#define	HAVE_INTIO_FB
 #endif
 
-#if defined(HP362)
-static const struct intio_builtins intio_362_builtins[] = {
-	{ "rtc",	RTC_BASE,	-1},
-	{ "hil",	HIL_BASE,	1},
-	{ "hpib",	HPIB_BASE,	3},
-	{ "dma",	DMA_BASE,	1},
-};
-#define nintio_362_builtins	__arraycount(intio_362_builtins)
+#if defined(HP382) || defined(HP400) || defined(HP425) || defined(HP433)
+#define	HAVE_INTIO_FRODO
 #endif
 
-#if defined(HP382)
-static const struct intio_builtins intio_382_builtins[] = {
-	{ "rtc",	RTC_BASE,	-1},
-	{ "frodo",	FRODO_BASE,	5},
-	{ "hil",	HIL_BASE,	1},
-	{ "hpib",	HPIB_BASE,	3},
-	{ "dma",	DMA_BASE,	1},
-};
-#define nintio_382_builtins	__arraycount(intio_382_builtins)
+#define	INTIO_3xx_BUILTINS		\
+	(__BIT(HP_320) | __BIT(HP_330) | __BIT(HP_340) ||		\
+	 __BIT(HP_345) | __BIT(HP_345) | __BIT(HP_350) ||		\
+	 __BIT(HP_360) | __BIT(HP_370) | __BIT(HP_375) ||		\
+	 __BIT(HP_380) | __BIT(HP_385))
+
+#define	INTIO_362_BUILTINS	__BIT(HP_362)
+#define	INTIO_382_BUILTINS	__BIT(HP_382)
+
+#define	INTIO_4xx_BUILTINS		\
+	(__BIT(HP_400) | __BIT(HP_425) | __BIT(HP_433))
+
+#define	INTIO_ALL_BUILTINS		\
+	(INTIO_3xx_BUILTINS | INTIO_362_BUILTINS |			\
+	 INTIO_382_BUILTINS | INTIO_4xx_BUILTINS)
+
+static const struct intio_builtins intio_builtins[] = {
+	{ "rtc",	RTC_BASE,	-1,
+	  INTIO_ALL_BUILTINS },
+
+#ifdef HAVE_INTIO_FRODO
+	{ "frodo",	FRODO_BASE,	5,
+	  INTIO_382_BUILTINS | INTIO_4xx_BUILTINS },
 #endif
 
-#if defined(HP400) || defined(HP425) || defined(HP433)
-static const struct intio_builtins intio_4xx_builtins[] = {
-	{ "rtc",	RTC_BASE,	-1},
-	{ "frodo",	FRODO_BASE,	5},
-	{ "hil",	HIL_BASE,	1},
-	{ "hpib",	HPIB_BASE,	3},
-	{ "dma",	DMA_BASE,	1},
-};
-#define nintio_4xx_builtins	__arraycount(intio_4xx_builtins)
+	{ "hil",	HIL_BASE,	1,
+	  INTIO_ALL_BUILTINS },
+
+	{ "hpib",	HPIB_BASE,	3,
+	  INTIO_ALL_BUILTINS },
+
+	{ "dma",	DMA_BASE,	1,
+	  INTIO_ALL_BUILTINS },
+
+#ifdef HAVE_INTIO_FB
+	{ "fb",		FB_BASE,	-1,
+	  INTIO_3xx_BUILTINS },
 #endif
+};
+#define	nintio_builtins		__arraycount(intio_builtins)
 
 static int intio_matched = 0;
 extern void *internalhpib;
@@ -122,76 +128,43 @@ intioattach(device_t parent, device_t se
 {
 	struct intio_softc *sc = device_private(self);
 	struct intio_attach_args ia;
-	const struct intio_builtins *ib;
 	bus_space_tag_t bst = &sc->sc_tag;
-	int ndevs;
+	const uint32_t spumask = 1U << machineid;
 	int i;
 
 	sc->sc_dev = self;
 	aprint_normal("\n");
 
+	KASSERT(spumask != 0);
+
 	memset(bst, 0, sizeof(struct bus_space_tag));
 	bst->bustype = HP300_BUS_SPACE_INTIO;
 
-	switch (machineid) {
-#if defined(HP320) || defined(HP330) || defined(HP340) || defined(HP345) || \
-defined(HP350) || defined(HP360) || defined(HP370) || defined(HP375) || \
-defined(HP380) || defined(HP385)
-	case HP_320:
-	case HP_330:
-	case HP_340:
-	case HP_345:
-	case HP_350:
-	case HP_360:
-	case HP_370:
-	case HP_375:
-	case HP_380:
-	case HP_385:
-		ib = intio_3xx_builtins;
-		ndevs = nintio_3xx_builtins;
-		break;
-#endif
-#if defined(HP362)
-	case HP_362:
-		ib = intio_362_builtins;
-		ndevs = nintio_362_builtins;
-		break;
-#endif
-#if defined(HP382)
-	case HP_382:
-		ib 

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

2024-01-28 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 28 17:31:40 UTC 2024

Modified Files:
src/sys/arch/hp300/dev: intio.c intiovar.h

Log Message:
Rather than having different "builtin" tables (3xx, 362, 382, 4xx),
just have a single "builtin" table with a mask indicating which of
those groups of machines have a particular built-in device.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/hp300/dev/intio.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hp300/dev/intiovar.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/hp300/dev

2023-09-08 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Sep  8 22:51:54 UTC 2023

Modified Files:
src/sys/arch/hp300/dev: dcm.c

Log Message:
hp300/dcm(4): set dsp value after sc is initialized.
fixes DCMSTATS enabled build for hp300.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/hp300/dev/dcm.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/hp300/dev/dcm.c
diff -u src/sys/arch/hp300/dev/dcm.c:1.92 src/sys/arch/hp300/dev/dcm.c:1.93
--- src/sys/arch/hp300/dev/dcm.c:1.92	Fri Apr 21 23:01:59 2023
+++ src/sys/arch/hp300/dev/dcm.c	Fri Sep  8 22:51:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dcm.c,v 1.92 2023/04/21 23:01:59 tsutsui Exp $	*/
+/*	$NetBSD: dcm.c,v 1.93 2023/09/08 22:51:54 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dcm.c,v 1.92 2023/04/21 23:01:59 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dcm.c,v 1.93 2023/09/08 22:51:54 andvar Exp $");
 
 #include "opt_kgdb.h"
 
@@ -1162,7 +1162,7 @@ dcmstart(struct tty *tp)
 	char buf[16];
 	int s;
 #ifdef DCMSTATS
-	struct dcmstats *dsp = &sc->sc_stats;
+	struct dcmstats *dsp;
 	int tch = 0;
 #endif
 
@@ -1172,6 +1172,9 @@ dcmstart(struct tty *tp)
 
 	sc = device_lookup_private(&dcm_cd, board);
 	dcm = sc->sc_dcm;
+#ifdef DCMSTATS
+	dsp = &sc->sc_stats;
+#endif
 
 	s = spltty();
 #ifdef DCMSTATS



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

2023-09-08 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Sep  8 22:51:54 UTC 2023

Modified Files:
src/sys/arch/hp300/dev: dcm.c

Log Message:
hp300/dcm(4): set dsp value after sc is initialized.
fixes DCMSTATS enabled build for hp300.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/arch/hp300/dev/dcm.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/hp300/dev

2022-12-03 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Dec  3 16:56:41 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Explicitly include  for hz(9) as man pages says.

XXX: it looks sys/param.h r1.615 and later also has extern int hz


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.123 src/sys/arch/hp300/dev/rd.c:1.124
--- src/sys/arch/hp300/dev/rd.c:1.123	Sat Dec  3 06:08:18 2022
+++ src/sys/arch/hp300/dev/rd.c	Sat Dec  3 16:56:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.123 2022/12/03 06:08:18 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.124 2022/12/03 16:56:40 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,12 +72,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.123 2022/12/03 06:08:18 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.124 2022/12/03 16:56:40 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



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

2022-12-03 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Dec  3 16:56:41 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Explicitly include  for hz(9) as man pages says.

XXX: it looks sys/param.h r1.615 and later also has extern int hz


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-12-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Dec  3 06:08:18 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Add empty DIOCCACHESYNC ioctl(2) for rd(4).

Without this raid(4) always complains on various raidctl(8) ops:
> raid0: cache flush[0] to component 0 failed (22)

RAID1 configured by raid(4) just works HP-IB disks on hp300.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.122 src/sys/arch/hp300/dev/rd.c:1.123
--- src/sys/arch/hp300/dev/rd.c:1.122	Thu Dec  1 15:02:11 2022
+++ src/sys/arch/hp300/dev/rd.c	Sat Dec  3 06:08:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.122 2022/12/01 15:02:11 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.123 2022/12/03 06:08:18 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.122 2022/12/01 15:02:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.123 2022/12/03 06:08:18 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -1363,6 +1363,10 @@ rdioctl(dev_t dev, u_long cmd, void *dat
 	case DIOCGDEFLABEL:
 		rdgetdefaultlabel(sc, (struct disklabel *)data);
 		return 0;
+
+	case DIOCCACHESYNC:
+		/* no cache to be flushed but required to appease raid(4) */
+		return 0;
 	}
 	return EINVAL;
 }



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

2022-12-02 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Dec  3 06:08:18 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Add empty DIOCCACHESYNC ioctl(2) for rd(4).

Without this raid(4) always complains on various raidctl(8) ops:
> raid0: cache flush[0] to component 0 failed (22)

RAID1 configured by raid(4) just works HP-IB disks on hp300.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-12-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Dec  1 15:02:11 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Misc KNF and cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.121 src/sys/arch/hp300/dev/rd.c:1.122
--- src/sys/arch/hp300/dev/rd.c:1.121	Wed Nov 30 18:15:32 2022
+++ src/sys/arch/hp300/dev/rd.c	Thu Dec  1 15:02:11 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.121 2022/11/30 18:15:32 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.122 2022/12/01 15:02:11 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.121 2022/11/30 18:15:32 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.122 2022/12/01 15:02:11 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -102,7 +102,7 @@ __KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.121
 
 #include "ioconf.h"
 
-int	rderrthresh = RDRETRY-1;	/* when to start reporting errors */
+int	rderrthresh = RDRETRY - 1;	/* when to start reporting errors */
 
 #ifdef DEBUG
 /* error message tables */
@@ -547,7 +547,7 @@ rdattach(device_t parent, device_t self,
 	sc->sc_flags = RDF_ALIVE;
 #ifdef DEBUG
 	/* always report errors */
-	if (rddebug & RDB_ERROR)
+	if ((rddebug & RDB_ERROR) != 0)
 		rderrthresh = 0;
 #endif
 	/*
@@ -812,8 +812,8 @@ rdopen(dev_t dev, int flags, int mode, s
 	/*
 	 * Wait for any pending opens/closes to complete
 	 */
-	while (sc->sc_flags & (RDF_OPENING|RDF_CLOSING))
-		(void) tsleep(sc, PRIBIO, "rdopen", 0);
+	while ((sc->sc_flags & (RDF_OPENING | RDF_CLOSING)) != 0)
+		(void)tsleep(sc, PRIBIO, "rdopen", 0);
 
 	/*
 	 * On first open, get label and partition info.
@@ -878,10 +878,10 @@ rdclose(dev_t dev, int flag, int mode, s
 		s = splbio();
 		while (sc->sc_active) {
 			sc->sc_flags |= RDF_WANTED;
-			(void) tsleep(&sc->sc_tab, PRIBIO, "rdclose", 0);
+			(void)tsleep(&sc->sc_tab, PRIBIO, "rdclose", 0);
 		}
 		splx(s);
-		sc->sc_flags &= ~(RDF_CLOSING|RDF_WLABEL);
+		sc->sc_flags &= ~(RDF_CLOSING | RDF_WLABEL);
 		wakeup((void *)sc);
 	}
 	return 0;
@@ -897,10 +897,11 @@ rdstrategy(struct buf *bp)
 	int offset;
 
 #ifdef DEBUG
-	if (rddebug & RDB_FOLLOW)
-		printf("rdstrategy(%p): dev %"PRIx64", bn %llx, bcount %x, %c\n",
-		   bp, bp->b_dev, bp->b_blkno, bp->b_bcount,
-		   (bp->b_flags & B_READ) ? 'R' : 'W');
+	if ((rddebug & RDB_FOLLOW) != 0)
+		printf("rdstrategy(%p): dev %" PRIx64
+		", bn %llx, bcount %x, %c\n",
+		bp, bp->b_dev, bp->b_blkno, bp->b_bcount,
+		(bp->b_flags & B_READ) != 0 ? 'R' : 'W');
 #endif
 	bn = bp->b_blkno;
 	pinfo = &sc->sc_dkdev.dk_label->d_partitions[rdpart(bp->b_dev)];
@@ -926,7 +927,7 @@ rdstrategy(struct buf *bp)
 	}
 	splx(s);
 	return;
-done:
+ done:
 	biodone(bp);
 }
 
@@ -936,8 +937,11 @@ done:
 static void
 rdrestart(void *arg)
 {
-	int s = splbio();
-	rdustart((struct rd_softc *)arg);
+	struct rd_softc *sc = arg;
+	int s;
+
+	s = splbio();
+	rdustart(sc);
 	splx(s);
 }
 
@@ -965,7 +969,7 @@ rdfinish(struct rd_softc *sc, struct buf
 	if ((bp = bufq_peek(sc->sc_tab)) != NULL)
 		return bp;
 	sc->sc_active = 0;
-	if (sc->sc_flags & RDF_WANTED) {
+	if ((sc->sc_flags & RDF_WANTED) != 0) {
 		sc->sc_flags &= ~RDF_WANTED;
 		wakeup((void *)&sc->sc_tab);
 	}
@@ -982,7 +986,7 @@ rdstart(void *arg)
 	ctlr = device_unit(device_parent(sc->sc_dev));
 	slave = sc->sc_slave;
 
-again:
+ again:
 #ifdef DEBUG
 	if (rddebug & RDB_FOLLOW)
 		printf("rdstart(%s): bp %p, %c\n", device_xname(sc->sc_dev), bp,
@@ -997,22 +1001,22 @@ again:
 	sc->sc_ioc.c_nop2 = C_NOP;
 	sc->sc_ioc.c_slen = C_SLEN;
 	sc->sc_ioc.c_len = sc->sc_resid;
-	sc->sc_ioc.c_cmd = bp->b_flags & B_READ ? C_READ : C_WRITE;
+	sc->sc_ioc.c_cmd = (bp->b_flags & B_READ) != 0 ? C_READ : C_WRITE;
 #ifdef DEBUG
-	if (rddebug & RDB_IO)
+	if ((rddebug & RDB_IO) != 0)
 		printf("rdstart: hpibsend(%x, %x, %x, %p, %x)\n",
-		   ctlr, slave, C_CMD,
-		   &sc->sc_ioc.c_unit, sizeof(sc->sc_ioc) - 2);
+		ctlr, slave, C_CMD,
+		&sc->sc_ioc.c_unit, sizeof(sc->sc_ioc) - 2);
 #endif
 	if (hpibsend(ctlr, slave, C_CMD, &sc->sc_ioc.c_unit,
-		 sizeof(sc->sc_ioc) - 2) == sizeof(sc->sc_ioc) - 2) {
+	sizeof(sc->sc_ioc) - 2) == sizeof(sc->sc_ioc) - 2) {
 
 		/* Instrumentation. */
 		disk_busy(&sc->sc_dkdev);
 		iostat_seek(sc->sc_dkdev.dk_stats);
 
 #ifdef DEBUG
-		if (rddebug & RDB_IO)
+		if ((rddebug & RDB_IO) != 0)
 			printf("rdstart: hpibawait(%x)\n", ctlr);
 #endif
 		hpibawait(ctlr);
@@ -1025,7 +1029,7 @@ again:
 	 * integrate this with the backoff code in rderror.
 	 */
 #ifdef DEBUG
-	if (rddebug & RDB_ERROR)
+	if ((rddebug & RDB_ERROR) != 0)
 		printf("%s: rdstart: cmd %x adr %x blk %lld len %d ecnt %d\n",
 		device_xname(sc->sc_dev),
 		sc->sc_io

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

2022-12-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Dec  1 15:02:11 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Misc KNF and cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 18:15:32 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Remove more duplicated static function declarations.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.120 src/sys/arch/hp300/dev/rd.c:1.121
--- src/sys/arch/hp300/dev/rd.c:1.120	Wed Nov 30 17:42:20 2022
+++ src/sys/arch/hp300/dev/rd.c	Wed Nov 30 18:15:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.120 2022/11/30 17:42:20 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.121 2022/11/30 18:15:32 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.120 2022/11/30 17:42:20 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.121 2022/11/30 18:15:32 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -430,8 +430,6 @@ static void	rdreset(struct rd_softc *);
 static void	rdreset_unit(int, int, int);
 static void	rd_set_geom(struct rd_softc *);
 static int	rdgetinfo(dev_t);
-static void	rdrestart(void *);
-static struct buf *rdfinish(struct rd_softc *, struct buf *);
 
 static void	rdgetdefaultlabel(struct rd_softc *, struct disklabel *);
 static void	rdrestart(void *);



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

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 18:15:32 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Remove more duplicated static function declarations.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 17:42:21 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Use proper RAW_PART macro rather than a magic number.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.119 src/sys/arch/hp300/dev/rd.c:1.120
--- src/sys/arch/hp300/dev/rd.c:1.119	Wed Nov 30 17:39:12 2022
+++ src/sys/arch/hp300/dev/rd.c	Wed Nov 30 17:42:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.119 2022/11/30 17:39:12 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.120 2022/11/30 17:42:20 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.119 2022/11/30 17:39:12 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.120 2022/11/30 17:42:20 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -790,7 +790,7 @@ rdgetinfo(dev_t dev)
 	pi = lp->d_partitions;
 	printf("%s: WARNING: %s\n", device_xname(sc->sc_dev), msg);
 
-	pi[2].p_size = rdidentinfo[sc->sc_type].ri_nblocks;
+	pi[RAW_PART].p_size = rdidentinfo[sc->sc_type].ri_nblocks;
 	/* XXX reset other info since readdisklabel screws with it */
 	lp->d_npartitions = 3;
 	pi[0].p_size = 0;



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

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 17:42:21 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Use proper RAW_PART macro rather than a magic number.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 17:39:12 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Set disk_geom parameters required by DIOCGPARTINFO in disk_ioctl().

With this change raid(4) no longer complains before mountroot:
> RAIDframe: can't get disk size for dev rd0 (22)

Should be pulled up to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 17:39:12 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Set disk_geom parameters required by DIOCGPARTINFO in disk_ioctl().

With this change raid(4) no longer complains before mountroot:
> RAIDframe: can't get disk size for dev rd0 (22)

Should be pulled up to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.118 src/sys/arch/hp300/dev/rd.c:1.119
--- src/sys/arch/hp300/dev/rd.c:1.118	Wed Nov 30 17:07:30 2022
+++ src/sys/arch/hp300/dev/rd.c	Wed Nov 30 17:39:12 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.118 2022/11/30 17:07:30 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.119 2022/11/30 17:39:12 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.118 2022/11/30 17:07:30 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.119 2022/11/30 17:39:12 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -428,6 +428,7 @@ static int	rdident(device_t, struct rd_s
 		struct hpibbus_attach_args *);
 static void	rdreset(struct rd_softc *);
 static void	rdreset_unit(int, int, int);
+static void	rd_set_geom(struct rd_softc *);
 static int	rdgetinfo(dev_t);
 static void	rdrestart(void *);
 static struct buf *rdfinish(struct rd_softc *, struct buf *);
@@ -531,6 +532,7 @@ rdattach(device_t parent, device_t self,
 	memset(&sc->sc_dkdev, 0, sizeof(sc->sc_dkdev));
 	disk_init(&sc->sc_dkdev, device_xname(sc->sc_dev), NULL);
 	disk_attach(&sc->sc_dkdev);
+	rd_set_geom(sc);
 
 	sc->sc_slave = ha->ha_slave;
 	sc->sc_punit = ha->ha_punit;
@@ -743,6 +745,23 @@ rdreset_unit(int ctlr, int slave, int pu
 	hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
 }
 
+static void
+rd_set_geom(struct rd_softc *sc)
+{
+	struct disk_geom *dg = &sc->sc_dkdev.dk_geom;
+	const struct rdidentinfo *ri = &rdidentinfo[sc->sc_type];
+
+	memset(dg, 0, sizeof(*dg));
+
+	dg->dg_secsize = DEV_BSIZE;
+	dg->dg_nsectors = ri->ri_nbpt;
+	dg->dg_ntracks = ri->ri_ntpc;
+	dg->dg_ncylinders = ri->ri_ncyl;
+	dg->dg_secperunit = ri->ri_nblocks;
+
+	disk_set_info(sc->sc_dev, &sc->sc_dkdev, ri->ri_desc);
+}
+
 /*
  * Read or construct a disklabel
  */



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

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 17:07:30 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Remove a duplicated static function declaration.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.117 src/sys/arch/hp300/dev/rd.c:1.118
--- src/sys/arch/hp300/dev/rd.c:1.117	Wed Nov 30 17:01:56 2022
+++ src/sys/arch/hp300/dev/rd.c	Wed Nov 30 17:07:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.117 2022/11/30 17:01:56 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.118 2022/11/30 17:07:30 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.117 2022/11/30 17:01:56 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.118 2022/11/30 17:07:30 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -428,7 +428,6 @@ static int	rdident(device_t, struct rd_s
 		struct hpibbus_attach_args *);
 static void	rdreset(struct rd_softc *);
 static void	rdreset_unit(int, int, int);
-static void	rdustart(struct rd_softc *);
 static int	rdgetinfo(dev_t);
 static void	rdrestart(void *);
 static struct buf *rdfinish(struct rd_softc *, struct buf *);



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

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 17:07:30 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Remove a duplicated static function declaration.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 17:01:56 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Pass a correct dev_t arg to disk_ioctl().

Probably harmless.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 17:01:56 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Pass a correct dev_t arg to disk_ioctl().

Probably harmless.


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.116 src/sys/arch/hp300/dev/rd.c:1.117
--- src/sys/arch/hp300/dev/rd.c:1.116	Wed Nov 30 16:37:44 2022
+++ src/sys/arch/hp300/dev/rd.c	Wed Nov 30 17:01:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.116 2022/11/30 16:37:44 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.117 2022/11/30 17:01:56 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.116 2022/11/30 16:37:44 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.117 2022/11/30 17:01:56 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -1305,7 +1305,7 @@ rdioctl(dev_t dev, u_long cmd, void *dat
 	struct disklabel *lp = sc->sc_dkdev.dk_label;
 	int error, flags;
 
-	error = disk_ioctl(&sc->sc_dkdev, rdpart(dev), cmd, data, flag, l);
+	error = disk_ioctl(&sc->sc_dkdev, dev, cmd, data, flag, l);
 	if (error != EPASSTHROUGH)
 		return error;
 



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

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 16:37:44 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Check bounds of each partition by MI bounds_check_with_label(9).

The previous implementation was committed in rev 1.26 about 26 years ago
and it looks there is no quirk to use the old MD one.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.115 src/sys/arch/hp300/dev/rd.c:1.116
--- src/sys/arch/hp300/dev/rd.c:1.115	Wed Nov 30 15:59:01 2022
+++ src/sys/arch/hp300/dev/rd.c	Wed Nov 30 16:37:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.115 2022/11/30 15:59:01 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.116 2022/11/30 16:37:44 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.115 2022/11/30 15:59:01 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.116 2022/11/30 16:37:44 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -877,7 +877,7 @@ rdstrategy(struct buf *bp)
 	struct rd_softc *sc = device_lookup_private(&rd_cd, rdunit(bp->b_dev));
 	struct partition *pinfo;
 	daddr_t bn;
-	int sz, s;
+	int s;
 	int offset;
 
 #ifdef DEBUG
@@ -887,7 +887,6 @@ rdstrategy(struct buf *bp)
 		   (bp->b_flags & B_READ) ? 'R' : 'W');
 #endif
 	bn = bp->b_blkno;
-	sz = howmany(bp->b_bcount, DEV_BSIZE);
 	pinfo = &sc->sc_dkdev.dk_label->d_partitions[rdpart(bp->b_dev)];
 
 	/* Don't perform partition translation on RAW_PART. */
@@ -898,34 +897,9 @@ rdstrategy(struct buf *bp)
 		rdidentinfo[sc->sc_type].ri_nblocks) <= 0)
 			goto done;
 	} else {
-		/*
-		 * XXX This block of code belongs in
-		 * XXX bounds_check_with_label()
-		 */
-
-		if (bn < 0 || bn + sz > pinfo->p_size) {
-			sz = pinfo->p_size - bn;
-			if (sz == 0) {
-bp->b_resid = bp->b_bcount;
-goto done;
-			}
-			if (sz < 0) {
-bp->b_error = EINVAL;
-goto done;
-			}
-			bp->b_bcount = dbtob(sz);
-		}
-		/*
-		 * Check for write to write protected label
-		 */
-		if (bn + offset <= LABELSECTOR &&
-#if LABELSECTOR != 0
-		bn + offset + sz > LABELSECTOR &&
-#endif
-		!(bp->b_flags & B_READ) && !(sc->sc_flags & RDF_WLABEL)) {
-			bp->b_error = EROFS;
+		if (bounds_check_with_label(&sc->sc_dkdev, bp,
+		(sc->sc_flags & RDF_WLABEL) != 0) <= 0)
 			goto done;
-		}
 	}
 	bp->b_rawblkno = bn + offset;
 	s = splbio();



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

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 16:37:44 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Check bounds of each partition by MI bounds_check_with_label(9).

The previous implementation was committed in rev 1.26 about 26 years ago
and it looks there is no quirk to use the old MD one.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 15:59:01 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Check bounds of RAW_PART by bounds_check_with_mediasize() as other drivers.

With this check, dd(1) without a count value against a raw partition
is terminated properly at the end of media.  Tested on 425t and HPDisk.

Should be pulled up to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.114 src/sys/arch/hp300/dev/rd.c:1.115
--- src/sys/arch/hp300/dev/rd.c:1.114	Fri Nov 25 16:12:32 2022
+++ src/sys/arch/hp300/dev/rd.c	Wed Nov 30 15:59:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.114 2022/11/25 16:12:32 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.115 2022/11/30 15:59:01 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.114 2022/11/25 16:12:32 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.115 2022/11/30 15:59:01 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -893,7 +893,11 @@ rdstrategy(struct buf *bp)
 	/* Don't perform partition translation on RAW_PART. */
 	offset = (rdpart(bp->b_dev) == RAW_PART) ? 0 : pinfo->p_offset;
 
-	if (rdpart(bp->b_dev) != RAW_PART) {
+	if (rdpart(bp->b_dev) == RAW_PART) {
+		if (bounds_check_with_mediasize(bp, DEV_BSIZE,
+		rdidentinfo[sc->sc_type].ri_nblocks) <= 0)
+			goto done;
+	} else {
 		/*
 		 * XXX This block of code belongs in
 		 * XXX bounds_check_with_label()



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

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 15:59:01 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Check bounds of RAW_PART by bounds_check_with_mediasize() as other drivers.

With this check, dd(1) without a count value against a raw partition
is terminated properly at the end of media.  Tested on 425t and HPDisk.

Should be pulled up to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 11:36:50 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Fix silent bus error panic on 98543A topcat framebuffer on HP320 and HP360.

It looks DELAY(100)s before checking cmap_busy in old pre-wscons grf_tc.c
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/hp300/dev/Attic/grf_tc.c?rev=1.42
are actually necessary on 68020 (HP320) and 68030 (HP360) machines,
while it works without them on 68040 (HP380).

Should be pulled up to netbsd-9.


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

2022-11-30 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 30 11:36:50 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: topcat.c

Log Message:
Fix silent bus error panic on 98543A topcat framebuffer on HP320 and HP360.

It looks DELAY(100)s before checking cmap_busy in old pre-wscons grf_tc.c
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/hp300/dev/Attic/grf_tc.c?rev=1.42
are actually necessary on 68020 (HP320) and 68030 (HP360) machines,
while it works without them on 68040 (HP380).

Should be pulled up to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hp300/dev/topcat.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/hp300/dev/topcat.c
diff -u src/sys/arch/hp300/dev/topcat.c:1.5 src/sys/arch/hp300/dev/topcat.c:1.6
--- src/sys/arch/hp300/dev/topcat.c:1.5	Thu Apr 15 14:43:19 2021
+++ src/sys/arch/hp300/dev/topcat.c	Wed Nov 30 11:36:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: topcat.c,v 1.5 2021/04/15 14:43:19 tsutsui Exp $	*/
+/*	$NetBSD: topcat.c,v 1.6 2022/11/30 11:36:50 tsutsui Exp $	*/
 /*	$OpenBSD: topcat.c,v 1.15 2006/08/11 18:33:13 miod Exp $	*/
 
 /*
@@ -448,6 +448,8 @@ topcat_setcolor(struct diofb *fb, u_int 
 		tc->gdata  = fb->cmap.g[index];
 		tc->bdata  = fb->cmap.b[index];
 		tc->strobe = 0xff;
+		/* XXX delay required on 68020/30 to avoid bus error */
+		DELAY(100);
 
 		tccm_waitbusy(tc);
 		tc->cindex = 0;
@@ -459,6 +461,8 @@ topcat_setcolor(struct diofb *fb, u_int 
 		tc->bdata  = fb->cmap.b[index];
 		tc->cindex = ~index;
 		tc->strobe = 0xff;
+		/* XXX delay required on 68020/30 to avoid bus error */
+		DELAY(100);
 
 		tccm_waitbusy(tc);
 		tc->rdata  = 0;



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

2022-11-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Nov 26 00:25:36 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: mt.c mtreg.h

Log Message:
Misc KNF and cosmetics.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/hp300/dev/mt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hp300/dev/mtreg.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/hp300/dev/mt.c
diff -u src/sys/arch/hp300/dev/mt.c:1.55 src/sys/arch/hp300/dev/mt.c:1.56
--- src/sys/arch/hp300/dev/mt.c:1.55	Mon Jul  5 14:03:46 2021
+++ src/sys/arch/hp300/dev/mt.c	Sat Nov 26 00:25:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: mt.c,v 1.55 2021/07/05 14:03:46 tsutsui Exp $	*/
+/*	$NetBSD: mt.c,v 1.56 2022/11/26 00:25:36 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mt.c,v 1.55 2021/07/05 14:03:46 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mt.c,v 1.56 2022/11/26 00:25:36 tsutsui Exp $");
 
 #include 
 #include 
@@ -86,7 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: mt.c,v 1.55 
 #include "ioconf.h"
 
 static const struct mtinfo {
-	u_short	hwid;
+	uint16_t hwid;
 	const char *desc;
 } mtinfo[] = {
 	{ MT7978ID,	"7978"	},
@@ -103,8 +103,8 @@ struct	mt_softc {
 	int	sc_hpibno;	/* logical HPIB this slave it attached to */
 	int	sc_slave;	/* HPIB slave address (0-6) */
 	short	sc_flags;	/* see below */
-	u_char	sc_lastdsj;	/* place for DSJ in mtreaddsj() */
-	u_char	sc_lastecmd;	/* place for End Command in mtreaddsj() */
+	uint8_t	sc_lastdsj;	/* place for DSJ in mtreaddsj() */
+	uint8_t	sc_lastecmd;	/* place for End Command in mtreaddsj() */
 	short	sc_recvtimeo;	/* count of hpibsend timeouts to prevent hang */
 	short	sc_statindex;	/* index for next sc_stat when MTF_STATTIMEO */
 	struct	mt_stat sc_stat;/* status bytes last read from device */
@@ -247,10 +247,10 @@ mtreaddsj(struct mt_softc *sc, int ecmd)
 {
 	int retval;
 
-	if (sc->sc_flags & MTF_STATTIMEO)
+	if ((sc->sc_flags & MTF_STATTIMEO) != 0)
 		goto getstats;
 	retval = hpibrecv(sc->sc_hpibno,
-	(sc->sc_flags & MTF_DSJTIMEO) ? -1 : sc->sc_slave,
+	(sc->sc_flags & MTF_DSJTIMEO) != 0 ? -1 : sc->sc_slave,
 	MTT_DSJ, &(sc->sc_lastdsj), 1);
 	sc->sc_flags &= ~MTF_DSJTIMEO;
 	if (retval != 1) {
@@ -270,24 +270,24 @@ mtreaddsj(struct mt_softc *sc, int ecmd)
 	sc->sc_lastdsj);
 	sc->sc_lastecmd = ecmd;
 	switch (sc->sc_lastdsj) {
-	case 0:
+	case 0:
 		if (ecmd & MTE_DSJ_FORCE)
 			break;
 		return 0;
 
-	case 2:
+	case 2:
 		sc->sc_lastecmd = MTE_COMPLETE;
-	case 1:
+	case 1:
 		break;
 
-	default:
+	default:
 		log(LOG_ERR, "%s readdsj: DSJ 0x%x\n", device_xname(sc->sc_dev),
 		sc->sc_lastdsj);
 		return -1;
 	}
  getstats:
 	retval = hpibrecv(sc->sc_hpibno,
-	(sc->sc_flags & MTF_STATCONT) ? -1 : sc->sc_slave,
+	(sc->sc_flags & MTF_STATCONT) != 0 ? -1 : sc->sc_slave,
 	MTT_STAT, ((char *)&(sc->sc_stat)) + sc->sc_statindex,
 	sizeof(sc->sc_stat) - sc->sc_statindex);
 	sc->sc_flags &= ~(MTF_STATTIMEO | MTF_STATCONT);
@@ -312,9 +312,9 @@ mtreaddsj(struct mt_softc *sc, int ecmd)
 	device_xname(sc->sc_dev),
 	sc->sc_stat1, sc->sc_stat2, sc->sc_stat3,
 	sc->sc_stat4, sc->sc_stat5, sc->sc_stat6);
-	if (sc->sc_lastecmd)
+	if (sc->sc_lastecmd != 0)
 		(void) hpibsend(sc->sc_hpibno, sc->sc_slave,
-		MTL_ECMD, &(sc->sc_lastecmd), 1);
+		MTL_ECMD, &sc->sc_lastecmd, 1);
 	return (int)sc->sc_lastdsj;
 }
 
@@ -334,7 +334,7 @@ mtopen(dev_t dev, int flag, int mode, st
 
 	dlog(LOG_DEBUG, "%s open: flags 0x%x", device_xname(sc->sc_dev),
 	sc->sc_flags);
-	if (sc->sc_flags & MTF_OPEN)
+	if ((sc->sc_flags & MTF_OPEN) != 0)
 		return EBUSY;
 	sc->sc_flags |= MTF_OPEN;
 	sc->sc_ttyp = tprintf_open(l->l_proc);
@@ -348,7 +348,7 @@ mtopen(dev_t dev, int flag, int mode, st
 	for (;;) {
 		if ((error = mtcommand(dev, MTNOP, 0)) != 0)
 			goto errout;
-		if (!(sc->sc_flags & MTF_REW))
+		if ((sc->sc_flags & MTF_REW) == 0)
 			break;
 		error = kpause("mt", true, hz, NULL);
 		if (error != 0 && error != EWOULDBLOCK) {
@@ -356,11 +356,11 @@ mtopen(dev_t dev, int flag, int mode, st
 			goto errout;
 		}
 	}
-	if ((flag & FWRITE) && (sc->sc_stat1 & SR1_RO)) {
+	if ((flag & FWRITE) != 0 && (sc->sc_stat1 & SR1_RO) != 0) {
 		error = EROFS;
 		goto errout;
 	}
-	if (!(sc->sc_stat1 & SR1_ONLINE)) {
+	if ((sc->sc_stat1 & SR1_ONLINE) == 0) {
 		uprintf("%s: not online\n", device_xname(sc->sc_dev));
 		error = EIO;
 		goto errout;
@@ -395,16 +395,15 @@ mtopen(dev_t dev, int flag, int mode, st
 			 (sc->sc_stat3 & SR3_800) ? T_800BPI : -1));
 	req_den = (dev & T_DENSEL);
 
-	if (flag & FWRITE) {
-		if (!(sc->sc_stat1 & SR1_BOT)) {
+	if ((flag & FWRITE) != 0) {
+		if ((sc->sc_stat1 & SR1_BOT) == 0) {
 			if (sc->sc_density != req_den) {
 uprintf("%s: can't change density mid-tape\n",
 device_xname(sc->sc_dev));
 

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

2022-11-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Nov 26 00:25:36 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: mt.c mtreg.h

Log Message:
Misc KNF and cosmetics.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/hp300/dev/mt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hp300/dev/mtreg.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/hp300/dev

2022-11-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Nov 25 16:12:32 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Remove unnecessary declarations.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.113 src/sys/arch/hp300/dev/rd.c:1.114
--- src/sys/arch/hp300/dev/rd.c:1.113	Fri Nov 25 13:02:51 2022
+++ src/sys/arch/hp300/dev/rd.c	Fri Nov 25 16:12:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.113 2022/11/25 13:02:51 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.114 2022/11/25 16:12:32 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.113 2022/11/25 13:02:51 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.114 2022/11/25 16:12:32 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -1202,7 +1202,6 @@ rderror(int unit)
 	struct rd_stat *sp;
 	struct buf *bp;
 	daddr_t hwbn, pbn;
-	char *hexstr(int, int); /* XXX */
 
 	if (rdstatus(sc)) {
 #ifdef DEBUG
@@ -1226,7 +1225,6 @@ rderror(int unit)
 	 * RDRETRY as defined, the range is 1 to 32 seconds.
 	 */
 	if (sp->c_fef & FEF_IMR) {
-		extern int hz;
 		int rdtimo = RDWAITC << sc->sc_errcnt;
 #ifdef DEBUG
 		printf("%s: internal maintenance, %d second timeout\n",



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

2022-11-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Nov 25 16:12:32 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Remove unnecessary declarations.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/arch/hp300/dev/rd.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/hp300/dev

2022-11-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Nov 25 13:12:02 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: frodo.c

Log Message:
Service mode switch should not be treated as an error.

Use aprint_normal(9) to avoid confusing dmesg.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/hp300/dev/frodo.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/hp300/dev/frodo.c
diff -u src/sys/arch/hp300/dev/frodo.c:1.34 src/sys/arch/hp300/dev/frodo.c:1.35
--- src/sys/arch/hp300/dev/frodo.c:1.34	Sat Aug  7 16:18:53 2021
+++ src/sys/arch/hp300/dev/frodo.c	Fri Nov 25 13:12:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: frodo.c,v 1.34 2021/08/07 16:18:53 thorpej Exp $	*/
+/*	$NetBSD: frodo.c,v 1.35 2022/11/25 13:12:02 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: frodo.c,v 1.34 2021/08/07 16:18:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: frodo.c,v 1.35 2022/11/25 13:12:02 tsutsui Exp $");
 
 #define	_HP300_INTR_H_PRIVATE
 
@@ -155,7 +155,7 @@ frodoattach(device_t parent, device_t se
 	sc->sc_ipl = ia->ia_ipl;
 
 	if ((FRODO_READ(sc, FRODO_IISR) & FRODO_IISR_SERVICE) == 0)
-		aprint_error(": service mode enabled");
+		aprint_normal(": service mode enabled");
 	aprint_normal("\n");
 
 	/* Initialize bus_space_tag_t for frodo */



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

2022-11-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Nov 25 13:12:02 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: frodo.c

Log Message:
Service mode switch should not be treated as an error.

Use aprint_normal(9) to avoid confusing dmesg.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/hp300/dev/frodo.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/hp300/dev

2022-11-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Nov 25 13:02:51 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c rdreg.h

Log Message:
Use proper integer types for HP-IB xfer parameters.

No visible regression on 425t and HPDisk.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/arch/hp300/dev/rd.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/hp300/dev/rdreg.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/hp300/dev

2022-11-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Nov 25 13:02:51 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c rdreg.h

Log Message:
Use proper integer types for HP-IB xfer parameters.

No visible regression on 425t and HPDisk.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/arch/hp300/dev/rd.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/hp300/dev/rdreg.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.112 src/sys/arch/hp300/dev/rd.c:1.113
--- src/sys/arch/hp300/dev/rd.c:1.112	Wed Nov 23 18:53:22 2022
+++ src/sys/arch/hp300/dev/rd.c	Fri Nov 25 13:02:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.112 2022/11/23 18:53:22 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.113 2022/11/25 13:02:51 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.112 2022/11/23 18:53:22 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.113 2022/11/25 13:02:51 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -562,7 +562,7 @@ static int
 rdident(device_t parent, struct rd_softc *sc, struct hpibbus_attach_args *ha)
 {
 	struct cs80_describe desc;
-	u_char stat, cmd[3];
+	uint8_t stat, cmd[3];
 	char name[7];
 	int i, id, n, ctlr, slave;
 
@@ -717,7 +717,7 @@ rdreset_unit(int ctlr, int slave, int pu
 	struct rd_ssmcmd ssmc;
 	struct rd_srcmd src;
 	struct rd_clearcmd clear;
-	u_char stat;
+	uint8_t stat;
 
 	clear.c_unit = C_SUNIT(punit);
 	clear.c_cmd = C_CLEAR;
@@ -1032,7 +1032,7 @@ again:
 	 */
 #ifdef DEBUG
 	if (rddebug & RDB_ERROR)
-		printf("%s: rdstart: cmd %x adr %lx blk %lld len %d ecnt %d\n",
+		printf("%s: rdstart: cmd %x adr %x blk %lld len %d ecnt %d\n",
 		device_xname(sc->sc_dev),
 		sc->sc_ioc.c_cmd, sc->sc_ioc.c_addr,
 		bp->b_blkno, sc->sc_resid, sc->sc_errcnt);
@@ -1042,7 +1042,7 @@ again:
 	rdreset(sc);
 	if (sc->sc_errcnt++ < RDRETRY)
 		goto again;
-	printf("%s: rdstart err: cmd 0x%x sect %ld blk %" PRId64 " len %d\n",
+	printf("%s: rdstart err: cmd 0x%x sect %u blk %" PRId64 " len %d\n",
 	device_xname(sc->sc_dev), sc->sc_ioc.c_cmd, sc->sc_ioc.c_addr,
 	bp->b_blkno, sc->sc_resid);
 	bp->b_error = EIO;
@@ -1083,7 +1083,7 @@ rdintr(void *arg)
 	struct rd_softc *sc = arg;
 	int unit = device_unit(sc->sc_dev);
 	struct buf *bp = bufq_peek(sc->sc_tab);
-	u_char stat = 13;	/* in case hpibrecv fails */
+	uint8_t stat = 13;	/* in case hpibrecv fails */
 	int rv, restart, ctlr, slave;
 
 	ctlr = device_unit(device_parent(sc->sc_dev));
@@ -1150,7 +1150,7 @@ static int
 rdstatus(struct rd_softc *sc)
 {
 	int c, s;
-	u_char stat;
+	uint8_t stat;
 	int rv;
 
 	c = device_unit(device_parent(sc->sc_dev));
@@ -1284,17 +1284,17 @@ rderror(int unit)
 		rdprinterr("access", sp->c_aef, err_access);
 		rdprinterr("info", sp->c_ief, err_info);
 		printf("block: %lld, P1-P10: ", hwbn);
-		printf("0x%x", *(u_int *)&sp->c_raw[0]);
-		printf("0x%x", *(u_int *)&sp->c_raw[4]);
-		printf("0x%x\n", *(u_short *)&sp->c_raw[8]);
+		printf("0x%x", *(uint32_t *)&sp->c_raw[0]);
+		printf("0x%x", *(uint32_t *)&sp->c_raw[4]);
+		printf("0x%x\n", *(uint16_t *)&sp->c_raw[8]);
 		/* command */
 		printf("ioc: ");
-		printf("0x%x", *(u_int *)&sc->sc_ioc.c_pad);
-		printf("0x%x", *(u_short *)&sc->sc_ioc.c_hiaddr);
-		printf("0x%x", *(u_int *)&sc->sc_ioc.c_addr);
-		printf("0x%x", *(u_short *)&sc->sc_ioc.c_nop2);
-		printf("0x%x", *(u_int *)&sc->sc_ioc.c_len);
-		printf("0x%x\n", *(u_short *)&sc->sc_ioc.c_cmd);
+		printf("0x%x", *(uint32_t *)&sc->sc_ioc.c_pad);
+		printf("0x%x", *(uint16_t *)&sc->sc_ioc.c_hiaddr);
+		printf("0x%x", *(uint32_t *)&sc->sc_ioc.c_addr);
+		printf("0x%x", *(uint16_t *)&sc->sc_ioc.c_nop2);
+		printf("0x%x", *(uint32_t *)&sc->sc_ioc.c_len);
+		printf("0x%x\n", *(uint16_t *)&sc->sc_ioc.c_cmd);
 		return 1;
 	}
 #endif
@@ -1302,9 +1302,9 @@ rderror(int unit)
 	(sp->c_vu>>4)&0xF, sp->c_vu&0xF,
 	sp->c_ref, sp->c_fef, sp->c_aef, sp->c_ief);
 	printf("P1-P10: ");
-	printf("0x%x", *(u_int *)&sp->c_raw[0]);
-	printf("0x%x", *(u_int *)&sp->c_raw[4]);
-	printf("0x%x\n", *(u_short *)&sp->c_raw[8]);
+	printf("0x%x", *(uint32_t *)&sp->c_raw[0]);
+	printf("0x%x", *(uint32_t *)&sp->c_raw[4]);
+	printf("0x%x\n", *(uint16_t *)&sp->c_raw[8]);
 	return 1;
 }
 

Index: src/sys/arch/hp300/dev/rdreg.h
diff -u src/sys/arch/hp300/dev/rdreg.h:1.19 src/sys/arch/hp300/dev/rdreg.h:1.20
--- src/sys/arch/hp300/dev/rdreg.h:1.19	Mon Nov 21 16:22:37 2022
+++ src/sys/arch/hp300/dev/rdreg.h	Fri Nov 25 13:02:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rdreg.h,v 1.19 2022/11/21 16:22:37 tsutsui Exp $	*/
+/*	$NetBSD: rdreg.h,v 1.20 2022/11/25 13:02:51 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,42 +39,42 @@
  */
 
 struct	rd_iocmd {
-	char	c_pad;
-	char	c_unit;
-	char	c_volume;
-	char	c_saddr;
-	short	c_

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

2022-11-23 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 23 18:55:06 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rdvar.h

Log Message:
Remove now unused buffer members from softc prepared only for rdreset().


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/hp300/dev/rdvar.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/hp300/dev/rdvar.h
diff -u src/sys/arch/hp300/dev/rdvar.h:1.26 src/sys/arch/hp300/dev/rdvar.h:1.27
--- src/sys/arch/hp300/dev/rdvar.h:1.26	Fri Jul  9 17:05:33 2021
+++ src/sys/arch/hp300/dev/rdvar.h	Wed Nov 23 18:55:06 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rdvar.h,v 1.26 2021/07/09 17:05:33 tsutsui Exp $	*/
+/*	$NetBSD: rdvar.h,v 1.27 2022/11/23 18:55:06 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -72,9 +72,6 @@ struct	rd_softc {
 	struct	rd_iocmd sc_ioc;
 	struct	rd_rscmd sc_rsc;
 	struct	rd_stat sc_stat;
-	struct	rd_ssmcmd sc_ssmc;
-	struct	rd_srcmd sc_src;
-	struct	rd_clearcmd sc_clear;
 	struct	bufq_state *sc_tab;
 	int	sc_active;
 	int	sc_errcnt;



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

2022-11-23 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 23 18:55:06 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rdvar.h

Log Message:
Remove now unused buffer members from softc prepared only for rdreset().


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/hp300/dev/rdvar.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/hp300/dev

2022-11-23 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 23 18:53:22 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Fix "rd(4) at punits not configured on HPDisk are misprobed" problem.

- check not only stat value returned by C_QSTAT command against
  each punit but also desc.d_name returned by C_DESC command
  because it looks HPDisk responds to commands against punits supported
  but not-configured punits at 1-3
- prepare rdreset_unit() function to manage reset punit ops during
  probe without valid softc

The stragety is taken from OpenBSD with several modification.
Tested on 425t with real 9122D and HPDisk emulating two 7937H drives.

Should be pulled up to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/arch/hp300/dev/rd.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.111 src/sys/arch/hp300/dev/rd.c:1.112
--- src/sys/arch/hp300/dev/rd.c:1.111	Mon Nov 21 16:22:37 2022
+++ src/sys/arch/hp300/dev/rd.c	Wed Nov 23 18:53:22 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.111 2022/11/21 16:22:37 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.112 2022/11/23 18:53:22 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.111 2022/11/21 16:22:37 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.112 2022/11/23 18:53:22 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -427,6 +427,7 @@ static const int numrdname2id = __arrayc
 static int	rdident(device_t, struct rd_softc *,
 		struct hpibbus_attach_args *);
 static void	rdreset(struct rd_softc *);
+static void	rdreset_unit(int, int, int);
 static void	rdustart(struct rd_softc *);
 static int	rdgetinfo(dev_t);
 static void	rdrestart(void *);
@@ -490,36 +491,8 @@ static int
 rdmatch(device_t parent, cfdata_t cf, void *aux)
 {
 	struct hpibbus_attach_args *ha = aux;
-	struct rd_clearcmd ccmd;
-	int ctlr, slave, punit;
-	int rv;
-	uint8_t stat;
-
-	rv = rdident(parent, NULL, ha);
-
-	if (rv == 0)
-		return 0;
-
-	/*
-	 * The supported device ID is probed.
-	 * Check if the specified physical unit is actually supported
-	 * by brandnew HP-IB emulator devices like HPDisk and HPDrive etc.
-	 */
-	ctlr  = device_unit(parent);
-	slave = ha->ha_slave;
-	punit = ha->ha_punit;
-	if (punit == 0)
-		return 1;
 
-	ccmd.c_unit = C_SUNIT(punit);
-	ccmd.c_cmd  = C_CLEAR;
-	hpibsend(ctlr, slave, C_TCMD, &ccmd, sizeof(ccmd));
-	hpibswait(ctlr, slave);
-	hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
-	if (stat != 0)
-		return 0;
-
-	return 1;
+	return rdident(parent, NULL, ha);
 }
 
 static void
@@ -608,29 +581,45 @@ rdident(device_t parent, struct rd_softc
 		return 0;
 
 	/*
-	 * If we're just probing for the device, that's all the
-	 * work we need to do.
+	 * The supported dvice ID is probed.
+	 * Check if the specified physical unit is actually supported
+	 * by brandnew HP-IB emulator devices like HPDisk and HPDrive etc.
 	 */
-	if (sc == NULL)
-		return 1;
-
 	/*
 	 * Reset device and collect description
 	 */
-	rdreset(sc);
+	memset(&desc, 0, sizeof(desc));
+	stat = 0;
+	rdreset_unit(ctlr, slave, ha->ha_punit);
 	cmd[0] = C_SUNIT(ha->ha_punit);
 	cmd[1] = C_SVOL(0);
 	cmd[2] = C_DESC;
 	hpibsend(ctlr, slave, C_CMD, cmd, sizeof(cmd));
 	hpibrecv(ctlr, slave, C_EXEC, &desc, sizeof(desc));
 	hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat));
+
+	if (stat != 0 || desc.d_name == 0) {
+		/*
+		 * No valid response from the specified punit.
+		 *
+		 * Note it looks HPDisk responds to commands against
+		 * supported but not-configured punits at 1 to 3.
+		 */
+		return 0;
+	}
+
+	/*
+	 * If we're just probing for the device, that's all the
+	 * work we need to do.
+	 */
+	if (sc == NULL)
+		return 1;
+
 	memset(name, 0, sizeof(name));
-	if (stat == 0) {
-		n = desc.d_name;
-		for (i = 5; i >= 0; i--) {
-			name[i] = (n & 0xf) + '0';
-			n >>= 4;
-		}
+	n = desc.d_name;
+	for (i = 5; i >= 0; i--) {
+		name[i] = (n & 0xf) + '0';
+		n >>= 4;
 	}
 
 #ifdef DEBUG
@@ -711,36 +700,48 @@ rdident(device_t parent, struct rd_softc
 static void
 rdreset(struct rd_softc *sc)
 {
-	int ctlr = device_unit(device_parent(sc->sc_dev));
-	int slave = sc->sc_slave;
+	int ctlr, slave, punit;
+
+	ctlr = device_unit(device_parent(sc->sc_dev));
+	slave = sc->sc_slave;
+	punit = sc->sc_punit;
+	rdreset_unit(ctlr, slave, punit);
+#ifdef DEBUG
+	sc->sc_stats.rdresets++;
+#endif
+}
+
+static void
+rdreset_unit(int ctlr, int slave, int punit)
+{
+	struct rd_ssmcmd ssmc;
+	struct rd_srcmd src;
+	struct rd_clearcmd clear;
 	u_char stat;
 
-	sc->sc_clear.c_unit = C_SUNIT(sc->sc_punit);
-	sc->sc_clear.c_cmd = C_CLEAR;
-	hpibsend(ctlr, slave, C_TCMD, &sc->sc_clear, sizeof(sc->sc_clear));
+	clear.c_unit = C_SUNIT(punit);
+	clear.c_cmd = C_CLEAR;
+	hpibsend(ctlr, slave, C_TCMD, &clear

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

2022-11-23 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Nov 23 18:53:22 UTC 2022

Modified Files:
src/sys/arch/hp300/dev: rd.c

Log Message:
Fix "rd(4) at punits not configured on HPDisk are misprobed" problem.

- check not only stat value returned by C_QSTAT command against
  each punit but also desc.d_name returned by C_DESC command
  because it looks HPDisk responds to commands against punits supported
  but not-configured punits at 1-3
- prepare rdreset_unit() function to manage reset punit ops during
  probe without valid softc

The stragety is taken from OpenBSD with several modification.
Tested on 425t with real 9122D and HPDisk emulating two 7937H drives.

Should be pulled up to netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/arch/hp300/dev/rd.c

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