xref: /openbsd/sys/scsi/sdvar.h (revision d485f761)
1 /*	$OpenBSD: sdvar.h,v 1.2 2001/06/22 14:35:43 deraadt Exp $	*/
2 /*	$NetBSD: sdvar.h,v 1.7 1998/08/17 00:49:03 mycroft Exp $	*/
3 
4 /*-
5  * Copyright (c) 1998 The NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to The NetBSD Foundation
9  * by Charles M. Hannum.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *        This product includes software developed by the NetBSD
22  *        Foundation, Inc. and its contributors.
23  * 4. Neither the name of The NetBSD Foundation nor the names of its
24  *    contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  */
39 
40 /*
41  * Originally written by Julian Elischer (julian@dialix.oz.au)
42  * for TRW Financial Systems for use under the MACH(2.5) operating system.
43  *
44  * TRW Financial Systems, in accordance with their agreement with Carnegie
45  * Mellon University, makes this software available to CMU to distribute
46  * or use in any manner that they see fit as long as this message is kept with
47  * the software. For this reason TFS also grants any other persons or
48  * organisations permission to use or modify this software.
49  *
50  * TFS supplies this software to be publicly redistributed
51  * on the understanding that TFS is not responsible for the correct
52  * functioning of this software in any circumstances.
53  *
54  * Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
55  */
56 
57 #define	SDRETRIES	4
58 
59 struct sd_ops;
60 
61 struct sd_softc {
62 	struct device sc_dev;
63 	struct disk sc_dk;
64 
65 	int flags;
66 #define	SDF_LOCKED	0x01
67 #define	SDF_WANTED	0x02
68 #define	SDF_WLABEL	0x04		/* label is writable */
69 #define	SDF_LABELLING	0x08		/* writing label */
70 #define	SDF_ANCIENT	0x10		/* disk is ancient; for minphys */
71 #define	SDF_DIRTY	0x20		/* disk is dirty; needs cache flush */
72 #define	SDF_FLUSHING	0x40		/* flushing, for sddone() */
73 	struct scsi_link *sc_link;	/* contains our targ, lun, etc. */
74 	struct disk_parms {
75 		u_long	heads;		/* number of heads */
76 		u_long	cyls;		/* number of cylinders */
77 		u_long	sectors;	/* number of sectors/track */
78 		u_long	blksize;	/* number of bytes/sector */
79 		u_long	disksize;	/* total number sectors */
80 		u_long	rot_rate;	/* rotational rate, in RPM */
81 	} params;
82 	struct buf buf_queue;
83 	u_int8_t type;
84 	struct disk_name {
85 		char vendor[9];		/* disk vendor/manufacturer */
86 		char product[17];	/* disk product model */
87 		char revision[5];	/* drive/firmware revision */
88 	} name;
89 	const struct sd_ops *sc_ops;	/* our bus-dependent ops vector */
90 
91 	void *sc_sdhook;		/* our shutdown hook */
92 
93 #if NRND > 0
94 	rndsource_element_t rnd_source;
95 #endif
96 };
97 
98 struct sd_ops {
99 	int	(*sdo_get_parms) __P((struct sd_softc *, struct disk_parms *,
100 		    int));
101 	void	(*sdo_flush) __P((struct sd_softc *, int));
102 };
103 #define	SDGP_RESULT_OK		0	/* paramters obtained */
104 #define	SDGP_RESULT_OFFLINE	1	/* no media, or otherwise losing */
105 #define	SDGP_RESULT_UNFORMATTED	2	/* unformatted media (max params) */
106 
107