blob: 3ab6aafb7343c2a3c56e5a81f230f3a7ea087263 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * drivers/s390/char/tape_34xx.h
3 * standard tape device functions for ibm tapes.
4 *
5 * S390 and zSeries version
6 * Copyright (C) 2001,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
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 */
11
12#ifndef _TAPE_STD_H
13#define _TAPE_STD_H
14
15#include <asm/tape390.h>
16
17/*
18 * Biggest block size to handle. Currently 64K because we only build
19 * channel programs without data chaining.
20 */
21#define MAX_BLOCKSIZE 65535
22
23/*
24 * The CCW commands for the Tape type of command.
25 */
26#define INVALID_00 0x00 /* Invalid cmd */
27#define BACKSPACEBLOCK 0x27 /* Back Space block */
28#define BACKSPACEFILE 0x2f /* Back Space file */
29#define DATA_SEC_ERASE 0x97 /* Data security erase */
30#define ERASE_GAP 0x17 /* Erase Gap */
31#define FORSPACEBLOCK 0x37 /* Forward space block */
32#define FORSPACEFILE 0x3F /* Forward Space file */
33#define FORCE_STREAM_CNT 0xEB /* Forced streaming count # */
34#define NOP 0x03 /* No operation */
35#define READ_FORWARD 0x02 /* Read forward */
36#define REWIND 0x07 /* Rewind */
37#define REWIND_UNLOAD 0x0F /* Rewind and Unload */
38#define SENSE 0x04 /* Sense */
39#define NEW_MODE_SET 0xEB /* Guess it is Mode set */
40#define WRITE_CMD 0x01 /* Write */
41#define WRITETAPEMARK 0x1F /* Write Tape Mark */
42
43#define ASSIGN 0xB7 /* 3420 REJECT,3480 OK */
44#define CONTROL_ACCESS 0xE3 /* Set high speed */
45#define DIAG_MODE_SET 0x0B /* 3420 NOP, 3480 REJECT */
46#define LOAD_DISPLAY 0x9F /* 3420 REJECT,3480 OK */
47#define LOCATE 0x4F /* 3420 REJ, 3480 NOP */
48#define LOOP_WRITE_TO_READ 0x8B /* 3480 REJECT */
49#define MODE_SET_DB 0xDB /* 3420 REJECT,3480 OK */
50#define MODE_SET_C3 0xC3 /* for 3420 */
51#define MODE_SET_CB 0xCB /* for 3420 */
52#define MODE_SET_D3 0xD3 /* for 3420 */
53#define READ_BACKWARD 0x0C /* */
54#define READ_BLOCK_ID 0x22 /* 3420 REJECT,3480 OK */
55#define READ_BUFFER 0x12 /* 3420 REJECT,3480 OK */
56#define READ_BUFF_LOG 0x24 /* 3420 REJECT,3480 OK */
57#define RELEASE 0xD4 /* 3420 NOP, 3480 REJECT */
58#define REQ_TRK_IN_ERROR 0x1B /* 3420 NOP, 3480 REJECT */
59#define RESERVE 0xF4 /* 3420 NOP, 3480 REJECT */
60#define SENSE_GROUP_ID 0x34 /* 3420 REJECT,3480 OK */
61#define SENSE_ID 0xE4 /* 3420 REJECT,3480 OK */
62#define READ_DEV_CHAR 0x64 /* Read device characteristics */
63#define SET_DIAGNOSE 0x4B /* 3420 NOP, 3480 REJECT */
64#define SET_GROUP_ID 0xAF /* 3420 REJECT,3480 OK */
65#define SET_TAPE_WRITE_IMMED 0xC3 /* for 3480 */
66#define SUSPEND 0x5B /* 3420 REJ, 3480 NOP */
67#define SYNC 0x43 /* Synchronize (flush buffer) */
68#define UNASSIGN 0xC7 /* 3420 REJECT,3480 OK */
69#define PERF_SUBSYS_FUNC 0x77 /* 3490 CMD */
70#define READ_CONFIG_DATA 0xFA /* 3490 CMD */
71#define READ_MESSAGE_ID 0x4E /* 3490 CMD */
72#define READ_SUBSYS_DATA 0x3E /* 3490 CMD */
73#define SET_INTERFACE_ID 0x73 /* 3490 CMD */
74
75#define SENSE_COMMAND_REJECT 0x80
76#define SENSE_INTERVENTION_REQUIRED 0x40
77#define SENSE_BUS_OUT_CHECK 0x20
78#define SENSE_EQUIPMENT_CHECK 0x10
79#define SENSE_DATA_CHECK 0x08
80#define SENSE_OVERRUN 0x04
81#define SENSE_DEFERRED_UNIT_CHECK 0x02
82#define SENSE_ASSIGNED_ELSEWHERE 0x01
83
84#define SENSE_LOCATE_FAILURE 0x80
85#define SENSE_DRIVE_ONLINE 0x40
86#define SENSE_RESERVED 0x20
87#define SENSE_RECORD_SEQUENCE_ERR 0x10
88#define SENSE_BEGINNING_OF_TAPE 0x08
89#define SENSE_WRITE_MODE 0x04
90#define SENSE_WRITE_PROTECT 0x02
91#define SENSE_NOT_CAPABLE 0x01
92
93#define SENSE_CHANNEL_ADAPTER_CODE 0xE0
94#define SENSE_CHANNEL_ADAPTER_LOC 0x10
95#define SENSE_REPORTING_CU 0x08
96#define SENSE_AUTOMATIC_LOADER 0x04
97#define SENSE_TAPE_SYNC_MODE 0x02
98#define SENSE_TAPE_POSITIONING 0x01
99
100/* discipline functions */
101struct tape_request *tape_std_read_block(struct tape_device *, size_t);
102void tape_std_read_backward(struct tape_device *device,
103 struct tape_request *request);
104struct tape_request *tape_std_write_block(struct tape_device *, size_t);
105struct tape_request *tape_std_bread(struct tape_device *, struct request *);
106void tape_std_free_bread(struct tape_request *);
107void tape_std_check_locate(struct tape_device *, struct tape_request *);
108struct tape_request *tape_std_bwrite(struct request *,
109 struct tape_device *, int);
110
111/* Some non-mtop commands. */
112int tape_std_assign(struct tape_device *);
113int tape_std_unassign(struct tape_device *);
114int tape_std_read_block_id(struct tape_device *device, __u64 *id);
115int tape_std_display(struct tape_device *, struct display_struct *disp);
116int tape_std_terminate_write(struct tape_device *);
117
118/* Standard magnetic tape commands. */
119int tape_std_mtbsf(struct tape_device *, int);
120int tape_std_mtbsfm(struct tape_device *, int);
121int tape_std_mtbsr(struct tape_device *, int);
122int tape_std_mtcompression(struct tape_device *, int);
123int tape_std_mteom(struct tape_device *, int);
124int tape_std_mterase(struct tape_device *, int);
125int tape_std_mtfsf(struct tape_device *, int);
126int tape_std_mtfsfm(struct tape_device *, int);
127int tape_std_mtfsr(struct tape_device *, int);
128int tape_std_mtload(struct tape_device *, int);
129int tape_std_mtnop(struct tape_device *, int);
130int tape_std_mtoffl(struct tape_device *, int);
131int tape_std_mtreset(struct tape_device *, int);
132int tape_std_mtreten(struct tape_device *, int);
133int tape_std_mtrew(struct tape_device *, int);
134int tape_std_mtsetblk(struct tape_device *, int);
135int tape_std_mtunload(struct tape_device *, int);
136int tape_std_mtweof(struct tape_device *, int);
137
138/* Event handlers */
139void tape_std_default_handler(struct tape_device *);
140void tape_std_unexpect_uchk_handler(struct tape_device *);
141void tape_std_irq(struct tape_device *);
142void tape_std_process_eov(struct tape_device *);
143
144// the error recovery stuff:
145void tape_std_error_recovery(struct tape_device *);
146void tape_std_error_recovery_has_failed(struct tape_device *,int error_id);
147void tape_std_error_recovery_succeded(struct tape_device *);
148void tape_std_error_recovery_do_retry(struct tape_device *);
149void tape_std_error_recovery_read_opposite(struct tape_device *);
150void tape_std_error_recovery_HWBUG(struct tape_device *, int condno);
151
152#endif // _TAPE_STD_H