コード例 #1
0
static int
dcons_attach(void)
{
	int polltime;

	dcons_attach_port(DCONS_CON, "dcons", 0);
	dcons_attach_port(DCONS_GDB, "dgdb", DC_GDB);
	callout_init(&dcons_callout, CALLOUT_MPSAFE);
	polltime = hz / poll_hz;
	if (polltime < 1)
		polltime = 1;
	callout_reset(&dcons_callout, polltime, dcons_timeout, NULL);
	return(0);
}
コード例 #2
0
struct ath_ratectrl *
ath_rate_attach(struct ath_softc *sc)
{
	struct amrr_softc *asc;

	asc = malloc(sizeof(struct amrr_softc), M_DEVBUF, M_NOWAIT|M_ZERO);
	if (asc == NULL)
		return NULL;
	asc->arc.arc_space = sizeof(struct amrr_node);
	callout_init(&asc->timer, debug_mpsafenet ? CALLOUT_MPSAFE : 0);
	ath_rate_sysctlattach(sc);

	return &asc->arc;
}
コード例 #3
0
ファイル: ntb_hw.c プロジェクト: Alkzndr/freebsd
static int
ntb_attach(device_t device)
{
	struct ntb_softc *ntb = DEVICE2SOFTC(device);
	struct ntb_hw_info *p = ntb_get_device_info(pci_get_devid(device));
	int error;

	ntb->device = device;
	ntb->type = p->type;
	ntb->features = p->features;

	/* Heartbeat timer for NTB_SOC since there is no link interrupt */
	callout_init(&ntb->heartbeat_timer, CALLOUT_MPSAFE);
	callout_init(&ntb->lr_timer, CALLOUT_MPSAFE);

	DETACH_ON_ERROR(ntb_map_pci_bars(ntb));
	DETACH_ON_ERROR(ntb_initialize_hw(ntb));
	DETACH_ON_ERROR(ntb_setup_interrupts(ntb));

	pci_enable_busmaster(ntb->device);

	return (error);
}
コード例 #4
0
struct ath_ratectrl *
ath_rate_attach(struct ath_softc *sc)
{
	struct onoe_softc *osc;

	osc = malloc(sizeof(struct onoe_softc), M_DEVBUF, M_NOWAIT|M_ZERO);
	if (osc == NULL)
		return NULL;
	osc->arc.arc_space = sizeof(struct onoe_node);
	callout_init(&osc->timer, 0);
	ath_rate_sysctlattach(sc);

	return &osc->arc;
}
コード例 #5
0
ファイル: hpcfb.c プロジェクト: MarginC/kame
void
hpcfbattach(struct device *parent, struct device *self, void *aux)
{
	struct hpcfb_softc *sc = (struct hpcfb_softc *)self;
	struct hpcfb_attach_args *ha = aux;
	struct wsemuldisplaydev_attach_args wa;

	sc->sc_accessops = ha->ha_accessops;
	sc->sc_accessctx = ha->ha_accessctx;
	sc->sc_nfbconf = ha->ha_nfbconf;
	sc->sc_fbconflist = ha->ha_fbconflist;

	if (hpcfbconsole) {
		sc->sc_dc = &hpcfb_console_dc;
		hpcfb_console_dc.dc_sc = sc;
		printf(": %dx%d pixels, %d colors, %dx%d chars",
		    sc->sc_dc->dc_rinfo.ri_width,sc->sc_dc->dc_rinfo.ri_height,
		    pow(2, sc->sc_dc->dc_rinfo.ri_depth),
		    sc->sc_dc->dc_rinfo.ri_cols,sc->sc_dc->dc_rinfo.ri_rows);
		/* Set video chip dependent CLUT if any. */
		if (sc->sc_accessops->setclut)
			sc->sc_accessops->setclut(sc->sc_accessctx, 
			    &hpcfb_console_dc.dc_rinfo);
	}
	printf("\n");

	sc->sc_polling = 0; /* XXX */
	sc->sc_mapping = 0; /* XXX */
	callout_init(&sc->sc_switch_callout);

	/* Add a power hook to power management */
	sc->sc_powerhook = powerhook_establish(hpcfb_power, sc);
	if (sc->sc_powerhook == NULL)
		printf("%s: WARNING: unable to establish power hook\n",
		    sc->sc_dev.dv_xname);

	wa.console = hpcfbconsole;
	wa.scrdata = &hpcfb_screenlist;
	wa.accessops = &hpcfb_accessops;
	wa.accesscookie = sc;

	sc->sc_wsdisplay = config_found(self, &wa, wsemuldisplaydevprint);

#ifdef HPCFB_JUMP
	/*
	 * Create a kernel thread to scroll,
	 */
	kthread_create(hpcfb_create_thread, sc);
#endif /* HPCFB_JUMP */
}
コード例 #6
0
ファイル: atkbd.c プロジェクト: FreeBSDFoundation/freebsd
int
atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags)
{
	keyboard_switch_t *sw;
	atkbd_state_t *state;
	int args[2];
	int error;
	int unit;

	sw = kbd_get_switch(ATKBD_DRIVER_NAME);
	if (sw == NULL)
		return ENXIO;

	/* reset, initialize and enable the device */
	unit = device_get_unit(dev);
	args[0] = device_get_unit(device_get_parent(dev));
	args[1] = irq;
	*kbd = NULL;
	error = (*sw->probe)(unit, args, flags);
	if (error)
		return error;
	error = (*sw->init)(unit, kbd, args, flags);
	if (error)
		return error;
	(*sw->enable)(*kbd);

#ifdef KBD_INSTALL_CDEV
	/* attach a virtual keyboard cdev */
	error = kbd_attach(*kbd);
	if (error)
		return error;
#endif

	/*
	 * This is a kludge to compensate for lost keyboard interrupts.
	 * A similar code used to be in syscons. See below. XXX
	 */
	state = (atkbd_state_t *)(*kbd)->kb_data;
	callout_init(&state->ks_timer, 0);
	atkbd_timeout(*kbd);

	if (bootverbose)
		(*sw->diag)(*kbd, bootverbose);

	EVENTHANDLER_REGISTER(shutdown_final, atkbd_shutdown_final, *kbd,
	    SHUTDOWN_PRI_DEFAULT);

	return 0;
}
コード例 #7
0
/*ARGSUSED*/
static	int
logopen(struct dev_open_args *ap)
{
	struct proc *p = curproc;

	KKASSERT(p != NULL);
	if (log_open)
		return (EBUSY);
	log_open = 1;
	callout_init(&logsoftc.sc_callout);
	fsetown(p->p_pid, &logsoftc.sc_sigio);	/* signal process only */
	callout_reset(&logsoftc.sc_callout, hz / log_wakeups_per_second,
	    logtimeout, NULL);
	return (0);
}
コード例 #8
0
/*
 * Called once to initialize data structures...
 */
static int
nfscommon_modevent(module_t mod, int type, void *data)
{
	int error = 0;
	static int loaded = 0;

	switch (type) {
	case MOD_LOAD:
		if (loaded)
			return (0);
		newnfs_portinit();
		mtx_init(&nfs_nameid_mutex, "nfs_nameid_mutex", NULL, MTX_DEF);
		mtx_init(&nfs_sockl_mutex, "nfs_sockl_mutex", NULL, MTX_DEF);
		mtx_init(&nfs_slock_mutex, "nfs_slock_mutex", NULL, MTX_DEF);
		mtx_init(&nfs_req_mutex, "nfs_req_mutex", NULL, MTX_DEF);
		mtx_init(&nfsrv_nfsuserdsock.nr_mtx, "nfsuserd", NULL,
		    MTX_DEF);
		callout_init(&newnfsd_callout, CALLOUT_MPSAFE);
		newnfs_init();
		nfsd_call_nfscommon = nfssvc_nfscommon;
		loaded = 1;
		break;

	case MOD_UNLOAD:
		if (newnfs_numnfsd != 0 || nfsrv_nfsuserd != 0 ||
		    nfs_numnfscbd != 0) {
			error = EBUSY;
			break;
		}

		nfsd_call_nfscommon = NULL;
		callout_drain(&newnfsd_callout);
		/* and get rid of the mutexes */
		mtx_destroy(&nfs_nameid_mutex);
		mtx_destroy(&newnfsd_mtx);
		mtx_destroy(&nfs_state_mutex);
		mtx_destroy(&nfs_sockl_mutex);
		mtx_destroy(&nfs_slock_mutex);
		mtx_destroy(&nfs_req_mutex);
		mtx_destroy(&nfsrv_nfsuserdsock.nr_mtx);
		loaded = 0;
		break;
	default:
		error = EOPNOTSUPP;
		break;
	}
	return error;
}
コード例 #9
0
ファイル: tc5165buf.c プロジェクト: lacombar/netbsd-alc
void
tc5165buf_attach(struct device *parent, struct device *self, void *aux)
{
	struct cs_attach_args *ca = aux;
	struct tc5165buf_softc *sc = (void*)self;
	struct hpckbd_attach_args haa;

	printf(": ");
	sc->sc_tc = ca->ca_tc;
	sc->sc_chip = &tc5165buf_chip;

	callout_init(&sc->sc_chip->scc_soft_ch, 0);

	sc->sc_chip->scc_cst = ca->ca_csio.cstag;

	if (bus_space_map(sc->sc_chip->scc_cst, ca->ca_csio.csbase, 
	    ca->ca_csio.cssize, 0, &sc->sc_chip->scc_csh)) {
		printf("can't map i/o space\n");
		return;
	}

	sc->sc_chip->scc_enabled = 0;

	if (ca->ca_irq1 != -1) {
		sc->sc_ih = tx_intr_establish(sc->sc_tc, ca->ca_irq1,
		    IST_EDGE, IPL_TTY, 
		    tc5165buf_intr, sc);
		printf("interrupt mode");
	} else {
		sc->sc_ih = tx39_poll_establish(sc->sc_tc, 1, IPL_TTY, 
		    tc5165buf_intr, sc);
		printf("polling mode");
	}

	if (!sc->sc_ih) {
		printf(" can't establish interrupt\n");
		return;
	}

	printf("\n");

	/* setup upper interface */
	tc5165buf_ifsetup(sc->sc_chip);
	
	haa.haa_ic = &sc->sc_chip->scc_if;

	config_found(self, &haa, hpckbd_print);
}
コード例 #10
0
/*
 * kern_timeout_callwheel_init() - initialize previously reserved callwheel
 *				   space.
 *
 *	This code is called just once, after the space reserved for the
 *	callout wheel has been finalized.
 */
void
kern_timeout_callwheel_init(void)
{
	int i;

	SLIST_INIT(&callfree);
	for (i = 0; i < ncallout; i++) {
		callout_init(&callout[i], 0);
		callout[i].c_flags = CALLOUT_LOCAL_ALLOC;
		SLIST_INSERT_HEAD(&callfree, &callout[i], c_links.sle);
	}
	for (i = 0; i < callwheelsize; i++) {
		TAILQ_INIT(&callwheel[i]);
	}
	mtx_init(&callout_lock, "callout", NULL, MTX_SPIN | MTX_RECURSE);
}
コード例 #11
0
int
vcons_init(struct vcons_data *vd, void *cookie, struct wsscreen_descr *def,
    struct wsdisplay_accessops *ao)
{

	/* zero out everything so we can rely on untouched fields being 0 */
	memset(vd, 0, sizeof(struct vcons_data));
	
	vd->cookie = cookie;

	vd->init_screen = vcons_dummy_init_screen;
	vd->show_screen_cb = NULL;

	/* keep a copy of the accessops that we replace below with our
	 * own wrappers */
	vd->ioctl = ao->ioctl;

	/* configure the accessops */
	ao->ioctl = vcons_ioctl;
	ao->alloc_screen = vcons_alloc_screen;
	ao->free_screen = vcons_free_screen;
	ao->show_screen = vcons_show_screen;
#ifdef WSDISPLAY_SCROLLSUPPORT
	ao->scroll = vcons_scroll;
#endif

	LIST_INIT(&vd->screens);
	vd->active = NULL;
	vd->wanted = NULL;
	vd->currenttype = def;
	callout_init(&vd->switch_callout, 0);
	callout_setfunc(&vd->switch_callout, vcons_do_switch, vd);

	/*
	 * a lock to serialize access to the framebuffer.
	 * when switching screens we need to make sure there's no rasops
	 * operation in progress
	 */
#ifdef DIAGNOSTIC
	vd->switch_poll_count = 0;
#endif
#ifdef VCONS_SWITCH_ASYNC
	kthread_create(PRI_NONE, 0, NULL, vcons_kthread, vd,
	    &vd->redraw_thread, "vcons_draw");
#endif
	return 0;
}
コード例 #12
0
ファイル: iw_cxgb_cm.c プロジェクト: cyrilmagsuci/freebsd
static void
start_ep_timer(struct iwch_ep *ep)
{
	CTR2(KTR_IW_CXGB, "%s ep %p", __FUNCTION__, ep);
	if (callout_pending(&ep->timer)) {
		CTR2(KTR_IW_CXGB, "%s stopped / restarted timer ep %p", __FUNCTION__, ep);
		callout_deactivate(&ep->timer);
		callout_drain(&ep->timer);
	} else {
		/*
		 * XXX this looks racy
		 */
		get_ep(&ep->com);
		callout_init(&ep->timer, 1);
	}
	callout_reset(&ep->timer, ep_timeout_secs * hz, ep_timeout, ep);
}
コード例 #13
0
ファイル: pckbd.c プロジェクト: 2asoft/freebsd
static int
pckbd_attach_unit(device_t dev, keyboard_t **kbd, int port, int irq, int flags)
{
	keyboard_switch_t *sw;
	pckbd_state_t *state;
	int args[2];
	int error;
	int unit;

	sw = kbd_get_switch(DRIVER_NAME);
	if (sw == NULL)
		return ENXIO;

	/* reset, initialize and enable the device */
	unit = device_get_unit(dev);
	args[0] = port;
	args[1] = irq;
	*kbd = NULL;
	error = (*sw->probe)(unit, args, flags);
	if (error)
		return error;
	error = (*sw->init)(unit, kbd, args, flags);
	if (error)
		return error;
	(*sw->enable)(*kbd);

#ifdef KBD_INSTALL_CDEV
	/* attach a virtual keyboard cdev */
	error = kbd_attach(*kbd);
	if (error)
		return error;
#endif /* KBD_INSTALL_CDEV */

	/*
	 * This is a kludge to compensate for lost keyboard interrupts.
	 * A similar code used to be in syscons. See below. XXX
	 */
	state = (pckbd_state_t *)(*kbd)->kb_data;
	callout_init(&state->ks_timer, 0);
	pckbd_timeout(*kbd);

	if (bootverbose)
		(*sw->diag)(*kbd, bootverbose);

	return 0;
}
コード例 #14
0
ファイル: acpi_tz.c プロジェクト: MarginC/kame
/*
 * acpitz_attach: autoconf(9) attach routine
 */
void
acpitz_attach(struct device *parent, struct device *self, void *aux)
{
	struct acpitz_softc *sc = (struct acpitz_softc *)self;
	struct acpi_attach_args *aa = aux;
	ACPI_STATUS rv;
	ACPI_INTEGER v;

#if 0
	sc->sc_flags = ATZ_F_VERBOSE;
#endif
	sc->sc_devnode = aa->aa_node;

	printf(": ACPI Thermal Zone\n");

	rv = acpi_eval_integer(sc->sc_devnode->ad_handle, "_TZP", &v);
	if (ACPI_FAILURE(rv)) {
		printf("%s: unable to get polling interval; using default of",
		    sc->sc_dev.dv_xname);
		sc->sc_zone.tzp = ATZ_TZP_RATE;
	} else {
		sc->sc_zone.tzp = v;
		printf("%s: polling interval is", sc->sc_dev.dv_xname);
	}
	printf(" %d.%ds\n", sc->sc_zone.tzp / 10, sc->sc_zone.tsp % 10);

	/* XXX a value of 0 means "polling is not necessary" */
	if (sc->sc_zone.tzp == 0)
		sc->sc_zone.tzp = ATZ_TZP_RATE;
	
	acpitz_get_status(sc);

	rv = AcpiInstallNotifyHandler(sc->sc_devnode->ad_handle,
	    ACPI_SYSTEM_NOTIFY, acpitz_notify_handler, sc);
	if (ACPI_FAILURE(rv)) {
		printf("%s: unable to install SYSTEM NOTIFY handler: %s\n",
		    sc->sc_dev.dv_xname, AcpiFormatException(rv));
		return;
	}

	callout_init(&sc->sc_callout);
	callout_reset(&sc->sc_callout, (sc->sc_zone.tzp / 10) * hz,
	    acpitz_tick, sc);

	acpitz_init_envsys(sc);
}
コード例 #15
0
void
sstouch_attach(device_t parent, device_t self, void *aux)
{
	struct sstouch_softc		*sc = device_private(self);
	struct s3c2xx0_attach_args	*sa = aux;
	struct wsmousedev_attach_args	mas;

	sc->dev = self;
	sc->iot = sa->sa_iot;

	if (bus_space_map(sc->iot, S3C2440_ADC_BASE,
			  S3C2440_ADC_SIZE, 0, &sc->ioh)) {
		aprint_error(": failed to map registers");
		return;
	}

	sc->next_stylus_intr = STYLUS_DOWN;


	/* XXX: Is IPL correct? */
	s3c24x0_intr_establish(S3C2440_INT_TC, IPL_BIO, IST_EDGE_RISING,
			       sstouch_tc_intr, sc);
	s3c24x0_intr_establish(S3C2440_INT_ADC, IPL_BIO, IST_EDGE_RISING,
			       sstouch_adc_intr, sc);

	aprint_normal("\n");

	mas.accessops = &sstouch_accessops;
	mas.accesscookie = sc;

	sc->wsmousedev = config_found_ia(self, "wsmousedev", &mas,
					 wsmousedevprint);

	tpcalib_init(&sc->tpcalib);
	tpcalib_ioctl(&sc->tpcalib, WSMOUSEIO_SCALIBCOORDS,
		      (void*)&default_calib, 0, 0);

	sc->sample_count = 0;

	/* Add CALLOUT_MPSAFE to avoid holding the global kernel lock */
	callout_init(&sc->callout, 0);
	callout_setfunc(&sc->callout, sstouch_callout, sc);

	/* Actual initialization is performed by sstouch_initialize(),
	   which is called by sstouch_enable() */
}
コード例 #16
0
ファイル: mpcsa_leds.c プロジェクト: lacombar/netbsd-alc
static void
mpcsa_leds_attach(device_t parent, device_t self, void *aux)
{
	struct mpcsa_leds_softc *sc = device_private(self);
	struct spi_attach_args *sa = aux;
#if NGPIO > 0
	struct gpiobus_attach_args gba;
#endif
	int n;

	aprint_naive(": output buffer\n");
	aprint_normal(": 74HC595 or compatible shift register(s)\n");

	sc->sc_sh = sa->sa_handle;
	sc->sc_pinstate = 0xffff;
	callout_init(&sc->sc_c, 0);

#if NGPIO > 0
	/* initialize and attach gpio(4) */
	for (n = 0; n < MPCSA_LEDS_NPINS; n++) {
		sc->sc_pins[n].pin_num = n;
		sc->sc_pins[n].pin_caps = (GPIO_PIN_OUTPUT
					   | GPIO_PIN_PUSHPULL);
		sc->sc_pins[n].pin_flags = GPIO_PIN_OUTPUT | GPIO_PIN_LOW;
	}

	sc->sc_gpio_chipset.gp_cookie = sc;
	sc->sc_gpio_chipset.gp_pin_read = mpcsa_leds_pin_read;
	sc->sc_gpio_chipset.gp_pin_write = mpcsa_leds_pin_write;
	sc->sc_gpio_chipset.gp_pin_ctl = mpcsa_leds_pin_ctl;
	gba.gba_gc = &sc->sc_gpio_chipset;
	gba.gba_pins = sc->sc_pins;
	gba.gba_npins = MPCSA_LEDS_NPINS;
	config_found_ia(self, "gpiobus", &gba, mpcsa_ledsbus_print);
#endif

	/* attach device */
//	config_search_ia(mpcsa_leds_search, self, "mpcsa_leds", mpcsa_leds_print);

	/* update leds ten times a second or so */
	mpcsa_leds_sc = sc; // @@@@
	sc->sc_spi_transfer.st_flags = SPI_F_DONE;
	callout_reset(&sc->sc_c, mstohz(LEDS_UPDATE_INTERVAL), mpcsa_leds_timer, sc);

	mpcsa_blink_led(LED_HB, 500);
}
コード例 #17
0
static void
rdattach(device_t parent, device_t self, void *aux)
{
	struct rd_softc *sc = device_private(self);
	struct hpibbus_attach_args *ha = aux;

	sc->sc_dev = self;
	bufq_alloc(&sc->sc_tab, "disksort", BUFQ_SORT_RAWBLOCK);

	if (rdident(parent, sc, ha) == 0) {
		aprint_error(": didn't respond to describe command!\n");
		return;
	}

	/*
	 * Initialize and attach the disk structure.
	 */
	memset(&sc->sc_dkdev, 0, sizeof(sc->sc_dkdev));
	disk_init(&sc->sc_dkdev, device_xname(sc->sc_dev), NULL);
	disk_attach(&sc->sc_dkdev);

	sc->sc_slave = ha->ha_slave;
	sc->sc_punit = ha->ha_punit;

	callout_init(&sc->sc_restart_ch, 0);

	/* Initialize the hpib job queue entry */
	sc->sc_hq.hq_softc = sc;
	sc->sc_hq.hq_slave = sc->sc_slave;
	sc->sc_hq.hq_start = rdstart;
	sc->sc_hq.hq_go = rdgo;
	sc->sc_hq.hq_intr = rdintr;

	sc->sc_flags = RDF_ALIVE;
#ifdef DEBUG
	/* always report errors */
	if (rddebug & RDB_ERROR)
		rderrthresh = 0;
#endif
	/*
	 * attach the device into the random source list
	 */
	rnd_attach_source(&sc->rnd_source, device_xname(sc->sc_dev),
	    RND_TYPE_DISK, RND_FLAG_DEFAULT);
}
コード例 #18
0
ファイル: lpt.c プロジェクト: eyberg/rumpkernel-netbsd-src
void
lpt_attach_subr(struct lpt_softc *sc)
{
	bus_space_tag_t iot;
	bus_space_handle_t ioh;

	sc->sc_state = 0;

	iot = sc->sc_iot;
	ioh = sc->sc_ioh;

	bus_space_write_1(iot, ioh, lpt_control, LPC_NINIT);

	callout_init(&sc->sc_wakeup_ch, 0);
	sc->sc_sih = softint_establish(SOFTINT_SERIAL, lptsoftintr, sc);

	sc->sc_dev_ok = 1;
}
コード例 #19
0
ファイル: ata.c プロジェクト: goroutines/rumprun
/*
 * ata_channel_attach:
 *
 *	Common parts of attaching an atabus to an ATA controller channel.
 */
void
ata_channel_attach(struct ata_channel *chp)
{

	if (chp->ch_flags & ATACH_DISABLED)
		return;

	/* XXX callout_destroy */
	callout_init(&chp->ch_callout, 0);

	TAILQ_INIT(&chp->ch_queue->queue_xfer);
	chp->ch_queue->queue_freeze = 0;
	chp->ch_queue->queue_flags = 0;
	chp->ch_queue->active_xfer = NULL;

	chp->atabus = config_found_ia(chp->ch_atac->atac_dev, "ata", chp,
		atabusprint);
}
コード例 #20
0
ファイル: ieee80211_hwmp.c プロジェクト: edgar-pek/PerspicuOS
void
hwmp_vattach(struct ieee80211vap *vap)
{
	struct ieee80211_hwmp_state *hs;

	KASSERT(vap->iv_opmode == IEEE80211_M_MBSS,
	    ("not a mesh vap, opmode %d", vap->iv_opmode));

	hs = malloc(sizeof(struct ieee80211_hwmp_state), M_80211_VAP,
	    M_NOWAIT | M_ZERO);
	if (hs == NULL) {
		printf("%s: couldn't alloc HWMP state\n", __func__);
		return;
	}
	hs->hs_maxhops = IEEE80211_HWMP_DEFAULT_MAXHOPS;
	callout_init(&hs->hs_roottimer, CALLOUT_MPSAFE);
	vap->iv_hwmp = hs;
}
コード例 #21
0
ファイル: mambo_console.c プロジェクト: edgar-pek/PerspicuOS
static void
cn_drvinit(void *unused)
{

	if (mambo_consdev.cn_pri != CN_DEAD &&
	    mambo_consdev.cn_name[0] != '\0') {
		if (OF_finddevice("/mambo") == -1)
			return;

		tp = tty_alloc(&mambo_ttydevsw, NULL);
		tty_init_console(tp, 0);
		tty_makedev(tp, NULL, "%s", "mambocons");

		polltime = 1;

		callout_init(&mambo_callout, CALLOUT_MPSAFE);
		callout_reset(&mambo_callout, polltime, mambo_timeout, NULL);
	}
}
コード例 #22
0
ファイル: btn_obio.c プロジェクト: lacombar/netbsd-alc
static void
btn_obio_attach(device_t parent, device_t self, void *aux)
{
	struct btn_obio_softc *sc;
	int i;

	aprint_naive("\n");
	aprint_normal(": USL-5P buttons\n");

	sc = device_private(self);
	sc->sc_dev = self;

	btn_softc = sc;

	callout_init(&sc->sc_guard_ch, 0);
	callout_setfunc(&sc->sc_guard_ch, btn_guard_timeout, sc);

	sc->sc_ih = extintr_establish(LANDISK_INTR_BTN, IPL_TTY, btn_intr, sc);
	if (sc->sc_ih == NULL) {
		aprint_error_dev(self, "unable to establish interrupt");
		panic("extintr_establish");
	}

	sc->sc_smpsw.smpsw_name = device_xname(self);
	sc->sc_smpsw.smpsw_type = PSWITCH_TYPE_RESET;
	if (sysmon_pswitch_register(&sc->sc_smpsw) != 0) {
		aprint_error_dev(self, "unable to register with sysmon\n");
		return;
	}
	sc->sc_mask |= BTN_RESET_BIT;

	for (i = 0; i < NBUTTON; i++) {
		int idx = btnlist[i].idx;
		sc->sc_bev[idx].bev_name = btnlist[i].name;
		if (btn_event_register(&sc->sc_bev[idx]) != 0) {
			aprint_error_dev(self,
					 "unable to register '%s' button\n",
					 btnlist[i].name);
		} else {
			sc->sc_mask |= btnlist[i].mask;
		}
	}
}
コード例 #23
0
ファイル: ss.c プロジェクト: Tommmster/netbsd-avr32
/*
 * The routine called by the low level scsi routine when it discovers
 * A device suitable for this driver
 * If it is a know special, call special attach routine to install
 * special handlers into the ss_softc structure
 */
static void
ssattach(struct device *parent, struct device *self, void *aux)
{
	struct ss_softc *ss = device_private(self);
	struct scsipibus_attach_args *sa = aux;
	struct scsipi_periph *periph = sa->sa_periph;

	SC_DEBUG(periph, SCSIPI_DB2, ("ssattach: "));

	ss->flags |= SSF_AUTOCONF;

	/*
	 * Store information needed to contact our base driver
	 */
	ss->sc_periph = periph;
	periph->periph_dev = &ss->sc_dev;
	periph->periph_switch = &ss_switch;

	printf("\n");

	/*
	 * Set up the buf queue for this device
	 */
	bufq_alloc(&ss->buf_queue, "fcfs", 0);

	callout_init(&ss->sc_callout, 0);

	/*
	 * look for non-standard scanners with help of the quirk table
	 * and install functions for special handling
	 */
	SC_DEBUG(periph, SCSIPI_DB2, ("ssattach:\n"));
	if (memcmp(sa->sa_inqbuf.vendor, "MUSTEK", 6) == 0)
		mustek_attach(ss, sa);
	if (memcmp(sa->sa_inqbuf.vendor, "HP      ", 8) == 0 &&
	    memcmp(sa->sa_inqbuf.product, "ScanJet 5300C", 13) != 0)
		scanjet_attach(ss, sa);
	if (ss->special == NULL) {
		/* XXX add code to restart a SCSI2 scanner, if any */
	}

	ss->flags &= ~SSF_AUTOCONF;
}
コード例 #24
0
ファイル: in_rmx.c プロジェクト: HariKishan8/Networks
/*
 * Initialize our routing tree.
 */
int
in_inithead(void **head, int off)
{
	struct radix_node_head *rnh;

	if (!rn_inithead(head, off))
		return 0;

	if (head != (void **)&rt_tables[AF_INET])	/* BOGUS! */
		return 1;	/* only do this for the real routing table */

	rnh = *head;
	rnh->rnh_addaddr = in_addroute;
	rnh->rnh_matchaddr = in_matroute;
	rnh->rnh_close = in_clsroute;
	callout_init(&rtq_timer, CALLOUT_MPSAFE);
	in_rtqtimo(rnh);	/* kick off timeout first time */
	return 1;
}
コード例 #25
0
ファイル: ofnet.c プロジェクト: Tommmster/netbsd-avr32
static void
ofnet_attach(struct device *parent, struct device *self, void *aux)
{
	struct ofnet_softc *of = device_private(self);
	struct ifnet *ifp = &of->sc_ethercom.ec_if;
	struct ofbus_attach_args *oba = aux;
	char path[256];
	int l;
	u_int8_t myaddr[ETHER_ADDR_LEN];

	of->sc_phandle = oba->oba_phandle;
#if NIPKDB_OFN > 0
	if (kifp &&
	    kifp->unit - 1 == device_unit(&of->sc_dev) &&
	    OF_instance_to_package(kifp->port) == oba->oba_phandle)  {
		ipkdb_of = of;
		of->sc_ihandle = kifp->port;
	} else
#endif
	if ((l = OF_package_to_path(oba->oba_phandle, path,
	    sizeof path - 1)) < 0 ||
	    l >= sizeof path ||
	    (path[l] = 0, !(of->sc_ihandle = OF_open(path))))
		panic("ofnet_attach: unable to open");
	if (OF_getprop(oba->oba_phandle, "mac-address", myaddr,
	    sizeof myaddr) < 0)
		panic("ofnet_attach: no mac-address");
	printf(": address %s\n", ether_sprintf(myaddr));

	callout_init(&of->sc_callout, 0);

	strlcpy(ifp->if_xname, device_xname(&of->sc_dev), IFNAMSIZ);
	ifp->if_softc = of;
	ifp->if_start = ofnet_start;
	ifp->if_ioctl = ofnet_ioctl;
	ifp->if_watchdog = ofnet_watchdog;
	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS;
	IFQ_SET_READY(&ifp->if_snd);

	if_attach(ifp);
	ether_ifattach(ifp, myaddr);
}
コード例 #26
0
isdnbchanattach(void)
#endif
{
	int i;

	rbch_driver_id = isdn_l4_driver_attach("isdnbchan", NISDNBCHAN, &rbch_driver_functions);

	for(i=0; i < NISDNBCHAN; i++)
	{
#if defined(__FreeBSD__)
#if __FreeBSD__ == 3

#ifdef DEVFS
		rbch_softc[i].devfs_token =
			devfs_add_devswf(&isdnbchan_cdevsw, i, DV_CHR,
				     UID_ROOT, GID_WHEEL, 0600,
				     "isdnbchan%d", i);
#endif

#else
		make_dev(&isdnbchan_cdevsw, i,
			UID_ROOT, GID_WHEEL, 0600, "isdnbchan%d", i);
#endif
#endif

#if I4BRBCHACCT
#if defined(__FreeBSD__)
		callout_handle_init(&rbch_softc[i].sc_callout);
#endif
#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
		callout_init(&rbch_softc[i].sc_callout, 0);
		selinit(&rbch_softc[i].selp);
#endif
		rbch_softc[i].sc_fn = 1;
#endif
		rbch_softc[i].sc_unit = i;
		rbch_softc[i].sc_devstate = ST_IDLE;
		rbch_softc[i].sc_hdlcq.ifq_maxlen = I4BRBCHMAXQLEN;
		rbch_softc[i].it_in.c_ispeed = rbch_softc[i].it_in.c_ospeed = 64000;
		termioschars(&rbch_softc[i].it_in);
	}
}
コード例 #27
0
ファイル: boca.c プロジェクト: lacombar/netbsd-alc
void
bocaattach(struct device *parent, struct device *self, void *aux)
{
    struct boca_softc *sc = (void *)self;
    struct isa_attach_args *ia = aux;
    struct commulti_attach_args ca;
    bus_space_tag_t iot = ia->ia_iot;
    int i, iobase;

    printf("\n");

    sc->sc_iot = ia->ia_iot;
    sc->sc_iobase = ia->ia_io[0].ir_addr;

    for (i = 0; i < NSLAVES; i++) {
        iobase = sc->sc_iobase + i * COM_NPORTS;
        if (!com_is_console(iot, iobase, &sc->sc_slaveioh[i]) &&
                bus_space_map(iot, iobase, COM_NPORTS, 0,
                              &sc->sc_slaveioh[i])) {
            aprint_error_dev(&sc->sc_dev, "can't map i/o space for slave %d\n", i);
            return;
        }
    }

    for (i = 0; i < NSLAVES; i++) {

        ca.ca_slave = i;
        ca.ca_iot = sc->sc_iot;
        ca.ca_ioh = sc->sc_slaveioh[i];
        ca.ca_iobase = sc->sc_iobase + i * COM_NPORTS;
        ca.ca_noien = 0;

        sc->sc_slaves[i] = config_found(self, &ca, commultiprint);
        if (sc->sc_slaves[i] != NULL)
            sc->sc_alive |= 1 << i;
    }

    sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
                                   IST_EDGE, IPL_SERIAL, bocaintr, sc);
    callout_init(&sc->fixup, 0);
    callout_reset(&sc->fixup, hz/10, boca_fixup, sc);
}
コード例 #28
0
ファイル: in6_rmx.c プロジェクト: hmatyschok/MeshBSD
int
in6_inithead(void **head, int off)
{
	struct rib_head *rh;

	rh = rt_table_init(offsetof(struct sockaddr_in6, sin6_addr) << 3);
	if (rh == NULL)
		return (0);

	rh->rnh_addaddr = in6_addroute;
	*head = (void *)rh;

	if (V__in6_rt_was_here == 0) {
		callout_init(&V_rtq_mtutimer, 1);
		in6_mtutimo(curvnet);	/* kick off timeout first time */
		V__in6_rt_was_here = 1;
	}

	return (1);
}
コード例 #29
0
static void
callout_cpu_init(struct callout_cpu *cc)
{
	struct callout *c;
	int i;

	mtx_init(&cc->cc_lock, "callout", NULL, MTX_SPIN | MTX_RECURSE);
	SLIST_INIT(&cc->cc_callfree);
	for (i = 0; i < callwheelsize; i++) {
		TAILQ_INIT(&cc->cc_callwheel[i]);
	}
	if (cc->cc_callout == NULL)
		return;
	for (i = 0; i < ncallout; i++) {
		c = &cc->cc_callout[i];
		callout_init(c, 0);
		c->c_flags = CALLOUT_LOCAL_ALLOC;
		SLIST_INSERT_HEAD(&cc->cc_callfree, c, c_links.sle);
	}
}
コード例 #30
0
void timeout_test_callout(int mpsave)
{
	enum arg argument = HANDLER_NOT_VISITED;
	struct callout callout;
	int retval = 0;
	printf("== Start a callout and test if handler has been called. mpsave=%d\n", mpsave);

	callout_init(&callout, mpsave);

	retval = callout_reset(&callout, RTEMS_MILLISECONDS_TO_TICKS(TIMEOUT_MILLISECONDS), timeout_handler, &argument);
	assert(retval == 0);

	usleep(TEST_NOT_FIRED_MS * 1000);
	assert(argument == HANDLER_NOT_VISITED);
	
	usleep(TEST_FIRED_MS * 1000);
	assert(argument == HANDLER_VISITED);

	callout_deactivate(&callout);
}