Module Name: src
Committed By: tls
Date: Sun Aug 10 06:57:05 UTC 2014
Modified Files:
src/tests/dev/md [tls-earlyentropy]: Makefile
src/tests/dev/scsipi [tls-earlyentropy]: Makefile t_cd.c
src/tests/dev/sysmon [tls-earlyentropy]: Makefile
Added Files:
src/tests/dev/scsipi/libscsitest [tls-earlyentropy]: Makefile
SCSITEST.ioconf scsitest.c scsitest.h scsitest_component.c
Log Message:
Rebase.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.6.1 src/tests/dev/md/Makefile
cvs rdiff -u -r1.3 -r1.3.22.1 src/tests/dev/scsipi/Makefile
cvs rdiff -u -r1.6 -r1.6.6.1 src/tests/dev/scsipi/t_cd.c
cvs rdiff -u -r0 -r1.3.4.2 src/tests/dev/scsipi/libscsitest/Makefile
cvs rdiff -u -r0 -r1.1.4.2 src/tests/dev/scsipi/libscsitest/SCSITEST.ioconf \
src/tests/dev/scsipi/libscsitest/scsitest.h \
src/tests/dev/scsipi/libscsitest/scsitest_component.c
cvs rdiff -u -r0 -r1.2.4.2 src/tests/dev/scsipi/libscsitest/scsitest.c
cvs rdiff -u -r1.2 -r1.2.22.1 src/tests/dev/sysmon/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/dev/md/Makefile
diff -u src/tests/dev/md/Makefile:1.3 src/tests/dev/md/Makefile:1.3.6.1
--- src/tests/dev/md/Makefile:1.3 Sun Dec 2 18:39:53 2012
+++ src/tests/dev/md/Makefile Sun Aug 10 06:57:05 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2012/12/02 18:39:53 pgoyette Exp $
+# $NetBSD: Makefile,v 1.3.6.1 2014/08/10 06:57:05 tls Exp $
#
.include <bsd.own.mk>
@@ -16,6 +16,7 @@ PROGS= h_mdserv
LDADD+= -lrumpdev_md -lrumpdev_disk -lrumpdev -lrumpvfs
LDADD+= -lrump
LDADD+= -lrumpuser
+LDADD+= -lrump
LDADD+= -lpthread
WARNS= 4
Index: src/tests/dev/scsipi/Makefile
diff -u src/tests/dev/scsipi/Makefile:1.3 src/tests/dev/scsipi/Makefile:1.3.22.1
--- src/tests/dev/scsipi/Makefile:1.3 Sat Sep 11 16:03:41 2010
+++ src/tests/dev/scsipi/Makefile Sun Aug 10 06:57:05 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2010/09/11 16:03:41 martin Exp $
+# $NetBSD: Makefile,v 1.3.22.1 2014/08/10 06:57:05 tls Exp $
#
.include <bsd.own.mk>
@@ -7,9 +7,18 @@ TESTSDIR= ${TESTSBASE}/dev/scsipi
TESTS_C= t_cd
-LDADD+= -lrumpdev_scsitest -lrumpdev_scsipi -lrumpdev_disk -lrumpdev -lrumpvfs
+CPPFLAGS+= -I${.CURDIR}/libscsitest
+
+# kernel component required by test
+SUBDIR= libscsitest
+SCSITESTDIR!= cd ${.CURDIR}/libscsitest && ${PRINTOBJDIR}
+LDFLAGS+= -L${SCSITESTDIR}
+LDADD+= -Wl,--whole-archive -lrumpdev_scsitest -Wl,--no-whole-archive
+
+LDADD+= -lrumpdev_scsipi -lrumpdev_disk -lrumpdev -lrumpvfs
LDADD+= -lrump -lutil
LDADD+= -lrumpuser -lpthread
+LDADD+= -lrump
WARNS= 4
Index: src/tests/dev/scsipi/t_cd.c
diff -u src/tests/dev/scsipi/t_cd.c:1.6 src/tests/dev/scsipi/t_cd.c:1.6.6.1
--- src/tests/dev/scsipi/t_cd.c:1.6 Fri Mar 15 16:18:49 2013
+++ src/tests/dev/scsipi/t_cd.c Sun Aug 10 06:57:05 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_cd.c,v 1.6 2013/03/15 16:18:49 martin Exp $ */
+/* $NetBSD: t_cd.c,v 1.6.6.1 2014/08/10 06:57:05 tls Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -36,7 +36,8 @@
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
-#include <rump/scsitest.h>
+
+#include "scsitest.h"
#include "../../h_macros.h"
Index: src/tests/dev/sysmon/Makefile
diff -u src/tests/dev/sysmon/Makefile:1.2 src/tests/dev/sysmon/Makefile:1.2.22.1
--- src/tests/dev/sysmon/Makefile:1.2 Mon Dec 20 04:56:18 2010
+++ src/tests/dev/sysmon/Makefile Sun Aug 10 06:57:05 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2010/12/20 04:56:18 pgoyette Exp $
+# $NetBSD: Makefile,v 1.2.22.1 2014/08/10 06:57:05 tls Exp $
#
.include <bsd.own.mk>
@@ -9,7 +9,9 @@ TESTS_C= t_swwdog
LDADD+= -lrumpdev_sysmon -lrumpdev -lrumpvfs
LDADD+= -lrump
-LDADD+= -lrumpuser -lpthread
+LDADD+= -lrumpuser
+LDADD+= -lrump
+LDADD+= -lpthread
WARNS= 4
Added files:
Index: src/tests/dev/scsipi/libscsitest/Makefile
diff -u /dev/null src/tests/dev/scsipi/libscsitest/Makefile:1.3.4.2
--- /dev/null Sun Aug 10 06:57:05 2014
+++ src/tests/dev/scsipi/libscsitest/Makefile Sun Aug 10 06:57:05 2014
@@ -0,0 +1,19 @@
+# $NetBSD: Makefile,v 1.3.4.2 2014/08/10 06:57:05 tls Exp $
+#
+
+.include <bsd.own.mk>
+
+RUMPTOP= ${NETBSDSRCDIR}/sys/rump
+
+LIB= rumpdev_scsitest
+IOCONF= SCSITEST.ioconf
+LIBISPRIVATE= #defined
+
+SRCS= scsitest.c
+SRCS+= scsitest_component.c
+
+CPPFLAGS+= -I${.CURDIR} -I${RUMPTOP}/librump/rumpkern
+
+.include "${RUMPTOP}/Makefile.rump"
+.include <bsd.lib.mk>
+.include <bsd.klinks.mk>
Index: src/tests/dev/scsipi/libscsitest/SCSITEST.ioconf
diff -u /dev/null src/tests/dev/scsipi/libscsitest/SCSITEST.ioconf:1.1.4.2
--- /dev/null Sun Aug 10 06:57:05 2014
+++ src/tests/dev/scsipi/libscsitest/SCSITEST.ioconf Sun Aug 10 06:57:05 2014
@@ -0,0 +1,12 @@
+# $NetBSD: SCSITEST.ioconf,v 1.1.4.2 2014/08/10 06:57:05 tls Exp $
+#
+
+ioconf scsitest
+
+include "conf/files"
+include "dev/scsipi/files.scsipi"
+include "rump/dev/files.rump"
+
+pseudo-root mainbus*
+
+scsitest0 at mainbus?
Index: src/tests/dev/scsipi/libscsitest/scsitest.h
diff -u /dev/null src/tests/dev/scsipi/libscsitest/scsitest.h:1.1.4.2
--- /dev/null Sun Aug 10 06:57:05 2014
+++ src/tests/dev/scsipi/libscsitest/scsitest.h Sun Aug 10 06:57:05 2014
@@ -0,0 +1,38 @@
+/* $NetBSD: scsitest.h,v 1.1.4.2 2014/08/10 06:57:05 tls Exp $ */
+
+/*
+ * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RUMP_SCSITEST_H_
+#define _RUMP_SCSITEST_H_
+
+enum {
+ RUMP_SCSITEST_NOISYSYNC,
+ RUMP_SCSITEST_MAXERROR
+};
+
+extern unsigned rump_scsitest_err[RUMP_SCSITEST_MAXERROR];
+
+#endif /* _RUMP_SCSITEST_H_ */
Index: src/tests/dev/scsipi/libscsitest/scsitest_component.c
diff -u /dev/null src/tests/dev/scsipi/libscsitest/scsitest_component.c:1.1.4.2
--- /dev/null Sun Aug 10 06:57:05 2014
+++ src/tests/dev/scsipi/libscsitest/scsitest_component.c Sun Aug 10 06:57:05 2014
@@ -0,0 +1,46 @@
+/* $NetBSD: scsitest_component.c,v 1.1.4.2 2014/08/10 06:57:05 tls Exp $ */
+
+/*
+ * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: scsitest_component.c,v 1.1.4.2 2014/08/10 06:57:05 tls Exp $");
+
+#include <sys/param.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/mbuf.h>
+#include <sys/stat.h>
+
+#include "ioconf.c"
+
+#include "rump_private.h"
+
+RUMP_COMPONENT(RUMP_COMPONENT_DEV)
+{
+
+ config_init_component(cfdriver_ioconf_scsitest,
+ cfattach_ioconf_scsitest, cfdata_ioconf_scsitest);
+}
Index: src/tests/dev/scsipi/libscsitest/scsitest.c
diff -u /dev/null src/tests/dev/scsipi/libscsitest/scsitest.c:1.2.4.2
--- /dev/null Sun Aug 10 06:57:05 2014
+++ src/tests/dev/scsipi/libscsitest/scsitest.c Sun Aug 10 06:57:05 2014
@@ -0,0 +1,259 @@
+/* $NetBSD: scsitest.c,v 1.2.4.2 2014/08/10 06:57:05 tls Exp $ */
+
+/*
+ * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * A SCSI target which is useful for debugging our scsipi driver stack.
+ * Currently it pretends to be a single CD.
+ *
+ * Freely add the necessary features for your tests. Just remember to
+ * run the atf test suite to make sure you didn't cause regressions to
+ * other tests.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: scsitest.c,v 1.2.4.2 2014/08/10 06:57:05 tls Exp $");
+
+#include <sys/param.h>
+#include <sys/atomic.h>
+#include <sys/buf.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/fcntl.h>
+
+#include <dev/scsipi/scsiconf.h>
+#include <dev/scsipi/scsipiconf.h>
+#include <dev/scsipi/scsi_disk.h>
+#include <dev/scsipi/scsipi_cd.h>
+#include <dev/scsipi/scsipi_all.h>
+
+#include <rump/rumpuser.h>
+
+#include "scsitest.h"
+
+int scsitest_match(device_t, cfdata_t, void *);
+void scsitest_attach(device_t, device_t, void *);
+
+struct scsitest {
+ struct scsipi_channel sc_channel;
+ struct scsipi_adapter sc_adapter;
+};
+
+CFATTACH_DECL_NEW(scsitest, sizeof(struct scsitest), scsitest_match,
+ scsitest_attach, NULL, NULL);
+
+/*
+ * tosi.iso can be used to deliver CD requests to a host file with the
+ * name in USE_TOSI_ISO (yes, it's extrasimplistic).
+ */
+//#define USE_TOSI_ISO
+
+#define CDBLOCKSIZE 2048
+static uint32_t mycdsize = 2048;
+static int isofd;
+
+#define MYCDISO "tosi.iso"
+
+unsigned rump_scsitest_err[RUMP_SCSITEST_MAXERROR];
+
+static void
+sense_notready(struct scsipi_xfer *xs)
+{
+ struct scsi_sense_data *sense = &xs->sense.scsi_sense;
+
+ xs->error = XS_SENSE;
+
+ sense->response_code = 0x70;
+ sense->flags = SKEY_NOT_READY;
+ sense->asc = 0x3A;
+ sense->ascq = 0x00;
+ sense->extra_len = 6;
+}
+
+/*
+ * This is pretty much a CD target for now
+ */
+static void
+scsitest_request(struct scsipi_channel *chan,
+ scsipi_adapter_req_t req, void *arg)
+{
+ struct scsipi_xfer *xs = arg;
+ struct scsipi_generic *cmd = xs->cmd;
+#ifdef USE_TOSI_ISO
+ int error;
+#endif
+
+ if (req != ADAPTER_REQ_RUN_XFER)
+ return;
+
+ //show_scsipi_xs(xs);
+
+ switch (cmd->opcode) {
+ case SCSI_TEST_UNIT_READY:
+ if (isofd == -1)
+ sense_notready(xs);
+
+ break;
+ case INQUIRY: {
+ struct scsipi_inquiry_data *inqbuf = (void *)xs->data;
+
+ memset(inqbuf, 0, sizeof(*inqbuf));
+ inqbuf->device = T_CDROM;
+ inqbuf->dev_qual2 = SID_REMOVABLE;
+ strcpy(inqbuf->vendor, "RUMPHOBO");
+ strcpy(inqbuf->product, "It's a LIE");
+ strcpy(inqbuf->revision, "0.00");
+ break;
+ }
+ case READ_CD_CAPACITY: {
+ struct scsipi_read_cd_cap_data *ret = (void *)xs->data;
+
+ _lto4b(CDBLOCKSIZE, ret->length);
+ _lto4b(mycdsize, ret->addr);
+
+ break;
+ }
+ case READ_DISCINFO: {
+ struct scsipi_read_discinfo_data *ret = (void *)xs->data;
+
+ memset(ret, 0, sizeof(*ret));
+ break;
+ }
+ case READ_TRACKINFO: {
+ struct scsipi_read_trackinfo_data *ret = (void *)xs->data;
+
+ _lto4b(mycdsize, ret->track_size);
+ break;
+ }
+ case READ_TOC: {
+ struct scsipi_toc_header *ret = (void *)xs->data;
+
+ memset(ret, 0, sizeof(*ret));
+ break;
+ }
+ case START_STOP: {
+ struct scsipi_start_stop *param = (void *)cmd;
+
+ if (param->how & SSS_LOEJ) {
+#ifdef USE_TOSI_ISO
+ rumpuser_close(isofd, &error);
+#endif
+ isofd = -1;
+ }
+ break;
+ }
+ case SCSI_SYNCHRONIZE_CACHE_10: {
+ if (isofd == -1) {
+ if ((xs->xs_control & XS_CTL_SILENT) == 0)
+ atomic_inc_uint(&rump_scsitest_err
+ [RUMP_SCSITEST_NOISYSYNC]);
+
+ sense_notready(xs);
+ }
+
+ break;
+ }
+ case GET_CONFIGURATION: {
+ memset(xs->data, 0, sizeof(struct scsipi_get_conf_data));
+ break;
+ }
+ case SCSI_READ_6_COMMAND: {
+#ifdef USE_TOSI_ISO
+ struct scsi_rw_6 *param = (void *)cmd;
+
+ printf("reading %d bytes from %d\n",
+ param->length * CDBLOCKSIZE,
+ _3btol(param->addr) * CDBLOCKSIZE);
+ rumpuser_pread(isofd, xs->data,
+ param->length * CDBLOCKSIZE,
+ _3btol(param->addr) * CDBLOCKSIZE,
+ &error);
+#endif
+
+ break;
+ }
+ case SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL:
+ /* hardcoded for now */
+ break;
+ default:
+ printf("unhandled opcode 0x%x\n", cmd->opcode);
+ break;
+ }
+
+ scsipi_done(xs);
+}
+
+int
+scsitest_match(device_t parent, cfdata_t match, void *aux)
+{
+#ifdef USE_TOSI_ISO
+ uint64_t fsize;
+ int error, ft;
+
+ if (rumpuser_getfileinfo(MYCDISO, &fsize, &ft, &error))
+ return 0;
+ if (ft != RUMPUSER_FT_REG)
+ return 0;
+ mycdsize = fsize / CDBLOCKSIZE;
+
+ if ((isofd = rumpuser_open(MYCDISO, RUMPUSER_OPEN_RDWR, &error)) == -1)
+ return 0;
+#else
+ /*
+ * We pretend to have a medium present initially, so != -1.
+ */
+ isofd = -2;
+#endif
+
+ return 1;
+}
+
+void
+scsitest_attach(device_t parent, device_t self, void *aux)
+{
+ struct scsitest *sc = device_private(self);
+
+ aprint_naive("\n");
+ aprint_normal("\n");
+
+ memset(&sc->sc_adapter, 0, sizeof(sc->sc_adapter));
+ sc->sc_adapter.adapt_nchannels = 1;
+ sc->sc_adapter.adapt_request = scsitest_request;
+ sc->sc_adapter.adapt_minphys = minphys;
+ sc->sc_adapter.adapt_dev = self;
+ sc->sc_adapter.adapt_max_periph = 1;
+ sc->sc_adapter.adapt_openings = 1;
+
+ memset(&sc->sc_channel, 0, sizeof(sc->sc_channel));
+ sc->sc_channel.chan_bustype = &scsi_bustype;
+ sc->sc_channel.chan_ntargets = 2;
+ sc->sc_channel.chan_nluns = 1;
+ sc->sc_channel.chan_id = 0;
+ sc->sc_channel.chan_flags = SCSIPI_CHAN_NOSETTLE;
+ sc->sc_channel.chan_adapter = &sc->sc_adapter;
+
+ config_found_ia(self, "scsi", &sc->sc_channel, scsiprint);
+}