static int iir_ioctl(struct cdev *dev, u_long cmd, caddr_t cmdarg, int flags, struct thread * p) { GDT_DPRINTF(GDT_D_DEBUG, ("iir_ioctl() cmd 0x%lx\n",cmd)); ++gdt_stat.io_count_act; if (gdt_stat.io_count_act > gdt_stat.io_count_max) gdt_stat.io_count_max = gdt_stat.io_count_act; switch (cmd) { case GDT_IOCTL_GENERAL: { gdt_ucmd_t *ucmd; struct gdt_softc *gdt; ucmd = (gdt_ucmd_t *)cmdarg; gdt = gdt_minor2softc(dev, ucmd->io_node); if (gdt == NULL) return (ENXIO); mtx_lock(&gdt->sc_lock); TAILQ_INSERT_TAIL(&gdt->sc_ucmd_queue, ucmd, links); ucmd->complete_flag = FALSE; gdt_next(gdt); if (!ucmd->complete_flag) (void) mtx_sleep(ucmd, &gdt->sc_lock, PCATCH | PRIBIO, "iirucw", 0); mtx_unlock(&gdt->sc_lock); break; } case GDT_IOCTL_DRVERS: case GDT_IOCTL_DRVERS_OLD: *(int *)cmdarg = (IIR_DRIVER_VERSION << 8) | IIR_DRIVER_SUBVERSION; break; case GDT_IOCTL_CTRTYPE: case GDT_IOCTL_CTRTYPE_OLD: { gdt_ctrt_t *p; struct gdt_softc *gdt; p = (gdt_ctrt_t *)cmdarg; gdt = gdt_minor2softc(dev, p->io_node); if (gdt == NULL) return (ENXIO); /* only RP controllers */ p->ext_type = 0x6000 | gdt->sc_device; if (gdt->sc_vendor == INTEL_VENDOR_ID_IIR) { p->oem_id = OEM_ID_INTEL; p->type = 0xfd; /* new -> subdevice into ext_type */ if (gdt->sc_device >= 0x600) p->ext_type = 0x6000 | gdt->sc_subdevice; } else { p->oem_id = OEM_ID_ICP; p->type = 0xfe; /* new -> subdevice into ext_type */ if (gdt->sc_device >= 0x300) p->ext_type = 0x6000 | gdt->sc_subdevice; } p->info = (gdt->sc_bus << 8) | (gdt->sc_slot << 3); p->device_id = gdt->sc_device; p->sub_device_id = gdt->sc_subdevice; break; } case GDT_IOCTL_OSVERS: { gdt_osv_t *p; p = (gdt_osv_t *)cmdarg; p->oscode = 10; p->version = osreldate / 100000; p->subversion = osreldate / 1000 % 100; p->revision = 0; strcpy(p->name, ostype); break; } case GDT_IOCTL_CTRCNT: *(int *)cmdarg = gdt_cnt; break; case GDT_IOCTL_EVENT: { gdt_event_t *p; p = (gdt_event_t *)cmdarg; if (p->erase == 0xff) { if (p->dvr.event_source == GDT_ES_TEST) p->dvr.event_data.size = sizeof(p->dvr.event_data.eu.test); else if (p->dvr.event_source == GDT_ES_DRIVER) p->dvr.event_data.size= sizeof(p->dvr.event_data.eu.driver); else if (p->dvr.event_source == GDT_ES_SYNC) p->dvr.event_data.size = sizeof(p->dvr.event_data.eu.sync); else p->dvr.event_data.size = sizeof(p->dvr.event_data.eu.async); gdt_store_event(p->dvr.event_source, p->dvr.event_idx, &p->dvr.event_data); } else if (p->erase == 0xfe) { gdt_clear_events(); } else if (p->erase == 0) { p->handle = gdt_read_event(p->handle, &p->dvr); } else { gdt_readapp_event((u_int8_t)p->erase, &p->dvr); } break; } case GDT_IOCTL_STATIST: { gdt_statist_t *p; p = (gdt_statist_t *)cmdarg; bcopy(&gdt_stat, p, sizeof(gdt_statist_t)); break; } default: break; } --gdt_stat.io_count_act; return (0); }
static int iir_ioctl(dev_t dev, u_long cmd, caddr_t cmdarg, int flags, d_thread_t * p) { GDT_DPRINTF(GDT_D_DEBUG, ("iir_ioctl() cmd 0x%lx\n",cmd)); #ifdef SDEV_PER_HBA int minor_no; struct gdt_softc *gdt; minor_no = minor(dev); gdt = gdt_minor2softc(minor_no); if (gdt == NULL) return (ENXIO); #endif ++gdt_stat.io_count_act; if (gdt_stat.io_count_act > gdt_stat.io_count_max) gdt_stat.io_count_max = gdt_stat.io_count_act; switch (cmd) { case GDT_IOCTL_GENERAL: { gdt_ucmd_t *ucmd; struct gdt_softc *gdt; int lock; ucmd = (gdt_ucmd_t *)cmdarg; gdt = gdt_minor2softc(ucmd->io_node); if (gdt == NULL) return (ENXIO); lock = splcam(); TAILQ_INSERT_TAIL(&gdt->sc_ucmd_queue, ucmd, links); ucmd->complete_flag = FALSE; splx(lock); gdt_next(gdt); if (!ucmd->complete_flag) (void) tsleep((void *)ucmd, PCATCH | PRIBIO, "iirucw", 0); break; } case GDT_IOCTL_DRVERS: *(int *)cmdarg = (IIR_DRIVER_VERSION << 8) | IIR_DRIVER_SUBVERSION; break; case GDT_IOCTL_CTRTYPE: { gdt_ctrt_t *p; struct gdt_softc *gdt; p = (gdt_ctrt_t *)cmdarg; gdt = gdt_minor2softc(p->io_node); if (gdt == NULL) return (ENXIO); p->oem_id = 0x8000; p->type = 0xfd; p->info = (gdt->sc_bus << 8) | (gdt->sc_slot << 3); p->ext_type = 0x6000 | gdt->sc_subdevice; p->device_id = gdt->sc_device; p->sub_device_id = gdt->sc_subdevice; break; } case GDT_IOCTL_OSVERS: { gdt_osv_t *p; p = (gdt_osv_t *)cmdarg; p->oscode = 10; p->version = osrelease[0] - '0'; if (osrelease[1] == '.') p->subversion = osrelease[2] - '0'; else p->subversion = 0; if (osrelease[3] == '.') p->revision = osrelease[4] - '0'; else p->revision = 0; strcpy(p->name, ostype); break; } case GDT_IOCTL_CTRCNT: *(int *)cmdarg = gdt_cnt; break; case GDT_IOCTL_EVENT: { gdt_event_t *p; int lock; p = (gdt_event_t *)cmdarg; if (p->erase == 0xff) { if (p->dvr.event_source == GDT_ES_TEST) p->dvr.event_data.size = sizeof(p->dvr.event_data.eu.test); else if (p->dvr.event_source == GDT_ES_DRIVER) p->dvr.event_data.size= sizeof(p->dvr.event_data.eu.driver); else if (p->dvr.event_source == GDT_ES_SYNC) p->dvr.event_data.size = sizeof(p->dvr.event_data.eu.sync); else p->dvr.event_data.size = sizeof(p->dvr.event_data.eu.async); lock = splcam(); gdt_store_event(p->dvr.event_source, p->dvr.event_idx, &p->dvr.event_data); splx(lock); } else if (p->erase == 0xfe) { lock = splcam(); gdt_clear_events(); splx(lock); } else if (p->erase == 0) { p->handle = gdt_read_event(p->handle, &p->dvr); } else { gdt_readapp_event((u_int8_t)p->erase, &p->dvr); } break; } case GDT_IOCTL_STATIST: { gdt_statist_t *p; p = (gdt_statist_t *)cmdarg; bcopy(&gdt_stat, p, sizeof(gdt_statist_t)); break; } default: break; } --gdt_stat.io_count_act; return (0); }