intr.h revision 1.1
11.1Sis/* $NetBSD: intr.h,v 1.1 2000/05/25 22:12:00 is Exp $ */ 21.1Sis 31.1Sis/*- 41.1Sis * Copyright (c) 1997 The NetBSD Foundation, Inc. 51.1Sis * All rights reserved. 61.1Sis * 71.1Sis * This code is derived from software contributed to The NetBSD Foundation 81.1Sis * by Ignatios Souvatzis. 91.1Sis * 101.1Sis * Redistribution and use in source and binary forms, with or without 111.1Sis * modification, are permitted provided that the following conditions 121.1Sis * are met: 131.1Sis * 1. Redistributions of source code must retain the above copyright 141.1Sis * notice, this list of conditions and the following disclaimer. 151.1Sis * 2. Redistributions in binary form must reproduce the above copyright 161.1Sis * notice, this list of conditions and the following disclaimer in the 171.1Sis * documentation and/or other materials provided with the distribution. 181.1Sis * 3. All advertising materials mentioning features or use of this software 191.1Sis * must display the following acknowledgement: 201.1Sis * This product includes software developed by the NetBSD 211.1Sis * Foundation, Inc. and its contributors. 221.1Sis * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Sis * contributors may be used to endorse or promote products derived 241.1Sis * from this software without specific prior written permission. 251.1Sis * 261.1Sis * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Sis * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Sis * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Sis * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Sis * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Sis * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Sis * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Sis * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Sis * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Sis * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Sis * POSSIBILITY OF SUCH DAMAGE. 371.1Sis */ 381.1Sis 391.1Sis/* 401.1Sis * machine/intr.h for the Amiga port. 411.1Sis * Currently, only a wrapper, for most of the stuff, around the old 421.1Sis * include files. 431.1Sis */ 441.1Sis 451.1Sis#ifndef _MACHINE_INTR_H_ 461.1Sis#define _MACHINE_INTR_H_ 471.1Sis 481.1Sis#include <amiga/amiga/isr.h> 491.1Sis#include <amiga/include/mtpr.h> 501.1Sis 511.1Sis#define __GENERIC_SOFT_INTERRUPTS 521.1Sis/* ADAM: commented out 531.1Sis#define IPL_SOFTSERIAL 1 541.1Sis#define IPL_SOFTNET 1 551.1Sis*/ 561.1Sis 571.1Sis#ifdef splaudio 581.1Sis#undef splaudio 591.1Sis#define splaudio spl6 601.1Sis#endif 611.1Sis 621.1Sis#define spllpt() spl6() 631.1Sis 641.1Sis/* ADAM: from macppc/intr.h */ 651.1Sis/* Interrupt priority `levels'. */ 661.1Sis#define IPL_NONE 9 /* nothing */ 671.1Sis#define IPL_SOFTCLOCK 8 /* timeouts */ 681.1Sis#define IPL_SOFTNET 7 /* protocol stacks */ 691.1Sis#define IPL_BIO 6 /* block I/O */ 701.1Sis#define IPL_NET 5 /* network */ 711.1Sis#define IPL_SOFTSERIAL 4 /* serial */ 721.1Sis#define IPL_TTY 3 /* terminal */ 731.1Sis#define IPL_IMP 3 /* memory allocation */ 741.1Sis#define IPL_AUDIO 2 /* audio */ 751.1Sis#define IPL_CLOCK 1 /* clock */ 761.1Sis#define IPL_HIGH 1 /* everything */ 771.1Sis#define IPL_SERIAL 0 /* serial */ 781.1Sis#define NIPL 10 791.1Sis 801.1Sis/* Interrupt sharing types. */ 811.1Sis#define IST_NONE 0 /* none */ 821.1Sis#define IST_PULSE 1 /* pulsed */ 831.1Sis#define IST_EDGE 2 /* edge-triggered */ 841.1Sis#define IST_LEVEL 3 /* level-triggered */ 851.1Sis 861.1Sis#ifndef _LOCORE 871.1Sis 881.1Sis/* 891.1Sis * Interrupt handler chains. intr_establish() inserts a handler into 901.1Sis * the list. The handler is called with its (single) argument. 911.1Sis */ 921.1Sisstruct intrhand { 931.1Sis int (*ih_fun) __P((void *)); 941.1Sis void *ih_arg; 951.1Sis u_long ih_count; 961.1Sis struct intrhand *ih_next; 971.1Sis int ih_level; 981.1Sis int ih_irq; 991.1Sis}; 1001.1Sis 1011.1Sis/* 1021.1Sisvoid setsoftclock __P((void)); 1031.1Sis*/ 1041.1Sisvoid clearsoftclock __P((void)); 1051.1Sisint splsoftclock __P((void)); 1061.1Sis/* 1071.1Sisvoid setsoftnet __P((void)); 1081.1Sis*/ 1091.1Sisvoid clearsoftnet __P((void)); 1101.1Sisint splsoftnet __P((void)); 1111.1Sis 1121.1Sisvoid do_pending_int __P((void)); 1131.1Sis 1141.1Sisstatic __inline int splraise __P((int)); 1151.1Sisstatic __inline int spllower __P((int)); 1161.1Sisstatic __inline void splx __P((int)); 1171.1Sisstatic __inline void softintr __P((int)); 1181.1Sis 1191.1Sis/* 1201.1Sisextern volatile int cpl, ipending, astpending, tickspending; 1211.1Sis*/ 1221.1Sisextern int imask[]; 1231.1Sis 1241.1Sis/* 1251.1Sis * Reorder protection in the following inline functions is 1261.1Sis * achived with the "eieio" instruction which the assembler 1271.1Sis * seems to detect and then doen't move instructions past.... 1281.1Sis */ 1291.1Sisstatic __inline int 1301.1Sissplraise(ncpl) 1311.1Sis int ncpl; 1321.1Sis{ 1331.1Sis int ocpl; 1341.1Sis 1351.1Sis __asm__ volatile("sync; eieio\n"); /* don't reorder.... */ 1361.1Sis/* 1371.1Sis ocpl = cpl; 1381.1Sis cpl = ocpl | ncpl; 1391.1Sis*/ 1401.1Sis __asm__ volatile("sync; eieio\n"); /* reorder protect */ 1411.1Sis return (ocpl); 1421.1Sis} 1431.1Sis 1441.1Sisstatic __inline void 1451.1Sissplx(ncpl) 1461.1Sis int ncpl; 1471.1Sis{ 1481.1Sis 1491.1Sis __asm__ volatile("sync; eieio\n"); /* reorder protect */ 1501.1Sis/* 1511.1Sis cpl = ncpl; 1521.1Sis if (ipending & ~ncpl) 1531.1Sis do_pending_int(); 1541.1Sis*/ 1551.1Sis __asm__ volatile("sync; eieio\n"); /* reorder protect */ 1561.1Sis} 1571.1Sis 1581.1Sisstatic __inline int 1591.1Sisspllower(ncpl) 1601.1Sis int ncpl; 1611.1Sis{ 1621.1Sis int ocpl; 1631.1Sis 1641.1Sis __asm__ volatile("sync; eieio\n"); /* reorder protect */ 1651.1Sis/* 1661.1Sis ocpl = cpl; 1671.1Sis cpl = ncpl; 1681.1Sis if (ipending & ~ncpl) 1691.1Sis do_pending_int(); 1701.1Sis*/ 1711.1Sis __asm__ volatile("sync; eieio\n"); /* reorder protect */ 1721.1Sis return (ocpl); 1731.1Sis} 1741.1Sis 1751.1Sis/* Following code should be implemented with lwarx/stwcx to avoid 1761.1Sis * the disable/enable. i need to read the manual once more.... */ 1771.1Sisstatic __inline void 1781.1Sissoftintr(ipl) 1791.1Sis int ipl; 1801.1Sis{ 1811.1Sis int msrsave; 1821.1Sis 1831.1Sis __asm__ volatile("mfmsr %0" : "=r"(msrsave)); 1841.1Sis __asm__ volatile("mtmsr %0" :: "r"(msrsave & ~PSL_EE)); 1851.1Sis// ipending |= 1 << ipl; 1861.1Sis __asm__ volatile("mtmsr %0" :: "r"(msrsave)); 1871.1Sis} 1881.1Sis 1891.1Sis#define ICU_LEN 32 1901.1Sis 1911.1Sis/* Soft interrupt masks. */ 1921.1Sis/* 1931.1Sis#define SIR_CLOCK 28 1941.1Sis#define SIR_NET 29 1951.1Sis#define SIR_SERIAL 30 1961.1Sis*/ 1971.1Sis#define SPL_CLOCK 31 1981.1Sis 1991.1Sis/* 2001.1Sis * Hardware interrupt masks 2011.1Sis */ 2021.1Sis#define splbio() splraise(imask[IPL_BIO]) 2031.1Sis#define splnet() splraise(imask[IPL_NET]) 2041.1Sis#define spltty() splraise(imask[IPL_TTY]) 2051.1Sis#define splaudio() splraise(imask[IPL_AUDIO]) 2061.1Sis#define splclock() splraise(imask[IPL_CLOCK]) 2071.1Sis#define splstatclock() splclock() 2081.1Sis#define splserial() splraise(imask[IPL_SERIAL]) 2091.1Sis 2101.1Sis/* ADAM: see above 2111.1Sis#define spllpt() spltty() 2121.1Sis*/ 2131.1Sis 2141.1Sis/* 2151.1Sis * Software interrupt masks 2161.1Sis * 2171.1Sis * NOTE: splsoftclock() is used by hardclock() to lower the priority from 2181.1Sis * clock to softclock before it calls softclock(). 2191.1Sis */ 2201.1Sis#define spllowersoftclock() spllower(imask[IPL_SOFTCLOCK]) 2211.1Sis#define splsoftclock() splraise(imask[IPL_SOFTCLOCK]) 2221.1Sis#define splsoftnet() splraise(imask[IPL_SOFTNET]) 2231.1Sis#define splsoftserial() splraise(imask[IPL_SOFTSERIAL]) 2241.1Sis 2251.1Sis/* 2261.1Sis * Miscellaneous 2271.1Sis */ 2281.1Sis#define splimp() splraise(imask[IPL_IMP]) 2291.1Sis#define splhigh() splraise(imask[IPL_HIGH]) 2301.1Sis#define spl0() spllower(0) 2311.1Sis 2321.1Sis/* 2331.1Sis#define setsoftclock() softintr(SIR_CLOCK) 2341.1Sis#define setsoftnet() softintr(SIR_NET) 2351.1Sis#define setsoftserial() softintr(SIR_SERIAL) 2361.1Sis*/ 2371.1Sisextern long intrcnt[]; 2381.1Sis 2391.1Sis#define CNT_IRQ0 0 2401.1Sis#define CNT_CLOCK 64 2411.1Sis#define CNT_SOFTCLOCK 65 2421.1Sis#define CNT_SOFTNET 66 2431.1Sis#define CNT_SOFTSERIAL 67 2441.1Sis 2451.1Sis#endif /* !_LOCORE */ 2461.1Sis 2471.1Sis#endif /* !_MACPPC_INTR_H_ */ 248