1/* $OpenBSD: ioctl_fd.h,v 1.2 2011/03/23 16:54:34 pirofti Exp $ */
2
3/*
4 * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
22 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 * DAMAGE.
28 *
29 * From: Id: ioctl_fd.h,v 1.7 1994/10/30 19:17:39 joerg Exp
30 */
31
32#ifndef _MACHINE_IOCTL_FD_H_
33#define _MACHINE_IOCTL_FD_H_
34
35#include <sys/ioccom.h>
36
37#define FD_FORMAT_VERSION 110 /* used to validate before formatting */
38#define FD_MAX_NSEC 36 /* highest known number of spt - allow for */
39 /* 2.88 MB drives */
40
41struct fd_formb {
42 int format_version; /* == FD_FORMAT_VERSION */
43 int cyl, head;
44 int transfer_rate; /* fdreg.h: FDC_???KBPS */
45
46 union {
47 struct fd_form_data {
48 /*
49 * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
50 * it is hardware-dependant since it exactly
51 * matches the byte sequence to write to FDC
52 * during its `format track' operation
53 */
54 u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
55 u_char nsecs; /* must be <= FD_MAX_NSEC */
56 u_char gaplen; /* GAP 3 length; usually 84 */
57 u_char fillbyte; /* usually 0xf6 */
58 struct fd_idfield_data {
59 /*
60 * data to write into id fields;
61 * for obscure formats, they mustn't match
62 * the real values (but mostly do)
63 */
64 u_char cylno; /* 0 thru 79 (or 39) */
65 u_char headno; /* 0, or 1 */
66 u_char secno; /* starting at 1! */
67 u_char secsize; /* usually 2 */
68 } idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
69 } structured;
70 u_char raw[1]; /* to have continuous indexed access */
71 } format_info;
72};
73
74/* make life easier */
75# define fd_formb_secshift format_info.structured.secshift
76# define fd_formb_nsecs format_info.structured.nsecs
77# define fd_formb_gaplen format_info.structured.gaplen
78# define fd_formb_fillbyte format_info.structured.fillbyte
79/* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
80# define fd_formb_cylno(i) format_info.structured.idfields[i].cylno
81# define fd_formb_headno(i) format_info.structured.idfields[i].headno
82# define fd_formb_secno(i) format_info.structured.idfields[i].secno
83# define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
84
85/*
86 * Floppies come in various flavors, e.g., 1.2MB vs 1.44MB; here is how
87 * we tell them apart.
88 */
89struct fd_type {
90 int sectrac; /* sectors per track */
91 int heads; /* number of heads */
92 int seccyl; /* sectors per cylinder */
93 int secsize; /* size code for sectors */
94 int datalen; /* data len when secsize = 0 */
95 int steprate; /* step rate and head unload time */
96 int gap1; /* gap len between sectors */
97 int gap2; /* formatting gap */
98 int tracks; /* total num of tracks */
99 int size; /* size of disk in sectors */
100 int step; /* steps per cylinder */
101 int rate; /* transfer speed code */
102 char *name;
103};
104
105
106#define FD_FORM _IOW('F', 61, struct fd_formb) /* format a track */
107#define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */
108#define FD_STYPE _IOW('F', 63, struct fd_type) /* set drive type */
109
110#define FD_GOPTS _IOR('F', 64, int) /* drive options, see below */
111#define FD_SOPTS _IOW('F', 65, int)
112
113#define FDOPT_NORETRY 0x0001 /* no retries on failure (cleared on close) */
114
115/*
116 * The following definitions duplicate those in sys/i386/isa/fdreg.h
117 * They are here since their values are to be used in the above
118 * structure when formatting a floppy. For very obvious reasons, both
119 * definitions must match ;-)
120 */
121#ifndef FDC_500KBPS
122#define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */
123#define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */
124#define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */
125#define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */
126 /* for some controllers 1MPBS instead */
127#endif /* FDC_500KBPS */
128
129
130#endif /* !_MACHINE_IOCTL_FD_H__ */