|
|
1.1 root 1:
2: /*
3: **
4: */
5:
6: #include <setjmp.h>
7: #include "../../machine/mtpr.h"
8: #include "../../h/param.h"
9: #include "../../h/buf.h"
10: #include "../../h/inode.h"
11: #include "../../h/fs.h"
12: #include "../../vba/vbavar.h"
13: #include "../../vba/vddc.h"
14:
15: /* Configuration parameters */
16: #define MAXCTLR 8 /* Maximum # of controllers */
17: #define MAXDRIVE 16 /* Max drives per controller */
18:
19: #define NUMMAP 1 /* # Cyls in bad sector map */
20: #define NUMMNT 1 /* # cyls for diagnostics */
21: #define NUMREL 3 /* # Cyls in relocation area */
22: #define NUMSYS (NUMREL+NUMMNT+NUMMAP) /* Total cyls used by system */
23:
24: #define MAXTRKS 24
25: #define MAXSECS_PER_TRK 66
26: #define MAXERR 1000
27: #define SECSIZ 512
28: #define TRKSIZ ((SECSIZ/sizeof(long)) * MAXSECS_PER_TRK)
29: #define bytes_trk (CURRENT->nsec * CURRENT->secsize)
30:
31: #define HARD_ERROR (DRVNRDY | INVDADR | DNEMEM | PARERR | OPABRT | \
32: WPTERR | DSEEKERR | NOTCYLERR)
33: #define DATA_ERROR (CTLRERR | UCDATERR | DCOMPERR | DSERLY | DSLATE | \
34: TOPLUS | TOMNUS | CPDCRT | \
35: HRDERR | SFTERR)
36: #define HEADER_ERROR (HCRCERR | HCMPERR)
37: #define NRM (short)0
38: #define BAD (short)VDUF
39: #define WPT (short)(NRM | VDWPT)
40: #define RELOC_SECTOR (short)(VDALT)
41: #define ALT_SECTOR (short)(VDALT)
42:
43:
44: /* New types used by VDFORMAT */
45:
46: typedef enum {false, true} boolean; /* Standard boolean expression */
47:
48: typedef enum {u_false, u_true, u_unknown} uncertain;
49:
50:
51: /* Free bad block allocation bit map */
52: typedef struct {
53: long free_error;
54: enum {ALLOCATED, NOTALLOCATED} free_status;
55: } fmt_free;
56:
57: /* Type of relocation that took place */
58: typedef enum {SINGLE_SECTOR, FULL_TRACK} rel_type;
59:
60: /* Error table format */
61: typedef struct {
62: dskadr err_adr;
63: long err_stat;
64: } fmt_err;
65:
66: /* utilities */
67:
68: int blkcopy(), blkzero(), to_sector(), to_track(), data_ok();
69: boolean blkcmp(), get_yes_no(), is_in_map();
70: boolean is_formatted(), read_bad_sector_map();
71: dskadr *from_sector(), *from_track(), *from_unix();
72: dskadr is_relocated(), *new_location();
73:
74: /* Operation table */
75:
76: extern int format(), verify(), relocate(), info();
77: extern int correct(), profile(), exercise();
78:
79: #define NUMOPS 7
80: /* operation bit mask values (must match order in operations table) */
81: #define FORMAT_OP 0x01 /* Format operation bit */
82: #define VERIFY_OP 0x02 /* Verify operation bit */
83: #define RELOCATE_OP 0x04 /* Relocate operation bit */
84: #define INFO_OP 0x08 /* Info operation bit */
85: #define CORRECT_OP 0x10 /* Correct operation bit */
86: #define PROFILE_OP 0x20 /* Profile operation bit */
87: #define EXERCISE_OP 0x40 /* Exercise operation bit */
88:
89: typedef struct {
90: int (*routine)();
91: char *op_name;
92: char *op_action;
93: } op_tbl;
94:
95: op_tbl operations[NUMOPS];
96:
97:
98: /* Operation table type and definitions */
99:
100: typedef struct {
101: int op;
102: int numpat;
103: } op_spec;
104:
105: op_spec ops_to_do[MAXCTLR][MAXDRIVE];
106:
107:
108: /* Contains all the current parameters */
109:
110: typedef enum {formatted, half_formatted, unformatted, unknown} drv_stat;
111: typedef enum {fmt, vfy, rel, cor, inf, cmd, exec, prof} state;
112: typedef enum {sub_chk,sub_rcvr,sub_stat,sub_rel,sub_vfy,sub_fmt,sub_sk}substate;
113:
114: /* Different environments for setjumps */
115: jmp_buf reset_environ; /* Use when reset is issued */
116: jmp_buf quit_environ; /* Use when you want to quit what your doing */
117: jmp_buf abort_environ; /* Use when nothing can be done to recover */
118:
119:
120: /* Flaw map definitions and storage */
121:
122: typedef struct {
123: short bs_cyl; /* Cylinder position of flaw */
124: short bs_trk; /* Track position of flaw */
125: long bs_offset; /* (byte) Position of flaw on track */
126: long bs_length; /* Length (in bits) of flaw */
127: dskadr bs_alt; /* Addr of alt sector (all 0 if none) */
128: enum {flaw_map, scanning, operator} bs_how; /* How it was found */
129: } bs_entry ;
130:
131:
132: struct {
133: int controller;
134: int drive;
135: state state;
136: substate substate;
137: int error;
138: dskadr daddr;
139: } cur;
140:
141:
142: /* Controller specific information */
143:
144: typedef struct {
145: uncertain alive;
146: cdr *addr;
147: char *name;
148: int type;
149: fmt_err (*decode_pos)();
150: bs_entry (*code_pos)();
151: int (*cylinder_skew)();
152: int (*track_skew)();
153: } ctlr_info;
154:
155: ctlr_info c_info[MAXCTLR];
156:
157:
158: /* drive specific information */
159:
160: typedef struct {
161: uncertain alive;
162: int id;
163: fs_tab *info;
164: int trk_size;
165: int num_slip;
166: int track_skew;
167: drv_stat condition;
168: } drive_info;
169:
170: drive_info d_info[MAXCTLR][MAXDRIVE];
171:
172:
173: #define D_INFO d_info[cur.controller][cur.drive]
174: #define C_INFO c_info[cur.controller]
175:
176: #define CURRENT D_INFO.info
177: typedef struct {
178: unsigned int bs_id; /* Pack id */
179: unsigned int bs_count; /* number of known bad sectors */
180: unsigned int bs_max; /* Maximum allowable bad sectors */
181: bs_entry list[1];
182: } bs_map;
183:
184: #define MAX_FLAWS (((TRKSIZ*sizeof(long))-sizeof(bs_map))/sizeof(bs_entry))
185:
186: long bs_map_space[TRKSIZ];
187: bs_map *bad_map;
188:
189: boolean kill_processes;
190: int num_controllers;
191:
192: /* Pattern buffers and the sort */
193: fmt_free free_tbl[NUMREL*MAXTRKS][MAXSECS_PER_TRK];
194: fmt_mdcb mdcb; /* Master device control block */
195: fmt_dcb dcb; /* Device control blocks */
196:
197: long pattern_0[TRKSIZ], pattern_1[TRKSIZ];
198: long pattern_2[TRKSIZ], pattern_3[TRKSIZ];
199: long pattern_4[TRKSIZ], pattern_5[TRKSIZ];
200: long pattern_6[TRKSIZ], pattern_7[TRKSIZ];
201: long pattern_8[TRKSIZ], pattern_9[TRKSIZ];
202: long pattern_10[TRKSIZ], pattern_11[TRKSIZ];
203: long pattern_12[TRKSIZ], pattern_13[TRKSIZ];
204: long pattern_14[TRKSIZ], pattern_15[TRKSIZ];
205:
206: /* Will be filled in at boot time with pointers to above patterns */
207: long *pattern_address[16];
208:
209: /* Double buffer for scanning existing file systems and general scratch */
210: long scratch[TRKSIZ];
211: long save[TRKSIZ];
212:
213:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.