The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/arm/arm/intr.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: intr.c,v 1.12 2003/07/15 00:24:41 lukem Exp $  */
    2 
    3 /*-
    4  * Copyright (c) 2004 Olivier Houchard.
    5  * Copyright (c) 1994-1998 Mark Brinicombe.
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. All advertising materials mentioning features or use of this software
   17  *    must display the following acknowledgement:
   18  *      This product includes software developed by Mark Brinicombe
   19  *      for the NetBSD Project.
   20  * 4. The name of the company nor the name of the author may be used to
   21  *    endorse or promote products derived from this software without specific
   22  *    prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   25  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   26  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   27  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   28  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   30  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  *
   36  * Soft interrupt and other generic interrupt functions.
   37  */
   38 
   39 #include <sys/cdefs.h>
   40 __FBSDID("$FreeBSD: releng/10.0/sys/arm/arm/intr.c 246000 2013-01-27 20:16:50Z ian $");
   41 #include <sys/param.h>
   42 #include <sys/systm.h>
   43 #include <sys/syslog.h>
   44 #include <sys/malloc.h>
   45 #include <sys/proc.h>
   46 #include <sys/bus.h>
   47 #include <sys/interrupt.h>
   48 #include <sys/conf.h>
   49 #include <machine/atomic.h>
   50 #include <machine/intr.h>
   51 #include <machine/cpu.h>
   52 
   53 #define INTRNAME_LEN    (MAXCOMLEN + 1)
   54 
   55 typedef void (*mask_fn)(void *);
   56 
   57 static struct intr_event *intr_events[NIRQ];
   58 
   59 void    arm_handler_execute(struct trapframe *, int);
   60 
   61 void (*arm_post_filter)(void *) = NULL;
   62 
   63 /*
   64  * Pre-format intrnames into an array of fixed-size strings containing spaces.
   65  * This allows us to avoid the need for an intermediate table of indices into
   66  * the names and counts arrays, while still meeting the requirements and
   67  * assumptions of vmstat(8) and the kdb "show intrcnt" command, the two
   68  * consumers of this data.
   69  */
   70 void
   71 arm_intrnames_init(void)
   72 {
   73         int i;
   74 
   75         for (i = 0; i < NIRQ; ++i) {
   76                 snprintf(&intrnames[i * INTRNAME_LEN], INTRNAME_LEN, "%-*s",
   77                     INTRNAME_LEN - 1, "");
   78         }
   79 }
   80 
   81 void
   82 arm_setup_irqhandler(const char *name, driver_filter_t *filt,
   83     void (*hand)(void*), void *arg, int irq, int flags, void **cookiep)
   84 {
   85         struct intr_event *event;
   86         int error;
   87 
   88         if (irq < 0 || irq >= NIRQ)
   89                 return;
   90         event = intr_events[irq];
   91         if (event == NULL) {
   92                 error = intr_event_create(&event, (void *)irq, 0, irq,
   93                     (mask_fn)arm_mask_irq, (mask_fn)arm_unmask_irq,
   94                     arm_post_filter, NULL, "intr%d:", irq);
   95                 if (error)
   96                         return;
   97                 intr_events[irq] = event;
   98                 snprintf(&intrnames[irq * INTRNAME_LEN], INTRNAME_LEN, 
   99                     "irq%d: %-*s", irq, INTRNAME_LEN - 1, name);
  100         }
  101         intr_event_add_handler(event, name, filt, hand, arg,
  102             intr_priority(flags), flags, cookiep);
  103 }
  104 
  105 int
  106 arm_remove_irqhandler(int irq, void *cookie)
  107 {
  108         struct intr_event *event;
  109         int error;
  110 
  111         event = intr_events[irq];
  112         arm_mask_irq(irq);
  113         
  114         error = intr_event_remove_handler(cookie);
  115 
  116         if (!TAILQ_EMPTY(&event->ie_handlers))
  117                 arm_unmask_irq(irq);
  118         return (error);
  119 }
  120 
  121 void dosoftints(void);
  122 void
  123 dosoftints(void)
  124 {
  125 }
  126 
  127 void
  128 arm_handler_execute(struct trapframe *frame, int irqnb)
  129 {
  130         struct intr_event *event;
  131         int i;
  132 
  133         PCPU_INC(cnt.v_intr);
  134         i = -1;
  135         while ((i = arm_get_next_irq(i)) != -1) {
  136                 intrcnt[i]++;
  137                 event = intr_events[i];
  138                 if (intr_event_handle(event, frame) != 0) {
  139                         /* XXX: Log stray IRQs */
  140                         arm_mask_irq(i);
  141                 }
  142         }
  143 }

Cache object: 087e1d2c2a0607516158ef8664c72774


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.