ixp425_intr.h revision 1.7 1 1.7 matt /* $NetBSD: ixp425_intr.h,v 1.7 2008/01/08 02:07:53 matt Exp $ */
2 1.1 ichiro
3 1.1 ichiro /*
4 1.1 ichiro * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
5 1.1 ichiro * All rights reserved.
6 1.1 ichiro *
7 1.1 ichiro * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 1.1 ichiro *
9 1.1 ichiro * Redistribution and use in source and binary forms, with or without
10 1.1 ichiro * modification, are permitted provided that the following conditions
11 1.1 ichiro * are met:
12 1.1 ichiro * 1. Redistributions of source code must retain the above copyright
13 1.1 ichiro * notice, this list of conditions and the following disclaimer.
14 1.1 ichiro * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 ichiro * notice, this list of conditions and the following disclaimer in the
16 1.1 ichiro * documentation and/or other materials provided with the distribution.
17 1.1 ichiro * 3. All advertising materials mentioning features or use of this software
18 1.1 ichiro * must display the following acknowledgement:
19 1.1 ichiro * This product includes software developed for the NetBSD Project by
20 1.1 ichiro * Wasabi Systems, Inc.
21 1.1 ichiro * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.1 ichiro * or promote products derived from this software without specific prior
23 1.1 ichiro * written permission.
24 1.1 ichiro *
25 1.1 ichiro * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.1 ichiro * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.1 ichiro * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.1 ichiro * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.1 ichiro * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.1 ichiro * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1 ichiro * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1 ichiro * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.1 ichiro * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1 ichiro * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.1 ichiro * POSSIBILITY OF SUCH DAMAGE.
36 1.1 ichiro */
37 1.1 ichiro
38 1.1 ichiro #ifndef _IXP425_INTR_H_
39 1.1 ichiro #define _IXP425_INTR_H_
40 1.1 ichiro
41 1.1 ichiro #define ARM_IRQ_HANDLER _C_LABEL(ixp425_intr_dispatch)
42 1.1 ichiro
43 1.1 ichiro #ifndef _LOCORE
44 1.1 ichiro
45 1.1 ichiro #include <arm/armreg.h>
46 1.1 ichiro #include <arm/cpufunc.h>
47 1.1 ichiro
48 1.1 ichiro #include <arm/xscale/ixp425reg.h>
49 1.1 ichiro
50 1.1 ichiro #define IXPREG(reg) *((volatile u_int32_t*) (reg))
51 1.1 ichiro
52 1.6 perry static inline void __attribute__((__unused__))
53 1.1 ichiro ixp425_set_intrmask(void)
54 1.1 ichiro {
55 1.6 perry extern volatile uint32_t intr_enabled;
56 1.1 ichiro
57 1.1 ichiro IXPREG(IXP425_INT_ENABLE) = intr_enabled & IXP425_INT_HWMASK;
58 1.1 ichiro }
59 1.1 ichiro
60 1.7 matt #ifdef __HAVE_FAST_SOFTINTS
61 1.7 matt void ixp425_do_pending(void);
62 1.7 matt
63 1.1 ichiro #define INT_SWMASK \
64 1.1 ichiro ((1U << IXP425_INT_bit31) | (1U << IXP425_INT_bit30) | \
65 1.4 scw (1U << IXP425_INT_bit14) | (1U << IXP425_INT_bit11))
66 1.7 matt #endif
67 1.1 ichiro
68 1.6 perry static inline void __attribute__((__unused__))
69 1.1 ichiro ixp425_splx(int new)
70 1.1 ichiro {
71 1.6 perry extern volatile uint32_t intr_enabled;
72 1.6 perry extern volatile int current_spl_level;
73 1.6 perry extern volatile int ixp425_ipending;
74 1.1 ichiro extern void ixp425_do_pending(void);
75 1.1 ichiro int oldirqstate, hwpend;
76 1.1 ichiro
77 1.3 scw /* Don't let the compiler re-order this code with preceding code */
78 1.3 scw __insn_barrier();
79 1.3 scw
80 1.1 ichiro current_spl_level = new;
81 1.1 ichiro
82 1.1 ichiro hwpend = (ixp425_ipending & IXP425_INT_HWMASK) & ~new;
83 1.1 ichiro if (hwpend != 0) {
84 1.1 ichiro oldirqstate = disable_interrupts(I32_bit);
85 1.1 ichiro intr_enabled |= hwpend;
86 1.1 ichiro ixp425_set_intrmask();
87 1.1 ichiro restore_interrupts(oldirqstate);
88 1.1 ichiro }
89 1.1 ichiro
90 1.7 matt #ifdef __HAVE_FAST_SOFTINTS
91 1.1 ichiro if ((ixp425_ipending & INT_SWMASK) & ~new)
92 1.1 ichiro ixp425_do_pending();
93 1.7 matt #endif
94 1.1 ichiro }
95 1.1 ichiro
96 1.6 perry static inline int __attribute__((__unused__))
97 1.1 ichiro ixp425_splraise(int ipl)
98 1.1 ichiro {
99 1.6 perry extern volatile int current_spl_level;
100 1.1 ichiro extern int ixp425_imask[];
101 1.1 ichiro int old;
102 1.1 ichiro
103 1.1 ichiro old = current_spl_level;
104 1.1 ichiro current_spl_level |= ixp425_imask[ipl];
105 1.1 ichiro
106 1.3 scw /* Don't let the compiler re-order this code with subsequent code */
107 1.3 scw __insn_barrier();
108 1.3 scw
109 1.1 ichiro return (old);
110 1.1 ichiro }
111 1.1 ichiro
112 1.6 perry static inline int __attribute__((__unused__))
113 1.1 ichiro ixp425_spllower(int ipl)
114 1.1 ichiro {
115 1.6 perry extern volatile int current_spl_level;
116 1.1 ichiro extern int ixp425_imask[];
117 1.1 ichiro int old = current_spl_level;
118 1.1 ichiro
119 1.1 ichiro ixp425_splx(ixp425_imask[ipl]);
120 1.1 ichiro return(old);
121 1.1 ichiro }
122 1.1 ichiro
123 1.1 ichiro #if !defined(EVBARM_SPL_NOINLINE)
124 1.1 ichiro
125 1.1 ichiro #define splx(new) ixp425_splx(new)
126 1.1 ichiro #define _spllower(ipl) ixp425_spllower(ipl)
127 1.1 ichiro #define _splraise(ipl) ixp425_splraise(ipl)
128 1.7 matt #ifdef __HAVE_FAST_SOFTINTS
129 1.1 ichiro void _setsoftintr(int);
130 1.7 matt #endif
131 1.1 ichiro
132 1.1 ichiro #else
133 1.1 ichiro
134 1.1 ichiro int _splraise(int);
135 1.1 ichiro int _spllower(int);
136 1.1 ichiro void splx(int);
137 1.7 matt #ifdef __HAVE_FAST_SOFTINTS
138 1.1 ichiro void _setsoftintr(int);
139 1.7 matt #endif
140 1.1 ichiro
141 1.1 ichiro #endif /* ! EVBARM_SPL_NOINLINE */
142 1.1 ichiro
143 1.1 ichiro #endif /* _LOCORE */
144 1.1 ichiro
145 1.2 matt #endif /* _IXP425_INTR_H_ */
146