Skip to content

Commit 2ba2c31

Browse files
committed
CCKD64 Support! (part 1 of 2):
Part of ongoing CCKD64 effort. This commit lays the groundwork to make it easier to see the actual CCKD64 changes in the upcoming part 2 commit. This commit is MOSTLY cosmetic (e.g. struct field renames, function renames, coding style white-space and comment tweaks, etc), BUT... also includes the following NON-cosmetic changes too: * cckd_cmd debug option now actually does something. * track length and track validation functions rewritten/cleaned up. * Utility messages fixed to be MSGLVL(DEBUG) compatible (fprintf changed to FWRMSG). * fetch_fw/store_fw/FETCH_LE_FW/STORE_LE_FW/etc used where appropriate. * Reorganize/consolidate static vars into global statics. * Use #define constants where possible. * Enable previously suppressed important compiler warnings.
1 parent 9e1b0a6 commit 2ba2c31

39 files changed

+3170
-2368
lines changed

Hercules_VS2008.vcproj

+4
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,10 @@
510510
RelativePath=".\shared.h"
511511
>
512512
</File>
513+
<File
514+
RelativePath=".\cckd64.h"
515+
>
516+
</File>
513517
</Filter>
514518
<Filter
515519
Name="Source Files"

Hercules_VS2015.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,7 @@
946946
<ClInclude Include="cache.h" />
947947
<ClInclude Include="ccfixme.h" />
948948
<ClInclude Include="cckd.h" />
949+
<ClInclude Include="cckd64.h" />
949950
<ClInclude Include="ccnowarn.h" />
950951
<ClInclude Include="ccwarn.h" />
951952
<ClInclude Include="chain.h" />

Hercules_VS2015.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,9 @@
22722272
<ClInclude Include="cckd.h">
22732273
<Filter>Source Files\Hercules\Devices\Dasd\Header Files</Filter>
22742274
</ClInclude>
2275+
<ClInclude Include="cckd64.h">
2276+
<Filter>Source Files\Hercules\Devices\Dasd\Header Files</Filter>
2277+
</ClInclude>
22752278
<ClInclude Include="dasdblks.h">
22762279
<Filter>Source Files\Hercules\Devices\Dasd\Header Files</Filter>
22772280
</ClInclude>

Hercules_VS2017.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,7 @@
946946
<ClInclude Include="cache.h" />
947947
<ClInclude Include="ccfixme.h" />
948948
<ClInclude Include="cckd.h" />
949+
<ClInclude Include="cckd64.h" />
949950
<ClInclude Include="ccnowarn.h" />
950951
<ClInclude Include="ccwarn.h" />
951952
<ClInclude Include="chain.h" />

Hercules_VS2017.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,9 @@
22722272
<ClInclude Include="cckd.h">
22732273
<Filter>Source Files\Hercules\Devices\Dasd\Header Files</Filter>
22742274
</ClInclude>
2275+
<ClInclude Include="cckd64.h">
2276+
<Filter>Source Files\Hercules\Devices\Dasd\Header Files</Filter>
2277+
</ClInclude>
22752278
<ClInclude Include="dasdblks.h">
22762279
<Filter>Source Files\Hercules\Devices\Dasd\Header Files</Filter>
22772280
</ClInclude>

Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ noinst_HEADERS = \
773773
cache.h \
774774
ccfixme.h \
775775
cckd.h \
776+
cckd64.h \
776777
ccnowarn.h \
777778
ccwarn.h \
778779
chain.h \

cache.h

+28-17
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ static void cache_allocbuf(int ix, int i, int len);
302302
/*-------------------------------------------------------------------*/
303303
/* Device buffer definitions */
304304
/*-------------------------------------------------------------------*/
305+
305306
#define CCKD_CACHE_ACTIVE 0x80000000 /* Active entry */
306307
#define CCKD_CACHE_READING 0x40000000 /* Entry being read */
307308
#define CCKD_CACHE_WRITING 0x20000000 /* Entry being written */
@@ -325,49 +326,59 @@ static void cache_allocbuf(int ix, int i, int len);
325326
#define DEVBUF_TYPE_SCKD (DEVBUF_TYPE_SHARED|DEVBUF_TYPE_CKD)
326327
#define DEVBUF_TYPE_SFBA (DEVBUF_TYPE_SHARED|DEVBUF_TYPE_FBA)
327328

329+
/*-------------------------------------------------------------------*/
330+
328331
#define CCKD_CACHE_GETKEY(_ix, _devnum, _trk) \
329332
do { \
330-
(_devnum) = (U16)((cache_getkey(CACHE_DEVBUF,(_ix)) >> 32) & 0xFFFF); \
331-
(_trk) = (U32)(cache_getkey(CACHE_DEVBUF,(_ix)) & 0xFFFFFFFF); \
333+
(_devnum) = (U16)((cache_getkey(CACHE_DEVBUF,(_ix)) >> 32) & 0xFFFF ); \
334+
(_trk) = (U32)((cache_getkey(CACHE_DEVBUF,(_ix)) ) & 0xFFFFFFFF); \
332335
} while (0)
333-
#define CCKD_CACHE_SETKEY(_devnum, _trk) \
334-
((U64)(((U64)(_devnum) << 32) | (U64)(_trk)))
335336

336337
#define CKD_CACHE_GETKEY(_ix, _devnum, _trk) \
337338
{ \
338-
(_devnum) = (U16)((cache_getkey(CACHE_DEVBUF,(_ix)) >> 32) & 0xFFFF); \
339-
(_trk) = (U32)(cache_getkey(CACHE_DEVBUF,(_ix)) & 0xFFFFFFFF); \
339+
(_devnum) = (U16)((cache_getkey(CACHE_DEVBUF,(_ix)) >> 32) & 0xFFFF ); \
340+
(_trk) = (U32)((cache_getkey(CACHE_DEVBUF,(_ix)) )& 0xFFFFFFFF); \
340341
}
341-
#define CKD_CACHE_SETKEY(_devnum, _trk) \
342-
((U64)(((U64)(_devnum) << 32) | (U64)(_trk)))
343342

344343
#define FBA_CACHE_GETKEY(_ix, _devnum, _blkgrp) \
345344
{ \
346-
(_devnum) = (U16)((cache_getkey(CACHE_DEVBUF,(_ix)) >> 32) & 0xFFFF); \
347-
(_blkgrp) = (U32)(cache_getkey(CACHE_DEVBUF,(_ix)) & 0xFFFFFFFF); \
345+
(_devnum) = (U16)((cache_getkey(CACHE_DEVBUF,(_ix)) >> 32) & 0xFFFF ); \
346+
(_blkgrp) = (U32)((cache_getkey(CACHE_DEVBUF,(_ix)) ) & 0xFFFFFFFF); \
348347
}
349-
#define FBA_CACHE_SETKEY(_devnum, _blkgrp) \
350-
((U64)(((U64)(_devnum) << 32) | (U64)(_blkgrp)))
351348

352349
#define SHRD_CACHE_GETKEY(_ix, _devnum, _trk) \
353350
{ \
354-
(_devnum) = (U16)((cache_getkey(CACHE_DEVBUF,(_ix)) >> 32) & 0xFFFF); \
355-
(_trk) = (U32)(cache_getkey(CACHE_DEVBUF,(_ix)) & 0xFFFFFFFF); \
351+
(_devnum) = (U16)((cache_getkey(CACHE_DEVBUF,(_ix)) >> 32) & 0xFFFF ); \
352+
(_trk) = (U32)((cache_getkey(CACHE_DEVBUF,(_ix)) ) & 0xFFFFFFFF); \
356353
}
354+
355+
/*-------------------------------------------------------------------*/
356+
357+
#define CCKD_CACHE_SETKEY(_devnum, _trk) \
358+
((U64)(((U64)(_devnum) << 32) | (U64)(_trk)))
359+
360+
#define CKD_CACHE_SETKEY(_devnum, _trk) \
361+
((U64)(((U64)(_devnum) << 32) | (U64)(_trk)))
362+
363+
#define FBA_CACHE_SETKEY(_devnum, _blkgrp) \
364+
((U64)(((U64)(_devnum) << 32) | (U64)(_blkgrp)))
365+
357366
#define SHRD_CACHE_SETKEY(_devnum, _trk) \
358367
((U64)(((U64)(_devnum) << 32) | (U64)(_trk)))
359368

360369
/*-------------------------------------------------------------------*/
361370
/* L2 definitions */
362371
/*-------------------------------------------------------------------*/
372+
363373
#define L2_CACHE_ACTIVE 0x80000000 /* Active entry */
364374

365375
#define L2_CACHE_GETKEY(_ix, _sfx, _devnum, _trk) \
366376
do { \
367-
(_sfx) = (U16)((cache_getkey(CACHE_L2,(_ix)) >> 48) & 0xFFFF); \
368-
(_devnum) = (U16)((cache_getkey(CACHE_L2,(_ix)) >> 32) & 0xFFFF); \
369-
(_trk) = (U32)(cache_getkey(CACHE_L2,(_ix)) & 0xFFFFFFFF); \
377+
(_sfx) = (U16)((cache_getkey(CACHE_L2,(_ix)) >> 48) & 0xFFFF ); \
378+
(_devnum) = (U16)((cache_getkey(CACHE_L2,(_ix)) >> 32) & 0xFFFF ); \
379+
(_trk) = (U32)((cache_getkey(CACHE_L2,(_ix)) ) & 0xFFFFFFFF); \
370380
} while (0)
381+
371382
#define L2_CACHE_SETKEY(_sfx, _devnum, _trk) \
372383
((U64)(((U64)(_sfx) << 48) | ((U64)(_devnum) << 32) | (U64)(_trk)))
373384

cckd.h

+48-43
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,29 @@ typedef struct CCKD_EXT CCKD_EXT; // CCKD Extension block
2525
typedef struct SPCTAB SPCTAB; // Space table
2626

2727
/*-------------------------------------------------------------------*/
28-
/* Structure definitions for CKD headers */
28+
/* Structure definitions for CKD headers */
29+
/*-------------------------------------------------------------------*/
30+
/* NOTE: The dh_heads, dh_trksize and dh_highcyl */
31+
/* values are always kept in LITTLE endian format. */
2932
/*-------------------------------------------------------------------*/
3033
struct CKD_DEVHDR /* Device header */
3134
{
32-
BYTE devhdrid[8]; /* ASCII Device Header id;
35+
BYTE dh_devid[8]; /* ASCII Device Header id;
3336
see dasdblks.h for list */
34-
35-
FWORD heads; /* CKD: heads per cylinder
36-
CFBA: number of sectors
37-
(bytes in reverse order) */
38-
39-
FWORD trksize; /* CKD: track size
40-
CFBA: sector size
41-
(bytes in reverse order) */
42-
43-
BYTE dvtyp; /* Low byte of hex device type
37+
FWORD dh_heads; /* CKD: heads per cylinder
38+
CFBA: number of sectors */
39+
FWORD dh_trksize; /* CKD: track size
40+
CFBA: sector size */
41+
BYTE dh_devtyp; /* Low byte of hex device type
4442
(x80=3380, x90=3390, etc) */
45-
46-
BYTE fileseq; /* CKD: image file sequence no.
43+
BYTE dh_fileseq; /* CKD: image file sequence no.
4744
(0=only file, 1=first file
4845
of multiple files)
4946
CFBA: 0 (not used) */
50-
51-
HWORD highcyl; /* CKD: Highest cylinder number
47+
HWORD dh_highcyl; /* CKD: Highest cylinder number
5248
on this file, or zero if this
5349
is the last or only file.
54-
CFBA: zero (not used)
55-
(bytes in reverse order) */
56-
50+
CFBA: zero (not used) */
5751
BYTE resv[492]; /* Reserved */
5852
};
5953

@@ -92,45 +86,41 @@ struct CKD_RECHDR { /* Record header */
9286
#define CKD_NULLTRK_SIZE2 (5 + 8 + 8 + (12 * (8 + 4096)) + 8)
9387

9488
/*-------------------------------------------------------------------*/
95-
/* Structure definitions for Compressed CCKD/CFBA devices */
89+
/* Structure definitions for Compressed CCKD/CFBA devices */
90+
/*-------------------------------------------------------------------*/
91+
/* NOTE: The num_L1tab, num_L2tab, cyls, cdh_size, cdh_used, */
92+
/* free_off, free_total, free_largest, free_num, free_imbed, */
93+
/* and cmp_parm fields are kept in LITTLE endian format. */
9694
/*-------------------------------------------------------------------*/
9795
struct CCKD_DEVHDR /* Compress device header */
9896
{
99-
/* 0 */BYTE vrm[3]; /* Version Release Modifier */
100-
/* 3 */BYTE opts; /* Options byte */
101-
97+
/* 0 */BYTE cdh_vrm[3]; /* Version Release Modifier */
98+
/* 3 */BYTE cdh_opts; /* Options byte */
10299
/* 4 */S32 num_L1tab; /* Number of L1tab entries */
103100
/* 8 */S32 num_L2tab; /* Number of L2tab entries */
104-
105101
/* 12 */U32 cdh_size; /* File size */
106102
/* 16 */U32 cdh_used; /* File used */
107-
108103
/* 20 */U32 free_off; /* Offset to free space */
109104
/* 24 */U32 free_total; /* Total free space */
110105
/* 28 */U32 free_largest; /* Largest free space */
111106
/* 32 */S32 free_num; /* Number free spaces */
112107
/* 36 */U32 free_imbed; /* Imbedded free space */
113-
114-
/* 40 */FWORD cyls; /* CCKD: Cylinders on device
108+
/* 40 */FWORD cdh_cyls; /* CCKD: Cylinders on device
115109
CFBA: Sectors on device */
116-
117-
/* 44 */BYTE nullfmt; /* Null track format */
118-
110+
/* 44 */BYTE cdh_nullfmt; /* Null track format */
119111
/* 45 */BYTE cmp_algo; /* Compression algorithm */
120112
/* 46 */S16 cmp_parm; /* Compression parameter */
121-
122113
/* 48 */BYTE resv2[464]; /* Reserved */
123114
};
124115

125116
#define CCKD_VERSION 0
126117
#define CCKD_RELEASE 3
127118
#define CCKD_MODLVL 1
128119

129-
#define CCKD_BIGENDIAN 2
130-
#define CCKD_SPERRS 32 /* Space errors detected */
131-
#define CCKD_ORDWR 64 /* Opened read/write since
132-
last chkdsk */
133-
#define CCKD_OPENED 128
120+
#define CCKD_OPT_BIGEND 0x02 /* file in BIG endian format */
121+
#define CCKD_OPT_SPERRS 0x20 /* Space errors detected */
122+
#define CCKD_OPT_OPENRW 0x40 /* Opened R/W since last chkdsk */
123+
#define CCKD_OPT_OPENED 0x80
134124

135125
#define CCKD_COMPRESS_NONE 0x00
136126
#define CCKD_COMPRESS_ZLIB 0x01
@@ -147,17 +137,30 @@ struct CCKD_DEVHDR /* Compress device header */
147137
#define CCKD_STRESS_PARM2 2
148138

149139
struct CCKD_L2ENT { /* Level 2 table entry */
140+
141+
/* NOTE: all fields are numeric and always in LITTLE endian format. */
142+
150143
U32 L2_trkoff; /* Offset to track image */
151144
U16 L2_len; /* Track length */
152145
U16 L2_size; /* Track size (size >= len) */
153146
};
154147

155148
struct CCKD_FREEBLK { /* Free block (file) */
149+
150+
/* NOTE: all fields are numeric and always in LITTLE endian format. */
151+
156152
U32 fb_offnxt; /* Offset to next free blk */
157153
U32 fb_len; /* Length this free blk */
158154
};
159155

160156
struct CCKD_IFREEBLK { /* Free block (internal) */
157+
158+
/* NOTE: because this control block is an INTERNAL control block */
159+
/* which does not actually exist in the emulated dasd image file */
160+
/* (i.e. it is only used internally), all of its fields are always */
161+
/* in *HOST* endian format (little endian on little endian hosts */
162+
/* and big endian on big endian hosts). */
163+
161164
U32 ifb_offnxt; /* Offset to next free blk */
162165
U32 ifb_len; /* Length this free blk */
163166
int ifb_idxprv; /* Index to prev free blk */
@@ -206,6 +209,7 @@ typedef char CCKD_TRACE[128]; /* Trace table entry */
206209
#define CCKD_MAX_RA 9 /* Max readahead threads */
207210
#define CCKD_MAX_WRITER 9 /* Max writer threads */
208211
#define CCKD_MAX_GCOL 1 /* Max garbage collectors */
212+
#define CCKD_DEF_TRACE 3 /* Def nbr trace entries */
209213
#define CCKD_MAX_TRACE 200000 /* Max nbr trace entries */
210214
#define CCKD_MAX_FREEPEND 4 /* Max free pending cycles */
211215

@@ -224,20 +228,15 @@ typedef char CCKD_TRACE[128]; /* Trace table entry */
224228
#define CCKD_DEF_READAHEADS 2 /* Default nbr to read ahead */
225229
#define CCKD_DEF_FREEPEND -1 /* Default freepend cycles */
226230

227-
#define CFBA_BLKGRP_BLKS 120 /* Number fba blocks / group */
228-
#define CFBA_BLKGRP_SIZE 61440 /* Size of a block group 60k */
229-
/* Number of bytes in an fba
230-
block group. Probably
231-
should be a multiple of 512
232-
but has to be < 64K */
233-
234231
/*-------------------------------------------------------------------*/
235232
/* Global CCKD dasd block */
236233
/*-------------------------------------------------------------------*/
237234
struct CCKDBLK { /* Global cckd dasd block */
238235
BYTE id[8]; /* "CCKDBLK " */
236+
#define CCKDBLK_ID "CCKDBLK " /* "CCKDBLK " */
239237
DEVBLK *dev1st; /* 1st device in cckd queue */
240238
unsigned int batch:1, /* 1=called in batch mode */
239+
debug:1, /* 1=CCW trace debug msgs */
241240
sfmerge:1, /* 1=sf-* merge */
242241
sfforce:1; /* 1=sf-* force */
243242
int sflevel; /* sfk xxxx level */
@@ -414,4 +413,10 @@ struct SPCTAB
414413
#define SPCTAB_FREE 7 /* Space is free block */
415414
#define SPCTAB_EOF 8 /* Space is end-of-file */
416415

416+
/*-------------------------------------------------------------------*/
417+
/* CCKD64 structs and definitions */
418+
/*-------------------------------------------------------------------*/
419+
420+
#include "cckd64.h" /* 64-bit CCKD64 structs/constants */
421+
417422
#endif // _CCKD_H_

0 commit comments

Comments
 (0)