c/src/lib/libcpu/powerpc/mpc55xx/irq/irq.c

Go to the documentation of this file.
00001 
00009 /*
00010  * Copyright (c) 2008
00011  * Embedded Brains GmbH
00012  * Obere Lagerstr. 30
00013  * D-82178 Puchheim
00014  * Germany
00015  * rtems@embedded-brains.de
00016  *
00017  * The license and distribution terms for this file may be found in the file
00018  * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
00019  */
00020 
00021 #include <libcpu/mpc55xx/regs.h>
00022 #include <bsp/irq.h>
00023 
00027 rtems_status_code mpc55xx_intc_get_priority( int i, int *p)
00028 {
00029         if (MPC55XX_IRQ_IS_VALID( i)) {
00030                 *p = INTC.PSR [i].B.PRI;
00031                 return RTEMS_SUCCESSFUL;
00032         } else {
00033                 *p = MPC55XX_INTC_INVALID_PRIORITY;
00034                 return RTEMS_INVALID_NUMBER;
00035         }              
00036 }
00037 
00041 rtems_status_code mpc55xx_intc_set_priority( int i, int p)
00042 {
00043         if (MPC55XX_IRQ_IS_VALID( i) && MPC55XX_INTC_IS_VALID_PRIORITY( p)) {
00044                 INTC.PSR [i].B.PRI = p;
00045                 if (INTC.PSR [i].B.PRI == p) {
00046                         return RTEMS_SUCCESSFUL;
00047                 } else {
00048                         return RTEMS_IO_ERROR;
00049                 }
00050         } else {
00051                 return RTEMS_INVALID_NUMBER;
00052         }              
00053 }
00054 
00058 rtems_status_code mpc55xx_intc_raise_software_irq( int i)
00059 {
00060         if (MPC55XX_IRQ_IS_SOFTWARE( i)) {
00061                 INTC.SSCIR [i].B.SET = 1;
00062                 return RTEMS_SUCCESSFUL;
00063         } else {
00064                 return RTEMS_INVALID_NUMBER;
00065         }              
00066 }
00067 
00071 rtems_status_code mpc55xx_intc_clear_software_irq( int i)
00072 {
00073         if (MPC55XX_IRQ_IS_SOFTWARE( i)) {
00074                 INTC.SSCIR [i].B.CLR = 1;
00075                 return RTEMS_SUCCESSFUL;
00076         } else {
00077                 return RTEMS_INVALID_NUMBER;
00078         }              
00079 }
00080 
00084 rtems_status_code mpc55xx_irq_install_handler( const rtems_irq_connect_data *handler, int p)
00085 {
00086         if (MPC55XX_IRQ_IS_VALID( handler->name) && MPC55XX_INTC_IS_VALID_PRIORITY( p)) {
00087                 if (BSP_install_rtems_shared_irq_handler( handler)) {
00088                         return mpc55xx_intc_set_priority( handler->name, p);
00089                 } else {
00090                         return RTEMS_IO_ERROR;
00091                 }
00092         } else {
00093                 return RTEMS_INVALID_NUMBER;
00094         }
00095 }
00096 
00097 #include <libcpu/raw_exception.h>
00098 #include <bsp/ppc_exc_bspsupp.h>
00099 #include <bsp/irq-generic.h>
00100 
00104 static int mpc55xx_external_exception_handler( BSP_Exception_frame *frame, unsigned exception_number)
00105 {
00106         /* Acknowlege interrupt request */
00107         uint32_t vector_number = INTC.IACKR.B.INTVEC;
00108 
00109         /* Save current interrupt level */
00110         uint32_t level = _ISR_Get_level();
00111 
00112         /* Enable all interrupts */
00113         _ISR_Set_level( 0);
00114 
00115         /* Dispatch interrupt handlers */
00116         bsp_interrupt_handler_dispatch( vector_number);
00117 
00118         /* Restore interrupt level */
00119         _ISR_Set_level( level);
00120 
00121         /* End of interrupt */
00122         INTC.EOIR.R = 1;
00123 
00124         return 0;
00125 }
00126 
00127 rtems_status_code bsp_interrupt_facility_initialize()
00128 {
00129         /* Install exception handler */
00130         if (ppc_exc_set_handler( ASM_EXT_VECTOR, mpc55xx_external_exception_handler)) {
00131                 return RTEMS_IO_ERROR;
00132         }
00133 
00134         /* Initialize interrupt controller */
00135 
00136         /* Software vector mode */
00137         INTC.MCR.B.VTES = 0;
00138         INTC.MCR.B.HVEN = 0;
00139 
00140         /* Set current priority to 0 */
00141         INTC.CPR.B.PRI = 0;
00142 
00143         return RTEMS_SUCCESSFUL;
00144 }
00145 
00146 rtems_status_code bsp_interrupt_vector_enable( rtems_vector_number vector)
00147 {
00148         if (MPC55XX_IRQ_IS_VALID( vector)) {
00149                 return mpc55xx_intc_set_priority( vector, MPC55XX_INTC_DEFAULT_PRIORITY);
00150         } else {
00151                 return RTEMS_SUCCESSFUL;
00152         }
00153 }
00154 
00155 rtems_status_code bsp_interrupt_vector_disable( rtems_vector_number vector)
00156 {
00157         if (MPC55XX_IRQ_IS_VALID( vector)) {
00158                 return mpc55xx_intc_set_priority( vector, MPC55XX_INTC_DISABLED_PRIORITY);
00159         } else {
00160                 return RTEMS_SUCCESSFUL;
00161         }
00162 }
00163 
00164 void bsp_interrupt_handler_default( rtems_vector_number vector)
00165 {
00166         /* Do nothing */
00167 }

Generated on Mon May 19 15:42:10 2008 for RTEMS by  doxygen 1.5.3