#ifndef _MACHINE_INTR_H_
#define _MACHINE_INTR_H_
#define __USE_MI_SOFTINTR
#include <sys/evcount.h>
#include <sys/softintr.h>
#include <machine/atomic.h>
#define SCB_IOVECBASE 0x0800
#define SCB_VECSIZE 0x0010
#define SCB_SIZE 0x2000
#define SCB_VECTOIDX(x) ((x) >> 4)
#define SCB_IDXTOVEC(x) ((x) << 4)
#define SCB_NIOVECS SCB_VECTOIDX(SCB_SIZE - SCB_IOVECBASE)
struct scbvec {
void (*scb_func)(void *, u_long);
void *scb_arg;
};
#define IPL_NONE ALPHA_PSL_IPL_0
#define IPL_SOFTINT ALPHA_PSL_IPL_SOFT
#define IPL_BIO ALPHA_PSL_IPL_IO
#define IPL_NET ALPHA_PSL_IPL_IO
#define IPL_TTY ALPHA_PSL_IPL_IO
#define IPL_SERIAL ALPHA_PSL_IPL_IO
#define IPL_AUDIO ALPHA_PSL_IPL_IO
#define IPL_VM ALPHA_PSL_IPL_IO
#define IPL_CLOCK ALPHA_PSL_IPL_CLOCK
#define IPL_SCHED ALPHA_PSL_IPL_CLOCK
#define IPL_IPI ALPHA_PSL_IPL_HIGH
#define IPL_HIGH ALPHA_PSL_IPL_HIGH
#define IPL_SOFTSERIAL 0
#define IPL_SOFTTTY IPL_SOFTSERIAL
#define IPL_SOFTCLOCK 1
#define IPL_SOFTNET 2
#define IPL_MPFLOOR IPL_AUDIO
#define IPL_MPSAFE 0
#define IST_UNUSABLE -1
#define IST_NONE 0
#define IST_PULSE 1
#define IST_EDGE 2
#define IST_LEVEL 3
#ifdef _KERNEL
void intr_barrier(void *);
#ifdef DIAGNOSTIC
void splassert_fail(int, int, const char *);
extern int splassert_ctl;
void splassert_check(int, const char *);
#define splassert(__wantipl) \
do { \
if (splassert_ctl > 0) { \
splassert_check(__wantipl, __func__); \
} \
} while (0)
#define splsoftassert(wantipl) splassert(IPL_SOFTINT)
#else
#define splassert(wantipl) do { } while (0)
#define splsoftassert(wantipl) do { } while (0)
#endif
#define splx(s) \
((s) == ALPHA_PSL_IPL_0 ? spl0() : (int)alpha_pal_swpipl(s))
int splraise(int);
int spl0(void);
#define splsoft() splraise(IPL_SOFTINT)
#define splsoftserial() splsoft()
#define splsoftclock() splsoft()
#define splsoftnet() splsoft()
#define splnet() splraise(IPL_NET)
#define splbio() splraise(IPL_BIO)
#define spltty() splraise(IPL_TTY)
#define splserial() splraise(IPL_SERIAL)
#define splaudio() splraise(IPL_AUDIO)
#define splvm() splraise(IPL_VM)
#define splclock() splraise(IPL_CLOCK)
#define splstatclock() splraise(IPL_CLOCK)
#define splsched() splraise(IPL_SCHED)
#define splipi() splraise(IPL_IPI)
#define splhigh() splraise(IPL_HIGH)
#define ALPHA_IPI_HALT (1UL << 0)
#define ALPHA_IPI_SHOOTDOWN (1UL << 1)
#define ALPHA_IPI_IMB (1UL << 2)
#define ALPHA_IPI_AST (1UL << 3)
#define ALPHA_IPI_SYNCH_FPU (1UL << 4)
#define ALPHA_IPI_DISCARD_FPU (1UL << 5)
#define ALPHA_IPI_PAUSE (1UL << 6)
#define ALPHA_NIPIS 7
struct cpu_info;
struct trapframe;
void alpha_ipi_process(struct cpu_info *, struct trapframe *);
#ifdef MP_LOCKDEBUG
void alpha_ipi_process_with_frame(struct cpu_info *);
#else
#define alpha_ipi_process_with_frame(ci) alpha_ipi_process((ci), NULL)
#endif
void alpha_send_ipi(unsigned long, unsigned long);
void alpha_broadcast_ipi(unsigned long);
void alpha_multicast_ipi(unsigned long, unsigned long);
struct alpha_shared_intrhand {
TAILQ_ENTRY(alpha_shared_intrhand)
ih_q;
struct alpha_shared_intr *ih_intrhead;
int (*ih_fn)(void *);
void *ih_arg;
int ih_level;
unsigned int ih_num;
struct evcount ih_count;
};
struct alpha_shared_intr {
TAILQ_HEAD(,alpha_shared_intrhand)
intr_q;
void *intr_private;
int intr_sharetype;
int intr_dfltsharetype;
int intr_nstrays;
int intr_maxstrays;
};
#define ALPHA_SHARED_INTR_DISABLE(asi, num) \
((asi)[num].intr_maxstrays != 0 && \
(asi)[num].intr_nstrays == (asi)[num].intr_maxstrays)
extern int intr_shared_edge;
extern unsigned long ssir;
#define softintr(x) atomic_setbits_ulong(&ssir, 1 << (x))
void dosoftint(void);
struct alpha_shared_intr *alpha_shared_intr_alloc(unsigned int);
int alpha_shared_intr_dispatch(struct alpha_shared_intr *,
unsigned int);
void *alpha_shared_intr_establish(struct alpha_shared_intr *,
unsigned int, int, int, int (*)(void *), void *, const char *);
void alpha_shared_intr_disestablish(struct alpha_shared_intr *, void *);
int alpha_shared_intr_get_sharetype(struct alpha_shared_intr *,
unsigned int);
int alpha_shared_intr_isactive(struct alpha_shared_intr *,
unsigned int);
int alpha_shared_intr_firstactive(struct alpha_shared_intr *,
unsigned int);
void alpha_shared_intr_set_dfltsharetype(struct alpha_shared_intr *,
unsigned int, int);
void alpha_shared_intr_set_maxstrays(struct alpha_shared_intr *,
unsigned int, int);
void alpha_shared_intr_reset_strays(struct alpha_shared_intr *,
unsigned int);
void alpha_shared_intr_stray(struct alpha_shared_intr *, unsigned int,
const char *);
void alpha_shared_intr_set_private(struct alpha_shared_intr *,
unsigned int, void *);
void *alpha_shared_intr_get_private(struct alpha_shared_intr *,
unsigned int);
extern struct scbvec scb_iovectab[];
void scb_init(void);
void scb_set(u_long, void (*)(void *, u_long), void *);
u_long scb_alloc(void (*)(void *, u_long), void *);
void scb_free(u_long);
#define SCB_ALLOC_FAILED ((u_long) -1)
#endif
#endif