1 #ifndef lint 2 static char sccsid[] = "@(#)vdfmt.c 1.2 (Berkeley/CCI) 11/04/86"; 3 #endif 4 5 /* 6 ** 7 */ 8 9 #include "vdfmt.h" 10 11 main() 12 { 13 exdent(-1); 14 print("VDFORMAT Version 3.0 \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 65 determine_controller_types() 66 { 67 extern fmt_err smd_decode_position(), smd_e_decode_position(); 68 extern bs_entry smd_code_position(), smd_e_code_position(); 69 extern int smd_cyl_skew(), smd_trk_skew(); 70 extern int smd_e_cyl_skew(), smd_e_trk_skew(); 71 register int ctlr, drive; 72 73 /* Identify which controllers are present and what type they are. */ 74 num_controllers = 0; 75 for(ctlr = 0; ctlr < MAXCTLR; ctlr++) { 76 c_info[ctlr].addr = (cdr *)(vddcaddr[ctlr]+VBIOBASE); 77 if(!badaddr(c_info[ctlr].addr, 2)) { 78 printf("controller %d: ", ctlr); 79 num_controllers++; 80 c_info[ctlr].addr->cdr_reset = (unsigned)0xffffffff; 81 DELAY(1000000); 82 if(c_info[ctlr].addr->cdr_reset!=(unsigned)0xffffffff) { 83 c_info[ctlr].alive = u_true; 84 c_info[ctlr].type = SMDCTLR; 85 c_info[ctlr].name = "VDDC"; 86 c_info[ctlr].decode_pos = smd_decode_position; 87 c_info[ctlr].code_pos = smd_code_position; 88 c_info[ctlr].cylinder_skew = smd_cyl_skew; 89 c_info[ctlr].track_skew = smd_trk_skew; 90 printf("smd\n"); 91 DELAY(1000000); 92 } else { 93 c_info[ctlr].alive = u_true; 94 c_info[ctlr].type = SMD_ECTLR; 95 c_info[ctlr].name = "SMD-E"; 96 c_info[ctlr].addr->cdr_reserved = 0x0; 97 c_info[ctlr].decode_pos = smd_e_decode_position; 98 c_info[ctlr].code_pos = smd_e_code_position; 99 c_info[ctlr].cylinder_skew = smd_e_cyl_skew; 100 c_info[ctlr].track_skew = smd_e_trk_skew; 101 printf("smd-e\n"); 102 DELAY(3000000); 103 } 104 } else { 105 c_info[ctlr].alive = u_false; 106 c_info[ctlr].type = UNKNOWN; 107 } 108 for(drive=0; drive<MAXDRIVE; drive++) { 109 d_info[ctlr][drive].alive = u_unknown; 110 d_info[ctlr][drive].info = (struct vdconfig *)0; 111 } 112 } 113 if(num_controllers == 0) 114 _stop("vdfmt: I can't find any disk controllers. Giving up!"); 115 } 116 117 118 /* 119 ** Init_environment is used to reset everything to it's initial state. 120 ** All previously stored drive information is lost when this command 121 ** is executed. 122 */ 123 124 init_environment() 125 { 126 register int ctlr, drive; 127 128 /* clear list of operations to do */ 129 for(ctlr=0; ctlr<MAXCTLR; ctlr++) { 130 for(drive=0; drive<MAXCTLR; drive++) { 131 d_info[ctlr][drive].alive = u_unknown; 132 d_info[ctlr][drive].info = (struct vdconfig *)0; 133 d_info[ctlr][drive].id = -1; 134 d_info[ctlr][drive].trk_size = 0; 135 d_info[ctlr][drive].num_slip = 0; 136 d_info[ctlr][drive].track_skew = 0; 137 } 138 } 139 /* Init pattern table pointers */ 140 pattern_address[0] = pattern_0; 141 pattern_address[1] = pattern_1; 142 pattern_address[2] = pattern_2; 143 pattern_address[3] = pattern_3; 144 pattern_address[4] = pattern_4; 145 pattern_address[5] = pattern_5; 146 pattern_address[6] = pattern_6; 147 pattern_address[7] = pattern_7; 148 pattern_address[8] = pattern_8; 149 pattern_address[9] = pattern_9; 150 pattern_address[10] = pattern_10; 151 pattern_address[11] = pattern_11; 152 pattern_address[12] = pattern_12; 153 pattern_address[13] = pattern_13; 154 pattern_address[14] = pattern_14; 155 pattern_address[15] = pattern_15; 156 /* Init operations command table */ 157 operations[0].routine = format; 158 operations[0].op_name = "Format"; 159 operations[0].op_action = "Formatting"; 160 operations[1].routine = verify; 161 operations[1].op_name = "Verify"; 162 operations[1].op_action = "Verification"; 163 operations[2].routine = relocate; 164 operations[2].op_name = "Relocate"; 165 operations[2].op_action = "Relocation"; 166 operations[3].routine = info; 167 operations[3].op_name = "Info"; 168 operations[3].op_action = "Information gathering"; 169 operations[4].routine = correct; 170 operations[4].op_name = "Correct"; 171 operations[4].op_action = "Correction"; 172 operations[5].routine = profile; 173 operations[5].op_name = "Profile"; 174 operations[5].op_action = "Profiling"; 175 operations[6].routine = exercise; 176 operations[6].op_name = "Exercise"; 177 operations[6].op_action = "exercising"; 178 bad_map = (bs_map *)bs_map_space; 179 } 180 181 182 /* 183 ** Reset_operation_tables reinitializes all the tables that 184 ** control the sequence of formatter operations. 185 */ 186 187 reset_operation_tables() 188 { 189 register int ctlr, drive; 190 191 /* clear list of operations to do */ 192 for(ctlr=0; ctlr<MAXCTLR; ctlr++) { 193 for(drive=0; drive<MAXDRIVE; drive++) { 194 ops_to_do[ctlr][drive].op = 0; 195 ops_to_do[ctlr][drive].numpat = 1; 196 } 197 } 198 kill_processes = false; 199 } 200 201