1 /***************************************************************************
3 * drivers/s390/char/tape.h
4 * tape device driver for 3480/3490E tapes.
6 * S390 and zSeries version
7 * Copyright (C) 2001 IBM Corporation
8 * Author(s): Carsten Otte <cotte@de.ibm.com>
9 * Tuan Ngo-Anh <ngoanh@de.ibm.com>
11 ****************************************************************************
17 #include <linux/config.h>
18 #include <linux/blkdev.h>
20 #define MAX_TAPES 7 /* Max tapes supported is 7*/
21 #define TAPE_MAGIC 0xE3C1D7C5 /* is ebcdic-"TAPE" */
24 TS_UNUSED=0, TS_IDLE, TS_DONE, TS_FAILED,
60 struct _tape_info_t; //Forward declaration
63 TE_START=0, TE_DONE, TE_FAILED, TE_ERROR, TE_OTHER,
64 TE_SIZE } tape_events;
66 typedef void (*tape_disc_shutdown_t) (int);
67 typedef void (*tape_event_handler_t) (struct _tape_info_t*);
68 typedef ccw_req_t* (*tape_ccwgen_t)(struct _tape_info_t* ti,int count);
69 typedef ccw_req_t* (*tape_reqgen_t)(struct request* req,struct _tape_info_t* ti,int tapeblock_major);
70 typedef ccw_req_t* (*tape_rwblock_t)(const char* data,size_t count,struct _tape_info_t* ti);
71 typedef void (*tape_freeblock_t)(ccw_req_t* cqr,struct _tape_info_t* ti);
72 typedef void (*tape_setup_assist_t) (struct _tape_info_t*);
73 #ifdef CONFIG_DEVFS_FS
74 typedef void (*tape_devfs_handler_t) (struct _tape_info_t*);
76 typedef tape_event_handler_t tape_event_table_t[TS_SIZE][TE_SIZE];
77 typedef struct _tape_discipline_t {
79 tape_setup_assist_t setup_assist;
80 tape_event_handler_t error_recovery;
82 tape_freeblock_t free_bread;
83 tape_rwblock_t write_block;
84 tape_freeblock_t free_write_block;
85 tape_rwblock_t read_block;
86 tape_freeblock_t free_read_block;
98 tape_ccwgen_t mterase;
99 tape_ccwgen_t mtsetdensity;
100 tape_ccwgen_t mtseek;
101 tape_ccwgen_t mttell;
102 tape_ccwgen_t mtsetdrvbuffer;
103 tape_ccwgen_t mtlock;
104 tape_ccwgen_t mtunlock;
105 tape_ccwgen_t mtload;
106 tape_ccwgen_t mtunload;
107 tape_ccwgen_t mtcompression;
108 tape_ccwgen_t mtsetpart;
109 tape_ccwgen_t mtmkpart;
110 tape_ccwgen_t mtiocget;
111 tape_ccwgen_t mtiocpos;
112 tape_disc_shutdown_t shutdown;
113 int (*discipline_ioctl_overload)(struct inode *,struct file*, unsigned int,unsigned long);
114 tape_event_table_t* event_table;
115 tape_event_handler_t default_handler;
116 struct _tape_info_t* tape; /* pointer for backreference */
118 } tape_discipline_t __attribute__ ((aligned(8)));
120 typedef struct _tape_frontend_t {
121 tape_setup_assist_t device_setup;
122 #ifdef CONFIG_DEVFS_FS
123 tape_devfs_handler_t mkdevfstree;
124 tape_devfs_handler_t rmdevfstree;
127 } tape_frontend_t __attribute__ ((aligned(8)));
130 typedef struct _tape_info_t {
131 wait_queue_head_t wq;
132 s390_dev_info_t devinfo; /* device info from Common I/O */
134 int rew_minor; /* minor number for the rewinding tape */
135 int nor_minor; /* minor number for the nonrewinding tape */
136 int blk_minor; /* minor number for the block device */
137 devstat_t devstat; /* contains irq, devno, status */
138 size_t block_size; /* block size of tape */
139 int drive_type; /* Code indicating type of drive */
140 struct file *rew_filp; /* backpointer to file structure */
141 struct file *nor_filp;
142 struct file *blk_filp;
143 int tape_state; /* State of the device. See tape_stat */
144 int rc; /* Return code. */
145 tape_discipline_t* discipline;
146 request_queue_t request_queue;
147 struct request* current_request;
150 int medium_is_unloaded; // Becomes true when a unload-type operation was issued, false again when medium-insert was detected
152 atomic_t bh_scheduled;
153 struct tq_struct bh_tq;
154 #ifdef CONFIG_DEVFS_FS
155 devfs_handle_t devfs_dir; /* devfs handle for tape/DEVNO directory */
156 devfs_handle_t devfs_char_dir; /* devfs handle for tape/DEVNO/char directory */
157 devfs_handle_t devfs_block_dir; /* devfs handle for tape/DEVNO/block directory */
158 devfs_handle_t devfs_nonrewinding; /* devfs handle for tape/DEVNO/char/nonrewinding device */
159 devfs_handle_t devfs_rewinding; /* devfs handle for tape/DEVNO/char/rewinding device */
160 devfs_handle_t devfs_disc; /* devfs handle for tape/DEVNO/block/disc device */
166 } tape_info_t __attribute__ ((aligned(8)));
168 /* tape initialisation functions */
170 int tape_setup (tape_info_t * ti, int irq, int minor);
172 /* functoins for alloc'ing ccw stuff */
173 inline ccw_req_t * tape_alloc_ccw_req (tape_info_t* ti, int cplength, int datasize);
174 void tape_free_request (ccw_req_t * request);
176 /* a function for dumping device sense info */
177 void tape_dump_sense (devstat_t * stat);
179 #ifdef CONFIG_S390_TAPE_DYNAMIC
180 /* functions for dyn. dev. attach/detach */
181 int tape_oper_handler ( int irq, struct _devreg *dreg);
184 /* functions for handling the status of a device */
185 inline void tapestate_set (tape_info_t * ti, int newstate);
186 inline int tapestate_get (tape_info_t * ti);
187 void tapestate_event (tape_info_t * ti, int event);
188 extern char* state_verbose[TS_SIZE];
189 extern char* event_verbose[TE_SIZE];
191 /****************************************************************************/
193 /* Some linked lists for storing plugins and devices */
194 extern tape_info_t *first_tape_info;
195 extern tape_discipline_t *first_discipline;
196 extern tape_frontend_t *first_frontend;
200 extern debug_info_t *tape_debug_area;
203 #endif /* for ifdef tape.h */