source: rtems/bsps/powerpc/shared/irq/ppc-irq-generic.c @ 2f56b737

5
Last change on this file since 2f56b737 was 2f56b737, checked in by Chris Johns <chrisj@…>, on 02/12/21 at 19:35:40

Update motorola_power to irq-generic interrupt management

  • Add support to the BSP to enable irq-generic management
  • Update the powerpc shared irq code to support irq-generic. This is an opt in option for existing powerpc bsps. This change should be simpler now
  • Fix a number of issues in ISA IRQ controller handling by porting fixes from the i386 (PC) BSP

Closes #4247
Closes #4248

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSBSPsPowerPC
7 *
8 * @brief Generic Interrupt suppoer
9 */
10
11/*
12 * Copyright (C) 2021 Chris Johns. All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 *    notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 *    notice, this list of conditions and the following disclaimer in the
21 *    documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#include <stdlib.h>
37
38#include <rtems.h>
39#include <stdlib.h>
40#include <rtems/bspIo.h> /* for printk */
41#include <libcpu/spr.h>
42#include <bsp/irq_supp.h>
43#include <bsp/irq-generic.h>
44#include <bsp/vectors.h>
45
46SPR_RW(BOOKE_TSR)
47SPR_RW(PPC405_TSR)
48
49/* legacy mode for bookE DEC exception;
50 * to avoid the double layer of function calls
51 * (dec_handler_bookE -> C_dispatch_irq_handler -> user handler)
52 * it is preferrable for the user to hook the DEC
53 * exception directly.
54 * However, the legacy mode works with less modifications
55 * of user code.
56 */
57static int C_dispatch_dec_handler_bookE (BSP_Exception_frame *frame, unsigned int excNum)
58{
59  /* clear interrupt; we must do this
60   * before C_dispatch_irq_handler()
61   * re-enables MSR_EE.
62   * Note that PPC405 uses a different SPR# for TSR
63   */
64  if (ppc_cpu_is_bookE()==PPC_BOOKE_405)
65    _write_PPC405_TSR( BOOKE_TSR_DIS );
66  else
67    _write_BOOKE_TSR( BOOKE_TSR_DIS );
68  return C_dispatch_irq_handler(frame, ASM_DEC_VECTOR);
69}
70
71/*
72 * RTEMS Global Interrupt Handler Management Routines
73 */
74int BSP_rtems_irq_generic_set(rtems_irq_global_settings* config)
75{
76  int r;
77
78  r = BSP_setup_the_pic(config);
79  if (!r)
80    return r;
81
82  ppc_exc_set_handler(ASM_EXT_VECTOR, C_dispatch_irq_handler);
83  if ( ppc_cpu_is_bookE() ) {
84    /* bookE decrementer interrupt needs to be cleared BEFORE
85     * dispatching the user ISR (because the user ISR is called
86     * with EE enabled)
87     * We do this so that existing DEC handlers can be used
88     * with minor modifications.
89     */
90    ppc_exc_set_handler(ASM_BOOKE_DEC_VECTOR, C_dispatch_dec_handler_bookE);
91  } else {
92    ppc_exc_set_handler(ASM_DEC_VECTOR, C_dispatch_irq_handler);
93  }
94
95  return 1;
96}
97
98void bsp_interrupt_vector_enable(rtems_vector_number vector)
99{
100  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
101  BSP_enable_irq_at_pic(vector);
102}
103
104void bsp_interrupt_vector_disable(rtems_vector_number vector)
105{
106  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
107  BSP_disable_irq_at_pic(vector);
108}
109
110rtems_status_code bsp_interrupt_facility_initialize(void)
111{
112  /*
113   * Initialize RTEMS IRQ system
114   */
115  BSP_rtems_irq_mng_init(0);
116  return RTEMS_SUCCESSFUL;
117}
Note: See TracBrowser for help on using the repository browser.