1 /* DASDTAB.C (c) Copyright Roger Bowler, 1999-2009 */
2 /* Hercules Supported DASD definitions */
3
4 /*-------------------------------------------------------------------*/
5 /* This module contains the tables that define the attributes of */
6 /* each DASD device and control unit supported by Hercules. */
7 /* Routines are also provided to perform table lookup and build the */
8 /* device identifier and characteristics areas. */
9 /* */
10 /* Note: source for most CKD/FBA device capacities take from SDI's */
11 /* device capacity page at: http://www.sdisw.com/dasd_capacity.html */
12 /* (used with permission) */
13 /*-------------------------------------------------------------------*/
14
15 #include "hstdinc.h"
16
17 #define _DASDTAB_C_
18 #define _HDASD_DLL_
19
20 #include "hercules.h"
21
22 /*-------------------------------------------------------------------*/
23 /* CKD device definitions */
24 /*-------------------------------------------------------------------*/
25 static CKDDEV ckdtab[] = {
26 /* name type model clas code prime a hd r0 r1 har0 len sec rps f f1 f2 f3 f4 f5 f6 cu */
27 {"2305", 0x2305,0x00,0x20,0x00, 48,0, 8,14568,14136, 432,14568, 90,0x0000,-1,202,432, 0, 0, 0,0,"2835"},
28 {"2305-1", 0x2305,0x00,0x20,0x00, 48,0, 8,14568,14136, 432,14568, 90,0x0000,-1,202,432, 0, 0, 0,0,"2835"},
29 {"2305-2", 0x2305,0x02,0x20,0x00, 96,0, 8,14858,14660, 198,14858, 90,0x0000,-1, 91,198, 0, 0, 0,0,"2835"},
30
31 {"2311", 0x2311,0x00,0x20,0x00, 200,3,10, 0, 3625, 0, 3625, 0,0x0000,-2,20, 61, 537, 512, 0,0,"2841"},
32 {"2311-1", 0x2311,0x00,0x20,0x00, 200,3,10, 0, 3625, 0, 3625, 0,0x0000,-2,20, 61, 537, 512, 0,0,"2841"},
33
34 {"2314", 0x2314,0x00,0x20,0x00, 200,3,20, 0, 7294, 0, 7294, 0,0x0000,-2,45,101,2137,2048, 0,0,"2314"},
35 {"2314-1", 0x2314,0x00,0x20,0x00, 200,3,20, 0, 7294, 0, 7294, 0,0x0000,-2,45,101,2137,2048, 0,0,"2314"},
36
37 {"3330", 0x3330,0x01,0x20,0x00, 404,7,19,13165,13030, 135,13165,128,0x0000,-1,56,135, 0, 0, 0,0,"3830"},
38 {"3330-1", 0x3330,0x01,0x20,0x00, 404,7,19,13165,13030, 135,13165,128,0x0000,-1,56,135, 0, 0, 0,0,"3830"},
39 {"3330-2", 0x3330,0x11,0x20,0x00, 808,7,19,13165,13030, 135,13165,128,0x0000,-1,56,135, 0, 0, 0,0,"3830"},
40 {"3330-11", 0x3330,0x11,0x20,0x00, 808,7,19,13165,13030, 135,13165,128,0x0000,-1,56,135, 0, 0, 0,0,"3830"},
41
42 {"3340", 0x3340,0x01,0x20,0x00, 348,1,12, 8535, 8368, 167, 8535, 64,0x0000,-1,75,167, 0, 0, 0,0,"3830"},
43 {"3340-1", 0x3340,0x01,0x20,0x00, 348,1,12, 8535, 8368, 167, 8535, 64,0x0000,-1,75,167, 0, 0, 0,0,"3830"},
44 {"3340-35", 0x3340,0x01,0x20,0x00, 348,1,12, 8535, 8368, 167, 8535, 64,0x0000,-1,75,167, 0, 0, 0,0,"3830"},
45 {"3340-2", 0x3340,0x02,0x20,0x00, 696,2,12, 8535, 8368, 167, 8535, 64,0x0000,-1,75,167, 0, 0, 0,0,"3830"},
46 {"3340-70", 0x3340,0x02,0x20,0x00, 696,2,12, 8535, 8368, 167, 8535, 64,0x0000,-1,75,167, 0, 0, 0,0,"3830"},
47
48 {"3350", 0x3350,0x00,0x20,0x00, 555,5,30,19254,19069, 185,19254,128,0x0000,-1,82,185, 0, 0, 0,0,"3830"},
49 {"3350-1", 0x3350,0x00,0x20,0x00, 555,5,30,19254,19069, 185,19254,128,0x0000,-1,82,185, 0, 0, 0,0,"3830"},
50 /* name type model clas code prime a hd r0 r1 har0 len sec rps f f1 f2 f3 f4 f5 f6 cu */
51
52 {"3375", 0x3375,0x02,0x20,0x0e, 959,3,12,36000,35616, 832,36000,196,0x5007, 1, 32,384,160, 0, 0,0,"3880"},
53 {"3375-1", 0x3375,0x02,0x20,0x0e, 959,3,12,36000,35616, 832,36000,196,0x5007, 1, 32,384,160, 0, 0,0,"3880"},
54
55 {"3380", 0x3380,0x02,0x20,0x0e, 885,1,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
56 {"3380-1", 0x3380,0x02,0x20,0x0e, 885,1,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
57 {"3380-A", 0x3380,0x02,0x20,0x0e, 885,1,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
58 {"3380-B", 0x3380,0x02,0x20,0x0e, 885,1,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
59 {"3380-D", 0x3380,0x06,0x20,0x0e, 885,1,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
60 {"3380-J", 0x3380,0x16,0x20,0x0e, 885,1,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
61 {"3380-2", 0x3380,0x0a,0x20,0x0e, 1770,2,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
62 {"3380-E", 0x3380,0x0a,0x20,0x0e, 1770,2,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
63 {"3380-3", 0x3380,0x1e,0x20,0x0e, 2655,3,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
64 {"3380-K", 0x3380,0x1e,0x20,0x0e, 2655,3,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
65 {"EMC3380K+", 0x3380,0x1e,0x20,0x0e, 3339,3,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
66 {"EMC3380K++",0x3380,0x1e,0x20,0x0e, 3993,3,15,47988,47476,1088,47968,222,0x5007, 1, 32,492,236, 0, 0,0,"3880"},
67 /* name type model clas code prime a hd r0 r1 har0 len sec rps f f1 f2 f3 f4 f5 f6 cu */
68
69 {"3390", 0x3390,0x02,0x20,0x26, 1113,1,15,57326,56664,1428,58786,224,0x7708, 2, 34,19, 9, 6,116,6,"3990"},
70 {"3390-1", 0x3390,0x02,0x20,0x26, 1113,1,15,57326,56664,1428,58786,224,0x7708, 2, 34,19, 9, 6,116,6,"3990"},
71 {"3390-2", 0x3390,0x06,0x20,0x27, 2226,1,15,57326,56664,1428,58786,224,0x7708, 2, 34,19, 9, 6,116,6,"3990"},
72 {"3390-3", 0x3390,0x0a,0x20,0x24, 3339,1,15,57326,56664,1428,58786,224,0x7708, 2, 34,19, 9, 6,116,6,"3990"},
73 {"3390-9", 0x3390,0x0c,0x20,0x32,10017,3,15,57326,56664,1428,58786,224,0x7708, 2, 34,19, 9, 6,116,6,"3990"},
74 {"3390-27", 0x3390,0x0c,0x20,0x32,32760,3,15,57326,56664,1428,58786,224,0x7708, 2, 34,19, 9, 6,116,6,"3990"},
75 {"3390-J", 0x3390,0x0c,0x20,0x32,32760,3,15,57326,56664,1428,58786,224,0x7708, 2, 34,19, 9, 6,116,6,"3990"},
76 {"3390-54", 0x3390,0x0c,0x20,0x32,65520,3,15,57326,56664,1428,58786,224,0x7708, 2, 34,19, 9, 6,116,6,"3990"},
77 {"3390-JJ", 0x3390,0x0c,0x20,0x32,65520,3,15,57326,56664,1428,58786,224,0x7708, 2, 34,19, 9, 6,116,6,"3990"},
78
79 {"9345", 0x9345,0x04,0x20,0x04, 1440,0,15,48174,46456,1184,48280,213,0x8b07, 2, 34,18, 7, 6,116,6,"9343"},
80 {"9345-1", 0x9345,0x04,0x20,0x04, 1440,0,15,48174,46456,1184,48280,213,0x8b07, 2, 34,18, 7, 6,116,6,"9343"},
81 {"9345-2", 0x9345,0x04,0x20,0x04, 2156,0,15,48174,46456,1184,48280,213,0x8b07, 2, 34,18, 7, 6,116,6,"9343"}
82 /* name type model clas code prime a hd r0 r1 har0 len sec rps f f1 f2 f3 f4 f5 f6 cu */
83 } ;
84 #define CKDDEV_NUM (sizeof(ckdtab)/CKDDEV_SIZE)
85
86 /*-------------------------------------------------------------------*/
87 /* CKD control unit definitions */
88 /*-------------------------------------------------------------------*/
89 /* */
90 /* */
91 /* 3880, 3990, 2105 and higher coding */
92 /* ---------------------------------- */
93 /* */
94 /* Model coding bits (RDC byte 2): */
95 /* */
96 /* 11.. .... 3880 Speed Matching Buffer (LR support) */
97 /* ..1. .... Non-Gap-Synchronous mode */
98 /* .... 1... Cached */
99 /* .... .011 3880-3 */
100 /* .... .101 3880-3 Feature 3005 - 3380 AJ4/AK4 Attachment */
101 /* .... .010 3990-1/2 Nocache/Synchronous */
102 /* .... .100 3990-3/6/7 Basic Operation Mode */
103 /* .... .001 3990-6/7 Enhanced Mode */
104 /* */
105 /* */
106 /* Features (RDC bytes 6-9): */
107 /* */
108 /* Byte 6: */
109 /* 1... .... Multiple Burst ECC (ignored, 3380 devices) */
110 /* .1.. .... Locate Record, Read Tracks */
111 /* ..1. .... Reserved */
112 /* ...1 .... Locate Record, Read */
113 /* .... ...1 Reserved for VM minidisk use */
114 /* (testing this bit for zero is not reliable as an */
115 /* indicator that this is not a minidisk; can fail */
116 /* when minidisk is a fullpack minidisk) */
117 /* */
118 /* Byte 7 - Levels defining byte 8 format */
119 /* 0000 0000 Not supported by Hercules, must be zero */
120 /* */
121 /* Byte 8 - Added feature support */
122 /* 000. .... Not supported by Hercules, must be zero */
123 /* ...1 .... Data striping (required for VSAM Extended Format) */
124 /* .... 0000 Not supported by Hercules, must be zero */
125 /* */
126 /* Byte 9 - Subsystem Program Visible Facilities */
127 /* 1... .... Cache Fast Write supported (not supported, yet!) */
128 /* (non-retentive data) */
129 /* .1.. .... Lock Facility supported (not supported, yet!) */
130 /* ..1. .... Record Cache supported */
131 /* ...1 .... Track Cache supported */
132 /* .... 1... Dual Copy supported (not supported) */
133 /* .... .1.. DASD Fast Write supported (not supported) */
134 /* .... ..1. Reset Allegiance (not supported, yet!) */
135 /* .... ...1 24 Byte Compatibility Sense Format */
136 /* (set by code when 3380 on 3390 controller) */
137 /* */
138 /* */
139 /*-------------------------------------------------------------------*/
140 static CKDCU ckdcutab[] = {
141 /* func/ type */
142 /* name type model code feat code features ciws --------- senselength */
143 {"2314", 0x2314,0x00,0x00,0x00,0x00,0x00000000,0,0,0,0,0,0,0,0,6},
144 {"2835", 0x2835,0x00,0x00,0x00,0x00,0x00000000,0,0,0,0,0,0,0,0,6},
145 {"2841", 0x2841,0x00,0x00,0x00,0x00,0x00000000,0,0,0,0,0,0,0,0,6},
146 {"3830", 0x3830,0x02,0x00,0x00,0x00,0x00000000,0,0,0,0,0,0,0,0,24},
147 {"3880", 0x3880,0x05,0x09,0x00,0x00,0x80000000,0,0,0,0,0,0,0,0,24},
148 {"3990", 0x3990,0xc2,0x10,0x00,0x00,0xd0000000,0x40fa0100,0,0,0,0,0,0,0,32},
149 {"3990-3", 0x3990,0xec,0x06,0x00,0x00,0xd0001010,0x40fa0100,0x41270004,0x423e0040,0,0,0,0,0,32},
150 {"3990-6", 0x3990,0xe9,0x15,0x48,0x15,0x50001010,0x40fa0100,0x41270004,0x423e0060,0,0,0,0,0,32},
151 {"9343", 0x9343,0xe0,0x11,0x00,0x00,0x80000000,0,0,0,0,0,0,0,0,32}
152 /*"2105", 0x2105,0xe8,0x15,0x48,0x15,0x50000037,0x40fa0100,0x41270004,0x423e01a0,0x433e0008,0,0,0,0,32}, */
153 } ;
154 #define CKDCU_NUM (sizeof(ckdcutab)/CKDCU_SIZE)
155
156 /*-------------------------------------------------------------------*/
157 /* FBA device definitions - courtesy of Tomas Masek */
158 /*-------------------------------------------------------------------*/
159 static FBADEV fbatab[] = {
160 /* name devt class type mdl bpg bpp size blks cu */
161 {"3310", 0x3310,0x21,0x01,0x01, 32,352,512, 125664,0x4331},
162 {"3310-1", 0x3310,0x21,0x01,0x01, 32,352,512, 125664,0x4331},
163 {"3310-x", 0x3310,0x21,0x01,0x01, 32,352,512, 0,0x4331},
164
165 {"3370", 0x3370,0x21,0x02,0x00, 62,744,512, 558000,0x3880},
166 {"3370-1", 0x3370,0x21,0x02,0x00, 62,744,512, 558000,0x3880},
167 {"3370-A1", 0x3370,0x21,0x02,0x00, 62,744,512, 558000,0x3880},
168 {"3370-B1", 0x3370,0x21,0x02,0x00, 62,744,512, 558000,0x3880},
169 {"3370-2", 0x3370,0x21,0x05,0x04, 62,744,512, 712752,0x3880},
170 {"3370-A2", 0x3370,0x21,0x05,0x04, 62,744,512, 712752,0x3880},
171 {"3370-B2", 0x3370,0x21,0x05,0x04, 62,744,512, 712752,0x3880},
172 {"3370-x", 0x3370,0x21,0x05,0x04, 62,744,512, 0,0x3880},
173
174 {"9332", 0x9332,0x21,0x07,0x00, 73,292,512, 360036,0x6310},
175 {"9332-400", 0x9332,0x21,0x07,0x00, 73,292,512, 360036,0x6310},
176 {"9332-600", 0x9332,0x21,0x07,0x01, 73,292,512, 554800,0x6310},
177 {"9332-x", 0x9332,0x21,0x07,0x01, 73,292,512, 0,0x6310},
178
179 {"9335", 0x9335,0x21,0x06,0x01, 71,426,512, 804714,0x6310},
180 {"9335-x", 0x9335,0x21,0x06,0x01, 71,426,512, 0,0x6310},
181
182 /*"9313", 0x9313,0x21,0x08,0x00, ??,???,512, 246240,0x????}, */
183 /*"9313-1, 0x9313,0x21,0x08,0x00, ??,???,512, 246240,0x????}, */
184 /*"9313-14", 0x9313,0x21,0x08,0x14, ??,???,512, 246240,0x????}, */
185 /* 246240=32*81*5*19 */
186 {"9313", 0x9313,0x21,0x08,0x00, 96,480,512, 246240,0x6310},
187 {"9313-x", 0x9313,0x21,0x08,0x00, 96,480,512, 0,0x6310},
188
189 /* 9336 Junior models 1,2,3 */
190 /*"9336-J1", 0x9336,0x21,0x11,0x00, 63,315,512, 920115,0x6310}, */
191 /*"9336-J2", 0x9336,0x21,0x11,0x04, ??,???,512, ?,0x6310}, */
192 /*"9336-J3", 0x9336,0x21,0x11,0x08, ??,???,512, ?,0x6310}, */
193 /* 9336 Senior models 1,2,3 */
194 /*"9336-S1", 0x9336,0x21,0x11,0x10,111,777,512,1672881,0x6310}, */
195 /*"9336-S2", 0x9336,0x21,0x11,0x14,???,???,512, ?,0x6310}, */
196 /*"9336-S3", 0x9336,0x21,0x11,0x18,???,???,512, ?,0x6310}, */
197 {"9336", 0x9336,0x21,0x11,0x00, 63,315,512, 920115,0x6310},
198 {"9336-10", 0x9336,0x21,0x11,0x00, 63,315,512, 920115,0x6310},
199 {"9336-20", 0x9336,0x21,0x11,0x10,111,777,512,1672881,0x6310},
200 {"9336-25", 0x9336,0x21,0x11,0x10,111,777,512,1672881,0x6310},
201 {"9336-x", 0x9336,0x21,0x11,0x10,111,777,512, 0,0x6310},
202
203 /* name devt class type mdl bpg bpp size blks cu */
204 {"0671-08", 0x0671,0x21,0x12,0x08, 63,504,512, 513072,0x6310},
205 {"0671", 0x0671,0x21,0x12,0x00, 63,504,512, 574560,0x6310},
206 {"0671-04", 0x0671,0x21,0x12,0x04, 63,504,512, 624456,0x6310},
207 {"0671-x", 0x0671,0x21,0x12,0x04, 63,504,512, 0,0x6310}
208 } ;
209 #define FBADEV_NUM (sizeof(fbatab)/FBADEV_SIZE)
210
211 #if defined(FEATURE_VM_BLOCKIO)
212 static BLKTAB blktab[] = {
213 #if 0
214 /* Remove conditional compilation when CKD devices supported */
215 CKDIOT("2305",0x2305,15,10,5,3),
216 CKDIOT("2311",0x2311,6,3,1,0),
217 CKDIOT("2314",0x2314,11,6,3,1),
218 CKDIOT("3330",0x3330,20,11,6,3),
219 CKDIOT("3340",0x3340,12,7,3,2),
220 CKDIOT("3350",0x3350,27,15,8,4),
221 CKDIOT("3375",0x3375,40,25,14,8),
222 CKDIOT("3380",0x3380,35,23,14,7),
223 CKDIOT("3390",0x3390,49,33,21,12),
224 CKDIOT("9345",0x9345,41,28,17,9),
225 #endif
226 FBAIOT("0671",0x0671),
227 FBAIOT("3310",0x3310),
228 FBAIOT("3370",0x3370),
229 FBAIOT("9332",0x9332),
230 FBAIOT("9335",0x9335),
231 FBAIOT("9336",0x9336)
232 };
233 #define BLKTAB_NUM (sizeof(blktab)/BLKTAB_SIZE)
234
235 #endif /* defined(FEATURE_VM_BLOCKIO) */
236
237
238 /*-------------------------------------------------------------------*/
239 /* Lookup a table entry either by name or type */
240 /*-------------------------------------------------------------------*/
dasd_lookup(int dtype,char * name,U32 devt,U32 size)241 DLL_EXPORT void *dasd_lookup (int dtype, char *name, U32 devt, U32 size)
242 {
243 U32 i; /* Loop Index */
244
245 switch (dtype) {
246
247 case DASD_CKDDEV:
248 for (i = 0; i < (int)CKDDEV_NUM; i++)
249 {
250 if ((name && !strcmp(name, ckdtab[i].name))
251 || (((U32)devt == (U32)ckdtab[i].devt || (U32)devt == (U32)(ckdtab[i].devt & 0xff))
252 && (U32)size <= (U32)(ckdtab[i].cyls + ckdtab[i].altcyls)))
253 return &ckdtab[i];
254 }
255 return NULL;
256
257 case DASD_CKDCU:
258 for (i = 0; i < (int)CKDCU_NUM; i++)
259 {
260 if ((name != NULL && strcmp(name, ckdcutab[i].name) == 0)
261 || devt == ckdcutab[i].devt)
262 return &ckdcutab[i];
263 }
264 return NULL;
265
266 case DASD_FBADEV:
267 for (i = 0; i < (int)FBADEV_NUM; i++)
268 {
269 if ((name && !strcmp(name, fbatab[i].name))
270 || (((U32)devt == (U32)fbatab[i].devt || (U32)devt == (U32)(fbatab[i].devt & 0xff))
271 && ((size <= fbatab[i].blks) || (fbatab[i].blks == 0))))
272 return &fbatab[i];
273 }
274 return NULL;
275 #if defined(FEATURE_VM_BLOCKIO)
276 case DASD_STDBLK:
277 for (i = 0; i < (int)BLKTAB_NUM; i++)
278 {
279 if ((name && !strcmp(name, blktab[i].name)) ||
280 (U32)devt == (U32)blktab[i].devt ||
281 (U32)devt == (U32)(blktab[i].devt & 0xff))
282 return &blktab[i];
283 }
284 return NULL;
285 #endif /* defined(FEATURE_VM_BLOCKIO) */
286 default:
287 return NULL;
288 }
289 return NULL;
290 }
291
292 /*-------------------------------------------------------------------*/
293 /* Build CKD devid field */
294 /*-------------------------------------------------------------------*/
dasd_build_ckd_devid(CKDDEV * ckd,CKDCU * cu,BYTE * devid)295 int dasd_build_ckd_devid (CKDDEV *ckd, CKDCU *cu, BYTE *devid)
296 {
297 int len;
298
299 memset (devid, 0, 256);
300
301 store_fw (devid + 0, 0xFF000000 | (cu->devt << 8) | cu->model);
302 store_fw (devid + 4, (ckd->devt << 16) | (ckd->model << 8) | 0x00);
303 store_fw (devid + 8, cu->ciw1);
304 store_fw (devid +12, cu->ciw2);
305 store_fw (devid +16, cu->ciw3);
306 store_fw (devid +20, cu->ciw4);
307 store_fw (devid +24, cu->ciw5);
308 store_fw (devid +28, cu->ciw6);
309 store_fw (devid +32, cu->ciw7);
310 store_fw (devid +36, cu->ciw8);
311
312 /* Set length */
313 if (cu->ciw8 != 0) len = 40;
314 else if (cu->ciw7 != 0) len = 36;
315 else if (cu->ciw6 != 0) len = 32;
316 else if (cu->ciw5 != 0) len = 28;
317 else if (cu->ciw4 != 0) len = 24;
318 else if (cu->ciw3 != 0) len = 20;
319 else if (cu->ciw2 != 0) len = 16;
320 else if (cu->ciw1 != 0) len = 12;
321 else len = 7;
322
323 /* If LEGACYSENSEID ENABLE is not set and device is a 2311
324 or 2314, set devid length to zero to force command reject
325 response to 0xE4 Sense ID command */
326 if (1
327 && !sysblk.legacysenseid
328 && (0
329 || 0x2311 == ckd->devt
330 || 0x2314 == ckd->devt
331 )
332 )
333 {
334 len = 0;
335 }
336
337 return len;
338 }
339
340
341 /*-------------------------------------------------------------------*/
342 /* Build CKD devchar field */
343 /*-------------------------------------------------------------------*/
dasd_build_ckd_devchar(CKDDEV * ckd,CKDCU * cu,BYTE * devchar,int cyls)344 int dasd_build_ckd_devchar (CKDDEV *ckd, CKDCU *cu, BYTE *devchar,
345 int cyls)
346 {
347 int altcyls; /* Number alternate cyls */
348
349 if (cyls > ckd->cyls) altcyls = cyls - ckd->cyls;
350 else altcyls = 0;
351
352 memset (devchar, 0, 64);
353 store_hw(devchar+0, cu->devt); // Storage control type
354 devchar[2] = cu->model; // CU model
355 store_hw(devchar+3, ckd->devt); // Device type
356 devchar[5] = ckd->model; // Device model
357 store_fw(devchar+6, cu->sctlfeat | // Device and SD facilities
358 (cu->devt == 0x3990 && // ... or in 24-byte sense
359 ckd->devt == 0x3380)); // ... compatability for 3380
360 // ... hosted on 3990 controller
361 devchar[10] = ckd->class; // Device class code
362 devchar[11] = ckd->code; // Device type code
363 store_hw(devchar+12, cyls - altcyls); // Primary cylinders
364 store_hw(devchar+14, ckd->heads); // Tracks per cylinder
365 devchar[16] = (BYTE)(ckd->sectors); // Number of sectors
366 store_hw(devchar+18, ckd->len); // Track length
367 store_hw(devchar+20, ckd->har0); // Length of HA and R0
368 if (ckd->formula == 1)
369 {
370 devchar[22] = (BYTE)(ckd->formula); // Track capacity formula
371 devchar[23] = (BYTE)(ckd->f1); // Factor F1
372 store_hw(devchar+24, ckd->f2); // Factor F2
373 store_hw(devchar+26, ckd->f3); // Factor F3
374 }
375 else if (ckd->formula == 2)
376 {
377 devchar[22] = (BYTE)(ckd->formula); // Track capacity formula
378 devchar[23] = (BYTE)(ckd->f1); // Factor F1
379 devchar[24] = (BYTE)(ckd->f2); // Factor F2
380 devchar[25] = (BYTE)(ckd->f3); // Factor F3
381 devchar[26] = (BYTE)(ckd->f4); // Factor F4
382 devchar[27] = (BYTE)(ckd->f5); // Factor F5
383 }
384 if (altcyls > 0)
385 {
386 store_hw(devchar+28, cyls - altcyls); // Alternate cylinder & tracks
387 store_hw(devchar+30, altcyls * ckd->heads);
388 }
389 devchar[40] = ckd->code; // MDR record ID
390 devchar[41] = ckd->code; // OBR record ID
391 devchar[42] = cu->code; // CU Type Code
392 devchar[43] = 0x02; // Parameter length
393 store_hw(devchar+44, ckd->r0); // Record 0 length
394 devchar[47] = 0x01; // Track set
395 devchar[48] = (BYTE)(ckd->f6); // F6
396 store_hw(devchar+49, ckd->rpscalc); // RPS factor
397 /* Bytes 51-53 are required for VSAM Extended Format */
398 if (MODEL3(cu)) { // 3990-3
399 devchar[51] = 0x0f; // Feature buffer lower limit
400 devchar[52] = 0x00; // Feature buffer upper limit
401 devchar[53] = 0x3f; // Feature buffer upper limit
402 }
403 if (MODEL6(cu)) { // 3990-6
404 devchar[51] = 0x0f; // Feature buffer lower limit
405 devchar[52] = 0x00; // Feature buffer upper limit
406 devchar[53] = 0x7f; // Feature buffer upper limit
407 }
408 devchar[54] = cu->funcfeat; // device/CU functions/features
409 devchar[56] = cu->typecode; // Real CU type code
410
411 /*---------------------------------------------------------------*/
412 /* 2007/05/04 @kl */
413 /* The following line to set devchar[57] to 0xff was restored */
414 /* to circumvent a command reject when ICKDSF issues a Read */
415 /* Special Home Address (0x0a) to an alternate track. */
416 /* According to the IBM 3880 Storage Control Reference, */
417 /* GA16-1661-09, and the 3990/9330 Reference, GA32-0274-05, */
418 /* it should be 0x00 for real 3380 and 3390 devices. Setting */
419 /* it to 0xff makes the underlying real DASD look like a */
420 /* disk array (whose virtual 3380/3390 disks have no alternate */
421 /* tracks). This causes DSF to skip issuing the 0x0a channel */
422 /* command, which Hercules does not currently support, for */
423 /* alternate tracks. */
424 /*---------------------------------------------------------------*/
425 devchar[57] = 0xff; // real device type code
426
427 return 64;
428 }
429
430
431 /*-------------------------------------------------------------------*/
432 /* Build CKD configuration data */
433 /*-------------------------------------------------------------------*/
dasd_build_ckd_config_data(DEVBLK * dev,BYTE * iobuf,int count)434 DLL_EXPORT int dasd_build_ckd_config_data (DEVBLK *dev, BYTE *iobuf, int count)
435 {
436 int i;
437 BYTE buf[256];
438
439 /* Clear the configuration data area */
440 memset (buf, 0, 256);
441
442 /* Bytes 0-31: NED 1 Node element descriptor for the device */
443 store_fw (buf, 0xc4010100);
444 sprintf ((char *)&buf[4], " %4.4X0%2.2XHRCZZ000000000001",
445 dev->ckdtab->devt, dev->ckdtab->model);
446 for (i = 4; i < 30; i++)
447 buf[i] = host_to_guest(buf[i]);
448 store_hw(buf + 30, dev->devnum); /* Uniquely tag within system */
449
450 /* Bytes 32-63: NED 2 Node element descriptor for the string */
451 store_fw (buf + 32, 0xc4000000);
452 sprintf ((char *)&buf[36], " %4.4X0%2.2XHRCZZ000000000001",
453 dev->ckdtab->devt, dev->ckdtab->model);
454 for (i = 36; i < 62; i++)
455 buf[i] = host_to_guest(buf[i]);
456 store_hw (buf + 62, 0x0000);
457
458 /* Bytes 64-95: NED 3 Node element descriptor for the storage director */
459 store_fw (buf + 64, 0xd4020000);
460 sprintf ((char *)&buf[68], " %4.4X0%2.2XHRCZZ000000000001",
461 dev->ckdcu->devt, dev->ckdcu->model);
462 for (i = 68; i < 94; i++)
463 buf[i] = host_to_guest(buf[i]);
464 buf[94] = 0x00;
465 buf[95] = (dev->devnum >> 8) & 0xFF;
466
467 /* Bytes 96-127: NED 4 Node element descriptor for the subsystem */
468 store_fw (buf + 96, 0xF0000001);
469 sprintf ((char *)&buf[100], " %4.4X HRCZZ000000000001",
470 dev->ckdcu->devt);
471 for (i = 100; i < 126; i++)
472 buf[i] = host_to_guest(buf[i]);
473 store_hw (buf + 126, 0x0000);
474
475 /* Bytes 128-223: zeroes */
476
477 /* Bytes 224-255: NEQ Node Element Qualifier */
478 buf[224] = 0x80; // flags (general NEQ)
479 buf[225] = 0; // record selector
480 store_hw (buf + 226, IFID(dev)); // interface id
481 store_hw (buf + 228, 0); // must be zero
482 buf[230] = 0x1E; // primary missing interrupt timer interval
483 buf[231] = 0x00; // secondary missing interrupt timer interval
484 store_hw (buf + 232, SSID(dev)); // subsystem id
485 buf[234] = 0x80; // path/cluster id
486 buf[235] = (dev->devnum & 0xFF); // unit address
487 buf[236] = (dev->devnum & 0xFF); // physical device id
488 buf[237] = (dev->devnum & 0xFF); // physical device address
489 buf[238] = buf[227]; // SA ID (same as interface ID, byte 227)
490 store_hw (buf + 239, 0); // escon link address
491 buf[241] = 0x80; // interface protocol type (parallel)
492 // buf[241] = 0x40; // interface protocol type (escon)
493 buf[242] = 0x80; // NEQ format flags
494 buf[243] = (dev->devnum & 0xFF); // logical device address (LDA)
495 // bytes 244-255 must be zero
496
497 /* Copy data characteristics to the I/O buf */
498 count = count > 256 ? 256 : count;
499 memcpy (iobuf, buf, count);
500
501 return 256;
502 }
503
504
505 /*-------------------------------------------------------------------*/
506 /* Build CKD subsystem status */
507 /*-------------------------------------------------------------------*/
dasd_build_ckd_subsys_status(DEVBLK * dev,BYTE * iobuf,int count)508 DLL_EXPORT int dasd_build_ckd_subsys_status (DEVBLK *dev, BYTE *iobuf, int count)
509 {
510 int num;
511 BYTE buf[44];
512
513 /* Build the basic subsystem status data in the I/O area */
514 memset (buf, 0, 44);
515 buf[1] = dev->devnum & 0xFF;
516 buf[2] = DEVICES_PER_SUBSYS - 1;
517 store_hw (buf + 38, SSID(dev));
518 num = 40;
519
520 /* Build an additional 4 bytes of data for the 3990-6 */
521 if (MODEL6(dev->ckdcu))
522 {
523 buf[0] = 0x01; /* Set 3990-6 enhanced flag */
524 num = 44;
525 } /* end if(3990-6) */
526
527 /* Copy subsystem status to the I/O buf */
528 count = count > num ? num : count;
529 memcpy (iobuf, buf, count);
530
531 return num;
532 }
533
534
535 /*-------------------------------------------------------------------*/
536 /* Build FBA devid field */
537 /*-------------------------------------------------------------------*/
dasd_build_fba_devid(FBADEV * fba,BYTE * devid)538 int dasd_build_fba_devid (FBADEV *fba, BYTE *devid)
539 {
540
541 memset (devid, 0, 256);
542
543 devid[0] = 0xff;
544 devid[1] = (fba->cu >> 8) & 0xff;
545 devid[2] = fba->cu & 0xff;
546 devid[3] = 0x01; /* assume model is 1 */
547 devid[4] = (fba->devt >> 8) & 0xff;
548 devid[5] = fba->devt & 0xff;
549 devid[6] = fba->model;
550
551 return 7;
552 }
553
554 /*-------------------------------------------------------------------*/
555 /* Build FBA devchar field */
556 /*-------------------------------------------------------------------*/
dasd_build_fba_devchar(FBADEV * fba,BYTE * devchar,int blks)557 int dasd_build_fba_devchar (FBADEV *fba, BYTE *devchar, int blks)
558 {
559
560 memset (devchar, 0, 64);
561
562 devchar[0] = 0x30; // operation modes
563 devchar[1] = 0x08; // features
564 devchar[2] = fba->class; // device class
565 devchar[3] = fba->type; // unit type
566 devchar[4] = (fba->size >> 8) & 0xff; // block size
567 devchar[5] = fba->size & 0xff;
568 devchar[6] = (fba->bpg >> 24) & 0xff; // blks per cyclical group
569 devchar[7] = (fba->bpg >> 16) & 0xff;
570 devchar[8] = (fba->bpg >> 8) & 0xff;
571 devchar[9] = fba->bpg & 0xff;
572 devchar[10] = (fba->bpp >> 24) & 0xff; // blks per access position
573 devchar[11] = (fba->bpp >> 16) & 0xff;
574 devchar[12] = (fba->bpp >> 8) & 0xff;
575 devchar[13] = fba->bpp & 0xff;
576 devchar[14] = (blks >> 24) & 0xff; // blks under movable heads
577 devchar[15] = (blks >> 16) & 0xff;
578 devchar[16] = (blks >> 8) & 0xff;
579 devchar[17] = blks & 0xff;
580 devchar[18] = 0; // blks under fixed heads
581 devchar[19] = 0;
582 devchar[20] = 0;
583 devchar[21] = 0;
584 devchar[22] = 0; // blks in alternate area
585 devchar[23] = 0;
586 devchar[24] = 0; // blks in CE+SA areas
587 devchar[25] = 0;
588 devchar[26] = 0; // cyclic period in ms
589 devchar[27] = 0;
590 devchar[28] = 0; // min time to change access
591 devchar[29] = 0; // position in ms
592 devchar[30] = 0; // max to change access
593 devchar[31] = 0; // position in ms
594
595 return 32;
596 }
597