2 * Copyright (c) 2003,2004 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * ----------------------------------------------------------------------------
35 * "THE BEER-WARE LICENSE" (Revision 42):
36 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
37 * can do whatever you want with this stuff. If we meet some day, and you think
38 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
39 * ----------------------------------------------------------------------------
41 * $FreeBSD: src/sys/sys/disk.h,v 1.16.2.3 2001/06/20 16:11:01 scottl Exp $
42 * $DragonFly: src/sys/sys/disk.h,v 1.18 2007/07/30 08:02:40 dillon Exp $
48 #if !defined(_KERNEL) && !defined(_KERNEL_STRUCTURES)
49 #error "This file should not be included by userland programs."
52 #ifndef _SYS_DISKSLICE_H_
53 #include <sys/diskslice.h>
56 #include <sys/queue.h>
58 #ifndef _SYS_MSGPORT_H_
59 #include <sys/msgport.h>
63 * Media information structure - filled in by the media driver.
65 * NOTE: d_serialno is copied on the call to setdiskinfo and need
66 * not be valid after that.
70 * These fields are required. Most drivers will load a disk_info
71 * structure in the device open function with the media parameters
72 * and call disk_setdiskinfo().
74 * Note that only one of d_media_size or d_media_blocks should be
77 * d_media_size media size in bytes
78 * d_media_blocks media size in blocks (e.g. total sectors)
79 * d_media_blksize media block size / sector size
80 * d_dsflags disklabel management flags
82 u_int64_t d_media_size
;
83 u_int64_t d_media_blocks
;
88 * Optional fields, leave 0 if not known
90 u_int d_type
; /* DTYPE_xxx */
99 * d_dsflags, also used for dsopen() - control disklabel processing
101 * COMPATPARTA - used by scsi devices to allow CDs to boot from cd0a.
102 * cd's don't have disklabels and the default compat label
103 * does not implement an 'a' partition.
105 * COMPARTMBR - used by the vn device to request that one sector be
106 * reserved as if an MBR were present even when one isn't.
108 * MBRQUIET - silently ignore MBR probe if unable to read sector 0.
111 #define DSO_NOLABELS 0x0001
112 #define DSO_ONESLICE 0x0002
113 #define DSO_COMPATLABEL 0x0004
114 #define DSO_COMPATPARTA 0x0008
115 #define DSO_COMPATMBR 0x0010
116 #define DSO_RAWEXTENSIONS 0x0020
117 #define DSO_MBRQUIET 0x0040
120 * Disk management structure - automated disklabel support.
123 struct dev_ops
*d_dev_ops
; /* our device switch */
124 struct dev_ops
*d_raw_ops
; /* the raw device switch */
126 cdev_t d_rawdev
; /* backing raw device */
127 cdev_t d_cdev
; /* special whole-disk part */
128 struct diskslices
*d_slice
;
129 struct disk_info d_info
; /* info structure for media */
130 LIST_ENTRY(disk
) d_list
;
136 #define DISKFLAG_LOCK 0x1
137 #define DISKFLAG_WANTED 0x2
140 cdev_t
disk_create (int unit
, struct disk
*disk
, struct dev_ops
*raw_ops
);
141 cdev_t
disk_locate (const char *devname
);
142 void disk_destroy (struct disk
*disk
);
143 void disk_setdiskinfo (struct disk
*disk
, struct disk_info
*info
);
144 void disk_setdiskinfo_sync(struct disk
*disk
, struct disk_info
*info
);
145 int disk_dumpcheck (cdev_t dev
, u_int64_t
*count
, u_int64_t
*blkno
, u_int
*secsize
);
146 struct disk
*disk_enumerate (struct disk
*disk
);
147 void disk_invalidate (struct disk
*disk
);
148 void disk_unprobe(struct disk
*disk
);
150 void disk_msg_send(uint32_t cmd
, void *load
, void *load2
);
151 void disk_msg_send_sync(uint32_t cmd
, void *load
, void *load2
);
152 void disk_config(void *);
154 typedef struct disk_msg
{
161 #define DISK_DISK_PROBE 0x01
162 #define DISK_DISK_DESTROY 0x02
163 #define DISK_SLICE_REPROBE 0x03
164 #define DISK_DISK_REPROBE 0x04
165 #define DISK_UNPROBE 0x05
166 #define DISK_SYNC 0x99
171 #endif /* _SYS_DISK_H_ */