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

2021-04-24 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Apr 24 16:24:14 UTC 2021

Modified Files:
src/sys/arch/x68k/dev: ms.c

Log Message:
Tidy up callout(9) implementation to handle mouse packets.

- define and use proper macro to specify ticks
- use callout_schedule(9) rather than callout_reset(9) to restart timer

No functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x68k/dev/ms.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/x68k/dev/ms.c
diff -u src/sys/arch/x68k/dev/ms.c:1.35 src/sys/arch/x68k/dev/ms.c:1.36
--- src/sys/arch/x68k/dev/ms.c:1.35	Sun Feb  7 16:13:56 2021
+++ src/sys/arch/x68k/dev/ms.c	Sat Apr 24 16:24:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ms.c,v 1.35 2021/02/07 16:13:56 tsutsui Exp $ */
+/*	$NetBSD: ms.c,v 1.36 2021/04/24 16:24:14 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.35 2021/02/07 16:13:56 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.36 2021/04/24 16:24:14 tsutsui Exp $");
 
 #include 
 #include 
@@ -87,6 +87,16 @@ __KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.35 
 #define MS_BPS 4800
 
 /*
+ * Send mouse commands per MS_TICK.
+ */
+#ifndef HZ
+#define HZ		100
+#endif
+#define MS_TICK		2
+#define MS_TIMEOUT_SEC	5
+#define MS_TIMEOUT	((MS_TIMEOUT_SEC * HZ) / MS_TICK)
+
+/*
  * Mouse state.  A SHARP X1/X680x0 mouse is a fairly simple device,
  * producing three-byte blobs of the form:
  *
@@ -258,7 +268,7 @@ msopen(dev_t dev, int flags, int mode, s
 	ms->ms_nodata = 0;
 
 	/* start sequencer */
-	ms_modem(ms);
+	callout_reset(>ms_modem_ch, MS_TICK, ms_modem, ms);
 
 	return 0;
 }
@@ -649,9 +659,9 @@ ms_modem(void *arg)
 
 	mutex_enter(>ms_lock);
 
-	if (ms->ms_nodata++ > 250) { /* XXX */
-		log(LOG_ERR, "%s: no data for 5 secs. resetting.\n",
-		device_xname(ms->ms_dev));
+	if (ms->ms_nodata++ > MS_TIMEOUT) {
+		log(LOG_ERR, "%s: no data for %d secs. resetting.\n",
+		device_xname(ms->ms_dev), MS_TIMEOUT_SEC);
 		ms->ms_byteno = -1;
 		ms->ms_nodata = 0;
 		ms->ms_rts = 0;
@@ -670,5 +680,5 @@ ms_modem(void *arg)
 	}
 
 	mutex_exit(>ms_lock);
-	callout_reset(>ms_modem_ch, 2, ms_modem, ms);
+	callout_schedule(>ms_modem_ch, MS_TICK);
 }



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

2021-02-07 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Feb  7 16:13:56 UTC 2021

Modified Files:
src/sys/arch/x68k/dev: ms.c

Log Message:
Remove dumb middle button emulation code from the ms(4) driver.

Also fix leftover comments (derived from the original Sun's "firm_event"
implementation as seen in sys/dev/sun/ms.c) to sync with reality on x68k.

The current implementation the ms(4) driver just checks whether
two (left/right) buttons are changed in the same packet.
This means it cannot handle a release event correctly if two
buttons pressed simultaneously are released in the different timing.

The middle button emulation should be handled in application layer
as other Xservers do, and I'll import Emulate3Buttons support for the
X68k Xorg based monolithic server.

See my post on port-x68k@ for details:
 https://mail-index.netbsd.org/port-x68k/2021/02/05/msg74.html


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x68k/dev/ms.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/x68k/dev/ms.c
diff -u src/sys/arch/x68k/dev/ms.c:1.34 src/sys/arch/x68k/dev/ms.c:1.35
--- src/sys/arch/x68k/dev/ms.c:1.34	Fri Jul 25 08:10:35 2014
+++ src/sys/arch/x68k/dev/ms.c	Sun Feb  7 16:13:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ms.c,v 1.34 2014/07/25 08:10:35 dholland Exp $ */
+/*	$NetBSD: ms.c,v 1.35 2021/02/07 16:13:56 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.34 2014/07/25 08:10:35 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ms.c,v 1.35 2021/02/07 16:13:56 tsutsui Exp $");
 
 #include 
 #include 
@@ -356,8 +356,8 @@ ms_input(struct ms_softc *ms, int c)
 {
 	struct firm_event *fe;
 	int mb, ub, d, get, put, any;
-	static const char to_one[] = { 1, 2, 3 };
-	static const int to_id[] = { MS_LEFT, MS_RIGHT, MS_MIDDLE };
+	static const char to_one[] = { 1, 2, 2 };
+	static const int to_id[] = { MS_LEFT, MS_RIGHT };
 
 	/*
 	 * Discard input if not ready.  Drop sync on parity or framing
@@ -402,7 +402,7 @@ ms_input(struct ms_softc *ms, int c)
 
 	/*
 	 * We have at least one event (mouse button, delta-X, or
-	 * delta-Y; possibly all three, and possibly three separate
+	 * delta-Y; possibly all three, and possibly two separate
 	 * button events).  Deliver these events until we are out
 	 * of changes or out of room.  As events get delivered,
 	 * mark them `unchanged'.
@@ -430,12 +430,12 @@ ms_input(struct ms_softc *ms, int c)
 	ub = ms->ms_ub;
 	while ((d = mb ^ ub) != 0) {
 		/*
-		 * Mouse button change.  Convert up to three changes
+		 * Mouse button change.  Convert up to two changes
 		 * to the `first' change, and drop it into the event queue.
 		 */
 		NEXT;
-		d = to_one[d - 1];		/* from 1..7 to {1,2,4} */
-		fe->id = to_id[d - 1];		/* from {1,2,4} to ID */
+		d = to_one[d - 1];		/* from 1..3 to {1,2} */
+		fe->id = to_id[d - 1];		/* from {1,2} to ID */
 		fe->value = mb & d ? VKEY_DOWN : VKEY_UP;
 		firm_gettime(fe);
 		ADVANCE;



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

2021-02-06 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb  6 12:50:04 UTC 2021

Modified Files:
src/sys/arch/x68k/dev: vs.c vsvar.h

Log Message:
Remove an unused variable.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/x68k/dev/vs.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x68k/dev/vsvar.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.53 src/sys/arch/x68k/dev/vs.c:1.54
--- src/sys/arch/x68k/dev/vs.c:1.53	Sat Feb  6 09:27:35 2021
+++ src/sys/arch/x68k/dev/vs.c	Sat Feb  6 12:50:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.53 2021/02/06 09:27:35 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.54 2021/02/06 12:50:04 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.53 2021/02/06 09:27:35 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.54 2021/02/06 12:50:04 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -212,7 +212,6 @@ vs_attach(device_t parent, device_t self
 	/* Initialize sc */
 	sc->sc_iot = iot;
 	sc->sc_ioh = ioh;
-	sc->sc_hw_if = _hw_if;
 	sc->sc_addr = (void *) ia->ia_addr;
 	sc->sc_dmas = NULL;
 	sc->sc_prev_vd = NULL;

Index: src/sys/arch/x68k/dev/vsvar.h
diff -u src/sys/arch/x68k/dev/vsvar.h:1.18 src/sys/arch/x68k/dev/vsvar.h:1.19
--- src/sys/arch/x68k/dev/vsvar.h:1.18	Sat Feb  6 09:27:35 2021
+++ src/sys/arch/x68k/dev/vsvar.h	Sat Feb  6 12:50:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsvar.h,v 1.18 2021/02/06 09:27:35 isaki Exp $	*/
+/*	$NetBSD: vsvar.h,v 1.19 2021/02/06 12:50:04 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -99,8 +99,6 @@ struct vs_softc {
 		int rate;
 	} sc_current;
 
-	const struct audio_hw_if *sc_hw_if;
-
 	void (*sc_pintr)(void *);
 	void (*sc_rintr)(void *);
 	void *sc_parg;



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

2021-02-06 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb  6 09:27:35 UTC 2021

Modified Files:
src/sys/arch/x68k/dev: vs.c vsvar.h

Log Message:
Remove sc_active flag.  sc_[pr]intr can be used instead of it.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/x68k/dev/vs.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x68k/dev/vsvar.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.52 src/sys/arch/x68k/dev/vs.c:1.53
--- src/sys/arch/x68k/dev/vs.c:1.52	Sat Jun  8 08:02:37 2019
+++ src/sys/arch/x68k/dev/vs.c	Sat Feb  6 09:27:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.52 2019/06/08 08:02:37 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.53 2021/02/06 09:27:35 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.52 2019/06/08 08:02:37 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.53 2021/02/06 09:27:35 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -72,8 +72,6 @@ static int  vs_dmaintr(void *);
 static int  vs_dmaerrintr(void *);
 
 /* MI audio layer interface */
-static int  vs_open(void *, int);
-static void vs_close(void *);
 static int  vs_query_format(void *, audio_format_query_t *);
 static int  vs_set_format(void *, int,
 	const audio_params_t *, const audio_params_t *,
@@ -108,8 +106,6 @@ CFATTACH_DECL_NEW(vs, sizeof(struct vs_s
 static int vs_attached;
 
 static const struct audio_hw_if vs_hw_if = {
-	.open			= vs_open,
-	.close			= vs_close,
 	.query_format		= vs_query_format,
 	.set_format		= vs_set_format,
 	.commit_settings	= vs_commit_settings,
@@ -220,7 +216,6 @@ vs_attach(device_t parent, device_t self
 	sc->sc_addr = (void *) ia->ia_addr;
 	sc->sc_dmas = NULL;
 	sc->sc_prev_vd = NULL;
-	sc->sc_active = 0;
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_VM);
 
@@ -286,27 +281,6 @@ vs_dmaerrintr(void *hdl)
  */
 
 static int
-vs_open(void *hdl, int flags)
-{
-	struct vs_softc *sc;
-
-	DPRINTF(1, ("vs_open: flags=%d\n", flags));
-	sc = hdl;
-	sc->sc_pintr = NULL;
-	sc->sc_rintr = NULL;
-	sc->sc_active = 0;
-
-	return 0;
-}
-
-static void
-vs_close(void *hdl)
-{
-
-	DPRINTF(1, ("vs_close\n"));
-}
-
-static int
 vs_query_format(void *hdl, audio_format_query_t *afp)
 {
 
@@ -398,9 +372,6 @@ vs_start_output(void *hdl, void *block, 
 	DPRINTF(2, ("%s: block=%p blksize=%d\n", __func__, block, blksize));
 	sc = hdl;
 
-	sc->sc_pintr = intr;
-	sc->sc_parg  = arg;
-
 	/* Find DMA buffer. */
 	for (vd = sc->sc_dmas; vd != NULL; vd = vd->vd_next) {
 		if (KVADDR(vd) <= block && block < KVADDR_END(vd)
@@ -424,11 +395,13 @@ vs_start_output(void *hdl, void *block, 
 	dmac_start_xfer_offset(chan->ch_softc, sc->sc_current.xfer,
 	(int)block - (int)KVADDR(vd), blksize);
 
-	if (sc->sc_active == 0) {
+	if (sc->sc_pintr == NULL) {
+		sc->sc_pintr = intr;
+		sc->sc_parg  = arg;
+
 		vs_set_panout(sc, VS_PANOUT_LR);
 		bus_space_write_1(sc->sc_iot, sc->sc_ioh,
 			MSM6258_CMD, MSM6258_CMD_PLAY_START);
-		sc->sc_active = 1;
 	}
 
 	return 0;
@@ -445,9 +418,6 @@ vs_start_input(void *hdl, void *block, i
 	DPRINTF(2, ("%s: block=%p blksize=%d\n", __func__, block, blksize));
 	sc = hdl;
 
-	sc->sc_rintr = intr;
-	sc->sc_rarg  = arg;
-
 	/* Find DMA buffer. */
 	for (vd = sc->sc_dmas; vd != NULL; vd = vd->vd_next) {
 		if (KVADDR(vd) <= block && block < KVADDR_END(vd)
@@ -471,10 +441,12 @@ vs_start_input(void *hdl, void *block, i
 	dmac_start_xfer_offset(chan->ch_softc, sc->sc_current.xfer,
 	(int)block - (int)KVADDR(vd), blksize);
 
-	if (sc->sc_active == 0) {
+	if (sc->sc_rintr == NULL) {
+		sc->sc_rintr = intr;
+		sc->sc_rarg  = arg;
+
 		bus_space_write_1(sc->sc_iot, sc->sc_ioh,
 			MSM6258_CMD, MSM6258_CMD_REC_START);
-		sc->sc_active = 1;
 	}
 
 	return 0;
@@ -487,13 +459,12 @@ vs_halt_output(void *hdl)
 
 	DPRINTF(1, ("vs_halt_output\n"));
 	sc = hdl;
-	if (sc->sc_active) {
-		/* stop ADPCM play */
-		dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer);
-		bus_space_write_1(sc->sc_iot, sc->sc_ioh,
-			MSM6258_CMD, MSM6258_CMD_STOP);
-		sc->sc_active = 0;
-	}
+
+	/* stop ADPCM play */
+	dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer);
+	bus_space_write_1(sc->sc_iot, sc->sc_ioh,
+	MSM6258_CMD, MSM6258_CMD_STOP);
+	sc->sc_pintr = NULL;
 
 	return 0;
 }
@@ -505,13 +476,12 @@ vs_halt_input(void *hdl)
 
 	DPRINTF(1, ("vs_halt_input\n"));
 	sc = hdl;
-	if (sc->sc_active) {
-		/* stop ADPCM recoding */
-		dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer);
-		bus_space_write_1(sc->sc_iot, sc->sc_ioh,
-			MSM6258_CMD, MSM6258_CMD_STOP);
-		sc->sc_active = 0;
-	}
+
+	/* stop ADPCM recoding */
+	dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer);
+	bus_space_write_1(sc->sc_iot, sc->sc_ioh,
+	MSM6258_CMD, MSM6258_CMD_STOP);

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

2020-12-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Dec 19 22:16:15 UTC 2020

Modified Files:
src/sys/arch/x68k/dev: event.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x68k/dev/event.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/x68k/dev/event.c
diff -u src/sys/arch/x68k/dev/event.c:1.16 src/sys/arch/x68k/dev/event.c:1.17
--- src/sys/arch/x68k/dev/event.c:1.16	Sat May 23 23:42:41 2020
+++ src/sys/arch/x68k/dev/event.c	Sat Dec 19 22:16:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: event.c,v 1.16 2020/05/23 23:42:41 ad Exp $ */
+/*	$NetBSD: event.c,v 1.17 2020/12/19 22:16:15 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: event.c,v 1.16 2020/05/23 23:42:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: event.c,v 1.17 2020/12/19 22:16:15 thorpej Exp $");
 
 #include 
 #include 
@@ -189,7 +189,7 @@ filt_evrdetach(struct knote *kn)
 	struct evvar *ev = kn->kn_hook;
 
 	mutex_enter(ev->ev_lock);
-	SLIST_REMOVE(>ev_sel.sel_klist, kn, knote, kn_selnext);
+	selremove_knote(>ev_sel, kn);
 	mutex_exit(ev->ev_lock);
 }
 
@@ -226,11 +226,9 @@ static const struct filterops ev_filtops
 int
 ev_kqfilter(struct evvar *ev, struct knote *kn)
 {
-	struct klist *klist;
 
 	switch (kn->kn_filter) {
 	case EVFILT_READ:
-		klist = >ev_sel.sel_klist;
 		kn->kn_fop = _filtops;
 		break;
 
@@ -241,7 +239,7 @@ ev_kqfilter(struct evvar *ev, struct kno
 	kn->kn_hook = ev;
 
 	mutex_enter(ev->ev_lock);
-	SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+	selrecord_knote(>ev_sel, kn);
 	mutex_exit(ev->ev_lock);
 
 	return (0);



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

2017-09-29 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Sep 30 04:07:04 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: vs.c vsvar.h

Log Message:
Avoid magic numbers and give appropriate names.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/x68k/dev/vs.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x68k/dev/vsvar.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.48 src/sys/arch/x68k/dev/vs.c:1.49
--- src/sys/arch/x68k/dev/vs.c:1.48	Sat Sep  2 15:40:31 2017
+++ src/sys/arch/x68k/dev/vs.c	Sat Sep 30 04:07:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.48 2017/09/02 15:40:31 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.49 2017/09/30 04:07:04 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.48 2017/09/02 15:40:31 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.49 2017/09/30 04:07:04 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -510,7 +510,8 @@ vs_start_output(void *hdl, void *block, 
 	(int)block - (int)KVADDR(vd), blksize);
 
 	if (sc->sc_active == 0) {
-		bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 2);
+		bus_space_write_1(sc->sc_iot, sc->sc_ioh,
+			MSM6258_CMD, MSM6258_CMD_PLAY_START);
 		sc->sc_active = 1;
 	}
 
@@ -555,7 +556,8 @@ vs_start_input(void *hdl, void *block, i
 	(int)block - (int)KVADDR(vd), blksize);
 
 	if (sc->sc_active == 0) {
-		bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 4);
+		bus_space_write_1(sc->sc_iot, sc->sc_ioh,
+			MSM6258_CMD, MSM6258_CMD_REC_START);
 		sc->sc_active = 1;
 	}
 
@@ -572,7 +574,8 @@ vs_halt_output(void *hdl)
 	if (sc->sc_active) {
 		/* stop ADPCM play */
 		dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer);
-		bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 1);
+		bus_space_write_1(sc->sc_iot, sc->sc_ioh,
+			MSM6258_CMD, MSM6258_CMD_STOP);
 		sc->sc_active = 0;
 	}
 
@@ -589,7 +592,8 @@ vs_halt_input(void *hdl)
 	if (sc->sc_active) {
 		/* stop ADPCM recoding */
 		dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer);
-		bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 1);
+		bus_space_write_1(sc->sc_iot, sc->sc_ioh,
+			MSM6258_CMD, MSM6258_CMD_STOP);
 		sc->sc_active = 0;
 	}
 

Index: src/sys/arch/x68k/dev/vsvar.h
diff -u src/sys/arch/x68k/dev/vsvar.h:1.15 src/sys/arch/x68k/dev/vsvar.h:1.16
--- src/sys/arch/x68k/dev/vsvar.h:1.15	Sat Sep  2 12:52:55 2017
+++ src/sys/arch/x68k/dev/vsvar.h	Sat Sep 30 04:07:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsvar.h,v 1.15 2017/09/02 12:52:55 isaki Exp $	*/
+/*	$NetBSD: vsvar.h,v 1.16 2017/09/30 04:07:04 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -59,8 +59,12 @@
 #define VS_MAX_BUFSIZE	(65536*4) /* XXX: enough? */
 
 /* XXX: msm6258vreg.h */
-#define MSM6258_STAT	0
-#define MSM6258_DATA	1
+#define MSM6258_CMD 	0		/* W */
+#define MSM6258_CMD_STOP	(0x01)
+#define MSM6258_CMD_PLAY_START	(0x02)
+#define MSM6258_CMD_REC_START	(0x04)
+#define MSM6258_STAT	0		/* R */
+#define MSM6258_DATA	1		/* R/W */
 
 struct vs_dma {
 	bus_dma_tag_t		vd_dmat;



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

2017-09-02 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Sep  2 15:40:31 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: vs.c

Log Message:
- Finally MI audio supports 4bit precision format without null_filter hack!
- Fix reusing play/rec argument as local variables.  It is in/out parameter.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/x68k/dev/vs.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.47 src/sys/arch/x68k/dev/vs.c:1.48
--- src/sys/arch/x68k/dev/vs.c:1.47	Sat Sep  2 12:52:55 2017
+++ src/sys/arch/x68k/dev/vs.c	Sat Sep  2 15:40:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.47 2017/09/02 12:52:55 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.48 2017/09/02 15:40:31 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.47 2017/09/02 12:52:55 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.48 2017/09/02 15:40:31 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -160,8 +160,6 @@ struct {
 
 #define NUM_RATE	(sizeof(vs_l2r)/sizeof(vs_l2r[0]))
 
-extern stream_filter_factory_t null_filter;
-
 static int
 vs_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -365,6 +363,7 @@ vs_set_params(void *hdl, int setmode, in
 	stream_filter_list_t *pfil, stream_filter_list_t *rfil)
 {
 	struct vs_softc *sc;
+	audio_params_t hw;
 	stream_filter_factory_t *pconv;
 	stream_filter_factory_t *rconv;
 	int rate;
@@ -405,18 +404,18 @@ vs_set_params(void *hdl, int setmode, in
 	/* pfil and rfil are independent even if !AUDIO_PROP_INDEPENDENT */
 
 	if ((setmode & AUMODE_PLAY) != 0) {
-		pfil->append(pfil, null_filter, play);
-		play->encoding = AUDIO_ENCODING_ADPCM;
-		play->validbits = 4;
-		play->precision = 4;
-		pfil->append(pfil, pconv, play);
+		hw = *play;
+		hw.encoding = AUDIO_ENCODING_ADPCM;
+		hw.precision = 4;
+		hw.validbits = 4;
+		pfil->prepend(pfil, pconv, );
 	}
 	if ((setmode & AUMODE_RECORD) != 0) {
-		rfil->append(rfil, null_filter, rec);
-		rec->encoding = AUDIO_ENCODING_ADPCM;
-		rec->validbits = 4;
-		rec->precision = 4;
-		rfil->append(rfil, rconv, rec);
+		hw = *rec;
+		hw.encoding = AUDIO_ENCODING_ADPCM;
+		hw.precision = 4;
+		hw.validbits = 4;
+		rfil->prepend(rfil, rconv, );
 	}
 
 	DPRINTF(1, ("accepted\n"));



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

2017-09-02 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Sep  2 12:52:55 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: vs.c vsvar.h

Log Message:
- Revert temporary local conversion introduced at rev 1.43.
- But does not revert to trigger method.  trigger method is not suitable for
  x68k ADPCM+DMA mechanism.
- Don't (re)start ADPCM when DMA is running.  This solves the noise.
  From Y.Sugahara.
- Cache dmac xfer.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/x68k/dev/vs.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x68k/dev/vsvar.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.46 src/sys/arch/x68k/dev/vs.c:1.47
--- src/sys/arch/x68k/dev/vs.c:1.46	Fri Aug 11 07:08:40 2017
+++ src/sys/arch/x68k/dev/vs.c	Sat Sep  2 12:52:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.46 2017/08/11 07:08:40 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.47 2017/09/02 12:52:55 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.46 2017/08/11 07:08:40 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.47 2017/09/02 12:52:55 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -101,7 +101,6 @@ static void vs_get_locks(void *, kmutex_
 static int vs_round_sr(u_long);
 static void vs_set_sr(struct vs_softc *, int);
 static inline void vs_set_po(struct vs_softc *, u_long);
-static void *vs_realloc_hwbuf(struct vs_softc *, int);
 
 extern struct cfdriver vs_cd;
 
@@ -130,8 +129,8 @@ static const struct audio_hw_if vs_hw_if
 	vs_set_port,
 	vs_get_port,
 	vs_query_devinfo,
-	NULL,			/* allocm */
-	NULL,			/* freem */
+	vs_allocm,
+	vs_freem,
 	vs_round_buffersize,
 	NULL,			/* mappage */
 	vs_get_props,
@@ -161,6 +160,8 @@ struct {
 
 #define NUM_RATE	(sizeof(vs_l2r)/sizeof(vs_l2r[0]))
 
+extern stream_filter_factory_t null_filter;
+
 static int
 vs_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -220,10 +221,8 @@ vs_attach(device_t parent, device_t self
 	sc->sc_hw_if = _hw_if;
 	sc->sc_addr = (void *) ia->ia_addr;
 	sc->sc_dmas = NULL;
+	sc->sc_prev_vd = NULL;
 	sc->sc_active = 0;
-	sc->sc_hwbuf = NULL;
-	sc->sc_hwbufsize = 0;
-	sc->sc_codec = vs_alloc_msm6258codec();
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
 
@@ -257,13 +256,9 @@ vs_dmaintr(void *hdl)
 
 	mutex_spin_enter(>sc_intr_lock);
 
-	sc->sc_active = 0;
 	if (sc->sc_pintr) {
 		sc->sc_pintr(sc->sc_parg);
 	} else if (sc->sc_rintr) {
-		/* convert ADPCM to slinear */
-		sc->sc_rconv(sc->sc_codec, sc->sc_current.rblock,
-		sc->sc_current.blksize, sc->sc_hwbuf);
 		sc->sc_rintr(sc->sc_rarg);
 	} else {
 		printf("vs_dmaintr: spurious interrupt\n");
@@ -301,6 +296,7 @@ vs_open(void *hdl, int flags)
 	sc = hdl;
 	sc->sc_pintr = NULL;
 	sc->sc_rintr = NULL;
+	sc->sc_active = 0;
 
 	return 0;
 }
@@ -369,6 +365,8 @@ vs_set_params(void *hdl, int setmode, in
 	stream_filter_list_t *pfil, stream_filter_list_t *rfil)
 {
 	struct vs_softc *sc;
+	stream_filter_factory_t *pconv;
+	stream_filter_factory_t *rconv;
 	int rate;
 
 	sc = hdl;
@@ -391,16 +389,12 @@ vs_set_params(void *hdl, int setmode, in
 	}
 
 	if (play->precision == 8 && play->encoding == AUDIO_ENCODING_SLINEAR) {
-		sc->sc_current.precision = 8;
-		sc->sc_pconv = vs_slinear8_to_adpcm;
-		sc->sc_rconv = vs_adpcm_to_slinear8;
-
+		pconv = msm6258_linear8_to_adpcm;
+		rconv = msm6258_adpcm_to_linear8;
 	} else if (play->precision == 16 &&
 	   play->encoding == AUDIO_ENCODING_SLINEAR_BE) {
-		sc->sc_current.precision = 16;
-		sc->sc_pconv = vs_slinear16be_to_adpcm;
-		sc->sc_rconv = vs_adpcm_to_slinear16be;
-
+		pconv = msm6258_slinear16_to_adpcm;
+		rconv = msm6258_adpcm_to_slinear16;
 	} else {
 		DPRINTF(1, ("prec/enc not matched\n"));
 		return EINVAL;
@@ -410,11 +404,20 @@ vs_set_params(void *hdl, int setmode, in
 
 	/* pfil and rfil are independent even if !AUDIO_PROP_INDEPENDENT */
 
-	/*
-	 * XXX MI audio(4) layer does not seem to support non SLINEAR devices.
-	 * So vs(4) behaves as SLINEAR device completely against MI layer
-	 * and converts SLINEAR <-> ADPCM by myself.
-	 */
+	if ((setmode & AUMODE_PLAY) != 0) {
+		pfil->append(pfil, null_filter, play);
+		play->encoding = AUDIO_ENCODING_ADPCM;
+		play->validbits = 4;
+		play->precision = 4;
+		pfil->append(pfil, pconv, play);
+	}
+	if ((setmode & AUMODE_RECORD) != 0) {
+		rfil->append(rfil, null_filter, rec);
+		rec->encoding = AUDIO_ENCODING_ADPCM;
+		rec->validbits = 4;
+		rec->precision = 4;
+		rfil->append(rfil, rconv, rec);
+	}
 
 	DPRINTF(1, ("accepted\n"));
 	return 0;
@@ -470,22 +473,6 @@ vs_init_input(void *hdl, void *buffer, i
 	return 0;
 }
 
-/* (re)allocate sc_hwbuf with hwbufsize */
-static void *
-vs_realloc_hwbuf(struct vs_softc *sc, int hwbufsize)
-{
-	if (sc->sc_hwbuf != NULL) {

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

2017-08-11 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri Aug 11 07:30:01 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: dmacvar.h intio_dmac.c

Log Message:
Fix a Continue Operation.
Patch from Y.Sugahara.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x68k/dev/dmacvar.h
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/x68k/dev/intio_dmac.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/x68k/dev/dmacvar.h
diff -u src/sys/arch/x68k/dev/dmacvar.h:1.11 src/sys/arch/x68k/dev/dmacvar.h:1.12
--- src/sys/arch/x68k/dev/dmacvar.h:1.11	Fri Aug 11 07:08:40 2017
+++ src/sys/arch/x68k/dev/dmacvar.h	Fri Aug 11 07:30:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmacvar.h,v 1.11 2017/08/11 07:08:40 isaki Exp $	*/
+/*	$NetBSD: dmacvar.h,v 1.12 2017/08/11 07:30:01 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -55,8 +55,6 @@ struct dmac_dma_xfer {
 	struct dmac_sg_array *dx_array;	/* DMAC array chain */
 	int		dx_done;
 #endif
-	int		dx_nextoff;	/* for continued operation */
-	int		dx_nextsize;
 };
 
 /*

Index: src/sys/arch/x68k/dev/intio_dmac.c
diff -u src/sys/arch/x68k/dev/intio_dmac.c:1.36 src/sys/arch/x68k/dev/intio_dmac.c:1.37
--- src/sys/arch/x68k/dev/intio_dmac.c:1.36	Fri Aug 11 07:08:40 2017
+++ src/sys/arch/x68k/dev/intio_dmac.c	Fri Aug 11 07:30:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: intio_dmac.c,v 1.36 2017/08/11 07:08:40 isaki Exp $	*/
+/*	$NetBSD: intio_dmac.c,v 1.37 2017/08/11 07:30:01 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include "opt_m68k_arch.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intio_dmac.c,v 1.36 2017/08/11 07:08:40 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intio_dmac.c,v 1.37 2017/08/11 07:30:01 isaki Exp $");
 
 #include 
 #include 
@@ -284,7 +284,6 @@ dmac_alloc_xfer(struct dmac_channel_stat
 	xf->dx_array = chan->ch_map;
 	xf->dx_done = 0;
 #endif
-	xf->dx_nextoff = xf->dx_nextsize = -1;
 	return xf;
 }
 
@@ -300,8 +299,6 @@ dmac_load_xfer(struct dmac_softc *dmac, 
 		xf->dx_ocr |= DMAC_OCR_CHAIN_DISABLED;
 	else {
 		xf->dx_ocr |= DMAC_OCR_CHAIN_ARRAY;
-		xf->dx_nextoff = ~0;
-		xf->dx_nextsize = ~0;
 	}
 
 	bus_space_write_1(dmac->sc_bst, chan->ch_bht, DMAC_REG_CSR, 0xff);
@@ -352,6 +349,8 @@ dmac_start_xfer_offset(struct dmac_softc
 	struct dmac_channel_stat *chan = xf->dx_channel;
 	struct x68k_bus_dmamap *dmamap = xf->dx_dmamap;
 	int go = DMAC_CCR_STR|DMAC_CCR_INT;
+	bus_addr_t paddr;
+	uint8_t csr;
 #ifdef DMAC_ARRAYCHAIN
 	int c;
 #endif
@@ -391,20 +390,21 @@ dmac_start_xfer_offset(struct dmac_softc
 		if (dmamap->dm_mapsize != dmamap->dm_segs[0].ds_len)
 			panic("dmac_start_xfer_offset: dmamap curruption");
 #endif
-		if (offset == xf->dx_nextoff &&
-		size == xf->dx_nextsize) {
-			/* Use continued operation */
+		paddr = dmamap->dm_segs[0].ds_addr + offset;
+		csr = bus_space_read_1(dmac->sc_bst, chan->ch_bht, DMAC_REG_CSR);
+		if ((csr & DMAC_CSR_ACT) != 0) {
+			/* Use 'Continue Mode' */
+			bus_space_write_4(dmac->sc_bst, chan->ch_bht,
+			DMAC_REG_BAR, paddr);
+			bus_space_write_2(dmac->sc_bst, chan->ch_bht,
+			DMAC_REG_BTCR, (int) size);
 			go |=  DMAC_CCR_CNT;
-			xf->dx_nextoff += size;
+			go &= ~DMAC_CCR_STR;
 		} else {
 			bus_space_write_4(dmac->sc_bst, chan->ch_bht,
-	  DMAC_REG_MAR,
-	  (int) dmamap->dm_segs[0].ds_addr
-	  + offset);
+	  DMAC_REG_MAR, paddr);
 			bus_space_write_2(dmac->sc_bst, chan->ch_bht,
 	  DMAC_REG_MTCR, (int) size);
-			xf->dx_nextoff = offset;
-			xf->dx_nextsize = size;
 		}
 #ifdef DMAC_ARRAYCHAIN
 		xf->dx_done = 1;
@@ -436,13 +436,6 @@ dmac_start_xfer_offset(struct dmac_softc
 #endif
 	bus_space_write_1(dmac->sc_bst, chan->ch_bht, DMAC_REG_CCR, go);
 
-	if (xf->dx_nextoff != ~0) {
-		bus_space_write_4(dmac->sc_bst, chan->ch_bht,
-  DMAC_REG_BAR, xf->dx_nextoff);
-		bus_space_write_2(dmac->sc_bst, chan->ch_bht,
-  DMAC_REG_BTCR, xf->dx_nextsize);
-	}
-
 	return 0;
 }
 
@@ -563,7 +556,6 @@ dmac_abort_xfer(struct dmac_softc *dmac,
 	bus_space_write_1(dmac->sc_bst, chan->ch_bht, DMAC_REG_CCR,
 			  DMAC_CCR_INT | DMAC_CCR_SAB);
 	bus_space_write_1(dmac->sc_bst, chan->ch_bht, DMAC_REG_CSR, 0xff);
-	xf->dx_nextoff = xf->dx_nextsize = -1;
 
 	return 0;
 }



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

2017-08-11 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri Aug 11 07:08:40 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: dmacvar.h fd.c intio_dmac.c vs.c

Log Message:
Allow dmac_alloc_channel() to specify DCR and OCR.
FDC uses 'Cycle Steal Mode with Hold' but ADPCM
should use 'Cycle Steal Mode without Hold' on x68k.
>From Y.Suhagara and it was found by XM6i.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x68k/dev/dmacvar.h
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/x68k/dev/fd.c
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x68k/dev/intio_dmac.c
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/x68k/dev/vs.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/x68k/dev/dmacvar.h
diff -u src/sys/arch/x68k/dev/dmacvar.h:1.10 src/sys/arch/x68k/dev/dmacvar.h:1.11
--- src/sys/arch/x68k/dev/dmacvar.h:1.10	Wed Jun 25 13:30:24 2008
+++ src/sys/arch/x68k/dev/dmacvar.h	Fri Aug 11 07:08:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dmacvar.h,v 1.10 2008/06/25 13:30:24 isaki Exp $	*/
+/*	$NetBSD: dmacvar.h,v 1.11 2017/08/11 07:08:40 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -99,9 +99,14 @@ struct dmac_softc {
 #define DMAC_MAXSEGSZ	0xff00
 #define DMAC_BOUNDARY	0
 
-struct dmac_channel_stat *dmac_alloc_channel(device_t, int, const char *,
-	int, dmac_intr_handler_t, void *, int, dmac_intr_handler_t, void *);
-		/* ch, name, normalv, normal, errorv, error */
+struct dmac_channel_stat *dmac_alloc_channel(device_t,
+	int,		/* ch */
+	const char *,	/* name */
+	int, dmac_intr_handler_t, void *,	/* normal handler */
+	int, dmac_intr_handler_t, void *,	/* error handler */
+	uint8_t,	/* dcr */
+	uint8_t		/* ocr */
+);
 int dmac_free_channel(device_t, int, void *);
 		/* ch, channel */
 struct dmac_dma_xfer *dmac_alloc_xfer(struct dmac_channel_stat *,

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.119 src/sys/arch/x68k/dev/fd.c:1.120
--- src/sys/arch/x68k/dev/fd.c:1.119	Thu Jan 12 14:24:53 2017
+++ src/sys/arch/x68k/dev/fd.c	Fri Aug 11 07:08:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.119 2017/01/12 14:24:53 isaki Exp $	*/
+/*	$NetBSD: fd.c,v 1.120 2017/08/11 07:08:40 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.119 2017/01/12 14:24:53 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.120 2017/08/11 07:08:40 isaki Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m68k_arch.h"
@@ -487,7 +487,10 @@ fdcattach(device_t parent, device_t self
 	/* Initialize DMAC channel */
 	fdc->sc_dmachan = dmac_alloc_channel(parent, ia->ia_dma, "fdc",
 	ia->ia_dmaintr, fdcdmaintr, fdc,
-	ia->ia_dmaintr + 1, fdcdmaerrintr, fdc);
+	ia->ia_dmaintr + 1, fdcdmaerrintr, fdc,
+	(DMAC_DCR_XRM_CSWH | DMAC_DCR_OTYP_EASYNC | DMAC_DCR_OPS_8BIT),
+	(DMAC_OCR_SIZE_BYTE | DMAC_OCR_REQG_EXTERNAL));
+
 	if (bus_dmamap_create(fdc->sc_dmat, FDC_MAXIOSIZE, 1, DMAC_MAXSEGSZ,
 	0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, >sc_dmamap)) {
 		aprint_error_dev(self, "can't set up intio DMA map\n");

Index: src/sys/arch/x68k/dev/intio_dmac.c
diff -u src/sys/arch/x68k/dev/intio_dmac.c:1.35 src/sys/arch/x68k/dev/intio_dmac.c:1.36
--- src/sys/arch/x68k/dev/intio_dmac.c:1.35	Wed Mar 26 08:17:59 2014
+++ src/sys/arch/x68k/dev/intio_dmac.c	Fri Aug 11 07:08:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: intio_dmac.c,v 1.35 2014/03/26 08:17:59 christos Exp $	*/
+/*	$NetBSD: intio_dmac.c,v 1.36 2017/08/11 07:08:40 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include "opt_m68k_arch.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intio_dmac.c,v 1.35 2014/03/26 08:17:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intio_dmac.c,v 1.36 2017/08/11 07:08:40 isaki Exp $");
 
 #include 
 #include 
@@ -159,9 +159,10 @@ dmac_init_channels(struct dmac_softc *sc
  * Channel initialization/deinitialization per user device.
  */
 struct dmac_channel_stat *
-dmac_alloc_channel(device_t self, int ch, const char *name, int normalv,
-dmac_intr_handler_t normal, void *normalarg, int errorv,
-dmac_intr_handler_t error, void *errorarg)
+dmac_alloc_channel(device_t self, int ch, const char *name,
+int normalv, dmac_intr_handler_t normal, void *normalarg,
+int errorv,  dmac_intr_handler_t error,  void *errorarg,
+uint8_t dcr, uint8_t ocr)
 {
 	struct intio_softc *intio = device_private(self);
 	struct dmac_softc *dmac = device_private(intio->sc_dmac);
@@ -201,9 +202,8 @@ dmac_alloc_channel(device_t self, int ch
 
 	/* fill the channel status structure by the default values. */
 	strcpy(chan->ch_name, name);
-	chan->ch_dcr = (DMAC_DCR_XRM_CSWH | DMAC_DCR_OTYP_EASYNC |
-			DMAC_DCR_OPS_8BIT);
-	chan->ch_ocr = (DMAC_OCR_SIZE_BYTE | DMAC_OCR_REQG_EXTERNAL);
+	chan->ch_dcr = dcr;
+	chan->ch_ocr = ocr;
 	chan->ch_normalv = normalv;
 	chan->ch_errorv 

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

2017-08-11 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri Aug 11 06:47:35 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: vs.c

Log Message:
Use dmac_prepare_xfer().
>From Y.Sugahara.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/x68k/dev/vs.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.44 src/sys/arch/x68k/dev/vs.c:1.45
--- src/sys/arch/x68k/dev/vs.c:1.44	Sat Aug  5 06:05:37 2017
+++ src/sys/arch/x68k/dev/vs.c	Fri Aug 11 06:47:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.44 2017/08/05 06:05:37 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.45 2017/08/11 06:47:35 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.44 2017/08/05 06:05:37 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.45 2017/08/11 06:47:35 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -490,7 +490,6 @@ vs_start_output(void *hdl, void *block, 
 {
 	struct vs_softc *sc;
 	struct vs_dma *vd;
-	struct dmac_dma_xfer *xf;
 	struct dmac_channel_stat *chan;
 	int hwblksize;
 
@@ -518,17 +517,17 @@ vs_start_output(void *hdl, void *block, 
 	vd = sc->sc_dmas;
 
 	chan = sc->sc_dma_ch;
-	xf = dmac_alloc_xfer(chan, sc->sc_dmat, vd->vd_map);
-	sc->sc_current.xfer = xf;
 	chan->ch_dcr = (DMAC_DCR_XRM_CSWOH | DMAC_DCR_OTYP_EASYNC |
 			DMAC_DCR_OPS_8BIT);
 	chan->ch_ocr = DMAC_OCR_REQG_EXTERNAL;
-	xf->dx_ocr = DMAC_OCR_DIR_MTD;
-	xf->dx_scr = DMAC_SCR_MAC_COUNT_UP | DMAC_SCR_DAC_NO_COUNT;
-	xf->dx_device = sc->sc_addr + MSM6258_DATA * 2 + 1;
 
-	dmac_load_xfer(chan->ch_softc, xf);
-	dmac_start_xfer_offset(chan->ch_softc, xf, 0, sc->sc_current.blksize);
+	sc->sc_current.xfer = dmac_prepare_xfer(chan, sc->sc_dmat, vd->vd_map,
+	DMAC_OCR_DIR_MTD,
+	(DMAC_SCR_MAC_COUNT_UP | DMAC_SCR_DAC_NO_COUNT),
+	sc->sc_addr + MSM6258_DATA * 2 + 1);
+
+	dmac_start_xfer_offset(chan->ch_softc, sc->sc_current.xfer, 0,
+	sc->sc_current.blksize);
 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 2);
 	sc->sc_active = 1;
 
@@ -541,7 +540,6 @@ vs_start_input(void *hdl, void *block, i
 {
 	struct vs_softc *sc;
 	struct vs_dma *vd;
-	struct dmac_dma_xfer *xf;
 	struct dmac_channel_stat *chan;
 	int hwblksize;
 
@@ -567,17 +565,17 @@ vs_start_input(void *hdl, void *block, i
 	vd = sc->sc_dmas;
 
 	chan = sc->sc_dma_ch;
-	xf = dmac_alloc_xfer(chan, sc->sc_dmat, vd->vd_map);
-	sc->sc_current.xfer = xf;
 	chan->ch_dcr = (DMAC_DCR_XRM_CSWOH | DMAC_DCR_OTYP_EASYNC |
 			DMAC_DCR_OPS_8BIT);
 	chan->ch_ocr = DMAC_OCR_REQG_EXTERNAL;
-	xf->dx_ocr = DMAC_OCR_DIR_DTM;
-	xf->dx_scr = DMAC_SCR_MAC_COUNT_UP | DMAC_SCR_DAC_NO_COUNT;
-	xf->dx_device = sc->sc_addr + MSM6258_DATA * 2 + 1;
 
-	dmac_load_xfer(chan->ch_softc, xf);
-	dmac_start_xfer_offset(chan->ch_softc, xf, 0, sc->sc_current.blksize);
+	sc->sc_current.xfer = dmac_prepare_xfer(chan, sc->sc_dmat, vd->vd_map,
+	DMAC_OCR_DIR_DTM,
+	(DMAC_SCR_MAC_COUNT_UP | DMAC_SCR_DAC_NO_COUNT),
+	sc->sc_addr + MSM6258_DATA * 2 + 1);
+
+	dmac_start_xfer_offset(chan->ch_softc, sc->sc_current.xfer, 0,
+	sc->sc_current.blksize);
 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 4);
 	sc->sc_active = 1;
 



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

2017-08-05 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug  5 06:05:37 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: vs.c vsvar.h

Log Message:
Merge prate and rrate.  These can not be separated.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x68k/dev/vs.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x68k/dev/vsvar.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.43 src/sys/arch/x68k/dev/vs.c:1.44
--- src/sys/arch/x68k/dev/vs.c:1.43	Sat Aug  5 05:53:27 2017
+++ src/sys/arch/x68k/dev/vs.c	Sat Aug  5 06:05:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.43 2017/08/05 05:53:27 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.44 2017/08/05 06:05:37 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.43 2017/08/05 05:53:27 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.44 2017/08/05 06:05:37 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -404,8 +404,7 @@ vs_set_params(void *hdl, int setmode, in
 		return EINVAL;
 	}
 
-	sc->sc_current.prate = rate;
-	sc->sc_current.rrate = rate;
+	sc->sc_current.rate = rate;
 
 	/* pfil and rfil are independent even if !AUDIO_PROP_INDEPENDENT */
 
@@ -449,7 +448,7 @@ vs_init_output(void *hdl, void *buffer, 
 	sc = hdl;
 
 	/* Set rate and pan */
-	vs_set_sr(sc, sc->sc_current.prate);
+	vs_set_sr(sc, sc->sc_current.rate);
 	vs_set_po(sc, VS_PANOUT_LR);
 
 	return 0;
@@ -464,7 +463,7 @@ vs_init_input(void *hdl, void *buffer, i
 	sc = hdl;
 
 	/* Set rate */
-	vs_set_sr(sc, sc->sc_current.rrate);
+	vs_set_sr(sc, sc->sc_current.rate);
 
 	return 0;
 }

Index: src/sys/arch/x68k/dev/vsvar.h
diff -u src/sys/arch/x68k/dev/vsvar.h:1.13 src/sys/arch/x68k/dev/vsvar.h:1.14
--- src/sys/arch/x68k/dev/vsvar.h:1.13	Sat Aug  5 05:53:27 2017
+++ src/sys/arch/x68k/dev/vsvar.h	Sat Aug  5 06:05:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsvar.h,v 1.13 2017/08/05 05:53:27 isaki Exp $	*/
+/*	$NetBSD: vsvar.h,v 1.14 2017/08/05 06:05:37 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -90,7 +90,7 @@ struct vs_softc {
 
 	struct {
 		struct dmac_dma_xfer *xfer;
-		int prate, rrate;
+		int rate;
 		int precision;
 		int bufsize, blksize;
 		int dmap;



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

2017-08-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Aug  5 05:22:55 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: vs.c

Log Message:
Remove temporary VS_USE_PREC8 option.
vs(4) now supports slinear16be and slinear8 (but now work yet).


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/x68k/dev/vs.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.41 src/sys/arch/x68k/dev/vs.c:1.42
--- src/sys/arch/x68k/dev/vs.c:1.41	Mon Jul 31 14:53:08 2017
+++ src/sys/arch/x68k/dev/vs.c	Sat Aug  5 05:22:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.41 2017/07/31 14:53:08 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.42 2017/08/05 05:22:55 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.41 2017/07/31 14:53:08 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.42 2017/08/05 05:22:55 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -56,7 +56,6 @@ __KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.41 
 
 #include 
 
-//#define VS_USE_PREC8 /* for debugging */
 #ifdef VS_DEBUG
 #define DPRINTF(y,x)	if (vs_debug >= (y)) printf x
 static int vs_debug;
@@ -330,15 +329,16 @@ vs_query_encoding(void *hdl, struct audi
 	DPRINTF(1, ("vs_query_encoding\n"));
 
 	if (fp->index == 0) {
-#if defined(VS_USE_PREC8)
 		strcpy(fp->name, AudioEslinear);
 		fp->encoding = AUDIO_ENCODING_SLINEAR;
 		fp->precision = 8;
-#else
+		fp->flags = 0;
+		return 0;
+	}
+	if (fp->index == 1) {
 		strcpy(fp->name, AudioEslinear_be);
 		fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
 		fp->precision = 16;
-#endif
 		fp->flags = 0;
 		return 0;
 	}
@@ -379,6 +379,8 @@ vs_set_params(void *hdl, int setmode, in
 	stream_filter_list_t *pfil, stream_filter_list_t *rfil)
 {
 	struct vs_softc *sc;
+	stream_filter_factory_t *pconv;
+	stream_filter_factory_t *rconv;
 	int rate;
 
 	sc = hdl;
@@ -400,11 +402,14 @@ vs_set_params(void *hdl, int setmode, in
 		return EINVAL;
 	}
 
-#if defined(VS_USE_PREC8)
-	if (play->precision != 8 || play->encoding != AUDIO_ENCODING_SLINEAR) {
-#else
-	if (play->precision != 16 || play->encoding != AUDIO_ENCODING_SLINEAR_BE) {
-#endif
+	if (play->precision == 8 && play->encoding == AUDIO_ENCODING_SLINEAR) {
+		pconv = msm6258_linear8_to_adpcm;
+		rconv = msm6258_adpcm_to_linear8;
+	} else if (play->precision == 16 &&
+	   play->encoding == AUDIO_ENCODING_SLINEAR_BE) {
+		pconv = msm6258_slinear16_to_adpcm;
+		rconv = msm6258_adpcm_to_slinear16;
+	} else {
 		DPRINTF(1, ("prec/enc not matched\n"));
 		return EINVAL;
 	}
@@ -419,22 +424,14 @@ vs_set_params(void *hdl, int setmode, in
 		play->encoding = AUDIO_ENCODING_ADPCM;
 		play->validbits = 4;
 		play->precision = 4;
-#if defined(VS_USE_PREC8)
-		pfil->append(pfil, msm6258_linear8_to_adpcm, play);
-#else
-		pfil->append(pfil, msm6258_slinear16_to_adpcm, play);
-#endif
+		pfil->append(pfil, pconv, play);
 	}
 	if ((setmode & AUMODE_RECORD) != 0) {
 		rfil->append(rfil, null_filter, rec);
 		rec->encoding = AUDIO_ENCODING_ADPCM;
 		rec->validbits = 4;
 		rec->precision = 4;
-#if defined(VS_USE_PREC8)
-		rfil->append(rfil, msm6258_adpcm_to_linear8, rec);
-#else
-		rfil->append(rfil, msm6258_adpcm_to_slinear16, rec);
-#endif
+		rfil->append(rfil, rconv, rec);
 	}
 
 	DPRINTF(1, ("accepted\n"));



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

2017-07-31 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Mon Jul 31 14:53:08 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: vs.c

Log Message:
Update confused vs_set_params().
play and rec are identical but pfil and rfil are independent.
XXX I introduce VS_USE_PREC8 option for debugging purposes
temporarily.  I'll remove it if the problem is solved.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x68k/dev/vs.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.40 src/sys/arch/x68k/dev/vs.c:1.41
--- src/sys/arch/x68k/dev/vs.c:1.40	Sat Jul 29 07:30:39 2017
+++ src/sys/arch/x68k/dev/vs.c	Mon Jul 31 14:53:08 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.40 2017/07/29 07:30:39 nat Exp $	*/
+/*	$NetBSD: vs.c,v 1.41 2017/07/31 14:53:08 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.40 2017/07/29 07:30:39 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.41 2017/07/31 14:53:08 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -56,6 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.40 
 
 #include 
 
+//#define VS_USE_PREC8 /* for debugging */
 #ifdef VS_DEBUG
 #define DPRINTF(y,x)	if (vs_debug >= (y)) printf x
 static int vs_debug;
@@ -329,9 +330,15 @@ vs_query_encoding(void *hdl, struct audi
 	DPRINTF(1, ("vs_query_encoding\n"));
 
 	if (fp->index == 0) {
+#if defined(VS_USE_PREC8)
+		strcpy(fp->name, AudioEslinear);
+		fp->encoding = AUDIO_ENCODING_SLINEAR;
+		fp->precision = 8;
+#else
 		strcpy(fp->name, AudioEslinear_be);
 		fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
 		fp->precision = 16;
+#endif
 		fp->flags = 0;
 		return 0;
 	}
@@ -380,6 +387,8 @@ vs_set_params(void *hdl, int setmode, in
 		setmode, play->encoding, play->sample_rate,
 		play->precision, play->channels));
 
+	/* *play and *rec are identical because !AUDIO_PROP_INDEPENDENT */
+
 	if (play->channels != 1) {
 		DPRINTF(1, ("channels not matched\n"));
 		return EINVAL;
@@ -391,33 +400,42 @@ vs_set_params(void *hdl, int setmode, in
 		return EINVAL;
 	}
 
-	if (play->encoding != AUDIO_ENCODING_SLINEAR_BE) {
-		DPRINTF(1, ("encoding not matched\n"));
-		return EINVAL;
-	}
-	if (play->precision != 16) {
-		DPRINTF(1, ("precision not matched\n"));
+#if defined(VS_USE_PREC8)
+	if (play->precision != 8 || play->encoding != AUDIO_ENCODING_SLINEAR) {
+#else
+	if (play->precision != 16 || play->encoding != AUDIO_ENCODING_SLINEAR_BE) {
+#endif
+		DPRINTF(1, ("prec/enc not matched\n"));
 		return EINVAL;
 	}
 
-	play->encoding = AUDIO_ENCODING_ADPCM;
-	play->validbits = 4;
-	play->precision = 4;
-
-	pfil->prepend(pfil, msm6258_slinear16_to_adpcm, play);
-	rfil->prepend(rfil, msm6258_adpcm_to_slinear16, play);
-
-	play->validbits = 16;
-	play->precision = 16;
-
-	pfil->prepend(pfil, null_filter, play);
-	rfil->prepend(rfil, null_filter, play);
-
 	sc->sc_current.prate = rate;
 	sc->sc_current.rrate = rate;
 
-	/* copy to rec because it's !AUDIO_PROP_INDEPENDENT */
-	*rec = *play;
+	/* pfil and rfil are independent even if !AUDIO_PROP_INDEPENDENT */
+
+	if ((setmode & AUMODE_PLAY) != 0) {
+		pfil->append(pfil, null_filter, play);
+		play->encoding = AUDIO_ENCODING_ADPCM;
+		play->validbits = 4;
+		play->precision = 4;
+#if defined(VS_USE_PREC8)
+		pfil->append(pfil, msm6258_linear8_to_adpcm, play);
+#else
+		pfil->append(pfil, msm6258_slinear16_to_adpcm, play);
+#endif
+	}
+	if ((setmode & AUMODE_RECORD) != 0) {
+		rfil->append(rfil, null_filter, rec);
+		rec->encoding = AUDIO_ENCODING_ADPCM;
+		rec->validbits = 4;
+		rec->precision = 4;
+#if defined(VS_USE_PREC8)
+		rfil->append(rfil, msm6258_adpcm_to_linear8, rec);
+#else
+		rfil->append(rfil, msm6258_adpcm_to_slinear16, rec);
+#endif
+	}
 
 	DPRINTF(1, ("accepted\n"));
 	return 0;



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

2017-07-29 Thread Nathanial Sloss
Module Name:src
Committed By:   nat
Date:   Sat Jul 29 07:30:39 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: vs.c

Log Message:
Audio vchan auto config works again due to the use of a null_filter.

Tested and confirmed working by isaki@.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/x68k/dev/vs.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.39 src/sys/arch/x68k/dev/vs.c:1.40
--- src/sys/arch/x68k/dev/vs.c:1.39	Sun Jul  9 12:49:26 2017
+++ src/sys/arch/x68k/dev/vs.c	Sat Jul 29 07:30:39 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.39 2017/07/09 12:49:26 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.40 2017/07/29 07:30:39 nat Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.39 2017/07/09 12:49:26 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.40 2017/07/29 07:30:39 nat Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -160,6 +160,8 @@ struct {
 
 #define NUM_RATE	(sizeof(vs_l2r)/sizeof(vs_l2r[0]))
 
+extern stream_filter_factory_t null_filter;
+
 static int
 vs_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -405,6 +407,12 @@ vs_set_params(void *hdl, int setmode, in
 	pfil->prepend(pfil, msm6258_slinear16_to_adpcm, play);
 	rfil->prepend(rfil, msm6258_adpcm_to_slinear16, play);
 
+	play->validbits = 16;
+	play->precision = 16;
+
+	pfil->prepend(pfil, null_filter, play);
+	rfil->prepend(rfil, null_filter, play);
+
 	sc->sc_current.prate = rate;
 	sc->sc_current.rrate = rate;
 



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

2017-07-09 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Jul  9 12:49:26 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: vs.c

Log Message:
Catch up vs_set_params() to recent MI audio (after in-kernel mixer).
Before that, MD part had to support all encodings I'd like to support,
but currently it's no longer necessary.  The hardware is
4bit/1ch/15.6kHz ADPCM but it behaves as 16bit/1ch/16.0kHz PCM.

For audio.c < 1.362, the device attach succeeded and playback is
still working.
For audio.c >= 1.363, the device attach fails again.
It does not work yet but I commit it for milestone.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x68k/dev/vs.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.38 src/sys/arch/x68k/dev/vs.c:1.39
--- src/sys/arch/x68k/dev/vs.c:1.38	Sun Jun 25 06:26:40 2017
+++ src/sys/arch/x68k/dev/vs.c	Sun Jul  9 12:49:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.38 2017/06/25 06:26:40 isaki Exp $	*/
+/*	$NetBSD: vs.c,v 1.39 2017/07/09 12:49:26 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.38 2017/06/25 06:26:40 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.39 2017/07/09 12:49:26 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -160,19 +160,6 @@ struct {
 
 #define NUM_RATE	(sizeof(vs_l2r)/sizeof(vs_l2r[0]))
 
-struct {
-	const char *name;
-	int	encoding;
-	int	precision;
-} vs_encodings[] = {
-	{AudioEadpcm,  AUDIO_ENCODING_ADPCM,   4},
-	{AudioEslinear,AUDIO_ENCODING_SLINEAR, 8},
-	{AudioEulinear,AUDIO_ENCODING_ULINEAR, 8},
-	{AudioEmulaw,  AUDIO_ENCODING_ULAW,	   8},
-	{AudioEslinear_be, AUDIO_ENCODING_SLINEAR_BE, 16},
-	{AudioEslinear_le, AUDIO_ENCODING_SLINEAR_LE, 16},
-};
-
 static int
 vs_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -338,17 +325,15 @@ vs_query_encoding(void *hdl, struct audi
 {
 
 	DPRINTF(1, ("vs_query_encoding\n"));
-	if (fp->index >= sizeof(vs_encodings) / sizeof(vs_encodings[0]))
-		return EINVAL;
 
-	strcpy(fp->name, vs_encodings[fp->index].name);
-	fp->encoding  = vs_encodings[fp->index].encoding;
-	fp->precision = vs_encodings[fp->index].precision;
-	if (fp->encoding == AUDIO_ENCODING_ADPCM)
+	if (fp->index == 0) {
+		strcpy(fp->name, AudioEslinear_be);
+		fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
+		fp->precision = 16;
 		fp->flags = 0;
-	else
-		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
-	return 0;
+		return 0;
+	}
+	return EINVAL;
 }
 
 static int
@@ -385,95 +370,48 @@ vs_set_params(void *hdl, int setmode, in
 	stream_filter_list_t *pfil, stream_filter_list_t *rfil)
 {
 	struct vs_softc *sc;
-	struct audio_params *p;
-	int mode;
 	int rate;
-	audio_params_t hw;
-	int matched;
-
-	DPRINTF(1, ("vs_set_params: setmode=%d, usemode=%d\n",
-		setmode, usemode));
 
 	sc = hdl;
-	/* set first record info, then play info */
-	for (mode = AUMODE_RECORD; mode != -1;
-	 mode = (mode == AUMODE_RECORD) ? AUMODE_PLAY : -1) {
-		if ((setmode & mode) == 0)
-			continue;
-
-		p = (mode == AUMODE_PLAY) ? play : rec;
-
-		if (p->channels != 1)
-			return EINVAL;
-
-		rate = p->sample_rate;
-		hw = *p;
-		hw.encoding = AUDIO_ENCODING_ADPCM;
-		hw.precision = hw.validbits = 4;
-		DPRINTF(1, ("vs_set_params: encoding=%d, precision=%d\n",
-			p->encoding, p->precision));
-		matched = 0;
-		switch (p->precision) {
-		case 4:
-			if (p->encoding == AUDIO_ENCODING_ADPCM)
-matched = 1;
-			break;
-		case 8:
-			switch (p->encoding) {
-			case AUDIO_ENCODING_ULAW:
-matched = 1;
-hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
-hw.precision = hw.validbits = 8;
-pfil->prepend(pfil, mulaw_to_linear8, );
-hw.encoding = AUDIO_ENCODING_ADPCM;
-hw.precision = hw.validbits = 4;
-pfil->prepend(pfil, msm6258_linear8_to_adpcm, );
-rfil->append(rfil, msm6258_adpcm_to_linear8, );
-hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
-hw.precision = hw.validbits = 8;
-rfil->append(rfil, linear8_to_mulaw, );
-break;
-			case AUDIO_ENCODING_SLINEAR:
-			case AUDIO_ENCODING_SLINEAR_LE:
-			case AUDIO_ENCODING_SLINEAR_BE:
-			case AUDIO_ENCODING_ULINEAR:
-			case AUDIO_ENCODING_ULINEAR_LE:
-			case AUDIO_ENCODING_ULINEAR_BE:
-matched = 1;
-pfil->append(pfil, msm6258_linear8_to_adpcm, );
-rfil->append(rfil, msm6258_adpcm_to_linear8, );
-break;
-			}
-			break;
-		case 16:
-			switch (p->encoding) {
-			case AUDIO_ENCODING_SLINEAR_LE:
-			case AUDIO_ENCODING_SLINEAR_BE:
-matched = 1;
-pfil->append(pfil, msm6258_slinear16_to_adpcm, );
-rfil->append(rfil, msm6258_adpcm_to_slinear16, );
-break;
-			}
-			break;
-		}
-		if (matched == 0) {
-			DPRINTF(1, ("vs_set_params: mode=%d, encoding=%d\n",
-mode, p->encoding));
-			return EINVAL;
-		}
 
-		DPRINTF(1, ("vs_set_params: rate=%d -> ", 

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

2017-06-25 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Jun 25 06:26:40 UTC 2017

Modified Files:
src/sys/arch/x68k/dev: vs.c vsvar.h

Log Message:
Avoid panic when the device is closed when not playing.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/x68k/dev/vs.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x68k/dev/vsvar.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.37 src/sys/arch/x68k/dev/vs.c:1.38
--- src/sys/arch/x68k/dev/vs.c:1.37	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x68k/dev/vs.c	Sun Jun 25 06:26:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vs.c,v 1.37 2017/06/01 02:45:08 chs Exp $	*/
+/*	$NetBSD: vs.c,v 1.38 2017/06/25 06:26:40 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.37 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.38 2017/06/25 06:26:40 isaki Exp $");
 
 #include "audio.h"
 #include "vs.h"
@@ -232,6 +232,7 @@ vs_attach(device_t parent, device_t self
 	sc->sc_hw_if = _hw_if;
 	sc->sc_addr = (void *) ia->ia_addr;
 	sc->sc_dmas = NULL;
+	sc->sc_active = 0;
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE);
 	mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
 
@@ -542,6 +543,7 @@ vs_trigger_output(void *hdl, void *start
 	dmac_load_xfer(chan->ch_softc, xf);
 	dmac_start_xfer_offset(chan->ch_softc, xf, 0, sc->sc_current.blksize);
 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 2);
+	sc->sc_active = 1;
 
 	return 0;
 }
@@ -589,6 +591,7 @@ vs_trigger_input(void *hdl, void *start,
 	dmac_load_xfer(chan->ch_softc, xf);
 	dmac_start_xfer_offset(chan->ch_softc, xf, 0, sc->sc_current.blksize);
 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 4);
+	sc->sc_active = 1;
 
 	return 0;
 }
@@ -600,9 +603,12 @@ vs_halt_output(void *hdl)
 
 	DPRINTF(1, ("vs_halt_output\n"));
 	sc = hdl;
-	/* stop ADPCM play */
-	dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer);
-	bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 1);
+	if (sc->sc_active) {
+		/* stop ADPCM play */
+		dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer);
+		bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 1);
+		sc->sc_active = 0;
+	}
 
 	return 0;
 }
@@ -614,9 +620,12 @@ vs_halt_input(void *hdl)
 
 	DPRINTF(1, ("vs_halt_input\n"));
 	sc = hdl;
-	/* stop ADPCM recoding */
-	dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer);
-	bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 1);
+	if (sc->sc_active) {
+		/* stop ADPCM recoding */
+		dmac_abort_xfer(sc->sc_dma_ch->ch_softc, sc->sc_current.xfer);
+		bus_space_write_1(sc->sc_iot, sc->sc_ioh, MSM6258_STAT, 1);
+		sc->sc_active = 0;
+	}
 
 	return 0;
 }

Index: src/sys/arch/x68k/dev/vsvar.h
diff -u src/sys/arch/x68k/dev/vsvar.h:1.11 src/sys/arch/x68k/dev/vsvar.h:1.12
--- src/sys/arch/x68k/dev/vsvar.h:1.11	Wed Nov 23 23:07:30 2011
+++ src/sys/arch/x68k/dev/vsvar.h	Sun Jun 25 06:26:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsvar.h,v 1.11 2011/11/23 23:07:30 jmcneill Exp $	*/
+/*	$NetBSD: vsvar.h,v 1.12 2017/06/25 06:26:40 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -94,6 +94,7 @@ struct vs_softc {
 		int bufsize, blksize;
 		int dmap;
 	} sc_current;
+	int sc_active;
 
 	const struct audio_hw_if *sc_hw_if;
 



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

2017-01-12 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Jan 12 14:24:53 UTC 2017

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

Log Message:
Fix the possibility of off-by-one on the grammer.  Reported by coypu.
Currently it never happens because type is (minor number % 7) and
the arraycount of fd_types[] is 8.  I.e., it is a dead code...
However, when the capacity of the FDTYPE() changes or the arraycount
of fd_types[] changes, this correction will be effective.


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

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

Modified files:

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.118 src/sys/arch/x68k/dev/fd.c:1.119
--- src/sys/arch/x68k/dev/fd.c:1.118	Sat Jul 11 10:32:46 2015
+++ src/sys/arch/x68k/dev/fd.c	Thu Jan 12 14:24:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.118 2015/07/11 10:32:46 kamil Exp $	*/
+/*	$NetBSD: fd.c,v 1.119 2017/01/12 14:24:53 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.118 2015/07/11 10:32:46 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.119 2017/01/12 14:24:53 isaki Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m68k_arch.h"
@@ -672,7 +672,7 @@ fd_dev_to_type(struct fd_softc *fd, dev_
 {
 	size_t type = FDTYPE(dev);
 
-	if (type > __arraycount(fd_types))
+	if (type >= __arraycount(fd_types))
 		return NULL;
 	return _types[type];
 }



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

2016-08-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri Aug  5 05:32:02 UTC 2016

Modified Files:
src/sys/arch/x68k/dev: zs.c

Log Message:
Revert a part of previous commit.
If addr is not specified as "zsc0 at intio0" in kernel config
(though it's not right of course), it will cause a panic.
intio_map_allocate_region() should be called after address check.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x68k/dev/zs.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/x68k/dev/zs.c
diff -u src/sys/arch/x68k/dev/zs.c:1.43 src/sys/arch/x68k/dev/zs.c:1.44
--- src/sys/arch/x68k/dev/zs.c:1.43	Tue May 31 03:22:30 2016
+++ src/sys/arch/x68k/dev/zs.c	Fri Aug  5 05:32:02 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: zs.c,v 1.43 2016/05/31 03:22:30 dholland Exp $	*/
+/*	$NetBSD: zs.c,v 1.44 2016/08/05 05:32:02 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1998 Minoura Makoto
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.43 2016/05/31 03:22:30 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.44 2016/08/05 05:32:02 isaki Exp $");
 
 #include 
 #include 
@@ -148,10 +148,6 @@ zs_match(device_t parent, cfdata_t cf, v
 	if (strcmp(ia->ia_name, "zsc") != 0)
 		return 0;
 
-	ia->ia_size = 8;
-	if (intio_map_allocate_region(parent, ia, INTIO_MAP_TESTONLY))
-		return 0;
-
 	for (i = 0; i < ZS_MAXDEV; i++)
 		if (zsaddr == (void *)zs_physaddr[i]) /* XXX */
 			break;
@@ -160,6 +156,10 @@ zs_match(device_t parent, cfdata_t cf, v
 		return 0;
 	}
 
+	ia->ia_size = 8;
+	if (intio_map_allocate_region(parent, ia, INTIO_MAP_TESTONLY))
+		return 0;
+
 	if (badaddr((void *)IIOV(zsaddr)))
 		return 0;
 



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

2016-05-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue May 31 03:22:30 UTC 2016

Modified Files:
src/sys/arch/x68k/dev: zs.c

Log Message:
PR 50759 David Binderman: fix out of bounds array access.

If we don't find one of the expected device addresses, reject the
match, but do it by checking whether the loop matched something rather
than by testing an array entry that might be one past the end.

Note: I have also moved the test to be with the loop; since the call
to intio_map_allocate_region had gotten placed in between them, I've
moved it to go before rather than after them as (a) it doesn't
interact with the loop itself and (b) this seems like the best choice
given the history as it was deliberately added before the original
test.

I have not tried running this, not having an x68k, but as best I can
tell by reading the intio code it seems like it should be harmless
even if it's not really correct.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/x68k/dev/zs.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/x68k/dev/zs.c
diff -u src/sys/arch/x68k/dev/zs.c:1.42 src/sys/arch/x68k/dev/zs.c:1.43
--- src/sys/arch/x68k/dev/zs.c:1.42	Wed Mar 26 08:17:32 2014
+++ src/sys/arch/x68k/dev/zs.c	Tue May 31 03:22:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: zs.c,v 1.42 2014/03/26 08:17:32 christos Exp $	*/
+/*	$NetBSD: zs.c,v 1.43 2016/05/31 03:22:30 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1998 Minoura Makoto
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.42 2014/03/26 08:17:32 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.43 2016/05/31 03:22:30 dholland Exp $");
 
 #include 
 #include 
@@ -148,16 +148,18 @@ zs_match(device_t parent, cfdata_t cf, v
 	if (strcmp(ia->ia_name, "zsc") != 0)
 		return 0;
 
-	for (i = 0; i < ZS_MAXDEV; i++)
-		if (zsaddr == (void *)zs_physaddr[i]) /* XXX */
-			break;
-
 	ia->ia_size = 8;
 	if (intio_map_allocate_region(parent, ia, INTIO_MAP_TESTONLY))
 		return 0;
 
-	if (zsaddr != (void *)zs_physaddr[i])
+	for (i = 0; i < ZS_MAXDEV; i++)
+		if (zsaddr == (void *)zs_physaddr[i]) /* XXX */
+			break;
+	if (i == ZS_MAXDEV) {
+		/* not a recognized address */
 		return 0;
+	}
+
 	if (badaddr((void *)IIOV(zsaddr)))
 		return 0;
 



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

2016-05-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue May 31 03:12:49 UTC 2016

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

Log Message:
fix flagrantly wrong indent


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/x68k/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/x68k/dev/intio.c
diff -u src/sys/arch/x68k/dev/intio.c:1.44 src/sys/arch/x68k/dev/intio.c:1.45
--- src/sys/arch/x68k/dev/intio.c:1.44	Fri Feb 26 18:19:16 2016
+++ src/sys/arch/x68k/dev/intio.c	Tue May 31 03:12:49 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: intio.c,v 1.44 2016/02/26 18:19:16 christos Exp $	*/
+/*	$NetBSD: intio.c,v 1.45 2016/05/31 03:12:49 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.44 2016/02/26 18:19:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.45 2016/05/31 03:12:49 dholland Exp $");
 
 #include 
 #include 
@@ -236,7 +236,7 @@ intio_map_allocate_region(device_t paren
 #endif
 	if (r == 0) {
 		if (flag != INTIO_MAP_ALLOCATE)
-		extent_free(map, ia->ia_addr, ia->ia_size, 0);
+			extent_free(map, ia->ia_addr, ia->ia_size, 0);
 		return 0;
 	}
 



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

2016-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Feb 26 18:19:16 UTC 2016

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

Log Message:
PR/50859: David Binderman: Remove redundant code.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x68k/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/x68k/dev/intio.c
diff -u src/sys/arch/x68k/dev/intio.c:1.43 src/sys/arch/x68k/dev/intio.c:1.44
--- src/sys/arch/x68k/dev/intio.c:1.43	Fri Jan 27 13:53:06 2012
+++ src/sys/arch/x68k/dev/intio.c	Fri Feb 26 13:19:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: intio.c,v 1.43 2012/01/27 18:53:06 para Exp $	*/
+/*	$NetBSD: intio.c,v 1.44 2016/02/26 18:19:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.43 2012/01/27 18:53:06 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.44 2016/02/26 18:19:16 christos Exp $");
 
 #include 
 #include 
@@ -514,8 +514,7 @@ _intio_bus_dmamap_load(bus_dma_tag_t t, 
 	 * and we can bounce, we will.
 	 */
 	error = x68k_bus_dmamap_load(t, map, buf, buflen, p, flags);
-	if (error == 0 ||
-	(error != 0 && (cookie->id_flags & ID_MIGHT_NEED_BOUNCE) == 0))
+	if (error == 0 || (cookie->id_flags & ID_MIGHT_NEED_BOUNCE) == 0)
 		return (error);
 
 	/*
@@ -580,8 +579,7 @@ _intio_bus_dmamap_load_mbuf(bus_dma_tag_
 	 * and we can bounce, we will.
 	 */
 	error = x68k_bus_dmamap_load_mbuf(t, map, m0, flags);
-	if (error == 0 ||
-	(error != 0 && (cookie->id_flags & ID_MIGHT_NEED_BOUNCE) == 0))
+	if (error == 0 || (cookie->id_flags & ID_MIGHT_NEED_BOUNCE) == 0)
 		return (error);
 
 	/*



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

2015-08-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 22 14:11:19 UTC 2015

Modified Files:
src/sys/arch/x68k/dev: opmbell.c

Log Message:
fix include filename.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x68k/dev/opmbell.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/x68k/dev/opmbell.c
diff -u src/sys/arch/x68k/dev/opmbell.c:1.26 src/sys/arch/x68k/dev/opmbell.c:1.27
--- src/sys/arch/x68k/dev/opmbell.c:1.26	Thu Aug 20 10:40:17 2015
+++ src/sys/arch/x68k/dev/opmbell.c	Sat Aug 22 10:11:19 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: opmbell.c,v 1.26 2015/08/20 14:40:17 christos Exp $	*/
+/*	$NetBSD: opmbell.c,v 1.27 2015/08/22 14:11:19 christos Exp $	*/
 
 /*
  * Copyright (c) 1995 MINOURA Makoto, Takuya Harakawa.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: opmbell.c,v 1.26 2015/08/20 14:40:17 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: opmbell.c,v 1.27 2015/08/22 14:11:19 christos Exp $);
 
 #include bell.h
 #if NBELL  0
@@ -65,7 +65,7 @@ __KERNEL_RCSID(0, $NetBSD: opmbell.c,v 
 
 #include x68k/dev/opmvar.h
 
-#include ioconfig.h
+#include ioconf.h
 
 /* In opm.c. */
 void opm_set_volume(int, int);



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

2015-01-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan  2 15:53:26 UTC 2015

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

Log Message:
restore part decl.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sys/arch/x68k/dev/fd.c

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

Modified files:

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.113 src/sys/arch/x68k/dev/fd.c:1.114
--- src/sys/arch/x68k/dev/fd.c:1.113	Thu Jan  1 12:48:56 2015
+++ src/sys/arch/x68k/dev/fd.c	Fri Jan  2 10:53:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.113 2015/01/01 17:48:56 christos Exp $	*/
+/*	$NetBSD: fd.c,v 1.114 2015/01/02 15:53:25 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.113 2015/01/01 17:48:56 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.114 2015/01/02 15:53:25 christos Exp $);
 
 #include opt_ddb.h
 #include opt_m68k_arch.h
@@ -1608,11 +1608,12 @@ fdioctl(dev_t dev, u_long cmd, void *add
 	struct fdformat_parms *form_parms;
 	struct fdformat_cmd *form_cmd;
 	struct ne7_fd_formb *fd_formb;
+	int part = DISKPART(dev);
 	struct disklabel buffer;
 	int error;
 	unsigned int scratch;
 	int il[FD_MAX_NSEC + 1];
-	int i, j, error;
+	int i, j;
 
 	error = disk_ioctl(fd-sc_dk, dev, cmd, addr, flag, l);
 	if (error != EPASSTHROUGH)



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

2015-01-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan  1 17:48:56 UTC 2015

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

Log Message:
declare error


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/arch/x68k/dev/fd.c

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

Modified files:

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.112 src/sys/arch/x68k/dev/fd.c:1.113
--- src/sys/arch/x68k/dev/fd.c:1.112	Wed Dec 31 14:52:05 2014
+++ src/sys/arch/x68k/dev/fd.c	Thu Jan  1 12:48:56 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.112 2014/12/31 19:52:05 christos Exp $	*/
+/*	$NetBSD: fd.c,v 1.113 2015/01/01 17:48:56 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.112 2014/12/31 19:52:05 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.113 2015/01/01 17:48:56 christos Exp $);
 
 #include opt_ddb.h
 #include opt_m68k_arch.h
@@ -1612,7 +1612,7 @@ fdioctl(dev_t dev, u_long cmd, void *add
 	int error;
 	unsigned int scratch;
 	int il[FD_MAX_NSEC + 1];
-	int i, j;
+	int i, j, error;
 
 	error = disk_ioctl(fd-sc_dk, dev, cmd, addr, flag, l);
 	if (error != EPASSTHROUGH)



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

2014-03-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 26 08:17:32 UTC 2014

Modified Files:
src/sys/arch/x68k/dev: zs.c

Log Message:
fix unused, missing splx.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/x68k/dev/zs.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/x68k/dev/zs.c
diff -u src/sys/arch/x68k/dev/zs.c:1.41 src/sys/arch/x68k/dev/zs.c:1.42
--- src/sys/arch/x68k/dev/zs.c:1.41	Sun May  1 12:19:13 2011
+++ src/sys/arch/x68k/dev/zs.c	Wed Mar 26 04:17:32 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: zs.c,v 1.41 2011/05/01 16:19:13 tsutsui Exp $	*/
+/*	$NetBSD: zs.c,v 1.42 2014/03/26 08:17:32 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998 Minoura Makoto
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: zs.c,v 1.41 2011/05/01 16:19:13 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: zs.c,v 1.42 2014/03/26 08:17:32 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -175,12 +175,12 @@ zs_attach(device_t parent, device_t self
 	struct zsc_attach_args zsc_args;
 	volatile struct zschan *zc;
 	struct zs_chanstate *cs;
-	int r, s, zs_unit, channel;
+	int r __diagused;
+	int s, channel;
 
 	zsc-zsc_dev = self;
 	aprint_normal(\n);
 
-	zs_unit = device_unit(self);
 	zsc-zsc_addr = (void *)ia-ia_addr;
 
 	ia-ia_size = 8;
@@ -325,6 +325,7 @@ zshard(void *arg)
 	/* We are at splzs here, so no need to lock. */
 	if (zsc-zsc_cs[0]-cs_softreq || zsc-zsc_cs[1]-cs_softreq)
 		softint_schedule(zsc-zsc_softintr_cookie);
+	splx(s);
 
 	return (rval);
 }



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

2014-03-21 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Mar 21 16:58:54 UTC 2014

Modified Files:
src/sys/arch/x68k/dev: event.c event_var.h kbd.c ms.c

Log Message:
Replace tsleep(9)/wakeup(9) with condvar(9) as practice.

Also replace malloc(9) with kmem_alloc(9).
Pevent more possible races.

Tested on both console and Xserver on X68030.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x68k/dev/event.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x68k/dev/event_var.h
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x68k/dev/kbd.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/x68k/dev/ms.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/x68k/dev/event.c
diff -u src/sys/arch/x68k/dev/event.c:1.13 src/sys/arch/x68k/dev/event.c:1.14
--- src/sys/arch/x68k/dev/event.c:1.13	Sat Mar  1 14:16:50 2008
+++ src/sys/arch/x68k/dev/event.c	Fri Mar 21 16:58:54 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: event.c,v 1.13 2008/03/01 14:16:50 rmind Exp $ */
+/*	$NetBSD: event.c,v 1.14 2014/03/21 16:58:54 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,16 +45,18 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: event.c,v 1.13 2008/03/01 14:16:50 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: event.c,v 1.14 2014/03/21 16:58:54 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/fcntl.h
-#include sys/malloc.h
+#include sys/kmem.h
 #include sys/proc.h
 #include sys/systm.h
 #include sys/vnode.h
 #include sys/select.h
 #include sys/poll.h
+#include sys/mutex.h
+#include sys/condvar.h
 
 #include machine/vuid_event.h
 #include x68k/dev/event_var.h
@@ -63,13 +65,15 @@ __KERNEL_RCSID(0, $NetBSD: event.c,v 1.
  * Initialize a firm_event queue.
  */
 void
-ev_init(struct evvar *ev)
+ev_init(struct evvar *ev, const char *name, kmutex_t *mtx)
 {
 
 	ev-ev_get = ev-ev_put = 0;
-	ev-ev_q = malloc((u_long)EV_QSIZE * sizeof(struct firm_event),
-	M_DEVBUF, M_WAITOK|M_ZERO);
+	ev-ev_q = kmem_zalloc((size_t)EV_QSIZE * sizeof(struct firm_event),
+	KM_SLEEP);
 	selinit(ev-ev_sel);
+	ev-ev_lock = mtx;
+	cv_init(ev-ev_cv, name);
 }
 
 /*
@@ -79,8 +83,9 @@ void
 ev_fini(struct evvar *ev)
 {
 
+	cv_destroy(ev-ev_cv);
 	seldestroy(ev-ev_sel);
-	free(ev-ev_q, M_DEVBUF);
+	kmem_free(ev-ev_q, (size_t)EV_QSIZE * sizeof(struct firm_event));
 }
 
 /*
@@ -90,23 +95,23 @@ ev_fini(struct evvar *ev)
 int
 ev_read(struct evvar *ev, struct uio *uio, int flags)
 {
-	int s, n, cnt, error;
+	int n, cnt, put, error;
 
 	/*
 	 * Make sure we can return at least 1.
 	 */
 	if (uio-uio_resid  sizeof(struct firm_event))
 		return (EMSGSIZE);	/* ??? */
-	s = splev();
+	mutex_enter(ev-ev_lock);
 	while (ev-ev_get == ev-ev_put) {
 		if (flags  IO_NDELAY) {
-			splx(s);
+			mutex_exit(ev-ev_lock);
 			return (EWOULDBLOCK);
 		}
-		ev-ev_wanted = 1;
-		error = tsleep((void *)ev, PEVENT | PCATCH, firm_event, 0);
-		if (error) {
-			splx(s);
+		ev-ev_wanted = true;
+		error = cv_wait_sig(ev-ev_cv, ev-ev_lock);
+		if (error != 0) {
+			mutex_exit(ev-ev_lock);
 			return (error);
 		}
 	}
@@ -118,7 +123,8 @@ ev_read(struct evvar *ev, struct uio *ui
 		cnt = EV_QSIZE - ev-ev_get;	/* events in [get..QSIZE) */
 	else
 		cnt = ev-ev_put - ev-ev_get;	/* events in [get..put) */
-	splx(s);
+	put = ev-ev_put;
+	mutex_exit(ev-ev_lock);
 	n = howmany(uio-uio_resid, sizeof(struct firm_event));
 	if (cnt  n)
 		cnt = n;
@@ -131,7 +137,7 @@ ev_read(struct evvar *ev, struct uio *ui
 	 * is anything there to move.
 	 */
 	if ((ev-ev_get = (ev-ev_get + cnt) % EV_QSIZE) != 0 ||
-	n == 0 || error || (cnt = ev-ev_put) == 0)
+	n == 0 || error || (cnt = put) == 0)
 		return (error);
 	if (cnt  n)
 		cnt = n;
@@ -144,9 +150,9 @@ ev_read(struct evvar *ev, struct uio *ui
 int
 ev_poll(struct evvar *ev, int events, struct lwp *l)
 {
-	int s, revents = 0;
+	int revents = 0;
 
-	s = splev();
+	mutex_enter(ev-ev_lock);
 	if (events  (POLLIN | POLLRDNORM)) {
 		if (ev-ev_get == ev-ev_put)
 			selrecord(l, ev-ev_sel);
@@ -154,38 +160,60 @@ ev_poll(struct evvar *ev, int events, st
 			revents |= events  (POLLIN | POLLRDNORM);
 	}
 	revents |= events  (POLLOUT | POLLWRNORM);
-	splx(s);
+	mutex_exit(ev-ev_lock);
 	return (revents);
 }
 
+void
+ev_wakeup(struct evvar *ev)
+{
+
+	mutex_enter(ev-ev_lock);
+	selnotify(ev-ev_sel, 0, 0);
+	if (ev-ev_wanted) {
+		ev-ev_wanted = false;
+		cv_signal(ev-ev_cv);
+	}
+	mutex_exit(ev-ev_lock);
+
+	if (ev-ev_async) {
+		mutex_enter(proc_lock);
+		psignal(ev-ev_io, SIGIO);
+		mutex_exit(proc_lock);
+	}
+}
+
 static void
 filt_evrdetach(struct knote *kn)
 {
 	struct evvar *ev = kn-kn_hook;
-	int s;
 
-	s = splev();
+	mutex_enter(ev-ev_lock);
 	SLIST_REMOVE(ev-ev_sel.sel_klist, kn, knote, kn_selnext);
-	splx(s);
+	mutex_exit(ev-ev_lock);
 }
 
 static int
 filt_evread(struct knote *kn, long hint)
 {
 	struct evvar *ev = kn-kn_hook;
+	int rv = 1;
 
-	if (ev-ev_get == ev-ev_put)
-		return (0);
-
-	if (ev-ev_get  ev-ev_put)
-		

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

2014-01-31 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Jan 31 18:42:45 UTC 2014

Modified Files:
src/sys/arch/x68k/dev: grf.c

Log Message:
Fix build botched in previous.

Christos, please at least compile before commit per the guideline.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/x68k/dev/grf.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/x68k/dev/grf.c
diff -u src/sys/arch/x68k/dev/grf.c:1.41 src/sys/arch/x68k/dev/grf.c:1.42
--- src/sys/arch/x68k/dev/grf.c:1.41	Sun Jan 26 00:09:46 2014
+++ src/sys/arch/x68k/dev/grf.c	Fri Jan 31 18:42:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: grf.c,v 1.41 2014/01/26 00:09:46 christos Exp $	*/
+/*	$NetBSD: grf.c,v 1.42 2014/01/31 18:42:45 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: grf.c,v 1.41 2014/01/26 00:09:46 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: grf.c,v 1.42 2014/01/31 18:42:45 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -271,7 +271,7 @@ grfmap(dev_t dev, void **addrp, struct p
 		flags |= MAP_FIXED;
 	else
 		*addrp = (void *)p-p_emul-e_vm_default_addr(p, 
-		p-p_vmspace-vm_daddr, len);
+		(vaddr_t)p-p_vmspace-vm_daddr, len);
 
 	vn.v_type = VCHR;			/* XXX */
 	vn.v_rdev = dev;			/* XXX */



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

2014-01-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 26 00:09:46 UTC 2014

Modified Files:
src/sys/arch/x68k/dev: grf.c

Log Message:
kill VM_DEFAULT_ADDRESS use.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x68k/dev/grf.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/x68k/dev/grf.c
diff -u src/sys/arch/x68k/dev/grf.c:1.40 src/sys/arch/x68k/dev/grf.c:1.41
--- src/sys/arch/x68k/dev/grf.c:1.40	Tue Feb  8 15:20:25 2011
+++ src/sys/arch/x68k/dev/grf.c	Sat Jan 25 19:09:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: grf.c,v 1.40 2011/02/08 20:20:25 rmind Exp $	*/
+/*	$NetBSD: grf.c,v 1.41 2014/01/26 00:09:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: grf.c,v 1.40 2011/02/08 20:20:25 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: grf.c,v 1.41 2014/01/26 00:09:46 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -270,8 +270,9 @@ grfmap(dev_t dev, void **addrp, struct p
 	if (*addrp)
 		flags |= MAP_FIXED;
 	else
-		*addrp =
-		(void *)VM_DEFAULT_ADDRESS(p-p_vmspace-vm_daddr, len);
+		*addrp = (void *)p-p_emul-e_vm_default_addr(p, 
+		p-p_vmspace-vm_daddr, len);
+
 	vn.v_type = VCHR;			/* XXX */
 	vn.v_rdev = dev;			/* XXX */
 	error = uvm_mmap(p-p_vmspace-vm_map, (vaddr_t *)addrp,



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

2013-05-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri May 24 18:24:27 UTC 2013

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

Log Message:
kill bogus inline


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

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

Modified files:

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.105 src/sys/arch/x68k/dev/fd.c:1.106
--- src/sys/arch/x68k/dev/fd.c:1.105	Sun Oct 14 15:06:25 2012
+++ src/sys/arch/x68k/dev/fd.c	Fri May 24 14:24:27 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.105 2012/10/14 19:06:25 tsutsui Exp $	*/
+/*	$NetBSD: fd.c,v 1.106 2013/05/24 18:24:27 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.105 2012/10/14 19:06:25 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.106 2013/05/24 18:24:27 christos Exp $);
 
 #include opt_ddb.h
 #include opt_m68k_arch.h
@@ -296,7 +296,7 @@ void fdctimeout(void *);
 void fdcpseudointr(void *);
 void fdcretry(struct fdc_softc *);
 void fdfinish(struct fd_softc *, struct buf *);
-inline struct fd_type *fd_dev_to_type(struct fd_softc *, dev_t);
+struct fd_type *fd_dev_to_type(struct fd_softc *, dev_t);
 int fdformat(dev_t, struct ne7_fd_formb *, struct lwp *);
 static int fdcpoll(struct fdc_softc *);
 static int fdgetdisklabel(struct fd_softc *, dev_t);
@@ -648,12 +648,12 @@ fdattach(device_t parent, device_t self,
 	RND_TYPE_DISK, 0);
 }
 
-inline struct fd_type *
+struct fd_type *
 fd_dev_to_type(struct fd_softc *fd, dev_t dev)
 {
-	int type = FDTYPE(dev);
+	size_t type = FDTYPE(dev);
 
-	if (type  (sizeof(fd_types) / sizeof(fd_types[0])))
+	if (type  __arraycount(fd_types))
 		return NULL;
 	return fd_types[type];
 }



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

2013-04-28 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Apr 28 14:44:46 UTC 2013

Modified Files:
src/sys/arch/x68k/dev: ite_tv.c

Log Message:
Fix a kernel panic by printf(1).
The 2nd byte of ISO-2022-JP must be 0x21-0x7e.  Especially,
the character code less than 0x2121 causes SEGV, because a
font address points outside of the CGROM.
Reported by tsutsui@.  Should be pulled up to netbsd-6.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x68k/dev/ite_tv.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/x68k/dev/ite_tv.c
diff -u src/sys/arch/x68k/dev/ite_tv.c:1.15 src/sys/arch/x68k/dev/ite_tv.c:1.16
--- src/sys/arch/x68k/dev/ite_tv.c:1.15	Sun Mar 11 06:01:05 2007
+++ src/sys/arch/x68k/dev/ite_tv.c	Sun Apr 28 14:44:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ite_tv.c,v 1.15 2007/03/11 06:01:05 isaki Exp $	*/
+/*	$NetBSD: ite_tv.c,v 1.16 2013/04/28 14:44:46 isaki Exp $	*/
 
 /*
  * Copyright (c) 1997 Masaru Oki.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ite_tv.c,v 1.15 2007/03/11 06:01:05 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: ite_tv.c,v 1.16 2013/04/28 14:44:46 isaki Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -283,10 +283,10 @@ tv_putc_nm(struct ite_softc *ip, int ch,
 
 	hi = ip-save_char  0x7f;
 
-	if (hi = 0x21  hi = 0x7e) {
+	if (hi = 0x21  hi = 0x7e  ch = 0x21  ch = 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch  0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh  FONTHEIGHT; fh++, p += ROWBYTES)
 			*(u_short *)p = *kf++;
@@ -312,10 +312,10 @@ tv_putc_in(struct ite_softc *ip, int ch,
 
 	hi = ip-save_char  0x7f;
 
-	if (hi = 0x21  hi = 0x7e) {
+	if (hi = 0x21  hi = 0x7e  ch = 0x21  ch = 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch  0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh  FONTHEIGHT; fh++, p += ROWBYTES)
 			*(u_short *)p = ~*kf++;
@@ -341,10 +341,10 @@ tv_putc_bd(struct ite_softc *ip, int ch,
 
 	hi = ip-save_char  0x7f;
 
-	if (hi = 0x21  hi = 0x7e) {
+	if (hi = 0x21  hi = 0x7e  ch = 0x21  ch = 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch  0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh  FONTHEIGHT; fh++, p += ROWBYTES) {
 			ch = *kf++;
@@ -388,10 +388,10 @@ tv_putc_ul(struct ite_softc *ip, int ch,
 
 	hi = ip-save_char  0x7f;
 
-	if (hi = 0x21  hi = 0x7e) {
+	if (hi = 0x21  hi = 0x7e  ch = 0x21  ch = 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch  0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh  UNDERLINE; fh++, p += ROWBYTES)
 			*(u_short *)p = *kf++;
@@ -425,10 +425,10 @@ tv_putc_bd_in(struct ite_softc *ip, int 
 
 	hi = ip-save_char  0x7f;
 
-	if (hi = 0x21  hi = 0x7e) {
+	if (hi = 0x21  hi = 0x7e  ch = 0x21  ch = 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch  0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh  FONTHEIGHT; fh++, p += ROWBYTES) {
 			ch = *kf++;
@@ -458,10 +458,10 @@ tv_putc_ul_in(struct ite_softc *ip, int 
 
 	hi = ip-save_char  0x7f;
 
-	if (hi = 0x21  hi = 0x7e) {
+	if (hi = 0x21  hi = 0x7e  ch = 0x21  ch = 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch  0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh  UNDERLINE; fh++, p += ROWBYTES)
 			*(u_short *)p = ~*kf++;
@@ -495,10 +495,10 @@ tv_putc_bd_ul(struct ite_softc *ip, int 
 
 	hi = ip-save_char  0x7f;
 
-	if (hi = 0x21  hi = 0x7e) {
+	if (hi = 0x21  hi = 0x7e  ch = 0x21  ch = 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch  0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh  UNDERLINE; fh++, p += ROWBYTES) {
 			ch = *kf++;
@@ -542,10 +542,10 @@ tv_putc_bd_ul_in(struct ite_softc *ip, i
 
 	hi = ip-save_char  0x7f;
 
-	if (hi = 0x21  hi = 0x7e) {
+	if (hi = 0x21  hi = 0x7e  ch = 0x21  ch = 0x7e) {
 		/* multibyte character */
 		kf = (volatile short *)tv_kfont[hi];
-		kf += (ch  0x7f) * FONTHEIGHT;
+		kf += ch * FONTHEIGHT;
 		/* draw plane */
 		for (fh = 0; fh  UNDERLINE; fh++, p += ROWBYTES) {
 			ch = *kf++;



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

2012-10-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Oct 14 16:36:32 UTC 2012

Modified Files:
src/sys/arch/x68k/dev: intio_dmac.c

Log Message:
To abort DMA in dmac_abort_xfer(), set DMAC_CCR_SAB (software abort)
rather than DMAC_CCR_HLT (halt operation).

DMAC_CCR_HLT doesn't abort DMA xfers but only suspends DMA ops
(i.e. clearing HLT bit will resume DMA xfers), so previously
DMAC error always occurs on the next DMA xfer ops after
dmac_abort_xfer() is called.

Also suppress DMAC error messages in dmac_error() if it's caused
by software abort command because it can happen during normal
audio play/record DMA ops in vs(4) driver.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/x68k/dev/intio_dmac.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/x68k/dev/intio_dmac.c
diff -u src/sys/arch/x68k/dev/intio_dmac.c:1.33 src/sys/arch/x68k/dev/intio_dmac.c:1.34
--- src/sys/arch/x68k/dev/intio_dmac.c:1.33	Sun Jun  6 04:50:08 2010
+++ src/sys/arch/x68k/dev/intio_dmac.c	Sun Oct 14 16:36:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: intio_dmac.c,v 1.33 2010/06/06 04:50:08 mrg Exp $	*/
+/*	$NetBSD: intio_dmac.c,v 1.34 2012/10/14 16:36:31 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include opt_m68k_arch.h
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: intio_dmac.c,v 1.33 2010/06/06 04:50:08 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: intio_dmac.c,v 1.34 2012/10/14 16:36:31 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -530,10 +530,18 @@ dmac_error(void *arg)
 {
 	struct dmac_channel_stat *chan = arg;
 	struct dmac_softc *sc = chan-ch_softc;
+	uint8_t csr, cer;
 
-	printf(DMAC transfer error CSR=%02x, CER=%02x\n,
-		bus_space_read_1(sc-sc_bst, chan-ch_bht, DMAC_REG_CSR),
-		bus_space_read_1(sc-sc_bst, chan-ch_bht, DMAC_REG_CER));
+	csr = bus_space_read_1(sc-sc_bst, chan-ch_bht, DMAC_REG_CSR);
+	cer = bus_space_read_1(sc-sc_bst, chan-ch_bht, DMAC_REG_CER);
+
+#ifndef DMAC_DEBUG
+	/* Software abort (CER=0x11) could happen on normal xfer termination */
+	if (cer != 0x11)
+#endif
+	{
+		printf(DMAC transfer error CSR=%02x, CER=%02x\n, csr, cer);
+	}
 	DDUMPREGS(3, (registers were:\n));
 
 	/* Clear the status bits */
@@ -552,7 +560,7 @@ dmac_abort_xfer(struct dmac_softc *dmac,
 	struct dmac_channel_stat *chan = xf-dx_channel;
 
 	bus_space_write_1(dmac-sc_bst, chan-ch_bht, DMAC_REG_CCR,
-			  DMAC_CCR_INT | DMAC_CCR_HLT);
+			  DMAC_CCR_INT | DMAC_CCR_SAB);
 	bus_space_write_1(dmac-sc_bst, chan-ch_bht, DMAC_REG_CSR, 0xff);
 	xf-dx_nextoff = xf-dx_nextsize = -1;
 



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

2012-10-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Oct 14 17:20:18 UTC 2012

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

Log Message:
Before probing floppy drives, call NE7CMD_SENSEI and fdcresult()
to drain possible pending FDC interrupts.  Taken from sys/dev/isa/fd.c.
Hopefully might fix occasional fd drive probe failure (but not confirmed).


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

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

Modified files:

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.101 src/sys/arch/x68k/dev/fd.c:1.102
--- src/sys/arch/x68k/dev/fd.c:1.101	Tue May 15 12:17:33 2012
+++ src/sys/arch/x68k/dev/fd.c	Sun Oct 14 17:20:18 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.101 2012/05/15 12:17:33 tsutsui Exp $	*/
+/*	$NetBSD: fd.c,v 1.102 2012/10/14 17:20:18 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.101 2012/05/15 12:17:33 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.102 2012/10/14 17:20:18 tsutsui Exp $);
 
 #include opt_ddb.h
 #include opt_m68k_arch.h
@@ -516,6 +516,11 @@ fdprobe(device_t parent, cfdata_t cf, vo
 
 	type = fd_types[0];	/* XXX 1.2MB */
 
+	/* toss any interrupt status */
+	for (n = 0; n  4; n++) {
+		out_fdc(iot, ioh, NE7CMD_SENSEI);
+		(void)fdcresult(fdc);
+	}
 	intio_disable_intr(SICILIAN_INTR_FDC);
 
 	/* select drive and turn on motor */



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

2012-10-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Oct 14 17:25:59 UTC 2012

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

Log Message:
Terminate DMAC and call bus_dmamap_unload(9) properly in all FDC xfer
error paths, as sys/dev/isa/fd.c does.  Fixes unexpected DMAC errors
(and possible VM panic due to un-unloaded dmamap) on the first floppy
access after read/write errors.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sys/arch/x68k/dev/fd.c

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

Modified files:

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.102 src/sys/arch/x68k/dev/fd.c:1.103
--- src/sys/arch/x68k/dev/fd.c:1.102	Sun Oct 14 17:20:18 2012
+++ src/sys/arch/x68k/dev/fd.c	Sun Oct 14 17:25:59 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.102 2012/10/14 17:20:18 tsutsui Exp $	*/
+/*	$NetBSD: fd.c,v 1.103 2012/10/14 17:25:59 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.102 2012/10/14 17:20:18 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.103 2012/10/14 17:25:59 tsutsui Exp $);
 
 #include opt_ddb.h
 #include opt_m68k_arch.h
@@ -291,6 +291,7 @@ void fd_mountroot_hook(device_t);
 
 /* DMA transfer routines */
 inline static void fdc_dmastart(struct fdc_softc *, int, void *, vsize_t);
+inline static void fdc_dmaabort(struct fdc_softc *);
 static int fdcdmaintr(void *);
 static int fdcdmaerrintr(void *);
 
@@ -333,6 +334,14 @@ fdc_dmastart(struct fdc_softc *fdc, int 
 	dmac_start_xfer(fdc-sc_dmachan-ch_softc, fdc-sc_xfer);
 }
 
+inline static void
+fdc_dmaabort(struct fdc_softc *fdc)
+{
+
+	dmac_abort_xfer(fdc-sc_dmachan-ch_softc, fdc-sc_xfer);
+	bus_dmamap_unload(fdc-sc_dmat, fdc-sc_dmamap);
+}
+
 static int
 fdcdmaintr(void *arg)
 {
@@ -1346,9 +1355,7 @@ fdcintr(void *arg)
 		goto doio;
 
 	case IOTIMEDOUT:
-#if 0
-		isa_dmaabort(fdc-sc_drq);
-#endif
+		fdc_dmaabort(fdc);
 	case SEEKTIMEDOUT:
 	case RECALTIMEDOUT:
 	case RESETTIMEDOUT:
@@ -1359,9 +1366,7 @@ fdcintr(void *arg)
 		callout_stop(fdc-sc_timo_ch);
 		DPRINTF((fdcintr: in IOCOMPLETE\n));
 		if ((tmp = fdcresult(fdc)) != 7 || (st0  0xf8) != 0) {
-#if 0
-			isa_dmaabort(fdc-sc_drq);
-#endif
+			fdc_dmaabort(fdc);
 			fdcstatus(fd-sc_dev, tmp, bp-b_flags  B_READ ?
 			read failed : write failed);
 			printf(blkno % PRId64  nblks %d\n,
@@ -1369,10 +1374,6 @@ fdcintr(void *arg)
 			fdcretry(fdc);
 			goto loop;
 		}
-#if 0
-		isa_dmadone(bp-b_flags  B_READ, bp-b_data + fd-sc_skip,
-		nblks * FDC_BSIZE, fdc-sc_drq);
-#endif
 	iocomplete2:
 		if (fdc-sc_errors) {
 			diskerr(bp, fd, soft error (corrected), LOG_PRINTF,
@@ -1398,9 +1399,7 @@ fdcintr(void *arg)
 		callout_stop(fdc-sc_timo_ch);
 		if ((tmp = fdcresult(fdc)) != 7 || (st0  0xf8) != 0) {
 			printf(fdcintr: resnum=%d, st0=%x\n, tmp, st0);
-#if 0
-			isa_dmaabort(fdc-sc_drq);
-#endif
+			fdc_dmaabort(fdc);
 			fdcstatus(fd-sc_dev, 7, bp-b_flags  B_READ ?
 			read failed : write failed);
 			printf(blkno % PRId64  nblks %d\n,



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

2012-10-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Oct 14 18:38:32 UTC 2012

Modified Files:
src/sys/arch/x68k/dev: fd.c fdreg.h

Log Message:
Add floppy format support.  Mostly taken from sys/dev/isa/fd.c.

Tested both fdNa (1232KB, 1024bytes/sector, 8sectors/track) and
fdNc (1200KB, 512bytes/sector, 15sectors/track) format on X68030
using fdformat(1).

Finally we can prepare NetBSD/x68k install floppies without Human68k
(except actual initial bootstrap).


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/x68k/dev/fd.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x68k/dev/fdreg.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/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.103 src/sys/arch/x68k/dev/fd.c:1.104
--- src/sys/arch/x68k/dev/fd.c:1.103	Sun Oct 14 17:25:59 2012
+++ src/sys/arch/x68k/dev/fd.c	Sun Oct 14 18:38:32 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.103 2012/10/14 17:25:59 tsutsui Exp $	*/
+/*	$NetBSD: fd.c,v 1.104 2012/10/14 18:38:32 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.103 2012/10/14 17:25:59 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.104 2012/10/14 18:38:32 tsutsui Exp $);
 
 #include opt_ddb.h
 #include opt_m68k_arch.h
@@ -87,6 +87,7 @@ __KERNEL_RCSID(0, $NetBSD: fd.c,v 1.103
 #include sys/uio.h
 #include sys/syslog.h
 #include sys/queue.h
+#include sys/proc.h
 #include sys/fdio.h
 #include sys/rnd.h
 
@@ -112,6 +113,9 @@ int fddebug = 0;
 #define FDUNIT(dev)	(minor(dev) / 8)
 #define FDTYPE(dev)	(minor(dev) % 8)
 
+/* (mis)use device use flag to identify format operation */
+#define B_FORMAT B_DEVPRIVATE
+
 enum fdc_state {
 	DEVIDLE = 0,
 	MOTORWAIT,
@@ -184,19 +188,29 @@ struct fd_type {
 	int	size;		/* size of disk in sectors */
 	int	step;		/* steps per cylinder */
 	int	rate;		/* transfer speed code */
+	uint8_t	fillbyte;	/* format fill byte */
+	uint8_t	interleave;	/* interleave factor (formatting) */
 	const char *name;
 };
 
 /* The order of entries in the following table is important -- BEWARE! */
 struct fd_type fd_types[] = {
-{  8,2,16,3,0xff,0xdf,0x35,0x74,77,1232,1,FDC_500KBPS, 1.2MB/[1024bytes/sector]}, /* 1.2 MB japanese format */
-{ 18,2,36,2,0xff,0xcf,0x1b,0x6c,80,2880,1,FDC_500KBPS,1.44MB}, /* 1.44MB diskette */
-{ 15,2,30,2,0xff,0xdf,0x1b,0x54,80,2400,1,FDC_500KBPS, 1.2MB}, /* 1.2 MB AT-diskettes */
-{  9,2,18,2,0xff,0xdf,0x23,0x50,40, 720,2,FDC_300KBPS, 360KB/AT }, /* 360kB in 1.2MB drive */
-{  9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,1,FDC_250KBPS, 360KB/PC }, /* 360kB PC diskettes */
-{  9,2,18,2,0xff,0xdf,0x2a,0x50,80,1440,1,FDC_250KBPS, 720KB}, /* 3.5 720kB diskette */
-{  9,2,18,2,0xff,0xdf,0x23,0x50,80,1440,1,FDC_300KBPS, 720KB/x  }, /* 720kB in 1.2MB drive */
-{  9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,2,FDC_250KBPS, 360KB/x  }, /* 360kB in 720kB drive */
+	{  8,2,16,3,0xff,0xdf,0x35,0x74,77,1232,1,FDC_500KBPS, 0xf6, 1,
+	1.2MB/[1024bytes/sector]}, /* 1.2 MB japanese format */
+	{ 18,2,36,2,0xff,0xcf,0x1b,0x6c,80,2880,1,FDC_500KBPS, 0xf6, 1,
+	1.44MB}, /* 1.44MB diskette */
+	{ 15,2,30,2,0xff,0xdf,0x1b,0x54,80,2400,1,FDC_500KBPS, 0xf6, 1,
+	1.2MB}, /* 1.2 MB AT-diskettes */
+	{  9,2,18,2,0xff,0xdf,0x23,0x50,40, 720,2,FDC_300KBPS, 0xf6, 1,
+	360KB/AT }, /* 360kB in 1.2MB drive */
+	{  9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,1,FDC_250KBPS, 0xf6, 1,
+	360KB/PC }, /* 360kB PC diskettes */
+	{  9,2,18,2,0xff,0xdf,0x2a,0x50,80,1440,1,FDC_250KBPS, 0xf6, 1,
+	720KB}, /* 3.5 720kB diskette */
+	{  9,2,18,2,0xff,0xdf,0x23,0x50,80,1440,1,FDC_300KBPS, 0xf6, 1,
+	720KB/x  }, /* 720kB in 1.2MB drive */
+	{  9,2,18,2,0xff,0xdf,0x2a,0x50,40, 720,2,FDC_250KBPS, 0xf6, 1,
+	360KB/x  }, /* 360kB in 720kB drive */
 };
 
 /* software state, per disk (with up to 4 disks per ctlr) */
@@ -283,6 +297,7 @@ void fdcpseudointr(void *);
 void fdcretry(struct fdc_softc *);
 void fdfinish(struct fd_softc *, struct buf *);
 inline struct fd_type *fd_dev_to_type(struct fd_softc *, dev_t);
+int fdformat(dev_t, struct ne7_fd_formb *, struct lwp *);
 static int fdcpoll(struct fdc_softc *);
 static int fdgetdisklabel(struct fd_softc *, dev_t);
 static void fd_do_eject(struct fdc_softc *, int);
@@ -659,7 +674,8 @@ fdstrategy(struct buf *bp)
 	}
 
 	if (bp-b_blkno  0 ||
-	(bp-b_bcount % FDC_BSIZE) != 0) {
+	((bp-b_bcount % FDC_BSIZE) != 0 
+	 (bp-b_flags  B_FORMAT) == 0)) {
 		DPRINTF((fdstrategy: unit=%d, blkno=% PRId64 , 
 		bcount=%d\n, unit,
 		bp-b_blkno, bp-b_bcount));
@@ -943,6 +959,9 @@ fdclose(dev_t dev, int flags, int mode, 
 		break;
 	}
 
+	/* clear flags */
+	fd-sc_opts = ~(FDOPT_NORETRY | FDOPT_SILENT);
+
 	if ((fd-sc_flags  FD_OPEN) == 0) {
 		

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

2012-10-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Oct 14 19:06:26 UTC 2012

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

Log Message:
KNF and space nits


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

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

Modified files:

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.104 src/sys/arch/x68k/dev/fd.c:1.105
--- src/sys/arch/x68k/dev/fd.c:1.104	Sun Oct 14 18:38:32 2012
+++ src/sys/arch/x68k/dev/fd.c	Sun Oct 14 19:06:25 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.104 2012/10/14 18:38:32 tsutsui Exp $	*/
+/*	$NetBSD: fd.c,v 1.105 2012/10/14 19:06:25 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.104 2012/10/14 18:38:32 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.105 2012/10/14 19:06:25 tsutsui Exp $);
 
 #include opt_ddb.h
 #include opt_m68k_arch.h
@@ -713,7 +713,7 @@ fdstrategy(struct buf *bp)
 
 	DPRINTF((fdstrategy: %s b_blkno % PRId64  b_bcount %d cylin %d\n,
 	bp-b_flags  B_READ ? read : write,
-		 bp-b_blkno, bp-b_bcount, bp-b_cylinder));
+	bp-b_blkno, bp-b_bcount, bp-b_cylinder));
 	/* Queue transfer on drive, activate drive and controller if idle. */
 	s = splbio();
 	bufq_put(fd-sc_q, bp);
@@ -818,7 +818,7 @@ void
 fd_motor_off(void *arg)
 {
 	struct fd_softc *fd = arg;
- 	struct fdc_softc *fdc = device_private(device_parent(fd-sc_dev));
+	struct fdc_softc *fdc = device_private(device_parent(fd-sc_dev));
 	int s;
 
 	DPRINTF((fd_motor_off:\n));
@@ -975,8 +975,10 @@ fdcstart(struct fdc_softc *fdc)
 {
 
 #ifdef DIAGNOSTIC
-	/* only got here if controller's drive queue was inactive; should
-	   be in idle state */
+	/*
+	 * only got here if controller's drive queue was inactive; should
+	 * be in idle state
+	 */
 	if (fdc-sc_state != DEVIDLE) {
 		printf(fdcstart: not idle\n);
 		return;



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

2012-10-13 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct 13 06:43:00 UTC 2012

Modified Files:
src/sys/arch/x68k/dev: grf_machdep.c par.c

Log Message:
Normalize autoconf(9) function arg names (parent, self, and aux)
for clarification.  from chs@.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/x68k/dev/grf_machdep.c
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x68k/dev/par.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/x68k/dev/grf_machdep.c
diff -u src/sys/arch/x68k/dev/grf_machdep.c:1.30 src/sys/arch/x68k/dev/grf_machdep.c:1.31
--- src/sys/arch/x68k/dev/grf_machdep.c:1.30	Tue Feb  8 20:20:25 2011
+++ src/sys/arch/x68k/dev/grf_machdep.c	Sat Oct 13 06:43:00 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: grf_machdep.c,v 1.30 2011/02/08 20:20:25 rmind Exp $	*/
+/*	$NetBSD: grf_machdep.c,v 1.31 2012/10/13 06:43:00 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1991 University of Utah.
@@ -44,7 +44,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: grf_machdep.c,v 1.30 2011/02/08 20:20:25 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: grf_machdep.c,v 1.31 2012/10/13 06:43:00 tsutsui Exp $);
 
 #include locators.h
 
@@ -79,32 +79,32 @@ CFATTACH_DECL_NEW(grf, sizeof(struct grf
 extern struct cfdriver grfbus_cd;
 
 int
-grfbusmatch(device_t pdp, cfdata_t cfp, void *auxp)
+grfbusmatch(device_t parent, cfdata_t cf, void *aux)
 {
-	if (strcmp(auxp, grfbus_cd.cd_name))
+	if (strcmp(aux, grfbus_cd.cd_name))
 		return (0);
 
 	return (1);
 }
 
 void
-grfbusattach(device_t pdp, device_t dp, void *auxp)
+grfbusattach(device_t parent, device_t self, void *aux)
 {
 
 	aprint_normal(\n);
-	config_search_ia(grfbussearch, dp, grfb, NULL);
+	config_search_ia(grfbussearch, self, grfb, NULL);
 }
 
 int
-grfbussearch(device_t dp, cfdata_t match, const int *ldesc, void *aux)
+grfbussearch(device_t self, cfdata_t match, const int *ldesc, void *aux)
 {
 
-	config_found(dp, match-cf_loc[GRFBCF_ADDR], grfbusprint);
+	config_found(self, match-cf_loc[GRFBCF_ADDR], grfbusprint);
 	return (0);
 }
 
 int
-grfbusprint(void *auxp, const char *name)
+grfbusprint(void *aux, const char *name)
 {
 
 	if (name == NULL)
@@ -130,17 +130,17 @@ grfmatch(device_t parent, cfdata_t cfp, 
 struct grf_softc congrf;
 
 void
-grfattach(device_t parent, device_t dp, void *aux)
+grfattach(device_t parent, device_t self, void *aux)
 {
 	struct grf_softc *gp;
 	struct cfdata *cf;
 	int addr;
 
-	cf = device_cfdata(dp);
+	cf = device_cfdata(self);
 	addr = cf-cf_loc[GRFBCF_ADDR];
 
-	gp = device_private(dp);
-	gp-g_device = dp;
+	gp = device_private(self);
+	gp-g_device = self;
 	gp-g_cfaddr = addr;
 	grfinit(gp, addr);
 
@@ -155,11 +155,11 @@ grfattach(device_t parent, device_t dp, 
 	/*
 	 * try and attach an ite
 	 */
-	config_found(dp, gp, grfprint);
+	config_found(self, gp, grfprint);
 }
 
 int
-grfprint(void *auxp, const char *pnp)
+grfprint(void *aux, const char *pnp)
 {
 
 	if (pnp)

Index: src/sys/arch/x68k/dev/par.c
diff -u src/sys/arch/x68k/dev/par.c:1.38 src/sys/arch/x68k/dev/par.c:1.39
--- src/sys/arch/x68k/dev/par.c:1.38	Sat Jan  9 09:16:32 2010
+++ src/sys/arch/x68k/dev/par.c	Sat Oct 13 06:43:00 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: par.c,v 1.38 2010/01/09 09:16:32 isaki Exp $	*/
+/*	$NetBSD: par.c,v 1.39 2012/10/13 06:43:00 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: par.c,v 1.38 2010/01/09 09:16:32 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: par.c,v 1.39 2012/10/13 06:43:00 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -130,7 +130,7 @@ const struct cdevsw par_cdevsw = {
 };
 
 int
-parmatch(device_t pdp, cfdata_t cfp, void *aux)
+parmatch(device_t parent, cfdata_t cf, void *aux)
 {
 	struct intio_attach_args *ia = aux;
 
@@ -141,7 +141,7 @@ parmatch(device_t pdp, cfdata_t cfp, voi
 	if (ia-ia_addr == INTIOCF_ADDR_DEFAULT)
 		ia-ia_addr = 0xe8c000;
 	ia-ia_size = 0x2000;
-	if (intio_map_allocate_region(pdp, ia, INTIO_MAP_TESTONLY))
+	if (intio_map_allocate_region(parent, ia, INTIO_MAP_TESTONLY))
 		return 0;
 	if (ia-ia_intr == INTIOCF_INTR_DEFAULT)
 		ia-ia_intr = 99;
@@ -154,19 +154,19 @@ parmatch(device_t pdp, cfdata_t cfp, voi
 }
 
 void
-parattach(device_t pdp, device_t dp, void *aux)
+parattach(device_t parent, device_t self, void *aux)
 {
-	struct par_softc *sc = device_private(dp);
+	struct par_softc *sc = device_private(self);
 	struct intio_attach_args *ia = aux;
 	int r;
 	
 	par_attached = 1;
 
-	sc-sc_dev = dp;
+	sc-sc_dev = self;
 	sc-sc_flags = PARF_ALIVE;
 	aprint_normal(: parallel port (write only, interrupt)\n);
 	ia-ia_size = 0x2000;
-	r = intio_map_allocate_region(pdp, ia, INTIO_MAP_ALLOCATE);
+	r = intio_map_allocate_region(parent, ia, INTIO_MAP_ALLOCATE);
 #ifdef DIAGNOSTIC
 	if (r)
 		panic(IO map for PAR corruption??);



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

2012-10-10 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Oct 10 16:55:50 UTC 2012

Modified Files:
src/sys/arch/x68k/dev: mha.c

Log Message:
Fix device_t/softc split botches that could be fatal.  From
Chuck Silvers' patch posted current-users and tech-kern:
http://mail-index.netbsd.org/current-users/2012/10/09/msg021233.html

Should be pulled up to netbsd-6.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/x68k/dev/mha.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/x68k/dev/mha.c
diff -u src/sys/arch/x68k/dev/mha.c:1.52 src/sys/arch/x68k/dev/mha.c:1.53
--- src/sys/arch/x68k/dev/mha.c:1.52	Mon Nov 23 00:11:45 2009
+++ src/sys/arch/x68k/dev/mha.c	Wed Oct 10 16:55:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mha.c,v 1.52 2009/11/23 00:11:45 rmind Exp $	*/
+/*	$NetBSD: mha.c,v 1.53 2012/10/10 16:55:50 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996-1999 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mha.c,v 1.52 2009/11/23 00:11:45 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: mha.c,v 1.53 2012/10/10 16:55:50 tsutsui Exp $);
 
 #include opt_ddb.h
 
@@ -337,7 +337,7 @@ mhaattach(device_t parent, device_t self
 	/*
 	 * Fill in the adapter.
 	 */
-	sc-sc_adapter.adapt_dev = sc-sc_dev;
+	sc-sc_adapter.adapt_dev = self;
 	sc-sc_adapter.adapt_nchannels = 1;
 	sc-sc_adapter.adapt_openings = 7;
 	sc-sc_adapter.adapt_max_periph = 1;
@@ -674,7 +674,7 @@ mha_scsi_request(struct scsipi_channel *
 {
 	struct scsipi_xfer *xs;
 	struct scsipi_periph *periph;
-	struct mha_softc *sc = (void *)chan-chan_adapter-adapt_dev;
+	struct mha_softc *sc = device_private(chan-chan_adapter-adapt_dev);
 	struct acb *acb;
 	int s, flags;
 
@@ -1949,7 +1949,7 @@ mha_timeout(void *arg)
 	struct scsipi_xfer *xs = acb-xs;
 	struct scsipi_periph *periph = xs-xs_periph;
 	struct mha_softc *sc =
-	(void *)periph-periph_channel-chan_adapter-adapt_dev;
+	device_private(periph-periph_channel-chan_adapter-adapt_dev);
 	int s;
 
 	s = splbio();



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

2012-10-10 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Oct 10 17:49:50 UTC 2012

Modified Files:
src/sys/arch/x68k/dev: ite.c itevar.h

Log Message:
Fix device_t/softc split bothces.  From Chuck Silvers' patch posted on
current-users and tech-kern:
http://mail-index.netbsd.org/current-users/2012/10/09/msg021233.html
and several more fixes by me.

Not sure if these are fatal (at least 6.0_RC2 works without thise fixes),
but needs more investigation.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/x68k/dev/ite.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x68k/dev/itevar.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/x68k/dev/ite.c
diff -u src/sys/arch/x68k/dev/ite.c:1.59 src/sys/arch/x68k/dev/ite.c:1.60
--- src/sys/arch/x68k/dev/ite.c:1.59	Sun Apr 24 16:26:58 2011
+++ src/sys/arch/x68k/dev/ite.c	Wed Oct 10 17:49:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ite.c,v 1.59 2011/04/24 16:26:58 rmind Exp $	*/
+/*	$NetBSD: ite.c,v 1.60 2012/10/10 17:49:50 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ite.c,v 1.59 2011/04/24 16:26:58 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: ite.c,v 1.60 2012/10/10 17:49:50 tsutsui Exp $);
 
 #include ite.h
 #if NITE  0
@@ -135,6 +135,7 @@ struct itesw itesw[] = {
 struct	tty *ite_tty[NITE];
 struct	ite_softc *kbd_ite = NULL;
 struct  ite_softc con_itesoftc;
+struct	device con_itedev;
 
 struct  tty *kbd_tty = NULL;
 
@@ -170,12 +171,12 @@ const struct cdevsw ite_cdevsw = {
 };
 
 int
-itematch(device_t pdp, cfdata_t cdp, void *auxp)
+itematch(device_t parent, cfdata_t cf, void *aux)
 {
 	struct grf_softc *gp;
 	
-	gp = auxp;
-	if (cdp-cf_loc[GRFCF_GRFADDR] != gp-g_cfaddr)
+	gp = aux;
+	if (cf-cf_loc[GRFCF_GRFADDR] != gp-g_cfaddr)
 		return 0;
 
 	return 1;
@@ -186,13 +187,14 @@ itematch(device_t pdp, cfdata_t cdp, voi
  * an ite device, it is also called from ite_cninit().
  */
 void
-iteattach(device_t pdp, device_t dp, void *auxp)
+iteattach(device_t parent, device_t self, void *aux)
 {
 	struct ite_softc *ip;
 	struct grf_softc *gp;
 
-	gp = (struct grf_softc *)auxp;
-	ip = device_private(dp);
+	gp = aux;
+	ip = device_private(self);
+	ip-device = self;
 	if(con_itesoftc.grf != NULL
 		/* con_itesoftc.grf-g_unit == gp-g_unit*/) {
 		/*
@@ -205,7 +207,7 @@ iteattach(device_t pdp, device_t dp, voi
 		kbd_ite = ip;
 	}
 	ip-grf = gp;
-	iteinit(device_unit(ip-device)); /* XXX */
+	iteinit(device_unit(self)); /* XXX */
 	aprint_normal(: rows %d cols %d, ip-rows, ip-cols);
 	if (kbd_ite == NULL)
 		kbd_ite = ip;
@@ -240,7 +242,7 @@ iteinit(dev_t dev)
 	ip-cursorx = 0;
 	ip-cursory = 0;
 
-	ip-isw = itesw[device_unit(ip-device)]; /* XXX */
+	ip-isw = itesw[device_unit(ip-device)]; /* XXX */
 	SUBR_INIT(ip);
 	SUBR_CURSOR(ip, DRAW_CURSOR);
 	if (!ip-tabs)
@@ -258,6 +260,7 @@ ite_config_console(void)
 		return;
 	con_itesoftc.grf = gp;
 	con_itesoftc.tabs = cons_tabs;
+	con_itesoftc.device = con_itedev;
 }
 
 /*
@@ -270,7 +273,7 @@ iteon(dev_t dev, int flag)
 	struct ite_softc *ip;
 
 	if (unit  0 || unit = ite_cd.cd_ndevs ||
-	(ip = getitesp(unit)) == NULL || (ip-flagsITE_ALIVE) == 0)
+	(ip = getitesp(dev)) == NULL || (ip-flagsITE_ALIVE) == 0)
 		return(ENXIO);
 	/* force ite active, overriding graphics mode */
 	if (flag  1) {
@@ -309,7 +312,7 @@ iteoff(dev_t dev, int flag)
 
 	/* XXX check whether when call from grf.c */
 	if (unit  0 || unit = ite_cd.cd_ndevs ||
-	(ip = getitesp(unit)) == NULL || (ip-flagsITE_ALIVE) == 0)
+	(ip = getitesp(dev)) == NULL || (ip-flagsITE_ALIVE) == 0)
 		return;
 	if (flag  2)
 		ip-flags |= ITE_INGRF;
@@ -538,7 +541,7 @@ ite_reinit(dev_t dev)
 
 	/* XXX check whether when call from grf.c */
 	if (unit  0 || unit = ite_cd.cd_ndevs ||
-	(ip = getitesp(unit)) == NULL)
+	(ip = getitesp(dev)) == NULL)
 		return;
 
 	ip-flags = ~ITE_INITED;
@@ -714,7 +717,7 @@ ite_filter(u_char c)
 	struct key key;
 	int s, i;
 
-	if (!kbd_ite || !(kbd_tty = ite_tty[device_unit(kbd_ite-device)]))
+	if (!kbd_ite || !(kbd_tty = ite_tty[device_unit(kbd_ite-device)]))
 		return;
 
 	/* have to make sure we're at spltty in here */
@@ -2086,7 +2089,7 @@ iteputchar(int c, struct ite_softc *ip)
 
 	case BEL:
 #if NBELL  0
-		if (kbd_ite  ite_tty[device_unit(kbd_ite-device)])
+		if (kbd_ite  ite_tty[device_unit(kbd_ite-device)])
 			opm_bell();
 #endif
 		break;

Index: src/sys/arch/x68k/dev/itevar.h
diff -u src/sys/arch/x68k/dev/itevar.h:1.14 src/sys/arch/x68k/dev/itevar.h:1.15
--- src/sys/arch/x68k/dev/itevar.h:1.14	Tue Feb  8 20:20:25 2011
+++ src/sys/arch/x68k/dev/itevar.h	Wed Oct 10 17:49:50 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: itevar.h,v 1.14 2011/02/08 20:20:25 rmind Exp $	*/
+/*	$NetBSD: itevar.h,v 1.15 2012/10/10 17:49:50 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -61,7 +61,7 @@ enum ite_arraymaxs 

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

2012-08-15 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Aug 15 19:13:58 UTC 2012

Modified Files:
src/sys/arch/x68k/dev: event_var.h

Log Message:
Make sure to take proc_lock mutex on calling psignal(9) in EV_WAKEUP() macro
as sys/dev/sun/event_var.h does.
Fixes immediate KASSERT(mutex_owned(proc_lock)) panic during running Xserver
on DIAGNOSTIC kernel.

Should be pulled up to netbsd-6.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x68k/dev/event_var.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/x68k/dev/event_var.h
diff -u src/sys/arch/x68k/dev/event_var.h:1.8 src/sys/arch/x68k/dev/event_var.h:1.9
--- src/sys/arch/x68k/dev/event_var.h:1.8	Sat Mar  1 14:16:50 2008
+++ src/sys/arch/x68k/dev/event_var.h	Wed Aug 15 19:13:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: event_var.h,v 1.8 2008/03/01 14:16:50 rmind Exp $ */
+/*	$NetBSD: event_var.h,v 1.9 2012/08/15 19:13:58 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -67,8 +67,11 @@ struct evvar {
 		(ev)-ev_wanted = 0; \
 		wakeup((void *)(ev)); \
 	} \
-	if ((ev)-ev_async) \
+	if ((ev)-ev_async) { \
+		mutex_enter(proc_lock); \
 		psignal((ev)-ev_io, SIGIO); \
+		mutex_exit(proc_lock); \
+	} \
 }
 
 void	ev_init(struct evvar *);



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

2012-07-28 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Jul 29 00:08:19 UTC 2012

Modified Files:
src/sys/arch/x68k/dev: mhavar.h

Log Message:
Another failed typedef fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x68k/dev/mhavar.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/x68k/dev/mhavar.h
diff -u src/sys/arch/x68k/dev/mhavar.h:1.9 src/sys/arch/x68k/dev/mhavar.h:1.10
--- src/sys/arch/x68k/dev/mhavar.h:1.9	Sat Nov 29 05:59:40 2008
+++ src/sys/arch/x68k/dev/mhavar.h	Sun Jul 29 00:08:19 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mhavar.h,v 1.9 2008/11/29 05:59:40 isaki Exp $	*/
+/*	$NetBSD: mhavar.h,v 1.10 2012/07/29 00:08:19 matt Exp $	*/
 
 /*
  * Copyright (c) 1994 Peter Galbavy.  All rights reserved.
@@ -82,7 +82,7 @@ struct spc_tinfo {
 	u_char  period;		/* Period suggestion */
 	u_char  offset;		/* Offset suggestion */
 	u_char	width;		/* Width suggestion */
-} tinfo_t;
+};
 
 struct mha_softc {
 	device_t sc_dev;



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

2012-05-15 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue May 15 12:17:34 UTC 2012

Modified Files:
src/sys/arch/x68k/dev: fd.c fdreg.h

Log Message:
- check bus_space_map(9) return value
- use BUS_SPACE_MAP_SHIFTED_ODD for clarify
- define and use proper macro instead of magic


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/arch/x68k/dev/fd.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x68k/dev/fdreg.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/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.100 src/sys/arch/x68k/dev/fd.c:1.101
--- src/sys/arch/x68k/dev/fd.c:1.100	Sun May 13 03:00:40 2012
+++ src/sys/arch/x68k/dev/fd.c	Tue May 15 12:17:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.100 2012/05/13 03:00:40 tsutsui Exp $	*/
+/*	$NetBSD: fd.c,v 1.101 2012/05/15 12:17:33 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.100 2012/05/13 03:00:40 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.101 2012/05/15 12:17:33 tsutsui Exp $);
 
 #include opt_ddb.h
 #include opt_m68k_arch.h
@@ -377,7 +377,7 @@ fdcprobe(device_t parent, cfdata_t cf, v
 	if ((ia-ia_intr  0x03) != 0)
 		return 0;
 
-	ia-ia_size = 0x2000;
+	ia-ia_size = FDC_MAPSIZE;
 	if (intio_map_allocate_region(parent, ia, INTIO_MAP_TESTONLY))
 		return 0;
 
@@ -423,12 +423,16 @@ fdcattach(device_t parent, device_t self
 
 	aprint_normal(\n);
 
+	/* Re-map the I/O space. */
+	if (bus_space_map(iot, ia-ia_addr, ia-ia_size,
+	BUS_SPACE_MAP_SHIFTED_ODD, ioh) != 0) {
+		aprint_error_dev(self, unable to map I/O space\n);
+		return;
+	}
+
 	callout_init(fdc-sc_timo_ch, 0);
 	callout_init(fdc-sc_intr_ch, 0);
 
-	/* Re-map the I/O space. */
-	bus_space_map(iot, ia-ia_addr, 0x2000, BUS_SPACE_MAP_SHIFTED, ioh);
-
 	fdc-sc_iot = iot;
 	fdc-sc_ioh = ioh;
 	fdc-sc_addr = (void *)ia-ia_addr;

Index: src/sys/arch/x68k/dev/fdreg.h
diff -u src/sys/arch/x68k/dev/fdreg.h:1.4 src/sys/arch/x68k/dev/fdreg.h:1.5
--- src/sys/arch/x68k/dev/fdreg.h:1.4	Sun Dec 11 12:19:37 2005
+++ src/sys/arch/x68k/dev/fdreg.h	Tue May 15 12:17:33 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdreg.h,v 1.4 2005/12/11 12:19:37 christos Exp $	*/
+/*	$NetBSD: fdreg.h,v 1.5 2012/05/15 12:17:33 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -56,6 +56,7 @@
 
 /* default attach args */
 #define FDC_ADDR 0xe94000	/* builtin fdc is here */
+#define FDC_MAPSIZE 0x2000	/* builtin fdc I/O range */
 #define FDC_INTR 96		/* interrupt vector */
 #define FDC_DMA 0		/* DMA ch# */
 #define FDC_DMAINTR 100		/* DMA interrupt vector */



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

2012-05-12 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun May 13 00:47:16 UTC 2012

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

Log Message:
- use sys/bus.h rather than machine/bus.h
- no need to include uvm_extern.h
- include ioconf.h for struct cfdriver foo_cd


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/x68k/dev/fd.c

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

Modified files:

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.98 src/sys/arch/x68k/dev/fd.c:1.99
--- src/sys/arch/x68k/dev/fd.c:1.98	Sat May 12 15:29:22 2012
+++ src/sys/arch/x68k/dev/fd.c	Sun May 13 00:47:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.98 2012/05/12 15:29:22 tsutsui Exp $	*/
+/*	$NetBSD: fd.c,v 1.99 2012/05/13 00:47:16 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,13 +64,14 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.98 2012/05/12 15:29:22 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.99 2012/05/13 00:47:16 tsutsui Exp $);
 
 #include opt_ddb.h
 #include opt_m68k_arch.h
 
 #include sys/param.h
 #include sys/systm.h
+#include sys/bus.h
 #include sys/callout.h
 #include sys/kernel.h
 #include sys/conf.h
@@ -89,11 +90,8 @@ __KERNEL_RCSID(0, $NetBSD: fd.c,v 1.98 
 #include sys/fdio.h
 #include sys/rnd.h
 
-#include uvm/uvm_extern.h
-
 #include dev/cons.h
 
-#include machine/bus.h
 #include machine/cpu.h
 
 #include arch/x68k/dev/intiovar.h
@@ -102,6 +100,7 @@ __KERNEL_RCSID(0, $NetBSD: fd.c,v 1.98 
 #include arch/x68k/dev/opmvar.h /* for CT1 access */
 
 #include locators.h
+#include ioconf.h
 
 #ifdef FDDEBUG
 #define DPRINTF(x)  if (fddebug) printf x
@@ -168,8 +167,6 @@ int fdprint(void *, const char *);
 CFATTACH_DECL_NEW(fdc, sizeof(struct fdc_softc),
 fdcprobe, fdcattach, NULL, NULL);
 
-extern struct cfdriver fdc_cd;
-
 /*
  * Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how
  * we tell them apart.
@@ -252,8 +249,6 @@ void fdattach(device_t, device_t, void *
 CFATTACH_DECL_NEW(fd, sizeof(struct fd_softc),
 fdprobe, fdattach, NULL, NULL);
 
-extern struct cfdriver fd_cd;
-
 dev_type_open(fdopen);
 dev_type_close(fdclose);
 dev_type_read(fdread);



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

2012-05-12 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun May 13 03:00:41 UTC 2012

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

Log Message:
KNF and cosmetics.  No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sys/arch/x68k/dev/fd.c

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

Modified files:

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.99 src/sys/arch/x68k/dev/fd.c:1.100
--- src/sys/arch/x68k/dev/fd.c:1.99	Sun May 13 00:47:16 2012
+++ src/sys/arch/x68k/dev/fd.c	Sun May 13 03:00:40 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.99 2012/05/13 00:47:16 tsutsui Exp $	*/
+/*	$NetBSD: fd.c,v 1.100 2012/05/13 03:00:40 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.99 2012/05/13 00:47:16 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.100 2012/05/13 03:00:40 tsutsui Exp $);
 
 #include opt_ddb.h
 #include opt_m68k_arch.h
@@ -144,7 +144,7 @@ struct fdc_softc {
 
 	bus_dma_tag_t sc_dmat;		/* intio DMA tag */
 	bus_dmamap_t sc_dmamap;		/* DMA map */
-	u_int8_t *sc_addr;			/* physical address */
+	uint8_t *sc_addr;		/* physical address */
 	struct dmac_channel_stat *sc_dmachan; /* intio DMA channel */
 	struct dmac_dma_xfer *sc_xfer;	/* DMA transfer */
 	int sc_read;
@@ -153,7 +153,7 @@ struct fdc_softc {
 	TAILQ_HEAD(drivehead, fd_softc) sc_drives;
 	enum fdc_state sc_state;
 	int sc_errors;			/* number of retries so far */
-	u_char sc_status[7];		/* copy of registers */
+	uint8_t sc_status[7];		/* copy of registers */
 } fdc_softc;
 
 int fdcintr(void *);
@@ -233,8 +233,8 @@ struct fd_softc {
 	int sc_ops;		/* I/O ops since last switch */
 	struct bufq_state *sc_q;/* pending I/O requests */
 	int sc_active;		/* number of active I/O operations */
-	u_char *sc_copybuf;	/* for secsize =3 */
-	u_char sc_part;		/* for secsize =3 */
+	uint8_t *sc_copybuf;	/* for secsize =3 */
+	uint8_t sc_part;	/* for secsize =3 */
 #define	SEC_P10	0x02		/* first part */
 #define	SEC_P01	0x01		/* second part */
 #define	SEC_P11	0x03		/* both part */
@@ -275,7 +275,7 @@ void fd_motor_off(void *);
 void fd_motor_on(void *);
 #endif
 int fdcresult(struct fdc_softc *);
-int out_fdc(bus_space_tag_t, bus_space_handle_t, u_char);
+int out_fdc(bus_space_tag_t, bus_space_handle_t, uint8_t);
 void fdcstart(struct fdc_softc *);
 void fdcstatus(device_t, int, const char *);
 void fdctimeout(void *);
@@ -300,16 +300,16 @@ fdc_dmastart(struct fdc_softc *fdc, int 
 	int error;
 
 	DPRINTF((fdc_dmastart: %s, addr = %p, count = %ld\n,
-		 read ? read : write, (void *) addr, count));
+	read ? read : write, (void *)addr, count));
 
 	error = bus_dmamap_load(fdc-sc_dmat, fdc-sc_dmamap, addr, count,
-0, BUS_DMA_NOWAIT);
+	0, BUS_DMA_NOWAIT);
 	if (error) {
-		panic (fdc_dmastart: cannot load dmamap);
+		panic(fdc_dmastart: cannot load dmamap);
 	}
 
 	bus_dmamap_sync(fdc-sc_dmat, fdc-sc_dmamap, 0, count,
-			read?BUS_DMASYNC_PREREAD:BUS_DMASYNC_PREWRITE);
+	read ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
 
 	/*
 	 * Note 1:
@@ -324,13 +324,10 @@ fdc_dmastart(struct fdc_softc *fdc, int 
 	 * XXX: No proper API to get DMA address of FDC register for DMAC.
 	 */
 	fdc-sc_xfer = dmac_prepare_xfer(fdc-sc_dmachan, fdc-sc_dmat,
-	 fdc-sc_dmamap,
-	 (read?
-	  DMAC_OCR_DIR_DTM:DMAC_OCR_DIR_MTD),
-	 (DMAC_SCR_MAC_COUNT_UP|
-	  DMAC_SCR_DAC_NO_COUNT),
-	 (u_int8_t*) (fdc-sc_addr +
-		  fddata * 2 + 1));
+	fdc-sc_dmamap,
+	read ? DMAC_OCR_DIR_DTM : DMAC_OCR_DIR_MTD,
+	DMAC_SCR_MAC_COUNT_UP | DMAC_SCR_DAC_NO_COUNT,
+	fdc-sc_addr + fddata * 2 + 1);
 
 	fdc-sc_read = read;
 	dmac_start_xfer(fdc-sc_dmachan-ch_softc, fdc-sc_xfer);
@@ -353,6 +350,7 @@ fdcdmaintr(void *arg)
 static int
 fdcdmaerrintr(void *dummy)
 {
+
 	DPRINTF((fdcdmaerrintr\n));
 
 	return 0;
@@ -380,7 +378,7 @@ fdcprobe(device_t parent, cfdata_t cf, v
 		return 0;
 
 	ia-ia_size = 0x2000;
-	if (intio_map_allocate_region (parent, ia, INTIO_MAP_TESTONLY))
+	if (intio_map_allocate_region(parent, ia, INTIO_MAP_TESTONLY))
 		return 0;
 
 	/* builtin device; always there */
@@ -407,7 +405,7 @@ fdprint(void *aux, const char *fdc)
 {
 	struct fdc_attach_args *fa = aux;
 
-	if (!fdc)
+	if (fdc == NULL)
 		aprint_normal( drive %d, fa-fa_drive);
 	return QUIET;
 }
@@ -441,18 +439,16 @@ fdcattach(device_t parent, device_t self
 
 	/* Initialize DMAC channel */
 	fdc-sc_dmachan = dmac_alloc_channel(parent, ia-ia_dma, fdc,
-	 ia-ia_dmaintr, fdcdmaintr, fdc,
-	 ia-ia_dmaintr+1, fdcdmaerrintr,
-	 fdc);
+	ia-ia_dmaintr, fdcdmaintr, fdc,
+	ia-ia_dmaintr + 1, fdcdmaerrintr, fdc);
 	if (bus_dmamap_create(fdc-sc_dmat, FDC_MAXIOSIZE, 1, DMAC_MAXSEGSZ,
-			  0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW,
-			  fdc-sc_dmamap)) {
+	0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, 

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

2011-10-23 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Oct 23 13:21:54 UTC 2011

Modified Files:
src/sys/arch/x68k/dev: kbd.c

Log Message:
Calling psignal(9) (via EV_WAKEUP()) in interrupt handlers
could cause mutex error panic, so defer it via softint(9).
This should fix panic on heavy key strokes during running Xserver.

Should be pulled up to netbsd-5.

XXX: amiga and atari might have the similar problem?


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/x68k/dev/kbd.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/x68k/dev/kbd.c
diff -u src/sys/arch/x68k/dev/kbd.c:1.36 src/sys/arch/x68k/dev/kbd.c:1.37
--- src/sys/arch/x68k/dev/kbd.c:1.36	Sat Jan 17 03:26:31 2009
+++ src/sys/arch/x68k/dev/kbd.c	Sun Oct 23 13:21:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: kbd.c,v 1.36 2009/01/17 03:26:31 isaki Exp $	*/
+/*	$NetBSD: kbd.c,v 1.37 2011/10/23 13:21:54 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: kbd.c,v 1.36 2009/01/17 03:26:31 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: kbd.c,v 1.37 2011/10/23 13:21:54 tsutsui Exp $);
 
 #include ite.h
 #include bell.h
@@ -350,7 +350,7 @@ kbdintr(void *arg)
 	fe-value = KEY_UP(c) ? VKEY_UP : VKEY_DOWN;
 	firm_gettime(fe);
 	sc-sc_events.ev_put = put;
-	EV_WAKEUP(sc-sc_events);
+	softint_schedule(sc-sc_softintr_cookie);
 
 	return 0;
 }
@@ -358,10 +358,14 @@ kbdintr(void *arg)
 void
 kbdsoftint(void *arg)			/* what if ite is not configured? */
 {
+	struct kbd_softc *sc = arg;
 	int s;
 
 	s = spltty();
 
+	if (sc-sc_event_mode)
+		EV_WAKEUP(sc-sc_events);
+
 	while(kbdgetoff  kbdputoff)
 		ite_filter(kbdbuf[kbdgetoff++  KBDBUFMASK]);
 	kbdgetoff = kbdputoff = 0;



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

2011-05-05 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu May  5 13:44:35 UTC 2011

Modified Files:
src/sys/arch/x68k/dev: mfp.c

Log Message:
Add a comment for the previous change.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x68k/dev/mfp.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/x68k/dev/mfp.c
diff -u src/sys/arch/x68k/dev/mfp.c:1.24 src/sys/arch/x68k/dev/mfp.c:1.25
--- src/sys/arch/x68k/dev/mfp.c:1.24	Wed May  4 12:27:03 2011
+++ src/sys/arch/x68k/dev/mfp.c	Thu May  5 13:44:35 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mfp.c,v 1.24 2011/05/04 12:27:03 tsutsui Exp $	*/
+/*	$NetBSD: mfp.c,v 1.25 2011/05/05 13:44:35 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mfp.c,v 1.24 2011/05/04 12:27:03 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: mfp.c,v 1.25 2011/05/05 13:44:35 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -103,6 +103,7 @@
 	aprint_normal(\n);
 	mfp_attached = 1;
 
+	/* mfp_init() is already called via early config_console() */
 	sc-sc_bst = ia-ia_bst;
 	sc-sc_intr = ia-ia_intr;
 	ia-ia_size = 0x30;



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

2011-05-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed May  4 12:27:03 UTC 2011

Modified Files:
src/sys/arch/x68k/dev: mfp.c

Log Message:
Don't call mfp_init() in mfp_attach().
It's already called from early mfp_config_console() via config_console()
and reinitializing MFP could sometimes cause silent hang.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/x68k/dev/mfp.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/x68k/dev/mfp.c
diff -u src/sys/arch/x68k/dev/mfp.c:1.23 src/sys/arch/x68k/dev/mfp.c:1.24
--- src/sys/arch/x68k/dev/mfp.c:1.23	Sat Jan 17 10:02:23 2009
+++ src/sys/arch/x68k/dev/mfp.c	Wed May  4 12:27:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mfp.c,v 1.23 2009/01/17 10:02:23 isaki Exp $	*/
+/*	$NetBSD: mfp.c,v 1.24 2011/05/04 12:27:03 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: mfp.c,v 1.23 2009/01/17 10:02:23 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: mfp.c,v 1.24 2011/05/04 12:27:03 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -103,7 +103,6 @@
 	aprint_normal(\n);
 	mfp_attached = 1;
 
-	mfp_init();
 	sc-sc_bst = ia-ia_bst;
 	sc-sc_intr = ia-ia_intr;
 	ia-ia_size = 0x30;



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

2011-05-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun May  1 16:19:13 UTC 2011

Modified Files:
src/sys/arch/x68k/dev: zs.c

Log Message:
Reset ZS chip properly in zscninit() so that zscngetc() works
even before zsc is attached during configure.
(i.e. make userconf(4) work on serial console)


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x68k/dev/zs.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/x68k/dev/zs.c
diff -u src/sys/arch/x68k/dev/zs.c:1.40 src/sys/arch/x68k/dev/zs.c:1.41
--- src/sys/arch/x68k/dev/zs.c:1.40	Wed Dec 31 09:50:21 2008
+++ src/sys/arch/x68k/dev/zs.c	Sun May  1 16:19:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: zs.c,v 1.40 2008/12/31 09:50:21 isaki Exp $	*/
+/*	$NetBSD: zs.c,v 1.41 2011/05/01 16:19:13 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 Minoura Makoto
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: zs.c,v 1.40 2008/12/31 09:50:21 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: zs.c,v 1.41 2011/05/01 16:19:13 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -580,9 +580,11 @@
 	zscn_cs.cs_brg_clk = PCLK / 16;
 	memcpy(zscn_cs.cs_preg, zs_init_reg, 16);
 	zscn_cs.cs_preg[4] = ZSWR4_CLK_X16 | ZSWR4_ONESB; /* XXX */
-	zscn_cs.cs_preg[9] = 0;
+	zscn_cs.cs_preg[5] |= ZSWR5_DTR | ZSWR5_RTS;
 	zs_set_speed(zscn_cs, ZSCN_SPEED);
 	s = splzs();
+	zs_write_reg(zscn_cs, 9, 0);
+	zs_write_reg(zscn_cs, 9, ZSWR9_HARD_RESET);
 	zs_loadchannelregs(zscn_cs);
 	splx(s);
 	conschan = cnchan;



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

2011-04-10 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Apr 10 15:23:06 UTC 2011

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

Log Message:
Fix hangup on the first floppy access since 2008.
Problem was reported by isaki@.

On X680x0 (and most other machines other than ISA FDC),
the ready line from FDD is connected to FDC and fdc driver can
be notified of the ready state after fd_set_motor() by interrupts.
In this case no need to use callout(9) to wait the FDD motor stabilized,
and the callout(9) method used in ISA fdc(4) driver rather caused
infinite unhandled interrupts since callout(9) was no longer invoked
during interrupt storm after vmlocking2 merge, I guess.

Should be pulled up to netbsd-5.


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

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

Modified files:

Index: src/sys/arch/x68k/dev/fd.c
diff -u src/sys/arch/x68k/dev/fd.c:1.93 src/sys/arch/x68k/dev/fd.c:1.94
--- src/sys/arch/x68k/dev/fd.c:1.93	Sun Jun  6 04:52:01 2010
+++ src/sys/arch/x68k/dev/fd.c	Sun Apr 10 15:23:06 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: fd.c,v 1.93 2010/06/06 04:52:01 mrg Exp $	*/
+/*	$NetBSD: fd.c,v 1.94 2011/04/10 15:23:06 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.93 2010/06/06 04:52:01 mrg Exp $);
+__KERNEL_RCSID(0, $NetBSD: fd.c,v 1.94 2011/04/10 15:23:06 tsutsui Exp $);
 
 #include rnd.h
 #include opt_ddb.h
@@ -212,7 +212,9 @@
 	struct fd_type *sc_deftype;	/* default type descriptor */
 	struct fd_type *sc_type;	/* current type descriptor */
 
+#if 0	/* see comments in fd_motor_on() */
 	struct callout sc_motoron_ch;
+#endif
 	struct callout sc_motoroff_ch;
 
 	daddr_t	sc_blkno;	/* starting block number */
@@ -278,7 +280,9 @@
 
 void fd_set_motor(struct fdc_softc *, int);
 void fd_motor_off(void *);
+#if 0
 void fd_motor_on(void *);
+#endif
 int fdcresult(struct fdc_softc *);
 int out_fdc(bus_space_tag_t, bus_space_handle_t, u_char);
 void fdcstart(struct fdc_softc *);
@@ -564,7 +568,9 @@
 	struct fd_type *type = fd_types[0];	/* XXX 1.2MB */
 	int drive = fa-fa_drive;
 
+#if 0
 	callout_init(fd-sc_motoron_ch, 0);
+#endif
 	callout_init(fd-sc_motoroff_ch, 0);
 
 	fd-sc_dev = self;
@@ -788,6 +794,7 @@
 	splx(s);
 }
 
+#if 0 /* on x68k motor on triggers interrupts by state change of ready line. */
 void
 fd_motor_on(void *arg)
 {
@@ -803,6 +810,7 @@
 		(void) fdcintr(fdc);
 	splx(s);
 }
+#endif
 
 int
 fdcresult(struct fdc_softc *fdc)
@@ -1082,9 +1090,11 @@
 			fd-sc_flags |= FD_MOTOR | FD_MOTOR_WAIT;
 			fd_set_motor(fdc, 0);
 			fdc-sc_state = MOTORWAIT;
+#if 0	/* no need to callout on x68k; motor on will trigger interrupts */
 			/* allow .5s for motor to stabilize */
 			callout_reset(fd-sc_motoron_ch, hz / 2,
 			fd_motor_on, fd);
+#endif
 			return 1;
 		}
 		/* Make sure the right drive is selected. */
@@ -1437,8 +1447,22 @@
 		goto doseek;
 
 	case MOTORWAIT:
+#if 0 /* on x68k motor on triggers interrupts by state change of ready line. */
 		if (fd-sc_flags  FD_MOTOR_WAIT)
 			return 1;		/* time's not up yet */
+#else
+		/* check drive ready by state change interrupt */
+		KASSERT(fd-sc_flags  FD_MOTOR_WAIT);
+		out_fdc(iot, ioh, NE7CMD_SENSEI);
+		tmp = fdcresult(fdc);
+		if (tmp != 2 || (st0  0xc0) != 0xc0 /* ready changed */) {
+			printf(%s: unexpected interrupt during MOTORWAIT,
+			device_xname(fd-sc_dev));
+			fdcpstatus(7, fdc);
+			return 1;
+		}
+		fd-sc_flags = ~FD_MOTOR_WAIT;
+#endif
 		goto doseek;
 
 	default:



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

2010-08-08 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Aug  8 09:30:29 UTC 2010

Modified Files:
src/sys/arch/x68k/dev: bmd.c

Log Message:
Probe not only ctrl address but also bank window address.
This prevents the wrong matching when other boards like
Neptune-X exist.  Reported by Yasushi Oshima.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x68k/dev/bmd.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/x68k/dev/bmd.c
diff -u src/sys/arch/x68k/dev/bmd.c:1.16 src/sys/arch/x68k/dev/bmd.c:1.17
--- src/sys/arch/x68k/dev/bmd.c:1.16	Thu Dec 18 05:56:42 2008
+++ src/sys/arch/x68k/dev/bmd.c	Sun Aug  8 09:30:29 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: bmd.c,v 1.16 2008/12/18 05:56:42 isaki Exp $	*/
+/*	$NetBSD: bmd.c,v 1.17 2010/08/08 09:30:29 isaki Exp $	*/
 
 /*
  * Copyright (c) 2002 Tetsuya Isaki. All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bmd.c,v 1.16 2008/12/18 05:56:42 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: bmd.c,v 1.17 2010/08/08 09:30:29 isaki Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -124,6 +124,8 @@
 	struct intio_attach_args *ia = aux;
 	bus_space_tag_t iot = ia-ia_bst;
 	bus_space_handle_t ioh;
+	int window;
+	int r;
 
 	if (ia-ia_addr == INTIOCF_ADDR_DEFAULT)
 		ia-ia_addr = BMD_ADDR1;
@@ -132,6 +134,7 @@
 	if (ia-ia_addr != BMD_ADDR1  ia-ia_addr != BMD_ADDR2)
 		return (0);
 
+	/* Check CTRL addr */
  	if (badaddr((void *)IIOV(ia-ia_addr)))
 		return (0);
 
@@ -139,8 +142,17 @@
 	if (bus_space_map(iot, ia-ia_addr, ia-ia_size, 0, ioh))
 		return (0);
 
+	/* Check window addr */
+	r = bus_space_read_1(iot, ioh, BMD_CTRL);
 	bus_space_unmap(iot, ioh, ia-ia_size);
 
+	if ((r  BMD_CTRL_WINDOW))
+		window = 0xef;
+	else
+		window = 0xee;
+	if (badaddr((void *)IIOV(window)))
+		return (0);
+
 	return (1);
 }
 



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

2010-07-24 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jul 24 13:15:13 UTC 2010

Modified Files:
src/sys/arch/x68k/dev: slhci_intio.c

Log Message:
Probe not only Nereid Ctrl port but also SL811HS/T port.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x68k/dev/slhci_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/x68k/dev/slhci_intio.c
diff -u src/sys/arch/x68k/dev/slhci_intio.c:1.13 src/sys/arch/x68k/dev/slhci_intio.c:1.14
--- src/sys/arch/x68k/dev/slhci_intio.c:1.13	Sat May  8 02:48:31 2010
+++ src/sys/arch/x68k/dev/slhci_intio.c	Sat Jul 24 13:15:13 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: slhci_intio.c,v 1.13 2010/05/08 02:48:31 isaki Exp $	*/
+/*	$NetBSD: slhci_intio.c,v 1.14 2010/07/24 13:15:13 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: slhci_intio.c,v 1.13 2010/05/08 02:48:31 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: slhci_intio.c,v 1.14 2010/07/24 13:15:13 isaki Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -87,6 +87,10 @@
 	   ia-ia_intr == SLHCI_INTIO_INTR2   ) )
 		return 0;
 
+	/* Whether the SL811 port is accessible or not */
+	if (badaddr((void *)IIOV(ia-ia_addr)))
+		return 0;
+
 	/* Whether the control port is accessible or not */
 	nc_addr = ia-ia_addr + NEREID_ADDR_OFFSET;
 	nc_size = 0x02;



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

2010-05-07 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat May  8 02:48:31 UTC 2010

Modified Files:
src/sys/arch/x68k/dev: slhci_intio.c

Log Message:
Correct rev1.11.
Fix panic reported by Yasushi Oshima.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x68k/dev/slhci_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/x68k/dev/slhci_intio.c
diff -u src/sys/arch/x68k/dev/slhci_intio.c:1.12 src/sys/arch/x68k/dev/slhci_intio.c:1.13
--- src/sys/arch/x68k/dev/slhci_intio.c:1.12	Thu Dec 18 05:56:42 2008
+++ src/sys/arch/x68k/dev/slhci_intio.c	Sat May  8 02:48:31 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: slhci_intio.c,v 1.12 2008/12/18 05:56:42 isaki Exp $	*/
+/*	$NetBSD: slhci_intio.c,v 1.13 2010/05/08 02:48:31 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: slhci_intio.c,v 1.12 2008/12/18 05:56:42 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: slhci_intio.c,v 1.13 2010/05/08 02:48:31 isaki Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -121,7 +121,7 @@
 	int nc_size;
 
 	sc-sc_dev = self;
-	sc-sc_bus.hci_private = self;
+	sc-sc_bus.hci_private = sc;
 
 	printf(: Nereid USB\n);
 



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

2010-01-09 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Jan  9 09:16:33 UTC 2010

Modified Files:
src/sys/arch/x68k/dev: grf.c par.c

Log Message:
Make compile with DEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x68k/dev/grf.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/x68k/dev/par.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/x68k/dev/grf.c
diff -u src/sys/arch/x68k/dev/grf.c:1.38 src/sys/arch/x68k/dev/grf.c:1.39
--- src/sys/arch/x68k/dev/grf.c:1.38	Sun Jan 18 02:40:05 2009
+++ src/sys/arch/x68k/dev/grf.c	Sat Jan  9 09:16:32 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: grf.c,v 1.38 2009/01/18 02:40:05 isaki Exp $	*/
+/*	$NetBSD: grf.c,v 1.39 2010/01/09 09:16:32 isaki Exp $	*/
 
 /*
  * Copyright (c) 1990, 1993
@@ -83,7 +83,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: grf.c,v 1.38 2009/01/18 02:40:05 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: grf.c,v 1.39 2010/01/09 09:16:32 isaki Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -329,8 +329,10 @@
 	vsize_t size;
 
 #ifdef DEBUG
-	if (grfdebug  GDB_MMAP)
-		printf(grfunmap(%d): dev %x addr %p\n, p-p_pid, dev, addr);
+	if (grfdebug  GDB_MMAP) {
+		printf(grfunmap(%d): dev %x addr %p\n,
+			p-p_pid, GRFUNIT(dev), addr);
+	}
 #endif
 	if (addr == 0)
 		return EINVAL;		/* XXX: how do we deal with this? */

Index: src/sys/arch/x68k/dev/par.c
diff -u src/sys/arch/x68k/dev/par.c:1.37 src/sys/arch/x68k/dev/par.c:1.38
--- src/sys/arch/x68k/dev/par.c:1.37	Wed Jun 25 08:14:59 2008
+++ src/sys/arch/x68k/dev/par.c	Sat Jan  9 09:16:32 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: par.c,v 1.37 2008/06/25 08:14:59 isaki Exp $	*/
+/*	$NetBSD: par.c,v 1.38 2010/01/09 09:16:32 isaki Exp $	*/
 
 /*
  * Copyright (c) 1982, 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: par.c,v 1.37 2008/06/25 08:14:59 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: par.c,v 1.38 2010/01/09 09:16:32 isaki Exp $);
 
 #include sys/param.h
 #include sys/errno.h
@@ -266,7 +266,7 @@
 	
 #ifdef DEBUG
 	if (pardebug  PDB_FOLLOW)
-		printf(parwrite(%x, %p)\n, dev, uio);
+		printf(parwrite(%x, %p)\n, UNIT(dev), uio);
 #endif
 	return (parrw(dev, uio));
 }



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

2009-11-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Nov 28 03:10:09 UTC 2009

Modified Files:
src/sys/arch/x68k/dev: if_ne_intio.c if_ne_neptune.c

Log Message:
Correct return value of ne_*_match().
It's attach priority, not ne2000 model.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x68k/dev/if_ne_intio.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x68k/dev/if_ne_neptune.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/x68k/dev/if_ne_intio.c
diff -u src/sys/arch/x68k/dev/if_ne_intio.c:1.13 src/sys/arch/x68k/dev/if_ne_intio.c:1.14
--- src/sys/arch/x68k/dev/if_ne_intio.c:1.13	Sun Jan 18 04:48:53 2009
+++ src/sys/arch/x68k/dev/if_ne_intio.c	Sat Nov 28 03:10:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ne_intio.c,v 1.13 2009/01/18 04:48:53 isaki Exp $	*/
+/*	$NetBSD: if_ne_intio.c,v 1.14 2009/11/28 03:10:09 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_ne_intio.c,v 1.13 2009/01/18 04:48:53 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_ne_intio.c,v 1.14 2009/11/28 03:10:09 isaki Exp $);
 
 #include opt_inet.h
 #include opt_ns.h
@@ -136,7 +136,7 @@
 
  out:
 	bus_space_unmap(iot, ioh, NE2000_NPORTS);
-	return rv;
+	return (rv != 0) ? 1 : 0;
 }
 
 static void

Index: src/sys/arch/x68k/dev/if_ne_neptune.c
diff -u src/sys/arch/x68k/dev/if_ne_neptune.c:1.17 src/sys/arch/x68k/dev/if_ne_neptune.c:1.18
--- src/sys/arch/x68k/dev/if_ne_neptune.c:1.17	Sun Jan 18 04:48:53 2009
+++ src/sys/arch/x68k/dev/if_ne_neptune.c	Sat Nov 28 03:10:09 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ne_neptune.c,v 1.17 2009/01/18 04:48:53 isaki Exp $	*/
+/*	$NetBSD: if_ne_neptune.c,v 1.18 2009/11/28 03:10:09 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_ne_neptune.c,v 1.17 2009/01/18 04:48:53 isaki Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_ne_neptune.c,v 1.18 2009/11/28 03:10:09 isaki Exp $);
 
 #include opt_inet.h
 #include opt_ns.h
@@ -122,7 +122,7 @@
 
  out:
 	bus_space_unmap(nict, nich, NE2000_NPORTS);
-	return (rv);
+	return (rv != 0) ? 1 : 0;
 }
 
 void



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

2009-11-07 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sat Nov  7 19:54:17 UTC 2009

Modified Files:
src/sys/arch/x68k/dev: mfp.h

Log Message:
Drop 3rd and 4th clauses on this TNF-copyrighted file.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x68k/dev/mfp.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/x68k/dev/mfp.h
diff -u src/sys/arch/x68k/dev/mfp.h:1.8 src/sys/arch/x68k/dev/mfp.h:1.9
--- src/sys/arch/x68k/dev/mfp.h:1.8	Sat Jan 17 10:02:23 2009
+++ src/sys/arch/x68k/dev/mfp.h	Sat Nov  7 19:54:17 2009
@@ -1,7 +1,6 @@
-/*	$NetBSD: mfp.h,v 1.8 2009/01/17 10:02:23 isaki Exp $	*/
+/*	$NetBSD: mfp.h,v 1.9 2009/11/07 19:54:17 snj Exp $	*/
 
 /*
- *
  * Copyright (c) 1998 NetBSD Foundation, Inc.
  * All rights reserved.
  *
@@ -13,12 +12,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *must display the following acknowledgement:
- *  This product includes software developed by Charles D. Cranor and
- *  Washington University.
- * 4. The name of the author may not be used to endorse or promote products
- *derived from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES