/* XXX Todo - try and detect if interrupt is working */ int lpt_attach(device_t dev) { int rid, unit; struct lpt_softc *sc; struct cdev *cdev; unit = device_get_unit(dev); sc = device_get_softc(dev); rid = 0; sc->res_port = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, lpt_iat, 4, RF_ACTIVE); if (sc->res_port == NULL) return ENXIO; isa_load_resourcev(sc->res_port, lpt_iat, 4); sc->sc_port = rman_get_start(sc->res_port); sc->sc_primed = 0; /* not primed yet */ outb(sc->sc_port+lpt_pstb_ctrl, LPC_DIS_PSTB); /* PSTB disable */ outb(sc->sc_port+lpt_control, LPC_MODE8255); /* 8255 mode set */ outb(sc->sc_port+lpt_control, LPC_NIRQ8); /* IRQ8 inactive */ outb(sc->sc_port+lpt_control, LPC_NPSTB); /* PSTB inactive */ outb(sc->sc_port+lpt_pstb_ctrl, LPC_EN_PSTB); /* PSTB enable */ sc->sc_irq = 0; if (isa_get_irq(dev) != -1) { rid = 0; sc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); if (sc->res_irq == NULL) { bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->res_port); return ENXIO; } if (bus_setup_intr(dev, sc->res_irq, INTR_TYPE_TTY, NULL, lpt_intr, sc, &sc->sc_ih)) { bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->res_port); bus_release_resource(dev, SYS_RES_IRQ, 0, sc->res_irq); return ENXIO; } sc->sc_irq = LP_HAS_IRQ | LP_USE_IRQ | LP_ENABLE_IRQ; device_printf(dev, "Interrupt-driven port"); } cdev = make_dev(&lpt_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "lpt%d", unit); cdev->si_drv1 = sc; cdev = make_dev(&lpt_cdevsw, LP_BYPASS, UID_ROOT, GID_WHEEL, 0600, "lpctl%d", unit); cdev->si_drv1 = sc; return 0; }
/* XXX Todo - try and detect if interrupt is working */ int lpt_attach(device_t dev) { int rid, unit; struct lpt_softc *sc; unit = device_get_unit(dev); sc = device_get_softc(dev); rid = 0; sc->res_port = isa_alloc_resourcev(dev, SYS_RES_IOPORT, &rid, lpt_iat, 4, RF_ACTIVE); if (sc->res_port == NULL) return ENXIO; isa_load_resourcev(sc->res_port, lpt_iat, 4); sc->sc_port = rman_get_start(sc->res_port); sc->sc_primed = 0; /* not primed yet */ #ifdef PC98 outb(sc->sc_port+lpt_pstb_ctrl, LPC_DIS_PSTB); /* PSTB disable */ outb(sc->sc_port+lpt_control, LPC_MODE8255); /* 8255 mode set */ outb(sc->sc_port+lpt_control, LPC_NIRQ8); /* IRQ8 inactive */ outb(sc->sc_port+lpt_control, LPC_NPSTB); /* PSTB inactive */ outb(sc->sc_port+lpt_pstb_ctrl, LPC_EN_PSTB); /* PSTB enable */ #else outb(sc->sc_port+lpt_control, LPC_NINIT); #endif sc->sc_irq = 0; if (isa_get_irq(dev) != -1) { rid = 0; sc->res_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, RF_ACTIVE); if (sc->res_irq == NULL) { bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->res_port); return ENXIO; } if (bus_setup_intr(dev, sc->res_irq, INTR_TYPE_TTY, lpt_intr, sc, &sc->sc_ih)) { bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->res_port); bus_release_resource(dev, SYS_RES_IRQ, 0, sc->res_irq); return ENXIO; } sc->sc_irq = LP_HAS_IRQ | LP_USE_IRQ | LP_ENABLE_IRQ; device_printf(dev, "Interrupt-driven port"); } /* XXX what to do about the flags in the minor number? */ make_dev(&lpt_cdevsw, unit, UID_ROOT, GID_WHEEL, 0600, "lpt%d", unit); make_dev(&lpt_cdevsw, unit | LP_BYPASS, UID_ROOT, GID_WHEEL, 0600, "lpctl%d", unit); return 0; }
void acpi_apm_init(struct acpi_softc *sc) { /* Create a clone for /dev/acpi also. */ STAILQ_INIT(&sc->apm_cdevs); sc->acpi_clone = apm_create_clone(sc->acpi_dev_t, sc); make_dev(&apm_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0660, "apmctl"); make_dev(&apm_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0664, "apm"); }
static int gscattach(struct isa_device *isdp) { int unit = isdp->id_unit; struct gsc_unit *scu = unittab + unit; scu->flags |= FLAG_DEBUG; lprintf(("gsc%d.attach: " "iobase 0x%03x, irq %d, drq %d, addr %p, size %d\n", unit, isdp->id_iobase, isdp->id_irq, isdp->id_drq, isdp->id_maddr, isdp->id_msize)); printf("gsc%d: GeniScan GS-4500 at %ddpi\n", unit, geomtab[scu->geometry].dpi); /* * Initialize buffer structure. * XXX this must be done early to give a good chance of getting a * contiguous buffer. This wastes memory. */ scu->sbuf.base = contigmalloc((unsigned long)MAX_BUFSIZE, M_DEVBUF, M_NOWAIT, 0ul, 0xfffffful, 1ul, 0x10000ul); if ( scu->sbuf.base == NULL ) { lprintf(("gsc%d.attach: buffer allocation failed\n", unit)); return ATTACH_FAIL; /* XXX attach must not fail */ } scu->sbuf.size = INVALID; scu->sbuf.poi = INVALID; scu->blen = DEFAULT_BLEN; scu->btime = TIMEOUT; scu->flags |= ATTACHED; lprintf(("gsc%d.attach: ok\n", unit)); scu->flags &= ~FLAG_DEBUG; #define GSC_UID 0 #define GSC_GID 13 make_dev(&gsc_cdevsw, unit<<6, GSC_UID, GSC_GID, 0666, "gsc%d", unit); make_dev(&gsc_cdevsw, ((unit<<6) + FRMT_PBM), GSC_UID, GSC_GID, 0666, "gsc%dp", unit); make_dev(&gsc_cdevsw, ((unit<<6) + DBUG_MASK), GSC_UID, GSC_GID, 0666, "gsc%dd", unit); make_dev(&gsc_cdevsw, ((unit<<6) + DBUG_MASK+FRMT_PBM), GSC_UID, GSC_GID, 0666, "gsc%dpd", unit); return ATTACH_SUCCESS; }
static int streams_modevent(module_t mod, int type, void *unused) { switch (type) { case MOD_LOAD: dt_ptm = make_dev(&streams_cdevsw, dev_ptm, 0, 0, 0666, "ptm"); dt_arp = make_dev(&streams_cdevsw, dev_arp, 0, 0, 0666, "arp"); dt_icmp = make_dev(&streams_cdevsw, dev_icmp, 0, 0, 0666, "icmp"); dt_ip = make_dev(&streams_cdevsw, dev_ip, 0, 0, 0666, "ip"); dt_tcp = make_dev(&streams_cdevsw, dev_tcp, 0, 0, 0666, "tcp"); dt_udp = make_dev(&streams_cdevsw, dev_udp, 0, 0, 0666, "udp"); dt_rawip = make_dev(&streams_cdevsw, dev_rawip, 0, 0, 0666, "rawip"); dt_unix_dgram = make_dev(&streams_cdevsw, dev_unix_dgram, 0, 0, 0666, "ticlts"); dt_unix_stream = make_dev(&streams_cdevsw, dev_unix_stream, 0, 0, 0666, "ticots"); dt_unix_ord_stream = make_dev(&streams_cdevsw, dev_unix_ord_stream, 0, 0, 0666, "ticotsord"); if (! (dt_ptm && dt_arp && dt_icmp && dt_ip && dt_tcp && dt_udp && dt_rawip && dt_unix_dgram && dt_unix_stream && dt_unix_ord_stream)) { printf("WARNING: device config for STREAMS failed\n"); printf("Suggest unloading streams KLD\n"); } return 0; case MOD_UNLOAD: /* XXX should check to see if it's busy first */ destroy_dev(dt_ptm); destroy_dev(dt_arp); destroy_dev(dt_icmp); destroy_dev(dt_ip); destroy_dev(dt_tcp); destroy_dev(dt_udp); destroy_dev(dt_rawip); destroy_dev(dt_unix_dgram); destroy_dev(dt_unix_stream); destroy_dev(dt_unix_ord_stream); return 0; default: return EOPNOTSUPP; break; } return 0; }
static int ipf_modload(void) { char *defpass, *c, *str; int i, j, error; RWLOCK_INIT(&ipf_global, "ipf filter load/unload mutex"); RWLOCK_INIT(&ipf_mutex, "ipf filter rwlock"); RWLOCK_INIT(&ipf_frcache, "ipf cache rwlock"); error = ipfattach(); if (error) { RW_DESTROY(&ipf_global); RW_DESTROY(&ipf_mutex); RW_DESTROY(&ipf_frcache); return error; } for (i = 0; i < IPL_LOGSIZE; i++) ipf_devs[i] = NULL; for (i = 0; (str = ipf_devfiles[i]); i++) { c = NULL; for(j = strlen(str); j > 0; j--) if (str[j] == '/') { c = str + j + 1; break; } if (!c) c = str; ipf_devs[i] = make_dev(&ipl_cdevsw, i, 0, 0, 0600, c); } error = ipf_pfil_hook(); if (error != 0) return error; ipf_event_reg(); if (FR_ISPASS(fr_pass)) defpass = "******"; else if (FR_ISBLOCK(fr_pass)) defpass = "******"; else defpass = "******"; printf("%s initialized. Default = %s all, Logging = %s%s\n", ipfilter_version, defpass, #ifdef IPFILTER_LOG "enabled", #else "disabled", #endif #ifdef IPFILTER_COMPILED " (COMPILED)" #else "" #endif ); return 0; }
static int fw_open (struct dev_open_args *ap) { cdev_t dev = ap->a_head.a_dev; int err = 0; if (DEV_FWMEM(dev)) return fwmem_open(ap); if (dev->si_drv1 != NULL) return (EBUSY); #if defined(__FreeBSD__) && __FreeBSD_version >= 500000 if ((dev->si_flags & SI_NAMED) == 0) { int unit = DEV2UNIT(dev); int sub = DEV2SUB(dev); make_dev(&firewire_ops, minor(dev), UID_ROOT, GID_OPERATOR, 0660, "fw%d.%d", unit, sub); } #endif dev->si_drv1 = kmalloc(sizeof(struct fw_drv1), M_FW, M_WAITOK | M_ZERO); return err; }
isdntrcattach() #endif { int i; for(i=0; i < NISDNTRC; i++) { #if defined(__FreeBSD__) #if __FreeBSD__ < 4 #ifdef DEVFS devfs_token[i] = devfs_add_devswf(&i4btrc_cdevsw, i, DV_CHR, UID_ROOT, GID_WHEEL, 0600, "isdntrc%d", i); #endif #else make_dev(&i4btrc_cdevsw, i, UID_ROOT, GID_WHEEL, 0600, "isdntrc%d", i); #endif #endif trace_queue[i].ifq_maxlen = IFQ_MAXLEN; device_state[i] = ST_IDLE; } }
static int openfirm_modevent(module_t mod, int type, void *data) { switch(type) { case MOD_LOAD: if (bootverbose) printf("openfirm: <Open Firmware control device>\n"); /* * Allow only root access by default; this device may allow * users to peek into firmware passwords, and likely to crash * the machine on some boxen due to firmware quirks. */ openfirm_dev = make_dev(&openfirm_cdevsw, OPENFIRM_MINOR, UID_ROOT, GID_WHEEL, 0600, "openfirm"); return 0; case MOD_UNLOAD: destroy_dev(openfirm_dev); return 0; case MOD_SHUTDOWN: return 0; default: return EOPNOTSUPP; } }
static int sysvipc_modevent(module_t mod, int type, void *unused) { struct sysvipc_softc *sysv; switch (type) { case MOD_LOAD: sysvipc_dev = make_dev(&sysvipc_dev_ops, 0, UID_ROOT, GID_WHEEL, 0600, "sysvipc"); kprintf("sysv ipc driver ready!\n"); return 0; case MOD_UNLOAD: sysv = sysvipc_dev->si_drv1; if(sysv != NULL) sysvipc_unregister(sysvipc_dev); destroy_dev(sysvipc_dev); kprintf("sysv ipc driver unloaded.\n"); return 0; } return EINVAL; }
static void consolectl_drvinit(void *unused) { make_dev(&consolectl_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "consolectl"); }
static void tunclone(void *arg, char *name, int namelen, struct cdev **dev) { int u, i; if (*dev != NULL) return; if (strcmp(name, TUNNAME) == 0) { u = -1; } else if (dev_stdclone(name, NULL, TUNNAME, &u) != 1) return; /* Don't recognise the name */ if (u != -1 && u > IF_MAXUNIT) return; /* Unit number too high */ /* find any existing device, or allocate new unit number */ i = clone_create(&tunclones, &tun_cdevsw, &u, dev, 0); if (i) { /* No preexisting struct cdev *, create one */ *dev = make_dev(&tun_cdevsw, unit2minor(u), UID_UUCP, GID_DIALER, 0600, "tun%d", u); if (*dev != NULL) (*dev)->si_flags |= SI_CHEAPCLONE; } }
int mcd_attach(struct mcd_softc *sc) { int unit; unit = device_get_unit(sc->dev); MCD_LOCK(sc); sc->data.flags |= MCDINIT; mcd_soft_reset(sc); bioq_init(&sc->data.head); #ifdef NOTYET /* wire controller for interrupts and dma */ mcd_configure(sc); #endif MCD_UNLOCK(sc); /* name filled in probe */ sc->mcd_dev_t = make_dev(&mcd_cdevsw, 8 * unit, UID_ROOT, GID_OPERATOR, 0640, "mcd%d", unit); sc->mcd_dev_t->si_drv1 = (void *)sc; callout_init_mtx(&sc->timer, &sc->mtx, 0); return (0); }
int tpm_attach(device_t dev) { struct tpm_softc *sc = device_get_softc(dev); int irq; sc->mem_rid = 0; sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid, RF_ACTIVE); if (sc->mem_res == NULL) return ENXIO; sc->sc_bt = rman_get_bustag(sc->mem_res); sc->sc_bh = rman_get_bushandle(sc->mem_res); sc->irq_rid = 0; sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid, RF_ACTIVE | RF_SHAREABLE); if (sc->irq_res != NULL) irq = rman_get_start(sc->irq_res); else irq = IRQUNK; /* In case PnP probe this may contain some initialization. */ tpm_tis12_probe(sc->sc_bt, sc->sc_bh); if (tpm_legacy_probe(sc->sc_bt, sc->sc_bh)) { sc->sc_init = tpm_legacy_init; sc->sc_start = tpm_legacy_start; sc->sc_read = tpm_legacy_read; sc->sc_write = tpm_legacy_write; sc->sc_end = tpm_legacy_end; } else { sc->sc_init = tpm_tis12_init; sc->sc_start = tpm_tis12_start; sc->sc_read = tpm_tis12_read; sc->sc_write = tpm_tis12_write; sc->sc_end = tpm_tis12_end; } printf("%s", device_get_name(dev)); if ((sc->sc_init)(sc, irq, "tpm")) { tpm_detach(dev); return ENXIO; } if (sc->sc_init == tpm_tis12_init && sc->irq_res != NULL && bus_setup_intr(dev, sc->irq_res, INTR_TYPE_TTY, NULL, tpm_intr, sc, &sc->intr_cookie) != 0) { tpm_detach(dev); printf(": cannot establish interrupt\n"); return 1; } sc->sc_cdev = make_dev(&tpm_cdevsw, device_get_unit(dev), UID_ROOT, GID_WHEEL, 0600, "tpm"); sc->sc_cdev->si_drv1 = sc; return 0; }
static int xrpu_attach(device_t self) { struct softc *sc; struct resource *res; int rid, unit; unit = device_get_unit(self); sc = device_get_softc(self); sc->mode = NORMAL; rid = PCI_MAP_REG_START; res = bus_alloc_resource(self, SYS_RES_MEMORY, &rid, 0, ~0, 1, RF_ACTIVE); if (res == NULL) { device_printf(self, "Could not map memory\n"); return ENXIO; } sc->virbase = (vm_offset_t)rman_get_virtual(res); sc->physbase = rman_get_start(res); sc->virbase62 = (u_int *)(sc->virbase + 0x800000); if (bootverbose) printf("Mapped physbase %#lx to virbase %#lx\n", (u_long)sc->physbase, (u_long)sc->virbase); make_dev(&xrpu_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "xrpu%d", unit); return 0; }
int cheri_compositor_cfb_attach(struct cheri_compositor_softc *sc) { /* Set up the CFB metadata. */ LIST_INIT(&sc->cfbs); /* Set the current resolution (0 until we send a SetConfiguration * command to the hardware. */ sc->configuration.x_resolution = 0; sc->configuration.y_resolution = 0; /* Set up command processing. */ sc->seq_num = 0; /* Create the device node. */ sc->compositor_cfb_cdev = make_dev(&compositor_cfb_cdevsw, sc->compositor_unit, UID_ROOT, GID_WHEEL, 0444 /* world readable/writeable */, "compositor_cfb%d", sc->compositor_unit); if (sc->compositor_cfb_cdev == NULL) { CHERI_COMPOSITOR_ERROR(sc, "make_dev failed"); return (ENXIO); } /* XXXRW: Slight race between make_dev(9) and here. */ sc->compositor_cfb_cdev->si_drv1 = sc; return (0); }
/* * module handeling */ static int ata_module_event_handler(module_t mod, int what, void *arg) { static struct cdev *atacdev; switch (what) { case MOD_LOAD: /* register controlling device */ atacdev = make_dev(&ata_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0600, "ata"); if (cold) { /* register boot attach to be run when interrupts are enabled */ if (!(ata_delayed_attach = (struct intr_config_hook *) malloc(sizeof(struct intr_config_hook), M_TEMP, M_NOWAIT | M_ZERO))) { printf("ata: malloc of delayed attach hook failed\n"); return EIO; } ata_delayed_attach->ich_func = (void*)ata_boot_attach; if (config_intrhook_establish(ata_delayed_attach) != 0) { printf("ata: config_intrhook_establish failed\n"); free(ata_delayed_attach, M_TEMP); } } return 0; case MOD_UNLOAD: /* deregister controlling device */ destroy_dev(atacdev); return 0; default: return EOPNOTSUPP; } }
static int ipf_modload() { char *c, *str; int i, j, error; if (ipf_load_all() != 0) return EIO; if (ipf_fbsd_sysctl_create() != 0) { return EIO; } for (i = 0; i < IPL_LOGSIZE; i++) ipf_devs[i] = NULL; for (i = 0; (str = ipf_devfiles[i]); i++) { c = NULL; for(j = strlen(str); j > 0; j--) if (str[j] == '/') { c = str + j + 1; break; } if (!c) c = str; ipf_devs[i] = make_dev(&ipf_cdevsw, i, 0, 0, 0600, "%s", c); } error = ipf_pfil_hook(); if (error != 0) return error; ipf_event_reg(); return 0; }
static int snp_modevent(module_t mod, int type, void *data) { int i; lwkt_gettoken(&tty_token); switch (type) { case MOD_LOAD: snooplinedisc = ldisc_register(LDISC_LOAD, &snpdisc); make_autoclone_dev(&snp_ops, &DEVFS_CLONE_BITMAP(snp), snpclone, UID_ROOT, GID_WHEEL, 0600, "snp"); for (i = 0; i < SNP_PREALLOCATED_UNITS; i++) { make_dev(&snp_ops, i, UID_ROOT, GID_WHEEL, 0600, "snp%d", i); devfs_clone_bitmap_set(&DEVFS_CLONE_BITMAP(snp), i); } break; case MOD_UNLOAD: if (!LIST_EMPTY(&snp_sclist)) { lwkt_reltoken(&tty_token); return (EBUSY); } ldisc_deregister(snooplinedisc); devfs_clone_handler_del("snp"); dev_ops_remove_all(&snp_ops); devfs_clone_bitmap_uninit(&DEVFS_CLONE_BITMAP(snp)); break; default: break; } lwkt_reltoken(&tty_token); return (0); }
static int cdev_load(module_t mod, int cmd, void *arg) { int err = 0; switch (cmd) { case MOD_LOAD: /* Do any initialization that you should do with the kernel */ /* if we make it to here, print copyright on console*/ printf("\nSample Loaded kld character device driver\n"); printf("Copyright (c) 1998\n"); printf("Rajesh Vaidheeswarran\n"); printf("All rights reserved\n"); sdev = make_dev(&my_devsw, 0, UID_ROOT, GID_WHEEL, 0600, "cdev"); break; /* Success*/ case MOD_UNLOAD: printf("Unloaded kld character device driver\n"); destroy_dev(sdev); break; /* Success*/ default: /* we only understand load/unload*/ err = EOPNOTSUPP; break; } return(err); }
static int nsmb_dev_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { struct smb_dev *sdp; struct ucred *cred = td->td_ucred; int s; sdp = SMB_GETDEV(dev); if (sdp && (sdp->sd_flags & NSMBFL_OPEN)) return EBUSY; if (sdp == NULL) { sdp = malloc(sizeof(*sdp), M_NSMBDEV, M_WAITOK); dev->si_drv1 = (void*)sdp; } /* * XXX: this is just crazy - make a device for an already passed device... * someone should take care of it. */ if ((dev->si_flags & SI_NAMED) == 0) make_dev(&nsmb_cdevsw, dev2unit(dev), cred->cr_uid, cred->cr_gid, 0700, NSMB_NAME"%d", dev2unit(dev)); bzero(sdp, sizeof(*sdp)); /* STAILQ_INIT(&sdp->sd_rqlist); STAILQ_INIT(&sdp->sd_rplist); bzero(&sdp->sd_pollinfo, sizeof(struct selinfo)); */ s = splimp(); sdp->sd_level = -1; sdp->sd_flags |= NSMBFL_OPEN; splx(s); return 0; }
static void ctty_drvinit(void *unused) { EVENTHANDLER_REGISTER(dev_clone, ctty_clone, 0, 1000); ctty = make_dev(&ctty_cdevsw, 0, 0, 0, 0666, "ctty"); }
JNIEXPORT void JNICALL Java_makemachine_android_examples_Nati_greyscale(JNIEnv * env, jclass klass, jobject bitmap,jint wind){ void * raw; uint32_t * pixels; int ret,j; int grey; AndroidBitmapInfo info; if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) return; if ((ret = AndroidBitmap_lockPixels(env, bitmap, &raw)) < 0) return; pixels=(uint32_t*) raw; #define USE_CONTRAST STRETCH #ifdef USE_CONTRAST_STRETCH determine_contrast(&pixels,info.height,info.width); #else Qwe::mingrey=0; Qwe::maxgrey=255; #endif greyscale(&pixels,info.height,info.width); make_mean(info.height,info.width,wind); #ifdef USE_DEVIATION make_dev(info.height,info.width,wind); #endif imtoin(info.height,info.width); thresh(info.height,info.width); close(info.height,info.width,2); open(info.height,info.width,2); AndroidBitmap_unlockPixels(env, bitmap); }
/** * DEVFS event handler. */ static void VBoxDrvFreeBSDClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev) { int iUnit; int rc; Log(("VBoxDrvFreeBSDClone: pszName=%s ppDev=%p\n", pszName, ppDev)); /* * One device node per user, si_drv1 points to the session. * /dev/vboxdrv<N> where N = {0...255}. */ if (!ppDev) return; if (dev_stdclone(pszName, NULL, "vboxdrv", &iUnit) != 1) return; if (iUnit >= 256 || iUnit < 0) { Log(("VBoxDrvFreeBSDClone: iUnit=%d >= 256 - rejected\n", iUnit)); return; } Log(("VBoxDrvFreeBSDClone: pszName=%s iUnit=%d\n", pszName, iUnit)); rc = clone_create(&g_pVBoxDrvFreeBSDClones, &g_VBoxDrvFreeBSDChrDevSW, &iUnit, ppDev, 0); Log(("VBoxDrvFreeBSDClone: clone_create -> %d; iUnit=%d\n", rc, iUnit)); if (rc) { #if __FreeBSD_version > 800061 *ppDev = make_dev(&g_VBoxDrvFreeBSDChrDevSW, iUnit, UID_ROOT, GID_WHEEL, VBOXDRV_PERM, "vboxdrv%d", iUnit); #else *ppDev = make_dev(&g_VBoxDrvFreeBSDChrDevSW, unit2minor(iUnit), UID_ROOT, GID_WHEEL, VBOXDRV_PERM, "vboxdrv%d", iUnit); #endif if (*ppDev) { dev_ref(*ppDev); (*ppDev)->si_flags |= SI_CHEAPCLONE; Log(("VBoxDrvFreeBSDClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n", *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2)); (*ppDev)->si_drv1 = (*ppDev)->si_drv2 = NULL; } else OSDBGPRINT(("VBoxDrvFreeBSDClone: make_dev iUnit=%d failed\n", iUnit)); } else Log(("VBoxDrvFreeBSDClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n", *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2)); }
int proto_attach(device_t dev) { struct proto_softc *sc; struct proto_res *r; u_int res; sc = device_get_softc(dev); sc->sc_dev = dev; for (res = 0; res < sc->sc_rescnt; res++) { r = sc->sc_res + res; switch (r->r_type) { case SYS_RES_IRQ: /* XXX TODO */ break; case SYS_RES_DRQ: break; case SYS_RES_MEMORY: case SYS_RES_IOPORT: r->r_size = rman_get_size(r->r_d.res); r->r_u.cdev = make_dev(&proto_devsw, res, 0, 0, 0666, "proto/%s/%02x.%s", device_get_desc(dev), r->r_rid, (r->r_type == SYS_RES_IOPORT) ? "io" : "mem"); r->r_u.cdev->si_drv1 = sc; r->r_u.cdev->si_drv2 = r; break; case PROTO_RES_PCICFG: r->r_size = 4096; r->r_u.cdev = make_dev(&proto_devsw, res, 0, 0, 0666, "proto/%s/pcicfg", device_get_desc(dev)); r->r_u.cdev->si_drv1 = sc; r->r_u.cdev->si_drv2 = r; break; case PROTO_RES_BUSDMA: r->r_d.busdma = proto_busdma_attach(sc); r->r_size = 0; /* no read(2) nor write(2) */ r->r_u.cdev = make_dev(&proto_devsw, res, 0, 0, 0666, "proto/%s/busdma", device_get_desc(dev)); r->r_u.cdev->si_drv1 = sc; r->r_u.cdev->si_drv2 = r; break; } } return (0); }
static void audit_trigger_cdev_init(void *unused) { /* Create the special device file. */ audit_dev = make_dev(&audit_cdevsw, 0, UID_ROOT, GID_KMEM, 0600, AUDITDEV_FILENAME); }
/* * Given a controller number, * make a special device and return the dev_t */ dev_t gdt_make_dev(int unit) { dev_t dev; #ifdef SDEV_PER_HBA dev = make_dev(&iir_cdevsw, hba2minor(unit), UID_ROOT, GID_OPERATOR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, "iir%d", unit); #else if (sdev_made) return (0); dev = make_dev(&iir_cdevsw, 0, UID_ROOT, GID_OPERATOR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, "iir"); sdev_made = 1; #endif return (dev); }
static void log_drvinit(void *unused) { cv_init(&log_wakeup, "klog"); callout_init_mtx(&logsoftc.sc_callout, &msgbuf_lock, 0); make_dev(&log_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "klog"); }
static void dm_doinit(void) { dm_target_init(); dm_dev_init(); dm_pdev_init(); dmcdev = make_dev(&dm_ops, 0, UID_ROOT, GID_OPERATOR, 0640, "mapper/control"); }
static void consolectl_drvinit(void *unused) { if (!vty_enabled(VTY_VT)) return; make_dev(&consolectl_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "consolectl"); }