void ieee80211_setup_node(struct ieee80211com *ic, struct ieee80211_node *ni, const u_int8_t *macaddr) { int s; DPRINTF(("%s\n", ether_sprintf((u_int8_t *)macaddr))); IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); ieee80211_node_newstate(ni, IEEE80211_STA_CACHE); ni->ni_ic = ic; /* back-pointer */ #ifndef IEEE80211_STA_ONLY IFQ_SET_MAXLEN(&ni->ni_savedq, IEEE80211_PS_MAX_QUEUE); timeout_set(&ni->ni_eapol_to, ieee80211_eapol_timeout, ni); timeout_set(&ni->ni_sa_query_to, ieee80211_sa_query_timeout, ni); #endif /* * Note we don't enable the inactive timer when acting * as a station. Nodes created in this mode represent * AP's identified while scanning. If we time them out * then several things happen: we can't return the data * to users to show the list of AP's we encountered, and * more importantly, we'll incorrectly deauthenticate * ourself because the inactivity timer will kick us off. */ s = splnet(); if (ic->ic_opmode != IEEE80211_M_STA && RB_EMPTY(&ic->ic_tree)) ic->ic_inact_timer = IEEE80211_INACT_WAIT; RB_INSERT(ieee80211_tree, &ic->ic_tree, ni); splx(s); }
void mbpp_attach(struct device *parent, struct device *dev, void *args) { struct magma_softc *sc = (struct magma_softc *)parent; struct mbpp_softc *ms = (struct mbpp_softc *)dev; struct mbpp_port *mp; int port; sc->ms_mbpp = ms; dprintf((" addr 0x%x", ms)); for (port = 0 ; port < sc->ms_board->mb_npar ; port++) { mp = &ms->ms_port[port]; if (sc->ms_ncd1190) mp->mp_cd1190 = &sc->ms_cd1190[port]; else mp->mp_cd1400 = &sc->ms_cd1400[0]; timeout_set(&mp->mp_timeout_tmo, mbpp_timeout, mp); timeout_set(&mp->mp_start_tmo, mbpp_start, mp); } ms->ms_nports = port; printf(": %d port%s\n", port, port == 1 ? "" : "s"); }
void dnkbd_attach(struct device *parent, struct device *self, void *aux) { struct dnkbd_softc *sc = (struct dnkbd_softc *)self; struct frodo_attach_args *fa = aux; printf(": "); sc->sc_regs = (struct apciregs *)IIOV(FRODO_BASE + fa->fa_offset); timeout_set(&sc->sc_bellstop_tmo, dnkbd_bellstop, sc); #ifdef WSDISPLAY_COMPAT_RAWKBD timeout_set(&sc->sc_rawrepeat_ch, dnkbd_rawrepeat, sc); #endif /* reset the port */ apciinit(sc->sc_regs, 1200, CFCR_8BITS | CFCR_PEVEN | CFCR_PENAB); sc->sc_isr.isr_func = dnkbd_intr; sc->sc_isr.isr_arg = sc; sc->sc_isr.isr_priority = IPL_TTY; frodo_intr_establish(parent, fa->fa_line, &sc->sc_isr, self->dv_xname); /* probe for keyboard */ if (dnkbd_probe(sc) != 0) { printf("no keyboard\n"); return; } dnkbd_attach_subdevices(sc); }
void imxuartattach(struct device *parent, struct device *self, void *args) { struct armv7_attach_args *aa = args; struct imxuart_softc *sc = (struct imxuart_softc *) self; sc->sc_irq = arm_intr_establish(aa->aa_dev->irq[0], IPL_TTY, imxuart_intr, sc, sc->sc_dev.dv_xname); sc->sc_iot = aa->aa_iot; if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr, aa->aa_dev->mem[0].size, 0, &sc->sc_ioh)) panic("imxuartattach: bus_space_map failed!"); if (aa->aa_dev->mem[0].addr == imxuartconsaddr) printf(" console"); timeout_set(&sc->sc_diag_tmo, imxuart_diag, sc); timeout_set(&sc->sc_dtr_tmo, imxuart_raisedtr, sc); sc->sc_si = softintr_establish(IPL_TTY, imxuart_softint, sc); if(sc->sc_si == NULL) panic("%s: can't establish soft interrupt.", sc->sc_dev.dv_xname); printf("\n"); }
void domaininit(void) { struct domain *dp; struct protosw *pr; static struct timeout pffast_timeout; static struct timeout pfslow_timeout; #undef unix /* * KAME NOTE: ADDDOMAIN(route) is moved to the last part so that * it will be initialized as the *first* element. confusing! */ #ifndef lint ADDDOMAIN(unix); #ifdef INET ADDDOMAIN(inet); #endif #ifdef INET6 ADDDOMAIN(inet6); #endif /* INET6 */ #if defined (KEY) || defined (IPSEC) || defined (TCP_SIGNATURE) pfkey_init(); #endif /* KEY || IPSEC */ #ifdef MPLS ADDDOMAIN(mpls); #endif #ifdef NATM ADDDOMAIN(natm); #endif #ifdef IPSEC #ifdef __KAME__ ADDDOMAIN(key); #endif #endif #if NBLUETOOTH > 0 ADDDOMAIN(bt); #endif ADDDOMAIN(route); #endif for (dp = domains; dp; dp = dp->dom_next) { if (dp->dom_init) (*dp->dom_init)(); for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_init) (*pr->pr_init)(); } if (max_linkhdr < 16) /* XXX */ max_linkhdr = 16; max_hdr = max_linkhdr + max_protohdr; max_datalen = MHLEN - max_hdr; timeout_set(&pffast_timeout, pffasttimo, &pffast_timeout); timeout_set(&pfslow_timeout, pfslowtimo, &pfslow_timeout); timeout_add(&pffast_timeout, 1); timeout_add(&pfslow_timeout, 1); }
void sxiuartattach(struct device *parent, struct device *self, void *args) { struct armv7_attach_args *aa = args; struct sxiuart_softc *sc = (struct sxiuart_softc *) self; bus_space_tag_t iot; bus_space_handle_t ioh; int s; sc->sc_iot = iot = aa->aa_iot; if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr, aa->aa_dev->mem[0].size, 0, &sc->sc_ioh)) panic("sxiuartattach: bus_space_map failed!"); ioh = sc->sc_ioh; if (aa->aa_dev->mem[0].addr == sxiuartconsaddr) { cn_tab->cn_dev = makedev(12 /* XXX */, 0); cdevsw[12] = sxiuartdev; /* KLUDGE */ printf(": console"); /* XXX compare uses of COM_HW_CONSOLE against com.c */ SET(sc->sc_hwflags, COM_HW_CONSOLE); SET(sc->sc_swflags, COM_SW_SOFTCAR); sxiuartconsiot = iot; sxiuartconsioh = ioh; } timeout_set(&sc->sc_diag_tmo, sxiuart_diag, sc); timeout_set(&sc->sc_dtr_tmo, sxiuart_raisedtr, sc); sc->sc_si = softintr_establish(IPL_TTY, sxiuart_softint, sc); if(sc->sc_si == NULL) panic("%s: can't establish soft interrupt.", sc->sc_dev.dv_xname); sc->sc_frequency = 24000000; /* XXX */ if ((bus_space_read_1(sc->sc_iot, sc->sc_ioh, SXIUART_IIR) & IIR_BUSY) == IIR_BUSY) (void)bus_space_read_4(sc->sc_iot, sc->sc_ioh, SXIUART_USR); sc->sc_ier = 0; /* disable interrupts */ bus_space_write_1(iot, ioh, SXIUART_IER, sc->sc_ier); /* clear and disable fifo */ bus_space_write_1(iot, ioh, SXIUART_FCR, 0 | RFIFOR | XFIFOR); s = splhigh(); SET(sc->sc_mcr, MCR_DTR | MCR_RTS | MCR_IENABLE); bus_space_write_1(sc->sc_iot, sc->sc_ioh, SXIUART_MCR, sc->sc_mcr); splx(s); arm_intr_establish(aa->aa_dev->irq[0], IPL_TTY, sxiuart_intr, sc, sc->sc_dev.dv_xname); printf("\n"); }
int pckbc_cnattach(bus_space_tag_t iot, bus_addr_t addr, bus_size_t cmd_offset, int flags) { bus_space_handle_t ioh_d, ioh_c; int res = 0; if (bus_space_map(iot, addr + KBDATAP, 1, 0, &ioh_d)) return (ENXIO); if (bus_space_map(iot, addr + cmd_offset, 1, 0, &ioh_c)) { bus_space_unmap(iot, ioh_d, 1); return (ENXIO); } pckbc_consdata.t_iot = iot; pckbc_consdata.t_ioh_d = ioh_d; pckbc_consdata.t_ioh_c = ioh_c; pckbc_consdata.t_addr = addr; pckbc_consdata.t_flags = flags; timeout_set(&pckbc_consdata.t_cleanup, pckbc_cleanup, &pckbc_consdata); timeout_set(&pckbc_consdata.t_poll, pckbc_poll, &pckbc_consdata); /* flush */ (void) pckbc_poll_data1(iot, ioh_d, ioh_c, PCKBC_KBD_SLOT, 0); /* selftest? */ /* init cmd byte, enable ports */ pckbc_consdata.t_cmdbyte = KC8_CPU; if (!pckbc_put8042cmd(&pckbc_consdata)) { printf("kbc: cmd word write error\n"); res = EIO; } if (!res) { #if (NPCKBD > 0) res = pckbd_cnattach(&pckbc_consdata); #else res = ENXIO; #endif /* NPCKBD > 0 */ } if (res) { bus_space_unmap(iot, pckbc_consdata.t_ioh_d, 1); bus_space_unmap(iot, pckbc_consdata.t_ioh_c, 1); } else { pckbc_consdata.t_slotdata[PCKBC_KBD_SLOT] = &pckbc_cons_slotdata; pckbc_init_slotdata(&pckbc_cons_slotdata); pckbc_console = 1; } return (res); }
/* * Determine i/o configuration for a machine. */ void cpu_configure(void) { #if NBIOS32 > 0 bios32_init(); #endif x86_64_proc0_tss_ldt_init(); if (config_rootfound("mainbus", NULL) == NULL) panic("configure: mainbus not configured"); intr_printconfig(); #if NIOAPIC > 0 lapic_set_lvt(); ioapic_enable(); #endif #ifdef MULTIPROCESSOR cpu_init_idle_pcbs(); #endif lcr8(0); spl0(); cold = 0; /* * At this point the RNG is running, and if FSXR is set we can * use it. Here we setup a periodic timeout to collect the data. */ if (viac3_rnd_present) { timeout_set(&viac3_rnd_tmo, viac3_rnd, &viac3_rnd_tmo); viac3_rnd(&viac3_rnd_tmo); } if (has_rdrand) { timeout_set(&rdrand_tmo, rdrand, &rdrand_tmo); rdrand(&rdrand_tmo); } #ifdef CRYPTO /* * Also, if the chip has crypto available, enable it. */ if (amd64_has_xcrypt) viac3_crypto_setup(); if (amd64_has_aesni) aesni_setup(); #endif }
void panel_attach(struct device *parent, struct device *self, void *aux) { struct panel_softc *sc = (struct panel_softc *)self; struct hpc_attach_args *haa = aux; sc->sc_iot = haa->ha_st; if (bus_space_subregion(haa->ha_st, haa->ha_sh, haa->ha_devoff + 3, 1, &sc->sc_ioh)) { printf(": can't map registers\n"); return; } sc->sc_irq = haa->ha_irq; sc->sc_ih = hpc_intr_establish(sc->sc_irq, IPL_BIO, panel_intr, sc, sc->sc_dev.dv_xname); if (sc->sc_ih == NULL) { printf(": can't establish interrupt\n"); return; } if (sys_config.system_subtype == IP22_INDY) printf(": power and volume buttons\n"); else printf(": power button\n"); timeout_set(&sc->sc_repeat_tmo, panel_repeat, sc); }
void midiattach(struct device *parent, struct device *self, void *aux) { struct midi_info mi; struct midi_softc *sc = (struct midi_softc *)self; struct audio_attach_args *sa = (struct audio_attach_args *)aux; struct midi_hw_if *hwif = sa->hwif; void *hdl = sa->hdl; #ifdef DIAGNOSTIC if (hwif == 0 || hwif->open == 0 || hwif->close == 0 || hwif->output == 0 || hwif->getinfo == 0) { printf("midi: missing method\n"); return; } #endif sc->hw_if = hwif; sc->hw_hdl = hdl; sc->hw_if->getinfo(sc->hw_hdl, &mi); sc->props = mi.props; sc->flags = 0; timeout_set(&sc->timeo, midi_timeout, sc); printf(": <%s>\n", mi.name); }
static boolean_t consthr_init_wait(void) { struct timespec timeout; disp_flag_t flag; int status = 0; timeout_set(&timeout, DISP_DEFAULT_INTVAL); (void) pthread_mutex_lock(&s_disp_ctl.mutex); flag = s_disp_ctl.flag; /* * The cons thread issues a command to go to home window * when it completes the initialization. */ while ((flag != DISP_FLAG_CMD) && (flag != DISP_FLAG_QUIT)) { status = pthread_cond_timedwait(&s_disp_ctl.cond, &s_disp_ctl.mutex, &timeout); if (status == ETIMEDOUT) { break; } flag = s_disp_ctl.flag; } (void) pthread_mutex_unlock(&s_disp_ctl.mutex); if ((status == ETIMEDOUT) || (flag == DISP_FLAG_QUIT)) { return (B_FALSE); } return (B_TRUE); }
/*----------------------------------------------------------------------------*/ void spin_edit_start(const char *caption, int *val, int max, int min, int increment) { int size; char buffer[16]; spin_data.value = val; spin_data.caption = caption; spin_data.min = min; spin_data.max = max; spin_data.increment = increment; spin_data.size = sprintf(buffer, "%d", min); size = sprintf(buffer, "%d", max); if(spin_data.size < size) spin_data.size = size; value = *val; if(value < min) value = min; if(value > max) value = max; spin_data.cursor_active = 1; timeout_set(&spin_data.timeout, CURSOR_TIME, sys_tick_count()); push_event_handler(); set_event_handler(spin_handler, 0); }
void zts_attach(struct device *parent, struct device *self, void *aux) { struct zts_softc *sc = (struct zts_softc *)self; struct wsmousedev_attach_args a; timeout_set(&sc->sc_ts_poll, zts_poll, sc); /* Initialize ADS7846 Difference Reference mode */ (void)zssp_ic_send(ZSSP_IC_ADS7846, (1<<ADSCTRL_ADR_SH) | (1<<ADSCTRL_STS_SH)); delay(5000); (void)zssp_ic_send(ZSSP_IC_ADS7846, (3<<ADSCTRL_ADR_SH) | (1<<ADSCTRL_STS_SH)); delay(5000); (void)zssp_ic_send(ZSSP_IC_ADS7846, (4<<ADSCTRL_ADR_SH) | (1<<ADSCTRL_STS_SH)); delay(5000); (void)zssp_ic_send(ZSSP_IC_ADS7846, (5<<ADSCTRL_ADR_SH) | (1<<ADSCTRL_STS_SH)); delay(5000); a.accessops = &zts_accessops; a.accesscookie = sc; printf("\n"); /* Copy the default scalue values to each softc */ bcopy(&zts_scale, &sc->sc_tsscale, sizeof(sc->sc_tsscale)); sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint); }
void octrng_attach(struct device *parent, struct device *self, void *aux) { struct octrng_softc *sc = (void *)self; sc->sc_io = aux; uint64_t control_reg; sc->sc_iot = sc->sc_io->aa_bust; if (bus_space_map(sc->sc_iot, OCTEON_RNG_BASE, OCTRNG_MAP_SIZE, 0, &sc->sc_ioh)) { printf(": can't map registers"); } control_reg = octeon_xkphys_read_8(OCTRNG_CONTROL_ADDR); control_reg |= (OCTRNG_ENABLE_OUTPUT | OCTRNG_ENABLE_ENTROPY); octeon_xkphys_write_8(OCTRNG_CONTROL_ADDR, control_reg); timeout_set(&sc->sc_to, octrng_rnd, sc); timeout_add_sec(&sc->sc_to, 5); printf("\n"); }
/* * Print out an error message. actions contain a set of flags that determine * what needs to get done. If BUG is set, it is an internal error. If SYS is * set, a system error is printed. If RET is set, we return rather than exit. */ static int error(int actions, const char *fmt, ...) { va_list alist; char *p = error_message; char *q = p + sizeof(error_message); if ((actions & BUG) != 0) buf_app(&p, q, "internal error: "); va_start(alist, fmt); p += vsnprintf(p, q-p, fmt, alist); va_end(alist); if ((actions & SYS) != 0 && errno) { buf_app(&p, q, ": "); buf_app(&p, q, strerror(errno)); } buf_end(&p, q); fwrite(error_message, 1, p+1-error_message, stdout); if ((actions & RET) != 0) return 0; #if 0 if (RemoteFD >= 0) { send(RemoteFD, "?", 1, MSG_OOB); (void) write(RemoteFD, error_message, p-error_message); shutdown(RemoteFD, SHUT_WR); timeout_set(ERROR_TIMEOUT, sig_alrm_die); while (read(RemoteFD, error_message, sizeof(error_message)) > 0) ; } #endif return -1; }
void fdcattach(struct device *parent, struct device *self, void *aux) { struct fdc_softc *fdc = (void *)self; bus_space_tag_t iot; bus_space_handle_t ioh; bus_space_handle_t ioh_ctl; struct isa_attach_args *ia = aux; struct fdc_attach_args fa; int type; iot = ia->ia_iot; /* Re-map the I/O space. */ if (bus_space_map(iot, ia->ia_iobase, FDC_NPORT, 0, &ioh) || bus_space_map(iot, ia->ia_iobase + FDCTL_OFFSET, FDCTL_NPORT, 0, &ioh_ctl)) panic("fdcattach: couldn't map I/O ports"); fdc->sc_iot = iot; fdc->sc_ioh = ioh; fdc->sc_ioh_ctl = ioh_ctl; fdc->sc_drq = ia->ia_drq; fdc->sc_state = DEVIDLE; TAILQ_INIT(&fdc->sc_link.fdlink.sc_drives); /* XXX */ printf("\n"); fdc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, IPL_BIO, fdcintr, fdc, fdc->sc_dev.dv_xname); #if defined(__i386__) || defined(__amd64__) /* * The NVRAM info only tells us about the first two disks on the * `primary' floppy controller. */ if (fdc->sc_dev.dv_unit == 0) type = mc146818_read(NULL, NVRAM_DISKETTE); /* XXX softc */ else #endif type = -1; timeout_set(&fdc->fdcpseudointr_to, fdcpseudointr, fdc); /* physical limit: four drives per controller. */ for (fa.fa_drive = 0; fa.fa_drive < 4; fa.fa_drive++) { fa.fa_flags = 0; fa.fa_type = 0; #if NFD > 0 if (type >= 0 && fa.fa_drive < 2) fa.fa_deftype = fd_nvtotype(fdc->sc_dev.dv_xname, type, fa.fa_drive); else #endif fa.fa_deftype = NULL; /* unknown */ (void)config_found(self, (void *)&fa, fddprint); } }
void ieee80211_node_attach(struct ifnet *ifp) { struct ieee80211com *ic = (void *)ifp; #ifndef IEEE80211_STA_ONLY int size; #endif RB_INIT(&ic->ic_tree); ic->ic_node_alloc = ieee80211_node_alloc; ic->ic_node_free = ieee80211_node_free; ic->ic_node_copy = ieee80211_node_copy; ic->ic_node_getrssi = ieee80211_node_getrssi; ic->ic_scangen = 1; ic->ic_max_nnodes = ieee80211_cache_size; if (ic->ic_max_aid == 0) ic->ic_max_aid = IEEE80211_AID_DEF; else if (ic->ic_max_aid > IEEE80211_AID_MAX) ic->ic_max_aid = IEEE80211_AID_MAX; #ifndef IEEE80211_STA_ONLY size = howmany(ic->ic_max_aid, 32) * sizeof(u_int32_t); ic->ic_aid_bitmap = malloc(size, M_DEVBUF, M_NOWAIT | M_ZERO); if (ic->ic_aid_bitmap == NULL) { /* XXX no way to recover */ printf("%s: no memory for AID bitmap!\n", __func__); ic->ic_max_aid = 0; } if (ic->ic_caps & (IEEE80211_C_HOSTAP | IEEE80211_C_IBSS)) { ic->ic_tim_len = howmany(ic->ic_max_aid, 8); ic->ic_tim_bitmap = malloc(ic->ic_tim_len, M_DEVBUF, M_NOWAIT | M_ZERO); if (ic->ic_tim_bitmap == NULL) { printf("%s: no memory for TIM bitmap!\n", __func__); ic->ic_tim_len = 0; } else ic->ic_set_tim = ieee80211_set_tim; timeout_set(&ic->ic_rsn_timeout, ieee80211_gtk_rekey_timeout, ic); timeout_set(&ic->ic_inact_timeout, ieee80211_inact_timeout, ic); timeout_set(&ic->ic_node_cache_timeout, ieee80211_node_cache_timeout, ic); } #endif }
/* * Network interface utility routines. * * Routines with ifa_ifwith* names take sockaddr *'s as * parameters. */ void ifinit() { static struct timeout if_slowtim; timeout_set(&if_slowtim, if_slowtimo, &if_slowtim); if_slowtimo(&if_slowtim); }
void lpt_attach_common(struct lpt_softc *sc) { printf("\n"); bus_space_write_1(sc->sc_iot, sc->sc_ioh, lpt_control, LPC_NINIT); timeout_set(&sc->sc_wakeup_tmo, lptwakeup, sc); }
int gre_clone_create(struct if_clone *ifc, int unit) { struct gre_softc *sc; int s; sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO); if (!sc) return (ENOMEM); snprintf(sc->sc_if.if_xname, sizeof sc->sc_if.if_xname, "%s%d", ifc->ifc_name, unit); sc->sc_if.if_softc = sc; sc->sc_if.if_type = IFT_TUNNEL; sc->sc_if.if_addrlen = 0; sc->sc_if.if_hdrlen = 24; /* IP + GRE */ sc->sc_if.if_mtu = GREMTU; sc->sc_if.if_flags = IFF_POINTOPOINT|IFF_MULTICAST; sc->sc_if.if_output = gre_output; sc->sc_if.if_ioctl = gre_ioctl; sc->sc_if.if_collisions = 0; sc->sc_if.if_ierrors = 0; sc->sc_if.if_oerrors = 0; sc->sc_if.if_ipackets = 0; sc->sc_if.if_opackets = 0; sc->g_dst.s_addr = sc->g_src.s_addr = INADDR_ANY; sc->g_proto = IPPROTO_GRE; sc->sc_if.if_flags |= IFF_LINK0; sc->sc_ka_state = GRE_STATE_UKNWN; timeout_set(&sc->sc_ka_hold, gre_keepalive, sc); timeout_set(&sc->sc_ka_snd, gre_send_keepalive, sc); if_attach(&sc->sc_if); if_alloc_sadl(&sc->sc_if); #if NBPFILTER > 0 bpfattach(&sc->sc_if.if_bpf, &sc->sc_if, DLT_LOOP, sizeof(u_int32_t)); #endif s = splnet(); LIST_INSERT_HEAD(&gre_softc_list, sc, sc_list); splx(s); return (0); }
/* * The common entry for processing command. */ static void cmd_received(cmd_t *cmd, boolean_t *quit, struct timespec *timeout) { boolean_t badcmd, execute; int cmd_id = CMD_ID(cmd); execute = B_TRUE; *quit = B_FALSE; switch (cmd_id) { case CMD_QUIT_ID: *quit = B_TRUE; return; case CMD_RESIZE_ID: /* * The screen resize signal would trigger this * command. Destroy existing screen and curses * resources and then re-init the curses resources. */ win_fix_fini(); page_win_destroy(); reg_curses_fini(); if (reg_curses_init(B_FALSE)) { win_fix_init(); } else { execute = B_FALSE; } timeout_set(timeout, DISP_DEFAULT_INTVAL); break; case CMD_REFRESH_ID: /* * User hit the hotkey 'R' to refresh current window. */ timeout_set(timeout, DISP_DEFAULT_INTVAL); break; } if (execute) { cmd_execute(cmd, &badcmd); } }
void ledattach(struct device *parent, struct device *self, void *aux) { struct led_softc *sc = (void *)self; #if VAX49 || VAX53 || VXT vaddr_t pgva; #endif printf("\n"); switch (vax_boardtype) { #if VAX46 case VAX_BTYP_46: { extern struct vs_cpu *ka46_cpu; sc->sc_reg = (volatile u_short *)(&ka46_cpu->vc_diagdsp); sc->sc_pat = led_pattern8; } break; #endif #if VAX48 case VAX_BTYP_48: { extern struct vs_cpu *ka48_cpu; sc->sc_reg = (volatile u_short *)(&ka48_cpu->vc_diagdsp); sc->sc_pat = led_pattern8; } break; #endif #if VAX49 case VAX_BTYP_49: pgva = vax_map_physmem(0x25800000, 1); sc->sc_reg = (volatile u_short *)(pgva + 4); sc->sc_pat = led_pattern8; break; #endif #if VAX53 case VAX_BTYP_1303: pgva = vax_map_physmem(0x20140000, 1); sc->sc_reg = (volatile u_short *)(pgva + 0x30); sc->sc_pat = led_pattern4; break; #endif #if VXT case VAX_BTYP_VXT: pgva = vax_map_physmem(0x200c1000, 1); sc->sc_reg = (volatile u_short *)pgva; sc->sc_pat = led_pattern8; break; #endif } sc->sc_patpos = sc->sc_pat; timeout_set(&sc->sc_tmo, led_blink, sc); led_blink(sc); }
void wdog_register(void *cb_arg, int (*cb)(void *, int)) { if (wdog_ctl_cb != NULL) return; wdog_ctl_cb = cb; wdog_ctl_cb_arg = cb_arg; timeout_set(&wdog_timeout, wdog_tickle, NULL); wdog_cookie = shutdownhook_establish(wdog_shutdown, NULL); }
/*----------------------------------------------------------------------------*/ void viewer(view_get_t get, void *data, int string_count) { view_data.get = get; view_data.data = data; view_data.string_count = string_count; view_data.index = 0; view_data.cursor_active = 1; view_data.active_key = 0; timeout_set(&view_data.timeout, CURSOR_TIME, sys_tick_count()); push_event_handler(); set_event_handler(view_handler, 0); }
int mainloop_modify_timeout(int id, unsigned int seconds) { if (seconds > 0) { if (timeout_set(id, seconds) < 0) return -EIO; } if (mainloop_modify_fd(id, EPOLLIN | EPOLLONESHOT) < 0) return -EIO; return 0; }
void ykbec_attach(device_t parent, device_t self, void *aux) { struct isa_attach_args *ia = aux; struct ykbec_softc *sc = device_private(self); int i; sc->sc_iot = ia->ia_iot; if (bus_space_map(sc->sc_iot, ia->ia_iobase, ia->ia_iosize, 0, &sc->sc_ioh)) { aprint_error(": couldn't map I/O space"); return; } /* Initialize sensor data. */ strlcpy(sc->sc_sensordev.xname, device_xname(self), sizeof(sc->sc_sensordev.xname)); if (sensor_task_register(sc, ykbec_refresh, 5) == NULL) { aprint_error(", unable to register update task\n"); return; } #ifdef DEBUG ykbec_print_bat_info(sc); #endif aprint_normal("\n"); for (i = 0; i < YKBEC_NSENSORS; i++) { sc->sc_sensor[i].type = ykbec_table[i].type; if (ykbec_table[i].desc) strlcpy(sc->sc_sensor[i].desc, ykbec_table[i].desc, sizeof(sc->sc_sensor[i].desc)); sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); } sensordev_install(&sc->sc_sensordev); #if NAPM > 0 /* make sure we have the apm state initialized before apm attaches */ ykbec_refresh(sc); apm_setinfohook(ykbec_apminfo); #endif #if NPCKBD > 0 || NHIDKBD > 0 timeout_set(&sc->sc_bell_tmo, ykbec_bell_stop, sc); #if NPCKBD > 0 pckbd_hookup_bell(ykbec_bell, sc); #endif #if NHIDKBD > 0 hidkbd_hookup_bell(ykbec_bell, sc); #endif #endif ykbec_sc = sc; }
void ieee80211_setup_node(struct ieee80211com *ic, struct ieee80211_node *ni, const u_int8_t *macaddr) { int s; DPRINTF(("%s\n", ether_sprintf((u_int8_t *)macaddr))); IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); ieee80211_node_newstate(ni, IEEE80211_STA_CACHE); ni->ni_ic = ic; /* back-pointer */ #ifndef IEEE80211_STA_ONLY IFQ_SET_MAXLEN(&ni->ni_savedq, IEEE80211_PS_MAX_QUEUE); timeout_set(&ni->ni_eapol_to, ieee80211_eapol_timeout, ni); timeout_set(&ni->ni_sa_query_to, ieee80211_sa_query_timeout, ni); #endif s = splnet(); RB_INSERT(ieee80211_tree, &ic->ic_tree, ni); ic->ic_nnodes++; splx(s); }
static void prv_redraw_parameters (void) { if (redraw_timeout) { timeout_reset (redraw_timeout, redraw_delay); } else { timeout_set (redraw_delay, prv_redraw_parameters_callback, 0); } }
int nmeaopen(dev_t dev, struct tty *tp, struct proc *p) { struct nmea *np; int error; if (tp->t_line == NMEADISC) return (ENODEV); if ((error = suser(p, 0)) != 0) return (error); np = malloc(sizeof(struct nmea), M_DEVBUF, M_WAITOK | M_ZERO); snprintf(np->timedev.xname, sizeof(np->timedev.xname), "nmea%d", nmea_nxid++); nmea_count++; np->time.status = SENSOR_S_UNKNOWN; np->time.type = SENSOR_TIMEDELTA; np->time.flags = SENSOR_FINVALID; sensor_attach(&np->timedev, &np->time); np->signal.type = SENSOR_INDICATOR; np->signal.status = SENSOR_S_UNKNOWN; np->signal.value = 0; strlcpy(np->signal.desc, "Signal", sizeof(np->signal.desc)); sensor_attach(&np->timedev, &np->signal); np->latitude.type = SENSOR_ANGLE; np->latitude.status = SENSOR_S_UNKNOWN; np->latitude.flags = SENSOR_FINVALID; np->latitude.value = 0; strlcpy(np->latitude.desc, "Latitude", sizeof(np->latitude.desc)); sensor_attach(&np->timedev, &np->latitude); np->longitude.type = SENSOR_ANGLE; np->longitude.status = SENSOR_S_UNKNOWN; np->longitude.flags = SENSOR_FINVALID; np->longitude.value = 0; strlcpy(np->longitude.desc, "Longitude", sizeof(np->longitude.desc)); sensor_attach(&np->timedev, &np->longitude); np->sync = 1; tp->t_sc = (caddr_t)np; error = linesw[TTYDISC].l_open(dev, tp, p); if (error) { free(np, M_DEVBUF, sizeof(*np)); tp->t_sc = NULL; } else { sensordev_install(&np->timedev); timeout_set(&np->nmea_tout, nmea_timeout, np); } return (error); }
void nep_attach(struct device *parent, struct device *self, void *aux) { struct nep_softc *sc = (struct nep_softc *)self; struct pci_attach_args *pa = aux; struct ifnet *ifp = &sc->sc_ac.ac_if; struct mii_data *mii = &sc->sc_mii; pcireg_t memtype; uint64_t cfg; sc->sc_dmat = pa->pa_dmat; memtype = PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT; if (pci_mapreg_map(pa, PCI_MAPREG_START, memtype, 0, &sc->sc_memt, &sc->sc_memh, NULL, &sc->sc_mems, 0)) { printf(": can't map registers\n"); return; } sc->sc_port = pa->pa_function; #ifdef __sparc64__ if (OF_getprop(PCITAG_NODE(pa->pa_tag), "local-mac-address", sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN) <= 0) myetheraddr(sc->sc_ac.ac_enaddr); #endif printf(", address %s\n", ether_sprintf(sc->sc_ac.ac_enaddr)); cfg = nep_read(sc, MIF_CONFIG); cfg &= ~MIF_CONFIG_INDIRECT_MODE; nep_write(sc, MIF_CONFIG, cfg); strlcpy(ifp->if_xname, sc->sc_dev.dv_xname, sizeof(ifp->if_xname)); ifp->if_softc = sc; ifp->if_ioctl = nep_ioctl; mii->mii_ifp = ifp; mii->mii_readreg = nep_mii_readreg; mii->mii_writereg = nep_mii_writereg; mii->mii_statchg = nep_mii_statchg; ifmedia_init(&mii->mii_media, 0, nep_mediachange, nep_mediastatus); mii_attach(&sc->sc_dev, mii, 0xffffffff, MII_PHY_ANY, sc->sc_port, 0); ifmedia_set(&mii->mii_media, IFM_ETHER|IFM_AUTO); if_attach(ifp); ether_ifattach(ifp); timeout_set(&sc->sc_tick_ch, nep_tick, sc); }