rem: dprintf("emulation!\n");
context: scsi_async_io(scsi_ccb *request){	scsi_bus_info *bus = request->bus;	//SHOW_FLOW( 0, "path_id=%d", bus->path_id );		//snooze( 1000000 );	// do some sanity tests first	if (request->state != SCSI_STATE_FINISHED)		panic("Passed ccb to scsi_action that isn't ready (state = %d)\n", request->state);	if (request->cdb_len < func_group_len[request->cdb[0] >> 5]) {		SHOW_ERROR(3, "invalid command len (%d instead of %d)",			request->cdb_len, func_group_len[request->cdb[0] >> 5]);		request->subsys_status = SCSI_REQ_INVALID;		goto err;	}	FAST_LOGN(request->device->log, ev_scsi_async_io, 		func_group_len[request->cdb[0] >> 5] + 2, 		(uint32)request, request->data_len,		request->cdb[0], request->cdb[1], request->cdb[2], request->cdb[3],		request->cdb[4], request->cdb[5], request->cdb[6], request->cdb[7],		request->cdb[8], request->cdb[9], request->cdb[10], request->cdb[11],		request->cdb[12], request->cdb[13], request->cdb[14], request->cdb[15]);	if (!request->device->valid) {		SHOW_ERROR0( 3, "device got removed" );		// device got removed meanwhile		request->subsys_status = SCSI_DEV_NOT_THERE;		goto err;	}	if ((request->flags & SCSI_DIR_MASK) != SCSI_DIR_NONE		&& request->sg_list == NULL && request->data_len > 0) {		SHOW_ERROR( 3, "Asynchronous SCSI I/O requires S/G list (data is %d bytes)",			(int)request->data_len );		request->subsys_status = SCSI_DATA_RUN_ERR;		goto err;	}	request->buffered = request->emulated = 0;	// make data DMA safe	// (S/G list must be created first to be able to verify DMA restrictions)	if ((request->flags & SCSI_DMA_SAFE) == 0 && request->data_len > 0) {		request->buffered = true;		if (!scsi_get_dma_buffer(request)) {			SHOW_ERROR0( 3, "cannot create DMA buffer for request - reduce data volume" );			request->subsys_status = SCSI_DATA_RUN_ERR;			goto err;		}	}	// emulate command if not supported	if ((request->device->emulation_map[request->cdb[0] >> 3]		& (1 << (request->cdb[0] & 7))) != 0) {		request->emulated = true;dprintf("emulation!\n");		if (!scsi_start_emulation(request)) {			SHOW_ERROR( 3, "cannot emulate SCSI command 0x%02x", request->cdb[0] );			goto err2;		}	}	// SCSI-1 uses 3 bits of command packet for LUN	// SCSI-2 uses identify message, but still needs LUN in command packet	//        (though it won't fit, as LUNs can be 4 bits wide)	// SCSI-3 doesn't use command packet for LUN anymore	// ATAPI uses 3 bits of command packet for LUN	// currently, we always copy LUN into command packet as a safe bet	{		// abuse TUR to find proper spot in command packet for LUN		scsi_cmd_tur *cmd = (scsi_cmd_tur *)request->cdb;		cmd->LUN = request->device->target_lun;	}	request->ordered = (request->flags & SCSI_ORDERED_QTAG) != 0;	SHOW_FLOW(3, "ordered=%d", request->ordered);	// give SIM a well-defined first state	request->sim_state = 0;	// make sure device/bus is not blocked		if (!scsi_check_enqueue_request(request))		return;	bus = request->bus;	request->state = SCSI_STATE_SENT;	bus->interface->scsi_io(bus->sim_cookie, request);	return;err2:	if (request->buffered)		scsi_release_dma_buffer(request);err:	release_sem(request->completion_sem);	return;}