[rtems commit] score: Add Processor_mask, etc.
Sebastian Huber
sebh at rtems.org
Fri Mar 4 13:52:25 UTC 2016
Module: rtems
Branch: master
Commit: a38d1fe41250de907e7d03edd3d7a113f37bba55
Changeset: http://git.rtems.org/rtems/commit/?id=a38d1fe41250de907e7d03edd3d7a113f37bba55
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Feb 17 15:25:10 2016 +0100
score: Add Processor_mask, etc.
---
cpukit/score/Makefile.am | 1 +
cpukit/score/include/rtems/score/processormask.h | 90 ++++++++++++++++++++++++
cpukit/score/preinstall.am | 4 ++
3 files changed, 95 insertions(+)
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 8506f22..3d3f1c1 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -61,6 +61,7 @@ include_rtems_score_HEADERS += include/rtems/score/priority.h
include_rtems_score_HEADERS += include/rtems/score/prioritybitmap.h
include_rtems_score_HEADERS += include/rtems/score/prioritybitmapimpl.h
include_rtems_score_HEADERS += include/rtems/score/profiling.h
+include_rtems_score_HEADERS += include/rtems/score/processormask.h
include_rtems_score_HEADERS += include/rtems/score/rbtree.h
include_rtems_score_HEADERS += include/rtems/score/rbtreeimpl.h
include_rtems_score_HEADERS += include/rtems/score/resource.h
diff --git a/cpukit/score/include/rtems/score/processormask.h b/cpukit/score/include/rtems/score/processormask.h
new file mode 100644
index 0000000..5a78dd3
--- /dev/null
+++ b/cpukit/score/include/rtems/score/processormask.h
@@ -0,0 +1,90 @@
+/**
+ * @file
+ *
+ * @brief Processor Mask API
+ *
+ * @ingroup ScoreProcessorMask
+ */
+
+/*
+ * Copyright (c) 2016 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef _RTEMS_SCORE_PROCESSORMASK_H
+#define _RTEMS_SCORE_PROCESSORMASK_H
+
+#include <rtems/score/cpu.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup ScoreProcessorMask Processor Mask
+ *
+ * @ingroup Score
+ *
+ * The processor mask provides a bit map large enough to provide one bit for
+ * each processor in the system. It is a fixed size internal data type
+ * provided for efficiency in addition to the API level cpu_set_t.
+ *
+ * @{
+ */
+
+#define PROCESSOR_MASK_BITS_PER_FIELD 32
+
+#define PROCESSOR_MASK_FIELD_COUNT \
+ ( ( CPU_MAXIMUM_PROCESSORS + PROCESSOR_MASK_BITS_PER_FIELD - 1 ) \
+ / PROCESSOR_MASK_BITS_PER_FIELD )
+
+#define PROCESSOR_MASK_BIT( index ) \
+ (1UL << ( ( index ) % PROCESSOR_MASK_BITS_PER_FIELD ) )
+
+#define PROCESSOR_MASK_FIELD( index ) \
+ ( ( index ) / PROCESSOR_MASK_BITS_PER_FIELD )
+
+/**
+ * @brief A bit map consisting of 32-bit integer fields which is large enough
+ * to provide one bit for each processor in the system.
+ *
+ * Processor 0 corresponds to the bit 0 (least-significant) of the field 0 in
+ * the array, and so on.
+ */
+typedef uint32_t Processor_mask[ PROCESSOR_MASK_FIELD_COUNT ];
+
+RTEMS_INLINE_ROUTINE void _Processor_mask_Set( Processor_mask mask, uint32_t index )
+{
+ mask[ PROCESSOR_MASK_FIELD( index ) ] |= PROCESSOR_MASK_BIT( index );
+}
+
+RTEMS_INLINE_ROUTINE void _Processor_mask_Clear( Processor_mask mask, uint32_t index )
+{
+ mask[ PROCESSOR_MASK_FIELD( index ) ] &= ~PROCESSOR_MASK_BIT( index );
+}
+
+RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_set(
+ const Processor_mask mask,
+ uint32_t index
+)
+{
+ return ( mask[ PROCESSOR_MASK_FIELD( index ) ]
+ & PROCESSOR_MASK_BIT( index ) ) != 0;
+}
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RTEMS_SCORE_PROCESSORMASK_H */
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index 0d9cade..3a70bfa 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -212,6 +212,10 @@ $(PROJECT_INCLUDE)/rtems/score/profiling.h: include/rtems/score/profiling.h $(PR
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/profiling.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/profiling.h
+$(PROJECT_INCLUDE)/rtems/score/processormask.h: include/rtems/score/processormask.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/processormask.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/processormask.h
+
$(PROJECT_INCLUDE)/rtems/score/rbtree.h: include/rtems/score/rbtree.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/rbtree.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/rbtree.h
More information about the vc
mailing list