mcd.c (14286) | mcd.c (14654) |
---|---|
1/* 2 * Copyright 1993 by Holger Veit (data part) 3 * Copyright 1993 by Brian Moore (audio part) 4 * Changes Copyright 1993 by Gary Clark II 5 * Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia 6 * 7 * Rewrote probe routine to work on newer Mitsumi drives. 8 * Additional changes (C) 1994 by Jordan K. Hubbard --- 26 unchanged lines hidden (view full) --- 35 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 36 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 37 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 38 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 * | 1/* 2 * Copyright 1993 by Holger Veit (data part) 3 * Copyright 1993 by Brian Moore (audio part) 4 * Changes Copyright 1993 by Gary Clark II 5 * Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia 6 * 7 * Rewrote probe routine to work on newer Mitsumi drives. 8 * Additional changes (C) 1994 by Jordan K. Hubbard --- 26 unchanged lines hidden (view full) --- 35 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 36 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 37 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 38 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 * |
43 * $Id: mcd.c,v 1.72 1996/02/27 18:53:50 ache Exp $ | 43 * $Id: mcd.c,v 1.73 1996/02/27 19:08:39 ache Exp $ |
44 */ 45static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; 46 47#include "mcd.h" 48#if NMCD > 0 49#include <sys/types.h> 50#include <sys/param.h> 51#include <sys/systm.h> --- 34 unchanged lines hidden (view full) --- 86} 87 88#define mcd_part(dev) ((minor(dev)) & 7) 89#define mcd_unit(dev) (((minor(dev)) & 0x38) >> 3) 90#define mcd_phys(dev) (((minor(dev)) & 0x40) >> 6) 91#define RAW_PART 2 92 93/* flags */ | 44 */ 45static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; 46 47#include "mcd.h" 48#if NMCD > 0 49#include <sys/types.h> 50#include <sys/param.h> 51#include <sys/systm.h> --- 34 unchanged lines hidden (view full) --- 86} 87 88#define mcd_part(dev) ((minor(dev)) & 7) 89#define mcd_unit(dev) (((minor(dev)) & 0x38) >> 3) 90#define mcd_phys(dev) (((minor(dev)) & 0x40) >> 6) 91#define RAW_PART 2 92 93/* flags */ |
94#define MCDOPEN 0x0001 /* device opened */ 95#define MCDVALID 0x0002 /* parameters loaded */ 96#define MCDINIT 0x0004 /* device is init'd */ 97#define MCDNEWMODEL 0x0008 /* device is new model */ 98#define MCDLABEL 0x0010 /* label is read */ 99#define MCDPROBING 0x0020 /* probing */ 100#define MCDREADRAW 0x0040 /* read raw mode (2352 bytes) */ 101#define MCDVOLINFO 0x0080 /* already read volinfo */ 102#define MCDTOC 0x0100 /* already read toc */ 103#define MCDMBXBSY 0x0200 /* local mbx is busy */ | 94#define MCDVALID 0x0001 /* parameters loaded */ 95#define MCDINIT 0x0002 /* device is init'd */ 96#define MCDNEWMODEL 0x0004 /* device is new model */ 97#define MCDLABEL 0x0008 /* label is read */ 98#define MCDPROBING 0x0010 /* probing */ 99#define MCDREADRAW 0x0020 /* read raw mode (2352 bytes) */ 100#define MCDVOLINFO 0x0040 /* already read volinfo */ 101#define MCDTOC 0x0080 /* already read toc */ 102#define MCDMBXBSY 0x0100 /* local mbx is busy */ |
104 105/* status */ 106#define MCDAUDIOBSY MCD_ST_AUDIOBSY /* playing audio */ 107#define MCDDSKCHNG MCD_ST_DSKCHNG /* sensed change of disk */ 108#define MCDDSKIN MCD_ST_DSKIN /* sensed disk in drive */ 109#define MCDDOOROPEN MCD_ST_DOOROPEN /* sensed door open */ 110 111/* These are apparently the different states a mitsumi can get up to */ --- 238 unchanged lines hidden (view full) --- 350 } 351 352 if (( (cd->status & (MCDDOOROPEN|MCDDSKCHNG)) 353 || !(cd->status & MCDDSKIN) 354 ) 355 && major(dev) == CDEV_MAJOR && part == RAW_PART 356 ) { 357 cd->openflags |= (1<<part); | 103 104/* status */ 105#define MCDAUDIOBSY MCD_ST_AUDIOBSY /* playing audio */ 106#define MCDDSKCHNG MCD_ST_DSKCHNG /* sensed change of disk */ 107#define MCDDSKIN MCD_ST_DSKIN /* sensed disk in drive */ 108#define MCDDOOROPEN MCD_ST_DOOROPEN /* sensed door open */ 109 110/* These are apparently the different states a mitsumi can get up to */ --- 238 unchanged lines hidden (view full) --- 349 } 350 351 if (( (cd->status & (MCDDOOROPEN|MCDDSKCHNG)) 352 || !(cd->status & MCDDSKIN) 353 ) 354 && major(dev) == CDEV_MAJOR && part == RAW_PART 355 ) { 356 cd->openflags |= (1<<part); |
357 if (phys) 358 cd->partflags[part] |= MCDREADRAW; |
|
358 kdc_mcd[unit].kdc_state = DC_BUSY; 359 return 0; 360 } 361 if (cd->status & MCDDOOROPEN) { 362 printf("mcd%d: door is open\n", unit); 363 return ENXIO; 364 } 365 if (!(cd->status & MCDDSKIN)) { 366 printf("mcd%d: no CD inside\n", unit); 367 return ENXIO; 368 } 369 if (cd->status & MCDDSKCHNG) { 370 printf("mcd%d: CD not sensed\n", unit); 371 return ENXIO; 372 } 373 374 if (mcdsize(dev) < 0) { 375 if (major(dev) == CDEV_MAJOR && part == RAW_PART) { 376 cd->openflags |= (1<<part); | 359 kdc_mcd[unit].kdc_state = DC_BUSY; 360 return 0; 361 } 362 if (cd->status & MCDDOOROPEN) { 363 printf("mcd%d: door is open\n", unit); 364 return ENXIO; 365 } 366 if (!(cd->status & MCDDSKIN)) { 367 printf("mcd%d: no CD inside\n", unit); 368 return ENXIO; 369 } 370 if (cd->status & MCDDSKCHNG) { 371 printf("mcd%d: CD not sensed\n", unit); 372 return ENXIO; 373 } 374 375 if (mcdsize(dev) < 0) { 376 if (major(dev) == CDEV_MAJOR && part == RAW_PART) { 377 cd->openflags |= (1<<part); |
378 if (phys) 379 cd->partflags[part] |= MCDREADRAW; |
|
377 kdc_mcd[unit].kdc_state = DC_BUSY; 378 return 0; 379 } 380 printf("mcd%d: failed to get disk size\n",unit); 381 return ENXIO; 382 } else 383 cd->flags |= MCDVALID; 384 385 /* XXX get a default disklabel */ 386 mcd_getdisklabel(unit); 387 388MCD_TRACE("open: partition=%d, disksize = %ld, blksize=%d\n", 389 part, cd->disksize, cd->blksize); 390 391 if (part == RAW_PART || 392 (part < cd->dlabel.d_npartitions && 393 cd->dlabel.d_partitions[part].p_fstype != FS_UNUSED)) { | 380 kdc_mcd[unit].kdc_state = DC_BUSY; 381 return 0; 382 } 383 printf("mcd%d: failed to get disk size\n",unit); 384 return ENXIO; 385 } else 386 cd->flags |= MCDVALID; 387 388 /* XXX get a default disklabel */ 389 mcd_getdisklabel(unit); 390 391MCD_TRACE("open: partition=%d, disksize = %ld, blksize=%d\n", 392 part, cd->disksize, cd->blksize); 393 394 if (part == RAW_PART || 395 (part < cd->dlabel.d_npartitions && 396 cd->dlabel.d_partitions[part].p_fstype != FS_UNUSED)) { |
394 cd->partflags[part] |= MCDOPEN; | |
395 cd->openflags |= (1<<part); | 397 cd->openflags |= (1<<part); |
396 if (part == RAW_PART && phys != 0) | 398 if (part == RAW_PART && phys) |
397 cd->partflags[part] |= MCDREADRAW; 398 kdc_mcd[unit].kdc_state = DC_BUSY; 399 (void) mcd_lock_door(unit, MCD_LK_LOCK); 400 if (!(cd->flags & MCDVALID)) 401 return ENXIO; 402 return 0; 403 } 404 --- 7 unchanged lines hidden (view full) --- 412 413 unit = mcd_unit(dev); 414 if (unit >= NMCD) 415 return ENXIO; 416 417 cd = mcd_data + unit; 418 part = mcd_part(dev); 419 | 399 cd->partflags[part] |= MCDREADRAW; 400 kdc_mcd[unit].kdc_state = DC_BUSY; 401 (void) mcd_lock_door(unit, MCD_LK_LOCK); 402 if (!(cd->flags & MCDVALID)) 403 return ENXIO; 404 return 0; 405 } 406 --- 7 unchanged lines hidden (view full) --- 414 415 unit = mcd_unit(dev); 416 if (unit >= NMCD) 417 return ENXIO; 418 419 cd = mcd_data + unit; 420 part = mcd_part(dev); 421 |
420 if (!(cd->flags & MCDINIT)) | 422 if (!(cd->flags & MCDINIT) || !(cd->openflags & (1<<part))) |
421 return ENXIO; 422 | 423 return ENXIO; 424 |
423 kdc_mcd[unit].kdc_state = DC_IDLE; 424 (void) mcd_lock_door(unit, MCD_LK_UNLOCK); | 425 MCD_TRACE("close: partition=%d\n", part); |
425 | 426 |
426 if (!(cd->flags & MCDVALID)) 427 return 0; 428 429 /* close channel */ 430 cd->partflags[part] &= ~(MCDOPEN|MCDREADRAW); | 427 (void) mcd_lock_door(unit, MCD_LK_UNLOCK); |
431 cd->openflags &= ~(1<<part); | 428 cd->openflags &= ~(1<<part); |
432 MCD_TRACE("close: partition=%d\n", part); | 429 cd->partflags[part] &= ~MCDREADRAW; 430 kdc_mcd[unit].kdc_state = DC_IDLE; |
433 434 return 0; 435} 436 437void 438mcdstrategy(struct buf *bp) 439{ 440 struct mcd_data *cd; --- 170 unchanged lines hidden (view full) --- 611 } 612 if ( (cd->status & (MCDDOOROPEN|MCDDSKCHNG)) 613 || !(cd->status & MCDDSKIN) 614 || mcdsize(dev) < 0 615 ) 616 return ENXIO; 617 cd->flags |= MCDVALID; 618 mcd_getdisklabel(unit); | 431 432 return 0; 433} 434 435void 436mcdstrategy(struct buf *bp) 437{ 438 struct mcd_data *cd; --- 170 unchanged lines hidden (view full) --- 609 } 610 if ( (cd->status & (MCDDOOROPEN|MCDDSKCHNG)) 611 || !(cd->status & MCDDSKIN) 612 || mcdsize(dev) < 0 613 ) 614 return ENXIO; 615 cd->flags |= MCDVALID; 616 mcd_getdisklabel(unit); |
619 cd->partflags[part] |= MCDOPEN; | |
620 if (mcd_phys(dev)) 621 cd->partflags[part] |= MCDREADRAW; 622 (void) mcd_lock_door(unit, MCD_LK_LOCK); 623 if (!(cd->flags & MCDVALID)) 624 return ENXIO; 625 } 626 627 switch (cmd) { --- 1217 unchanged lines hidden --- | 617 if (mcd_phys(dev)) 618 cd->partflags[part] |= MCDREADRAW; 619 (void) mcd_lock_door(unit, MCD_LK_LOCK); 620 if (!(cd->flags & MCDVALID)) 621 return ENXIO; 622 } 623 624 switch (cmd) { --- 1217 unchanged lines hidden --- |