1 | /* $NetBSD: fdvar.h,v 1.9 2015/04/13 16:33:24 riastradh 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 <sys/rndsource.h> |
33 | |
34 | /* |
35 | * Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how |
36 | * we tell them apart. |
37 | */ |
38 | struct fd_type { |
39 | int sectrac; /* sectors per track */ |
40 | int heads; /* number of heads */ |
41 | int seccyl; /* sectors per cylinder */ |
42 | int secsize; /* size code for sectors */ |
43 | int datalen; /* data len when secsize = 0 */ |
44 | int steprate; /* step rate and head unload time */ |
45 | int gap1; /* gap len between sectors */ |
46 | int gap2; /* formatting gap */ |
47 | int cyls; /* total num of cylinders */ |
48 | int size; /* size of disk in sectors */ |
49 | int step; /* steps per cylinder */ |
50 | int rate; /* transfer speed code */ |
51 | u_char fillbyte; /* format fill byte */ |
52 | u_char interleave; /* interleave factor (formatting) */ |
53 | const char *name; |
54 | }; |
55 | |
56 | /* software state, per disk (with up to 4 disks per ctlr) */ |
57 | struct fd_softc { |
58 | device_t sc_dev; |
59 | struct disk sc_dk; |
60 | |
61 | const struct fd_type *sc_deftype; /* default type descriptor */ |
62 | struct fd_type *sc_type; /* current type descriptor */ |
63 | struct fd_type sc_type_copy; /* copy for fiddling when formatting */ |
64 | |
65 | struct callout sc_motoron_ch; |
66 | struct callout sc_motoroff_ch; |
67 | |
68 | daddr_t sc_blkno; /* starting block number */ |
69 | int sc_bcount; /* byte count left */ |
70 | int sc_opts; /* user-set options */ |
71 | int sc_skip; /* bytes already transferred */ |
72 | int sc_nblks; /* number of blocks currently transferring */ |
73 | int sc_nbytes; /* number of bytes currently transferring */ |
74 | |
75 | int sc_drive; /* physical unit number */ |
76 | int sc_flags; |
77 | #define FD_OPEN 0x01 /* it's open */ |
78 | #define FD_MOTOR 0x02 /* motor should be on */ |
79 | #define FD_MOTOR_WAIT 0x04 /* motor coming up */ |
80 | int sc_cylin; /* where we think the head is */ |
81 | |
82 | void *sc_roothook; /* mountroot hook */ |
83 | |
84 | TAILQ_ENTRY(fd_softc) sc_drivechain; |
85 | int sc_ops; /* I/O ops since last switch */ |
86 | struct bufq_state *sc_q;/* pending I/O requests */ |
87 | int sc_active; /* number of active I/O operations */ |
88 | |
89 | krndsource_t rnd_source; |
90 | }; |
91 | |