int ramdisk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp) { switch (req) { case RTEMS_BLKIO_REQUEST: { rtems_blkdev_request *r = argp; struct ramdisk *rd = rtems_disk_get_driver_data(dd); switch (r->req) { case RTEMS_BLKDEV_REQ_READ: return ramdisk_read(rd, r); case RTEMS_BLKDEV_REQ_WRITE: return ramdisk_write(rd, r); default: errno = EINVAL; return -1; } break; } default: return rtems_blkdev_ioctl (dd, req, argp); break; } errno = EINVAL; return -1; }
/* * ioctl handler to be passed to the block device handler */ static int sparse_disk_ioctl( rtems_disk_device *dd, uint32_t req, void *argp ) { rtems_status_code sc; rtems_sparse_disk *sd = rtems_disk_get_driver_data( dd ); if ( RTEMS_BLKIO_REQUEST == req ) { rtems_blkdev_request *r = argp; switch ( r->req ) { case RTEMS_BLKDEV_REQ_READ: case RTEMS_BLKDEV_REQ_WRITE: return sparse_disk_read_write( sd, r, r->req == RTEMS_BLKDEV_REQ_READ ); default: break; } } else if ( RTEMS_BLKIO_DELETED == req ) { sc = rtems_semaphore_delete( sd->mutex ); if ( RTEMS_SUCCESSFUL != sc ) rtems_fatal_error_occurred( 0xdeadbeef ); sd->mutex = RTEMS_ID_NONE; if ( NULL != sd->delete_handler ) ( *sd->delete_handler )( sd ); return 0; } else { return rtems_blkdev_ioctl( dd, req, argp ); } errno = EINVAL; return -1; }
static int disk_ioctl(rtems_disk_device *dd, uint32_t req, void *arg) { rtems_status_code sc = RTEMS_SUCCESSFUL; if (req == RTEMS_BLKIO_REQUEST) { rtems_blkdev_request *r = arg; uint32_t i = 0; for (i = 0; i < r->bufnum; ++i) { rtems_blkdev_sg_buffer *sg = &r->bufs [i]; char *buf = sg->buffer; if (sg->length != 1) { return -1; } switch (r->req) { case RTEMS_BLKDEV_REQ_READ: switch (sg->block) { case BLOCK_READ_IO_ERROR: sc = RTEMS_IO_ERROR; break; case BLOCK_READ_UNSATISFIED: sc = RTEMS_UNSATISFIED; break; case BLOCK_READ_SUCCESSFUL: case BLOCK_WRITE_IO_ERROR: *buf = disk_data [sg->block]; break; default: return -1; } break; case RTEMS_BLKDEV_REQ_WRITE: switch (sg->block) { case BLOCK_READ_IO_ERROR: case BLOCK_READ_UNSATISFIED: case BLOCK_READ_SUCCESSFUL: disk_data [sg->block] = *buf; break; case BLOCK_WRITE_IO_ERROR: sc = RTEMS_IO_ERROR; break; default: return -1; } break; default: return -1; } } r->req_done(r->done_arg, sc); return 0; } else { return rtems_blkdev_ioctl(dd, req, arg); } }
static int disk_ioctl(rtems_disk_device *dd, uint32_t req, void *arg) { rtems_status_code sc = RTEMS_SUCCESSFUL; if (req == RTEMS_BLKIO_REQUEST) { rtems_blkdev_request *r = arg; if (r->req == RTEMS_BLKDEV_REQ_WRITE) { set_task_prio(RTEMS_SELF, PRIORITY_IDLE); set_task_prio(RTEMS_SELF, PRIORITY_SWAPOUT); } r->req_done(r->done_arg, sc); return 0; } else { return rtems_blkdev_ioctl(dd, req, arg); } }
static int disk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp) { if (req == RTEMS_BLKIO_REQUEST) { rtems_blkdev_request *r = argp; set_task_prio(task_id_low, PRIORITY_LOW_ALT); switch (r->req) { case RTEMS_BLKDEV_REQ_READ: case RTEMS_BLKDEV_REQ_WRITE: rtems_blkdev_request_done(r, RTEMS_SUCCESSFUL); return 0; default: errno = EINVAL; return -1; } } else { return rtems_blkdev_ioctl(dd, req, argp); } }
static int rtems_bsd_sim_disk_ioctl(rtems_disk_device *dd, uint32_t req, void *arg) { struct cam_sim *sim = rtems_disk_get_driver_data(dd); if (req == RTEMS_BLKIO_REQUEST) { rtems_blkdev_request *r = arg; return rtems_bsd_sim_disk_read_write(sim, r); } else if (req == RTEMS_BLKIO_DELETED) { mtx_lock(sim->mtx); free(sim->disk, M_RTEMS_HEAP); sim->disk = NULL; rtems_bsd_sim_set_state_and_notify(sim, BSD_SIM_DELETED); mtx_unlock(sim->mtx); return 0; } else { return rtems_blkdev_ioctl(dd, req, arg); } }