diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-s390/vtoc.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/asm-s390/vtoc.h')
-rw-r--r-- | include/asm-s390/vtoc.h | 372 |
1 files changed, 372 insertions, 0 deletions
diff --git a/include/asm-s390/vtoc.h b/include/asm-s390/vtoc.h new file mode 100644 index 000000000000..a14e34e80b88 --- /dev/null +++ b/include/asm-s390/vtoc.h | |||
@@ -0,0 +1,372 @@ | |||
1 | #ifndef __KERNEL__ | ||
2 | #include <string.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <stdio.h> | ||
5 | #include <errno.h> | ||
6 | #include <ctype.h> | ||
7 | #include <time.h> | ||
8 | #include <fcntl.h> | ||
9 | #include <unistd.h> | ||
10 | |||
11 | #include <sys/stat.h> | ||
12 | #include <sys/ioctl.h> | ||
13 | |||
14 | #include <linux/fs.h> | ||
15 | #include <linux/types.h> | ||
16 | #include <linux/hdreg.h> | ||
17 | #include <asm/dasd.h> | ||
18 | #endif | ||
19 | |||
20 | |||
21 | #define LINE_LENGTH 80 | ||
22 | #define VTOC_START_CC 0x0 | ||
23 | #define VTOC_START_HH 0x1 | ||
24 | #define FIRST_USABLE_CYL 1 | ||
25 | #define FIRST_USABLE_TRK 2 | ||
26 | |||
27 | #define DASD_3380_TYPE 13148 | ||
28 | #define DASD_3390_TYPE 13200 | ||
29 | #define DASD_9345_TYPE 37701 | ||
30 | |||
31 | #define DASD_3380_VALUE 0xbb60 | ||
32 | #define DASD_3390_VALUE 0xe5a2 | ||
33 | #define DASD_9345_VALUE 0xbc98 | ||
34 | |||
35 | #define VOLSER_LENGTH 6 | ||
36 | #define BIG_DISK_SIZE 0x10000 | ||
37 | |||
38 | #define VTOC_ERROR "VTOC error:" | ||
39 | |||
40 | |||
41 | typedef struct ttr | ||
42 | { | ||
43 | __u16 tt; | ||
44 | __u8 r; | ||
45 | } __attribute__ ((packed)) ttr_t; | ||
46 | |||
47 | typedef struct cchhb | ||
48 | { | ||
49 | __u16 cc; | ||
50 | __u16 hh; | ||
51 | __u8 b; | ||
52 | } __attribute__ ((packed)) cchhb_t; | ||
53 | |||
54 | typedef struct cchh | ||
55 | { | ||
56 | __u16 cc; | ||
57 | __u16 hh; | ||
58 | } __attribute__ ((packed)) cchh_t; | ||
59 | |||
60 | typedef struct labeldate | ||
61 | { | ||
62 | __u8 year; | ||
63 | __u16 day; | ||
64 | } __attribute__ ((packed)) labeldate_t; | ||
65 | |||
66 | |||
67 | typedef struct volume_label | ||
68 | { | ||
69 | char volkey[4]; /* volume key = volume label */ | ||
70 | char vollbl[4]; /* volume label */ | ||
71 | char volid[6]; /* volume identifier */ | ||
72 | __u8 security; /* security byte */ | ||
73 | cchhb_t vtoc; /* VTOC address */ | ||
74 | char res1[5]; /* reserved */ | ||
75 | char cisize[4]; /* CI-size for FBA,... */ | ||
76 | /* ...blanks for CKD */ | ||
77 | char blkperci[4]; /* no of blocks per CI (FBA), blanks for CKD */ | ||
78 | char labperci[4]; /* no of labels per CI (FBA), blanks for CKD */ | ||
79 | char res2[4]; /* reserved */ | ||
80 | char lvtoc[14]; /* owner code for LVTOC */ | ||
81 | char res3[29]; /* reserved */ | ||
82 | } __attribute__ ((packed)) volume_label_t; | ||
83 | |||
84 | |||
85 | typedef struct extent | ||
86 | { | ||
87 | __u8 typeind; /* extent type indicator */ | ||
88 | __u8 seqno; /* extent sequence number */ | ||
89 | cchh_t llimit; /* starting point of this extent */ | ||
90 | cchh_t ulimit; /* ending point of this extent */ | ||
91 | } __attribute__ ((packed)) extent_t; | ||
92 | |||
93 | |||
94 | typedef struct dev_const | ||
95 | { | ||
96 | __u16 DS4DSCYL; /* number of logical cyls */ | ||
97 | __u16 DS4DSTRK; /* number of tracks in a logical cylinder */ | ||
98 | __u16 DS4DEVTK; /* device track length */ | ||
99 | __u8 DS4DEVI; /* non-last keyed record overhead */ | ||
100 | __u8 DS4DEVL; /* last keyed record overhead */ | ||
101 | __u8 DS4DEVK; /* non-keyed record overhead differential */ | ||
102 | __u8 DS4DEVFG; /* flag byte */ | ||
103 | __u16 DS4DEVTL; /* device tolerance */ | ||
104 | __u8 DS4DEVDT; /* number of DSCB's per track */ | ||
105 | __u8 DS4DEVDB; /* number of directory blocks per track */ | ||
106 | } __attribute__ ((packed)) dev_const_t; | ||
107 | |||
108 | |||
109 | typedef struct format1_label | ||
110 | { | ||
111 | char DS1DSNAM[44]; /* data set name */ | ||
112 | __u8 DS1FMTID; /* format identifier */ | ||
113 | char DS1DSSN[6]; /* data set serial number */ | ||
114 | __u16 DS1VOLSQ; /* volume sequence number */ | ||
115 | labeldate_t DS1CREDT; /* creation date: ydd */ | ||
116 | labeldate_t DS1EXPDT; /* expiration date */ | ||
117 | __u8 DS1NOEPV; /* number of extents on volume */ | ||
118 | __u8 DS1NOBDB; /* no. of bytes used in last direction blk */ | ||
119 | __u8 DS1FLAG1; /* flag 1 */ | ||
120 | char DS1SYSCD[13]; /* system code */ | ||
121 | labeldate_t DS1REFD; /* date last referenced */ | ||
122 | __u8 DS1SMSFG; /* system managed storage indicators */ | ||
123 | __u8 DS1SCXTF; /* sec. space extension flag byte */ | ||
124 | __u16 DS1SCXTV; /* secondary space extension value */ | ||
125 | __u8 DS1DSRG1; /* data set organisation byte 1 */ | ||
126 | __u8 DS1DSRG2; /* data set organisation byte 2 */ | ||
127 | __u8 DS1RECFM; /* record format */ | ||
128 | __u8 DS1OPTCD; /* option code */ | ||
129 | __u16 DS1BLKL; /* block length */ | ||
130 | __u16 DS1LRECL; /* record length */ | ||
131 | __u8 DS1KEYL; /* key length */ | ||
132 | __u16 DS1RKP; /* relative key position */ | ||
133 | __u8 DS1DSIND; /* data set indicators */ | ||
134 | __u8 DS1SCAL1; /* secondary allocation flag byte */ | ||
135 | char DS1SCAL3[3]; /* secondary allocation quantity */ | ||
136 | ttr_t DS1LSTAR; /* last used track and block on track */ | ||
137 | __u16 DS1TRBAL; /* space remaining on last used track */ | ||
138 | __u16 res1; /* reserved */ | ||
139 | extent_t DS1EXT1; /* first extent description */ | ||
140 | extent_t DS1EXT2; /* second extent description */ | ||
141 | extent_t DS1EXT3; /* third extent description */ | ||
142 | cchhb_t DS1PTRDS; /* possible pointer to f2 or f3 DSCB */ | ||
143 | } __attribute__ ((packed)) format1_label_t; | ||
144 | |||
145 | |||
146 | typedef struct format4_label | ||
147 | { | ||
148 | char DS4KEYCD[44]; /* key code for VTOC labels: 44 times 0x04 */ | ||
149 | __u8 DS4IDFMT; /* format identifier */ | ||
150 | cchhb_t DS4HPCHR; /* highest address of a format 1 DSCB */ | ||
151 | __u16 DS4DSREC; /* number of available DSCB's */ | ||
152 | cchh_t DS4HCCHH; /* CCHH of next available alternate track */ | ||
153 | __u16 DS4NOATK; /* number of remaining alternate tracks */ | ||
154 | __u8 DS4VTOCI; /* VTOC indicators */ | ||
155 | __u8 DS4NOEXT; /* number of extents in VTOC */ | ||
156 | __u8 DS4SMSFG; /* system managed storage indicators */ | ||
157 | __u8 DS4DEVAC; /* number of alternate cylinders. | ||
158 | Subtract from first two bytes of | ||
159 | DS4DEVSZ to get number of usable | ||
160 | cylinders. can be zero. valid | ||
161 | only if DS4DEVAV on. */ | ||
162 | dev_const_t DS4DEVCT; /* device constants */ | ||
163 | char DS4AMTIM[8]; /* VSAM time stamp */ | ||
164 | char DS4AMCAT[3]; /* VSAM catalog indicator */ | ||
165 | char DS4R2TIM[8]; /* VSAM volume/catalog match time stamp */ | ||
166 | char res1[5]; /* reserved */ | ||
167 | char DS4F6PTR[5]; /* pointer to first format 6 DSCB */ | ||
168 | extent_t DS4VTOCE; /* VTOC extent description */ | ||
169 | char res2[10]; /* reserved */ | ||
170 | __u8 DS4EFLVL; /* extended free-space management level */ | ||
171 | cchhb_t DS4EFPTR; /* pointer to extended free-space info */ | ||
172 | char res3[9]; /* reserved */ | ||
173 | } __attribute__ ((packed)) format4_label_t; | ||
174 | |||
175 | |||
176 | typedef struct ds5ext | ||
177 | { | ||
178 | __u16 t; /* RTA of the first track of free extent */ | ||
179 | __u16 fc; /* number of whole cylinders in free ext. */ | ||
180 | __u8 ft; /* number of remaining free tracks */ | ||
181 | } __attribute__ ((packed)) ds5ext_t; | ||
182 | |||
183 | |||
184 | typedef struct format5_label | ||
185 | { | ||
186 | char DS5KEYID[4]; /* key identifier */ | ||
187 | ds5ext_t DS5AVEXT; /* first available (free-space) extent. */ | ||
188 | ds5ext_t DS5EXTAV[7]; /* seven available extents */ | ||
189 | __u8 DS5FMTID; /* format identifier */ | ||
190 | ds5ext_t DS5MAVET[18]; /* eighteen available extents */ | ||
191 | cchhb_t DS5PTRDS; /* pointer to next format5 DSCB */ | ||
192 | } __attribute__ ((packed)) format5_label_t; | ||
193 | |||
194 | |||
195 | typedef struct ds7ext | ||
196 | { | ||
197 | __u32 a; /* starting RTA value */ | ||
198 | __u32 b; /* ending RTA value + 1 */ | ||
199 | } __attribute__ ((packed)) ds7ext_t; | ||
200 | |||
201 | |||
202 | typedef struct format7_label | ||
203 | { | ||
204 | char DS7KEYID[4]; /* key identifier */ | ||
205 | ds7ext_t DS7EXTNT[5]; /* space for 5 extent descriptions */ | ||
206 | __u8 DS7FMTID; /* format identifier */ | ||
207 | ds7ext_t DS7ADEXT[11]; /* space for 11 extent descriptions */ | ||
208 | char res1[2]; /* reserved */ | ||
209 | cchhb_t DS7PTRDS; /* pointer to next FMT7 DSCB */ | ||
210 | } __attribute__ ((packed)) format7_label_t; | ||
211 | |||
212 | |||
213 | char * vtoc_ebcdic_enc ( | ||
214 | unsigned char source[LINE_LENGTH], | ||
215 | unsigned char target[LINE_LENGTH], | ||
216 | int l); | ||
217 | char * vtoc_ebcdic_dec ( | ||
218 | unsigned char source[LINE_LENGTH], | ||
219 | unsigned char target[LINE_LENGTH], | ||
220 | int l); | ||
221 | void vtoc_set_extent ( | ||
222 | extent_t * ext, | ||
223 | __u8 typeind, | ||
224 | __u8 seqno, | ||
225 | cchh_t * lower, | ||
226 | cchh_t * upper); | ||
227 | void vtoc_set_cchh ( | ||
228 | cchh_t * addr, | ||
229 | __u16 cc, | ||
230 | __u16 hh); | ||
231 | void vtoc_set_cchhb ( | ||
232 | cchhb_t * addr, | ||
233 | __u16 cc, | ||
234 | __u16 hh, | ||
235 | __u8 b); | ||
236 | void vtoc_set_date ( | ||
237 | labeldate_t * d, | ||
238 | __u8 year, | ||
239 | __u16 day); | ||
240 | |||
241 | void vtoc_volume_label_init ( | ||
242 | volume_label_t *vlabel); | ||
243 | |||
244 | int vtoc_read_volume_label ( | ||
245 | char * device, | ||
246 | unsigned long vlabel_start, | ||
247 | volume_label_t * vlabel); | ||
248 | |||
249 | int vtoc_write_volume_label ( | ||
250 | char *device, | ||
251 | unsigned long vlabel_start, | ||
252 | volume_label_t *vlabel); | ||
253 | |||
254 | void vtoc_volume_label_set_volser ( | ||
255 | volume_label_t *vlabel, | ||
256 | char *volser); | ||
257 | |||
258 | char *vtoc_volume_label_get_volser ( | ||
259 | volume_label_t *vlabel, | ||
260 | char *volser); | ||
261 | |||
262 | void vtoc_volume_label_set_key ( | ||
263 | volume_label_t *vlabel, | ||
264 | char *key); | ||
265 | |||
266 | void vtoc_volume_label_set_label ( | ||
267 | volume_label_t *vlabel, | ||
268 | char *lbl); | ||
269 | |||
270 | char *vtoc_volume_label_get_label ( | ||
271 | volume_label_t *vlabel, | ||
272 | char *lbl); | ||
273 | |||
274 | void vtoc_read_label ( | ||
275 | char *device, | ||
276 | unsigned long position, | ||
277 | format1_label_t *f1, | ||
278 | format4_label_t *f4, | ||
279 | format5_label_t *f5, | ||
280 | format7_label_t *f7); | ||
281 | |||
282 | void vtoc_write_label ( | ||
283 | char *device, | ||
284 | unsigned long position, | ||
285 | format1_label_t *f1, | ||
286 | format4_label_t *f4, | ||
287 | format5_label_t *f5, | ||
288 | format7_label_t *f7); | ||
289 | |||
290 | |||
291 | void vtoc_init_format1_label ( | ||
292 | char *volid, | ||
293 | unsigned int blksize, | ||
294 | extent_t *part_extent, | ||
295 | format1_label_t *f1); | ||
296 | |||
297 | |||
298 | void vtoc_init_format4_label ( | ||
299 | format4_label_t *f4lbl, | ||
300 | unsigned int usable_partitions, | ||
301 | unsigned int cylinders, | ||
302 | unsigned int tracks, | ||
303 | unsigned int blocks, | ||
304 | unsigned int blksize, | ||
305 | __u16 dev_type); | ||
306 | |||
307 | void vtoc_update_format4_label ( | ||
308 | format4_label_t *f4, | ||
309 | cchhb_t *highest_f1, | ||
310 | __u16 unused_update); | ||
311 | |||
312 | |||
313 | void vtoc_init_format5_label ( | ||
314 | format5_label_t *f5); | ||
315 | |||
316 | void vtoc_update_format5_label_add ( | ||
317 | format5_label_t *f5, | ||
318 | int verbose, | ||
319 | int cyl, | ||
320 | int trk, | ||
321 | __u16 a, | ||
322 | __u16 b, | ||
323 | __u8 c); | ||
324 | |||
325 | void vtoc_update_format5_label_del ( | ||
326 | format5_label_t *f5, | ||
327 | int verbose, | ||
328 | int cyl, | ||
329 | int trk, | ||
330 | __u16 a, | ||
331 | __u16 b, | ||
332 | __u8 c); | ||
333 | |||
334 | |||
335 | void vtoc_init_format7_label ( | ||
336 | format7_label_t *f7); | ||
337 | |||
338 | void vtoc_update_format7_label_add ( | ||
339 | format7_label_t *f7, | ||
340 | int verbose, | ||
341 | __u32 a, | ||
342 | __u32 b); | ||
343 | |||
344 | void vtoc_update_format7_label_del ( | ||
345 | format7_label_t *f7, | ||
346 | int verbose, | ||
347 | __u32 a, | ||
348 | __u32 b); | ||
349 | |||
350 | |||
351 | void vtoc_set_freespace( | ||
352 | format4_label_t *f4, | ||
353 | format5_label_t *f5, | ||
354 | format7_label_t *f7, | ||
355 | char ch, | ||
356 | int verbose, | ||
357 | __u32 start, | ||
358 | __u32 stop, | ||
359 | int cyl, | ||
360 | int trk); | ||
361 | |||
362 | |||
363 | |||
364 | |||
365 | |||
366 | |||
367 | |||
368 | |||
369 | |||
370 | |||
371 | |||
372 | |||