Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Linux driver for System z and s390 unit record devices
0004  * (z/VM virtual punch, reader, printer)
0005  *
0006  * Copyright IBM Corp. 2001, 2007
0007  * Authors: Malcolm Beattie <beattiem@uk.ibm.com>
0008  *      Michael Holzheu <holzheu@de.ibm.com>
0009  *      Frank Munzert <munzert@de.ibm.com>
0010  */
0011 
0012 #ifndef _VMUR_H_
0013 #define _VMUR_H_
0014 
0015 #include <linux/refcount.h>
0016 
0017 #define DEV_CLASS_UR_I 0x20 /* diag210 unit record input device class */
0018 #define DEV_CLASS_UR_O 0x10 /* diag210 unit record output device class */
0019 /*
0020  * we only support z/VM's default unit record devices:
0021  * both in SPOOL directory control statement and in CP DEFINE statement
0022  *  RDR defaults to 2540 reader
0023  *  PUN defaults to 2540 punch
0024  *  PRT defaults to 1403 printer
0025  */
0026 #define READER_PUNCH_DEVTYPE    0x2540
0027 #define PRINTER_DEVTYPE     0x1403
0028 
0029 /* z/VM spool file control block SFBLOK */
0030 struct file_control_block {
0031     char reserved_1[8];
0032     char user_owner[8];
0033     char user_orig[8];
0034     __s32 data_recs;
0035     __s16 rec_len;
0036     __s16 file_num;
0037     __u8  file_stat;
0038     __u8  dev_type;
0039     char  reserved_2[6];
0040     char  file_name[12];
0041     char  file_type[12];
0042     char  create_date[8];
0043     char  create_time[8];
0044     char  reserved_3[6];
0045     __u8  file_class;
0046     __u8  sfb_lok;
0047     __u64 distr_code;
0048     __u32 reserved_4;
0049     __u8  current_starting_copy_number;
0050     __u8  sfblock_cntrl_flags;
0051     __u8  reserved_5;
0052     __u8  more_status_flags;
0053     char  rest[200];
0054 } __attribute__ ((packed));
0055 
0056 #define FLG_SYSTEM_HOLD 0x04
0057 #define FLG_CP_DUMP 0x10
0058 #define FLG_USER_HOLD   0x20
0059 #define FLG_IN_USE  0x80
0060 
0061 /*
0062  * A struct urdev is created for each ur device that is made available
0063  * via the ccw_device driver model.
0064  */
0065 struct urdev {
0066     struct ccw_device *cdev;    /* Backpointer to ccw device */
0067     struct mutex io_mutex;      /* Serialises device IO */
0068     struct completion *io_done; /* do_ur_io waits; irq completes */
0069     struct device *device;
0070     struct cdev *char_device;
0071     struct ccw_dev_id dev_id;   /* device id */
0072     size_t reclen;          /* Record length for *write* CCWs */
0073     int class;          /* VM device class */
0074     int io_request_rc;      /* return code from I/O request */
0075     refcount_t ref_count;       /* reference counter */
0076     wait_queue_head_t wait;     /* wait queue to serialize open */
0077     int open_flag;          /* "urdev is open" flag */
0078     spinlock_t open_lock;       /* serialize critical sections */
0079 };
0080 
0081 /*
0082  * A struct urfile is allocated at open() time for each device and
0083  * freed on release().
0084  */
0085 struct urfile {
0086     struct urdev *urd;
0087     unsigned int flags;
0088     size_t dev_reclen;
0089     __u16 file_reclen;
0090 };
0091 
0092 /*
0093  * Device major/minor definitions.
0094  */
0095 
0096 #define UR_MAJOR 0  /* get dynamic major */
0097 /*
0098  * We map minor numbers directly to device numbers (0-FFFF) for simplicity.
0099  * This avoids having to allocate (and manage) slot numbers.
0100  */
0101 #define NUM_MINORS 65536
0102 
0103 /* Limiting each I/O to 511 records limits chan prog to 4KB (511 r/w + 1 NOP) */
0104 #define MAX_RECS_PER_IO     511
0105 #define WRITE_CCW_CMD       0x01
0106 
0107 #define TRACE(x...) debug_sprintf_event(vmur_dbf, 1, x)
0108 #define CCWDEV_CU_DI(cutype, di) \
0109         CCW_DEVICE(cutype, 0x00), .driver_info = (di)
0110 
0111 #define FILE_RECLEN_OFFSET  4064 /* reclen offset in spool data block */
0112 
0113 #endif /* _VMUR_H_ */