intr_machdep.h revision 121982
1121982Sjhb/*-
2121982Sjhb * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org>
3121982Sjhb * All rights reserved.
4121982Sjhb *
5121982Sjhb * Redistribution and use in source and binary forms, with or without
6121982Sjhb * modification, are permitted provided that the following conditions
7121982Sjhb * are met:
8121982Sjhb * 1. Redistributions of source code must retain the above copyright
9121982Sjhb *    notice, this list of conditions and the following disclaimer.
10121982Sjhb * 2. Redistributions in binary form must reproduce the above copyright
11121982Sjhb *    notice, this list of conditions and the following disclaimer in the
12121982Sjhb *    documentation and/or other materials provided with the distribution.
13121982Sjhb *
14121982Sjhb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15121982Sjhb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16121982Sjhb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17121982Sjhb * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18121982Sjhb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19121982Sjhb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20121982Sjhb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21121982Sjhb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22121982Sjhb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23121982Sjhb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24121982Sjhb * SUCH DAMAGE.
25121982Sjhb *
26121982Sjhb * $FreeBSD: head/sys/amd64/include/intr_machdep.h 121982 2003-11-03 21:25:52Z jhb $
27121982Sjhb */
28121982Sjhb
29121982Sjhb#ifndef __MACHINE_INTR_MACHDEP_H__
30121982Sjhb#define	__MACHINE_INTR_MACHDEP_H__
31121982Sjhb
32121982Sjhb#ifdef _KERNEL
33121982Sjhb
34121982Sjhb/* With I/O APIC's we can have up to 159 interrupts. */
35121982Sjhb#define	NUM_IO_INTS	159
36121982Sjhb#define	INTRCNT_COUNT	(1 + NUM_IO_INTS * 2)
37121982Sjhb
38121982Sjhb#ifndef LOCORE
39121982Sjhb
40121982Sjhbtypedef void inthand_t(u_int cs, u_int ef, u_int esp, u_int ss);
41121982Sjhb
42121982Sjhb#define	IDTVEC(name)	__CONCAT(X,name)
43121982Sjhb
44121982Sjhbstruct intsrc;
45121982Sjhb
46121982Sjhb/*
47121982Sjhb * Methods that a PIC provides to mask/unmask a given interrupt source,
48121982Sjhb * "turn on" the interrupt on the CPU side by setting up an IDT entry, and
49121982Sjhb * return the vector associated with this source.
50121982Sjhb */
51121982Sjhbstruct pic {
52121982Sjhb	void (*pic_enable_source)(struct intsrc *);
53121982Sjhb	void (*pic_disable_source)(struct intsrc *);
54121982Sjhb	void (*pic_eoi_source)(struct intsrc *);
55121982Sjhb	void (*pic_enable_intr)(struct intsrc *);
56121982Sjhb	int (*pic_vector)(struct intsrc *);
57121982Sjhb	int (*pic_source_pending)(struct intsrc *);
58121982Sjhb	void (*pic_suspend)(struct intsrc *);
59121982Sjhb	void (*pic_resume)(struct intsrc *);
60121982Sjhb};
61121982Sjhb
62121982Sjhb/*
63121982Sjhb * An interrupt source.  The upper-layer code uses the PIC methods to
64121982Sjhb * control a given source.  The lower-layer PIC drivers can store additional
65121982Sjhb * private data in a given interrupt source such as an interrupt pin number
66121982Sjhb * or an I/O APIC pointer.
67121982Sjhb */
68121982Sjhbstruct intsrc {
69121982Sjhb	struct pic *is_pic;
70121982Sjhb	struct ithd *is_ithread;
71121982Sjhb	u_long *is_count;
72121982Sjhb	u_long *is_straycount;
73121982Sjhb	u_int is_index;
74121982Sjhb};
75121982Sjhb
76121982Sjhbstruct intrframe;
77121982Sjhb
78121982Sjhbextern struct mtx icu_lock;
79121982Sjhb
80121982Sjhbint	intr_add_handler(const char *name, int vector, driver_intr_t handler,
81121982Sjhb    void *arg, enum intr_type flags, void **cookiep);
82121982Sjhbvoid	intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe);
83121982Sjhbstruct intsrc *intr_lookup_source(int vector);
84121982Sjhbint	intr_register_source(struct intsrc *isrc);
85121982Sjhbint	intr_remove_handler(void *cookie);
86121982Sjhbvoid	intr_resume(void);
87121982Sjhbvoid	intr_suspend(void);
88121982Sjhb
89121982Sjhb#endif	/* !LOCORE */
90121982Sjhb#endif	/* _KERNEL */
91121982Sjhb#endif	/* !__MACHINE_INTR_MACHDEP_H__ */
92