Lines Matching refs:cmd
26 void ide_tf_readback(ide_drive_t *drive, struct ide_cmd *cmd) in ide_tf_readback() argument
34 tp_ops->tf_read(drive, &cmd->tf, cmd->valid.in.tf); in ide_tf_readback()
36 if (cmd->tf_flags & IDE_TFLAG_LBA48) { in ide_tf_readback()
39 tp_ops->tf_read(drive, &cmd->hob, cmd->valid.in.hob); in ide_tf_readback()
43 void ide_tf_dump(const char *s, struct ide_cmd *cmd) in ide_tf_dump() argument
48 s, cmd->tf.feature, cmd->tf.nsect, in ide_tf_dump()
49 cmd->tf.lbal, cmd->tf.lbam, cmd->tf.lbah, in ide_tf_dump()
50 cmd->tf.device, cmd->tf.command); in ide_tf_dump()
52 s, cmd->hob.nsect, cmd->hob.lbal, cmd->hob.lbam, cmd->hob.lbah); in ide_tf_dump()
58 struct ide_cmd cmd; in taskfile_lib_get_identify() local
60 memset(&cmd, 0, sizeof(cmd)); in taskfile_lib_get_identify()
61 cmd.tf.nsect = 0x01; in taskfile_lib_get_identify()
63 cmd.tf.command = ATA_CMD_ID_ATA; in taskfile_lib_get_identify()
65 cmd.tf.command = ATA_CMD_ID_ATAPI; in taskfile_lib_get_identify()
66 cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; in taskfile_lib_get_identify()
67 cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; in taskfile_lib_get_identify()
68 cmd.protocol = ATA_PROT_PIO; in taskfile_lib_get_identify()
70 return ide_raw_taskfile(drive, &cmd, buf, 1); in taskfile_lib_get_identify()
80 struct ide_cmd *cmd = &hwif->cmd; in do_rw_taskfile() local
81 struct ide_taskfile *tf = &cmd->tf; in do_rw_taskfile()
96 memcpy(cmd, orig_cmd, sizeof(*cmd)); in do_rw_taskfile()
98 if ((cmd->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { in do_rw_taskfile()
99 ide_tf_dump(drive->name, cmd); in do_rw_taskfile()
102 if (cmd->ftf_flags & IDE_FTFLAG_OUT_DATA) { in do_rw_taskfile()
103 u8 data[2] = { cmd->tf.data, cmd->hob.data }; in do_rw_taskfile()
105 tp_ops->output_data(drive, cmd, data, 2); in do_rw_taskfile()
108 if (cmd->valid.out.tf & IDE_VALID_DEVICE) { in do_rw_taskfile()
109 u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ? in do_rw_taskfile()
112 if (!(cmd->ftf_flags & IDE_FTFLAG_FLAGGED)) in do_rw_taskfile()
113 cmd->tf.device &= HIHI; in do_rw_taskfile()
114 cmd->tf.device |= drive->select; in do_rw_taskfile()
117 tp_ops->tf_load(drive, &cmd->hob, cmd->valid.out.hob); in do_rw_taskfile()
118 tp_ops->tf_load(drive, &cmd->tf, cmd->valid.out.tf); in do_rw_taskfile()
121 switch (cmd->protocol) { in do_rw_taskfile()
123 if (cmd->tf_flags & IDE_TFLAG_WRITE) { in do_rw_taskfile()
126 return pre_task_out_intr(drive, cmd); in do_rw_taskfile()
133 ide_execute_command(drive, cmd, handler, WAIT_WORSTCASE); in do_rw_taskfile()
136 if (ide_dma_prepare(drive, cmd)) in do_rw_taskfile()
139 ide_execute_command(drive, cmd, ide_dma_intr, 2 * WAIT_CMD); in do_rw_taskfile()
150 struct ide_cmd *cmd = &hwif->cmd; in task_no_data_intr() local
151 struct ide_taskfile *tf = &cmd->tf; in task_no_data_intr()
152 int custom = (cmd->tf_flags & IDE_TFLAG_CUSTOM_HANDLER) ? 1 : 0; in task_no_data_intr()
191 ide_finish_cmd(drive, cmd, stat); in task_no_data_intr()
222 void ide_pio_bytes(ide_drive_t *drive, struct ide_cmd *cmd, in ide_pio_bytes() argument
227 struct scatterlist *cursg = cmd->cursg; in ide_pio_bytes()
233 cursg = cmd->cursg; in ide_pio_bytes()
235 cursg = cmd->cursg = sg; in ide_pio_bytes()
238 unsigned nr_bytes = min(len, cursg->length - cmd->cursg_ofs); in ide_pio_bytes()
245 offset = cursg->offset + cmd->cursg_ofs; in ide_pio_bytes()
257 cmd->nleft -= nr_bytes; in ide_pio_bytes()
258 cmd->cursg_ofs += nr_bytes; in ide_pio_bytes()
260 if (cmd->cursg_ofs == cursg->length) { in ide_pio_bytes()
261 cursg = cmd->cursg = sg_next(cmd->cursg); in ide_pio_bytes()
262 cmd->cursg_ofs = 0; in ide_pio_bytes()
267 hwif->tp_ops->output_data(drive, cmd, buf, nr_bytes); in ide_pio_bytes()
269 hwif->tp_ops->input_data(drive, cmd, buf, nr_bytes); in ide_pio_bytes()
281 static void ide_pio_datablock(ide_drive_t *drive, struct ide_cmd *cmd, in ide_pio_datablock() argument
288 if (cmd->tf_flags & IDE_TFLAG_FS) in ide_pio_datablock()
289 cmd->rq->errors = 0; in ide_pio_datablock()
291 if (cmd->tf_flags & IDE_TFLAG_IO_16BIT) in ide_pio_datablock()
296 if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) in ide_pio_datablock()
297 nr_bytes = min_t(unsigned, cmd->nleft, drive->mult_count << 9); in ide_pio_datablock()
301 ide_pio_bytes(drive, cmd, write, nr_bytes); in ide_pio_datablock()
306 static void ide_error_cmd(ide_drive_t *drive, struct ide_cmd *cmd) in ide_error_cmd() argument
308 if (cmd->tf_flags & IDE_TFLAG_FS) { in ide_error_cmd()
309 int nr_bytes = cmd->nbytes - cmd->nleft; in ide_error_cmd()
311 if (cmd->protocol == ATA_PROT_PIO && in ide_error_cmd()
312 ((cmd->tf_flags & IDE_TFLAG_WRITE) || cmd->nleft == 0)) { in ide_error_cmd()
313 if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) in ide_error_cmd()
324 void ide_finish_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat) in ide_finish_cmd() argument
327 u8 err = ide_read_error(drive), nsect = cmd->tf.nsect; in ide_finish_cmd()
328 u8 set_xfer = !!(cmd->tf_flags & IDE_TFLAG_SET_XFER); in ide_finish_cmd()
330 ide_complete_cmd(drive, cmd, stat, err); in ide_finish_cmd()
347 struct ide_cmd *cmd = &drive->hwif->cmd; in task_pio_intr() local
349 u8 write = !!(cmd->tf_flags & IDE_TFLAG_WRITE); in task_pio_intr()
370 if (((stat & ATA_DRQ) == 0) ^ (cmd->nleft == 0)) in task_pio_intr()
374 if (write && cmd->nleft == 0) in task_pio_intr()
378 ide_pio_datablock(drive, cmd, write); in task_pio_intr()
381 if (write == 0 && cmd->nleft == 0) { in task_pio_intr()
393 if ((cmd->tf_flags & IDE_TFLAG_FS) == 0) in task_pio_intr()
394 ide_finish_cmd(drive, cmd, stat); in task_pio_intr()
396 ide_complete_rq(drive, 0, blk_rq_sectors(cmd->rq) << 9); in task_pio_intr()
399 ide_error_cmd(drive, cmd); in task_pio_intr()
404 struct ide_cmd *cmd) in pre_task_out_intr() argument
411 (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) ? "MULT" : "", in pre_task_out_intr()
421 ide_pio_datablock(drive, cmd, 1); in pre_task_out_intr()
426 int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf, in ide_raw_taskfile() argument
431 int rw = !(cmd->tf_flags & IDE_TFLAG_WRITE) ? READ : WRITE; in ide_raw_taskfile()
449 rq->special = cmd; in ide_raw_taskfile()
450 cmd->rq = rq; in ide_raw_taskfile()
460 int ide_no_data_taskfile(ide_drive_t *drive, struct ide_cmd *cmd) in ide_no_data_taskfile() argument
462 cmd->protocol = ATA_PROT_NODATA; in ide_no_data_taskfile()
464 return ide_raw_taskfile(drive, cmd, NULL, 0); in ide_no_data_taskfile()
472 struct ide_cmd cmd; in ide_taskfile_ioctl() local
521 memset(&cmd, 0, sizeof(cmd)); in ide_taskfile_ioctl()
523 memcpy(&cmd.hob, req_task->hob_ports, HDIO_DRIVE_HOB_HDR_SIZE - 2); in ide_taskfile_ioctl()
524 memcpy(&cmd.tf, req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE); in ide_taskfile_ioctl()
526 cmd.valid.out.tf = IDE_VALID_DEVICE; in ide_taskfile_ioctl()
527 cmd.valid.in.tf = IDE_VALID_DEVICE | IDE_VALID_IN_TF; in ide_taskfile_ioctl()
528 cmd.tf_flags = IDE_TFLAG_IO_16BIT; in ide_taskfile_ioctl()
531 cmd.tf_flags |= IDE_TFLAG_LBA48; in ide_taskfile_ioctl()
532 cmd.valid.in.hob = IDE_VALID_IN_HOB; in ide_taskfile_ioctl()
536 cmd.ftf_flags |= IDE_FTFLAG_FLAGGED; in ide_taskfile_ioctl()
539 cmd.ftf_flags |= IDE_FTFLAG_OUT_DATA; in ide_taskfile_ioctl()
542 cmd.valid.out.hob |= IDE_VALID_NSECT; in ide_taskfile_ioctl()
544 cmd.valid.out.hob |= IDE_VALID_LBAL; in ide_taskfile_ioctl()
546 cmd.valid.out.hob |= IDE_VALID_LBAM; in ide_taskfile_ioctl()
548 cmd.valid.out.hob |= IDE_VALID_LBAH; in ide_taskfile_ioctl()
551 cmd.valid.out.tf |= IDE_VALID_FEATURE; in ide_taskfile_ioctl()
553 cmd.valid.out.tf |= IDE_VALID_NSECT; in ide_taskfile_ioctl()
555 cmd.valid.out.tf |= IDE_VALID_LBAL; in ide_taskfile_ioctl()
557 cmd.valid.out.tf |= IDE_VALID_LBAM; in ide_taskfile_ioctl()
559 cmd.valid.out.tf |= IDE_VALID_LBAH; in ide_taskfile_ioctl()
561 cmd.valid.out.tf |= IDE_VALID_OUT_TF; in ide_taskfile_ioctl()
562 if (cmd.tf_flags & IDE_TFLAG_LBA48) in ide_taskfile_ioctl()
563 cmd.valid.out.hob |= IDE_VALID_OUT_HOB; in ide_taskfile_ioctl()
567 cmd.ftf_flags |= IDE_FTFLAG_IN_DATA; in ide_taskfile_ioctl()
573 cmd.tf_flags |= IDE_TFLAG_WRITE; in ide_taskfile_ioctl()
576 cmd.protocol = ATA_PROT_DMA; in ide_taskfile_ioctl()
587 cmd.tf_flags |= IDE_TFLAG_MULTI_PIO; in ide_taskfile_ioctl()
590 cmd.protocol = ATA_PROT_PIO; in ide_taskfile_ioctl()
594 cmd.tf_flags |= IDE_TFLAG_WRITE; in ide_taskfile_ioctl()
606 cmd.tf_flags |= IDE_TFLAG_MULTI_PIO; in ide_taskfile_ioctl()
609 cmd.protocol = ATA_PROT_PIO; in ide_taskfile_ioctl()
617 cmd.protocol = ATA_PROT_NODATA; in ide_taskfile_ioctl()
627 nsect = (cmd.hob.nsect << 8) | cmd.tf.nsect; in ide_taskfile_ioctl()
637 err = ide_raw_taskfile(drive, &cmd, data_buf, nsect); in ide_taskfile_ioctl()
639 memcpy(req_task->hob_ports, &cmd.hob, HDIO_DRIVE_HOB_HDR_SIZE - 2); in ide_taskfile_ioctl()
640 memcpy(req_task->io_ports, &cmd.tf, HDIO_DRIVE_TASK_HDR_SIZE); in ide_taskfile_ioctl()
642 if ((cmd.ftf_flags & IDE_FTFLAG_SET_IN_FLAGS) && in ide_taskfile_ioctl()