1/* $NecBSD: scsi_low_pisa.c,v 1.13.18.1 2001/06/08 06:27:48 honda Exp $ */ 2/* $NetBSD$ */ 3/*- 4 * [NetBSD for NEC PC-98 series] 5 * Copyright (c) 1995, 1996, 1997, 1998 6 * NetBSD/pc98 porting staff. All rights reserved. 7 * Copyright (c) 1995, 1996, 1997, 1998 8 * Naofumi HONDA. All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> 35__FBSDID("$FreeBSD$"); 36 37#ifdef __NetBSD__ 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/kernel.h> 41#include <sys/device.h> 42#include <sys/errno.h> 43 44#include <machine/bus.h> 45#include <machine/intr.h> 46 47#include <dev/isa/isareg.h> 48#include <dev/isa/isavar.h> 49 50#include <dev/isa/pisaif.h> 51 52#include <machine/dvcfg.h> 53 54#include <dev/scsipi/scsi_all.h> 55#include <dev/scsipi/scsipi_all.h> 56#include <dev/scsipi/scsiconf.h> 57#include <dev/scsipi/scsi_disk.h> 58 59#include <i386/Cbus/dev/scsi_low.h> 60#include <i386/Cbus/dev/scsi_low_pisa.h> 61 62#define SCSIBUS_RESCAN 63 64int 65scsi_low_deactivate_pisa(dh) 66 pisa_device_handle_t dh; 67{ 68 struct scsi_low_softc *sc = PISA_DEV_SOFTC(dh); 69 70 if (scsi_low_deactivate(sc) != 0) 71 return EBUSY; 72 return 0; 73} 74 75int 76scsi_low_activate_pisa(dh) 77 pisa_device_handle_t dh; 78{ 79 struct scsi_low_softc *sc = PISA_DEV_SOFTC(dh); 80 slot_device_res_t dr = PISA_RES_DR(dh); 81 82 sc->sl_cfgflags = DVCFG_MKCFG(DVCFG_MAJOR(sc->sl_cfgflags), \ 83 DVCFG_MINOR(PISA_DR_DVCFG(dr))); 84 sc->sl_irq = PISA_DR_IRQ(dr); 85 86 if (scsi_low_activate(sc) != 0) 87 return EBUSY; 88 89 /* rescan the scsi bus */ 90#ifdef SCSIBUS_RESCAN 91 if (scsi_low_is_busy(sc) == 0 && 92 PISA_RES_EVENT(dh) == PISA_EVENT_INSERT) 93 scsi_probe_busses((int) sc->sl_si.si_splp->scsipi_scsi.scsibus, 94 -1, -1); 95#endif 96 return 0; 97} 98 99int 100scsi_low_notify_pisa(dh, ev) 101 pisa_device_handle_t dh; 102 pisa_event_t ev; 103{ 104 struct scsi_low_softc *sc = PISA_DEV_SOFTC(dh); 105 106 switch(ev) 107 { 108 case PISA_EVENT_QUERY_SUSPEND: 109 if (scsi_low_is_busy(sc) != 0) 110 return SD_EVENT_STATUS_BUSY; 111 break; 112 113 default: 114 break; 115 } 116 return 0; 117} 118#endif /* __NetBSD__ */ 119 120#ifdef __FreeBSD__ 121#include <sys/param.h> 122#include <sys/systm.h> 123#include <sys/kernel.h> 124#if __FreeBSD_version >= 500001 125#include <sys/bio.h> 126#endif 127#include <sys/buf.h> 128#include <sys/queue.h> 129#include <sys/device_port.h> 130#include <sys/module.h> 131 132#include <cam/scsi/scsi_low.h> 133#include <cam/scsi/scsi_low_pisa.h> 134 135int 136scsi_low_deactivate_pisa(sc) 137 struct scsi_low_softc *sc; 138{ 139 140 if (scsi_low_deactivate(sc) != 0) 141 return EBUSY; 142 return 0; 143} 144 145int 146scsi_low_activate_pisa(sc, flags) 147 struct scsi_low_softc *sc; 148 int flags; 149{ 150 151 sc->sl_cfgflags = ((sc->sl_cfgflags & 0xffff0000) | 152 (flags & 0x00ff)); 153 154 if (scsi_low_activate(sc) != 0) 155 return EBUSY; 156 return 0; 157} 158 159static moduledata_t scsi_low_moduledata = { 160 "scsi_low", 161 NULL, 162 NULL 163}; 164 165DECLARE_MODULE(scsi_low, scsi_low_moduledata, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); 166MODULE_VERSION(scsi_low, 1); 167MODULE_DEPEND(scsi_low, cam, 1, 1, 1); 168#endif /* __FreeBSD__ */ 169