Annotation of sys/arch/vax/include/intr.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: intr.h,v 1.8 2007/05/16 19:37:06 thib Exp $ */
! 2: /* $NetBSD: intr.h,v 1.1 1998/08/18 23:55:00 matt Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1998 Matt Thomas.
! 6: * All rights reserved.
! 7: *
! 8: * Redistribution and use in source and binary forms, with or without
! 9: * modification, are permitted provided that the following conditions
! 10: * are met:
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. Redistributions in binary form must reproduce the above copyright
! 14: * notice, this list of conditions and the following disclaimer in the
! 15: * documentation and/or other materials provided with the distribution.
! 16: * 3. The name of the company nor the name of the author may be used to
! 17: * endorse or promote products derived from this software without specific
! 18: * prior written permission.
! 19: *
! 20: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
! 21: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
! 22: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 23: * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
! 24: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
! 25: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! 26: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 30: * SUCH DAMAGE.
! 31: */
! 32:
! 33: #ifndef _VAX_INTR_H_
! 34: #define _VAX_INTR_H_
! 35:
! 36: /* Define the various Interrupt Priority Levels */
! 37:
! 38: /* Interrupt Priority Levels are not mutually exclusive. */
! 39:
! 40: #define IPL_NONE 0x00
! 41: #define IPL_SOFTCLOCK 0x08
! 42: #define IPL_SOFTNET 0x0c
! 43: #define IPL_BIO 0x15 /* block I/O */
! 44: #define IPL_NET 0x15 /* network */
! 45: #define IPL_TTY 0x15 /* terminal */
! 46: #define IPL_VM 0x17 /* memory allocation */
! 47: #define IPL_AUDIO 0x15 /* audio */
! 48: #define IPL_CLOCK 0x18 /* clock */
! 49: #define IPL_STATCLOCK 0x18 /* statclock */
! 50: #define IPL_HIGH 0x1f
! 51:
! 52: #define IST_UNUSABLE -1 /* interrupt cannot be used */
! 53: #define IST_NONE 0 /* none (dummy) */
! 54: #define IST_PULSE 1 /* pulsed */
! 55: #define IST_EDGE 2 /* edge-triggered */
! 56: #define IST_LEVEL 3 /* level-triggered */
! 57:
! 58: #ifndef lint
! 59: #define _splset(reg) \
! 60: ({ \
! 61: register int val; \
! 62: __asm __volatile ("mfpr $0x12,%0;mtpr %1,$0x12" \
! 63: : "=&g" (val) \
! 64: : "g" (reg)); \
! 65: val; \
! 66: })
! 67:
! 68: #define _splraise(reg) \
! 69: ({ \
! 70: register int val; \
! 71: __asm __volatile ("mfpr $0x12,%0" \
! 72: : "=&g" (val) \
! 73: : ); \
! 74: if ((reg) > val) { \
! 75: __asm __volatile ("mtpr %0,$0x12" \
! 76: : \
! 77: : "g" (reg)); \
! 78: } \
! 79: val; \
! 80: })
! 81:
! 82: #define splx(reg) \
! 83: __asm __volatile ("mtpr %0,$0x12" : : "g" (reg))
! 84: #endif
! 85:
! 86: #define spl0() _splset(IPL_NONE)
! 87: #define splsoftclock() _splraise(IPL_SOFTCLOCK)
! 88: #define splsoftnet() _splraise(IPL_SOFTNET)
! 89: #define splbio() _splraise(IPL_BIO)
! 90: #define splnet() _splraise(IPL_NET)
! 91: #define spltty() _splraise(IPL_TTY)
! 92: #define splvm() _splraise(IPL_VM)
! 93: #define splclock() _splraise(IPL_CLOCK)
! 94: #define splstatclock() _splraise(IPL_STATCLOCK)
! 95: #define splhigh() _splset(IPL_HIGH)
! 96: #define splsched() splhigh()
! 97:
! 98: /* These are better to use when playing with VAX buses */
! 99: #define spl4() _splraise(0x14)
! 100: #define spl5() _splraise(0x15)
! 101: #define spl6() _splraise(0x16)
! 102: #define spl7() _splraise(0x17)
! 103:
! 104: /* SPL asserts */
! 105: #ifdef DIAGNOSTIC
! 106: /*
! 107: * Although this function is implemented in MI code, it must be in this MD
! 108: * header because we don't want this header to include MI includes.
! 109: */
! 110: void splassert_fail(int, int, const char *);
! 111: extern int splassert_ctl;
! 112: void splassert_check(int, const char *);
! 113: #define splassert(__wantipl) do { \
! 114: if (splassert_ctl > 0) { \
! 115: splassert_check(__wantipl, __func__); \
! 116: } \
! 117: } while (0)
! 118: #else
! 119: #define splassert(wantipl) do { /* nothing */ } while (0)
! 120: #endif
! 121:
! 122: #endif /* _VAX_INTR_H */
CVSweb