MCPcopy Create free account
hub / github.com/F-Stack/f-stack / devinit

Function devinit

freebsd/kern/subr_bus.c:426–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424static struct cdev *devctl_dev;
425
426static void
427devinit(void)
428{
429 int reserve;
430 uma_zone_t z;
431
432 devctl_dev = make_dev_credf(MAKEDEV_ETERNAL, &dev_cdevsw, 0, NULL,
433 UID_ROOT, GID_WHEEL, 0600, "devctl");
434 mtx_init(&devsoftc.mtx, "dev mtx", "devd", MTX_DEF);
435 cv_init(&devsoftc.cv, "dev cv");
436 STAILQ_INIT(&devsoftc.devq);
437 knlist_init_mtx(&devsoftc.sel.si_note, &devsoftc.mtx);
438 if (devctl_queue_length > 0) {
439 /*
440 * Allocate a zone for the messages. Preallocate 2% of these for
441 * a reserve. Allow only devctl_queue_length slabs to cap memory
442 * usage. The reserve usually allows coverage of surges of
443 * events during memory shortages. Normally we won't have to
444 * re-use events from the queue, but will in extreme shortages.
445 */
446 z = devsoftc.zone = uma_zcreate("DEVCTL",
447 sizeof(struct dev_event_info), NULL, NULL, NULL, NULL,
448 UMA_ALIGN_PTR, 0);
449 reserve = max(devctl_queue_length / 50, 100); /* 2% reserve */
450 uma_zone_set_max(z, devctl_queue_length);
451 uma_zone_set_maxcache(z, 0);
452 uma_zone_reserve(z, reserve);
453 uma_prealloc(z, reserve);
454 }
455 devctl2_init();
456}
457
458static int
459devopen(struct cdev *dev, int oflags, int devtype, struct thread *td)

Callers 2

root_bus_module_handlerFunction · 0.85

Calls 11

make_dev_credfFunction · 0.85
mtx_initFunction · 0.85
knlist_init_mtxFunction · 0.85
uma_zcreateFunction · 0.85
maxFunction · 0.85
uma_zone_set_maxFunction · 0.85
uma_zone_set_maxcacheFunction · 0.85
uma_zone_reserveFunction · 0.85
uma_preallocFunction · 0.85
devctl2_initFunction · 0.85
cv_initFunction · 0.70

Tested by

no test coverage detected