source: rtems/bsps/arm/shared/irq/irq-armv7m.c @ c7b4eca7

Last change on this file since c7b4eca7 was c7b4eca7, checked in by Sebastian Huber <sebastian.huber@…>, on 07/27/21 at 07:58:43

bsps/irq: bsp_interrupt_facility_initialize()

Do not return a status code in bsp_interrupt_facility_initialize() since this
leads to unreachable code in bsp_interrupt_initialize(). Use RTEMS_DEBUG
assertions in bsp_interrupt_facility_initialize() if necessary.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
5 * Copyright (C) 2011, 2012 Sebastian Huber
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <bsp/irq-generic.h>
30#include <bsp.h>
31#include <bsp/irq.h>
32#include <bsp/linker-symbols.h>
33#include <bsp/armv7m-irq.h>
34
35#include <rtems/score/armv7m.h>
36
37#include <string.h>
38
39#ifdef ARM_MULTILIB_ARCH_V7M
40
41rtems_status_code bsp_interrupt_get_attributes(
42  rtems_vector_number         vector,
43  rtems_interrupt_attributes *attributes
44)
45{
46  return RTEMS_SUCCESSFUL;
47}
48
49rtems_status_code bsp_interrupt_is_pending(
50  rtems_vector_number vector,
51  bool               *pending
52)
53{
54  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
55  bsp_interrupt_assert(pending != NULL);
56  *pending = false;
57  return RTEMS_UNSATISFIED;
58}
59
60rtems_status_code bsp_interrupt_raise(rtems_vector_number vector)
61{
62  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
63  return RTEMS_UNSATISFIED;
64}
65
66rtems_status_code bsp_interrupt_clear(rtems_vector_number vector)
67{
68  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
69  return RTEMS_UNSATISFIED;
70}
71
72rtems_status_code bsp_interrupt_vector_is_enabled(
73  rtems_vector_number vector,
74  bool               *enabled
75)
76{
77  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
78  bsp_interrupt_assert(enabled != NULL);
79  *enabled = false;
80  return RTEMS_UNSATISFIED;
81}
82
83rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector)
84{
85  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
86  _ARMV7M_NVIC_Set_enable((int) vector);
87  return RTEMS_SUCCESSFUL;
88}
89
90rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
91{
92  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
93  _ARMV7M_NVIC_Clear_enable((int) vector);
94  return RTEMS_SUCCESSFUL;
95}
96
97void bsp_interrupt_facility_initialize(void)
98{
99  ARMV7M_Exception_handler *vector_table;
100  int                       i;
101
102  vector_table = (ARMV7M_Exception_handler *) bsp_vector_table_begin;
103
104  if (bsp_vector_table_begin != bsp_start_vector_table_begin) {
105    memcpy(
106      vector_table,
107      bsp_start_vector_table_begin,
108      (size_t) bsp_vector_table_size
109    );
110  }
111
112  _ARMV7M_SCB->icsr = ARMV7M_SCB_ICSR_PENDSVCLR | ARMV7M_SCB_ICSR_PENDSTCLR;
113
114  for (i = 0; i < BSP_INTERRUPT_VECTOR_COUNT; ++i) {
115    _ARMV7M_NVIC_Clear_enable(i);
116    _ARMV7M_NVIC_Clear_pending(i);
117    _ARMV7M_NVIC_Set_priority(i, BSP_ARMV7M_IRQ_PRIORITY_DEFAULT);
118  }
119
120  _ARMV7M_SCB->vtor = vector_table;
121}
122
123#endif /* ARM_MULTILIB_ARCH_V7M */
Note: See TracBrowser for help on using the repository browser.