1 1.1 pgoyette /* $NetBSD: scsi_subr.c,v 1.1 2022/04/14 16:50:26 pgoyette Exp $ */ 2 1.1 pgoyette 3 1.1 pgoyette /*- 4 1.1 pgoyette * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc. 5 1.1 pgoyette * All rights reserved. 6 1.1 pgoyette * 7 1.1 pgoyette * This code is derived from software contributed to The NetBSD Foundation 8 1.1 pgoyette * by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace 9 1.1 pgoyette * Simulation Facility, NASA Ames Research Center. 10 1.1 pgoyette * 11 1.1 pgoyette * Redistribution and use in source and binary forms, with or without 12 1.1 pgoyette * modification, are permitted provided that the following conditions 13 1.1 pgoyette * are met: 14 1.1 pgoyette * 1. Redistributions of source code must retain the above copyright 15 1.1 pgoyette * notice, this list of conditions and the following disclaimer. 16 1.1 pgoyette * 2. Redistributions in binary form must reproduce the above copyright 17 1.1 pgoyette * notice, this list of conditions and the following disclaimer in the 18 1.1 pgoyette * documentation and/or other materials provided with the distribution. 19 1.1 pgoyette * 20 1.1 pgoyette * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 1.1 pgoyette * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 1.1 pgoyette * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 1.1 pgoyette * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 1.1 pgoyette * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 1.1 pgoyette * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 1.1 pgoyette * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 1.1 pgoyette * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 1.1 pgoyette * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 1.1 pgoyette * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 1.1 pgoyette * POSSIBILITY OF SUCH DAMAGE. 31 1.1 pgoyette */ 32 1.1 pgoyette 33 1.1 pgoyette /* 34 1.1 pgoyette * Originally written by Julian Elischer (julian (at) tfs.com) 35 1.1 pgoyette * for TRW Financial Systems for use under the MACH(2.5) operating system. 36 1.1 pgoyette * 37 1.1 pgoyette * TRW Financial Systems, in accordance with their agreement with Carnegie 38 1.1 pgoyette * Mellon University, makes this software available to CMU to distribute 39 1.1 pgoyette * or use in any manner that they see fit as long as this message is kept with 40 1.1 pgoyette * the software. For this reason TFS also grants any other persons or 41 1.1 pgoyette * organisations permission to use or modify this software. 42 1.1 pgoyette * 43 1.1 pgoyette * TFS supplies this software to be publicly redistributed 44 1.1 pgoyette * on the understanding that TFS is not responsible for the correct 45 1.1 pgoyette * functioning of this software in any circumstances. 46 1.1 pgoyette * 47 1.1 pgoyette * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992 48 1.1 pgoyette */ 49 1.1 pgoyette 50 1.1 pgoyette #include <sys/cdefs.h> 51 1.1 pgoyette __KERNEL_RCSID(0, "$NetBSD: scsi_subr.c,v 1.1 2022/04/14 16:50:26 pgoyette Exp $"); 52 1.1 pgoyette 53 1.1 pgoyette #include <sys/param.h> 54 1.1 pgoyette #include <sys/systm.h> 55 1.1 pgoyette 56 1.1 pgoyette #include <sys/device.h> 57 1.1 pgoyette #include <sys/kernel.h> 58 1.1 pgoyette #include <sys/proc.h> 59 1.1 pgoyette #include <sys/module.h> 60 1.1 pgoyette 61 1.1 pgoyette #include <dev/scsipi/scsi_all.h> 62 1.1 pgoyette #include <dev/scsipi/scsipi_all.h> 63 1.1 pgoyette #include <dev/scsipi/scsiconf.h> 64 1.1 pgoyette 65 1.1 pgoyette const struct scsipi_bustype scsi_bustype = { 66 1.1 pgoyette .bustype_type = SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, 67 1.1 pgoyette SCSIPI_BUSTYPE_SCSI_PSCSI), 68 1.1 pgoyette .bustype_cmd = scsi_scsipi_cmd, 69 1.1 pgoyette .bustype_interpret_sense = scsipi_interpret_sense, 70 1.1 pgoyette .bustype_printaddr = scsi_print_addr, 71 1.1 pgoyette .bustype_kill_pending = scsi_kill_pending, 72 1.1 pgoyette .bustype_async_event_xfer_mode = scsi_async_event_xfer_mode, 73 1.1 pgoyette }; 74 1.1 pgoyette 75 1.1 pgoyette const struct scsipi_bustype scsi_fc_bustype = { 76 1.1 pgoyette .bustype_type = SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, 77 1.1 pgoyette SCSIPI_BUSTYPE_SCSI_FC), 78 1.1 pgoyette .bustype_cmd = scsi_scsipi_cmd, 79 1.1 pgoyette .bustype_interpret_sense = scsipi_interpret_sense, 80 1.1 pgoyette .bustype_printaddr = scsi_print_addr, 81 1.1 pgoyette .bustype_kill_pending = scsi_kill_pending, 82 1.1 pgoyette .bustype_async_event_xfer_mode = scsi_fc_sas_async_event_xfer_mode, 83 1.1 pgoyette }; 84 1.1 pgoyette 85 1.1 pgoyette const struct scsipi_bustype scsi_sas_bustype = { 86 1.1 pgoyette .bustype_type = SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, 87 1.1 pgoyette SCSIPI_BUSTYPE_SCSI_SAS), 88 1.1 pgoyette .bustype_cmd = scsi_scsipi_cmd, 89 1.1 pgoyette .bustype_interpret_sense = scsipi_interpret_sense, 90 1.1 pgoyette .bustype_printaddr = scsi_print_addr, 91 1.1 pgoyette .bustype_kill_pending = scsi_kill_pending, 92 1.1 pgoyette .bustype_async_event_xfer_mode = scsi_fc_sas_async_event_xfer_mode, 93 1.1 pgoyette }; 94 1.1 pgoyette 95 1.1 pgoyette const struct scsipi_bustype scsi_usb_bustype = { 96 1.1 pgoyette .bustype_type = SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, 97 1.1 pgoyette SCSIPI_BUSTYPE_SCSI_USB), 98 1.1 pgoyette .bustype_cmd = scsi_scsipi_cmd, 99 1.1 pgoyette .bustype_interpret_sense = scsipi_interpret_sense, 100 1.1 pgoyette .bustype_printaddr = scsi_print_addr, 101 1.1 pgoyette .bustype_kill_pending = scsi_kill_pending, 102 1.1 pgoyette .bustype_async_event_xfer_mode = NULL, 103 1.1 pgoyette }; 104 1.1 pgoyette 105 1.1 pgoyette int 106 1.1 pgoyette scsiprint(void *aux, const char *pnp) 107 1.1 pgoyette { 108 1.1 pgoyette struct scsipi_channel *chan = aux; 109 1.1 pgoyette struct scsipi_adapter *adapt = chan->chan_adapter; 110 1.1 pgoyette 111 1.1 pgoyette /* only "scsibus"es can attach to "scsi"s; easy. */ 112 1.1 pgoyette if (pnp) 113 1.1 pgoyette aprint_normal("scsibus at %s", pnp); 114 1.1 pgoyette 115 1.1 pgoyette /* don't print channel if the controller says there can be only one. */ 116 1.1 pgoyette if (adapt->adapt_nchannels != 1) 117 1.1 pgoyette aprint_normal(" channel %d", chan->chan_channel); 118 1.1 pgoyette 119 1.1 pgoyette return (UNCONF); 120 1.1 pgoyette } 121 1.1 pgoyette 122 1.1 pgoyette MODULE(MODULE_CLASS_EXEC, scsi_subr, NULL); 123 1.1 pgoyette 124 1.1 pgoyette static int scsi_subr_modcmd(modcmd_t cmd, void *opaque) 125 1.1 pgoyette { 126 1.1 pgoyette 127 1.1 pgoyette switch(cmd) { 128 1.1 pgoyette case MODULE_CMD_INIT: 129 1.1 pgoyette case MODULE_CMD_FINI: 130 1.1 pgoyette return 0; 131 1.1 pgoyette default: 132 1.1 pgoyette return ENOTTY; 133 1.1 pgoyette } 134 1.1 pgoyette } 135