sd.c revision 1.1 1 1.1 tsutsui /* $NetBSD: sd.c,v 1.1 2013/01/05 17:44:24 tsutsui Exp $ */
2 1.1 tsutsui
3 1.1 tsutsui /*
4 1.1 tsutsui * Copyright (c) 1992 OMRON Corporation.
5 1.1 tsutsui *
6 1.1 tsutsui * This code is derived from software contributed to Berkeley by
7 1.1 tsutsui * OMRON Corporation.
8 1.1 tsutsui *
9 1.1 tsutsui * Redistribution and use in source and binary forms, with or without
10 1.1 tsutsui * modification, are permitted provided that the following conditions
11 1.1 tsutsui * are met:
12 1.1 tsutsui * 1. Redistributions of source code must retain the above copyright
13 1.1 tsutsui * notice, this list of conditions and the following disclaimer.
14 1.1 tsutsui * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 tsutsui * notice, this list of conditions and the following disclaimer in the
16 1.1 tsutsui * documentation and/or other materials provided with the distribution.
17 1.1 tsutsui * 3. All advertising materials mentioning features or use of this software
18 1.1 tsutsui * must display the following acknowledgement:
19 1.1 tsutsui * This product includes software developed by the University of
20 1.1 tsutsui * California, Berkeley and its contributors.
21 1.1 tsutsui * 4. Neither the name of the University nor the names of its contributors
22 1.1 tsutsui * may be used to endorse or promote products derived from this software
23 1.1 tsutsui * without specific prior written permission.
24 1.1 tsutsui *
25 1.1 tsutsui * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 1.1 tsutsui * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.1 tsutsui * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.1 tsutsui * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 1.1 tsutsui * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.1 tsutsui * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.1 tsutsui * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.1 tsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.1 tsutsui * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.1 tsutsui * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.1 tsutsui * SUCH DAMAGE.
36 1.1 tsutsui *
37 1.1 tsutsui * @(#)sd.c 8.1 (Berkeley) 6/10/93
38 1.1 tsutsui */
39 1.1 tsutsui /*
40 1.1 tsutsui * Copyright (c) 1992, 1993
41 1.1 tsutsui * The Regents of the University of California. All rights reserved.
42 1.1 tsutsui *
43 1.1 tsutsui * This code is derived from software contributed to Berkeley by
44 1.1 tsutsui * OMRON Corporation.
45 1.1 tsutsui *
46 1.1 tsutsui * Redistribution and use in source and binary forms, with or without
47 1.1 tsutsui * modification, are permitted provided that the following conditions
48 1.1 tsutsui * are met:
49 1.1 tsutsui * 1. Redistributions of source code must retain the above copyright
50 1.1 tsutsui * notice, this list of conditions and the following disclaimer.
51 1.1 tsutsui * 2. Redistributions in binary form must reproduce the above copyright
52 1.1 tsutsui * notice, this list of conditions and the following disclaimer in the
53 1.1 tsutsui * documentation and/or other materials provided with the distribution.
54 1.1 tsutsui * 3. Neither the name of the University nor the names of its contributors
55 1.1 tsutsui * may be used to endorse or promote products derived from this software
56 1.1 tsutsui * without specific prior written permission.
57 1.1 tsutsui *
58 1.1 tsutsui * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 1.1 tsutsui * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 1.1 tsutsui * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 1.1 tsutsui * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 1.1 tsutsui * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 1.1 tsutsui * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 1.1 tsutsui * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 1.1 tsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 1.1 tsutsui * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 1.1 tsutsui * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 1.1 tsutsui * SUCH DAMAGE.
69 1.1 tsutsui *
70 1.1 tsutsui * @(#)sd.c 8.1 (Berkeley) 6/10/93
71 1.1 tsutsui */
72 1.1 tsutsui
73 1.1 tsutsui /*
74 1.1 tsutsui * sd.c -- SCSI DISK device driver
75 1.1 tsutsui * by A.Fujita, FEB-26-1992
76 1.1 tsutsui */
77 1.1 tsutsui
78 1.1 tsutsui
79 1.1 tsutsui /*
80 1.1 tsutsui * SCSI CCS (Command Command Set) disk driver.
81 1.1 tsutsui */
82 1.1 tsutsui #include <sys/param.h>
83 1.1 tsutsui #include <sys/disklabel.h>
84 1.1 tsutsui #include <luna68k/stand/boot/samachdep.h>
85 1.1 tsutsui #include <luna68k/stand/boot/scsireg.h>
86 1.1 tsutsui #include <luna68k/stand/boot/device.h>
87 1.1 tsutsui
88 1.1 tsutsui struct disklabel sdlabel[NSD];
89 1.1 tsutsui
90 1.1 tsutsui struct sd_softc {
91 1.1 tsutsui struct hp_device *sc_hd;
92 1.1 tsutsui struct devqueue sc_dq;
93 1.1 tsutsui int sc_format_pid; /* process using "format" mode */
94 1.1 tsutsui short sc_flags;
95 1.1 tsutsui short sc_type; /* drive type */
96 1.1 tsutsui short sc_punit; /* physical unit (scsi lun) */
97 1.1 tsutsui u_short sc_bshift; /* convert device blocks to DEV_BSIZE blks */
98 1.1 tsutsui u_int sc_blks; /* number of blocks on device */
99 1.1 tsutsui int sc_blksize; /* device block size in bytes */
100 1.1 tsutsui u_int sc_wpms; /* average xfer rate in 16 bit wds/sec. */
101 1.1 tsutsui };
102 1.1 tsutsui
103 1.1 tsutsui struct sd_devdata {
104 1.1 tsutsui int unit; /* drive number */
105 1.1 tsutsui int part; /* partition */
106 1.1 tsutsui };
107 1.1 tsutsui
108 1.1 tsutsui static int sdinit(void *);
109 1.1 tsutsui static int sdstart(void);
110 1.1 tsutsui static int sdgo(void);
111 1.1 tsutsui static int sdintr(void);
112 1.1 tsutsui static int sdident(struct sd_softc *, struct hp_device *);
113 1.1 tsutsui
114 1.1 tsutsui struct driver sddriver = {
115 1.1 tsutsui sdinit, "sd", sdstart, sdgo, sdintr,
116 1.1 tsutsui };
117 1.1 tsutsui
118 1.1 tsutsui struct sd_softc sd_softc[NSD];
119 1.1 tsutsui struct sd_devdata sd_devdata[NSD];
120 1.1 tsutsui
121 1.1 tsutsui /* sc_flags values */
122 1.1 tsutsui #define SDF_ALIVE 0x1
123 1.1 tsutsui
124 1.1 tsutsui #define sdunit(x) ((minor(x) >> 3) & 0x7)
125 1.1 tsutsui #define sdpart(x) (minor(x) & 0x7)
126 1.1 tsutsui #define sdpunit(x) ((x) & 7)
127 1.1 tsutsui
128 1.1 tsutsui static struct scsi_inquiry inqbuf;
129 1.1 tsutsui static struct scsi_fmt_cdb inq = {
130 1.1 tsutsui 6,
131 1.1 tsutsui { CMD_INQUIRY, 0, 0, 0, sizeof(inqbuf), 0 }
132 1.1 tsutsui };
133 1.1 tsutsui
134 1.1 tsutsui static u_long capbuf[2];
135 1.1 tsutsui struct scsi_fmt_cdb cap = {
136 1.1 tsutsui 10,
137 1.1 tsutsui { CMD_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
138 1.1 tsutsui };
139 1.1 tsutsui
140 1.1 tsutsui int
141 1.1 tsutsui sdident(struct sd_softc *sc, struct hp_device *hd)
142 1.1 tsutsui {
143 1.1 tsutsui char idstr[32];
144 1.1 tsutsui int unit;
145 1.1 tsutsui int ctlr, slave;
146 1.1 tsutsui int i;
147 1.1 tsutsui int tries = 10;
148 1.1 tsutsui
149 1.1 tsutsui ctlr = hd->hp_ctlr;
150 1.1 tsutsui slave = hd->hp_slave;
151 1.1 tsutsui unit = sc->sc_punit;
152 1.1 tsutsui
153 1.1 tsutsui /*
154 1.1 tsutsui * See if unit exists and is a disk then read block size & nblocks.
155 1.1 tsutsui */
156 1.1 tsutsui while ((i = scsi_test_unit_rdy(ctlr, slave, unit)) != 0) {
157 1.1 tsutsui if (i < 0 || --tries < 0)
158 1.1 tsutsui return (-1);
159 1.1 tsutsui if (i == STS_CHECKCOND) {
160 1.1 tsutsui u_char sensebuf[8];
161 1.1 tsutsui struct scsi_xsense *sp = (struct scsi_xsense *)sensebuf;
162 1.1 tsutsui
163 1.1 tsutsui scsi_request_sense(ctlr, slave, unit, sensebuf, 8);
164 1.1 tsutsui if (sp->class == 7 && sp->key == 6)
165 1.1 tsutsui /* drive doing an RTZ -- give it a while */
166 1.1 tsutsui DELAY(1000000);
167 1.1 tsutsui }
168 1.1 tsutsui DELAY(1000);
169 1.1 tsutsui }
170 1.1 tsutsui if (scsi_immed_command(ctlr, slave, unit, &inq, (u_char *)&inqbuf,
171 1.1 tsutsui sizeof(inqbuf)) ||
172 1.1 tsutsui scsi_immed_command(ctlr, slave, unit, &cap, (u_char *)&capbuf,
173 1.1 tsutsui sizeof(capbuf)))
174 1.1 tsutsui /* doesn't exist or not a CCS device */
175 1.1 tsutsui return (-1);
176 1.1 tsutsui
177 1.1 tsutsui switch (inqbuf.type) {
178 1.1 tsutsui case 0: /* disk */
179 1.1 tsutsui case 4: /* WORM */
180 1.1 tsutsui case 5: /* CD-ROM */
181 1.1 tsutsui case 7: /* Magneto-optical */
182 1.1 tsutsui break;
183 1.1 tsutsui default: /* not a disk */
184 1.1 tsutsui return (-1);
185 1.1 tsutsui }
186 1.1 tsutsui sc->sc_blks = capbuf[0];
187 1.1 tsutsui sc->sc_blksize = capbuf[1];
188 1.1 tsutsui
189 1.1 tsutsui memcpy(idstr, &inqbuf.vendor_id, 28);
190 1.1 tsutsui for (i = 27; i > 23; --i)
191 1.1 tsutsui if (idstr[i] != ' ')
192 1.1 tsutsui break;
193 1.1 tsutsui idstr[i+1] = 0;
194 1.1 tsutsui for (i = 23; i > 7; --i)
195 1.1 tsutsui if (idstr[i] != ' ')
196 1.1 tsutsui break;
197 1.1 tsutsui idstr[i+1] = 0;
198 1.1 tsutsui for (i = 7; i >= 0; --i)
199 1.1 tsutsui if (idstr[i] != ' ')
200 1.1 tsutsui break;
201 1.1 tsutsui idstr[i+1] = 0;
202 1.1 tsutsui printf("sd%d: %s %s rev %s", hd->hp_unit, idstr, &idstr[8],
203 1.1 tsutsui &idstr[24]);
204 1.1 tsutsui
205 1.1 tsutsui printf(", %d %d byte blocks\n", sc->sc_blks, sc->sc_blksize);
206 1.1 tsutsui if (sc->sc_blksize != DEV_BSIZE) {
207 1.1 tsutsui if (sc->sc_blksize < DEV_BSIZE) {
208 1.1 tsutsui printf("sd%d: need %d byte blocks - drive ignored\n",
209 1.1 tsutsui unit, DEV_BSIZE);
210 1.1 tsutsui return (-1);
211 1.1 tsutsui }
212 1.1 tsutsui for (i = sc->sc_blksize; i > DEV_BSIZE; i >>= 1)
213 1.1 tsutsui ++sc->sc_bshift;
214 1.1 tsutsui sc->sc_blks <<= sc->sc_bshift;
215 1.1 tsutsui }
216 1.1 tsutsui sc->sc_wpms = 32 * (60 * DEV_BSIZE / 2); /* XXX */
217 1.1 tsutsui return(inqbuf.type);
218 1.1 tsutsui }
219 1.1 tsutsui
220 1.1 tsutsui int
221 1.1 tsutsui sdinit(void *arg)
222 1.1 tsutsui {
223 1.1 tsutsui struct hp_device *hd = arg;
224 1.1 tsutsui struct sd_softc *sc = &sd_softc[hd->hp_unit];
225 1.1 tsutsui struct disklabel *lp;
226 1.1 tsutsui char *msg;
227 1.1 tsutsui
228 1.1 tsutsui #ifdef DEBUG
229 1.1 tsutsui printf("sdinit: hd->hp_unit = %d\n", hd->hp_unit);
230 1.1 tsutsui printf("sdinit: hd->hp_ctlr = %d, hd->hp_slave = %d\n",
231 1.1 tsutsui hd->hp_ctlr, hd->hp_slave);
232 1.1 tsutsui #endif
233 1.1 tsutsui sc->sc_hd = hd;
234 1.1 tsutsui sc->sc_punit = sdpunit(hd->hp_flags);
235 1.1 tsutsui sc->sc_type = sdident(sc, hd);
236 1.1 tsutsui if (sc->sc_type < 0)
237 1.1 tsutsui return(0);
238 1.1 tsutsui
239 1.1 tsutsui /*
240 1.1 tsutsui * Use the default sizes until we've read the label,
241 1.1 tsutsui * or longer if there isn't one there.
242 1.1 tsutsui */
243 1.1 tsutsui lp = &sdlabel[hd->hp_unit];
244 1.1 tsutsui
245 1.1 tsutsui if (lp->d_secpercyl == 0) {
246 1.1 tsutsui lp->d_secsize = DEV_BSIZE;
247 1.1 tsutsui lp->d_nsectors = 32;
248 1.1 tsutsui lp->d_ntracks = 20;
249 1.1 tsutsui lp->d_secpercyl = 32*20;
250 1.1 tsutsui lp->d_npartitions = 1;
251 1.1 tsutsui lp->d_partitions[0].p_offset = 0;
252 1.1 tsutsui lp->d_partitions[0].p_size = LABELSECTOR + 1;
253 1.1 tsutsui }
254 1.1 tsutsui
255 1.1 tsutsui /*
256 1.1 tsutsui * read disklabel
257 1.1 tsutsui */
258 1.1 tsutsui msg = readdisklabel(hd->hp_slave, sdstrategy, lp);
259 1.1 tsutsui if (msg != NULL)
260 1.1 tsutsui printf("sd%d: %s\n", hd->hp_unit, msg);
261 1.1 tsutsui
262 1.1 tsutsui sc->sc_flags = SDF_ALIVE;
263 1.1 tsutsui return(1);
264 1.1 tsutsui }
265 1.1 tsutsui
266 1.1 tsutsui int
267 1.1 tsutsui sdopen(struct open_file *f, ...)
268 1.1 tsutsui {
269 1.1 tsutsui va_list ap;
270 1.1 tsutsui struct sd_devdata *sd;
271 1.1 tsutsui int unit, part;
272 1.1 tsutsui
273 1.1 tsutsui va_start(ap, f);
274 1.1 tsutsui unit = va_arg(ap, int);
275 1.1 tsutsui part = va_arg(ap, int);
276 1.1 tsutsui va_end(ap);
277 1.1 tsutsui
278 1.1 tsutsui if (unit < 0 || unit >= NSD)
279 1.1 tsutsui return(-1);
280 1.1 tsutsui if (part < 0 || part >= 8)
281 1.1 tsutsui return(-1);
282 1.1 tsutsui
283 1.1 tsutsui sd = &sd_devdata[unit];
284 1.1 tsutsui sd->unit = unit;
285 1.1 tsutsui sd->part = part;
286 1.1 tsutsui f->f_devdata = (void *)sd;
287 1.1 tsutsui
288 1.1 tsutsui return 0;
289 1.1 tsutsui }
290 1.1 tsutsui
291 1.1 tsutsui int
292 1.1 tsutsui sdclose(struct open_file *f)
293 1.1 tsutsui {
294 1.1 tsutsui struct sd_devdata *sd = f->f_devdata;
295 1.1 tsutsui
296 1.1 tsutsui sd->unit = -1;
297 1.1 tsutsui sd->part = -1;
298 1.1 tsutsui f->f_devdata = NULL;
299 1.1 tsutsui
300 1.1 tsutsui return 0;
301 1.1 tsutsui }
302 1.1 tsutsui
303 1.1 tsutsui static struct scsi_fmt_cdb cdb_read = {
304 1.1 tsutsui 10,
305 1.1 tsutsui { CMD_READ_EXT, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
306 1.1 tsutsui };
307 1.1 tsutsui
308 1.1 tsutsui static struct scsi_fmt_cdb cdb_write = {
309 1.1 tsutsui 6,
310 1.1 tsutsui { CMD_WRITE_EXT, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
311 1.1 tsutsui };
312 1.1 tsutsui
313 1.1 tsutsui int
314 1.1 tsutsui sdstrategy(void *devdata, int func, daddr_t dblk, size_t size, void *v_buf,
315 1.1 tsutsui size_t *rsize)
316 1.1 tsutsui {
317 1.1 tsutsui struct sd_devdata *sd = devdata;
318 1.1 tsutsui struct disklabel *lp;
319 1.1 tsutsui uint8_t *buf = v_buf;
320 1.1 tsutsui int unit = sd->unit;
321 1.1 tsutsui int part = sd->part;
322 1.1 tsutsui struct sd_softc *sc = &sd_softc[unit];
323 1.1 tsutsui struct scsi_fmt_cdb *cdb;
324 1.1 tsutsui daddr_t blk;
325 1.1 tsutsui u_int nblk = size >> sc->sc_bshift;
326 1.1 tsutsui int stat, ctlr, slave;
327 1.1 tsutsui #ifdef DEBUG
328 1.1 tsutsui int i;
329 1.1 tsutsui #endif
330 1.1 tsutsui
331 1.1 tsutsui if (unit < 0 || unit >= NSD)
332 1.1 tsutsui return(-1);
333 1.1 tsutsui
334 1.1 tsutsui ctlr = sc->sc_hd->hp_ctlr;
335 1.1 tsutsui slave = sc->sc_hd->hp_slave;
336 1.1 tsutsui
337 1.1 tsutsui lp = &sdlabel[unit];
338 1.1 tsutsui blk = dblk + (lp->d_partitions[part].p_offset >> sc->sc_bshift);
339 1.1 tsutsui
340 1.1 tsutsui if (func == F_READ)
341 1.1 tsutsui cdb = &cdb_read;
342 1.1 tsutsui else
343 1.1 tsutsui cdb = &cdb_write;
344 1.1 tsutsui
345 1.1 tsutsui cdb->cdb[2] = (blk & 0xff000000) >> 24;
346 1.1 tsutsui cdb->cdb[3] = (blk & 0x00ff0000) >> 16;
347 1.1 tsutsui cdb->cdb[4] = (blk & 0x0000ff00) >> 8;
348 1.1 tsutsui cdb->cdb[5] = (blk & 0x000000ff);
349 1.1 tsutsui
350 1.1 tsutsui cdb->cdb[7] = ((nblk >> DEV_BSHIFT) & 0xff00) >> 8;
351 1.1 tsutsui cdb->cdb[8] = ((nblk >> DEV_BSHIFT) & 0x00ff);
352 1.1 tsutsui
353 1.1 tsutsui #ifdef DEBUG
354 1.1 tsutsui printf("sdstrategy: unit = %d\n", unit);
355 1.1 tsutsui printf("sdstrategy: blk = %lu (0x%lx), nblk = %u (0x%x)\n", (u_long)blk, (long)blk, nblk, nblk);
356 1.1 tsutsui for (i = 0; i < 10; i++)
357 1.1 tsutsui printf("sdstrategy: cdb[%d] = 0x%x\n", i, cdb->cdb[i]);
358 1.1 tsutsui printf("sdstrategy: ctlr = %d, slave = %d\n", ctlr, slave);
359 1.1 tsutsui #endif
360 1.1 tsutsui stat = scsi_immed_command(ctlr, slave, sc->sc_punit, cdb, buf, size);
361 1.1 tsutsui if (rsize)
362 1.1 tsutsui *rsize = size;
363 1.1 tsutsui
364 1.1 tsutsui return 0;
365 1.1 tsutsui }
366 1.1 tsutsui
367 1.1 tsutsui int
368 1.1 tsutsui sdstart(void)
369 1.1 tsutsui {
370 1.1 tsutsui
371 1.1 tsutsui return 0;
372 1.1 tsutsui }
373 1.1 tsutsui
374 1.1 tsutsui int
375 1.1 tsutsui sdgo(void)
376 1.1 tsutsui {
377 1.1 tsutsui
378 1.1 tsutsui return 0;
379 1.1 tsutsui }
380 1.1 tsutsui
381 1.1 tsutsui int
382 1.1 tsutsui sdintr(void)
383 1.1 tsutsui {
384 1.1 tsutsui
385 1.1 tsutsui return 0;
386 1.1 tsutsui }
387 1.1 tsutsui
388 1.1 tsutsui #if 0
389 1.1 tsutsui int
390 1.1 tsutsui sdread(dev_t dev, u_int blk, u_int nblk, u_char *buff, u_int len)
391 1.1 tsutsui {
392 1.1 tsutsui int unit = sdunit(dev);
393 1.1 tsutsui int part = sdpart(dev);
394 1.1 tsutsui struct sd_softc *sc = &sd_softc[unit];
395 1.1 tsutsui struct scsi_fmt_cdb *cdb;
396 1.1 tsutsui int stat, ctlr, slave;
397 1.1 tsutsui
398 1.1 tsutsui ctlr = sc->sc_hd->hp_ctlr;
399 1.1 tsutsui slave = sc->sc_hd->hp_slave;
400 1.1 tsutsui
401 1.1 tsutsui cdb = &cdb_read;
402 1.1 tsutsui
403 1.1 tsutsui cdb->cdb[2] = (blk & 0xff000000) >> 24;
404 1.1 tsutsui cdb->cdb[3] = (blk & 0x00ff0000) >> 16;
405 1.1 tsutsui cdb->cdb[4] = (blk & 0x0000ff00) >> 8;
406 1.1 tsutsui cdb->cdb[5] = (blk & 0x000000ff);
407 1.1 tsutsui
408 1.1 tsutsui cdb->cdb[7] = (nblk & 0xff00) >> 8;
409 1.1 tsutsui cdb->cdb[8] = (nblk & 0x00ff);
410 1.1 tsutsui
411 1.1 tsutsui stat = scsi_immed_command(ctlr, slave, sc->sc_punit, cdb, buff, len);
412 1.1 tsutsui
413 1.1 tsutsui if (stat == 0)
414 1.1 tsutsui return(1);
415 1.1 tsutsui else
416 1.1 tsutsui return(0);
417 1.1 tsutsui }
418 1.1 tsutsui
419 1.1 tsutsui int
420 1.1 tsutsui sdioctl(dev_t dev, u_long data[])
421 1.1 tsutsui {
422 1.1 tsutsui int unit = sdunit(dev);
423 1.1 tsutsui int part = sdpart(dev);
424 1.1 tsutsui struct disklabel *lp;
425 1.1 tsutsui
426 1.1 tsutsui if (unit < 0 || unit >= NSD)
427 1.1 tsutsui return(0);
428 1.1 tsutsui
429 1.1 tsutsui if (part < 0 || part >= MAXPARTITIONS)
430 1.1 tsutsui return(0);
431 1.1 tsutsui
432 1.1 tsutsui lp = &sdlabel[unit];
433 1.1 tsutsui data[0] = lp->d_partitions[part].p_offset;
434 1.1 tsutsui data[1] = lp->d_partitions[part].p_size;
435 1.1 tsutsui
436 1.1 tsutsui return(1);
437 1.1 tsutsui }
438 1.1 tsutsui #endif
439