98 static int cmdkrw(dev_t dev, struct uio *uio, int flag);
99 static int cmdkarw(dev_t dev, struct aio_req *aio, int flag);
100
101 /*
102 * Bad Block Handling Functions Prototypes
103 */
104 static void cmdk_bbh_reopen(struct cmdk *dkp);
105 static opaque_t cmdk_bbh_gethandle(opaque_t bbh_data, struct buf *bp);
106 static bbh_cookie_t cmdk_bbh_htoc(opaque_t bbh_data, opaque_t handle);
107 static void cmdk_bbh_freehandle(opaque_t bbh_data, opaque_t handle);
108 static void cmdk_bbh_close(struct cmdk *dkp);
109 static void cmdk_bbh_setalts_idx(struct cmdk *dkp);
110 static int cmdk_bbh_bsearch(struct alts_ent *buf, int cnt, daddr32_t key);
111
112 static struct bbh_objops cmdk_bbh_ops = {
113 nulldev,
114 nulldev,
115 cmdk_bbh_gethandle,
116 cmdk_bbh_htoc,
117 cmdk_bbh_freehandle,
118 0, 0
119 };
120
121 static int cmdkopen(dev_t *dev_p, int flag, int otyp, cred_t *credp);
122 static int cmdkclose(dev_t dev, int flag, int otyp, cred_t *credp);
123 static int cmdkstrategy(struct buf *bp);
124 static int cmdkdump(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
125 static int cmdkioctl(dev_t, int, intptr_t, int, cred_t *, int *);
126 static int cmdkread(dev_t dev, struct uio *uio, cred_t *credp);
127 static int cmdkwrite(dev_t dev, struct uio *uio, cred_t *credp);
128 static int cmdk_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
129 int mod_flags, char *name, caddr_t valuep, int *lengthp);
130 static int cmdkaread(dev_t dev, struct aio_req *aio, cred_t *credp);
131 static int cmdkawrite(dev_t dev, struct aio_req *aio, cred_t *credp);
132
133 /*
134 * Device driver ops vector
135 */
136
137 static struct cb_ops cmdk_cb_ops = {
138 cmdkopen, /* open */
177 nodev, /* reset */
178 &cmdk_cb_ops, /* driver operations */
179 (struct bus_ops *)0, /* bus operations */
180 cmdkpower, /* power */
181 ddi_quiesce_not_needed, /* quiesce */
182 };
183
184 /*
185 * This is the loadable module wrapper.
186 */
187 #include <sys/modctl.h>
188
189 #ifndef XPV_HVM_DRIVER
190 static struct modldrv modldrv = {
191 &mod_driverops, /* Type of module. This one is a driver */
192 "Common Direct Access Disk",
193 &cmdk_ops, /* driver ops */
194 };
195
196 static struct modlinkage modlinkage = {
197 MODREV_1, (void *)&modldrv, NULL
198 };
199
200
201 #else /* XPV_HVM_DRIVER */
202 static struct modlmisc modlmisc = {
203 &mod_miscops, /* Type of module. This one is a misc */
204 "HVM Common Direct Access Disk",
205 };
206
207 static struct modlinkage modlinkage = {
208 MODREV_1, (void *)&modlmisc, NULL
209 };
210
211 #endif /* XPV_HVM_DRIVER */
212
213 /* Function prototypes for cmlb callbacks */
214
215 static int cmdk_lb_rdwr(dev_info_t *dip, uchar_t cmd, void *bufaddr,
216 diskaddr_t start, size_t length, void *tg_cookie);
217
218 static int cmdk_lb_getinfo(dev_info_t *dip, int cmd, void *arg,
219 void *tg_cookie);
220
221 static void cmdk_devid_setup(struct cmdk *dkp);
222 static int cmdk_devid_modser(struct cmdk *dkp);
223 static int cmdk_get_modser(struct cmdk *dkp, int ioccmd, char *buf, int len);
224 static int cmdk_devid_fabricate(struct cmdk *dkp);
225 static int cmdk_devid_read(struct cmdk *dkp);
226
227 static cmlb_tg_ops_t cmdk_lb_ops = {
228 TG_DK_OPS_VERSION_1,
|
98 static int cmdkrw(dev_t dev, struct uio *uio, int flag);
99 static int cmdkarw(dev_t dev, struct aio_req *aio, int flag);
100
101 /*
102 * Bad Block Handling Functions Prototypes
103 */
104 static void cmdk_bbh_reopen(struct cmdk *dkp);
105 static opaque_t cmdk_bbh_gethandle(opaque_t bbh_data, struct buf *bp);
106 static bbh_cookie_t cmdk_bbh_htoc(opaque_t bbh_data, opaque_t handle);
107 static void cmdk_bbh_freehandle(opaque_t bbh_data, opaque_t handle);
108 static void cmdk_bbh_close(struct cmdk *dkp);
109 static void cmdk_bbh_setalts_idx(struct cmdk *dkp);
110 static int cmdk_bbh_bsearch(struct alts_ent *buf, int cnt, daddr32_t key);
111
112 static struct bbh_objops cmdk_bbh_ops = {
113 nulldev,
114 nulldev,
115 cmdk_bbh_gethandle,
116 cmdk_bbh_htoc,
117 cmdk_bbh_freehandle,
118 { NULL, NULL }
119 };
120
121 static int cmdkopen(dev_t *dev_p, int flag, int otyp, cred_t *credp);
122 static int cmdkclose(dev_t dev, int flag, int otyp, cred_t *credp);
123 static int cmdkstrategy(struct buf *bp);
124 static int cmdkdump(dev_t dev, caddr_t addr, daddr_t blkno, int nblk);
125 static int cmdkioctl(dev_t, int, intptr_t, int, cred_t *, int *);
126 static int cmdkread(dev_t dev, struct uio *uio, cred_t *credp);
127 static int cmdkwrite(dev_t dev, struct uio *uio, cred_t *credp);
128 static int cmdk_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op,
129 int mod_flags, char *name, caddr_t valuep, int *lengthp);
130 static int cmdkaread(dev_t dev, struct aio_req *aio, cred_t *credp);
131 static int cmdkawrite(dev_t dev, struct aio_req *aio, cred_t *credp);
132
133 /*
134 * Device driver ops vector
135 */
136
137 static struct cb_ops cmdk_cb_ops = {
138 cmdkopen, /* open */
177 nodev, /* reset */
178 &cmdk_cb_ops, /* driver operations */
179 (struct bus_ops *)0, /* bus operations */
180 cmdkpower, /* power */
181 ddi_quiesce_not_needed, /* quiesce */
182 };
183
184 /*
185 * This is the loadable module wrapper.
186 */
187 #include <sys/modctl.h>
188
189 #ifndef XPV_HVM_DRIVER
190 static struct modldrv modldrv = {
191 &mod_driverops, /* Type of module. This one is a driver */
192 "Common Direct Access Disk",
193 &cmdk_ops, /* driver ops */
194 };
195
196 static struct modlinkage modlinkage = {
197 MODREV_1, { (void *)&modldrv, NULL }
198 };
199
200
201 #else /* XPV_HVM_DRIVER */
202 static struct modlmisc modlmisc = {
203 &mod_miscops, /* Type of module. This one is a misc */
204 "HVM Common Direct Access Disk",
205 };
206
207 static struct modlinkage modlinkage = {
208 MODREV_1, { (void *)&modlmisc, NULL }
209 };
210
211 #endif /* XPV_HVM_DRIVER */
212
213 /* Function prototypes for cmlb callbacks */
214
215 static int cmdk_lb_rdwr(dev_info_t *dip, uchar_t cmd, void *bufaddr,
216 diskaddr_t start, size_t length, void *tg_cookie);
217
218 static int cmdk_lb_getinfo(dev_info_t *dip, int cmd, void *arg,
219 void *tg_cookie);
220
221 static void cmdk_devid_setup(struct cmdk *dkp);
222 static int cmdk_devid_modser(struct cmdk *dkp);
223 static int cmdk_get_modser(struct cmdk *dkp, int ioccmd, char *buf, int len);
224 static int cmdk_devid_fabricate(struct cmdk *dkp);
225 static int cmdk_devid_read(struct cmdk *dkp);
226
227 static cmlb_tg_ops_t cmdk_lb_ops = {
228 TG_DK_OPS_VERSION_1,
|