source: rtems/c/src/lib/libcpu/powerpc/mpc55xx/irq/irq.c @ 599e6fbd

5
Last change on this file since 599e6fbd was 599e6fbd, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 19, 2017 at 7:02:30 AM

bsps/powerpc: PPC_EXC_CONFIG_USE_FIXED_HANDLER

Make PPC_EXC_CONFIG_USE_FIXED_HANDLER mandatory for BSPs using
ppc_exc_interrupt(). Pass exception number to bsp_interrupt_dispatch()
to allow processing of decrementer and doorbell exceptions as hypervisor
guest.

Update #3085.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc55xx
5 *
6 * @brief Source file for MPC55XX interrupt support.
7 */
8
9/*
10 * Copyright (c) 2008-2012 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#include <mpc55xx/regs.h>
24
25#include <libcpu/powerpc-utility.h>
26
27#include <bsp/irq.h>
28#include <bsp/vectors.h>
29#include <bsp/irq-generic.h>
30
31#define RTEMS_STATUS_CHECKS_USE_PRINTK
32
33#include <rtems/status-checks.h>
34
35/**
36 * @brief Returns the priority @a priority of IRQ @a vector from the INTC.
37 */
38rtems_status_code mpc55xx_intc_get_priority( rtems_vector_number vector, unsigned *priority)
39{
40        if (MPC55XX_IRQ_IS_VALID( vector)) {
41                *priority = INTC.PSR [vector].B.PRI;
42                return RTEMS_SUCCESSFUL;
43        } else {
44                *priority = MPC55XX_INTC_INVALID_PRIORITY;
45                return RTEMS_INVALID_NUMBER;
46        }
47}
48
49/**
50 * @brief Sets the priority of IRQ @a vector to @a priority at the INTC.
51 */
52rtems_status_code mpc55xx_intc_set_priority( rtems_vector_number vector, unsigned priority)
53{
54        if (MPC55XX_IRQ_IS_VALID( vector) && MPC55XX_INTC_IS_VALID_PRIORITY( priority)) {
55                INTC.PSR [vector].B.PRI = priority;
56                if (INTC.PSR [vector].B.PRI == priority) {
57                        return RTEMS_SUCCESSFUL;
58                } else {
59                        return RTEMS_IO_ERROR;
60                }
61        } else {
62                return RTEMS_INVALID_NUMBER;
63        }
64}
65
66/**
67 * @brief Raises the software IRQ with number @a vector.
68 */
69rtems_status_code mpc55xx_intc_raise_software_irq( rtems_vector_number vector)
70{
71        if (MPC55XX_IRQ_IS_SOFTWARE( vector)) {
72                INTC.SSCIR [vector].B.SET = 1;
73                return RTEMS_SUCCESSFUL;
74        } else {
75                return RTEMS_INVALID_NUMBER;
76        }
77}
78
79/**
80 * @brief Clears the software IRQ with number @a vector.
81 */
82rtems_status_code mpc55xx_intc_clear_software_irq( rtems_vector_number vector)
83{
84        if (MPC55XX_IRQ_IS_SOFTWARE( vector)) {
85                INTC.SSCIR [vector].B.CLR = 1;
86                return RTEMS_SUCCESSFUL;
87        } else {
88                return RTEMS_INVALID_NUMBER;
89        }
90}
91
92/**
93 * @brief Installs interrupt handler and sets priority.
94 */
95rtems_status_code mpc55xx_interrupt_handler_install(
96        rtems_vector_number vector,
97        const char *info,
98        rtems_option options,
99        unsigned priority,
100        rtems_interrupt_handler handler,
101        void *arg
102)
103{
104        if (MPC55XX_IRQ_IS_VALID( vector) && MPC55XX_INTC_IS_VALID_PRIORITY( priority)) {
105                rtems_status_code sc = RTEMS_SUCCESSFUL;
106
107                sc = rtems_interrupt_handler_install( vector, info, options, handler, arg);
108                RTEMS_CHECK_SC( sc, "Install interrupt handler");
109
110                return mpc55xx_intc_set_priority( vector, priority);
111        } else {
112                return RTEMS_INVALID_NUMBER;
113        }
114}
115
116void bsp_interrupt_dispatch(uintptr_t exception_number)
117{
118        /* Acknowledge interrupt request */
119        rtems_vector_number vector = INTC.IACKR.B.INTVEC;
120
121        /* Save machine state and enable external exceptions */
122        uint32_t msr = ppc_external_exceptions_enable();
123
124        /* Dispatch interrupt handlers */
125        bsp_interrupt_handler_dispatch( vector);
126
127        /* Restore machine state */
128        ppc_external_exceptions_disable( msr);
129
130        /* End of interrupt */
131        INTC.EOIR.R = 1;
132}
133
134rtems_status_code bsp_interrupt_facility_initialize(void)
135{
136        rtems_vector_number vector;
137
138        /* Initialize interrupt controller */
139
140        /* Disable all interrupts */
141        for (vector = MPC55XX_IRQ_MIN; vector <= MPC55XX_IRQ_MAX; ++vector) {
142                INTC.PSR [vector].B.PRI = MPC55XX_INTC_DISABLED_PRIORITY;
143        }
144
145        /* Software vector mode */
146        INTC.MCR.B.VTES = 0;
147        INTC.MCR.B.HVEN = 0;
148
149        /* Set current priority to 0 */
150        INTC.CPR.B.PRI = 0;
151
152        return RTEMS_SUCCESSFUL;
153}
154
155void bsp_interrupt_vector_enable( rtems_vector_number vector)
156{
157        bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
158        mpc55xx_intc_set_priority( vector, MPC55XX_INTC_DEFAULT_PRIORITY);
159}
160
161void bsp_interrupt_vector_disable( rtems_vector_number vector)
162{
163        bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
164        mpc55xx_intc_set_priority( vector, MPC55XX_INTC_DISABLED_PRIORITY);
165}
Note: See TracBrowser for help on using the repository browser.