xref: /csrg-svn/sys/tahoe/stand/vdformat/vdfmt.c (revision 43645)
129539Ssam #ifndef lint
2*43645Skarels static char sccsid[] = "@(#)vdfmt.c	1.7 (Berkeley/CCI) 06/24/90";
329539Ssam #endif
429539Ssam 
529539Ssam /*
629539Ssam **
729539Ssam */
829539Ssam 
929539Ssam #include	"vdfmt.h"
1029539Ssam 
main()1129539Ssam main()
1229539Ssam {
1329539Ssam 	exdent(-1);
14*43645Skarels 	print("VDFORMAT            Berkeley Version 1.7 \n\n");
1529539Ssam 
1629539Ssam 	for(;;) {
1729539Ssam 		determine_controller_types();
1829981Skarels 		print(
1929981Skarels 		  "\nType `Help' for help, `Start' to execute operations.\n\n");
2029539Ssam 		if(!_setjmp(reset_environ)) {
2129539Ssam 			init_environment();
2229539Ssam 			for(;;) {
2329539Ssam 				if(!_setjmp(quit_environ)) {
2429539Ssam 					reset_operation_tables();
2529539Ssam 					process_commands();
2629539Ssam 				}
2729539Ssam 				else
2829539Ssam 					report_unexecuted_ops();
2929539Ssam 			}
3029539Ssam 		}
3129539Ssam 	}
3229539Ssam }
3329539Ssam 
3429539Ssam 
3529539Ssam /*
3629539Ssam **
3729539Ssam */
3829539Ssam 
report_unexecuted_ops()3929539Ssam report_unexecuted_ops()
4029539Ssam {
4129539Ssam 	register int	ctlr, drive;
4229539Ssam 	char *header = "The following operations will not be executed:\n";
4329539Ssam 
4429539Ssam 	indent();
4529539Ssam 	for(ctlr=0; ctlr<MAXCTLR; ctlr++)
4629539Ssam 		for(drive=0; drive<MAXDRIVE; drive++)
4729539Ssam 			if(ops_to_do[ctlr][drive].op) {
4829539Ssam 				print(header);
4929539Ssam 				if(strlen(header)) {
5029539Ssam 					indent();
5129539Ssam 					header = "";
5229539Ssam 					print(header);
5329539Ssam 				}
5429539Ssam 				display_operations(ctlr, drive);
5529539Ssam 				ops_to_do[ctlr][drive].op = 0;
5629539Ssam 			}
5729539Ssam 	exdent(-1);
5829539Ssam }
5929539Ssam 
6029539Ssam 
6129539Ssam /*
6229539Ssam **
6329539Ssam */
6431318Ssam #define	VDBASE	0xffff2000	/* address of first controller */
6531318Ssam #define	VDOFF	0x100		/* offset between controllers */
6629539Ssam 
determine_controller_types()6729539Ssam determine_controller_types()
6829539Ssam {
6934667Skarels 	extern fmt_err	*smd_decode_position(), *smd_e_decode_position();
7034667Skarels 	extern bs_entry	*smd_code_position(), *smd_e_code_position();
7129539Ssam 	register int	ctlr, drive;
7232662Skarels 	register ctlr_info *ci;
7329539Ssam 
7429539Ssam 	/* Identify which controllers are present and what type they are. */
7529539Ssam 	num_controllers = 0;
7629539Ssam 	for(ctlr = 0; ctlr < MAXCTLR; ctlr++) {
7732662Skarels 		ci = &c_info[ctlr];
7832662Skarels 		ci->addr = (struct vddevice *)(VDBASE+(ctlr*VDOFF));
7932662Skarels 		if(!badaddr(ci->addr, 2)) {
8029981Skarels 			printf("controller %d: ", ctlr);
8129539Ssam 			num_controllers++;
8232662Skarels 			ci->addr->vdreset = (unsigned)0xffffffff;
8329539Ssam 			DELAY(1000000);
8432662Skarels 			if(ci->addr->vdreset!=(unsigned)0xffffffff) {
8532662Skarels 				ci->alive = u_true;
8632662Skarels 				ci->type = VDTYPE_VDDC;
8732662Skarels 				ci->name = "VDDC";
8832662Skarels 				ci->decode_pos = smd_decode_position;
8932662Skarels 				ci->code_pos = smd_code_position;
9031318Ssam 				printf("vddc\n");
9129539Ssam 				DELAY(1000000);
9229981Skarels 			} else {
9332662Skarels 				ci->alive = u_true;
9432662Skarels 				ci->type = VDTYPE_SMDE;
9532662Skarels 				ci->name = "SMD-E";
9632662Skarels 				ci->addr->vdrstclr = 0;
9732662Skarels 				ci->decode_pos = smd_e_decode_position;
9832662Skarels 				ci->code_pos = smd_e_code_position;
9929981Skarels 				printf("smd-e\n");
10029539Ssam 				DELAY(3000000);
10129539Ssam 			}
10229981Skarels 		} else  {
10332662Skarels 			ci->alive = u_false;
10432662Skarels 			ci->type = -1;
10529539Ssam 		}
10632662Skarels 		for(drive=0; drive<MAXDRIVE; drive++)
10729539Ssam 			d_info[ctlr][drive].alive = u_unknown;
10829539Ssam 	}
10929539Ssam 	if(num_controllers == 0)
11029539Ssam 		_stop("vdfmt: I can't find any disk controllers.  Giving up!");
11129539Ssam }
11229539Ssam 
11329539Ssam 
11429539Ssam /*
11529539Ssam **	Init_environment is used to reset everything to it's initial state.
11629539Ssam ** All previously stored drive information is lost when this command
11729539Ssam ** is executed.
11829539Ssam */
11929539Ssam 
init_environment()12029539Ssam init_environment()
12129539Ssam {
12229539Ssam 	register int	ctlr, drive;
12329539Ssam 
12429539Ssam 	/* clear list of operations to do */
12529539Ssam 	for(ctlr=0; ctlr<MAXCTLR; ctlr++) {
12632662Skarels 		for(drive=0; drive<MAXDRIVE; drive++) {
12732662Skarels 			bzero((char *)&d_info[ctlr][drive],
12832662Skarels 			    sizeof(d_info[ctlr][drive]));
12929539Ssam 			d_info[ctlr][drive].alive = u_unknown;
13029539Ssam 			d_info[ctlr][drive].id = -1;
13129539Ssam 		}
13229539Ssam 	}
13329539Ssam 	/* Init pattern table pointers */
13429539Ssam 	pattern_address[0] = pattern_0;
13529539Ssam 	pattern_address[1] = pattern_1;
13629539Ssam 	pattern_address[2] = pattern_2;
13729539Ssam 	pattern_address[3] = pattern_3;
13829539Ssam 	pattern_address[4] = pattern_4;
13929539Ssam 	pattern_address[5] = pattern_5;
14029539Ssam 	pattern_address[6] = pattern_6;
14129539Ssam 	pattern_address[7] = pattern_7;
14229539Ssam 	pattern_address[8] = pattern_8;
14329539Ssam 	pattern_address[9] = pattern_9;
14429539Ssam 	pattern_address[10] = pattern_10;
14529539Ssam 	pattern_address[11] = pattern_11;
14629539Ssam 	pattern_address[12] = pattern_12;
14729539Ssam 	pattern_address[13] = pattern_13;
14829539Ssam 	pattern_address[14] = pattern_14;
14929539Ssam 	pattern_address[15] = pattern_15;
15029539Ssam 	/* Init operations command table */
15129539Ssam 	operations[0].routine = format;
15229539Ssam 	operations[0].op_name = "Format";
15329539Ssam 	operations[0].op_action = "Formatting";
15429539Ssam 	operations[1].routine = verify;
15529539Ssam 	operations[1].op_name = "Verify";
15629539Ssam 	operations[1].op_action = "Verification";
15729539Ssam 	operations[2].routine = relocate;
15829539Ssam 	operations[2].op_name = "Relocate";
15929539Ssam 	operations[2].op_action = "Relocation";
16029539Ssam 	operations[3].routine = info;
16129539Ssam 	operations[3].op_name = "Info";
16229539Ssam 	operations[3].op_action = "Information gathering";
16329539Ssam 	operations[4].routine = correct;
16429539Ssam 	operations[4].op_name = "Correct";
16529539Ssam 	operations[4].op_action = "Correction";
16629539Ssam 	operations[5].routine = profile;
16729539Ssam 	operations[5].op_name = "Profile";
16829539Ssam 	operations[5].op_action = "Profiling";
16929539Ssam 	operations[6].routine = exercise;
17029539Ssam 	operations[6].op_name = "Exercise";
17129539Ssam 	operations[6].op_action = "exercising";
172*43645Skarels 	bad_map = &norm_bad_map;
17329539Ssam }
17429539Ssam 
17529539Ssam 
17629539Ssam /*
17729539Ssam **	Reset_operation_tables reinitializes all the  tables that
17829539Ssam **  control the sequence of formatter operations.
17929539Ssam */
18029539Ssam 
reset_operation_tables()18129539Ssam reset_operation_tables()
18229539Ssam {
18329539Ssam 	register int	ctlr, drive;
18429539Ssam 
18529539Ssam 	/* clear list of operations to do */
18629539Ssam 	for(ctlr=0; ctlr<MAXCTLR; ctlr++) {
18729539Ssam 		for(drive=0; drive<MAXDRIVE; drive++) {
18829539Ssam 			ops_to_do[ctlr][drive].op = 0;
18929539Ssam 			ops_to_do[ctlr][drive].numpat = 1;
19029539Ssam 		}
19129539Ssam 	}
19229539Ssam 	kill_processes = false;
19329539Ssam }
194