static void vaudio_attach(device_t parent, device_t self, void *opaque) { struct vaudio_softc *sc = device_private(self); struct thunkbus_attach_args *taa = opaque; int error; aprint_naive("\n"); aprint_normal(": Virtual Audio (device = %s)\n", taa->u.vaudio.device); sc->sc_dev = self; pmf_device_register1(self, NULL, NULL, vaudio_shutdown); sc->sc_audiopath = taa->u.vaudio.device; sc->sc_audiofd = thunk_audio_open(sc->sc_audiopath); if (sc->sc_audiofd == -1) { aprint_error_dev(self, "couldn't open audio device: %d\n", thunk_geterrno()); return; } mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_AUDIO); error = auconv_create_encodings(vaudio_audio_formats, __arraycount(vaudio_audio_formats), &sc->sc_encodings); if (error) { aprint_error_dev(self, "couldn't create encodings\n"); return; } sc->sc_play.st_softc = sc; sc->sc_play.st_sih = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE, vaudio_softintr_play, &sc->sc_play); callout_init(&sc->sc_play.st_callout, CALLOUT_MPSAFE); callout_setfunc(&sc->sc_play.st_callout, vaudio_intr, &sc->sc_play); sc->sc_record.st_softc = sc; sc->sc_record.st_sih = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE, vaudio_softintr_record, &sc->sc_record); callout_init(&sc->sc_record.st_callout, CALLOUT_MPSAFE); callout_setfunc(&sc->sc_record.st_callout, vaudio_intr, &sc->sc_record); sc->sc_audiodev = audio_attach_mi(&vaudio_hw_if, sc, self); }
static void cpu_switchto_atomic(lwp_t *oldlwp, lwp_t *newlwp) { struct pcb *oldpcb = oldlwp ? lwp_getpcb(oldlwp) : NULL; struct pcb *newpcb = lwp_getpcb(newlwp); struct cpu_info *ci = curcpu(); ci->ci_stash = oldlwp; if (oldpcb) oldpcb->pcb_errno = thunk_geterrno(); thunk_seterrno(newpcb->pcb_errno); curlwp = newlwp; if (thunk_setcontext(&newpcb->pcb_ucp)) panic("setcontext failed"); /* not reached */ }