Lines Matching refs:devsoftc

75 } devsoftc;  variable
150 mtx_init(&devsoftc.mtx, "dev mtx", "devd", MTX_DEF); in devctl_init()
151 cv_init(&devsoftc.cv, "dev cv"); in devctl_init()
152 STAILQ_INIT(&devsoftc.devq); in devctl_init()
153 knlist_init_mtx(&devsoftc.sel.si_note, &devsoftc.mtx); in devctl_init()
162 z = devsoftc.zone = uma_zcreate("DEVCTL", in devctl_init()
221 mtx_lock(&devsoftc.mtx); in devopen()
222 if (devsoftc.inuse) { in devopen()
223 mtx_unlock(&devsoftc.mtx); in devopen()
227 devsoftc.inuse = 1; in devopen()
228 mtx_unlock(&devsoftc.mtx); in devopen()
235 mtx_lock(&devsoftc.mtx); in devclose()
236 devsoftc.inuse = 0; in devclose()
237 devsoftc.nonblock = 0; in devclose()
238 devsoftc.async = 0; in devclose()
239 cv_broadcast(&devsoftc.cv); in devclose()
240 funsetown(&devsoftc.sigio); in devclose()
241 mtx_unlock(&devsoftc.mtx); in devclose()
259 mtx_lock(&devsoftc.mtx); in devread()
260 while (STAILQ_EMPTY(&devsoftc.devq)) { in devread()
261 if (devsoftc.nonblock) { in devread()
262 mtx_unlock(&devsoftc.mtx); in devread()
265 rv = cv_wait_sig(&devsoftc.cv, &devsoftc.mtx); in devread()
270 mtx_unlock(&devsoftc.mtx); in devread()
274 n1 = STAILQ_FIRST(&devsoftc.devq); in devread()
275 STAILQ_REMOVE_HEAD(&devsoftc.devq, dei_link); in devread()
276 devsoftc.queued--; in devread()
277 mtx_unlock(&devsoftc.mtx); in devread()
279 uma_zfree(devsoftc.zone, n1); in devread()
289 devsoftc.nonblock = 1; in devioctl()
291 devsoftc.nonblock = 0; in devioctl()
295 devsoftc.async = 1; in devioctl()
297 devsoftc.async = 0; in devioctl()
300 return fsetown(*(int *)data, &devsoftc.sigio); in devioctl()
302 *(int *)data = fgetown(&devsoftc.sigio); in devioctl()
320 mtx_lock(&devsoftc.mtx); in devpoll()
322 if (!STAILQ_EMPTY(&devsoftc.devq)) in devpoll()
325 selrecord(td, &devsoftc.sel); in devpoll()
327 mtx_unlock(&devsoftc.mtx); in devpoll()
339 knlist_add(&devsoftc.sel.si_note, kn, 0); in devkqfilter()
349 knlist_remove(&devsoftc.sel.si_note, kn, 0); in filt_devctl_detach()
355 kn->kn_data = devsoftc.queued; in filt_devctl_read()
365 return (devsoftc.inuse == 1); in devctl_process_running()
373 mtx_lock(&devsoftc.mtx); in devctl_alloc_dei()
376 dei = uma_zalloc(devsoftc.zone, M_NOWAIT); in devctl_alloc_dei()
378 dei = uma_zalloc(devsoftc.zone, M_NOWAIT | M_USE_RESERVE); in devctl_alloc_dei()
388 if (devsoftc.queued == 0) in devctl_alloc_dei()
390 dei = STAILQ_FIRST(&devsoftc.devq); in devctl_alloc_dei()
391 STAILQ_REMOVE_HEAD(&devsoftc.devq, dei_link); in devctl_alloc_dei()
392 devsoftc.queued--; in devctl_alloc_dei()
397 mtx_unlock(&devsoftc.mtx); in devctl_alloc_dei()
415 uma_zfree(devsoftc.zone, dei); in devctl_free_dei()
421 mtx_lock(&devsoftc.mtx); in devctl_queue()
422 STAILQ_INSERT_TAIL(&devsoftc.devq, dei, dei_link); in devctl_queue()
423 devsoftc.queued++; in devctl_queue()
424 cv_broadcast(&devsoftc.cv); in devctl_queue()
425 KNOTE_LOCKED(&devsoftc.sel.si_note, 0); in devctl_queue()
426 mtx_unlock(&devsoftc.mtx); in devctl_queue()
427 selwakeup(&devsoftc.sel); in devctl_queue()
428 if (devsoftc.async && devsoftc.sigio != NULL) in devctl_queue()
429 pgsigio(&devsoftc.sigio, SIGIO, 0); in devctl_queue()
557 if (!mtx_initialized(&devsoftc.mtx)) { in sysctl_devctl_queue()
571 mtx_lock(&devsoftc.mtx); in sysctl_devctl_queue()
573 uma_zdestroy(devsoftc.zone); in sysctl_devctl_queue()
574 devsoftc.zone = 0; in sysctl_devctl_queue()
575 mtx_unlock(&devsoftc.mtx); in sysctl_devctl_queue()