1 #ifndef lint 2 static char sccsid[] = "@(#)smd_e.c 1.3 (Berkeley/CCI) 06/07/88"; 3 #endif 4 5 #include "vdfmt.h" 6 7 8 /* 9 ** The sector format of the SMD controller looks like this: 10 ** 32 bytes sector gap (header error) 11 ** 1 byte sync (0x19) (header error) 12 ** 2 bytes cylinder address (header error) 13 ** 1 byte track address (header error) 14 ** 1 byte sector address (header error) 15 ** 2 bytes alt cylinder address (header error) 16 ** 1 byte alt track address (header error) 17 ** 1 byte alt sector address (header error) 18 ** 4 bytes header crc (header error) 19 ** 34 bytes header gap (data error) 20 ** 512 bytes data (data error) 21 ** 4 byte ecc (data error) 22 ** ?? trailing pad (data error) 23 */ 24 smd_e_decode_position(bad_entry,error)25smd_e_decode_position(bad_entry, error) 26 register bs_entry *bad_entry; 27 register fmt_err *error; 28 { 29 int sector_length = lab->d_traksize / lab->d_nsectors; 30 int offset = (bad_entry->bs_offset-2) % sector_length; 31 int bytes = (bad_entry->bs_length / 8) + 4; 32 33 error->err_adr.cylinder = bad_entry->bs_cyl; 34 error->err_adr.track = bad_entry->bs_trk; 35 error->err_adr.sector = (bad_entry->bs_offset-2) / sector_length; 36 if(error->err_adr.sector >= lab->d_nsectors) { 37 error->err_adr.sector = lab->d_nsectors - 1; 38 error->err_stat = DATA_ERROR; 39 } 40 else if((offset < 45) || ((offset+bytes) > sector_length)) 41 error->err_stat = HEADER_ERROR; 42 else 43 error->err_stat = DATA_ERROR; 44 } 45 46 47 /* 48 ** 49 */ 50 smd_e_code_position(error,badent)51smd_e_code_position(error, badent) 52 register fmt_err *error; 53 register bs_entry *badent; 54 { 55 int sector_length = lab->d_traksize / lab->d_nsectors; 56 57 badent->bs_length = 1; 58 badent->bs_cyl = error->err_adr.cylinder; 59 badent->bs_trk = error->err_adr.track; 60 badent->bs_offset = error->err_adr.sector * sector_length; 61 if(error->err_stat & HEADER_ERROR) { 62 badent->bs_offset += 1; 63 } 64 else { 65 badent->bs_offset += 60; 66 } 67 badent->bs_alt.cylinder = 0; 68 badent->bs_alt.track = 0; 69 badent->bs_alt.sector = 0; 70 badent->bs_how = scanning; 71 } 72