void scsi_dev_attached(struct scsi_dev *dev) { dev->attached = 1; dev->state = dev->holded_state = NULL; scsi_state_transit(dev, &scsi_state_inquiry); }
void scsi_dev_recover(struct scsi_dev *dev) { assertf(dev->holded_state == NULL, "Can't recover recovering procedure"); dev->holded_state = dev->state; scsi_state_transit(dev, &scsi_state_sense); }
static void scsi_inquiry_input(struct scsi_dev *dev, int res) { struct scsi_data_inquiry *data; assert(res == 0); data = (struct scsi_data_inquiry *) dev->scsi_data_scratchpad; if ((data->dinq_devtype & SCSI_INQIRY_DEVTYPE_MASK) != SCSI_INQIRY_DEVTYPE_BLK) { return; } scsi_state_transit(dev, &scsi_state_capacity); }
static void scsi_sense_input(struct scsi_dev *dev, int res) { struct scsi_data_sense *data; uint8_t acode; assert(res == 0); data = (struct scsi_data_sense *) dev->scsi_data_scratchpad; acode = data->dsns_additional_code; assertf(acode == 0x28 || acode == 0x29, "Don't know how to recover " "unknown error %x", acode); /* 0x28 and 0x29 are just required attention, seems that can go on */ scsi_state_transit(dev, dev->holded_state); dev->holded_state = NULL; }
void scsi_disk_found(struct scsi_dev *sdev) { struct block_dev *bdev; char path[PATH_MAX]; strcpy(path, "/dev/sd*"); if (0 > (sdev->idx = block_dev_named(path, &scsi_disk_idx))) { return; } bdev = block_dev_create(path, (void *) &bdev_driver_scsi, sdev); bdev->size = sdev->blk_n * sdev->blk_size; sdev->bdev = bdev; scsi_state_transit(sdev, &scsi_state_user); }