1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Linux driver for System z and s390 unit record devices
4 * (z/VM virtual punch, reader, printer)
6 * Copyright IBM Corp. 2001, 2007
7 * Authors: Malcolm Beattie <beattiem@uk.ibm.com>
8 * Michael Holzheu <holzheu@de.ibm.com>
9 * Frank Munzert <munzert@de.ibm.com>
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 */
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
24 #define READER_PUNCH_DEVTYPE 0x2540
25 #define PRINTER_DEVTYPE 0x1403
27 /* z/VM spool file control block SFBLOK */
28 struct file_control_block {
47 __u8 current_starting_copy_number;
48 __u8 sfblock_cntrl_flags;
50 __u8 more_status_flags;
52 } __attribute__ ((packed));
54 #define FLG_SYSTEM_HOLD 0x04
55 #define FLG_CP_DUMP 0x10
56 #define FLG_USER_HOLD 0x20
57 #define FLG_IN_USE 0x80
60 * A struct urdev is created for each ur device that is made available
61 * via the ccw_device driver model.
64 struct ccw_device *cdev; /* Backpointer to ccw device */
65 struct mutex io_mutex; /* Serialises device IO */
66 struct completion *io_done; /* do_ur_io waits; irq completes */
67 struct device *device;
68 struct cdev *char_device;
69 struct ccw_dev_id dev_id; /* device id */
70 size_t reclen; /* Record length for *write* CCWs */
71 int class; /* VM device class */
72 int io_request_rc; /* return code from I/O request */
73 atomic_t ref_count; /* reference counter */
74 wait_queue_head_t wait; /* wait queue to serialize open */
75 int open_flag; /* "urdev is open" flag */
76 spinlock_t open_lock; /* serialize critical sections */
80 * A struct urfile is allocated at open() time for each device and
91 * Device major/minor definitions.
94 #define UR_MAJOR 0 /* get dynamic major */
96 * We map minor numbers directly to device numbers (0-FFFF) for simplicity.
97 * This avoids having to allocate (and manage) slot numbers.
99 #define NUM_MINORS 65536
101 /* Limiting each I/O to 511 records limits chan prog to 4KB (511 r/w + 1 NOP) */
102 #define MAX_RECS_PER_IO 511
103 #define WRITE_CCW_CMD 0x01
105 #define TRACE(x...) debug_sprintf_event(vmur_dbf, 1, x)
106 #define CCWDEV_CU_DI(cutype, di) \
107 CCW_DEVICE(cutype, 0x00), .driver_info = (di)
109 #define FILE_RECLEN_OFFSET 4064 /* reclen offset in spool data block */
111 #endif /* _VMUR_H_ */