kernel tree reorganization stage 1: Major cvs repository work (not logged as
[dragonfly.git] / sys / bus / cam / scsi / scsi_low_pisa.c
1 /*      $FreeBSD: src/sys/cam/scsi/scsi_low_pisa.c,v 1.2.2.4 2001/12/17 13:30:20 non Exp $      */
2 /*      $DragonFly: src/sys/bus/cam/scsi/scsi_low_pisa.c,v 1.3 2003/08/07 21:16:45 dillon Exp $ */
3 /*      $NecBSD: scsi_low_pisa.c,v 1.13 1998/11/26 14:26:11 honda Exp $ */
4 /*      $NetBSD$        */
5
6 /*
7  * [NetBSD for NEC PC-98 series]
8  *  Copyright (c) 1995, 1996, 1997, 1998
9  *      NetBSD/pc98 porting staff. All rights reserved.
10  *  Copyright (c) 1995, 1996, 1997, 1998
11  *      Naofumi HONDA. All rights reserved.
12  * 
13  *  Redistribution and use in source and binary forms, with or without
14  *  modification, are permitted provided that the following conditions
15  *  are met:
16  *  1. Redistributions of source code must retain the above copyright
17  *     notice, this list of conditions and the following disclaimer.
18  *  2. Redistributions in binary form must reproduce the above copyright
19  *     notice, this list of conditions and the following disclaimer in the
20  *     documentation and/or other materials provided with the distribution.
21  *  3. The name of the author may not be used to endorse or promote products
22  *     derived from this software without specific prior written permission.
23  * 
24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
28  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
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
64 int
65 scsi_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
75 int
76 scsi_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
99 int
100 scsi_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 "scsi_low.h"
133 #include "scsi_low_pisa.h"
134
135 int
136 scsi_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
145 int
146 scsi_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
159 static moduledata_t scsi_low_moduledata = {
160         "scsi_low",
161         NULL,
162         NULL
163 };
164
165 DECLARE_MODULE(scsi_low, scsi_low_moduledata, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
166 MODULE_VERSION(scsi_low, 1);
167 MODULE_DEPEND(scsi_low, cam, 1, 1, 1);
168 #endif  /* __FreeBSD__ */