1 /* $NetBSD: fdvar.h,v 1.6 2008/04/28 20:23:52 martin Exp $ */ 2 3 /*- 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Charles M. Hannum. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include "rnd.h" 33 34 #if NRND > 0 35 #include <sys/rnd.h> 36 #endif 37 38 /* 39 * Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how 40 * we tell them apart. 41 */ 42 struct fd_type { 43 int sectrac; /* sectors per track */ 44 int heads; /* number of heads */ 45 int seccyl; /* sectors per cylinder */ 46 int secsize; /* size code for sectors */ 47 int datalen; /* data len when secsize = 0 */ 48 int steprate; /* step rate and head unload time */ 49 int gap1; /* gap len between sectors */ 50 int gap2; /* formatting gap */ 51 int cyls; /* total num of cylinders */ 52 int size; /* size of disk in sectors */ 53 int step; /* steps per cylinder */ 54 int rate; /* transfer speed code */ 55 u_char fillbyte; /* format fill byte */ 56 u_char interleave; /* interleave factor (formatting) */ 57 const char *name; 58 }; 59 60 /* software state, per disk (with up to 4 disks per ctlr) */ 61 struct fd_softc { 62 device_t sc_dev; 63 struct disk sc_dk; 64 65 const struct fd_type *sc_deftype; /* default type descriptor */ 66 struct fd_type *sc_type; /* current type descriptor */ 67 struct fd_type sc_type_copy; /* copy for fiddling when formatting */ 68 69 struct callout sc_motoron_ch; 70 struct callout sc_motoroff_ch; 71 72 daddr_t sc_blkno; /* starting block number */ 73 int sc_bcount; /* byte count left */ 74 int sc_opts; /* user-set options */ 75 int sc_skip; /* bytes already transferred */ 76 int sc_nblks; /* number of blocks currently transferring */ 77 int sc_nbytes; /* number of bytes currently transferring */ 78 79 int sc_drive; /* physical unit number */ 80 int sc_flags; 81 #define FD_OPEN 0x01 /* it's open */ 82 #define FD_MOTOR 0x02 /* motor should be on */ 83 #define FD_MOTOR_WAIT 0x04 /* motor coming up */ 84 int sc_cylin; /* where we think the head is */ 85 86 void *sc_roothook; /* mountroot hook */ 87 88 TAILQ_ENTRY(fd_softc) sc_drivechain; 89 int sc_ops; /* I/O ops since last switch */ 90 struct bufq_state *sc_q;/* pending I/O requests */ 91 int sc_active; /* number of active I/O operations */ 92 93 #if NRND > 0 94 rndsource_element_t rnd_source; 95 #endif 96 }; 97