• Home
  • Raw
  • Download

Lines Matching +full:512 +full:- +full:bytes

2  * atari_scsi.c -- Device dependent functions for the Atari generic SCSI port
4 * Copyright 1994 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
7 * - working real DMA
8 * - Falcon support (untested yet!) ++bjoern fixed and now it works
9 * - lots of extensions and bug fixes.
137 * scatter-gather anyway, so most transfers are 1024 byte only. In the rare
143 /* mask for address bits that can't be used with the ST-DMA */
147 static int setup_can_queue = -1;
149 static int setup_cmd_per_lun = -1;
151 static int setup_sg_tablesize = -1;
153 static int setup_hostid = -1;
155 static int setup_toshiba_delay = -1;
166 /* A bus error happens when DMA-ing from the last page of a in scsi_dma_is_ignored_buserr()
199 printk(KERN_CRIT "SCSI DMA bus error -- bad DMA programming!"); in scsi_tt_intr()
205 * This means we have residual bytes, if the desired end address in scsi_tt_intr()
206 * is not yet reached. Maybe we have to fetch some bytes from the in scsi_tt_intr()
209 * addr reg counts bytes not yet written and pending in the rest in scsi_tt_intr()
213 atari_dma_residual = hostdata->dma_len - in scsi_tt_intr()
214 (SCSI_DMA_READ_P(dma_addr) - atari_dma_startaddr); in scsi_tt_intr()
216 dprintk(NDEBUG_DMA, "SCSI DMA: There are %ld residual bytes.\n", in scsi_tt_intr()
224 * transport some rest bytes in scsi_tt_intr()
229 * There seems to be a nasty bug in some SCSI-DMA/NCR in scsi_tt_intr()
232 * DMA may be a few bytes farer than it actually read. in scsi_tt_intr()
235 * dma_addr is 9 bytes to high, but this could vary. in scsi_tt_intr()
248 "difference %ld bytes\n", in scsi_tt_intr()
249 512 - (atari_dma_residual & 0x1ff)); in scsi_tt_intr()
256 /* If the DMA is finished, fetch the rest bytes and turn it off */ in scsi_tt_intr()
292 * calculate the number of residual bytes and give a warning if in scsi_falcon_intr()
293 * bytes are stuck in the ST-DMA fifo (there's no way to reach them!) in scsi_falcon_intr()
298 transferred = SCSI_DMA_GETADR() - atari_dma_startaddr; in scsi_falcon_intr()
299 /* The ST-DMA address is incremented in 2-byte steps, but the in scsi_falcon_intr()
300 * data are written only in 16-byte chunks. If the number of in scsi_falcon_intr()
301 * transferred bytes is not divisible by 16, the remainder is in scsi_falcon_intr()
305 printk(KERN_ERR "SCSI DMA error: %ld bytes lost in " in scsi_falcon_intr()
306 "ST-DMA fifo\n", transferred & 15); in scsi_falcon_intr()
308 atari_dma_residual = hostdata->dma_len - transferred; in scsi_falcon_intr()
309 dprintk(NDEBUG_DMA, "SCSI DMA: There are %ld residual bytes.\n", in scsi_falcon_intr()
316 /* If the dribble buffer was used on a read operation, copy the DMA-ed in scsi_falcon_intr()
320 hostdata->dma_len - atari_dma_residual); in scsi_falcon_intr()
336 /* fetch rest bytes in the DMA register */ in atari_scsi_fetch_restbytes()
340 /* there are 'nr' bytes left for the last long address in atari_scsi_fetch_restbytes()
343 dprintk(NDEBUG_DMA, "SCSI DMA: there are %d rest bytes for phys addr 0x%08lx", in atari_scsi_fetch_restbytes()
348 for (src = (char *)&tt_scsi_dma.dma_restdata; nr != 0; --nr) in atari_scsi_fetch_restbytes()
367 /* This function manages the locking of the ST-DMA.
371 * command immediately but tell the SCSI mid-layer to defer.
380 instance->hostt->can_queue > 1) in falcon_get_lock()
432 hostdata->host->host_no, data, addr, count, dir); in atari_scsi_dma_setup()
435 /* If we have a non-DMAable address on a Falcon, use the dribble in atari_scsi_dma_setup()
451 * the ST-DMA begins to fill internal buffers right after setup. For in atari_scsi_dma_setup()
476 /* On writes, round up the transfer length to the next multiple of 512 in atari_scsi_dma_setup()
513 unsigned char opcode = cmd->cmnd[0]; in falcon_classify_cmd()
521 /* In case of a sequential-access target (tape), special care is in falcon_classify_cmd()
522 * needed here: The transfer is block-mode only if the 'fixed' bit is in falcon_classify_cmd()
524 if (cmd->device->type == TYPE_TAPE && !(cmd->cmnd[1] & 1)) in falcon_classify_cmd()
533 /* This function calculates the number of bytes that can be transferred via
535 * ST-DMA chip. There are only multiples of 512 bytes possible and max.
536 * 255*512 bytes :-( This means also, that defining READ_OVERRUNS is not
538 * n*512 - atari_read_overrun bytes. But it seems that the Falcon doesn't have
539 * the overrun problem, so this question is academic :-)
545 int wanted_len = cmd->SCp.this_residual; in atari_scsi_dma_xfer_len()
552 /* TT SCSI DMA can transfer arbitrary #bytes */ in atari_scsi_dma_xfer_len()
555 /* ST DMA chip is stupid -- only multiples of 512 bytes! (and max. in atari_scsi_dma_xfer_len()
556 * 255*512 bytes, but this should be enough) in atari_scsi_dma_xfer_len()
558 * ++roman: Aaargl! Another Falcon-SCSI problem... There are some commands in atari_scsi_dma_xfer_len()
559 * that return a number of bytes which cannot be known beforehand. In this in atari_scsi_dma_xfer_len()
561 * can happen that this allocation length is a multiple of 512 bytes and in atari_scsi_dma_xfer_len()
562 * the DMA is used. But if not n*512 bytes really arrive, some input data in atari_scsi_dma_xfer_len()
563 * will be lost in the ST-DMA's FIFO :-( Thus, we have to distinguish in atari_scsi_dma_xfer_len()
569 * The solution: We classify SCSI commands in 1) surely block-mode cmd.s, in atari_scsi_dma_xfer_len()
570 * 2) surely byte-mode cmd.s and 3) cmd.s with unknown mode. In case 1) in atari_scsi_dma_xfer_len()
577 * receiving a sufficient number of bytes. in atari_scsi_dma_xfer_len()
579 * Another point: If the transfer is from/to an non-ST-RAM address, we in atari_scsi_dma_xfer_len()
580 * use the dribble buffer and thus can do only STRAM_BUFFER_SIZE bytes. in atari_scsi_dma_xfer_len()
583 if (cmd->sc_data_direction == DMA_TO_DEVICE) { in atari_scsi_dma_xfer_len()
585 * be rounded up to the next multiple of 512 (atari_dma_setup() does in atari_scsi_dma_xfer_len()
591 * 512, we cannot use DMA, since the ST-DMA cannot split transfers in atari_scsi_dma_xfer_len()
617 limit = (atari_dma_buffer && !STRAM_ADDR(virt_to_phys(cmd->SCp.ptr))) ? in atari_scsi_dma_xfer_len()
618 STRAM_BUFFER_SIZE : 255*512; in atari_scsi_dma_xfer_len()
623 dprintk(NDEBUG_DMA, "DMA transfer now %d bytes instead of %d\n", in atari_scsi_dma_xfer_len()
717 .dma_boundary = PAGE_SIZE - 1,
730 return -ENODEV; in atari_scsi_probe()
775 /* If running on a Falcon and if there's TT-Ram (i.e., more than one in atari_scsi_probe()
776 * memory block, since there's always ST-Ram in a Falcon), then in atari_scsi_probe()
784 pr_err(PFX "can't allocate ST-RAM double buffer\n"); in atari_scsi_probe()
785 return -ENOMEM; in atari_scsi_probe()
794 error = -ENOMEM; in atari_scsi_probe()
798 instance->irq = irq->start; in atari_scsi_probe()
808 error = request_irq(instance->irq, scsi_tt_intr, 0, in atari_scsi_probe()
812 instance->irq); in atari_scsi_probe()
815 tt_mfp.active_edge |= 0x80; /* SCSI int on L->H */ in atari_scsi_probe()
836 hostdata->read_overruns = 4; in atari_scsi_probe()
839 /* Nothing to do for the interrupt: the ST-DMA is initialized in atari_scsi_probe()
861 free_irq(instance->irq, instance); in atari_scsi_probe()
878 free_irq(instance->irq, instance); in atari_scsi_remove()