4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
23 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
30 #include <sys/types.h>
31 #include <sys/ksynch.h>
33 #include <sys/sunddi.h>
40 * This describes a fairly simple block device. The idea here is that
41 * these things want to take advantage of the common labelling support,
42 * but do not need all the capabilities of SCSA. So we make quite a few
45 * 1) Device block size is a power of 2 greater or equal to 512 bytes.
46 * An optional physical block size can be reported if the underlying
47 * device uses larger block sizes internally, so that writes can be
50 * 2) Non-rotating media. We assume a simple linear layout.
52 * 3) Fixed queue depth, for each device. The adapter driver reports
53 * the queue depth at registration. We don't have any form of
54 * dynamic flow control.
56 * 4) Negligible power management support. The framework does not support
57 * fine grained power management. If the adapter driver wants to use
58 * such, it will need to manage power on its own.
60 * 5) Suspend/resume support managed by the adapter driver. We don't
61 * support suspend/resume directly. The adapter device driver will
62 * need to manage this on its own behalf.
64 * 6) No request priorities. Transfers are assumed to execute in
65 * roughly FIFO order. The adapter driver may reorder them, but the
66 * submitter has no control over that.
68 * 7) No request cancellation. Once submitted, the job completes or
69 * fails. It cannot be canceled.
71 * 8) Limited support for removable media. There is no support for
72 * locking bay doors or mechanised media bays. This could be
73 * added, but at present the only such interesting devices are
74 * covered by the SCSI disk driver.
77 typedef struct bd_handle
*bd_handle_t
;
78 typedef struct bd_xfer bd_xfer_t
;
79 typedef struct bd_drive bd_drive_t
;
80 typedef struct bd_media bd_media_t
;
81 typedef struct bd_ops bd_ops_t
;
86 * NB: If using DMA the br_ndmac will be non-zero. Otherwise
87 * the br_kaddr will be non-NULL.
91 ddi_dma_handle_t x_dmah
;
92 ddi_dma_cookie_t x_dmac
;
98 #define BD_XFER_POLL (1U << 0) /* no interrupts (dump) */
103 boolean_t d_removable
;
104 boolean_t d_hotpluggable
;
111 * NB: The block size must be a power of two not less than
112 * DEV_BSIZE (512). Other values of the block size will
113 * simply not function and the media will be rejected.
115 * The block size must also divide evenly into the device's
116 * d_maxxfer field. If the maxxfer is a power of two larger
117 * than the block size, then this will automatically be
120 * The physical block size (m_pblksize) must be 0 or a power
121 * of two not less than the block size.
125 boolean_t m_readonly
;
126 boolean_t m_solidstate
;
130 #define BD_INFO_FLAG_REMOVABLE (1U << 0)
131 #define BD_INFO_FLAG_HOTPLUGGABLE (1U << 1)
132 #define BD_INFO_FLAG_READ_ONLY (1U << 2)
136 void (*o_drive_info
)(void *, bd_drive_t
*);
137 int (*o_media_info
)(void *, bd_media_t
*);
138 int (*o_devid_init
)(void *, dev_info_t
*, ddi_devid_t
*);
139 int (*o_sync_cache
)(void *, bd_xfer_t
*);
140 int (*o_read
)(void *, bd_xfer_t
*);
141 int (*o_write
)(void *, bd_xfer_t
*);
144 #define BD_OPS_VERSION_0 0
147 * Note, one handler *per* address. Drivers with multiple targets at
148 * different addresses must use separate handles.
150 bd_handle_t
bd_alloc_handle(void *, bd_ops_t
*, ddi_dma_attr_t
*, int);
151 void bd_free_handle(bd_handle_t
);
152 int bd_attach_handle(dev_info_t
*, bd_handle_t
);
153 int bd_detach_handle(bd_handle_t
);
154 void bd_state_change(bd_handle_t
);
155 void bd_xfer_done(bd_xfer_t
*, int);
156 void bd_mod_init(struct dev_ops
*);
157 void bd_mod_fini(struct dev_ops
*);
163 #endif /* _SYS_BLKDEV_H */