|
|
1.1 ! root 1: /* $Header: /usr/src/sys/ldrv/RCS/setivec.c,v 1.1 88/03/24 16:31:02 src Exp $ */ ! 2: /* ! 3: * The information contained herein is a trade secret of INETCO ! 4: * Systems, and is confidential information. It is provided under ! 5: * a license agreement, and may be copied or disclosed only under ! 6: * the terms of that agreement. Any reproduction or disclosure of ! 7: * this material without the express written authorization of ! 8: * INETCO Systems or persuant to the license agreement is unlawful. ! 9: * ! 10: * Copyright (c) 1987 ! 11: * An unpublished work by INETCO Systems, Ltd. ! 12: * All rights reserved. ! 13: */ ! 14: ! 15: /* ! 16: * Loadable Driver - Enable/Disable Interrupts. ! 17: * ! 18: * $Log: /usr/src/sys/ldrv/RCS/setivec.c,v $ ! 19: * Revision 1.1 88/03/24 16:31:02 src ! 20: * Initial revision ! 21: * ! 22: * 87/12/03 Allan Cornish /usr/src/sys/ldrv/setivec.c ! 23: * Initial version. ! 24: */ ! 25: #include <sys/coherent.h> ! 26: #include <errno.h> ! 27: #include <sys/con.h> ! 28: #include <sys/uproc.h> ! 29: ! 30: /* ! 31: * Interrupt entry points [within kernel] for loadable drivers. ! 32: */ ! 33: extern void (*ldrvint[16])(); ! 34: ! 35: /* ! 36: * Interrupt handlers [within driver] for loadable drivers. ! 37: * ldrvics[n]: Interrupt handler code segment. ! 38: * ldrvipc[n]: Interrupt handler program counter. ! 39: */ ! 40: extern saddr_t ldrvics[16]; ! 41: extern void (*ldrvipc[16])(); ! 42: ! 43: setivec( level, func ) ! 44: int level; ! 45: void (*func)(); ! 46: { ! 47: extern void Ksetivec(); ! 48: extern saddr_t ucs; ! 49: ! 50: u.u_error = 0; ! 51: level &= 15; ! 52: ! 53: /* ! 54: * Ensure interrupt is not already in use. ! 55: */ ! 56: if ( (ldrvics[level] != 0) || (ldrvipc[level] != NULL) ) { ! 57: u.u_error = EDBUSY; ! 58: return; ! 59: } ! 60: ! 61: /* ! 62: * Record interrupt function BEFORE enabling interrupt. ! 63: */ ! 64: ldrvipc[level] = func; ! 65: ldrvics[level] = ucs; ! 66: ! 67: /* ! 68: * Attempt to enable interrupt. ! 69: */ ! 70: kcall( Ksetivec, level, ldrvint[level] ); ! 71: ! 72: /* ! 73: * Interrupt is in use by a resident driver. ! 74: */ ! 75: if ( u.u_error ) { ! 76: ldrvipc[level] = NULL; ! 77: ldrvics[level] = 0; ! 78: } ! 79: } ! 80: ! 81: clrivec( level ) ! 82: register int level; ! 83: { ! 84: extern void Kclrivec(); ! 85: extern saddr_t ucs; ! 86: ! 87: level &= 15; ! 88: ! 89: /* ! 90: * Ensure interrupt belongs to our process. ! 91: */ ! 92: if ( ldrvics[level] != ucs ) { ! 93: u.u_error = EPERM; ! 94: return; ! 95: } ! 96: ! 97: /* ! 98: * Disable interrupt. ! 99: */ ! 100: kcall( Kclrivec, level ); ! 101: ! 102: /* ! 103: * Erase interrupt function AFTER disabling interrupt. ! 104: */ ! 105: ldrvipc[level] = NULL; ! 106: ldrvics[level] = 0; ! 107: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.