summaryrefslogtreecommitdiff
path: root/include/linux/atapi.h
blob: 3a2fa93cc6c0c74dd73bd42e5d3a06be982130cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**** vi:set ts=8 sts=8 sw=8:************************************************
 *
 * Copyright (C) 2002 Marcin Dalecki <martin@dalecki.de>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 */

/*
 * With each packet command, we allocate a buffer.
 * This is used for several packet
 * commands (Not for READ/WRITE commands).
 */
#define IDEFLOPPY_PC_BUFFER_SIZE	256
#define IDETAPE_PC_BUFFER_SIZE		256

/* This struct get's shared between different drivers.
 */
struct atapi_packet_command {
	u8 c[12];			/* Actual packet bytes */
	char *buffer;			/* Data buffer */
	int buffer_size;		/* Size of our data buffer */
	char *current_position;		/* Pointer into the above buffer */
	int request_transfer;		/* Bytes to transfer */
	int actually_transferred;	/* Bytes actually transferred */

	unsigned long flags;		/* Status/Action bit flags: long for set_bit */

	/* FIXME: the following is ugly as hell, but the only way we can start
	 * actually to unify the code.
	 */
	/* driver specific data. */
	/* floppy/tape */
	int retries;				/* On each retry, we increment retries */
	int error;				/* Error code */
	char *b_data;				/* Pointer which runs on the buffers */
	unsigned int b_count;			/* Missing/Available data on the current buffer */
	u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE];	/* Temporary buffer */
	/* Called when this packet command is completed */
	void (*callback) (struct ata_device *, struct request *);

	/* only tape */
	struct bio *bio;

	/* only scsi */
	struct {
		unsigned int b_count;			/* Bytes transferred from current entry */
		struct scatterlist *sg;			/* Scatter gather table */
		struct scsi_cmnd *scsi_cmd;		/* SCSI command */
		void (*done)(struct scsi_cmnd *);	/* Scsi completion routine */
		unsigned long timeout;			/* Command timeout */
	} s;
};

extern void atapi_init_pc(struct atapi_packet_command *pc);

extern void atapi_discard_data(struct ata_device *, unsigned int);
extern void atapi_write_zeros(struct ata_device *, unsigned int);

extern void atapi_read(struct ata_device *, u8 *, unsigned int);
extern void atapi_write(struct ata_device *, u8 *, unsigned int);