patch-1.3.40 linux/include/linux/fd.h

Next file: linux/include/linux/module.h
Previous file: linux/fs/smbfs/sock.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.39/linux/include/linux/fd.h linux/include/linux/fd.h
@@ -1,62 +1,26 @@
 #ifndef _LINUX_FD_H
 #define _LINUX_FD_H
 
-/* new interface flag */
-#define FDHAVEBATCHEDRAWCMD
-
-/* commands needing write access have 0x40 set */
-/* commands needing super user access have 0x80 set */
-
-#define FDCLRPRM 0x0241 /* clear user-defined parameters */
-#define FDSETPRM 0x0242 /* set user-defined parameters for current media */
-#define FDSETMEDIAPRM 0x0242
-#define FDDEFPRM 0x0243 /* set user-defined parameters until explicitly 
-			* cleared */
-#define FDDEFMEDIAPRM 0x0243
-#define FDGETPRM 0x0204 /* get disk parameters */
-#define FDGETMEDIAPRM 0x0204
-#define	FDMSGON  0x0205 /* issue kernel messages on media type change */
-#define	FDMSGOFF 0x0206 /* don't issue kernel messages on media type change */
-#define FDFMTBEG 0x0247 /* begin formatting a disk */
-#define	FDFMTTRK 0x0248 /* format the specified track */
-#define FDFMTEND 0x0249 /* end formatting a disk */
-#define FDSETEMSGTRESH	0x024a	/* set fdc error reporting threshold */
-#define FDFLUSH  0x024b /* flush buffers for media; either for verifying media, or for
-                       handling a media change without closing the file
-		       descriptor */
-#define FDSETMAXERRS 0x024c /* set abortion and read_track threshold */
-#define FDGETMAXERRS 0x020e /* get abortion and read_track threshold */
-#define FDGETDRVTYP 0x020f          /* get drive type: 5 1/4 or 3 1/2 */
-
-#define FDSETDRVPRM 0x0250 /* set drive parameters */
-#define FDGETDRVPRM 0x0211 /* get drive parameters */
-#define FDGETDRVSTAT 0x0212 /* get drive state */
-#define FDPOLLDRVSTAT 0x0213 /* get drive state */
-#define FDRESET 0x0254 /* reset FDC */
+#include <linux/ioctl.h>
 
-#ifndef __ASSEMBLY__
-enum reset_mode {
-	FD_RESET_IF_NEEDED ,
-	FD_RESET_IF_RAWCMD ,
-	FD_RESET_ALWAYS };
-#endif
-
-#define FDGETFDCSTAT 0x0215 /* get fdc state */
-#define FDWERRORCLR  0x0256 /* clear write error and badness information */
-#define FDWERRORGET  0x0217 /* get write error and badness information */
-
-#define FDRAWCMD 0x0258 /* send a raw command to the fdc */
-
-#define FDTWADDLE 0x0259 /* flicker motor-on bit before reading a sector */
+/* New file layout: Now the ioctl definitions immediately follow the
+ * definitions of the structures that they use */
 
 /*
- * Maximum number of sectors in a track buffer. Track buffering is disabled
- * if tracks are bigger.
+ * Geometry
  */
-#define MAX_BUFFER_SECTORS 24 /* was 18 -bb */
+struct floppy_struct {
+	unsigned int	size,		/* nr of sectors total */
+			sect,		/* sectors per track */
+			head,		/* nr of heads */
+			track,		/* nr of tracks */
+			stretch;	/* !=0 means double track steps */
+#define FD_STRETCH 1
+#define FD_SWAPSIDES 2
 
-#define FD_FILL_BYTE 0xF6 /* format fill byte */
+	unsigned char	gap,		/* gap1 size */
 
+			rate,		/* data rate. |= 0x40 for perpendicular */
 #define FD_2M 0x4
 #define FD_SIZECODEMASK 0x38
 #define FD_SIZECODE(floppy) (((((floppy)->rate&FD_SIZECODEMASK)>> 3)+ 2) %8)
@@ -64,28 +28,54 @@
 			     512 : 128 << FD_SIZECODE(floppy) )
 #define FD_PERP 0x40
 
-#define FD_STRETCH 1
-#define FD_SWAPSIDES 2
-
-#ifndef __ASSEMBLY__
-/* the following structure is used by FDSETPRM, FDDEFPRM and FDGETPRM */
-struct floppy_struct {
-	unsigned int	size,		/* nr of sectors total */
-			sect,		/* sectors per track */
-			head,		/* nr of heads */
-			track,		/* nr of tracks */
-			stretch;	/* !=0 means double track steps */
-	unsigned char	gap,		/* gap1 size */
-			rate,		/* data rate. |= 0x40 for perpendicular */
 			spec1,		/* stepping rate, head unload time */
 			fmt_gap;	/* gap2 size */
 	const char	* name; /* used only for predefined formats */
 };
 
+
+/* commands needing write access have 0x40 set */
+/* commands needing super user access have 0x80 set */
+
+#define FDCLRPRM _IO(2, 0x41)
+/* clear user-defined parameters */
+
+#define FDSETPRM _IOW(2, 0x42, struct floppy_struct) 
+#define FDSETMEDIAPRM FDSETPRM
+/* set user-defined parameters for current media */
+
+#define FDDEFPRM _IOW(2, 0x43, struct floppy_struct) 
+#define FDGETPRM _IOR(2, 0x04, struct floppy_struct)
+#define FDDEFMEDIAPRM FDDEFPRM
+#define FDGETMEDIAPRM FDGETPRM
+/* set/get disk parameters */
+
+
+#define	FDMSGON  _IO(2,0x45)
+#define	FDMSGOFF _IO(2,0x46)
+/* issue/don't issue kernel messages on media type change */
+
+
+/* 
+ * Formatting (obsolete)
+ */
+#define FD_FILL_BYTE 0xF6 /* format fill byte. */
+
 struct format_descr {
 	unsigned int device,head,track;
 };
 
+#define FDFMTBEG _IO(2,0x47)
+/* begin formatting a disk */
+#define	FDFMTTRK _IOW(2,0x48, struct format_descr)
+/* format the specified track */
+#define FDFMTEND _IO(2,0x49)
+/* end formatting a disk */
+
+
+/*
+ * Error thresholds
+ */
 struct floppy_max_errors {
 	unsigned int
 	  abort,      /* number of errors to be reached before aborting */
@@ -104,7 +94,27 @@
 
 };
 
-/* the following structure is used by FDSETDRVPRM and FDGETDRVPRM */
+#define FDSETEMSGTRESH	_IO(2,0x4a)
+/* set fdc error reporting threshold */
+
+#define FDFLUSH  _IO(2,0x4b)
+/* flush buffers for media; either for verifying media, or for
+ * handling a media change without closing the file descriptor */
+
+#define FDSETMAXERRS _IOW(2, 0x4c, struct floppy_max_errors)
+#define FDGETMAXERRS _IOR(2, 0x0e, struct floppy_max_errors)
+/* set/get abortion and read_track threshold. See also floppy_drive_params
+ * structure */
+
+
+typedef char floppy_drive_name[16];
+#define FDGETDRVTYP _IOR(2, 0x0f, floppy_drive_name)
+/* get drive type: 5 1/4 or 3 1/2 */
+
+
+/*
+ * Drive parameters (user modifyable)
+ */
 struct floppy_drive_params {
 	char cmos;			/* cmos type */
 	
@@ -160,15 +170,25 @@
 };
 
 enum {
-	FD_NEED_TWADDLE_BIT, /* more magic */
-	FD_VERIFY_BIT, /* inquire for write protection */
-	FD_DISK_NEWCHANGE_BIT, /* change detected, and no action undertaken yet
-				* to clear media change status */
+	FD_NEED_TWADDLE_BIT,	/* more magic */
+	FD_VERIFY_BIT,		/* inquire for write protection */
+	FD_DISK_NEWCHANGE_BIT,	/* change detected, and no action undertaken yet
+				 * to clear media change status */
 	FD_UNUSED_BIT,
-	FD_DISK_CHANGED_BIT, /* disk has been changed since last i/o */
-	FD_DISK_WRITABLE_BIT /* disk is writable */
+	FD_DISK_CHANGED_BIT,	/* disk has been changed since last i/o */
+	FD_DISK_WRITABLE_BIT	/* disk is writable */
 };
 
+#define FDSETDRVPRM _IOW(2, 0x90, struct floppy_drive_params)
+#define FDGETDRVPRM _IOR(2, 0x11, struct floppy_drive_params)
+/* set/get drive parameters */
+
+
+/*
+ * Current drive state (not directly modifyable by user, readonly)
+ */
+struct floppy_drive_struct {
+	signed char flags;
 /* values for these flags */
 #define FD_NEED_TWADDLE (1 << FD_NEED_TWADDLE_BIT)
 #define FD_VERIFY (1 << FD_VERIFY_BIT)
@@ -176,10 +196,6 @@
 #define FD_DISK_CHANGED (1 << FD_DISK_CHANGED_BIT)
 #define FD_DISK_WRITABLE (1 << FD_DISK_WRITABLE_BIT)
 
-#define FD_DRIVE_PRESENT 0 /* keep fdpatch utils compiling */
-
-struct floppy_drive_struct {
-	signed char flags;
 	unsigned long spinup_date;
 	unsigned long select_date;
 	unsigned long first_read_date;
@@ -206,28 +222,25 @@
 	int bufblocks;
 };
 
-struct floppy_write_errors {
-	/* Write error logging.
-	 *
-	 * These fields can be cleared with the FDWERRORCLR ioctl.
-	 * Only writes that were attempted but failed due to a physical media
-	 * error are logged.  write(2) calls that fail and return an error code
-	 * to the user process are not counted.
-	 */
+#define FDGETDRVSTAT _IOR(2, 0x12, struct floppy_drive_struct)
+#define FDPOLLDRVSTAT _IOR(2, 0x13, struct floppy_drive_struct)
+/* get drive state: GET returns the cached state, POLL polls for new state */
 
-	unsigned int write_errors;  /* number of physical write errors 
-				     * encountered */
-	
-	/* position of first and last write errors */
-	unsigned long first_error_sector;
-	int           first_error_generation;
-	unsigned long last_error_sector;
-	int           last_error_generation;
-	
-	unsigned int badness; /* highest retry count for a read or write 
-			       * operation */
+
+/*
+ * reset FDC
+ */
+enum reset_mode {
+	FD_RESET_IF_NEEDED,	/* reset only if the reset flags is set */
+	FD_RESET_IF_RAWCMD,	/* obsolete */
+	FD_RESET_ALWAYS		/* reset always */
 };
+#define FDRESET _IO(2, 0x54)
+
 
+/*
+ * FDC state
+ */
 struct floppy_fdc_state {	
 	int spec1;		/* spec1 value last used */
 	int spec2;		/* spec2 value last used */
@@ -241,26 +254,6 @@
 	unsigned int perp_mode:2;
 	unsigned int has_fifo:1;
 	unsigned int driver_version;	/* version code for floppy driver */
-
-	unsigned char track[4]; /* Position of the heads of the 4
-				 * units attached to this FDC, as
-				 * stored on the FDC. In the future,
-				 * the position as stored on the FDC
-				 * might not agree with the actual
-				 * physical position of these drive
-				 * heads. By allowing such
-				 * disagreement, it will be possible
-				 * to reset the FDC without incurring
-				 * the expensive cost of repositioning
-				 * all heads. 
-				 * Right now, these positions are
-				 * hard wired to 0. */
-
-	unsigned int reserved1;
-	unsigned int reserved2;
-};
-
-
 #define FD_DRIVER_VERSION 0x100
 /* user programs using the floppy API should use floppy_fdc_state to
  * get the version number of the floppy driver that they are running
@@ -269,33 +262,59 @@
  * to bigger structures
  */
 
+	unsigned char track[4];
+	/* Position of the heads of the 4 units attached to this FDC,
+	 * as stored on the FDC. In the future, the position as stored
+	 * on the FDC might not agree with the actual physical
+	 * position of these drive heads. By allowing such
+	 * disagreement, it will be possible to reset the FDC without
+	 * incurring the expensive cost of repositioning all heads.
+	 * Right now, these positions are hard wired to 0. */
 
-struct floppy_raw_cmd {
-	unsigned int flags;
-	void *data;
-	char *kernel_data; /* location of data buffer in the kernel */
-	struct floppy_raw_cmd *next; /* used for chaining of raw cmd's 
-				      * withing the kernel */
-	long length; /* in: length of dma transfer. out: remaining bytes */
-	long phys_length; /* physical length, if different from dma length */
-	int buffer_length; /* length of allocated buffer */
+};
 
-	unsigned char rate;
-	unsigned char cmd_count;
-	unsigned char cmd[16];
-	unsigned char reply_count;
-	unsigned char reply[16];
-	int track;
-	int resultcode;
+#define FDGETFDCSTAT _IOR(2, 0x15, struct floppy_fdc_state)
 
-	int reserved1;
-	int reserved2;
+
+/*
+ * Asynchronous Write error tracking
+ */
+struct floppy_write_errors {
+	/* Write error logging.
+	 *
+	 * These fields can be cleared with the FDWERRORCLR ioctl.
+	 * Only writes that were attempted but failed due to a physical media
+	 * error are logged.  write(2) calls that fail and return an error code
+	 * to the user process are not counted.
+	 */
+
+	unsigned int write_errors;  /* number of physical write errors 
+				     * encountered */
+	
+	/* position of first and last write errors */
+	unsigned long first_error_sector;
+	int           first_error_generation;
+	unsigned long last_error_sector;
+	int           last_error_generation;
+	
+	unsigned int badness; /* highest retry count for a read or write 
+			       * operation */
 };
-#endif
 
-/* meaning of the various bytes */
+#define FDWERRORCLR  _IO(2, 0x56)
+/* clear write error and badness information */
+#define FDWERRORGET  _IOR(2, 0x17, struct floppy_write_errors)
+/* get write error and badness information */
+
 
-/* flags */
+/*
+ * Raw commands
+ */
+/* new interface flag: now we can do them in batches */
+#define FDHAVEBATCHEDRAWCMD
+
+struct floppy_raw_cmd {
+	unsigned int flags;
 #define FD_RAW_READ 1
 #define FD_RAW_WRITE 2
 #define FD_RAW_NO_MOTOR 4
@@ -317,4 +336,33 @@
 /* more "out" flags */
 #define FD_RAW_FAILURE 0x10000 /* command sent to fdc, fdc returned error */
 #define FD_RAW_HARDFAILURE 0x20000 /* fdc had to be reset, or timed out */
+
+	void *data;
+	char *kernel_data; /* location of data buffer in the kernel */
+	struct floppy_raw_cmd *next; /* used for chaining of raw cmd's 
+				      * withing the kernel */
+	long length; /* in: length of dma transfer. out: remaining bytes */
+	long phys_length; /* physical length, if different from dma length */
+	int buffer_length; /* length of allocated buffer */
+
+	unsigned char rate;
+	unsigned char cmd_count;
+	unsigned char cmd[16];
+	unsigned char reply_count;
+	unsigned char reply[16];
+	int track;
+	int resultcode;
+
+	int reserved1;
+	int reserved2;
+};
+
+#define FDRAWCMD _IO(2, 0x58)
+/* send a raw command to the fdc. Structure size not included, because of
+ * batches */
+
+#define FDTWADDLE _IO(2, 0x59)
+/* flicker motor-on bit before reading a sector. Experimental */
+
+
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this