166458Sdfr/*-
2203883Smarcel * Copyright (c) 2007-2010 Marcel Moolenaar
366458Sdfr * Copyright (c) 1998 Doug Rabson
466458Sdfr * All rights reserved.
566458Sdfr *
666458Sdfr * Redistribution and use in source and binary forms, with or without
766458Sdfr * modification, are permitted provided that the following conditions
866458Sdfr * are met:
966458Sdfr * 1. Redistributions of source code must retain the above copyright
1066458Sdfr *    notice, this list of conditions and the following disclaimer.
1166458Sdfr * 2. Redistributions in binary form must reproduce the above copyright
1266458Sdfr *    notice, this list of conditions and the following disclaimer in the
1366458Sdfr *    documentation and/or other materials provided with the distribution.
1466458Sdfr *
1566458Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1666458Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1766458Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1866458Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1966458Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2066458Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2166458Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2266458Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2366458Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2466458Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2566458Sdfr * SUCH DAMAGE.
2666458Sdfr *
2766458Sdfr * $FreeBSD: releng/10.3/sys/ia64/include/intr.h 205726 2010-03-27 05:40:50Z marcel $
2866458Sdfr */
2966458Sdfr
3066458Sdfr#ifndef _MACHINE_INTR_H_
31203883Smarcel#define	_MACHINE_INTR_H_
3266458Sdfr
33205234Smarcel#define	IA64_NXIVS		256	/* External Interrupt Vectors */
34205234Smarcel#define	IA64_MIN_XIV		16
35205234Smarcel
36205234Smarcel#define	IA64_MAX_HWPRIO		14
37205234Smarcel
38205726Smarcelstruct pcpu;
39204425Smarcelstruct sapic;
40205234Smarcelstruct thread;
41205234Smarcelstruct trapframe;
42204425Smarcel
4384541Sdfr/*
4484541Sdfr * Layout of the Processor Interrupt Block.
4584541Sdfr */
46203883Smarcelstruct ia64_pib
4784541Sdfr{
48203883Smarcel	uint64_t	ib_ipi[65536][2];	/* 64K-way IPIs (1MB area). */
49203883Smarcel	uint8_t		_rsvd1[0xe0000];
50203883Smarcel	uint8_t		ib_inta;		/* Generate INTA cycle. */
51203883Smarcel	uint8_t		_rsvd2[7];
52203883Smarcel	uint8_t		ib_xtp;			/* External Task Priority. */
53203883Smarcel	uint8_t		_rsvd3[7];
54203883Smarcel	uint8_t		_rsvd4[0x1fff0];
5584541Sdfr};
5666458Sdfr
57205234Smarcelenum ia64_xiv_use {
58205234Smarcel	IA64_XIV_FREE,
59205234Smarcel	IA64_XIV_ARCH,		/* Architecturally defined. */
60205234Smarcel	IA64_XIV_PLAT,		/* Platform defined. */
61205234Smarcel	IA64_XIV_IPI,		/* Used for IPIs. */
62205234Smarcel	IA64_XIV_IRQ		/* Used for external interrupts. */
63205234Smarcel};
64205234Smarcel
65205234Smarceltypedef u_int (ia64_ihtype)(struct thread *, u_int, struct trapframe *);
66205234Smarcel
67203883Smarcelextern struct ia64_pib *ia64_pib;
68108737Smarcel
69205726Smarcelvoid	ia64_bind_intr(void);
70205234Smarcelvoid	ia64_handle_intr(struct trapframe *);
71204425Smarcelint	ia64_setup_intr(const char *, int, driver_filter_t, driver_intr_t,
72204425Smarcel	    void *, enum intr_type, void **);
73204425Smarcelint	ia64_teardown_intr(void *);
7484541Sdfr
75205234Smarcelvoid	ia64_xiv_init(void);
76205234Smarcelu_int	ia64_xiv_alloc(u_int, enum ia64_xiv_use, ia64_ihtype);
77205234Smarcelint	ia64_xiv_free(u_int, enum ia64_xiv_use);
78205234Smarcelint	ia64_xiv_reserve(u_int, enum ia64_xiv_use, ia64_ihtype);
79205234Smarcel
80205726Smarcelint	sapic_bind_intr(u_int, struct pcpu *);
81204425Smarcelint	sapic_config_intr(u_int, enum intr_trigger, enum intr_polarity);
82204425Smarcelstruct sapic *sapic_create(u_int, u_int, uint64_t);
83204425Smarcelint	sapic_enable(struct sapic *, u_int, u_int);
84204425Smarcelvoid	sapic_eoi(struct sapic *, u_int);
85204425Smarcelstruct sapic *sapic_lookup(u_int, u_int *);
86204425Smarcelvoid	sapic_mask(struct sapic *, u_int);
87204425Smarcelvoid	sapic_unmask(struct sapic *, u_int);
88204425Smarcel
89204425Smarcel#ifdef DDB
90204425Smarcelvoid	sapic_print(struct sapic *, u_int);
91204425Smarcel#endif
92204425Smarcel
9366458Sdfr#endif /* !_MACHINE_INTR_H_ */
94