Changeset 95518e59 in rtems


Ignore:
Timestamp:
Apr 6, 2012, 10:05:07 AM (8 years ago)
Author:
Daniel Hellstrom <daniel@…>
Branches:
4.11, master
Children:
684b54a
Parents:
e60e862
git-author:
Daniel Hellstrom <daniel@…> (04/06/12 10:05:07)
git-committer:
Joel Sherrill <joel.sherrill@…> (04/06/12 13:17:58)
Message:

SPARC BSPs: implemented shared-irq using libbsp/shared layer

The implementation use IRQ number instead of vector number since
some IRQs does not have a unique vector, for example the extended
interrupts all enter the same trap vector entry.

Added support for the LEON3 extended interrupt controller when using
the shared IRQ layer.

ERC32 patches untested.

Signed-off-by: Daniel Hellstrom <daniel@…>

Regenerate

Location:
c/src/lib/libbsp/sparc
Files:
8 added
15 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/Makefile.am

    re60e862 r95518e59  
    1212EXTRA_DIST += shared/gnatcommon.c
    1313EXTRA_DIST += shared/start.S
     14
     15# Interrupt
     16EXTRA_DIST += shared/irq/irq-shared.c
    1417
    1518# AMBA Plug&Play bus
  • c/src/lib/libbsp/sparc/erc32/Makefile.am

    re60e862 r95518e59  
    3434# startup
    3535libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \
    36     ../../shared/bsppredriverhook.c ../../sparc/shared/bspgetworkarea.c \
     36    startup/bsppredriver.c ../../sparc/shared/bspgetworkarea.c \
    3737    ../../sparc/shared/bsppretaskinghook.c ../../shared/bsppost.c \
    3838    ../../shared/bspstart.c ../../shared/bootcard.c ../../shared/bspinit.c \
     
    5555# timer
    5656libbsp_a_SOURCES += timer/timer.c
     57
     58# IRQ
     59include_bsp_HEADERS = \
     60    ../../shared/include/irq-generic.h \
     61    ../../shared/include/irq-info.h \
     62    include/bsp/irq.h
     63libbsp_a_SOURCES += \
     64    ../../sparc/shared/irq/irq-shared.c \
     65    ../../shared/src/irq-default-handler.c \
     66    ../../shared/src/irq-generic.c \
     67    ../../shared/src/irq-info.c \
     68    ../../shared/src/irq-legacy.c \
     69    ../../shared/src/irq-server.c \
     70    ../../shared/src/irq-shell.c
    5771
    5872if HAS_SMP
  • c/src/lib/libbsp/sparc/erc32/include/bsp.h

    re60e862 r95518e59  
    3131#include <erc32.h>
    3232#include <rtems/clockdrv.h>
    33 
    3433#include <rtems/console.h>
     34#include <rtems/irq-extension.h>
    3535
    3636/*
     
    8787void *bsp_early_malloc(int size);
    8888
     89/* Interrupt Service Routine (ISR) pointer */
     90typedef void (*bsp_shared_isr)(void *arg);
     91
     92/* Initializes the Shared System Interrupt service */
     93extern int BSP_shared_interrupt_init(void);
     94
     95/* Registers a shared IRQ handler, and enable it at IRQ controller. Multiple
     96 * interrupt handlers may use the same IRQ number, all ISRs will be called
     97 * when an interrupt on that line is fired.
     98 *
     99 * Arguments
     100 *  irq       System IRQ number
     101 *  info      Optional Name of IRQ source
     102 *  isr       Function pointer to the ISR
     103 *  arg       Second argument to function isr
     104 */
     105static __inline__ int BSP_shared_interrupt_register
     106       (
     107       int irq,
     108       const char *info,
     109       bsp_shared_isr isr,
     110       void *arg
     111       )
     112{
     113       return rtems_interrupt_handler_install(irq, info,
     114                                       RTEMS_INTERRUPT_SHARED, isr, arg);
     115}
     116
     117/* Unregister previously registered shared IRQ handler.
     118 *
     119 * Arguments
     120 *  irq       System IRQ number
     121 *  isr       Function pointer to the ISR
     122 *  arg       Second argument to function isr
     123 */
     124static __inline__ int BSP_shared_interrupt_unregister
     125       (
     126       int irq,
     127       bsp_shared_isr isr,
     128       void *arg
     129       )
     130{
     131       return rtems_interrupt_handler_remove(irq, isr, arg);
     132}
     133
     134/* Clear interrupt pending on IRQ controller, this is typically done on a
     135 * level triggered interrupt source such as PCI to avoid taking double IRQs.
     136 * In such a case the interrupt source must be cleared first on LEON, before
     137 * acknowledging the IRQ with this function.
     138 *
     139 * Arguments
     140 *  irq       System IRQ number
     141 */
     142extern void BSP_shared_interrupt_clear(int irq);
     143
     144/* Enable Interrupt. This function will unmask the IRQ at the interrupt
     145 * controller. This is normally done by _register(). Note that this will
     146 * affect all ISRs on this IRQ.
     147 *
     148 * Arguments
     149 *  irq       System IRQ number
     150 */
     151extern void BSP_shared_interrupt_unmask(int irq);
     152
     153/* Disable Interrupt. This function will mask one IRQ at the interrupt
     154 * controller. This is normally done by _unregister().  Note that this will
     155 * affect all ISRs on this IRQ.
     156 *
     157 * Arguments
     158 *  irq         System IRQ number
     159 */
     160extern void BSP_shared_interrupt_mask(int irq);
     161
    89162#ifdef __cplusplus
    90163}
  • c/src/lib/libbsp/sparc/erc32/include/erc32.h

    re60e862 r95518e59  
    325325extern ERC32_Register_Map ERC32_MEC;
    326326
     327static __inline__ int bsp_irq_fixup(int irq)
     328{
     329       return irq;
     330}
     331
    327332/*
    328333 *  Macros to manipulate the Interrupt Clear, Interrupt Force, Interrupt Mask,
     
    396401    sparc_enable_interrupts( _level ); \
    397402  } while (0)
     403
     404/* Make all SPARC BSPs have common macros for interrupt handling */
     405#define BSP_Clear_interrupt(_source) ERC32_Clear_interrupt(_source)
     406#define BSP_Force_interrupt(_source) ERC32_Force_interrupt(_source)
     407#define BSP_Is_interrupt_pending(_source) ERC32_Is_interrupt_pending(_source)
     408#define BSP_Is_interrupt_masked(_source) ERC32_Is_interrupt_masked(_source)
     409#define BSP_Unmask_interrupt(_source) ERC32_Unmask_interrupt(_source)
     410#define BSP_Mask_interrupt(_source) ERC32_Mask_interrupt(_source)
     411#define BSP_Disable_interrupt(_source, _previous) \
     412        ERC32_Disable_interrupt(_source, _prev)
     413#define BSP_Restore_interrupt(_source, _previous) \
     414        ERC32_Restore_interrupt(_source, _previous)
    398415
    399416/*
  • c/src/lib/libbsp/sparc/erc32/preinstall.am

    re60e862 r95518e59  
    7474PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds.base
    7575
     76$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     77        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
     78PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
     79
     80$(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     81        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
     82PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h
     83
     84$(PROJECT_INCLUDE)/bsp/irq.h: include/bsp/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     85        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
     86PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
     87
  • c/src/lib/libbsp/sparc/leon2/Makefile.am

    re60e862 r95518e59  
    5252# startup
    5353libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \
    54     ../../shared/bsppost.c ../../shared/bsppredriverhook.c \
     54    ../../shared/bsppost.c startup/bsppredriver.c \
    5555    startup/bspstart.c ../../sparc/shared/bsppretaskinghook.c \
    5656    ../../sparc/shared/bspgetworkarea.c ../../shared/bootcard.c \
     
    6767libbsp_a_SOURCES += clock/ckinit.c
    6868libbsp_a_SOURCES += ../../shared/clockdrv_shell.h
     69# IRQ
     70include_bsp_HEADERS = \
     71    ../../shared/include/irq-generic.h \
     72    ../../shared/include/irq-info.h \
     73    include/bsp/irq.h
     74libbsp_a_SOURCES += \
     75    ../../sparc/shared/irq/irq-shared.c \
     76    ../../shared/src/irq-default-handler.c \
     77    ../../shared/src/irq-generic.c \
     78    ../../shared/src/irq-info.c \
     79    ../../shared/src/irq-legacy.c \
     80    ../../shared/src/irq-server.c \
     81    ../../shared/src/irq-shell.c
    6982# AMBA PnP Scanning
    7083libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp.c
  • c/src/lib/libbsp/sparc/leon2/include/bsp.h

    re60e862 r95518e59  
    3131#include <rtems/clockdrv.h>
    3232#include <rtems/console.h>
     33#include <rtems/irq-extension.h>
    3334
    3435/* SPARC CPU variant: LEON2 */
     
    106107void *bsp_early_malloc(int size);
    107108
     109/* Interrupt Service Routine (ISR) pointer */
     110typedef void (*bsp_shared_isr)(void *arg);
     111
     112/* Initializes the Shared System Interrupt service */
     113extern int BSP_shared_interrupt_init(void);
     114
     115/* Registers a shared IRQ handler, and enable it at IRQ controller. Multiple
     116 * interrupt handlers may use the same IRQ number, all ISRs will be called
     117 * when an interrupt on that line is fired.
     118 *
     119 * Arguments
     120 *  irq       System IRQ number
     121 *  info      Optional Name of IRQ source
     122 *  isr       Function pointer to the ISR
     123 *  arg       Second argument to function isr
     124 */
     125static __inline__ int BSP_shared_interrupt_register
     126       (
     127       int irq,
     128       const char *info,
     129       bsp_shared_isr isr,
     130       void *arg
     131       )
     132{
     133       return rtems_interrupt_handler_install(irq, info,
     134                                       RTEMS_INTERRUPT_SHARED, isr, arg);
     135}
     136
     137/* Unregister previously registered shared IRQ handler.
     138 *
     139 * Arguments
     140 *  irq       System IRQ number
     141 *  isr       Function pointer to the ISR
     142 *  arg       Second argument to function isr
     143 */
     144static __inline__ int BSP_shared_interrupt_unregister
     145       (
     146       int irq,
     147       bsp_shared_isr isr,
     148       void *arg
     149       )
     150{
     151       return rtems_interrupt_handler_remove(irq, isr, arg);
     152}
     153
     154/* Clear interrupt pending on IRQ controller, this is typically done on a
     155 * level triggered interrupt source such as PCI to avoid taking double IRQs.
     156 * In such a case the interrupt source must be cleared first on LEON, before
     157 * acknowledging the IRQ with this function.
     158 *
     159 * Arguments
     160 *  irq       System IRQ number
     161 */
     162extern void BSP_shared_interrupt_clear(int irq);
     163
     164/* Enable Interrupt. This function will unmask the IRQ at the interrupt
     165 * controller. This is normally done by _register(). Note that this will
     166 * affect all ISRs on this IRQ.
     167 *
     168 * Arguments
     169 *  irq       System IRQ number
     170 */
     171extern void BSP_shared_interrupt_unmask(int irq);
     172
     173/* Disable Interrupt. This function will mask one IRQ at the interrupt
     174 * controller. This is normally done by _unregister().  Note that this will
     175 * affect all ISRs on this IRQ.
     176 *
     177 * Arguments
     178 *  irq         System IRQ number
     179 */
     180extern void BSP_shared_interrupt_mask(int irq);
     181
    108182#ifdef __cplusplus
    109183}
  • c/src/lib/libbsp/sparc/leon2/include/leon.h

    re60e862 r95518e59  
    272272extern LEON_Register_Map LEON_REG;
    273273
     274static __inline__ int bsp_irq_fixup(int irq)
     275{
     276       return irq;
     277}
     278
    274279/*
    275280 *  Macros to manipulate the Interrupt Clear, Interrupt Force, Interrupt Mask,
     
    339344  } while (0)
    340345
     346/* Make all SPARC BSPs have common macros for interrupt handling */
     347#define BSP_Clear_interrupt(_source) LEON_Clear_interrupt(_source)
     348#define BSP_Force_interrupt(_source) LEON_Force_interrupt(_source)
     349#define BSP_Is_interrupt_pending(_source) LEON_Is_interrupt_pending(_source)
     350#define BSP_Is_interrupt_masked(_source) LEON_Is_interrupt_masked(_source)
     351#define BSP_Unmask_interrupt(_source) LEON_Unmask_interrupt(_source)
     352#define BSP_Mask_interrupt(_source) LEON_Mask_interrupt(_source)
     353#define BSP_Disable_interrupt(_source, _previous) \
     354        LEON_Disable_interrupt(_source, _prev)
     355#define BSP_Restore_interrupt(_source, _previous) \
     356        LEON_Restore_interrupt(_source, _previous)
     357
    341358/*
    342359 *  Each timer control register is organized as follows:
  • c/src/lib/libbsp/sparc/leon2/preinstall.am

    re60e862 r95518e59  
    146146PREINSTALL_FILES += $(PROJECT_LIB)/linkcmds.base
    147147
     148$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     149        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
     150PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
     151
     152$(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     153        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
     154PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h
     155
     156$(PROJECT_INCLUDE)/bsp/irq.h: include/bsp/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     157        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
     158PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
     159
    148160$(PROJECT_INCLUDE)/i2cmst.h: ../../sparc/shared/include/i2cmst.h $(PROJECT_INCLUDE)/$(dirstamp)
    149161        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/i2cmst.h
  • c/src/lib/libbsp/sparc/leon3/Makefile.am

    re60e862 r95518e59  
    3636libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \
    3737    ../../shared/bsppost.c ../../shared/bootcard.c startup/bspstart.c \
    38     ../../sparc/shared/bsppretaskinghook.c ../../shared/bsppredriverhook.c \
     38    ../../sparc/shared/bsppretaskinghook.c startup/bsppredriver.c \
    3939    ../../sparc/shared/bspgetworkarea.c ../../shared/sbrk.c startup/setvec.c \
    4040    startup/spurious.c startup/bspidle.S startup/bspdelay.c \
     
    5656libbsp_a_SOURCES += clock/ckinit.c
    5757libbsp_a_SOURCES += ../../shared/clockdrv_shell.h
     58# IRQ
     59include_bsp_HEADERS = \
     60    ../../shared/include/irq-generic.h \
     61    ../../shared/include/irq-info.h \
     62    include/bsp/irq.h
     63libbsp_a_SOURCES += \
     64    startup/eirq.c \
     65    ../../sparc/shared/irq/irq-shared.c \
     66    ../../shared/src/irq-default-handler.c \
     67    ../../shared/src/irq-generic.c \
     68    ../../shared/src/irq-info.c \
     69    ../../shared/src/irq-legacy.c \
     70    ../../shared/src/irq-server.c \
     71    ../../shared/src/irq-shell.c
    5872# PCI
    5973include_HEADERS += ../../sparc/shared/include/pci.h
  • c/src/lib/libbsp/sparc/leon3/amba/amba.c

    re60e862 r95518e59  
    1818/* Structure containing address to devices found on the Amba Plug&Play bus */
    1919amba_confarea_type amba_conf;
     20
     21/* GRLIB extended IRQ controller register */
     22extern void leon3_ext_irq_init(void);
    2023
    2124/* Pointers to Interrupt Controller configuration registers */
     
    4952  }
    5053
     54  /* Init Extended IRQ controller if available */
     55  leon3_ext_irq_init();
     56
    5157  /* find GP Timer */
    5258  i = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_GPTIMER,&dev);
  • c/src/lib/libbsp/sparc/leon3/include/bsp.h

    re60e862 r95518e59  
    3131#include <rtems/clockdrv.h>
    3232#include <rtems/console.h>
     33#include <rtems/irq-extension.h>
    3334
    3435/* SPARC CPU variant: LEON3 */
     
    116117void *bsp_early_malloc(int size);
    117118
     119/* Interrupt Service Routine (ISR) pointer */
     120typedef void (*bsp_shared_isr)(void *arg);
     121
     122/* Initializes the Shared System Interrupt service */
     123extern int BSP_shared_interrupt_init(void);
     124
     125/* Registers a shared IRQ handler, and enable it at IRQ controller. Multiple
     126 * interrupt handlers may use the same IRQ number, all ISRs will be called
     127 * when an interrupt on that line is fired.
     128 *
     129 * Arguments
     130 *  irq       System IRQ number
     131 *  info      Optional Name of IRQ source
     132 *  isr       Function pointer to the ISR
     133 *  arg       Second argument to function isr
     134 */
     135static __inline__ int BSP_shared_interrupt_register
     136       (
     137       int irq,
     138       const char *info,
     139       bsp_shared_isr isr,
     140       void *arg
     141       )
     142{
     143       return rtems_interrupt_handler_install(irq, info,
     144                                       RTEMS_INTERRUPT_SHARED, isr, arg);
     145}
     146
     147/* Unregister previously registered shared IRQ handler.
     148 *
     149 * Arguments
     150 *  irq       System IRQ number
     151 *  isr       Function pointer to the ISR
     152 *  arg       Second argument to function isr
     153 */
     154static __inline__ int BSP_shared_interrupt_unregister
     155       (
     156       int irq,
     157       bsp_shared_isr isr,
     158       void *arg
     159       )
     160{
     161       return rtems_interrupt_handler_remove(irq, isr, arg);
     162}
     163
     164/* Clear interrupt pending on IRQ controller, this is typically done on a
     165 * level triggered interrupt source such as PCI to avoid taking double IRQs.
     166 * In such a case the interrupt source must be cleared first on LEON, before
     167 * acknowledging the IRQ with this function.
     168 *
     169 * Arguments
     170 *  irq       System IRQ number
     171 */
     172extern void BSP_shared_interrupt_clear(int irq);
     173
     174/* Enable Interrupt. This function will unmask the IRQ at the interrupt
     175 * controller. This is normally done by _register(). Note that this will
     176 * affect all ISRs on this IRQ.
     177 *
     178 * Arguments
     179 *  irq       System IRQ number
     180 */
     181extern void BSP_shared_interrupt_unmask(int irq);
     182
     183/* Disable Interrupt. This function will mask one IRQ at the interrupt
     184 * controller. This is normally done by _unregister().  Note that this will
     185 * affect all ISRs on this IRQ.
     186 *
     187 * Arguments
     188 *  irq         System IRQ number
     189 */
     190extern void BSP_shared_interrupt_mask(int irq);
     191
    118192#ifdef __cplusplus
    119193}
  • c/src/lib/libbsp/sparc/leon3/include/leon.h

    re60e862 r95518e59  
    153153extern int LEON3_Cpu_Index;
    154154
     155/* The external IRQ number, -1 if not external interrupts */
     156extern int LEON3_IrqCtrl_EIrq;
     157
     158static __inline__ int bsp_irq_fixup(int irq)
     159{
     160       int eirq;
     161
     162       if (LEON3_IrqCtrl_EIrq != 0 && irq == LEON3_IrqCtrl_EIrq) {
     163               /* Get interrupt number from IRQ controller */
     164               eirq = LEON3_IrqCtrl_Regs->intid[LEON3_Cpu_Index] & 0x1f;
     165               if (eirq & 0x10)
     166                       irq = eirq;
     167       }
     168
     169       return irq;
     170}
     171
    155172/* Macros used for manipulating bits in LEON3 GP Timer Control Register */
    156173
     
    233250  } while (0)
    234251
     252/* Make all SPARC BSPs have common macros for interrupt handling */
     253#define BSP_Clear_interrupt(_source) LEON_Clear_interrupt(_source)
     254#define BSP_Force_interrupt(_source) LEON_Force_interrupt(_source)
     255#define BSP_Is_interrupt_pending(_source) LEON_Is_interrupt_pending(_source)
     256#define BSP_Is_interrupt_masked(_source) LEON_Is_interrupt_masked(_source)
     257#define BSP_Unmask_interrupt(_source) LEON_Unmask_interrupt(_source)
     258#define BSP_Mask_interrupt(_source) LEON_Mask_interrupt(_source)
     259#define BSP_Disable_interrupt(_source, _previous) \
     260        LEON_Disable_interrupt(_source, _prev)
     261#define BSP_Restore_interrupt(_source, _previous) \
     262        LEON_Restore_interrupt(_source, _previous)
    235263
    236264/*
  • c/src/lib/libbsp/sparc/leon3/preinstall.am

    re60e862 r95518e59  
    8686PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp.h
    8787
     88$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     89        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
     90PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
     91
     92$(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     93        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
     94PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h
     95
     96$(PROJECT_INCLUDE)/bsp/irq.h: include/bsp/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     97        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
     98PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
     99
    88100$(PROJECT_INCLUDE)/pci.h: ../../sparc/shared/include/pci.h $(PROJECT_INCLUDE)/$(dirstamp)
    89101        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci.h
  • c/src/lib/libbsp/sparc/shared/include/ambapp.h

    re60e862 r95518e59  
    273273  volatile unsigned int mask[16];
    274274  volatile unsigned int force[16];
     275  /* Extended IRQ registers */
     276  volatile unsigned int intid[16];
    275277} LEON3_IrqCtrl_Regs_Map;
    276278
Note: See TracChangeset for help on using the changeset viewer.