mcd.c (104440) | mcd.c (104441) |
---|---|
1#include "opt_geom.h" 2#ifndef GEOM 3/* 4 * Copyright 1993 by Holger Veit (data part) 5 * Copyright 1993 by Brian Moore (audio part) 6 * Changes Copyright 1993 by Gary Clark II 7 * Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia 8 * --- 28 unchanged lines hidden (view full) --- 37 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 38 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 39 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 40 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 41 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 42 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 43 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 * | 1#include "opt_geom.h" 2#ifndef GEOM 3/* 4 * Copyright 1993 by Holger Veit (data part) 5 * Copyright 1993 by Brian Moore (audio part) 6 * Changes Copyright 1993 by Gary Clark II 7 * Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia 8 * --- 28 unchanged lines hidden (view full) --- 37 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 38 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 39 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 40 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 41 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 42 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 43 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 * |
45 * $FreeBSD: head/sys/dev/mcd/mcd.c 104440 2002-10-04 01:58:55Z mdodd $ | 45 * $FreeBSD: head/sys/dev/mcd/mcd.c 104441 2002-10-04 02:21:26Z mdodd $ |
46 */ 47static const char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; 48 49#include "mcd.h" 50#include <sys/param.h> 51#include <sys/systm.h> 52#include <sys/kernel.h> 53#include <sys/conf.h> --- 186 unchanged lines hidden (view full) --- 240/* several delays */ 241#define RDELAY_WAITSTAT 300 242#define RDELAY_WAITMODE 300 243#define RDELAY_WAITREAD 800 244 245#define MIN_DELAY 15 246#define DELAY_GETREPLY 5000000 247 | 46 */ 47static const char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; 48 49#include "mcd.h" 50#include <sys/param.h> 51#include <sys/systm.h> 52#include <sys/kernel.h> 53#include <sys/conf.h> --- 186 unchanged lines hidden (view full) --- 240/* several delays */ 241#define RDELAY_WAITSTAT 300 242#define RDELAY_WAITMODE 300 243#define RDELAY_WAITREAD 800 244 245#define MIN_DELAY 15 246#define DELAY_GETREPLY 5000000 247 |
248int mcd_attach(struct isa_device *dev) | 248static int 249mcd_attach(struct isa_device *dev) |
249{ 250 int unit = dev->id_unit; 251 struct mcd_data *cd = mcd_data + unit; 252 253 dev->id_ointr = mcdintr; 254 cd->iobase = dev->id_iobase; 255 cd->flags |= MCDINIT; 256 mcd_soft_reset(unit); --- 6 unchanged lines hidden (view full) --- 263 /* name filled in probe */ 264 make_dev(&mcd_cdevsw, dkmakeminor(unit, 0, 0), 265 UID_ROOT, GID_OPERATOR, 0640, "mcd%da", unit); 266 make_dev(&mcd_cdevsw, dkmakeminor(unit, 0, RAW_PART), 267 UID_ROOT, GID_OPERATOR, 0640, "mcd%dc", unit); 268 return 1; 269} 270 | 250{ 251 int unit = dev->id_unit; 252 struct mcd_data *cd = mcd_data + unit; 253 254 dev->id_ointr = mcdintr; 255 cd->iobase = dev->id_iobase; 256 cd->flags |= MCDINIT; 257 mcd_soft_reset(unit); --- 6 unchanged lines hidden (view full) --- 264 /* name filled in probe */ 265 make_dev(&mcd_cdevsw, dkmakeminor(unit, 0, 0), 266 UID_ROOT, GID_OPERATOR, 0640, "mcd%da", unit); 267 make_dev(&mcd_cdevsw, dkmakeminor(unit, 0, RAW_PART), 268 UID_ROOT, GID_OPERATOR, 0640, "mcd%dc", unit); 269 return 1; 270} 271 |
271int mcdopen(dev_t dev, int flags, int fmt, struct thread *td) | 272static int 273mcdopen(dev_t dev, int flags, int fmt, struct thread *td) |
272{ 273 int unit,part,phys,r,retry; 274 struct mcd_data *cd; 275 276 unit = mcd_unit(dev); 277 if (unit >= NMCD) 278 return ENXIO; 279 --- 75 unchanged lines hidden (view full) --- 355 if (!(cd->flags & MCDVALID)) 356 return ENXIO; 357 return 0; 358 } 359 360 return ENXIO; 361} 362 | 274{ 275 int unit,part,phys,r,retry; 276 struct mcd_data *cd; 277 278 unit = mcd_unit(dev); 279 if (unit >= NMCD) 280 return ENXIO; 281 --- 75 unchanged lines hidden (view full) --- 357 if (!(cd->flags & MCDVALID)) 358 return ENXIO; 359 return 0; 360 } 361 362 return ENXIO; 363} 364 |
363int mcdclose(dev_t dev, int flags, int fmt, struct thread *td) | 365static int 366mcdclose(dev_t dev, int flags, int fmt, struct thread *td) |
364{ 365 int unit,part; 366 struct mcd_data *cd; 367 368 unit = mcd_unit(dev); 369 if (unit >= NMCD) 370 return ENXIO; 371 --- 7 unchanged lines hidden (view full) --- 379 380 (void) mcd_lock_door(unit, MCD_LK_UNLOCK); 381 cd->openflags &= ~(1<<part); 382 cd->partflags[part] &= ~MCDREADRAW; 383 384 return 0; 385} 386 | 367{ 368 int unit,part; 369 struct mcd_data *cd; 370 371 unit = mcd_unit(dev); 372 if (unit >= NMCD) 373 return ENXIO; 374 --- 7 unchanged lines hidden (view full) --- 382 383 (void) mcd_lock_door(unit, MCD_LK_UNLOCK); 384 cd->openflags &= ~(1<<part); 385 cd->partflags[part] &= ~MCDREADRAW; 386 387 return 0; 388} 389 |
387void | 390static void |
388mcdstrategy(struct bio *bp) 389{ 390 struct mcd_data *cd; 391 int s; 392 393 int unit = mcd_unit(bp->bio_dev); 394 395 cd = mcd_data + unit; --- 54 unchanged lines hidden (view full) --- 450bad: 451 bp->bio_flags |= BIO_ERROR; 452done: 453 bp->bio_resid = bp->bio_bcount; 454 biodone(bp); 455 return; 456} 457 | 391mcdstrategy(struct bio *bp) 392{ 393 struct mcd_data *cd; 394 int s; 395 396 int unit = mcd_unit(bp->bio_dev); 397 398 cd = mcd_data + unit; --- 54 unchanged lines hidden (view full) --- 453bad: 454 bp->bio_flags |= BIO_ERROR; 455done: 456 bp->bio_resid = bp->bio_bcount; 457 biodone(bp); 458 return; 459} 460 |
458static void mcd_start(int unit) | 461static void 462mcd_start(int unit) |
459{ 460 struct mcd_data *cd = mcd_data + unit; 461 struct partition *p; 462 struct bio *bp; 463 int s = splbio(); 464 465 if (cd->flags & MCDMBXBSY) { 466 splx(s); --- 30 unchanged lines hidden (view full) --- 497 cd->mbx.p_offset = p->p_offset; 498 499 /* calling the read routine */ 500 mcd_doread(MCD_S_BEGIN,&(cd->mbx)); 501 /* triggers mcd_start, when successful finished */ 502 return; 503} 504 | 463{ 464 struct mcd_data *cd = mcd_data + unit; 465 struct partition *p; 466 struct bio *bp; 467 int s = splbio(); 468 469 if (cd->flags & MCDMBXBSY) { 470 splx(s); --- 30 unchanged lines hidden (view full) --- 501 cd->mbx.p_offset = p->p_offset; 502 503 /* calling the read routine */ 504 mcd_doread(MCD_S_BEGIN,&(cd->mbx)); 505 /* triggers mcd_start, when successful finished */ 506 return; 507} 508 |
505int mcdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) | 509static int 510mcdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) |
506{ 507 struct mcd_data *cd; 508 int unit,part,retry,r; 509 510 unit = mcd_unit(dev); 511 part = mcd_part(dev); 512 cd = mcd_data + unit; 513 --- 103 unchanged lines hidden (view full) --- 617 return ENOTTY; 618 } 619 /*NOTREACHED*/ 620} 621 622/* this could have been taken from scsi/cd.c, but it is not clear 623 * whether the scsi cd driver is linked in 624 */ | 511{ 512 struct mcd_data *cd; 513 int unit,part,retry,r; 514 515 unit = mcd_unit(dev); 516 part = mcd_part(dev); 517 cd = mcd_data + unit; 518 --- 103 unchanged lines hidden (view full) --- 622 return ENOTTY; 623 } 624 /*NOTREACHED*/ 625} 626 627/* this could have been taken from scsi/cd.c, but it is not clear 628 * whether the scsi cd driver is linked in 629 */ |
625static int mcd_getdisklabel(int unit) | 630static int 631mcd_getdisklabel(int unit) |
626{ 627 struct mcd_data *cd = mcd_data + unit; 628 629 if (cd->flags & MCDLABEL) 630 return -1; 631 632 bzero(&cd->dlabel,sizeof(struct disklabel)); 633 /* filled with spaces first */ --- 19 unchanged lines hidden (view full) --- 653 cd->dlabel.d_magic = DISKMAGIC; 654 cd->dlabel.d_magic2 = DISKMAGIC; 655 cd->dlabel.d_checksum = dkcksum(&cd->dlabel); 656 657 cd->flags |= MCDLABEL; 658 return 0; 659} 660 | 632{ 633 struct mcd_data *cd = mcd_data + unit; 634 635 if (cd->flags & MCDLABEL) 636 return -1; 637 638 bzero(&cd->dlabel,sizeof(struct disklabel)); 639 /* filled with spaces first */ --- 19 unchanged lines hidden (view full) --- 659 cd->dlabel.d_magic = DISKMAGIC; 660 cd->dlabel.d_magic2 = DISKMAGIC; 661 cd->dlabel.d_checksum = dkcksum(&cd->dlabel); 662 663 cd->flags |= MCDLABEL; 664 return 0; 665} 666 |
661int mcdsize(dev_t dev) | 667static int 668mcdsize(dev_t dev) |
662{ 663 int size; 664 int unit = mcd_unit(dev); 665 struct mcd_data *cd = mcd_data + unit; 666 667 if (mcd_volinfo(unit) == 0) { 668 cd->blksize = MCDBLK; 669 size = msf2hsg(cd->volinfo.vol_msf, 0); --- 40 unchanged lines hidden (view full) --- 710 } 711 if (bootverbose) 712 printf("mcd%d: timeout %s\n", unit, whine); 713 return 0; 714} 715 716/* check to see if a Mitsumi CD-ROM is attached to the ISA bus */ 717 | 669{ 670 int size; 671 int unit = mcd_unit(dev); 672 struct mcd_data *cd = mcd_data + unit; 673 674 if (mcd_volinfo(unit) == 0) { 675 cd->blksize = MCDBLK; 676 size = msf2hsg(cd->volinfo.vol_msf, 0); --- 40 unchanged lines hidden (view full) --- 717 } 718 if (bootverbose) 719 printf("mcd%d: timeout %s\n", unit, whine); 720 return 0; 721} 722 723/* check to see if a Mitsumi CD-ROM is attached to the ISA bus */ 724 |
718int | 725static int |
719mcd_probe(struct isa_device *dev) 720{ 721 int port = dev->id_iobase; 722 int unit = dev->id_unit; 723 int i, j; 724 unsigned char stbytes[3]; 725 726 mcd_data[unit].flags = MCDPROBING; --- 1098 unchanged lines hidden --- | 726mcd_probe(struct isa_device *dev) 727{ 728 int port = dev->id_iobase; 729 int unit = dev->id_unit; 730 int i, j; 731 unsigned char stbytes[3]; 732 733 mcd_data[unit].flags = MCDPROBING; --- 1098 unchanged lines hidden --- |