|
|
1.1 root 1: #ifndef lint
2: static char sccsid[] = "@(#)vdfmt.c 1.7 (Berkeley/CCI) 6/24/90";
3: #endif
4:
5: /*
6: **
7: */
8:
9: #include "vdfmt.h"
10:
11: main()
12: {
13: exdent(-1);
14: print("VDFORMAT Berkeley Version 1.7 \n\n");
15:
16: for(;;) {
17: determine_controller_types();
18: print(
19: "\nType `Help' for help, `Start' to execute operations.\n\n");
20: if(!_setjmp(reset_environ)) {
21: init_environment();
22: for(;;) {
23: if(!_setjmp(quit_environ)) {
24: reset_operation_tables();
25: process_commands();
26: }
27: else
28: report_unexecuted_ops();
29: }
30: }
31: }
32: }
33:
34:
35: /*
36: **
37: */
38:
39: report_unexecuted_ops()
40: {
41: register int ctlr, drive;
42: char *header = "The following operations will not be executed:\n";
43:
44: indent();
45: for(ctlr=0; ctlr<MAXCTLR; ctlr++)
46: for(drive=0; drive<MAXDRIVE; drive++)
47: if(ops_to_do[ctlr][drive].op) {
48: print(header);
49: if(strlen(header)) {
50: indent();
51: header = "";
52: print(header);
53: }
54: display_operations(ctlr, drive);
55: ops_to_do[ctlr][drive].op = 0;
56: }
57: exdent(-1);
58: }
59:
60:
61: /*
62: **
63: */
64: #define VDBASE 0xffff2000 /* address of first controller */
65: #define VDOFF 0x100 /* offset between controllers */
66:
67: determine_controller_types()
68: {
69: extern fmt_err *smd_decode_position(), *smd_e_decode_position();
70: extern bs_entry *smd_code_position(), *smd_e_code_position();
71: register int ctlr, drive;
72: register ctlr_info *ci;
73:
74: /* Identify which controllers are present and what type they are. */
75: num_controllers = 0;
76: for(ctlr = 0; ctlr < MAXCTLR; ctlr++) {
77: ci = &c_info[ctlr];
78: ci->addr = (struct vddevice *)(VDBASE+(ctlr*VDOFF));
79: if(!badaddr(ci->addr, 2)) {
80: printf("controller %d: ", ctlr);
81: num_controllers++;
82: ci->addr->vdreset = (unsigned)0xffffffff;
83: DELAY(1000000);
84: if(ci->addr->vdreset!=(unsigned)0xffffffff) {
85: ci->alive = u_true;
86: ci->type = VDTYPE_VDDC;
87: ci->name = "VDDC";
88: ci->decode_pos = smd_decode_position;
89: ci->code_pos = smd_code_position;
90: printf("vddc\n");
91: DELAY(1000000);
92: } else {
93: ci->alive = u_true;
94: ci->type = VDTYPE_SMDE;
95: ci->name = "SMD-E";
96: ci->addr->vdrstclr = 0;
97: ci->decode_pos = smd_e_decode_position;
98: ci->code_pos = smd_e_code_position;
99: printf("smd-e\n");
100: DELAY(3000000);
101: }
102: } else {
103: ci->alive = u_false;
104: ci->type = -1;
105: }
106: for(drive=0; drive<MAXDRIVE; drive++)
107: d_info[ctlr][drive].alive = u_unknown;
108: }
109: if(num_controllers == 0)
110: _stop("vdfmt: I can't find any disk controllers. Giving up!");
111: }
112:
113:
114: /*
115: ** Init_environment is used to reset everything to it's initial state.
116: ** All previously stored drive information is lost when this command
117: ** is executed.
118: */
119:
120: init_environment()
121: {
122: register int ctlr, drive;
123:
124: /* clear list of operations to do */
125: for(ctlr=0; ctlr<MAXCTLR; ctlr++) {
126: for(drive=0; drive<MAXDRIVE; drive++) {
127: bzero((char *)&d_info[ctlr][drive],
128: sizeof(d_info[ctlr][drive]));
129: d_info[ctlr][drive].alive = u_unknown;
130: d_info[ctlr][drive].id = -1;
131: }
132: }
133: /* Init pattern table pointers */
134: pattern_address[0] = pattern_0;
135: pattern_address[1] = pattern_1;
136: pattern_address[2] = pattern_2;
137: pattern_address[3] = pattern_3;
138: pattern_address[4] = pattern_4;
139: pattern_address[5] = pattern_5;
140: pattern_address[6] = pattern_6;
141: pattern_address[7] = pattern_7;
142: pattern_address[8] = pattern_8;
143: pattern_address[9] = pattern_9;
144: pattern_address[10] = pattern_10;
145: pattern_address[11] = pattern_11;
146: pattern_address[12] = pattern_12;
147: pattern_address[13] = pattern_13;
148: pattern_address[14] = pattern_14;
149: pattern_address[15] = pattern_15;
150: /* Init operations command table */
151: operations[0].routine = format;
152: operations[0].op_name = "Format";
153: operations[0].op_action = "Formatting";
154: operations[1].routine = verify;
155: operations[1].op_name = "Verify";
156: operations[1].op_action = "Verification";
157: operations[2].routine = relocate;
158: operations[2].op_name = "Relocate";
159: operations[2].op_action = "Relocation";
160: operations[3].routine = info;
161: operations[3].op_name = "Info";
162: operations[3].op_action = "Information gathering";
163: operations[4].routine = correct;
164: operations[4].op_name = "Correct";
165: operations[4].op_action = "Correction";
166: operations[5].routine = profile;
167: operations[5].op_name = "Profile";
168: operations[5].op_action = "Profiling";
169: operations[6].routine = exercise;
170: operations[6].op_name = "Exercise";
171: operations[6].op_action = "exercising";
172: bad_map = &norm_bad_map;
173: }
174:
175:
176: /*
177: ** Reset_operation_tables reinitializes all the tables that
178: ** control the sequence of formatter operations.
179: */
180:
181: reset_operation_tables()
182: {
183: register int ctlr, drive;
184:
185: /* clear list of operations to do */
186: for(ctlr=0; ctlr<MAXCTLR; ctlr++) {
187: for(drive=0; drive<MAXDRIVE; drive++) {
188: ops_to_do[ctlr][drive].op = 0;
189: ops_to_do[ctlr][drive].numpat = 1;
190: }
191: }
192: kill_processes = false;
193: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.