xref: /original-bsd/sys/sys/disk.h (revision d1f811c7)
1 /*
2  * Copyright (c) 1992 The Regents of the University of California.
3  * 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  * %sccs.include.redist.c%
10  *
11  *	@(#)disk.h	5.1 (Berkeley) 07/10/92
12  *
13  * from: $Header: disk.h,v 1.1 92/07/10 07:13:43 torek Exp $ (LBL)
14  */
15 
16 /*
17  * Disk device structures.
18  *
19  * Note that this is only a preliminary outline.  The final disk structures
20  * may be somewhat different.
21  */
22 struct buf;
23 
24 struct dkdevice {
25 	struct	device dk_dev;		/* base device */
26 	struct	dkdevice *dk_next;	/* list of disks; not yet used */
27 	int	dk_wpms;		/* xfer rate */
28 	int	dk_bopenmask;		/* block devices open */
29 	int	dk_copenmask;		/* character devices open */
30 	int	dk_openmask;		/* composite (bopen|copen) */
31 	int	dk_state;		/* label state   ### */
32 	int	dk_blkshift;		/* shift to convert DEV_BSIZE to blks */
33 	int	dk_byteshift;		/* shift to convert bytes to blks */
34 	struct	dkdriver *dk_driver;	/* pointer to driver */
35 	daddr_t	dk_labelsector;		/* sector containing label */
36 	struct	disklabel dk_label;	/* label */
37 };
38 
39 struct dkdriver {
40 	void	(*d_strategy) __P((struct buf *));
41 #ifdef notyet
42 	int	(*d_open) __P((dev_t dev, int ifmt, int, struct proc *));
43 	int	(*d_close) __P((dev_t dev, int, int ifmt, struct proc *));
44 	int	(*d_ioctl) __P((dev_t dev, int cmd, caddr_t data, int fflag,
45 				struct proc *));
46 	int	(*d_dump) __P((dev_t));
47 #endif
48 	void	(*d_start) __P((struct buf *, daddr_t));
49 	int	(*d_mklabel) __P((struct dkdevice *));
50 };
51 
52 /* states */
53 #define	DK_CLOSED	0		/* drive is closed */
54 #define	DK_WANTOPEN	1		/* drive being opened */
55 #define	DK_WANTOPENRAW	2		/* drive being opened */
56 #define	DK_RDLABEL	3		/* label being read */
57 #define	DK_OPEN		4		/* label read, drive open */
58 #define	DK_OPENRAW	5		/* open without label */
59 
60 #ifdef DISKSORT_STATS
61 /*
62  * Stats from disksort().
63  */
64 struct disksort_stats {
65 	long	ds_newhead;		/* # new queue heads created */
66 	long	ds_newtail;		/* # new queue tails created */
67 	long	ds_midfirst;		/* # insertions into sort list */
68 	long	ds_endfirst;		/* # insertions at end of sort list */
69 	long	ds_newsecond;		/* # inversions (2nd lists) created */
70 	long	ds_midsecond;		/* # insertions into 2nd list */
71 	long	ds_endsecond;		/* # insertions at end of 2nd list */
72 };
73 #endif
74 
75 #ifdef KERNEL
76 void	disksort __P((struct buf *, struct buf *));
77 char	*readdisklabel __P((struct dkdevice *, int));
78 int	setdisklabel __P((struct dkdevice *, struct disklabel *));
79 int	writedisklabel __P((struct dkdevice *, int));
80 int	diskerr __P((struct dkdevice *, struct buf *, char *, int, int));
81 #endif
82