tape_std.h 5.8 KB

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