1 /* DASDTAB.H    (c) Copyright Roger Bowler, 1999-2009                */
2 /*              DASD table structures                                */
3 
4 /*-------------------------------------------------------------------*/
5 /* This header file contains defines the table entries that          */
6 /* describe all DASD devices supported by Hercules.                  */
7 /* It also contains function prototypes for the DASD table utilities.*/
8 /*-------------------------------------------------------------------*/
9 
10 
11 #if !defined(_DASDTAB_H)
12 #define _DASDTAB_H
13 
14 #include "hercules.h"
15 
16 #ifndef _DASDTAB_C_
17 #ifndef _HDASD_DLL_
18 #define DTB_DLL_IMPORT DLL_IMPORT
19 #else   /* _HDASD_DLL_ */
20 #define DTB_DLL_IMPORT extern
21 #endif  /* _HDASD_DLL_ */
22 #else
23 #define DTB_DLL_IMPORT DLL_EXPORT
24 #endif
25 
26 #define CKD_CONFIG_DATA_SIZE 256
27 #if 0
28 #define myssid (dev->devnum & 0xffe0)   /* Storage subsystem identifier
29                                            32 devices per subsystem  */
30 #else
31 #define myssid SSID(dev)
32 #endif
33 
34 /* 32 devices per subsystem */
35 #define DEVICES_PER_SUBSYS_SHIFT 5
36 #define DEVICES_PER_SUBSYS (1 << DEVICES_PER_SUBSYS_SHIFT)
37 #define SSID(_dev) ((_dev)->devnum & ~(DEVICES_PER_SUBSYS-1))
38 #define IFID(_dev) ((SSID((_dev)) >> DEVICES_PER_SUBSYS_SHIFT) & 0x7)
39 
40 /* Test for 3990-3 or 3990-6 control unit */
41 #define MODEL3(_cu) ((_cu)->devt == 0x3990 && (_cu)->model == 0xec)
42 #define MODEL6(_cu) ((_cu)->devt == 0x3990 && (_cu)->model == 0xe9)
43 
44 /*-------------------------------------------------------------------*/
45 /* Definition of a CKD DASD device entry                             */
46 /*-------------------------------------------------------------------*/
47 typedef struct _CKDDEV {                /* CKD Device table entry    */
48         char   *name;                   /* Device name               */
49         U16     devt;                   /* Device type               */
50         BYTE    model;                  /* Device model              */
51         BYTE    class;                  /* Device class              */
52         BYTE    code;                   /* Device code               */
53         U16     cyls;                   /* Number primary cylinders  */
54         U16     altcyls;                /* Number alternate cylinders*/
55         U16     heads;                  /* Number heads (trks/cyl)   */
56         U16     r0;                     /* R0 max size               */
57         U16     r1;                     /* R1 max size               */
58         U16     har0;                   /* HA/R0 overhead size       */
59         U16     len;                    /* Max length                */
60         U16     sectors;                /* Number sectors            */
61         U16     rpscalc;                /* RPS calculation factor    */
62         S16     formula;                /* Space calculation formula */
63         U16     f1,f2,f3,f4,f5,f6;      /* Space calculation factors */
64         char   *cu;                     /* Default control unit name */
65       } CKDDEV;
66 #define CKDDEV_SIZE sizeof(CKDDEV)
67 
68 /*-------------------------------------------------------------------*/
69 /* Definition of a CKD DASD control unit entry                       */
70 /*-------------------------------------------------------------------*/
71 typedef struct _CKDCU {                 /* CKD Control Unit entry    */
72         char   *name;                   /* Control Unit name         */
73         U16     devt;                   /* Control Unit type         */
74         BYTE    model;                  /* Control Unit model        */
75         BYTE    code;                   /* Control Unit code         */
76         BYTE    funcfeat;               /* Functions/Features        */
77         BYTE    typecode;               /* CU Type Code              */
78         U32     sctlfeat;               /* Control Unit features     */
79         U32     ciw1;                   /* CIW 1                     */
80         U32     ciw2;                   /* CIW 2                     */
81         U32     ciw3;                   /* CIW 3                     */
82         U32     ciw4;                   /* CIW 4                     */
83         U32     ciw5;                   /* CIW 5                     */
84         U32     ciw6;                   /* CIW 6                     */
85         U32     ciw7;                   /* CIW 7                     */
86         U32     ciw8;                   /* CIW 8                     */
87         U8      senselength;            /* Sense length              */
88       } CKDCU;
89 #define CKDCU_SIZE sizeof(CKDCU)
90 
91 /*-------------------------------------------------------------------*/
92 /* Definition of a FBA DASD device entry                             */
93 /*-------------------------------------------------------------------*/
94 typedef struct _FBADEV {                /* FBA Device entry          */
95         char   *name;                   /* Device name               */
96         U16     devt;                   /* Device type               */
97         BYTE    class;                  /* Device class              */
98         BYTE    type;                   /* Type                      */
99         BYTE    model;                  /* Model                     */
100         U32     bpg;                    /* Blocks per cyclical group */
101         U32     bpp;                    /* Blocks per access position*/
102         U32     size;                   /* Block size                */
103         U32     blks;                   /* Number of blocks          */
104         U16     cu;                     /* Default control unit type */
105       } FBADEV;
106 #define FBADEV_SIZE sizeof(FBADEV)
107 
108 #if defined(FEATURE_VM_BLOCKIO)
109 /*-------------------------------------------------------------------*/
110 /* Device Standard Block Size Information Table                      */
111 /*-------------------------------------------------------------------*/
112 typedef struct _BLKTAB {
113         char  *name;         /* Device name                          */
114         U16    devt;         /* Hercules supported device Type       */
115         int    darch;        /* FBA (0) or CKD (1) device            */
116 #define VMDEVFBA 0           /* Fixed-Block Architecture device      */
117 #define VMDEVCKD 1           /* (Extended-)Count-Key-Data device     */
118    /* sectors per block or blocks per track for standardblock sizes  */
119         int    phys512;      /* Block size 512  */
120         int    phys1024;     /* Block size 1024 */
121         int    phys2048;     /* Block size 2048 */
122         int    phys4096;     /* Block size 4096 */
123     } BLKTAB;
124 #define BLKTAB_SIZE sizeof(BLKTAB)
125 
126 /* Macros that define a table entry */
127 #define CKDIOT(_name,_type,_bs512,_bs1024,_bs2048,_bs4096) \
128        { _name, _type, 1, _bs512, _bs1024, _bs2048, _bs4906 }
129 #define FBAIOT(_name,_type) \
130        { _name, _type, 0, 1, 2, 4, 8 }
131 #endif /* defined(FEATURE_VM_BLOCKIO) */
132 
133 /*-------------------------------------------------------------------*/
134 /* Request types for dasd_lookup                                     */
135 /*-------------------------------------------------------------------*/
136 #define DASD_CKDDEV 1                   /* Lookup CKD device         */
137 #define DASD_CKDCU  2                   /* Lookup CKD control unit   */
138 #define DASD_FBADEV 3                   /* Lookup FBA device         */
139 #if defined(FEATURE_VM_BLOCKIO)
140 #define DASD_STDBLK 4       /* Lookup device standard block/physical */
141 #endif /* defined(FEATURE_VM_BLOCKIO) */
142 
143 /*-------------------------------------------------------------------*/
144 /* Dasd table function prototypes                                    */
145 /*-------------------------------------------------------------------*/
146 DTB_DLL_IMPORT void   *dasd_lookup (int, char *, U32   , U32   );
147 int     dasd_build_ckd_devid (CKDDEV *, CKDCU *, BYTE *);
148 int     dasd_build_ckd_devchar (CKDDEV *, CKDCU *, BYTE *, int);
149 DTB_DLL_IMPORT int     dasd_build_ckd_config_data (DEVBLK *, BYTE *, int);
150 DTB_DLL_IMPORT int     dasd_build_ckd_subsys_status (DEVBLK *, BYTE *, int);
151 int     dasd_build_fba_devid (FBADEV *, BYTE *);
152 int     dasd_build_fba_devchar (FBADEV *, BYTE *, int);
153 
154 #endif /*!defined(_DASDTAB_H)*/
155