Module Name: src
Committed By: abs
Date: Fri Jun 22 20:42:24 UTC 2012
Modified Files:
src/etc/etc.vax: MAKEDEV.conf
src/sys/arch/vax/conf: GENERIC INSTALL VAX780 majors.vax
src/sys/arch/vax/vax: disksubr.c
src/sys/dev: DEVNAMES
src/sys/dev/mscp: files.mscp mscp_disk.c mscp_subr.c
Log Message:
- Add racd* devices for MSCP based CD-ROM drives (RRD40s), as opposed
to mixing them in with the ra* disks, modelled loosely on how MSCP
rx* floppies are handled
- racd* defaults to the same single iso9660 partition as cd*
- Cleanup config option handling slightly so any combination of ra*,
rx* (and now raccd*) can be defined without build errors.
- Avoid ugly printf when disks have all zero disklabel magic number
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/etc/etc.vax/MAKEDEV.conf
cvs rdiff -u -r1.181 -r1.182 src/sys/arch/vax/conf/GENERIC
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/vax/conf/INSTALL
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/vax/conf/VAX780
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/vax/conf/majors.vax
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/vax/vax/disksubr.c
cvs rdiff -u -r1.274 -r1.275 src/sys/dev/DEVNAMES
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/mscp/files.mscp
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/mscp/mscp_disk.c
cvs rdiff -u -r1.41 -r1.42 src/sys/dev/mscp/mscp_subr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/etc/etc.vax/MAKEDEV.conf
diff -u src/etc/etc.vax/MAKEDEV.conf:1.13 src/etc/etc.vax/MAKEDEV.conf:1.14
--- src/etc/etc.vax/MAKEDEV.conf:1.13 Wed Oct 12 17:03:49 2011
+++ src/etc/etc.vax/MAKEDEV.conf Fri Jun 22 20:42:22 2012
@@ -1,9 +1,9 @@
-# $NetBSD: MAKEDEV.conf,v 1.13 2011/10/12 17:03:49 njoly Exp $
+# $NetBSD: MAKEDEV.conf,v 1.14 2012/06/22 20:42:22 abs Exp $
all_md)
makedev mt0 mt1 ts0 ts1 st0 st1 uk0 ss0 cd0 vt0
makedev ra0 ra1 ra2 ra3 hp0 hp1 hp2 hp3 sd0 sd1 sd2 sd3 rd0 rd1 rd2
- makedev dz0 dl0 dhu0 rx0 rx1
+ makedev dz0 dl0 dhu0 racd0 racd1 rx0 rx1
makedev scsibus0 scsibus1 scsibus2 scsibus3
makedev ses0 ses1 ses2 ses3
makedev std_vax
@@ -60,11 +60,12 @@ ht[0-9]*|tm[0-9]*|mt[0-9]*|ts[0-9]*|ut[0
esac
;;
-hp[0-9]*|hk[0-9]*|up[0-9]*|ra[0-9]*|rl[0-9]*|rb[0-9]*|rd[0-9]*|rx[0-9]*)
+hp[0-9]*|hk[0-9]*|up[0-9]*|ra[0-9]*|racd[0-9]*|rl[0-9]*|rb[0-9]*|rd[0-9]*|rx[0-9]*)
case $i in
hp*) name=hp; unit=${i#hp}; blk=0; chr=4;;
hk*) name=hk; unit=${i#hk}; blk=3; chr=11;;
up*) name=up; unit=${i#up}; blk=2; chr=13;;
+ racd*) name=racd; unit=${i#racd}; blk=28; chr=28;; # before ra*
ra*) name=ra; unit=${i#ra}; blk=9; chr=9;;
rb*) name=rb; unit=${i#rb}; blk=11; chr=23;;
rx*) name=rx; unit=${i#rx}; blk=12; chr=30;;
Index: src/sys/arch/vax/conf/GENERIC
diff -u src/sys/arch/vax/conf/GENERIC:1.181 src/sys/arch/vax/conf/GENERIC:1.182
--- src/sys/arch/vax/conf/GENERIC:1.181 Tue Jun 5 08:41:36 2012
+++ src/sys/arch/vax/conf/GENERIC Fri Jun 22 20:42:22 2012
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.181 2012/06/05 08:41:36 abs Exp $
+# $NetBSD: GENERIC,v 1.182 2012/06/22 20:42:22 abs Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@ include "arch/vax/conf/std.vax"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.181 $"
+#ident "GENERIC-$Revision: 1.182 $"
# Here are all different supported CPU types listed.
#options VAX8800 # VAX 8500, 8530, 8550, 8700, 8800
@@ -270,7 +270,8 @@ mscpbus* at uda?
mscpbus* at mtc?
mscpbus* at kdb?
-ra* at mscpbus? drive? # MSCP disk
+ra* at mscpbus? drive? # MSCP disk
+racd* at mscpbus? drive? # MSCP CD-ROM (RRD40)
rx* at mscpbus? drive? # MSCP floppy
mt* at mscpbus? drive? # MSCP tape
Index: src/sys/arch/vax/conf/INSTALL
diff -u src/sys/arch/vax/conf/INSTALL:1.59 src/sys/arch/vax/conf/INSTALL:1.60
--- src/sys/arch/vax/conf/INSTALL:1.59 Sun Mar 18 14:12:55 2012
+++ src/sys/arch/vax/conf/INSTALL Fri Jun 22 20:42:23 2012
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.59 2012/03/18 14:12:55 he Exp $
+# $NetBSD: INSTALL,v 1.60 2012/06/22 20:42:23 abs Exp $
#
# INSTALL kernel; all supported devices but nothing fancy.
#
@@ -160,6 +160,7 @@ mscpbus* at mtc?
# MSCP devices
ra* at mscpbus? drive? # MSCP disk
+racd* at mscpbus? drive? # MSCP CD-ROM (RRD40)
rx* at mscpbus? drive? # MSCP floppy
mt* at mscpbus? drive? # MSCP tape
Index: src/sys/arch/vax/conf/VAX780
diff -u src/sys/arch/vax/conf/VAX780:1.8 src/sys/arch/vax/conf/VAX780:1.9
--- src/sys/arch/vax/conf/VAX780:1.8 Sat Mar 10 21:51:57 2012
+++ src/sys/arch/vax/conf/VAX780 Fri Jun 22 20:42:23 2012
@@ -1,4 +1,4 @@
-# $NetBSD: VAX780,v 1.8 2012/03/10 21:51:57 joerg Exp $
+# $NetBSD: VAX780,v 1.9 2012/06/22 20:42:23 abs Exp $
#
# 11/780,750,730 machine description file
#
@@ -255,6 +255,7 @@ mscpbus* at mtc?
#mscpbus* at kdb?
ra* at mscpbus? drive? # MSCP disk
+racd* at mscpbus? drive? # MSCP CD-ROM (RRD40)
rx* at mscpbus? drive? # MSCP floppy
mt* at mscpbus? drive? # MSCP tape
Index: src/sys/arch/vax/conf/majors.vax
diff -u src/sys/arch/vax/conf/majors.vax:1.23 src/sys/arch/vax/conf/majors.vax:1.24
--- src/sys/arch/vax/conf/majors.vax:1.23 Thu Jun 30 20:09:38 2011
+++ src/sys/arch/vax/conf/majors.vax Fri Jun 22 20:42:23 2012
@@ -1,4 +1,4 @@
-# $NetBSD: majors.vax,v 1.23 2011/06/30 20:09:38 wiz Exp $
+# $NetBSD: majors.vax,v 1.24 2012/06/22 20:42:23 abs Exp $
#
# Device majors for vax
#
@@ -36,6 +36,7 @@ device-major gen char 25 vax8600 | va
vaxany
device-major lpa char 26 lpa
device-major ps char 27 ps
+device-major racd char 28 block 28 racd
device-major ad char 29 ad
device-major rx char 30 block 12 rx
device-major ik char 31 ik
Index: src/sys/arch/vax/vax/disksubr.c
diff -u src/sys/arch/vax/vax/disksubr.c:1.52 src/sys/arch/vax/vax/disksubr.c:1.53
--- src/sys/arch/vax/vax/disksubr.c:1.52 Tue Dec 14 23:44:49 2010
+++ src/sys/arch/vax/vax/disksubr.c Fri Jun 22 20:42:23 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: disksubr.c,v 1.52 2010/12/14 23:44:49 matt Exp $ */
+/* $NetBSD: disksubr.c,v 1.53 2012/06/22 20:42:23 abs Exp $ */
/*
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.52 2010/12/14 23:44:49 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.53 2012/06/22 20:42:23 abs Exp $");
#include "opt_compat_ultrix.h"
@@ -157,7 +157,8 @@ compat_label(dev_t dev, void (*strat)(st
int part;
if (dlp->magic != DEC_LABEL_MAGIC) {
- printf("label: %x\n",dlp->magic);
+ if (dlp->magic != 0)
+ printf("label: %x\n",dlp->magic);
msg = ((msg != NULL) ? msg: "no disk label");
goto done;
}
Index: src/sys/dev/DEVNAMES
diff -u src/sys/dev/DEVNAMES:1.274 src/sys/dev/DEVNAMES:1.275
--- src/sys/dev/DEVNAMES:1.274 Sun Jun 3 01:47:26 2012
+++ src/sys/dev/DEVNAMES Fri Jun 22 20:42:23 2012
@@ -1,4 +1,4 @@
-# $NetBSD: DEVNAMES,v 1.274 2012/06/03 01:47:26 nonaka Exp $
+# $NetBSD: DEVNAMES,v 1.275 2012/06/22 20:42:23 abs Exp $
#
# This file contains all used device names and defined attributes in
# alphabetical order. New devices added to the system somewhere should first
@@ -1114,6 +1114,7 @@ qsphy MI
qt MI
qv vax
ra MI
+racd MI
radio MI
radio MI Attribute
rambo mipsco
Index: src/sys/dev/mscp/files.mscp
diff -u src/sys/dev/mscp/files.mscp:1.7 src/sys/dev/mscp/files.mscp:1.8
--- src/sys/dev/mscp/files.mscp:1.7 Sun Jun 6 19:16:18 1999
+++ src/sys/dev/mscp/files.mscp Fri Jun 22 20:42:24 2012
@@ -1,4 +1,4 @@
-# $NetBSD: files.mscp,v 1.7 1999/06/06 19:16:18 ragge Exp $
+# $NetBSD: files.mscp,v 1.8 2012/06/22 20:42:24 abs Exp $
#
# File and device description for MSCP devices.
#
@@ -10,12 +10,16 @@ file dev/mscp/mscp_subr.c mscp
device mscpbus {drive = -1}
attach mscpbus at mscp
+device ra: disk
+attach ra at mscpbus
+
+device racd: disk
+attach racd at mscpbus
+
device rx: disk
attach rx at mscpbus
-device ra: disk
-attach ra at mscpbus
-file dev/mscp/mscp_disk.c ra | rx needs-flag
+file dev/mscp/mscp_disk.c ra | racd | rx needs-flag
device mt: tape
attach mt at mscpbus
Index: src/sys/dev/mscp/mscp_disk.c
diff -u src/sys/dev/mscp/mscp_disk.c:1.71 src/sys/dev/mscp/mscp_disk.c:1.72
--- src/sys/dev/mscp/mscp_disk.c:1.71 Sat Sep 12 18:01:50 2009
+++ src/sys/dev/mscp/mscp_disk.c Fri Jun 22 20:42:24 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: mscp_disk.c,v 1.71 2009/09/12 18:01:50 tsutsui Exp $ */
+/* $NetBSD: mscp_disk.c,v 1.72 2012/06/22 20:42:24 abs Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
@@ -73,6 +73,7 @@
/*
* RA disk device driver
* RX MSCP floppy disk device driver
+ * RRD MSCP CD device driver
*/
/*
@@ -81,7 +82,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.71 2009/09/12 18:01:50 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp_disk.c,v 1.72 2012/06/22 20:42:24 abs Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -125,19 +126,24 @@ struct ra_softc {
};
#define rx_softc ra_softc
+#define racd_softc ra_softc
-void rxattach(device_t, device_t, void *);
+void raattach(device_t, device_t, void *);
int rx_putonline(struct rx_softc *);
void rrmakelabel(struct disklabel *, long);
+int ra_putonline(dev_t, struct ra_softc *);
+static inline struct ra_softc *mscp_device_lookup(dev_t);
#if NRA
int ramatch(device_t, cfdata_t, void *);
-void raattach(device_t, device_t, void *);
-int ra_putonline(struct ra_softc *);
CFATTACH_DECL(ra, sizeof(struct ra_softc),
- ramatch, rxattach, NULL, NULL);
+ ramatch, raattach, NULL, NULL);
+
+#endif /* NRA */
+
+#if NRA || NRACD || NRX
dev_type_open(raopen);
dev_type_close(raclose);
@@ -148,6 +154,8 @@ dev_type_strategy(rastrategy);
dev_type_dump(radump);
dev_type_size(rasize);
+#if NRA
+
const struct bdevsw ra_bdevsw = {
raopen, raclose, rastrategy, raioctl, radump, rasize, D_DISK
};
@@ -177,45 +185,17 @@ ramatch(device_t parent, cfdata_t cf, vo
cf->cf_loc[MSCPBUSCF_DRIVE] != mp->mscp_unit)
return 0;
/*
- * Check if this disk is a floppy; then don't configure it.
+ * Check if this disk is a floppy (RX) or cd (RRD)
* Seems to be a safe way to test it per Chris Torek.
*/
if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) == 'X' - '@')
return 0;
+ if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) == 'R' - '@')
+ return 0;
return 1;
}
-/*
- * (Try to) put the drive online. This is done the first time the
- * drive is opened, or if it har fallen offline.
- */
-int
-ra_putonline(struct ra_softc *ra)
-{
- struct disklabel *dl;
- const char *msg;
- int maj;
-
- if (rx_putonline(ra) != MSCP_DONE)
- return MSCP_FAILED;
-
- dl = ra->ra_disk.dk_label;
-
- ra->ra_state = DK_RDLABEL;
- printf("%s", device_xname(&ra->ra_dev));
- maj = cdevsw_lookup_major(&ra_cdevsw);
- if ((msg = readdisklabel(MAKEDISKDEV(maj, device_unit(&ra->ra_dev),
- RAW_PART), rastrategy, dl, NULL)) != NULL)
- printf(": %s", msg);
- else {
- ra->ra_havelabel = 1;
- ra->ra_state = DK_OPEN;
- }
-
- printf(": size %d sectors\n", dl->d_secperunit);
-
- return MSCP_DONE;
-}
+#endif /* NRA */
/*
* Open a drive.
@@ -224,13 +204,11 @@ ra_putonline(struct ra_softc *ra)
int
raopen(dev_t dev, int flag, int fmt, struct lwp *l)
{
- struct ra_softc *ra;
- int error, part, unit, mask;
+ struct ra_softc *ra = mscp_device_lookup(dev);
+ int error, part, mask;
/*
* Make sure this is a reasonable open request.
*/
- unit = DISKUNIT(dev);
- ra = device_lookup_private(&ra_cd, unit);
if (!ra)
return ENXIO;
@@ -252,7 +230,7 @@ raopen(dev_t dev, int flag, int fmt, str
* the disk online (and read the label).
*/
if (ra->ra_state == DK_CLOSED) {
- if (ra_putonline(ra) == MSCP_FAILED) {
+ if (ra_putonline(dev, ra) == MSCP_FAILED) {
error = ENXIO;
goto bad1;
}
@@ -300,8 +278,7 @@ raopen(dev_t dev, int flag, int fmt, str
int
raclose(dev_t dev, int flags, int fmt, struct lwp *l)
{
- int unit = DISKUNIT(dev);
- struct ra_softc *ra = device_lookup_private(&ra_cd, unit);
+ struct ra_softc *ra = mscp_device_lookup(dev);
int mask = (1 << DISKPART(dev));
mutex_enter(&ra->ra_disk.dk_openlock);
@@ -342,15 +319,15 @@ raclose(dev_t dev, int flags, int fmt, s
void
rastrategy(struct buf *bp)
{
+ struct ra_softc *ra = mscp_device_lookup(bp->b_dev);
int unit;
- struct ra_softc *ra;
int b;
/*
* Make sure this is a reasonable drive to use.
*/
unit = DISKUNIT(bp->b_dev);
- if ((ra = device_lookup_private(&ra_cd, unit)) == NULL) {
+ if (ra == NULL) {
bp->b_error = ENXIO;
goto done;
}
@@ -368,7 +345,7 @@ rastrategy(struct buf *bp)
/* If disk is not online, try to put it online */
if (ra->ra_state == DK_CLOSED)
- if (ra_putonline(ra) == MSCP_FAILED) {
+ if (ra_putonline(bp->b_dev, ra) == MSCP_FAILED) {
bp->b_error = EIO;
goto done;
}
@@ -411,9 +388,8 @@ rawrite(dev_t dev, struct uio *uio, int
int
raioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
{
- int unit = DISKUNIT(dev);
struct disklabel *lp, *tp;
- struct ra_softc *ra = device_lookup_private(&ra_cd, unit);
+ struct ra_softc *ra = mscp_device_lookup(dev);
int error = 0;
#ifdef __HAVE_OLD_DISKLABEL
struct disklabel newlabel;
@@ -560,40 +536,38 @@ radump(dev_t dev, daddr_t blkno, void *v
int
rasize(dev_t dev)
{
- int unit = DISKUNIT(dev);
- struct ra_softc *ra;
+ struct ra_softc *ra = mscp_device_lookup(dev);
- ra = device_lookup_private(&ra_cd, unit);
if (!ra)
return -1;
if (ra->ra_state == DK_CLOSED)
- if (ra_putonline(ra) == MSCP_FAILED)
+ if (ra_putonline(dev, ra) == MSCP_FAILED)
return -1;
return ra->ra_disk.dk_label->d_partitions[DISKPART(dev)].p_size *
(ra->ra_disk.dk_label->d_secsize / DEV_BSIZE);
}
-#endif /* NRA */
+#endif /* NRA || NRACD || NRX */
#if NRX
int rxmatch(device_t, cfdata_t, void *);
CFATTACH_DECL(rx, sizeof(struct rx_softc),
- rxmatch, rxattach, NULL, NULL);
+ rxmatch, raattach, NULL, NULL);
dev_type_open(rxopen);
dev_type_read(rxread);
dev_type_write(rxwrite);
dev_type_ioctl(rxioctl);
dev_type_strategy(rxstrategy);
-dev_type_dump(rxdump);
+dev_type_dump(radump);
dev_type_size(rxsize);
const struct bdevsw rx_bdevsw = {
- rxopen, nullclose, rxstrategy, rxioctl, rxdump, rxsize, D_DISK
+ rxopen, nullclose, rxstrategy, rxioctl, radump, rxsize, D_DISK
};
const struct cdevsw rx_cdevsw = {
@@ -621,7 +595,7 @@ rxmatch(device_t parent, cfdata_t cf, vo
cf->cf_loc[MSCPBUSCF_DRIVE] != mp->mscp_unit)
return 0;
/*
- * Check if this disk is a floppy; then configure it.
+ * Check if this disk is a floppy (RX)
* Seems to be a safe way to test it per Chris Torek.
*/
if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) == 'X' - '@')
@@ -631,13 +605,68 @@ rxmatch(device_t parent, cfdata_t cf, vo
#endif /* NRX */
+#if NRACD
+
+/* Use almost all ra* routines for racd */
+
+int racdmatch(device_t, cfdata_t, void *);
+
+CFATTACH_DECL(racd, sizeof(struct racd_softc),
+ racdmatch, raattach, NULL, NULL);
+
+dev_type_open(raopen);
+dev_type_read(raread);
+dev_type_write(rawrite);
+dev_type_ioctl(raioctl);
+dev_type_strategy(rastrategy);
+dev_type_dump(radump);
+dev_type_size(rasize);
+
+const struct bdevsw racd_bdevsw = {
+ raopen, nullclose, rastrategy, raioctl, radump, rasize, D_DISK
+};
+
+const struct cdevsw racd_cdevsw = {
+ raopen, nullclose, raread, rawrite, raioctl,
+ nostop, notty, nopoll, nommap, nokqfilter, D_DISK
+};
+
+static struct dkdriver racddkdriver = {
+ rastrategy, minphys
+};
+
+/*
+ * More driver definitions, for generic MSCP code.
+ */
+
+int
+racdmatch(device_t parent, cfdata_t cf, void *aux)
+{
+ struct drive_attach_args *da = aux;
+ struct mscp *mp = da->da_mp;
+
+ if ((da->da_typ & MSCPBUS_DISK) == 0)
+ return 0;
+ if (cf->cf_loc[MSCPBUSCF_DRIVE] != MSCPBUSCF_DRIVE_DEFAULT &&
+ cf->cf_loc[MSCPBUSCF_DRIVE] != mp->mscp_unit)
+ return 0;
+ /*
+ * Check if this disk is a CD (RRD)
+ */
+ if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) == 'R' - '@')
+ return 1;
+ return 0;
+}
+
+#endif /* NRACD */
+
/*
* The attach routine only checks and prints drive type.
* Bringing the disk online is done when the disk is accessed
* the first time.
*/
void
-rxattach(device_t parent, device_t self, void *aux)
+raattach(device_t parent, device_t self, void *aux)
{
struct rx_softc *rx = device_private(self);
struct drive_attach_args *da = aux;
@@ -655,8 +684,14 @@ rxattach(device_t parent, device_t self,
disk_init((struct disk *)&rx->ra_disk, device_xname(&rx->ra_dev),
&rxdkdriver);
#endif
+#if NRACD
+ if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) == 'R' - '@')
+ disk_init((struct disk *)&rx->ra_disk, device_xname(&rx->ra_dev),
+ &racddkdriver);
+#endif
#if NRA
- if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) != 'X' - '@')
+ if (MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) != 'X' - '@' &&
+ MSCP_MID_ECH(1, mp->mscp_guse.guse_mediaid) != 'R' - '@')
disk_init((struct disk *)&rx->ra_disk, device_xname(&rx->ra_dev),
&radkdriver);
#endif
@@ -849,14 +884,6 @@ rxioctl(dev_t dev, u_long cmd, void *dat
}
int
-rxdump(dev_t dev, daddr_t blkno, void *va, size_t size)
-{
-
- /* Not likely. */
- return ENXIO;
-}
-
-int
rxsize(dev_t dev)
{
@@ -906,27 +933,12 @@ rrdgram(device_t usc, struct mscp *mp, s
mp->mscp_erd.erd_sdistat[11]);
}
+
void
rriodone(device_t usc, struct buf *bp)
{
- struct ra_softc *ra;
- int unit;
+ struct ra_softc *ra = device_private(usc);
- /* We assume that this is a reasonable drive. ra_strategy should
- already have verified it. Thus, no checks here... /bqt */
- unit = DISKUNIT(bp->b_dev);
-#if NRA
- if (cdevsw_lookup(bp->b_dev) == &ra_cdevsw)
- ra = device_lookup_private(&ra_cd, unit);
- else
-#endif
-#if NRX
- if (cdevsw_lookup(bp->b_dev) == &rx_cdevsw)
- ra = device_lookup_private(&rx_cd, unit);
- else
-#endif
- panic("rriodone: unexpected major %"PRIu32" unit %u",
- major(bp->b_dev), unit);
disk_unbusy(&ra->ra_disk, bp->b_bcount, (bp->b_flags & B_READ));
biodone(bp);
@@ -940,19 +952,19 @@ rriodone(device_t usc, struct buf *bp)
int
rronline(device_t usc, struct mscp *mp)
{
- struct rx_softc *rx = (struct rx_softc *)usc;
+ struct ra_softc *ra = device_private(usc);
struct disklabel *dl;
- wakeup((void *)&rx->ra_state);
+ wakeup((void *)&ra->ra_state);
if ((mp->mscp_status & M_ST_MASK) != M_ST_SUCCESS) {
aprint_error_dev(usc, "attempt to bring on line failed: ");
mscp_printevent(mp);
return (MSCP_FAILED);
}
- rx->ra_state = DK_OPEN;
+ ra->ra_state = DK_OPEN;
- dl = rx->ra_disk.dk_label;
+ dl = ra->ra_disk.dk_label;
dl->d_secperunit = (daddr_t)mp->mscp_onle.onle_unitsize;
if (dl->d_secpercyl) {
@@ -963,7 +975,7 @@ rronline(device_t usc, struct mscp *mp)
dl->d_type = DTYPE_FLOPPY;
dl->d_rpm = 300;
}
- rrmakelabel(dl, rx->ra_mediaid);
+ rrmakelabel(dl, ra->ra_mediaid);
return (MSCP_DONE);
}
@@ -1038,7 +1050,7 @@ rrreplace(device_t usc, struct mscp *mp)
int
rrioerror(device_t usc, struct mscp *mp, struct buf *bp)
{
- struct ra_softc *ra = (void *)usc;
+ struct ra_softc *ra = device_private(usc);
int code = mp->mscp_event;
switch (code & M_ST_MASK) {
@@ -1069,23 +1081,15 @@ rrioerror(device_t usc, struct mscp *mp,
void
rrfillin(struct buf *bp, struct mscp *mp)
{
- struct rx_softc *rx = 0; /* Wall */
+ struct ra_softc *ra;
struct disklabel *lp;
- int unit = DISKUNIT(bp->b_dev);
int part = DISKPART(bp->b_dev);
-#if NRA
- if (cdevsw_lookup(bp->b_dev) == &ra_cdevsw)
- rx = device_lookup_private(&ra_cd, unit);
-#endif
-#if NRX
- if (cdevsw_lookup(bp->b_dev) == &rx_cdevsw)
- rx = device_lookup_private(&rx_cd, unit);
-#endif
- lp = rx->ra_disk.dk_label;
+ ra = mscp_device_lookup(bp->b_dev);
+ lp = ra->ra_disk.dk_label;
mp->mscp_seq.seq_lbn = lp->d_partitions[part].p_offset + bp->b_blkno;
- mp->mscp_unit = rx->ra_hwunit;
+ mp->mscp_unit = ra->ra_hwunit;
mp->mscp_seq.seq_bytecount = bp->b_bcount;
}
@@ -1099,3 +1103,70 @@ rrbb(device_t usc, struct mscp *mp, stru
panic("udabb");
}
+
+/*
+ * (Try to) put the drive online. This is done the first time the
+ * drive is opened, or if it has fallen offline.
+ */
+int
+ra_putonline(dev_t dev, struct ra_softc *ra)
+{
+ struct disklabel *dl;
+ const char *msg;
+
+ if (rx_putonline(ra) != MSCP_DONE)
+ return MSCP_FAILED;
+
+ dl = ra->ra_disk.dk_label;
+
+ ra->ra_state = DK_RDLABEL;
+ printf("%s", device_xname(&ra->ra_dev));
+ if ((msg = readdisklabel(
+ MAKEDISKDEV(major(dev), device_unit(&ra->ra_dev), RAW_PART),
+ rastrategy, dl, NULL)) == NULL) {
+ ra->ra_havelabel = 1;
+ ra->ra_state = DK_OPEN;
+ }
+#if NRACD
+ else if (cdevsw_lookup(dev) == &racd_cdevsw) {
+ dl->d_partitions[0].p_offset = 0;
+ dl->d_partitions[0].p_size = dl->d_secperunit;
+ dl->d_partitions[0].p_fstype = FS_ISO9660;
+ }
+#endif /* NRACD */
+ else {
+ printf(": %s", msg);
+ }
+
+ printf(": size %d sectors\n", dl->d_secperunit);
+
+ return MSCP_DONE;
+}
+
+
+static inline struct ra_softc *
+mscp_device_lookup(dev_t dev)
+{
+ struct ra_softc *ra;
+ int unit;
+
+ unit = DISKUNIT(dev);
+#if NRA
+ if (cdevsw_lookup(dev) == &ra_cdevsw)
+ ra = device_lookup_private(&ra_cd, unit);
+ else
+#endif
+#if NRACD
+ if (cdevsw_lookup(dev) == &racd_cdevsw)
+ ra = device_lookup_private(&racd_cd, unit);
+ else
+#endif
+#if NRX
+ if (cdevsw_lookup(dev) == &rx_cdevsw)
+ ra = device_lookup_private(&rx_cd, unit);
+ else
+#endif
+ panic("mscp_device_lookup: unexpected major %"PRIu32" unit %u",
+ major(dev), unit);
+ return ra;
+}
Index: src/sys/dev/mscp/mscp_subr.c
diff -u src/sys/dev/mscp/mscp_subr.c:1.41 src/sys/dev/mscp/mscp_subr.c:1.42
--- src/sys/dev/mscp/mscp_subr.c:1.41 Tue May 12 14:37:59 2009
+++ src/sys/dev/mscp/mscp_subr.c Fri Jun 22 20:42:24 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: mscp_subr.c,v 1.41 2009/05/12 14:37:59 cegger Exp $ */
+/* $NetBSD: mscp_subr.c,v 1.42 2012/06/22 20:42:24 abs Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
@@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mscp_subr.c,v 1.41 2009/05/12 14:37:59 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mscp_subr.c,v 1.42 2012/06/22 20:42:24 abs Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -159,7 +159,7 @@ mscp_match(device_t parent, cfdata_t mat
{
struct mscp_attach_args *ma = aux;
-#if NRA || NRX
+#if NRA || NRACD || NRX
if (ma->ma_type & MSCPBUS_DISK)
return 1;
#endif
@@ -245,7 +245,7 @@ mscp_attach(device_t parent, device_t se
}
-#if NRA
+#if NRA || NRACD || NRX
if (ma->ma_type & MSCPBUS_DISK) {
extern struct mscp_device ra_device;