simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)){	unsigned int target_id = sc->device->id;	char fname[MAX_ROOT_LEN+16];	size_t disk_size;	char *buf;#if DEBUG_SIMSCSI	register long sp asm ("sp");	if (DBG)		printk("simscsi_queuecommand: target=%d,cmnd=%u,sc=%lu,sp=%lx,done=%p\n",		       target_id, sc->cmnd[0], sc->serial_number, sp, done);#endif	sc->result = DID_BAD_TARGET << 16;	sc->scsi_done = done;	if (target_id <= 15 && sc->device->lun == 0) {		switch (sc->cmnd[0]) {		      case INQUIRY:			if (sc->request_bufflen < 35) {				break;			}			sprintf (fname, "%s%c", simscsi_root, 'a' + target_id);			desc[target_id] = ia64_ssc(__pa(fname), SSC_READ_ACCESS|SSC_WRITE_ACCESS,						   0, 0, SSC_OPEN);			if (desc[target_id] < 0) {				/* disk doesn't exist... */				break;			}			buf = sc->request_buffer;			buf[0] = 0;	/* magnetic disk */			buf[1] = 0;	/* not a removable medium */			buf[2] = 2;	/* SCSI-2 compliant device */			buf[3] = 2;	/* SCSI-2 response data format */			buf[4] = 31;	/* additional length (bytes) */			buf[5] = 0;	/* reserved */			buf[6] = 0;	/* reserved */			buf[7] = 0;	/* various flags */			memcpy(buf + 8, "HP      SIMULATED DISK  0.00",  28);			sc->result = GOOD;			break;		      case TEST_UNIT_READY:			sc->result = GOOD;			break;		      case READ_6:			if (desc[target_id] < 0 )				break;			simscsi_readwrite6(sc, SSC_READ);			break;		      case READ_10:			if (desc[target_id] < 0 )				break;			simscsi_readwrite10(sc, SSC_READ);			break;		      case WRITE_6:			if (desc[target_id] < 0)				break;			simscsi_readwrite6(sc, SSC_WRITE);			break;		      case WRITE_10:			if (desc[target_id] < 0)				break;			simscsi_readwrite10(sc, SSC_WRITE);			break;		      case READ_CAPACITY:			if (desc[target_id] < 0 || sc->request_bufflen < 8) {				break;			}			buf = sc->request_buffer;			disk_size = simscsi_get_disk_size(desc[target_id]);			/* pretend to be a 1GB disk (partition table contains real stuff): */			buf[0] = (disk_size >> 24) & 0xff;			buf[1] = (disk_size >> 16) & 0xff;			buf[2] = (disk_size >>  8) & 0xff;			buf[3] = (disk_size >>  0) & 0xff;			/* set block size of 512 bytes: */			buf[4] = 0;			buf[5] = 0;			buf[6] = 2;			buf[7] = 0;			sc->result = GOOD;			break;		      case MODE_SENSE:		      case MODE_SENSE_10:			/* sd.c uses this to determine whether disk does write-caching. */			memset(sc->request_buffer, 0, 128);			sc->result = GOOD;			break;		      case START_STOP:			printk(KERN_ERR "START_STOP\n");			break;		      default:			panic("simscsi: unknown SCSI command %u\n", sc->cmnd[0]);		}	}	if (sc->result == DID_BAD_TARGET) {		sc->result |= DRIVER_SENSE << 24;		sc->sense_buffer[0] = 0x70;		sc->sense_buffer[2] = 0x00;	}	if (atomic_read(&num_reqs) >= SIMSCSI_REQ_QUEUE_LEN) {		panic("Attempt to queue command while command is pending!!");	}	atomic_inc(&num_reqs);	queue[wr].sc = sc;	wr = (wr + 1) % SIMSCSI_REQ_QUEUE_LEN;	tasklet_schedule(&simscsi_tasklet);	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/83a78d9ba792660418d692fd6737871aefdbff36/simscsi.c/clean/arch/ia64/hp/sim/simscsi.c