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