static SectorMap convert_sector_map(buffer_struct * buff) { int i = 0; SectorMap bad_map = ftape_get_bad_sector_entry(buff->segment_id); SectorMap src_map = buff->soft_error_map | buff->hard_error_map; SectorMap dst_map = 0; TRACE_FUN(ft_t_any); if (bad_map || src_map) { TRACE(ft_t_flow, "bad_map = 0x%08lx", (long) bad_map); TRACE(ft_t_flow, "src_map = 0x%08lx", (long) src_map); } while (bad_map) { while ((bad_map & 1) == 0) { if (src_map & 1) { dst_map |= (1 << i); } src_map >>= 1; bad_map >>= 1; ++i; } /* (bad_map & 1) == 1 */ src_map >>= 1; bad_map >>= 1; } if (src_map) { dst_map |= (src_map << i); } if (dst_map) { TRACE(ft_t_flow, "dst_map = 0x%08lx", (long) dst_map); } TRACE_EXIT dst_map; }
/* Calculate Floppy Disk Controller and DMA parameters for a segment. * head: selects buffer struct in array. * offset: number of physical sectors to skip (including bad ones). * count: number of physical sectors to handle (including bad ones). */ static int setup_segment(buffer_struct * buff, int segment_id, unsigned int sector_offset, unsigned int sector_count, int retry) { SectorMap offset_mask; SectorMap mask; TRACE_FUN(ft_t_any); buff->segment_id = segment_id; buff->sector_offset = sector_offset; buff->remaining = sector_count; buff->head = segment_id / ftape_segments_per_head; buff->cyl = (segment_id % ftape_segments_per_head) / ftape_segments_per_cylinder; buff->sect = (segment_id % ftape_segments_per_cylinder) * FT_SECTORS_PER_SEGMENT + 1; buff->deleted = 0; offset_mask = (1 << buff->sector_offset) - 1; mask = ftape_get_bad_sector_entry(segment_id) & offset_mask; while (mask) { if (mask & 1) { offset_mask >>= 1; /* don't count bad sector */ } mask >>= 1; }
unsigned int zft_get_seg_sz(unsigned int segment) { int size; TRACE_FUN(ft_t_any); size = FT_SEGMENT_SIZE - count_ones(ftape_get_bad_sector_entry(segment))*FT_SECTOR_SIZE; if (size > 0) { TRACE_EXIT (unsigned)size; } else { TRACE_EXIT 0; } }