Changeset 0296f518 in rtems


Ignore:
Timestamp:
Dec 12, 2007, 1:16:34 AM (13 years ago)
Author:
Till Straumann <strauman@…>
Branches:
4.10, 4.11, 4.9, 5, master
Children:
06bd7c7
Parents:
85982c6
Message:

2007-12-11 Till Straumann <strauman@…>

  • Makefile.am, irq/irq.c, irq/irq.h, irq/irq_init.c: use new exception/irq support from libcpu/powerpc/new-exceptions/bspsupport rather than borrowing from ../shared/vectors ../shared/irq
Location:
c/src/lib/libbsp/powerpc/mvme5500
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/mvme5500/ChangeLog

    r85982c6 r0296f518  
     12007-12-11      Till Straumann <strauman@slac.stanford.edu>
     2
     3        * Makefile.am, irq/irq.c, irq/irq.h, irq/irq_init.c:
     4        use new exception/irq support from
     5        libcpu/powerpc/new-exceptions/bspsupport
     6        rather than borrowing from ../shared/vectors ../shared/irq
     7
    182007-12-11      Joel Sherrill <joel.sherrill@OARcorp.com>
    29
  • c/src/lib/libbsp/powerpc/mvme5500/Makefile.am

    r85982c6 r0296f518  
    7070
    7171noinst_PROGRAMS += irq.rel
    72 irq_rel_SOURCES = irq/irq_init.c irq/irq.c \
    73     ../../powerpc/shared/irq/irq_asm.S
     72irq_rel_SOURCES = irq/irq_init.c irq/irq.c
    7473irq_rel_CPPFLAGS = $(AM_CPPFLAGS)
    7574irq_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
     
    8483
    8584##
    86 include_bsp_HEADERS += ../../powerpc/shared/vectors/vectors.h \
     85include_bsp_HEADERS += \
    8786    vectors/bspException.h
    8887
     88include_bsp_HEADERS += \
     89        ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/vectors.h \
     90        ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/irq_supp.h \
     91        ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/ppc_exc_bspsupp.h
     92
    8993noinst_PROGRAMS += vectors.rel
    90 vectors_rel_SOURCES = ../../powerpc/shared/vectors/vectors_init.c \
    91     vectors/exceptionhandler.c ../../powerpc/shared/vectors/vectors.S \
     94vectors_rel_SOURCES = \
     95    vectors/exceptionhandler.c \
    9296    ../../powerpc/shared/start/vectors_entry.S 
    9397vectors_rel_CPPFLAGS = $(AM_CPPFLAGS)
     
    159163    ../../../libcpu/@RTEMS_CPU@/mpc6xx/clock.rel \
    160164    ../../../libcpu/@RTEMS_CPU@/@exceptions@/raw_exception.rel \
     165    ../../../libcpu/@RTEMS_CPU@/@exceptions@/exc_bspsupport.rel \
     166    ../../../libcpu/@RTEMS_CPU@/@exceptions@/irq_bspsupport.rel \
    161167    ../../../libcpu/@RTEMS_CPU@/mpc6xx/mmu.rel \
    162168    ../../../libcpu/@RTEMS_CPU@/mpc6xx/timer.rel
  • c/src/lib/libbsp/powerpc/mvme5500/irq/irq.c

    r85982c6 r0296f518  
    4444#define EDGE_TRIGGER
    4545
    46 #define _MSR_GET( _mask) \
    47   do { \
    48      RTEMS_COMPILER_MEMORY_BARRIER(); \
    49      _CPU_MSR_GET( _mask); \
    50      RTEMS_COMPILER_MEMORY_BARRIER(); \
    51   } while (0);
    52 
    53 #define _MSR_SET( _mask) \
    54   do { \
    55      RTEMS_COMPILER_MEMORY_BARRIER(); \
    56      _CPU_MSR_SET( _mask); \
    57      RTEMS_COMPILER_MEMORY_BARRIER(); \
    58   } while (0);
    59 
    6046/* #define DEBUG_IRQ*/
    6147
     
    7157
    7258/*
    73  * default handler connected on each irq after bsp initialization
    74  */
    75 static rtems_irq_connect_data   default_rtems_entry;
    76 
    77 /*
    7859 * location used to store initial tables used for interrupt
    7960 * management.
    8061 */
    8162static rtems_irq_global_settings*       internal_config;
     63/* handler table (cached copy ) */
    8264static rtems_irq_connect_data*          rtems_hdl_tbl;
     65/*
     66 * default handler connected on each irq after bsp initialization
     67 * (locally cached copy)
     68 */
     69void (*default_rtems_hdl)(rtems_irq_hdl_param) = (void(*)(rtems_irq_hdl_param)) -1;
     70
    8371
    8472static volatile unsigned  *BSP_irqMask_reg[3];
     
    163151 * and accessible.
    164152 */
    165 static void compute_pic_masks_from_prio()
     153static void compute_pic_masks_from_prio(rtems_irq_global_settings *config)
    166154{
    167155  int i,j, k;
     
    193181         * or <Till Straumann> a equal priority.
    194182         */
    195         if (internal_config->irqPrioTbl [i] >= internal_config->irqPrioTbl [j])
     183        if (config->irqPrioTbl [i] >= config->irqPrioTbl [j])
    196184           irq_prio_mask |= (unsigned long long)(1LLU << j);
    197185    }
     
    208196    /* Compute for the GPP priority interrupt mask */
    209197    for (j=BSP_GPP_IRQ_LOWEST_OFFSET; j <BSP_PROCESSOR_IRQ_LOWEST_OFFSET; j++) {     
    210       if (internal_config->irqPrioTbl [i] >= internal_config->irqPrioTbl [j])
     198      if (config->irqPrioTbl [i] >= config->irqPrioTbl [j])
    211199           BSP_irq_prio_mask_tbl[2][i] |= 1 << (j-BSP_GPP_IRQ_LOWEST_OFFSET);
    212200    }
     
    304292  unsigned int level;
    305293
     294  if ( !is_pic_irq(irqNum) )
     295        return;
     296
    306297  bitNum = modIrq32(((unsigned int)irqNum) - BSP_MICL_IRQ_LOWEST_OFFSET);
    307298  regNum = divIrq32(((unsigned int)irqNum) - BSP_MICL_IRQ_LOWEST_OFFSET);
     
    318309}
    319310
    320 void BSP_disable_pic_irq(const rtems_irq_number irqNum)
    321 {
     311void BSP_enable_irq_at_pic(const rtems_irq_number irqNum)
     312{
     313        BSP_enable_pic_irq(irqNum);
     314}
     315
     316int BSP_disable_irq_at_pic(const rtems_irq_number irqNum)
     317{
     318  int      rval;
    322319  unsigned bitNum, regNum;
    323320  unsigned int level;
    324321
     322  if ( ! is_pic_irq(irqNum) )
     323        return -1;
     324
    325325  bitNum = modIrq32(((unsigned int)irqNum) - BSP_MICL_IRQ_LOWEST_OFFSET);
    326326  regNum = divIrq32(((unsigned int)irqNum) - BSP_MICL_IRQ_LOWEST_OFFSET);
     
    329329
    330330  CleanMainIrqTbl((int) irqNum);
     331
     332  rval = BSP_irqMask_cache[regNum] & (1<<bitNum);
     333
    331334  BSP_irqMask_cache[regNum] &=  ~(1 << bitNum);
    332335
     
    335338
    336339  rtems_interrupt_enable(level);
    337 }
    338 
    339 int BSP_setup_the_pic()  /* adapt the same name as shared/irq */
     340
     341  return rval ? 1 : 0;
     342}
     343
     344void BSP_disable_pic_irq(const rtems_irq_number irqNum)
     345{
     346        (void)BSP_disable_irq_at_pic(irqNum);
     347}
     348
     349int BSP_setup_the_pic(rtems_irq_global_settings *config)  /* adapt the same name as shared/irq */
    340350{
    341351    int i;
     352
     353        internal_config   = config;
     354        default_rtems_hdl = config->defaultEntry.hdl;
     355        rtems_hdl_tbl     = config->irqHdlTbl;
    342356
    343357    /* Get ready for discovery BSP */
     
    381395    }         
    382396    in_le32(BSP_irqMask_reg[2]);
    383     compute_pic_masks_from_prio();
     397    compute_pic_masks_from_prio(config);
    384398
    385399#if 0
     
    395409#endif
    396410
    397     /*
    398      *
    399      */
    400     for (i=BSP_MICL_IRQ_LOWEST_OFFSET; i < BSP_PROCESSOR_IRQ_LOWEST_OFFSET ; i++) {
    401       if (rtems_hdl_tbl[i].hdl != default_rtems_entry.hdl) {
    402         BSP_enable_pic_irq(i);
    403         if (rtems_hdl_tbl[i].on)
    404                 rtems_hdl_tbl[i].on(&rtems_hdl_tbl[i]);
    405       }
    406       else {
    407         if (rtems_hdl_tbl[i].off)
    408                 rtems_hdl_tbl[i].off(&rtems_hdl_tbl[i]);
    409         BSP_disable_pic_irq(i);
    410       }
    411     }
    412 
    413411    return(1);
    414412}
     
    419417 */
    420418
    421 static int isValidInterrupt(int irq)
    422 {
    423   if ( (irq < BSP_LOWEST_OFFSET) || (irq > BSP_MAX_OFFSET))
    424     return 0;
    425   return 1;
    426 }
    427 
    428 /*
    429  * ------------------------ RTEMS Single Irq Handler Mngt Routines ----------------
    430  */
    431 
    432 int BSP_install_rtems_irq_handler  (const rtems_irq_connect_data* irq)
    433 {
    434     unsigned int level;
    435  
    436     if (!isValidInterrupt(irq->name)) {
    437       printk("Invalid interrupt vector %d\n",irq->name);
    438       return 0;
    439     }
    440     /*
    441      * Check if default handler is actually connected. If not issue an error.
    442      * You must first get the current handler via i386_get_current_idt_entry
    443      * and then disconnect it using i386_delete_idt_entry.
    444      * RATIONALE : to always have the same transition by forcing the user
    445      * to get the previous handler before accepting to disconnect.
    446      */
    447     rtems_interrupt_disable(level);
    448     if (rtems_hdl_tbl[irq->name].hdl != default_rtems_entry.hdl) {
    449       rtems_interrupt_enable(level);
    450       printk("IRQ vector %d already connected\n",irq->name);
    451       return 0;
    452     }
    453 
    454     /*
    455      * store the data provided by user
    456      */
    457     rtems_hdl_tbl[irq->name] = *irq;
    458 #ifdef BSP_SHARED_HANDLER_SUPPORT
    459     rtems_hdl_tbl[irq->name].next_handler = (void *)-1;
    460 #endif
    461 
    462     if (is_pic_irq(irq->name)) {
    463       /*
    464        * Enable PIC  irq : Main Interrupt Cause Low and High & GPP external
    465        */
    466 #ifdef DEBUG_IRQ
    467       printk("PIC irq %d\n",irq->name);
    468 #endif
    469       BSP_enable_pic_irq(irq->name);
    470     }
    471     else {
    472       if (is_processor_irq(irq->name)) {
    473          /*
    474           * Enable exception at processor level
    475           */
    476 
    477        }
    478     }
    479     /*
    480      * Enable interrupt on device
    481      */
    482         if (irq->on)
    483         irq->on(irq);
    484    
    485     rtems_interrupt_enable(level);
    486 
    487     return 1;
    488 }
    489 
    490 
    491 int BSP_get_current_rtems_irq_handler   (rtems_irq_connect_data* irq)
    492 {
    493      if (!isValidInterrupt(irq->name)) {
    494       return 0;
    495      }
    496      *irq = rtems_hdl_tbl[irq->name];
    497      return 1;
    498 }
    499 
    500 int BSP_remove_rtems_irq_handler  (const rtems_irq_connect_data* irq)
    501 {
    502     unsigned int level;
    503  
    504     if (!isValidInterrupt(irq->name)) {
    505       return 0;
    506     }
    507     /*
    508      * Check if default handler is actually connected. If not issue an error.
    509      * You must first get the current handler via i386_get_current_idt_entry
    510      * and then disconnect it using i386_delete_idt_entry.
    511      * RATIONALE : to always have the same transition by forcing the user
    512      * to get the previous handler before accepting to disconnect.
    513      */
    514     if (rtems_hdl_tbl[irq->name].hdl != irq->hdl) {
    515       return 0;
    516     }
    517     rtems_interrupt_disable(level);
    518 
    519     /*
    520      * disable PIC interrupt
    521      */
    522     if (is_pic_irq(irq->name))
    523       BSP_disable_pic_irq(irq->name);
    524     else {
    525       if (is_processor_irq(irq->name)) {
    526          /*
    527           * disable exception at processor level
    528           */
    529        }
    530     }   
    531 
    532     /*
    533      * Disable interrupt on device
    534      */
    535         if (irq->off)
    536         irq->off(irq);
    537 
    538     /*
    539      * restore the default irq value
    540      */
    541     rtems_hdl_tbl[irq->name] = default_rtems_entry;
    542 
    543 
    544     rtems_interrupt_enable(level);
    545 
    546     return 1;
    547 }
    548 
    549 /*
    550  * ------------------------ RTEMS Global Irq Handler Mngt Routines ----------------
    551  */
    552 
    553 int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config)
    554 {
    555     unsigned int level;
    556     int i;
    557 
    558    /*
    559     * Store various code accelerators
    560     */
    561     internal_config             = config;
    562     default_rtems_entry         = config->defaultEntry;
    563     rtems_hdl_tbl               = config->irqHdlTbl;
    564 
    565     rtems_interrupt_disable(level);
    566 
    567     if ( !BSP_setup_the_pic() ) {
    568        printk("PIC setup failed; leaving IRQs OFF\n");
    569        return 0;
    570     }
    571 
    572     for (i= BSP_MAIN_GPP7_0_IRQ; i <= BSP_MAIN_GPP31_24_IRQ; i++)
    573       BSP_enable_pic_irq(i);
    574 
    575     rtems_interrupt_enable(level);
    576     return 1;
    577 }
    578 
    579 int BSP_rtems_irq_mngt_get(rtems_irq_global_settings** config)
    580 {
    581     *config = internal_config;
    582     return 0;
    583 }   
    584 
    585419/*
    586420 * High level IRQ handler called from shared_raw_irq_code_entry
    587421 */
    588422
    589 int C_dispatch_irq_handler (CPU_Interrupt_frame *frame, unsigned int excNum)
    590 {
    591   register unsigned msr, new_msr;
     423int C_dispatch_irq_handler (BSP_Exception_frame *frame, unsigned int excNum)
     424{
    592425  unsigned long irqCause[3]={0, 0,0};
    593426  register unsigned long selectCause;
     
    596429
    597430  if (excNum == ASM_DEC_VECTOR) {
    598     _MSR_GET(msr);
    599     new_msr = msr | MSR_EE;
    600     _MSR_SET(new_msr);
    601    
    602     rtems_hdl_tbl[BSP_DECREMENTER].hdl(rtems_hdl_tbl[BSP_DECREMENTER].handle);
    603 
    604     _MSR_SET(msr);
     431
     432        bsp_irq_dispatch_list( rtems_hdl_tbl, BSP_DECREMENTER, default_rtems_hdl);
     433
    605434    return 0;
    606435   
     
    636465#endif
    637466
    638       _MSR_GET(msr);
    639       new_msr = msr | MSR_EE;
    640       _MSR_SET(new_msr);
    641       rtems_hdl_tbl[irq].hdl(rtems_hdl_tbl[irq].handle);
    642       _MSR_SET(msr);
     467          bsp_irq_dispatch_list( rtems_hdl_tbl, irq, default_rtems_hdl);
    643468     
    644469      for (j=0; j<3; j++ ) BSP_irqMask_cache[j] = oldMask[j];
     
    655480}
    656481
    657 void _ThreadProcessSignalsFromIrq (BSP_Exception_frame* ctx)
    658 {
    659   /*
    660    * Process pending signals that have not already been
    661    * processed by _Thread_Displatch. This happens quite
    662    * unfrequently : the ISR must have posted an action
    663    * to the current running thread.
    664    */
    665   if ( _Thread_Do_post_task_switch_extension ||
    666        _Thread_Executing->do_post_task_switch_extension ) {
    667     _Thread_Executing->do_post_task_switch_extension = FALSE;
    668     _API_extensions_Run_postswitch();
    669   }
    670   /*
    671    * I plan to process other thread related events here.
    672    * This will include DEBUG session requested from keyboard...
    673    */
    674 }
    675 
    676482/* Only print part of the entries for now */
    677483void BSP_printPicIsrTbl()
  • c/src/lib/libbsp/powerpc/mvme5500/irq/irq.h

    r85982c6 r0296f518  
    3030#define LIBBSP_POWERPC_MVME5500_IRQ_IRQ_H
    3131
    32 /*#define BSP_SHARED_HANDLER_SUPPORT      1*/
     32#define BSP_SHARED_HANDLER_SUPPORT      1
    3333#include <rtems/irq.h>
    3434
     
    134134extern void BSP_rtems_irq_mng_init(unsigned cpuId);
    135135
     136#include <bsp/irq_supp.h>
     137
    136138#endif
    137139#endif
  • c/src/lib/libbsp/powerpc/mvme5500/irq/irq_init.c

    r85982c6 r0296f518  
    2121#include <libcpu/raw_exception.h>  /* ASM_EXT_VECTOR, ASM_DEC_VECTOR ... */
    2222/*#define  TRACE_IRQ_INIT*/
    23 
    24 extern unsigned int external_exception_vector_prolog_code_size[];
    25 extern void external_exception_vector_prolog_code();
    26 extern unsigned int decrementer_exception_vector_prolog_code_size[];
    27 extern void decrementer_exception_vector_prolog_code();
    2823
    2924/*
     
    9489void BSP_rtems_irq_mng_init(unsigned cpuId)
    9590{
    96   rtems_raw_except_connect_data vectorDesc;
    97   int i;
     91  int                   i;
     92  rtems_interrupt_level l;
    9893
    9994  /*
     
    131126#endif       
    132127
     128  rtems_interrupt_disable(l);
    133129  if (!BSP_rtems_irq_mngt_set(&initial_config)) {
    134130      /*
     
    139135#ifdef TRACE_IRQ_INIT 
    140136  printk("Done setup irq mngt configuration\n");
    141 #endif     
     137#endif
     138 
     139  /* I don't really understand why all sources are enable here... (T.S) */
     140  for (i= BSP_MAIN_GPP7_0_IRQ; i <= BSP_MAIN_GPP31_24_IRQ; i++)
     141      BSP_enable_pic_irq(i);
    142142
    143   /*
    144    * We must connect the raw irq handler for the two
    145    * expected interrupt sources : decrementer and external interrupts.
    146    */
    147   vectorDesc.exceptIndex        = ASM_DEC_VECTOR;
    148   vectorDesc.hdl.vector = ASM_DEC_VECTOR;
    149   vectorDesc.hdl.raw_hdl        = decrementer_exception_vector_prolog_code;
    150   vectorDesc.hdl.raw_hdl_size   = (unsigned) decrementer_exception_vector_prolog_code_size;
    151   vectorDesc.on         = nop_func;
    152   vectorDesc.off                = nop_func;
    153   vectorDesc.isOn               = connected;
    154   if (!ppc_set_exception (&vectorDesc)) {
    155       BSP_panic("Unable to initialize RTEMS decrementer raw exception\n");
    156   }
    157   vectorDesc.exceptIndex        = ASM_EXT_VECTOR;
    158   vectorDesc.hdl.vector = ASM_EXT_VECTOR;
    159   vectorDesc.hdl.raw_hdl        = external_exception_vector_prolog_code;
    160   vectorDesc.hdl.raw_hdl_size   = (unsigned) external_exception_vector_prolog_code_size;
    161   if (!ppc_set_exception (&vectorDesc)) {
    162       BSP_panic("Unable to initialize RTEMS external raw exception\n");
    163     }
     143  rtems_interrupt_enable(l);
     144
    164145#ifdef TRACE_IRQ_INIT 
    165146  printk("RTEMS IRQ management is now operationnal\n");
  • c/src/lib/libbsp/powerpc/mvme5500/preinstall.am

    r85982c6 r0296f518  
    8282PREINSTALL_FILES += $(PROJECT_INCLUDE)/tod.h
    8383
    84 $(PROJECT_INCLUDE)/bsp/vectors.h: ../../powerpc/shared/vectors/vectors.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     84$(PROJECT_INCLUDE)/bsp/bspException.h: vectors/bspException.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     85        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bspException.h
     86PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bspException.h
     87
     88$(PROJECT_INCLUDE)/bsp/vectors.h: ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/vectors.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    8589        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/vectors.h
    8690PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/vectors.h
    8791
    88 $(PROJECT_INCLUDE)/bsp/bspException.h: vectors/bspException.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
    89         $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bspException.h
    90 PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bspException.h
     92$(PROJECT_INCLUDE)/bsp/irq_supp.h: ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/irq_supp.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     93        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq_supp.h
     94PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq_supp.h
     95
     96$(PROJECT_INCLUDE)/bsp/ppc_exc_bspsupp.h: ../../../libcpu/@RTEMS_CPU@/@exceptions@/bspsupport/ppc_exc_bspsupp.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     97        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/ppc_exc_bspsupp.h
     98PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/ppc_exc_bspsupp.h
    9199
    92100$(PROJECT_INCLUDE)/bsp/bspMvme5500.h: GT64260/bspMvme5500.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
Note: See TracChangeset for help on using the changeset viewer.