Linux Audio

Check our new training course

Loading...
v6.9.4
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
 
  3 *    tape device driver for 3480/3490E/3590 tapes.
  4 *
  5 *  S390 and zSeries version
  6 *    Copyright IBM Corp. 2001, 2009
  7 *    Author(s): Carsten Otte <cotte@de.ibm.com>
  8 *		 Tuan Ngo-Anh <ngoanh@de.ibm.com>
  9 *		 Martin Schwidefsky <schwidefsky@de.ibm.com>
 10 *		 Stefan Bader <shbader@de.ibm.com>
 11 */
 12
 13#ifndef _TAPE_H
 14#define _TAPE_H
 15
 16#include <asm/ccwdev.h>
 17#include <asm/debug.h>
 18#include <asm/idals.h>
 
 19#include <linux/kernel.h>
 20#include <linux/module.h>
 21#include <linux/mtio.h>
 22#include <linux/interrupt.h>
 23#include <linux/workqueue.h>
 24
 25struct gendisk;
 26
 27/*
 28 * Define DBF_LIKE_HELL for lots of messages in the debug feature.
 29 */
 30#define DBF_LIKE_HELL
 31#ifdef  DBF_LIKE_HELL
 32#define DBF_LH(level, str, ...) \
 33do { \
 34	debug_sprintf_event(TAPE_DBF_AREA, level, str, ## __VA_ARGS__); \
 35} while (0)
 36#else
 37#define DBF_LH(level, str, ...) do {} while(0)
 38#endif
 39
 40/*
 41 * macros s390 debug feature (dbf)
 42 */
 43#define DBF_EVENT(d_level, d_str...) \
 44do { \
 45	debug_sprintf_event(TAPE_DBF_AREA, d_level, d_str); \
 46} while (0)
 47
 48#define DBF_EXCEPTION(d_level, d_str...) \
 49do { \
 50	debug_sprintf_exception(TAPE_DBF_AREA, d_level, d_str); \
 51} while (0)
 52
 53#define TAPE_VERSION_MAJOR 2
 54#define TAPE_VERSION_MINOR 0
 55#define TAPE_MAGIC "tape"
 56
 57#define TAPE_MINORS_PER_DEV 2	    /* two minors per device */
 58#define TAPEBLOCK_HSEC_SIZE	2048
 59#define TAPEBLOCK_HSEC_S2B	2
 60#define TAPEBLOCK_RETRIES	5
 61
 62enum tape_medium_state {
 63	MS_UNKNOWN,
 64	MS_LOADED,
 65	MS_UNLOADED,
 66	MS_SIZE
 67};
 68
 69enum tape_state {
 70	TS_UNUSED=0,
 71	TS_IN_USE,
 72	TS_BLKUSE,
 73	TS_INIT,
 74	TS_NOT_OPER,
 75	TS_SIZE
 76};
 77
 78enum tape_op {
 79	TO_BLOCK,	/* Block read */
 80	TO_BSB,		/* Backward space block */
 81	TO_BSF,		/* Backward space filemark */
 82	TO_DSE,		/* Data security erase */
 83	TO_FSB,		/* Forward space block */
 84	TO_FSF,		/* Forward space filemark */
 85	TO_LBL,		/* Locate block label */
 86	TO_NOP,		/* No operation */
 87	TO_RBA,		/* Read backward */
 88	TO_RBI,		/* Read block information */
 89	TO_RFO,		/* Read forward */
 90	TO_REW,		/* Rewind tape */
 91	TO_RUN,		/* Rewind and unload tape */
 92	TO_WRI,		/* Write block */
 93	TO_WTM,		/* Write tape mark */
 94	TO_MSEN,	/* Medium sense */
 95	TO_LOAD,	/* Load tape */
 96	TO_READ_CONFIG, /* Read configuration data */
 97	TO_READ_ATTMSG, /* Read attention message */
 98	TO_DIS,		/* Tape display */
 99	TO_ASSIGN,	/* Assign tape to channel path */
100	TO_UNASSIGN,	/* Unassign tape from channel path */
101	TO_CRYPT_ON,	/* Enable encrpytion */
102	TO_CRYPT_OFF,	/* Disable encrpytion */
103	TO_KEKL_SET,	/* Set KEK label */
104	TO_KEKL_QUERY,	/* Query KEK label */
105	TO_RDC,		/* Read device characteristics */
106	TO_SIZE,	/* #entries in tape_op_t */
107};
108
109/* Forward declaration */
110struct tape_device;
111
112/* tape_request->status can be: */
113enum tape_request_status {
114	TAPE_REQUEST_INIT,	/* request is ready to be processed */
115	TAPE_REQUEST_QUEUED,	/* request is queued to be processed */
116	TAPE_REQUEST_IN_IO,	/* request is currently in IO */
117	TAPE_REQUEST_DONE,	/* request is completed. */
118	TAPE_REQUEST_CANCEL,	/* request should be canceled. */
119	TAPE_REQUEST_LONG_BUSY, /* request has to be restarted after long busy */
120};
121
122/* Tape CCW request */
123struct tape_request {
124	struct list_head list;		/* list head for request queueing. */
125	struct tape_device *device;	/* tape device of this request */
126	struct ccw1 *cpaddr;		/* address of the channel program. */
127	void *cpdata;			/* pointer to ccw data. */
128	enum tape_request_status status;/* status of this request */
129	int options;			/* options for execution. */
130	int retries;			/* retry counter for error recovery. */
131	int rescnt;			/* residual count from devstat. */
132	struct timer_list timer;	/* timer for std_assign_timeout(). */
133
134	/* Callback for delivering final status. */
135	void (*callback)(struct tape_request *, void *);
136	void *callback_data;
137
138	enum tape_op op;
139	int rc;
140};
141
142/* Function type for magnetic tape commands */
143typedef int (*tape_mtop_fn)(struct tape_device *, int);
144
145/* Size of the array containing the mtops for a discipline */
146#define TAPE_NR_MTOPS (MTMKPART+1)
147
148/* Tape Discipline */
149struct tape_discipline {
150	struct module *owner;
151	int  (*setup_device)(struct tape_device *);
152	void (*cleanup_device)(struct tape_device *);
153	int (*irq)(struct tape_device *, struct tape_request *, struct irb *);
154	struct tape_request *(*read_block)(struct tape_device *, size_t);
155	struct tape_request *(*write_block)(struct tape_device *, size_t);
156	void (*process_eov)(struct tape_device*);
 
 
 
 
 
 
157	/* ioctl function for additional ioctls. */
158	int (*ioctl_fn)(struct tape_device *, unsigned int, unsigned long);
159	/* Array of tape commands with TAPE_NR_MTOPS entries */
160	tape_mtop_fn *mtop_array;
161};
162
163/*
164 * The discipline irq function either returns an error code (<0) which
165 * means that the request has failed with an error or one of the following:
166 */
167#define TAPE_IO_SUCCESS		0	/* request successful */
168#define TAPE_IO_PENDING		1	/* request still running */
169#define TAPE_IO_RETRY		2	/* retry to current request */
170#define TAPE_IO_STOP		3	/* stop the running request */
171#define TAPE_IO_LONG_BUSY	4	/* delay the running request */
172
173/* Char Frontend Data */
174struct tape_char_data {
175	struct idal_buffer *idal_buf;	/* idal buffer for user char data */
176	int block_size;			/*   of size block_size. */
177};
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179/* Tape Info */
180struct tape_device {
181	/* entry in tape_device_list */
182	struct list_head		node;
183
184	int				cdev_id;
185	struct ccw_device *		cdev;
186	struct tape_class_device *	nt;
187	struct tape_class_device *	rt;
188
189	/* Device mutex to serialize tape commands. */
190	struct mutex			mutex;
191
192	/* Device discipline information. */
193	struct tape_discipline *	discipline;
194	void *				discdata;
195
196	/* Generic status flags */
197	long				tape_generic_status;
198
199	/* Device state information. */
200	wait_queue_head_t		state_change_wq;
201	enum tape_state			tape_state;
202	enum tape_medium_state		medium_state;
203	unsigned char *			modeset_byte;
204
205	/* Reference count. */
206	atomic_t			ref_count;
207
208	/* Request queue. */
209	struct list_head		req_queue;
210
211	/* Request wait queue. */
212	wait_queue_head_t		wait_queue;
213
214	/* Each tape device has (currently) two minor numbers. */
215	int				first_minor;
216
217	/* Number of tapemarks required for correct termination. */
218	int				required_tapemarks;
219
220	/* Block ID of the BOF */
221	unsigned int			bof;
222
223	/* Character device frontend data */
224	struct tape_char_data		char_data;
 
 
 
 
225
226	/* Function to start or stop the next request later. */
227	struct delayed_work		tape_dnr;
228
229	/* Timer for long busy */
230	struct timer_list		lb_timeout;
231
232};
233
234/* Externals from tape_core.c */
235extern struct tape_request *tape_alloc_request(int cplength, int datasize);
236extern void tape_free_request(struct tape_request *);
237extern int tape_do_io(struct tape_device *, struct tape_request *);
238extern int tape_do_io_async(struct tape_device *, struct tape_request *);
239extern int tape_do_io_interruptible(struct tape_device *, struct tape_request *);
240extern int tape_cancel_io(struct tape_device *, struct tape_request *);
 
241
242static inline int
243tape_do_io_free(struct tape_device *device, struct tape_request *request)
244{
245	int rc;
246
247	rc = tape_do_io(device, request);
248	tape_free_request(request);
249	return rc;
250}
251
252static inline void
253tape_do_io_async_free(struct tape_device *device, struct tape_request *request)
254{
255	request->callback = (void *) tape_free_request;
256	request->callback_data = NULL;
257	tape_do_io_async(device, request);
258}
259
 
 
260extern int tape_open(struct tape_device *);
261extern int tape_release(struct tape_device *);
262extern int tape_mtop(struct tape_device *, int, int);
263extern void tape_state_set(struct tape_device *, enum tape_state);
264
265extern int tape_generic_online(struct tape_device *, struct tape_discipline *);
266extern int tape_generic_offline(struct ccw_device *);
 
267
268/* Externals from tape_devmap.c */
269extern int tape_generic_probe(struct ccw_device *);
270extern void tape_generic_remove(struct ccw_device *);
271
272extern struct tape_device *tape_find_device(int devindex);
273extern struct tape_device *tape_get_device(struct tape_device *);
274extern void tape_put_device(struct tape_device *);
275
276/* Externals from tape_char.c */
277extern int tapechar_init(void);
278extern void tapechar_exit(void);
279extern int  tapechar_setup_device(struct tape_device *);
280extern void tapechar_cleanup_device(struct tape_device *);
281
 
 
 
 
 
 
 
 
 
 
 
 
 
282/* tape initialisation functions */
283#ifdef CONFIG_PROC_FS
284extern void tape_proc_init (void);
285extern void tape_proc_cleanup (void);
286#else
287static inline void tape_proc_init (void) {;}
288static inline void tape_proc_cleanup (void) {;}
289#endif
290
291/* a function for dumping device sense info */
292extern void tape_dump_sense_dbf(struct tape_device *, struct tape_request *,
293				struct irb *);
294
295/* functions for handling the status of a device */
296extern void tape_med_state_set(struct tape_device *, enum tape_medium_state);
297
298/* The debug area */
299extern debug_info_t *TAPE_DBF_AREA;
300
301/* functions for building ccws */
302static inline struct ccw1 *
303tape_ccw_cc(struct ccw1 *ccw, __u8 cmd_code, __u16 memsize, void *cda)
304{
305	ccw->cmd_code = cmd_code;
306	ccw->flags = CCW_FLAG_CC;
307	ccw->count = memsize;
308	ccw->cda = 0;
309	if (cda)
310		ccw->cda = virt_to_dma32(cda);
311	return ccw + 1;
312}
313
314static inline struct ccw1 *
315tape_ccw_end(struct ccw1 *ccw, __u8 cmd_code, __u16 memsize, void *cda)
316{
317	ccw->cmd_code = cmd_code;
318	ccw->flags = 0;
319	ccw->count = memsize;
320	ccw->cda = 0;
321	if (cda)
322		ccw->cda = virt_to_dma32(cda);
323	return ccw + 1;
324}
325
326static inline struct ccw1 *
327tape_ccw_cmd(struct ccw1 *ccw, __u8 cmd_code)
328{
329	ccw->cmd_code = cmd_code;
330	ccw->flags = 0;
331	ccw->count = 0;
332	ccw->cda = virt_to_dma32(&ccw->cmd_code);
333	return ccw + 1;
334}
335
336static inline struct ccw1 *
337tape_ccw_repeat(struct ccw1 *ccw, __u8 cmd_code, int count)
338{
339	while (count-- > 0) {
340		ccw->cmd_code = cmd_code;
341		ccw->flags = CCW_FLAG_CC;
342		ccw->count = 0;
343		ccw->cda = virt_to_dma32(&ccw->cmd_code);
344		ccw++;
345	}
346	return ccw;
347}
348
349static inline struct ccw1 *
350tape_ccw_cc_idal(struct ccw1 *ccw, __u8 cmd_code, struct idal_buffer *idal)
351{
352	ccw->cmd_code = cmd_code;
353	ccw->flags    = CCW_FLAG_CC;
354	idal_buffer_set_cda(idal, ccw);
355	return ccw++;
356}
357
358static inline struct ccw1 *
359tape_ccw_end_idal(struct ccw1 *ccw, __u8 cmd_code, struct idal_buffer *idal)
360{
361	ccw->cmd_code = cmd_code;
362	ccw->flags    = 0;
363	idal_buffer_set_cda(idal, ccw);
364	return ccw++;
365}
366
367/* Global vars */
368extern const char *tape_state_verbose[];
369extern const char *tape_op_verbose[];
370
371#endif /* for ifdef tape.h */
v3.1
 
  1/*
  2 *  drivers/s390/char/tape.h
  3 *    tape device driver for 3480/3490E/3590 tapes.
  4 *
  5 *  S390 and zSeries version
  6 *    Copyright IBM Corp. 2001, 2009
  7 *    Author(s): Carsten Otte <cotte@de.ibm.com>
  8 *		 Tuan Ngo-Anh <ngoanh@de.ibm.com>
  9 *		 Martin Schwidefsky <schwidefsky@de.ibm.com>
 10 *		 Stefan Bader <shbader@de.ibm.com>
 11 */
 12
 13#ifndef _TAPE_H
 14#define _TAPE_H
 15
 16#include <asm/ccwdev.h>
 17#include <asm/debug.h>
 18#include <asm/idals.h>
 19#include <linux/blkdev.h>
 20#include <linux/kernel.h>
 21#include <linux/module.h>
 22#include <linux/mtio.h>
 23#include <linux/interrupt.h>
 24#include <linux/workqueue.h>
 25
 26struct gendisk;
 27
 28/*
 29 * Define DBF_LIKE_HELL for lots of messages in the debug feature.
 30 */
 31#define DBF_LIKE_HELL
 32#ifdef  DBF_LIKE_HELL
 33#define DBF_LH(level, str, ...) \
 34do { \
 35	debug_sprintf_event(TAPE_DBF_AREA, level, str, ## __VA_ARGS__); \
 36} while (0)
 37#else
 38#define DBF_LH(level, str, ...) do {} while(0)
 39#endif
 40
 41/*
 42 * macros s390 debug feature (dbf)
 43 */
 44#define DBF_EVENT(d_level, d_str...) \
 45do { \
 46	debug_sprintf_event(TAPE_DBF_AREA, d_level, d_str); \
 47} while (0)
 48
 49#define DBF_EXCEPTION(d_level, d_str...) \
 50do { \
 51	debug_sprintf_exception(TAPE_DBF_AREA, d_level, d_str); \
 52} while (0)
 53
 54#define TAPE_VERSION_MAJOR 2
 55#define TAPE_VERSION_MINOR 0
 56#define TAPE_MAGIC "tape"
 57
 58#define TAPE_MINORS_PER_DEV 2	    /* two minors per device */
 59#define TAPEBLOCK_HSEC_SIZE	2048
 60#define TAPEBLOCK_HSEC_S2B	2
 61#define TAPEBLOCK_RETRIES	5
 62
 63enum tape_medium_state {
 64	MS_UNKNOWN,
 65	MS_LOADED,
 66	MS_UNLOADED,
 67	MS_SIZE
 68};
 69
 70enum tape_state {
 71	TS_UNUSED=0,
 72	TS_IN_USE,
 73	TS_BLKUSE,
 74	TS_INIT,
 75	TS_NOT_OPER,
 76	TS_SIZE
 77};
 78
 79enum tape_op {
 80	TO_BLOCK,	/* Block read */
 81	TO_BSB,		/* Backward space block */
 82	TO_BSF,		/* Backward space filemark */
 83	TO_DSE,		/* Data security erase */
 84	TO_FSB,		/* Forward space block */
 85	TO_FSF,		/* Forward space filemark */
 86	TO_LBL,		/* Locate block label */
 87	TO_NOP,		/* No operation */
 88	TO_RBA,		/* Read backward */
 89	TO_RBI,		/* Read block information */
 90	TO_RFO,		/* Read forward */
 91	TO_REW,		/* Rewind tape */
 92	TO_RUN,		/* Rewind and unload tape */
 93	TO_WRI,		/* Write block */
 94	TO_WTM,		/* Write tape mark */
 95	TO_MSEN,	/* Medium sense */
 96	TO_LOAD,	/* Load tape */
 97	TO_READ_CONFIG, /* Read configuration data */
 98	TO_READ_ATTMSG, /* Read attention message */
 99	TO_DIS,		/* Tape display */
100	TO_ASSIGN,	/* Assign tape to channel path */
101	TO_UNASSIGN,	/* Unassign tape from channel path */
102	TO_CRYPT_ON,	/* Enable encrpytion */
103	TO_CRYPT_OFF,	/* Disable encrpytion */
104	TO_KEKL_SET,	/* Set KEK label */
105	TO_KEKL_QUERY,	/* Query KEK label */
106	TO_RDC,		/* Read device characteristics */
107	TO_SIZE,	/* #entries in tape_op_t */
108};
109
110/* Forward declaration */
111struct tape_device;
112
113/* tape_request->status can be: */
114enum tape_request_status {
115	TAPE_REQUEST_INIT,	/* request is ready to be processed */
116	TAPE_REQUEST_QUEUED,	/* request is queued to be processed */
117	TAPE_REQUEST_IN_IO,	/* request is currently in IO */
118	TAPE_REQUEST_DONE,	/* request is completed. */
119	TAPE_REQUEST_CANCEL,	/* request should be canceled. */
120	TAPE_REQUEST_LONG_BUSY, /* request has to be restarted after long busy */
121};
122
123/* Tape CCW request */
124struct tape_request {
125	struct list_head list;		/* list head for request queueing. */
126	struct tape_device *device;	/* tape device of this request */
127	struct ccw1 *cpaddr;		/* address of the channel program. */
128	void *cpdata;			/* pointer to ccw data. */
129	enum tape_request_status status;/* status of this request */
130	int options;			/* options for execution. */
131	int retries;			/* retry counter for error recovery. */
132	int rescnt;			/* residual count from devstat. */
 
133
134	/* Callback for delivering final status. */
135	void (*callback)(struct tape_request *, void *);
136	void *callback_data;
137
138	enum tape_op op;
139	int rc;
140};
141
142/* Function type for magnetic tape commands */
143typedef int (*tape_mtop_fn)(struct tape_device *, int);
144
145/* Size of the array containing the mtops for a discipline */
146#define TAPE_NR_MTOPS (MTMKPART+1)
147
148/* Tape Discipline */
149struct tape_discipline {
150	struct module *owner;
151	int  (*setup_device)(struct tape_device *);
152	void (*cleanup_device)(struct tape_device *);
153	int (*irq)(struct tape_device *, struct tape_request *, struct irb *);
154	struct tape_request *(*read_block)(struct tape_device *, size_t);
155	struct tape_request *(*write_block)(struct tape_device *, size_t);
156	void (*process_eov)(struct tape_device*);
157#ifdef CONFIG_S390_TAPE_BLOCK
158	/* Block device stuff. */
159	struct tape_request *(*bread)(struct tape_device *, struct request *);
160	void (*check_locate)(struct tape_device *, struct tape_request *);
161	void (*free_bread)(struct tape_request *);
162#endif
163	/* ioctl function for additional ioctls. */
164	int (*ioctl_fn)(struct tape_device *, unsigned int, unsigned long);
165	/* Array of tape commands with TAPE_NR_MTOPS entries */
166	tape_mtop_fn *mtop_array;
167};
168
169/*
170 * The discipline irq function either returns an error code (<0) which
171 * means that the request has failed with an error or one of the following:
172 */
173#define TAPE_IO_SUCCESS		0	/* request successful */
174#define TAPE_IO_PENDING		1	/* request still running */
175#define TAPE_IO_RETRY		2	/* retry to current request */
176#define TAPE_IO_STOP		3	/* stop the running request */
177#define TAPE_IO_LONG_BUSY	4	/* delay the running request */
178
179/* Char Frontend Data */
180struct tape_char_data {
181	struct idal_buffer *idal_buf;	/* idal buffer for user char data */
182	int block_size;			/*   of size block_size. */
183};
184
185#ifdef CONFIG_S390_TAPE_BLOCK
186/* Block Frontend Data */
187struct tape_blk_data
188{
189	struct tape_device *	device;
190	/* Block device request queue. */
191	struct request_queue *	request_queue;
192	spinlock_t		request_queue_lock;
193
194	/* Task to move entries from block request to CCS request queue. */
195	struct work_struct	requeue_task;
196	atomic_t		requeue_scheduled;
197
198	/* Current position on the tape. */
199	long			block_position;
200	int			medium_changed;
201	struct gendisk *	disk;
202};
203#endif
204
205/* Tape Info */
206struct tape_device {
207	/* entry in tape_device_list */
208	struct list_head		node;
209
210	int				cdev_id;
211	struct ccw_device *		cdev;
212	struct tape_class_device *	nt;
213	struct tape_class_device *	rt;
214
215	/* Device mutex to serialize tape commands. */
216	struct mutex			mutex;
217
218	/* Device discipline information. */
219	struct tape_discipline *	discipline;
220	void *				discdata;
221
222	/* Generic status flags */
223	long				tape_generic_status;
224
225	/* Device state information. */
226	wait_queue_head_t		state_change_wq;
227	enum tape_state			tape_state;
228	enum tape_medium_state		medium_state;
229	unsigned char *			modeset_byte;
230
231	/* Reference count. */
232	atomic_t			ref_count;
233
234	/* Request queue. */
235	struct list_head		req_queue;
236
237	/* Request wait queue. */
238	wait_queue_head_t		wait_queue;
239
240	/* Each tape device has (currently) two minor numbers. */
241	int				first_minor;
242
243	/* Number of tapemarks required for correct termination. */
244	int				required_tapemarks;
245
246	/* Block ID of the BOF */
247	unsigned int			bof;
248
249	/* Character device frontend data */
250	struct tape_char_data		char_data;
251#ifdef CONFIG_S390_TAPE_BLOCK
252	/* Block dev frontend data */
253	struct tape_blk_data		blk_data;
254#endif
255
256	/* Function to start or stop the next request later. */
257	struct delayed_work		tape_dnr;
258
259	/* Timer for long busy */
260	struct timer_list		lb_timeout;
261
262};
263
264/* Externals from tape_core.c */
265extern struct tape_request *tape_alloc_request(int cplength, int datasize);
266extern void tape_free_request(struct tape_request *);
267extern int tape_do_io(struct tape_device *, struct tape_request *);
268extern int tape_do_io_async(struct tape_device *, struct tape_request *);
269extern int tape_do_io_interruptible(struct tape_device *, struct tape_request *);
270extern int tape_cancel_io(struct tape_device *, struct tape_request *);
271void tape_hotplug_event(struct tape_device *, int major, int action);
272
273static inline int
274tape_do_io_free(struct tape_device *device, struct tape_request *request)
275{
276	int rc;
277
278	rc = tape_do_io(device, request);
279	tape_free_request(request);
280	return rc;
281}
282
283static inline void
284tape_do_io_async_free(struct tape_device *device, struct tape_request *request)
285{
286	request->callback = (void *) tape_free_request;
287	request->callback_data = NULL;
288	tape_do_io_async(device, request);
289}
290
291extern int tape_oper_handler(int irq, int status);
292extern void tape_noper_handler(int irq, int status);
293extern int tape_open(struct tape_device *);
294extern int tape_release(struct tape_device *);
295extern int tape_mtop(struct tape_device *, int, int);
296extern void tape_state_set(struct tape_device *, enum tape_state);
297
298extern int tape_generic_online(struct tape_device *, struct tape_discipline *);
299extern int tape_generic_offline(struct ccw_device *);
300extern int tape_generic_pm_suspend(struct ccw_device *);
301
302/* Externals from tape_devmap.c */
303extern int tape_generic_probe(struct ccw_device *);
304extern void tape_generic_remove(struct ccw_device *);
305
306extern struct tape_device *tape_find_device(int devindex);
307extern struct tape_device *tape_get_device(struct tape_device *);
308extern void tape_put_device(struct tape_device *);
309
310/* Externals from tape_char.c */
311extern int tapechar_init(void);
312extern void tapechar_exit(void);
313extern int  tapechar_setup_device(struct tape_device *);
314extern void tapechar_cleanup_device(struct tape_device *);
315
316/* Externals from tape_block.c */
317#ifdef CONFIG_S390_TAPE_BLOCK
318extern int tapeblock_init (void);
319extern void tapeblock_exit(void);
320extern int tapeblock_setup_device(struct tape_device *);
321extern void tapeblock_cleanup_device(struct tape_device *);
322#else
323static inline int tapeblock_init (void) {return 0;}
324static inline void tapeblock_exit (void) {;}
325static inline int tapeblock_setup_device(struct tape_device *t) {return 0;}
326static inline void tapeblock_cleanup_device (struct tape_device *t) {;}
327#endif
328
329/* tape initialisation functions */
330#ifdef CONFIG_PROC_FS
331extern void tape_proc_init (void);
332extern void tape_proc_cleanup (void);
333#else
334static inline void tape_proc_init (void) {;}
335static inline void tape_proc_cleanup (void) {;}
336#endif
337
338/* a function for dumping device sense info */
339extern void tape_dump_sense_dbf(struct tape_device *, struct tape_request *,
340				struct irb *);
341
342/* functions for handling the status of a device */
343extern void tape_med_state_set(struct tape_device *, enum tape_medium_state);
344
345/* The debug area */
346extern debug_info_t *TAPE_DBF_AREA;
347
348/* functions for building ccws */
349static inline struct ccw1 *
350tape_ccw_cc(struct ccw1 *ccw, __u8 cmd_code, __u16 memsize, void *cda)
351{
352	ccw->cmd_code = cmd_code;
353	ccw->flags = CCW_FLAG_CC;
354	ccw->count = memsize;
355	ccw->cda = (__u32)(addr_t) cda;
 
 
356	return ccw + 1;
357}
358
359static inline struct ccw1 *
360tape_ccw_end(struct ccw1 *ccw, __u8 cmd_code, __u16 memsize, void *cda)
361{
362	ccw->cmd_code = cmd_code;
363	ccw->flags = 0;
364	ccw->count = memsize;
365	ccw->cda = (__u32)(addr_t) cda;
 
 
366	return ccw + 1;
367}
368
369static inline struct ccw1 *
370tape_ccw_cmd(struct ccw1 *ccw, __u8 cmd_code)
371{
372	ccw->cmd_code = cmd_code;
373	ccw->flags = 0;
374	ccw->count = 0;
375	ccw->cda = (__u32)(addr_t) &ccw->cmd_code;
376	return ccw + 1;
377}
378
379static inline struct ccw1 *
380tape_ccw_repeat(struct ccw1 *ccw, __u8 cmd_code, int count)
381{
382	while (count-- > 0) {
383		ccw->cmd_code = cmd_code;
384		ccw->flags = CCW_FLAG_CC;
385		ccw->count = 0;
386		ccw->cda = (__u32)(addr_t) &ccw->cmd_code;
387		ccw++;
388	}
389	return ccw;
390}
391
392static inline struct ccw1 *
393tape_ccw_cc_idal(struct ccw1 *ccw, __u8 cmd_code, struct idal_buffer *idal)
394{
395	ccw->cmd_code = cmd_code;
396	ccw->flags    = CCW_FLAG_CC;
397	idal_buffer_set_cda(idal, ccw);
398	return ccw++;
399}
400
401static inline struct ccw1 *
402tape_ccw_end_idal(struct ccw1 *ccw, __u8 cmd_code, struct idal_buffer *idal)
403{
404	ccw->cmd_code = cmd_code;
405	ccw->flags    = 0;
406	idal_buffer_set_cda(idal, ccw);
407	return ccw++;
408}
409
410/* Global vars */
411extern const char *tape_state_verbose[];
412extern const char *tape_op_verbose[];
413
414#endif /* for ifdef tape.h */