Bug Summary

File:obj-scan-build/../linux/src/drivers/scsi/eata_pio.c
Location:line 227, column 6
Description:Value stored to 'eata_stat' is never read

Annotated Source Code

1/************************************************************
2 * *
3 * Linux EATA SCSI PIO driver *
4 * *
5 * based on the CAM document CAM/89-004 rev. 2.0c, *
6 * DPT's driver kit, some internal documents and source, *
7 * and several other Linux scsi drivers and kernel docs. *
8 * *
9 * The driver currently: *
10 * -supports all EATA-PIO boards *
11 * -only supports DASD devices *
12 * *
13 * (c)1993-96 Michael Neuffer, Alfred Arnold *
14 * neuffer@goofy.zdv.uni-mainz.de *
15 * a.arnold@kfa-juelich.de *
16 * *
17 * This program is free software; you can redistribute it *
18 * and/or modify it under the terms of the GNU General *
19 * Public License as published by the Free Software *
20 * Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
22 * *
23 * This program is distributed in the hope that it will be *
24 * useful, but WITHOUT ANY WARRANTY; without even the *
25 * implied warranty of MERCHANTABILITY or FITNESS FOR A *
26 * PARTICULAR PURPOSE. See the GNU General Public License *
27 * for more details. *
28 * *
29 * You should have received a copy of the GNU General *
30 * Public License along with this kernel; if not, write to *
31 * the Free Software Foundation, Inc., 675 Mass Ave, *
32 * Cambridge, MA 02139, USA. *
33 * *
34 ************************************************************
35 * last change: 96/07/16 OS: Linux 2.0.8 *
36 ************************************************************/
37
38/* Look in eata_pio.h for configuration information */
39
40#include <linux/module.h>
41
42#include <linux/kernel.h>
43#include <linux/sched.h>
44#include <linux/string.h>
45#include <linux/ioport.h>
46#include <linux/malloc.h>
47#include <linux/in.h>
48#include <linux/bios32.h>
49#include <linux/pci.h>
50#include <linux/proc_fs.h>
51#include <asm/io.h>
52#include "eata_pio.h"
53#include "eata_dma_proc.h"
54#include "scsi.h"
55#include "sd.h"
56
57#include <linux/stat.h>
58#include <linux/config.h> /* for CONFIG_PCI */
59
60struct proc_dir_entry proc_scsi_eata_pio = {
61 PROC_SCSI_EATA_PIO, 9, "eata_pio",
62 S_IFDIR0040000 | S_IRUGO(00400|00040|00004) | S_IXUGO(00100|00010|00001), 2
63};
64
65static uint ISAbases[MAXISA4] =
66{0x1F0, 0x170, 0x330, 0x230};
67static uint ISAirqs[MAXISA4] =
68{14,12,15,11};
69static unchar EISAbases[] =
70{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
71static uint registered_HBAs = 0;
72static struct Scsi_Host *last_HBA = NULL((void *) 0);
73static struct Scsi_Host *first_HBA = NULL((void *) 0);
74static unchar reg_IRQ[] =
75{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
76static unchar reg_IRQL[] =
77{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
78
79static ulong int_counter = 0;
80static ulong queue_counter = 0;
81
82#include "eata_pio_proc.c"
83
84#ifdef MODULE
85int eata_pio_release((void *) 0)(struct Scsi_Host *sh)
86{
87 if (sh->irq && reg_IRQ[sh->irq] == 1) free_irq(sh->irq, NULL((void *) 0));
88 else reg_IRQ[sh->irq]--;
89 if (SD(sh)((hostdata *)&(sh->hostdata))->channel == 0) {
90 if (sh->io_port && sh->n_io_port)
91 release_region(sh->io_port, sh->n_io_port);
92 }
93 return(TRUE1);
94}
95#endif
96
97void IncStat(Scsi_Pointer *SCp, uint Increment)
98{
99 SCp->ptr+=Increment;
100 if ((SCp->this_residual-=Increment)==0)
101 {
102 if ((--SCp->buffers_residual)==0) SCp->Status=FALSE0;
103 else
104 {
105 SCp->buffer++;
106 SCp->ptr=SCp->buffer->address;
107 SCp->this_residual=SCp->buffer->length;
108 }
109 }
110}
111
112void eata_pio_int_handler(int irq, void *dev_id, struct pt_regs * regs)
113{
114 uint eata_stat = 0xfffff;
115 Scsi_Cmnd *cmd;
116 hostdata *hd;
117 struct eata_ccb *cp;
118 uint base;
119 ulong flags;
120 uint x,z;
121 struct Scsi_Host *sh;
122 ushort zwickel=0;
123 unchar stat,odd;
124
125 save_flags(flags)__asm__ __volatile__("pushf ; pop %0" : "=r" (flags): :"memory"
)
;
126 cli()__asm__ __volatile__ ("cli": : :"memory");
127
128 for (x = 1, sh = first_HBA; x <= registered_HBAs; x++, sh = SD(sh)((hostdata *)&(sh->hostdata))->prev) {
129 if (sh->irq != irq)
130 continue;
131 if (inb((uint)sh->base + HA_RSTATUS)((__builtin_constant_p(((uint)sh->base + 0x07)) &&
((uint)sh->base + 0x07) < 256) ? __inbc((uint)sh->base
+ 0x07) : __inb((uint)sh->base + 0x07))
& HA_SBUSY0x80)
132 continue;
133
134 int_counter++;
135
136 hd=SD(sh)((hostdata *)&(sh->hostdata));
137
138 cp = &hd->ccb[0];
139 cmd = cp->cmd;
140 base = (uint) cmd->host->base;
141
142 do
143 {
144 stat=inb(base+HA_RSTATUS)((__builtin_constant_p((base+0x07)) && (base+0x07) <
256) ? __inbc(base+0x07) : __inb(base+0x07))
;
145 if (stat&HA_SDRQ0x08)
146 if (cp->DataIn)
147 {
148 z=256; odd=FALSE0;
149 while ((cmd->SCp.Status)&&((z>0)||(odd)))
150 {
151 if (odd)
152 {
153 *(cmd->SCp.ptr)=zwickel>>8;
154 IncStat(&cmd->SCp,1);
155 odd=FALSE0;
156 }
157 x=min(z,cmd->SCp.this_residual/2)((z<cmd->SCp.this_residual/2)?(z):(cmd->SCp.this_residual
/2))
;
158 insw(base+HA_RDATA0x00,cmd->SCp.ptr,x);
159 z-=x;
160 IncStat(&cmd->SCp,2*x);
161 if ((z>0)&&(cmd->SCp.this_residual==1))
162 {
163 zwickel=inw(base+HA_RDATA)((__builtin_constant_p((base+0x00)) && (base+0x00) <
256) ? __inwc(base+0x00) : __inw(base+0x00))
;
164 *(cmd->SCp.ptr)=zwickel&0xff;
165 IncStat(&cmd->SCp,1); z--;
166 odd=TRUE1;
167 }
168 }
169 while (z>0) {
170 zwickel=inw(base+HA_RDATA)((__builtin_constant_p((base+0x00)) && (base+0x00) <
256) ? __inwc(base+0x00) : __inw(base+0x00))
;
171 z--;
172 }
173 }
174 else /* cp->DataOut */
175 {
176 odd=FALSE0; z=256;
177 while ((cmd->SCp.Status)&&((z>0)||(odd)))
178 {
179 if (odd)
180 {
181 zwickel+=*(cmd->SCp.ptr)<<8;
182 IncStat(&cmd->SCp,1);
183 outw(zwickel,base+HA_RDATA)((__builtin_constant_p((base+0x00)) && (base+0x00) <
256) ? __outwc((zwickel),(base+0x00)) : __outw((zwickel),(base
+0x00)))
;
184 z--;
185 odd=FALSE0;
186 }
187 x=min(z,cmd->SCp.this_residual/2)((z<cmd->SCp.this_residual/2)?(z):(cmd->SCp.this_residual
/2))
;
188 outsw(base+HA_RDATA0x00,cmd->SCp.ptr,x);
189 z-=x;
190 IncStat(&cmd->SCp,2*x);
191 if ((z>0)&&(cmd->SCp.this_residual==1))
192 {
193 zwickel=*(cmd->SCp.ptr);
194 zwickel&=0xff;
195 IncStat(&cmd->SCp,1);
196 odd=TRUE1;
197 }
198 }
199 while (z>0||odd) {
200 outw(zwickel,base+HA_RDATA)((__builtin_constant_p((base+0x00)) && (base+0x00) <
256) ? __outwc((zwickel),(base+0x00)) : __outw((zwickel),(base
+0x00)))
;
201 z--;
202 odd=FALSE0;
203 }
204 }
205 }
206 while ((stat&HA_SDRQ0x08)||((stat&HA_SMORE0x02)&&hd->moresupport));
207
208 /* terminate handler if HBA goes busy again, i.e. transfers
209 * more data */
210
211 if (stat&HA_SBUSY0x80) break;
212
213 /* OK, this is quite stupid, but I haven't found any correct
214 * way to get HBA&SCSI status so far */
215
216 if (!(inb(base+HA_RSTATUS)((__builtin_constant_p((base+0x07)) && (base+0x07) <
256) ? __inbc(base+0x07) : __inb(base+0x07))
&HA_SERROR0x01))
217 {
218 cmd->result=(DID_OK0x00<<16);
219 hd->devflags|=(1<<cp->cp_id);
220 }
221 else if (hd->devflags&1<<cp->cp_id)
222 cmd->result=(DID_OK0x00<<16)+0x02;
223 else cmd->result=(DID_NO_CONNECT0x01<<16);
224
225 if (cp->status == LOCKED8) {
226 cp->status = FREE0;
227 eata_stat = inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
;
Value stored to 'eata_stat' is never read
228 printk(KERN_NOTICE"<5>" "eata_pio: int_handler, freeing locked "
229 "queueslot\n");
230 DBG(DBG_INTR&&DBG_DELAY,DELAY(1))if ((0&&0)) {{ ulong flags, i; __asm__ __volatile__("pushf ; pop %0"
: "=r" (flags): :"memory"); __asm__ __volatile__ ("sti": : :
"memory"); i = jiffies + (1 * 100); while (jiffies < i); __asm__
__volatile__("push %0 ; popf": :"g" (flags):"memory"); };}
;
231 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
232 return;
233 }
234
235#if DBG_INTR20
236 if (stat != 0x50)
237 printk(KERN_DEBUG"<7>" "stat: %#.2x, result: %#.8x\n", stat,
238 cmd->result);
239 DBG(DBG_INTR&&DBG_DELAY,DELAY(1))if ((0&&0)) {{ ulong flags, i; __asm__ __volatile__("pushf ; pop %0"
: "=r" (flags): :"memory"); __asm__ __volatile__ ("sti": : :
"memory"); i = jiffies + (1 * 100); while (jiffies < i); __asm__
__volatile__("push %0 ; popf": :"g" (flags):"memory"); };}
;
240#endif
241
242 cp->status = FREE0; /* now we can release the slot */
243
244 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
245 cmd->scsi_done(cmd);
246 save_flags(flags)__asm__ __volatile__("pushf ; pop %0" : "=r" (flags): :"memory"
)
;
247 cli()__asm__ __volatile__ ("cli": : :"memory");
248 }
249 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
250
251 return;
252}
253
254inlineinline __attribute__((always_inline)) uint eata_pio_send_command(uint base, unchar command)
255{
256 uint loop = HZ100/2;
257
258 while (inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SBUSY0x80)
259 if (--loop == 0)
260 return(TRUE1);
261
262 /* Enable interrupts for HBA. It is not the best way to do it at this
263 * place, but I hope that it doesn't interfere with the IDE driver
264 * initialization this way */
265
266 outb(HA_CTRL_8HEADS,base+HA_CTRLREG)((__builtin_constant_p((base+0x206)) && (base+0x206) <
256) ? __outbc((0x08),(base+0x206)) : __outb((0x08),(base+0x206
)))
;
267
268 outb(command, base + HA_WCOMMAND)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __outbc((command),(base + 0x07)) : __outb((command
),(base + 0x07)))
;
269 return(FALSE0);
270}
271
272int eata_pio_queue(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
273{
274 uint x, y;
275 long flags;
276 uint base;
277
278 hostdata *hd;
279 struct Scsi_Host *sh;
280 struct eata_ccb *cp;
281
282 save_flags(flags)__asm__ __volatile__("pushf ; pop %0" : "=r" (flags): :"memory"
)
;
283 cli()__asm__ __volatile__ ("cli": : :"memory");
284
285 queue_counter++;
286
287 hd = HD(cmd)((hostdata *)&(cmd->host->hostdata));
288 sh = cmd->host;
289 base = (uint) sh->base;
290
291 /* use only slot 0, as 2001 can handle only one cmd at a time */
292
293 y = x = 0;
294
295 if (hd->ccb[y].status!=FREE0) {
296
297 DBG(DBG_QUEUE, printk(KERN_EMERG "can_queue %d, x %d, y %d\n",if ((0)) {printk("<0>" "can_queue %d, x %d, y %d\n", sh
->can_queue,x,y);}
298 sh->can_queue,x,y))if ((0)) {printk("<0>" "can_queue %d, x %d, y %d\n", sh
->can_queue,x,y);}
;
299#if DEBUG_EATA1
300 panic(KERN_EMERG"<0>" "eata_pio: run out of queue slots cmdno:%ld "
301 "intrno: %ld\n", queue_counter, int_counter);
302#else
303 panic(KERN_EMERG"<0>" "eata_pio: run out of queue slots....\n");
304#endif
305 }
306
307 cp = &hd->ccb[y];
308
309 memset(cp, 0, sizeof(struct eata_ccb))(__builtin_constant_p(0) ? (__builtin_constant_p((sizeof(struct
eata_ccb))) ? __constant_c_and_count_memset(((cp)),((0x01010101UL
*(unsigned char)(0))),((sizeof(struct eata_ccb)))) : __constant_c_memset
(((cp)),((0x01010101UL*(unsigned char)(0))),((sizeof(struct eata_ccb
))))) : (__builtin_constant_p((sizeof(struct eata_ccb))) ? __memset_generic
((((cp))),(((0))),(((sizeof(struct eata_ccb))))) : __memset_generic
(((cp)),((0)),((sizeof(struct eata_ccb))))))
;
310 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer))(__builtin_constant_p(0) ? (__builtin_constant_p((sizeof(cmd->
sense_buffer))) ? __constant_c_and_count_memset(((cmd->sense_buffer
)),((0x01010101UL*(unsigned char)(0))),((sizeof(cmd->sense_buffer
)))) : __constant_c_memset(((cmd->sense_buffer)),((0x01010101UL
*(unsigned char)(0))),((sizeof(cmd->sense_buffer))))) : (__builtin_constant_p
((sizeof(cmd->sense_buffer))) ? __memset_generic((((cmd->
sense_buffer))),(((0))),(((sizeof(cmd->sense_buffer))))) :
__memset_generic(((cmd->sense_buffer)),((0)),((sizeof(cmd
->sense_buffer))))))
;
311
312 cp->status = USED1; /* claim free slot */
313
314 DBG(DBG_QUEUE, printk(KERN_DEBUG "eata_pio_queue pid %ld, target: %x, lun:"if ((0)) {printk("<7>" "eata_pio_queue pid %ld, target: %x, lun:"
" %x, y %d\n", cmd->pid, cmd->target, cmd->lun, y);
}
315 " %x, y %d\n", cmd->pid, cmd->target, cmd->lun, y))if ((0)) {printk("<7>" "eata_pio_queue pid %ld, target: %x, lun:"
" %x, y %d\n", cmd->pid, cmd->target, cmd->lun, y);
}
;
316 DBG(DBG_QUEUE && DBG_DELAY, DELAY(1))if ((0 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
317
318 cmd->scsi_done = (void *)done;
319
320 switch (cmd->cmnd[0]) {
321 case CHANGE_DEFINITION0x40: case COMPARE0x39: case COPY0x18:
322 case COPY_VERIFY0x3a: case LOG_SELECT0x4c: case MODE_SELECT0x15:
323 case MODE_SELECT_100x55: case SEND_DIAGNOSTIC0x1d: case WRITE_BUFFER0x3b:
324 case FORMAT_UNIT0x04: case REASSIGN_BLOCKS0x07: case RESERVE0x16:
325 case SEARCH_EQUAL0x31: case SEARCH_HIGH0x30: case SEARCH_LOW0x32:
326 case WRITE_60x0a: case WRITE_100x2a: case WRITE_VERIFY0x2e:
327 case UPDATE_BLOCK0x3d: case WRITE_LONG0x3f: case WRITE_SAME0x41:
328 case SEARCH_HIGH_120xb0: case SEARCH_EQUAL_120xb1: case SEARCH_LOW_120xb2:
329 case WRITE_120xaa: case WRITE_VERIFY_120xae: case SET_WINDOW0x24:
330 case MEDIUM_SCAN0x38: case SEND_VOLUME_TAG0xb6:
331 case 0xea: /* alternate number for WRITE LONG */
332 cp->DataOut = TRUE1; /* Output mode */
333 break;
334 case TEST_UNIT_READY0x00:
335 default:
336 cp->DataIn = TRUE1; /* Input mode */
337 }
338
339 cp->Interpret = (cmd->target == hd->hostid);
340 cp->cp_datalen = htonl((ulong)cmd->request_bufflen);
341 cp->Auto_Req_Sen = FALSE0;
342 cp->cp_reqDMA = htonl(0);
343 cp->reqlen = 0;
344
345 cp->cp_id = cmd->target;
346 cp->cp_lun = cmd->lun;
347 cp->cp_dispri = FALSE0;
348 cp->cp_identify = TRUE1;
349 memcpy(cp->cp_cdb, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd))(__builtin_constant_p(scsi_command_size[((*cmd->cmnd) >>
5) & 7]) ? __constant_memcpy((cp->cp_cdb),(cmd->cmnd
),(scsi_command_size[((*cmd->cmnd) >> 5) & 7])) :
__memcpy((cp->cp_cdb),(cmd->cmnd),(scsi_command_size[(
(*cmd->cmnd) >> 5) & 7])))
;
350
351 cp->cp_statDMA = htonl(0);
352
353 cp->cp_viraddr = cp;
354 cp->cmd = cmd;
355 cmd->host_scribble = (char *)&hd->ccb[y];
356
357 if (cmd->use_sg == 0)
358 {
359 cmd->SCp.buffers_residual=1;
360 cmd->SCp.ptr = cmd->request_buffer;
361 cmd->SCp.this_residual = cmd->request_bufflen;
362 cmd->SCp.buffer = NULL((void *) 0);
363 } else {
364 cmd->SCp.buffer = cmd->request_buffer;
365 cmd->SCp.buffers_residual = cmd->use_sg;
366 cmd->SCp.ptr = cmd->SCp.buffer->address;
367 cmd->SCp.this_residual = cmd->SCp.buffer->length;
368 }
369 cmd->SCp.Status = (cmd->SCp.this_residual != 0); /* TRUE as long as bytes
370 * are to transfer */
371
372 if (eata_pio_send_command(base, EATA_CMD_PIO_SEND_CP0xf2))
373 {
374 cmd->result = DID_BUS_BUSY0x02 << 16;
375 printk(KERN_NOTICE"<5>" "eata_pio_queue target %d, pid %ld, HBA busy, "
376 "returning DID_BUS_BUSY, done.\n", cmd->target, cmd->pid);
377 done(cmd);
378 cp->status = FREE0;
379 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
380 return (0);
381 }
382 while (!(inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SDRQ0x08));
383 outsw(base + HA_RDATA0x00, cp, hd->cplen);
384 outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __outbc((0xf4),(base + 0x07)) : __outb((0xf4),(
base + 0x07)))
;
385 for (x = 0; x < hd->cppadlen; x++) outw(0, base + HA_RDATA)((__builtin_constant_p((base + 0x00)) && (base + 0x00
) < 256) ? __outwc((0),(base + 0x00)) : __outw((0),(base +
0x00)))
;
386
387 DBG(DBG_QUEUE,printk(KERN_DEBUG "Queued base %#.4lx pid: %ld target: %x "if ((0)) {printk("<7>" "Queued base %#.4lx pid: %ld target: %x "
"lun: %x slot %d irq %d\n", (long)sh->base, cmd->pid, cmd
->target, cmd->lun, y, sh->irq);}
388 "lun: %x slot %d irq %d\n", (long)sh->base, cmd->pid,if ((0)) {printk("<7>" "Queued base %#.4lx pid: %ld target: %x "
"lun: %x slot %d irq %d\n", (long)sh->base, cmd->pid, cmd
->target, cmd->lun, y, sh->irq);}
389 cmd->target, cmd->lun, y, sh->irq))if ((0)) {printk("<7>" "Queued base %#.4lx pid: %ld target: %x "
"lun: %x slot %d irq %d\n", (long)sh->base, cmd->pid, cmd
->target, cmd->lun, y, sh->irq);}
;
390 DBG(DBG_QUEUE && DBG_DELAY, DELAY(1))if ((0 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
391
392 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
393 return (0);
394}
395
396int eata_pio_abort(Scsi_Cmnd * cmd)
397{
398 ulong flags;
399 uint loop = HZ100;
400
401 save_flags(flags)__asm__ __volatile__("pushf ; pop %0" : "=r" (flags): :"memory"
)
;
402 cli()__asm__ __volatile__ ("cli": : :"memory");
403
404 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_abort called pid: %ld "if ((1)) {printk("<4>" "eata_pio_abort called pid: %ld "
"target: %x lun: %x reason %x\n", cmd->pid, cmd->target
, cmd->lun, cmd->abort_reason);}
405 "target: %x lun: %x reason %x\n", cmd->pid,if ((1)) {printk("<4>" "eata_pio_abort called pid: %ld "
"target: %x lun: %x reason %x\n", cmd->pid, cmd->target
, cmd->lun, cmd->abort_reason);}
406 cmd->target, cmd->lun, cmd->abort_reason))if ((1)) {printk("<4>" "eata_pio_abort called pid: %ld "
"target: %x lun: %x reason %x\n", cmd->pid, cmd->target
, cmd->lun, cmd->abort_reason);}
;
407 DBG(DBG_ABNORM && DBG_DELAY, DELAY(1))if ((1 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
408
409
410 while (inb((uint)(cmd->host->base) + HA_RAUXSTAT)((__builtin_constant_p(((uint)(cmd->host->base) + 0x08)
) && ((uint)(cmd->host->base) + 0x08) < 256)
? __inbc((uint)(cmd->host->base) + 0x08) : __inb((uint
)(cmd->host->base) + 0x08))
& HA_ABUSY0x01)
411 if (--loop == 0) {
412 printk(KERN_WARNING"<4>" "eata_pio: abort, timeout error.\n");
413 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
414 DBG(DBG_ABNORM && DBG_DELAY, DELAY(1))if ((1 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
415 return (SCSI_ABORT_ERROR5);
416 }
417 if (CD(cmd)((struct eata_ccb *)(cmd->host_scribble))->status == FREE0) {
418 DBG(DBG_ABNORM, printk(KERN_WARNING "Returning: SCSI_ABORT_NOT_RUNNING\n"))if ((1)) {printk("<4>" "Returning: SCSI_ABORT_NOT_RUNNING\n"
);}
;
419 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
420 return (SCSI_ABORT_NOT_RUNNING4);
421 }
422 if (CD(cmd)((struct eata_ccb *)(cmd->host_scribble))->status == USED1) {
423 DBG(DBG_ABNORM, printk(KERN_WARNING "Returning: SCSI_ABORT_BUSY\n"))if ((1)) {printk("<4>" "Returning: SCSI_ABORT_BUSY\n");
}
;
424 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
425 return (SCSI_ABORT_BUSY3); /* SNOOZE */
426 }
427 if (CD(cmd)((struct eata_ccb *)(cmd->host_scribble))->status == RESET4) {
428 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
429 printk(KERN_WARNING"<4>" "eata_pio: abort, command reset error.\n");
430 DBG(DBG_ABNORM && DBG_DELAY, DELAY(1))if ((1 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
431 return (SCSI_ABORT_ERROR5);
432 }
433 if (CD(cmd)((struct eata_ccb *)(cmd->host_scribble))->status == LOCKED8) {
434 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
435 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio: abort, queue slot "if ((1)) {printk("<4>" "eata_pio: abort, queue slot " "locked.\n"
);}
436 "locked.\n"))if ((1)) {printk("<4>" "eata_pio: abort, queue slot " "locked.\n"
);}
;
437 DBG(DBG_ABNORM && DBG_DELAY, DELAY(1))if ((1 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
438 return (SCSI_ABORT_NOT_RUNNING4);
439 }
440 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
441 panic("eata_pio: abort: invalid slot status\n");
442}
443
444int eata_pio_reset(Scsi_Cmnd * cmd, unsigned int dummy)
445{
446 uint x, time, limit = 0;
447 ulong flags;
448 unchar success = FALSE0;
449 Scsi_Cmnd *sp;
450
451 save_flags(flags)__asm__ __volatile__("pushf ; pop %0" : "=r" (flags): :"memory"
)
;
452 cli()__asm__ __volatile__ ("cli": : :"memory");
453 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset called pid:%ld target:"if ((1)) {printk("<4>" "eata_pio_reset called pid:%ld target:"
" %x lun: %x reason %x\n", cmd->pid, cmd->target, cmd->
lun, cmd->abort_reason);}
454 " %x lun: %x reason %x\n", cmd->pid, cmd->target,if ((1)) {printk("<4>" "eata_pio_reset called pid:%ld target:"
" %x lun: %x reason %x\n", cmd->pid, cmd->target, cmd->
lun, cmd->abort_reason);}
455 cmd->lun, cmd->abort_reason))if ((1)) {printk("<4>" "eata_pio_reset called pid:%ld target:"
" %x lun: %x reason %x\n", cmd->pid, cmd->target, cmd->
lun, cmd->abort_reason);}
;
456
457 if (HD(cmd)((hostdata *)&(cmd->host->hostdata))->state == RESET4) {
458 printk(KERN_WARNING"<4>" "eata_pio_reset: exit, already in reset.\n");
459 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
460 DBG(DBG_ABNORM && DBG_DELAY, DELAY(1))if ((1 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
461 return (SCSI_RESET_ERROR6);
462 }
463
464 /* force all slots to be free */
465
466 for (x = 0; x < cmd->host->can_queue; x++) {
467
468 if (HD(cmd)((hostdata *)&(cmd->host->hostdata))->ccb[x].status == FREE0)
469 continue;
470
471 sp = HD(cmd)((hostdata *)&(cmd->host->hostdata))->ccb[x].cmd;
472 HD(cmd)((hostdata *)&(cmd->host->hostdata))->ccb[x].status = RESET4;
473 printk(KERN_WARNING"<4>" "eata_pio_reset: slot %d in reset, pid %ld.\n", x,
474 sp->pid);
475 DBG(DBG_ABNORM && DBG_DELAY, DELAY(1))if ((1 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
476
477 if (sp == NULL((void *) 0))
478 panic("eata_pio_reset: slot %d, sp==NULL.\n", x);
479 DBG(DBG_ABNORM && DBG_DELAY, DELAY(1))if ((1 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
480 }
481
482 /* hard reset the HBA */
483 outb(EATA_CMD_RESET, (uint) cmd->host->base+HA_WCOMMAND)((__builtin_constant_p(((uint) cmd->host->base+0x07)) &&
((uint) cmd->host->base+0x07) < 256) ? __outbc((0xf9
),((uint) cmd->host->base+0x07)) : __outb((0xf9),((uint
) cmd->host->base+0x07)))
;
484
485 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: board reset done.\n"))if ((1)) {printk("<4>" "eata_pio_reset: board reset done.\n"
);}
;
486 HD(cmd)((hostdata *)&(cmd->host->hostdata))->state = RESET4;
487
488 time = jiffies;
489 while (jiffies < (time + (3 * HZ100)) && limit++ < 10000000);
490
491 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: interrupts disabled, "if ((1)) {printk("<4>" "eata_pio_reset: interrupts disabled, "
"loops %d.\n", limit);}
492 "loops %d.\n", limit))if ((1)) {printk("<4>" "eata_pio_reset: interrupts disabled, "
"loops %d.\n", limit);}
;
493 DBG(DBG_ABNORM && DBG_DELAY, DELAY(1))if ((1 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
494
495 for (x = 0; x < cmd->host->can_queue; x++) {
496
497 /* Skip slots already set free by interrupt */
498 if (HD(cmd)((hostdata *)&(cmd->host->hostdata))->ccb[x].status != RESET4)
499 continue;
500
501 sp = HD(cmd)((hostdata *)&(cmd->host->hostdata))->ccb[x].cmd;
502 sp->result = DID_RESET0x08 << 16;
503
504 /* This mailbox is terminated */
505 printk(KERN_WARNING"<4>" "eata_pio_reset: reset ccb %d.\n",x);
506 HD(cmd)((hostdata *)&(cmd->host->hostdata))->ccb[x].status = FREE0;
507
508 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
509 sp->scsi_done(sp);
510 cli()__asm__ __volatile__ ("cli": : :"memory");
511 }
512
513 HD(cmd)((hostdata *)&(cmd->host->hostdata))->state = FALSE0;
514 restore_flags(flags)__asm__ __volatile__("push %0 ; popf": :"g" (flags):"memory");
515
516 if (success) { /* hmmm... */
517 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: exit, success.\n"))if ((1)) {printk("<4>" "eata_pio_reset: exit, success.\n"
);}
;
518 DBG(DBG_ABNORM && DBG_DELAY, DELAY(1))if ((1 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
519 return (SCSI_RESET_SUCCESS2);
520 } else {
521 DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: exit, wakeup.\n"))if ((1)) {printk("<4>" "eata_pio_reset: exit, wakeup.\n"
);}
;
522 DBG(DBG_ABNORM && DBG_DELAY, DELAY(1))if ((1 && 0)) {{ ulong flags, i; __asm__ __volatile__
("pushf ; pop %0" : "=r" (flags): :"memory"); __asm__ __volatile__
("sti": : :"memory"); i = jiffies + (1 * 100); while (jiffies
< i); __asm__ __volatile__("push %0 ; popf": :"g" (flags)
:"memory"); };}
;
523 return (SCSI_RESET_PUNT1);
524 }
525}
526
527char * get_pio_board_data(ulong base, uint irq, uint id, ulong cplen, ushort cppadlen)
528{
529 struct eata_ccb cp;
530 static char buff[256];
531 int z;
532
533 memset(&cp, 0, sizeof(struct eata_ccb))(__builtin_constant_p(0) ? (__builtin_constant_p((sizeof(struct
eata_ccb))) ? __constant_c_and_count_memset(((&cp)),((0x01010101UL
*(unsigned char)(0))),((sizeof(struct eata_ccb)))) : __constant_c_memset
(((&cp)),((0x01010101UL*(unsigned char)(0))),((sizeof(struct
eata_ccb))))) : (__builtin_constant_p((sizeof(struct eata_ccb
))) ? __memset_generic((((&cp))),(((0))),(((sizeof(struct
eata_ccb))))) : __memset_generic(((&cp)),((0)),((sizeof(
struct eata_ccb))))))
;
534 memset(buff, 0, sizeof(buff))(__builtin_constant_p(0) ? (__builtin_constant_p((sizeof(buff
))) ? __constant_c_and_count_memset(((buff)),((0x01010101UL*(
unsigned char)(0))),((sizeof(buff)))) : __constant_c_memset((
(buff)),((0x01010101UL*(unsigned char)(0))),((sizeof(buff))))
) : (__builtin_constant_p((sizeof(buff))) ? __memset_generic(
(((buff))),(((0))),(((sizeof(buff))))) : __memset_generic(((buff
)),((0)),((sizeof(buff))))))
;
535
536 cp.DataIn = TRUE1;
537 cp.Interpret = TRUE1; /* Interpret command */
538
539 cp.cp_datalen = htonl(254);
540 cp.cp_dataDMA = htonl(0);
541
542 cp.cp_id = id;
543 cp.cp_lun = 0;
544
545 cp.cp_cdb[0] = INQUIRY0x12;
546 cp.cp_cdb[1] = 0;
547 cp.cp_cdb[2] = 0;
548 cp.cp_cdb[3] = 0;
549 cp.cp_cdb[4] = 254;
550 cp.cp_cdb[5] = 0;
551
552 if (eata_pio_send_command((uint) base, EATA_CMD_PIO_SEND_CP0xf2))
553 return (NULL((void *) 0));
554 while (!(inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SDRQ0x08));
555 outsw(base + HA_RDATA0x00, &cp, cplen);
556 outb(EATA_CMD_PIO_TRUNC, base + HA_WCOMMAND)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __outbc((0xf4),(base + 0x07)) : __outb((0xf4),(
base + 0x07)))
;
557 for (z = 0; z < cppadlen; z++) outw(0, base + HA_RDATA)((__builtin_constant_p((base + 0x00)) && (base + 0x00
) < 256) ? __outwc((0),(base + 0x00)) : __outw((0),(base +
0x00)))
;
558
559 while (inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SBUSY0x80);
560 if (inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SERROR0x01)
561 return (NULL((void *) 0));
562 else if (!(inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SDRQ0x08))
563 return (NULL((void *) 0));
564 else
565 {
566 insw(base+HA_RDATA0x00, &buff, 127);
567 while (inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
&HA_SDRQ0x08) inw(base + HA_RDATA)((__builtin_constant_p((base + 0x00)) && (base + 0x00
) < 256) ? __inwc(base + 0x00) : __inw(base + 0x00))
;
568 return (buff);
569 }
570}
571
572int get_pio_conf_PIO(u32 base, struct get_conf *buf)
573{
574 ulong loop = HZ100/2;
575 int z;
576 ushort *p;
577
578 if(check_region(base, 9))
579 return (FALSE0);
580
581 memset(buf, 0, sizeof(struct get_conf))(__builtin_constant_p(0) ? (__builtin_constant_p((sizeof(struct
get_conf))) ? __constant_c_and_count_memset(((buf)),((0x01010101UL
*(unsigned char)(0))),((sizeof(struct get_conf)))) : __constant_c_memset
(((buf)),((0x01010101UL*(unsigned char)(0))),((sizeof(struct get_conf
))))) : (__builtin_constant_p((sizeof(struct get_conf))) ? __memset_generic
((((buf))),(((0))),(((sizeof(struct get_conf))))) : __memset_generic
(((buf)),((0)),((sizeof(struct get_conf))))))
;
582
583 while (inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SBUSY0x80)
584 if (--loop == 0)
585 return (FALSE0);
586
587 DBG(DBG_PIO && DBG_PROBE,if ((0 && 0)) {printk("<7>" "Issuing PIO READ CONFIG to HBA at %#x\n"
, base);}
588 printk(KERN_DEBUG "Issuing PIO READ CONFIG to HBA at %#x\n", base))if ((0 && 0)) {printk("<7>" "Issuing PIO READ CONFIG to HBA at %#x\n"
, base);}
;
589 eata_pio_send_command(base, EATA_CMD_PIO_READ_CONFIG0xf0);
590
591 loop = HZ100/2;
592 for (p = (ushort *) buf;
593 (long)p <= ((long)buf + (sizeof(struct get_conf) / 2)); p++) {
594 while (!(inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SDRQ0x08))
595 if (--loop == 0)
596 return (FALSE0);
597
598 loop = HZ100/2;
599 *p = inw(base + HA_RDATA)((__builtin_constant_p((base + 0x00)) && (base + 0x00
) < 256) ? __inwc(base + 0x00) : __inw(base + 0x00))
;
600 }
601 if (!(inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SERROR0x01)) { /* Error ? */
602 if (htonl(EATA_SIGNATURE0x45415441) == buf->signature) {
603 DBG(DBG_PIO&&DBG_PROBE, printk(KERN_NOTICE "EATA Controller found "if ((0&&0)) {printk("<5>" "EATA Controller found "
"at %#4x EATA Level: %x\n", base, (uint) (buf->version));
}
604 "at %#4x EATA Level: %x\n", base,if ((0&&0)) {printk("<5>" "EATA Controller found "
"at %#4x EATA Level: %x\n", base, (uint) (buf->version));
}
605 (uint) (buf->version)))if ((0&&0)) {printk("<5>" "EATA Controller found "
"at %#4x EATA Level: %x\n", base, (uint) (buf->version));
}
;
606
607 while (inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SDRQ0x08)
608 inw(base + HA_RDATA)((__builtin_constant_p((base + 0x00)) && (base + 0x00
) < 256) ? __inwc(base + 0x00) : __inw(base + 0x00))
;
609 if(ALLOW_DMA_BOARDS1 == FALSE0) {
610 for (z = 0; z < MAXISA4; z++)
611 if (base == ISAbases[z]) {
612 buf->IRQ = ISAirqs[z];
613 break;
614 }
615 }
616 return (TRUE1);
617 }
618 } else {
619 DBG(DBG_PROBE, printk("eata_dma: get_conf_PIO, error during transfer "if ((0)) {printk("eata_dma: get_conf_PIO, error during transfer "
"for HBA at %x\n", base);}
620 "for HBA at %x\n", base))if ((0)) {printk("eata_dma: get_conf_PIO, error during transfer "
"for HBA at %x\n", base);}
;
621 }
622 return (FALSE0);
623}
624
625void print_pio_config(struct get_conf *gc)
626{
627 printk("Please check values: (read config data)\n");
628 printk("LEN: %d ver:%d OCS:%d TAR:%d TRNXFR:%d MORES:%d\n",
629 (uint) ntohl(gc->len), gc->version,
630 gc->OCS_enabled, gc->TAR_support, gc->TRNXFR, gc->MORE_support);
631 printk("HAAV:%d SCSIID0:%d ID1:%d ID2:%d QUEUE:%d SG:%d SEC:%d\n",
632 gc->HAA_valid, gc->scsi_id[3], gc->scsi_id[2],
633 gc->scsi_id[1], ntohs(gc->queuesiz), ntohs(gc->SGsiz), gc->SECOND);
634 printk("IRQ:%d IRQT:%d FORCADR:%d MCH:%d RIDQ:%d\n",
635 gc->IRQ, gc->IRQ_TR, gc->FORCADR,
636 gc->MAX_CHAN, gc->ID_qest);
637 DBG(DPT_DEBUG, DELAY(14))if ((0)) {{ ulong flags, i; __asm__ __volatile__("pushf ; pop %0"
: "=r" (flags): :"memory"); __asm__ __volatile__ ("sti": : :
"memory"); i = jiffies + (14 * 100); while (jiffies < i); __asm__
__volatile__("push %0 ; popf": :"g" (flags):"memory"); };}
;
638}
639
640static uint print_selftest(uint base)
641{
642 unchar buffer[512];
643#ifdef VERBOSE_SETUP
644 int z;
645#endif
646
647 printk("eata_pio: executing controller self test & setup...\n");
648 while (inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SBUSY0x80);
649 outb(EATA_CMD_PIO_SETUPTEST, base + HA_WCOMMAND)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __outbc((0xc6),(base + 0x07)) : __outb((0xc6),(
base + 0x07)))
;
650 do {
651 while (inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SBUSY0x80)
652 /* nothing */ ;
653 if (inb(base + HA_RSTATUS)((__builtin_constant_p((base + 0x07)) && (base + 0x07
) < 256) ? __inbc(base + 0x07) : __inb(base + 0x07))
& HA_SDRQ0x08)
654 {
655 insw(base + HA_RDATA0x00, &buffer, 256);
656#ifdef VERBOSE_SETUP
657 /* no beeps please... */
658 for (z = 0; z < 511 && buffer[z]; z++)
659 if (buffer[z] != 7) printk("%c", buffer[z]);
660#endif
661 }
662 } while (inb(base+HA_RSTATUS)((__builtin_constant_p((base+0x07)) && (base+0x07) <
256) ? __inbc(base+0x07) : __inb(base+0x07))
& (HA_SBUSY0x80|HA_SDRQ0x08));
663
664 return (!(inb(base+HA_RSTATUS)((__builtin_constant_p((base+0x07)) && (base+0x07) <
256) ? __inbc(base+0x07) : __inb(base+0x07))
& HA_SERROR0x01));
665}
666
667int register_pio_HBA(long base, struct get_conf *gc, Scsi_Host_Template * tpnt)
668{
669 ulong size = 0;
670 char *buff;
671 ulong cplen;
672 ushort cppadlen;
673 struct Scsi_Host *sh;
674 hostdata *hd;
675
676 DBG(DBG_REGISTER, print_pio_config(gc))if ((0)) {print_pio_config(gc);};
677
678 if (gc->DMA_support == TRUE1) {
679 printk("HBA at %#.4lx supports DMA. Please use EATA-DMA driver.\n",base);
680 if(ALLOW_DMA_BOARDS1 == FALSE0)
681 return (FALSE0);
682 }
683
684 if ((buff = get_pio_board_data((uint)base, gc->IRQ, gc->scsi_id[3],
685 cplen =(htonl(gc->cplen )+1)/2,
686 cppadlen=(htons(gc->cppadlen)+1)/2)) == NULL((void *) 0))
687 {
688 printk("HBA at %#lx didn't react on INQUIRY. Sorry.\n", (ulong) base);
689 return (FALSE0);
690 }
691
692 if (print_selftest(base) == FALSE0 && ALLOW_DMA_BOARDS1 == FALSE0)
693 {
694 printk("HBA at %#lx failed while performing self test & setup.\n",
695 (ulong) base);
696 return (FALSE0);
697 }
698
699 if (!reg_IRQ[gc->IRQ]) { /* Interrupt already registered ? */
700 if (!request_irq(gc->IRQ, eata_pio_int_handler, SA_INTERRUPT0x20000000,
701 "EATA-PIO", NULL((void *) 0))){
702 reg_IRQ[gc->IRQ]++;
703 if (!gc->IRQ_TR)
704 reg_IRQL[gc->IRQ] = TRUE1; /* IRQ is edge triggered */
705 } else {
706 printk("Couldn't allocate IRQ %d, Sorry.\n", gc->IRQ);
707 return (FALSE0);
708 }
709 } else { /* More than one HBA on this IRQ */
710 if (reg_IRQL[gc->IRQ] == TRUE1) {
711 printk("Can't support more than one HBA on this IRQ,\n"
712 " if the IRQ is edge triggered. Sorry.\n");
713 return (FALSE0);
714 } else
715 reg_IRQ[gc->IRQ]++;
716 }
717
718 request_region(base, 8, "eata_pio");
719
720 size = sizeof(hostdata) + (sizeof(struct eata_ccb) * ntohs(gc->queuesiz));
721
722 sh = scsi_register(tpnt, size);
723 hd = SD(sh)((hostdata *)&(sh->hostdata));
724
725 memset(hd->ccb, 0, (sizeof(struct eata_ccb) * ntohs(gc->queuesiz)))(__builtin_constant_p(0) ? (__builtin_constant_p(((sizeof(struct
eata_ccb) * ntohs(gc->queuesiz)))) ? __constant_c_and_count_memset
(((hd->ccb)),((0x01010101UL*(unsigned char)(0))),(((sizeof
(struct eata_ccb) * ntohs(gc->queuesiz))))) : __constant_c_memset
(((hd->ccb)),((0x01010101UL*(unsigned char)(0))),(((sizeof
(struct eata_ccb) * ntohs(gc->queuesiz)))))) : (__builtin_constant_p
(((sizeof(struct eata_ccb) * ntohs(gc->queuesiz)))) ? __memset_generic
((((hd->ccb))),(((0))),((((sizeof(struct eata_ccb) * ntohs
(gc->queuesiz)))))) : __memset_generic(((hd->ccb)),((0)
),(((sizeof(struct eata_ccb) * ntohs(gc->queuesiz)))))))
;
726 memset(hd->reads, 0, sizeof(ulong) * 26)(__builtin_constant_p(0) ? (__builtin_constant_p((sizeof(ulong
) * 26)) ? __constant_c_and_count_memset(((hd->reads)),((0x01010101UL
*(unsigned char)(0))),((sizeof(ulong) * 26))) : __constant_c_memset
(((hd->reads)),((0x01010101UL*(unsigned char)(0))),((sizeof
(ulong) * 26)))) : (__builtin_constant_p((sizeof(ulong) * 26)
) ? __memset_generic((((hd->reads))),(((0))),(((sizeof(ulong
) * 26)))) : __memset_generic(((hd->reads)),((0)),((sizeof
(ulong) * 26)))))
;
727
728 strncpy(SD(sh)((hostdata *)&(sh->hostdata))->vendor, &buff[8], 8);
729 SD(sh)((hostdata *)&(sh->hostdata))->vendor[8] = 0;
730 strncpy(SD(sh)((hostdata *)&(sh->hostdata))->name, &buff[16], 17);
731 SD(sh)((hostdata *)&(sh->hostdata))->name[17] = 0;
732 SD(sh)((hostdata *)&(sh->hostdata))->revision[0] = buff[32];
733 SD(sh)((hostdata *)&(sh->hostdata))->revision[1] = buff[33];
734 SD(sh)((hostdata *)&(sh->hostdata))->revision[2] = buff[34];
735 SD(sh)((hostdata *)&(sh->hostdata))->revision[3] = '.';
736 SD(sh)((hostdata *)&(sh->hostdata))->revision[4] = buff[35];
737 SD(sh)((hostdata *)&(sh->hostdata))->revision[5] = 0;
738
739 switch (ntohl(gc->len)) {
740 case 0x1c:
741 SD(sh)((hostdata *)&(sh->hostdata))->EATA_revision = 'a';
742 break;
743 case 0x1e:
744 SD(sh)((hostdata *)&(sh->hostdata))->EATA_revision = 'b';
745 break;
746 case 0x22:
747 SD(sh)((hostdata *)&(sh->hostdata))->EATA_revision = 'c';
748 break;
749 case 0x24:
750 SD(sh)((hostdata *)&(sh->hostdata))->EATA_revision = 'z';
751 default:
752 SD(sh)((hostdata *)&(sh->hostdata))->EATA_revision = '?';
753 }
754
755 if(ntohl(gc->len) >= 0x22) {
756 if (gc->is_PCI == TRUE1)
757 hd->bustype = IS_PCI'P';
758 else if (gc->is_EISA == TRUE1)
759 hd->bustype = IS_EISA'E';
760 else
761 hd->bustype = IS_ISA'I';
762 } else {
763 if (buff[21] == '4')
764 hd->bustype = IS_PCI'P';
765 else if (buff[21] == '2')
766 hd->bustype = IS_EISA'E';
767 else
768 hd->bustype = IS_ISA'I';
769 }
770
771 SD(sh)((hostdata *)&(sh->hostdata))->cplen=cplen;
772 SD(sh)((hostdata *)&(sh->hostdata))->cppadlen=cppadlen;
773 SD(sh)((hostdata *)&(sh->hostdata))->hostid=gc->scsi_id[3];
774 SD(sh)((hostdata *)&(sh->hostdata))->devflags=1<<gc->scsi_id[3];
775 SD(sh)((hostdata *)&(sh->hostdata))->moresupport=gc->MORE_support;
776 sh->unique_id = base;
777 sh->base = (char *) base;
778 sh->io_port = base;
779 sh->n_io_port = 8;
780 sh->irq = gc->IRQ;
781 sh->dma_channel = PIO0xfe;
782 sh->this_id = gc->scsi_id[3];
783 sh->can_queue = 1;
784 sh->cmd_per_lun = 1;
785 sh->sg_tablesize = SG_ALL0xff;
786
787 hd->channel = 0;
788
789 sh->max_id = 8;
790 sh->max_lun = 8;
791
792 if (gc->SECOND)
793 hd->primary = FALSE0;
794 else
795 hd->primary = TRUE1;
796
797 sh->unchecked_isa_dma = FALSE0; /* We can only do PIO */
798
799 hd->next = NULL((void *) 0); /* build a linked list of all HBAs */
800 hd->prev = last_HBA;
801 if(hd->prev != NULL((void *) 0))
802 SD(hd->prev)((hostdata *)&(hd->prev->hostdata))->next = sh;
803 last_HBA = sh;
804 if (first_HBA == NULL((void *) 0))
805 first_HBA = sh;
806 registered_HBAs++;
807 return (1);
808}
809
810void find_pio_ISA(struct get_conf *buf, Scsi_Host_Template * tpnt)
811{
812 int i;
813
814 for (i = 0; i < MAXISA4; i++) {
815 if (ISAbases[i]) {
816 if (get_pio_conf_PIO(ISAbases[i], buf) == TRUE1){
817 register_pio_HBA(ISAbases[i], buf, tpnt);
818 }
819 ISAbases[i] = 0;
820 }
821 }
822 return;
823}
824
825void find_pio_EISA(struct get_conf *buf, Scsi_Host_Template * tpnt)
826{
827 u32 base;
828 int i;
829
830#if CHECKPAL
831 u8 pal1, pal2, pal3;
832#endif
833
834 for (i = 0; i < MAXEISA16; i++) {
835 if (EISAbases[i] == TRUE1) { /* Still a possibility ? */
836
837 base = 0x1c88 + (i * 0x1000);
838#if CHECKPAL
839 pal1 = inb((u16)base - 8)((__builtin_constant_p(((u16)base - 8)) && ((u16)base
- 8) < 256) ? __inbc((u16)base - 8) : __inb((u16)base - 8
))
;
840 pal2 = inb((u16)base - 7)((__builtin_constant_p(((u16)base - 7)) && ((u16)base
- 7) < 256) ? __inbc((u16)base - 7) : __inb((u16)base - 7
))
;
841 pal3 = inb((u16)base - 6)((__builtin_constant_p(((u16)base - 6)) && ((u16)base
- 6) < 256) ? __inbc((u16)base - 6) : __inb((u16)base - 6
))
;
842
843 if (((pal1 == 0x12) && (pal2 == 0x14)) ||
844 ((pal1 == 0x38) && (pal2 == 0xa3) && (pal3 == 0x82)) ||
845 ((pal1 == 0x06) && (pal2 == 0x94) && (pal3 == 0x24))) {
846 DBG(DBG_PROBE, printk(KERN_NOTICE "EISA EATA id tags found: "if ((0)) {printk("<5>" "EISA EATA id tags found: " "%x %x %x \n"
, (int)pal1, (int)pal2, (int)pal3);}
847 "%x %x %x \n",if ((0)) {printk("<5>" "EISA EATA id tags found: " "%x %x %x \n"
, (int)pal1, (int)pal2, (int)pal3);}
848 (int)pal1, (int)pal2, (int)pal3))if ((0)) {printk("<5>" "EISA EATA id tags found: " "%x %x %x \n"
, (int)pal1, (int)pal2, (int)pal3);}
;
849#endif
850 if (get_pio_conf_PIO(base, buf) == TRUE1) {
851 DBG(DBG_PROBE && DBG_EISA, print_pio_config(buf))if ((0 && 0)) {print_pio_config(buf);};
852 if (buf->IRQ) {
853 register_pio_HBA(base, buf, tpnt);
854 } else
855 printk(KERN_NOTICE"<5>" "eata_dma: No valid IRQ. HBA "
856 "removed from list\n");
857 }
858 /* Nothing found here so we take it from the list */
859 EISAbases[i] = 0;
860#if CHECKPAL
861 }
862#endif
863 }
864 }
865 return;
866}
867
868void find_pio_PCI(struct get_conf *buf, Scsi_Host_Template * tpnt)
869{
870
871#ifndef CONFIG_PCI1
872 printk(KERN_ERR"<3>" "eata_pio: kernel PCI support not enabled. Skipping scan "
873 "for PCI HBAs.\n");
874#else
875
876 u8 pci_bus, pci_device_fn;
877 static s16 pci_index = 0; /* Device index to PCI BIOS calls */
878 u32 base = 0;
879 u16 com_adr;
880 u16 rev_device;
881 u32 error, i, x;
882
883 if (pcibios_present()) {
884 for (i = 0; i <= MAXPCI16; ++i, ++pci_index) {
885 if (pcibios_find_device(PCI_VENDOR_ID_DPT0x1044, PCI_DEVICE_ID_DPT0xa400,
886 pci_index, &pci_bus, &pci_device_fn))
887 break;
888 DBG(DBG_PROBE && DBG_PCI,if ((0 && 0)) {printk("eata_pio: HBA at bus %d, device %d,"
" function %d, index %d\n", (s32)pci_bus, (s32)((pci_device_fn
& 0xf8) >> 3), (s32)(pci_device_fn & 7), pci_index
);}
889 printk("eata_pio: HBA at bus %d, device %d,"if ((0 && 0)) {printk("eata_pio: HBA at bus %d, device %d,"
" function %d, index %d\n", (s32)pci_bus, (s32)((pci_device_fn
& 0xf8) >> 3), (s32)(pci_device_fn & 7), pci_index
);}
890 " function %d, index %d\n", (s32)pci_bus,if ((0 && 0)) {printk("eata_pio: HBA at bus %d, device %d,"
" function %d, index %d\n", (s32)pci_bus, (s32)((pci_device_fn
& 0xf8) >> 3), (s32)(pci_device_fn & 7), pci_index
);}
891 (s32)((pci_device_fn & 0xf8) >> 3),if ((0 && 0)) {printk("eata_pio: HBA at bus %d, device %d,"
" function %d, index %d\n", (s32)pci_bus, (s32)((pci_device_fn
& 0xf8) >> 3), (s32)(pci_device_fn & 7), pci_index
);}
892 (s32)(pci_device_fn & 7), pci_index))if ((0 && 0)) {printk("eata_pio: HBA at bus %d, device %d,"
" function %d, index %d\n", (s32)pci_bus, (s32)((pci_device_fn
& 0xf8) >> 3), (s32)(pci_device_fn & 7), pci_index
);}
;
893
894 if (!(error = pcibios_read_config_word(pci_bus, pci_device_fn,
895 PCI_CLASS_DEVICE0x0a, &rev_device))) {
896 if (rev_device == PCI_CLASS_STORAGE_SCSI0x0100) {
897 if (!(error = pcibios_read_config_word(pci_bus,
898 pci_device_fn, PCI_COMMAND0x04,
899 (u16 *) & com_adr))) {
900 if (!((com_adr & PCI_COMMAND_IO0x1) &&
901 (com_adr & PCI_COMMAND_MASTER0x4))) {
902 printk("HBA has IO or BUSMASTER mode disabled\n");
903 continue;
904 }
905 } else
906 printk("eata_pio: error %x while reading "
907 "PCI_COMMAND\n", error);
908 } else
909 printk("DEVICECLASSID %x didn't match\n", rev_device);
910 } else {
911 printk("eata_pio: error %x while reading PCI_CLASS_BASE\n",
912 error);
913 continue;
914 }
915
916 if (!(error = pcibios_read_config_dword(pci_bus, pci_device_fn,
917 PCI_BASE_ADDRESS_00x10, (int *) &base))){
918
919 /* Check if the address is valid */
920 if (base & 0x01) {
921 base &= 0xfffffffe;
922 /* EISA tag there ? */
923 if ((inb(base)((__builtin_constant_p((base)) && (base) < 256) ? __inbc
(base) : __inb(base))
== 0x12) && (inb(base + 1)((__builtin_constant_p((base + 1)) && (base + 1) <
256) ? __inbc(base + 1) : __inb(base + 1))
== 0x14))
924 continue; /* Jep, it's forced, so move on */
925 base += 0x10; /* Now, THIS is the real address */
926 if (base != 0x1f8) {
927 /* We didn't find it in the primary search */
928 if (get_pio_conf_PIO(base, buf) == TRUE1) {
929 if (buf->FORCADR) /* If the address is forced */
930 continue; /* we'll find it later */
931
932 /* OK. We made it till here, so we can go now
933 * and register it. We only have to check and
934 * eventually remove it from the EISA and ISA list
935 */
936
937 register_pio_HBA(base, buf, tpnt);
938
939 if (base < 0x1000) {
940 for (x = 0; x < MAXISA4; ++x) {
941 if (ISAbases[x] == base) {
942 ISAbases[x] = 0;
943 break;
944 }
945 }
946 } else if ((base & 0x0fff) == 0x0c88) {
947 x = (base >> 12) & 0x0f;
948 EISAbases[x] = 0;
949 }
950 continue; /* break; */
951 }
952 }
953 }
954 } else
955 printk("eata_pio: error %x while reading "
956 "PCI_BASE_ADDRESS_0\n", error);
957 }
958 } else
959 printk("eata_pio: No BIOS32 extensions present. This driver release "
960 "still depends on it.\n"
961 " Skipping scan for PCI HBAs.\n");
962#endif /* #ifndef CONFIG_PCI */
963 return;
964}
965
966
967int eata_pio_detect(Scsi_Host_Template * tpnt)
968{
969 struct Scsi_Host *HBA_ptr;
970 struct get_conf gc;
971 int i;
972
973 DBG((DBG_PROBE && DBG_DELAY) || DPT_DEBUG,if (((0 && 0) || 0)) {printk("Using lots of delays to let you read the debugging output\n"
);}
974 printk("Using lots of delays to let you read the debugging output\n"))if (((0 && 0) || 0)) {printk("Using lots of delays to let you read the debugging output\n"
);}
;
975
976 tpnt->proc_dir = &proc_scsi_eata_pio;
977
978 find_pio_PCI(&gc, tpnt);
979
980 find_pio_EISA(&gc, tpnt);
981
982 find_pio_ISA(&gc, tpnt);
983
984 for (i = 0; i < MAXIRQ16; i++)
985 if (reg_IRQ[i])
986 request_irq(i, eata_pio_int_handler, SA_INTERRUPT0x20000000, "EATA-PIO", NULL((void *) 0));
987
988 HBA_ptr = first_HBA;
989
990 if (registered_HBAs != 0) {
991 printk("EATA (Extended Attachment) PIO driver version: %d.%d%s\n"
992 "(c) 1993-95 Michael Neuffer, neuffer@goofy.zdv.uni-mainz.de\n"
993 " Alfred Arnold, a.arnold@kfa-juelich.de\n"
994 "This release only supports DASD devices (harddisks)\n",
995 VER_MAJOR0, VER_MINOR0, VER_SUB"1b");
996
997 printk("Registered HBAs:\n");
998 printk("HBA no. Boardtype: Revis: EATA: Bus: BaseIO: IRQ: Ch: ID: Pr:"
999 " QS: SG: CPL:\n");
1000 for (i = 1; i <= registered_HBAs; i++) {
1001 printk("scsi%-2d: %.10s v%s 2.0%c %s %#.4x %2d %d %d %c"
1002 " %2d %2d %2d\n",
1003 HBA_ptr->host_no, SD(HBA_ptr)((hostdata *)&(HBA_ptr->hostdata))->name, SD(HBA_ptr)((hostdata *)&(HBA_ptr->hostdata))->revision,
1004 SD(HBA_ptr)((hostdata *)&(HBA_ptr->hostdata))->EATA_revision, (SD(HBA_ptr)((hostdata *)&(HBA_ptr->hostdata))->bustype == 'P')?
1005 "PCI ":(SD(HBA_ptr)((hostdata *)&(HBA_ptr->hostdata))->bustype == 'E')?"EISA":"ISA ",
1006 (uint) HBA_ptr->base, HBA_ptr->irq, SD(HBA_ptr)((hostdata *)&(HBA_ptr->hostdata))->channel,
1007 HBA_ptr->this_id, (SD(HBA_ptr)((hostdata *)&(HBA_ptr->hostdata))->primary == TRUE1)?'Y':'N',
1008 HBA_ptr->can_queue, HBA_ptr->sg_tablesize,
1009 HBA_ptr->cmd_per_lun);
1010 HBA_ptr = SD(HBA_ptr)((hostdata *)&(HBA_ptr->hostdata))->next;
1011 }
1012 }
1013 DBG(DPT_DEBUG,DELAY(12))if ((0)) {{ ulong flags, i; __asm__ __volatile__("pushf ; pop %0"
: "=r" (flags): :"memory"); __asm__ __volatile__ ("sti": : :
"memory"); i = jiffies + (12 * 100); while (jiffies < i); __asm__
__volatile__("push %0 ; popf": :"g" (flags):"memory"); };}
;
1014
1015 return (registered_HBAs);
1016}
1017
1018#ifdef MODULE
1019/* Eventually this will go into an include file, but this will be later */
1020Scsi_Host_Template driver_template = EATA_PIO{ ((void *) 0), ((void *) 0), ((void *) 0), eata_pio_proc_info
, "EATA (Extended Attachment) PIO driver", eata_pio_detect, (
(void *) 0), ((void *) 0), ((void *) 0), eata_pio_queue, eata_pio_abort
, eata_pio_reset, ((void *) 0), scsicam_bios_param, 0, 0, 0, 0
, 0, 1, 1 }
;
1021
1022#include "scsi_module.c"
1023#endif
1024
1025/*
1026 * Overrides for Emacs so that we almost follow Linus's tabbing style.
1027 * Emacs will notice this stuff at the end of the file and automatically
1028 * adjust the settings for this buffer only. This must remain at the end
1029 * of the file.
1030 * ---------------------------------------------------------------------------
1031 * Local variables:
1032 * c-indent-level: 4
1033 * c-brace-imaginary-offset: 0
1034 * c-brace-offset: -4
1035 * c-argdecl-indent: 4
1036 * c-label-offset: -4
1037 * c-continued-statement-offset: 4
1038 * c-continued-brace-offset: 0
1039 * indent-tabs-mode: nil
1040 * tab-width: 8
1041 * End:
1042 */