xref: /original-bsd/sys/sys/disk.h (revision fac0c393)
1 /*
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * All advertising materials mentioning features or use of this software
10  * must display the following acknowledgement:
11  *	This product includes software developed by the University of
12  *	California, Lawrence Berkeley Laboratory.
13  *
14  * %sccs.include.redist.c%
15  *
16  *	@(#)disk.h	8.2 (Berkeley) 01/09/95
17  *
18  * from: $Header: disk.h,v 1.5 92/11/19 04:33:03 torek Exp $ (LBL)
19  */
20 
21 /*
22  * Disk device structures.
23  *
24  * Note that this is only a preliminary outline.  The final disk structures
25  * may be somewhat different.
26  */
27 struct buf;
28 
29 struct dkdevice {
30 	struct	device dk_dev;		/* base device */
31 	struct	dkdevice *dk_next;	/* list of disks; not yet used */
32 	int	dk_bps;			/* xfer rate: bytes per second */
33 	int	dk_bopenmask;		/* block devices open */
34 	int	dk_copenmask;		/* character devices open */
35 	int	dk_openmask;		/* composite (bopen|copen) */
36 	int	dk_state;		/* label state   ### */
37 	int	dk_blkshift;		/* shift to convert DEV_BSIZE to blks */
38 	int	dk_byteshift;		/* shift to convert bytes to blks */
39 	struct	dkdriver *dk_driver;	/* pointer to driver */
40 	daddr_t	dk_labelsector;		/* sector containing label */
41 	struct	disklabel dk_label;	/* label */
42 };
43 
44 struct dkdriver {
45 	void	(*d_strategy) __P((struct buf *));
46 #ifdef notyet
47 	int	(*d_open) __P((dev_t dev, int ifmt, int, struct proc *));
48 	int	(*d_close) __P((dev_t dev, int, int ifmt, struct proc *));
49 	int	(*d_ioctl) __P((dev_t dev, u_long cmd, caddr_t data, int fflag,
50 				struct proc *));
51 	int	(*d_dump) __P((dev_t));
52 	void	(*d_start) __P((struct buf *, daddr_t));
53 	int	(*d_mklabel) __P((struct dkdevice *));
54 #endif
55 };
56 
57 /* states */
58 #define	DK_CLOSED	0		/* drive is closed */
59 #define	DK_WANTOPEN	1		/* drive being opened */
60 #define	DK_WANTOPENRAW	2		/* drive being opened */
61 #define	DK_RDLABEL	3		/* label being read */
62 #define	DK_OPEN		4		/* label read, drive open */
63 #define	DK_OPENRAW	5		/* open without label */
64 
65 #ifdef DISKSORT_STATS
66 /*
67  * Stats from disksort().
68  */
69 struct disksort_stats {
70 	long	ds_newhead;		/* # new queue heads created */
71 	long	ds_newtail;		/* # new queue tails created */
72 	long	ds_midfirst;		/* # insertions into sort list */
73 	long	ds_endfirst;		/* # insertions at end of sort list */
74 	long	ds_newsecond;		/* # inversions (2nd lists) created */
75 	long	ds_midsecond;		/* # insertions into 2nd list */
76 	long	ds_endsecond;		/* # insertions at end of 2nd list */
77 };
78 #endif
79 
80 #ifdef KERNEL
81 void	disksort __P((struct buf *, struct buf *));
82 char	*readdisklabel __P((struct dkdevice *, int));
83 int	setdisklabel __P((struct dkdevice *, struct disklabel *));
84 int	writedisklabel __P((struct dkdevice *, int));
85 int	diskerr __P((struct dkdevice *, struct buf *, char *, int, int));
86 #endif
87