2008-04-29 00:22:51 +04:00
|
|
|
/* $NetBSD: marvell_intr.h,v 1.15 2008/04/28 20:23:32 martin Exp $ */
|
2003-03-06 01:08:18 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Charles M. Hannum.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MVPPPC_INTR_H_
|
|
|
|
#define _MVPPPC_INTR_H_
|
|
|
|
|
2008-04-24 15:36:51 +04:00
|
|
|
#include <powerpc/psl.h>
|
|
|
|
#include <powerpc/frame.h>
|
|
|
|
|
2003-03-06 01:08:18 +03:00
|
|
|
/*
|
|
|
|
* Interrupt Priority Levels
|
|
|
|
*/
|
|
|
|
#define IPL_NONE 0 /* nothing */
|
|
|
|
#define IPL_SOFTCLOCK 1 /* timeouts */
|
2007-12-03 18:33:00 +03:00
|
|
|
#define IPL_SOFTBIO 2 /* block I/O */
|
|
|
|
#define IPL_SOFTNET 3 /* protocol stacks */
|
|
|
|
#define IPL_SOFTSERIAL 4 /* serial */
|
2003-03-06 01:08:18 +03:00
|
|
|
#define IPL_VM 12 /* memory allocation */
|
2007-12-03 18:33:00 +03:00
|
|
|
#define IPL_SCHED 14 /* clock */
|
2003-03-06 01:08:18 +03:00
|
|
|
#define IPL_HIGH 15 /* everything */
|
|
|
|
#define NIPL 16
|
|
|
|
#define IPL_PRIMASK 0xf
|
|
|
|
#define IPL_EE 0x10 /* enable external interrupts on splx */
|
|
|
|
|
|
|
|
/* Interrupt sharing types. */
|
|
|
|
#define IST_NONE 0 /* none */
|
|
|
|
#define IST_PULSE 1 /* pulsed */
|
|
|
|
#define IST_EDGE 2 /* edge-triggered */
|
|
|
|
#define IST_LEVEL 3 /* level-triggered */
|
|
|
|
#define IST_SOFT 4 /* software-triggered */
|
|
|
|
#define IST_CLOCK 5 /* exclusive for clock */
|
|
|
|
#define NIST 6
|
|
|
|
|
|
|
|
#if !defined(_LOCORE) && defined(_KERNEL)
|
|
|
|
|
2003-09-04 01:33:31 +04:00
|
|
|
#define CLKF_BASEPRI(frame) ((frame)->pri == IPL_NONE)
|
|
|
|
|
2003-03-06 01:08:18 +03:00
|
|
|
/*
|
|
|
|
* we support 128 IRQs:
|
|
|
|
* 96 (ICU_LEN) hard interrupt IRQs:
|
|
|
|
* - 64 Main Cause IRQs,
|
|
|
|
* - 32 GPP IRQs,
|
|
|
|
* and 32 softint IRQs
|
|
|
|
*/
|
|
|
|
#define ICU_LEN 96 /* number of HW IRQs */
|
|
|
|
#define IRQ_GPP_BASE 64 /* base of GPP IRQs */
|
|
|
|
#define IRQ_GPP_SUM (32+24) /* GPP[7..0] interrupt */ /* XXX */
|
|
|
|
#define NIRQ 128 /* total # of HW IRQs */
|
|
|
|
|
|
|
|
#define IMASK_ICU_LO 0
|
|
|
|
#define IMASK_ICU_HI 1
|
|
|
|
#define IMASK_ICU_GPP 2
|
|
|
|
#define IMASK_SOFTINT 3
|
|
|
|
#define IMASK_WORDSHIFT 5 /* log2(32) */
|
|
|
|
#define IMASK_BITMASK ~((~0) << IMASK_WORDSHIFT)
|
|
|
|
|
|
|
|
#define IRQ_IS_GPP(irq) ((irq >= IRQ_GPP_BASE) && (irq < ICU_LEN))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* interrupt mask bit vector
|
|
|
|
*/
|
2003-04-09 19:44:26 +04:00
|
|
|
typedef struct {
|
|
|
|
u_int32_t bits[4];
|
|
|
|
} imask_t __attribute__ ((aligned(16)));
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void imask_zero(imask_t *);
|
|
|
|
static inline void imask_zero_v(volatile imask_t *);
|
|
|
|
static inline void imask_dup_v(imask_t *, const volatile imask_t *);
|
|
|
|
static inline void imask_and(imask_t *, const imask_t *);
|
|
|
|
static inline void imask_andnot_v(volatile imask_t *, const imask_t *);
|
|
|
|
static inline void imask_andnot_icu_vv(volatile imask_t *, const volatile imask_t *);
|
|
|
|
static inline int imask_empty(const imask_t *);
|
|
|
|
static inline void imask_orbit(imask_t *, int);
|
|
|
|
static inline void imask_orbit_v(volatile imask_t *, int);
|
|
|
|
static inline void imask_clrbit(imask_t *, int);
|
|
|
|
static inline void imask_clrbit_v(volatile imask_t *, int);
|
|
|
|
static inline u_int32_t imask_andbit_v(const volatile imask_t *, int);
|
|
|
|
static inline int imask_test_v(const volatile imask_t *, const imask_t *);
|
|
|
|
|
|
|
|
static inline void
|
2003-03-06 01:08:18 +03:00
|
|
|
imask_zero(imask_t *idp)
|
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
idp->bits[IMASK_ICU_LO] = 0;
|
|
|
|
idp->bits[IMASK_ICU_HI] = 0;
|
|
|
|
idp->bits[IMASK_ICU_GPP] = 0;
|
|
|
|
idp->bits[IMASK_SOFTINT] = 0;
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-03-06 01:08:18 +03:00
|
|
|
imask_zero_v(volatile imask_t *idp)
|
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
idp->bits[IMASK_ICU_LO] = 0;
|
|
|
|
idp->bits[IMASK_ICU_HI] = 0;
|
|
|
|
idp->bits[IMASK_ICU_GPP] = 0;
|
|
|
|
idp->bits[IMASK_SOFTINT] = 0;
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-04-09 19:44:26 +04:00
|
|
|
imask_dup_v(imask_t *idp, const volatile imask_t *isp)
|
2003-03-06 01:08:18 +03:00
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
*idp = *isp;
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-04-09 19:44:26 +04:00
|
|
|
imask_and(imask_t *idp, const imask_t *isp)
|
2003-03-06 01:08:18 +03:00
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
idp->bits[IMASK_ICU_LO] &= isp->bits[IMASK_ICU_LO];
|
|
|
|
idp->bits[IMASK_ICU_HI] &= isp->bits[IMASK_ICU_HI];
|
|
|
|
idp->bits[IMASK_ICU_GPP] &= isp->bits[IMASK_ICU_GPP];
|
|
|
|
idp->bits[IMASK_SOFTINT] &= isp->bits[IMASK_SOFTINT];
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-04-09 19:44:26 +04:00
|
|
|
imask_andnot_v(volatile imask_t *idp, const imask_t *isp)
|
2003-03-06 01:08:18 +03:00
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
idp->bits[IMASK_ICU_LO] &= ~isp->bits[IMASK_ICU_LO];
|
|
|
|
idp->bits[IMASK_ICU_HI] &= ~isp->bits[IMASK_ICU_HI];
|
|
|
|
idp->bits[IMASK_ICU_GPP] &= ~isp->bits[IMASK_ICU_GPP];
|
|
|
|
idp->bits[IMASK_SOFTINT] &= ~isp->bits[IMASK_SOFTINT];
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-04-09 19:44:26 +04:00
|
|
|
imask_andnot_icu_vv(volatile imask_t *idp, const volatile imask_t *isp)
|
2003-03-06 01:08:18 +03:00
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
idp->bits[IMASK_ICU_LO] &= ~isp->bits[IMASK_ICU_LO];
|
|
|
|
idp->bits[IMASK_ICU_HI] &= ~isp->bits[IMASK_ICU_HI];
|
|
|
|
idp->bits[IMASK_ICU_GPP] &= ~isp->bits[IMASK_ICU_GPP];
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline int
|
2003-04-09 19:44:26 +04:00
|
|
|
imask_empty(const imask_t *isp)
|
2003-03-06 01:08:18 +03:00
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
return (! (isp->bits[IMASK_ICU_LO] | isp->bits[IMASK_ICU_HI] |
|
|
|
|
isp->bits[IMASK_ICU_GPP]| isp->bits[IMASK_SOFTINT]));
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-03-06 01:08:18 +03:00
|
|
|
imask_orbit(imask_t *idp, int bitno)
|
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
idp->bits[bitno>>IMASK_WORDSHIFT] |= (1 << (bitno&IMASK_BITMASK));
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-03-06 01:08:18 +03:00
|
|
|
imask_orbit_v(volatile imask_t *idp, int bitno)
|
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
idp->bits[bitno>>IMASK_WORDSHIFT] |= (1 << (bitno&IMASK_BITMASK));
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-03-06 01:08:18 +03:00
|
|
|
imask_clrbit(imask_t *idp, int bitno)
|
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
idp->bits[bitno>>IMASK_WORDSHIFT] &= ~(1 << (bitno&IMASK_BITMASK));
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-03-06 01:08:18 +03:00
|
|
|
imask_clrbit_v(volatile imask_t *idp, int bitno)
|
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
idp->bits[bitno>>IMASK_WORDSHIFT] &= ~(1 << (bitno&IMASK_BITMASK));
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline u_int32_t
|
2003-04-09 19:44:26 +04:00
|
|
|
imask_andbit_v(const volatile imask_t *idp, int bitno)
|
2003-03-06 01:08:18 +03:00
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
return idp->bits[bitno>>IMASK_WORDSHIFT] & (1 << (bitno&IMASK_BITMASK));
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline int
|
2003-04-09 19:44:26 +04:00
|
|
|
imask_test_v(const volatile imask_t *idp, const imask_t *isp)
|
2003-03-06 01:08:18 +03:00
|
|
|
{
|
2003-04-09 19:44:26 +04:00
|
|
|
return ((idp->bits[IMASK_ICU_LO] & isp->bits[IMASK_ICU_LO]) ||
|
|
|
|
(idp->bits[IMASK_ICU_HI] & isp->bits[IMASK_ICU_HI]) ||
|
|
|
|
(idp->bits[IMASK_ICU_GPP] & isp->bits[IMASK_ICU_GPP])||
|
|
|
|
(idp->bits[IMASK_SOFTINT] & isp->bits[IMASK_SOFTINT]));
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef EXT_INTR_STATS
|
|
|
|
/*
|
|
|
|
* ISR timing stats
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct ext_intr_hist {
|
|
|
|
u_int64_t tcause;
|
|
|
|
u_int64_t tcommit;
|
|
|
|
u_int64_t tstart;
|
|
|
|
u_int64_t tfin;
|
|
|
|
} ext_intr_hist_t __attribute__ ((aligned(32)));
|
|
|
|
|
|
|
|
typedef struct ext_intr_stat {
|
|
|
|
struct ext_intr_hist *histp;
|
|
|
|
unsigned int histix;
|
|
|
|
u_int64_t cnt;
|
|
|
|
u_int64_t sum;
|
|
|
|
u_int64_t min;
|
|
|
|
u_int64_t max;
|
|
|
|
u_int64_t pnd;
|
|
|
|
u_int64_t borrowed;
|
|
|
|
struct ext_intr_stat *save;
|
|
|
|
unsigned long preempted[NIRQ]; /* XXX */
|
|
|
|
} ext_intr_stat_t __attribute__ ((aligned(32)));
|
|
|
|
|
|
|
|
extern int intr_depth_max;
|
|
|
|
extern int ext_intr_stats_enb;
|
|
|
|
extern ext_intr_stat_t ext_intr_stats[];
|
|
|
|
extern ext_intr_stat_t *ext_intr_statp;
|
|
|
|
|
|
|
|
extern void ext_intr_stats_init __P((void));
|
|
|
|
extern void ext_intr_stats_cause
|
|
|
|
__P((u_int32_t, u_int32_t, u_int32_t, u_int32_t));
|
|
|
|
extern void ext_intr_stats_pend
|
|
|
|
__P((u_int32_t, u_int32_t, u_int32_t, u_int32_t));
|
|
|
|
extern void ext_intr_stats_commit __P((imask_t *));
|
|
|
|
extern void ext_intr_stats_commit_m __P((imask_t *));
|
|
|
|
extern void ext_intr_stats_commit_irq __P((u_int));
|
|
|
|
extern u_int64_t ext_intr_stats_pre __P((int));
|
|
|
|
extern void ext_intr_stats_post __P((int, u_int64_t));
|
|
|
|
|
|
|
|
#define EXT_INTR_STATS_INIT() ext_intr_stats_init()
|
|
|
|
#define EXT_INTR_STATS_CAUSE(l, h, g, s) ext_intr_stats_cause(l, h, g, s)
|
|
|
|
#define EXT_INTR_STATS_COMMIT_M(m) ext_intr_stats_commit_m(m)
|
|
|
|
#define EXT_INTR_STATS_COMMIT_IRQ(i) ext_intr_stats_commit_irq(i)
|
|
|
|
#define EXT_INTR_STATS_DECL(t) u_int64_t t
|
|
|
|
#define EXT_INTR_STATS_PRE(i, t) t = ext_intr_stats_pre(i)
|
|
|
|
#define EXT_INTR_STATS_POST(i, t) ext_intr_stats_post(i, t)
|
|
|
|
#define EXT_INTR_STATS_PEND(l, h, g, s) ext_intr_stats_pend(l, h, g, s)
|
|
|
|
#define EXT_INTR_STATS_PEND_IRQ(i) ext_intr_stats[i].pnd++
|
|
|
|
#define EXT_INTR_STATS_DEPTH() \
|
|
|
|
intr_depth_max = (intr_depth > intr_depth_max) ? \
|
|
|
|
intr_depth : intr_depth_max
|
|
|
|
|
|
|
|
#else /* EXT_INTR_STATS */
|
|
|
|
|
|
|
|
#define EXT_INTR_STATS_INIT()
|
|
|
|
#define EXT_INTR_STATS_CAUSE(l, h, g, s)
|
|
|
|
#define EXT_INTR_STATS_COMMIT_M(m)
|
|
|
|
#define EXT_INTR_STATS_COMMIT_IRQ(i)
|
|
|
|
#define EXT_INTR_STATS_DECL(t)
|
|
|
|
#define EXT_INTR_STATS_PRE(irq, t)
|
|
|
|
#define EXT_INTR_STATS_POST(i, t)
|
|
|
|
#define EXT_INTR_STATS_PEND(l, h, g, s)
|
|
|
|
#define EXT_INTR_STATS_PEND_IRQ(i)
|
|
|
|
#define EXT_INTR_STATS_DEPTH()
|
|
|
|
|
|
|
|
#endif /* EXT_INTR_STATS */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SPL_STATS
|
|
|
|
typedef struct spl_hist {
|
|
|
|
int level;
|
|
|
|
void *addr;
|
|
|
|
u_int64_t time;
|
|
|
|
} spl_hist_t;
|
|
|
|
|
|
|
|
extern void spl_stats_init();
|
|
|
|
extern void spl_stats_log();
|
|
|
|
extern unsigned int spl_stats_enb;
|
|
|
|
|
|
|
|
#define SPL_STATS_INIT() spl_stats_init()
|
|
|
|
#define SPL_STATS_LOG(ipl, cc) spl_stats_log((ipl), (cc))
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define SPL_STATS_INIT()
|
|
|
|
#define SPL_STATS_LOG(ipl, cc)
|
|
|
|
|
|
|
|
#endif /* SPL_STATS */
|
|
|
|
|
|
|
|
|
|
|
|
void intr_dispatch __P((void));
|
|
|
|
#ifdef SPL_INLINE
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline int splraise __P((int));
|
|
|
|
static inline int spllower __P((int));
|
|
|
|
static inline void splx __P((int));
|
2003-03-06 01:08:18 +03:00
|
|
|
#else
|
|
|
|
extern int splraise __P((int));
|
|
|
|
extern int spllower __P((int));
|
|
|
|
extern void splx __P((int));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern volatile int tickspending;
|
|
|
|
|
|
|
|
extern volatile imask_t ipending;
|
|
|
|
extern imask_t imask[];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* inlines for manipulating PSL_EE
|
|
|
|
*/
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-03-06 01:08:18 +03:00
|
|
|
extintr_restore(register_t omsr)
|
|
|
|
{
|
2005-12-24 23:06:46 +03:00
|
|
|
__asm volatile ("sync; mtmsr %0;" :: "r"(omsr));
|
2003-03-06 01:08:18 +03:00
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline register_t
|
2003-03-06 01:08:18 +03:00
|
|
|
extintr_enable(void)
|
|
|
|
{
|
|
|
|
register_t omsr;
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
__asm volatile("sync;");
|
|
|
|
__asm volatile("mfmsr %0;" : "=r"(omsr));
|
|
|
|
__asm volatile("mtmsr %0;" :: "r"(omsr | PSL_EE));
|
2003-03-06 01:08:18 +03:00
|
|
|
|
|
|
|
return omsr;
|
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline register_t
|
2003-03-06 01:08:18 +03:00
|
|
|
extintr_disable(void)
|
|
|
|
{
|
|
|
|
register_t omsr;
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
__asm volatile("mfmsr %0;" : "=r"(omsr));
|
|
|
|
__asm volatile("mtmsr %0;" :: "r"(omsr & ~PSL_EE));
|
|
|
|
__asm volatile("isync;");
|
2003-03-06 01:08:18 +03:00
|
|
|
|
|
|
|
return omsr;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SPL_INLINE
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline int
|
2003-03-06 01:08:18 +03:00
|
|
|
splraise(int ncpl)
|
|
|
|
{
|
|
|
|
int ocpl;
|
|
|
|
register_t omsr;
|
|
|
|
|
|
|
|
omsr = extintr_disable();
|
|
|
|
ocpl = cpl;
|
|
|
|
if (ncpl > cpl) {
|
|
|
|
SPL_STATS_LOG(ncpl, 0);
|
|
|
|
cpl = ncpl;
|
|
|
|
if ((ncpl == IPL_HIGH) && ((omsr & PSL_EE) != 0)) {
|
|
|
|
/* leave external interrupts disabled */
|
|
|
|
return (ocpl | IPL_EE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
extintr_restore(omsr);
|
|
|
|
return (ocpl);
|
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline void
|
2003-03-06 01:08:18 +03:00
|
|
|
splx(int xcpl)
|
|
|
|
{
|
|
|
|
imask_t *ncplp;
|
|
|
|
register_t omsr;
|
|
|
|
int ncpl = xcpl & IPL_PRIMASK;
|
|
|
|
|
|
|
|
ncplp = &imask[ncpl];
|
|
|
|
|
|
|
|
omsr = extintr_disable();
|
|
|
|
if (ncpl < cpl) {
|
|
|
|
cpl = ncpl;
|
|
|
|
SPL_STATS_LOG(ncpl, 0);
|
|
|
|
if (imask_test_v(&ipending, ncplp))
|
|
|
|
intr_dispatch();
|
|
|
|
}
|
|
|
|
if (xcpl & IPL_EE)
|
|
|
|
omsr |= PSL_EE;
|
|
|
|
extintr_restore(omsr);
|
|
|
|
}
|
|
|
|
|
2005-12-24 23:06:46 +03:00
|
|
|
static inline int
|
2003-03-06 01:08:18 +03:00
|
|
|
spllower(int ncpl)
|
|
|
|
{
|
|
|
|
int ocpl;
|
|
|
|
imask_t *ncplp;
|
|
|
|
register_t omsr;
|
|
|
|
|
|
|
|
ncpl &= IPL_PRIMASK;
|
|
|
|
ncplp = &imask[ncpl];
|
|
|
|
|
|
|
|
omsr = extintr_disable();
|
|
|
|
ocpl = cpl;
|
|
|
|
cpl = ncpl;
|
|
|
|
SPL_STATS_LOG(ncpl, 0);
|
|
|
|
#ifdef EXT_INTR_STATS
|
|
|
|
ext_intr_statp = 0;
|
|
|
|
#endif
|
|
|
|
if (imask_test_v(&ipending, ncplp))
|
|
|
|
intr_dispatch();
|
|
|
|
|
|
|
|
if (ncpl < IPL_HIGH)
|
|
|
|
omsr |= PSL_EE;
|
|
|
|
extintr_restore(omsr);
|
|
|
|
|
|
|
|
return (ocpl);
|
|
|
|
}
|
|
|
|
#endif /* SPL_INLINE */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Soft interrupt IRQs
|
|
|
|
* see also intrnames[] in locore.S
|
|
|
|
*/
|
|
|
|
#define SIR_BASE (NIRQ-32)
|
2007-10-17 23:52:51 +04:00
|
|
|
#define SIXBIT(ipl) ((ipl) - SIR_BASE) /* XXX rennovate later */
|
2003-03-06 01:08:18 +03:00
|
|
|
#define SIR_SOFTCLOCK (NIRQ-5)
|
2007-10-17 23:52:51 +04:00
|
|
|
#define SIR_CLOCK SIXBIT(SIR_SOFTCLOCK) /* XXX rennovate later */
|
2003-03-17 19:54:16 +03:00
|
|
|
#define SIR_SOFTNET (NIRQ-4)
|
2007-12-03 18:33:00 +03:00
|
|
|
#define SIR_SOFTBIO (NIRQ-3)
|
2003-03-17 19:54:16 +03:00
|
|
|
#define SIR_SOFTSERIAL (NIRQ-2)
|
2003-03-06 01:08:18 +03:00
|
|
|
#define SIR_HWCLOCK (NIRQ-1)
|
2007-10-17 23:52:51 +04:00
|
|
|
#define SPL_CLOCK SIXBIT(SIR_HWCLOCK) /* XXX rennovate later */
|
2003-03-17 19:54:16 +03:00
|
|
|
#define SIR_RES ~(SIBIT(SIR_SOFTCLOCK)|\
|
|
|
|
SIBIT(SIR_SOFTNET)|\
|
2007-12-03 18:33:00 +03:00
|
|
|
SIBIT(SIR_SOFTBIO)|\
|
2003-03-17 19:54:16 +03:00
|
|
|
SIBIT(SIR_SOFTSERIAL)|\
|
|
|
|
SIBIT(SIR_HWCLOCK))
|
2003-03-06 01:08:18 +03:00
|
|
|
|
2004-06-01 04:49:41 +04:00
|
|
|
struct intrhand;
|
2003-03-17 19:54:16 +03:00
|
|
|
|
2003-03-06 01:08:18 +03:00
|
|
|
/*
|
|
|
|
* Miscellaneous
|
|
|
|
*/
|
|
|
|
#define spl0() spllower(IPL_NONE)
|
|
|
|
|
2006-12-21 18:55:21 +03:00
|
|
|
typedef int ipl_t;
|
|
|
|
typedef struct {
|
|
|
|
ipl_t _ipl;
|
|
|
|
} ipl_cookie_t;
|
|
|
|
|
|
|
|
static inline ipl_cookie_t
|
|
|
|
makeiplcookie(ipl_t ipl)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (ipl_cookie_t){._ipl = ipl};
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
splraiseipl(ipl_cookie_t icookie)
|
|
|
|
{
|
|
|
|
|
|
|
|
return splraise(icookie._ipl);
|
|
|
|
}
|
2005-11-27 17:01:45 +03:00
|
|
|
|
|
|
|
#include <sys/spl.h>
|
|
|
|
|
2003-03-06 01:08:18 +03:00
|
|
|
#define SIBIT(ipl) (1 << ((ipl) - SIR_BASE))
|
|
|
|
|
|
|
|
void *intr_establish(int, int, int, int (*)(void *), void *);
|
|
|
|
void intr_disestablish(void *);
|
|
|
|
void init_interrupt(void);
|
|
|
|
const char * intr_typename(int);
|
|
|
|
const char * intr_string(int);
|
|
|
|
const struct evcnt * intr_evcnt(int);
|
|
|
|
void ext_intr(struct intrframe *);
|
|
|
|
|
2007-10-17 23:52:51 +04:00
|
|
|
/* the following are needed to compile until this port is properly
|
|
|
|
* converted to ppcoea-rennovation.
|
|
|
|
*/
|
|
|
|
void genppc_cpu_configure(void);
|
|
|
|
|
2003-03-06 01:08:18 +03:00
|
|
|
void strayintr(int);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* defines for indexing intrcnt
|
|
|
|
*/
|
|
|
|
#define CNT_IRQ0 0
|
|
|
|
#define CNT_CLOCK SIR_HWCLOCK
|
|
|
|
#define CNT_SOFTCLOCK SIR_SOFTCLOCK
|
|
|
|
#define CNT_SOFTNET SIR_NET
|
|
|
|
#define CNT_SOFTSERIAL SIR_SOFTSERIAL
|
2007-12-03 18:33:00 +03:00
|
|
|
#define CNT_SOFTBIO SIR_BIO
|
2003-03-06 01:08:18 +03:00
|
|
|
|
|
|
|
#endif /* !_LOCORE */
|
|
|
|
|
|
|
|
#endif /* _MVPPPC_INTR_H_ */
|