3a2f7427fe
date: 1994/05/22 12:35:38; author: joerg; state: Exp; lines: +6 -6 First round of floppy changes. Try making `fd' more robust. New features: . ioctl command for setting the drive type (density etc.); restricted to the super-user . ioctl for getting/seting `drive options'; currently only option is FDOPT_NORETRY: inhibit the usual retries; used when verifying a newly formatted track Fixes: . function prototypes . made all internal functions `static' . cleaned up & corrected .h files . restructured, to make the chaotic function sequence more rational . compiled with -Wall, and cleared all warnings . introduced a mirror for the (write-only) `digital output register', to avoid the current kludge . device probing completed by seeking/recalibrating, and looking for track 0 being found . holding the controller down in reset state while it is idle (and thus saving allot of headaches) . make requests fail that are not a multiple of the (physical) sector size . removed the fixed physical sector size (512 bytes), allowing for any size the controller could handle (128/256/512/1024 bytes) . replaced some silly messages . fixed the TRACE* macro usage, debugging reports should be complete now again (debugging output is HUGE! though) . removed fd_timeout for SEEK command; seeks are always reported by the controller to succeed, since the `success' only refers to the controller's idea of success - there is no hardware line to tell about the seek end (other than the `track 0' line) . catch SENSEI's that report about a `terminated due to READY changed' status - could happen after a controller reset . converted ``hz / <something>'' divide operations to divisors that are powers of two, so gcc can optimize them into shifts . write/format operations are checked against a write-protected medium now *prior* starting the operation . error reports of `invalid command' and `wrong cylinder' will cause shortcuts in the retrier() now . fixed a bug in the retrier() causing bogus block numbers to be reported . fdformat() does care for errors now Known Bugs: . no attempts have been made (yet) to improve the performance . sometimes, bogus ``seek/recalib failed'' messages are logged; this is still a bug in the driver, but it's not harmful since it's usually caught by the retrier() Reviewed by: Submitted by: Obtained from:
108 lines
4.1 KiB
C
108 lines
4.1 KiB
C
/*
|
|
* Copyright (C) 1992-1994 by Joerg Wunsch, Dresden
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY
|
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
|
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
* DAMAGE.
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
#ifndef _IOCTL_FD_H
|
|
#define _IOCTL_FD_H
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
#define FD_FORMAT_VERSION 110 /* used to validate before formatting */
|
|
#define FD_MAX_NSEC 36 /* highest known number of spt - allow for */
|
|
/* 2.88 MB drives */
|
|
|
|
struct fd_formb {
|
|
int format_version; /* == FD_FORMAT_VERSION */
|
|
int cyl, head;
|
|
int transfer_rate; /* fdreg.h: FDC_???KBPS */
|
|
|
|
union {
|
|
struct fd_form_data {
|
|
/*
|
|
* DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
|
|
* it is hardware-dependant since it exactly
|
|
* matches the byte sequence to write to FDC
|
|
* during its `format track' operation
|
|
*/
|
|
u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
|
|
u_char nsecs; /* must be <= FD_MAX_NSEC */
|
|
u_char gaplen; /* GAP 3 length; usually 84 */
|
|
u_char fillbyte; /* usually 0xf6 */
|
|
struct fd_idfield_data {
|
|
/*
|
|
* data to write into id fields;
|
|
* for obscure formats, they mustn't match
|
|
* the real values (but mostly do)
|
|
*/
|
|
u_char cylno; /* 0 thru 79 (or 39) */
|
|
u_char headno; /* 0, or 1 */
|
|
u_char secno; /* starting at 1! */
|
|
u_char secsize; /* usually 2 */
|
|
} idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
|
|
} structured;
|
|
u_char raw[1]; /* to have continuous indexed access */
|
|
} format_info;
|
|
};
|
|
|
|
/* make life easier */
|
|
# define fd_formb_secshift format_info.structured.secshift
|
|
# define fd_formb_nsecs format_info.structured.nsecs
|
|
# define fd_formb_gaplen format_info.structured.gaplen
|
|
# define fd_formb_fillbyte format_info.structured.fillbyte
|
|
/* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
|
|
# define fd_formb_cylno(i) format_info.structured.idfields[i].cylno
|
|
# define fd_formb_headno(i) format_info.structured.idfields[i].headno
|
|
# define fd_formb_secno(i) format_info.structured.idfields[i].secno
|
|
# define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
|
|
|
|
struct fd_type {
|
|
int sectrac; /* sectors per track */
|
|
int secsize; /* size code for sectors */
|
|
int datalen; /* data len when secsize = 0 */
|
|
int gap; /* gap len between sectors */
|
|
int tracks; /* total num of tracks */
|
|
int size; /* size of disk in sectors */
|
|
int steptrac; /* steps per cylinder */
|
|
int trans; /* transfer speed code */
|
|
int heads; /* number of heads */
|
|
int f_gap; /* format gap len */
|
|
int f_inter; /* format interleave factor */
|
|
};
|
|
|
|
#define FD_FORM _IOW('F', 61, struct fd_formb) /* format a track */
|
|
#define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */
|
|
#define FD_STYPE _IOW('F', 63, struct fd_type) /* set drive type */
|
|
|
|
#define FD_GOPTS _IOR('F', 64, int) /* drive options, see below */
|
|
#define FD_SOPTS _IOW('F', 65, int)
|
|
|
|
#define FDOPT_NORETRY 0x0001 /* no retries on failure (cleared on close) */
|
|
|
|
#endif /* !def _IOCTL_FD_H */
|