vmur.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Linux driver for System z and s390 unit record devices
  4. * (z/VM virtual punch, reader, printer)
  5. *
  6. * Copyright IBM Corp. 2001, 2007
  7. * Authors: Malcolm Beattie <[email protected]>
  8. * Michael Holzheu <[email protected]>
  9. * Frank Munzert <[email protected]>
  10. */
  11. #ifndef _VMUR_H_
  12. #define _VMUR_H_
  13. #include <linux/refcount.h>
  14. #include <linux/workqueue.h>
  15. #define DEV_CLASS_UR_I 0x20 /* diag210 unit record input device class */
  16. #define DEV_CLASS_UR_O 0x10 /* diag210 unit record output device class */
  17. /*
  18. * we only support z/VM's default unit record devices:
  19. * both in SPOOL directory control statement and in CP DEFINE statement
  20. * RDR defaults to 2540 reader
  21. * PUN defaults to 2540 punch
  22. * PRT defaults to 1403 printer
  23. */
  24. #define READER_PUNCH_DEVTYPE 0x2540
  25. #define PRINTER_DEVTYPE 0x1403
  26. /* z/VM spool file control block SFBLOK */
  27. struct file_control_block {
  28. char reserved_1[8];
  29. char user_owner[8];
  30. char user_orig[8];
  31. __s32 data_recs;
  32. __s16 rec_len;
  33. __s16 file_num;
  34. __u8 file_stat;
  35. __u8 dev_type;
  36. char reserved_2[6];
  37. char file_name[12];
  38. char file_type[12];
  39. char create_date[8];
  40. char create_time[8];
  41. char reserved_3[6];
  42. __u8 file_class;
  43. __u8 sfb_lok;
  44. __u64 distr_code;
  45. __u32 reserved_4;
  46. __u8 current_starting_copy_number;
  47. __u8 sfblock_cntrl_flags;
  48. __u8 reserved_5;
  49. __u8 more_status_flags;
  50. char rest[200];
  51. } __attribute__ ((packed));
  52. #define FLG_SYSTEM_HOLD 0x04
  53. #define FLG_CP_DUMP 0x10
  54. #define FLG_USER_HOLD 0x20
  55. #define FLG_IN_USE 0x80
  56. /*
  57. * A struct urdev is created for each ur device that is made available
  58. * via the ccw_device driver model.
  59. */
  60. struct urdev {
  61. struct ccw_device *cdev; /* Backpointer to ccw device */
  62. struct mutex io_mutex; /* Serialises device IO */
  63. struct completion *io_done; /* do_ur_io waits; irq completes */
  64. struct device *device;
  65. struct cdev *char_device;
  66. struct ccw_dev_id dev_id; /* device id */
  67. size_t reclen; /* Record length for *write* CCWs */
  68. int class; /* VM device class */
  69. int io_request_rc; /* return code from I/O request */
  70. refcount_t ref_count; /* reference counter */
  71. wait_queue_head_t wait; /* wait queue to serialize open */
  72. int open_flag; /* "urdev is open" flag */
  73. spinlock_t open_lock; /* serialize critical sections */
  74. struct work_struct uevent_work; /* work to send uevent */
  75. };
  76. /*
  77. * A struct urfile is allocated at open() time for each device and
  78. * freed on release().
  79. */
  80. struct urfile {
  81. struct urdev *urd;
  82. unsigned int flags;
  83. size_t dev_reclen;
  84. __u16 file_reclen;
  85. };
  86. /*
  87. * Device major/minor definitions.
  88. */
  89. #define UR_MAJOR 0 /* get dynamic major */
  90. /*
  91. * We map minor numbers directly to device numbers (0-FFFF) for simplicity.
  92. * This avoids having to allocate (and manage) slot numbers.
  93. */
  94. #define NUM_MINORS 65536
  95. /* Limiting each I/O to 511 records limits chan prog to 4KB (511 r/w + 1 NOP) */
  96. #define MAX_RECS_PER_IO 511
  97. #define WRITE_CCW_CMD 0x01
  98. #define TRACE(x...) debug_sprintf_event(vmur_dbf, 1, x)
  99. #define CCWDEV_CU_DI(cutype, di) \
  100. CCW_DEVICE(cutype, 0x00), .driver_info = (di)
  101. #define FILE_RECLEN_OFFSET 4064 /* reclen offset in spool data block */
  102. #endif /* _VMUR_H_ */