Back to home page

LXR

 
 

    


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

0001 #ifndef RTEMS_BSP_VME_CONFIG_H
0002 #define RTEMS_BSP_VME_CONFIG_H
0003 
0004 /* BSP specific address space configuration parameters */
0005 
0006 /*
0007  * Authorship
0008  * ----------
0009  * This software was created by
0010  *     Till Straumann <strauman@slac.stanford.edu>, 2002,
0011  *      Stanford Linear Accelerator Center, Stanford University.
0012  *
0013  * Acknowledgement of sponsorship
0014  * ------------------------------
0015  * This software was produced by
0016  *     the Stanford Linear Accelerator Center, Stanford University,
0017  *      under Contract DE-AC03-76SFO0515 with the Department of Energy.
0018  *
0019  * Government disclaimer of liability
0020  * ----------------------------------
0021  * Neither the United States nor the United States Department of Energy,
0022  * nor any of their employees, makes any warranty, express or implied, or
0023  * assumes any legal liability or responsibility for the accuracy,
0024  * completeness, or usefulness of any data, apparatus, product, or process
0025  * disclosed, or represents that its use would not infringe privately owned
0026  * rights.
0027  *
0028  * Stanford disclaimer of liability
0029  * --------------------------------
0030  * Stanford University makes no representations or warranties, express or
0031  * implied, nor assumes any liability for the use of this software.
0032  *
0033  * Stanford disclaimer of copyright
0034  * --------------------------------
0035  * Stanford University, owner of the copyright, hereby disclaims its
0036  * copyright and all other rights in this software.  Hence, anyone may
0037  * freely use it for any purpose without restriction.
0038  *
0039  * Maintenance of notices
0040  * ----------------------
0041  * In the interest of clarity regarding the origin and status of this
0042  * SLAC software, this and all the preceding Stanford University notices
0043  * are to remain affixed to any copy or derivative of this software made
0044  * or distributed by the recipient and are to be affixed to any copy of
0045  * software made or distributed by the recipient that contains a copy or
0046  * derivative of this software.
0047  *
0048  * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
0049  */
0050 
0051 /*
0052  * The BSP maps VME address ranges into
0053  * one BAT.
0054  * NOTE: the BSP (startup/bspstart.c) uses
0055  * hardcoded window lengths that match this
0056  * layout:
0057  *
0058  * BSP_VME_BAT_IDX defines
0059  * which BAT to use for mapping the VME bus.
0060  * If this is undefined, no extra BAT will be
0061  * configured and VME has to share the available
0062  * PCI address space with PCI devices.
0063  *
0064  * If you do define BSP_VME_BAT_IDX you must
0065  * make sure the corresponding BAT is really
0066  * available and unused!
0067  */
0068 
0069 #if defined(mot_ppc_mvme2100)
0070 #define _VME_A32_WIN0_ON_PCI  0x90000000
0071 #define _VME_A24_ON_PCI      0x9f000000
0072 #define _VME_A16_ON_PCI      0x9fff0000
0073 #define BSP_VME_BAT_IDX      1
0074 #else
0075 #define _VME_A32_WIN0_ON_PCI  0x10000000
0076 #define _VME_A24_ON_PCI      0x1f000000
0077 #define _VME_A16_ON_PCI      0x1fff0000
0078 #define BSP_VME_BAT_IDX      0
0079 #endif
0080 
0081 /* start of the A32 window on the VME bus
0082  * TODO: this should perhaps be a run-time configuration option
0083  */
0084 #define _VME_A32_WIN0_ON_VME  0x20000000
0085 
0086 /* if _VME_DRAM_OFFSET is defined, the BSP
0087  * will map the board RAM onto the VME bus, starting
0088  * at _VME_DRAM_OFFSET
0089  */
0090 #define _VME_DRAM_OFFSET    0xc0000000
0091 
0092 /* Define BSP_PCI_VME_DRIVER_DOES_EOI to let the vmeUniverse
0093  * driver (Tsi148 driver doesn't implement this) implement
0094  * VME IRQ priorities in software.
0095  *
0096  * Here's how this works:
0097  *
0098  *    1) VME IRQ happens
0099  *    2) universe propagates IRQ to PCI/PPC/main interrupt
0100  *       controller ('PIC' - programmable interrupt controller).
0101  *    3) PIC driver dispatches universe driver's ISR
0102  *    4) universe driver ISR acknowledges IRQ on VME,
0103  *       determines VME vector.
0104  * ++++++++++++ stuff between ++ signs is related to SW priorities +++++++++
0105  *    5) universe driver *masks* all VME IRQ levels <= interrupting
0106  *       level.
0107  *    6) universe driver calls PIC driver's 'EOI' routine.
0108  *       This effectively re-enables PCI and hence higher
0109  *       level VME interrupts.
0110  *    7) universe driver dispatches user VME ISR.
0111  *
0112  * ++>> HIGHER PRIORITY VME IRQ COULD HAPPEN HERE and would be handled <<++
0113  *
0114  *    8) user ISR returns, universe driver re-enables lower
0115  *       level VME interrupts, returns.
0116  *    9) universe driver ISR returns control to PIC driver
0117  *   10) PIC driver *omits* regular EOI sequence since this
0118  *       was already done by universe driver (step 6).
0119  * ++++++++++++ end of special handling (SW priorities) ++++++++++++++++++++
0120  *   11) PIC driver ISR dispatcher returns.
0121  *
0122  * Note that the BSP *MUST* provide the following hooks
0123  * in order for this to work:
0124  *   a) bsp.h must define the symbol BSP_PIC_DO_EOI to
0125  *      a sequence of instructions that terminates an
0126  *      interrupt at the interrupt controller.
0127  *   b) The interrupt controller driver must check the
0128  *      interrupt source and *must omit* running the EOI
0129  *      sequence if the interrupt source is the vmeUniverse
0130  *      (because the universe driver already ran BSP_PIC_DO_EOI)
0131  *      The interrupt controller must define the variable
0132  *
0133  *          int _BSP_vme_bridge_irq = -1;
0134  *
0135  *      which is assigned the universe's interrupt line information
0136  *      by vme_universe.c:BSP_VMEIrqMgrInstall(). The interrupt
0137  *      controller driver may use this variable to determine
0138  *      if an IRQ was caused by the universe.
0139  *
0140  *   c) define BSP_PCI_VME_DRIVER_DOES_EOI
0141  *
0142  *  NOTE: If a) and b) are not implemented by the BSP
0143  *        BSP_PCI_VME_DRIVER_DOES_EOI must be *undefined*.
0144  */
0145 #define BSP_PCI_VME_DRIVER_DOES_EOI
0146 
0147 #ifdef BSP_PCI_VME_DRIVER_DOES_EOI
0148 /* don't reference vmeUniverse0PciIrqLine directly from the irq
0149  * controller driver - leave it up to BSP_VMEIrqMgrInstall() to
0150  * set _BSP_vme_bridge_irq. That way, we can avoid linking
0151  * the universe driver if VME is unused...
0152  */
0153 extern int _BSP_vme_bridge_irq;
0154 #endif
0155 
0156 /* If your BSP requires a non-standard way to configure
0157  * the VME interrupt manager then define the symbol
0158  *
0159  * BSP_VME_UNIVERSE_INSTALL_IRQ_MGR
0160  *
0161  * to a proper instruction sequence that installs the
0162  * universe interrupt manager. This requires knowledge
0163  * of the wiring between the universe and the PIC (main
0164  * interrupt controller), i.e., which IRQ 'pins' of the
0165  * universe are wired to which 'lines'/inputs at the PIC.
0166  * (consult vmeUniverse.h for more information).
0167  *
0168  * When installing the universe IRQ manager it is also
0169  * possible to specify whether it should try to share
0170  * PIC interrupts with other sources. This might not
0171  * be supported by all BSPs (but the unverse driver
0172  * recognizes that).
0173  *
0174  * If BSP_VME_UNIVERSE_INSTALL_IRQ_MGR is undefined then
0175  * the default algorithm is used (vme_universe.c):
0176  *
0177  * This default setup uses only a single wire. It reads
0178  * the PIC 'line' from PCI configuration space and assumes
0179  * this to be wired to the first (LIRQ0) IRQ input at the
0180  * universe. The default setup tries to use interrupt
0181  * sharing.
0182  */
0183 
0184 #include <bsp/motorola.h>
0185 #include <bsp/pci.h>
0186 
0187 #define BSP_VME_UNIVERSE_INSTALL_IRQ_MGR(err) \
0188 do { \
0189 int              bus, dev, i = 0, j; \
0190 const struct _int_map  *bspmap; \
0191   /* install the VME interrupt manager; \
0192    * if there's a bsp route map, use it to \
0193    * configure additional lines... \
0194    */ \
0195   err = -1; \
0196   if (0 == pci_find_device(0x10e3, 0x0000, 0, &bus, &dev, &i)){ \
0197   if ( (bspmap = motorolaIntMap(currentBoard)) ) { \
0198   for ( i=0; bspmap[i].bus >= 0; i++ ) { \
0199     if ( bspmap[i].bus == bus && bspmap[i].slot == dev ) { \
0200     int pins[5], names[4]; \
0201     /* found it; use info here...                   */ \
0202     /* copy up to 4 entries; terminated with -1 pin */ \
0203     for ( j=0; \
0204           j<5 && (pins[j]=bspmap[i].pin_route[j].pin-1)>=0; \
0205           j++) { \
0206       names[j] = bspmap[i].pin_route[j].int_name[0]; \
0207     } \
0208     pins[4] = -1; \
0209     if ( 0 == vmeUniverseInstallIrqMgrAlt( \
0210         VMEUNIVERSE_IRQ_MGR_FLAG_SHARED, /* shared IRQs */\
0211         pins[0], names[0], \
0212         pins[1], names[1], \
0213         pins[2], names[2], \
0214         pins[3], names[3], \
0215         -1) ) { \
0216       i = -1; \
0217       break; \
0218     } \
0219     } \
0220   } \
0221     } \
0222   if ( i >= 0 ) \
0223       err = vmeUniverseInstallIrqMgrAlt( \
0224           VMEUNIVERSE_IRQ_MGR_FLAG_SHARED, \
0225         0,-1, \
0226         -1); \
0227   } \
0228 } while (0)
0229 
0230 extern int BSP_VMEInit(void);
0231 extern int BSP_VMEIrqMgrInstall(void);
0232 
0233 #endif