[PATCH v3 01/42] bsps/irq: Move get/set affinity to separate file

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jul 23 13:56:09 UTC 2021


Update #3269.
---
 bsps/shared/irq-default-sources.am           |  1 +
 bsps/shared/irq-sources.am                   |  1 +
 bsps/shared/irq/irq-affinity.c               | 90 ++++++++++++++++++++
 bsps/shared/irq/irq-generic.c                | 52 -----------
 c/src/lib/libbsp/m68k/genmcf548x/Makefile.am |  1 +
 c/src/lib/libbsp/powerpc/ss555/Makefile.am   |  1 +
 spec/build/bsps/m68k/genmcf548x/obj.yml      |  1 +
 spec/build/bsps/objirq.yml                   |  1 +
 spec/build/bsps/powerpc/ss555/bspss555.yml   |  1 +
 9 files changed, 97 insertions(+), 52 deletions(-)
 create mode 100644 bsps/shared/irq/irq-affinity.c

diff --git a/bsps/shared/irq-default-sources.am b/bsps/shared/irq-default-sources.am
index 1163f77bd8..6b4696dd26 100644
--- a/bsps/shared/irq-default-sources.am
+++ b/bsps/shared/irq-default-sources.am
@@ -1,3 +1,4 @@
+librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-affinity.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default-handler.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-generic.c
diff --git a/bsps/shared/irq-sources.am b/bsps/shared/irq-sources.am
index a5e8e6ffdf..65c380a2da 100644
--- a/bsps/shared/irq-sources.am
+++ b/bsps/shared/irq-sources.am
@@ -1,3 +1,4 @@
+librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-affinity.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-generic.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-info.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-legacy.c
diff --git a/bsps/shared/irq/irq-affinity.c b/bsps/shared/irq/irq-affinity.c
new file mode 100644
index 0000000000..f750d6b174
--- /dev/null
+++ b/bsps/shared/irq/irq-affinity.c
@@ -0,0 +1,90 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup bsp_interrupt
+ *
+ * @brief This source file contains the implementation of
+ *   rtems_interrupt_get_affinity() and rtems_interrupt_set_affinity().
+ */
+
+/*
+ * Copyright (C) 2017 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <bsp/irq-generic.h>
+
+#include <rtems/score/processormask.h>
+
+rtems_status_code rtems_interrupt_set_affinity(
+  rtems_vector_number  vector,
+  size_t               affinity_size,
+  const cpu_set_t     *affinity
+)
+{
+  Processor_mask             set;
+  Processor_mask_Copy_status status;
+
+  if (!bsp_interrupt_is_valid_vector(vector)) {
+    return RTEMS_INVALID_ID;
+  }
+
+  status = _Processor_mask_From_cpu_set_t(&set, affinity_size, affinity);
+  if (status != PROCESSOR_MASK_COPY_LOSSLESS) {
+    return RTEMS_INVALID_SIZE;
+  }
+
+#if defined(RTEMS_SMP)
+  bsp_interrupt_set_affinity(vector, &set);
+#endif
+  return RTEMS_SUCCESSFUL;
+}
+
+rtems_status_code rtems_interrupt_get_affinity(
+  rtems_vector_number  vector,
+  size_t               affinity_size,
+  cpu_set_t           *affinity
+)
+{
+  Processor_mask             set;
+  Processor_mask_Copy_status status;
+
+  if (!bsp_interrupt_is_valid_vector(vector)) {
+    return RTEMS_INVALID_ID;
+  }
+
+#if defined(RTEMS_SMP)
+  bsp_interrupt_get_affinity(vector, &set);
+#else
+  _Processor_mask_From_index(&set, 0);
+#endif
+
+  status = _Processor_mask_To_cpu_set_t(&set, affinity_size, affinity);
+  if (status != PROCESSOR_MASK_COPY_LOSSLESS) {
+    return RTEMS_INVALID_SIZE;
+  }
+
+  return RTEMS_SUCCESSFUL;
+}
diff --git a/bsps/shared/irq/irq-generic.c b/bsps/shared/irq/irq-generic.c
index 65971fb1b3..bea6612136 100644
--- a/bsps/shared/irq/irq-generic.c
+++ b/bsps/shared/irq/irq-generic.c
@@ -39,7 +39,6 @@
 
 #include <stdlib.h>
 
-#include <rtems/score/processormask.h>
 #include <rtems/malloc.h>
 
 #ifdef BSP_INTERRUPT_USE_INDEX_TABLE
@@ -548,54 +547,3 @@ bool bsp_interrupt_handler_is_empty(rtems_vector_number vector)
 
   return empty;
 }
-
-rtems_status_code rtems_interrupt_set_affinity(
-  rtems_vector_number  vector,
-  size_t               affinity_size,
-  const cpu_set_t     *affinity
-)
-{
-  Processor_mask             set;
-  Processor_mask_Copy_status status;
-
-  if (!bsp_interrupt_is_valid_vector(vector)) {
-    return RTEMS_INVALID_ID;
-  }
-
-  status = _Processor_mask_From_cpu_set_t(&set, affinity_size, affinity);
-  if (status != PROCESSOR_MASK_COPY_LOSSLESS) {
-    return RTEMS_INVALID_SIZE;
-  }
-
-#if defined(RTEMS_SMP)
-  bsp_interrupt_set_affinity(vector, &set);
-#endif
-  return RTEMS_SUCCESSFUL;
-}
-
-rtems_status_code rtems_interrupt_get_affinity(
-  rtems_vector_number  vector,
-  size_t               affinity_size,
-  cpu_set_t           *affinity
-)
-{
-  Processor_mask             set;
-  Processor_mask_Copy_status status;
-
-  if (!bsp_interrupt_is_valid_vector(vector)) {
-    return RTEMS_INVALID_ID;
-  }
-
-#if defined(RTEMS_SMP)
-  bsp_interrupt_get_affinity(vector, &set);
-#else
-  _Processor_mask_From_index(&set, 0);
-#endif
-
-  status = _Processor_mask_To_cpu_set_t(&set, affinity_size, affinity);
-  if (status != PROCESSOR_MASK_COPY_LOSSLESS) {
-    return RTEMS_INVALID_SIZE;
-  }
-
-  return RTEMS_SUCCESSFUL;
-}
diff --git a/c/src/lib/libbsp/m68k/genmcf548x/Makefile.am b/c/src/lib/libbsp/m68k/genmcf548x/Makefile.am
index a7dc71edd8..0ae30ca93a 100644
--- a/c/src/lib/libbsp/m68k/genmcf548x/Makefile.am
+++ b/c/src/lib/libbsp/m68k/genmcf548x/Makefile.am
@@ -38,6 +38,7 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/m68k/genmcf548x/console/console.
 librtemsbsp_a_SOURCES += ../../../../../../bsps/m68k/genmcf548x/btimer/btimer.c
 
 # IRQ
+librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-affinity.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default-handler.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-info.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-legacy.c
diff --git a/c/src/lib/libbsp/powerpc/ss555/Makefile.am b/c/src/lib/libbsp/powerpc/ss555/Makefile.am
index d5da8fb303..43fed4fcbd 100644
--- a/c/src/lib/libbsp/powerpc/ss555/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/ss555/Makefile.am
@@ -46,6 +46,7 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/ss555/start/raw_exceptio
 librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/ss555/start/vectors_init.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/ss555/start/vectors.S
 
+librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-affinity.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default-handler.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-generic.c
diff --git a/spec/build/bsps/m68k/genmcf548x/obj.yml b/spec/build/bsps/m68k/genmcf548x/obj.yml
index d01149ce38..a318da5e93 100644
--- a/spec/build/bsps/m68k/genmcf548x/obj.yml
+++ b/spec/build/bsps/m68k/genmcf548x/obj.yml
@@ -38,6 +38,7 @@ source:
 - bsps/m68k/shared/m68kidle.c
 - bsps/m68k/shared/memProbe.c
 - bsps/shared/dev/getentropy/getentropy-cpucounter.c
+- bsps/shared/irq/irq-affinity.c
 - bsps/shared/irq/irq-default-handler.c
 - bsps/shared/irq/irq-info.c
 - bsps/shared/irq/irq-legacy.c
diff --git a/spec/build/bsps/objirq.yml b/spec/build/bsps/objirq.yml
index aa3da23aa7..cb4eeb8fd4 100644
--- a/spec/build/bsps/objirq.yml
+++ b/spec/build/bsps/objirq.yml
@@ -10,6 +10,7 @@ includes: []
 install: []
 links: []
 source:
+- bsps/shared/irq/irq-affinity.c
 - bsps/shared/irq/irq-generic.c
 - bsps/shared/irq/irq-info.c
 - bsps/shared/irq/irq-legacy.c
diff --git a/spec/build/bsps/powerpc/ss555/bspss555.yml b/spec/build/bsps/powerpc/ss555/bspss555.yml
index c76dae2a4a..89c0ff7774 100644
--- a/spec/build/bsps/powerpc/ss555/bspss555.yml
+++ b/spec/build/bsps/powerpc/ss555/bspss555.yml
@@ -67,6 +67,7 @@ source:
 - bsps/powerpc/ss555/start/vectors.S
 - bsps/powerpc/ss555/start/vectors_init.c
 - bsps/shared/dev/getentropy/getentropy-cpucounter.c
+- bsps/shared/irq/irq-affinity.c
 - bsps/shared/irq/irq-default-handler.c
 - bsps/shared/irq/irq-default.c
 - bsps/shared/irq/irq-generic.c
-- 
2.26.2



More information about the devel mailing list