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