1 |
1626 |
jcastillo |
/************************************************************************
|
2 |
|
|
* GDT ISA/EISA/PCI Disk Array Controller driver for Linux *
|
3 |
|
|
* *
|
4 |
|
|
* gdth.c *
|
5 |
|
|
* Copyright (C) 1995-98 ICP vortex Computersysteme GmbH, Achim Leubner *
|
6 |
|
|
* *
|
7 |
|
|
* <achim@vortex.de> *
|
8 |
|
|
* *
|
9 |
|
|
* This program is free software; you can redistribute it and/or modify *
|
10 |
|
|
* it under the terms of the GNU General Public License as published *
|
11 |
|
|
* by the Free Software Foundation; either version 2 of the License, *
|
12 |
|
|
* or (at your option) any later version. *
|
13 |
|
|
* *
|
14 |
|
|
* This program is distributed in the hope that it will be useful, *
|
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
17 |
|
|
* GNU General Public License for more details. *
|
18 |
|
|
* *
|
19 |
|
|
* You should have received a copy of the GNU General Public License *
|
20 |
|
|
* along with this kernel; if not, write to the Free Software *
|
21 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
22 |
|
|
* *
|
23 |
|
|
* Tested with Linux 1.2.13, ..., 2.1.103 *
|
24 |
|
|
* *
|
25 |
|
|
* $Log: not supported by cvs2svn $
|
26 |
|
|
* Revision 1.1.1.1 2001/09/10 07:44:33 simons
|
27 |
|
|
* Initial import
|
28 |
|
|
*
|
29 |
|
|
* Revision 1.1.1.1 2001/07/02 17:58:29 simons
|
30 |
|
|
* Initial revision
|
31 |
|
|
*
|
32 |
|
|
* Revision 1.16 1998/09/28 16:08:46 achim
|
33 |
|
|
* GDT_PCIMPR: DPMEM remapping, if required
|
34 |
|
|
* mdelay() added
|
35 |
|
|
*
|
36 |
|
|
* Revision 1.15 1998/06/03 14:54:06 achim
|
37 |
|
|
* gdth_delay(), gdth_flush() implemented
|
38 |
|
|
* Bugfix: gdth_release() changed
|
39 |
|
|
*
|
40 |
|
|
* Revision 1.14 1998/05/22 10:01:17 achim
|
41 |
|
|
* mj: pcibios_strerror() removed
|
42 |
|
|
* Improved SMP support (if version >= 2.1.95)
|
43 |
|
|
* gdth_halt(): halt_called flag added (if version < 2.1)
|
44 |
|
|
*
|
45 |
|
|
* Revision 1.13 1998/04/16 09:14:57 achim
|
46 |
|
|
* Reserve drives (for raw service) implemented
|
47 |
|
|
* New error handling code enabled
|
48 |
|
|
* Get controller name from board_info() IOCTL
|
49 |
|
|
* Final round of PCI device driver patches by Martin Mares
|
50 |
|
|
*
|
51 |
|
|
* Revision 1.12 1998/03/03 09:32:37 achim
|
52 |
|
|
* Fibre channel controller support added
|
53 |
|
|
*
|
54 |
|
|
* Revision 1.11 1998/01/27 16:19:14 achim
|
55 |
|
|
* SA_SHIRQ added
|
56 |
|
|
* add_timer()/del_timer() instead of GDTH_TIMER
|
57 |
|
|
* scsi_add_timer()/scsi_del_timer() instead of SCSI_TIMER
|
58 |
|
|
* New error handling included
|
59 |
|
|
*
|
60 |
|
|
* Revision 1.10 1997/10/31 12:29:57 achim
|
61 |
|
|
* Read heads/sectors from host drive
|
62 |
|
|
*
|
63 |
|
|
* Revision 1.9 1997/09/04 10:07:25 achim
|
64 |
|
|
* IO-mapping with virt_to_bus(), readb(), writeb(), ...
|
65 |
|
|
* register_reboot_notifier() to get a notify on shutdown used
|
66 |
|
|
*
|
67 |
|
|
* Revision 1.8 1997/04/02 12:14:30 achim
|
68 |
|
|
* Version 1.00 (see gdth.h), tested with kernel 2.0.29
|
69 |
|
|
*
|
70 |
|
|
* Revision 1.7 1997/03/12 13:33:37 achim
|
71 |
|
|
* gdth_reset() changed, new async. events
|
72 |
|
|
*
|
73 |
|
|
* Revision 1.6 1997/03/04 14:01:11 achim
|
74 |
|
|
* Shutdown routine gdth_halt() implemented
|
75 |
|
|
*
|
76 |
|
|
* Revision 1.5 1997/02/21 09:08:36 achim
|
77 |
|
|
* New controller included (RP, RP1, RP2 series)
|
78 |
|
|
* IOCTL interface implemented
|
79 |
|
|
*
|
80 |
|
|
* Revision 1.4 1996/07/05 12:48:55 achim
|
81 |
|
|
* Function gdth_bios_param() implemented
|
82 |
|
|
* New constant GDTH_MAXC_P_L inserted
|
83 |
|
|
* GDT_WRITE_THR, GDT_EXT_INFO implemented
|
84 |
|
|
* Function gdth_reset() changed
|
85 |
|
|
*
|
86 |
|
|
* Revision 1.3 1996/05/10 09:04:41 achim
|
87 |
|
|
* Small changes for Linux 1.2.13
|
88 |
|
|
*
|
89 |
|
|
* Revision 1.2 1996/05/09 12:45:27 achim
|
90 |
|
|
* Loadable module support implemented
|
91 |
|
|
* /proc support corrections made
|
92 |
|
|
*
|
93 |
|
|
* Revision 1.1 1996/04/11 07:35:57 achim
|
94 |
|
|
* Initial revision
|
95 |
|
|
*
|
96 |
|
|
*
|
97 |
|
|
* $Id: gdth.c,v 1.1 2005-12-20 10:17:45 jcastillo Exp $
|
98 |
|
|
************************************************************************/
|
99 |
|
|
|
100 |
|
|
#ifdef MODULE
|
101 |
|
|
#include <linux/module.h>
|
102 |
|
|
#endif
|
103 |
|
|
|
104 |
|
|
#include <linux/version.h>
|
105 |
|
|
#include <linux/kernel.h>
|
106 |
|
|
#include <linux/head.h>
|
107 |
|
|
#include <linux/types.h>
|
108 |
|
|
#include <linux/pci.h>
|
109 |
|
|
#include <linux/string.h>
|
110 |
|
|
#include <linux/ioport.h>
|
111 |
|
|
#include <linux/delay.h>
|
112 |
|
|
#include <linux/sched.h>
|
113 |
|
|
#include <linux/in.h>
|
114 |
|
|
#include <linux/proc_fs.h>
|
115 |
|
|
#include <linux/time.h>
|
116 |
|
|
#include <linux/timer.h>
|
117 |
|
|
#if LINUX_VERSION_CODE >= 0x020100
|
118 |
|
|
#include <linux/reboot.h>
|
119 |
|
|
#else
|
120 |
|
|
#include <linux/bios32.h>
|
121 |
|
|
#endif
|
122 |
|
|
|
123 |
|
|
#include <asm/dma.h>
|
124 |
|
|
#include <asm/system.h>
|
125 |
|
|
#include <asm/io.h>
|
126 |
|
|
#if LINUX_VERSION_CODE >= 0x02015F
|
127 |
|
|
#include <asm/spinlock.h>
|
128 |
|
|
#endif
|
129 |
|
|
|
130 |
|
|
#if LINUX_VERSION_CODE >= 0x010300
|
131 |
|
|
#include <linux/blk.h>
|
132 |
|
|
#else
|
133 |
|
|
#include "../block/blk.h"
|
134 |
|
|
#endif
|
135 |
|
|
#include "scsi.h"
|
136 |
|
|
#include "hosts.h"
|
137 |
|
|
#include "sd.h"
|
138 |
|
|
|
139 |
|
|
#include "gdth.h"
|
140 |
|
|
|
141 |
|
|
/****************************************************************************/
|
142 |
|
|
|
143 |
|
|
/* LILO params: gdth=<IRQ>
|
144 |
|
|
*
|
145 |
|
|
* Where: <IRQ> is any of the valid IRQs for EISA controllers (10,11,12,14)
|
146 |
|
|
* Sets the IRQ of the GDT3000/3020 EISA controller to this value,
|
147 |
|
|
* if the IRQ can not automat. detect (controller BIOS disabled)
|
148 |
|
|
* See gdth_init_eisa()
|
149 |
|
|
*
|
150 |
|
|
* You can use the command line gdth=0 to disable the driver
|
151 |
|
|
*/
|
152 |
|
|
static unchar irqs[MAXHA] = {0xff};
|
153 |
|
|
static unchar disable_gdth_scan = FALSE;
|
154 |
|
|
|
155 |
|
|
/* Reserve drives for raw service: Fill the following structure with the
|
156 |
|
|
* appropriate values: Controller number, Channel, Target ID
|
157 |
|
|
*/
|
158 |
|
|
static gdth_reserve_str reserve_list[] = {
|
159 |
|
|
/* { 0, 1, 4 }, Example: Controller 0, Channel B, ID 4 */
|
160 |
|
|
{ 0xff, 0xff, 0xff } /* end of list */
|
161 |
|
|
};
|
162 |
|
|
|
163 |
|
|
/****************************************************************************/
|
164 |
|
|
|
165 |
|
|
#if LINUX_VERSION_CODE >= 0x02015F
|
166 |
|
|
static void gdth_interrupt(int irq,void *dev_id,struct pt_regs *regs);
|
167 |
|
|
static void do_gdth_interrupt(int irq,void *dev_id,struct pt_regs *regs);
|
168 |
|
|
#elif LINUX_VERSION_CODE >= 0x010346
|
169 |
|
|
static void gdth_interrupt(int irq,void *dev_id,struct pt_regs *regs);
|
170 |
|
|
#else
|
171 |
|
|
static void gdth_interrupt(int irq,struct pt_regs *regs);
|
172 |
|
|
#endif
|
173 |
|
|
static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp);
|
174 |
|
|
static int gdth_async_event(int hanum,int service);
|
175 |
|
|
|
176 |
|
|
static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority);
|
177 |
|
|
static void gdth_next(int hanum);
|
178 |
|
|
static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b);
|
179 |
|
|
static int gdth_special_cmd(int hanum,Scsi_Cmnd *scp,unchar b);
|
180 |
|
|
static gdth_evt_str *gdth_store_event(ushort source, ushort idx,
|
181 |
|
|
gdth_evt_data *evt);
|
182 |
|
|
static int gdth_read_event(int handle, gdth_evt_str *estr);
|
183 |
|
|
static void gdth_readapp_event(unchar application, gdth_evt_str *estr);
|
184 |
|
|
static void gdth_clear_events(void);
|
185 |
|
|
|
186 |
|
|
static void gdth_copy_internal_data(Scsi_Cmnd *scp,char *buffer,ushort count);
|
187 |
|
|
static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp,
|
188 |
|
|
unchar b,ulong *flags);
|
189 |
|
|
static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive);
|
190 |
|
|
|
191 |
|
|
static int gdth_search_eisa(ushort eisa_adr);
|
192 |
|
|
static int gdth_search_isa(ulong bios_adr);
|
193 |
|
|
static int gdth_search_pci(ushort device_id,ushort index,gdth_pci_str *pcistr);
|
194 |
|
|
static int gdth_init_eisa(ushort eisa_adr,gdth_ha_str *ha);
|
195 |
|
|
static int gdth_init_isa(ulong bios_adr,gdth_ha_str *ha);
|
196 |
|
|
static int gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha);
|
197 |
|
|
|
198 |
|
|
static void gdth_enable_int(int hanum);
|
199 |
|
|
static int gdth_get_status(unchar *pIStatus,int irq);
|
200 |
|
|
static int gdth_test_busy(int hanum);
|
201 |
|
|
static int gdth_get_cmd_index(int hanum);
|
202 |
|
|
static void gdth_release_event(int hanum);
|
203 |
|
|
static int gdth_wait(int hanum,int index,ulong time);
|
204 |
|
|
static int gdth_internal_cmd(int hanum,unchar service,ushort opcode,ulong p1,
|
205 |
|
|
ulong p2,ulong p3);
|
206 |
|
|
static int gdth_search_drives(int hanum);
|
207 |
|
|
|
208 |
|
|
static void *gdth_mmap(ulong paddr, ulong size);
|
209 |
|
|
static void gdth_munmap(void *addr);
|
210 |
|
|
|
211 |
|
|
static const char *gdth_ctr_name(int hanum);
|
212 |
|
|
|
213 |
|
|
static void gdth_flush(int hanum);
|
214 |
|
|
#if LINUX_VERSION_CODE >= 0x020100
|
215 |
|
|
static int gdth_halt(struct notifier_block *nb, ulong event, void *buf);
|
216 |
|
|
#else
|
217 |
|
|
static int halt_called = FALSE;
|
218 |
|
|
void gdth_halt(void);
|
219 |
|
|
#endif
|
220 |
|
|
|
221 |
|
|
#ifdef DEBUG_GDTH
|
222 |
|
|
static unchar DebugState = DEBUG_GDTH;
|
223 |
|
|
extern int sys_syslog(int,char*,int);
|
224 |
|
|
#define LOGEN sys_syslog(7,NULL,0)
|
225 |
|
|
|
226 |
|
|
#ifdef __SERIAL__
|
227 |
|
|
#define MAX_SERBUF 160
|
228 |
|
|
static void ser_init(void);
|
229 |
|
|
static void ser_puts(char *str);
|
230 |
|
|
static void ser_putc(char c);
|
231 |
|
|
static int ser_printk(const char *fmt, ...);
|
232 |
|
|
static char strbuf[MAX_SERBUF+1];
|
233 |
|
|
#ifdef __COM2__
|
234 |
|
|
#define COM_BASE 0x2f8
|
235 |
|
|
#else
|
236 |
|
|
#define COM_BASE 0x3f8
|
237 |
|
|
#endif
|
238 |
|
|
static void ser_init()
|
239 |
|
|
{
|
240 |
|
|
unsigned port=COM_BASE;
|
241 |
|
|
|
242 |
|
|
outb(0x80,port+3);
|
243 |
|
|
outb(0,port+1);
|
244 |
|
|
/* 19200 Baud, if 9600: outb(12,port) */
|
245 |
|
|
outb(6, port);
|
246 |
|
|
outb(3,port+3);
|
247 |
|
|
outb(0,port+1);
|
248 |
|
|
/*
|
249 |
|
|
ser_putc('I');
|
250 |
|
|
ser_putc(' ');
|
251 |
|
|
*/
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
static void ser_puts(char *str)
|
255 |
|
|
{
|
256 |
|
|
char *ptr;
|
257 |
|
|
|
258 |
|
|
ser_init();
|
259 |
|
|
for (ptr=str;*ptr;++ptr)
|
260 |
|
|
ser_putc(*ptr);
|
261 |
|
|
}
|
262 |
|
|
|
263 |
|
|
static void ser_putc(char c)
|
264 |
|
|
{
|
265 |
|
|
unsigned port=COM_BASE;
|
266 |
|
|
|
267 |
|
|
while ((inb(port+5) & 0x20)==0);
|
268 |
|
|
outb(c,port);
|
269 |
|
|
if (c==0x0a)
|
270 |
|
|
{
|
271 |
|
|
while ((inb(port+5) & 0x20)==0);
|
272 |
|
|
outb(0x0d,port);
|
273 |
|
|
}
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
static int ser_printk(const char *fmt, ...)
|
277 |
|
|
{
|
278 |
|
|
va_list args;
|
279 |
|
|
int i;
|
280 |
|
|
|
281 |
|
|
va_start(args,fmt);
|
282 |
|
|
i = vsprintf(strbuf,fmt,args);
|
283 |
|
|
ser_puts(strbuf);
|
284 |
|
|
va_end(args);
|
285 |
|
|
return i;
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
#define TRACE(a) {if (DebugState==1) {ser_printk a;}}
|
289 |
|
|
#define TRACE2(a) {if (DebugState==1 || DebugState==2) {ser_printk a;}}
|
290 |
|
|
#define TRACE3(a) {if (DebugState!=0) {ser_printk a;}}
|
291 |
|
|
|
292 |
|
|
#else /* !__SERIAL__ */
|
293 |
|
|
#define TRACE(a) {if (DebugState==1) {LOGEN;printk a;}}
|
294 |
|
|
#define TRACE2(a) {if (DebugState==1 || DebugState==2) {LOGEN;printk a;}}
|
295 |
|
|
#define TRACE3(a) {if (DebugState!=0) {LOGEN;printk a;}}
|
296 |
|
|
#endif
|
297 |
|
|
|
298 |
|
|
#else /* !DEBUG */
|
299 |
|
|
#define TRACE(a)
|
300 |
|
|
#define TRACE2(a)
|
301 |
|
|
#define TRACE3(a)
|
302 |
|
|
#endif
|
303 |
|
|
|
304 |
|
|
#ifdef GDTH_STATISTICS
|
305 |
|
|
static ulong max_rq=0, max_index=0, max_sg=0;
|
306 |
|
|
static ulong act_ints=0, act_ios=0, act_stats=0, act_rq=0;
|
307 |
|
|
static struct timer_list gdth_timer;
|
308 |
|
|
#endif
|
309 |
|
|
|
310 |
|
|
#define PTR2USHORT(a) (ushort)(ulong)(a)
|
311 |
|
|
#define GDTOFFSOF(a,b) (size_t)&(((a*)0)->b)
|
312 |
|
|
#define INDEX_OK(i,t) ((i)<sizeof(t)/sizeof((t)[0]))
|
313 |
|
|
|
314 |
|
|
#define NUMDATA(a) ( (gdth_num_str *)((a)->hostdata))
|
315 |
|
|
#define HADATA(a) (&((gdth_ext_str *)((a)->hostdata))->haext)
|
316 |
|
|
#define CMDDATA(a) (&((gdth_ext_str *)((a)->hostdata))->cmdext)
|
317 |
|
|
#define DMADATA(a) (&((gdth_ext_str *)((a)->hostdata))->dmaext)
|
318 |
|
|
|
319 |
|
|
|
320 |
|
|
#if LINUX_VERSION_CODE < 0x010300
|
321 |
|
|
static void *gdth_mmap(ulong paddr, ulong size)
|
322 |
|
|
{
|
323 |
|
|
if (paddr >= high_memory)
|
324 |
|
|
return NULL;
|
325 |
|
|
else
|
326 |
|
|
return (void *)paddr;
|
327 |
|
|
}
|
328 |
|
|
static void gdth_munmap(void *addr)
|
329 |
|
|
{
|
330 |
|
|
}
|
331 |
|
|
inline ulong virt_to_phys(volatile void *addr)
|
332 |
|
|
{
|
333 |
|
|
return (ulong)addr;
|
334 |
|
|
}
|
335 |
|
|
inline void *phys_to_virt(ulong addr)
|
336 |
|
|
{
|
337 |
|
|
return (void *)addr;
|
338 |
|
|
}
|
339 |
|
|
#define virt_to_bus virt_to_phys
|
340 |
|
|
#define bus_to_virt phys_to_virt
|
341 |
|
|
#define readb(addr) (*(volatile unchar *)(addr))
|
342 |
|
|
#define readw(addr) (*(volatile ushort *)(addr))
|
343 |
|
|
#define readl(addr) (*(volatile ulong *)(addr))
|
344 |
|
|
#define writeb(b,addr) (*(volatile unchar *)(addr) = (b))
|
345 |
|
|
#define writew(b,addr) (*(volatile ushort *)(addr) = (b))
|
346 |
|
|
#define writel(b,addr) (*(volatile ulong *)(addr) = (b))
|
347 |
|
|
#define memset_io(a,b,c) memset((void *)(a),(b),(c))
|
348 |
|
|
#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
|
349 |
|
|
#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
|
350 |
|
|
|
351 |
|
|
#elif LINUX_VERSION_CODE < 0x020100
|
352 |
|
|
static int remapped = FALSE;
|
353 |
|
|
static void *gdth_mmap(ulong paddr, ulong size)
|
354 |
|
|
{
|
355 |
|
|
if ( paddr >= high_memory) {
|
356 |
|
|
remapped = TRUE;
|
357 |
|
|
return vremap(paddr, size);
|
358 |
|
|
} else {
|
359 |
|
|
return (void *)paddr;
|
360 |
|
|
}
|
361 |
|
|
}
|
362 |
|
|
static void gdth_munmap(void *addr)
|
363 |
|
|
{
|
364 |
|
|
if (remapped)
|
365 |
|
|
vfree(addr);
|
366 |
|
|
remapped = FALSE;
|
367 |
|
|
}
|
368 |
|
|
#else
|
369 |
|
|
static void *gdth_mmap(ulong paddr, ulong size)
|
370 |
|
|
{
|
371 |
|
|
return ioremap(paddr, size);
|
372 |
|
|
}
|
373 |
|
|
static void gdth_munmap(void *addr)
|
374 |
|
|
{
|
375 |
|
|
return iounmap(addr);
|
376 |
|
|
}
|
377 |
|
|
#endif
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
static unchar gdth_drq_tab[4] = {5,6,7,7}; /* DRQ table */
|
381 |
|
|
static unchar gdth_irq_tab[6] = {0,10,11,12,14,0}; /* IRQ table */
|
382 |
|
|
static unchar gdth_polling; /* polling if TRUE */
|
383 |
|
|
static unchar gdth_from_wait = FALSE; /* gdth_wait() */
|
384 |
|
|
static int wait_index,wait_hanum; /* gdth_wait() */
|
385 |
|
|
static int gdth_ctr_count = 0; /* controller count */
|
386 |
|
|
static int gdth_ctr_vcount = 0; /* virt. ctr. count */
|
387 |
|
|
static int gdth_ctr_released = 0; /* gdth_release() */
|
388 |
|
|
static struct Scsi_Host *gdth_ctr_tab[MAXHA]; /* controller table */
|
389 |
|
|
static struct Scsi_Host *gdth_ctr_vtab[MAXHA*MAXBUS]; /* virt. ctr. table */
|
390 |
|
|
static unchar gdth_write_through = FALSE; /* write through */
|
391 |
|
|
static char *gdth_ioctl_tab[4][MAXHA]; /* ioctl buffer */
|
392 |
|
|
static gdth_evt_str ebuffer[MAX_EVENTS]; /* event buffer */
|
393 |
|
|
static int elastidx;
|
394 |
|
|
static int eoldidx;
|
395 |
|
|
|
396 |
|
|
static struct {
|
397 |
|
|
Scsi_Cmnd *cmnd; /* pending request */
|
398 |
|
|
ushort service; /* service */
|
399 |
|
|
} gdth_cmd_tab[GDTH_MAXCMDS][MAXHA]; /* table of pend. requests */
|
400 |
|
|
|
401 |
|
|
#define DIN 1 /* IN data direction */
|
402 |
|
|
#define DOU 2 /* OUT data direction */
|
403 |
|
|
#define DNO DIN /* no data transfer */
|
404 |
|
|
#define DUN DIN /* unknown data direction */
|
405 |
|
|
static unchar gdth_direction_tab[0x100] = {
|
406 |
|
|
DNO,DNO,DIN,DIN,DOU,DIN,DIN,DOU,DIN,DUN,DOU,DOU,DUN,DUN,DUN,DIN,
|
407 |
|
|
DNO,DIN,DIN,DOU,DIN,DOU,DNO,DNO,DOU,DNO,DIN,DNO,DIN,DOU,DNO,DUN,
|
408 |
|
|
DIN,DUN,DIN,DUN,DOU,DIN,DUN,DUN,DIN,DIN,DIN,DUN,DUN,DIN,DIN,DIN,
|
409 |
|
|
DIN,DIN,DIN,DNO,DIN,DNO,DNO,DIN,DIN,DIN,DIN,DIN,DIN,DIN,DIN,DIN,
|
410 |
|
|
DIN,DIN,DIN,DIN,DIN,DNO,DUN,DNO,DNO,DNO,DUN,DNO,DIN,DIN,DUN,DUN,
|
411 |
|
|
DUN,DUN,DUN,DUN,DUN,DIN,DUN,DUN,DUN,DUN,DIN,DUN,DUN,DUN,DUN,DUN,
|
412 |
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
413 |
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
414 |
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
415 |
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
416 |
|
|
DUN,DUN,DUN,DUN,DUN,DNO,DNO,DUN,DIN,DNO,DIN,DUN,DNO,DUN,DIN,DIN,
|
417 |
|
|
DIN,DIN,DIN,DNO,DUN,DIN,DIN,DIN,DIN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
418 |
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
419 |
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
|
420 |
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DOU,DUN,DUN,DUN,DUN,DUN,
|
421 |
|
|
DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN
|
422 |
|
|
};
|
423 |
|
|
|
424 |
|
|
/* __initfunc, __initdata macros */
|
425 |
|
|
#if LINUX_VERSION_CODE >= 0x020126
|
426 |
|
|
#include <linux/init.h>
|
427 |
|
|
#else
|
428 |
|
|
#define __initfunc(A) A
|
429 |
|
|
#define __initdata
|
430 |
|
|
#define __init
|
431 |
|
|
#endif
|
432 |
|
|
|
433 |
|
|
/* /proc support */
|
434 |
|
|
#if LINUX_VERSION_CODE >= 0x010300
|
435 |
|
|
#include <linux/stat.h>
|
436 |
|
|
struct proc_dir_entry proc_scsi_gdth = {
|
437 |
|
|
PROC_SCSI_GDTH, 4, "gdth",
|
438 |
|
|
S_IFDIR | S_IRUGO | S_IXUGO, 2
|
439 |
|
|
};
|
440 |
|
|
#include "gdth_proc.h"
|
441 |
|
|
#include "gdth_proc.c"
|
442 |
|
|
#endif
|
443 |
|
|
|
444 |
|
|
#if LINUX_VERSION_CODE >= 0x020100
|
445 |
|
|
/* notifier block to get a notify on system shutdown/halt/reboot */
|
446 |
|
|
static struct notifier_block gdth_notifier = {
|
447 |
|
|
gdth_halt, NULL, 0
|
448 |
|
|
};
|
449 |
|
|
#endif
|
450 |
|
|
|
451 |
|
|
static void gdth_delay(int milliseconds)
|
452 |
|
|
{
|
453 |
|
|
if (milliseconds == 0) {
|
454 |
|
|
udelay(1);
|
455 |
|
|
} else {
|
456 |
|
|
#if LINUX_VERSION_CODE >= 0x020168
|
457 |
|
|
mdelay(milliseconds);
|
458 |
|
|
#else
|
459 |
|
|
int i;
|
460 |
|
|
for (i = 0; i < milliseconds; ++i)
|
461 |
|
|
udelay(1000);
|
462 |
|
|
#endif
|
463 |
|
|
}
|
464 |
|
|
}
|
465 |
|
|
|
466 |
|
|
/* controller search and initialization functions */
|
467 |
|
|
|
468 |
|
|
__initfunc (static int gdth_search_eisa(ushort eisa_adr))
|
469 |
|
|
{
|
470 |
|
|
ulong id;
|
471 |
|
|
|
472 |
|
|
TRACE(("gdth_search_eisa() adr. %x\n",eisa_adr));
|
473 |
|
|
id = inl(eisa_adr+ID0REG);
|
474 |
|
|
if (id == GDT3A_ID || id == GDT3B_ID) { /* GDT3000A or GDT3000B */
|
475 |
|
|
if ((inb(eisa_adr+EISAREG) & 8) == 0)
|
476 |
|
|
return 0; /* not EISA configured */
|
477 |
|
|
return 1;
|
478 |
|
|
}
|
479 |
|
|
if (id == GDT3_ID) /* GDT3000 */
|
480 |
|
|
return 1;
|
481 |
|
|
|
482 |
|
|
return 0;
|
483 |
|
|
}
|
484 |
|
|
|
485 |
|
|
|
486 |
|
|
__initfunc (static int gdth_search_isa(ulong bios_adr))
|
487 |
|
|
{
|
488 |
|
|
void *addr;
|
489 |
|
|
ulong id;
|
490 |
|
|
|
491 |
|
|
TRACE(("gdth_search_isa() bios adr. %lx\n",bios_adr));
|
492 |
|
|
if ((addr = gdth_mmap(bios_adr+BIOS_ID_OFFS, sizeof(ulong))) != NULL) {
|
493 |
|
|
id = readl(addr);
|
494 |
|
|
gdth_munmap(addr);
|
495 |
|
|
if (id == GDT2_ID) /* GDT2000 */
|
496 |
|
|
return 1;
|
497 |
|
|
}
|
498 |
|
|
return 0;
|
499 |
|
|
}
|
500 |
|
|
|
501 |
|
|
|
502 |
|
|
__initfunc (static int gdth_search_pci(ushort device_id,ushort index,gdth_pci_str *pcistr))
|
503 |
|
|
{
|
504 |
|
|
int error;
|
505 |
|
|
ulong base0,base1,base2;
|
506 |
|
|
|
507 |
|
|
TRACE(("gdth_search_pci() device_id %d, index %d\n",
|
508 |
|
|
device_id,index));
|
509 |
|
|
|
510 |
|
|
#if LINUX_VERSION_CODE >= 0x20155
|
511 |
|
|
if (!pci_present())
|
512 |
|
|
return 0;
|
513 |
|
|
#else
|
514 |
|
|
if (!pcibios_present())
|
515 |
|
|
return 0;
|
516 |
|
|
#endif
|
517 |
|
|
|
518 |
|
|
if (pcibios_find_device(PCI_VENDOR_ID_VORTEX,device_id,index,
|
519 |
|
|
&pcistr->bus,&pcistr->device_fn))
|
520 |
|
|
return 0;
|
521 |
|
|
|
522 |
|
|
/* GDT PCI controller found, now read resources from config space */
|
523 |
|
|
#if LINUX_VERSION_CODE >= 0x20155
|
524 |
|
|
{
|
525 |
|
|
struct pci_dev *pdev = pci_find_slot(pcistr->bus, pcistr->device_fn);
|
526 |
|
|
base0 = pdev->base_address[0];
|
527 |
|
|
base1 = pdev->base_address[1];
|
528 |
|
|
base2 = pdev->base_address[2];
|
529 |
|
|
if ((error = pcibios_read_config_dword(pcistr->bus,pcistr->device_fn,
|
530 |
|
|
PCI_ROM_ADDRESS,
|
531 |
|
|
(int *) &pcistr->bios))) {
|
532 |
|
|
printk("GDT-PCI: error %d reading configuration space", error);
|
533 |
|
|
return -1;
|
534 |
|
|
}
|
535 |
|
|
pcistr->irq = pdev->irq;
|
536 |
|
|
}
|
537 |
|
|
#else
|
538 |
|
|
#if LINUX_VERSION_CODE >= 0x010300
|
539 |
|
|
#define GDTH_BASEP (int *)
|
540 |
|
|
#else
|
541 |
|
|
#define GDTH_BASEP
|
542 |
|
|
#endif
|
543 |
|
|
if ((error = pcibios_read_config_dword(pcistr->bus,pcistr->device_fn,
|
544 |
|
|
PCI_BASE_ADDRESS_0,
|
545 |
|
|
GDTH_BASEP&base0)) ||
|
546 |
|
|
(error = pcibios_read_config_dword(pcistr->bus,pcistr->device_fn,
|
547 |
|
|
PCI_BASE_ADDRESS_1,
|
548 |
|
|
GDTH_BASEP&base1)) ||
|
549 |
|
|
(error = pcibios_read_config_dword(pcistr->bus,pcistr->device_fn,
|
550 |
|
|
PCI_BASE_ADDRESS_2,
|
551 |
|
|
GDTH_BASEP&base2)) ||
|
552 |
|
|
(error = pcibios_read_config_dword(pcistr->bus,pcistr->device_fn,
|
553 |
|
|
PCI_ROM_ADDRESS,
|
554 |
|
|
GDTH_BASEP&pcistr->bios)) ||
|
555 |
|
|
(error = pcibios_read_config_byte(pcistr->bus,pcistr->device_fn,
|
556 |
|
|
PCI_INTERRUPT_LINE,&pcistr->irq))) {
|
557 |
|
|
printk("GDT-PCI: error %d reading configuration space", error);
|
558 |
|
|
return -1;
|
559 |
|
|
}
|
560 |
|
|
#endif
|
561 |
|
|
|
562 |
|
|
pcistr->device_id = device_id;
|
563 |
|
|
if (device_id <= PCI_DEVICE_ID_VORTEX_GDT6000B || /* GDT6000 or GDT6000B */
|
564 |
|
|
device_id >= PCI_DEVICE_ID_VORTEX_GDT6x17RP) { /* MPR */
|
565 |
|
|
if ((base0 & PCI_BASE_ADDRESS_SPACE)!=PCI_BASE_ADDRESS_SPACE_MEMORY)
|
566 |
|
|
return -1;
|
567 |
|
|
pcistr->dpmem = base0 & PCI_BASE_ADDRESS_MEM_MASK;
|
568 |
|
|
} else { /* GDT6110, GDT6120, .. */
|
569 |
|
|
if ((base0 & PCI_BASE_ADDRESS_SPACE)!=PCI_BASE_ADDRESS_SPACE_MEMORY ||
|
570 |
|
|
(base2 & PCI_BASE_ADDRESS_SPACE)!=PCI_BASE_ADDRESS_SPACE_MEMORY ||
|
571 |
|
|
(base1 & PCI_BASE_ADDRESS_SPACE)!=PCI_BASE_ADDRESS_SPACE_IO)
|
572 |
|
|
return -1;
|
573 |
|
|
pcistr->dpmem = base2 & PCI_BASE_ADDRESS_MEM_MASK;
|
574 |
|
|
pcistr->io_mm = base0 & PCI_BASE_ADDRESS_MEM_MASK;
|
575 |
|
|
pcistr->io = base1 & PCI_BASE_ADDRESS_IO_MASK;
|
576 |
|
|
}
|
577 |
|
|
return 1;
|
578 |
|
|
}
|
579 |
|
|
|
580 |
|
|
|
581 |
|
|
__initfunc (static int gdth_init_eisa(ushort eisa_adr,gdth_ha_str *ha))
|
582 |
|
|
{
|
583 |
|
|
ulong retries,id;
|
584 |
|
|
unchar prot_ver,eisacf,i,irq_found;
|
585 |
|
|
|
586 |
|
|
TRACE(("gdth_init_eisa() adr. %x\n",eisa_adr));
|
587 |
|
|
|
588 |
|
|
/* disable board interrupts, deinitialize services */
|
589 |
|
|
outb(0xff,eisa_adr+EDOORREG);
|
590 |
|
|
outb(0x00,eisa_adr+EDENABREG);
|
591 |
|
|
outb(0x00,eisa_adr+EINTENABREG);
|
592 |
|
|
|
593 |
|
|
outb(0xff,eisa_adr+LDOORREG);
|
594 |
|
|
retries = INIT_RETRIES;
|
595 |
|
|
gdth_delay(20);
|
596 |
|
|
while (inb(eisa_adr+EDOORREG) != 0xff) {
|
597 |
|
|
if (--retries == 0) {
|
598 |
|
|
printk("GDT-EISA: Initialization error (DEINIT failed)\n");
|
599 |
|
|
return 0;
|
600 |
|
|
}
|
601 |
|
|
gdth_delay(1);
|
602 |
|
|
TRACE2(("wait for DEINIT: retries=%ld\n",retries));
|
603 |
|
|
}
|
604 |
|
|
prot_ver = inb(eisa_adr+MAILBOXREG);
|
605 |
|
|
outb(0xff,eisa_adr+EDOORREG);
|
606 |
|
|
if (prot_ver != PROTOCOL_VERSION) {
|
607 |
|
|
printk("GDT-EISA: Illegal protocol version\n");
|
608 |
|
|
return 0;
|
609 |
|
|
}
|
610 |
|
|
ha->bmic = eisa_adr;
|
611 |
|
|
ha->brd_phys = (ulong)eisa_adr >> 12;
|
612 |
|
|
|
613 |
|
|
outl(0,eisa_adr+MAILBOXREG);
|
614 |
|
|
outl(0,eisa_adr+MAILBOXREG+4);
|
615 |
|
|
outl(0,eisa_adr+MAILBOXREG+8);
|
616 |
|
|
outl(0,eisa_adr+MAILBOXREG+12);
|
617 |
|
|
|
618 |
|
|
/* detect IRQ */
|
619 |
|
|
if ((id = inl(eisa_adr+ID0REG)) == GDT3_ID) {
|
620 |
|
|
ha->type = GDT_EISA;
|
621 |
|
|
ha->stype = id;
|
622 |
|
|
outl(1,eisa_adr+MAILBOXREG+8);
|
623 |
|
|
outb(0xfe,eisa_adr+LDOORREG);
|
624 |
|
|
retries = INIT_RETRIES;
|
625 |
|
|
gdth_delay(20);
|
626 |
|
|
while (inb(eisa_adr+EDOORREG) != 0xfe) {
|
627 |
|
|
if (--retries == 0) {
|
628 |
|
|
printk("GDT-EISA: Initialization error (get IRQ failed)\n");
|
629 |
|
|
return 0;
|
630 |
|
|
}
|
631 |
|
|
gdth_delay(1);
|
632 |
|
|
}
|
633 |
|
|
ha->irq = inb(eisa_adr+MAILBOXREG);
|
634 |
|
|
outb(0xff,eisa_adr+EDOORREG);
|
635 |
|
|
TRACE2(("GDT3000/3020: IRQ=%d\n",ha->irq));
|
636 |
|
|
/* check the result */
|
637 |
|
|
if (ha->irq == 0) {
|
638 |
|
|
TRACE2(("Unknown IRQ, check IRQ table from cmd line !\n"));
|
639 |
|
|
for (i=0,irq_found=FALSE; i<MAXHA && irqs[i]!=0xff; ++i) {
|
640 |
|
|
if (irqs[i]!=0) {
|
641 |
|
|
irq_found=TRUE;
|
642 |
|
|
break;
|
643 |
|
|
}
|
644 |
|
|
}
|
645 |
|
|
if (irq_found) {
|
646 |
|
|
ha->irq = irqs[i];
|
647 |
|
|
irqs[i] = 0;
|
648 |
|
|
printk("GDT-EISA: Can not detect controller IRQ,\n");
|
649 |
|
|
printk("Use IRQ setting from command line (IRQ = %d)\n",
|
650 |
|
|
ha->irq);
|
651 |
|
|
} else {
|
652 |
|
|
printk("GDT-EISA: Initialization error (unknown IRQ), Enable\n");
|
653 |
|
|
printk("the controller BIOS or use command line parameters\n");
|
654 |
|
|
return 0;
|
655 |
|
|
}
|
656 |
|
|
}
|
657 |
|
|
} else {
|
658 |
|
|
eisacf = inb(eisa_adr+EISAREG) & 7;
|
659 |
|
|
if (eisacf > 4) /* level triggered */
|
660 |
|
|
eisacf -= 4;
|
661 |
|
|
ha->irq = gdth_irq_tab[eisacf];
|
662 |
|
|
ha->type = GDT_EISA;
|
663 |
|
|
ha->stype= id;
|
664 |
|
|
}
|
665 |
|
|
return 1;
|
666 |
|
|
}
|
667 |
|
|
|
668 |
|
|
|
669 |
|
|
__initfunc (static int gdth_init_isa(ulong bios_adr,gdth_ha_str *ha))
|
670 |
|
|
{
|
671 |
|
|
register gdt2_dpram_str *dp2_ptr;
|
672 |
|
|
int i;
|
673 |
|
|
unchar irq_drq,prot_ver;
|
674 |
|
|
ulong retries;
|
675 |
|
|
|
676 |
|
|
TRACE(("gdth_init_isa() bios adr. %lx\n",bios_adr));
|
677 |
|
|
|
678 |
|
|
ha->brd = gdth_mmap(bios_adr, sizeof(gdt2_dpram_str));
|
679 |
|
|
if (ha->brd == NULL) {
|
680 |
|
|
printk("GDT-ISA: Initialization error (DPMEM remap error)\n");
|
681 |
|
|
return 0;
|
682 |
|
|
}
|
683 |
|
|
dp2_ptr = (gdt2_dpram_str *)ha->brd;
|
684 |
|
|
writeb(1, &dp2_ptr->io.memlock); /* switch off write protection */
|
685 |
|
|
/* reset interface area */
|
686 |
|
|
memset_io((char *)&dp2_ptr->u,0,sizeof(dp2_ptr->u));
|
687 |
|
|
if (readl(&dp2_ptr->u) != 0) {
|
688 |
|
|
printk("GDT-PCI: Initialization error (DPMEM write error)\n");
|
689 |
|
|
gdth_munmap(ha->brd);
|
690 |
|
|
return 0;
|
691 |
|
|
}
|
692 |
|
|
|
693 |
|
|
/* disable board interrupts, read DRQ and IRQ */
|
694 |
|
|
writeb(0xff, &dp2_ptr->io.irqdel);
|
695 |
|
|
writeb(0x00, &dp2_ptr->io.irqen);
|
696 |
|
|
writeb(0x00, &dp2_ptr->u.ic.S_Status);
|
697 |
|
|
writeb(0x00, &dp2_ptr->u.ic.Cmd_Index);
|
698 |
|
|
|
699 |
|
|
irq_drq = readb(&dp2_ptr->io.rq);
|
700 |
|
|
for (i=0; i<3; ++i) {
|
701 |
|
|
if ((irq_drq & 1)==0)
|
702 |
|
|
break;
|
703 |
|
|
irq_drq >>= 1;
|
704 |
|
|
}
|
705 |
|
|
ha->drq = gdth_drq_tab[i];
|
706 |
|
|
|
707 |
|
|
irq_drq = readb(&dp2_ptr->io.rq) >> 3;
|
708 |
|
|
for (i=1; i<5; ++i) {
|
709 |
|
|
if ((irq_drq & 1)==0)
|
710 |
|
|
break;
|
711 |
|
|
irq_drq >>= 1;
|
712 |
|
|
}
|
713 |
|
|
ha->irq = gdth_irq_tab[i];
|
714 |
|
|
|
715 |
|
|
/* deinitialize services */
|
716 |
|
|
writel(bios_adr, &dp2_ptr->u.ic.S_Info[0]);
|
717 |
|
|
writeb(0xff, &dp2_ptr->u.ic.S_Cmd_Indx);
|
718 |
|
|
writeb(0, &dp2_ptr->io.event);
|
719 |
|
|
retries = INIT_RETRIES;
|
720 |
|
|
gdth_delay(20);
|
721 |
|
|
while (readb(&dp2_ptr->u.ic.S_Status) != 0xff) {
|
722 |
|
|
if (--retries == 0) {
|
723 |
|
|
printk("GDT-ISA: Initialization error (DEINIT failed)\n");
|
724 |
|
|
gdth_munmap(ha->brd);
|
725 |
|
|
return 0;
|
726 |
|
|
}
|
727 |
|
|
gdth_delay(1);
|
728 |
|
|
}
|
729 |
|
|
prot_ver = (unchar)readl(&dp2_ptr->u.ic.S_Info[0]);
|
730 |
|
|
writeb(0, &dp2_ptr->u.ic.Status);
|
731 |
|
|
writeb(0xff, &dp2_ptr->io.irqdel);
|
732 |
|
|
if (prot_ver != PROTOCOL_VERSION) {
|
733 |
|
|
printk("GDT-ISA: Illegal protocol version\n");
|
734 |
|
|
gdth_munmap(ha->brd);
|
735 |
|
|
return 0;
|
736 |
|
|
}
|
737 |
|
|
|
738 |
|
|
ha->type = GDT_ISA;
|
739 |
|
|
ha->ic_all_size = sizeof(dp2_ptr->u);
|
740 |
|
|
ha->stype= GDT2_ID;
|
741 |
|
|
ha->brd_phys = bios_adr >> 4;
|
742 |
|
|
|
743 |
|
|
/* special request to controller BIOS */
|
744 |
|
|
writel(0x00, &dp2_ptr->u.ic.S_Info[0]);
|
745 |
|
|
writel(0x00, &dp2_ptr->u.ic.S_Info[1]);
|
746 |
|
|
writel(0x01, &dp2_ptr->u.ic.S_Info[2]);
|
747 |
|
|
writel(0x00, &dp2_ptr->u.ic.S_Info[3]);
|
748 |
|
|
writeb(0xfe, &dp2_ptr->u.ic.S_Cmd_Indx);
|
749 |
|
|
writeb(0, &dp2_ptr->io.event);
|
750 |
|
|
retries = INIT_RETRIES;
|
751 |
|
|
gdth_delay(20);
|
752 |
|
|
while (readb(&dp2_ptr->u.ic.S_Status) != 0xfe) {
|
753 |
|
|
if (--retries == 0) {
|
754 |
|
|
printk("GDT-ISA: Initialization error\n");
|
755 |
|
|
gdth_munmap(ha->brd);
|
756 |
|
|
return 0;
|
757 |
|
|
}
|
758 |
|
|
gdth_delay(1);
|
759 |
|
|
}
|
760 |
|
|
writeb(0, &dp2_ptr->u.ic.Status);
|
761 |
|
|
writeb(0xff, &dp2_ptr->io.irqdel);
|
762 |
|
|
return 1;
|
763 |
|
|
}
|
764 |
|
|
|
765 |
|
|
|
766 |
|
|
__initfunc (static int gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha))
|
767 |
|
|
{
|
768 |
|
|
register gdt6_dpram_str *dp6_ptr;
|
769 |
|
|
register gdt6c_dpram_str *dp6c_ptr;
|
770 |
|
|
register gdt6m_dpram_str *dp6m_ptr;
|
771 |
|
|
ulong retries;
|
772 |
|
|
unchar prot_ver;
|
773 |
|
|
int i, found = FALSE;
|
774 |
|
|
|
775 |
|
|
TRACE(("gdth_init_pci()\n"));
|
776 |
|
|
|
777 |
|
|
ha->brd_phys = (pcistr->bus << 8) | (pcistr->device_fn & 0xf8);
|
778 |
|
|
ha->stype = (ulong)pcistr->device_id;
|
779 |
|
|
ha->irq = pcistr->irq;
|
780 |
|
|
|
781 |
|
|
if (ha->stype <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000 or GDT6000B */
|
782 |
|
|
TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq));
|
783 |
|
|
ha->brd = gdth_mmap(pcistr->dpmem, sizeof(gdt6_dpram_str));
|
784 |
|
|
if (ha->brd == NULL) {
|
785 |
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
786 |
|
|
return 0;
|
787 |
|
|
}
|
788 |
|
|
dp6_ptr = (gdt6_dpram_str *)ha->brd;
|
789 |
|
|
/* reset interface area */
|
790 |
|
|
memset_io((char *)&dp6_ptr->u,0,sizeof(dp6_ptr->u));
|
791 |
|
|
if (readl(&dp6_ptr->u) != 0) {
|
792 |
|
|
printk("GDT-PCI: Initialization error (DPMEM write error)\n");
|
793 |
|
|
gdth_munmap(ha->brd);
|
794 |
|
|
return 0;
|
795 |
|
|
}
|
796 |
|
|
|
797 |
|
|
/* disable board interrupts, deinit services */
|
798 |
|
|
writeb(0xff, &dp6_ptr->io.irqdel);
|
799 |
|
|
writeb(0x00, &dp6_ptr->io.irqen);;
|
800 |
|
|
writeb(0x00, &dp6_ptr->u.ic.S_Status);
|
801 |
|
|
writeb(0x00, &dp6_ptr->u.ic.Cmd_Index);
|
802 |
|
|
|
803 |
|
|
writel(pcistr->dpmem, &dp6_ptr->u.ic.S_Info[0]);
|
804 |
|
|
writeb(0xff, &dp6_ptr->u.ic.S_Cmd_Indx);
|
805 |
|
|
writeb(0, &dp6_ptr->io.event);
|
806 |
|
|
retries = INIT_RETRIES;
|
807 |
|
|
gdth_delay(20);
|
808 |
|
|
while (readb(&dp6_ptr->u.ic.S_Status) != 0xff) {
|
809 |
|
|
if (--retries == 0) {
|
810 |
|
|
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
|
811 |
|
|
gdth_munmap(ha->brd);
|
812 |
|
|
return 0;
|
813 |
|
|
}
|
814 |
|
|
gdth_delay(1);
|
815 |
|
|
}
|
816 |
|
|
prot_ver = (unchar)readl(&dp6_ptr->u.ic.S_Info[0]);
|
817 |
|
|
writeb(0, &dp6_ptr->u.ic.S_Status);
|
818 |
|
|
writeb(0xff, &dp6_ptr->io.irqdel);
|
819 |
|
|
if (prot_ver != PROTOCOL_VERSION) {
|
820 |
|
|
printk("GDT-PCI: Illegal protocol version\n");
|
821 |
|
|
gdth_munmap(ha->brd);
|
822 |
|
|
return 0;
|
823 |
|
|
}
|
824 |
|
|
|
825 |
|
|
ha->type = GDT_PCI;
|
826 |
|
|
ha->ic_all_size = sizeof(dp6_ptr->u);
|
827 |
|
|
|
828 |
|
|
/* special command to controller BIOS */
|
829 |
|
|
writel(0x00, &dp6_ptr->u.ic.S_Info[0]);
|
830 |
|
|
writel(0x00, &dp6_ptr->u.ic.S_Info[1]);
|
831 |
|
|
writel(0x01, &dp6_ptr->u.ic.S_Info[2]);
|
832 |
|
|
writel(0x00, &dp6_ptr->u.ic.S_Info[3]);
|
833 |
|
|
writeb(0xfe, &dp6_ptr->u.ic.S_Cmd_Indx);
|
834 |
|
|
writeb(0, &dp6_ptr->io.event);
|
835 |
|
|
retries = INIT_RETRIES;
|
836 |
|
|
gdth_delay(20);
|
837 |
|
|
while (readb(&dp6_ptr->u.ic.S_Status) != 0xfe) {
|
838 |
|
|
if (--retries == 0) {
|
839 |
|
|
printk("GDT-PCI: Initialization error\n");
|
840 |
|
|
gdth_munmap(ha->brd);
|
841 |
|
|
return 0;
|
842 |
|
|
}
|
843 |
|
|
gdth_delay(1);
|
844 |
|
|
}
|
845 |
|
|
writeb(0, &dp6_ptr->u.ic.S_Status);
|
846 |
|
|
writeb(0xff, &dp6_ptr->io.irqdel);
|
847 |
|
|
|
848 |
|
|
} else if (ha->stype <= PCI_DEVICE_ID_VORTEX_GDT6555) { /* GDT6110, GDT6120, .. */
|
849 |
|
|
ha->plx = (gdt6c_plx_regs *)pcistr->io;
|
850 |
|
|
TRACE2(("init_pci_new() dpmem %lx io %lx irq %d\n",
|
851 |
|
|
pcistr->dpmem,(ulong)ha->plx,ha->irq));
|
852 |
|
|
ha->brd = gdth_mmap(pcistr->dpmem, sizeof(gdt6c_dpram_str));
|
853 |
|
|
if (ha->brd == NULL) {
|
854 |
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
855 |
|
|
gdth_munmap(ha->brd);
|
856 |
|
|
return 0;
|
857 |
|
|
}
|
858 |
|
|
dp6c_ptr = (gdt6c_dpram_str *)ha->brd;
|
859 |
|
|
/* reset interface area */
|
860 |
|
|
memset_io((char *)&dp6c_ptr->u,0,sizeof(dp6c_ptr->u));
|
861 |
|
|
if (readl(&dp6c_ptr->u) != 0) {
|
862 |
|
|
printk("GDT-PCI: Initialization error (DPMEM write error)\n");
|
863 |
|
|
gdth_munmap(ha->brd);
|
864 |
|
|
return 0;
|
865 |
|
|
}
|
866 |
|
|
|
867 |
|
|
/* disable board interrupts, deinit services */
|
868 |
|
|
outb(0x00,PTR2USHORT(&ha->plx->control1));
|
869 |
|
|
outb(0xff,PTR2USHORT(&ha->plx->edoor_reg));
|
870 |
|
|
|
871 |
|
|
writeb(0x00, &dp6c_ptr->u.ic.S_Status);
|
872 |
|
|
writeb(0x00, &dp6c_ptr->u.ic.Cmd_Index);
|
873 |
|
|
|
874 |
|
|
writel(pcistr->dpmem, &dp6c_ptr->u.ic.S_Info[0]);
|
875 |
|
|
writeb(0xff, &dp6c_ptr->u.ic.S_Cmd_Indx);
|
876 |
|
|
|
877 |
|
|
outb(1,PTR2USHORT(&ha->plx->ldoor_reg));
|
878 |
|
|
|
879 |
|
|
retries = INIT_RETRIES;
|
880 |
|
|
gdth_delay(20);
|
881 |
|
|
while (readb(&dp6c_ptr->u.ic.S_Status) != 0xff) {
|
882 |
|
|
if (--retries == 0) {
|
883 |
|
|
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
|
884 |
|
|
gdth_munmap(ha->brd);
|
885 |
|
|
return 0;
|
886 |
|
|
}
|
887 |
|
|
gdth_delay(1);
|
888 |
|
|
}
|
889 |
|
|
prot_ver = (unchar)readl(&dp6c_ptr->u.ic.S_Info[0]);
|
890 |
|
|
writeb(0, &dp6c_ptr->u.ic.Status);
|
891 |
|
|
if (prot_ver != PROTOCOL_VERSION) {
|
892 |
|
|
printk("GDT-PCI: Illegal protocol version\n");
|
893 |
|
|
gdth_munmap(ha->brd);
|
894 |
|
|
return 0;
|
895 |
|
|
}
|
896 |
|
|
|
897 |
|
|
ha->type = GDT_PCINEW;
|
898 |
|
|
ha->ic_all_size = sizeof(dp6c_ptr->u);
|
899 |
|
|
|
900 |
|
|
/* special command to controller BIOS */
|
901 |
|
|
writel(0x00, &dp6c_ptr->u.ic.S_Info[0]);
|
902 |
|
|
writel(0x00, &dp6c_ptr->u.ic.S_Info[1]);
|
903 |
|
|
writel(0x01, &dp6c_ptr->u.ic.S_Info[2]);
|
904 |
|
|
writel(0x00, &dp6c_ptr->u.ic.S_Info[3]);
|
905 |
|
|
writeb(0xfe, &dp6c_ptr->u.ic.S_Cmd_Indx);
|
906 |
|
|
|
907 |
|
|
outb(1,PTR2USHORT(&ha->plx->ldoor_reg));
|
908 |
|
|
|
909 |
|
|
retries = INIT_RETRIES;
|
910 |
|
|
gdth_delay(20);
|
911 |
|
|
while (readb(&dp6c_ptr->u.ic.S_Status) != 0xfe) {
|
912 |
|
|
if (--retries == 0) {
|
913 |
|
|
printk("GDT-PCI: Initialization error\n");
|
914 |
|
|
gdth_munmap(ha->brd);
|
915 |
|
|
return 0;
|
916 |
|
|
}
|
917 |
|
|
gdth_delay(1);
|
918 |
|
|
}
|
919 |
|
|
writeb(0, &dp6c_ptr->u.ic.S_Status);
|
920 |
|
|
|
921 |
|
|
} else { /* MPR */
|
922 |
|
|
TRACE2(("init_pci_mpr() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq));
|
923 |
|
|
ha->brd = gdth_mmap(pcistr->dpmem, sizeof(gdt6m_dpram_str));
|
924 |
|
|
if (ha->brd == NULL) {
|
925 |
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
926 |
|
|
return 0;
|
927 |
|
|
}
|
928 |
|
|
|
929 |
|
|
/* check and reset interface area */
|
930 |
|
|
dp6m_ptr = (gdt6m_dpram_str *)ha->brd;
|
931 |
|
|
writel(DPMEM_MAGIC, &dp6m_ptr->u);
|
932 |
|
|
if (readl(&dp6m_ptr->u) != DPMEM_MAGIC) {
|
933 |
|
|
printk("GDT-PCI: Cannot access DPMEM at 0x%x (shadowed?)\n",
|
934 |
|
|
(int)ha->brd);
|
935 |
|
|
found = FALSE;
|
936 |
|
|
for (i = 0xC8000; i < 0xE8000; i += 0x4000) {
|
937 |
|
|
pcibios_write_config_dword( pcistr->bus, pcistr->device_fn,
|
938 |
|
|
PCI_BASE_ADDRESS_0, i );
|
939 |
|
|
gdth_munmap( ha->brd );
|
940 |
|
|
ha->brd = gdth_mmap(i, sizeof(gdt6m_dpram_str));
|
941 |
|
|
if (ha->brd == NULL) {
|
942 |
|
|
printk("GDT-PCI: Initialization error (DPMEM remap error)\n");
|
943 |
|
|
return 0;
|
944 |
|
|
}
|
945 |
|
|
dp6m_ptr = (gdt6m_dpram_str *)ha->brd;
|
946 |
|
|
writel(DPMEM_MAGIC, &dp6m_ptr->u);
|
947 |
|
|
if (readl(&dp6m_ptr->u) == DPMEM_MAGIC) {
|
948 |
|
|
printk("GDT-PCI: Use free address at 0x%x\n",
|
949 |
|
|
(int)ha->brd);
|
950 |
|
|
found = TRUE;
|
951 |
|
|
break;
|
952 |
|
|
}
|
953 |
|
|
}
|
954 |
|
|
if (!found) {
|
955 |
|
|
printk("GDT-PCI: No free address found!\n");
|
956 |
|
|
gdth_munmap( ha->brd );
|
957 |
|
|
return 0;
|
958 |
|
|
}
|
959 |
|
|
}
|
960 |
|
|
memset_io((char *)&dp6m_ptr->u,0,sizeof(dp6m_ptr->u));
|
961 |
|
|
|
962 |
|
|
/* disable board interrupts, deinit services */
|
963 |
|
|
writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) | 4,
|
964 |
|
|
&dp6m_ptr->i960r.edoor_en_reg);
|
965 |
|
|
writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
|
966 |
|
|
writeb(0x00, &dp6m_ptr->u.ic.S_Status);
|
967 |
|
|
writeb(0x00, &dp6m_ptr->u.ic.Cmd_Index);
|
968 |
|
|
|
969 |
|
|
writel(pcistr->dpmem, &dp6m_ptr->u.ic.S_Info[0]);
|
970 |
|
|
writeb(0xff, &dp6m_ptr->u.ic.S_Cmd_Indx);
|
971 |
|
|
writeb(1, &dp6m_ptr->i960r.ldoor_reg);
|
972 |
|
|
retries = INIT_RETRIES;
|
973 |
|
|
gdth_delay(20);
|
974 |
|
|
while (readb(&dp6m_ptr->u.ic.S_Status) != 0xff) {
|
975 |
|
|
if (--retries == 0) {
|
976 |
|
|
printk("GDT-PCI: Initialization error (DEINIT failed)\n");
|
977 |
|
|
gdth_munmap(ha->brd);
|
978 |
|
|
return 0;
|
979 |
|
|
}
|
980 |
|
|
gdth_delay(1);
|
981 |
|
|
}
|
982 |
|
|
prot_ver = (unchar)readl(&dp6m_ptr->u.ic.S_Info[0]);
|
983 |
|
|
writeb(0, &dp6m_ptr->u.ic.S_Status);
|
984 |
|
|
if (prot_ver != PROTOCOL_VERSION) {
|
985 |
|
|
printk("GDT-PCI: Illegal protocol version\n");
|
986 |
|
|
gdth_munmap(ha->brd);
|
987 |
|
|
return 0;
|
988 |
|
|
}
|
989 |
|
|
|
990 |
|
|
ha->type = GDT_PCIMPR;
|
991 |
|
|
ha->ic_all_size = sizeof(dp6m_ptr->u);
|
992 |
|
|
|
993 |
|
|
/* special command to controller BIOS */
|
994 |
|
|
writel(0x00, &dp6m_ptr->u.ic.S_Info[0]);
|
995 |
|
|
writel(0x00, &dp6m_ptr->u.ic.S_Info[1]);
|
996 |
|
|
writel(0x01, &dp6m_ptr->u.ic.S_Info[2]);
|
997 |
|
|
writel(0x00, &dp6m_ptr->u.ic.S_Info[3]);
|
998 |
|
|
writeb(0xfe, &dp6m_ptr->u.ic.S_Cmd_Indx);
|
999 |
|
|
writeb(1, &dp6m_ptr->i960r.ldoor_reg);
|
1000 |
|
|
retries = INIT_RETRIES;
|
1001 |
|
|
gdth_delay(20);
|
1002 |
|
|
while (readb(&dp6m_ptr->u.ic.S_Status) != 0xfe) {
|
1003 |
|
|
if (--retries == 0) {
|
1004 |
|
|
printk("GDT-PCI: Initialization error\n");
|
1005 |
|
|
gdth_munmap(ha->brd);
|
1006 |
|
|
return 0;
|
1007 |
|
|
}
|
1008 |
|
|
gdth_delay(1);
|
1009 |
|
|
}
|
1010 |
|
|
writeb(0, &dp6m_ptr->u.ic.S_Status);
|
1011 |
|
|
}
|
1012 |
|
|
|
1013 |
|
|
return 1;
|
1014 |
|
|
}
|
1015 |
|
|
|
1016 |
|
|
|
1017 |
|
|
/* controller protocol functions */
|
1018 |
|
|
|
1019 |
|
|
__initfunc (static void gdth_enable_int(int hanum))
|
1020 |
|
|
{
|
1021 |
|
|
gdth_ha_str *ha;
|
1022 |
|
|
ulong flags;
|
1023 |
|
|
gdt2_dpram_str *dp2_ptr;
|
1024 |
|
|
gdt6_dpram_str *dp6_ptr;
|
1025 |
|
|
gdt6m_dpram_str *dp6m_ptr;
|
1026 |
|
|
|
1027 |
|
|
TRACE(("gdth_enable_int() hanum %d\n",hanum));
|
1028 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1029 |
|
|
|
1030 |
|
|
save_flags(flags);
|
1031 |
|
|
cli();
|
1032 |
|
|
|
1033 |
|
|
if (ha->type == GDT_EISA) {
|
1034 |
|
|
outb(0xff, ha->bmic + EDOORREG);
|
1035 |
|
|
outb(0xff, ha->bmic + EDENABREG);
|
1036 |
|
|
outb(0x01, ha->bmic + EINTENABREG);
|
1037 |
|
|
} else if (ha->type == GDT_ISA) {
|
1038 |
|
|
dp2_ptr = (gdt2_dpram_str *)ha->brd;
|
1039 |
|
|
writeb(1, &dp2_ptr->io.irqdel);
|
1040 |
|
|
writeb(0, &dp2_ptr->u.ic.Cmd_Index);
|
1041 |
|
|
writeb(1, &dp2_ptr->io.irqen);
|
1042 |
|
|
} else if (ha->type == GDT_PCI) {
|
1043 |
|
|
dp6_ptr = (gdt6_dpram_str *)ha->brd;
|
1044 |
|
|
writeb(1, &dp6_ptr->io.irqdel);
|
1045 |
|
|
writeb(0, &dp6_ptr->u.ic.Cmd_Index);
|
1046 |
|
|
writeb(1, &dp6_ptr->io.irqen);
|
1047 |
|
|
} else if (ha->type == GDT_PCINEW) {
|
1048 |
|
|
outb(0xff, PTR2USHORT(&ha->plx->edoor_reg));
|
1049 |
|
|
outb(0x03, PTR2USHORT(&ha->plx->control1));
|
1050 |
|
|
} else if (ha->type == GDT_PCIMPR) {
|
1051 |
|
|
dp6m_ptr = (gdt6m_dpram_str *)ha->brd;
|
1052 |
|
|
writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
|
1053 |
|
|
writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) & ~4,
|
1054 |
|
|
&dp6m_ptr->i960r.edoor_en_reg);
|
1055 |
|
|
}
|
1056 |
|
|
restore_flags(flags);
|
1057 |
|
|
}
|
1058 |
|
|
|
1059 |
|
|
|
1060 |
|
|
static int gdth_get_status(unchar *pIStatus,int irq)
|
1061 |
|
|
{
|
1062 |
|
|
register gdth_ha_str *ha;
|
1063 |
|
|
int i;
|
1064 |
|
|
|
1065 |
|
|
TRACE(("gdth_get_status() irq %d ctr_count %d\n",
|
1066 |
|
|
irq,gdth_ctr_count));
|
1067 |
|
|
|
1068 |
|
|
*pIStatus = 0;
|
1069 |
|
|
for (i=0; i<gdth_ctr_count; ++i) {
|
1070 |
|
|
ha = HADATA(gdth_ctr_tab[i]);
|
1071 |
|
|
if (ha->irq != (unchar)irq) /* check IRQ */
|
1072 |
|
|
continue;
|
1073 |
|
|
if (ha->type == GDT_EISA)
|
1074 |
|
|
*pIStatus = inb((ushort)ha->bmic + EDOORREG);
|
1075 |
|
|
else if (ha->type == GDT_ISA)
|
1076 |
|
|
*pIStatus = readb(&((gdt2_dpram_str *)ha->brd)->u.ic.Cmd_Index);
|
1077 |
|
|
else if (ha->type == GDT_PCI)
|
1078 |
|
|
*pIStatus = readb(&((gdt6_dpram_str *)ha->brd)->u.ic.Cmd_Index);
|
1079 |
|
|
else if (ha->type == GDT_PCINEW)
|
1080 |
|
|
*pIStatus = inb(PTR2USHORT(&ha->plx->edoor_reg));
|
1081 |
|
|
else if (ha->type == GDT_PCIMPR)
|
1082 |
|
|
*pIStatus = readb(&((gdt6m_dpram_str *)ha->brd)->i960r.edoor_reg);
|
1083 |
|
|
|
1084 |
|
|
if (*pIStatus)
|
1085 |
|
|
return i; /* board found */
|
1086 |
|
|
}
|
1087 |
|
|
return -1;
|
1088 |
|
|
}
|
1089 |
|
|
|
1090 |
|
|
|
1091 |
|
|
static int gdth_test_busy(int hanum)
|
1092 |
|
|
{
|
1093 |
|
|
register gdth_ha_str *ha;
|
1094 |
|
|
register int gdtsema0 = 0;
|
1095 |
|
|
|
1096 |
|
|
TRACE(("gdth_test_busy() hanum %d\n",hanum));
|
1097 |
|
|
|
1098 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1099 |
|
|
if (ha->type == GDT_EISA)
|
1100 |
|
|
gdtsema0 = (int)inb(ha->bmic + SEMA0REG);
|
1101 |
|
|
else if (ha->type == GDT_ISA)
|
1102 |
|
|
gdtsema0 = (int)readb(&((gdt2_dpram_str *)ha->brd)->u.ic.Sema0);
|
1103 |
|
|
else if (ha->type == GDT_PCI)
|
1104 |
|
|
gdtsema0 = (int)readb(&((gdt6_dpram_str *)ha->brd)->u.ic.Sema0);
|
1105 |
|
|
else if (ha->type == GDT_PCINEW)
|
1106 |
|
|
gdtsema0 = (int)inb(PTR2USHORT(&ha->plx->sema0_reg));
|
1107 |
|
|
else if (ha->type == GDT_PCIMPR)
|
1108 |
|
|
gdtsema0 = (int)readb(&((gdt6m_dpram_str *)ha->brd)->i960r.sema0_reg);
|
1109 |
|
|
|
1110 |
|
|
return (gdtsema0 & 1);
|
1111 |
|
|
}
|
1112 |
|
|
|
1113 |
|
|
|
1114 |
|
|
static int gdth_get_cmd_index(int hanum)
|
1115 |
|
|
{
|
1116 |
|
|
register gdth_ha_str *ha;
|
1117 |
|
|
int i;
|
1118 |
|
|
|
1119 |
|
|
TRACE(("gdth_get_cmd_index() hanum %d\n",hanum));
|
1120 |
|
|
|
1121 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1122 |
|
|
for (i=0; i<GDTH_MAXCMDS; ++i) {
|
1123 |
|
|
if (gdth_cmd_tab[i][hanum].cmnd == UNUSED_CMND) {
|
1124 |
|
|
gdth_cmd_tab[i][hanum].cmnd = ha->pccb->RequestBuffer;
|
1125 |
|
|
gdth_cmd_tab[i][hanum].service = ha->pccb->Service;
|
1126 |
|
|
ha->pccb->CommandIndex = (ulong)i+2;
|
1127 |
|
|
return (i+2);
|
1128 |
|
|
}
|
1129 |
|
|
}
|
1130 |
|
|
return 0;
|
1131 |
|
|
}
|
1132 |
|
|
|
1133 |
|
|
|
1134 |
|
|
static void gdth_set_sema0(int hanum)
|
1135 |
|
|
{
|
1136 |
|
|
register gdth_ha_str *ha;
|
1137 |
|
|
|
1138 |
|
|
TRACE(("gdth_set_sema0() hanum %d\n",hanum));
|
1139 |
|
|
|
1140 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1141 |
|
|
if (ha->type == GDT_EISA)
|
1142 |
|
|
outb(1, ha->bmic + SEMA0REG);
|
1143 |
|
|
else if (ha->type == GDT_ISA)
|
1144 |
|
|
writeb(1, &((gdt2_dpram_str *)ha->brd)->u.ic.Sema0);
|
1145 |
|
|
else if (ha->type == GDT_PCI)
|
1146 |
|
|
writeb(1, &((gdt6_dpram_str *)ha->brd)->u.ic.Sema0);
|
1147 |
|
|
else if (ha->type == GDT_PCINEW)
|
1148 |
|
|
outb(1, PTR2USHORT(&ha->plx->sema0_reg));
|
1149 |
|
|
else if (ha->type == GDT_PCIMPR)
|
1150 |
|
|
writeb(1, &((gdt6m_dpram_str *)ha->brd)->i960r.sema0_reg);
|
1151 |
|
|
|
1152 |
|
|
}
|
1153 |
|
|
|
1154 |
|
|
|
1155 |
|
|
static void gdth_copy_command(int hanum)
|
1156 |
|
|
{
|
1157 |
|
|
register gdth_ha_str *ha;
|
1158 |
|
|
register gdth_cmd_str *cmd_ptr;
|
1159 |
|
|
register gdt6m_dpram_str *dp6m_ptr;
|
1160 |
|
|
register gdt6c_dpram_str *dp6c_ptr;
|
1161 |
|
|
gdt6_dpram_str *dp6_ptr;
|
1162 |
|
|
gdt2_dpram_str *dp2_ptr;
|
1163 |
|
|
ushort cp_count,dp_offset,cmd_no;
|
1164 |
|
|
|
1165 |
|
|
TRACE(("gdth_copy_command() hanum %d\n",hanum));
|
1166 |
|
|
|
1167 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1168 |
|
|
cp_count = ha->cmd_len;
|
1169 |
|
|
dp_offset= ha->cmd_offs_dpmem;
|
1170 |
|
|
cmd_no = ha->cmd_cnt;
|
1171 |
|
|
cmd_ptr = ha->pccb;
|
1172 |
|
|
|
1173 |
|
|
++ha->cmd_cnt;
|
1174 |
|
|
if (ha->type == GDT_EISA)
|
1175 |
|
|
return; /* no DPMEM, no copy */
|
1176 |
|
|
|
1177 |
|
|
/* set cpcount dword aligned */
|
1178 |
|
|
if (cp_count & 3)
|
1179 |
|
|
cp_count += (4 - (cp_count & 3));
|
1180 |
|
|
|
1181 |
|
|
ha->cmd_offs_dpmem += cp_count;
|
1182 |
|
|
|
1183 |
|
|
/* set offset and service, copy command to DPMEM */
|
1184 |
|
|
if (ha->type == GDT_ISA) {
|
1185 |
|
|
dp2_ptr = (gdt2_dpram_str *)ha->brd;
|
1186 |
|
|
writew(dp_offset + DPMEM_COMMAND_OFFSET,
|
1187 |
|
|
&dp2_ptr->u.ic.comm_queue[cmd_no].offset);
|
1188 |
|
|
writew((ushort)cmd_ptr->Service,
|
1189 |
|
|
&dp2_ptr->u.ic.comm_queue[cmd_no].serv_id);
|
1190 |
|
|
memcpy_toio(&dp2_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
|
1191 |
|
|
} else if (ha->type == GDT_PCI) {
|
1192 |
|
|
dp6_ptr = (gdt6_dpram_str *)ha->brd;
|
1193 |
|
|
writew(dp_offset + DPMEM_COMMAND_OFFSET,
|
1194 |
|
|
&dp6_ptr->u.ic.comm_queue[cmd_no].offset);
|
1195 |
|
|
writew((ushort)cmd_ptr->Service,
|
1196 |
|
|
&dp6_ptr->u.ic.comm_queue[cmd_no].serv_id);
|
1197 |
|
|
memcpy_toio(&dp6_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
|
1198 |
|
|
} else if (ha->type == GDT_PCINEW) {
|
1199 |
|
|
dp6c_ptr = (gdt6c_dpram_str *)ha->brd;
|
1200 |
|
|
writew(dp_offset + DPMEM_COMMAND_OFFSET,
|
1201 |
|
|
&dp6c_ptr->u.ic.comm_queue[cmd_no].offset);
|
1202 |
|
|
writew((ushort)cmd_ptr->Service,
|
1203 |
|
|
&dp6c_ptr->u.ic.comm_queue[cmd_no].serv_id);
|
1204 |
|
|
memcpy_toio(&dp6c_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
|
1205 |
|
|
} else if (ha->type == GDT_PCIMPR) {
|
1206 |
|
|
dp6m_ptr = (gdt6m_dpram_str *)ha->brd;
|
1207 |
|
|
writew(dp_offset + DPMEM_COMMAND_OFFSET,
|
1208 |
|
|
&dp6m_ptr->u.ic.comm_queue[cmd_no].offset);
|
1209 |
|
|
writew((ushort)cmd_ptr->Service,
|
1210 |
|
|
&dp6m_ptr->u.ic.comm_queue[cmd_no].serv_id);
|
1211 |
|
|
memcpy_toio(&dp6m_ptr->u.ic.gdt_dpr_cmd[dp_offset],cmd_ptr,cp_count);
|
1212 |
|
|
}
|
1213 |
|
|
}
|
1214 |
|
|
|
1215 |
|
|
|
1216 |
|
|
static void gdth_release_event(int hanum)
|
1217 |
|
|
{
|
1218 |
|
|
register gdth_ha_str *ha;
|
1219 |
|
|
|
1220 |
|
|
#ifdef GDTH_STATISTICS
|
1221 |
|
|
ulong i,j;
|
1222 |
|
|
for (i=0,j=0; j<GDTH_MAXCMDS; ++j) {
|
1223 |
|
|
if (gdth_cmd_tab[j][hanum].cmnd != UNUSED_CMND)
|
1224 |
|
|
++i;
|
1225 |
|
|
}
|
1226 |
|
|
if (max_index < i) {
|
1227 |
|
|
max_index = i;
|
1228 |
|
|
TRACE3(("GDT: max_index = %d\n",(ushort)i));
|
1229 |
|
|
}
|
1230 |
|
|
#endif
|
1231 |
|
|
|
1232 |
|
|
TRACE(("gdth_release_event() hanum %d\n",hanum));
|
1233 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1234 |
|
|
|
1235 |
|
|
if (ha->pccb->OpCode == GDT_INIT)
|
1236 |
|
|
ha->pccb->Service |= 0x80;
|
1237 |
|
|
|
1238 |
|
|
if (ha->type == GDT_EISA) {
|
1239 |
|
|
outb(ha->pccb->Service, ha->bmic + LDOORREG);
|
1240 |
|
|
if (ha->pccb->OpCode == GDT_INIT) /* store DMA buffer */
|
1241 |
|
|
outl((ulong)ha->pccb, ha->bmic + MAILBOXREG);
|
1242 |
|
|
} else if (ha->type == GDT_ISA)
|
1243 |
|
|
writeb(0, &((gdt2_dpram_str *)ha->brd)->io.event);
|
1244 |
|
|
else if (ha->type == GDT_PCI)
|
1245 |
|
|
writeb(0, &((gdt6_dpram_str *)ha->brd)->io.event);
|
1246 |
|
|
else if (ha->type == GDT_PCINEW)
|
1247 |
|
|
outb(1, PTR2USHORT(&ha->plx->ldoor_reg));
|
1248 |
|
|
else if (ha->type == GDT_PCIMPR)
|
1249 |
|
|
writeb(1, &((gdt6m_dpram_str *)ha->brd)->i960r.ldoor_reg);
|
1250 |
|
|
}
|
1251 |
|
|
|
1252 |
|
|
|
1253 |
|
|
static int gdth_wait(int hanum,int index,ulong time)
|
1254 |
|
|
{
|
1255 |
|
|
gdth_ha_str *ha;
|
1256 |
|
|
int answer_found = FALSE;
|
1257 |
|
|
|
1258 |
|
|
TRACE(("gdth_wait() hanum %d index %d time %ld\n",hanum,index,time));
|
1259 |
|
|
|
1260 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1261 |
|
|
if (index == 0)
|
1262 |
|
|
return 1; /* no wait required */
|
1263 |
|
|
|
1264 |
|
|
gdth_from_wait = TRUE;
|
1265 |
|
|
do {
|
1266 |
|
|
#if LINUX_VERSION_CODE >= 0x010346
|
1267 |
|
|
gdth_interrupt((int)ha->irq,NULL,NULL);
|
1268 |
|
|
#else
|
1269 |
|
|
gdth_interrupt((int)ha->irq,NULL);
|
1270 |
|
|
#endif
|
1271 |
|
|
if (wait_hanum==hanum && wait_index==index) {
|
1272 |
|
|
answer_found = TRUE;
|
1273 |
|
|
break;
|
1274 |
|
|
}
|
1275 |
|
|
gdth_delay(1);
|
1276 |
|
|
} while (--time);
|
1277 |
|
|
gdth_from_wait = FALSE;
|
1278 |
|
|
|
1279 |
|
|
while (gdth_test_busy(hanum))
|
1280 |
|
|
gdth_delay(0);
|
1281 |
|
|
|
1282 |
|
|
return (answer_found);
|
1283 |
|
|
}
|
1284 |
|
|
|
1285 |
|
|
|
1286 |
|
|
static int gdth_internal_cmd(int hanum,unchar service,ushort opcode,ulong p1,
|
1287 |
|
|
ulong p2,ulong p3)
|
1288 |
|
|
{
|
1289 |
|
|
register gdth_ha_str *ha;
|
1290 |
|
|
register gdth_cmd_str *cmd_ptr;
|
1291 |
|
|
int retries,index;
|
1292 |
|
|
|
1293 |
|
|
TRACE2(("gdth_internal_cmd() service %d opcode %d\n",service,opcode));
|
1294 |
|
|
|
1295 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1296 |
|
|
cmd_ptr = ha->pccb;
|
1297 |
|
|
memset((char*)cmd_ptr,0,sizeof(gdth_cmd_str));
|
1298 |
|
|
|
1299 |
|
|
/* make command */
|
1300 |
|
|
for (retries = INIT_RETRIES;;) {
|
1301 |
|
|
cmd_ptr->Service = service;
|
1302 |
|
|
cmd_ptr->RequestBuffer = INTERNAL_CMND;
|
1303 |
|
|
if (!(index=gdth_get_cmd_index(hanum))) {
|
1304 |
|
|
TRACE(("GDT: No free command index found\n"));
|
1305 |
|
|
return 0;
|
1306 |
|
|
}
|
1307 |
|
|
gdth_set_sema0(hanum);
|
1308 |
|
|
cmd_ptr->OpCode = opcode;
|
1309 |
|
|
cmd_ptr->BoardNode = LOCALBOARD;
|
1310 |
|
|
if (service == CACHESERVICE) {
|
1311 |
|
|
if (opcode == GDT_IOCTL) {
|
1312 |
|
|
cmd_ptr->u.ioctl.subfunc = p1;
|
1313 |
|
|
cmd_ptr->u.ioctl.channel = p2;
|
1314 |
|
|
cmd_ptr->u.ioctl.param_size = (ushort)p3;
|
1315 |
|
|
cmd_ptr->u.ioctl.p_param = virt_to_bus(ha->pscratch);
|
1316 |
|
|
} else {
|
1317 |
|
|
cmd_ptr->u.cache.DeviceNo = (ushort)p1;
|
1318 |
|
|
cmd_ptr->u.cache.BlockNo = p2;
|
1319 |
|
|
}
|
1320 |
|
|
} else if (service == SCSIRAWSERVICE) {
|
1321 |
|
|
cmd_ptr->u.raw.direction = p1;
|
1322 |
|
|
cmd_ptr->u.raw.bus = (unchar)p2;
|
1323 |
|
|
cmd_ptr->u.raw.target = (unchar)p3;
|
1324 |
|
|
cmd_ptr->u.raw.lun = 0;
|
1325 |
|
|
}
|
1326 |
|
|
ha->cmd_len = sizeof(gdth_cmd_str);
|
1327 |
|
|
ha->cmd_offs_dpmem = 0;
|
1328 |
|
|
ha->cmd_cnt = 0;
|
1329 |
|
|
gdth_copy_command(hanum);
|
1330 |
|
|
gdth_release_event(hanum);
|
1331 |
|
|
gdth_delay(20);
|
1332 |
|
|
if (!gdth_wait(hanum,index,INIT_TIMEOUT)) {
|
1333 |
|
|
printk("GDT: Initialization error (timeout service %d)\n",service);
|
1334 |
|
|
return 0;
|
1335 |
|
|
}
|
1336 |
|
|
if (ha->status != S_BSY || --retries == 0)
|
1337 |
|
|
break;
|
1338 |
|
|
gdth_delay(1);
|
1339 |
|
|
}
|
1340 |
|
|
|
1341 |
|
|
return (ha->status != S_OK ? 0:1);
|
1342 |
|
|
}
|
1343 |
|
|
|
1344 |
|
|
|
1345 |
|
|
/* search for devices */
|
1346 |
|
|
|
1347 |
|
|
__initfunc (static int gdth_search_drives(int hanum))
|
1348 |
|
|
{
|
1349 |
|
|
register gdth_ha_str *ha;
|
1350 |
|
|
ushort cdev_cnt,i;
|
1351 |
|
|
unchar b,t,pos_found;
|
1352 |
|
|
ulong drv_cyls, drv_hds, drv_secs;
|
1353 |
|
|
ulong bus_no;
|
1354 |
|
|
gdth_getch_str *chn;
|
1355 |
|
|
gdth_iochan_str *ioc;
|
1356 |
|
|
|
1357 |
|
|
TRACE(("gdth_search_drives() hanum %d\n",hanum));
|
1358 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1359 |
|
|
|
1360 |
|
|
/* initialize controller services, at first: screen service */
|
1361 |
|
|
if (!gdth_internal_cmd(hanum,SCREENSERVICE,GDT_INIT,0,0,0)) {
|
1362 |
|
|
printk("GDT: Initialization error screen service (code %d)\n",
|
1363 |
|
|
ha->status);
|
1364 |
|
|
return 0;
|
1365 |
|
|
}
|
1366 |
|
|
TRACE2(("gdth_search_drives(): SCREENSERVICE initialized\n"));
|
1367 |
|
|
|
1368 |
|
|
/* initialize cache service */
|
1369 |
|
|
if (!gdth_internal_cmd(hanum,CACHESERVICE,GDT_INIT,LINUX_OS,0,0)) {
|
1370 |
|
|
printk("GDT: Initialization error cache service (code %d)\n",
|
1371 |
|
|
ha->status);
|
1372 |
|
|
return 0;
|
1373 |
|
|
}
|
1374 |
|
|
TRACE2(("gdth_search_drives(): CACHESERVICE initialized\n"));
|
1375 |
|
|
cdev_cnt = (ushort)ha->info;
|
1376 |
|
|
|
1377 |
|
|
/* mount all cache devices */
|
1378 |
|
|
gdth_internal_cmd(hanum,CACHESERVICE,GDT_MOUNT,0xffff,1,0);
|
1379 |
|
|
TRACE2(("gdth_search_drives(): mountall CACHESERVICE OK\n"));
|
1380 |
|
|
|
1381 |
|
|
/* initialize cache service after mountall */
|
1382 |
|
|
if (!gdth_internal_cmd(hanum,CACHESERVICE,GDT_INIT,LINUX_OS,0,0)) {
|
1383 |
|
|
printk("GDT: Initialization error cache service (code %d)\n",
|
1384 |
|
|
ha->status);
|
1385 |
|
|
return 0;
|
1386 |
|
|
}
|
1387 |
|
|
TRACE2(("gdth_search_drives() CACHES. init. after mountall\n"));
|
1388 |
|
|
cdev_cnt = (ushort)ha->info;
|
1389 |
|
|
|
1390 |
|
|
/* detect number of SCSI buses - try new IOCTL */
|
1391 |
|
|
ioc = (gdth_iochan_str *)DMADATA(gdth_ctr_tab[hanum]);
|
1392 |
|
|
ioc->version = -1UL;
|
1393 |
|
|
ioc->list_entries = MAXBUS;
|
1394 |
|
|
ioc->first_chan = 0;
|
1395 |
|
|
ioc->last_chan = MAXBUS-1;
|
1396 |
|
|
ioc->list_offset = GDTOFFSOF(gdth_iochan_str, list[0]);
|
1397 |
|
|
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,GET_IOCHAN_DESC,
|
1398 |
|
|
INVALID_CHANNEL,sizeof(gdth_iochan_str))) {
|
1399 |
|
|
TRACE2(("GET_IOCHAN_DESC supported!\n"));
|
1400 |
|
|
ha->bus_cnt = ioc->chan_count;
|
1401 |
|
|
for (bus_no = 0; bus_no < ha->bus_cnt; ++bus_no)
|
1402 |
|
|
if (ioc->list[bus_no].proc_id < MAXID)
|
1403 |
|
|
ha->id[bus_no][ioc->list[bus_no].proc_id].type = SIOP_DTYP;
|
1404 |
|
|
} else {
|
1405 |
|
|
/* old method */
|
1406 |
|
|
chn = (gdth_getch_str *)DMADATA(gdth_ctr_tab[hanum]);
|
1407 |
|
|
for (bus_no = 0; bus_no < MAXBUS; ++bus_no) {
|
1408 |
|
|
chn->channel_no = bus_no;
|
1409 |
|
|
if (!gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,
|
1410 |
|
|
SCSI_CHAN_CNT | L_CTRL_PATTERN,
|
1411 |
|
|
IO_CHANNEL | INVALID_CHANNEL,
|
1412 |
|
|
sizeof(gdth_getch_str))) {
|
1413 |
|
|
if (bus_no == 0) {
|
1414 |
|
|
printk("GDT: Error detecting SCSI channel count (0x%x)\n",
|
1415 |
|
|
ha->status);
|
1416 |
|
|
return 0;
|
1417 |
|
|
}
|
1418 |
|
|
break;
|
1419 |
|
|
}
|
1420 |
|
|
if (chn->siop_id < MAXID)
|
1421 |
|
|
ha->id[bus_no][chn->siop_id].type = SIOP_DTYP;
|
1422 |
|
|
}
|
1423 |
|
|
ha->bus_cnt = (unchar)bus_no;
|
1424 |
|
|
}
|
1425 |
|
|
TRACE2(("gdth_search_drives() %d SCSI channels\n",ha->bus_cnt));
|
1426 |
|
|
|
1427 |
|
|
/* read cache configuration */
|
1428 |
|
|
if (!gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,CACHE_INFO,
|
1429 |
|
|
INVALID_CHANNEL,sizeof(gdth_cinfo_str))) {
|
1430 |
|
|
printk("GDT: Initialization error cache service (code %d)\n",
|
1431 |
|
|
ha->status);
|
1432 |
|
|
return 0;
|
1433 |
|
|
}
|
1434 |
|
|
ha->cpar = ((gdth_cinfo_str *)DMADATA(gdth_ctr_tab[hanum]))->cpar;
|
1435 |
|
|
TRACE2(("gdth_search_drives() cinfo: vs %lx sta %d str %d dw %d b %d\n",
|
1436 |
|
|
ha->cpar.version,ha->cpar.state,ha->cpar.strategy,
|
1437 |
|
|
ha->cpar.write_back,ha->cpar.block_size));
|
1438 |
|
|
|
1439 |
|
|
/* read board info, fill ctr_name[] */
|
1440 |
|
|
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_IOCTL,BOARD_INFO,
|
1441 |
|
|
INVALID_CHANNEL,sizeof(gdth_binfo_str))) {
|
1442 |
|
|
TRACE2(("BOARD_INFO supported!\n"));
|
1443 |
|
|
strcpy(ha->ctr_name, ((gdth_binfo_str *)DMADATA(gdth_ctr_tab[hanum]))->type_string);
|
1444 |
|
|
} else {
|
1445 |
|
|
strcpy(ha->ctr_name, gdth_ctr_name(hanum));
|
1446 |
|
|
}
|
1447 |
|
|
TRACE2(("Controller name: %s\n",ha->ctr_name));
|
1448 |
|
|
|
1449 |
|
|
/* initialize raw service */
|
1450 |
|
|
if (!gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_INIT,0,0,0)) {
|
1451 |
|
|
printk("GDT: Initialization error raw service (code %d)\n",
|
1452 |
|
|
ha->status);
|
1453 |
|
|
return 0;
|
1454 |
|
|
}
|
1455 |
|
|
TRACE2(("gdth_search_drives(): RAWSERVICE initialized\n"));
|
1456 |
|
|
|
1457 |
|
|
/* set/get features raw service (scatter/gather) */
|
1458 |
|
|
ha->raw_feat = 0;
|
1459 |
|
|
if (gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_SET_FEAT,SCATTER_GATHER,
|
1460 |
|
|
0,0)) {
|
1461 |
|
|
TRACE2(("gdth_search_drives(): set features RAWSERVICE OK\n"));
|
1462 |
|
|
if (gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_GET_FEAT,0,0,0)) {
|
1463 |
|
|
TRACE2(("gdth_search_dr(): get feat RAWSERVICE %ld\n",
|
1464 |
|
|
ha->info));
|
1465 |
|
|
ha->raw_feat = (ushort)ha->info;
|
1466 |
|
|
}
|
1467 |
|
|
}
|
1468 |
|
|
|
1469 |
|
|
/* set/get features cache service (equal to raw service) */
|
1470 |
|
|
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_SET_FEAT,0,
|
1471 |
|
|
SCATTER_GATHER,0)) {
|
1472 |
|
|
TRACE2(("gdth_search_drives(): set features CACHESERVICE OK\n"));
|
1473 |
|
|
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_GET_FEAT,0,0,0)) {
|
1474 |
|
|
TRACE2(("gdth_search_dr(): get feat CACHESERV. %ld\n",
|
1475 |
|
|
ha->info));
|
1476 |
|
|
ha->cache_feat = (ushort)ha->info;
|
1477 |
|
|
}
|
1478 |
|
|
}
|
1479 |
|
|
|
1480 |
|
|
/* reserve drives for raw service */
|
1481 |
|
|
for (i = 0; reserve_list[i].hanum != 0xff; ++i) {
|
1482 |
|
|
if (reserve_list[i].hanum < MAXHA && reserve_list[i].hanum == hanum &&
|
1483 |
|
|
reserve_list[i].bus < MAXBUS && reserve_list[i].id < MAXID) {
|
1484 |
|
|
TRACE2(("gdth_search_drives(): reserve ha %d bus %d id %d\n",
|
1485 |
|
|
reserve_list[i].hanum, reserve_list[i].bus,
|
1486 |
|
|
reserve_list[i].id));
|
1487 |
|
|
if (!gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_RESERVE,0,
|
1488 |
|
|
reserve_list[i].bus, reserve_list[i].id)) {
|
1489 |
|
|
printk("GDT: Error raw service (RESERVE, code %d)\n",
|
1490 |
|
|
ha->status);
|
1491 |
|
|
}
|
1492 |
|
|
}
|
1493 |
|
|
}
|
1494 |
|
|
|
1495 |
|
|
/* scanning for raw devices */
|
1496 |
|
|
for (b=0; b<ha->bus_cnt; ++b) {
|
1497 |
|
|
for (t=0; t<MAXID; ++t) {
|
1498 |
|
|
TRACE(("gdth_search_drives() rawd. bus %d id %d\n",b,t));
|
1499 |
|
|
if (ha->id[b][t].type != SIOP_DTYP &&
|
1500 |
|
|
gdth_internal_cmd(hanum,SCSIRAWSERVICE,GDT_INFO,0,b,t)) {
|
1501 |
|
|
ha->id[b][t].type = RAW_DTYP;
|
1502 |
|
|
}
|
1503 |
|
|
}
|
1504 |
|
|
}
|
1505 |
|
|
|
1506 |
|
|
/* scanning for cache devices */
|
1507 |
|
|
for (i=0; i<cdev_cnt && i<MAX_HDRIVES; ++i) {
|
1508 |
|
|
TRACE(("gdth_search_drives() cachedev. %d\n",i));
|
1509 |
|
|
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_INFO,i,0,0)) {
|
1510 |
|
|
/* dynamic relation between host drive number and Bus/ID */
|
1511 |
|
|
/* search free position */
|
1512 |
|
|
pos_found = FALSE;
|
1513 |
|
|
for (b=0,t=0; b<ha->bus_cnt; ++b) {
|
1514 |
|
|
for (t=0; t<MAXID; ++t) {
|
1515 |
|
|
if (ha->id[b][t].type == EMPTY_DTYP) {
|
1516 |
|
|
pos_found = TRUE;
|
1517 |
|
|
break;
|
1518 |
|
|
}
|
1519 |
|
|
}
|
1520 |
|
|
if (pos_found)
|
1521 |
|
|
break;
|
1522 |
|
|
}
|
1523 |
|
|
TRACE(("gdth_search_dr() drive %d free pos at bus/id %d/%d\n",
|
1524 |
|
|
i,b,t));
|
1525 |
|
|
|
1526 |
|
|
ha->id[b][t].type = CACHE_DTYP;
|
1527 |
|
|
ha->id[b][t].devtype = 0;
|
1528 |
|
|
ha->id[b][t].size = ha->info;
|
1529 |
|
|
ha->id[b][t].hostdrive = i;
|
1530 |
|
|
|
1531 |
|
|
/* evaluate mapping (sectors per head, heads per cylinder) */
|
1532 |
|
|
ha->id[b][t].size &= ~SECS32;
|
1533 |
|
|
if (ha->info2 == 0) {
|
1534 |
|
|
drv_cyls = ha->id[b][t].size /HEADS/SECS;
|
1535 |
|
|
if (drv_cyls <= MAXCYLS) {
|
1536 |
|
|
drv_hds = HEADS;
|
1537 |
|
|
drv_secs= SECS;
|
1538 |
|
|
} else { /* too high for 64*32 */
|
1539 |
|
|
drv_cyls = ha->id[b][t].size /MEDHEADS/MEDSECS;
|
1540 |
|
|
if (drv_cyls <= MAXCYLS) {
|
1541 |
|
|
drv_hds = MEDHEADS;
|
1542 |
|
|
drv_secs= MEDSECS;
|
1543 |
|
|
} else { /* too high for 127*63 */
|
1544 |
|
|
drv_cyls = ha->id[b][t].size /BIGHEADS/BIGSECS;
|
1545 |
|
|
drv_hds = BIGHEADS;
|
1546 |
|
|
drv_secs= BIGSECS;
|
1547 |
|
|
}
|
1548 |
|
|
}
|
1549 |
|
|
} else {
|
1550 |
|
|
drv_hds = ha->info2 & 0xff;
|
1551 |
|
|
drv_secs = (ha->info2 >> 8) & 0xff;
|
1552 |
|
|
drv_cyls = ha->id[b][t].size /drv_hds/drv_secs;
|
1553 |
|
|
}
|
1554 |
|
|
ha->id[b][t].heads = (unchar)drv_hds;
|
1555 |
|
|
ha->id[b][t].secs = (unchar)drv_secs;
|
1556 |
|
|
/* round size */
|
1557 |
|
|
ha->id[b][t].size = drv_cyls * drv_hds * drv_secs;
|
1558 |
|
|
TRACE2(("gdth_search_dr() cdr. %d size %ld hds %ld scs %ld\n",
|
1559 |
|
|
i,ha->id[b][t].size,drv_hds,drv_secs));
|
1560 |
|
|
|
1561 |
|
|
/* get informations about device */
|
1562 |
|
|
if (gdth_internal_cmd(hanum,CACHESERVICE,GDT_DEVTYPE,i,
|
1563 |
|
|
0,0)) {
|
1564 |
|
|
TRACE(("gdth_search_dr() cache drive %d devtype %ld\n",
|
1565 |
|
|
i,ha->info));
|
1566 |
|
|
ha->id[b][t].devtype = (ushort)ha->info;
|
1567 |
|
|
}
|
1568 |
|
|
}
|
1569 |
|
|
}
|
1570 |
|
|
|
1571 |
|
|
TRACE(("gdth_search_drives() OK\n"));
|
1572 |
|
|
return 1;
|
1573 |
|
|
}
|
1574 |
|
|
|
1575 |
|
|
|
1576 |
|
|
/* command queueing/sending functions */
|
1577 |
|
|
|
1578 |
|
|
static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority)
|
1579 |
|
|
{
|
1580 |
|
|
register gdth_ha_str *ha;
|
1581 |
|
|
register Scsi_Cmnd *pscp;
|
1582 |
|
|
register Scsi_Cmnd *nscp;
|
1583 |
|
|
ulong flags;
|
1584 |
|
|
unchar b, t;
|
1585 |
|
|
|
1586 |
|
|
TRACE(("gdth_putq() priority %d\n",priority));
|
1587 |
|
|
save_flags(flags);
|
1588 |
|
|
cli();
|
1589 |
|
|
|
1590 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1591 |
|
|
scp->SCp.this_residual = (int)priority;
|
1592 |
|
|
gdth_update_timeout(hanum, scp, scp->timeout_per_command * 6);
|
1593 |
|
|
#if LINUX_VERSION_CODE >= 0x020000
|
1594 |
|
|
b = scp->channel;
|
1595 |
|
|
#else
|
1596 |
|
|
b = NUMDATA(nscp->host)->busnum;
|
1597 |
|
|
#endif
|
1598 |
|
|
t = scp->target;
|
1599 |
|
|
#if LINUX_VERSION_CODE >= 0x010300
|
1600 |
|
|
if (priority >= DEFAULT_PRI && ha->id[b][t].lock) {
|
1601 |
|
|
TRACE2(("gdth_putq(): locked IO -> update_timeout()\n"));
|
1602 |
|
|
scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0);
|
1603 |
|
|
}
|
1604 |
|
|
#endif
|
1605 |
|
|
|
1606 |
|
|
if (ha->req_first==NULL) {
|
1607 |
|
|
ha->req_first = scp; /* queue was empty */
|
1608 |
|
|
scp->SCp.ptr = NULL;
|
1609 |
|
|
} else { /* queue not empty */
|
1610 |
|
|
pscp = ha->req_first;
|
1611 |
|
|
nscp = (Scsi_Cmnd *)pscp->SCp.ptr;
|
1612 |
|
|
/* priority: 0-highest,..,0xff-lowest */
|
1613 |
|
|
while (nscp && (unchar)nscp->SCp.this_residual <= priority) {
|
1614 |
|
|
pscp = nscp;
|
1615 |
|
|
nscp = (Scsi_Cmnd *)pscp->SCp.ptr;
|
1616 |
|
|
}
|
1617 |
|
|
pscp->SCp.ptr = (char *)scp;
|
1618 |
|
|
scp->SCp.ptr = (char *)nscp;
|
1619 |
|
|
}
|
1620 |
|
|
restore_flags(flags);
|
1621 |
|
|
|
1622 |
|
|
#ifdef GDTH_STATISTICS
|
1623 |
|
|
flags = 0;
|
1624 |
|
|
for (nscp=ha->req_first; nscp; nscp=(Scsi_Cmnd*)nscp->SCp.ptr)
|
1625 |
|
|
++flags;
|
1626 |
|
|
if (max_rq < flags) {
|
1627 |
|
|
max_rq = flags;
|
1628 |
|
|
TRACE3(("GDT: max_rq = %d\n",(ushort)max_rq));
|
1629 |
|
|
}
|
1630 |
|
|
#endif
|
1631 |
|
|
}
|
1632 |
|
|
|
1633 |
|
|
static void gdth_next(int hanum)
|
1634 |
|
|
{
|
1635 |
|
|
register gdth_ha_str *ha;
|
1636 |
|
|
register Scsi_Cmnd *pscp;
|
1637 |
|
|
register Scsi_Cmnd *nscp;
|
1638 |
|
|
unchar b, t, next_cmd, firsttime;
|
1639 |
|
|
ushort hdrive;
|
1640 |
|
|
ulong flags;
|
1641 |
|
|
int cmd_index;
|
1642 |
|
|
|
1643 |
|
|
TRACE(("gdth_next() hanum %d\n",hanum));
|
1644 |
|
|
save_flags(flags);
|
1645 |
|
|
cli();
|
1646 |
|
|
|
1647 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1648 |
|
|
ha->cmd_cnt = ha->cmd_offs_dpmem = 0;
|
1649 |
|
|
next_cmd = firsttime = TRUE;
|
1650 |
|
|
cmd_index = 0;
|
1651 |
|
|
|
1652 |
|
|
for (nscp = pscp = ha->req_first; nscp; nscp = (Scsi_Cmnd *)nscp->SCp.ptr) {
|
1653 |
|
|
if (nscp != pscp && nscp != (Scsi_Cmnd *)pscp->SCp.ptr)
|
1654 |
|
|
pscp = (Scsi_Cmnd *)pscp->SCp.ptr;
|
1655 |
|
|
#if LINUX_VERSION_CODE >= 0x020000
|
1656 |
|
|
b = nscp->channel;
|
1657 |
|
|
#else
|
1658 |
|
|
b = NUMDATA(nscp->host)->busnum;
|
1659 |
|
|
#endif
|
1660 |
|
|
t = nscp->target;
|
1661 |
|
|
if (nscp->SCp.this_residual < DEFAULT_PRI || !ha->id[b][t].lock) {
|
1662 |
|
|
|
1663 |
|
|
if (firsttime) {
|
1664 |
|
|
if (gdth_test_busy(hanum)) { /* controller busy ? */
|
1665 |
|
|
TRACE(("gdth_next() controller %d busy !\n",hanum));
|
1666 |
|
|
if (!gdth_polling) {
|
1667 |
|
|
restore_flags(flags);
|
1668 |
|
|
return;
|
1669 |
|
|
}
|
1670 |
|
|
while (gdth_test_busy(hanum))
|
1671 |
|
|
gdth_delay(1);
|
1672 |
|
|
}
|
1673 |
|
|
firsttime = FALSE;
|
1674 |
|
|
}
|
1675 |
|
|
|
1676 |
|
|
#if LINUX_VERSION_CODE >= 0x010300
|
1677 |
|
|
if (nscp->done == gdth_scsi_done) {
|
1678 |
|
|
if (!(cmd_index=gdth_special_cmd(hanum,nscp,b)))
|
1679 |
|
|
next_cmd = FALSE;
|
1680 |
|
|
} else
|
1681 |
|
|
#endif
|
1682 |
|
|
if (ha->id[b][t].type != CACHE_DTYP) {
|
1683 |
|
|
if (!(cmd_index=gdth_fill_raw_cmd(hanum,nscp,b)))
|
1684 |
|
|
next_cmd = FALSE;
|
1685 |
|
|
} else {
|
1686 |
|
|
hdrive = ha->id[b][t].hostdrive;
|
1687 |
|
|
switch (nscp->cmnd[0]) {
|
1688 |
|
|
case TEST_UNIT_READY:
|
1689 |
|
|
case INQUIRY:
|
1690 |
|
|
case REQUEST_SENSE:
|
1691 |
|
|
case READ_CAPACITY:
|
1692 |
|
|
case VERIFY:
|
1693 |
|
|
case START_STOP:
|
1694 |
|
|
case MODE_SENSE:
|
1695 |
|
|
TRACE2(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp->cmnd[0],
|
1696 |
|
|
nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3],
|
1697 |
|
|
nscp->cmnd[4],nscp->cmnd[5]));
|
1698 |
|
|
gdth_internal_cache_cmd(hanum,nscp,b,&flags);
|
1699 |
|
|
break;
|
1700 |
|
|
|
1701 |
|
|
case ALLOW_MEDIUM_REMOVAL:
|
1702 |
|
|
TRACE2(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp->cmnd[0],
|
1703 |
|
|
nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3],
|
1704 |
|
|
nscp->cmnd[4],nscp->cmnd[5]));
|
1705 |
|
|
if ( (nscp->cmnd[4]&1) && !(ha->id[b][t].devtype&1) ) {
|
1706 |
|
|
TRACE2(("Prevent r. nonremov. drive->do nothing\n"));
|
1707 |
|
|
nscp->result = DID_OK << 16;
|
1708 |
|
|
restore_flags( flags );
|
1709 |
|
|
if (!nscp->SCp.have_data_in)
|
1710 |
|
|
nscp->SCp.have_data_in++;
|
1711 |
|
|
else
|
1712 |
|
|
nscp->scsi_done(nscp);
|
1713 |
|
|
save_flags( flags );
|
1714 |
|
|
cli();
|
1715 |
|
|
} else {
|
1716 |
|
|
nscp->cmnd[3] = (ha->id[b][t].devtype&1) ? 1:0;
|
1717 |
|
|
TRACE2(("Prevent/allow r. %d rem. drive %d\n",
|
1718 |
|
|
nscp->cmnd[4],nscp->cmnd[3]));
|
1719 |
|
|
if (!(cmd_index=gdth_fill_cache_cmd(hanum,nscp,hdrive)))
|
1720 |
|
|
next_cmd = FALSE;
|
1721 |
|
|
}
|
1722 |
|
|
break;
|
1723 |
|
|
|
1724 |
|
|
case READ_6:
|
1725 |
|
|
case WRITE_6:
|
1726 |
|
|
case READ_10:
|
1727 |
|
|
case WRITE_10:
|
1728 |
|
|
if (!(cmd_index=gdth_fill_cache_cmd(hanum,nscp,hdrive)))
|
1729 |
|
|
next_cmd = FALSE;
|
1730 |
|
|
break;
|
1731 |
|
|
|
1732 |
|
|
default:
|
1733 |
|
|
TRACE2(("cache cmd %x/%x/%x/%x/%x/%x\n",nscp->cmnd[0],
|
1734 |
|
|
nscp->cmnd[1],nscp->cmnd[2],nscp->cmnd[3],
|
1735 |
|
|
nscp->cmnd[4],nscp->cmnd[5]));
|
1736 |
|
|
printk("GDT: Unknown SCSI command 0x%x to cache service !\n",
|
1737 |
|
|
nscp->cmnd[0]);
|
1738 |
|
|
nscp->result = DID_ABORT << 16;
|
1739 |
|
|
restore_flags( flags );
|
1740 |
|
|
if (!nscp->SCp.have_data_in)
|
1741 |
|
|
nscp->SCp.have_data_in++;
|
1742 |
|
|
else
|
1743 |
|
|
nscp->scsi_done(nscp);
|
1744 |
|
|
save_flags( flags );
|
1745 |
|
|
cli();
|
1746 |
|
|
break;
|
1747 |
|
|
}
|
1748 |
|
|
}
|
1749 |
|
|
|
1750 |
|
|
if (!next_cmd)
|
1751 |
|
|
break;
|
1752 |
|
|
if (nscp == ha->req_first)
|
1753 |
|
|
ha->req_first = pscp = (Scsi_Cmnd *)nscp->SCp.ptr;
|
1754 |
|
|
else
|
1755 |
|
|
pscp->SCp.ptr = nscp->SCp.ptr;
|
1756 |
|
|
if (gdth_polling)
|
1757 |
|
|
break;
|
1758 |
|
|
}
|
1759 |
|
|
}
|
1760 |
|
|
|
1761 |
|
|
if (ha->cmd_cnt > 0) {
|
1762 |
|
|
gdth_release_event(hanum);
|
1763 |
|
|
}
|
1764 |
|
|
|
1765 |
|
|
restore_flags(flags);
|
1766 |
|
|
|
1767 |
|
|
if (gdth_polling && ha->cmd_cnt > 0) {
|
1768 |
|
|
if (!gdth_wait(hanum,cmd_index,POLL_TIMEOUT))
|
1769 |
|
|
printk("GDT: Controller %d: Command %d timed out !\n",
|
1770 |
|
|
hanum,cmd_index);
|
1771 |
|
|
}
|
1772 |
|
|
}
|
1773 |
|
|
|
1774 |
|
|
static void gdth_copy_internal_data(Scsi_Cmnd *scp,char *buffer,ushort count)
|
1775 |
|
|
{
|
1776 |
|
|
ushort cpcount,i;
|
1777 |
|
|
ushort cpsum,cpnow;
|
1778 |
|
|
struct scatterlist *sl;
|
1779 |
|
|
|
1780 |
|
|
cpcount = count<=(ushort)scp->bufflen ? count:(ushort)scp->bufflen;
|
1781 |
|
|
if (scp->use_sg) {
|
1782 |
|
|
sl = (struct scatterlist *)scp->request_buffer;
|
1783 |
|
|
for (i=0,cpsum=0; i<scp->use_sg; ++i,++sl) {
|
1784 |
|
|
cpnow = (ushort)sl->length;
|
1785 |
|
|
TRACE(("copy_internal() now %d sum %d count %d %d\n",
|
1786 |
|
|
cpnow,cpsum,cpcount,(ushort)scp->bufflen));
|
1787 |
|
|
if (cpsum+cpnow > cpcount)
|
1788 |
|
|
cpnow = cpcount - cpsum;
|
1789 |
|
|
cpsum += cpnow;
|
1790 |
|
|
memcpy((char*)sl->address,buffer,cpnow);
|
1791 |
|
|
if (cpsum == cpcount)
|
1792 |
|
|
break;
|
1793 |
|
|
buffer += cpnow;
|
1794 |
|
|
}
|
1795 |
|
|
} else {
|
1796 |
|
|
TRACE(("copy_internal() count %d\n",cpcount));
|
1797 |
|
|
memcpy((char*)scp->request_buffer,buffer,cpcount);
|
1798 |
|
|
}
|
1799 |
|
|
}
|
1800 |
|
|
|
1801 |
|
|
static int gdth_internal_cache_cmd(int hanum,Scsi_Cmnd *scp,
|
1802 |
|
|
unchar b,ulong *flags)
|
1803 |
|
|
{
|
1804 |
|
|
register gdth_ha_str *ha;
|
1805 |
|
|
ushort hdrive;
|
1806 |
|
|
unchar t;
|
1807 |
|
|
gdth_inq_data inq;
|
1808 |
|
|
gdth_rdcap_data rdc;
|
1809 |
|
|
gdth_sense_data sd;
|
1810 |
|
|
gdth_modep_data mpd;
|
1811 |
|
|
|
1812 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1813 |
|
|
t = scp->target;
|
1814 |
|
|
hdrive = ha->id[b][t].hostdrive;
|
1815 |
|
|
TRACE(("gdth_internal_cache_cmd() cmd 0x%x hdrive %d\n",
|
1816 |
|
|
scp->cmnd[0],hdrive));
|
1817 |
|
|
|
1818 |
|
|
if (scp->lun !=0)
|
1819 |
|
|
scp->result = DID_BAD_TARGET << 16;
|
1820 |
|
|
else {
|
1821 |
|
|
switch (scp->cmnd[0]) {
|
1822 |
|
|
case TEST_UNIT_READY:
|
1823 |
|
|
case VERIFY:
|
1824 |
|
|
case START_STOP:
|
1825 |
|
|
TRACE2(("Test/Verify/Start hdrive %d\n",hdrive));
|
1826 |
|
|
break;
|
1827 |
|
|
|
1828 |
|
|
case INQUIRY:
|
1829 |
|
|
TRACE2(("Inquiry hdrive %d devtype %d\n",
|
1830 |
|
|
hdrive,ha->id[b][t].devtype));
|
1831 |
|
|
inq.type_qual = (ha->id[b][t].devtype&4) ? TYPE_ROM:TYPE_DISK;
|
1832 |
|
|
/* you can here set all disks to removable, if you want to do
|
1833 |
|
|
a flush using the ALLOW_MEDIUM_REMOVAL command */
|
1834 |
|
|
inq.modif_rmb = ha->id[b][t].devtype&1 ? 0x80:0x00;
|
1835 |
|
|
inq.version = 2;
|
1836 |
|
|
inq.resp_aenc = 2;
|
1837 |
|
|
inq.add_length= 32;
|
1838 |
|
|
strcpy(inq.vendor,"ICP ");
|
1839 |
|
|
sprintf(inq.product,"Host Drive #%02d",hdrive);
|
1840 |
|
|
strcpy(inq.revision," ");
|
1841 |
|
|
gdth_copy_internal_data(scp,(char*)&inq,sizeof(gdth_inq_data));
|
1842 |
|
|
break;
|
1843 |
|
|
|
1844 |
|
|
case REQUEST_SENSE:
|
1845 |
|
|
TRACE2(("Request sense hdrive %d\n",hdrive));
|
1846 |
|
|
sd.errorcode = 0x70;
|
1847 |
|
|
sd.segno = 0x00;
|
1848 |
|
|
sd.key = NO_SENSE;
|
1849 |
|
|
sd.info = 0;
|
1850 |
|
|
sd.add_length= 0;
|
1851 |
|
|
gdth_copy_internal_data(scp,(char*)&sd,sizeof(gdth_sense_data));
|
1852 |
|
|
break;
|
1853 |
|
|
|
1854 |
|
|
case MODE_SENSE:
|
1855 |
|
|
TRACE2(("Mode sense hdrive %d\n",hdrive));
|
1856 |
|
|
memset((char*)&mpd,0,sizeof(gdth_modep_data));
|
1857 |
|
|
mpd.hd.data_length = sizeof(gdth_modep_data);
|
1858 |
|
|
mpd.hd.dev_par = (ha->id[b][t].devtype&2) ? 0x80:0;
|
1859 |
|
|
mpd.hd.bd_length = sizeof(mpd.bd);
|
1860 |
|
|
mpd.bd.block_length[0] = (SECTOR_SIZE & 0x00ff0000) >> 16;
|
1861 |
|
|
mpd.bd.block_length[1] = (SECTOR_SIZE & 0x0000ff00) >> 8;
|
1862 |
|
|
mpd.bd.block_length[2] = (SECTOR_SIZE & 0x000000ff);
|
1863 |
|
|
gdth_copy_internal_data(scp,(char*)&mpd,sizeof(gdth_modep_data));
|
1864 |
|
|
break;
|
1865 |
|
|
|
1866 |
|
|
case READ_CAPACITY:
|
1867 |
|
|
TRACE2(("Read capacity hdrive %d\n",hdrive));
|
1868 |
|
|
rdc.last_block_no = ntohl(ha->id[b][t].size-1);
|
1869 |
|
|
rdc.block_length = ntohl(SECTOR_SIZE);
|
1870 |
|
|
gdth_copy_internal_data(scp,(char*)&rdc,sizeof(gdth_rdcap_data));
|
1871 |
|
|
break;
|
1872 |
|
|
|
1873 |
|
|
default:
|
1874 |
|
|
TRACE2(("Internal cache cmd 0x%x unknown\n",scp->cmnd[0]));
|
1875 |
|
|
break;
|
1876 |
|
|
}
|
1877 |
|
|
scp->result = DID_OK << 16;
|
1878 |
|
|
}
|
1879 |
|
|
|
1880 |
|
|
restore_flags(*flags);
|
1881 |
|
|
if (!scp->SCp.have_data_in)
|
1882 |
|
|
scp->SCp.have_data_in++;
|
1883 |
|
|
else
|
1884 |
|
|
scp->scsi_done(scp);
|
1885 |
|
|
save_flags(*flags);
|
1886 |
|
|
cli();
|
1887 |
|
|
return 1;
|
1888 |
|
|
}
|
1889 |
|
|
|
1890 |
|
|
static int gdth_fill_cache_cmd(int hanum,Scsi_Cmnd *scp,ushort hdrive)
|
1891 |
|
|
{
|
1892 |
|
|
register gdth_ha_str *ha;
|
1893 |
|
|
register gdth_cmd_str *cmdp;
|
1894 |
|
|
struct scatterlist *sl;
|
1895 |
|
|
ushort i;
|
1896 |
|
|
int cmd_index;
|
1897 |
|
|
|
1898 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
1899 |
|
|
cmdp = ha->pccb;
|
1900 |
|
|
TRACE(("gdth_fill_cache_cmd() cmd 0x%x cmdsize %d hdrive %d\n",
|
1901 |
|
|
scp->cmnd[0],scp->cmd_len,hdrive));
|
1902 |
|
|
|
1903 |
|
|
if (ha->type==GDT_EISA && ha->cmd_cnt>0)
|
1904 |
|
|
return 0;
|
1905 |
|
|
|
1906 |
|
|
cmdp->Service = CACHESERVICE;
|
1907 |
|
|
cmdp->RequestBuffer = scp;
|
1908 |
|
|
/* search free command index */
|
1909 |
|
|
if (!(cmd_index=gdth_get_cmd_index(hanum))) {
|
1910 |
|
|
TRACE(("GDT: No free command index found\n"));
|
1911 |
|
|
return 0;
|
1912 |
|
|
}
|
1913 |
|
|
/* if it's the first command, set command semaphore */
|
1914 |
|
|
if (ha->cmd_cnt == 0)
|
1915 |
|
|
gdth_set_sema0(hanum);
|
1916 |
|
|
|
1917 |
|
|
/* fill command */
|
1918 |
|
|
if (scp->cmnd[0]==ALLOW_MEDIUM_REMOVAL) {
|
1919 |
|
|
if (scp->cmnd[4] & 1) /* prevent ? */
|
1920 |
|
|
cmdp->OpCode = GDT_MOUNT;
|
1921 |
|
|
else if (scp->cmnd[3] & 1) /* removable drive ? */
|
1922 |
|
|
cmdp->OpCode = GDT_UNMOUNT;
|
1923 |
|
|
else
|
1924 |
|
|
cmdp->OpCode = GDT_FLUSH;
|
1925 |
|
|
} else {
|
1926 |
|
|
if (scp->cmnd[0]==WRITE_6 || scp->cmnd[0]==WRITE_10) {
|
1927 |
|
|
if (gdth_write_through)
|
1928 |
|
|
cmdp->OpCode = GDT_WRITE_THR;
|
1929 |
|
|
else
|
1930 |
|
|
cmdp->OpCode = GDT_WRITE;
|
1931 |
|
|
} else {
|
1932 |
|
|
cmdp->OpCode = GDT_READ;
|
1933 |
|
|
}
|
1934 |
|
|
}
|
1935 |
|
|
|
1936 |
|
|
cmdp->BoardNode = LOCALBOARD;
|
1937 |
|
|
cmdp->u.cache.DeviceNo = hdrive;
|
1938 |
|
|
|
1939 |
|
|
if (scp->cmnd[0]==ALLOW_MEDIUM_REMOVAL) {
|
1940 |
|
|
cmdp->u.cache.BlockNo = 1;
|
1941 |
|
|
cmdp->u.cache.sg_canz = 0;
|
1942 |
|
|
} else {
|
1943 |
|
|
if (scp->cmd_len != 6) {
|
1944 |
|
|
cmdp->u.cache.BlockNo = ntohl(*(ulong*)&scp->cmnd[2]);
|
1945 |
|
|
cmdp->u.cache.BlockCnt= (ulong)ntohs(*(ushort*)&scp->cmnd[7]);
|
1946 |
|
|
} else {
|
1947 |
|
|
cmdp->u.cache.BlockNo = ntohl(*(ulong*)&scp->cmnd[0]) & 0x001fffffUL;
|
1948 |
|
|
cmdp->u.cache.BlockCnt= scp->cmnd[4]==0 ? 0x100 : scp->cmnd[4];
|
1949 |
|
|
}
|
1950 |
|
|
|
1951 |
|
|
if (scp->use_sg) {
|
1952 |
|
|
cmdp->u.cache.DestAddr= -1UL;
|
1953 |
|
|
sl = (struct scatterlist *)scp->request_buffer;
|
1954 |
|
|
for (i=0; i<scp->use_sg; ++i,++sl) {
|
1955 |
|
|
cmdp->u.cache.sg_lst[i].sg_ptr = virt_to_bus(sl->address);
|
1956 |
|
|
cmdp->u.cache.sg_lst[i].sg_len = (ulong)sl->length;
|
1957 |
|
|
}
|
1958 |
|
|
cmdp->u.cache.sg_canz = (ulong)i;
|
1959 |
|
|
|
1960 |
|
|
#ifdef GDTH_STATISTICS
|
1961 |
|
|
if (max_sg < (ulong)i) {
|
1962 |
|
|
max_sg = (ulong)i;
|
1963 |
|
|
TRACE3(("GDT: max_sg = %d\n",i));
|
1964 |
|
|
}
|
1965 |
|
|
#endif
|
1966 |
|
|
if (i<GDTH_MAXSG)
|
1967 |
|
|
cmdp->u.cache.sg_lst[i].sg_len = 0;
|
1968 |
|
|
} else {
|
1969 |
|
|
if (ha->cache_feat & SCATTER_GATHER) {
|
1970 |
|
|
cmdp->u.cache.DestAddr = -1UL;
|
1971 |
|
|
cmdp->u.cache.sg_canz = 1;
|
1972 |
|
|
cmdp->u.cache.sg_lst[0].sg_ptr = virt_to_bus(scp->request_buffer);
|
1973 |
|
|
cmdp->u.cache.sg_lst[0].sg_len = scp->request_bufflen;
|
1974 |
|
|
cmdp->u.cache.sg_lst[1].sg_len = 0;
|
1975 |
|
|
} else {
|
1976 |
|
|
cmdp->u.cache.DestAddr = virt_to_bus(scp->request_buffer);
|
1977 |
|
|
cmdp->u.cache.sg_canz= 0;
|
1978 |
|
|
}
|
1979 |
|
|
}
|
1980 |
|
|
}
|
1981 |
|
|
TRACE(("cache cmd: addr. %lx sganz %lx sgptr0 %lx sglen0 %lx\n",
|
1982 |
|
|
cmdp->u.cache.DestAddr,cmdp->u.cache.sg_canz,
|
1983 |
|
|
cmdp->u.cache.sg_lst[0].sg_ptr,
|
1984 |
|
|
cmdp->u.cache.sg_lst[0].sg_len));
|
1985 |
|
|
TRACE(("cache cmd: cmd %d blockno. %ld, blockcnt %ld\n",
|
1986 |
|
|
cmdp->OpCode,cmdp->u.cache.BlockNo,cmdp->u.cache.BlockCnt));
|
1987 |
|
|
|
1988 |
|
|
/* evaluate command size, check space */
|
1989 |
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.cache.sg_lst) +
|
1990 |
|
|
(ushort)cmdp->u.cache.sg_canz * sizeof(gdth_sg_str);
|
1991 |
|
|
if (ha->cmd_len & 3)
|
1992 |
|
|
ha->cmd_len += (4 - (ha->cmd_len & 3));
|
1993 |
|
|
|
1994 |
|
|
if (ha->cmd_cnt > 0) {
|
1995 |
|
|
if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) >
|
1996 |
|
|
ha->ic_all_size) {
|
1997 |
|
|
TRACE2(("gdth_fill_cache() DPMEM overflow\n"));
|
1998 |
|
|
gdth_cmd_tab[cmd_index-2][hanum].cmnd = UNUSED_CMND;
|
1999 |
|
|
return 0;
|
2000 |
|
|
}
|
2001 |
|
|
}
|
2002 |
|
|
|
2003 |
|
|
/* copy command */
|
2004 |
|
|
gdth_copy_command(hanum);
|
2005 |
|
|
return cmd_index;
|
2006 |
|
|
}
|
2007 |
|
|
|
2008 |
|
|
static int gdth_fill_raw_cmd(int hanum,Scsi_Cmnd *scp,unchar b)
|
2009 |
|
|
{
|
2010 |
|
|
register gdth_ha_str *ha;
|
2011 |
|
|
register gdth_cmd_str *cmdp;
|
2012 |
|
|
struct scatterlist *sl;
|
2013 |
|
|
ushort i;
|
2014 |
|
|
int cmd_index;
|
2015 |
|
|
unchar t,l;
|
2016 |
|
|
|
2017 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
2018 |
|
|
t = scp->target;
|
2019 |
|
|
l = scp->lun;
|
2020 |
|
|
cmdp = ha->pccb;
|
2021 |
|
|
TRACE(("gdth_fill_raw_cmd() cmd 0x%x bus %d ID %d LUN %d\n",
|
2022 |
|
|
scp->cmnd[0],b,t,l));
|
2023 |
|
|
|
2024 |
|
|
if (ha->type==GDT_EISA && ha->cmd_cnt>0)
|
2025 |
|
|
return 0;
|
2026 |
|
|
|
2027 |
|
|
cmdp->Service = SCSIRAWSERVICE;
|
2028 |
|
|
cmdp->RequestBuffer = scp;
|
2029 |
|
|
/* search free command index */
|
2030 |
|
|
if (!(cmd_index=gdth_get_cmd_index(hanum))) {
|
2031 |
|
|
TRACE(("GDT: No free command index found\n"));
|
2032 |
|
|
return 0;
|
2033 |
|
|
}
|
2034 |
|
|
/* if it's the first command, set command semaphore */
|
2035 |
|
|
if (ha->cmd_cnt == 0)
|
2036 |
|
|
gdth_set_sema0(hanum);
|
2037 |
|
|
|
2038 |
|
|
/* fill command */
|
2039 |
|
|
cmdp->OpCode = GDT_WRITE; /* always */
|
2040 |
|
|
cmdp->BoardNode = LOCALBOARD;
|
2041 |
|
|
cmdp->u.raw.reserved = 0;
|
2042 |
|
|
cmdp->u.raw.mdisc_time = 0;
|
2043 |
|
|
cmdp->u.raw.mcon_time = 0;
|
2044 |
|
|
cmdp->u.raw.clen = scp->cmd_len;
|
2045 |
|
|
cmdp->u.raw.target = t;
|
2046 |
|
|
cmdp->u.raw.lun = l;
|
2047 |
|
|
cmdp->u.raw.bus = b;
|
2048 |
|
|
cmdp->u.raw.priority = 0;
|
2049 |
|
|
cmdp->u.raw.link_p = NULL;
|
2050 |
|
|
cmdp->u.raw.sdlen = scp->request_bufflen;
|
2051 |
|
|
cmdp->u.raw.sense_len = 16;
|
2052 |
|
|
cmdp->u.raw.sense_data = virt_to_bus(scp->sense_buffer);
|
2053 |
|
|
cmdp->u.raw.direction =
|
2054 |
|
|
gdth_direction_tab[scp->cmnd[0]]==DOU ? DATA_OUT : DATA_IN;
|
2055 |
|
|
memcpy(cmdp->u.raw.cmd,scp->cmnd,12);
|
2056 |
|
|
|
2057 |
|
|
if (scp->use_sg) {
|
2058 |
|
|
cmdp->u.raw.sdata = -1UL;
|
2059 |
|
|
sl = (struct scatterlist *)scp->request_buffer;
|
2060 |
|
|
for (i=0; i<scp->use_sg; ++i,++sl) {
|
2061 |
|
|
cmdp->u.raw.sg_lst[i].sg_ptr = virt_to_bus(sl->address);
|
2062 |
|
|
cmdp->u.raw.sg_lst[i].sg_len = (ulong)sl->length;
|
2063 |
|
|
}
|
2064 |
|
|
cmdp->u.raw.sg_ranz = (ulong)i;
|
2065 |
|
|
|
2066 |
|
|
#ifdef GDTH_STATISTICS
|
2067 |
|
|
if (max_sg < (ulong)i) {
|
2068 |
|
|
max_sg = (ulong)i;
|
2069 |
|
|
TRACE3(("GDT: max_sg = %d\n",i));
|
2070 |
|
|
}
|
2071 |
|
|
#endif
|
2072 |
|
|
if (i<GDTH_MAXSG)
|
2073 |
|
|
cmdp->u.raw.sg_lst[i].sg_len = 0;
|
2074 |
|
|
} else {
|
2075 |
|
|
if (ha->raw_feat & SCATTER_GATHER) {
|
2076 |
|
|
cmdp->u.raw.sdata = -1UL;
|
2077 |
|
|
cmdp->u.raw.sg_ranz= 1;
|
2078 |
|
|
cmdp->u.raw.sg_lst[0].sg_ptr = virt_to_bus(scp->request_buffer);
|
2079 |
|
|
cmdp->u.raw.sg_lst[0].sg_len = scp->request_bufflen;
|
2080 |
|
|
cmdp->u.raw.sg_lst[1].sg_len = 0;
|
2081 |
|
|
} else {
|
2082 |
|
|
cmdp->u.raw.sdata = virt_to_bus(scp->request_buffer);
|
2083 |
|
|
cmdp->u.raw.sg_ranz= 0;
|
2084 |
|
|
}
|
2085 |
|
|
}
|
2086 |
|
|
TRACE(("raw cmd: addr. %lx sganz %lx sgptr0 %lx sglen0 %lx\n",
|
2087 |
|
|
cmdp->u.raw.sdata,cmdp->u.raw.sg_ranz,
|
2088 |
|
|
cmdp->u.raw.sg_lst[0].sg_ptr,
|
2089 |
|
|
cmdp->u.raw.sg_lst[0].sg_len));
|
2090 |
|
|
|
2091 |
|
|
/* evaluate command size, check space */
|
2092 |
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst) +
|
2093 |
|
|
(ushort)cmdp->u.raw.sg_ranz * sizeof(gdth_sg_str);
|
2094 |
|
|
if (ha->cmd_len & 3)
|
2095 |
|
|
ha->cmd_len += (4 - (ha->cmd_len & 3));
|
2096 |
|
|
|
2097 |
|
|
if (ha->cmd_cnt > 0) {
|
2098 |
|
|
if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) >
|
2099 |
|
|
ha->ic_all_size) {
|
2100 |
|
|
TRACE2(("gdth_fill_raw() DPMEM overflow\n"));
|
2101 |
|
|
gdth_cmd_tab[cmd_index-2][hanum].cmnd = UNUSED_CMND;
|
2102 |
|
|
return 0;
|
2103 |
|
|
}
|
2104 |
|
|
}
|
2105 |
|
|
|
2106 |
|
|
/* copy command */
|
2107 |
|
|
gdth_copy_command(hanum);
|
2108 |
|
|
return cmd_index;
|
2109 |
|
|
}
|
2110 |
|
|
|
2111 |
|
|
static int gdth_special_cmd(int hanum,Scsi_Cmnd *scp,unchar b)
|
2112 |
|
|
{
|
2113 |
|
|
register gdth_ha_str *ha;
|
2114 |
|
|
register gdth_cmd_str *cmdp;
|
2115 |
|
|
int cmd_index;
|
2116 |
|
|
|
2117 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
2118 |
|
|
cmdp= ha->pccb;
|
2119 |
|
|
TRACE2(("gdth_special_cmd(): "));
|
2120 |
|
|
|
2121 |
|
|
if (ha->type==GDT_EISA && ha->cmd_cnt>0)
|
2122 |
|
|
return 0;
|
2123 |
|
|
|
2124 |
|
|
memcpy( cmdp, scp->request_buffer, sizeof(gdth_cmd_str));
|
2125 |
|
|
cmdp->RequestBuffer = scp;
|
2126 |
|
|
|
2127 |
|
|
/* search free command index */
|
2128 |
|
|
if (!(cmd_index=gdth_get_cmd_index(hanum))) {
|
2129 |
|
|
TRACE(("GDT: No free command index found\n"));
|
2130 |
|
|
return 0;
|
2131 |
|
|
}
|
2132 |
|
|
|
2133 |
|
|
/* if it's the first command, set command semaphore */
|
2134 |
|
|
if (ha->cmd_cnt == 0)
|
2135 |
|
|
gdth_set_sema0(hanum);
|
2136 |
|
|
|
2137 |
|
|
/* evaluate command size, check space */
|
2138 |
|
|
if (cmdp->OpCode == GDT_IOCTL) {
|
2139 |
|
|
TRACE2(("IOCTL\n"));
|
2140 |
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.ioctl.p_param) + sizeof(ulong);
|
2141 |
|
|
} else if (cmdp->Service == CACHESERVICE) {
|
2142 |
|
|
TRACE2(("cache command %d\n",cmdp->OpCode));
|
2143 |
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.cache.sg_lst) + sizeof(gdth_sg_str);
|
2144 |
|
|
} else if (cmdp->Service == SCSIRAWSERVICE) {
|
2145 |
|
|
TRACE2(("raw command %d/%d\n",cmdp->OpCode,cmdp->u.raw.cmd[0]));
|
2146 |
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.raw.sg_lst) + sizeof(gdth_sg_str);
|
2147 |
|
|
}
|
2148 |
|
|
|
2149 |
|
|
if (ha->cmd_len & 3)
|
2150 |
|
|
ha->cmd_len += (4 - (ha->cmd_len & 3));
|
2151 |
|
|
|
2152 |
|
|
if (ha->cmd_cnt > 0) {
|
2153 |
|
|
if ((ha->cmd_offs_dpmem + ha->cmd_len + DPMEM_COMMAND_OFFSET) >
|
2154 |
|
|
ha->ic_all_size) {
|
2155 |
|
|
TRACE2(("gdth_special_cmd() DPMEM overflow\n"));
|
2156 |
|
|
gdth_cmd_tab[cmd_index-2][hanum].cmnd = UNUSED_CMND;
|
2157 |
|
|
return 0;
|
2158 |
|
|
}
|
2159 |
|
|
}
|
2160 |
|
|
|
2161 |
|
|
/* copy command */
|
2162 |
|
|
gdth_copy_command(hanum);
|
2163 |
|
|
return cmd_index;
|
2164 |
|
|
}
|
2165 |
|
|
|
2166 |
|
|
|
2167 |
|
|
/* Controller event handling functions */
|
2168 |
|
|
static gdth_evt_str *gdth_store_event(ushort source, ushort idx,
|
2169 |
|
|
gdth_evt_data *evt)
|
2170 |
|
|
{
|
2171 |
|
|
gdth_evt_str *e;
|
2172 |
|
|
ulong flags;
|
2173 |
|
|
struct timeval tv;
|
2174 |
|
|
|
2175 |
|
|
TRACE2(("gdth_store_event() source %d idx %d\n", source, idx));
|
2176 |
|
|
if (source == 0) /* no source -> no event */
|
2177 |
|
|
return 0;
|
2178 |
|
|
|
2179 |
|
|
save_flags(flags);
|
2180 |
|
|
cli();
|
2181 |
|
|
if (ebuffer[elastidx].event_source == source &&
|
2182 |
|
|
ebuffer[elastidx].event_idx == idx &&
|
2183 |
|
|
!memcmp((char *)&ebuffer[elastidx].event_data.eu,
|
2184 |
|
|
(char *)&evt->eu, evt->size)) {
|
2185 |
|
|
e = &ebuffer[elastidx];
|
2186 |
|
|
do_gettimeofday(&tv);
|
2187 |
|
|
e->last_stamp = tv.tv_sec;
|
2188 |
|
|
++e->same_count;
|
2189 |
|
|
} else {
|
2190 |
|
|
if (ebuffer[elastidx].event_source != 0) { /* entry not free ? */
|
2191 |
|
|
++elastidx;
|
2192 |
|
|
if (elastidx == MAX_EVENTS)
|
2193 |
|
|
elastidx = 0;
|
2194 |
|
|
if (elastidx == eoldidx) { /* reached mark ? */
|
2195 |
|
|
++eoldidx;
|
2196 |
|
|
if (eoldidx == MAX_EVENTS)
|
2197 |
|
|
eoldidx = 0;
|
2198 |
|
|
}
|
2199 |
|
|
}
|
2200 |
|
|
e = &ebuffer[elastidx];
|
2201 |
|
|
e->event_source = source;
|
2202 |
|
|
e->event_idx = idx;
|
2203 |
|
|
do_gettimeofday(&tv);
|
2204 |
|
|
e->first_stamp = e->last_stamp = tv.tv_sec;
|
2205 |
|
|
e->same_count = 1;
|
2206 |
|
|
e->event_data = *evt;
|
2207 |
|
|
}
|
2208 |
|
|
restore_flags(flags);
|
2209 |
|
|
return e;
|
2210 |
|
|
}
|
2211 |
|
|
|
2212 |
|
|
static int gdth_read_event(int handle, gdth_evt_str *estr)
|
2213 |
|
|
{
|
2214 |
|
|
gdth_evt_str *e;
|
2215 |
|
|
int eindex;
|
2216 |
|
|
ulong flags;
|
2217 |
|
|
|
2218 |
|
|
TRACE2(("gdth_read_event() handle %d\n", handle));
|
2219 |
|
|
save_flags(flags);
|
2220 |
|
|
cli();
|
2221 |
|
|
if (handle == -1)
|
2222 |
|
|
eindex = eoldidx;
|
2223 |
|
|
else
|
2224 |
|
|
eindex = handle;
|
2225 |
|
|
estr->event_source = 0;
|
2226 |
|
|
|
2227 |
|
|
if (eindex >= MAX_EVENTS) {
|
2228 |
|
|
restore_flags(flags);
|
2229 |
|
|
return eindex;
|
2230 |
|
|
}
|
2231 |
|
|
e = &ebuffer[eindex];
|
2232 |
|
|
if (e->event_source != 0) {
|
2233 |
|
|
if (eindex != elastidx) {
|
2234 |
|
|
if (++eindex == MAX_EVENTS)
|
2235 |
|
|
eindex = 0;
|
2236 |
|
|
} else {
|
2237 |
|
|
eindex = -1;
|
2238 |
|
|
}
|
2239 |
|
|
memcpy(estr, e, sizeof(gdth_evt_str));
|
2240 |
|
|
}
|
2241 |
|
|
restore_flags(flags);
|
2242 |
|
|
return eindex;
|
2243 |
|
|
}
|
2244 |
|
|
|
2245 |
|
|
static void gdth_readapp_event(unchar application, gdth_evt_str *estr)
|
2246 |
|
|
{
|
2247 |
|
|
gdth_evt_str *e;
|
2248 |
|
|
int eindex;
|
2249 |
|
|
ulong flags;
|
2250 |
|
|
unchar found = FALSE;
|
2251 |
|
|
|
2252 |
|
|
TRACE2(("gdth_readapp_event() app. %d\n", application));
|
2253 |
|
|
save_flags(flags);
|
2254 |
|
|
cli();
|
2255 |
|
|
eindex = eoldidx;
|
2256 |
|
|
for (;;) {
|
2257 |
|
|
e = &ebuffer[eindex];
|
2258 |
|
|
if (e->event_source == 0)
|
2259 |
|
|
break;
|
2260 |
|
|
if ((e->application & application) == 0) {
|
2261 |
|
|
e->application |= application;
|
2262 |
|
|
found = TRUE;
|
2263 |
|
|
break;
|
2264 |
|
|
}
|
2265 |
|
|
if (eindex == elastidx)
|
2266 |
|
|
break;
|
2267 |
|
|
if (++eindex == MAX_EVENTS)
|
2268 |
|
|
eindex = 0;
|
2269 |
|
|
}
|
2270 |
|
|
if (found)
|
2271 |
|
|
memcpy(estr, e, sizeof(gdth_evt_str));
|
2272 |
|
|
else
|
2273 |
|
|
estr->event_source = 0;
|
2274 |
|
|
restore_flags(flags);
|
2275 |
|
|
}
|
2276 |
|
|
|
2277 |
|
|
static void gdth_clear_events()
|
2278 |
|
|
{
|
2279 |
|
|
ulong flags;
|
2280 |
|
|
|
2281 |
|
|
TRACE(("gdth_clear_events()"));
|
2282 |
|
|
save_flags(flags);
|
2283 |
|
|
cli();
|
2284 |
|
|
|
2285 |
|
|
eoldidx = elastidx = 0;
|
2286 |
|
|
ebuffer[0].event_source = 0;
|
2287 |
|
|
restore_flags(flags);
|
2288 |
|
|
}
|
2289 |
|
|
|
2290 |
|
|
|
2291 |
|
|
/* SCSI interface functions */
|
2292 |
|
|
|
2293 |
|
|
#if LINUX_VERSION_CODE >= 0x02015F
|
2294 |
|
|
static void do_gdth_interrupt(int irq,void *dev_id,struct pt_regs *regs)
|
2295 |
|
|
{
|
2296 |
|
|
ulong flags;
|
2297 |
|
|
|
2298 |
|
|
spin_lock_irqsave(&io_request_lock, flags);
|
2299 |
|
|
gdth_interrupt(irq, dev_id, regs);
|
2300 |
|
|
spin_unlock_irqrestore(&io_request_lock, flags);
|
2301 |
|
|
}
|
2302 |
|
|
#endif
|
2303 |
|
|
|
2304 |
|
|
#if LINUX_VERSION_CODE >= 0x010346
|
2305 |
|
|
static void gdth_interrupt(int irq,void *dev_id,struct pt_regs *regs)
|
2306 |
|
|
#else
|
2307 |
|
|
static void gdth_interrupt(int irq,struct pt_regs *regs)
|
2308 |
|
|
#endif
|
2309 |
|
|
{
|
2310 |
|
|
register gdth_ha_str *ha;
|
2311 |
|
|
gdt6m_dpram_str *dp6m_ptr;
|
2312 |
|
|
gdt6_dpram_str *dp6_ptr;
|
2313 |
|
|
gdt2_dpram_str *dp2_ptr;
|
2314 |
|
|
Scsi_Cmnd *scp;
|
2315 |
|
|
int hanum;
|
2316 |
|
|
unchar IStatus;
|
2317 |
|
|
ushort CmdStatus, Service = 0;
|
2318 |
|
|
ulong InfoBytes, InfoBytes2 = 0;
|
2319 |
|
|
gdth_evt_data dvr;
|
2320 |
|
|
|
2321 |
|
|
TRACE(("gdth_interrupt() IRQ %d\n",irq));
|
2322 |
|
|
|
2323 |
|
|
/* if polling and not from gdth_wait() -> return */
|
2324 |
|
|
if (gdth_polling) {
|
2325 |
|
|
if (!gdth_from_wait) {
|
2326 |
|
|
return;
|
2327 |
|
|
}
|
2328 |
|
|
}
|
2329 |
|
|
|
2330 |
|
|
wait_index = 0;
|
2331 |
|
|
|
2332 |
|
|
/* search controller */
|
2333 |
|
|
if ((hanum = gdth_get_status(&IStatus,irq)) == -1) {
|
2334 |
|
|
/*
|
2335 |
|
|
TRACE2(("gdth_interrupt(): Spurious interrupt received\n"));
|
2336 |
|
|
*/
|
2337 |
|
|
return;
|
2338 |
|
|
}
|
2339 |
|
|
|
2340 |
|
|
#ifdef GDTH_STATISTICS
|
2341 |
|
|
++act_ints;
|
2342 |
|
|
#endif
|
2343 |
|
|
|
2344 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
2345 |
|
|
if (ha->type == GDT_EISA) {
|
2346 |
|
|
if (IStatus & 0x80) { /* error flag */
|
2347 |
|
|
IStatus &= ~0x80;
|
2348 |
|
|
CmdStatus = inw(ha->bmic + MAILBOXREG+8);
|
2349 |
|
|
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,CmdStatus));
|
2350 |
|
|
if (IStatus == ASYNCINDEX) { /* async. event ? */
|
2351 |
|
|
Service = inw(ha->bmic + MAILBOXREG+10);
|
2352 |
|
|
InfoBytes2 = inl(ha->bmic + MAILBOXREG+4);
|
2353 |
|
|
}
|
2354 |
|
|
} else /* no error */
|
2355 |
|
|
CmdStatus = S_OK;
|
2356 |
|
|
InfoBytes = inl(ha->bmic + MAILBOXREG+12);
|
2357 |
|
|
if (gdth_polling) /* init. -> more info */
|
2358 |
|
|
InfoBytes2 = inl(ha->bmic + MAILBOXREG+4);
|
2359 |
|
|
outb(0xff, ha->bmic + EDOORREG); /* acknowledge interrupt */
|
2360 |
|
|
outb(0x00, ha->bmic + SEMA1REG); /* reset status semaphore */
|
2361 |
|
|
} else if (ha->type == GDT_ISA) {
|
2362 |
|
|
dp2_ptr = (gdt2_dpram_str *)ha->brd;
|
2363 |
|
|
if (IStatus & 0x80) { /* error flag */
|
2364 |
|
|
IStatus &= ~0x80;
|
2365 |
|
|
CmdStatus = readw(&dp2_ptr->u.ic.Status);
|
2366 |
|
|
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,CmdStatus));
|
2367 |
|
|
if (IStatus == ASYNCINDEX) { /* async. event ? */
|
2368 |
|
|
Service = readw(&dp2_ptr->u.ic.Service);
|
2369 |
|
|
InfoBytes2 = readl(&dp2_ptr->u.ic.Info[1]);
|
2370 |
|
|
}
|
2371 |
|
|
} else /* no error */
|
2372 |
|
|
CmdStatus = S_OK;
|
2373 |
|
|
InfoBytes = readl(&dp2_ptr->u.ic.Info[0]);
|
2374 |
|
|
if (gdth_polling) /* init. -> more info */
|
2375 |
|
|
InfoBytes2 = readl(&dp2_ptr->u.ic.Info[1]);
|
2376 |
|
|
writeb(0xff, &dp2_ptr->io.irqdel); /* acknowledge interrupt */
|
2377 |
|
|
writeb(0, &dp2_ptr->u.ic.Cmd_Index); /* reset command index */
|
2378 |
|
|
writeb(0, &dp2_ptr->io.Sema1); /* reset status semaphore */
|
2379 |
|
|
} else if (ha->type == GDT_PCI) {
|
2380 |
|
|
dp6_ptr = (gdt6_dpram_str *)ha->brd;
|
2381 |
|
|
if (IStatus & 0x80) { /* error flag */
|
2382 |
|
|
IStatus &= ~0x80;
|
2383 |
|
|
CmdStatus = readw(&dp6_ptr->u.ic.Status);
|
2384 |
|
|
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,CmdStatus));
|
2385 |
|
|
if (IStatus == ASYNCINDEX) { /* async. event ? */
|
2386 |
|
|
Service = readw(&dp6_ptr->u.ic.Service);
|
2387 |
|
|
InfoBytes2 = readl(&dp6_ptr->u.ic.Info[1]);
|
2388 |
|
|
}
|
2389 |
|
|
} else /* no error */
|
2390 |
|
|
CmdStatus = S_OK;
|
2391 |
|
|
InfoBytes = readl(&dp6_ptr->u.ic.Info[0]);
|
2392 |
|
|
if (gdth_polling) /* init. -> more info */
|
2393 |
|
|
InfoBytes2 = readl(&dp6_ptr->u.ic.Info[1]);
|
2394 |
|
|
writeb(0xff, &dp6_ptr->io.irqdel); /* acknowledge interrupt */
|
2395 |
|
|
writeb(0, &dp6_ptr->u.ic.Cmd_Index); /* reset command index */
|
2396 |
|
|
writeb(0, &dp6_ptr->io.Sema1); /* reset status semaphore */
|
2397 |
|
|
} else if (ha->type == GDT_PCINEW) {
|
2398 |
|
|
if (IStatus & 0x80) { /* error flag */
|
2399 |
|
|
IStatus &= ~0x80;
|
2400 |
|
|
CmdStatus = inw(PTR2USHORT(&ha->plx->status));
|
2401 |
|
|
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,CmdStatus));
|
2402 |
|
|
if (IStatus == ASYNCINDEX) { /* async. event ? */
|
2403 |
|
|
Service = inw(PTR2USHORT(&ha->plx->service));
|
2404 |
|
|
InfoBytes2 = inl(PTR2USHORT(&ha->plx->info[1]));
|
2405 |
|
|
}
|
2406 |
|
|
} else
|
2407 |
|
|
CmdStatus = S_OK;
|
2408 |
|
|
|
2409 |
|
|
InfoBytes = inl(PTR2USHORT(&ha->plx->info[0]));
|
2410 |
|
|
if (gdth_polling) /* init. -> more info */
|
2411 |
|
|
InfoBytes2 = inl(PTR2USHORT(&ha->plx->info[1]));
|
2412 |
|
|
outb(0xff, PTR2USHORT(&ha->plx->edoor_reg));
|
2413 |
|
|
outb(0x00, PTR2USHORT(&ha->plx->sema1_reg));
|
2414 |
|
|
} else if (ha->type == GDT_PCIMPR) {
|
2415 |
|
|
dp6m_ptr = (gdt6m_dpram_str *)ha->brd;
|
2416 |
|
|
if (IStatus & 0x80) { /* error flag */
|
2417 |
|
|
IStatus &= ~0x80;
|
2418 |
|
|
CmdStatus = readw(&dp6m_ptr->i960r.status);
|
2419 |
|
|
TRACE2(("gdth_interrupt() error %d/%d\n",IStatus,CmdStatus));
|
2420 |
|
|
if (IStatus == ASYNCINDEX) { /* async. event ? */
|
2421 |
|
|
Service = readw(&dp6m_ptr->i960r.service);
|
2422 |
|
|
InfoBytes2 = readl(&dp6m_ptr->i960r.info[1]);
|
2423 |
|
|
}
|
2424 |
|
|
} else /* no error */
|
2425 |
|
|
CmdStatus = S_OK;
|
2426 |
|
|
InfoBytes = readl(&dp6m_ptr->i960r.info[0]);
|
2427 |
|
|
if (gdth_polling) /* init. -> more info */
|
2428 |
|
|
InfoBytes2 = readl(&dp6m_ptr->i960r.info[1]);
|
2429 |
|
|
writeb(0xff, &dp6m_ptr->i960r.edoor_reg);
|
2430 |
|
|
writeb(0, &dp6m_ptr->i960r.sema1_reg);
|
2431 |
|
|
} else {
|
2432 |
|
|
TRACE2(("gdth_interrupt() unknown controller type\n"));
|
2433 |
|
|
return;
|
2434 |
|
|
}
|
2435 |
|
|
|
2436 |
|
|
TRACE(("gdth_interrupt() index %d stat %d info %ld\n",
|
2437 |
|
|
IStatus,CmdStatus,InfoBytes));
|
2438 |
|
|
ha->status = CmdStatus;
|
2439 |
|
|
ha->info = InfoBytes;
|
2440 |
|
|
ha->info2 = InfoBytes2;
|
2441 |
|
|
|
2442 |
|
|
if (gdth_from_wait) {
|
2443 |
|
|
wait_hanum = hanum;
|
2444 |
|
|
wait_index = (int)IStatus;
|
2445 |
|
|
}
|
2446 |
|
|
|
2447 |
|
|
if (IStatus == ASYNCINDEX) {
|
2448 |
|
|
TRACE2(("gdth_interrupt() async. event\n"));
|
2449 |
|
|
gdth_async_event(hanum,Service);
|
2450 |
|
|
} else {
|
2451 |
|
|
if (IStatus == SPEZINDEX) {
|
2452 |
|
|
TRACE2(("Service unknown or not initialized !\n"));
|
2453 |
|
|
dvr.size = sizeof(dvr.eu.driver);
|
2454 |
|
|
dvr.eu.driver.ionode = hanum;
|
2455 |
|
|
gdth_store_event(ES_DRIVER, 4, &dvr);
|
2456 |
|
|
return;
|
2457 |
|
|
}
|
2458 |
|
|
scp = gdth_cmd_tab[IStatus-2][hanum].cmnd;
|
2459 |
|
|
Service = gdth_cmd_tab[IStatus-2][hanum].service;
|
2460 |
|
|
gdth_cmd_tab[IStatus-2][hanum].cmnd = UNUSED_CMND;
|
2461 |
|
|
if (scp == UNUSED_CMND) {
|
2462 |
|
|
TRACE2(("gdth_interrupt() index to unused command (%d)\n",IStatus));
|
2463 |
|
|
dvr.size = sizeof(dvr.eu.driver);
|
2464 |
|
|
dvr.eu.driver.ionode = hanum;
|
2465 |
|
|
dvr.eu.driver.index = IStatus;
|
2466 |
|
|
gdth_store_event(ES_DRIVER, 1, &dvr);
|
2467 |
|
|
return;
|
2468 |
|
|
}
|
2469 |
|
|
if (scp == INTERNAL_CMND) {
|
2470 |
|
|
TRACE(("gdth_interrupt() answer to internal command\n"));
|
2471 |
|
|
return;
|
2472 |
|
|
}
|
2473 |
|
|
TRACE(("gdth_interrupt() sync. status\n"));
|
2474 |
|
|
gdth_sync_event(hanum,Service,IStatus,scp);
|
2475 |
|
|
}
|
2476 |
|
|
gdth_next(hanum);
|
2477 |
|
|
}
|
2478 |
|
|
|
2479 |
|
|
static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
|
2480 |
|
|
{
|
2481 |
|
|
register gdth_ha_str *ha;
|
2482 |
|
|
gdth_msg_str *msg;
|
2483 |
|
|
gdth_cmd_str *cmdp;
|
2484 |
|
|
char c='\r';
|
2485 |
|
|
ushort i;
|
2486 |
|
|
gdth_evt_data dvr;
|
2487 |
|
|
|
2488 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
2489 |
|
|
cmdp = ha->pccb;
|
2490 |
|
|
TRACE(("gdth_sync_event() scp %lx serv %d status %d\n",
|
2491 |
|
|
(ulong)scp,service,ha->status));
|
2492 |
|
|
|
2493 |
|
|
if (service == SCREENSERVICE) {
|
2494 |
|
|
msg = (gdth_msg_str *)ha->pscratch;
|
2495 |
|
|
TRACE(("len: %ld, answer: %d, ext: %d, alen: %ld\n",
|
2496 |
|
|
msg->msg_len,msg->msg_answer,msg->msg_ext,msg->msg_alen));
|
2497 |
|
|
if (msg->msg_len)
|
2498 |
|
|
if (!(msg->msg_answer && msg->msg_ext)) {
|
2499 |
|
|
msg->msg_text[msg->msg_len] = '\0';
|
2500 |
|
|
printk("%s",msg->msg_text);
|
2501 |
|
|
}
|
2502 |
|
|
|
2503 |
|
|
if (msg->msg_ext && !msg->msg_answer) {
|
2504 |
|
|
while (gdth_test_busy(hanum))
|
2505 |
|
|
gdth_delay(0);
|
2506 |
|
|
cmdp->Service = SCREENSERVICE;
|
2507 |
|
|
cmdp->RequestBuffer = SCREEN_CMND;
|
2508 |
|
|
gdth_get_cmd_index(hanum);
|
2509 |
|
|
gdth_set_sema0(hanum);
|
2510 |
|
|
cmdp->OpCode = GDT_READ;
|
2511 |
|
|
cmdp->BoardNode = LOCALBOARD;
|
2512 |
|
|
cmdp->u.screen.reserved = 0;
|
2513 |
|
|
cmdp->u.screen.msg_handle= msg->msg_handle;
|
2514 |
|
|
cmdp->u.screen.msg_addr = (ulong)msg;
|
2515 |
|
|
ha->cmd_offs_dpmem = 0;
|
2516 |
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.msg_addr)
|
2517 |
|
|
+ sizeof(ulong);
|
2518 |
|
|
ha->cmd_cnt = 0;
|
2519 |
|
|
gdth_copy_command(hanum);
|
2520 |
|
|
gdth_release_event(hanum);
|
2521 |
|
|
return 1;
|
2522 |
|
|
}
|
2523 |
|
|
|
2524 |
|
|
if (msg->msg_answer && msg->msg_alen) {
|
2525 |
|
|
for (i=0; i<msg->msg_alen && i<MSGLEN; ++i) {
|
2526 |
|
|
/* getchar() ?? */
|
2527 |
|
|
/* .. */
|
2528 |
|
|
if (c == '\r')
|
2529 |
|
|
break;
|
2530 |
|
|
msg->msg_text[i] = c;
|
2531 |
|
|
}
|
2532 |
|
|
msg->msg_alen -= i;
|
2533 |
|
|
if (c!='\r' && msg->msg_alen!=0) {
|
2534 |
|
|
msg->msg_answer = 1;
|
2535 |
|
|
msg->msg_ext = 1;
|
2536 |
|
|
} else {
|
2537 |
|
|
msg->msg_ext = 0;
|
2538 |
|
|
msg->msg_answer = 0;
|
2539 |
|
|
}
|
2540 |
|
|
msg->msg_len = i;
|
2541 |
|
|
while (gdth_test_busy(hanum))
|
2542 |
|
|
gdth_delay(0);
|
2543 |
|
|
cmdp->Service = SCREENSERVICE;
|
2544 |
|
|
cmdp->RequestBuffer = SCREEN_CMND;
|
2545 |
|
|
gdth_get_cmd_index(hanum);
|
2546 |
|
|
gdth_set_sema0(hanum);
|
2547 |
|
|
cmdp->OpCode = GDT_WRITE;
|
2548 |
|
|
cmdp->BoardNode = LOCALBOARD;
|
2549 |
|
|
cmdp->u.screen.reserved = 0;
|
2550 |
|
|
cmdp->u.screen.msg_handle= msg->msg_handle;
|
2551 |
|
|
cmdp->u.screen.msg_addr = (ulong)msg;
|
2552 |
|
|
ha->cmd_offs_dpmem = 0;
|
2553 |
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.msg_addr)
|
2554 |
|
|
+ sizeof(ulong);
|
2555 |
|
|
ha->cmd_cnt = 0;
|
2556 |
|
|
gdth_copy_command(hanum);
|
2557 |
|
|
gdth_release_event(hanum);
|
2558 |
|
|
return 1;
|
2559 |
|
|
}
|
2560 |
|
|
printk("\n");
|
2561 |
|
|
|
2562 |
|
|
} else {
|
2563 |
|
|
scp->SCp.Message = (int)ha->status;
|
2564 |
|
|
/* cache or raw service */
|
2565 |
|
|
if (ha->status == S_OK) {
|
2566 |
|
|
scp->result = DID_OK << 16;
|
2567 |
|
|
} else if (ha->status == S_BSY) {
|
2568 |
|
|
TRACE2(("Controller busy -> retry !\n"));
|
2569 |
|
|
gdth_putq(hanum,scp,scp->SCp.this_residual);
|
2570 |
|
|
return 1;
|
2571 |
|
|
} else {
|
2572 |
|
|
if (service == CACHESERVICE) {
|
2573 |
|
|
memset((char*)scp->sense_buffer,0,16);
|
2574 |
|
|
scp->sense_buffer[0] = 0x70;
|
2575 |
|
|
scp->sense_buffer[2] = NOT_READY;
|
2576 |
|
|
scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
|
2577 |
|
|
|
2578 |
|
|
if (scp->done != gdth_scsi_done) {
|
2579 |
|
|
dvr.size = sizeof(dvr.eu.sync);
|
2580 |
|
|
dvr.eu.sync.ionode = hanum;
|
2581 |
|
|
dvr.eu.sync.service = service;
|
2582 |
|
|
dvr.eu.sync.status = ha->status;
|
2583 |
|
|
dvr.eu.sync.info = ha->info;
|
2584 |
|
|
dvr.eu.sync.hostdrive =
|
2585 |
|
|
#if LINUX_VERSION_CODE >= 0x020000
|
2586 |
|
|
ha->id[scp->channel][scp->target].hostdrive;
|
2587 |
|
|
#else
|
2588 |
|
|
ha->id[NUMDATA(scp->host)->busnum][scp->target].hostdrive;
|
2589 |
|
|
#endif
|
2590 |
|
|
if (ha->status >= 0x8000)
|
2591 |
|
|
gdth_store_event(ES_SYNC, 0, &dvr);
|
2592 |
|
|
else
|
2593 |
|
|
gdth_store_event(ES_SYNC, service, &dvr);
|
2594 |
|
|
}
|
2595 |
|
|
} else {
|
2596 |
|
|
if (ha->status!=S_RAW_SCSI || ha->status==S_RAW_ILL || ha->info>=0x100) {
|
2597 |
|
|
scp->result = DID_BAD_TARGET << 16;
|
2598 |
|
|
} else {
|
2599 |
|
|
scp->result = (DID_OK << 16) | ha->info;
|
2600 |
|
|
}
|
2601 |
|
|
}
|
2602 |
|
|
}
|
2603 |
|
|
if (!scp->SCp.have_data_in)
|
2604 |
|
|
scp->SCp.have_data_in++;
|
2605 |
|
|
else
|
2606 |
|
|
scp->scsi_done(scp);
|
2607 |
|
|
}
|
2608 |
|
|
|
2609 |
|
|
return 1;
|
2610 |
|
|
}
|
2611 |
|
|
|
2612 |
|
|
static char *async_cache_tab[] = {
|
2613 |
|
|
/* 0*/ "\011\000\002\002\002\004\002\006\004"
|
2614 |
|
|
"GDT HA %u, service %u, async. status %u/%lu unknown",
|
2615 |
|
|
/* 1*/ "\011\000\002\002\002\004\002\006\004"
|
2616 |
|
|
"GDT HA %u, service %u, async. status %u/%lu unknown",
|
2617 |
|
|
/* 2*/ "\005\000\002\006\004"
|
2618 |
|
|
"GDT HA %u, Host Drive %lu not ready",
|
2619 |
|
|
/* 3*/ "\005\000\002\006\004"
|
2620 |
|
|
"GDT HA %u, Host Drive %lu: REASSIGN not successful and/or data error on reassigned blocks. Drive may crash in the future and should be replaced",
|
2621 |
|
|
/* 4*/ "\005\000\002\006\004"
|
2622 |
|
|
"GDT HA %u, mirror update on Host Drive %lu failed",
|
2623 |
|
|
/* 5*/ "\005\000\002\006\004"
|
2624 |
|
|
"GDT HA %u, Mirror Drive %lu failed",
|
2625 |
|
|
/* 6*/ "\005\000\002\006\004"
|
2626 |
|
|
"GDT HA %u, Mirror Drive %lu: REASSIGN not successful and/or data error on reassigned blocks. Drive may crash in the future and should be replaced",
|
2627 |
|
|
/* 7*/ "\005\000\002\006\004"
|
2628 |
|
|
"GDT HA %u, Host Drive %lu write protected",
|
2629 |
|
|
/* 8*/ "\005\000\002\006\004"
|
2630 |
|
|
"GDT HA %u, media changed in Host Drive %lu",
|
2631 |
|
|
/* 9*/ "\005\000\002\006\004"
|
2632 |
|
|
"GDT HA %u, Host Drive %lu is offline",
|
2633 |
|
|
/*10*/ "\005\000\002\006\004"
|
2634 |
|
|
"GDT HA %u, media change of Mirror Drive %lu",
|
2635 |
|
|
/*11*/ "\005\000\002\006\004"
|
2636 |
|
|
"GDT HA %u, Mirror Drive %lu is write protected",
|
2637 |
|
|
/*12*/ "\005\000\002\006\004"
|
2638 |
|
|
"GDT HA %u, general error on Host Drive %lu. Please check the devices of this drive!",
|
2639 |
|
|
/*13*/ "\007\000\002\006\002\010\002"
|
2640 |
|
|
"GDT HA %u, Array Drive %u: Cache Drive %u failed",
|
2641 |
|
|
/*14*/ "\005\000\002\006\002"
|
2642 |
|
|
"GDT HA %u, Array Drive %u: FAIL state entered",
|
2643 |
|
|
/*15*/ "\005\000\002\006\002"
|
2644 |
|
|
"GDT HA %u, Array Drive %u: error",
|
2645 |
|
|
/*16*/ "\007\000\002\006\002\010\002"
|
2646 |
|
|
"GDT HA %u, Array Drive %u: failed drive replaced by Cache Drive %u",
|
2647 |
|
|
/*17*/ "\005\000\002\006\002"
|
2648 |
|
|
"GDT HA %u, Array Drive %u: parity build failed",
|
2649 |
|
|
/*18*/ "\005\000\002\006\002"
|
2650 |
|
|
"GDT HA %u, Array Drive %u: drive rebuild failed",
|
2651 |
|
|
/*19*/ "\007\000\002\010\002"
|
2652 |
|
|
"GDT HA %u, Test of Hot Fix %u failed",
|
2653 |
|
|
/*20*/ "\005\000\002\006\002"
|
2654 |
|
|
"GDT HA %u, Array Drive %u: drive build finished successfully",
|
2655 |
|
|
/*21*/ "\005\000\002\006\002"
|
2656 |
|
|
"GDT HA %u, Array Drive %u: drive rebuild finished successfully",
|
2657 |
|
|
/*22*/ "\007\000\002\006\002\010\002"
|
2658 |
|
|
"GDT HA %u, Array Drive %u: Hot Fix %u activated",
|
2659 |
|
|
/*23*/ "\005\000\002\006\002"
|
2660 |
|
|
"GDT HA %u, Host Drive %u: processing of i/o aborted due to serious drive error",
|
2661 |
|
|
/*24*/ "\005\000\002\010\002"
|
2662 |
|
|
"GDT HA %u, mirror update on Cache Drive %u completed",
|
2663 |
|
|
/*25*/ "\005\000\002\010\002"
|
2664 |
|
|
"GDT HA %u, mirror update on Cache Drive %lu failed",
|
2665 |
|
|
/*26*/ "\005\000\002\006\002"
|
2666 |
|
|
"GDT HA %u, Array Drive %u: drive rebuild started",
|
2667 |
|
|
/*27*/ "\005\000\002\012\001"
|
2668 |
|
|
"GDT HA %u, Fault bus %u: SHELF OK detected",
|
2669 |
|
|
/*28*/ "\005\000\002\012\001"
|
2670 |
|
|
"GDT HA %u, Fault bus %u: SHELF not OK detected",
|
2671 |
|
|
/*29*/ "\007\000\002\012\001\013\001"
|
2672 |
|
|
"GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug started",
|
2673 |
|
|
/*30*/ "\007\000\002\012\001\013\001"
|
2674 |
|
|
"GDT HA %u, Fault bus %u, ID %u: new disk detected",
|
2675 |
|
|
/*31*/ "\007\000\002\012\001\013\001"
|
2676 |
|
|
"GDT HA %u, Fault bus %u, ID %u: old disk detected",
|
2677 |
|
|
/*32*/ "\007\000\002\012\001\013\001"
|
2678 |
|
|
"GDT HA %u, Fault bus %u, ID %u: plugging an active disk is illegal",
|
2679 |
|
|
/*33*/ "\007\000\002\012\001\013\001"
|
2680 |
|
|
"GDT HA %u, Fault bus %u, ID %u: illegal device detected",
|
2681 |
|
|
/*34*/ "\011\000\002\012\001\013\001\006\004"
|
2682 |
|
|
"GDT HA %u, Fault bus %u, ID %u: insufficient disk capacity (%lu MB required)",
|
2683 |
|
|
/*35*/ "\007\000\002\012\001\013\001"
|
2684 |
|
|
"GDT HA %u, Fault bus %u, ID %u: disk write protected",
|
2685 |
|
|
/*36*/ "\007\000\002\012\001\013\001"
|
2686 |
|
|
"GDT HA %u, Fault bus %u, ID %u: disk not available",
|
2687 |
|
|
/*37*/ "\007\000\002\012\001\006\004"
|
2688 |
|
|
"GDT HA %u, Fault bus %u: swap detected (%lu)",
|
2689 |
|
|
/*38*/ "\007\000\002\012\001\013\001"
|
2690 |
|
|
"GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug finished successfully",
|
2691 |
|
|
/*39*/ "\007\000\002\012\001\013\001"
|
2692 |
|
|
"GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted due to user Hot Plug",
|
2693 |
|
|
/*40*/ "\007\000\002\012\001\013\001"
|
2694 |
|
|
"GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug aborted",
|
2695 |
|
|
/*41*/ "\007\000\002\012\001\013\001"
|
2696 |
|
|
"GDT HA %u, Fault bus %u, ID %u: Auto Hot Plug for Hot Fix started",
|
2697 |
|
|
/*42*/ "\005\000\002\006\002"
|
2698 |
|
|
"GDT HA %u, Array Drive %u: drive build started",
|
2699 |
|
|
/*43*/ "\003\000\002"
|
2700 |
|
|
"GDT HA %u, DRAM parity error detected",
|
2701 |
|
|
/*44*/ "\005\000\002\006\002"
|
2702 |
|
|
"GDT HA %u, Mirror Drive %u: update started",
|
2703 |
|
|
/*45*/ "\007\000\002\006\002\010\002"
|
2704 |
|
|
"GDT HA %u, Mirror Drive %u: Hot Fix %u activated",
|
2705 |
|
|
/*46*/ "\005\000\002\006\002"
|
2706 |
|
|
"GDT HA %u, Array Drive %u: no matching Pool Hot Fix Drive available",
|
2707 |
|
|
/*47*/ "\005\000\002\006\002"
|
2708 |
|
|
"GDT HA %u, Array Drive %u: Pool Hot Fix Drive available",
|
2709 |
|
|
/*48*/ "\005\000\002\006\002"
|
2710 |
|
|
"GDT HA %u, Mirror Drive %u: no matching Pool Hot Fix Drive available",
|
2711 |
|
|
/*49*/ "\005\000\002\006\002"
|
2712 |
|
|
"GDT HA %u, Mirror Drive %u: Pool Hot Fix Drive available",
|
2713 |
|
|
/*50*/ "\007\000\002\012\001\013\001"
|
2714 |
|
|
"GDT HA %u, SCSI bus %u, ID %u: IGNORE_WIDE_RESIDUE message received",
|
2715 |
|
|
/*51*/ "\005\000\002\006\002"
|
2716 |
|
|
"GDT HA %u, Array Drive %u: expand started",
|
2717 |
|
|
/*52*/ "\005\000\002\006\002"
|
2718 |
|
|
"GDT HA %u, Array Drive %u: expand finished successfully",
|
2719 |
|
|
/*53*/ "\005\000\002\006\002"
|
2720 |
|
|
"GDT HA %u, Array Drive %u: expand failed",
|
2721 |
|
|
/*54*/ "\003\000\002"
|
2722 |
|
|
"GDT HA %u, CPU temperature critical",
|
2723 |
|
|
/*55*/ "\003\000\002"
|
2724 |
|
|
"GDT HA %u, CPU temperature OK",
|
2725 |
|
|
/*56*/ "\005\000\002\006\004"
|
2726 |
|
|
"GDT HA %u, Host drive %lu created",
|
2727 |
|
|
/*57*/ "\005\000\002\006\002"
|
2728 |
|
|
"GDT HA %u, Array Drive %u: expand restarted",
|
2729 |
|
|
/*58*/ "\005\000\002\006\002"
|
2730 |
|
|
"GDT HA %u, Array Drive %u: expand stopped",
|
2731 |
|
|
};
|
2732 |
|
|
|
2733 |
|
|
|
2734 |
|
|
static int gdth_async_event(int hanum,int service)
|
2735 |
|
|
{
|
2736 |
|
|
gdth_stackframe stack;
|
2737 |
|
|
gdth_evt_data dvr;
|
2738 |
|
|
char *f = NULL;
|
2739 |
|
|
int i,j;
|
2740 |
|
|
gdth_ha_str *ha;
|
2741 |
|
|
gdth_msg_str *msg;
|
2742 |
|
|
gdth_cmd_str *cmdp;
|
2743 |
|
|
int cmd_index;
|
2744 |
|
|
|
2745 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
2746 |
|
|
cmdp= ha->pccb;
|
2747 |
|
|
msg = (gdth_msg_str *)ha->pscratch;
|
2748 |
|
|
TRACE2(("gdth_async_event() ha %d serv %d\n",
|
2749 |
|
|
hanum,service));
|
2750 |
|
|
|
2751 |
|
|
if (service == SCREENSERVICE) {
|
2752 |
|
|
if (ha->status == MSG_REQUEST) {
|
2753 |
|
|
while (gdth_test_busy(hanum))
|
2754 |
|
|
gdth_delay(0);
|
2755 |
|
|
cmdp->Service = SCREENSERVICE;
|
2756 |
|
|
cmdp->RequestBuffer = SCREEN_CMND;
|
2757 |
|
|
cmd_index = gdth_get_cmd_index(hanum);
|
2758 |
|
|
gdth_set_sema0(hanum);
|
2759 |
|
|
cmdp->OpCode = GDT_READ;
|
2760 |
|
|
cmdp->BoardNode = LOCALBOARD;
|
2761 |
|
|
cmdp->u.screen.reserved = 0;
|
2762 |
|
|
cmdp->u.screen.msg_handle= MSG_INV_HANDLE;
|
2763 |
|
|
cmdp->u.screen.msg_addr = (ulong)msg;
|
2764 |
|
|
ha->cmd_offs_dpmem = 0;
|
2765 |
|
|
ha->cmd_len = GDTOFFSOF(gdth_cmd_str,u.screen.msg_addr)
|
2766 |
|
|
+ sizeof(ulong);
|
2767 |
|
|
ha->cmd_cnt = 0;
|
2768 |
|
|
gdth_copy_command(hanum);
|
2769 |
|
|
if (ha->type == GDT_EISA)
|
2770 |
|
|
printk("[EISA slot %d] ",(ushort)ha->brd_phys);
|
2771 |
|
|
else if (ha->type == GDT_ISA)
|
2772 |
|
|
printk("[DPMEM 0x%4X] ",(ushort)ha->brd_phys);
|
2773 |
|
|
else
|
2774 |
|
|
printk("[PCI %d/%d] ",(ushort)(ha->brd_phys>>8),
|
2775 |
|
|
(ushort)((ha->brd_phys>>3)&0x1f));
|
2776 |
|
|
gdth_release_event(hanum);
|
2777 |
|
|
}
|
2778 |
|
|
|
2779 |
|
|
} else {
|
2780 |
|
|
dvr.size = sizeof(dvr.eu.async);
|
2781 |
|
|
dvr.eu.async.ionode = hanum;
|
2782 |
|
|
dvr.eu.async.service = service;
|
2783 |
|
|
dvr.eu.async.status = ha->status;
|
2784 |
|
|
dvr.eu.async.info = ha->info;
|
2785 |
|
|
*(ulong *)dvr.eu.async.scsi_coord = ha->info2;
|
2786 |
|
|
gdth_store_event(ES_ASYNC, service, &dvr);
|
2787 |
|
|
|
2788 |
|
|
if (service==CACHESERVICE && INDEX_OK(ha->status,async_cache_tab)) {
|
2789 |
|
|
TRACE2(("GDT: Async. event cache service, event no.: %d\n",
|
2790 |
|
|
ha->status));
|
2791 |
|
|
|
2792 |
|
|
f = async_cache_tab[ha->status];
|
2793 |
|
|
|
2794 |
|
|
/* i: parameter to push, j: stack element to fill */
|
2795 |
|
|
for (j=0,i=1; i < f[0]; i+=2) {
|
2796 |
|
|
switch (f[i+1]) {
|
2797 |
|
|
case 4:
|
2798 |
|
|
stack.b[j++] = *(ulong*)&dvr.eu.stream[(int)f[i]];
|
2799 |
|
|
break;
|
2800 |
|
|
case 2:
|
2801 |
|
|
stack.b[j++] = *(ushort*)&dvr.eu.stream[(int)f[i]];
|
2802 |
|
|
break;
|
2803 |
|
|
case 1:
|
2804 |
|
|
stack.b[j++] = *(unchar*)&dvr.eu.stream[(int)f[i]];
|
2805 |
|
|
break;
|
2806 |
|
|
default:
|
2807 |
|
|
break;
|
2808 |
|
|
}
|
2809 |
|
|
}
|
2810 |
|
|
|
2811 |
|
|
printk(&f[f[0]],stack); printk("\n");
|
2812 |
|
|
|
2813 |
|
|
} else {
|
2814 |
|
|
printk("GDT: Unknown async. event service %d event no. %d\n",
|
2815 |
|
|
service,ha->status);
|
2816 |
|
|
}
|
2817 |
|
|
}
|
2818 |
|
|
return 1;
|
2819 |
|
|
}
|
2820 |
|
|
|
2821 |
|
|
|
2822 |
|
|
#ifdef GDTH_STATISTICS
|
2823 |
|
|
void gdth_timeout(ulong data)
|
2824 |
|
|
{
|
2825 |
|
|
ulong flags,i;
|
2826 |
|
|
Scsi_Cmnd *nscp;
|
2827 |
|
|
gdth_ha_str *ha;
|
2828 |
|
|
int hanum = 0;
|
2829 |
|
|
|
2830 |
|
|
save_flags(flags);
|
2831 |
|
|
cli();
|
2832 |
|
|
|
2833 |
|
|
for (act_stats=0,i=0; i<GDTH_MAXCMDS; ++i)
|
2834 |
|
|
if (gdth_cmd_tab[i][hanum].cmnd != UNUSED_CMND)
|
2835 |
|
|
++act_stats;
|
2836 |
|
|
|
2837 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
2838 |
|
|
for (act_rq=0,nscp=ha->req_first; nscp; nscp=(Scsi_Cmnd*)nscp->SCp.ptr)
|
2839 |
|
|
++act_rq;
|
2840 |
|
|
|
2841 |
|
|
TRACE2(("gdth_to(): ints %ld, ios %ld, act_stats %ld, act_rq %ld\n",
|
2842 |
|
|
act_ints, act_ios, act_stats, act_rq));
|
2843 |
|
|
act_ints = act_ios = 0;
|
2844 |
|
|
|
2845 |
|
|
gdth_timer.expires = jiffies + 30 * HZ;
|
2846 |
|
|
add_timer(&gdth_timer);
|
2847 |
|
|
restore_flags(flags);
|
2848 |
|
|
}
|
2849 |
|
|
#endif
|
2850 |
|
|
|
2851 |
|
|
|
2852 |
|
|
__initfunc (int gdth_detect(Scsi_Host_Template *shtp))
|
2853 |
|
|
{
|
2854 |
|
|
struct Scsi_Host *shp;
|
2855 |
|
|
gdth_ha_str *ha;
|
2856 |
|
|
unsigned long flags;
|
2857 |
|
|
ulong isa_bios;
|
2858 |
|
|
ushort eisa_slot,device_id,index;
|
2859 |
|
|
gdth_pci_str pcistr;
|
2860 |
|
|
int i,j,hanum;
|
2861 |
|
|
unchar b;
|
2862 |
|
|
|
2863 |
|
|
|
2864 |
|
|
#ifdef DEBUG_GDTH
|
2865 |
|
|
printk("GDT: This driver contains debugging information !! Trace level = %d\n",
|
2866 |
|
|
DebugState);
|
2867 |
|
|
printk(" Destination of debugging information: ");
|
2868 |
|
|
#ifdef __SERIAL__
|
2869 |
|
|
#ifdef __COM2__
|
2870 |
|
|
printk("Serial port COM2\n");
|
2871 |
|
|
#else
|
2872 |
|
|
printk("Serial port COM1\n");
|
2873 |
|
|
#endif
|
2874 |
|
|
#else
|
2875 |
|
|
printk("Console\n");
|
2876 |
|
|
#endif
|
2877 |
|
|
gdth_delay(3000);
|
2878 |
|
|
#endif
|
2879 |
|
|
|
2880 |
|
|
TRACE(("gdth_detect()\n"));
|
2881 |
|
|
|
2882 |
|
|
if (disable_gdth_scan) {
|
2883 |
|
|
printk("GDT: Controller driver disabled from command line !\n");
|
2884 |
|
|
return 0;
|
2885 |
|
|
}
|
2886 |
|
|
|
2887 |
|
|
/* initializations */
|
2888 |
|
|
gdth_polling = TRUE; b = 0;
|
2889 |
|
|
for (i=0; i<GDTH_MAXCMDS; ++i)
|
2890 |
|
|
for (j=0; j<MAXHA; ++j)
|
2891 |
|
|
gdth_cmd_tab[i][j].cmnd = UNUSED_CMND;
|
2892 |
|
|
for (i=0; i<4; ++i)
|
2893 |
|
|
for (j=0; j<MAXHA; ++j)
|
2894 |
|
|
gdth_ioctl_tab[i][j] = NULL;
|
2895 |
|
|
gdth_clear_events();
|
2896 |
|
|
|
2897 |
|
|
/* scanning for controllers, at first: ISA controller */
|
2898 |
|
|
for (isa_bios=0xc8000UL; isa_bios<=0xd8000UL; isa_bios+=0x8000UL) {
|
2899 |
|
|
if (gdth_search_isa(isa_bios)) { /* controller found */
|
2900 |
|
|
shp = scsi_register(shtp,sizeof(gdth_ext_str));
|
2901 |
|
|
ha = HADATA(shp);
|
2902 |
|
|
if (!gdth_init_isa(isa_bios,ha)) {
|
2903 |
|
|
scsi_unregister(shp);
|
2904 |
|
|
continue;
|
2905 |
|
|
}
|
2906 |
|
|
/* controller found and initialized */
|
2907 |
|
|
printk("Configuring GDT-ISA HA at BIOS 0x%05lX IRQ %u DRQ %u\n",
|
2908 |
|
|
isa_bios,ha->irq,ha->drq);
|
2909 |
|
|
|
2910 |
|
|
save_flags(flags);
|
2911 |
|
|
cli();
|
2912 |
|
|
#if LINUX_VERSION_CODE >= 0x02015F
|
2913 |
|
|
if (request_irq(ha->irq,do_gdth_interrupt,SA_INTERRUPT,"gdth",NULL))
|
2914 |
|
|
#elif LINUX_VERSION_CODE >= 0x010346
|
2915 |
|
|
if (request_irq(ha->irq,gdth_interrupt,SA_INTERRUPT,"gdth",NULL))
|
2916 |
|
|
#else
|
2917 |
|
|
if (request_irq(ha->irq,gdth_interrupt,SA_INTERRUPT,"gdth"))
|
2918 |
|
|
#endif
|
2919 |
|
|
{
|
2920 |
|
|
printk("GDT-ISA: Unable to allocate IRQ\n");
|
2921 |
|
|
restore_flags(flags);
|
2922 |
|
|
scsi_unregister(shp);
|
2923 |
|
|
continue;
|
2924 |
|
|
}
|
2925 |
|
|
if (request_dma(ha->drq,"gdth")) {
|
2926 |
|
|
printk("GDT-ISA: Unable to allocate DMA channel\n");
|
2927 |
|
|
#if LINUX_VERSION_CODE >= 0x010346
|
2928 |
|
|
free_irq(ha->irq,NULL);
|
2929 |
|
|
#else
|
2930 |
|
|
free_irq(ha->irq);
|
2931 |
|
|
#endif
|
2932 |
|
|
restore_flags(flags);
|
2933 |
|
|
scsi_unregister(shp);
|
2934 |
|
|
continue;
|
2935 |
|
|
}
|
2936 |
|
|
set_dma_mode(ha->drq,DMA_MODE_CASCADE);
|
2937 |
|
|
enable_dma(ha->drq);
|
2938 |
|
|
shp->unchecked_isa_dma = 1;
|
2939 |
|
|
shp->irq = ha->irq;
|
2940 |
|
|
shp->dma_channel = ha->drq;
|
2941 |
|
|
for (i=0; i<MAXID; ++i) {
|
2942 |
|
|
if (ha->id[0][i].type==SIOP_DTYP) {
|
2943 |
|
|
shp->this_id = i;
|
2944 |
|
|
break;
|
2945 |
|
|
}
|
2946 |
|
|
}
|
2947 |
|
|
hanum = gdth_ctr_count;
|
2948 |
|
|
gdth_ctr_tab[gdth_ctr_count++] = shp;
|
2949 |
|
|
gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
|
2950 |
|
|
|
2951 |
|
|
NUMDATA(shp)->hanum = (ushort)hanum;
|
2952 |
|
|
NUMDATA(shp)->busnum= 0;
|
2953 |
|
|
|
2954 |
|
|
ha->pccb = CMDDATA(shp);
|
2955 |
|
|
ha->pscratch = DMADATA(shp);
|
2956 |
|
|
ha->req_first = NULL;
|
2957 |
|
|
for (i=0; i<MAXBUS; ++i) {
|
2958 |
|
|
for (j=0; j<MAXID; ++j) {
|
2959 |
|
|
ha->id[i][j].type = EMPTY_DTYP;
|
2960 |
|
|
ha->id[i][j].lock = 0;
|
2961 |
|
|
ha->id[i][j].heads = 0;
|
2962 |
|
|
}
|
2963 |
|
|
}
|
2964 |
|
|
restore_flags(flags);
|
2965 |
|
|
|
2966 |
|
|
if (!gdth_search_drives(hanum)) {
|
2967 |
|
|
printk("GDT-ISA: Error during device scan\n");
|
2968 |
|
|
--gdth_ctr_count;
|
2969 |
|
|
--gdth_ctr_vcount;
|
2970 |
|
|
save_flags(flags);
|
2971 |
|
|
cli();
|
2972 |
|
|
#if LINUX_VERSION_CODE >= 0x010346
|
2973 |
|
|
free_irq(ha->irq,NULL);
|
2974 |
|
|
#else
|
2975 |
|
|
free_irq(ha->irq);
|
2976 |
|
|
#endif
|
2977 |
|
|
restore_flags(flags);
|
2978 |
|
|
scsi_unregister(shp);
|
2979 |
|
|
continue;
|
2980 |
|
|
}
|
2981 |
|
|
|
2982 |
|
|
#if LINUX_VERSION_CODE >= 0x020000
|
2983 |
|
|
shp->max_id = 8;
|
2984 |
|
|
shp->max_lun = MAXLUN;
|
2985 |
|
|
shp->max_channel = ha->bus_cnt - 1;
|
2986 |
|
|
#else
|
2987 |
|
|
/* register addit. SCSI channels as virtual controllers */
|
2988 |
|
|
for (b=1; b<ha->bus_cnt; ++b) {
|
2989 |
|
|
shp = scsi_register(shtp,sizeof(gdth_num_str));
|
2990 |
|
|
shp->unchecked_isa_dma = 1;
|
2991 |
|
|
shp->irq = ha->irq;
|
2992 |
|
|
shp->dma_channel = ha->drq;
|
2993 |
|
|
for (i=0; i<MAXID; ++i) {
|
2994 |
|
|
if (ha->id[b][i].type==SIOP_DTYP) {
|
2995 |
|
|
shp->this_id = i;
|
2996 |
|
|
break;
|
2997 |
|
|
}
|
2998 |
|
|
}
|
2999 |
|
|
gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
|
3000 |
|
|
NUMDATA(shp)->hanum = (ushort)hanum;
|
3001 |
|
|
NUMDATA(shp)->busnum = b;
|
3002 |
|
|
}
|
3003 |
|
|
#endif
|
3004 |
|
|
|
3005 |
|
|
gdth_enable_int(hanum);
|
3006 |
|
|
}
|
3007 |
|
|
}
|
3008 |
|
|
|
3009 |
|
|
/* scanning for EISA controllers */
|
3010 |
|
|
for (eisa_slot=0x1000; eisa_slot<=0x8000; eisa_slot+=0x1000) {
|
3011 |
|
|
if (gdth_search_eisa(eisa_slot)) { /* controller found */
|
3012 |
|
|
shp = scsi_register(shtp,sizeof(gdth_ext_str));
|
3013 |
|
|
ha = HADATA(shp);
|
3014 |
|
|
if (!gdth_init_eisa(eisa_slot,ha)) {
|
3015 |
|
|
scsi_unregister(shp);
|
3016 |
|
|
continue;
|
3017 |
|
|
}
|
3018 |
|
|
/* controller found and initialized */
|
3019 |
|
|
printk("Configuring GDT-EISA HA at Slot %d IRQ %u\n",
|
3020 |
|
|
eisa_slot>>12,ha->irq);
|
3021 |
|
|
|
3022 |
|
|
save_flags(flags);
|
3023 |
|
|
cli();
|
3024 |
|
|
#if LINUX_VERSION_CODE >= 0x02015F
|
3025 |
|
|
if (request_irq(ha->irq,do_gdth_interrupt,SA_INTERRUPT,"gdth",NULL))
|
3026 |
|
|
#elif LINUX_VERSION_CODE >= 0x010346
|
3027 |
|
|
if (request_irq(ha->irq,gdth_interrupt,SA_INTERRUPT,"gdth",NULL))
|
3028 |
|
|
#else
|
3029 |
|
|
if (request_irq(ha->irq,gdth_interrupt,SA_INTERRUPT,"gdth"))
|
3030 |
|
|
#endif
|
3031 |
|
|
{
|
3032 |
|
|
printk("GDT-EISA: Unable to allocate IRQ\n");
|
3033 |
|
|
restore_flags(flags);
|
3034 |
|
|
scsi_unregister(shp);
|
3035 |
|
|
continue;
|
3036 |
|
|
}
|
3037 |
|
|
shp->unchecked_isa_dma = 0;
|
3038 |
|
|
shp->irq = ha->irq;
|
3039 |
|
|
shp->dma_channel = 0xff;
|
3040 |
|
|
for (i=0; i<MAXID; ++i) {
|
3041 |
|
|
if (ha->id[0][i].type==SIOP_DTYP) {
|
3042 |
|
|
shp->this_id = i;
|
3043 |
|
|
break;
|
3044 |
|
|
}
|
3045 |
|
|
}
|
3046 |
|
|
hanum = gdth_ctr_count;
|
3047 |
|
|
gdth_ctr_tab[gdth_ctr_count++] = shp;
|
3048 |
|
|
gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
|
3049 |
|
|
|
3050 |
|
|
NUMDATA(shp)->hanum = (ushort)hanum;
|
3051 |
|
|
NUMDATA(shp)->busnum= 0;
|
3052 |
|
|
TRACE2(("EISA detect Bus 0: shp %lx hanum %d\n",
|
3053 |
|
|
(ulong)shp,NUMDATA(shp)->hanum));
|
3054 |
|
|
|
3055 |
|
|
ha->pccb = CMDDATA(shp);
|
3056 |
|
|
ha->pscratch = DMADATA(shp);
|
3057 |
|
|
ha->req_first = NULL;
|
3058 |
|
|
for (i=0; i<MAXBUS; ++i) {
|
3059 |
|
|
for (j=0; j<MAXID; ++j) {
|
3060 |
|
|
ha->id[i][j].type = EMPTY_DTYP;
|
3061 |
|
|
ha->id[i][j].lock = 0;
|
3062 |
|
|
ha->id[i][j].heads = 0;
|
3063 |
|
|
}
|
3064 |
|
|
}
|
3065 |
|
|
restore_flags(flags);
|
3066 |
|
|
|
3067 |
|
|
if (!gdth_search_drives(hanum)) {
|
3068 |
|
|
printk("GDT-EISA: Error during device scan\n");
|
3069 |
|
|
--gdth_ctr_count;
|
3070 |
|
|
--gdth_ctr_vcount;
|
3071 |
|
|
save_flags(flags);
|
3072 |
|
|
cli();
|
3073 |
|
|
#if LINUX_VERSION_CODE >= 0x010346
|
3074 |
|
|
free_irq(ha->irq,NULL);
|
3075 |
|
|
#else
|
3076 |
|
|
free_irq(ha->irq);
|
3077 |
|
|
#endif
|
3078 |
|
|
restore_flags(flags);
|
3079 |
|
|
scsi_unregister(shp);
|
3080 |
|
|
continue;
|
3081 |
|
|
}
|
3082 |
|
|
|
3083 |
|
|
#if LINUX_VERSION_CODE >= 0x020000
|
3084 |
|
|
shp->max_id = 8;
|
3085 |
|
|
shp->max_lun = MAXLUN;
|
3086 |
|
|
shp->max_channel = ha->bus_cnt - 1;
|
3087 |
|
|
#else
|
3088 |
|
|
/* register addit. SCSI channels as virtual controllers */
|
3089 |
|
|
for (b=1; b<ha->bus_cnt; ++b) {
|
3090 |
|
|
shp = scsi_register(shtp,sizeof(gdth_num_str));
|
3091 |
|
|
shp->unchecked_isa_dma = 0;
|
3092 |
|
|
shp->irq = ha->irq;
|
3093 |
|
|
shp->dma_channel = 0xff;
|
3094 |
|
|
for (i=0; i<MAXID; ++i) {
|
3095 |
|
|
if (ha->id[b][i].type==SIOP_DTYP) {
|
3096 |
|
|
shp->this_id = i;
|
3097 |
|
|
break;
|
3098 |
|
|
}
|
3099 |
|
|
}
|
3100 |
|
|
gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
|
3101 |
|
|
NUMDATA(shp)->hanum = (ushort)hanum;
|
3102 |
|
|
NUMDATA(shp)->busnum = b;
|
3103 |
|
|
TRACE2(("EISA detect Bus %d: shp %lx hanum %d\n",
|
3104 |
|
|
NUMDATA(shp)->busnum,(ulong)shp,
|
3105 |
|
|
NUMDATA(shp)->hanum));
|
3106 |
|
|
}
|
3107 |
|
|
#endif
|
3108 |
|
|
|
3109 |
|
|
gdth_enable_int(hanum);
|
3110 |
|
|
}
|
3111 |
|
|
}
|
3112 |
|
|
|
3113 |
|
|
/* scanning for PCI controllers */
|
3114 |
|
|
for (device_id = 0; device_id <= PCI_DEVICE_ID_VORTEX_GDTMAXRP; ++device_id) {
|
3115 |
|
|
if (device_id > PCI_DEVICE_ID_VORTEX_GDT6555 &&
|
3116 |
|
|
device_id < PCI_DEVICE_ID_VORTEX_GDT6x17RP)
|
3117 |
|
|
continue;
|
3118 |
|
|
for (index = 0; ; ++index) {
|
3119 |
|
|
if (!gdth_search_pci(device_id,index,&pcistr))
|
3120 |
|
|
break; /* next device_id */
|
3121 |
|
|
shp = scsi_register(shtp,sizeof(gdth_ext_str));
|
3122 |
|
|
ha = HADATA(shp);
|
3123 |
|
|
if (!gdth_init_pci(&pcistr,ha)) {
|
3124 |
|
|
scsi_unregister(shp);
|
3125 |
|
|
continue;
|
3126 |
|
|
}
|
3127 |
|
|
/* controller found and initialized */
|
3128 |
|
|
printk("Configuring GDT-PCI HA at %d/%d IRQ %u\n",
|
3129 |
|
|
pcistr.bus,pcistr.device_fn>>3,ha->irq);
|
3130 |
|
|
|
3131 |
|
|
save_flags(flags);
|
3132 |
|
|
cli();
|
3133 |
|
|
#if LINUX_VERSION_CODE >= 0x02015F
|
3134 |
|
|
if (request_irq(ha->irq,do_gdth_interrupt,SA_INTERRUPT|SA_SHIRQ,"gdth",NULL))
|
3135 |
|
|
#elif LINUX_VERSION_CODE >= 0x010346
|
3136 |
|
|
if (request_irq(ha->irq,gdth_interrupt,SA_INTERRUPT|SA_SHIRQ,"gdth",NULL))
|
3137 |
|
|
#else
|
3138 |
|
|
if (request_irq(ha->irq,gdth_interrupt,SA_INTERRUPT|SA_SHIRQ,"gdth"))
|
3139 |
|
|
#endif
|
3140 |
|
|
{
|
3141 |
|
|
printk("GDT-PCI: Unable to allocate IRQ\n");
|
3142 |
|
|
restore_flags(flags);
|
3143 |
|
|
scsi_unregister(shp);
|
3144 |
|
|
continue;
|
3145 |
|
|
}
|
3146 |
|
|
shp->unchecked_isa_dma = 0;
|
3147 |
|
|
shp->irq = ha->irq;
|
3148 |
|
|
shp->dma_channel = 0xff;
|
3149 |
|
|
for (i=0; i<MAXID; ++i) {
|
3150 |
|
|
if (ha->id[0][i].type==SIOP_DTYP) {
|
3151 |
|
|
shp->this_id = i;
|
3152 |
|
|
break;
|
3153 |
|
|
}
|
3154 |
|
|
}
|
3155 |
|
|
hanum = gdth_ctr_count;
|
3156 |
|
|
gdth_ctr_tab[gdth_ctr_count++] = shp;
|
3157 |
|
|
gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
|
3158 |
|
|
|
3159 |
|
|
NUMDATA(shp)->hanum = (ushort)hanum;
|
3160 |
|
|
NUMDATA(shp)->busnum= 0;
|
3161 |
|
|
|
3162 |
|
|
ha->pccb = CMDDATA(shp);
|
3163 |
|
|
ha->pscratch = DMADATA(shp);
|
3164 |
|
|
ha->req_first = NULL;
|
3165 |
|
|
for (i=0; i<MAXBUS; ++i) {
|
3166 |
|
|
for (j=0; j<MAXID; ++j) {
|
3167 |
|
|
ha->id[i][j].type = EMPTY_DTYP;
|
3168 |
|
|
ha->id[i][j].lock = 0;
|
3169 |
|
|
ha->id[i][j].heads = 0;
|
3170 |
|
|
}
|
3171 |
|
|
}
|
3172 |
|
|
restore_flags(flags);
|
3173 |
|
|
|
3174 |
|
|
if (!gdth_search_drives(hanum)) {
|
3175 |
|
|
printk("GDT-PCI: Error during device scan\n");
|
3176 |
|
|
--gdth_ctr_count;
|
3177 |
|
|
--gdth_ctr_vcount;
|
3178 |
|
|
save_flags(flags);
|
3179 |
|
|
cli();
|
3180 |
|
|
#if LINUX_VERSION_CODE >= 0x010346
|
3181 |
|
|
free_irq(ha->irq,NULL);
|
3182 |
|
|
#else
|
3183 |
|
|
free_irq(ha->irq);
|
3184 |
|
|
#endif
|
3185 |
|
|
restore_flags(flags);
|
3186 |
|
|
scsi_unregister(shp);
|
3187 |
|
|
continue;
|
3188 |
|
|
}
|
3189 |
|
|
|
3190 |
|
|
#if LINUX_VERSION_CODE >= 0x020000
|
3191 |
|
|
shp->max_id = MAXID;
|
3192 |
|
|
shp->max_lun = MAXLUN;
|
3193 |
|
|
shp->max_channel = ha->bus_cnt - 1;
|
3194 |
|
|
#else
|
3195 |
|
|
/* register addit. SCSI channels as virtual controllers */
|
3196 |
|
|
for (b=1; b<ha->bus_cnt; ++b) {
|
3197 |
|
|
shp = scsi_register(shtp,sizeof(gdth_num_str));
|
3198 |
|
|
shp->unchecked_isa_dma = 0;
|
3199 |
|
|
shp->irq = ha->irq;
|
3200 |
|
|
shp->dma_channel = 0xff;
|
3201 |
|
|
for (i=0; i<MAXID; ++i) {
|
3202 |
|
|
if (ha->id[b][i].type==SIOP_DTYP) {
|
3203 |
|
|
shp->this_id = i;
|
3204 |
|
|
break;
|
3205 |
|
|
}
|
3206 |
|
|
}
|
3207 |
|
|
gdth_ctr_vtab[gdth_ctr_vcount++] = shp;
|
3208 |
|
|
NUMDATA(shp)->hanum = (ushort)hanum;
|
3209 |
|
|
NUMDATA(shp)->busnum = b;
|
3210 |
|
|
}
|
3211 |
|
|
#endif
|
3212 |
|
|
|
3213 |
|
|
gdth_enable_int(hanum);
|
3214 |
|
|
}
|
3215 |
|
|
}
|
3216 |
|
|
|
3217 |
|
|
TRACE2(("gdth_detect() %d controller detected\n",gdth_ctr_count));
|
3218 |
|
|
if (gdth_ctr_count > 0) {
|
3219 |
|
|
#ifdef GDTH_STATISTICS
|
3220 |
|
|
TRACE2(("gdth_detect(): Initializing timer !\n"));
|
3221 |
|
|
init_timer(&gdth_timer);
|
3222 |
|
|
gdth_timer.expires = jiffies + HZ;
|
3223 |
|
|
gdth_timer.data = 0L;
|
3224 |
|
|
gdth_timer.function = gdth_timeout;
|
3225 |
|
|
add_timer(&gdth_timer);
|
3226 |
|
|
#endif
|
3227 |
|
|
#if LINUX_VERSION_CODE >= 0x020100
|
3228 |
|
|
register_reboot_notifier(&gdth_notifier);
|
3229 |
|
|
#endif
|
3230 |
|
|
}
|
3231 |
|
|
gdth_polling = FALSE;
|
3232 |
|
|
return gdth_ctr_vcount;
|
3233 |
|
|
}
|
3234 |
|
|
|
3235 |
|
|
|
3236 |
|
|
int gdth_release(struct Scsi_Host *shp)
|
3237 |
|
|
{
|
3238 |
|
|
unsigned long flags;
|
3239 |
|
|
|
3240 |
|
|
TRACE2(("gdth_release()\n"));
|
3241 |
|
|
|
3242 |
|
|
if (NUMDATA(shp)->busnum == 0) {
|
3243 |
|
|
gdth_flush(NUMDATA(shp)->hanum);
|
3244 |
|
|
|
3245 |
|
|
save_flags(flags);
|
3246 |
|
|
cli();
|
3247 |
|
|
if (shp->irq) {
|
3248 |
|
|
#if LINUX_VERSION_CODE >= 0x010346
|
3249 |
|
|
free_irq(shp->irq,NULL);
|
3250 |
|
|
#else
|
3251 |
|
|
free_irq(shp->irq);
|
3252 |
|
|
#endif
|
3253 |
|
|
}
|
3254 |
|
|
if (shp->dma_channel != 0xff) {
|
3255 |
|
|
free_dma(shp->dma_channel);
|
3256 |
|
|
}
|
3257 |
|
|
restore_flags(flags);
|
3258 |
|
|
gdth_ctr_released++;
|
3259 |
|
|
TRACE2(("gdth_release(): HA %d of %d\n",
|
3260 |
|
|
gdth_ctr_released, gdth_ctr_count));
|
3261 |
|
|
|
3262 |
|
|
if (gdth_ctr_released == gdth_ctr_count) {
|
3263 |
|
|
#ifdef GDTH_STATISTICS
|
3264 |
|
|
del_timer(&gdth_timer);
|
3265 |
|
|
#endif
|
3266 |
|
|
#if LINUX_VERSION_CODE >= 0x020100
|
3267 |
|
|
unregister_reboot_notifier(&gdth_notifier);
|
3268 |
|
|
#endif
|
3269 |
|
|
}
|
3270 |
|
|
}
|
3271 |
|
|
|
3272 |
|
|
scsi_unregister(shp);
|
3273 |
|
|
return 0;
|
3274 |
|
|
}
|
3275 |
|
|
|
3276 |
|
|
|
3277 |
|
|
static const char *gdth_ctr_name(int hanum)
|
3278 |
|
|
{
|
3279 |
|
|
gdth_ha_str *ha;
|
3280 |
|
|
|
3281 |
|
|
TRACE2(("gdth_ctr_name()\n"));
|
3282 |
|
|
|
3283 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
3284 |
|
|
|
3285 |
|
|
if (ha->type == GDT_EISA) {
|
3286 |
|
|
switch (ha->stype) {
|
3287 |
|
|
case GDT3_ID:
|
3288 |
|
|
return("GDT3000/3020");
|
3289 |
|
|
case GDT3A_ID:
|
3290 |
|
|
return("GDT3000A/3020A/3050A");
|
3291 |
|
|
case GDT3B_ID:
|
3292 |
|
|
return("GDT3000B/3010A");
|
3293 |
|
|
}
|
3294 |
|
|
} else if (ha->type == GDT_ISA) {
|
3295 |
|
|
return("GDT2000/2020");
|
3296 |
|
|
} else if (ha->type == GDT_PCI) {
|
3297 |
|
|
switch (ha->stype) {
|
3298 |
|
|
case PCI_DEVICE_ID_VORTEX_GDT60x0:
|
3299 |
|
|
return("GDT6000/6020/6050");
|
3300 |
|
|
case PCI_DEVICE_ID_VORTEX_GDT6000B:
|
3301 |
|
|
return("GDT6000B/6010");
|
3302 |
|
|
}
|
3303 |
|
|
}
|
3304 |
|
|
/* new controllers (GDT_PCINEW, GDT_PCIMPR, ..) use board_info IOCTL! */
|
3305 |
|
|
|
3306 |
|
|
return("");
|
3307 |
|
|
}
|
3308 |
|
|
|
3309 |
|
|
const char *gdth_info(struct Scsi_Host *shp)
|
3310 |
|
|
{
|
3311 |
|
|
int hanum;
|
3312 |
|
|
gdth_ha_str *ha;
|
3313 |
|
|
|
3314 |
|
|
TRACE2(("gdth_info()\n"));
|
3315 |
|
|
hanum = NUMDATA(shp)->hanum;
|
3316 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
3317 |
|
|
|
3318 |
|
|
return ((const char *)ha->ctr_name);
|
3319 |
|
|
}
|
3320 |
|
|
|
3321 |
|
|
/* old error handling */
|
3322 |
|
|
int gdth_abort(Scsi_Cmnd *scp)
|
3323 |
|
|
{
|
3324 |
|
|
TRACE2(("gdth_abort() reason %d\n",scp->abort_reason));
|
3325 |
|
|
return SCSI_ABORT_SNOOZE;
|
3326 |
|
|
}
|
3327 |
|
|
|
3328 |
|
|
#if LINUX_VERSION_CODE >= 0x010346
|
3329 |
|
|
int gdth_reset(Scsi_Cmnd *scp, unsigned int reset_flags)
|
3330 |
|
|
#else
|
3331 |
|
|
int gdth_reset(Scsi_Cmnd *scp)
|
3332 |
|
|
#endif
|
3333 |
|
|
{
|
3334 |
|
|
TRACE2(("gdth_reset()\n"));
|
3335 |
|
|
return SCSI_RESET_PUNT;
|
3336 |
|
|
}
|
3337 |
|
|
|
3338 |
|
|
#if LINUX_VERSION_CODE >= 0x02015F
|
3339 |
|
|
/* new error handling */
|
3340 |
|
|
int gdth_eh_abort(Scsi_Cmnd *scp)
|
3341 |
|
|
{
|
3342 |
|
|
TRACE2(("gdth_eh_abort()\n"));
|
3343 |
|
|
return FAILED;
|
3344 |
|
|
}
|
3345 |
|
|
|
3346 |
|
|
int gdth_eh_device_reset(Scsi_Cmnd *scp)
|
3347 |
|
|
{
|
3348 |
|
|
TRACE2(("gdth_eh_device_reset()\n"));
|
3349 |
|
|
return FAILED;
|
3350 |
|
|
}
|
3351 |
|
|
|
3352 |
|
|
int gdth_eh_bus_reset(Scsi_Cmnd *scp)
|
3353 |
|
|
{
|
3354 |
|
|
TRACE2(("gdth_eh_bus_reset()\n"));
|
3355 |
|
|
return FAILED;
|
3356 |
|
|
}
|
3357 |
|
|
|
3358 |
|
|
int gdth_eh_host_reset(Scsi_Cmnd *scp)
|
3359 |
|
|
{
|
3360 |
|
|
TRACE2(("gdth_eh_host_reset()\n"));
|
3361 |
|
|
return FAILED;
|
3362 |
|
|
}
|
3363 |
|
|
#endif
|
3364 |
|
|
|
3365 |
|
|
#if LINUX_VERSION_CODE >= 0x010300
|
3366 |
|
|
int gdth_bios_param(Disk *disk,kdev_t dev,int *ip)
|
3367 |
|
|
#else
|
3368 |
|
|
int gdth_bios_param(Disk *disk,int dev,int *ip)
|
3369 |
|
|
#endif
|
3370 |
|
|
{
|
3371 |
|
|
unchar b, t;
|
3372 |
|
|
int hanum;
|
3373 |
|
|
gdth_ha_str *ha;
|
3374 |
|
|
int drv_hds, drv_secs;
|
3375 |
|
|
|
3376 |
|
|
hanum = NUMDATA(disk->device->host)->hanum;
|
3377 |
|
|
b = disk->device->channel;
|
3378 |
|
|
t = disk->device->id;
|
3379 |
|
|
TRACE2(("gdth_bios_param() ha %d bus %d target %d\n", hanum, b, t));
|
3380 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
3381 |
|
|
|
3382 |
|
|
if (ha->id[b][t].heads == 0) {
|
3383 |
|
|
/* raw device: evaluate mapping (sectors per head, heads per cylinder) */
|
3384 |
|
|
if (disk->capacity /HEADS/SECS <= MAXCYLS) {
|
3385 |
|
|
drv_hds = HEADS;
|
3386 |
|
|
drv_secs= SECS;
|
3387 |
|
|
} else if (disk->capacity /MEDHEADS/MEDSECS <= MAXCYLS) {
|
3388 |
|
|
drv_hds = MEDHEADS;
|
3389 |
|
|
drv_secs= MEDSECS;
|
3390 |
|
|
} else {
|
3391 |
|
|
drv_hds = BIGHEADS;
|
3392 |
|
|
drv_secs= BIGSECS;
|
3393 |
|
|
}
|
3394 |
|
|
ha->id[b][t].heads = drv_hds;
|
3395 |
|
|
ha->id[b][t].secs = drv_secs;
|
3396 |
|
|
TRACE2(("gdth_bios_param(): raw device -> params evaluated\n"));
|
3397 |
|
|
}
|
3398 |
|
|
|
3399 |
|
|
ip[0] = ha->id[b][t].heads;
|
3400 |
|
|
ip[1] = ha->id[b][t].secs;
|
3401 |
|
|
ip[2] = disk->capacity / ip[0] / ip[1];
|
3402 |
|
|
|
3403 |
|
|
TRACE2(("gdth_bios_param(): %d heads, %d secs, %d cyls\n",
|
3404 |
|
|
ip[0],ip[1],ip[2]));
|
3405 |
|
|
return 0;
|
3406 |
|
|
}
|
3407 |
|
|
|
3408 |
|
|
|
3409 |
|
|
static void internal_done(Scsi_Cmnd *scp)
|
3410 |
|
|
{
|
3411 |
|
|
scp->SCp.sent_command++;
|
3412 |
|
|
}
|
3413 |
|
|
|
3414 |
|
|
int gdth_command(Scsi_Cmnd *scp)
|
3415 |
|
|
{
|
3416 |
|
|
TRACE2(("gdth_command()\n"));
|
3417 |
|
|
|
3418 |
|
|
scp->SCp.sent_command = 0;
|
3419 |
|
|
gdth_queuecommand(scp,internal_done);
|
3420 |
|
|
|
3421 |
|
|
while (!scp->SCp.sent_command)
|
3422 |
|
|
barrier();
|
3423 |
|
|
return scp->result;
|
3424 |
|
|
}
|
3425 |
|
|
|
3426 |
|
|
|
3427 |
|
|
int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *))
|
3428 |
|
|
{
|
3429 |
|
|
int hanum;
|
3430 |
|
|
int priority;
|
3431 |
|
|
|
3432 |
|
|
TRACE(("gdth_queuecommand() cmd 0x%x id %d lun %d\n",
|
3433 |
|
|
scp->cmnd[0],scp->target,scp->lun));
|
3434 |
|
|
|
3435 |
|
|
scp->scsi_done = (void *)done;
|
3436 |
|
|
scp->SCp.have_data_in = 1;
|
3437 |
|
|
hanum = NUMDATA(scp->host)->hanum;
|
3438 |
|
|
#ifdef GDTH_STATISTICS
|
3439 |
|
|
++act_ios;
|
3440 |
|
|
#endif
|
3441 |
|
|
|
3442 |
|
|
priority = DEFAULT_PRI;
|
3443 |
|
|
#if LINUX_VERSION_CODE >= 0x010300
|
3444 |
|
|
if (scp->done == gdth_scsi_done)
|
3445 |
|
|
priority = scp->SCp.this_residual;
|
3446 |
|
|
#endif
|
3447 |
|
|
gdth_putq( hanum, scp, priority );
|
3448 |
|
|
gdth_next( hanum );
|
3449 |
|
|
return 0;
|
3450 |
|
|
}
|
3451 |
|
|
|
3452 |
|
|
/* flush routine */
|
3453 |
|
|
static void gdth_flush(int hanum)
|
3454 |
|
|
{
|
3455 |
|
|
int i, j;
|
3456 |
|
|
gdth_ha_str *ha;
|
3457 |
|
|
Scsi_Cmnd scp;
|
3458 |
|
|
Scsi_Device sdev;
|
3459 |
|
|
gdth_cmd_str gdtcmd;
|
3460 |
|
|
char cmnd[12];
|
3461 |
|
|
|
3462 |
|
|
TRACE2(("gdth_flush() hanum %d\n",hanum));
|
3463 |
|
|
ha = HADATA(gdth_ctr_tab[hanum]);
|
3464 |
|
|
memset(&sdev,0,sizeof(Scsi_Device));
|
3465 |
|
|
memset(&scp, 0,sizeof(Scsi_Cmnd));
|
3466 |
|
|
sdev.host = gdth_ctr_tab[hanum];
|
3467 |
|
|
sdev.id = sdev.host->this_id;
|
3468 |
|
|
scp.cmd_len = 12;
|
3469 |
|
|
scp.host = gdth_ctr_tab[hanum];
|
3470 |
|
|
scp.target = sdev.host->this_id;
|
3471 |
|
|
scp.device = &sdev;
|
3472 |
|
|
scp.use_sg = 0;
|
3473 |
|
|
|
3474 |
|
|
for (i = 0; i < MAXBUS; ++i) {
|
3475 |
|
|
for (j = 0; j < MAXID; ++j) {
|
3476 |
|
|
if (ha->id[i][j].type == CACHE_DTYP) {
|
3477 |
|
|
gdtcmd.BoardNode = LOCALBOARD;
|
3478 |
|
|
gdtcmd.Service = CACHESERVICE;
|
3479 |
|
|
gdtcmd.OpCode = GDT_FLUSH;
|
3480 |
|
|
gdtcmd.u.cache.DeviceNo = ha->id[i][j].hostdrive;
|
3481 |
|
|
gdtcmd.u.cache.BlockNo = 1;
|
3482 |
|
|
gdtcmd.u.cache.sg_canz = 0;
|
3483 |
|
|
TRACE2(("gdth_flush(): flush ha %d drive %d\n",
|
3484 |
|
|
hanum, ha->id[i][j].hostdrive));
|
3485 |
|
|
{
|
3486 |
|
|
struct semaphore sem = MUTEX_LOCKED;
|
3487 |
|
|
scp.request.rq_status = RQ_SCSI_BUSY;
|
3488 |
|
|
scp.request.sem = &sem;
|
3489 |
|
|
scp.SCp.this_residual = IOCTL_PRI;
|
3490 |
|
|
scsi_do_cmd(&scp, cmnd, &gdtcmd,
|
3491 |
|
|
sizeof(gdth_cmd_str), gdth_scsi_done,
|
3492 |
|
|
30*HZ, 1);
|
3493 |
|
|
down(&sem);
|
3494 |
|
|
}
|
3495 |
|
|
}
|
3496 |
|
|
}
|
3497 |
|
|
}
|
3498 |
|
|
}
|
3499 |
|
|
|
3500 |
|
|
/* shutdown routine */
|
3501 |
|
|
#if LINUX_VERSION_CODE >= 0x020100
|
3502 |
|
|
static int gdth_halt(struct notifier_block *nb, ulong event, void *buf)
|
3503 |
|
|
#else
|
3504 |
|
|
void gdth_halt(void)
|
3505 |
|
|
#endif
|
3506 |
|
|
{
|
3507 |
|
|
int hanum;
|
3508 |
|
|
Scsi_Cmnd scp;
|
3509 |
|
|
Scsi_Device sdev;
|
3510 |
|
|
gdth_cmd_str gdtcmd;
|
3511 |
|
|
char cmnd[12];
|
3512 |
|
|
|
3513 |
|
|
#if LINUX_VERSION_CODE >= 0x020100
|
3514 |
|
|
TRACE2(("gdth_halt() event %d\n",event));
|
3515 |
|
|
if (event != SYS_RESTART && event != SYS_HALT && event != SYS_POWER_OFF)
|
3516 |
|
|
return NOTIFY_DONE;
|
3517 |
|
|
#else
|
3518 |
|
|
TRACE2(("gdth_halt()\n"));
|
3519 |
|
|
if (halt_called) {
|
3520 |
|
|
TRACE2(("already called\n"));
|
3521 |
|
|
return;
|
3522 |
|
|
}
|
3523 |
|
|
halt_called = TRUE;
|
3524 |
|
|
#endif
|
3525 |
|
|
printk("GDT: Flushing all host drives .. ");
|
3526 |
|
|
for (hanum = 0; hanum < gdth_ctr_count; ++hanum) {
|
3527 |
|
|
gdth_flush(hanum);
|
3528 |
|
|
|
3529 |
|
|
/* controller reset */
|
3530 |
|
|
memset(&sdev,0,sizeof(Scsi_Device));
|
3531 |
|
|
memset(&scp, 0,sizeof(Scsi_Cmnd));
|
3532 |
|
|
sdev.host = gdth_ctr_tab[hanum];
|
3533 |
|
|
sdev.id = sdev.host->this_id;
|
3534 |
|
|
scp.cmd_len = 12;
|
3535 |
|
|
scp.host = gdth_ctr_tab[hanum];
|
3536 |
|
|
scp.target = sdev.host->this_id;
|
3537 |
|
|
scp.device = &sdev;
|
3538 |
|
|
scp.use_sg = 0;
|
3539 |
|
|
|
3540 |
|
|
gdtcmd.BoardNode = LOCALBOARD;
|
3541 |
|
|
gdtcmd.Service = CACHESERVICE;
|
3542 |
|
|
gdtcmd.OpCode = GDT_RESET;
|
3543 |
|
|
TRACE2(("gdth_halt(): reset controller %d\n", hanum));
|
3544 |
|
|
{
|
3545 |
|
|
struct semaphore sem = MUTEX_LOCKED;
|
3546 |
|
|
scp.request.rq_status = RQ_SCSI_BUSY;
|
3547 |
|
|
scp.request.sem = &sem;
|
3548 |
|
|
scp.SCp.this_residual = IOCTL_PRI;
|
3549 |
|
|
scsi_do_cmd(&scp, cmnd, &gdtcmd,
|
3550 |
|
|
sizeof(gdth_cmd_str), gdth_scsi_done,
|
3551 |
|
|
10*HZ, 1);
|
3552 |
|
|
down(&sem);
|
3553 |
|
|
}
|
3554 |
|
|
}
|
3555 |
|
|
printk("Done.\n");
|
3556 |
|
|
|
3557 |
|
|
#ifdef GDTH_STATISTICS
|
3558 |
|
|
del_timer(&gdth_timer);
|
3559 |
|
|
#endif
|
3560 |
|
|
#if LINUX_VERSION_CODE >= 0x020100
|
3561 |
|
|
unregister_reboot_notifier(&gdth_notifier);
|
3562 |
|
|
return NOTIFY_OK;
|
3563 |
|
|
#endif
|
3564 |
|
|
}
|
3565 |
|
|
|
3566 |
|
|
|
3567 |
|
|
/* called from init/main.c */
|
3568 |
|
|
__initfunc (void gdth_setup(char *str,int *ints))
|
3569 |
|
|
{
|
3570 |
|
|
static size_t setup_idx = 0;
|
3571 |
|
|
|
3572 |
|
|
TRACE2(("gdth_setup() str %s ints[0] %d ints[1] %d\n",
|
3573 |
|
|
str ? str:"NULL", ints[0],
|
3574 |
|
|
ints[0] ? ints[1]:0));
|
3575 |
|
|
|
3576 |
|
|
if (setup_idx >= MAXHA) {
|
3577 |
|
|
printk("GDT: gdth_setup() called too many times. Bad LILO params ?\n");
|
3578 |
|
|
return;
|
3579 |
|
|
}
|
3580 |
|
|
if (ints[0] != 1) {
|
3581 |
|
|
printk("GDT: Illegal command line !\n");
|
3582 |
|
|
printk("Usage: gdth=<IRQ>\n");
|
3583 |
|
|
printk("Where: <IRQ>: valid EISA controller IRQ (10,11,12,14)\n");
|
3584 |
|
|
printk(" or 0 to disable controller driver\n");
|
3585 |
|
|
return;
|
3586 |
|
|
}
|
3587 |
|
|
if (ints[1] == 10 || ints[1] == 11 || ints[1] == 12 || ints[1] == 14) {
|
3588 |
|
|
irqs[setup_idx++] = ints[1];
|
3589 |
|
|
irqs[setup_idx] = 0xff;
|
3590 |
|
|
return;
|
3591 |
|
|
}
|
3592 |
|
|
if (ints[1] == 0) {
|
3593 |
|
|
disable_gdth_scan = TRUE;
|
3594 |
|
|
return;
|
3595 |
|
|
}
|
3596 |
|
|
printk("GDT: Invalid IRQ (%d) specified\n",ints[1]);
|
3597 |
|
|
}
|
3598 |
|
|
|
3599 |
|
|
|
3600 |
|
|
#ifdef MODULE
|
3601 |
|
|
Scsi_Host_Template driver_template = GDTH;
|
3602 |
|
|
#include "scsi_module.c"
|
3603 |
|
|
#endif
|
3604 |
|
|
|