|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)kern_softint.c 1.1 86/02/03 Copyr 1985 Sun Micro"; ! 3: #endif ! 4: ! 5: /* ! 6: * Copyright (c) 1985 by Sun Microsystems, Inc. ! 7: */ ! 8: #include "../h/types.h" ! 9: ! 10: /* ! 11: * Handle software interrupts through 'softcall' mechanism ! 12: */ ! 13: ! 14: typedef int (*func_t)(); ! 15: ! 16: #define NSOFTCALLS 50 ! 17: ! 18: struct softcall { ! 19: func_t sc_func; /* function to call */ ! 20: caddr_t sc_arg; /* arg to pass to func */ ! 21: struct softcall *sc_next; /* next in list */ ! 22: } softcalls[NSOFTCALLS]; ! 23: ! 24: struct softcall *softhead, *softtail, *softfree; ! 25: ! 26: /* ! 27: * Call function func with argument arg ! 28: * at some later time at software interrupt priority ! 29: */ ! 30: softcall(func, arg) ! 31: register func_t func; ! 32: register caddr_t arg; ! 33: { ! 34: register struct softcall *sc; ! 35: static int first = 1; ! 36: int s; ! 37: ! 38: s = spl6(); ! 39: if (first) { ! 40: for (sc = softcalls; sc < &softcalls[NSOFTCALLS]; sc++) { ! 41: sc->sc_next = softfree; ! 42: softfree = sc; ! 43: } ! 44: first = 0; ! 45: } ! 46: /* coalesce identical softcalls */ ! 47: for (sc = softhead; sc != 0; sc = sc->sc_next) ! 48: if (sc->sc_func == func && sc->sc_arg == arg) ! 49: goto out; ! 50: if ((sc = softfree) == 0) ! 51: panic("too many softcalls"); ! 52: softfree = sc->sc_next; ! 53: sc->sc_func = func; ! 54: sc->sc_arg = arg; ! 55: sc->sc_next = 0; ! 56: if (softhead) { ! 57: softtail->sc_next = sc; ! 58: softtail = sc; ! 59: } else { ! 60: softhead = softtail = sc; ! 61: siron(); ! 62: } ! 63: out: ! 64: (void) splx(s); ! 65: } ! 66: ! 67: /* ! 68: * Called to process software interrupts ! 69: * take one off queue, call it, repeat ! 70: * Note queue may change during call ! 71: */ ! 72: softint() ! 73: { ! 74: register func_t func; ! 75: register caddr_t arg; ! 76: register struct softcall *sc; ! 77: int s; ! 78: ! 79: for (;;) { ! 80: s = spl6(); ! 81: if (sc = softhead) { ! 82: func = sc->sc_func; ! 83: arg = sc->sc_arg; ! 84: softhead = sc->sc_next; ! 85: sc->sc_next = softfree; ! 86: softfree = sc; ! 87: } ! 88: (void) splx(s); ! 89: if (sc == 0) ! 90: return; ! 91: (*func)(arg); ! 92: } ! 93: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.