Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:56

0001 /* irq_init.c
0002  *
0003  *  This file contains the implementation of rtems initialization
0004  *  related to interrupt handling.
0005  *
0006  *  CopyRight (C) 1999 valette@crf.canon.fr
0007  *
0008  * Enhanced by Jay Kulpinski <jskulpin@eng01.gdds.com>
0009  * to make it valid for MVME2300 Motorola boards.
0010  *
0011  * Till Straumann <strauman@slac.stanford.edu>, 12/20/2001:
0012  * Use the new interface to openpic_init
0013  *
0014  * Adapted for the mvme3100 BSP by T. Straumann, 2007.
0015  *
0016  *  The license and distribution terms for this file may be
0017  *  found in the file LICENSE in this distribution or at
0018  *  http://www.rtems.org/license/LICENSE.
0019  */
0020 
0021 #include <libcpu/io.h>
0022 #include <bsp/pci.h>
0023 #include <bsp/openpic.h>
0024 #include <bsp/irq.h>
0025 #include <bsp.h>
0026 #include <bsp/vectors.h>
0027 #include <rtems/bspIo.h>
0028 
0029 static void nop_func(void *unused)
0030 {
0031     printk("Unhandled IRQ\n");
0032 }
0033 
0034 static rtems_irq_connect_data       rtemsIrq[BSP_IRQ_NUMBER];
0035 static rtems_irq_global_settings    initial_config;
0036 static rtems_irq_connect_data       defaultIrq = {
0037   /* vectorIdex,     hdl        , handle    , on        , off       , isOn */
0038   0,             nop_func   , NULL      , 0 , 0 , 0
0039 };
0040 
0041 static rtems_irq_prio irqPrioTable[BSP_IRQ_NUMBER]={
0042   /*
0043    * actual priorities for interrupt :
0044    *    0   means that only current interrupt is masked
0045    *    255 means all other interrupts are masked
0046    */
0047   /*
0048    * PCI Interrupts
0049    */
0050   8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,             /* for raven prio 0 means unactive... */
0051   8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, /* for raven prio 0 means unactive... */
0052   8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, /* for raven prio 0 means unactive... */
0053   /*
0054    * Processor exceptions handled as interrupts
0055    */
0056   0
0057 };
0058 
0059   /*
0060    * This code assumes the exceptions management setup has already
0061    * been done. We just need to replace the exceptions that will
0062    * be handled like interrupt. On mcp750/mpc750 and many PPC processors
0063    * this means the decrementer exception and the external exception.
0064    */
0065 void BSP_rtems_irq_mng_init(unsigned cpuId)
0066 {
0067     /* We should really have a way to find the number of sources
0068      * the driver will use so that the size of the polarity-array
0069      * matches the driver's idea of it.
0070      */
0071     unsigned char pol[56];
0072     int i;
0073 
0074     /* Note: The openpic driver initializes only as many
0075      *       'pic-external' interrupt sources as reported
0076      *       by the feature register.
0077      *       The 8540's openpic supports 12 core-external
0078      *       and 23 core-internal (both of these groups
0079      *       are external to the PIC, i.e., 'pic-external')
0080      *       interrupts but between the corresponding
0081      *       banks of vector/priority registers there is
0082      *       a gap leaving space for 4 (unsupported) irqs.
0083      *       The driver, not knowing of this gap, would
0084      *       initialize the 12 core-external sources
0085      *       followed by 4 unsupported sources and 19
0086      *       core-internal sources thus leaving the last
0087      *       four core-internal sources uninitialized.
0088      *       Luckily, the feature register reports
0089      *       too many sources:
0090      *          - the 4 IPI plus 4 timer plus 4 messaging
0091      *            sources are included with the count
0092      *          - there are unused core-internal sources 24..32
0093      *            which are also supported by the pic
0094      *       bringing the reported number of sources to
0095      *       a count of 56 (12+32+4+4+4) which is enough
0096      *       so that all pic-external sources are covered
0097      *       and initialized.
0098      *
0099      *       NOTE: All core-internal sources are active-high.
0100      *             The manual says that setting the polarity
0101      *             to 'low/0' will disable the interrupt but
0102      *             I found this not to be true: on the device
0103      *             I tested the interrupt was asserted hard.
0104      */
0105 
0106     /* core-external sources on the mvme3100 are active-low,
0107      * core-internal sources are active high.
0108      */
0109     for (i=0; i<BSP_EXT_IRQ_NUMBER; i++)
0110         pol[i]=0;
0111     for (i=BSP_EXT_IRQ_NUMBER; i< BSP_EXT_IRQ_NUMBER + BSP_CORE_IRQ_NUMBER; i++)
0112         pol[i]=1;
0113 
0114     openpic_init(1, pol, 0, 0, 0, 0);
0115 
0116     /*
0117      * re-init the rtemsIrq table
0118      */
0119     for (i = 0; i < BSP_IRQ_NUMBER; i++) {
0120         rtemsIrq[i]      = defaultIrq;
0121         rtemsIrq[i].name = i;
0122     }
0123     /*
0124      * Init initial Interrupt management config
0125      */
0126     initial_config.irqNb    = BSP_IRQ_NUMBER;
0127     initial_config.defaultEntry = defaultIrq;
0128     initial_config.irqHdlTbl    = rtemsIrq;
0129     initial_config.irqBase  = BSP_LOWEST_OFFSET;
0130     initial_config.irqPrioTbl   = irqPrioTable;
0131 
0132     if (!BSP_rtems_irq_mngt_set(&initial_config)) {
0133         /*
0134          * put something here that will show the failure...
0135          */
0136         rtems_panic("Unable to initialize RTEMS interrupt Management!!! System locked\n");
0137     }
0138 }