129539Ssam #ifndef lint 2*32662Skarels static char sccsid[] = "@(#)vdfmt.c 1.5 (Berkeley/CCI) 11/23/87"; 329539Ssam #endif 429539Ssam 529539Ssam /* 629539Ssam ** 729539Ssam */ 829539Ssam 929539Ssam #include "vdfmt.h" 1029539Ssam 1129539Ssam main() 1229539Ssam { 1329539Ssam exdent(-1); 14*32662Skarels print("VDFORMAT Berkeley Version 1.5 \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 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 6729539Ssam determine_controller_types() 6829539Ssam { 6929539Ssam extern fmt_err smd_decode_position(), smd_e_decode_position(); 7029539Ssam extern bs_entry smd_code_position(), smd_e_code_position(); 7129539Ssam register int ctlr, drive; 72*32662Skarels 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++) { 77*32662Skarels ci = &c_info[ctlr]; 78*32662Skarels ci->addr = (struct vddevice *)(VDBASE+(ctlr*VDOFF)); 79*32662Skarels if(!badaddr(ci->addr, 2)) { 8029981Skarels printf("controller %d: ", ctlr); 8129539Ssam num_controllers++; 82*32662Skarels ci->addr->vdreset = (unsigned)0xffffffff; 8329539Ssam DELAY(1000000); 84*32662Skarels if(ci->addr->vdreset!=(unsigned)0xffffffff) { 85*32662Skarels ci->alive = u_true; 86*32662Skarels ci->type = VDTYPE_VDDC; 87*32662Skarels ci->name = "VDDC"; 88*32662Skarels ci->decode_pos = smd_decode_position; 89*32662Skarels ci->code_pos = smd_code_position; 9031318Ssam printf("vddc\n"); 9129539Ssam DELAY(1000000); 9229981Skarels } else { 93*32662Skarels ci->alive = u_true; 94*32662Skarels ci->type = VDTYPE_SMDE; 95*32662Skarels ci->name = "SMD-E"; 96*32662Skarels ci->addr->vdrstclr = 0; 97*32662Skarels ci->decode_pos = smd_e_decode_position; 98*32662Skarels ci->code_pos = smd_e_code_position; 9929981Skarels printf("smd-e\n"); 10029539Ssam DELAY(3000000); 10129539Ssam } 10229981Skarels } else { 103*32662Skarels ci->alive = u_false; 104*32662Skarels ci->type = -1; 10529539Ssam } 106*32662Skarels 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 12029539Ssam init_environment() 12129539Ssam { 12229539Ssam register int ctlr, drive; 12329539Ssam 12429539Ssam /* clear list of operations to do */ 12529539Ssam for(ctlr=0; ctlr<MAXCTLR; ctlr++) { 126*32662Skarels for(drive=0; drive<MAXDRIVE; drive++) { 127*32662Skarels bzero((char *)&d_info[ctlr][drive], 128*32662Skarels 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"; 17229539Ssam bad_map = (bs_map *)bs_map_space; 17329539Ssam } 17429539Ssam 17529539Ssam 17629539Ssam /* 17729539Ssam ** Reset_operation_tables reinitializes all the tables that 17829539Ssam ** control the sequence of formatter operations. 17929539Ssam */ 18029539Ssam 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