intr_machdep.h revision 121982
1255670Sdes/*- 2137015Sdes * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org> 3137015Sdes * All rights reserved. 4147001Sdes * 5137015Sdes * Redistribution and use in source and binary forms, with or without 6137015Sdes * modification, are permitted provided that the following conditions 7137015Sdes * are met: 8218767Sdes * 1. Redistributions of source code must retain the above copyright 9146998Sdes * notice, this list of conditions and the following disclaimer. 10146998Sdes * 2. Redistributions in binary form must reproduce the above copyright 11146998Sdes * notice, this list of conditions and the following disclaimer in the 12146998Sdes * documentation and/or other materials provided with the distribution. 13255670Sdes * 14137015Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15248613Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16248613Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17248613Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18248613Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19248613Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20248613Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21248613Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22248613Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23248613Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24248613Sdes * SUCH DAMAGE. 25137015Sdes * 26137015Sdes * $FreeBSD: head/sys/i386/include/intr_machdep.h 121982 2003-11-03 21:25:52Z jhb $ 27255670Sdes */ 28255670Sdes 29255670Sdes#ifndef __MACHINE_INTR_MACHDEP_H__ 30255670Sdes#define __MACHINE_INTR_MACHDEP_H__ 31255670Sdes 32255670Sdes#ifdef _KERNEL 33255670Sdes 34255670Sdes/* With I/O APIC's we can have up to 159 interrupts. */ 35137015Sdes#define NUM_IO_INTS 159 36255670Sdes#define INTRCNT_COUNT (1 + NUM_IO_INTS * 2) 37255670Sdes 38137015Sdes#ifndef LOCORE 39137015Sdes 40204861Sdestypedef void inthand_t(u_int cs, u_int ef, u_int esp, u_int ss); 41137015Sdes 42137015Sdes#define IDTVEC(name) __CONCAT(X,name) 43137015Sdes 44137015Sdesstruct intsrc; 45137015Sdes 46137015Sdes/* 47137015Sdes * Methods that a PIC provides to mask/unmask a given interrupt source, 48137015Sdes * "turn on" the interrupt on the CPU side by setting up an IDT entry, and 49137015Sdes * return the vector associated with this source. 50204861Sdes */ 51137015Sdesstruct pic { 52137015Sdes void (*pic_enable_source)(struct intsrc *); 53137015Sdes void (*pic_disable_source)(struct intsrc *); 54137015Sdes void (*pic_eoi_source)(struct intsrc *); 55137015Sdes void (*pic_enable_intr)(struct intsrc *); 56204861Sdes int (*pic_vector)(struct intsrc *); 57137015Sdes int (*pic_source_pending)(struct intsrc *); 58137015Sdes void (*pic_suspend)(struct intsrc *); 59137015Sdes void (*pic_resume)(struct intsrc *); 60137015Sdes}; 61137015Sdes 62137015Sdes/* 63255670Sdes * An interrupt source. The upper-layer code uses the PIC methods to 64137015Sdes * control a given source. The lower-layer PIC drivers can store additional 65137015Sdes * private data in a given interrupt source such as an interrupt pin number 66137015Sdes * or an I/O APIC pointer. 67137015Sdes */ 68137015Sdesstruct intsrc { 69255670Sdes struct pic *is_pic; 70137015Sdes struct ithd *is_ithread; 71137015Sdes u_long *is_count; 72137015Sdes u_long *is_straycount; 73137015Sdes u_int is_index; 74137015Sdes}; 75137015Sdes 76137015Sdesstruct intrframe; 77137015Sdes 78204861Sdesextern struct mtx icu_lock; 79137015Sdes 80137015Sdesint intr_add_handler(const char *name, int vector, driver_intr_t handler, 81137015Sdes void *arg, enum intr_type flags, void **cookiep); 82137015Sdesvoid intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe); 83137015Sdesstruct intsrc *intr_lookup_source(int vector); 84137015Sdesint intr_register_source(struct intsrc *isrc); 85137015Sdesint intr_remove_handler(void *cookie); 86204861Sdesvoid intr_resume(void); 87137015Sdesvoid intr_suspend(void); 88137015Sdes 89137015Sdes#endif /* !LOCORE */ 90137015Sdes#endif /* _KERNEL */ 91137015Sdes#endif /* !__MACHINE_INTR_MACHDEP_H__ */ 92137015Sdes