source: rtems/bsps/include/dev/irq/arm-gic-tm27.h @ 5e8ec63

Last change on this file since 5e8ec63 was 5e8ec63, checked in by Joel Sherrill <joel@…>, on 07/08/22 at 13:46:56

bsps/include: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 *  @file
5 *
6 *  @ingroup arm_gic
7 *
8 *  @brief ARM GIC TM27 Support
9 */
10
11/*
12 * Copyright (c) 2013-2014 embedded brains GmbH.  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#ifndef _RTEMS_TMTEST27
37#error "This is an RTEMS internal file you must not include directly."
38#endif
39
40#ifndef LIBBSP_ARM_SHARED_ARM_GIC_TM27_H
41#define LIBBSP_ARM_SHARED_ARM_GIC_TM27_H
42
43#include <assert.h>
44
45#include <bsp.h>
46#include <bsp/irq.h>
47
48#define MUST_WAIT_FOR_INTERRUPT 1
49
50#ifndef ARM_GIC_TM27_IRQ_LOW
51#define ARM_GIC_TM27_IRQ_LOW ARM_GIC_IRQ_SGI_12
52#endif
53
54#ifndef ARM_GIC_TM27_IRQ_HIGH
55#define ARM_GIC_TM27_IRQ_HIGH ARM_GIC_IRQ_SGI_13
56#endif
57
58#define ARM_GIC_TM27_PRIO_LOW 0x80
59
60#define ARM_GIC_TM27_PRIO_HIGH 0x00
61
62static inline void Install_tm27_vector(void (*handler)(rtems_vector_number))
63{
64  rtems_status_code sc = rtems_interrupt_handler_install(
65    ARM_GIC_TM27_IRQ_LOW,
66    "tm27 low",
67    RTEMS_INTERRUPT_UNIQUE,
68    (rtems_interrupt_handler) handler,
69    NULL
70  );
71  assert(sc == RTEMS_SUCCESSFUL);
72
73  sc = arm_gic_irq_set_priority(
74    ARM_GIC_TM27_IRQ_LOW,
75    ARM_GIC_TM27_PRIO_LOW
76  );
77  assert(sc == RTEMS_SUCCESSFUL);
78
79  sc = rtems_interrupt_handler_install(
80    ARM_GIC_TM27_IRQ_HIGH,
81    "tm27 high",
82    RTEMS_INTERRUPT_UNIQUE,
83    (rtems_interrupt_handler) handler,
84    NULL
85  );
86  assert(sc == RTEMS_SUCCESSFUL);
87
88  sc = arm_gic_irq_set_priority(
89    ARM_GIC_TM27_IRQ_HIGH,
90    ARM_GIC_TM27_PRIO_HIGH
91  );
92  assert(sc == RTEMS_SUCCESSFUL);
93}
94
95static inline void Cause_tm27_intr(void)
96{
97  rtems_status_code sc = arm_gic_irq_generate_software_irq(
98    ARM_GIC_TM27_IRQ_LOW,
99    1U << _SMP_Get_current_processor()
100  );
101  assert(sc == RTEMS_SUCCESSFUL);
102}
103
104static inline void Clear_tm27_intr(void)
105{
106  /* Nothing to do */
107}
108
109static inline void Lower_tm27_intr(void)
110{
111  rtems_status_code sc = arm_gic_irq_generate_software_irq(
112    ARM_GIC_TM27_IRQ_HIGH,
113    1U << _SMP_Get_current_processor()
114  );
115  assert(sc == RTEMS_SUCCESSFUL);
116}
117
118#endif /* LIBBSP_ARM_SHARED_ARM_GIC_TM27_H */
Note: See TracBrowser for help on using the repository browser.