static int devinfo_vfile_show(struct xnvfile_regular_iterator *it, void *data) { struct rtdm_device *device; int i; if (down_interruptible(&nrt_dev_lock)) return -ERESTARTSYS; /* * As the device may have disappeared while the handler was called, * first match the pointer against registered devices. */ for (i = 0; i < devname_hashtab_size; i++) list_for_each_entry(device, &rtdm_named_devices[i], reserved.entry) if (device == xnvfile_priv(it->vfile)) goto found; for (i = 0; i < protocol_hashtab_size; i++) list_for_each_entry(device, &rtdm_protocol_devices[i], reserved.entry) if (device == xnvfile_priv(it->vfile)) goto found; up(&nrt_dev_lock); return -ENODEV; found: xnvfile_printf(it, "driver:\t\t%s\nversion:\t%d.%d.%d\n", device->driver_name, RTDM_DRIVER_MAJOR_VER(device->driver_version), RTDM_DRIVER_MINOR_VER(device->driver_version), RTDM_DRIVER_PATCH_VER(device->driver_version)); xnvfile_printf(it, "peripheral:\t%s\nprovider:\t%s\n", device->peripheral_name, device->provider_name); xnvfile_printf(it, "class:\t\t%d\nsub-class:\t%d\n", device->device_class, device->device_sub_class); xnvfile_printf(it, "flags:\t\t%s%s%s\n", (device->device_flags & RTDM_EXCLUSIVE) ? "EXCLUSIVE " : "", (device->device_flags & RTDM_NAMED_DEVICE) ? "NAMED_DEVICE " : "", (device->device_flags & RTDM_PROTOCOL_DEVICE) ? "PROTOCOL_DEVICE " : ""); xnvfile_printf(it, "lock count:\t%d\n", atomic_read(&device->reserved.refcount)); up(&nrt_dev_lock); return 0; }
int rtdm_proc_register_device(struct rtdm_device *device) { int ret; ret = xnvfile_init_dir(device->proc_name, &device->vfroot, &rtdm_vfroot); if (ret) goto err_out; memset(&device->info_vfile, 0, sizeof(device->info_vfile)); device->info_vfile.ops = &devinfo_vfile_ops; ret = xnvfile_init_regular("information", &device->info_vfile, &device->vfroot); if (ret) { xnvfile_destroy_dir(&device->vfroot); goto err_out; } xnvfile_priv(&device->info_vfile) = device; return 0; err_out: xnlogerr("RTDM: error while creating device vfile\n"); return ret; }
static int vfile_next(struct xnvfile_snapshot_iterator *it, void *data) { struct vfile_priv *priv = xnvfile_iterator_priv(it); struct uiflag *flag = xnvfile_priv(it->vfile); struct vfile_data *p = data; struct xnthread *thread; struct uitask *task; priv->value = flag->flgvalue; /* Refresh as we collect. */ if (priv->curr == NULL) return 0; /* We are done. */ /* Fetch current waiter, advance list cursor. */ thread = link2thread(priv->curr, plink); priv->curr = nextpq(xnsynch_wait_queue(&flag->synchbase), priv->curr); /* Collect thread name to be output in ->show(). */ strncpy(p->name, xnthread_name(thread), sizeof(p->name)); task = thread2uitask(thread); p->wfmode = task->wargs.flag.wfmode; p->waiptn = task->wargs.flag.waiptn; return 1; }
static int vfile_next(struct xnvfile_snapshot_iterator *it, void *data) { struct vfile_priv *priv = xnvfile_iterator_priv(it); RT_BUFFER *bf = xnvfile_priv(it->vfile); struct vfile_data *p = data; struct xnthread *thread; struct xnpqueue *waitq; if (priv->curr == NULL) { /* Attempt to switch queues. */ if (!priv->input) /* Finished output side, we are done. */ return 0; priv->input = 0; waitq = xnsynch_wait_queue(&bf->osynch_base); priv->curr = getheadpq(waitq); if (priv->curr == NULL) return 0; } else waitq = priv->input ? xnsynch_wait_queue(&bf->isynch_base) : xnsynch_wait_queue(&bf->osynch_base); /* Fetch current waiter, advance list cursor. */ thread = link2thread(priv->curr, plink); priv->curr = nextpq(waitq, priv->curr); /* Collect thread name to be output in ->show(). */ strncpy(p->name, xnthread_name(thread), sizeof(p->name)); p->input = priv->input; return 1; }
static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { struct vfile_priv *priv = xnvfile_iterator_priv(it); wind_sem_t *sem = xnvfile_priv(it->vfile); struct xnthread *owner; sem = wind_h2obj_active((SEM_ID)sem, WIND_SEM_MAGIC, wind_sem_t); if (sem == NULL) return -EIDRM; priv->curr = getheadpq(xnsynch_wait_queue(&sem->synchbase)); priv->type = sem->vtbl->type; if (sem->vtbl == &semm_vtbl) { owner = xnsynch_owner(&sem->synchbase); if (owner) strncpy(priv->owner, xnthread_name(owner), sizeof(priv->owner)); else *priv->owner = 0; priv->count = -1U; } else priv->count = sem->count; return xnsynch_nsleepers(&sem->synchbase); }
static int vfile_next(struct xnvfile_snapshot_iterator *it, void *data) { struct vfile_priv *priv = xnvfile_iterator_priv(it); RT_EVENT *event = xnvfile_priv(it->vfile); struct vfile_data *p = data; struct xnthread *thread; RT_TASK *task; priv->value = event->value; /* Refresh as we collect. */ if (priv->curr == NULL) return 0; /* We are done. */ /* Fetch current waiter, advance list cursor. */ thread = link2thread(priv->curr, plink); priv->curr = nextpq(xnsynch_wait_queue(&event->synch_base), priv->curr); /* Collect thread name to be output in ->show(). */ strncpy(p->name, xnthread_name(thread), sizeof(p->name)); task = thread2rtask(thread); p->mode = task->wait_args.event.mode; p->mask = task->wait_args.event.mask; return 1; }
static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { struct vfile_priv *priv = xnvfile_iterator_priv(it); struct uiflag *flag = xnvfile_priv(it->vfile); priv->curr = getheadpq(xnsynch_wait_queue(&flag->synchbase)); priv->value = flag->flgvalue; return xnsynch_nsleepers(&flag->synchbase); }
static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { struct vfile_priv *priv = xnvfile_iterator_priv(it); struct vrtxsem *sem = xnvfile_priv(it->vfile); priv->curr = getheadpq(xnsynch_wait_queue(&sem->synchbase)); priv->count = sem->count; return xnsynch_nsleepers(&sem->synchbase); }
static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { struct vfile_priv *priv = xnvfile_iterator_priv(it); struct vrtxmb *mb = xnvfile_priv(it->vfile); priv->curr = getheadpq(xnsynch_wait_queue(&mb->synchbase)); priv->msg = mb->msg; return xnsynch_nsleepers(&mb->synchbase); }
static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { struct vfile_priv *priv = xnvfile_iterator_priv(it); RT_COND *cond = xnvfile_priv(it->vfile); cond = xeno_h2obj_validate(cond, XENO_COND_MAGIC, RT_COND); if (cond == NULL) return -EIDRM; priv->curr = getheadpq(xnsynch_wait_queue(&cond->synch_base)); return xnsynch_nsleepers(&cond->synch_base); }
static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { struct vfile_priv *priv = xnvfile_iterator_priv(it); RT_EVENT *event = xnvfile_priv(it->vfile); event = xeno_h2obj_validate(event, XENO_EVENT_MAGIC, RT_EVENT); if (event == NULL) return -EIDRM; priv->curr = getheadpq(xnsynch_wait_queue(&event->synch_base)); priv->value = event->value; return xnsynch_nsleepers(&event->synch_base); }
static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { struct vfile_priv *priv = xnvfile_iterator_priv(it); wind_msgq_t *q = xnvfile_priv(it->vfile); q = wind_h2obj_active((MSG_Q_ID)q, WIND_MSGQ_MAGIC, wind_msgq_t); if (q == NULL) return -EIDRM; priv->curr = getheadpq(xnsynch_wait_queue(&q->synchbase)); priv->flags = xnsynch_test_flags(&q->synchbase, XNSYNCH_PRIO); priv->mlength = q->msg_length; priv->mcount = countq(&q->msgq); return xnsynch_nsleepers(&q->synchbase); }
static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { struct vfile_priv *priv = xnvfile_iterator_priv(it); struct vrtxmx *mx = xnvfile_priv(it->vfile); struct xnthread *owner; priv->curr = getheadpq(xnsynch_wait_queue(&mx->synchbase)); owner = xnsynch_owner(&mx->synchbase); if (owner) strncpy(priv->owner, xnthread_name(owner), sizeof(priv->owner)); else *priv->owner = 0; return xnsynch_nsleepers(&mx->synchbase); }
static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { struct vfile_priv *priv = xnvfile_iterator_priv(it); RT_HEAP *heap = xnvfile_priv(it->vfile); heap = xeno_h2obj_validate(heap, XENO_HEAP_MAGIC, RT_HEAP); if (heap == NULL) return -EIDRM; priv->curr = getheadpq(xnsynch_wait_queue(&heap->synch_base)); priv->mode = heap->mode; priv->usable_mem = xnheap_usable_mem(&heap->heap_base); priv->used_mem = xnheap_used_mem(&heap->heap_base); priv->nrmaps = heap->heap_base.archdep.numaps; return xnsynch_nsleepers(&heap->synch_base); }
static int vfile_next(struct xnvfile_snapshot_iterator *it, void *data) { struct vfile_priv *priv = xnvfile_iterator_priv(it); RT_COND *cond = xnvfile_priv(it->vfile); struct vfile_data *p = data; struct xnthread *thread; if (priv->curr == NULL) return 0; /* We are done. */ /* Fetch current waiter, advance list cursor. */ thread = link2thread(priv->curr, plink); priv->curr = nextpq(xnsynch_wait_queue(&cond->synch_base), priv->curr); /* Collect thread name to be output in ->show(). */ strncpy(p->name, xnthread_name(thread), sizeof(p->name)); return 1; }
static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { struct vfile_priv *priv = xnvfile_iterator_priv(it); RT_BUFFER *bf = xnvfile_priv(it->vfile); bf = xeno_h2obj_validate(bf, XENO_BUFFER_MAGIC, RT_BUFFER); if (bf == NULL) return -EIDRM; /* Start collecting records from the input wait side. */ priv->curr = getheadpq(xnsynch_wait_queue(&bf->isynch_base)); priv->mode = bf->mode; priv->bufsz = bf->bufsz; priv->fillsz = bf->fillsz; priv->input = 1; return xnsynch_nsleepers(&bf->isynch_base) + xnsynch_nsleepers(&bf->osynch_base); }