diff options
Diffstat (limited to 'cpukit/include/rtems')
378 files changed, 19396 insertions, 10601 deletions
diff --git a/cpukit/include/rtems/assoc.h b/cpukit/include/rtems/assoc.h index 78cbdf6efe..70dd05f49e 100644 --- a/cpukit/include/rtems/assoc.h +++ b/cpukit/include/rtems/assoc.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -6,6 +8,30 @@ * @brief RTEMS Associativity Routines */ +/* + * Copyright (C) 1995 Tony Bennett <tbennett@divnc.com> + * + * 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. + */ #ifndef _RTEMS_RTEMS_ASSOC_H #define _RTEMS_RTEMS_ASSOC_H diff --git a/cpukit/include/rtems/base64.h b/cpukit/include/rtems/base64.h new file mode 100644 index 0000000000..58e48a8c33 --- /dev/null +++ b/cpukit/include/rtems/base64.h @@ -0,0 +1,198 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSImplBase64 + * + * @brief This header file provides the interfaces of the + * @ref RTEMSImplBase64. + */ + +/* + * Copyright (C) 2020, 2024 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_BASE64_H +#define _RTEMS_BASE64_H + +#include <rtems/dev/io.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup RTEMSImplBase64 Base64 Encoding and Decoding + * + * @ingroup RTEMSImpl + * + * @brief This group contains support functions for base64 and base64url + * encoding and decoding. + * + * @{ + */ + +/** + * @brief Maps a 6-bit integer to the corresponding base64 encoding. + */ +extern const uint8_t _Base64_Encoding[ 64 ]; + +/** + * @brief Maps a 6-bit integer to the corresponding base64url encoding. + */ +extern const uint8_t _Base64url_Encoding[ 64 ]; + +/** + * @brief Outputs the source buffer in base64 encoding. + * + * After word length of output characters produced by the encoding a word break + * is produced. + * + * @param put_char is the put character function used to output the encoded + * source buffer. + * + * @param arg is the argument passed to the put character function. + * + * @param src is the pointer to the source buffer begin. + * + * @param srclen is the length of the source buffer in bytes. + * + * @param wordbreak is the word break string. + * + * @param wordlen is the word length in bytes. If the word length is less than + * four, then a word length of four will be used. + * + * @return Returns the count of output characters. + */ +int _Base64_Encode( + IO_Put_char put_char, + void *arg, + const void *src, + size_t len, + const char *wordbreak, + int wordlen +); + +/** + * @brief Outputs the source buffer in base64url encoding. + * + * After word length of output characters produced by the encoding a word break + * is produced. + * + * @param put_char is the put character function used to output the encoded + * source buffer. + * + * @param arg is the argument passed to the put character function. + * + * @param src is the pointer to the source buffer begin. + * + * @param srclen is the length of the source buffer in bytes. + * + * @param wordbreak is the word break string. + * + * @param wordlen is the word length in bytes. If the word length is less than + * four, then a word length of four will be used. + * + * @return Returns the count of output characters. + */ +int _Base64url_Encode( + IO_Put_char put_char, + void *arg, + const void *src, + size_t len, + const char *wordbreak, + int wordlen +); + +/** + * @brief Represents the base64 and base64url decoder state. + */ +typedef enum { + BASE64_DECODE_STATE_0, + BASE64_DECODE_STATE_1, + BASE64_DECODE_STATE_2, + BASE64_DECODE_STATE_3 +} Base64_Decode_state; + +/** + * @brief Contains the base64 and base64url decoder control. + */ +typedef struct { + Base64_Decode_state state; + uint8_t *target; + const uint8_t *target_end; +} Base64_Decode_control; + +/** + * @brief Maps a 7-bit character to the associated 6-bit integer as defined by + * the base64 or base64url encoding or a special value. + */ +extern const uint8_t _Base64_Decoding[ 128 ]; + +/** + * @brief Initializes the base64 decoder. + * + * @param[out] self is the base64 decoder control to initialize. + * + * @param[out] target is the base address of the target area for decoding. + * + * @param target_size is the size in bytes of the target area for decoding. + */ +void _Base64_Decode_initialize( + Base64_Decode_control *self, + uint8_t *target, + size_t target_size +); + +/** + * @brief Represents the base64 and base64url decoder status. + */ +typedef enum { + BASE64_DECODE_SUCCESS, + BASE64_DECODE_OVERFLOW, + BASE64_DECODE_INVALID_INPUT +} Base64_Decode_status; + +/** + * @brief Decodes the character. + * + * The decoder accepts base64 and base64url encodings. White space is ignored. + * + * @param[in, out] self is the base64 decoder control. + * + * @param ch is the character to decode. + */ +Base64_Decode_status _Base64_Decode( + Base64_Decode_control *self, + char ch +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_BASE64_H */ diff --git a/cpukit/include/rtems/bdbuf.h b/cpukit/include/rtems/bdbuf.h index 4d11a47619..2d6c022259 100644 --- a/cpukit/include/rtems/bdbuf.h +++ b/cpukit/include/rtems/bdbuf.h @@ -15,7 +15,7 @@ * issues. * Change to support demand driven variable buffer sizes. * - * Copyright (c) 2009-2012 embedded brains GmbH. + * Copyright (C) 2009, 2012 embedded brains GmbH & Co. KG */ #ifndef _RTEMS_BDBUF_H diff --git a/cpukit/include/rtems/bdpart.h b/cpukit/include/rtems/bdpart.h index f82a3275de..872fe5ca9f 100644 --- a/cpukit/include/rtems/bdpart.h +++ b/cpukit/include/rtems/bdpart.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,11 +9,28 @@ */ /* - * Copyright (C) 2009, 2012 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2009, 2012 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef RTEMS_BDPART_H diff --git a/cpukit/include/rtems/bsd.h b/cpukit/include/rtems/bsd.h index 8f852885f3..00dd82e12e 100644 --- a/cpukit/include/rtems/bsd.h +++ b/cpukit/include/rtems/bsd.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * Copyright (c) 2015 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_BSD_H @@ -41,7 +54,7 @@ extern "C" { /** * @copydoc _Timecounter_Bintime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_bintime( struct bintime *bt ) +static inline void rtems_bsd_bintime( struct bintime *bt ) { _Timecounter_Bintime( bt ); } @@ -49,7 +62,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_bintime( struct bintime *bt ) /** * @copydoc _Timecounter_Nanotime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_nanotime( struct timespec *ts ) +static inline void rtems_bsd_nanotime( struct timespec *ts ) { _Timecounter_Nanotime( ts ); } @@ -57,7 +70,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_nanotime( struct timespec *ts ) /** * @copydoc _Timecounter_Microtime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_microtime( struct timeval *tv ) +static inline void rtems_bsd_microtime( struct timeval *tv ) { _Timecounter_Microtime( tv ); } @@ -65,7 +78,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_microtime( struct timeval *tv ) /** * @copydoc _Timecounter_Binuptime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_binuptime( struct bintime *bt ) +static inline void rtems_bsd_binuptime( struct bintime *bt ) { _Timecounter_Binuptime( bt ); } @@ -73,7 +86,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_binuptime( struct bintime *bt ) /** * @copydoc _Timecounter_Nanouptime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_nanouptime( struct timespec *ts ) +static inline void rtems_bsd_nanouptime( struct timespec *ts ) { _Timecounter_Nanouptime( ts ); } @@ -81,7 +94,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_nanouptime( struct timespec *ts ) /** * @copydoc _Timecounter_Microtime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_microuptime( struct timeval *tv ) +static inline void rtems_bsd_microuptime( struct timeval *tv ) { _Timecounter_Microuptime( tv ); } @@ -89,7 +102,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_microuptime( struct timeval *tv ) /** * @copydoc _Timecounter_Getbintime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getbintime( struct bintime *bt ) +static inline void rtems_bsd_getbintime( struct bintime *bt ) { _Timecounter_Getbintime( bt ); } @@ -97,7 +110,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_getbintime( struct bintime *bt ) /** * @copydoc _Timecounter_Getnanotime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getnanotime( struct timespec *ts ) +static inline void rtems_bsd_getnanotime( struct timespec *ts ) { _Timecounter_Getnanotime( ts ); } @@ -105,7 +118,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_getnanotime( struct timespec *ts ) /** * @copydoc _Timecounter_Getmicrotime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getmicrotime( struct timeval *tv ) +static inline void rtems_bsd_getmicrotime( struct timeval *tv ) { _Timecounter_Getmicrotime( tv ); } @@ -113,7 +126,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_getmicrotime( struct timeval *tv ) /** * @copydoc _Timecounter_Getbinuptime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getbinuptime( struct bintime *bt ) +static inline void rtems_bsd_getbinuptime( struct bintime *bt ) { _Timecounter_Getbinuptime( bt ); } @@ -121,7 +134,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_getbinuptime( struct bintime *bt ) /** * @copydoc _Timecounter_Getnanouptime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getnanouptime( struct timespec *ts ) +static inline void rtems_bsd_getnanouptime( struct timespec *ts ) { _Timecounter_Getnanouptime( ts ); } @@ -129,7 +142,7 @@ RTEMS_INLINE_ROUTINE void rtems_bsd_getnanouptime( struct timespec *ts ) /** * @copydoc _Timecounter_Getmicrouptime() */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getmicrouptime( struct timeval *tv ) +static inline void rtems_bsd_getmicrouptime( struct timeval *tv ) { _Timecounter_Getmicrouptime( tv ); } diff --git a/cpukit/include/rtems/bspIo.h b/cpukit/include/rtems/bspIo.h index b8a48e8237..a03e08c6a9 100644 --- a/cpukit/include/rtems/bspIo.h +++ b/cpukit/include/rtems/bspIo.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 2015 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -78,7 +78,7 @@ extern "C" { * * The directives may be used to print debug and test information. The kernel * character input/output support should work even if no Console Driver is - * configured, see #CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER. The kernel + * configured, see @ref CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER. The kernel * character input and output device is provided by the BSP. Applications may * change the device. */ diff --git a/cpukit/include/rtems/bspcmdline.h b/cpukit/include/rtems/bspcmdline.h index fea73fcc37..29f2cde7d5 100644 --- a/cpukit/include/rtems/bspcmdline.h +++ b/cpukit/include/rtems/bspcmdline.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -16,9 +18,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef __BSP_COMMAND_LINE_h diff --git a/cpukit/include/rtems/btimer.h b/cpukit/include/rtems/btimer.h index a2eee251e9..dff726769e 100644 --- a/cpukit/include/rtems/btimer.h +++ b/cpukit/include/rtems/btimer.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-1999. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ /* diff --git a/cpukit/include/rtems/capture.h b/cpukit/include/rtems/capture.h index c37d652211..4ab638ec24 100644 --- a/cpukit/include/rtems/capture.h +++ b/cpukit/include/rtems/capture.h @@ -838,7 +838,7 @@ rtems_capture_task_flags (rtems_tcb* tcb) static inline rtems_capture_control* rtems_capture_task_control (rtems_tcb* tcb) { - return tcb->Capture.control; + return (rtems_capture_control*) tcb->Capture.control; } /** @@ -853,7 +853,7 @@ rtems_capture_task_control (rtems_tcb* tcb) static inline uint32_t rtems_capture_task_control_flags (rtems_tcb* tcb) { - rtems_capture_control* control = tcb->Capture.control; + rtems_capture_control* control = rtems_capture_task_control (tcb); if (!control) return 0; return control->flags; diff --git a/cpukit/include/rtems/cbs.h b/cpukit/include/rtems/cbs.h index a42061ddc0..ee87cb7ae0 100644 --- a/cpukit/include/rtems/cbs.h +++ b/cpukit/include/rtems/cbs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * Copyright (C) 2011 Petr Benes. * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef CONFIGURE_SCHEDULER_CBS @@ -62,7 +81,7 @@ typedef Scheduler_CBS_Parameters rtems_cbs_parameters; * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_initialize ( void ) +static inline int rtems_cbs_initialize ( void ) { return _Scheduler_CBS_Initialize(); } @@ -74,7 +93,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_initialize ( void ) * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_cleanup ( void ) +static inline int rtems_cbs_cleanup ( void ) { return _Scheduler_CBS_Cleanup(); } @@ -86,7 +105,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_cleanup ( void ) * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_create_server ( +static inline int rtems_cbs_create_server ( rtems_cbs_parameters *params, rtems_cbs_budget_overrun budget_overrun_callback, rtems_cbs_server_id *server_id @@ -106,7 +125,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_create_server ( * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_attach_thread ( +static inline int rtems_cbs_attach_thread ( rtems_cbs_server_id server_id, rtems_id task_id ) @@ -121,7 +140,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_attach_thread ( * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_detach_thread ( +static inline int rtems_cbs_detach_thread ( rtems_cbs_server_id server_id, rtems_id task_id ) @@ -136,7 +155,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_detach_thread ( * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_destroy_server ( +static inline int rtems_cbs_destroy_server ( rtems_cbs_server_id server_id ) { @@ -151,7 +170,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_destroy_server ( * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_get_server_id ( +static inline int rtems_cbs_get_server_id ( rtems_id task_id, rtems_cbs_server_id *server_id ) @@ -166,7 +185,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_get_server_id ( * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_get_parameters ( +static inline int rtems_cbs_get_parameters ( rtems_cbs_server_id server_id, rtems_cbs_parameters *params ) @@ -181,7 +200,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_get_parameters ( * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_set_parameters ( +static inline int rtems_cbs_set_parameters ( rtems_cbs_server_id server_id, rtems_cbs_parameters *params ) @@ -196,7 +215,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_set_parameters ( * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_get_execution_time ( +static inline int rtems_cbs_get_execution_time ( rtems_cbs_server_id server_id, time_t *exec_time, time_t *abs_time @@ -212,7 +231,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_get_execution_time ( * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_get_remaining_budget ( +static inline int rtems_cbs_get_remaining_budget ( rtems_cbs_server_id server_id, time_t *remaining_budget ) @@ -228,7 +247,7 @@ RTEMS_INLINE_ROUTINE int rtems_cbs_get_remaining_budget ( * * @return status code. */ -RTEMS_INLINE_ROUTINE int rtems_cbs_get_approved_budget ( +static inline int rtems_cbs_get_approved_budget ( rtems_cbs_server_id server_id, time_t *appr_budget ) diff --git a/cpukit/include/rtems/chain.h b/cpukit/include/rtems/chain.h index 03177834a9..4f9f9495d5 100644 --- a/cpukit/include/rtems/chain.h +++ b/cpukit/include/rtems/chain.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,14 +9,31 @@ */ /* - * Copyright (c) 2010-2014 embedded brains GmbH. + * Copyright (C) 2010, 2014 embedded brains GmbH & Co. KG * * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_CHAIN_H @@ -147,7 +166,7 @@ rtems_status_code rtems_chain_get_with_wait( * @param[in] number_nodes is the number of nodes that will be in the chain * @param[in] node_size is the size of each node */ -RTEMS_INLINE_ROUTINE void rtems_chain_initialize( +static inline void rtems_chain_initialize( rtems_chain_control *the_chain, void *starting_address, size_t number_nodes, @@ -169,7 +188,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_initialize( * * @param[in] the_chain is the chain to be initialized. */ -RTEMS_INLINE_ROUTINE void rtems_chain_initialize_empty( +static inline void rtems_chain_initialize_empty( rtems_chain_control *the_chain ) { @@ -184,7 +203,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_initialize_empty( * * @param[in] node the node set to off chain. */ -RTEMS_INLINE_ROUTINE void rtems_chain_set_off_chain( +static inline void rtems_chain_set_off_chain( rtems_chain_node *node ) { @@ -199,7 +218,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_set_off_chain( * * @param[in] the_node The chain node to initialize. */ -RTEMS_INLINE_ROUTINE void rtems_chain_initialize_node( +static inline void rtems_chain_initialize_node( rtems_chain_node *node ) { @@ -217,7 +236,7 @@ RTEMS_INLINE_ROUTINE void rtems_chain_initialize_node( * @retval true The node is off chain. * @retval false The node is not off chain. */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_node_off_chain( +static inline bool rtems_chain_is_node_off_chain( const rtems_chain_node *node ) { @@ -234,7 +253,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_node_off_chain( * @retval true The chain node pointer is NULL. * @retval false The chain node pointer is not NULL. */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_null_node( +static inline bool rtems_chain_is_null_node( const rtems_chain_node *the_node ) { @@ -250,7 +269,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_null_node( * * @return This method returns the permanent node of the chain. */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_head( +static inline rtems_chain_node *rtems_chain_head( rtems_chain_control *the_chain ) { @@ -266,7 +285,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_head( * * @return This method returns the permanent head node of the chain. */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_head( +static inline const rtems_chain_node *rtems_chain_immutable_head( const rtems_chain_control *the_chain ) { @@ -282,7 +301,7 @@ RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_head( * * @return This method returns the permanent tail node of the chain. */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_tail( +static inline rtems_chain_node *rtems_chain_tail( rtems_chain_control *the_chain ) { @@ -298,7 +317,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_tail( * * @return This method returns the permanent tail node of the chain. */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_tail( +static inline const rtems_chain_node *rtems_chain_immutable_tail( const rtems_chain_control *the_chain ) { @@ -315,7 +334,7 @@ RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_tail( * * @return This method returns the first node of the chain. */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_first( +static inline rtems_chain_node *rtems_chain_first( const rtems_chain_control *the_chain ) { @@ -332,7 +351,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_first( * * @return This method returns the first node of the chain. */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_first( +static inline const rtems_chain_node *rtems_chain_immutable_first( const rtems_chain_control *the_chain ) { @@ -349,7 +368,7 @@ RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_first( * * @return This method returns the last node of the chain. */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_last( +static inline rtems_chain_node *rtems_chain_last( const rtems_chain_control *the_chain ) { @@ -366,7 +385,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_last( * * @return This method returns the last node of the chain. */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_last( +static inline const rtems_chain_node *rtems_chain_immutable_last( const rtems_chain_control *the_chain ) { @@ -382,7 +401,7 @@ RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_last( * * @return This method returns the next node on the chain. */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_next( +static inline rtems_chain_node *rtems_chain_next( const rtems_chain_node *the_node ) { @@ -398,7 +417,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_next( * * @return This method returns the next node on the chain. */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_next( +static inline const rtems_chain_node *rtems_chain_immutable_next( const rtems_chain_node *the_node ) { @@ -414,7 +433,7 @@ RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_next( * * @return This method returns the previous node on the chain. */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_previous( +static inline rtems_chain_node *rtems_chain_previous( const rtems_chain_node *the_node ) { @@ -430,7 +449,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_previous( * * @return This method returns the previous node on the chain. */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_previous( +static inline const rtems_chain_node *rtems_chain_immutable_previous( const rtems_chain_node *the_node ) { @@ -449,7 +468,7 @@ RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_previous( * @retval true @a left is equal to @a right. * @retval false @a left is not equal to @a right */ -RTEMS_INLINE_ROUTINE bool rtems_chain_are_nodes_equal( +static inline bool rtems_chain_are_nodes_equal( const rtems_chain_node *left, const rtems_chain_node *right ) @@ -468,7 +487,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_are_nodes_equal( * @retval true The chain is empty. * @retval false The chain is not empty. */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_empty( +static inline bool rtems_chain_is_empty( const rtems_chain_control *the_chain ) { @@ -487,7 +506,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_empty( * @retval true @a the_node is the first node on a chain. * @retval false @a the_node is not the first node on a chain. */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_first( +static inline bool rtems_chain_is_first( const rtems_chain_node *the_node ) { @@ -505,7 +524,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_first( * @retval true @a the_node is the last node on a chain. * @retval false @a the_node is not the last node on a chain */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_last( +static inline bool rtems_chain_is_last( const rtems_chain_node *the_node ) { @@ -523,7 +542,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_last( * @retval true The chain has only one node. * @retval false The chain has more than one nodes. */ -RTEMS_INLINE_ROUTINE bool rtems_chain_has_only_one_node( +static inline bool rtems_chain_has_only_one_node( const rtems_chain_control *the_chain ) { @@ -542,7 +561,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_has_only_one_node( * @retval true @a the_node is the head of @a the_chain. * @retval false @a the_node is not the head of @a the_chain. */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_head( +static inline bool rtems_chain_is_head( const rtems_chain_control *the_chain, const rtems_chain_node *the_node ) @@ -562,7 +581,7 @@ RTEMS_INLINE_ROUTINE bool rtems_chain_is_head( * @retval true @a the_node is the tail of @a the_chain. * @retval false @a the_node is not the tail of @a the_chain. */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_tail( +static inline bool rtems_chain_is_tail( const rtems_chain_control *the_chain, const rtems_chain_node *the_node ) @@ -591,7 +610,7 @@ void rtems_chain_extract( * NOTE: It does NOT disable interrupts to ensure the atomicity of the * append operation. */ -RTEMS_INLINE_ROUTINE void rtems_chain_extract_unprotected( +static inline void rtems_chain_extract_unprotected( rtems_chain_node *the_node ) { @@ -617,7 +636,7 @@ rtems_chain_node *rtems_chain_get( /** * @brief See _Chain_Get_unprotected(). */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_unprotected( +static inline rtems_chain_node *rtems_chain_get_unprotected( rtems_chain_control *the_chain ) { @@ -627,7 +646,7 @@ RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_unprotected( /** * @brief See _Chain_Get_first_unprotected(). */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_first_unprotected( +static inline rtems_chain_node *rtems_chain_get_first_unprotected( rtems_chain_control *the_chain ) { @@ -651,7 +670,7 @@ void rtems_chain_insert( /** * @brief See _Chain_Insert_unprotected(). */ -RTEMS_INLINE_ROUTINE void rtems_chain_insert_unprotected( +static inline void rtems_chain_insert_unprotected( rtems_chain_node *after_node, rtems_chain_node *the_node ) @@ -680,7 +699,7 @@ void rtems_chain_append( * NOTE: It does NOT disable interrupts to ensure the atomicity of the * append operation. */ -RTEMS_INLINE_ROUTINE void rtems_chain_append_unprotected( +static inline void rtems_chain_append_unprotected( rtems_chain_control *the_chain, rtems_chain_node *the_node ) @@ -715,7 +734,7 @@ void rtems_chain_prepend( * NOTE: It does NOT disable interrupts to ensure the atomicity of the * prepend operation. */ -RTEMS_INLINE_ROUTINE void rtems_chain_prepend_unprotected( +static inline void rtems_chain_prepend_unprotected( rtems_chain_control *the_chain, rtems_chain_node *the_node ) @@ -776,7 +795,7 @@ bool rtems_chain_get_with_empty_check( * * @return The node count of the chain. */ -RTEMS_INLINE_ROUTINE size_t rtems_chain_node_count_unprotected( +static inline size_t rtems_chain_node_count_unprotected( const rtems_chain_control *chain ) { diff --git a/cpukit/include/rtems/clockdrv.h b/cpukit/include/rtems/clockdrv.h index f3df912e74..cd55e1bfe5 100644 --- a/cpukit/include/rtems/clockdrv.h +++ b/cpukit/include/rtems/clockdrv.h @@ -1,20 +1,37 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * * @ingroup RTEMSDriverClock * - * @brief Clock Driver API - * - * This file defines the Clock Driver API. + * @brief This header file defines the Clock Driver API. */ /* * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_CLOCKDRV_H @@ -31,7 +48,7 @@ extern "C" { * * @ingroup RTEMSDeviceDrivers * - * @brief The Clock Driver API. + * @brief This group contains the Clock Driver API. * * @{ */ diff --git a/cpukit/include/rtems/concat.h b/cpukit/include/rtems/concat.h index f3072466b5..4cb0ae0c04 100644 --- a/cpukit/include/rtems/concat.h +++ b/cpukit/include/rtems/concat.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,9 +9,26 @@ /* * Copyright (c) 2004,2005 Ralf Corsepius, Ulm, Germany. * - * 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. + * 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. */ #ifndef _RTEMS_CONCAT_H diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h index e6dd3d70ee..29f7a2e71f 100644 --- a/cpukit/include/rtems/confdefs.h +++ b/cpukit/include/rtems/confdefs.h @@ -15,7 +15,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * Copyright (C) 1989, 2000 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -64,6 +64,7 @@ #include <rtems/confdefs/clock.h> #include <rtems/confdefs/console.h> #include <rtems/confdefs/extensions.h> +#include <rtems/confdefs/face.h> #include <rtems/confdefs/inittask.h> #include <rtems/confdefs/initthread.h> #include <rtems/confdefs/iodrivers.h> diff --git a/cpukit/include/rtems/confdefs/bdbuf.h b/cpukit/include/rtems/confdefs/bdbuf.h index 79e991f6d9..1cffe3fef6 100644 --- a/cpukit/include/rtems/confdefs/bdbuf.h +++ b/cpukit/include/rtems/confdefs/bdbuf.h @@ -18,7 +18,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/confdefs/bsp.h b/cpukit/include/rtems/confdefs/bsp.h index 03ad9bf55f..9e50b14f26 100644 --- a/cpukit/include/rtems/confdefs/bsp.h +++ b/cpukit/include/rtems/confdefs/bsp.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2013 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2013 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -41,19 +41,8 @@ #error "Do not include this file directly, use <rtems/confdefs.h> instead" #endif -#ifdef CONFIGURE_INIT - -#ifdef CONFIGURE_DISABLE_BSP_SETTINGS - #undef BSP_IDLE_TASK_BODY - #undef BSP_IDLE_TASK_STACK_SIZE - #undef BSP_INITIAL_EXTENSION - #undef BSP_INTERRUPT_STACK_SIZE - #undef CONFIGURE_BSP_PREREQUISITE_DRIVERS - #undef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK -#else - #include <bsp.h> +#if defined(CONFIGURE_INIT) && !defined(CONFIGURE_DISABLE_BSP_SETTINGS) +#include <bsp.h> #endif -#endif /* CONFIGURE_INIT */ - #endif /* _RTEMS_CONFDEFS_BSP_H */ diff --git a/cpukit/include/rtems/confdefs/clock.h b/cpukit/include/rtems/confdefs/clock.h index 4e86ec5d02..e57daa899b 100644 --- a/cpukit/include/rtems/confdefs/clock.h +++ b/cpukit/include/rtems/confdefs/clock.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -70,6 +70,11 @@ #warning "The clock ticks per second is not an integer" #endif +#if defined(CONFIGURE_TICKS_PER_TIMESLICE) \ + && CONFIGURE_TICKS_PER_TIMESLICE <= 0 + #error "CONFIGURE_TICKS_PER_TIMESLICE shall be greater than zero" +#endif + #if CONFIGURE_MICROSECONDS_PER_TICK <= 0 #error "CONFIGURE_MICROSECONDS_PER_TICK must be positive" #endif diff --git a/cpukit/include/rtems/confdefs/console.h b/cpukit/include/rtems/confdefs/console.h index f4ee59feea..9e12fa4c86 100644 --- a/cpukit/include/rtems/confdefs/console.h +++ b/cpukit/include/rtems/confdefs/console.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/confdefs/extensions.h b/cpukit/include/rtems/confdefs/extensions.h index 83d690d50a..c3bceda773 100644 --- a/cpukit/include/rtems/confdefs/extensions.h +++ b/cpukit/include/rtems/confdefs/extensions.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -93,6 +93,10 @@ #include <rtems/stackchk.h> #endif +#ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING + #include <rtems/score/exception.h> +#endif + #ifdef __cplusplus extern "C" { #endif @@ -103,6 +107,9 @@ extern "C" { || defined(CONFIGURE_INITIAL_EXTENSIONS) \ || defined(BSP_INITIAL_EXTENSION) const User_extensions_Table _User_extensions_Initial_extensions[] = { + #ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING + { .fatal = _Exception_Raise_signal }, + #endif #ifdef _CONFIGURE_RECORD_NEED_EXTENSION { #ifdef CONFIGURE_RECORD_EXTENSIONS_ENABLED @@ -139,7 +146,8 @@ extern "C" { #ifdef CONFIGURE_INITIAL_EXTENSIONS CONFIGURE_INITIAL_EXTENSIONS, #endif - #ifdef BSP_INITIAL_EXTENSION + #if !defined(CONFIGURE_DISABLE_BSP_SETTINGS) && \ + defined(BSP_INITIAL_EXTENSION) BSP_INITIAL_EXTENSION #endif }; @@ -180,6 +188,14 @@ extern "C" { RTEMS_SYSINIT_RECORD, RTEMS_SYSINIT_ORDER_MIDDLE ); + + #ifdef CONFIGURE_RECORD_INTERRUPTS_ENABLED + RTEMS_SYSINIT_ITEM( + _Record_Interrupt_initialize, + RTEMS_SYSINIT_LAST, + RTEMS_SYSINIT_ORDER_MIDDLE + ); + #endif #endif #ifdef CONFIGURE_VERBOSE_SYSTEM_INITIALIZATION diff --git a/cpukit/include/rtems/confdefs/face.h b/cpukit/include/rtems/confdefs/face.h new file mode 100644 index 0000000000..317d821623 --- /dev/null +++ b/cpukit/include/rtems/confdefs/face.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSImplApplConfig + * + * @brief This header file evaluates configuration options related to + * the FACE Technical Standard. + * + * The FACE Technical Standard (https://opengroup.org/face) is an + * open standard designed for safety critical embedded systems. It + * includes POSIX profiles and requirements that promote safety + * and portability. As a general rules, the profiles place a minimum + * on the services which an operating system must provide. Those + * same profile definitions represent the maximum services which + * an application may use. + */ + +/* + * Copyright (C) 2022 On-Line Applications Research Corporation (OAR) + * + * 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. + */ + +#ifndef _RTEMS_CONFDEFS_FACE_H +#define _RTEMS_CONFDEFS_FACE_H + +#ifndef __CONFIGURATION_TEMPLATE_h +#error "Do not include this file directly, use <rtems/confdefs.h> instead" +#endif + +#ifdef CONFIGURE_INIT + +#ifdef CONFIGURE_POSIX_TIMERS_FACE_BEHAVIOR + + #include <rtems/posix/timer.h> + + int _POSIX_Timer_Is_allowed( + clockid_t clock_id + ) + { + /* + * Per the FACE Technical Standard, POSIX timers should not be + * allowed on CLOCK_REALTIME for safety reasons. If the application + * wants the FACE behavior, then this method is instantiated. + */ + if ( clock_id == CLOCK_REALTIME ) { + return EPERM; + } + + if ( clock_id != CLOCK_MONOTONIC ) { + return EINVAL; + } + + return 0; + } + +#endif /* CONFIGURE_POSIX_TIMERS_FACE_BEHAVIOR */ + +#endif /* CONFIGURE_INIT */ + +#endif /* _RTEMS_CONFDEFS_FACE_H */ diff --git a/cpukit/include/rtems/confdefs/inittask.h b/cpukit/include/rtems/confdefs/inittask.h index 9dbf0b967b..0b17c08677 100644 --- a/cpukit/include/rtems/confdefs/inittask.h +++ b/cpukit/include/rtems/confdefs/inittask.h @@ -13,7 +13,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -122,8 +122,9 @@ RTEMS_STATIC_ASSERT( CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE_IS_TOO_SMALL ); +static RTEMS_SECTION( ".rtemsstack.userinit" ) RTEMS_ALIGNED( RTEMS_TASK_STORAGE_ALIGNMENT ) -static char _RTEMS_tasks_User_task_storage[ CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE ]; +char _RTEMS_tasks_User_task_storage[ CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE ]; const RTEMS_tasks_User_task_config _RTEMS_tasks_User_task_config = { { diff --git a/cpukit/include/rtems/confdefs/initthread.h b/cpukit/include/rtems/confdefs/initthread.h index 2b3d957515..325795b754 100644 --- a/cpukit/include/rtems/confdefs/initthread.h +++ b/cpukit/include/rtems/confdefs/initthread.h @@ -13,7 +13,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/confdefs/iodrivers.h b/cpukit/include/rtems/confdefs/iodrivers.h index a7de77a8c3..16d64fbb98 100644 --- a/cpukit/include/rtems/confdefs/iodrivers.h +++ b/cpukit/include/rtems/confdefs/iodrivers.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -43,16 +43,30 @@ #ifdef CONFIGURE_INIT -#if defined(CONFIGURE_APPLICATION_EXTRA_DRIVERS) \ - || defined(CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER) \ - || defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) \ - || defined(CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER) \ - || defined(CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER) \ - || defined(CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER) \ - || defined(CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER) \ - || defined(CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER) \ - || defined(CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER) \ - || CONFIGURE_MAXIMUM_DRIVERS > 0 +#include <rtems/confdefs/bsp.h> + +#if !defined(CONFIGURE_DISABLE_BSP_SETTINGS) && \ + defined(CONFIGURE_BSP_PREREQUISITE_DRIVERS) +#define _CONFIGURE_BSP_PREREQUISITE_DRIVERS CONFIGURE_BSP_PREREQUISITE_DRIVERS +#endif + +#if defined(_CONFIGURE_BSP_PREREQUISITE_DRIVERS) || \ + defined(CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS) || \ + defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) || \ + defined(CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER) || \ + defined(CONFIGURE_APPLICATION_NEEDS_WATCHDOG_DRIVER) || \ + defined(CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER) || \ + defined(CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER) || \ + defined(CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER) || \ + defined(CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER) || \ + defined(CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER) || \ + defined(CONFIGURE_APPLICATION_EXTRA_DRIVERS) +#define _CONFIGURE_HAS_IO_DRIVERS +#endif + +#if defined(_CONFIGURE_HAS_IO_DRIVERS) || \ + defined(CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER) || \ + CONFIGURE_MAXIMUM_DRIVERS > 0 #include <rtems/ioimpl.h> #include <rtems/sysinit.h> @@ -110,8 +124,8 @@ extern "C" { rtems_driver_address_table _IO_Driver_address_table[ CONFIGURE_MAXIMUM_DRIVERS ] = { - #ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS - CONFIGURE_BSP_PREREQUISITE_DRIVERS, + #ifdef _CONFIGURE_BSP_PREREQUISITE_DRIVERS + _CONFIGURE_BSP_PREREQUISITE_DRIVERS, #endif #ifdef CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS, @@ -143,15 +157,8 @@ _IO_Driver_address_table[ CONFIGURE_MAXIMUM_DRIVERS ] = { #ifdef CONFIGURE_APPLICATION_EXTRA_DRIVERS CONFIGURE_APPLICATION_EXTRA_DRIVERS, #endif - #if defined(CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER) \ - || ( !defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) \ - && !defined(CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER) \ - && !defined(CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER) \ - && !defined(CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER) \ - && !defined(CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER) \ - && !defined(CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER) \ - && !defined(CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER) \ - && !defined(CONFIGURE_APPLICATION_EXTRA_DRIVERS) ) + #if defined(CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER) || \ + !defined(_CONFIGURE_HAS_IO_DRIVERS) NULL_DRIVER_TABLE_ENTRY #endif }; @@ -178,16 +185,9 @@ RTEMS_SYSINIT_ITEM( } #endif -#endif /* CONFIGURE_APPLICATION_EXTRA_DRIVERS - || CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER - || CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER - || CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER - || CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER - || CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER - || CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER - || CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER - || CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER - || CONFIGURE_MAXIMUM_DRIVERS */ +#endif /* _CONFIGURE_HAS_IO_DRIVERS) || + CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER || + CONFIGURE_MAXIMUM_DRIVERS */ /* diff --git a/cpukit/include/rtems/confdefs/libio.h b/cpukit/include/rtems/confdefs/libio.h index 1b84f8c20f..7cf9f46487 100644 --- a/cpukit/include/rtems/confdefs/libio.h +++ b/cpukit/include/rtems/confdefs/libio.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -145,6 +145,16 @@ #ifdef CONFIGURE_FILESYSTEM_JFFS2 #include <rtems/jffs2.h> + +#ifndef CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY + #define CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY \ + RTEMS_JFFS2_DELAYED_WRITE_TASK_PRIORITY_DEFAULT +#endif + +const rtems_jffs2_config jffs2_config = { + CONFIGURE_JFFS2_DELAYED_WRITE_TASK_PRIORITY, +}; + #endif #ifdef CONFIGURE_FILESYSTEM_NFS diff --git a/cpukit/include/rtems/confdefs/libpci.h b/cpukit/include/rtems/confdefs/libpci.h index fb30eacdfa..07bf346f69 100644 --- a/cpukit/include/rtems/confdefs/libpci.h +++ b/cpukit/include/rtems/confdefs/libpci.h @@ -1,10 +1,4 @@ -/* - * Copyright (C) 2011 Cobham Gaisler AB - * - * 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. - */ +/* SPDX-License-Identifier: BSD-2-Clause */ /** * @file @@ -15,6 +9,31 @@ * library configuration. */ +/* + * Copyright (C) 2011 Cobham Gaisler AB + * + * 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. + */ + #ifndef _RTEMS_CONFDEFS_LIBPCI_H #define _RTEMS_CONFDEFS_LIBPCI_H diff --git a/cpukit/include/rtems/confdefs/malloc.h b/cpukit/include/rtems/confdefs/malloc.h index d864a98270..a20c6a290e 100644 --- a/cpukit/include/rtems/confdefs/malloc.h +++ b/cpukit/include/rtems/confdefs/malloc.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -45,8 +45,12 @@ #include <rtems/confdefs/bsp.h> -#if defined(CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK) \ - || defined(CONFIGURE_MALLOC_DIRTY) +#if !defined(CONFIGURE_DISABLE_BSP_SETTINGS) && \ + defined(CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK) +#define _CONFIGURE_HEAP_EXTEND_VIA_SBRK +#endif + +#if defined(_CONFIGURE_HEAP_EXTEND_VIA_SBRK) || defined(CONFIGURE_MALLOC_DIRTY) #include <rtems/malloc.h> #endif @@ -54,7 +58,7 @@ extern "C" { #endif -#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK +#ifdef _CONFIGURE_HEAP_EXTEND_VIA_SBRK const rtems_heap_extend_handler rtems_malloc_extend_handler = rtems_heap_extend_via_sbrk; #endif diff --git a/cpukit/include/rtems/confdefs/mpci.h b/cpukit/include/rtems/confdefs/mpci.h index 76bdf4af16..e079a59d70 100644 --- a/cpukit/include/rtems/confdefs/mpci.h +++ b/cpukit/include/rtems/confdefs/mpci.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/confdefs/newlib.h b/cpukit/include/rtems/confdefs/newlib.h index 96bf850163..65393fe92d 100644 --- a/cpukit/include/rtems/confdefs/newlib.h +++ b/cpukit/include/rtems/confdefs/newlib.h @@ -13,7 +13,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -57,7 +57,8 @@ extern "C" { #endif -#ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY +#if defined(_CONFIGURE_ENABLE_NEWLIB_REENTRANCY) && \ + !defined(_REENT_THREAD_LOCAL) struct _reent *__getreent( void ) { return _Thread_Get_executing()->libc_reent; diff --git a/cpukit/include/rtems/confdefs/objectsclassic.h b/cpukit/include/rtems/confdefs/objectsclassic.h index ff6f79a30b..aec4cf388b 100644 --- a/cpukit/include/rtems/confdefs/objectsclassic.h +++ b/cpukit/include/rtems/confdefs/objectsclassic.h @@ -12,7 +12,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/confdefs/objectsposix.h b/cpukit/include/rtems/confdefs/objectsposix.h index b4685c28f7..7dabb326f4 100644 --- a/cpukit/include/rtems/confdefs/objectsposix.h +++ b/cpukit/include/rtems/confdefs/objectsposix.h @@ -12,7 +12,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/confdefs/obsolete.h b/cpukit/include/rtems/confdefs/obsolete.h index b8b041efb5..a2eedad794 100644 --- a/cpukit/include/rtems/confdefs/obsolete.h +++ b/cpukit/include/rtems/confdefs/obsolete.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2017, 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2017, 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/confdefs/percpu.h b/cpukit/include/rtems/confdefs/percpu.h index 3bea8340cb..8ea7dae250 100644 --- a/cpukit/include/rtems/confdefs/percpu.h +++ b/cpukit/include/rtems/confdefs/percpu.h @@ -18,7 +18,7 @@ */ /* - * Copyright (C) 2018, 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2018, 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -78,7 +78,8 @@ extern "C" { /* Interrupt stack configuration */ #ifndef CONFIGURE_INTERRUPT_STACK_SIZE - #ifdef BSP_INTERRUPT_STACK_SIZE + #if !defined(CONFIGURE_DISABLE_BSP_SETTINGS) && \ + defined(BSP_INTERRUPT_STACK_SIZE) #define CONFIGURE_INTERRUPT_STACK_SIZE BSP_INTERRUPT_STACK_SIZE #else #define CONFIGURE_INTERRUPT_STACK_SIZE CPU_STACK_MINIMUM_SIZE @@ -121,7 +122,8 @@ RTEMS_DEFINE_GLOBAL_SYMBOL( /* Idle thread configuration */ #ifndef CONFIGURE_IDLE_TASK_STACK_SIZE - #ifdef BSP_IDLE_TASK_STACK_SIZE + #if !defined(CONFIGURE_DISABLE_BSP_SETTINGS) && \ + defined(BSP_IDLE_TASK_STACK_SIZE) #define CONFIGURE_IDLE_TASK_STACK_SIZE BSP_IDLE_TASK_STACK_SIZE #else #define CONFIGURE_IDLE_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE @@ -134,26 +136,13 @@ RTEMS_DEFINE_GLOBAL_SYMBOL( const size_t _Thread_Idle_stack_size = CONFIGURE_IDLE_TASK_STACK_SIZE; -/* - * If the user provides a custom idle stack allocator, then we do not need - * memory reserved for the stacks but the symbol is still referenced in - * threadcreateidle.c. The code path just never uses it. Make it minimal - * size to proceed. - */ -#ifndef CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE - char _Thread_Idle_stacks[ - _CONFIGURE_MAXIMUM_PROCESSORS - * ( CONFIGURE_IDLE_TASK_STACK_SIZE + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE ) - ] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT ) - RTEMS_SECTION( ".rtemsstack.idle" ); -#endif - #if defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) && \ !defined(CONFIGURE_IDLE_TASK_BODY) #error "If you define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, then you must define CONFIGURE_IDLE_TASK_BODY as well" #endif -#if !defined(CONFIGURE_IDLE_TASK_BODY) && defined(BSP_IDLE_TASK_BODY) +#if !defined(CONFIGURE_IDLE_TASK_BODY) && \ + !defined(CONFIGURE_DISABLE_BSP_SETTINGS) && defined(BSP_IDLE_TASK_BODY) #define CONFIGURE_IDLE_TASK_BODY BSP_IDLE_TASK_BODY #endif diff --git a/cpukit/include/rtems/confdefs/scheduler.h b/cpukit/include/rtems/confdefs/scheduler.h index 84ca810fd7..fdad17a4e1 100644 --- a/cpukit/include/rtems/confdefs/scheduler.h +++ b/cpukit/include/rtems/confdefs/scheduler.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -234,7 +234,17 @@ extern "C" { #endif #ifdef CONFIGURE_SCHEDULER + /* + * Ignore these warnings: + * + * - invalid use of structure with flexible array member + * + * - struct has no members + */ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpedantic" CONFIGURE_SCHEDULER; + #pragma GCC diagnostic pop #endif const Scheduler_Control _Scheduler_Table[] = { diff --git a/cpukit/include/rtems/confdefs/threads.h b/cpukit/include/rtems/confdefs/threads.h index 279c6264db..2e83df73b0 100644 --- a/cpukit/include/rtems/confdefs/threads.h +++ b/cpukit/include/rtems/confdefs/threads.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -147,7 +147,15 @@ const size_t _Thread_Maximum_TLS_size = CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE; struct Thread_Configured_control { +/* + * This was added to address the following warning. + * warning: invalid use of structure with flexible array member + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" Thread_Control Control; +#pragma GCC diagnostic pop + #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0 void *extensions[ CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1 ]; #endif @@ -159,10 +167,9 @@ struct Thread_Configured_control { #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1 char name[ CONFIGURE_MAXIMUM_THREAD_NAME_SIZE ]; #endif - #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY + #if defined(_CONFIGURE_ENABLE_NEWLIB_REENTRANCY) && \ + !defined(_REENT_THREAD_LOCAL) struct _reent Newlib; - #else - struct { /* Empty */ } Newlib; #endif }; @@ -176,13 +183,17 @@ const Thread_Control_add_on _Thread_Control_add_ons[] = { Control.API_Extensions[ THREAD_API_RTEMS ] ), offsetof( Thread_Configured_control, API_RTEMS ) - }, { - offsetof( - Thread_Configured_control, - Control.libc_reent - ), - offsetof( Thread_Configured_control, Newlib ) } + #if defined(_CONFIGURE_ENABLE_NEWLIB_REENTRANCY) && \ + !defined(_REENT_THREAD_LOCAL) + , { + offsetof( + Thread_Configured_control, + Control.libc_reent + ), + offsetof( Thread_Configured_control, Newlib ) + } + #endif #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1 , { offsetof( @@ -208,7 +219,14 @@ const size_t _Thread_Control_add_on_count = #ifdef RTEMS_SMP struct Thread_queue_Configured_heads { +/* + * This was put in to address the following warning. + * warning: invalid use of structure with flexible array member + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" Thread_queue_Heads Heads; +#pragma GCC diagnostic pop Thread_queue_Priority_queue Priority[ _CONFIGURE_SCHEDULER_COUNT ]; }; @@ -217,6 +235,10 @@ const size_t _Thread_Control_add_on_count = #endif const size_t _Thread_Initial_thread_count = +#if !defined(CONFIGURE_IDLE_TASK_STORAGE_SIZE) && \ + !defined(CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE) + _CONFIGURE_MAXIMUM_PROCESSORS + +#endif rtems_resource_maximum_per_allocation( _CONFIGURE_TASKS ) + rtems_resource_maximum_per_allocation( CONFIGURE_MAXIMUM_POSIX_THREADS ); diff --git a/cpukit/include/rtems/confdefs/unlimited.h b/cpukit/include/rtems/confdefs/unlimited.h index 41e79af1ba..98475297ed 100644 --- a/cpukit/include/rtems/confdefs/unlimited.h +++ b/cpukit/include/rtems/confdefs/unlimited.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/confdefs/wkspace.h b/cpukit/include/rtems/confdefs/wkspace.h index 82de8633bf..65f66c5c48 100644 --- a/cpukit/include/rtems/confdefs/wkspace.h +++ b/cpukit/include/rtems/confdefs/wkspace.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -47,6 +47,7 @@ #include <rtems/confdefs/inittask.h> #include <rtems/confdefs/initthread.h> #include <rtems/confdefs/objectsposix.h> +#include <rtems/confdefs/percpu.h> #include <rtems/confdefs/threads.h> #include <rtems/confdefs/wkspacesupport.h> #include <rtems/score/coremsg.h> @@ -111,8 +112,18 @@ + 1024 * CONFIGURE_MEMORY_OVERHEAD \ + _CONFIGURE_HEAP_HANDLER_OVERHEAD ) +#if defined(CONFIGURE_IDLE_TASK_STORAGE_SIZE) || \ + defined(CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE) + #define _CONFIGURE_IDLE_TASK_STACKS 0 +#else + #define _CONFIGURE_IDLE_TASK_STACKS \ + ( _CONFIGURE_MAXIMUM_PROCESSORS * \ + _Configure_From_stackspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) ) +#endif + #define _CONFIGURE_STACK_SPACE_SIZE \ ( _CONFIGURE_INIT_TASK_STACK_EXTRA \ + + _CONFIGURE_IDLE_TASK_STACKS \ + _CONFIGURE_POSIX_INIT_THREAD_STACK_EXTRA \ + _CONFIGURE_LIBBLOCK_TASKS_STACK_EXTRA \ + CONFIGURE_EXTRA_TASK_STACKS \ @@ -212,15 +223,40 @@ const uintptr_t _Stack_Space_size = _CONFIGURE_STACK_SPACE_SIZE; #error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined" #endif -/* - * Custom IDLE thread stacks allocator. If this is provided, it is assumed - * that the allocator is providing its own memory for these stacks. - */ -#ifdef CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE - const Stack_Allocator_allocate_for_idle _Stack_Allocator_allocate_for_idle = - CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE; +#ifdef CONFIGURE_IDLE_TASK_STORAGE_SIZE + #ifdef CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE + #error "CONFIGURE_IDLE_TASK_STORAGE_SIZE and CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE are mutually exclusive" + #endif + + #define _CONFIGURE_IDLE_TASK_STORAGE_SIZE \ + RTEMS_ALIGN_UP( \ + RTEMS_TASK_STORAGE_SIZE( \ + CONFIGURE_IDLE_TASK_STORAGE_SIZE, \ + RTEMS_DEFAULT_ATTRIBUTES \ + ), \ + CPU_INTERRUPT_STACK_ALIGNMENT \ + ) + + const size_t _Stack_Allocator_allocate_for_idle_storage_size = + _CONFIGURE_IDLE_TASK_STORAGE_SIZE; + + char _Stack_Allocator_allocate_for_idle_storage_areas[ + _CONFIGURE_MAXIMUM_PROCESSORS * _CONFIGURE_IDLE_TASK_STORAGE_SIZE + ] RTEMS_ALIGNED( CPU_INTERRUPT_STACK_ALIGNMENT ) + RTEMS_SECTION( ".rtemsstack.idle" ); + + #define CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE \ + _Stack_Allocator_allocate_for_idle_static #endif +#ifndef CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE + #define CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE \ + _Stack_Allocator_allocate_for_idle_workspace +#endif + +const Stack_Allocator_allocate_for_idle _Stack_Allocator_allocate_for_idle = + CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE; + #ifdef CONFIGURE_DIRTY_MEMORY RTEMS_SYSINIT_ITEM( _Memory_Dirty_free_areas, diff --git a/cpukit/include/rtems/confdefs/wkspacesupport.h b/cpukit/include/rtems/confdefs/wkspacesupport.h index 4036a7ae7f..ada91d7e91 100644 --- a/cpukit/include/rtems/confdefs/wkspacesupport.h +++ b/cpukit/include/rtems/confdefs/wkspacesupport.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/config.h b/cpukit/include/rtems/config.h index 7b15bc34a2..a19d809cf9 100644 --- a/cpukit/include/rtems/config.h +++ b/cpukit/include/rtems/config.h @@ -10,7 +10,8 @@ */ /* - * Copyright (C) 2009, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2009, 2021 embedded brains GmbH & Co. KG + * Copyright (C) 1988, 2021 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -60,6 +61,7 @@ #include <stdint.h> #include <rtems/rtems/config.h> #include <rtems/score/cpu.h> +#include <rtems/score/cpuopts.h> #include <rtems/score/isr.h> #include <rtems/score/memory.h> #include <rtems/score/object.h> @@ -89,10 +91,146 @@ extern "C" { * @brief The application configuration information group provides an API to * get the configuration of an application. * - * Some interfaces of this API are also used to define application - * configuration option values, for example rtems_resource_unlimited(). + * RTEMS must be configured for an application. This configuration encompasses + * a variety of information including the length of each clock tick, the + * maximum number of each information RTEMS object that can be created, the + * application initialization tasks, the task scheduling algorithm to be used, + * and the device drivers in the application. + * + * Although this information is contained in data structures that are used by + * RTEMS at system initialization time, the data structures themselves must not + * be generated by hand. RTEMS provides a set of macros system which provides a + * simple standard mechanism to automate the generation of these structures. + * + * The RTEMS header file ``<rtems/confdefs.h>`` is at the core of the automatic + * generation of system configuration. It is based on the idea of setting + * macros which define configuration parameters of interest to the application + * and defaulting or calculating all others. This variety of macros can + * automatically produce all of the configuration data required for an RTEMS + * application. The term ``confdefs`` is shorthand for a *Configuration + * Defaults*. + * + * As a general rule, application developers only specify values for the + * configuration parameters of interest to them. They define what resources or + * features they require. In most cases, when a parameter is not specified, it + * defaults to zero (0) instances, a standards compliant value, or disabled as + * appropriate. For example, by default there will be 256 task priority levels + * but this can be lowered by the application. This number of priority levels + * is required to be compliant with the RTEID/ORKID standards upon which the + * Classic API is based. There are similar cases where the default is selected + * to be compliant with the POSIX standard. + * + * For each configuration parameter in the configuration tables, the macro + * corresponding to that field is discussed. The RTEMS Maintainers expect that + * all systems can be easily configured using the ``<rtems/confdefs.h>`` + * mechanism and that using this mechanism will avoid internal RTEMS + * configuration changes impacting applications. + * + * Some application configuration settings and other system parameters can be + * queried by the application. */ +/* Generated from spec:/rtems/config/if/unlimited-objects */ + +/** + * @ingroup RTEMSAPIConfig + * + * @brief This flag is used in augment a resource number so that it indicates + * an unlimited resource. + */ +#define RTEMS_UNLIMITED_OBJECTS OBJECTS_UNLIMITED_OBJECTS + +/* Generated from spec:/rtems/config/if/get-stack-allocator-avoids-work-space */ + +/** + * @ingroup RTEMSAPIConfig + * + * @brief Indicates if the task stack allocator is configured to avoid the + * RTEMS Workspace for this application. + * + * @return Returns true, if the task stack allocator is configured to avoid the + * RTEMS Workspace for this application, otherwise false. + * + * @par Notes + * The setting is defined by the @ref + * CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE application configuration + * option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +#define rtems_configuration_get_stack_allocator_avoids_work_space() \ + _Stack_Allocator_avoids_workspace + +/* Generated from spec:/rtems/config/if/get-stack-space-size */ + +/** + * @ingroup RTEMSAPIConfig + * + * @brief Gets the configured size in bytes of the memory space used to + * allocate thread stacks for this application. + * + * @return Returns the configured size in bytes of the memory space used to + * allocate thread stacks for this application. + * + * @par Notes + * The size takes only threads and tasks into account with are known at the + * application configuration time. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +uintptr_t rtems_configuration_get_stack_space_size( void ); + +/* Generated from spec:/rtems/config/if/has-hardware-fp */ + +/** + * @ingroup RTEMSAPIConfig + * + * @brief This constant evaluates to #TRUE, if this processor variant has + * hardware floating point support, otherwise to #FALSE. + */ +#define RTEMS_HAS_HARDWARE_FP CPU_HARDWARE_FP + +/* Generated from spec:/rtems/config/if/stack-allocate-hook */ + +/** + * @ingroup RTEMSAPIConfig + * + * @brief A thread stack allocator allocate handler shall have this type. + */ +typedef Stack_Allocator_allocate rtems_stack_allocate_hook; + +/* Generated from spec:/rtems/config/if/stack-allocate-init-hook */ + +/** + * @ingroup RTEMSAPIConfig + * + * @brief A task stack allocator initialization handler shall have this type. + */ +typedef Stack_Allocator_initialize rtems_stack_allocate_init_hook; + +/* Generated from spec:/rtems/config/if/stack-free-hook */ + +/** + * @ingroup RTEMSAPIConfig + * + * @brief A task stack allocator free handler shall have this type. + */ +typedef Stack_Allocator_free rtems_stack_free_hook; + /* Generated from spec:/rtems/config/if/get-build-label */ /** @@ -100,10 +238,11 @@ extern "C" { * * @brief Gets the RTEMS build label. * - * The build label is a user-provided string defined by the build - * configuration. + * The build label is a user-provided string defined by the build configuration + * through the ``RTEMS_BUILD_LABEL`` build option. The format of the string is + * completely user-defined. * - * @return Returns the pointer to the RTEMS build label. + * @return Returns a pointer to the RTEMS build label. * * @par Notes * The build label can be used to distinguish test suite results obtained from @@ -131,10 +270,77 @@ const char *rtems_get_build_label( void ); * * @brief Gets the RTEMS copyright notice. * - * @return Returns the pointer to the RTEMS copyright notice. + * @return Returns a pointer to the RTEMS copyright notice. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ const char *rtems_get_copyright_notice( void ); +/* Generated from spec:/rtems/config/if/get-target-hash */ + +/** + * @ingroup RTEMSAPIConfig + * + * @brief Gets the RTEMS target hash. + * + * The target hash is calculated from BSP-specific values which characterize a + * target system. The target hash is encoded as a base64url string. The + * target hash algorithm is unspecified. + * + * @return Returns a pointer to the RTEMS target hash. + * + * @par Notes + * @parblock + * For example, the device tree, settings of the memory controller, processor + * and bus frequencies, a serial number of a chip may be used to calculate the + * target hash. + * + * The target hash can be used to distinguish test suite results obtained from + * different target systems. See also rtems_get_build_label(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +const char *rtems_get_target_hash( void ); + +/* Generated from spec:/rtems/config/if/get-version-string */ + +/** + * @ingroup RTEMSAPIConfig + * + * @brief Gets the RTEMS version string. + * + * @return Returns a pointer to the RTEMS version string. + * + * @par Notes + * The version string has no particular format. Parsing the string may break + * across RTEMS releases. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +const char *rtems_get_version_string( void ); + /* Generated from spec:/rtems/config/if/get-do-zero-of-workspace */ /** @@ -147,37 +353,67 @@ const char *rtems_get_copyright_notice( void ); * during system initialization for this application, otherwise false. * * @par Notes - * See #CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY. + * The setting is defined by the @ref CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY + * application configuration option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_do_zero_of_workspace() _Memory_Zero_before_use -/* Generated from spec:/rtems/config/if/get-idle-task */ +/* Generated from spec:/rtems/config/if/get-idle-task-stack-size */ /** * @ingroup RTEMSAPIConfig * - * @brief Gets the IDLE task entry of this application. + * @brief Gets the IDLE task stack size in bytes of this application. * - * @return Returns the IDLE task entry of this application. + * @return Returns the IDLE task stack size in bytes of this application. * * @par Notes - * See #CONFIGURE_IDLE_TASK_BODY. + * The IDLE task stack size is defined by the @ref + * CONFIGURE_IDLE_TASK_STACK_SIZE application configuration option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ -#define rtems_configuration_get_idle_task() _Thread_Idle_body +#define rtems_configuration_get_idle_task_stack_size() _Thread_Idle_stack_size -/* Generated from spec:/rtems/config/if/get-idle-task-stack-size */ +/* Generated from spec:/rtems/config/if/get-idle-task */ /** * @ingroup RTEMSAPIConfig * - * @brief Gets the IDLE task stack size in bytes of this application. + * @brief Gets the IDLE task body of this application. * - * @return Returns the IDLE task stack size in bytes of this application. + * @return Returns the IDLE task body of this application. * * @par Notes - * See #CONFIGURE_IDLE_TASK_STACK_SIZE. + * The IDLE task body is defined by the @ref CONFIGURE_IDLE_TASK_BODY + * application configuration option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ -#define rtems_configuration_get_idle_task_stack_size() _Thread_Idle_stack_size +#define rtems_configuration_get_idle_task() _Thread_Idle_body /* Generated from spec:/rtems/config/if/get-interrupt-stack-size */ @@ -189,24 +425,45 @@ const char *rtems_get_copyright_notice( void ); * @return Returns the interrupt stack size in bytes of this application. * * @par Notes - * See #CONFIGURE_INTERRUPT_STACK_SIZE. + * The interrupt stack size is defined by the @ref + * CONFIGURE_INTERRUPT_STACK_SIZE application configuration option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_interrupt_stack_size() \ - ((size_t) _ISR_Stack_size) + ((size_t) _ISR_Stack_size_object) /* Generated from spec:/rtems/config/if/get-maximum-extensions */ /** * @ingroup RTEMSAPIConfig * - * @brief Gets the maximum number of Classic API User Extensions configured for - * this application. + * @brief Gets the resource number of @ref RTEMSAPIClassicUserExt objects + * configured for this application. * - * @return Returns the maximum number of Classic API User Extensions configured - * for this application. + * @return Returns the resource number of @ref RTEMSAPIClassicUserExt objects + * configured for this application. * * @par Notes - * See #CONFIGURE_MAXIMUM_USER_EXTENSIONS. + * The resource number is defined by the @ref CONFIGURE_MAXIMUM_USER_EXTENSIONS + * application configuration option. See also rtems_resource_is_unlimited() + * and rtems_resource_maximum_per_allocation(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ uint32_t rtems_configuration_get_maximum_extensions( void ); @@ -225,11 +482,20 @@ uint32_t rtems_configuration_get_maximum_extensions( void ); * @parblock * The actual number of processors available to the application is returned by * rtems_scheduler_get_processor_maximum() which less than or equal to the - * configured maximum number of processors (#CONFIGURE_MAXIMUM_PROCESSORS). + * configured maximum number of processors (@ref CONFIGURE_MAXIMUM_PROCESSORS). * * In uniprocessor configurations, this macro is a compile time constant which * evaluates to one. * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_maximum_processors() \ _SMP_Processor_configured_maximum @@ -246,7 +512,17 @@ uint32_t rtems_configuration_get_maximum_extensions( void ); * this application. * * @par Notes - * See #CONFIGURE_MICROSECONDS_PER_TICK. + * The number of microseconds per clock tick is defined by the @ref + * CONFIGURE_MICROSECONDS_PER_TICK application configuration option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_microseconds_per_tick() \ _Watchdog_Microseconds_per_tick @@ -263,7 +539,17 @@ uint32_t rtems_configuration_get_maximum_extensions( void ); * this application. * * @par Notes - * See #CONFIGURE_MICROSECONDS_PER_TICK. + * The number of milliseconds per clock tick is defined by the @ref + * CONFIGURE_MICROSECONDS_PER_TICK application configuration option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_milliseconds_per_tick() \ ( _Watchdog_Microseconds_per_tick / 1000 ) @@ -280,7 +566,17 @@ uint32_t rtems_configuration_get_maximum_extensions( void ); * this application. * * @par Notes - * See #CONFIGURE_MICROSECONDS_PER_TICK. + * The number of nanoseconds per clock tick is defined by the @ref + * CONFIGURE_MICROSECONDS_PER_TICK application configuration option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_nanoseconds_per_tick() \ _Watchdog_Nanoseconds_per_tick @@ -297,123 +593,116 @@ uint32_t rtems_configuration_get_maximum_extensions( void ); * application. * * @par Notes - * See #CONFIGURE_INITIAL_EXTENSIONS. + * The number of initial extensions is defined by the @ref + * CONFIGURE_INITIAL_EXTENSIONS application configuration option and related + * options. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_number_of_initial_extensions() \ ((uint32_t) _User_extensions_Initial_count) -/* Generated from spec:/rtems/config/if/get-stack-allocate-hook */ +/* Generated from spec:/rtems/config/if/get-stack-allocate-for-idle-hook */ /** * @ingroup RTEMSAPIConfig * - * @brief Gets the thread stack allocator allocate hook configured for this - * application. + * @brief Gets the task stack allocator allocate hook used to allocate the + * stack of each IDLE task configured for this application. * - * @return Returns the thread stack allocator allocate hook configured for this - * application. + * @return Returns the task stack allocator allocate hook used to allocate the + * stack of each IDLE task configured for this application. * * @par Notes - * See #CONFIGURE_TASK_STACK_ALLOCATOR. - */ -#define rtems_configuration_get_stack_allocate_hook() _Stack_Allocator_allocate - -/* Generated from spec:/rtems/config/if/get-stack-allocate-init-hook */ - -/** - * @ingroup RTEMSAPIConfig + * The task stack allocator allocate hook for idle tasks is defined by the @ref + * CONFIGURE_TASK_STACK_ALLOCATOR_FOR_IDLE application configuration option. * - * @brief Gets the thread stack allocator initialization hook configured for - * this application. + * @par Constraints + * @parblock + * The following constraints apply to this directive: * - * @return Returns the thread stack allocator initialization hook configured - * for this application. + * * The directive may be called from within any runtime context. * - * @par Notes - * See #CONFIGURE_TASK_STACK_ALLOCATOR_INIT. + * * The directive will not cause the calling task to be preempted. + * @endparblock */ -#define rtems_configuration_get_stack_allocate_init_hook() \ - _Stack_Allocator_initialize +#define rtems_configuration_get_stack_allocate_for_idle_hook() \ + _Stack_Allocator_allocate_for_idle -/* Generated from spec:/rtems/config/if/get-stack-allocator-avoids-work-space */ +/* Generated from spec:/rtems/config/if/get-stack-allocate-hook */ /** * @ingroup RTEMSAPIConfig * - * @brief Indicates if the thread stack allocator is configured to avoid the - * RTEMS Workspace for this application. + * @brief Gets the task stack allocator allocate hook configured for this + * application. * - * @return Returns true, if the thread stack allocator is configured to avoid - * the RTEMS Workspace for this application, otherwise false. + * @return Returns the task stack allocator allocate hook configured for this + * application. * * @par Notes - * See #CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE. + * The task stack allocator allocate hook is defined by the @ref + * CONFIGURE_TASK_STACK_ALLOCATOR application configuration option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ -#define rtems_configuration_get_stack_allocator_avoids_work_space() \ - _Stack_Allocator_avoids_workspace +#define rtems_configuration_get_stack_allocate_hook() _Stack_Allocator_allocate -/* Generated from spec:/rtems/config/if/get-stack-free-hook */ +/* Generated from spec:/rtems/config/if/get-stack-allocate-init-hook */ /** * @ingroup RTEMSAPIConfig * - * @brief Gets the thread stack allocator free hook configured for this + * @brief Gets the task stack allocator initialization hook configured for this * application. * - * @return Returns the thread stack allocator free hook configured for this - * application. + * @return Returns the task stack allocator initialization hook configured for + * this application. * * @par Notes - * See #CONFIGURE_TASK_STACK_DEALLOCATOR. - */ -#define rtems_configuration_get_stack_free_hook() _Stack_Allocator_free - -/** - * @ingroup RTEMSAPIConfig + * The task stack allocator initialization hook is defined by the @ref + * CONFIGURE_TASK_STACK_ALLOCATOR_INIT application configuration option. * - * @brief Gets the IDLE thread stack allocator hook configured for this - * application. + * @par Constraints + * @parblock + * The following constraints apply to this directive: * - * @return Returns the IDLE thread stack allocator hook configured for this - * application. + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ -#define rtems_configuration_get_stack_allocate_for_idle_hook() \ - (_Stack_Allocator_allocate_for_idle) +#define rtems_configuration_get_stack_allocate_init_hook() \ + _Stack_Allocator_initialize -/* Generated from spec:/rtems/config/if/get-stack-space-size */ +/* Generated from spec:/rtems/config/if/get-stack-free-hook */ /** * @ingroup RTEMSAPIConfig * - * @brief Gets the thread stack space size in bytes of configured for this + * @brief Gets the task stack allocator free hook configured for this * application. * - * @return Returns the thread stack space size in bytes of configured for this + * @return Returns the task stack allocator free hook configured for this * application. - */ -uintptr_t rtems_configuration_get_stack_space_size( void ); - -/* Generated from spec:/rtems/config/if/get-target-hash */ - -/** - * @ingroup RTEMSAPIConfig - * - * @brief Gets the RTEMS target hash. - * - * The target hash is calculated from BSP-specific values which characterize a - * target system. - * - * @return Returns the pointer to the RTEMS target hash. * * @par Notes - * @parblock - * For example, the device tree, settings of the memory controller, processor - * and bus frequencies, a serial number of a chip may be used to calculate the - * target hash. - * - * The target hash can be used to distinguish test suite results obtained from - * different target systems. See also rtems_get_build_label(). - * @endparblock + * The task stack allocator free hook is defined by the @ref + * CONFIGURE_TASK_STACK_DEALLOCATOR application configuration option. * * @par Constraints * @parblock @@ -424,7 +713,7 @@ uintptr_t rtems_configuration_get_stack_space_size( void ); * * The directive will not cause the calling task to be preempted. * @endparblock */ -const char *rtems_get_target_hash( void ); +#define rtems_configuration_get_stack_free_hook() _Stack_Allocator_free /* Generated from spec:/rtems/config/if/get-ticks-per-timeslice */ @@ -437,7 +726,17 @@ const char *rtems_get_target_hash( void ); * application. * * @par Notes - * See #CONFIGURE_TICKS_PER_TIMESLICE. + * The clock ticks per timeslice is defined by the @ref + * CONFIGURE_TICKS_PER_TIMESLICE application configuration option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_ticks_per_timeslice() \ _Watchdog_Ticks_per_timeslice @@ -454,7 +753,17 @@ const char *rtems_get_target_hash( void ); * configured to be unified for this application, otherwise false. * * @par Notes - * See #CONFIGURE_UNIFIED_WORK_AREAS. + * The setting is defined by the @ref CONFIGURE_UNIFIED_WORK_AREAS application + * configuration option. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_unified_work_area() _Workspace_Is_unified @@ -465,8 +774,17 @@ const char *rtems_get_target_hash( void ); * * @brief Gets the initial extensions table configured for this application. * - * @return Returns the pointer to the initial extensions table configured for + * @return Returns a pointer to the initial extensions table configured for * this application. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_user_extension_table() \ _User_extensions_Initial_extensions @@ -478,8 +796,17 @@ const char *rtems_get_target_hash( void ); * * @brief Gets the MPCI configuration table configured for this application. * - * @return Returns the pointer to the MPCI configuration table configured for + * @return Returns a pointer to the MPCI configuration table configured for * this application. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #if defined(RTEMS_MULTIPROCESSING) #define rtems_configuration_get_user_multiprocessing_table() \ @@ -488,17 +815,6 @@ const char *rtems_get_target_hash( void ); #define rtems_configuration_get_user_multiprocessing_table() NULL #endif -/* Generated from spec:/rtems/config/if/get-version-string */ - -/** - * @ingroup RTEMSAPIConfig - * - * @brief Gets the RTEMS version string. - * - * @return Returns the pointer to the RTEMS version string. - */ -const char *rtems_get_version_string( void ); - /* Generated from spec:/rtems/config/if/get-work-space-size */ /** @@ -509,22 +825,21 @@ const char *rtems_get_version_string( void ); * * @return Returns the RTEMS Workspace size in bytes configured for this * application. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_configuration_get_work_space_size() \ ( _Workspace_Size + \ ( rtems_configuration_get_stack_allocator_avoids_work_space() ? \ 0 : rtems_configuration_get_stack_space_size() ) ) -/* Generated from spec:/rtems/config/if/has-hardware-fp */ - -/** - * @ingroup RTEMSAPIConfig - * - * @brief This constant evaluates to #TRUE, if this processor variant has - * hardware floating point support, otherwise to #FALSE. - */ -#define RTEMS_HAS_HARDWARE_FP CPU_HARDWARE_FP - /* Generated from spec:/rtems/config/if/resource-is-unlimited */ /** @@ -536,9 +851,16 @@ const char *rtems_get_version_string( void ); * * @return Returns true, if the resource is unlimited, otherwise false. * - * @par Notes - * This function is implemented as a macro and can be used to define compile - * time constants. + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive is implemented by a macro and may be called from within + * C/C++ constant expressions. In addition, a function implementation of the + * directive exists for bindings to other programming languages. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_resource_is_unlimited( _resource ) \ _Objects_Is_unlimited( _resource ) @@ -554,49 +876,19 @@ const char *rtems_get_version_string( void ); * * @return Returns the maximum number per allocation of a resource number. * - * @par Notes - * This function is implemented as a macro and can be used to define compile - * time constants. - */ -#define rtems_resource_maximum_per_allocation( _resource ) \ - _Objects_Maximum_per_allocation( _resource ) - -/* Generated from spec:/rtems/config/if/stack-allocate-hook */ - -/** - * @ingroup RTEMSAPIConfig - * - * @brief A thread stack allocator allocate handler shall have this type. - */ -typedef Stack_Allocator_allocate rtems_stack_allocate_hook; - -/* Generated from spec:/rtems/config/if/stack-allocate-init-hook */ - -/** - * @ingroup RTEMSAPIConfig - * - * @brief A thread stack allocator initialization handler shall have this type. - */ -typedef Stack_Allocator_initialize rtems_stack_allocate_init_hook; - -/* Generated from spec:/rtems/config/if/stack-free-hook */ - -/** - * @ingroup RTEMSAPIConfig + * @par Constraints + * @parblock + * The following constraints apply to this directive: * - * @brief A thread stack allocator free handler shall have this type. - */ -typedef Stack_Allocator_free rtems_stack_free_hook; - -/* Generated from spec:/rtems/config/if/unlimited-objects */ - -/** - * @ingroup RTEMSAPIConfig + * * The directive is implemented by a macro and may be called from within + * C/C++ constant expressions. In addition, a function implementation of the + * directive exists for bindings to other programming languages. * - * @brief This flag is used in augment a resource number so that it indicates - * an unlimited resource. + * * The directive will not cause the calling task to be preempted. + * @endparblock */ -#define RTEMS_UNLIMITED_OBJECTS OBJECTS_UNLIMITED_OBJECTS +#define rtems_resource_maximum_per_allocation( _resource ) \ + _Objects_Maximum_per_allocation( _resource ) /* Generated from spec:/rtems/config/if/resource-unlimited */ @@ -612,8 +904,19 @@ typedef Stack_Allocator_free rtems_stack_free_hook; * resource. * * @par Notes - * This function is implemented as a macro and can be used to define compile - * time constants. + * This directive should be used to configure unlimited objects, see Unlimited + * Objects. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive is implemented by a macro and may be called from within + * C/C++ constant expressions. In addition, a function implementation of the + * directive exists for bindings to other programming languages. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ #define rtems_resource_unlimited( _resource ) \ ( ( _resource ) | RTEMS_UNLIMITED_OBJECTS ) diff --git a/cpukit/include/rtems/console.h b/cpukit/include/rtems/console.h index 522e6fef41..7a7ad7a936 100644 --- a/cpukit/include/rtems/console.h +++ b/cpukit/include/rtems/console.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_CONSOLE_H diff --git a/cpukit/include/rtems/counter.h b/cpukit/include/rtems/counter.h index 0053afcbd5..9d8fa31719 100644 --- a/cpukit/include/rtems/counter.h +++ b/cpukit/include/rtems/counter.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. + * Copyright (C) 2014, 2018 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_SAPI_COUNTER_H @@ -86,20 +99,20 @@ static inline rtems_counter_ticks rtems_counter_read( void ) * @brief Returns the difference between the second and first CPU counter * value. * - * This operation may be carried out as a modulo operation depending on the - * range of the CPU counter device. + * This function is provided for backward compatibility. + * You may use "second - first" directly in the code. * * @param[in] second The second CPU counter value. * @param[in] first The first CPU counter value. * - * @return Returns second minus first modulo counter period. + * @return Returns second minus first. */ static inline rtems_counter_ticks rtems_counter_difference( rtems_counter_ticks second, rtems_counter_ticks first ) { - return _CPU_Counter_difference( second, first ); + return second - first; } /** diff --git a/cpukit/include/rtems/cpuuse.h b/cpukit/include/rtems/cpuuse.h index 86338a7332..f02f004073 100644 --- a/cpukit/include/rtems/cpuuse.h +++ b/cpukit/include/rtems/cpuuse.h @@ -3,13 +3,13 @@ /** * @file * - * @ingroup libmisc_cpuuse + * @ingroup RTEMSAPICPUUsageReporting * * @brief This header file provides the CPU usage reporting API. */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2021 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -62,7 +62,7 @@ extern "C" { /* Generated from spec:/rtems/cpuuse/if/group */ /** - * @defgroup libmisc_cpuuse CPU Usage Reporting + * @defgroup RTEMSAPICPUUsageReporting CPU Usage Reporting * * @ingroup RTEMSAPI * @@ -78,7 +78,7 @@ struct rtems_printer; /* Generated from spec:/rtems/cpuuse/if/cpu-info-report */ /** - * @ingroup libmisc_cpuuse + * @ingroup RTEMSAPICPUUsageReporting * * @brief Reports the CPU information using the printer plugin. * @@ -100,7 +100,7 @@ int rtems_cpu_info_report( const struct rtems_printer *printer ); /* Generated from spec:/rtems/cpuuse/if/report */ /** - * @ingroup libmisc_cpuuse + * @ingroup RTEMSAPICPUUsageReporting * * @brief Reports the CPU usage of each thread using the printk() printer. * @@ -125,7 +125,7 @@ void rtems_cpu_usage_report( void ); /* Generated from spec:/rtems/cpuuse/if/report-with-plugin */ /** - * @ingroup libmisc_cpuuse + * @ingroup RTEMSAPICPUUsageReporting * * @brief Reports the CPU usage of each thread using the printer plugin. * @@ -149,7 +149,7 @@ void rtems_cpu_usage_report_with_plugin( const struct rtems_printer *printer ); /* Generated from spec:/rtems/cpuuse/if/reset */ /** - * @ingroup libmisc_cpuuse + * @ingroup RTEMSAPICPUUsageReporting * * @brief Resets the CPU usage of each thread. * @@ -171,7 +171,7 @@ void rtems_cpu_usage_reset( void ); /* Generated from spec:/rtems/cpuuse/if/top */ /** - * @ingroup libmisc_cpuuse + * @ingroup RTEMSAPICPUUsageReporting * * @brief Starts an interactive CPU usage reporting using the printk() printer. * @@ -196,7 +196,7 @@ void rtems_cpu_usage_top( void ); /* Generated from spec:/rtems/cpuuse/if/top-with-plugin */ /** - * @ingroup libmisc_cpuuse + * @ingroup RTEMSAPICPUUsageReporting * * @brief Starts an interactive CPU usage reporting using the printer plugin. * diff --git a/cpukit/include/rtems/crc.h b/cpukit/include/rtems/crc.h new file mode 100644 index 0000000000..1158dbcd7b --- /dev/null +++ b/cpukit/include/rtems/crc.h @@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSImplCRC + * + * @brief This header file provides the interfaces of the + * @ref RTEMSImplCRC. + */ + +/* + * Copyright (C) 2024 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_CRC_H +#define _RTEMS_CRC_H + +#include <stddef.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup RTEMSImplCRC Cyclic Redundancy Check (CRC) Support + * + * @ingroup RTEMSImpl + * + * @brief This group contains functions to calculate + * Cyclic Redundancy Check (CRC) values. + * + * @{ + */ + + +/** + * @brief This constant represents the default CRC-24Q seed state. + */ +#define CRC24Q_SEED 0U + +/** + * @brief This constant provides a mask to get a valid CRC-24Q value from the + * integers returned by _CRC24Q_Update() and _CRC24Q_Sequence_update(). + */ +#define CRC24Q_MASK 0xffffffU + +/** + * @brief Updates the CRC-24Q state using a byte. + * + * @param crc is the input CRC-24Q state. + * + * @param byte is the byte updating the input CRC-24Q state. + * + * @return Returns the updated CRC-24Q state. Use the #CRC24Q_MASK to get a + * valid CRC-24Q value. + */ +uint32_t _CRC24Q_Update( uint32_t crc, uint8_t byte ); + +/** + * @brief Updates the CRC-24Q state using a sequence of bytes. + * + * @param crc is the input CRC-24Q state. + * + * @param bytes[in] is the sequence of bytes updating the input CRC-24Q state. + * + * @param size_in_bytes is the size in bytes of the byte sequence. + * + * @return Returns the updated CRC-24Q state. Use the #CRC24Q_MASK to get a + * valid CRC-24Q value. + */ +uint32_t _CRC24Q_Sequence_update( + uint32_t crc, + const void *bytes, + size_t size_in_bytes +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_CRC_H */ diff --git a/cpukit/include/rtems/debugger/rtems-debugger-server.h b/cpukit/include/rtems/debugger/rtems-debugger-server.h index 2189aac873..4d0407a951 100644 --- a/cpukit/include/rtems/debugger/rtems-debugger-server.h +++ b/cpukit/include/rtems/debugger/rtems-debugger-server.h @@ -103,6 +103,7 @@ extern "C" { #define RTEMS_DEBUGGER_FLAG_MULTIPROCESS (1 << 4) #define RTEMS_DEBUGGER_FLAG_VERBOSE_LOCK (1 << 5) #define RTEMS_DEBUGGER_FLAG_VERBOSE_CMDS (1 << 6) +#define RTEMS_DEBUGGER_FLAG_BREAK_WAITER (1 << 7) /** * Forward decl for the threads and targets. diff --git a/cpukit/include/rtems/dev/io.h b/cpukit/include/rtems/dev/io.h new file mode 100644 index 0000000000..b8bcde7af4 --- /dev/null +++ b/cpukit/include/rtems/dev/io.h @@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSDeviceIO + * + * @brief This header file provides the interfaces of the + * @ref RTEMSDeviceIO. + */ + +/* + * Copyright (C) 2017, 2023 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_DEV_IO_H +#define _RTEMS_DEV_IO_H + +#include <rtems/score/basedefs.h> + +#include <stdarg.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup RTEMSDeviceIO Device I/O Support + * + * @ingroup RTEMSDeviceDrivers + * + * @brief This group contains the Device I/O Support API and implementation. + * + * @{ + */ + +/** + * @brief This type defines the put character handler. + * + * @param c is the character to put. + * + * @param arg is the user-provided argument. + */ +typedef void ( *IO_Put_char )( int c, void *arg ); + +/** + * @brief Prints characters using the put character handler according to the + * format string. + * + * @param put_char is the put character handler. + * + * @param arg is the user-provided argument for the put character handler. + * + * @param fmt is the printf()-style format string. + * + * @param ... is the list of parameters required by the format string. + * + * @return Returns the count of put characters. + */ +int _IO_Printf( + IO_Put_char put_char, + void *arg, + char const *fmt, + ... +) RTEMS_PRINTFLIKE( 3, 4 ); + +/** + * @brief Prints characters using the put character handler according to the + * format string. + * + * @param put_char is the put character handler. + * + * @param arg is the user-provided argument for the put character handler. + * + * @param fmt is the printf()-style format string. + * + * @param ap is the argument list required by the format string. + * + * @return Returns the count of put characters. + */ +int _IO_Vprintf( + IO_Put_char put_char, + void *arg, + char const *fmt, + va_list ap +); + +/** + * @brief Issues a couple of no-operation instructions. + * + * This function may be used to burn a couple of processor cycles with minimum + * impact on the system bus. It may be used in busy wait loops. + */ +void _IO_Relax( void ); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_DEV_IO_H */ diff --git a/cpukit/include/rtems/deviceio.h b/cpukit/include/rtems/deviceio.h index a448fc7bb4..d598decb49 100644 --- a/cpukit/include/rtems/deviceio.h +++ b/cpukit/include/rtems/deviceio.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,9 +10,26 @@ * COPYRIGHT (c) 1989-2012. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_DEVICEIO_H diff --git a/cpukit/include/rtems/devnull.h b/cpukit/include/rtems/devnull.h index cb5d078d52..a6c20b9da3 100644 --- a/cpukit/include/rtems/devnull.h +++ b/cpukit/include/rtems/devnull.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ * COPYRIGHT (c) 1989-2000. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_DEVNULL_H diff --git a/cpukit/include/rtems/devzero.h b/cpukit/include/rtems/devzero.h index 2c3f7a11a6..734b02ef52 100644 --- a/cpukit/include/rtems/devzero.h +++ b/cpukit/include/rtems/devzero.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * Copyright (c) 2011 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_DEVZERO_H diff --git a/cpukit/include/rtems/dosfs.h b/cpukit/include/rtems/dosfs.h index 70347f0c05..1304347a44 100644 --- a/cpukit/include/rtems/dosfs.h +++ b/cpukit/include/rtems/dosfs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,11 +13,28 @@ * Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru> * * Modifications to support UTF-8 in the file system are - * Copyright (c) 2013 embedded brains GmbH. - * - * 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. + * Copyright (c) 2013 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_DOSFS_H diff --git a/cpukit/include/rtems/dumpbuf.h b/cpukit/include/rtems/dumpbuf.h index 690ac63341..f3a10733c7 100644 --- a/cpukit/include/rtems/dumpbuf.h +++ b/cpukit/include/rtems/dumpbuf.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,12 +10,29 @@ */ /* - * COPYRIGHT (c) 1997-2011. - * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (c) 1997-2011. + * On-Line Applications Research Corporation (OAR). + * + * 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. * - * The license and distribution terms for this file may in - * the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #ifndef __DUMP_BUFFER_h diff --git a/cpukit/include/rtems/endian.h b/cpukit/include/rtems/endian.h index 03a089d5a1..e0b12a6ab1 100644 --- a/cpukit/include/rtems/endian.h +++ b/cpukit/include/rtems/endian.h @@ -1,9 +1,35 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** - * @file + * @file * - * This include file provides endian information about the target. + * @brief Includes endian information about the target */ +/* + * COPYRIGHT (C) 1989-1999 On-Line Applications Research Corporation (OAR). + * + * 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. + */ #ifndef _RTEMS_ENDIAN_H #define _RTEMS_ENDIAN_H diff --git a/cpukit/include/rtems/error.h b/cpukit/include/rtems/error.h index 8277a62261..f7947ea407 100644 --- a/cpukit/include/rtems/error.h +++ b/cpukit/include/rtems/error.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -44,6 +46,31 @@ * @endcode */ +/* + * Copyright (C) 1995 Tony Bennett <tbennett@divnc.com> + * + * 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. + */ + #ifndef _RTEMS_RTEMS_ERROR_H #define _RTEMS_RTEMS_ERROR_H diff --git a/cpukit/include/rtems/extension.h b/cpukit/include/rtems/extension.h index 0117a41b8a..31fb18de65 100644 --- a/cpukit/include/rtems/extension.h +++ b/cpukit/include/rtems/extension.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2009, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2009, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -140,7 +140,7 @@ rtems_status_code rtems_extension_delete( rtems_id id ); * may be in an undefined and corrupt state. * * It is recommended to register fatal extensions through initial extension - * sets, see #CONFIGURE_INITIAL_EXTENSIONS. + * sets, see @ref CONFIGURE_INITIAL_EXTENSIONS. * @endparblock */ typedef User_extensions_fatal_extension rtems_fatal_extension; @@ -230,7 +230,7 @@ rtems_status_code rtems_extension_ident( rtems_name name, rtems_id *id ); * @ingroup RTEMSAPIClassicUserExt * * @brief The extensions table contains a set of extensions which may be - * registered in the system through the #CONFIGURE_INITIAL_EXTENSIONS + * registered in the system through the @ref CONFIGURE_INITIAL_EXTENSIONS * application configuration option or the rtems_extension_create() * directive. */ @@ -271,8 +271,8 @@ typedef User_extensions_Table rtems_extensions_table; * * @retval ::RTEMS_TOO_MANY There was no inactive object available to create an * extension set. The number of extension sets available to the application - * is configured through the #CONFIGURE_MAXIMUM_USER_EXTENSIONS application - * configuration option. + * is configured through the @ref CONFIGURE_MAXIMUM_USER_EXTENSIONS + * application configuration option. * * @par Notes * @parblock @@ -286,8 +286,8 @@ typedef User_extensions_Table rtems_extensions_table; * are invoked upon the next system event supporting an extension. * * An alternative to dynamically created extension sets are initial extensions, - * see #CONFIGURE_INITIAL_EXTENSIONS. Initial extensions are recommended for - * extension sets which provide a fatal error extension. + * see @ref CONFIGURE_INITIAL_EXTENSIONS. Initial extensions are recommended + * for extension sets which provide a fatal error extension. * * For control and maintenance of the extension set, RTEMS allocates a ESCB * from the local ESCB free pool and initializes it. @@ -306,8 +306,8 @@ typedef User_extensions_Table rtems_extensions_table; * cause the calling task to be preempted. * * * The number of extension sets available to the application is configured - * through the #CONFIGURE_MAXIMUM_USER_EXTENSIONS application configuration - * option. + * through the @ref CONFIGURE_MAXIMUM_USER_EXTENSIONS application + * configuration option. * @endparblock */ rtems_status_code rtems_extension_create( diff --git a/cpukit/include/rtems/extensiondata.h b/cpukit/include/rtems/extensiondata.h index 8872e2c569..776ea9f696 100644 --- a/cpukit/include/rtems/extensiondata.h +++ b/cpukit/include/rtems/extensiondata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_EXTENSIONDATA_H diff --git a/cpukit/include/rtems/extensionimpl.h b/cpukit/include/rtems/extensionimpl.h index 502aac87ca..8d559e2fed 100644 --- a/cpukit/include/rtems/extensionimpl.h +++ b/cpukit/include/rtems/extensionimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ * COPYRIGHT (c) 1989-1999. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_EXTENSIONIMPL_H @@ -35,19 +54,19 @@ extern "C" { * @{ */ -RTEMS_INLINE_ROUTINE Extension_Control *_Extension_Allocate( void ) +static inline Extension_Control *_Extension_Allocate( void ) { return (Extension_Control *) _Objects_Allocate( &_Extension_Information ); } -RTEMS_INLINE_ROUTINE void _Extension_Free ( +static inline void _Extension_Free ( Extension_Control *the_extension ) { _Objects_Free( &_Extension_Information, &the_extension->Object ); } -RTEMS_INLINE_ROUTINE Extension_Control *_Extension_Get( Objects_Id id ) +static inline Extension_Control *_Extension_Get( Objects_Id id ) { return (Extension_Control *) _Objects_Get_no_protection( id, &_Extension_Information ); diff --git a/cpukit/include/rtems/fatal.h b/cpukit/include/rtems/fatal.h index 0253ab4343..680fd4f934 100644 --- a/cpukit/include/rtems/fatal.h +++ b/cpukit/include/rtems/fatal.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassic + * * @brief This header file defines the Fatal Error Manager API. */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/flashdisk.h b/cpukit/include/rtems/flashdisk.h index bf2658e07a..b3ba0aea77 100644 --- a/cpukit/include/rtems/flashdisk.h +++ b/cpukit/include/rtems/flashdisk.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* * Copyright (C) 2007 Chris Johns * - * 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. + * 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. */ #if !defined (_RTEMS_FLASHDISK_H_) diff --git a/cpukit/include/rtems/framebuffer.h b/cpukit/include/rtems/framebuffer.h index 7828be1cf8..6a9a9e4e26 100644 --- a/cpukit/include/rtems/framebuffer.h +++ b/cpukit/include/rtems/framebuffer.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef __RTEMS_FRAMEBUFFER_h__ diff --git a/cpukit/include/rtems/fs.h b/cpukit/include/rtems/fs.h index 90e9eb8dd6..8b86536cc2 100644 --- a/cpukit/include/rtems/fs.h +++ b/cpukit/include/rtems/fs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,11 +13,28 @@ * On-Line Applications Research Corporation (OAR). * * Modifications to support reference counting in the file system are - * Copyright (c) 2012 embedded brains GmbH. + * Copyright (c) 2012 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_FS_H diff --git a/cpukit/include/rtems/fsmount.h b/cpukit/include/rtems/fsmount.h index 7c6d4558c3..25b4232814 100644 --- a/cpukit/include/rtems/fsmount.h +++ b/cpukit/include/rtems/fsmount.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,15 +14,29 @@ */ /* - * Copyright (c) 2003 IMD - * - * Ingenieurbuero fuer Microcomputertechnik Th. Doerfler - * <Thomas.Doerfler@imd-systems.de> - * all rights reserved - * - * 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. + * Copyright (c) 2003 IMD Ingenieurbuero fuer Microcomputertechnik + * All rights reserved. + * + * 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. */ #ifndef _FSMOUNT_H diff --git a/cpukit/include/rtems/ftpd.h b/cpukit/include/rtems/ftpd.h index 3e956fe33f..46cfbd9f45 100644 --- a/cpukit/include/rtems/ftpd.h +++ b/cpukit/include/rtems/ftpd.h @@ -1,5 +1,34 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @brief FTP Server Information + */ + /* - * FTP Server Information + * Copyright (C) 1999 Jake Janovetz <jvanovetz@uiuc.edu> + * + * 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. */ #ifndef _RTEMS_FTPD_H diff --git a/cpukit/include/rtems/ftpfs.h b/cpukit/include/rtems/ftpfs.h index eb6a0c664f..c21894a7fe 100644 --- a/cpukit/include/rtems/ftpfs.h +++ b/cpukit/include/rtems/ftpfs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -5,28 +7,35 @@ */ /* - * Copyright (c) 2009 - * embedded brains GmbH - * Obere Lagerstr. 30 - * D-82178 Puchheim - * Germany - * <rtems@embedded-brains.de> - * - * (c) Copyright 2002 - * Thomas Doerfler - * IMD Ingenieurbuero fuer Microcomputertechnik - * Herbststr. 8 - * 82178 Puchheim, Germany - * <Thomas.Doerfler@imd-systems.de> + * Copyright (c) 2009 embedded brains GmbH & Co. KG * + * Copyright (c) 2002 IMD Ingenieurbuero fuer Microcomputertechnik + * All rights reserved. * Modified by Sebastian Huber <sebastian.huber@embedded-brains.de>. * * This code has been created after closly inspecting "tftpdriver.c" from Eric * Norum. * - * 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. + * 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. */ #ifndef _RTEMS_FTPFS_H diff --git a/cpukit/include/rtems/gxx_wrappers.h b/cpukit/include/rtems/gxx_wrappers.h deleted file mode 100644 index e462d27d66..0000000000 --- a/cpukit/include/rtems/gxx_wrappers.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file - * - * RTEMS threads compatibility routines for libgcc2. - */ - -/* - * by: Rosimildo da Silva (rdasilva@connecttel.com) - * - * Used ideas from: - * W. Eric Norum - * Canadian Light Source - * University of Saskatchewan - * Saskatoon, Saskatchewan, CANADA - * eric@cls.usask.ca - * - * Eric sent some e-mail in the rtems-list as a start point for this - * module implementation. - */ - -#ifndef __GCC_WRAPPERS_h -#define __GCC_WRAPPERS_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup GxxWrappersSupport Gxx Wrappers Support - * - * @ingroup libcsupport - * - * @brief RTEMS Threads Compatibility Routines for Libgcc2 - */ - -/* - * These typedefs should match with the ones defined in the file - * gcc/gthr-rtems.h in the gcc distribution. - */ -typedef void *__gthread_key_t; -typedef int __gthread_once_t; -typedef void *__gthread_mutex_t; -typedef void *__gthread_recursive_mutex_t; - -int rtems_gxx_once(__gthread_once_t *once, void (*func) (void)); - -int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *)); - -int rtems_gxx_key_delete (__gthread_key_t key); - -void *rtems_gxx_getspecific(__gthread_key_t key); - -int rtems_gxx_setspecific(__gthread_key_t key, const void *ptr); - -/* - * MUTEX support - */ -void rtems_gxx_mutex_init (__gthread_mutex_t *mutex); - -int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex); - -int rtems_gxx_mutex_destroy (__gthread_mutex_t *mutex); - -int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex); - -int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex); - -void rtems_gxx_recursive_mutex_init(__gthread_recursive_mutex_t *mutex); - -int rtems_gxx_recursive_mutex_lock(__gthread_recursive_mutex_t *mutex); - -int rtems_gxx_recursive_mutex_trylock(__gthread_recursive_mutex_t *mutex); - -int rtems_gxx_recursive_mutex_unlock(__gthread_recursive_mutex_t *mutex); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GCC_WRAPPERS_h */ diff --git a/cpukit/include/rtems/ide_part_table.h b/cpukit/include/rtems/ide_part_table.h index 9fd991ec5f..2e95fb66d1 100644 --- a/cpukit/include/rtems/ide_part_table.h +++ b/cpukit/include/rtems/ide_part_table.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ * Author: Konstantin Abramenko <Konstantin.Abramenko@oktet.ru> * Alexander Kukuta <Alexander.Kukuta@oktet.ru> * - * 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. + * 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. * *****************************************************************************/ diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h index 57c498cfe8..405f489ab3 100644 --- a/cpukit/include/rtems/imfs.h +++ b/cpukit/include/rtems/imfs.h @@ -3,7 +3,7 @@ /** * @file * - * @brief Header File for the In-Memory File System + * @brief This header file defines the API of the In-Memory File System. */ /* @@ -39,7 +39,6 @@ #include <rtems/libio_.h> #include <rtems/pipe.h> -#include <rtems/score/timecounter.h> /** * @brief In-Memory File System Support. @@ -372,41 +371,6 @@ static inline IMFS_memfile_t *IMFS_iop_to_memfile( const rtems_libio_t *iop ) return (IMFS_memfile_t *) iop->pathinfo.node_access; } -static inline time_t _IMFS_get_time( void ) -{ - struct bintime now; - - /* Use most efficient way to get the time in seconds (CLOCK_REALTIME) */ - _Timecounter_Getbintime( &now ); - - return now.sec; -} - -static inline void IMFS_update_atime( IMFS_jnode_t *jnode ) -{ - jnode->stat_atime = _IMFS_get_time(); -} - -static inline void IMFS_update_mtime( IMFS_jnode_t *jnode ) -{ - jnode->stat_mtime = _IMFS_get_time(); -} - -static inline void IMFS_update_ctime( IMFS_jnode_t *jnode ) -{ - jnode->stat_ctime = _IMFS_get_time(); -} - -static inline void IMFS_mtime_ctime_update( IMFS_jnode_t *jnode ) -{ - time_t now; - - now = _IMFS_get_time(); - - jnode->stat_mtime = now; - jnode->stat_ctime = now; -} - typedef struct { const IMFS_mknod_control *directory; const IMFS_mknod_control *device; @@ -513,7 +477,7 @@ extern void IMFS_fsunmount( */ extern int rtems_tarfs_load( const char *mountpoint, - uint8_t *tar_image, + const void *tar_image, size_t tar_size ); diff --git a/cpukit/include/rtems/imfsimpl.h b/cpukit/include/rtems/imfsimpl.h new file mode 100644 index 0000000000..1275d831b3 --- /dev/null +++ b/cpukit/include/rtems/imfsimpl.h @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @brief This header file contains interfaces used by the implementation of + * the In-Memory File System. + */ + +/* + * Copyright (C) 2013, 2018 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_IMFSIMPL_H +#define _RTEMS_IMFSIMPL_H + +#include <rtems/imfs.h> +#include <rtems/score/timecounter.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup IMFS + * + * @{ + */ + +static inline time_t _IMFS_get_time( void ) +{ + struct bintime now; + + /* Use most efficient way to get the time in seconds (CLOCK_REALTIME) */ + _Timecounter_Getbintime( &now ); + + return now.sec; +} + +static inline void IMFS_update_atime( IMFS_jnode_t *jnode ) +{ + jnode->stat_atime = _IMFS_get_time(); +} + +static inline void IMFS_update_mtime( IMFS_jnode_t *jnode ) +{ + jnode->stat_mtime = _IMFS_get_time(); +} + +static inline void IMFS_update_ctime( IMFS_jnode_t *jnode ) +{ + jnode->stat_ctime = _IMFS_get_time(); +} + +static inline void IMFS_mtime_ctime_update( IMFS_jnode_t *jnode ) +{ + time_t now; + + now = _IMFS_get_time(); + + jnode->stat_mtime = now; + jnode->stat_ctime = now; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_IMFSIMPL_H */ diff --git a/cpukit/include/rtems/init.h b/cpukit/include/rtems/init.h index a821f92107..0ae483edf5 100644 --- a/cpukit/include/rtems/init.h +++ b/cpukit/include/rtems/init.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassic + * * @brief This header file defines the Initialization Manager API. */ /* - * Copyright (C) 2015, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2015, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/inttypes.h b/cpukit/include/rtems/inttypes.h index 4914629234..463b1e948a 100644 --- a/cpukit/include/rtems/inttypes.h +++ b/cpukit/include/rtems/inttypes.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ /* * COPYRIGHT (c) 2017 On-Line Applications Research Corporation. * - * 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. + * 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. */ #ifndef _RTEMS_INTTYPES_H diff --git a/cpukit/include/rtems/io.h b/cpukit/include/rtems/io.h index 181da9fe4f..b6a25b5f2f 100644 --- a/cpukit/include/rtems/io.h +++ b/cpukit/include/rtems/io.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -98,7 +98,7 @@ typedef rtems_status_code rtems_device_driver; * * @par Notes * The major number of a device is determined by rtems_io_register_driver() and - * the application configuration (see #CONFIGURE_MAXIMUM_DRIVERS) . + * the application configuration (see @ref CONFIGURE_MAXIMUM_DRIVERS) . */ typedef uint32_t rtems_device_major_number; @@ -207,7 +207,7 @@ typedef struct { * @retval ::RTEMS_INVALID_ADDRESS The device driver address table was empty. * * @retval ::RTEMS_INVALID_NUMBER The device major number of the device was out - * of range, see #CONFIGURE_MAXIMUM_DRIVERS. + * of range, see @ref CONFIGURE_MAXIMUM_DRIVERS. * * @retval ::RTEMS_TOO_MANY The system was unable to obtain a device major * number. diff --git a/cpukit/include/rtems/ioimpl.h b/cpukit/include/rtems/ioimpl.h index df2cc8d43e..3be4df286b 100644 --- a/cpukit/include/rtems/ioimpl.h +++ b/cpukit/include/rtems/ioimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_IOIMPL_H @@ -51,7 +70,7 @@ void _IO_Initialize_all_drivers( void ); ISR_LOCK_DECLARE( extern, _IO_Driver_registration_lock ) -RTEMS_INLINE_ROUTINE void _IO_Driver_registration_acquire( +static inline void _IO_Driver_registration_acquire( ISR_lock_Context *lock_context ) { @@ -61,7 +80,7 @@ RTEMS_INLINE_ROUTINE void _IO_Driver_registration_acquire( ); } -RTEMS_INLINE_ROUTINE void _IO_Driver_registration_release( +static inline void _IO_Driver_registration_release( ISR_lock_Context *lock_context ) { diff --git a/cpukit/include/rtems/iosupp.h b/cpukit/include/rtems/iosupp.h index 84ede0bd74..efdba124cb 100644 --- a/cpukit/include/rtems/iosupp.h +++ b/cpukit/include/rtems/iosupp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,9 +10,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_IOSUPP_H diff --git a/cpukit/include/rtems/irq-extension.h b/cpukit/include/rtems/irq-extension.h index e45ea43004..c2576ec372 100644 --- a/cpukit/include/rtems/irq-extension.h +++ b/cpukit/include/rtems/irq-extension.h @@ -5,11 +5,11 @@ * * @ingroup RTEMSAPIClassicIntr * - * @brief This header file defines the Interrupt Manager Extension API. + * @brief This header file is provided for backward compatiblility. */ /* - * Copyright (C) 2008, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2021 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -55,2265 +55,12 @@ #ifndef _RTEMS_IRQ_EXTENSION_H #define _RTEMS_IRQ_EXTENSION_H -#include <stddef.h> -#include <stdint.h> -#include <sys/cpuset.h> -#include <rtems/rtems/attr.h> #include <rtems/rtems/intr.h> -#include <rtems/rtems/modes.h> -#include <rtems/rtems/options.h> -#include <rtems/rtems/status.h> -#include <rtems/rtems/types.h> -#include <rtems/score/chain.h> #ifdef __cplusplus extern "C" { #endif -/* Generated from spec:/rtems/intr/if/handler */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Interrupt handler routines shall have this type. - */ -typedef void ( *rtems_interrupt_handler )( void * ); - -/* Generated from spec:/rtems/intr/if/per-handler-routine */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Visitor routines invoked by rtems_interrupt_handler_iterate() shall - * have this type. - */ -typedef void ( *rtems_interrupt_per_handler_routine )( - void *, - const char *, - rtems_option, - rtems_interrupt_handler, - void * -); - -/* Generated from spec:/rtems/intr/if/shared */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This interrupt handler install option allows that the interrupt - * handler may share the interrupt vector with other handler. - */ -#define RTEMS_INTERRUPT_SHARED ( (rtems_option) 0x00000000 ) - -/* Generated from spec:/rtems/intr/if/unique */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This interrupt handler install option ensures that the interrupt - * handler is unique. - * - * This option prevents other handler from using the same interrupt vector. - */ -#define RTEMS_INTERRUPT_UNIQUE ( (rtems_option) 0x00000001 ) - -/* Generated from spec:/rtems/intr/if/replace */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This interrupt handler install option requests that the interrupt - * handler replaces the first handler with the same argument. - */ -#define RTEMS_INTERRUPT_REPLACE ( (rtems_option) 0x00000002 ) - -/* Generated from spec:/rtems/intr/if/is-shared */ - -/** - * @brief Checks if the interrupt handler shared option is set. - * - * @param _options is the interrupt handler option set to check. - * - * @return Returns true, if the interrupt handler shared option - * #RTEMS_INTERRUPT_SHARED is set, otherwise false. - */ -#define RTEMS_INTERRUPT_IS_SHARED( _options ) \ - ( ( _options ) & RTEMS_INTERRUPT_SHARED ) - -/* Generated from spec:/rtems/intr/if/is-unique */ - -/** - * @brief Checks if the interrupt handler unique option is set. - * - * @param _options is the interrupt handler option set to check. - * - * @return Returns true, if the interrupt handler unique option - * #RTEMS_INTERRUPT_UNIQUE is set, otherwise false. - */ -#define RTEMS_INTERRUPT_IS_UNIQUE( _options ) \ - ( ( _options ) & RTEMS_INTERRUPT_UNIQUE ) - -/* Generated from spec:/rtems/intr/if/is-replace */ - -/** - * @brief Checks if the interrupt handler replace option is set. - * - * @param _options is the interrupt handler option set to check. - * - * @return Returns true, if the interrupt handler replace option - * #RTEMS_INTERRUPT_REPLACE is set, otherwise false. - */ -#define RTEMS_INTERRUPT_IS_REPLACE( _options ) \ - ( ( _options ) & RTEMS_INTERRUPT_REPLACE ) - -/* Generated from spec:/rtems/intr/if/entry */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt entry. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. An entry may be initialized - * by RTEMS_INTERRUPT_ENTRY_INITIALIZER() or - * rtems_interrupt_entry_initialize(). It may be installed for an interrupt - * vector with rtems_interrupt_entry_install() and removed from an interrupt - * vector by rtems_interrupt_entry_remove(). - */ -typedef struct rtems_interrupt_entry { - /** - * @brief This member is the interrupt handler routine. - */ - rtems_interrupt_handler handler; - - /** - * @brief This member is the interrupt handler argument. - */ - void *arg; - - /** - * @brief This member is the reference to the next entry or NULL. - */ - struct rtems_interrupt_entry *next; - - /** - * @brief This member is the descriptive information of the entry. - */ - const char *info; -} rtems_interrupt_entry; - -/* Generated from spec:/rtems/intr/if/entry-initializer */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Statically initializes an interrupt entry object. - * - * @param _routine is the interrupt handler routine for the entry. - * - * @param _arg is the interrupt handler argument for the entry. - * - * @param _info is the descriptive information for the entry. - * - * @par Notes - * Alternatively, rtems_interrupt_entry_initialize() may be used to dynamically - * initialize an interrupt entry. - */ -#define RTEMS_INTERRUPT_ENTRY_INITIALIZER( _routine, _arg, _info ) \ - { _routine, _arg, NULL, _info } - -/* Generated from spec:/rtems/intr/if/entry-initialize */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Initializes the interrupt entry. - * - * @param[out] entry is the interrupt entry to initialize. - * - * @param routine is the interrupt handler routine for the entry. - * - * @param arg is the interrupt handler argument for the entry. - * - * @param info is the descriptive information for the entry. - * - * @par Notes - * Alternatively, RTEMS_INTERRUPT_ENTRY_INITIALIZER() may be used to statically - * initialize an interrupt entry. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -static inline void rtems_interrupt_entry_initialize( - rtems_interrupt_entry *entry, - rtems_interrupt_handler routine, - void *arg, - const char *info -) -{ - entry->handler = routine; - entry->arg = arg; - entry->next = NULL; - entry->info = info; -} - -/* Generated from spec:/rtems/intr/if/entry-install */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Installs the interrupt entry at the interrupt vector. - * - * @param vector is the interrupt vector number. - * - * @param options is the interrupt entry install option set. - * - * @param entry is the interrupt entry to install. - * - * One of the following mutually exclusive options - * - * * #RTEMS_INTERRUPT_UNIQUE, and - * - * * #RTEMS_INTERRUPT_SHARED - * - * shall be set in the ``options`` parameter. - * - * The handler routine of the entry specified by ``entry`` will be called with - * the handler argument of the entry when dispatched. The order in which - * shared interrupt handlers are dispatched for one vector is defined by the - * installation order. The first installed handler is dispatched first. - * - * If the option #RTEMS_INTERRUPT_UNIQUE is set, then it will be ensured that - * the handler will be the only one for the interrupt vector. - * - * If the option #RTEMS_INTERRUPT_SHARED is set, then multiple handlers may be - * installed for the interrupt vector. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``entry`` parameter was NULL. - * - * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. - * - * @retval ::RTEMS_INVALID_ADDRESS The handler routine of the entry was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @retval ::RTEMS_INVALID_NUMBER An option specified by ``options`` was not - * applicable. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set - * in ``entry`` and the interrupt vector was already occupied by a handler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set - * in ``entry`` and the interrupt vector was already occupied by a unique - * handler. - * - * @retval ::RTEMS_TOO_MANY The handler routine of the entry specified by - * ``entry`` was already installed for the interrupt vector specified by - * ``vector`` with an argument equal to the handler argument of the entry. - * - * @par Notes - * When the directive call was successful, the ownership of the interrupt entry - * has been transferred from the caller to the interrupt service. An installed - * interrupt entry may be removed from the interrupt service by calling - * rtems_interrupt_entry_remove(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * - * * The interrupt entry shall have been initialized by - * rtems_interrupt_entry_initialize() or RTEMS_INTERRUPT_ENTRY_INITIALIZER(). - * @endparblock - */ -rtems_status_code rtems_interrupt_entry_install( - rtems_vector_number vector, - rtems_option options, - rtems_interrupt_entry *entry -); - -/* Generated from spec:/rtems/intr/if/entry-remove */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Removes the interrupt entry from the interrupt vector. - * - * @param vector is the interrupt vector number. - * - * @param entry is the interrupt entry to remove. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``entry`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @retval ::RTEMS_UNSATISFIED The entry specified by ``entry`` was not - * installed at the interrupt vector specified by ``vector``. - * - * @par Notes - * When the directive call was successful, the ownership of the interrupt entry - * has been transferred from the interrupt service to the caller. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * - * * The interrupt entry shall have been installed by - * rtems_interrupt_entry_install(). - * @endparblock - */ -rtems_status_code rtems_interrupt_entry_remove( - rtems_vector_number vector, - rtems_interrupt_entry *entry -); - -/* Generated from spec:/rtems/intr/if/handler-install */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Installs the interrupt handler routine and argument at the interrupt - * vector. - * - * @param vector is the interrupt vector number. - * - * @param info is the descriptive information of the interrupt handler to - * install. - * - * @param options is the interrupt handler install option set. - * - * @param routine is the interrupt handler routine to install. - * - * @param arg is the interrupt handler argument to install. - * - * One of the following mutually exclusive options - * - * * #RTEMS_INTERRUPT_UNIQUE, - * - * * #RTEMS_INTERRUPT_SHARED, and - * - * * #RTEMS_INTERRUPT_REPLACE - * - * shall be set in the ``options`` parameter. - * - * The handler routine will be called with the argument specified by ``arg`` - * when dispatched. The order in which shared interrupt handlers are - * dispatched for one vector is defined by the installation order. The first - * installed handler is dispatched first. - * - * If the option #RTEMS_INTERRUPT_UNIQUE is set, then it will be ensured that - * the handler will be the only one for the interrupt vector. - * - * If the option #RTEMS_INTERRUPT_SHARED is set, then multiple handler may be - * installed for the interrupt vector. - * - * If the option #RTEMS_INTERRUPT_REPLACE is set, then the handler specified by - * ``routine`` will replace the first handler with the same argument for the - * interrupt vector if it exists, otherwise an error status will be returned. - * A second handler with the same argument for the interrupt vector will remain - * unchanged. The new handler will inherit the unique or shared options from - * the replaced handler. - * - * An informative description may be provided in ``info``. It may be used for - * system debugging and diagnostic tools. The referenced string has to be - * persistent as long as the handler is installed. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @retval ::RTEMS_NO_MEMORY There was not enough memory available to allocate - * data structures to install the handler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set - * in ``options`` and the interrupt vector was already occupied by a handler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set - * in ``options`` and the interrupt vector was already occupied by a unique - * handler. - * - * @retval ::RTEMS_TOO_MANY The handler specified by ``routine`` was already - * installed for the interrupt vector specified by ``vector`` with an - * argument equal to the argument specified by ``arg``. - * - * @retval ::RTEMS_UNSATISFIED The #RTEMS_INTERRUPT_REPLACE option was set in - * ``options`` and no handler to replace was installed. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_handler_install( - rtems_vector_number vector, - const char *info, - rtems_option options, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/handler-remove */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Removes the interrupt handler routine and argument from the interrupt - * vector. - * - * @param vector is the interrupt vector number. - * - * @param routine is the interrupt handler routine to remove. - * - * @param arg is the interrupt handler argument to remove. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @retval ::RTEMS_UNSATISFIED There was no handler routine and argument pair - * installed specified by ``routine`` and ``arg``. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_handler_remove( - rtems_vector_number vector, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/vector-is-enabled */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Checks if the interrupt vector is enabled. - * - * @param vector is the interrupt vector number. - * - * @param[out] enabled is the pointer to a ``bool`` object. When the directive - * call is successful, the enabled status of the interrupt associated with - * the interrupt vector specified by ``vector`` will be stored in this - * object. When the interrupt was enabled for the processor executing the - * directive call at some time point during the call, the object value will - * be set to true, otherwise to false. - * - * The directive checks if the interrupt associated with the interrupt vector - * specified by ``vector`` was enabled for the processor executing the - * directive call at some time point during the call. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``enabled`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @par Notes - * Interrupt vectors may be enabled by rtems_interrupt_vector_enable() and - * disabled by rtems_interrupt_vector_disable(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_vector_is_enabled( - rtems_vector_number vector, - bool *enabled -); - -/* Generated from spec:/rtems/intr/if/vector-enable */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Enables the interrupt vector. - * - * @param vector is the number of the interrupt vector to enable. - * - * The directive enables the interrupt vector specified by ``vector``. This - * allows that interrupt service requests are issued to the target processors - * of the interrupt vector. Interrupt service requests for an interrupt vector - * may be raised by rtems_interrupt_raise(), rtems_interrupt_raise_on(), - * external signals, or messages. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_UNSATISFIED The request to enable the interrupt vector has - * not been satisfied. - * - * @par Notes - * The rtems_interrupt_get_attributes() directive may be used to check if an - * interrupt vector can be enabled. Interrupt vectors may be disabled by - * rtems_interrupt_vector_disable(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_vector_enable( rtems_vector_number vector ); - -/* Generated from spec:/rtems/intr/if/vector-disable */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Disables the interrupt vector. - * - * @param vector is the number of the interrupt vector to disable. - * - * The directive disables the interrupt vector specified by ``vector``. This - * prevents that an interrupt service request is issued to the target - * processors of the interrupt vector. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_UNSATISFIED The request to disable the interrupt vector has - * not been satisfied. - * - * @par Notes - * The rtems_interrupt_get_attributes() directive may be used to check if an - * interrupt vector can be disabled. Interrupt vectors may be enabled by - * rtems_interrupt_vector_enable(). There may be targets on which some - * interrupt vectors cannot be disabled, for example a hardware watchdog - * interrupt or software generated interrupts. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_vector_disable( rtems_vector_number vector ); - -/* Generated from spec:/rtems/intr/if/is-pending */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Checks if the interrupt is pending. - * - * @param vector is the interrupt vector number. - * - * @param[out] pending is the pointer to a ``bool`` object. When the directive - * call is successful, the pending status of the interrupt associated with - * the interrupt vector specified by ``vector`` will be stored in this - * object. When the interrupt was pending for the processor executing the - * directive call at some time point during the call, the object value will - * be set to true, otherwise to false. - * - * The directive checks if the interrupt associated with the interrupt vector - * specified by ``vector`` was pending for the processor executing the - * directive call at some time point during the call. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``pending`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_UNSATISFIED The request to get the pending status has not - * been satisfied. - * - * @par Notes - * Interrupts may be made pending by calling the rtems_interrupt_raise() or - * rtems_interrupt_raise_on() directives or due to external signals or - * messages. The pending state may be cleared by rtems_interrupt_clear(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_is_pending( - rtems_vector_number vector, - bool *pending -); - -/* Generated from spec:/rtems/intr/if/get-affinity */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Gets the processor affinity set of the interrupt vector. - * - * @param vector is the interrupt vector number. - * - * @param affinity_size is the size of the processor set referenced by - * ``affinity`` in bytes. - * - * @param[out] affinity is the pointer to a cpu_set_t object. When the - * directive call is successful, the processor affinity set of the interrupt - * vector will be stored in this object. A set bit in the processor set - * means that the corresponding processor is in the processor affinity set of - * the interrupt vector, otherwise the bit is cleared. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``affinity`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_INVALID_SIZE The size specified by ``affinity_size`` of the - * processor set was too small for the processor affinity set of the - * interrupt vector. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_get_affinity( - rtems_vector_number vector, - size_t affinity_size, - cpu_set_t *affinity -); - -/* Generated from spec:/rtems/intr/if/set-affinity */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Sets the processor affinity set of the interrupt vector. - * - * @param vector is the interrupt vector number. - * - * @param affinity_size is the size of the processor set referenced by - * ``affinity`` in bytes. - * - * @param affinity is the pointer to a cpu_set_t object. The processor set - * defines the new processor affinity set of the interrupt vector. A set bit - * in the processor set means that the corresponding processor shall be in - * the processor affinity set of the interrupt vector, otherwise the bit - * shall be cleared. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``affinity`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_INVALID_NUMBER The referenced processor set was not a valid - * new processor affinity set for the interrupt vector. - * - * @retval ::RTEMS_UNSATISFIED The request to set the processor affinity of the - * interrupt vector has not been satisfied. - * - * @par Notes - * The rtems_interrupt_get_attributes() directive may be used to check if the - * processor affinity of an interrupt vector can be set. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_set_affinity( - rtems_vector_number vector, - size_t affinity_size, - const cpu_set_t *affinity -); - -/* Generated from spec:/rtems/intr/if/signal-variant */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This enumeration provides interrupt trigger signal variants. - */ -typedef enum { - /** - * @brief This interrupt signal variant indicates that the interrupt trigger - * signal is unspecified. - */ - RTEMS_INTERRUPT_UNSPECIFIED_SIGNAL, - - /** - * @brief This interrupt signal variant indicates that the interrupt cannot be - * triggered by a signal. - */ - RTEMS_INTERRUPT_NO_SIGNAL, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a low level signal. - */ - RTEMS_INTERRUPT_SIGNAL_LEVEL_LOW, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a high level signal. - */ - RTEMS_INTERRUPT_SIGNAL_LEVEL_HIGH, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a falling edge signal. - */ - RTEMS_INTERRUPT_SIGNAL_EDGE_FALLING, - - /** - * @brief This interrupt signal variant indicates that the interrupt is - * triggered by a raising edge signal. - */ - RTEMS_INTERRUPT_SIGNAL_EDGE_RAISING -} rtems_interrupt_signal_variant; - -/* Generated from spec:/rtems/intr/if/attributes */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure provides the attributes of an interrupt vector. - * - * The rtems_interrupt_get_attributes() directive may be used to obtain the - * attributes of an interrupt vector. - */ -typedef struct { - /** - * @brief This member is true, if the interrupt vector is maskable by - * rtems_interrupt_local_disable(), otherwise it is false. - * - * Interrupt vectors which are not maskable by rtems_interrupt_local_disable() - * should be used with care since they cannot use most operating system - * services. - */ - bool is_maskable; - - /** - * @brief This member is true, if the interrupt vector can be enabled by - * rtems_interrupt_vector_enable(), otherwise it is false. - * - * When an interrupt vector can be enabled, this means that the enabled state - * can always be changed from disabled to enabled. For an interrupt vector - * which can be enabled it follows that it may be enabled. - */ - bool can_enable; - - /** - * @brief This member is true, if the interrupt vector may be enabled by - * rtems_interrupt_vector_enable(), otherwise it is false. - * - * When an interrupt vector may be enabled, this means that the enabled state - * may be changed from disabled to enabled. The requested enabled state change - * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt - * vectors may be optionally available and cannot be enabled on a particular - * target. - */ - bool maybe_enable; - - /** - * @brief This member is true, if the interrupt vector can be disabled by - * rtems_interrupt_vector_disable(), otherwise it is false. - * - * When an interrupt vector can be disabled, this means that the enabled state - * can be changed from enabled to disabled. For an interrupt vector which can - * be disabled it follows that it may be disabled. - */ - bool can_disable; - - /** - * @brief This member is true, if the interrupt vector may be disabled by - * rtems_interrupt_vector_disable(), otherwise it is false. - * - * When an interrupt vector may be disabled, this means that the enabled state - * may be changed from enabled to disabled. The requested enabled state change - * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt - * vectors may be always enabled and cannot be disabled on a particular target. - */ - bool maybe_disable; - - /** - * @brief This member is true, if the interrupt vector can be raised by - * rtems_interrupt_raise(), otherwise it is false. - */ - bool can_raise; - - /** - * @brief This member is true, if the interrupt vector can be raised on a - * processor by rtems_interrupt_raise_on(), otherwise it is false. - */ - bool can_raise_on; - - /** - * @brief This member is true, if the interrupt vector can be cleared by - * rtems_interrupt_clear(), otherwise it is false. - */ - bool can_clear; - - /** - * @brief This member is true, if the pending status of the interrupt - * associated with the interrupt vector is cleared by an interrupt - * acknowledge from the processor, otherwise it is false. - */ - bool cleared_by_acknowledge; - - /** - * @brief This member is true, if the affinity set of the interrupt vector can - * be obtained by rtems_interrupt_get_affinity(), otherwise it is false. - */ - bool can_get_affinity; - - /** - * @brief This member is true, if the affinity set of the interrupt vector can - * be set by rtems_interrupt_set_affinity(), otherwise it is false. - */ - bool can_set_affinity; - - /** - * @brief This member is true, if the interrupt associated with the interrupt - * vector can be triggered by a message. - * - * Interrupts may be also triggered by signals, rtems_interrupt_raise(), or - * rtems_interrupt_raise_on(). Examples for message triggered interrupts are - * the PCIe MSI/MSI-X and the ARM GICv3 Locality-specific Peripheral Interrupts - * (LPI). - */ - bool can_be_triggered_by_message; - - /** - * @brief This member describes the trigger signal of the interrupt associated - * with the interrupt vector. - * - * Interrupts are normally triggered by signals which indicate an interrupt - * request from a peripheral. Interrupts may be also triggered by messages, - * rtems_interrupt_raise(), or rtems_interrupt_raise_on(). - */ - rtems_interrupt_signal_variant trigger_signal; -} rtems_interrupt_attributes; - -/* Generated from spec:/rtems/intr/if/get-attributes */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Gets the attributes of the interrupt vector. - * - * @param vector is the interrupt vector number. - * - * @param[out] attributes is the pointer to an rtems_interrupt_attributes - * object. When the directive call is successful, the attributes of the - * interrupt vector will be stored in this object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``attributes`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_get_attributes( - rtems_vector_number vector, - rtems_interrupt_attributes *attributes -); - -/* Generated from spec:/rtems/intr/if/handler-iterate */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Iterates over all interrupt handler installed at the interrupt - * vector. - * - * @param vector is the interrupt vector number. - * - * @param routine is the visitor routine. - * - * @param arg is the visitor argument. - * - * For each installed handler at the interrupt vector the visitor function - * specified by ``routine`` will be called with the argument specified by - * ``arg`` and the handler information, options, routine and argument. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @par Notes - * @parblock - * The directive is intended for system information and diagnostics. - * - * Never install or remove an interrupt handler within the visitor function. - * This may result in a deadlock. - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_handler_iterate( - rtems_vector_number vector, - rtems_interrupt_per_handler_routine routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-default */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief The constant represents the index of the default interrupt server. - */ -#define RTEMS_INTERRUPT_SERVER_DEFAULT 0 - -/* Generated from spec:/rtems/intr/if/server-control */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt server. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. The structure is initialized - * by rtems_interrupt_server_create() and maintained by the interrupt server - * support. - */ -typedef struct rtems_interrupt_server_control { - #if defined(RTEMS_SMP) - /** - * @brief This member is the ISR lock protecting the server control state. - */ - rtems_interrupt_lock lock; - #endif - - /** - * @brief This member is the chain of pending interrupt entries. - */ - Chain_Control entries; - - /** - * @brief This member is the identifier of the server task. - */ - rtems_id server; - - /** - * @brief This member is the error count. - */ - unsigned long errors; - - /** - * @brief This member is the server index. - */ - uint32_t index; - - /** - * @brief This member is the node for the interrupt server registry. - */ - Chain_Node node; - - /** - * @brief This member is the optional handler to destroy the interrupt server - * control. - */ - void ( *destroy )( struct rtems_interrupt_server_control * ); -} rtems_interrupt_server_control; - -/* Generated from spec:/rtems/intr/if/server-config */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure defines an interrupt server configuration. - * - * @par Notes - * See also rtems_interrupt_server_create(). - */ -typedef struct { - /** - * @brief This member is the task name of the interrupt server. - */ - rtems_name name; - - /** - * @brief This member is the initial task priority of the interrupt server. - */ - rtems_task_priority priority; - - /** - * @brief This member is the task storage area of the interrupt server. - * - * It shall be NULL for interrupt servers created by - * rtems_interrupt_server_create(). - */ - void *storage_area; - - /** - * @brief This member is the task storage size of the interrupt server. - * - * For interrupt servers created by rtems_interrupt_server_create() this is the - * task stack size. - */ - size_t storage_size; - - /** - * @brief This member is the initial mode set of the interrupt server. - */ - rtems_mode modes; - - /** - * @brief This member is the attribute set of the interrupt server. - */ - rtems_attribute attributes; - - /** - * @brief This member is an optional handler to destroy the interrupt server - * control handed over to rtems_interrupt_server_create(). - * - * The destroy handler is optional and may be NULL. If the destroy handler is - * present, it is called from within the context of the interrupt server to be - * deleted, see also rtems_interrupt_server_delete(). - */ - void ( *destroy )( rtems_interrupt_server_control * ); -} rtems_interrupt_server_config; - -/* Generated from spec:/rtems/intr/if/server-initialize */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Initializes the interrupt server tasks. - * - * @param priority is the initial task priority of the created interrupt - * servers. - * - * @param stack_size is the task stack size of the created interrupt servers. - * - * @param modes is the initial mode set of the created interrupt servers. - * - * @param attributes is the attribute set of the created interrupt servers. - * - * @param[out] server_count is the pointer to an uint32_t object or NULL. When - * the pointer is not equal to NULL, the count of successfully created - * interrupt servers is stored in this object regardless of the return - * status. - * - * The directive tries to create an interrupt server task for each online - * processor in the system. The tasks will have the initial priority specified - * by ``priority``, the stack size specified by ``stack_size``, the initial - * mode set specified by ``modes``, and the attribute set specified by - * ``attributes``. The count of successfully created server tasks will be - * returned in ``server_count`` if the pointer is not equal to NULL. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INCORRECT_STATE The interrupt servers were already - * initialized. - * - * @return The directive uses rtems_task_create(). If this directive fails, - * then its error status will be returned. - * - * @par Notes - * @parblock - * Interrupt handlers may be installed on an interrupt server with - * rtems_interrupt_server_handler_install() and removed with - * rtems_interrupt_server_handler_remove() using a server index. In case of an - * interrupt, the request will be forwarded to the interrupt server. The - * handlers are executed within the interrupt server context. If one handler - * blocks on something this may delay the processing of other handlers. - * - * Interrupt servers may be deleted by rtems_interrupt_server_delete(). - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_initialize( - rtems_task_priority priority, - size_t stack_size, - rtems_mode modes, - rtems_attribute attributes, - uint32_t *server_count -); - -/* Generated from spec:/rtems/intr/if/server-create */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Creates an interrupt server. - * - * @param[out] control is the pointer to an rtems_interrupt_server_control - * object. When the directive call was successful, the ownership of the - * object was transferred from the caller of the directive to the interrupt - * server management. - * - * @param config is the interrupt server configuration. - * - * @param[out] server_index is the pointer to an uint32_t object. When the - * directive call was successful, the index of the created interrupt server - * will be stored in this object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @return The directive uses rtems_task_create(). If this directive fails, - * then its error status will be returned. - * - * @par Notes - * See also rtems_interrupt_server_initialize() and - * rtems_interrupt_server_delete(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_create( - rtems_interrupt_server_control *control, - const rtems_interrupt_server_config *config, - uint32_t *server_index -); - -/* Generated from spec:/rtems/intr/if/server-handler-install */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Installs the interrupt handler routine and argument at the interrupt - * vector on the interrupt server. - * - * @param server_index is the interrupt server index. The constant - * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default - * interrupt server. - * - * @param vector is the interrupt vector number. - * - * @param info is the descriptive information of the interrupt handler to - * install. - * - * @param options is the interrupt handler install option set. - * - * @param routine is the interrupt handler routine to install. - * - * @param arg is the interrupt handler argument to install. - * - * The handler routine specified by ``routine`` will be executed within the - * context of the interrupt server task specified by ``server_index``. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within - * interrupt context. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_INVALID_NUMBER An option specified by ``info`` was not - * applicable. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set - * in ``info`` and the interrupt vector was already occupied by a handler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set - * in ``info`` and the interrupt vector was already occupied by a unique - * handler. - * - * @retval ::RTEMS_TOO_MANY The handler specified by ``routine`` was already - * installed for the interrupt vector specified by ``vector`` with an - * argument equal to the argument specified by ``arg``. - * - * @retval ::RTEMS_UNSATISFIED The #RTEMS_INTERRUPT_REPLACE option was set in - * ``info`` and no handler to replace was installed. - * - * @par Notes - * See also rtems_interrupt_handler_install(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_handler_install( - uint32_t server_index, - rtems_vector_number vector, - const char *info, - rtems_option options, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-handler-remove */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Removes the interrupt handler routine and argument from the interrupt - * vector and the interrupt server. - * - * @param server_index is the interrupt server index. The constant - * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default - * interrupt server. - * - * @param vector is the interrupt vector number. - * - * @param routine is the interrupt handler routine to remove. - * - * @param arg is the interrupt handler argument to remove. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @retval ::RTEMS_UNSATISFIED There was no handler routine and argument pair - * installed specified by ``routine`` and ``arg``. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_handler_remove( - uint32_t server_index, - rtems_vector_number vector, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-set-affinity */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Sets the processor affinity of the interrupt server. - * - * @param server_index is the interrupt server index. The constant - * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default - * interrupt server. - * - * @param affinity_size is the size of the processor set referenced by - * ``affinity`` in bytes. - * - * @param affinity is the pointer to a cpu_set_t object. The processor set - * defines the new processor affinity set of the interrupt server. A set bit - * in the processor set means that the corresponding processor shall be in - * the processor affinity set of the task, otherwise the bit shall be - * cleared. - * - * @param priority is the new real priority for the interrupt server. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @return The directive uses rtems_scheduler_ident_by_processor_set(), - * rtems_task_set_scheduler(), and rtems_task_set_affinity(). If one of - * these directive fails, then its error status will be returned. - * - * @par Notes - * @parblock - * The scheduler is set determined by the highest numbered processor in the - * affinity set specified by ``affinity``. - * - * This operation is only reliable in case the interrupt server was suspended - * via rtems_interrupt_server_suspend(). - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may change the processor affinity of a task. This may cause - * the calling task to be preempted. - * - * * The directive may change the priority of a task. This may cause the - * calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_set_affinity( - uint32_t server_index, - size_t affinity_size, - const cpu_set_t *affinity, - rtems_task_priority priority -); - -/* Generated from spec:/rtems/intr/if/server-delete */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Deletes the interrupt server. - * - * @param server_index is the index of the interrupt server to delete. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * server index specified by ``server_index``. - * - * @par Notes - * @parblock - * The interrupt server deletes itself, so after the return of the directive - * the interrupt server may be still in the termination process depending on - * the task priorities of the system. - * - * See also rtems_interrupt_server_create(). - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_delete( uint32_t server_index ); - -/* Generated from spec:/rtems/intr/if/server-suspend */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Suspends the interrupt server. - * - * @param server_index is the index of the interrupt server to suspend. The - * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the - * default interrupt server. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @par Notes - * Interrupt server may be resumed by rtems_interrupt_server_resume(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_suspend( uint32_t server_index ); - -/* Generated from spec:/rtems/intr/if/server-resume */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Resumes the interrupt server. - * - * @param server_index is the index of the interrupt server to resume. The - * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the - * default interrupt server. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @par Notes - * Interrupt server may be suspended by rtems_interrupt_server_suspend(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_resume( uint32_t server_index ); - -/* Generated from spec:/rtems/intr/if/server-move */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Moves the interrupt handlers installed at the interrupt vector and - * the source interrupt server to the destination interrupt server. - * - * @param source_server_index is the index of the source interrupt server. The - * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the - * default interrupt server. - * - * @param vector is the interrupt vector number. - * - * @param destination_server_index is the index of the destination interrupt - * server. The constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to - * specify the default interrupt server. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``source_server_index``. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``destination_server_index``. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_move( - uint32_t source_server_index, - rtems_vector_number vector, - uint32_t destination_server_index -); - -/* Generated from spec:/rtems/intr/if/server-handler-iterate */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Iterates over all interrupt handler installed at the interrupt vector - * and interrupt server. - * - * @param server_index is the index of the interrupt server. - * - * @param vector is the interrupt vector number. - * - * @param routine is the visitor routine. - * - * @param arg is the visitor argument. - * - * For each installed handler at the interrupt vector and interrupt server the - * visitor function specified by ``vector`` will be called with the argument - * specified by ``routine`` and the handler information, options, routine and - * argument. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the - * number specified by ``vector``. - * - * @par Notes - * @parblock - * The directive is intended for system information and diagnostics. - * - * Never install or remove an interrupt handler within the visitor function. - * This may result in a deadlock. - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_handler_iterate( - uint32_t server_index, - rtems_vector_number vector, - rtems_interrupt_per_handler_routine routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-action */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt server action. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. - */ -typedef struct rtems_interrupt_server_action { - /** - * @brief This member is the reference to the next action or NULL. - */ - struct rtems_interrupt_server_action *next; - - /** - * @brief This member is the interrupt handler. - */ - rtems_interrupt_handler handler; - - /** - * @brief This member is the interrupt handler argument. - */ - void *arg; -} rtems_interrupt_server_action; - -/* Generated from spec:/rtems/intr/if/server-entry */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt server entry. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. An entry is initialized by - * rtems_interrupt_server_entry_initialize() and destroyed by - * rtems_interrupt_server_entry_destroy(). Interrupt server actions can be - * prepended to the entry by rtems_interrupt_server_action_prepend(). The - * entry is submitted to be serviced by rtems_interrupt_server_entry_submit(). - */ -typedef struct { - /** - * @brief This member is the node for the interrupt entry processing. - */ - Chain_Node node; - - /** - * @brief This member references the interrupt server used to process the - * entry. - */ - rtems_interrupt_server_control *server; - - /** - * @brief This member is the interrupt vector number. - */ - rtems_vector_number vector; - - /** - * @brief This member is the interrupt server actions list head. - */ - rtems_interrupt_server_action *actions; -} rtems_interrupt_server_entry; - -/* Generated from spec:/rtems/intr/if/server-entry-initialize */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Initializes the interrupt server entry. - * - * @param server_index is the interrupt server index. The constant - * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default - * interrupt server. - * - * @param entry is the interrupt server entry to initialize. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @par Notes - * After initialization, the list of actions of the interrupt server entry is - * empty. Actions may be prepended by rtems_interrupt_server_action_prepend(). - * Interrupt server entries may be moved to another interrupt vector with - * rtems_interrupt_server_entry_move(). Server entries may be submitted to get - * serviced by the interrupt server with rtems_interrupt_server_entry_submit(). - * Server entries may be destroyed by rtems_interrupt_server_entry_destroy(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_entry_initialize( - uint32_t server_index, - rtems_interrupt_server_entry *entry -); - -/* Generated from spec:/rtems/intr/if/server-action-prepend */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Prepends the interrupt server action to the list of actions of the - * interrupt server entry. - * - * @param[in,out] entry is the interrupt server entry to prepend the interrupt - * server action. It shall have been initialized via - * rtems_interrupt_server_entry_initialize(). - * - * @param[out] action is the interrupt server action to initialize and prepend - * to the list of actions of the entry. - * - * @param routine is the interrupt handler routine to set in the action. - * - * @param arg is the interrupt handler argument to set in the action. - * - * @par Notes - * No error checking is performed by the directive. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * - * * The interrupt server entry shall have been initialized by - * rtems_interrupt_server_entry_initialize() and further optional calls to - * rtems_interrupt_server_action_prepend(). - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_action_prepend() with the same interrupt server - * entry. Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_entry_move() with the same interrupt server entry. - * Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_entry_submit() with the same interrupt server - * entry. Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called while the interrupt server entry is - * pending on or serviced by its current interrupt server. Calling the - * directive under these conditions is undefined behaviour. - * @endparblock - */ -void rtems_interrupt_server_action_prepend( - rtems_interrupt_server_entry *entry, - rtems_interrupt_server_action *action, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-entry-destroy */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Destroys the interrupt server entry. - * - * @param[in,out] entry is the interrupt server entry to destroy. - * - * @par Notes - * No error checking is performed by the directive. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * - * * The interrupt server entry shall have been initialized by - * rtems_interrupt_server_entry_initialize() and further optional calls to - * rtems_interrupt_server_action_prepend(). - * @endparblock - */ -void rtems_interrupt_server_entry_destroy( - rtems_interrupt_server_entry *entry -); - -/* Generated from spec:/rtems/intr/if/server-entry-submit */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Submits the interrupt server entry to be serviced by the interrupt - * server. - * - * @param entry is the interrupt server entry to submit. - * - * The directive appends the entry to the pending entries of the interrupt - * server. The interrupt server is notified that a new entry is pending. Once - * the interrupt server is scheduled it services the actions of all pending - * entries. - * - * @par Notes - * @parblock - * This directive may be used to do a two-step interrupt processing. The first - * step is done from within interrupt context by a call to this directive. The - * second step is then done from within the context of the interrupt server. - * - * No error checking is performed by the directive. - * - * A submitted entry may be destroyed by - * rtems_interrupt_server_entry_destroy(). - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may unblock a task. This may cause the calling task to be - * preempted. - * - * * The interrupt server entry shall have been initialized by - * rtems_interrupt_server_entry_initialize() and further optional calls to - * rtems_interrupt_server_action_prepend(). - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_action_prepend() with the same interrupt server - * entry. Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_entry_move() with the same interrupt server entry. - * Calling the directive under this condition is undefined behaviour. - * @endparblock - */ -void rtems_interrupt_server_entry_submit( - rtems_interrupt_server_entry *entry -); - -/* Generated from spec:/rtems/intr/if/server-entry-move */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Moves the interrupt server entry to the interrupt server. - * - * @param entry is the interrupt server entry to move. - * - * @param server_index is the index of the destination interrupt server. The - * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the - * default interrupt server. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * - * * The interrupt server entry shall have been initialized by - * rtems_interrupt_server_entry_initialize() and further optional calls to - * rtems_interrupt_server_action_prepend(). - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_action_prepend() with the same interrupt server - * entry. Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_entry_move() with the same interrupt server entry. - * Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_entry_submit() with the same interrupt server - * entry. Calling the directive under this condition is undefined behaviour. - * - * * The directive shall not be called while the interrupt server entry is - * pending on or serviced by its current interrupt server. Calling the - * directive under these conditions is undefined behaviour. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_entry_move( - rtems_interrupt_server_entry *entry, - uint32_t server_index -); - -/* Generated from spec:/rtems/intr/if/server-request */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This structure represents an interrupt server request. - * - * @par Notes - * This structure shall be treated as an opaque data type from the API point of - * view. Members shall not be accessed directly. A request is initialized by - * rtems_interrupt_server_request_initialize() and destroyed by - * rtems_interrupt_server_request_destroy(). The interrupt vector of the - * request can be set by rtems_interrupt_server_request_set_vector(). The - * request is submitted to be serviced by - * rtems_interrupt_server_request_submit(). - */ -typedef struct { - /** - * @brief This member is the interrupt server entry. - */ - rtems_interrupt_server_entry entry; - - /** - * @brief This member is the interrupt server action. - */ - rtems_interrupt_server_action action; -} rtems_interrupt_server_request; - -/* Generated from spec:/rtems/intr/if/server-request-initialize */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Initializes the interrupt server request. - * - * @param server_index is the interrupt server index. The constant - * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default - * interrupt server. - * - * @param[out] request is the interrupt server request to initialize. - * - * @param routine is the interrupt handler routine for the request action. - * - * @param arg is the interrupt handler argument for the request action. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the - * index specified by ``server_index``. - * - * @par Notes - * An interrupt server requests consists of an interrupt server entry and - * exactly one interrupt server action. The interrupt vector of the request - * may be changed with rtems_interrupt_server_request_set_vector(). Interrupt - * server requests may be submitted to get serviced by the interrupt server - * with rtems_interrupt_server_request_submit(). Requests may be destroyed by - * rtems_interrupt_server_request_destroy(). - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_interrupt_server_request_initialize( - uint32_t server_index, - rtems_interrupt_server_request *request, - rtems_interrupt_handler routine, - void *arg -); - -/* Generated from spec:/rtems/intr/if/server-request-set-vector */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Sets the interrupt vector in the interrupt server request. - * - * @param[in,out] request is the interrupt server request to change. - * - * @param vector is the interrupt vector number to be used by the request. - * - * @par Notes - * @parblock - * By default, the interrupt vector of an interrupt server request is set to a - * special value which is outside the range of vectors supported by the - * interrupt controller hardware. - * - * Calls to rtems_interrupt_server_request_submit() will disable the interrupt - * vector of the request. After processing of the request by the interrupt - * server the interrupt vector will be enabled again. - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive will not cause the calling task to be preempted. - * - * * The interrupt server request shall have been initialized by - * rtems_interrupt_server_request_initialize(). - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_request_set_vector() with the same interrupt server - * request. Calling the directive under this condition is undefined - * behaviour. - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_request_submit() with the same interrupt server - * request. Calling the directive under this condition is undefined - * behaviour. - * - * * The directive shall not be called while the interrupt server entry is - * pending on or serviced by its current interrupt server. Calling the - * directive under these conditions is undefined behaviour. - * @endparblock - */ -static inline void rtems_interrupt_server_request_set_vector( - rtems_interrupt_server_request *request, - rtems_vector_number vector -) -{ - request->entry.vector = vector; -} - -/* Generated from spec:/rtems/intr/if/server-request-destroy */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Destroys the interrupt server request. - * - * @param[in,out] request is the interrupt server request to destroy. - * - * @par Notes - * No error checking is performed by the directive. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within task context. - * - * * The directive shall not be called from within the context of an interrupt - * server. Calling the directive from within the context of an interrupt - * server is undefined behaviour. - * - * * The directive sends a request to another task and waits for a response. - * This may cause the calling task to be blocked and unblocked. - * - * * The interrupt server request shall have been initialized by - * rtems_interrupt_server_request_initialize(). - * @endparblock - */ -static inline void rtems_interrupt_server_request_destroy( - rtems_interrupt_server_request *request -) -{ - rtems_interrupt_server_entry_destroy( &request->entry ); -} - -/* Generated from spec:/rtems/intr/if/server-request-submit */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief Submits the interrupt server request to be serviced by the interrupt - * server. - * - * @param[in,out] request is the interrupt server request to submit. - * - * The directive appends the interrupt server entry of the request to the - * pending entries of the interrupt server. The interrupt server is notified - * that a new entry is pending. Once the interrupt server is scheduled it - * services the actions of all pending entries. - * - * @par Notes - * @parblock - * This directive may be used to do a two-step interrupt processing. The first - * step is done from within interrupt context by a call to this directive. The - * second step is then done from within the context of the interrupt server. - * - * No error checking is performed by the directive. - * - * A submitted request may be destroyed by - * rtems_interrupt_server_request_destroy(). - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within interrupt context. - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may unblock a task. This may cause the calling task to be - * preempted. - * - * * The interrupt server request shall have been initialized by - * rtems_interrupt_server_request_initialize(). - * - * * The directive shall not be called concurrently with - * rtems_interrupt_server_request_set_vector() with the same interrupt server - * request. Calling the directive under this condition is undefined - * behaviour. - * @endparblock - */ -static inline void rtems_interrupt_server_request_submit( - rtems_interrupt_server_request *request -) -{ - rtems_interrupt_server_entry_submit( &request->entry ); -} - #ifdef __cplusplus } #endif diff --git a/cpukit/include/rtems/irq.h b/cpukit/include/rtems/irq.h index 7e50a0b6a1..c76b89b0c3 100644 --- a/cpukit/include/rtems/irq.h +++ b/cpukit/include/rtems/irq.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -14,9 +16,26 @@ * <http://www.chorus.com/Documentation/index.html> by following * the STREAM API Specification Document link. * - * 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. + * 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. */ #ifndef _RTEMS_IRQ_H diff --git a/cpukit/include/rtems/jffs2.h b/cpukit/include/rtems/jffs2.h index a856c46c41..12f4f8e073 100644 --- a/cpukit/include/rtems/jffs2.h +++ b/cpukit/include/rtems/jffs2.h @@ -1,15 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2013, 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. + * Copyright (C) 2013, 2016 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef RTEMS_JFFS2_H @@ -217,6 +230,99 @@ typedef int (*rtems_jffs2_flash_erase)( ); /** + * @brief Flash bad block check operation. + * + * This operation checks whether a block is bad. + * + * @param[in, out] self The flash control. + * @param[in] offset The offset in bytes of the block to check. + * @param[out] The result of the bad block check. + * + * @retval 0 Successful operation. + * @retval -EIO An error occurred. Please note that the value is negative. + * @retval other All other values are reserved and must not be used. + */ +typedef int (*rtems_jffs2_flash_block_is_bad)( + rtems_jffs2_flash_control *self, + uint32_t offset, + bool *bad +); + +/** + * @brief Flash bad block mark operation. + * + * This operation marks a block bad. + * + * @param[in, out] self The flash control. + * @param[in] offset The offset in bytes of the block to mark bad. + * + * @retval 0 Successful operation. + * @retval -EIO An error occurred. Please note that the value is negative. + * @retval other All other values are reserved and must not be used. + */ +typedef int (*rtems_jffs2_flash_block_mark_bad)( + rtems_jffs2_flash_control *self, + uint32_t offset +); + +/** + * @brief Flash oob write. + * + * This operation writes the out-of-band/spare bytes for the block matching + * the given offset in bytes. + * + * @param[in, out] self The flash control. + * @param[in] offset The offset to erase from the flash begin in bytes. + * @param[in] pointer to the buffer which will be written to the oob/spare bytes. + * @param[in] length of the buffer which will be written to the oob/spare bytes. + * + * @retval 0 Successful operation. + * @retval -EIO An error occurred. Please note that the value is negative. + * @retval other All other values are reserved and must not be used. + */ +typedef int (*rtems_jffs2_flash_oob_write)( + rtems_jffs2_flash_control *self, + uint32_t offset, + uint8_t *oobbuf, + uint32_t obblen +); + +/** + * @brief Flash oob read. + * + * This operation reads the out-of-band/spare bytes for the block matching + * the given offset in bytes. + * + * @param[in, out] self The flash control. + * @param[in] offset The offset to erase from the flash begin in bytes. + * @param[out] pointer to the buffer which will have the oob/spare bytes data written to it. + * @param[in] length of the buffer which will hold the oob/spare bytes. + * + * @retval 0 Successful operation. + * @retval -EIO An error occurred. Please note that the value is negative. + * @retval other All other values are reserved and must not be used. + */ +typedef int (*rtems_jffs2_flash_oob_read)( + rtems_jffs2_flash_control *self, + uint32_t offset, + uint8_t *oobbuf, + uint32_t obblen +); + +/** + * @brief Flash get oob size. + * + * This operation gets the size of the out-of-band/spare bytes for each page. + * + * @param[in, out] self The flash control. + * + * @retval The size of the OOB/spare area available to each page + */ +typedef uint32_t (*rtems_jffs2_flash_get_oob_size)( + rtems_jffs2_flash_control *self +); + +/** * @brief Flash destroy operation. * * The flash destroy operation is called during unmount of the file system @@ -261,6 +367,14 @@ struct rtems_jffs2_flash_control { uint32_t flash_size; /** + * @brief The size in bytes of the minimum write size for the flash device. + * + * It must be an integral divisor into the block size. This is only applicable + * for NAND devices. + */ + uint32_t write_size; + + /** * @brief Read from flash operation. */ rtems_jffs2_flash_read read; @@ -276,6 +390,31 @@ struct rtems_jffs2_flash_control { rtems_jffs2_flash_erase erase; /** + * @brief Flash bad block check operation. + */ + rtems_jffs2_flash_block_is_bad block_is_bad; + + /** + * @brief Flash bad block mark operation. + */ + rtems_jffs2_flash_block_mark_bad block_mark_bad; + + /** + * @brief Flash oob bytes write operation. + */ + rtems_jffs2_flash_oob_write oob_write; + + /** + * @brief Flash oob bytes read operation. + */ + rtems_jffs2_flash_oob_read oob_read; + + /** + * @brief Flash get oob bytes per page operation. + */ + rtems_jffs2_flash_get_oob_size get_oob_size; + + /** * @brief Flash destroy operation. * * This operation is optional and the pointer may be @c NULL. @@ -595,6 +734,27 @@ typedef struct { */ #define RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION _IO('F', 3) +/** + * Default delayed-write servicing task priority. + */ +#define RTEMS_JFFS2_DELAYED_WRITE_TASK_PRIORITY_DEFAULT 15 + +/** + * JFFS2 configuration definition. See confdefs.h for support on using this + * structure. + */ +typedef struct rtems_jffs2_config { + rtems_task_priority delayed_write_priority; /**< Priority of the delayed write + * task. */ +} rtems_jffs2_config; + +/** + * External reference to the configuration. + * + * The configuration is provided by the application. + */ +extern const rtems_jffs2_config jffs2_config; + /** @} */ #ifdef __cplusplus diff --git a/cpukit/include/rtems/libcsupport.h b/cpukit/include/rtems/libcsupport.h index f4be4cfc9a..9329b82674 100644 --- a/cpukit/include/rtems/libcsupport.h +++ b/cpukit/include/rtems/libcsupport.h @@ -1,8 +1,12 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file - * + * + * @ingroup libcsupport + * * @brief Standard C Library Support - * + * * This include file contains the information regarding the * RTEMS specific support for the standard C library. */ @@ -11,9 +15,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_LIBCSUPPORT_H @@ -36,8 +57,8 @@ extern "C" { * * @brief RTEMS Specific Support for the Standard C Library * + * @{ */ -/**@{**/ extern void malloc_dump(void); @@ -77,27 +98,33 @@ extern int malloc_info(Heap_Information_block *the_info); /* * Prototypes required to install newlib reentrancy user extension */ + +#ifdef _REENT_THREAD_LOCAL +#define _NEWLIB_CREATE_HOOK NULL +#else bool newlib_create_hook( rtems_tcb *current_task, rtems_tcb *creating_task ); +#define _NEWLIB_CREATE_HOOK newlib_create_hook +#endif void newlib_terminate_hook( rtems_tcb *current_task ); #define RTEMS_NEWLIB_EXTENSION \ -{ \ - newlib_create_hook, /* rtems_task_create */ \ - 0, /* rtems_task_start */ \ - 0, /* rtems_task_restart */ \ - 0, /* rtems_task_delete */ \ - 0, /* task_switch */ \ - 0, /* task_begin */ \ - 0, /* task_exitted */ \ - 0, /* fatal */ \ - newlib_terminate_hook /* thread terminate */ \ -} + { \ + _NEWLIB_CREATE_HOOK, /* thread_create */ \ + NULL, /* thread_start */ \ + NULL, /* thread_restart */ \ + NULL, /* thread_delete */ \ + NULL, /* thread_switch */ \ + NULL, /* thread_begin */ \ + NULL, /* thread_exitted */ \ + NULL, /* fatal */ \ + newlib_terminate_hook /* thread_terminate */ \ + } typedef struct { uint32_t active_barriers; diff --git a/cpukit/include/rtems/libio.h b/cpukit/include/rtems/libio.h index 5379d92e4a..5424a2a03c 100644 --- a/cpukit/include/rtems/libio.h +++ b/cpukit/include/rtems/libio.h @@ -16,7 +16,7 @@ * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). * * Modifications to support reference counting in the file system are - * Copyright (C) 2012 embedded brains GmbH. + * Copyright (C) 2012 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -56,6 +56,7 @@ #include <rtems/fs.h> #include <rtems/chain.h> #include <rtems/score/atomic.h> +#include <rtems/termiosdevice.h> #ifdef __cplusplus extern "C" { @@ -1360,7 +1361,7 @@ typedef struct { /** * @brief Parameter block for open/close. */ -typedef struct { +typedef struct rtems_libio_open_close_args { rtems_libio_t *iop; uint32_t flags; uint32_t mode; @@ -1902,10 +1903,10 @@ typedef struct rtems_termios_callbacks { int (*setAttributes)(int minor, const struct termios *t); int (*stopRemoteTx)(int minor); int (*startRemoteTx)(int minor); - int outputUsesInterrupts; + rtems_termios_device_mode outputUsesInterrupts; } rtems_termios_callbacks; -RTEMS_INLINE_ROUTINE void rtems_termios_initialize( void ) +static inline void rtems_termios_initialize( void ) { /* Nothing to do, provided for backward compatibility */ } diff --git a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index 8d4a2dc861..eb487934bc 100644 --- a/cpukit/include/rtems/libio_.h +++ b/cpukit/include/rtems/libio_.h @@ -12,7 +12,7 @@ * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). * * Modifications to support reference counting in the file system are - * Copyright (c) 2012 embedded brains GmbH. + * Copyright (c) 2012 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/linkersets.h b/cpukit/include/rtems/linkersets.h index e156fd4379..a5d7b1b037 100644 --- a/cpukit/include/rtems/linkersets.h +++ b/cpukit/include/rtems/linkersets.h @@ -1,15 +1,36 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSAPILinkerSets + * + * @brief This header file provides the linker sets API. + */ + /* - * Copyright (c) 2015, 2020 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 2020 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_LINKERSET_H @@ -21,6 +42,36 @@ extern "C" { #endif /* __cplusplus */ +/** + * @ingroup RTEMSImpl + * + * @brief Obfuscates a pointer to prevent compiler optimizations. + * + * @param ptr is the pointer to obfuscate. + * + * @return Returns the unsigned integer representation of the obfuscated + * pointer. + */ +static inline uintptr_t _Linker_set_Obfuscate( const void *ptr ) +{ + uintptr_t addr; + + addr = (uintptr_t) ptr; + RTEMS_OBFUSCATE_VARIABLE( addr ); + + return addr; +} + +/** + * @defgroup RTEMSAPILinkerSets Linker Sets + * + * @ingroup RTEMSAPI + * + * @brief This group contains the linker sets API. + * + * @{ + */ + #define RTEMS_LINKER_SET_BEGIN( set ) \ _Linker_set_##set##_begin @@ -116,16 +167,6 @@ extern "C" { decl \ RTEMS_SECTION( ".rtemsrwset." #set ".content" ) -RTEMS_INLINE_ROUTINE uintptr_t _Linker_set_Obfuscate( const void *ptr ) -{ - uintptr_t addr; - - addr = (uintptr_t) ptr; - RTEMS_OBFUSCATE_VARIABLE( addr ); - - return addr; -} - #define RTEMS_LINKER_SET_SIZE( set ) \ ( _Linker_set_Obfuscate( RTEMS_LINKER_SET_END( set ) ) \ - _Linker_set_Obfuscate( RTEMS_LINKER_SET_BEGIN( set ) ) ) @@ -144,6 +185,8 @@ RTEMS_INLINE_ROUTINE uintptr_t _Linker_set_Obfuscate( const void *ptr ) ++item \ ) +/** @} */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/cpukit/include/rtems/malloc.h b/cpukit/include/rtems/malloc.h index eba538e223..c26b262881 100644 --- a/cpukit/include/rtems/malloc.h +++ b/cpukit/include/rtems/malloc.h @@ -1,16 +1,40 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * This file defines the interface to RTEMS extensions to the Malloc Family. + * @ingroup MallocSupport + * + * @ingroup RTEMSAPIMalloc + * + * @brief This header file defines interfaces to support and use dynamic memory + * allocation. */ /* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). * - * The license and distribution terms for this file may in - * the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #ifndef _RTEMS_MALLOC_H @@ -19,7 +43,6 @@ #include <rtems.h> #include <rtems/bspIo.h> #include <rtems/libcsupport.h> /* for malloc_walk() */ -#include <rtems/score/memory.h> #include <stdint.h> @@ -28,11 +51,13 @@ extern "C" { #endif /** - * @defgroup MallocSupport Malloc Support + * @defgroup MallocSupport Malloc Support + * + * @ingroup libcsupport * - * @ingroup libcsupport + * @brief This group contains interfaces to support dynamic memory allocation. * - * @brief RTEMS extensions to the Malloc Family + * @{ */ /** @@ -43,12 +68,7 @@ extern "C" { */ extern Heap_Control *RTEMS_Malloc_Heap; -Heap_Control *RTEMS_Malloc_Initialize( - const Memory_Information *mem, - Heap_Initialization_or_extend_handler extend -); - -void rtems_heap_set_sbrk_amount( ptrdiff_t sbrk_amount ); +void _Malloc_Initialize( void ); typedef void *(*rtems_heap_extend_handler)( Heap_Control *heap, @@ -63,19 +83,6 @@ void *rtems_heap_extend_via_sbrk( size_t alloc_size ); -/** - * @brief Greedy allocate that empties the sbrk memory - * - * Afterwards all the sbrk avialable memory will have been allocated - * to the provided heap. - * - * @see rtems_heap_extend_via_sbrk(). - */ -void rtems_heap_sbrk_greedy_allocate( - Heap_Control *heap, - size_t alloc_size -); - void *rtems_heap_null_extend( Heap_Control *heap, size_t alloc_size @@ -89,6 +96,34 @@ extern const rtems_heap_extend_handler rtems_malloc_extend_handler; typedef void (*rtems_malloc_dirtier_t)(void *, size_t); extern rtems_malloc_dirtier_t rtems_malloc_dirty_helper; +/** @} */ + +/** + * @defgroup RTEMSAPIMalloc Dynamic Memory Allocation + * + * @ingroup RTEMSAPI + * + * @brief This group contains non-standard interfaces to use dynamic memory + * allocation. + * + * @{ + */ + +void rtems_heap_set_sbrk_amount( ptrdiff_t sbrk_amount ); + +/** + * @brief Greedy allocate that empties the sbrk memory + * + * Afterwards all the sbrk avialable memory will have been allocated + * to the provided heap. + * + * @see rtems_heap_extend_via_sbrk(). + */ +void rtems_heap_sbrk_greedy_allocate( + Heap_Control *heap, + size_t alloc_size +); + /** * @brief Dirty Memory Function * @@ -236,6 +271,8 @@ void *rtems_heap_greedy_allocate_all_except_largest( */ void rtems_heap_greedy_free( void *opaque ); +/** @} */ + #ifdef __cplusplus } #endif diff --git a/cpukit/include/rtems/mallocinitmulti.h b/cpukit/include/rtems/mallocinitmulti.h new file mode 100644 index 0000000000..ba9cf6830c --- /dev/null +++ b/cpukit/include/rtems/mallocinitmulti.h @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup MallocSupport + * + * @brief This header file provides the implementation of + * _Malloc_Initialize_for_multiple_areas(). + */ + +/* + * Copyright (C) 2012, 2020 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_MALLOCINITMULTI_H +#define _RTEMS_MALLOCINITMULTI_H + +#include <rtems/malloc.h> +#include <rtems/score/heapimpl.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup MallocSupport + * + * @brief Initializes the separate C Program Heap with support for more than + * one memory area. + * + * This implementation should be used by BSPs which provide more than one + * memory area via _Memory_Get() to implement + * _Workspace_Malloc_initialize_separate(). + */ +static inline Heap_Control *_Malloc_Initialize_for_multiple_areas( + Heap_Control *heap +) +{ + const Memory_Information *mem; + Heap_Initialization_or_extend_handler init_or_extend; + uintptr_t page_size; + size_t i; + + mem = _Memory_Get(); + RTEMS_Malloc_Heap = heap; + init_or_extend = _Heap_Initialize; + page_size = CPU_HEAP_ALIGNMENT; + + for (i = 0; i < _Memory_Get_count( mem ); ++i) { + Memory_Area *area; + uintptr_t space_available; + + area = _Memory_Get_area( mem, i ); + space_available = ( *init_or_extend )( + heap, + _Memory_Get_free_begin( area ), + _Memory_Get_free_size( area ), + page_size + ); + + if ( space_available > 0 ) { + _Memory_Consume( area, _Memory_Get_free_size( area ) ); + init_or_extend = _Heap_Extend; + } + } + + if ( init_or_extend == _Heap_Initialize ) { + _Internal_error( INTERNAL_ERROR_NO_MEMORY_FOR_HEAP ); + } + + return heap; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_MALLOCINITMULTI_H */ diff --git a/cpukit/include/rtems/mallocinitone.h b/cpukit/include/rtems/mallocinitone.h new file mode 100644 index 0000000000..7ad13e3804 --- /dev/null +++ b/cpukit/include/rtems/mallocinitone.h @@ -0,0 +1,90 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup MallocSupport + * + * @brief This header file provides the implementation of + * _Malloc_Initialize_for_one_area(). + */ + +/* + * Copyright (C) 2012, 2020 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_MALLOCINITONE_H +#define _RTEMS_MALLOCINITONE_H + +#include <rtems/malloc.h> +#include <rtems/score/assert.h> +#include <rtems/score/heapimpl.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup MallocSupport + * + * @brief Initializes the separate C Program Heap with support for exactly one + * memory area. + * + * This implementation should be used by BSPs which provide exactly one memory + * area via _Memory_Get() to implement _Workspace_Malloc_initialize_separate(). + */ +static inline Heap_Control *_Malloc_Initialize_for_one_area( + Heap_Control *heap +) +{ + const Memory_Information *mem; + Memory_Area *area; + uintptr_t space_available; + + mem = _Memory_Get(); + _Assert( _Memory_Get_count( mem ) == 1 ); + + RTEMS_Malloc_Heap = heap; + area = _Memory_Get_area( mem, 0 ); + space_available = _Heap_Initialize( + heap, + _Memory_Get_free_begin( area ), + _Memory_Get_free_size( area ), + CPU_HEAP_ALIGNMENT + ); + + if ( space_available > 0 ) { + _Memory_Consume( area, _Memory_Get_free_size( area ) ); + } else { + _Internal_error( INTERNAL_ERROR_NO_MEMORY_FOR_HEAP ); + } + + return heap; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_MALLOCINITONE_H */ diff --git a/cpukit/include/rtems/media.h b/cpukit/include/rtems/media.h index 3fea38b261..ea9c667b93 100644 --- a/cpukit/include/rtems/media.h +++ b/cpukit/include/rtems/media.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2009, 2018 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. + * Copyright (C) 2009, 2018 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef RTEMS_MEDIA_H @@ -330,7 +343,7 @@ typedef rtems_status_code (*rtems_media_worker)( * @retval RTEMS_SUCCESSFUL Successful operation. * @retval RTEMS_NO_MEMORY Not enough resources. */ -RTEMS_INLINE_ROUTINE rtems_status_code rtems_media_initialize(void) +static inline rtems_status_code rtems_media_initialize(void) { return RTEMS_SUCCESSFUL; } diff --git a/cpukit/include/rtems/monitor.h b/cpukit/include/rtems/monitor.h index 9367e2b6e8..22f3d6235c 100644 --- a/cpukit/include/rtems/monitor.h +++ b/cpukit/include/rtems/monitor.h @@ -1,9 +1,35 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * * @brief The RTEMS Monitor Task */ +/* + * COPYRIGHT (C) 1989-1999 On-Line Applications Research Corporation (OAR). + * + * 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. + */ #ifndef __MONITOR_H #define __MONITOR_H diff --git a/cpukit/include/rtems/mptables.h b/cpukit/include/rtems/mptables.h index 01e5b653b4..2f67000d2a 100644 --- a/cpukit/include/rtems/mptables.h +++ b/cpukit/include/rtems/mptables.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_MPTABLES_H diff --git a/cpukit/include/rtems/nvdisk.h b/cpukit/include/rtems/nvdisk.h index 0fa9390627..d8de95062c 100644 --- a/cpukit/include/rtems/nvdisk.h +++ b/cpukit/include/rtems/nvdisk.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,9 +9,26 @@ /* * Copyright (C) 2007 Chris Johns * - * 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. + * 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. */ /** diff --git a/cpukit/include/rtems/passwd.h b/cpukit/include/rtems/passwd.h index 8d5c299a5e..ccc14b7f8c 100644 --- a/cpukit/include/rtems/passwd.h +++ b/cpukit/include/rtems/passwd.h @@ -1,3 +1,36 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @brief Default password for telnetd + */ + +/* + * COPYRIGHT (C) 2007 On-Line Applications Research Corporation (OAR). + * + * 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. + */ + /* Define a default password for telnetd here. * NOTES: * - this can be overridden at run-time by setting diff --git a/cpukit/include/rtems/pipe.h b/cpukit/include/rtems/pipe.h index eb016ed0a6..12e5803304 100644 --- a/cpukit/include/rtems/pipe.h +++ b/cpukit/include/rtems/pipe.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* * Author: Wei Shen <cquark@gmail.com> * - * 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. + * 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. */ #ifndef _RTEMS_PIPE_H diff --git a/cpukit/include/rtems/posix/aio_misc.h b/cpukit/include/rtems/posix/aio_misc.h index 059753ef58..8356d3df5a 100644 --- a/cpukit/include/rtems/posix/aio_misc.h +++ b/cpukit/include/rtems/posix/aio_misc.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,9 +11,26 @@ /* * Copyright 2010, Alin Rus <alin.codejunkie@gmail.com> * - * 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. + * 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. */ #ifndef _AIO_MISC_H diff --git a/cpukit/include/rtems/posix/barrierimpl.h b/cpukit/include/rtems/posix/barrierimpl.h index a1794b82fd..3c75f9f50d 100644 --- a/cpukit/include/rtems/posix/barrierimpl.h +++ b/cpukit/include/rtems/posix/barrierimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,11 +13,28 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2017 embedded brains GmbH + * Copyright (c) 2017 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_BARRIERIMPL_H diff --git a/cpukit/include/rtems/posix/condimpl.h b/cpukit/include/rtems/posix/condimpl.h index 66e09bf6d8..5bbc35c4b3 100644 --- a/cpukit/include/rtems/posix/condimpl.h +++ b/cpukit/include/rtems/posix/condimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,9 +11,26 @@ * COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_CONDIMPL_H @@ -63,7 +82,7 @@ static inline POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get( return (POSIX_Condition_variables_Control *) cond; } -RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Initialize( +static inline void _POSIX_Condition_variables_Initialize( POSIX_Condition_variables_Control *the_cond, const pthread_condattr_t *the_attr ) @@ -83,14 +102,14 @@ RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Initialize( the_cond->flags = flags; } -RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Destroy( +static inline void _POSIX_Condition_variables_Destroy( POSIX_Condition_variables_Control *the_cond ) { the_cond->flags = ~the_cond->flags; } -RTEMS_INLINE_ROUTINE clockid_t _POSIX_Condition_variables_Get_clock( +static inline clockid_t _POSIX_Condition_variables_Get_clock( unsigned long flags ) { @@ -101,7 +120,7 @@ RTEMS_INLINE_ROUTINE clockid_t _POSIX_Condition_variables_Get_clock( return CLOCK_REALTIME; } -RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Condition_variables_Acquire( +static inline Thread_Control *_POSIX_Condition_variables_Acquire( POSIX_Condition_variables_Control *the_cond, Thread_queue_Context *queue_context ) @@ -121,7 +140,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Condition_variables_Acquire( return executing; } -RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Release( +static inline void _POSIX_Condition_variables_Release( POSIX_Condition_variables_Control *the_cond, Thread_queue_Context *queue_context ) diff --git a/cpukit/include/rtems/posix/key.h b/cpukit/include/rtems/posix/key.h index a710855b93..465986a91f 100644 --- a/cpukit/include/rtems/posix/key.h +++ b/cpukit/include/rtems/posix/key.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,11 +13,28 @@ * Copyright (c) 2012 Zhongwei Yao. * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). - * Copyright (c) 2016 embedded brains GmbH. + * Copyright (c) 2016 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_KEY_H diff --git a/cpukit/include/rtems/posix/keyimpl.h b/cpukit/include/rtems/posix/keyimpl.h index eed5d3fed2..2cc68eff3e 100644 --- a/cpukit/include/rtems/posix/keyimpl.h +++ b/cpukit/include/rtems/posix/keyimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,11 +12,28 @@ /* * COPYRIGHT (c) 1989-1999. * On-Line Applications Research Corporation (OAR). - * Copyright (c) 2016 embedded brains GmbH. + * Copyright (c) 2016 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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 <rtems/posix/key.h> @@ -51,7 +70,7 @@ extern Freechain_Control _POSIX_Keys_Keypool; * the inactive chain of free keys control blocks. */ -RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Allocate( void ) +static inline POSIX_Keys_Control *_POSIX_Keys_Allocate( void ) { return (POSIX_Keys_Control *) _Objects_Allocate( &_POSIX_Keys_Information ); } @@ -62,20 +81,20 @@ RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Allocate( void ) * This routine frees a keys control block to the * inactive chain of free keys control blocks. */ -RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free( +static inline void _POSIX_Keys_Free( POSIX_Keys_Control *the_key ) { _Objects_Free( &_POSIX_Keys_Information, &the_key->Object ); } -RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Get( pthread_key_t key ) +static inline POSIX_Keys_Control *_POSIX_Keys_Get( pthread_key_t key ) { return (POSIX_Keys_Control *) _Objects_Get_no_protection( (Objects_Id) key, &_POSIX_Keys_Information ); } -RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_acquire( +static inline void _POSIX_Keys_Key_value_acquire( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -83,7 +102,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_acquire( _ISR_lock_ISR_disable_and_acquire( &the_thread->Keys.Lock, lock_context ); } -RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_release( +static inline void _POSIX_Keys_Key_value_release( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -93,7 +112,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_release( POSIX_Keys_Key_value_pair * _POSIX_Keys_Key_value_allocate( void ); -RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_free( +static inline void _POSIX_Keys_Key_value_free( POSIX_Keys_Key_value_pair *key_value_pair ) { @@ -101,7 +120,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_free( _Freechain_Put( &_POSIX_Keys_Keypool, key_value_pair ); } -RTEMS_INLINE_ROUTINE bool _POSIX_Keys_Key_value_equal( +static inline bool _POSIX_Keys_Key_value_equal( const void *left, const RBTree_Node *right ) @@ -115,7 +134,7 @@ RTEMS_INLINE_ROUTINE bool _POSIX_Keys_Key_value_equal( return *the_left == the_right->key; } -RTEMS_INLINE_ROUTINE bool _POSIX_Keys_Key_value_less( +static inline bool _POSIX_Keys_Key_value_less( const void *left, const RBTree_Node *right ) @@ -129,12 +148,12 @@ RTEMS_INLINE_ROUTINE bool _POSIX_Keys_Key_value_less( return *the_left < the_right->key; } -RTEMS_INLINE_ROUTINE void *_POSIX_Keys_Key_value_map( RBTree_Node *node ) +static inline void *_POSIX_Keys_Key_value_map( RBTree_Node *node ) { return POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ); } -RTEMS_INLINE_ROUTINE POSIX_Keys_Key_value_pair *_POSIX_Keys_Key_value_find( +static inline POSIX_Keys_Key_value_pair *_POSIX_Keys_Key_value_find( pthread_key_t key, const Thread_Control *the_thread ) @@ -148,7 +167,7 @@ RTEMS_INLINE_ROUTINE POSIX_Keys_Key_value_pair *_POSIX_Keys_Key_value_find( ); } -RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_insert( +static inline void _POSIX_Keys_Key_value_insert( pthread_key_t key, POSIX_Keys_Key_value_pair *key_value_pair, Thread_Control *the_thread diff --git a/cpukit/include/rtems/posix/mmanimpl.h b/cpukit/include/rtems/posix/mmanimpl.h index e1cc672331..80dda40671 100644 --- a/cpukit/include/rtems/posix/mmanimpl.h +++ b/cpukit/include/rtems/posix/mmanimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,9 +10,26 @@ /* * Copyright (c) 2012 Chris Johns * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_MMANIMPL_H diff --git a/cpukit/include/rtems/posix/mqueue.h b/cpukit/include/rtems/posix/mqueue.h index 84010e7d4f..4145891d7b 100644 --- a/cpukit/include/rtems/posix/mqueue.h +++ b/cpukit/include/rtems/posix/mqueue.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -23,9 +25,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_MQUEUE_H diff --git a/cpukit/include/rtems/posix/mqueueimpl.h b/cpukit/include/rtems/posix/mqueueimpl.h index 14573287ad..c2749db1e2 100644 --- a/cpukit/include/rtems/posix/mqueueimpl.h +++ b/cpukit/include/rtems/posix/mqueueimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_MQUEUE_INL @@ -80,7 +99,7 @@ int _POSIX_Message_queue_Send_support( Thread_queue_Enqueue_callout enqueue_callout ); -RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * +static inline POSIX_Message_queue_Control * _POSIX_Message_queue_Allocate_unprotected( void ) { return (POSIX_Message_queue_Control *) @@ -93,7 +112,7 @@ RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * * This routine frees a message queue control block to the * inactive chain of free message queue control blocks. */ -RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free( +static inline void _POSIX_Message_queue_Free( POSIX_Message_queue_Control *the_mq ) { @@ -101,7 +120,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free( } -RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get( +static inline POSIX_Message_queue_Control *_POSIX_Message_queue_Get( Objects_Id id, Thread_queue_Context *queue_context ) @@ -120,7 +139,7 @@ RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get( * This method converts a POSIX message priority to the priorities used * by the Score. */ -RTEMS_INLINE_ROUTINE CORE_message_queue_Submit_types +static inline CORE_message_queue_Submit_types _POSIX_Message_queue_Priority_to_core( unsigned int priority ) @@ -135,7 +154,7 @@ RTEMS_INLINE_ROUTINE CORE_message_queue_Submit_types * This method converts a POSIX message priority from the priorities used * by the Score. */ -RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core( +static inline unsigned int _POSIX_Message_queue_Priority_from_core( CORE_message_queue_Submit_types priority ) { @@ -146,7 +165,7 @@ RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core( /** * @brief POSIX Message Queue Remove from Namespace */ -RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove ( +static inline void _POSIX_Message_queue_Namespace_remove ( POSIX_Message_queue_Control *the_mq ) { @@ -156,7 +175,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove ( ); } -RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * +static inline POSIX_Message_queue_Control * _POSIX_Message_queue_Get_by_name( const char *name, size_t *name_length_p, diff --git a/cpukit/include/rtems/posix/muteximpl.h b/cpukit/include/rtems/posix/muteximpl.h index 3decb6f4ac..8dffea80a5 100644 --- a/cpukit/include/rtems/posix/muteximpl.h +++ b/cpukit/include/rtems/posix/muteximpl.h @@ -1,18 +1,37 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * * @brief Private Inlined Routines for POSIX Mutex's. - * - * This include file contains the static inline implementation of the private + * + * This include file contains the static inline implementation of the private * inlined routines for POSIX mutex's. */ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_MUTEXIMPL_H @@ -68,7 +87,7 @@ typedef enum { */ extern const pthread_mutexattr_t _POSIX_Mutex_Default_attributes; -RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Mutex_Acquire( +static inline Thread_Control *_POSIX_Mutex_Acquire( POSIX_Mutex_Control *the_mutex, Thread_queue_Context *queue_context ) @@ -89,7 +108,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Mutex_Acquire( return executing; } -RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Release( +static inline void _POSIX_Mutex_Release( POSIX_Mutex_Control *the_mutex, Thread_queue_Context *queue_context ) @@ -100,28 +119,28 @@ RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Release( ); } -RTEMS_INLINE_ROUTINE POSIX_Mutex_Protocol _POSIX_Mutex_Get_protocol( +static inline POSIX_Mutex_Protocol _POSIX_Mutex_Get_protocol( unsigned long flags ) { - return flags & POSIX_MUTEX_PROTOCOL_MASK; + return (POSIX_Mutex_Protocol) (flags & POSIX_MUTEX_PROTOCOL_MASK); } -RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_recursive( +static inline bool _POSIX_Mutex_Is_recursive( unsigned long flags ) { return ( flags & POSIX_MUTEX_RECURSIVE ) != 0; } -RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Mutex_Get_owner( +static inline Thread_Control *_POSIX_Mutex_Get_owner( const POSIX_Mutex_Control *the_mutex ) { return the_mutex->Recursive.Mutex.Queue.Queue.owner; } -RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_locked( +static inline bool _POSIX_Mutex_Is_locked( const POSIX_Mutex_Control *the_mutex ) { @@ -136,7 +155,7 @@ Status_Control _POSIX_Mutex_Seize_slow( Thread_queue_Context *queue_context ); -RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_owner( +static inline void _POSIX_Mutex_Set_owner( POSIX_Mutex_Control *the_mutex, Thread_Control *owner ) @@ -144,7 +163,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_owner( the_mutex->Recursive.Mutex.Queue.Queue.owner = owner; } -RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_owner( +static inline bool _POSIX_Mutex_Is_owner( const POSIX_Mutex_Control *the_mutex, const Thread_Control *the_thread ) @@ -166,7 +185,7 @@ static Status_Control _POSIX_Mutex_Lock_nested( } } -RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Seize( +static inline Status_Control _POSIX_Mutex_Seize( POSIX_Mutex_Control *the_mutex, unsigned long flags, const Thread_queue_Operations *operations, @@ -203,7 +222,7 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Seize( ); } -RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Surrender( +static inline Status_Control _POSIX_Mutex_Surrender( POSIX_Mutex_Control *the_mutex, const Thread_queue_Operations *operations, Thread_Control *executing, @@ -246,7 +265,7 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Surrender( return STATUS_SUCCESSFUL; } -RTEMS_INLINE_ROUTINE const Scheduler_Control *_POSIX_Mutex_Get_scheduler( +static inline const Scheduler_Control *_POSIX_Mutex_Get_scheduler( const POSIX_Mutex_Control *the_mutex ) { @@ -257,7 +276,7 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_POSIX_Mutex_Get_scheduler( #endif } -RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_priority( +static inline void _POSIX_Mutex_Set_priority( POSIX_Mutex_Control *the_mutex, Priority_Control priority_ceiling, Thread_queue_Context *queue_context @@ -282,14 +301,14 @@ RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_priority( } } -RTEMS_INLINE_ROUTINE Priority_Control _POSIX_Mutex_Get_priority( +static inline Priority_Control _POSIX_Mutex_Get_priority( const POSIX_Mutex_Control *the_mutex ) { return the_mutex->Priority_ceiling.priority; } -RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_set_owner( +static inline Status_Control _POSIX_Mutex_Ceiling_set_owner( POSIX_Mutex_Control *the_mutex, Thread_Control *owner, Thread_queue_Context *queue_context @@ -328,7 +347,7 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_set_owner( return STATUS_SUCCESSFUL; } -RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_seize( +static inline Status_Control _POSIX_Mutex_Ceiling_seize( POSIX_Mutex_Control *the_mutex, unsigned long flags, Thread_Control *executing, @@ -376,7 +395,7 @@ RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_seize( ); } -RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_surrender( +static inline Status_Control _POSIX_Mutex_Ceiling_surrender( POSIX_Mutex_Control *the_mutex, Thread_Control *executing, Thread_queue_Context *queue_context @@ -446,4 +465,3 @@ bool _POSIX_Mutex_Auto_initialization( POSIX_Mutex_Control *the_mutex ); #endif /* end of include file */ - diff --git a/cpukit/include/rtems/posix/posixapi.h b/cpukit/include/rtems/posix/posixapi.h index 8d30ee21e5..5d78573ef7 100644 --- a/cpukit/include/rtems/posix/posixapi.h +++ b/cpukit/include/rtems/posix/posixapi.h @@ -1,19 +1,38 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief POSIX API Implementation + * @ingroup POSIXAPI * - * This include file defines the top level interface to the POSIX API - * implementation in RTEMS. + * @brief This header file provides interfaces used by the POSIX API + * implementation. */ /* * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_POSIXAPI_H @@ -40,7 +59,7 @@ extern const int _POSIX_Get_by_name_error_table[ 3 ]; -RTEMS_INLINE_ROUTINE int _POSIX_Get_by_name_error( +static inline int _POSIX_Get_by_name_error( Objects_Get_by_name_error error ) { @@ -48,19 +67,19 @@ RTEMS_INLINE_ROUTINE int _POSIX_Get_by_name_error( return _POSIX_Get_by_name_error_table[ error ]; } -RTEMS_INLINE_ROUTINE int _POSIX_Get_error( Status_Control status ) +static inline int _POSIX_Get_error( Status_Control status ) { return STATUS_GET_POSIX( status ); } -RTEMS_INLINE_ROUTINE int _POSIX_Get_error_after_wait( +static inline int _POSIX_Get_error_after_wait( const Thread_Control *executing ) { return _POSIX_Get_error( _Thread_Wait_get_status( executing ) ); } -RTEMS_INLINE_ROUTINE int _POSIX_Zero_or_minus_one_plus_errno( +static inline int _POSIX_Zero_or_minus_one_plus_errno( Status_Control status ) { @@ -78,7 +97,7 @@ RTEMS_INLINE_ROUTINE int _POSIX_Zero_or_minus_one_plus_errno( * * http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_09 */ -RTEMS_INLINE_ROUTINE bool _POSIX_Is_valid_pshared( int pshared ) +static inline bool _POSIX_Is_valid_pshared( int pshared ) { return pshared == PTHREAD_PROCESS_PRIVATE || pshared == PTHREAD_PROCESS_SHARED; diff --git a/cpukit/include/rtems/posix/priorityimpl.h b/cpukit/include/rtems/posix/priorityimpl.h index eb2e3e059f..2cb1bb22fc 100644 --- a/cpukit/include/rtems/posix/priorityimpl.h +++ b/cpukit/include/rtems/posix/priorityimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_PRIORITYIMPL_H @@ -49,7 +68,7 @@ extern "C" { * * @return The maximum POSIX API priority for this scheduler instance. */ -RTEMS_INLINE_ROUTINE int _POSIX_Priority_Get_maximum( +static inline int _POSIX_Priority_Get_maximum( const Scheduler_Control *scheduler ) { @@ -65,7 +84,7 @@ RTEMS_INLINE_ROUTINE int _POSIX_Priority_Get_maximum( * Thus, SuperCore has priorities run in the opposite sense of the POSIX API. * * Let N be the maximum priority of this scheduler instance. The SuperCore - * priority zero is system reserved (PRIORITY_PSEUDO_ISR). There are only + * priority zero is system reserved (PRIORITY_MINIMUM). There are only * N - 1 POSIX API priority levels since a thread at SuperCore priority N would * never run because of the idle threads. This is necessary because GNAT maps * the lowest Ada task priority to the lowest thread priority. The lowest diff --git a/cpukit/include/rtems/posix/psignal.h b/cpukit/include/rtems/posix/psignal.h index 4a078c57aa..de4848e000 100644 --- a/cpukit/include/rtems/posix/psignal.h +++ b/cpukit/include/rtems/posix/psignal.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_PSIGNAL_H diff --git a/cpukit/include/rtems/posix/psignalimpl.h b/cpukit/include/rtems/posix/psignalimpl.h index cccc3dafc9..16c9b38607 100644 --- a/cpukit/include/rtems/posix/psignalimpl.h +++ b/cpukit/include/rtems/posix/psignalimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ * COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_PSIGNALIMPL_H @@ -73,14 +92,14 @@ extern Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ]; * Internal routines */ -RTEMS_INLINE_ROUTINE void _POSIX_signals_Acquire( +static inline void _POSIX_signals_Acquire( Thread_queue_Context *queue_context ) { _Thread_queue_Acquire( &_POSIX_signals_Wait_queue, queue_context ); } -RTEMS_INLINE_ROUTINE void _POSIX_signals_Release( +static inline void _POSIX_signals_Release( Thread_queue_Context *queue_context ) { diff --git a/cpukit/include/rtems/posix/pthread.h b/cpukit/include/rtems/posix/pthread.h index 8aa11c53fe..b76c61159e 100644 --- a/cpukit/include/rtems/posix/pthread.h +++ b/cpukit/include/rtems/posix/pthread.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_PTHREAD_H diff --git a/cpukit/include/rtems/posix/pthreadattrimpl.h b/cpukit/include/rtems/posix/pthreadattrimpl.h index b5e02ec1c7..726519c690 100644 --- a/cpukit/include/rtems/posix/pthreadattrimpl.h +++ b/cpukit/include/rtems/posix/pthreadattrimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_PTHREADATTRIMPL_H @@ -41,7 +60,7 @@ extern "C" { */ extern const pthread_attr_t _POSIX_Threads_Default_attributes; -RTEMS_INLINE_ROUTINE void _POSIX_Threads_Copy_attributes( +static inline void _POSIX_Threads_Copy_attributes( pthread_attr_t *dst_attr, const pthread_attr_t *src_attr ) @@ -53,7 +72,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Copy_attributes( dst_attr->affinityset = &dst_attr->affinitysetpreallocated; } -RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes( +static inline void _POSIX_Threads_Initialize_attributes( pthread_attr_t *attr ) { @@ -63,7 +82,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes( ); } -RTEMS_INLINE_ROUTINE void _POSIX_Threads_Get_sched_param_sporadic( +static inline void _POSIX_Threads_Get_sched_param_sporadic( const Thread_Control *the_thread, const Scheduler_Control *scheduler, struct sched_param *param @@ -72,7 +91,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Get_sched_param_sporadic( #if defined(RTEMS_POSIX_API) const POSIX_API_Control *api; - api = the_thread->API_Extensions[ THREAD_API_POSIX ]; + api = (const POSIX_API_Control*) the_thread->API_Extensions[ THREAD_API_POSIX ]; param->sched_ss_low_priority = _POSIX_Priority_From_core( scheduler, api->Sporadic.Low_priority.priority diff --git a/cpukit/include/rtems/posix/pthreadimpl.h b/cpukit/include/rtems/posix/pthreadimpl.h index 723b20e8d2..3e76f2792a 100644 --- a/cpukit/include/rtems/posix/pthreadimpl.h +++ b/cpukit/include/rtems/posix/pthreadimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_PTHREADIMPL_H @@ -42,12 +61,12 @@ extern "C" { #define PTHREAD_MINIMUM_STACK_SIZE _POSIX_Threads_Minimum_stack_size #if defined(RTEMS_POSIX_API) -RTEMS_INLINE_ROUTINE void _POSIX_Threads_Sporadic_timer_insert( +static inline void _POSIX_Threads_Sporadic_timer_insert( Thread_Control *the_thread, POSIX_API_Control *api ) { - the_thread->cpu_time_budget = + the_thread->CPU_budget.available = _Timespec_To_ticks( &api->Sporadic.sched_ss_init_budget ); _Watchdog_Per_CPU_insert_ticks( @@ -61,19 +80,12 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Sporadic_timer_insert( void _POSIX_Threads_Sporadic_timer( Watchdog_Control *watchdog ); /** - * @brief POSIX threads sporadic budget callout. - * - * This routine handles the sporadic scheduling algorithm. - * - * @param[in] the_thread is a pointer to the thread whose budget - * has been exceeded. + * @brief The POSIX threads sporadic budget operations. */ -void _POSIX_Threads_Sporadic_budget_callout( - Thread_Control *the_thread -); +extern const Thread_CPU_budget_operations _POSIX_Threads_Sporadic_budget; int _POSIX_Thread_Translate_to_sched_policy( - Thread_CPU_budget_algorithms budget_algorithm + const Thread_CPU_budget_operations *operations ); /** @@ -97,7 +109,7 @@ int _POSIX_Thread_Translate_sched_param( Thread_Configuration *config ); -RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate(void) +static inline Thread_Control *_POSIX_Threads_Allocate(void) { _Objects_Allocator_lock(); diff --git a/cpukit/include/rtems/posix/rwlockimpl.h b/cpukit/include/rtems/posix/rwlockimpl.h index b92ca9d04c..f17967b1f6 100644 --- a/cpukit/include/rtems/posix/rwlockimpl.h +++ b/cpukit/include/rtems/posix/rwlockimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_RWLOCKIMPL_H @@ -35,7 +54,7 @@ typedef struct { CORE_RWLock_Control RWLock; } POSIX_RWLock_Control; -RTEMS_INLINE_ROUTINE POSIX_RWLock_Control *_POSIX_RWLock_Get( +static inline POSIX_RWLock_Control *_POSIX_RWLock_Get( pthread_rwlock_t *rwlock ) { diff --git a/cpukit/include/rtems/posix/semaphore.h b/cpukit/include/rtems/posix/semaphore.h index db36b39c9d..cce16a2ca2 100644 --- a/cpukit/include/rtems/posix/semaphore.h +++ b/cpukit/include/rtems/posix/semaphore.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_SEMAPHORE_H diff --git a/cpukit/include/rtems/posix/semaphoreimpl.h b/cpukit/include/rtems/posix/semaphoreimpl.h index b662d001cb..7f322c21c0 100644 --- a/cpukit/include/rtems/posix/semaphoreimpl.h +++ b/cpukit/include/rtems/posix/semaphoreimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_SEMAPHOREIMPL_H @@ -34,7 +53,7 @@ extern "C" { */ #define POSIX_SEMAPHORE_MAGIC 0x5d367fe7UL -RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control * +static inline POSIX_Semaphore_Control * _POSIX_Semaphore_Allocate_unprotected( void ) { return (POSIX_Semaphore_Control *) @@ -47,31 +66,31 @@ RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control * * This routine frees a semaphore control block to the * inactive chain of free semaphore control blocks. */ -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free ( +static inline void _POSIX_Semaphore_Free ( POSIX_Semaphore_Control *the_semaphore ) { _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object ); } -RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get( +static inline POSIX_Semaphore_Control *_POSIX_Semaphore_Get( sem_t *sem ) { return RTEMS_CONTAINER_OF( sem, POSIX_Semaphore_Control, Semaphore ); } -RTEMS_INLINE_ROUTINE bool _POSIX_Semaphore_Is_named( const sem_t *sem ) +static inline bool _POSIX_Semaphore_Is_named( const sem_t *sem ) { return sem->_Semaphore._Queue._name != NULL; } -RTEMS_INLINE_ROUTINE bool _POSIX_Semaphore_Is_busy( const sem_t *sem ) +static inline bool _POSIX_Semaphore_Is_busy( const sem_t *sem ) { return sem->_Semaphore._Queue._heads != NULL; } -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Initialize( +static inline void _POSIX_Semaphore_Initialize( sem_t *sem, const char *name, unsigned int value @@ -81,7 +100,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Initialize( _Semaphore_Initialize_named( &sem->_Semaphore, name, value ); } -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Destroy( sem_t *sem ) +static inline void _POSIX_Semaphore_Destroy( sem_t *sem ) { sem->_flags = 0; _Semaphore_Destroy( &sem->_Semaphore ); @@ -97,7 +116,7 @@ void _POSIX_Semaphore_Delete( POSIX_Semaphore_Control *the_semaphore ); /** * @brief POSIX Semaphore Namespace Remove */ -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove ( +static inline void _POSIX_Semaphore_Namespace_remove ( POSIX_Semaphore_Control *the_semaphore ) { @@ -107,7 +126,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove ( ); } -RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get_by_name( +static inline POSIX_Semaphore_Control *_POSIX_Semaphore_Get_by_name( const char *name, size_t *name_length_p, Objects_Get_by_name_error *error diff --git a/cpukit/include/rtems/posix/shm.h b/cpukit/include/rtems/posix/shm.h index 3d10e65fea..f2985f4874 100644 --- a/cpukit/include/rtems/posix/shm.h +++ b/cpukit/include/rtems/posix/shm.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,9 +9,26 @@ /* * Copyright (c) 2016 Gedare Bloom. * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_SHM_H diff --git a/cpukit/include/rtems/posix/shmimpl.h b/cpukit/include/rtems/posix/shmimpl.h index 6882119a83..b5f8847b0c 100644 --- a/cpukit/include/rtems/posix/shmimpl.h +++ b/cpukit/include/rtems/posix/shmimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,9 +10,26 @@ /* * Copyright (c) 2016 Gedare Bloom. * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_SHMIMPL_H @@ -31,7 +50,7 @@ extern "C" { * @{ */ -RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void ) +static inline POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void ) { return (POSIX_Shm_Control *) _Objects_Allocate_unprotected( &_POSIX_Shm_Information ); @@ -42,14 +61,14 @@ RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void ) * * This routine frees a shm control block. */ -RTEMS_INLINE_ROUTINE void _POSIX_Shm_Free ( +static inline void _POSIX_Shm_Free ( POSIX_Shm_Control *the_shm ) { _Objects_Free( &_POSIX_Shm_Information, &the_shm->Object ); } -RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Get_by_name( +static inline POSIX_Shm_Control *_POSIX_Shm_Get_by_name( const char *name, size_t *name_length_p, Objects_Get_by_name_error *error @@ -63,7 +82,7 @@ RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Get_by_name( ); } -RTEMS_INLINE_ROUTINE void _POSIX_Shm_Update_atime( +static inline void _POSIX_Shm_Update_atime( POSIX_Shm_Control *shm ) { @@ -72,7 +91,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Shm_Update_atime( shm->atime = now.tv_sec; } -RTEMS_INLINE_ROUTINE void _POSIX_Shm_Update_mtime_ctime( +static inline void _POSIX_Shm_Update_mtime_ctime( POSIX_Shm_Control *shm ) { diff --git a/cpukit/include/rtems/posix/sigset.h b/cpukit/include/rtems/posix/sigset.h index 6f46f61104..0fcd8da464 100644 --- a/cpukit/include/rtems/posix/sigset.h +++ b/cpukit/include/rtems/posix/sigset.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_SIGSET_H diff --git a/cpukit/include/rtems/posix/spinlockimpl.h b/cpukit/include/rtems/posix/spinlockimpl.h index d28e0391fc..10424f1961 100644 --- a/cpukit/include/rtems/posix/spinlockimpl.h +++ b/cpukit/include/rtems/posix/spinlockimpl.h @@ -1,21 +1,40 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file - * - * @brief Inlined Routines from the POSIX Spinlock Manager * - * This file contains the static inlin implementation of the inlined - * routines from the POSIX Spinlock Manager. + * @ingroup POSIXAPI + * + * @brief This header file provides interfaces used by the POSIX Spinlock + * implementation. */ /* * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2016 embedded brains GmbH + * Copyright (c) 2016 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_SPINLOCKIMPL_H @@ -43,7 +62,7 @@ typedef struct { ISR_Level interrupt_state; } POSIX_Spinlock_Control; -RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Get( +static inline POSIX_Spinlock_Control *_POSIX_Spinlock_Get( pthread_spinlock_t *lock ) { diff --git a/cpukit/include/rtems/posix/threadsup.h b/cpukit/include/rtems/posix/threadsup.h index 127d897531..95f56abb12 100644 --- a/cpukit/include/rtems/posix/threadsup.h +++ b/cpukit/include/rtems/posix/threadsup.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_THREADSUP_H diff --git a/cpukit/include/rtems/posix/timer.h b/cpukit/include/rtems/posix/timer.h index 7ae089173a..86b45ba05d 100644 --- a/cpukit/include/rtems/posix/timer.h +++ b/cpukit/include/rtems/posix/timer.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_TIMER_H @@ -75,6 +94,24 @@ extern Objects_Information _POSIX_Timer_Information; NULL \ ) +/** + * @brief Follow POSIX or FACE Technical Standard on timer_create + * + * POSIX allows for the creation of timers based on CLOCK_REALTIME. + * This is viewed as a safety issue by the FACE Technical Standard + * and required to return an error. These are conflicting behaviors. + * This method is instanced by configuration when FACE conformant + * behavior is desired by the application. + * + * @param[in] clock_id is the clock ID to validate + * + * @return 0 if @a clock_id is allowed for use. Otherwise an errno value. + */ +int _POSIX_Timer_Is_allowed( + clockid_t clock_id +); + + /** @} */ #ifdef __cplusplus diff --git a/cpukit/include/rtems/posix/timerimpl.h b/cpukit/include/rtems/posix/timerimpl.h index 2b4eec1e24..f0622b6026 100644 --- a/cpukit/include/rtems/posix/timerimpl.h +++ b/cpukit/include/rtems/posix/timerimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_POSIX_TIMERIMPL_H @@ -57,7 +76,7 @@ extern "C" { * This function allocates a timer control block from * the inactive chain of free timer control blocks. */ -RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void ) +static inline POSIX_Timer_Control *_POSIX_Timer_Allocate( void ) { return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information ); } @@ -68,7 +87,7 @@ RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void ) * This routine frees a timer control block to the * inactive chain of free timer control blocks. */ -RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free ( +static inline void _POSIX_Timer_Free ( POSIX_Timer_Control *the_timer ) { @@ -86,7 +105,7 @@ void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog ); * is set to OBJECTS_LOCAL. Otherwise, location is set * to OBJECTS_ERROR and the returned value is undefined. */ -RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get ( +static inline POSIX_Timer_Control *_POSIX_Timer_Get ( timer_t id, ISR_lock_Context *lock_context ) @@ -98,7 +117,7 @@ RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get ( ); } -RTEMS_INLINE_ROUTINE Per_CPU_Control *_POSIX_Timer_Acquire_critical( +static inline Per_CPU_Control *_POSIX_Timer_Acquire_critical( POSIX_Timer_Control *ptimer, ISR_lock_Context *lock_context ) @@ -111,7 +130,7 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_POSIX_Timer_Acquire_critical( return cpu; } -RTEMS_INLINE_ROUTINE void _POSIX_Timer_Release( +static inline void _POSIX_Timer_Release( Per_CPU_Control *cpu, ISR_lock_Context *lock_context ) diff --git a/cpukit/include/rtems/print.h b/cpukit/include/rtems/print.h index cae81b7630..1f870482d4 100644 --- a/cpukit/include/rtems/print.h +++ b/cpukit/include/rtems/print.h @@ -1,6 +1,10 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * + * @ingroup RTEMSPrintSupport + * * @brief User print interface to the bspIO print plug in. * * This include file defines the user interface to kernel print methods. @@ -10,9 +14,26 @@ * Copyright (c) 2016 Chris Johns <chrisj@rtems.org> * All rights reserved. * - * 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. + * 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. */ #ifndef _RTEMS_PRINT_H @@ -35,6 +56,8 @@ typedef struct rtems_printer rtems_printer; * * This module contains all methods and support related to providing the user * with an interface to the kernel level print support. + * + * @{ */ /** diff --git a/cpukit/include/rtems/printer.h b/cpukit/include/rtems/printer.h index 310937cc2f..424d59563e 100644 --- a/cpukit/include/rtems/printer.h +++ b/cpukit/include/rtems/printer.h @@ -1,6 +1,10 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * + * @ingroup RTEMSPrintSupport + * * @brief User print interface to the bspIO print plug in. * * This include file defines the user interface to kernel print methods. @@ -10,9 +14,26 @@ * Copyright (c) 2016 Chris Johns <chrisj@rtems.org> * All rights reserved. * - * 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. + * 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. */ #ifndef _RTEMS_PRINTER_H diff --git a/cpukit/include/rtems/profiling.h b/cpukit/include/rtems/profiling.h index 9b4b70489c..95ec3323e1 100644 --- a/cpukit/include/rtems/profiling.h +++ b/cpukit/include/rtems/profiling.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 2014 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_PROFILING_H diff --git a/cpukit/include/rtems/pty.h b/cpukit/include/rtems/pty.h index 94b66d63c4..e9303a1be3 100644 --- a/cpukit/include/rtems/pty.h +++ b/cpukit/include/rtems/pty.h @@ -1,8 +1,11 @@ +/** + * @file + * + * @brief /dev/ptyXX (A first version for pseudo-terminals) + */ + /* - * /dev/ptyXX (A first version for pseudo-terminals) - * - * Author: Fernando RUIZ CASAS (fernando.ruiz@ctv.es) - * May 2001 + * Copyright (c) 2001 Fernando Ruiz Casas <fruizcasas@gmail.com> * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -36,7 +39,7 @@ typedef struct { const char *rtems_pty_initialize(rtems_pty_context *pty, uintptr_t unique); -RTEMS_INLINE_ROUTINE const char *rtems_pty_get_path(const rtems_pty_context *pty) +static inline const char *rtems_pty_get_path(const rtems_pty_context *pty) { return pty->name; } diff --git a/cpukit/include/rtems/qreslib.h b/cpukit/include/rtems/qreslib.h index 88d9aba721..a8e70433a1 100644 --- a/cpukit/include/rtems/qreslib.h +++ b/cpukit/include/rtems/qreslib.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -14,9 +16,26 @@ * Copyright (C) 2011 Petr Benes. * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef CONFIGURE_SCHEDULER_CBS @@ -79,7 +98,7 @@ typedef struct { * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_init ( void ) +static inline qos_rv qres_init ( void ) { return _Scheduler_CBS_Initialize(); } @@ -91,7 +110,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_init ( void ) * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_cleanup ( void ) +static inline qos_rv qres_cleanup ( void ) { return _Scheduler_CBS_Cleanup(); } @@ -103,7 +122,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_cleanup ( void ) * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_create_server ( +static inline qos_rv qres_create_server ( qres_params_t *params, qres_sid_t *server_id ) @@ -122,7 +141,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_create_server ( * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_attach_thread ( +static inline qos_rv qres_attach_thread ( qres_sid_t server_id, pid_t pid, tid_t task_id @@ -138,7 +157,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_attach_thread ( * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_detach_thread ( +static inline qos_rv qres_detach_thread ( qres_sid_t server_id, pid_t pid, tid_t task_id @@ -154,7 +173,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_detach_thread ( * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_destroy_server ( +static inline qos_rv qres_destroy_server ( qres_sid_t server_id ) { @@ -169,7 +188,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_destroy_server ( * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_get_sid ( +static inline qos_rv qres_get_sid ( pid_t pid, tid_t task_id, qres_sid_t *server_id @@ -185,7 +204,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_get_sid ( * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_get_params ( +static inline qos_rv qres_get_params ( qres_sid_t server_id, qres_params_t *params ) @@ -203,7 +222,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_get_params ( * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_set_params ( +static inline qos_rv qres_set_params ( qres_sid_t server_id, qres_params_t *params ) @@ -221,7 +240,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_set_params ( * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_get_exec_time ( +static inline qos_rv qres_get_exec_time ( qres_sid_t server_id, qres_time_t *exec_time, qres_atime_t *abs_time @@ -237,7 +256,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_get_exec_time ( * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_get_curr_budget ( +static inline qos_rv qres_get_curr_budget ( qres_sid_t server_id, qres_time_t *current_budget ) @@ -253,7 +272,7 @@ RTEMS_INLINE_ROUTINE qos_rv qres_get_curr_budget ( * * @return status code. */ -RTEMS_INLINE_ROUTINE qos_rv qres_get_appr_budget ( +static inline qos_rv qres_get_appr_budget ( qres_sid_t server_id, qres_time_t *appr_budget ) diff --git a/cpukit/include/rtems/rbheap.h b/cpukit/include/rtems/rbheap.h index 0db72ebf93..8b190051a8 100644 --- a/cpukit/include/rtems/rbheap.h +++ b/cpukit/include/rtems/rbheap.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * Copyright (c) 2012 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_RBHEAP_H diff --git a/cpukit/include/rtems/rbtree.h b/cpukit/include/rtems/rbtree.h index be3f08c7f1..45d08701da 100644 --- a/cpukit/include/rtems/rbtree.h +++ b/cpukit/include/rtems/rbtree.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,9 +11,26 @@ /* * Copyright (c) 2010 Gedare Bloom. * - * 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. + * 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. */ #ifndef _RTEMS_RBTREE_H @@ -120,7 +139,7 @@ void rtems_rbtree_initialize( * * This routine initializes @a the_rbtree to contain zero nodes. */ -RTEMS_INLINE_ROUTINE void rtems_rbtree_initialize_empty( +static inline void rtems_rbtree_initialize_empty( rtems_rbtree_control *the_rbtree ) { @@ -133,7 +152,7 @@ RTEMS_INLINE_ROUTINE void rtems_rbtree_initialize_empty( * This function sets the next and previous fields of the @a node to NULL * indicating the @a node is not part of any rbtree. */ -RTEMS_INLINE_ROUTINE void rtems_rbtree_set_off_tree( +static inline void rtems_rbtree_set_off_tree( rtems_rbtree_node *node ) { @@ -146,7 +165,7 @@ RTEMS_INLINE_ROUTINE void rtems_rbtree_set_off_tree( * This function returns true if the @a node is not on a rbtree. A @a node is * off rbtree if the next and previous fields are set to NULL. */ -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_node_off_tree( +static inline bool rtems_rbtree_is_node_off_tree( const rtems_rbtree_node *node ) { @@ -158,7 +177,7 @@ RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_node_off_tree( * * This function returns a pointer to the root node of @a the_rbtree. */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_root( +static inline rtems_rbtree_node *rtems_rbtree_root( const rtems_rbtree_control *the_rbtree ) { @@ -168,7 +187,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_root( /** * @copydoc _RBTree_Minimum() */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_min( +static inline rtems_rbtree_node *rtems_rbtree_min( const rtems_rbtree_control *the_rbtree ) { @@ -178,7 +197,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_min( /** * @copydoc _RBTree_Maximum() */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_max( +static inline rtems_rbtree_node *rtems_rbtree_max( const rtems_rbtree_control *the_rbtree ) { @@ -190,7 +209,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_max( * * This function returns a pointer to the left child node of @a the_node. */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_left( +static inline rtems_rbtree_node *rtems_rbtree_left( const rtems_rbtree_node *the_node ) { @@ -202,7 +221,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_left( * * This function returns a pointer to the right child node of @a the_node. */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_right( +static inline rtems_rbtree_node *rtems_rbtree_right( const rtems_rbtree_node *the_node ) { @@ -212,7 +231,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_right( /** * @copydoc _RBTree_Parent() */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_parent( +static inline rtems_rbtree_node *rtems_rbtree_parent( const rtems_rbtree_node *the_node ) { @@ -225,7 +244,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_parent( * This function returns true if there a no nodes on @a the_rbtree and * false otherwise. */ -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_empty( +static inline bool rtems_rbtree_is_empty( const rtems_rbtree_control *the_rbtree ) { @@ -238,7 +257,7 @@ RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_empty( * This function returns true if @a the_node is the min node on @a the_rbtree * and false otherwise. */ -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_min( +static inline bool rtems_rbtree_is_min( const rtems_rbtree_control *the_rbtree, const rtems_rbtree_node *the_node ) @@ -252,7 +271,7 @@ RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_min( * This function returns true if @a the_node is the max node on @a the_rbtree * and false otherwise. */ -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_max( +static inline bool rtems_rbtree_is_max( const rtems_rbtree_control *the_rbtree, const rtems_rbtree_node *the_node ) @@ -263,28 +282,28 @@ RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_max( /** * @copydoc _RBTree_Is_root() */ -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_root( +static inline bool rtems_rbtree_is_root( const rtems_rbtree_node *the_node ) { return _RBTree_Is_root( the_node ); } -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_equal( +static inline bool rtems_rbtree_is_equal( rtems_rbtree_compare_result compare_result ) { return compare_result == 0; } -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_greater( +static inline bool rtems_rbtree_is_greater( rtems_rbtree_compare_result compare_result ) { return compare_result > 0; } -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_lesser( +static inline bool rtems_rbtree_is_lesser( rtems_rbtree_compare_result compare_result ) { @@ -315,7 +334,7 @@ rtems_rbtree_node* rtems_rbtree_find( /** * @copydoc _RBTree_Predecessor() */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node* rtems_rbtree_predecessor( +static inline rtems_rbtree_node* rtems_rbtree_predecessor( const rtems_rbtree_node *node ) { @@ -325,7 +344,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node* rtems_rbtree_predecessor( /** * @copydoc _RBTree_Successor() */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node* rtems_rbtree_successor( +static inline rtems_rbtree_node* rtems_rbtree_successor( const rtems_rbtree_node *node ) { @@ -335,7 +354,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node* rtems_rbtree_successor( /** * @copydoc _RBTree_Extract() */ -RTEMS_INLINE_ROUTINE void rtems_rbtree_extract( +static inline void rtems_rbtree_extract( rtems_rbtree_control *the_rbtree, rtems_rbtree_node *the_node ) @@ -355,7 +374,7 @@ RTEMS_INLINE_ROUTINE void rtems_rbtree_extract( * @retval NULL The tree is empty. * @retval node A node with the minimal key value on the tree. */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_min( +static inline rtems_rbtree_node *rtems_rbtree_get_min( rtems_rbtree_control *the_rbtree ) { @@ -380,7 +399,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_min( * @retval NULL The tree is empty. * @retval node A node with the maximal key value on the tree. */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_max( +static inline rtems_rbtree_node *rtems_rbtree_get_max( rtems_rbtree_control *the_rbtree ) { @@ -400,7 +419,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_max( * without changing the tree. If @a the_rbtree is empty, * then NULL is returned. */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_peek_min( +static inline rtems_rbtree_node *rtems_rbtree_peek_min( const rtems_rbtree_control *the_rbtree ) { @@ -414,7 +433,7 @@ RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_peek_min( * without changing the tree. If @a the_rbtree is empty, * then NULL is returned. */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_peek_max( +static inline rtems_rbtree_node *rtems_rbtree_peek_max( const rtems_rbtree_control *the_rbtree ) { diff --git a/cpukit/include/rtems/record.h b/cpukit/include/rtems/record.h index 2f5ad5415c..cd52083e0c 100644 --- a/cpukit/include/rtems/record.h +++ b/cpukit/include/rtems/record.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2018, 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2018, 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -67,6 +67,8 @@ extern const Record_Configuration _Record_Configuration; void _Record_Initialize( void ); +void _Record_Interrupt_initialize( void ); + bool _Record_Thread_create( struct _Thread_Control *executing, struct _Thread_Control *created @@ -112,7 +114,7 @@ void _Record_Thread_terminate( struct _Thread_Control *executing ); -RTEMS_INLINE_ROUTINE unsigned int _Record_Index( +static inline unsigned int _Record_Index( const Record_Control *control, unsigned int index ) @@ -120,17 +122,17 @@ RTEMS_INLINE_ROUTINE unsigned int _Record_Index( return index & control->mask; } -RTEMS_INLINE_ROUTINE unsigned int _Record_Head( const Record_Control *control ) +static inline unsigned int _Record_Head( const Record_Control *control ) { return _Atomic_Load_uint( &control->head, ATOMIC_ORDER_RELAXED ); } -RTEMS_INLINE_ROUTINE unsigned int _Record_Tail( const Record_Control *control ) +static inline unsigned int _Record_Tail( const Record_Control *control ) { return control->tail; } -RTEMS_INLINE_ROUTINE bool _Record_Is_overflow( +static inline bool _Record_Is_overflow( const Record_Control *control, unsigned int tail, unsigned int head @@ -139,7 +141,7 @@ RTEMS_INLINE_ROUTINE bool _Record_Is_overflow( return head - tail >= control->mask + 1U; } -RTEMS_INLINE_ROUTINE unsigned int _Record_Capacity( +static inline unsigned int _Record_Capacity( const Record_Control *control, unsigned int tail, unsigned int head @@ -148,7 +150,7 @@ RTEMS_INLINE_ROUTINE unsigned int _Record_Capacity( return ( tail - head - 1U ) & control->mask; } -RTEMS_INLINE_ROUTINE rtems_counter_ticks _Record_Now( void ) +static inline rtems_counter_ticks _Record_Now( void ) { return rtems_counter_read(); } @@ -498,7 +500,7 @@ void _Record_Exit_10( * context may have an arbitrary content at function entry. * @param cpu_self The control of the current processor. */ -RTEMS_INLINE_ROUTINE void rtems_record_prepare_critical( +static inline void rtems_record_prepare_critical( rtems_record_context *context, const Per_CPU_Control *cpu_self ) @@ -524,7 +526,7 @@ RTEMS_INLINE_ROUTINE void rtems_record_prepare_critical( * * @see rtems_record_produce(). */ -RTEMS_INLINE_ROUTINE void rtems_record_prepare( rtems_record_context *context ) +static inline void rtems_record_prepare( rtems_record_context *context ) { uint32_t level; const Per_CPU_Control *cpu_self; @@ -549,7 +551,7 @@ RTEMS_INLINE_ROUTINE void rtems_record_prepare( rtems_record_context *context ) * @param event The record event without a time stamp for the item. * @param data The record data for the item. */ -RTEMS_INLINE_ROUTINE void rtems_record_add( +static inline void rtems_record_add( rtems_record_context *context, rtems_record_event event, rtems_record_data data @@ -575,7 +577,7 @@ RTEMS_INLINE_ROUTINE void rtems_record_add( * @param context The record context initialized via * rtems_record_prepare_critical(). */ -RTEMS_INLINE_ROUTINE void rtems_record_commit_critical( rtems_record_context *context ) +static inline void rtems_record_commit_critical( rtems_record_context *context ) { _Atomic_Store_uint( &context->control->head, @@ -589,7 +591,7 @@ RTEMS_INLINE_ROUTINE void rtems_record_commit_critical( rtems_record_context *co * * @param context The record context initialized via rtems_record_prepare(). */ -RTEMS_INLINE_ROUTINE void rtems_record_commit( rtems_record_context *context ) +static inline void rtems_record_commit( rtems_record_context *context ) { rtems_record_commit_critical( context ); RTEMS_COMPILER_MEMORY_BARRIER(); diff --git a/cpukit/include/rtems/recordclient.h b/cpukit/include/rtems/recordclient.h index cb1e704f99..037c9d52f7 100644 --- a/cpukit/include/rtems/recordclient.h +++ b/cpukit/include/rtems/recordclient.h @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2018, 2019 embedded brains GmbH + * Copyright (C) 2018, 2019 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/recorddata.h b/cpukit/include/rtems/recorddata.h index 4fa16d6775..3ba67975c1 100644 --- a/cpukit/include/rtems/recorddata.h +++ b/cpukit/include/rtems/recorddata.h @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2018, 2019 embedded brains GmbH + * Copyright (C) 2018, 2019 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/recorddump.h b/cpukit/include/rtems/recorddump.h index 246482161c..c8d020b216 100644 --- a/cpukit/include/rtems/recorddump.h +++ b/cpukit/include/rtems/recorddump.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/recordserver.h b/cpukit/include/rtems/recordserver.h index 2c04ea65cb..eb6d98136a 100644 --- a/cpukit/include/rtems/recordserver.h +++ b/cpukit/include/rtems/recordserver.h @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2018, 2019 embedded brains GmbH + * Copyright (C) 2018, 2019 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/regulator.h b/cpukit/include/rtems/regulator.h new file mode 100644 index 0000000000..442040a180 --- /dev/null +++ b/cpukit/include/rtems/regulator.h @@ -0,0 +1,502 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RegulatorAPI + * + * @brief This header file defines the Regulator API. + * + */ + +/* + * Copyright (C) 2023 On-Line Applications Research Corporation (OAR) + * + * 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. + */ + +/** + * @defgroup RegulatorAPI Regulator API + * + * @brief Regulator APIs + * + * The Regulator provides a set of APIs to manage input sources which + * produces bursts of message traffic. + * + * The regulator is designed to sit logically between two entities -- a + * source and a destination, where it limits the traffic sent to the + * destination to prevent it from being flooded with messages from the + * source. This can be used to accommodate bursts of input from a source + * and meter it out to a destination. The maximum number of messages + * which can be buffered in the regulator is specified by the + * @a maximum_messages field in the @a rtems_regulator_attributes + * structure passed as an argument to @a rtems_regulator_create(). + * + * The regulator library accepts an input stream of messages from a + * source and delivers them to a destination. The regulator assumes that the + * input stream from the source contains sporadic bursts of data which can + * exceed the acceptable rate of the destination. By limiting the message rate, + * the regulator prevents an overflow of messages. + * + * The regulator can be configured for the input buffering required to manage + * the maximum burst and for the metering rate for the output. The output rate + * is in messages per second. If the sender produces data too fast, the + * regulator will buffer the configured number of messages. + * + * A configuration capability is provided to allow for adaptation to different + * message streams. The regulator can also support running multiple instances, + * which could be used on independent message streams. + * + * The regulator provides a simple interface to the application for avoiding + * bursts of input from a fast source overflowing a slower destination. + * + * It is assumed that the application has a design limit on the number of + * messages which may be buffered. All messages accepted by the regulator, + * assuming no overflow on input, will eventually be output by the Delivery + * thread. + * + * A regulator instance is used as follows from the producer/source side: + * + * @code + * while (1) + * use rtems_regulator_obtain_buffer to obtain a buffer + * input operation to fetch data into the buffer + * rtems_regulator_send(buffer, size of message) + * @endcode + * + * The delivery of message buffers to the Destination and subsequent + * release is performed in the context of the delivery thread by either + * the delivery function or delivery thread. Details are below. + * + * The sequence diagram below shows the interaction between a message Source, + * a Regulator instance, and RTEMS, given the usage described in the above + * paragraphs. + * + * \startuml "Regulator Application Input Source Usage" + * Source -> Regulator : rtems_regulator_obtain_buffer(regulator, buffer) + * Regulator -> RTEMS : rtems_partition_get_buffer(id, buffer) + * RTEMS --> Regulator : rtems_status_code + * Regulator --> Source : rtems_status_code + * Source -> Regulator : rtems_regulator_send(regulator, message, length) + * Regulator -> RTEMS : rtems_message_queue_send(id, message, size) + * RTEMS --> Regulator : rtems_status_code + * Regulator --> Source : rtems_status_code + * \enduml + * + * As illustrated in the sequence diagram, the Source usually corresponds + * to application software reading a system input. The Source obtains a + * buffer from the Regulator instance and fills it with incoming data. + * The application explicitly obtaining a buffer and filling it in allows + * for zero copy operations on the Source side. + * + * The Source then sends the buffer to the Regulator instance. The Regulator + * the sends the buffer via a message queue which to the Delivery thread. + * The Delivery thread executes periodically at a rate specified at + * Regulation creation. At each period, the Delivery thread attempts to + * receive up to a configured number of buffers and invoke the Delivery + * function to deliver them to the Destination. + * + * The Delivery function is provided by the application for this + * specific Regulator instance. Depending on the Destination, it may use + * a function which copies the buffer contents (e.g., write()) or which + * operates directly on the buffer contents (e.g. DMA from buffer). In + * the case of a Destination which copies the buffer contents, the buffer + * can be released via @a rtems_regulator_release_buffer() as soon as the + * function or copying completes. In the case where the delivery uses the + * buffer and returns, the call to @a rtems_regulator_release_buffer() + * will occur when the use of the buffer is complete (e.g. completion + * of DMA transfer). This explicit and deliberate exposure of buffering + * provides the application with the ability to avoid copying the contents. + * + * After the Source has sent the message to the Regulator instance, + * the Source is free to process another input and the Regulator + * instance will ensure that the buffer is delivered to the Delivery + * function and Destination. + * + * The Regulator implementation uses the RTEMS Classic API Partition Manager + * to manage the buffer pool and the RTEMS Classic API Message Queue + * Manager to send the buffer to the Delivery thread. + */ + +#ifndef REGULATOR_H +#define REGULATOR_H + +#include <stdlib.h> + +#include <rtems.h> + +/** + * @ingroup RegulatorAPI + * + * @brief Regulator Delivery Function Type + * + * The user provides a function which is invoked to deliver a message + * to the output. It is invoked by the Delivery thread created as part + * of @a rtems_regulator_create(). The priority and stack size of the + * Delivery thread are specified in the regulator attribute set. + * + * It takes three parameters: + * + * @param[in] context is an untyped pointer to a user context + * @param[in] message points to the message + * @param[in] length is the message size + * + * The following is an example deliverer function. It assumes that the + * application has defined the my_context_t structure and it has at least + * the socket field. The @a message passed in originated with an + * application source which obtained the @a message buffer using + * @a rtems_regulator_obtain_buffer(), filled it in with source data, + * and used @a rtems_regulator_send() to hand to the regulator instance + * for later delivery. + * + * @code + * bool my_deliverer( + * void *context, + * void *message, + * size_t length + * ) + * { + * my_context_t *my_context; + * + * my_context = (my_context_t *)context; + * + * write(my_context->socket, message, length); + * rtems_regulator_release_buffer(message); + * // return false to indicate we released the buffer + * return false; + * } + * @endcode + * + * The delivery function returns true to indicate that the delivery thread + * should release the buffer or false to indicate that it released the + * buffer. If the delivery function invokes a function like @a write() + * to deliver the message to the destination, then the buffer can be + * released immediately after the call. If the delivery function does + * something like setting up a DMA transfer of the buffer, it cannot be + * released until after the DMA is complete. + * + * The following sequence diagram shows the behavior of the Delivery thread + * body and its interaction with the user-supplied deliverer() function. + * + * \startuml "Regulator Delivery Thread Body" + * loop while (1) + * "Delivery Thread" -> RTEMS : rtems_rate_monotonic_period(id, delivery_thread_period) + * loop for 0 : maximum_to_dequeue_per_period + * "Delivery Thread" -> RTEMS : rtems_message_queue_receive(id, message, size, wait, 0) + * RTEMS --> "Delivery Thread" : rtems_status_code + * group if [rtems_status_code != RTEMS_SUCCESSFUL] + * RTEMS -> "Delivery Thread" : break + * end + * "Delivery Thread" -> Application : deliverer(context, buffer, length) + * "Delivery Thread" -> RTEMS : rtems_partition_return_buffer(id, buffer) + * RTEMS --> "Delivery Thread" : rtems_status_code + * end + * end + * \enduml + * + * In the above sequence diagram, the key points are: + * + * -# The Delivery Thread Body is periodically executed. + * -# During each period, up to the instance configuration parameter + * @a maximum_to_dequeue_per_period may be dequeued and + * passed the application's delivery function for processing. + * + * Note that the application explicitly obtains buffers from the + * regulator instance but that the release may be done by Delivery + * Thread, the Delivery function, or later when the buffer contents + * are transferred. + */ +typedef bool (*rtems_regulator_deliverer)( + void *context, + void *message, + size_t length +); + +/** + * @ingroup RegulatorAPI + * + * @brief Attributes for Regulator Instance + * + * An instance of this structure must be populated by the application + * before creating an instance of the regulator. These settings tailor + * the behavior of the regulator instance. + */ +typedef struct { + /** Application function to invoke to output a message to the destination*/ + rtems_regulator_deliverer deliverer; + + /** Context pointer to pass to deliver function */ + void *deliverer_context; + + /** Maximum size message to process */ + size_t maximum_message_size; + + /** Maximum number of messages to be able to buffer */ + size_t maximum_messages; + + /** Priority of Delivery thread */ + rtems_task_priority delivery_thread_priority; + + /** Stack size of Delivery thread */ + size_t delivery_thread_stack_size; + + /** Period (in ticks) of Delivery thread */ + rtems_interval delivery_thread_period; + + /** Maximum messages to dequeue per period */ + size_t maximum_to_dequeue_per_period; + +} rtems_regulator_attributes; + +/** + * @ingroup RegulatorAPI + * + * @brief Statistics for Regulator Instance + * + * An instance of this structure is provided to the directive + * @a rtems_regulator_get_statistics and is filled in by that service. + */ +typedef struct { + /** Number of successfully obtained buffers. */ + size_t obtained; + + /** Number of successfully released buffers. */ + size_t released; + + /** Number of successfully delivered buffers. */ + size_t delivered; + + /** Rate Monotonic Period statistics for Delivery Thread */ + rtems_rate_monotonic_period_statistics period_statistics; + +} rtems_regulator_statistics; + +/** + * @ingroup RegulatorAPI + * + * @brief Regulator Internal Structure + */ +struct _Regulator_Control; + +/** + * @ingroup RegulatorAPI + * + * @brief Regulator Instance + * + * This is used by the application as the handle to a Regulator instance. + */ +typedef struct _Regulator_Control *rtems_regulator_instance; + +/** + * @ingroup RegulatorAPI + * + * @brief Create a regulator + * + * This function creates an instance of a regulator. It uses the provided + * @a attributes to create the instance return in @a regulator. This instance + * will allocate the buffers associated with the regulator instance as well + * as the Delivery thread. + * + * The @a attributes structure defines the priority and stack size of + * the Delivery thread dedicated to this regulator instance. It also + * defines the period of the Delivery thread and the maximum number of + * messages that may be delivered per period via invocation of the + * delivery function. + * + * For each regulator instance, the following resources are allocated: + * + * - A memory area for the regulator control block using @a malloc(). + * - A RTEMS Classic API Message Queue is constructed with message + * buffer memory allocated using @a malloc(). Each message consists + * of a pointer and a length. + * - A RTEMS Classic API Partition. + * - A RTEMS Classic API Rate Monotonic Period. + * + * @param[in] attributes specify the regulator instance attributes + * @param[inout] regulator will point to the regulator instance + * + * @return an RTEMS status code indicating success or failure. + * + * @note This function allocates memory for the buffers holding messages, + * an Delivery thread and an RTEMS partition. When it executes, the + * Delivery thread will create an RTEMS rate monotonic period. + */ +rtems_status_code rtems_regulator_create( + rtems_regulator_attributes *attributes, + rtems_regulator_instance **regulator +); + +/** + * @ingroup RegulatorAPI + * + * @brief Delete a regulator + * + * This function is used to delete the specified @a regulator instance. + * + * It is the responsibility of the user to ensure that any resources + * such as sockets or open file descriptors used by the delivery + * function are also deleted. It is likely safer to delete those + * delivery resources after deleting the regulator instance rather than + * before. + * + * @param[in] regulator is the instance to delete + * @param[in] ticks is the maximum number of ticks to wait for + * the delivery thread to shutdown. + * + * @return an RTEMS status code indicating success or failure. + * + * @note This function deallocates the resources allocated during + * @a rtems_regulator_create(). + */ +rtems_status_code rtems_regulator_delete( + rtems_regulator_instance *regulator, + rtems_interval ticks +); + +/** + * @ingroup RegulatorAPI + * + * @brief Obtain Buffer from Regulator + * + * This function is used to obtain a buffer from the regulator's pool. The + * @a buffer returned is assumed to be filled in with contents and used + * in a subsequent call to @a rtems_regulator_send(). When the @a buffer is + * delivered, it is expected to be released. If the @a buffer is not + * successfully accepted by this function, then it should be returned + * using @a rtems_regulator_release_buffer() or used to send another message. + * + * The @a buffer is of the maximum_message_size specified in the attributes + * passed in to @a rtems_regulator_create(). + * + * @param[in] regulator is the regulator instance to operate upon + * @param[out] buffer will point to the allocated buffer + * + * @return an RTEMS status code indicating success or failure. + * + * @note This function does not perform dynamic allocation. It obtains a + * buffer from the pool allocated during @a rtems_regulator_create(). + * + * @note Any attempt to write outside the buffer area is undefined. + */ +rtems_status_code rtems_regulator_obtain_buffer( + rtems_regulator_instance *regulator, + void **buffer +); + +/** + * @ingroup RegulatorAPI + * + * @brief Release Previously Obtained Regulator Buffer + * + * This function is used to release a buffer to the regulator's pool. It is + * assumed that the @a buffer returned will not be used by the application + * anymore. The @a buffer must have previously been allocated by + * @a rtems_regulator_obtain_buffer() and NOT passed to + * @a rtems_regulator_send(). + * + * If a subsequent @a rtems_regulator_send() using this @a buffer is + * successful, the @a buffer will eventually be processed by the delivery + * thread and released. + * + * @param[in] regulator is the regulator instance to operate upon + * @param[out] buffer will point to the buffer to release + * + * @return an RTEMS status code indicating success or failure. + * + * @note This function does not perform dynamic deallocation. It releases a + * buffer to the pool allocated during @a rtems_regulator_create(). + */ +rtems_status_code rtems_regulator_release_buffer( + rtems_regulator_instance *regulator, + void *buffer +); + +/** + * @ingroup RegulatorAPI + * + * @brief Send to regulator instance + * + * This function is used by the producer to send a @a message to the + * @a regulator for later delivery by the Delivery thread. The message is + * contained in the memory pointed to by @a message and is @a length + * bytes in length. + * + * It is required that the @a message buffer was obtained via + * @a rtems_regulator_obtain_buffer(). + * + * It is assumed that the @a message buffer has been filled in with + * application content to deliver. + * + * If the @a rtems_regulator_send() is successful, the buffer is enqueued + * inside the regulator instance for subsequent delivery. After the + * @a message is delivered, it may be released by either delivery + * function or the application code depending on the implementation. + * + * The status @a RTEMS_TOO_MANY is returned if the regulator's + * internal queue is full. This indicates that the configured + * maximum number of messages was insufficient. It is the + * responsibility of the caller to decide whether to hold messages, + * drop them, or print a message that the maximum number of messages + * should be increased. + * + * If @a rtems_regulator_send() is unsuccessful, it is the application's + * responsibility to release the buffer. If it is successfully sent, + * then it becomes the responsibility of the delivery function to + * release it. + * + * @param[in] regulator is the regulator instance to operate upon + * @param[out] message points to the message to deliver + * @param[out] length is the size of the message in bytes + * + * @return an RTEMS status code indicating success or failure. + * + */ +rtems_status_code rtems_regulator_send( + rtems_regulator_instance *regulator, + void *message, + size_t length +); + +/** + * @ingroup RegulatorAPI + * + * @brief Obtain statistics for regulator instance + * + * This function is used by the application to obtain statistics + * information about the regulator instance. + * + * If the @a obtained and @a released fields in the returned + * @a statistics structure are equal, then there are no buffers + * outstanding from this regulator instance. + * + * @param[in] regulator is the regulator instance to operate upon + * @param[inout] statistics points to the statistics structure to fill in + * + * @return an RTEMS status code indicating success or failure. + * + */ +rtems_status_code rtems_regulator_get_statistics( + rtems_regulator_instance *regulator, + rtems_regulator_statistics *statistics +); + +#endif /* REGULATOR_H */ diff --git a/cpukit/include/rtems/regulatorimpl.h b/cpukit/include/rtems/regulatorimpl.h new file mode 100644 index 0000000000..a5652a764d --- /dev/null +++ b/cpukit/include/rtems/regulatorimpl.h @@ -0,0 +1,135 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RegulatorInternalAPI + * + * @brief Regulator Library Implementation Support + */ + +/* + * Copyright (C) 2023 On-Line Applications Research Corporation (OAR) + * + * 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. + */ + +/** + * @defgroup RegulatorInternalAPI Regulator API Internals + * + * @brief Regulator Internal Information + * + * This concerns implementation information about the Regulator. + */ + +#ifndef RTEMS_REGULATORIMPL_H +#define RTEMS_REGULATORIMPL_H + +#include <stdatomic.h> + +#include <rtems/chain.h> + + +/** + * @ingroup RegulatorInternalAPI + * + * This constant is used to indicate the regulator instance is initialized. + */ +#define REGULATOR_INITIALIZED 0xDeadF00d + +/** + * @ingroup RegulatorInternalAPI + * + * @brief Regulator Message Instance Management Structure + */ +typedef struct { + /** This points to the message contents. */ + void *buffer; + /** This is the length of the message. */ + size_t length; +} _Regulator_Message_t; + +/** + * @ingroup RegulatorInternalAPI + * + * @brief Regulator Statistics Private Structure + * + * An instance of this structure is allocated per regulator instance. + */ +typedef struct { + /** Number of successfully obtained buffers. */ + atomic_size_t obtained; + + /** Number of successfully released buffers. */ + atomic_size_t released; + + /** Number of successfully delivered buffers. */ + atomic_size_t delivered; +} _Regulator_Statistics; + +/** + * @ingroup RegulatorInternalAPI + * + * @brief Regulator Instance Private Structure + * + * An instance of this structure is allocated per regulator instance. + */ +typedef struct { + /** Has magic value when instance is usable */ + uint32_t initialized; + + /** Attributes for this instance -- copied from user */ + rtems_regulator_attributes Attributes; + + /** Pointer to allocated message memory */ + void *message_memory; + + /** Pointer to allocated memory for RTEMS Message Queue for pending buffers*/ + void *message_queue_storage; + + /** RTEMS Message Queue of pending outgoing messages */ + rtems_id queue_id; + + /** RTEMS Partition for pool of unused messages */ + rtems_id messages_partition_id; + + /** RTEMS Task for performing output */ + rtems_id delivery_thread_id; + + /** Id of period used by output thread */ + rtems_id delivery_thread_period_id; + + /** Indicates Delivery thread is running */ + bool delivery_thread_is_running; + + /** Indicates Delivery thread has been requested to exit */ + bool delivery_thread_request_exit; + + /** Indicates Delivery thread has exited */ + bool delivery_thread_has_exited; + + /** Internal Statistics */ + _Regulator_Statistics Statistics; + +} _Regulator_Control; + +#endif /* RTEMS_REGULATORIMPL_H */ diff --git a/cpukit/include/rtems/rfs/rtems-rfs-bitmaps.h b/cpukit/include/rtems/rfs/rtems-rfs-bitmaps.h index 5574339421..bc7be4fcee 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-bitmaps.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-bitmaps.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -16,9 +18,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ diff --git a/cpukit/include/rtems/rfs/rtems-rfs-block-pos.h b/cpukit/include/rtems/rfs/rtems-rfs-block-pos.h index 7d0f0693be..1539ba194c 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-block-pos.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-block-pos.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -21,9 +23,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined (_RTEMS_RFS_BLOCK_POS_H_) diff --git a/cpukit/include/rtems/rfs/rtems-rfs-block.h b/cpukit/include/rtems/rfs/rtems-rfs-block.h index 394853b7ad..36055de0f1 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-block.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-block.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ diff --git a/cpukit/include/rtems/rfs/rtems-rfs-buffer.h b/cpukit/include/rtems/rfs/rtems-rfs-buffer.h index 1c603e1827..3a5f83fe2c 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-buffer.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-buffer.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ diff --git a/cpukit/include/rtems/rfs/rtems-rfs-data.h b/cpukit/include/rtems/rfs/rtems-rfs-data.h index 6217e74587..6b8bfc1e50 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-data.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-data.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -16,9 +18,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ diff --git a/cpukit/include/rtems/rfs/rtems-rfs-dir-hash.h b/cpukit/include/rtems/rfs/rtems-rfs-dir-hash.h index 7855c874b6..ca2a31edb0 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-dir-hash.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-dir-hash.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined (_RTEMS_RFS_DIR_HASH_H_) diff --git a/cpukit/include/rtems/rfs/rtems-rfs-dir.h b/cpukit/include/rtems/rfs/rtems-rfs-dir.h index ae3647d03c..0ba32fdb42 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-dir.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-dir.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined (_RTEMS_RFS_DIR_H_) diff --git a/cpukit/include/rtems/rfs/rtems-rfs-file-system-fwd.h b/cpukit/include/rtems/rfs/rtems-rfs-file-system-fwd.h index e239c25d6f..004bc82e23 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-file-system-fwd.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-file-system-fwd.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ diff --git a/cpukit/include/rtems/rfs/rtems-rfs-file-system.h b/cpukit/include/rtems/rfs/rtems-rfs-file-system.h index e00b142532..67a53f3d48 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-file-system.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-file-system.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined (_RTEMS_RFS_FILE_SYSTEM_H_) diff --git a/cpukit/include/rtems/rfs/rtems-rfs-file.h b/cpukit/include/rtems/rfs/rtems-rfs-file.h index 772e846143..82376fcc38 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-file.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-file.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined (_RTEMS_RFS_FILE_H_) diff --git a/cpukit/include/rtems/rfs/rtems-rfs-group.h b/cpukit/include/rtems/rfs/rtems-rfs-group.h index 23e6434b2c..707fa5c3ff 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-group.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-group.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ diff --git a/cpukit/include/rtems/rfs/rtems-rfs-inode.h b/cpukit/include/rtems/rfs/rtems-rfs-inode.h index 95861ea8a7..f39c664f42 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-inode.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-inode.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ diff --git a/cpukit/include/rtems/rfs/rtems-rfs-link.h b/cpukit/include/rtems/rfs/rtems-rfs-link.h index d30814aaff..0812258391 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-link.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-link.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ diff --git a/cpukit/include/rtems/rfs/rtems-rfs-mutex.h b/cpukit/include/rtems/rfs/rtems-rfs-mutex.h index 57b58e507e..c52a1b9f1b 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-mutex.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-mutex.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -14,9 +16,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined (_RTEMS_RFS_MUTEX_H_) diff --git a/cpukit/include/rtems/rfs/rtems-rfs-trace.h b/cpukit/include/rtems/rfs/rtems-rfs-trace.h index 4d6d0c9ddb..0697a42414 100644 --- a/cpukit/include/rtems/rfs/rtems-rfs-trace.h +++ b/cpukit/include/rtems/rfs/rtems-rfs-trace.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -14,9 +16,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ diff --git a/cpukit/include/rtems/ringbuf.h b/cpukit/include/rtems/ringbuf.h index c16a79d1ae..611c7380b3 100644 --- a/cpukit/include/rtems/ringbuf.h +++ b/cpukit/include/rtems/ringbuf.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -6,6 +8,30 @@ * This file provides simple ring buffer functionality. */ +/* + * COPYRIGHT (C) 1989-1999 On-Line Applications Research Corporation (OAR). + * + * 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. + */ #ifndef _RTEMS_RINGBUF_H #define _RTEMS_RINGBUF_H diff --git a/cpukit/include/rtems/rtc.h b/cpukit/include/rtems/rtc.h index 9906acd425..5d37ea4289 100644 --- a/cpukit/include/rtems/rtc.h +++ b/cpukit/include/rtems/rtc.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ * COPYRIGHT (c) 1989-2001. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTC_H diff --git a/cpukit/include/rtems/rtems-debugger.h b/cpukit/include/rtems/rtems-debugger.h index 1fc8b3d522..7627e83382 100644 --- a/cpukit/include/rtems/rtems-debugger.h +++ b/cpukit/include/rtems/rtems-debugger.h @@ -54,6 +54,14 @@ extern int rtems_debugger_start(const char* remote, const rtems_printer* printer); /** + * Suspend all running threads including the caller if not + * excluded. Returns when the debugger has connected and continued. + * + * If wait is true and there is no remote connected wait then break. + */ +extern int rtems_debugger_break(bool wait); + +/** * Stop the Debugger. */ extern int rtems_debugger_stop(void); diff --git a/cpukit/include/rtems/rtems-fdt-shell.h b/cpukit/include/rtems/rtems-fdt-shell.h index 74e9a44aaf..a4c87552b0 100644 --- a/cpukit/include/rtems/rtems-fdt-shell.h +++ b/cpukit/include/rtems/rtems-fdt-shell.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2013-2017 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtems-fdt.h b/cpukit/include/rtems/rtems-fdt.h index ebc222e4c9..e3ebfe3ba4 100644 --- a/cpukit/include/rtems/rtems-fdt.h +++ b/cpukit/include/rtems/rtems-fdt.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2013-2017 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. * * Interface based on the libdft: * libfdt - Flat Device Tree manipulation @@ -45,6 +64,21 @@ typedef struct rtems_fdt_blob* blob; /**< The blob the handle references. */ } rtems_fdt_handle; +/** + * FDT Address property. It is an address an optionally a size. + * + * Only 32bit addresses and sizes on 32bit machine. Ignore the upper + * 32bits. + */ +typedef struct +{ + int node; + uint64_t address; + uint64_t size; + int address_cells; + int size_cells; +} rtems_fdt_address_map; + /* * The following are mappings to the standard FDT calls. */ @@ -146,9 +180,13 @@ typedef struct * The blob cannot be unloaded as it is referenced. */ #define RTEMS_FDT_ERR_REFERENCED 104 +/** + * The property length is invalid + */ +#define RTEMS_FDT_ERR_BADLENGTH 105 #define RTEMS_FDT_ERR_RTEMS_MIN 100 -#define RTEMS_FDT_ERR_MAX 104 +#define RTEMS_FDT_ERR_MAX 105 /** * Initialise a handle to a default state. @@ -218,7 +256,7 @@ int rtems_fdt_register (const void* blob, rtems_fdt_handle* handle); /** * Unload a device tree blob or DTB file and release any memory allocated when - * loading. The blob is removed from the list of registered. + * loading. The blob is removed from the list if registered. * * @param blob_desc A valid blob descriptor. * @return int If less than 0 it is an error code else 0 is return on success. @@ -258,7 +296,7 @@ int rtems_fdt_get_mem_rsv (rtems_fdt_handle* handle, * larger string, such as a full path. * * @param blob_desc A valid blob descriptor. - * @param arentoffset Structure block offset of a node + * @param parentoffset Structure block offset of a node * @param name Name of the subnode to locate. * @param namelen Number of characters of name to consider. * @return int If less than 0 it is an error code else the node offset is @@ -307,7 +345,9 @@ int rtems_fdt_path_offset (rtems_fdt_handle* handle, const char* path); * * @param handle The FDT handle to the current blob. * @param nodeoffset Structure block offset of the starting node. - * @param length Pointer to an integer variable (will be overwritten) or NULL. + * @param length Pointer to an integer variable or NULL. If non-NULL, this will + * be overwritten with either the length in bytes or the error + * code. * @return const char* The node's name on success or NULL on error. The length * if non-NULL will hold the error code. */ @@ -316,6 +356,41 @@ const char* rtems_fdt_get_name (rtems_fdt_handle* handle, int* length); /** + * Retrieve the offset for the first property for a node. + * + * @param handle The FDT handle to the current blob. + * @param nodeoffset Structure block offset of the starting node. + * @return int The offset of a node's first property. + */ +int rtems_fdt_first_prop_offset(rtems_fdt_handle* handle, int nodeoffset); + +/** + * Retrieve the next property of a node relative to the property + * + * @param handle The FDT handle to the current blob. + * @param propoffset Property offset to search from + * @return int Property offset or end if less than 0. + */ +int rtems_fdt_next_prop_offset(rtems_fdt_handle* handle, int propoffset); + +/** + * Retrieve the property value, name and length of name given a + * property offset. + * + * @param handle The FDT handle to the current blob. + * @param propoffset Property offset + * @param name If not NULL set the pointer to the name string. + * @param length Pointer to an integer variable or NULL. If non-NULL, this will + * be overwritten with either the length in bytes or the error + * code. + * @return const void* The node's value data. + */ +const void* rtems_fdt_getprop_by_offset(rtems_fdt_handle* handle, + int propoffset, + const char** name, + int* length); + +/** * Get property value based on substring. Identical to rtems_fdt_getprop(), but * only examine the first namelen characters of name for matching the property * name. @@ -324,8 +399,9 @@ const char* rtems_fdt_get_name (rtems_fdt_handle* handle, * @param nodeoffset Offset of the node whose property to find * @param name The name of the property to find * @param namelen The number of characters of name to consider - * @param length A pointer to an integer variable (will be overwritten) or - * NULL. + * @param length Pointer to an integer variable or NULL. If non-NULL, this will + * be overwritten with either the length in bytes or the error + * code. * @return const void* The node's property on success or NULL on error. The * length if non-NULL will hold the error code. */ @@ -345,8 +421,9 @@ const void *rtems_fdt_getprop_namelen (rtems_fdt_handle* handle, * @param handle The FDT handle to the current blob. * @param nodeoffset The offset of the node whose property to find. * @param name The name of the property to find. - * @param length A pointer to an integer variable (will be overwritten) or - * NULL. + * @param length Pointer to an integer variable or NULL. If non-NULL, this will + * be overwritten with either the length in bytes or the error + * code. * @return const void* The node's property on success or NULL on error. The * length if non-NULL will hold the error code. */ @@ -356,7 +433,7 @@ const void *rtems_fdt_getprop (rtems_fdt_handle* handle, int* length); /** - * Retrieve the phandle of a given of the device tree node at structure block + * Retrieve the phandle of the device tree node at structure block * offset nodeoffset. * * @param handle The FDT handle to the current blob. @@ -567,6 +644,14 @@ int rtems_fdt_next_node (rtems_fdt_handle* handle, int offset, int* depth); const char* rtems_fdt_strerror (int errval); /** + * Return a parent property given a node offset. Travel up until found + * or the root node is reached + */ +bool rtems_fdt_get_parent_prop_value(rtems_fdt_handle* handle, + int nodeoffset, + const char* name, + uint32_t* value); +/** * Return a property given a path. */ int rtems_fdt_prop_value(const char* const path, @@ -581,7 +666,7 @@ int rtems_fdt_prop_value(const char* const path, int rtems_fdt_prop_map (const char* const path, const char* const propname, const char* const names[], - uint32_t* values, + uintptr_t* values, size_t count); /* @@ -590,7 +675,7 @@ int rtems_fdt_prop_map (const char* const path, int rtems_fdt_get_value (const char* const path, const char* const property, size_t size, - uint32_t* value); + uintptr_t* value); /** * Get the number of entries in an FDT handle. @@ -610,9 +695,46 @@ const char *rtems_fdt_entry_name(rtems_fdt_handle* handle, int id); int rtems_fdt_entry_offset(rtems_fdt_handle* handle, int id); /* + * Helper function to convert the void* property result of unknown + * length to an unsigned int pointer value. + */ +uintptr_t rtems_fdt_get_offset_len_uintptr(const void* prop, int offset, int len); + +/* * Helper function to convert the void* property result to a 32bit unsigned int. */ -uint32_t rtems_fdt_get_uint32 (const void* prop); +uint32_t rtems_fdt_get_uint32(const void* prop); +uint32_t rtems_fdt_get_offset_uint32(const void* prop, int offset); + +/* + * Helper function to convert the void* property result to a 64bit unsigned int. + */ +uint64_t rtems_fdt_get_uint64(const void* prop); +uint64_t rtems_fdt_get_offset_uint64(const void* prop, int offset); + +/* + * Helper function to convert the void* property result to a uintptr_t + */ +uintptr_t rtems_fdt_get_uintptr(const void* prop); +uintptr_t rtems_fdt_get_offset_uintptr(const void* prop, int offset); + +/* + * Find the address cells property in parent nodes. + */ +int rtems_fdt_getprop_address_cells(rtems_fdt_handle* handle, int nodeoffset); + +/* + * Find the size cells property in parent nodes. + */ +int rtems_fdt_getprop_size_cells(rtems_fdt_handle* handle, int nodeoffset); + +/* + * Get an address space property. + */ +int rtems_fdt_getprop_address_map(rtems_fdt_handle* handle, + const char* path, + const char* name, + rtems_fdt_address_map* addr_map); #ifdef __cplusplus } diff --git a/cpukit/include/rtems/rtems-rfs-format.h b/cpukit/include/rtems/rtems-rfs-format.h index f65cce1789..483bb00397 100644 --- a/cpukit/include/rtems/rtems-rfs-format.h +++ b/cpukit/include/rtems/rtems-rfs-format.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined (_RTEMS_RFS_FORMAT_H_) diff --git a/cpukit/include/rtems/rtems-rfs-shell.h b/cpukit/include/rtems/rtems-rfs-shell.h index c2e1108a47..be61ac7d47 100644 --- a/cpukit/include/rtems/rtems-rfs-shell.h +++ b/cpukit/include/rtems/rtems-rfs-shell.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined (_RTEMS_RFS_SHELL_H_) diff --git a/cpukit/include/rtems/rtems-rfs.h b/cpukit/include/rtems/rtems-rfs.h index f0e76cf25c..9d96fc7364 100644 --- a/cpukit/include/rtems/rtems-rfs.h +++ b/cpukit/include/rtems/rtems-rfs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ /* * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined(RTEMS_RFS_DEFINED) diff --git a/cpukit/include/rtems/rtems/asr.h b/cpukit/include/rtems/rtems/asr.h index f58d60790d..1d3ba5fe4f 100644 --- a/cpukit/include/rtems/rtems/asr.h +++ b/cpukit/include/rtems/rtems/asr.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassicSignal + * * @brief This header file defines the parts of the Signal Manager API. */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/rtems/asrdata.h b/cpukit/include/rtems/rtems/asrdata.h index 924e616a9a..1a02a20ce5 100644 --- a/cpukit/include/rtems/rtems/asrdata.h +++ b/cpukit/include/rtems/rtems/asrdata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_ASRDATA_H diff --git a/cpukit/include/rtems/rtems/attr.h b/cpukit/include/rtems/rtems/attr.h index 24b49247ee..708be99b2d 100644 --- a/cpukit/include/rtems/rtems/attr.h +++ b/cpukit/include/rtems/rtems/attr.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2014, 2020 embedded brains GmbH & Co. KG * Copyright (C) 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/rtems/attrimpl.h b/cpukit/include/rtems/rtems/attrimpl.h index a41b3ad89b..e5ac35c26a 100644 --- a/cpukit/include/rtems/rtems/attrimpl.h +++ b/cpukit/include/rtems/rtems/attrimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_ATTR_INL @@ -61,7 +80,7 @@ extern "C" { * This function sets the requested new_attributes in the attribute_set * passed in. The result is returned to the user. */ -RTEMS_INLINE_ROUTINE rtems_attribute _Attributes_Set ( +static inline rtems_attribute _Attributes_Set ( rtems_attribute new_attributes, rtems_attribute attribute_set ) @@ -76,7 +95,7 @@ RTEMS_INLINE_ROUTINE rtems_attribute _Attributes_Set ( * This function clears the requested new_attributes in the attribute_set * passed in. The result is returned to the user. */ -RTEMS_INLINE_ROUTINE rtems_attribute _Attributes_Clear ( +static inline rtems_attribute _Attributes_Clear ( rtems_attribute attribute_set, rtems_attribute mask ) @@ -91,7 +110,7 @@ RTEMS_INLINE_ROUTINE rtems_attribute _Attributes_Clear ( * This function returns TRUE if the floating point attribute is * enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_floating_point( +static inline bool _Attributes_Is_floating_point( rtems_attribute attribute_set ) { @@ -106,7 +125,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_floating_point( * This function returns TRUE if the global object attribute is * enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_global( +static inline bool _Attributes_Is_global( rtems_attribute attribute_set ) { @@ -120,7 +139,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_global( * This function returns TRUE if the priority attribute is * enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_priority( +static inline bool _Attributes_Is_priority( rtems_attribute attribute_set ) { @@ -134,7 +153,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_priority( * This function returns TRUE if the binary semaphore attribute is * enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_binary_semaphore( +static inline bool _Attributes_Is_binary_semaphore( rtems_attribute attribute_set ) { @@ -148,7 +167,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_binary_semaphore( * This function returns TRUE if the simple binary semaphore attribute is * enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_simple_binary_semaphore( +static inline bool _Attributes_Is_simple_binary_semaphore( rtems_attribute attribute_set ) { @@ -163,7 +182,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_simple_binary_semaphore( * This function returns TRUE if the counting semaphore attribute is * enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_counting_semaphore( +static inline bool _Attributes_Is_counting_semaphore( rtems_attribute attribute_set ) { @@ -177,7 +196,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_counting_semaphore( * This function returns TRUE if the priority inheritance attribute * is enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_inherit_priority( +static inline bool _Attributes_Is_inherit_priority( rtems_attribute attribute_set ) { @@ -191,7 +210,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_inherit_priority( * The protocols are RTEMS_INHERIT_PRIORITY, RTEMS_PRIORITY_CEILING and * RTEMS_MULTIPROCESSOR_RESOURCE_SHARING. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Has_at_most_one_protocol( +static inline bool _Attributes_Has_at_most_one_protocol( rtems_attribute attribute_set ) { @@ -208,7 +227,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Has_at_most_one_protocol( * This function returns TRUE if the priority ceiling attribute * is enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_priority_ceiling( +static inline bool _Attributes_Is_priority_ceiling( rtems_attribute attribute_set ) { @@ -222,7 +241,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_priority_ceiling( * This function returns TRUE if the Multiprocessor Resource Sharing Protocol * attribute is enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_multiprocessor_resource_sharing( +static inline bool _Attributes_Is_multiprocessor_resource_sharing( rtems_attribute attribute_set ) { @@ -236,7 +255,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_multiprocessor_resource_sharing( * This function returns TRUE if the barrier automatic release * attribute is enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_barrier_automatic( +static inline bool _Attributes_Is_barrier_automatic( rtems_attribute attribute_set ) { @@ -250,7 +269,7 @@ RTEMS_INLINE_ROUTINE bool _Attributes_Is_barrier_automatic( * This function returns TRUE if the system task attribute * is enabled in the attribute_set and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_system_task( +static inline bool _Attributes_Is_system_task( rtems_attribute attribute_set ) { diff --git a/cpukit/include/rtems/rtems/barrier.h b/cpukit/include/rtems/rtems/barrier.h index 348610d886..029cffb406 100644 --- a/cpukit/include/rtems/rtems/barrier.h +++ b/cpukit/include/rtems/rtems/barrier.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -137,7 +137,7 @@ extern "C" { * * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a * barrier. The number of barriers available to the application is - * configured through the #CONFIGURE_MAXIMUM_BARRIERS application + * configured through the @ref CONFIGURE_MAXIMUM_BARRIERS application * configuration option. * * @par Notes @@ -157,7 +157,7 @@ extern "C" { * cause the calling task to be preempted. * * * The number of barriers available to the application is configured through - * the #CONFIGURE_MAXIMUM_BARRIERS application configuration option. + * the @ref CONFIGURE_MAXIMUM_BARRIERS application configuration option. * * * Where the object class corresponding to the directive is configured to use * unlimited objects, the directive may allocate memory from the RTEMS diff --git a/cpukit/include/rtems/rtems/barrierdata.h b/cpukit/include/rtems/rtems/barrierdata.h index b449186a59..b963d08603 100644 --- a/cpukit/include/rtems/rtems/barrierdata.h +++ b/cpukit/include/rtems/rtems/barrierdata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_BARRIERDATA_H diff --git a/cpukit/include/rtems/rtems/barrierimpl.h b/cpukit/include/rtems/rtems/barrierimpl.h index 5f96273f89..88228b64f9 100644 --- a/cpukit/include/rtems/rtems/barrierimpl.h +++ b/cpukit/include/rtems/rtems/barrierimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_BARRIERIMPL_H @@ -43,7 +62,7 @@ extern "C" { * This function allocates a barrier control block from * the inactive chain of free barrier control blocks. */ -RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Allocate( void ) +static inline Barrier_Control *_Barrier_Allocate( void ) { return (Barrier_Control *) _Objects_Allocate( &_Barrier_Information ); } @@ -54,7 +73,7 @@ RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Allocate( void ) * This routine frees a barrier control block to the * inactive chain of free barrier control blocks. */ -RTEMS_INLINE_ROUTINE void _Barrier_Free ( +static inline void _Barrier_Free ( Barrier_Control *the_barrier ) { @@ -62,7 +81,7 @@ RTEMS_INLINE_ROUTINE void _Barrier_Free ( _Objects_Free( &_Barrier_Information, &the_barrier->Object ); } -RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Get( +static inline Barrier_Control *_Barrier_Get( Objects_Id id, Thread_queue_Context *queue_context ) diff --git a/cpukit/include/rtems/rtems/cache.h b/cpukit/include/rtems/rtems/cache.h index c7c19b80e2..d59a3fddca 100644 --- a/cpukit/include/rtems/rtems/cache.h +++ b/cpukit/include/rtems/rtems/cache.h @@ -3,12 +3,14 @@ /** * @file * + * @ingroup RTEMSImplClassicCache + * * @brief This header file defines the Cache Manager API. */ /* * Copyright (C) 2016 Pavel Pisa - * Copyright (C) 2014, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2014, 2021 embedded brains GmbH & Co. KG * Copyright (C) 2000, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -57,6 +59,7 @@ #include <stddef.h> #include <stdint.h> +#include <rtems/rtems/status.h> #ifdef __cplusplus extern "C" { @@ -87,6 +90,10 @@ extern "C" { * * @param size is the size in bytes of the cache coherent memory area to add. * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_UNSATISFIED The requested operation was not successful. + * * @par Constraints * @parblock * The following constraints apply to this directive: @@ -100,7 +107,7 @@ extern "C" { * cause the calling task to be preempted. * @endparblock */ -void rtems_cache_coherent_add_area( void *begin, uintptr_t size ); +rtems_status_code rtems_cache_coherent_add_area( void *begin, uintptr_t size ); /* Generated from spec:/rtems/cache/if/coherent-allocate */ diff --git a/cpukit/include/rtems/rtems/clock.h b/cpukit/include/rtems/rtems/clock.h index e158b18947..5a8d0a44f9 100644 --- a/cpukit/include/rtems/rtems/clock.h +++ b/cpukit/include/rtems/rtems/clock.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2014, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2014, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -81,6 +81,11 @@ extern "C" { * related capabilities. */ +/* Generated from spec:/rtems/clock/if/bintime */ + +/* Forward declaration */ +struct bintime; + /* Generated from spec:/rtems/clock/if/set */ /** @@ -111,8 +116,8 @@ extern "C" { * before 2100-01-01:00:00.000000000Z. The latest valid time of day accepted * by the POSIX clock_settime() is 2400-01-01T00:00:00.999999999Z. * - * The specified time is based on the configured clock tick rate, see the - * #CONFIGURE_MICROSECONDS_PER_TICK application configuration option. + * The specified time is based on the configured clock tick rate, see the @ref + * CONFIGURE_MICROSECONDS_PER_TICK application configuration option. * * Setting the time forward will fire all CLOCK_REALTIME timers which are * scheduled at a time point before or at the time set by the directive. This @@ -213,6 +218,593 @@ rtems_status_code rtems_clock_get_tod( rtems_time_of_day *time_of_day ); */ rtems_status_code rtems_clock_get_tod_timeval( struct timeval *time_of_day ); +/* Generated from spec:/rtems/clock/if/get-realtime */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since the Unix epoch measured using + * CLOCK_REALTIME in seconds and nanoseconds format. + * + * @param[out] time_snapshot is the pointer to a struct timespec object. The + * time elapsed since the Unix epoch measured using the CLOCK_REALTIME at + * some time point during the directive call will be stored in this object. + * Calling the directive with a pointer equal to NULL is undefined behaviour. + * + * @par Notes + * @parblock + * The directive accesses a device provided by the Clock Driver to get the time + * in the highest resolution available to the system. Alternatively, the + * rtems_clock_get_realtime_coarse() directive may be used to get the time in a + * lower resolution and with less runtime overhead. + * + * See rtems_clock_get_realtime_bintime() and + * rtems_clock_get_realtime_timeval() to get the time in alternative formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_realtime( struct timespec *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-realtime-bintime */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since the Unix epoch measured using + * CLOCK_REALTIME in binary time format. + * + * @param[out] time_snapshot is the pointer to a bintime object. The time + * elapsed since the Unix epoch measured using the CLOCK_REALTIME at some + * time point during the directive call will be stored in this object. + * Calling the directive with a pointer equal to NULL is undefined behaviour. + * + * @par Notes + * @parblock + * The directive accesses a device provided by the Clock Driver to get the time + * in the highest resolution available to the system. Alternatively, the + * rtems_clock_get_realtime_coarse_bintime() directive may be used to get the + * time in a lower resolution and with less runtime overhead. + * + * See rtems_clock_get_realtime() and rtems_clock_get_realtime_timeval() to get + * the time in alternative formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_realtime_bintime( struct bintime *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-realtime-timeval */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since the Unix epoch measured using + * CLOCK_REALTIME in seconds and microseconds format. + * + * @param[out] time_snapshot is the pointer to a struct timeval object. The + * time elapsed since the Unix epoch measured using the CLOCK_REALTIME at + * some time point during the directive call will be stored in this object. + * Calling the directive with a pointer equal to NULL is undefined behaviour. + * + * @par Notes + * @parblock + * The directive accesses a device provided by the Clock Driver to get the time + * in the highest resolution available to the system. Alternatively, the + * rtems_clock_get_realtime_coarse_timeval() directive may be used to get the + * time in a lower resolution and with less runtime overhead. + * + * See rtems_clock_get_realtime() and rtems_clock_get_realtime_bintime() to get + * the time in alternative formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_realtime_timeval( struct timeval *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-realtime-coarse */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since the Unix epoch measured using + * CLOCK_REALTIME in coarse resolution in seconds and nanoseconds format. + * + * @param[out] time_snapshot is the pointer to a struct timespec object. The + * time elapsed since the Unix epoch measured using the CLOCK_REALTIME at + * some time point close to the directive call will be stored in this object. + * Calling the directive with a pointer equal to NULL is undefined behaviour. + * + * @par Notes + * @parblock + * The directive does not access a device to get the time. It uses a recent + * snapshot provided by the Clock Driver. Alternatively, the + * rtems_clock_get_realtime() directive may be used to get the time in a higher + * resolution and with a higher runtime overhead. + * + * See rtems_clock_get_realtime_coarse_bintime() and + * rtems_clock_get_realtime_coarse_timeval() to get the time in alternative + * formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_realtime_coarse( struct timespec *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-realtime-coarse-bintime */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since the Unix epoch measured using + * CLOCK_REALTIME in coarse resolution in binary time format. + * + * @param[out] time_snapshot is the pointer to a bintime object. The time + * elapsed since the Unix epoch measured using the CLOCK_REALTIME at some + * time point close to the directive call will be stored in this object. + * Calling the directive with a pointer equal to NULL is undefined behaviour. + * + * @par Notes + * @parblock + * The directive does not access a device to get the time. It uses a recent + * snapshot provided by the Clock Driver. Alternatively, the + * rtems_clock_get_realtime_bintime() directive may be used to get the time in + * a higher resolution and with a higher runtime overhead. + * + * See rtems_clock_get_realtime_coarse() and + * rtems_clock_get_realtime_coarse_timeval() to get the time in alternative + * formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_realtime_coarse_bintime( struct bintime *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-realtime-coarse-timeval */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since the Unix epoch measured using + * CLOCK_REALTIME in coarse resolution in seconds and microseconds format. + * + * @param[out] time_snapshot is the pointer to a struct timeval object. The + * time elapsed since the Unix epoch measured using the CLOCK_REALTIME at + * some time point close to the directive call will be stored in this object. + * Calling the directive with a pointer equal to NULL is undefined behaviour. + * + * @par Notes + * @parblock + * The directive does not access a device to get the time. It uses a recent + * snapshot provided by the Clock Driver. Alternatively, the + * rtems_clock_get_realtime_timeval() directive may be used to get the time in + * a higher resolution and with a higher runtime overhead. + * + * See rtems_clock_get_realtime_coarse() and + * rtems_clock_get_realtime_coarse_timeval() to get the time in alternative + * formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_realtime_coarse_timeval( struct timeval *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-monotonic */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since some fixed time point in the past + * measured using the CLOCK_MONOTONIC in seconds and nanoseconds format. + * + * @param[out] time_snapshot is the pointer to a struct timespec object. The + * time elapsed since some fixed time point in the past measured using the + * CLOCK_MONOTONIC at some time point during the directive call will be + * stored in this object. Calling the directive with a pointer equal to NULL + * is undefined behaviour. + * + * @par Notes + * @parblock + * The directive accesses a device provided by the Clock Driver to get the time + * in the highest resolution available to the system. Alternatively, the + * rtems_clock_get_monotonic_coarse() directive may be used to get the time + * with in a lower resolution and with less runtime overhead. + * + * See rtems_clock_get_monotonic_bintime(), + * rtems_clock_get_monotonic_sbintime(), and + * rtems_clock_get_monotonic_timeval() to get the time in alternative formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_monotonic( struct timespec *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-monotonic-bintime */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since some fixed time point in the past + * measured using the CLOCK_MONOTONIC in binary time format. + * + * @param[out] time_snapshot is the pointer to a bintime object. The time + * elapsed since some fixed time point in the past measured using the + * CLOCK_MONOTONIC at some time point during the directive call will be + * stored in this object. Calling the directive with a pointer equal to NULL + * is undefined behaviour. + * + * @par Notes + * @parblock + * The directive accesses a device provided by the Clock Driver to get the time + * in the highest resolution available to the system. Alternatively, the + * rtems_clock_get_monotonic_coarse_bintime() directive may be used to get the + * time in a lower resolution and with less runtime overhead. + * + * See rtems_clock_get_monotonic(), rtems_clock_get_monotonic_sbintime(), and + * rtems_clock_get_monotonic_timeval() to get the time in alternative formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_monotonic_bintime( struct bintime *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-monotonic-sbintime */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since some fixed time point in the past + * measured using the CLOCK_MONOTONIC in signed binary time format. + * + * @return Returns the time elapsed since some fixed time point in the past + * measured using the CLOCK_MONOTONIC at some time point during the directive + * call. + * + * @par Notes + * @parblock + * The directive accesses a device provided by the Clock Driver to get the time + * in the highest resolution available to the system. + * + * See rtems_clock_get_monotonic(), rtems_clock_get_monotonic_bintime(), and + * rtems_clock_get_monotonic_timeval() to get the time in alternative formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +int64_t rtems_clock_get_monotonic_sbintime( void ); + +/* Generated from spec:/rtems/clock/if/get-monotonic-timeval */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since some fixed time point in the past + * measured using the CLOCK_MONOTONIC in seconds and microseconds format. + * + * @param[out] time_snapshot is the pointer to a struct timeval object. The + * time elapsed since some fixed time point in the past measured using the + * CLOCK_MONOTONIC at some time point during the directive call will be + * stored in this object. Calling the directive with a pointer equal to NULL + * is undefined behaviour. + * + * @par Notes + * @parblock + * The directive accesses a device provided by the Clock Driver to get the time + * in the highest resolution available to the system. Alternatively, the + * rtems_clock_get_monotonic_coarse_timeval() directive may be used to get the + * time in a lower resolution and with less runtime overhead. + * + * See rtems_clock_get_monotonic(), rtems_clock_get_monotonic_bintime(), and + * rtems_clock_get_monotonic_sbintime() to get the time in alternative formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_monotonic_timeval( struct timeval *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-monotonic-coarse */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since some fixed time point in the past + * measured using the CLOCK_MONOTONIC in coarse resolution in seconds and + * nanoseconds format. + * + * @param[out] time_snapshot is the pointer to a struct timespec object. The + * time elapsed since some fixed time point in the past measured using the + * CLOCK_MONOTONIC at some time point close to the directive call will be + * stored in this object. Calling the directive with a pointer equal to NULL + * is undefined behaviour. + * + * @par Notes + * @parblock + * The directive does not access a device to get the time. It uses a recent + * snapshot provided by the Clock Driver. Alternatively, the + * rtems_clock_get_monotonic() directive may be used to get the time in a + * higher resolution and with a higher runtime overhead. + * + * See rtems_clock_get_monotonic_coarse_bintime() and + * rtems_clock_get_monotonic_coarse_timeval() to get the time in alternative + * formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_monotonic_coarse( struct timespec *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-monotonic-coarse-bintime */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since some fixed time point in the past + * measured using the CLOCK_MONOTONIC in coarse resolution in binary time + * format. + * + * @param[out] time_snapshot is the pointer to a bintime object. The time + * elapsed since some fixed time point in the past measured using the + * CLOCK_MONOTONIC at some time point close to the directive call will be + * stored in this object. Calling the directive with a pointer equal to NULL + * is undefined behaviour. + * + * @par Notes + * @parblock + * The directive does not access a device to get the time. It uses a recent + * snapshot provided by the Clock Driver. Alternatively, the + * rtems_clock_get_monotonic_bintime() directive may be used to get the time in + * a higher resolution and with a higher runtime overhead. + * + * See rtems_clock_get_monotonic_coarse() and + * rtems_clock_get_monotonic_coarse_timeval() to get the time in alternative + * formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_monotonic_coarse_bintime( struct bintime *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-monotonic-coarse-timeval */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since some fixed time point in the past + * measured using the CLOCK_MONOTONIC in coarse resolution in seconds and + * microseconds format. + * + * @param[out] time_snapshot is the pointer to a struct timeval object. The + * time elapsed since some fixed time point in the past measured using the + * CLOCK_MONOTONIC at some time point close to the directive call will be + * stored in this object. Calling the directive with a pointer equal to NULL + * is undefined behaviour. + * + * @par Notes + * @parblock + * The directive does not access a device to get the time. It uses a recent + * snapshot provided by the Clock Driver. Alternatively, the + * rtems_clock_get_monotonic_timeval() directive may be used to get the time in + * a higher resolution and with a higher runtime overhead. + * + * See rtems_clock_get_monotonic_coarse() and + * rtems_clock_get_monotonic_coarse_bintime() to get the time in alternative + * formats. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_monotonic_coarse_timeval( struct timeval *time_snapshot ); + +/* Generated from spec:/rtems/clock/if/get-boot-time */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since the Unix epoch at some time point during + * system initialization in seconds and nanoseconds format. + * + * @param[out] boot_time is the pointer to a struct timespec object. The time + * elapsed since the Unix epoch at some time point during system + * initialization call will be stored in this object. Calling the directive + * with a pointer equal to NULL is undefined behaviour. + * + * @par Notes + * See rtems_clock_get_boot_time_bintime() and + * rtems_clock_get_boot_time_timeval() to get the boot time in alternative + * formats. Setting the CLOCK_REALTIME will also set the boot time. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_boot_time( struct timespec *boot_time ); + +/* Generated from spec:/rtems/clock/if/get-boot-time-bintime */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since the Unix epoch at some time point during + * system initialization in binary time format. + * + * @param[out] boot_time is the pointer to a bintime object. The time elapsed + * since the Unix epoch at some time point during system initialization call + * will be stored in this object. Calling the directive with a pointer equal + * to NULL is undefined behaviour. + * + * @par Notes + * See rtems_clock_get_boot_time() and rtems_clock_get_boot_time_timeval() to + * get the boot time in alternative formats. Setting the CLOCK_REALTIME will + * also set the boot time. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_boot_time_bintime( struct bintime *boot_time ); + +/* Generated from spec:/rtems/clock/if/get-boot-time-timeval */ + +/** + * @ingroup RTEMSAPIClassicClock + * + * @brief Gets the time elapsed since the Unix epoch at some time point during + * system initialization in seconds and microseconds format. + * + * @param[out] boot_time is the pointer to a struct timeval object. The time + * elapsed since the Unix epoch at some time point during system + * initialization call will be stored in this object. Calling the directive + * with a pointer equal to NULL is undefined behaviour. + * + * @par Notes + * See rtems_clock_get_boot_time() and rtems_clock_get_boot_time_bintime() to + * get the boot time in alternative formats. Setting the CLOCK_REALTIME will + * also set the boot time. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The directive requires a Clock Driver. + * @endparblock + */ +void rtems_clock_get_boot_time_timeval( struct timeval *boot_time ); + /* Generated from spec:/rtems/clock/if/get-seconds-since-epoch */ /** @@ -261,8 +853,8 @@ rtems_status_code rtems_clock_get_seconds_since_epoch( * application. * * @par Notes - * The number of clock ticks per second is defined indirectly by the - * #CONFIGURE_MICROSECONDS_PER_TICK configuration option. + * The number of clock ticks per second is defined indirectly by the @ref + * CONFIGURE_MICROSECONDS_PER_TICK configuration option. * * @par Constraints * @parblock @@ -317,7 +909,7 @@ rtems_interval rtems_clock_get_ticks_since_boot( void ); * @brief Gets the seconds and nanoseconds elapsed since some time point during * the system initialization using CLOCK_MONOTONIC. * - * @param[out] uptime is the pointer to a struct timeval object. When the + * @param[out] uptime is the pointer to a struct timespec object. When the * directive call is successful, the seconds and nanoseconds elapsed since * some time point during the system initialization and some point during the * directive call using CLOCK_MONOTONIC will be stored in this object. @@ -543,6 +1135,18 @@ static inline bool rtems_clock_tick_before( rtems_interval ticks ) * @par Notes * The directive is a legacy interface. It should not be called by * applications directly. A Clock Driver may call this directive. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * @endparblock */ rtems_status_code rtems_clock_tick( void ); diff --git a/cpukit/include/rtems/rtems/clockimpl.h b/cpukit/include/rtems/rtems/clockimpl.h index c8334afaf3..c025ea9c9a 100644 --- a/cpukit/include/rtems/rtems/clockimpl.h +++ b/cpukit/include/rtems/rtems/clockimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_CLOCKIMPL_H diff --git a/cpukit/include/rtems/rtems/config.h b/cpukit/include/rtems/rtems/config.h index 2a12c8f3cb..d225902bf1 100644 --- a/cpukit/include/rtems/rtems/config.h +++ b/cpukit/include/rtems/rtems/config.h @@ -3,12 +3,14 @@ /** * @file * + * @ingroup RTEMSImplClassic + * * @brief This header file provides parts of the application configuration * information API. */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * Copyright (C) 1989, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -78,7 +80,7 @@ typedef struct { * @brief This member contains the maximum number of Classic API Tasks * configured for this application. * - * See #CONFIGURE_MAXIMUM_TASKS. + * See @ref CONFIGURE_MAXIMUM_TASKS. */ uint32_t maximum_tasks; @@ -92,7 +94,7 @@ typedef struct { * @brief This member contains the maximum number of Classic API Timers * configured for this application. * - * See #CONFIGURE_MAXIMUM_TIMERS. + * See @ref CONFIGURE_MAXIMUM_TIMERS. */ uint32_t maximum_timers; @@ -100,7 +102,7 @@ typedef struct { * @brief This member contains the maximum number of Classic API Semaphores * configured for this application. * - * See #CONFIGURE_MAXIMUM_SEMAPHORES. + * See @ref CONFIGURE_MAXIMUM_SEMAPHORES. */ uint32_t maximum_semaphores; @@ -108,7 +110,7 @@ typedef struct { * @brief This member contains the maximum number of Classic API Message Queues * configured for this application. * - * See #CONFIGURE_MAXIMUM_MESSAGE_QUEUES. + * See @ref CONFIGURE_MAXIMUM_MESSAGE_QUEUES. */ uint32_t maximum_message_queues; @@ -116,7 +118,7 @@ typedef struct { * @brief This member contains the maximum number of Classic API Partitions * configured for this application. * - * See #CONFIGURE_MAXIMUM_PARTITIONS. + * See @ref CONFIGURE_MAXIMUM_PARTITIONS. */ uint32_t maximum_partitions; @@ -124,7 +126,7 @@ typedef struct { * @brief This member contains the maximum number of Classic API Regions * configured for this application. * - * See #CONFIGURE_MAXIMUM_REGIONS. + * See @ref CONFIGURE_MAXIMUM_REGIONS. */ uint32_t maximum_regions; @@ -132,7 +134,7 @@ typedef struct { * @brief This member contains the maximum number of Classic API Dual-Ported * Memories configured for this application. * - * See #CONFIGURE_MAXIMUM_PORTS. + * See @ref CONFIGURE_MAXIMUM_PORTS. */ uint32_t maximum_ports; @@ -140,7 +142,7 @@ typedef struct { * @brief This member contains the maximum number of Classic API Rate Monotonic * Periods configured for this application. * - * See #CONFIGURE_MAXIMUM_PERIODS. + * See @ref CONFIGURE_MAXIMUM_PERIODS. */ uint32_t maximum_periods; @@ -148,7 +150,7 @@ typedef struct { * @brief This member contains the maximum number of Classic API Barriers * configured for this application. * - * See #CONFIGURE_MAXIMUM_BARRIERS. + * See @ref CONFIGURE_MAXIMUM_BARRIERS. */ uint32_t maximum_barriers; @@ -156,7 +158,7 @@ typedef struct { * @brief This member contains the number of Classic API Initialization Tasks * configured for this application. * - * See #CONFIGURE_RTEMS_INIT_TASKS_TABLE. + * See @ref CONFIGURE_RTEMS_INIT_TASKS_TABLE. */ uint32_t number_of_initialization_tasks; @@ -164,37 +166,35 @@ typedef struct { * @brief This member contains the pointer to Classic API Initialization Tasks * Table of this application. * - * See #CONFIGURE_RTEMS_INIT_TASKS_TABLE. + * See @ref CONFIGURE_RTEMS_INIT_TASKS_TABLE. */ const rtems_initialization_tasks_table *User_initialization_tasks_table; } rtems_api_configuration_table; -/* Generated from spec:/rtems/config/if/get-api-configuration */ - -/** - * @ingroup RTEMSAPIConfig - * - * @brief Gets the Classic API Configuration Table of this application. - * - * @return Returns the pointer to the Classic API Configuration Table of this - * application. - */ -const rtems_api_configuration_table * -rtems_configuration_get_rtems_api_configuration( void ); - /* Generated from spec:/rtems/config/if/get-maximum-barriers */ /** * @ingroup RTEMSAPIConfig * - * @brief Gets the maximum number of Classic API Barriers configured for this - * application. + * @brief Gets the resource number of @ref RTEMSAPIClassicBarrier objects + * configured for this application. * - * @return Returns the maximum number of Classic API Barriers configured for - * this application. + * @return Returns the resource number of @ref RTEMSAPIClassicBarrier objects + * configured for this application. * * @par Notes - * See #CONFIGURE_MAXIMUM_BARRIERS. + * The resource number is defined by the @ref CONFIGURE_MAXIMUM_BARRIERS + * application configuration option. See also rtems_resource_is_unlimited() + * and rtems_resource_maximum_per_allocation(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ uint32_t rtems_configuration_get_maximum_barriers( void ); @@ -203,14 +203,25 @@ uint32_t rtems_configuration_get_maximum_barriers( void ); /** * @ingroup RTEMSAPIConfig * - * @brief Gets the maximum number of Classic API Message Queues configured for - * this application. + * @brief Gets the resource number of @ref RTEMSAPIClassicMessage objects + * configured for this application. * - * @return Returns the maximum number of Classic API Message Queues configured - * for this application. + * @return Returns the resource number of @ref RTEMSAPIClassicMessage objects + * configured for this application. * * @par Notes - * See #CONFIGURE_MAXIMUM_MESSAGE_QUEUES. + * The resource number is defined by the @ref CONFIGURE_MAXIMUM_MESSAGE_QUEUES + * application configuration option. See also rtems_resource_is_unlimited() + * and rtems_resource_maximum_per_allocation(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ uint32_t rtems_configuration_get_maximum_message_queues( void ); @@ -219,14 +230,25 @@ uint32_t rtems_configuration_get_maximum_message_queues( void ); /** * @ingroup RTEMSAPIConfig * - * @brief Gets the maximum number of Classic API Partitions configured for this - * application. + * @brief Gets the resource number of @ref RTEMSAPIClassicPart objects + * configured for this application. * - * @return Returns the maximum number of Classic API Partitions configured for - * this application. + * @return Returns the resource number of @ref RTEMSAPIClassicPart objects + * configured for this application. * * @par Notes - * See #CONFIGURE_MAXIMUM_PARTITIONS. + * The resource number is defined by the @ref CONFIGURE_MAXIMUM_PARTITIONS + * application configuration option. See also rtems_resource_is_unlimited() + * and rtems_resource_maximum_per_allocation(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ uint32_t rtems_configuration_get_maximum_partitions( void ); @@ -235,14 +257,25 @@ uint32_t rtems_configuration_get_maximum_partitions( void ); /** * @ingroup RTEMSAPIConfig * - * @brief Gets the maximum number of Classic API Rate Monotonic Periods + * @brief Gets the resource number of @ref RTEMSAPIClassicRatemon objects * configured for this application. * - * @return Returns the maximum number of Classic API Rate Monotonic Periods + * @return Returns the resource number of @ref RTEMSAPIClassicRatemon objects * configured for this application. * * @par Notes - * See #CONFIGURE_MAXIMUM_PERIODS. + * The resource number is defined by the @ref CONFIGURE_MAXIMUM_PERIODS + * application configuration option. See also rtems_resource_is_unlimited() + * and rtems_resource_maximum_per_allocation(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ uint32_t rtems_configuration_get_maximum_periods( void ); @@ -251,14 +284,25 @@ uint32_t rtems_configuration_get_maximum_periods( void ); /** * @ingroup RTEMSAPIConfig * - * @brief Gets the maximum number of Classic API Dual-Ported Memories + * @brief Gets the resource number of @ref RTEMSAPIClassicDPMem objects * configured for this application. * - * @return Returns the maximum number of Classic API Dual-Ported Memories + * @return Returns the resource number of @ref RTEMSAPIClassicDPMem objects * configured for this application. * * @par Notes - * See #CONFIGURE_MAXIMUM_PORTS. + * The resource number is defined by the @ref CONFIGURE_MAXIMUM_PORTS + * application configuration option. See also rtems_resource_is_unlimited() + * and rtems_resource_maximum_per_allocation(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ uint32_t rtems_configuration_get_maximum_ports( void ); @@ -267,14 +311,25 @@ uint32_t rtems_configuration_get_maximum_ports( void ); /** * @ingroup RTEMSAPIConfig * - * @brief Gets the maximum number of Classic API Regions configured for this - * application. + * @brief Gets the resource number of @ref RTEMSAPIClassicRegion objects + * configured for this application. * - * @return Returns the maximum number of Classic API Regions configured for - * this application. + * @return Returns the resource number of @ref RTEMSAPIClassicRegion objects + * configured for this application. * * @par Notes - * See #CONFIGURE_MAXIMUM_REGIONS. + * The resource number is defined by the @ref CONFIGURE_MAXIMUM_REGIONS + * application configuration option. See also rtems_resource_is_unlimited() + * and rtems_resource_maximum_per_allocation(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ uint32_t rtems_configuration_get_maximum_regions( void ); @@ -283,14 +338,25 @@ uint32_t rtems_configuration_get_maximum_regions( void ); /** * @ingroup RTEMSAPIConfig * - * @brief Gets the maximum number of Classic API Semaphores configured for this - * application. + * @brief Gets the resource number of @ref RTEMSAPIClassicSem objects + * configured for this application. * - * @return Returns the maximum number of Classic API Semaphores configured for - * this application. + * @return Returns the resource number of @ref RTEMSAPIClassicSem objects + * configured for this application. * * @par Notes - * See #CONFIGURE_MAXIMUM_SEMAPHORES. + * The resource number is defined by the @ref CONFIGURE_MAXIMUM_SEMAPHORES + * application configuration option. See also rtems_resource_is_unlimited() + * and rtems_resource_maximum_per_allocation(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ uint32_t rtems_configuration_get_maximum_semaphores( void ); @@ -299,14 +365,25 @@ uint32_t rtems_configuration_get_maximum_semaphores( void ); /** * @ingroup RTEMSAPIConfig * - * @brief Gets the maximum number of Classic API Tasks configured for this - * application. + * @brief Gets the resource number of @ref RTEMSAPIClassicTasks objects + * configured for this application. * - * @return Returns the maximum number of Classic API Tasks configured for this - * application. + * @return Returns the resource number of @ref RTEMSAPIClassicTasks objects + * configured for this application. * * @par Notes - * See #CONFIGURE_MAXIMUM_TASKS. + * The resource number is defined by the @ref CONFIGURE_MAXIMUM_TASKS + * application configuration option. See also rtems_resource_is_unlimited() + * and rtems_resource_maximum_per_allocation(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ uint32_t rtems_configuration_get_maximum_tasks( void ); @@ -315,17 +392,50 @@ uint32_t rtems_configuration_get_maximum_tasks( void ); /** * @ingroup RTEMSAPIConfig * - * @brief Gets the maximum number of Classic API Timers configured for this - * application. + * @brief Gets the resource number of @ref RTEMSAPIClassicTimer objects + * configured for this application. * - * @return Returns the maximum number of Classic API Timers configured for this - * application. + * @return Returns the resource number of @ref RTEMSAPIClassicTimer objects + * configured for this application. * * @par Notes - * See #CONFIGURE_MAXIMUM_TIMERS. + * The resource number is defined by the @ref CONFIGURE_MAXIMUM_TIMERS + * application configuration option. See also rtems_resource_is_unlimited() + * and rtems_resource_maximum_per_allocation(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock */ uint32_t rtems_configuration_get_maximum_timers( void ); +/* Generated from spec:/rtems/config/if/get-api-configuration */ + +/** + * @ingroup RTEMSAPIConfig + * + * @brief Gets the Classic API Configuration Table of this application. + * + * @return Returns a pointer to the Classic API Configuration Table of this + * application. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +const rtems_api_configuration_table * +rtems_configuration_get_rtems_api_configuration( void ); + #ifdef __cplusplus } #endif diff --git a/cpukit/include/rtems/rtems/dpmem.h b/cpukit/include/rtems/rtems/dpmem.h index 9ecdf3a170..62e34053ea 100644 --- a/cpukit/include/rtems/rtems/dpmem.h +++ b/cpukit/include/rtems/rtems/dpmem.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassicDPMem + * * @brief This header file defines the Dual-Ported Memory Manager API. */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -112,7 +114,7 @@ extern "C" { * * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a * port. The number of port available to the application is configured - * through the #CONFIGURE_MAXIMUM_PORTS application configuration option. + * through the @ref CONFIGURE_MAXIMUM_PORTS application configuration option. * * @par Notes * @parblock @@ -136,7 +138,7 @@ extern "C" { * cause the calling task to be preempted. * * * The number of ports available to the application is configured through the - * #CONFIGURE_MAXIMUM_PORTS application configuration option. + * @ref CONFIGURE_MAXIMUM_PORTS application configuration option. * * * Where the object class corresponding to the directive is configured to use * unlimited objects, the directive may allocate memory from the RTEMS diff --git a/cpukit/include/rtems/rtems/dpmemdata.h b/cpukit/include/rtems/rtems/dpmemdata.h index 5303b8623a..11c80f2dff 100644 --- a/cpukit/include/rtems/rtems/dpmemdata.h +++ b/cpukit/include/rtems/rtems/dpmemdata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_DPMEMDATA_H diff --git a/cpukit/include/rtems/rtems/dpmemimpl.h b/cpukit/include/rtems/rtems/dpmemimpl.h index a399eccd94..04462335b8 100644 --- a/cpukit/include/rtems/rtems/dpmemimpl.h +++ b/cpukit/include/rtems/rtems/dpmemimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_DPMEM_INL @@ -42,7 +61,7 @@ extern "C" { * This routine allocates a port control block from the inactive chain * of free port control blocks. */ -RTEMS_INLINE_ROUTINE Dual_ported_memory_Control +static inline Dual_ported_memory_Control *_Dual_ported_memory_Allocate ( void ) { return (Dual_ported_memory_Control *) @@ -56,14 +75,14 @@ RTEMS_INLINE_ROUTINE Dual_ported_memory_Control * This routine frees a port control block to the inactive chain * of free port control blocks. */ -RTEMS_INLINE_ROUTINE void _Dual_ported_memory_Free ( +static inline void _Dual_ported_memory_Free ( Dual_ported_memory_Control *the_port ) { _Objects_Free( &_Dual_ported_memory_Information, &the_port->Object ); } -RTEMS_INLINE_ROUTINE Dual_ported_memory_Control *_Dual_ported_memory_Get( +static inline Dual_ported_memory_Control *_Dual_ported_memory_Get( Objects_Id id, ISR_lock_Context *lock_context ) diff --git a/cpukit/include/rtems/rtems/event.h b/cpukit/include/rtems/rtems/event.h index 8d4424e628..81aa57585f 100644 --- a/cpukit/include/rtems/rtems/event.h +++ b/cpukit/include/rtems/rtems/event.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2014, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2014, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/rtems/eventdata.h b/cpukit/include/rtems/rtems/eventdata.h index 7078cc2248..db60056da3 100644 --- a/cpukit/include/rtems/rtems/eventdata.h +++ b/cpukit/include/rtems/rtems/eventdata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_EVENTDATA_H diff --git a/cpukit/include/rtems/rtems/eventimpl.h b/cpukit/include/rtems/rtems/eventimpl.h index bd90554455..9c0380930a 100644 --- a/cpukit/include/rtems/rtems/eventimpl.h +++ b/cpukit/include/rtems/rtems/eventimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_EVENTIMPL_H @@ -104,7 +123,7 @@ rtems_status_code _Event_Surrender( * * @param event is the event control block to initialize. */ -RTEMS_INLINE_ROUTINE void _Event_Initialize( Event_Control *event ) +static inline void _Event_Initialize( Event_Control *event ) { event->pending_events = 0; } @@ -117,7 +136,7 @@ RTEMS_INLINE_ROUTINE void _Event_Initialize( Event_Control *event ) * @return Returns true, if there are no posted events in the event set, * otherwise false. */ -RTEMS_INLINE_ROUTINE bool _Event_sets_Is_empty( +static inline bool _Event_sets_Is_empty( rtems_event_set the_event_set ) { @@ -131,7 +150,7 @@ RTEMS_INLINE_ROUTINE bool _Event_sets_Is_empty( * * @param the_event_set[in, out] is the event set. */ -RTEMS_INLINE_ROUTINE void _Event_sets_Post( +static inline void _Event_sets_Post( rtems_event_set the_new_events, rtems_event_set *the_event_set ) @@ -149,7 +168,7 @@ RTEMS_INLINE_ROUTINE void _Event_sets_Post( * @return Return the events of the event condition which are posted in the * event set. */ -RTEMS_INLINE_ROUTINE rtems_event_set _Event_sets_Get( +static inline rtems_event_set _Event_sets_Get( rtems_event_set the_event_set, rtems_event_set the_event_condition ) @@ -167,7 +186,7 @@ RTEMS_INLINE_ROUTINE rtems_event_set _Event_sets_Get( * @return Returns the event set with all event cleared specified by the event * mask. */ -RTEMS_INLINE_ROUTINE rtems_event_set _Event_sets_Clear( +static inline rtems_event_set _Event_sets_Clear( rtems_event_set the_event_set, rtems_event_set the_mask ) diff --git a/cpukit/include/rtems/rtems/eventmp.h b/cpukit/include/rtems/rtems/eventmp.h index e8c77cac24..c614d4b14f 100644 --- a/cpukit/include/rtems/rtems/eventmp.h +++ b/cpukit/include/rtems/rtems/eventmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_EVENTMP_H diff --git a/cpukit/include/rtems/rtems/intr.h b/cpukit/include/rtems/rtems/intr.h index 7663541adc..f682112bf5 100644 --- a/cpukit/include/rtems/rtems/intr.h +++ b/cpukit/include/rtems/rtems/intr.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassic + * * @brief This header file defines the Interrupt Manager API. */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2008, 2022 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -54,10 +56,18 @@ #ifndef _RTEMS_RTEMS_INTR_H #define _RTEMS_RTEMS_INTR_H +#include <stddef.h> #include <stdint.h> +#include <sys/cpuset.h> +#include <rtems/rtems/attr.h> +#include <rtems/rtems/modes.h> +#include <rtems/rtems/options.h> #include <rtems/rtems/status.h> +#include <rtems/rtems/types.h> #include <rtems/score/basedefs.h> +#include <rtems/score/chain.h> #include <rtems/score/cpu.h> +#include <rtems/score/cpuopts.h> #include <rtems/score/isr.h> #include <rtems/score/isrlevel.h> #include <rtems/score/isrlock.h> @@ -82,31 +92,14 @@ extern "C" { * task to be preempted upon exit from an ISR. */ -/* Generated from spec:/rtems/intr/if/isr */ - -/** - * @ingroup RTEMSAPIClassicIntr - * - * @brief This type defines the return type of interrupt service routines. - * - * This type can be used to document interrupt service routines in the source - * code. - */ -typedef ISR_Handler rtems_isr; - -/* Generated from spec:/rtems/intr/if/isr-entry */ +/* Generated from spec:/rtems/intr/if/vector-number */ /** * @ingroup RTEMSAPIClassicIntr * - * @brief Interrupt service routines installed by rtems_interrupt_catch() shall - * have this type. + * @brief This integer type represents interrupt vector numbers. */ -#if CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE - typedef ISR_Handler_entry rtems_isr_entry; -#else - typedef void ( *rtems_isr_entry )( void * ); -#endif +typedef ISR_Vector_number rtems_vector_number; /* Generated from spec:/rtems/intr/if/level */ @@ -117,33 +110,31 @@ typedef ISR_Handler rtems_isr; */ typedef ISR_Level rtems_interrupt_level; -/* Generated from spec:/rtems/intr/if/lock */ +/* Generated from spec:/rtems/intr/if/isr */ /** * @ingroup RTEMSAPIClassicIntr * - * @brief This structure represents an ISR lock. - */ -typedef ISR_lock_Control rtems_interrupt_lock; - -/* Generated from spec:/rtems/intr/if/lock-context */ - -/** - * @ingroup RTEMSAPIClassicIntr + * @brief This type defines the return type of interrupt service routines. * - * @brief This structure provides an ISR lock context for acquire and release - * pairs. + * This type can be used to document interrupt service routines in the source + * code. */ -typedef ISR_lock_Context rtems_interrupt_lock_context; +typedef ISR_Handler rtems_isr; -/* Generated from spec:/rtems/intr/if/vector-number */ +/* Generated from spec:/rtems/intr/if/isr-entry */ /** * @ingroup RTEMSAPIClassicIntr * - * @brief This integer type represents interrupt vector numbers. + * @brief Interrupt service routines installed by rtems_interrupt_catch() shall + * have this type. */ -typedef ISR_Vector_number rtems_vector_number; +#if CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE + typedef ISR_Handler_entry rtems_isr_entry; +#else + typedef void ( *rtems_isr_entry )( void * ); +#endif /* Generated from spec:/rtems/intr/if/catch */ @@ -503,6 +494,25 @@ rtems_status_code rtems_interrupt_catch( */ #define rtems_interrupt_is_in_progress() _ISR_Is_in_progress() +/* Generated from spec:/rtems/intr/if/lock */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an ISR lock. + */ +typedef ISR_lock_Control rtems_interrupt_lock; + +/* Generated from spec:/rtems/intr/if/lock-context */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure provides an ISR lock context for acquire and release + * pairs. + */ +typedef ISR_lock_Context rtems_interrupt_lock_context; + /* Generated from spec:/rtems/intr/if/lock-initialize */ /** @@ -874,6 +884,687 @@ rtems_status_code rtems_interrupt_catch( #define RTEMS_INTERRUPT_LOCK_REFERENCE( _designator, _target ) \ ISR_LOCK_REFERENCE( _designator, _target ) +/* Generated from spec:/rtems/intr/if/shared */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This interrupt handler install option allows that the interrupt + * handler may share the interrupt vector with other handler. + */ +#define RTEMS_INTERRUPT_SHARED ( (rtems_option) 0x00000000 ) + +/* Generated from spec:/rtems/intr/if/unique */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This interrupt handler install option ensures that the interrupt + * handler is unique. + * + * This option prevents other handler from using the same interrupt vector. + */ +#define RTEMS_INTERRUPT_UNIQUE ( (rtems_option) 0x00000001 ) + +/* Generated from spec:/rtems/intr/if/replace */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This interrupt handler install option requests that the interrupt + * handler replaces the first handler with the same argument. + */ +#define RTEMS_INTERRUPT_REPLACE ( (rtems_option) 0x00000002 ) + +/* Generated from spec:/rtems/intr/if/is-shared */ + +/** + * @brief Checks if the interrupt handler shared option is set. + * + * @param _options is the interrupt handler option set to check. + * + * @return Returns true, if the interrupt handler shared option + * #RTEMS_INTERRUPT_SHARED is set, otherwise false. + */ +#define RTEMS_INTERRUPT_IS_SHARED( _options ) \ + ( ( _options ) & RTEMS_INTERRUPT_SHARED ) + +/* Generated from spec:/rtems/intr/if/is-unique */ + +/** + * @brief Checks if the interrupt handler unique option is set. + * + * @param _options is the interrupt handler option set to check. + * + * @return Returns true, if the interrupt handler unique option + * #RTEMS_INTERRUPT_UNIQUE is set, otherwise false. + */ +#define RTEMS_INTERRUPT_IS_UNIQUE( _options ) \ + ( ( _options ) & RTEMS_INTERRUPT_UNIQUE ) + +/* Generated from spec:/rtems/intr/if/is-replace */ + +/** + * @brief Checks if the interrupt handler replace option is set. + * + * @param _options is the interrupt handler option set to check. + * + * @return Returns true, if the interrupt handler replace option + * #RTEMS_INTERRUPT_REPLACE is set, otherwise false. + */ +#define RTEMS_INTERRUPT_IS_REPLACE( _options ) \ + ( ( _options ) & RTEMS_INTERRUPT_REPLACE ) + +/* Generated from spec:/rtems/intr/if/handler */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Interrupt handler routines shall have this type. + */ +typedef void ( *rtems_interrupt_handler )( void * ); + +/* Generated from spec:/rtems/intr/if/per-handler-routine */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Visitor routines invoked by rtems_interrupt_handler_iterate() shall + * have this type. + */ +typedef void ( *rtems_interrupt_per_handler_routine )( + void *, + const char *, + rtems_option, + rtems_interrupt_handler, + void * +); + +/* Generated from spec:/rtems/intr/if/entry */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt entry. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. An entry may be initialized + * by RTEMS_INTERRUPT_ENTRY_INITIALIZER() or + * rtems_interrupt_entry_initialize(). It may be installed for an interrupt + * vector with rtems_interrupt_entry_install() and removed from an interrupt + * vector by rtems_interrupt_entry_remove(). + * + * @par Constraints + * @parblock + * The following constraints apply to this structure: + * + * * Members of the type shall not be accessed directly by the application. + * @endparblock + */ +typedef struct rtems_interrupt_entry { + /** + * @brief This member is the interrupt handler routine. + */ + rtems_interrupt_handler handler; + + /** + * @brief This member is the interrupt handler argument. + */ + void *arg; + + /** + * @brief This member is the reference to the next entry or NULL. + */ + struct rtems_interrupt_entry *next; + + /** + * @brief This member is the descriptive information of the entry. + */ + const char *info; +} rtems_interrupt_entry; + +/* Generated from spec:/rtems/intr/if/entry-initializer */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Statically initializes an interrupt entry object. + * + * @param _routine is the interrupt handler routine for the entry. + * + * @param _arg is the interrupt handler argument for the entry. + * + * @param _info is the descriptive information for the entry. + * + * @par Notes + * Alternatively, rtems_interrupt_entry_initialize() may be used to dynamically + * initialize an interrupt entry. + */ +#define RTEMS_INTERRUPT_ENTRY_INITIALIZER( _routine, _arg, _info ) \ + { _routine, _arg, NULL, _info } + +/* Generated from spec:/rtems/intr/if/entry-initialize */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Initializes the interrupt entry. + * + * @param[out] entry is the interrupt entry to initialize. + * + * @param routine is the interrupt handler routine for the entry. + * + * @param arg is the interrupt handler argument for the entry. + * + * @param info is the descriptive information for the entry. + * + * @par Notes + * Alternatively, RTEMS_INTERRUPT_ENTRY_INITIALIZER() may be used to statically + * initialize an interrupt entry. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +static inline void rtems_interrupt_entry_initialize( + rtems_interrupt_entry *entry, + rtems_interrupt_handler routine, + void *arg, + const char *info +) +{ + entry->handler = routine; + entry->arg = arg; + entry->next = NULL; + entry->info = info; +} + +/* Generated from spec:/rtems/intr/if/entry-install */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Installs the interrupt entry at the interrupt vector. + * + * @param vector is the interrupt vector number. + * + * @param options is the interrupt entry install option set. + * + * @param entry is the interrupt entry to install. + * + * One of the following mutually exclusive options + * + * * #RTEMS_INTERRUPT_UNIQUE, and + * + * * #RTEMS_INTERRUPT_SHARED + * + * shall be set in the ``options`` parameter. + * + * The handler routine of the entry specified by ``entry`` will be called with + * the handler argument of the entry when dispatched. The order in which + * shared interrupt handlers are dispatched for one vector is defined by the + * installation order. The first installed handler is dispatched first. + * + * If the option #RTEMS_INTERRUPT_UNIQUE is set, then it will be ensured that + * the handler will be the only one for the interrupt vector. + * + * If the option #RTEMS_INTERRUPT_SHARED is set, then multiple handlers may be + * installed for the interrupt vector. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``entry`` parameter was NULL. + * + * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. + * + * @retval ::RTEMS_INVALID_ADDRESS The handler routine of the entry was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @retval ::RTEMS_INVALID_NUMBER An option specified by ``options`` was not + * applicable. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set + * in ``entry`` and the interrupt vector was already occupied by a handler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set + * in ``entry`` and the interrupt vector was already occupied by a unique + * handler. + * + * @retval ::RTEMS_TOO_MANY The handler routine of the entry specified by + * ``entry`` was already installed for the interrupt vector specified by + * ``vector`` with an argument equal to the handler argument of the entry. + * + * @par Notes + * When the directive call was successful, the ownership of the interrupt entry + * has been transferred from the caller to the interrupt service. An installed + * interrupt entry may be removed from the interrupt service by calling + * rtems_interrupt_entry_remove(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * + * * The interrupt entry shall have been initialized by + * rtems_interrupt_entry_initialize() or RTEMS_INTERRUPT_ENTRY_INITIALIZER(). + * @endparblock + */ +rtems_status_code rtems_interrupt_entry_install( + rtems_vector_number vector, + rtems_option options, + rtems_interrupt_entry *entry +); + +/* Generated from spec:/rtems/intr/if/entry-remove */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Removes the interrupt entry from the interrupt vector. + * + * @param vector is the interrupt vector number. + * + * @param entry is the interrupt entry to remove. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``entry`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @retval ::RTEMS_UNSATISFIED The entry specified by ``entry`` was not + * installed at the interrupt vector specified by ``vector``. + * + * @par Notes + * When the directive call was successful, the ownership of the interrupt entry + * has been transferred from the interrupt service to the caller. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * + * * The interrupt entry shall have been installed by + * rtems_interrupt_entry_install(). + * @endparblock + */ +rtems_status_code rtems_interrupt_entry_remove( + rtems_vector_number vector, + rtems_interrupt_entry *entry +); + +/* Generated from spec:/rtems/intr/if/handler-install */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Installs the interrupt handler routine and argument at the interrupt + * vector. + * + * @param vector is the interrupt vector number. + * + * @param info is the descriptive information of the interrupt handler to + * install. + * + * @param options is the interrupt handler install option set. + * + * @param routine is the interrupt handler routine to install. + * + * @param arg is the interrupt handler argument to install. + * + * One of the following mutually exclusive options + * + * * #RTEMS_INTERRUPT_UNIQUE, + * + * * #RTEMS_INTERRUPT_SHARED, and + * + * * #RTEMS_INTERRUPT_REPLACE + * + * shall be set in the ``options`` parameter. + * + * The handler routine will be called with the argument specified by ``arg`` + * when dispatched. The order in which shared interrupt handlers are + * dispatched for one vector is defined by the installation order. The first + * installed handler is dispatched first. + * + * If the option #RTEMS_INTERRUPT_UNIQUE is set, then it will be ensured that + * the handler will be the only one for the interrupt vector. + * + * If the option #RTEMS_INTERRUPT_SHARED is set, then multiple handler may be + * installed for the interrupt vector. + * + * If the option #RTEMS_INTERRUPT_REPLACE is set, then the handler specified by + * ``routine`` will replace the first handler with the same argument for the + * interrupt vector if it exists, otherwise an error status will be returned. + * A second handler with the same argument for the interrupt vector will remain + * unchanged. The new handler will inherit the unique or shared options from + * the replaced handler. + * + * An informative description may be provided in ``info``. It may be used for + * system debugging and diagnostic tools. The referenced string has to be + * persistent as long as the handler is installed. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @retval ::RTEMS_NO_MEMORY There was not enough memory available to allocate + * data structures to install the handler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set + * in ``options`` and the interrupt vector was already occupied by a handler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set + * in ``options`` and the interrupt vector was already occupied by a unique + * handler. + * + * @retval ::RTEMS_TOO_MANY The handler specified by ``routine`` was already + * installed for the interrupt vector specified by ``vector`` with an + * argument equal to the argument specified by ``arg``. + * + * @retval ::RTEMS_UNSATISFIED The #RTEMS_INTERRUPT_REPLACE option was set in + * ``options`` and no handler to replace was installed. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_handler_install( + rtems_vector_number vector, + const char *info, + rtems_option options, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/handler-remove */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Removes the interrupt handler routine and argument from the interrupt + * vector. + * + * @param vector is the interrupt vector number. + * + * @param routine is the interrupt handler routine to remove. + * + * @param arg is the interrupt handler argument to remove. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @retval ::RTEMS_UNSATISFIED There was no handler routine and argument pair + * installed specified by ``routine`` and ``arg``. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_handler_remove( + rtems_vector_number vector, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/vector-is-enabled */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Checks if the interrupt vector is enabled. + * + * @param vector is the interrupt vector number. + * + * @param[out] enabled is the pointer to a ``bool`` object. When the directive + * call is successful, the enabled status of the interrupt associated with + * the interrupt vector specified by ``vector`` will be stored in this + * object. When the interrupt was enabled for the processor executing the + * directive call at some time point during the call, the object value will + * be set to true, otherwise to false. + * + * The directive checks if the interrupt associated with the interrupt vector + * specified by ``vector`` was enabled for the processor executing the + * directive call at some time point during the call. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``enabled`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @par Notes + * Interrupt vectors may be enabled by rtems_interrupt_vector_enable() and + * disabled by rtems_interrupt_vector_disable(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_vector_is_enabled( + rtems_vector_number vector, + bool *enabled +); + +/* Generated from spec:/rtems/intr/if/vector-enable */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Enables the interrupt vector. + * + * @param vector is the number of the interrupt vector to enable. + * + * The directive enables the interrupt vector specified by ``vector``. This + * allows that interrupt service requests are issued to the target processors + * of the interrupt vector. Interrupt service requests for an interrupt vector + * may be raised by rtems_interrupt_raise(), rtems_interrupt_raise_on(), + * external signals, or messages. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_UNSATISFIED The request to enable the interrupt vector has + * not been satisfied. + * + * @par Notes + * The rtems_interrupt_get_attributes() directive may be used to check if an + * interrupt vector can be enabled. Interrupt vectors may be disabled by + * rtems_interrupt_vector_disable(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_vector_enable( rtems_vector_number vector ); + +/* Generated from spec:/rtems/intr/if/vector-disable */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Disables the interrupt vector. + * + * @param vector is the number of the interrupt vector to disable. + * + * The directive disables the interrupt vector specified by ``vector``. This + * prevents that an interrupt service request is issued to the target + * processors of the interrupt vector. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_UNSATISFIED The request to disable the interrupt vector has + * not been satisfied. + * + * @par Notes + * The rtems_interrupt_get_attributes() directive may be used to check if an + * interrupt vector can be disabled. Interrupt vectors may be enabled by + * rtems_interrupt_vector_enable(). There may be targets on which some + * interrupt vectors cannot be disabled, for example a hardware watchdog + * interrupt or software generated interrupts. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_vector_disable( rtems_vector_number vector ); + +/* Generated from spec:/rtems/intr/if/is-pending */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Checks if the interrupt is pending. + * + * @param vector is the interrupt vector number. + * + * @param[out] pending is the pointer to a ``bool`` object. When the directive + * call is successful, the pending status of the interrupt associated with + * the interrupt vector specified by ``vector`` will be stored in this + * object. When the interrupt was pending for the processor executing the + * directive call at some time point during the call, the object value will + * be set to true, otherwise to false. + * + * The directive checks if the interrupt associated with the interrupt vector + * specified by ``vector`` was pending for the processor executing the + * directive call at some time point during the call. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``pending`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_UNSATISFIED The request to get the pending status has not + * been satisfied. + * + * @par Notes + * Interrupts may be made pending by calling the rtems_interrupt_raise() or + * rtems_interrupt_raise_on() directives or due to external signals or + * messages. The pending state may be cleared by rtems_interrupt_clear(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_is_pending( + rtems_vector_number vector, + bool *pending +); + /* Generated from spec:/rtems/intr/if/raise */ /** @@ -997,6 +1688,1618 @@ rtems_status_code rtems_interrupt_raise_on( */ rtems_status_code rtems_interrupt_clear( rtems_vector_number vector ); +/* Generated from spec:/rtems/intr/if/get-affinity */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Gets the processor affinity set of the interrupt vector. + * + * @param vector is the interrupt vector number. + * + * @param affinity_size is the size of the processor set referenced by + * ``affinity`` in bytes. + * + * @param[out] affinity is the pointer to a cpu_set_t object. When the + * directive call is successful, the processor affinity set of the interrupt + * vector will be stored in this object. A set bit in the processor set + * means that the corresponding processor is in the processor affinity set of + * the interrupt vector, otherwise the bit is cleared. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``affinity`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_INVALID_SIZE The size specified by ``affinity_size`` of the + * processor set was too small for the processor affinity set of the + * interrupt vector. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_get_affinity( + rtems_vector_number vector, + size_t affinity_size, + cpu_set_t *affinity +); + +/* Generated from spec:/rtems/intr/if/set-affinity */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Sets the processor affinity set of the interrupt vector. + * + * @param vector is the interrupt vector number. + * + * @param affinity_size is the size of the processor set referenced by + * ``affinity`` in bytes. + * + * @param affinity is the pointer to a cpu_set_t object. The processor set + * defines the new processor affinity set of the interrupt vector. A set bit + * in the processor set means that the corresponding processor shall be in + * the processor affinity set of the interrupt vector, otherwise the bit + * shall be cleared. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``affinity`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_INVALID_NUMBER The referenced processor set was not a valid + * new processor affinity set for the interrupt vector. + * + * @retval ::RTEMS_UNSATISFIED The request to set the processor affinity of the + * interrupt vector has not been satisfied. + * + * @par Notes + * @parblock + * The rtems_interrupt_get_attributes() directive may be used to check if the + * processor affinity of an interrupt vector can be set. + * + * Only online processors of the affinity set specified by ``affinity_size`` + * and ``affinity`` are considered by the directive. Other processors of the + * set are ignored. If the set contains no online processor, then the set is + * invalid and an error status is returned. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_set_affinity( + rtems_vector_number vector, + size_t affinity_size, + const cpu_set_t *affinity +); + +/* Generated from spec:/rtems/intr/if/signal-variant */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This enumeration provides interrupt trigger signal variants. + */ +typedef enum { + /** + * @brief This interrupt signal variant indicates that the interrupt trigger + * signal is unspecified. + */ + RTEMS_INTERRUPT_UNSPECIFIED_SIGNAL, + + /** + * @brief This interrupt signal variant indicates that the interrupt cannot be + * triggered by a signal. + */ + RTEMS_INTERRUPT_NO_SIGNAL, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a low level signal. + */ + RTEMS_INTERRUPT_SIGNAL_LEVEL_LOW, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a high level signal. + */ + RTEMS_INTERRUPT_SIGNAL_LEVEL_HIGH, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a falling edge signal. + */ + RTEMS_INTERRUPT_SIGNAL_EDGE_FALLING, + + /** + * @brief This interrupt signal variant indicates that the interrupt is + * triggered by a raising edge signal. + */ + RTEMS_INTERRUPT_SIGNAL_EDGE_RAISING +} rtems_interrupt_signal_variant; + +/* Generated from spec:/rtems/intr/if/attributes */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure provides the attributes of an interrupt vector. + * + * The rtems_interrupt_get_attributes() directive may be used to obtain the + * attributes of an interrupt vector. + */ +typedef struct { + /** + * @brief This member is true, if the interrupt vector is maskable by + * rtems_interrupt_local_disable(), otherwise it is false. + * + * Interrupt vectors which are not maskable by rtems_interrupt_local_disable() + * should be used with care since they cannot use most operating system + * services. + */ + bool is_maskable; + + /** + * @brief This member is true, if the interrupt vector can be enabled by + * rtems_interrupt_vector_enable(), otherwise it is false. + * + * When an interrupt vector can be enabled, this means that the enabled state + * can always be changed from disabled to enabled. For an interrupt vector + * which can be enabled it follows that it may be enabled. + */ + bool can_enable; + + /** + * @brief This member is true, if the interrupt vector may be enabled by + * rtems_interrupt_vector_enable(), otherwise it is false. + * + * When an interrupt vector may be enabled, this means that the enabled state + * may be changed from disabled to enabled. The requested enabled state change + * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt + * vectors may be optionally available and cannot be enabled on a particular + * target. + */ + bool maybe_enable; + + /** + * @brief This member is true, if the interrupt vector can be disabled by + * rtems_interrupt_vector_disable(), otherwise it is false. + * + * When an interrupt vector can be disabled, this means that the enabled state + * can be changed from enabled to disabled. For an interrupt vector which can + * be disabled it follows that it may be disabled. + */ + bool can_disable; + + /** + * @brief This member is true, if the interrupt vector may be disabled by + * rtems_interrupt_vector_disable(), otherwise it is false. + * + * When an interrupt vector may be disabled, this means that the enabled state + * may be changed from enabled to disabled. The requested enabled state change + * should be checked by rtems_interrupt_vector_is_enabled(). Some interrupt + * vectors may be always enabled and cannot be disabled on a particular target. + */ + bool maybe_disable; + + /** + * @brief This member is true, if the interrupt vector can be raised by + * rtems_interrupt_raise(), otherwise it is false. + */ + bool can_raise; + + /** + * @brief This member is true, if the interrupt vector can be raised on a + * processor by rtems_interrupt_raise_on(), otherwise it is false. + */ + bool can_raise_on; + + /** + * @brief This member is true, if the interrupt vector can be cleared by + * rtems_interrupt_clear(), otherwise it is false. + */ + bool can_clear; + + /** + * @brief This member is true, if the pending status of the interrupt + * associated with the interrupt vector is cleared by an interrupt + * acknowledge from the processor, otherwise it is false. + */ + bool cleared_by_acknowledge; + + /** + * @brief This member is true, if the affinity set of the interrupt vector can + * be obtained by rtems_interrupt_get_affinity(), otherwise it is false. + */ + bool can_get_affinity; + + /** + * @brief This member is true, if the affinity set of the interrupt vector can + * be set by rtems_interrupt_set_affinity(), otherwise it is false. + */ + bool can_set_affinity; + + /** + * @brief This member is true, if the interrupt associated with the interrupt + * vector can be triggered by a message. + * + * Interrupts may be also triggered by signals, rtems_interrupt_raise(), or + * rtems_interrupt_raise_on(). Examples for message triggered interrupts are + * the PCIe MSI/MSI-X and the ARM GICv3 Locality-specific Peripheral Interrupts + * (LPI). + */ + bool can_be_triggered_by_message; + + /** + * @brief This member describes the trigger signal of the interrupt associated + * with the interrupt vector. + * + * Interrupts are normally triggered by signals which indicate an interrupt + * request from a peripheral. Interrupts may be also triggered by messages, + * rtems_interrupt_raise(), or rtems_interrupt_raise_on(). + */ + rtems_interrupt_signal_variant trigger_signal; +} rtems_interrupt_attributes; + +/* Generated from spec:/rtems/intr/if/get-attributes */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Gets the attributes of the interrupt vector. + * + * @param vector is the interrupt vector number. + * + * @param[out] attributes is the pointer to an rtems_interrupt_attributes + * object. When the directive call is successful, the attributes of the + * interrupt vector will be stored in this object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``attributes`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_get_attributes( + rtems_vector_number vector, + rtems_interrupt_attributes *attributes +); + +/* Generated from spec:/rtems/intr/if/handler-iterate */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Iterates over all interrupt handler installed at the interrupt + * vector. + * + * @param vector is the interrupt vector number. + * + * @param routine is the visitor routine. + * + * @param arg is the visitor argument. + * + * For each installed handler at the interrupt vector the visitor function + * specified by ``routine`` will be called with the argument specified by + * ``arg`` and the handler information, options, routine and argument. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INCORRECT_STATE The service was not initialized. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @par Notes + * @parblock + * The directive is intended for system information and diagnostics. + * + * Never install or remove an interrupt handler within the visitor function. + * This may result in a deadlock. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_handler_iterate( + rtems_vector_number vector, + rtems_interrupt_per_handler_routine routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-default */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief The constant represents the index of the default interrupt server. + */ +#define RTEMS_INTERRUPT_SERVER_DEFAULT 0 + +/* Generated from spec:/rtems/intr/if/server-control */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt server. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. The structure is initialized + * by rtems_interrupt_server_create() and maintained by the interrupt server + * support. + * + * @par Constraints + * @parblock + * The following constraints apply to this structure: + * + * * Members of the type shall not be accessed directly by the application. + * @endparblock + */ +typedef struct rtems_interrupt_server_control { + #if defined(RTEMS_SMP) + /** + * @brief This member is the ISR lock protecting the server control state. + */ + rtems_interrupt_lock lock; + #endif + + /** + * @brief This member is the chain of pending interrupt entries. + */ + Chain_Control entries; + + /** + * @brief This member is the identifier of the server task. + */ + rtems_id server; + + /** + * @brief This member is the error count. + */ + unsigned long errors; + + /** + * @brief This member is the server index. + */ + uint32_t index; + + /** + * @brief This member is the node for the interrupt server registry. + */ + Chain_Node node; + + /** + * @brief This member is the optional handler to destroy the interrupt server + * control. + */ + void ( *destroy )( struct rtems_interrupt_server_control * ); +} rtems_interrupt_server_control; + +/* Generated from spec:/rtems/intr/if/server-config */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure defines an interrupt server configuration. + * + * @par Notes + * See also rtems_interrupt_server_create(). + * + * @par Constraints + * @parblock + * The following constraints apply to this structure: + * + * * Members of the type shall not be accessed directly by the application. + * @endparblock + */ +typedef struct { + /** + * @brief This member is the task name of the interrupt server. + */ + rtems_name name; + + /** + * @brief This member is the initial task priority of the interrupt server. + */ + rtems_task_priority priority; + + /** + * @brief This member is the task storage area of the interrupt server. + * + * It shall be NULL for interrupt servers created by + * rtems_interrupt_server_create(). + */ + void *storage_area; + + /** + * @brief This member is the task storage size of the interrupt server. + * + * For interrupt servers created by rtems_interrupt_server_create() this is the + * task stack size. + */ + size_t storage_size; + + /** + * @brief This member is the initial mode set of the interrupt server. + */ + rtems_mode modes; + + /** + * @brief This member is the attribute set of the interrupt server. + */ + rtems_attribute attributes; + + /** + * @brief This member is an optional handler to destroy the interrupt server + * control handed over to rtems_interrupt_server_create(). + * + * The destroy handler is optional and may be NULL. If the destroy handler is + * present, it is called from within the context of the interrupt server to be + * deleted, see also rtems_interrupt_server_delete(). + */ + void ( *destroy )( rtems_interrupt_server_control * ); +} rtems_interrupt_server_config; + +/* Generated from spec:/rtems/intr/if/server-initialize */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Initializes the interrupt server tasks. + * + * @param priority is the initial task priority of the created interrupt + * servers. + * + * @param stack_size is the task stack size of the created interrupt servers. + * + * @param modes is the initial mode set of the created interrupt servers. + * + * @param attributes is the attribute set of the created interrupt servers. + * + * @param[out] server_count is the pointer to an uint32_t object or NULL. When + * the pointer is not equal to NULL, the count of successfully created + * interrupt servers is stored in this object regardless of the return + * status. + * + * The directive tries to create an interrupt server task for each online + * processor in the system. The tasks will have the initial priority specified + * by ``priority``, the stack size specified by ``stack_size``, the initial + * mode set specified by ``modes``, and the attribute set specified by + * ``attributes``. The count of successfully created server tasks will be + * returned in ``server_count`` if the pointer is not equal to NULL. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INCORRECT_STATE The interrupt servers were already + * initialized. + * + * @return The directive uses rtems_task_create(). If this directive fails, + * then its error status will be returned. + * + * @par Notes + * @parblock + * Interrupt handlers may be installed on an interrupt server with + * rtems_interrupt_server_handler_install() and removed with + * rtems_interrupt_server_handler_remove() using a server index. In case of an + * interrupt, the request will be forwarded to the interrupt server. The + * handlers are executed within the interrupt server context. If one handler + * blocks on something this may delay the processing of other handlers. + * + * Interrupt servers may be deleted by rtems_interrupt_server_delete(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_initialize( + rtems_task_priority priority, + size_t stack_size, + rtems_mode modes, + rtems_attribute attributes, + uint32_t *server_count +); + +/* Generated from spec:/rtems/intr/if/server-create */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Creates an interrupt server. + * + * @param[out] control is the pointer to an rtems_interrupt_server_control + * object. When the directive call was successful, the ownership of the + * object was transferred from the caller of the directive to the interrupt + * server management. + * + * @param config is the interrupt server configuration. + * + * @param[out] server_index is the pointer to an uint32_t object. When the + * directive call was successful, the index of the created interrupt server + * will be stored in this object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @return The directive uses rtems_task_create(). If this directive fails, + * then its error status will be returned. + * + * @par Notes + * See also rtems_interrupt_server_initialize() and + * rtems_interrupt_server_delete(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_create( + rtems_interrupt_server_control *control, + const rtems_interrupt_server_config *config, + uint32_t *server_index +); + +/* Generated from spec:/rtems/intr/if/server-handler-install */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Installs the interrupt handler routine and argument at the interrupt + * vector on the interrupt server. + * + * @param server_index is the interrupt server index. The constant + * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default + * interrupt server. + * + * @param vector is the interrupt vector number. + * + * @param info is the descriptive information of the interrupt handler to + * install. + * + * @param options is the interrupt handler install option set. + * + * @param routine is the interrupt handler routine to install. + * + * @param arg is the interrupt handler argument to install. + * + * The handler routine specified by ``routine`` will be executed within the + * context of the interrupt server task specified by ``server_index``. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within + * interrupt context. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``routine`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_INVALID_NUMBER An option specified by ``info`` was not + * applicable. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_UNIQUE option was set + * in ``info`` and the interrupt vector was already occupied by a handler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The #RTEMS_INTERRUPT_SHARED option was set + * in ``info`` and the interrupt vector was already occupied by a unique + * handler. + * + * @retval ::RTEMS_TOO_MANY The handler specified by ``routine`` was already + * installed for the interrupt vector specified by ``vector`` with an + * argument equal to the argument specified by ``arg``. + * + * @retval ::RTEMS_UNSATISFIED The #RTEMS_INTERRUPT_REPLACE option was set in + * ``info`` and no handler to replace was installed. + * + * @par Notes + * See also rtems_interrupt_handler_install(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_handler_install( + uint32_t server_index, + rtems_vector_number vector, + const char *info, + rtems_option options, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-handler-remove */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Removes the interrupt handler routine and argument from the interrupt + * vector and the interrupt server. + * + * @param server_index is the interrupt server index. The constant + * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default + * interrupt server. + * + * @param vector is the interrupt vector number. + * + * @param routine is the interrupt handler routine to remove. + * + * @param arg is the interrupt handler argument to remove. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @retval ::RTEMS_UNSATISFIED There was no handler routine and argument pair + * installed specified by ``routine`` and ``arg``. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_handler_remove( + uint32_t server_index, + rtems_vector_number vector, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-set-affinity */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Sets the processor affinity of the interrupt server. + * + * @param server_index is the interrupt server index. The constant + * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default + * interrupt server. + * + * @param affinity_size is the size of the processor set referenced by + * ``affinity`` in bytes. + * + * @param affinity is the pointer to a cpu_set_t object. The processor set + * defines the new processor affinity set of the interrupt server. A set bit + * in the processor set means that the corresponding processor shall be in + * the processor affinity set of the task, otherwise the bit shall be + * cleared. + * + * @param priority is the new real priority for the interrupt server. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @return The directive uses rtems_scheduler_ident_by_processor_set(), + * rtems_task_set_scheduler(), and rtems_task_set_affinity(). If one of + * these directive fails, then its error status will be returned. + * + * @par Notes + * @parblock + * The scheduler is set determined by the highest numbered processor in the + * affinity set specified by ``affinity``. + * + * This operation is only reliable in case the interrupt server was suspended + * via rtems_interrupt_server_suspend(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may change the processor affinity of a task. This may cause + * the calling task to be preempted. + * + * * The directive may change the priority of a task. This may cause the + * calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_set_affinity( + uint32_t server_index, + size_t affinity_size, + const cpu_set_t *affinity, + rtems_task_priority priority +); + +/* Generated from spec:/rtems/intr/if/server-delete */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Deletes the interrupt server. + * + * @param server_index is the index of the interrupt server to delete. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * server index specified by ``server_index``. + * + * @par Notes + * @parblock + * The interrupt server deletes itself, so after the return of the directive + * the interrupt server may be still in the termination process depending on + * the task priorities of the system. + * + * See also rtems_interrupt_server_create(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_delete( uint32_t server_index ); + +/* Generated from spec:/rtems/intr/if/server-suspend */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Suspends the interrupt server. + * + * @param server_index is the index of the interrupt server to suspend. The + * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the + * default interrupt server. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @par Notes + * Interrupt server may be resumed by rtems_interrupt_server_resume(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_suspend( uint32_t server_index ); + +/* Generated from spec:/rtems/intr/if/server-resume */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Resumes the interrupt server. + * + * @param server_index is the index of the interrupt server to resume. The + * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the + * default interrupt server. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @par Notes + * Interrupt server may be suspended by rtems_interrupt_server_suspend(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_resume( uint32_t server_index ); + +/* Generated from spec:/rtems/intr/if/server-move */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Moves the interrupt handlers installed at the interrupt vector and + * the source interrupt server to the destination interrupt server. + * + * @param source_server_index is the index of the source interrupt server. The + * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the + * default interrupt server. + * + * @param vector is the interrupt vector number. + * + * @param destination_server_index is the index of the destination interrupt + * server. The constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to + * specify the default interrupt server. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``source_server_index``. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``destination_server_index``. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_move( + uint32_t source_server_index, + rtems_vector_number vector, + uint32_t destination_server_index +); + +/* Generated from spec:/rtems/intr/if/server-handler-iterate */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Iterates over all interrupt handler installed at the interrupt vector + * and interrupt server. + * + * @param server_index is the index of the interrupt server. + * + * @param vector is the interrupt vector number. + * + * @param routine is the visitor routine. + * + * @param arg is the visitor argument. + * + * For each installed handler at the interrupt vector and interrupt server the + * visitor function specified by ``vector`` will be called with the argument + * specified by ``routine`` and the handler information, options, routine and + * argument. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt vector associated with the + * number specified by ``vector``. + * + * @par Notes + * @parblock + * The directive is intended for system information and diagnostics. + * + * Never install or remove an interrupt handler within the visitor function. + * This may result in a deadlock. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_handler_iterate( + uint32_t server_index, + rtems_vector_number vector, + rtems_interrupt_per_handler_routine routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-action */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt server action. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. + * + * @par Constraints + * @parblock + * The following constraints apply to this structure: + * + * * Members of the type shall not be accessed directly by the application. + * @endparblock + */ +typedef struct rtems_interrupt_server_action { + /** + * @brief This member is the reference to the next action or NULL. + */ + struct rtems_interrupt_server_action *next; + + /** + * @brief This member is the interrupt handler. + */ + rtems_interrupt_handler handler; + + /** + * @brief This member is the interrupt handler argument. + */ + void *arg; +} rtems_interrupt_server_action; + +/* Generated from spec:/rtems/intr/if/server-entry */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt server entry. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. An entry is initialized by + * rtems_interrupt_server_entry_initialize() and destroyed by + * rtems_interrupt_server_entry_destroy(). Interrupt server actions can be + * prepended to the entry by rtems_interrupt_server_action_prepend(). The + * entry is submitted to be serviced by rtems_interrupt_server_entry_submit(). + * + * @par Constraints + * @parblock + * The following constraints apply to this structure: + * + * * Members of the type shall not be accessed directly by the application. + * @endparblock + */ +typedef struct { + /** + * @brief This member is the node for the interrupt entry processing. + */ + Chain_Node node; + + /** + * @brief This member references the interrupt server used to process the + * entry. + */ + rtems_interrupt_server_control *server; + + /** + * @brief This member is the interrupt vector number. + */ + rtems_vector_number vector; + + /** + * @brief This member is the interrupt server actions list head. + */ + rtems_interrupt_server_action *actions; +} rtems_interrupt_server_entry; + +/* Generated from spec:/rtems/intr/if/server-entry-initialize */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Initializes the interrupt server entry. + * + * @param server_index is the interrupt server index. The constant + * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default + * interrupt server. + * + * @param entry is the interrupt server entry to initialize. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @par Notes + * After initialization, the list of actions of the interrupt server entry is + * empty. Actions may be prepended by rtems_interrupt_server_action_prepend(). + * Interrupt server entries may be moved to another interrupt vector with + * rtems_interrupt_server_entry_move(). Server entries may be submitted to get + * serviced by the interrupt server with rtems_interrupt_server_entry_submit(). + * Server entries may be destroyed by rtems_interrupt_server_entry_destroy(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_entry_initialize( + uint32_t server_index, + rtems_interrupt_server_entry *entry +); + +/* Generated from spec:/rtems/intr/if/server-action-prepend */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Prepends the interrupt server action to the list of actions of the + * interrupt server entry. + * + * @param[in,out] entry is the interrupt server entry to prepend the interrupt + * server action. It shall have been initialized via + * rtems_interrupt_server_entry_initialize(). + * + * @param[out] action is the interrupt server action to initialize and prepend + * to the list of actions of the entry. + * + * @param routine is the interrupt handler routine to set in the action. + * + * @param arg is the interrupt handler argument to set in the action. + * + * @par Notes + * No error checking is performed by the directive. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The interrupt server entry shall have been initialized by + * rtems_interrupt_server_entry_initialize() and further optional calls to + * rtems_interrupt_server_action_prepend(). + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_action_prepend() with the same interrupt server + * entry. Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_entry_move() with the same interrupt server entry. + * Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_entry_submit() with the same interrupt server + * entry. Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called while the interrupt server entry is + * pending on or serviced by its current interrupt server. Calling the + * directive under these conditions is undefined behaviour. + * @endparblock + */ +void rtems_interrupt_server_action_prepend( + rtems_interrupt_server_entry *entry, + rtems_interrupt_server_action *action, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-entry-destroy */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Destroys the interrupt server entry. + * + * @param[in,out] entry is the interrupt server entry to destroy. + * + * @par Notes + * No error checking is performed by the directive. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * + * * The interrupt server entry shall have been initialized by + * rtems_interrupt_server_entry_initialize() and further optional calls to + * rtems_interrupt_server_action_prepend(). + * @endparblock + */ +void rtems_interrupt_server_entry_destroy( + rtems_interrupt_server_entry *entry +); + +/* Generated from spec:/rtems/intr/if/server-entry-submit */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Submits the interrupt server entry to be serviced by the interrupt + * server. + * + * @param entry is the interrupt server entry to submit. + * + * The directive appends the entry to the pending entries of the interrupt + * server. The interrupt server is notified that a new entry is pending. Once + * the interrupt server is scheduled it services the actions of all pending + * entries. + * + * @par Notes + * @parblock + * This directive may be used to do a two-step interrupt processing. The first + * step is done from within interrupt context by a call to this directive. The + * second step is then done from within the context of the interrupt server. + * + * No error checking is performed by the directive. + * + * A submitted entry may be destroyed by + * rtems_interrupt_server_entry_destroy(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may unblock a task. This may cause the calling task to be + * preempted. + * + * * The interrupt server entry shall have been initialized by + * rtems_interrupt_server_entry_initialize() and further optional calls to + * rtems_interrupt_server_action_prepend(). + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_action_prepend() with the same interrupt server + * entry. Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_entry_move() with the same interrupt server entry. + * Calling the directive under this condition is undefined behaviour. + * @endparblock + */ +void rtems_interrupt_server_entry_submit( + rtems_interrupt_server_entry *entry +); + +/* Generated from spec:/rtems/intr/if/server-entry-move */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Moves the interrupt server entry to the interrupt server. + * + * @param entry is the interrupt server entry to move. + * + * @param server_index is the index of the destination interrupt server. The + * constant #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the + * default interrupt server. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * + * * The interrupt server entry shall have been initialized by + * rtems_interrupt_server_entry_initialize() and further optional calls to + * rtems_interrupt_server_action_prepend(). + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_action_prepend() with the same interrupt server + * entry. Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_entry_move() with the same interrupt server entry. + * Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_entry_submit() with the same interrupt server + * entry. Calling the directive under this condition is undefined behaviour. + * + * * The directive shall not be called while the interrupt server entry is + * pending on or serviced by its current interrupt server. Calling the + * directive under these conditions is undefined behaviour. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_entry_move( + rtems_interrupt_server_entry *entry, + uint32_t server_index +); + +/* Generated from spec:/rtems/intr/if/server-request */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief This structure represents an interrupt server request. + * + * @par Notes + * This structure shall be treated as an opaque data type from the API point of + * view. Members shall not be accessed directly. A request is initialized by + * rtems_interrupt_server_request_initialize() and destroyed by + * rtems_interrupt_server_request_destroy(). The interrupt vector of the + * request can be set by rtems_interrupt_server_request_set_vector(). The + * request is submitted to be serviced by + * rtems_interrupt_server_request_submit(). + * + * @par Constraints + * @parblock + * The following constraints apply to this structure: + * + * * Members of the type shall not be accessed directly by the application. + * @endparblock + */ +typedef struct { + /** + * @brief This member is the interrupt server entry. + */ + rtems_interrupt_server_entry entry; + + /** + * @brief This member is the interrupt server action. + */ + rtems_interrupt_server_action action; +} rtems_interrupt_server_request; + +/* Generated from spec:/rtems/intr/if/server-request-initialize */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Initializes the interrupt server request. + * + * @param server_index is the interrupt server index. The constant + * #RTEMS_INTERRUPT_SERVER_DEFAULT may be used to specify the default + * interrupt server. + * + * @param[out] request is the interrupt server request to initialize. + * + * @param routine is the interrupt handler routine for the request action. + * + * @param arg is the interrupt handler argument for the request action. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no interrupt server associated with the + * index specified by ``server_index``. + * + * @par Notes + * An interrupt server requests consists of an interrupt server entry and + * exactly one interrupt server action. The interrupt vector of the request + * may be changed with rtems_interrupt_server_request_set_vector(). Interrupt + * server requests may be submitted to get serviced by the interrupt server + * with rtems_interrupt_server_request_submit(). Requests may be destroyed by + * rtems_interrupt_server_request_destroy(). + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_interrupt_server_request_initialize( + uint32_t server_index, + rtems_interrupt_server_request *request, + rtems_interrupt_handler routine, + void *arg +); + +/* Generated from spec:/rtems/intr/if/server-request-set-vector */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Sets the interrupt vector in the interrupt server request. + * + * @param[in,out] request is the interrupt server request to change. + * + * @param vector is the interrupt vector number to be used by the request. + * + * @par Notes + * @parblock + * By default, the interrupt vector of an interrupt server request is set to a + * special value which is outside the range of vectors supported by the + * interrupt controller hardware. + * + * Calls to rtems_interrupt_server_request_submit() will disable the interrupt + * vector of the request. After processing of the request by the interrupt + * server the interrupt vector will be enabled again. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive will not cause the calling task to be preempted. + * + * * The interrupt server request shall have been initialized by + * rtems_interrupt_server_request_initialize(). + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_request_set_vector() with the same interrupt server + * request. Calling the directive under this condition is undefined + * behaviour. + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_request_submit() with the same interrupt server + * request. Calling the directive under this condition is undefined + * behaviour. + * + * * The directive shall not be called while the interrupt server entry is + * pending on or serviced by its current interrupt server. Calling the + * directive under these conditions is undefined behaviour. + * @endparblock + */ +static inline void rtems_interrupt_server_request_set_vector( + rtems_interrupt_server_request *request, + rtems_vector_number vector +) +{ + request->entry.vector = vector; +} + +/* Generated from spec:/rtems/intr/if/server-request-destroy */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Destroys the interrupt server request. + * + * @param[in,out] request is the interrupt server request to destroy. + * + * @par Notes + * No error checking is performed by the directive. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within task context. + * + * * The directive shall not be called from within the context of an interrupt + * server. Calling the directive from within the context of an interrupt + * server is undefined behaviour. + * + * * The directive sends a request to another task and waits for a response. + * This may cause the calling task to be blocked and unblocked. + * + * * The interrupt server request shall have been initialized by + * rtems_interrupt_server_request_initialize(). + * @endparblock + */ +static inline void rtems_interrupt_server_request_destroy( + rtems_interrupt_server_request *request +) +{ + rtems_interrupt_server_entry_destroy( &request->entry ); +} + +/* Generated from spec:/rtems/intr/if/server-request-submit */ + +/** + * @ingroup RTEMSAPIClassicIntr + * + * @brief Submits the interrupt server request to be serviced by the interrupt + * server. + * + * @param[in,out] request is the interrupt server request to submit. + * + * The directive appends the interrupt server entry of the request to the + * pending entries of the interrupt server. The interrupt server is notified + * that a new entry is pending. Once the interrupt server is scheduled it + * services the actions of all pending entries. + * + * @par Notes + * @parblock + * This directive may be used to do a two-step interrupt processing. The first + * step is done from within interrupt context by a call to this directive. The + * second step is then done from within the context of the interrupt server. + * + * No error checking is performed by the directive. + * + * A submitted request may be destroyed by + * rtems_interrupt_server_request_destroy(). + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within interrupt context. + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may unblock a task. This may cause the calling task to be + * preempted. + * + * * The interrupt server request shall have been initialized by + * rtems_interrupt_server_request_initialize(). + * + * * The directive shall not be called concurrently with + * rtems_interrupt_server_request_set_vector() with the same interrupt server + * request. Calling the directive under this condition is undefined + * behaviour. + * @endparblock + */ +static inline void rtems_interrupt_server_request_submit( + rtems_interrupt_server_request *request +) +{ + rtems_interrupt_server_entry_submit( &request->entry ); +} + #ifdef __cplusplus } #endif diff --git a/cpukit/include/rtems/rtems/mainpage.h b/cpukit/include/rtems/rtems/mainpage.h deleted file mode 100644 index 05bae7fe70..0000000000 --- a/cpukit/include/rtems/rtems/mainpage.h +++ /dev/null @@ -1,929 +0,0 @@ -/** - * @file - * - * This file exists to provide a top level description of RTEMS for Doxygen. - */ - -/* - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * 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. - */ - -/** - * @mainpage - * - * The RTEMS real-time operating systems is a layered system with each of the - * public APIs implemented in terms of a common foundation layer called the - * SuperCore. This is the Doxygen generated documentation for the RTEMS CPU - * Kit including the Classic API, POSIX API and SuperCore. - */ - -/** - * @page RTEMSPreface RTEMS History and Introduction - * - * In recent years, the cost required to develop a software product has - * increased significantly while the target hardware costs have decreased. Now - * a larger portion of money is expended in developing, using, and maintaining - * software. The trend in computing costs is the complete dominance of software - * over hardware costs. Because of this, it is necessary that formal - * disciplines be established to increase the probability that software is - * characterized by a high degree of correctness, maintainability, and - * portability. In addition, these disciplines must promote practices that aid - * in the consistent and orderly development of a software system within - * schedule and budgetary constraints. To be effective, these disciplines must - * adopt standards which channel individual software efforts toward a common - * goal. - * - * The push for standards in the software development field has been met with - * various degrees of success. The Microprocessor Operating Systems Interfaces - * (MOSI) effort has experienced only limited success. As popular as the UNIX - * operating system has grown, the attempt to develop a standard interface - * definition to allow portable application development has only recently begun - * to produce the results needed in this area. Unfortunately, very little - * effort has been expended to provide standards addressing the needs of the - * real-time community. Several organizations have addressed this need during - * recent years. - * - * The Real Time Executive Interface Definition (RTEID) was developed by - * Motorola with technical input from Software Components Group. RTEID was - * adopted by the VMEbus International Trade Association (VITA) as a baseline - * draft for their proposed standard multiprocessor, real-time executive - * interface, Open Real-Time Kernel Interface Definition (ORKID). These two - * groups are currently working together with the IEEE P1003.4 committee to - * insure that the functionality of their proposed standards is adopted as the - * real-time extensions to POSIX. - * - * This emerging standard defines an interface for the development of real-time - * software to ease the writing of real-time application programs that are - * directly portable across multiple real-time executive implementations. This - * interface includes both the source code interfaces and run-time behavior as - * seen by a real-time application. It does not include the details of how a - * kernel implements these functions. The standard's goal is to serve as a - * complete definition of external interfaces so that application code that - * conforms to these interfaces will execute properly in all real-time - * executive environments. With the use of a standards compliant executive, - * routines that acquire memory blocks, create and manage message queues, - * establish and use semaphores, and send and receive signals need not be - * redeveloped for a different real-time environment as long as the new - * environment is compliant with the standard. Software developers need only - * concentrate on the hardware dependencies of the real-time system. - * Furthermore, most hardware dependencies for real-time applications can be - * localized to the device drivers. - * - * A compliant executive provides simple and flexible real-time - * multiprocessing. It easily lends itself to both tightly-coupled and - * loosely-coupled configurations (depending on the system hardware - * configuration). Objects such as tasks, queues, events, signals, semaphores, - * and memory blocks can be designated as global objects and accessed by any - * task regardless of which processor the object and the accessing task reside. - * - * The acceptance of a standard for real-time executives will produce the same - * advantages enjoyed from the push for UNIX standardization by AT&T's System V - * Interface Definition and IEEE's POSIX efforts. A compliant multiprocessing - * executive will allow close coupling between UNIX systems and real-time - * executives to provide the many benefits of the UNIX development environment - * to be applied to real-time software development. Together they provide the - * necessary laboratory environment to implement real-time, distributed, - * embedded systems using a wide variety of computer architectures. - * - * A study was completed in 1988, within the Research, Development, and - * Engineering Center, U.S. Army Missile Command, which compared the various - * aspects of the Ada programming language as they related to the application - * of Ada code in distributed and/or multiple processing systems. Several - * critical conclusions were derived from the study. These conclusions have a - * major impact on the way the Army develops application software for embedded - * applications. These impacts apply to both in-house software development and - * contractor developed software. - * - * A conclusion of the analysis, which has been previously recognized by other - * agencies attempting to utilize Ada in a distributed or multiprocessing - * environment, is that the Ada programming language does not adequately - * support multiprocessing. Ada does provide a mechanism for multi-tasking, - * however, this capability exists only for a single processor system. The - * language also does not have inherent capabilities to access global named - * variables, flags or program code. These critical features are essential in - * order for data to be shared between processors. However, these drawbacks do - * have workarounds which are sometimes awkward and defeat the intent of - * software maintainability and portability goals. - * - * Another conclusion drawn from the analysis, was that the run time executives - * being delivered with the Ada compilers were too slow and inefficient to be - * used in modern missile systems. A run time executive is the core part of the - * run time system code, or operating system code, that controls task - * scheduling, input/output management and memory management. Traditionally, - * whenever efficient executive (also known as kernel) code was required by the - * application, the user developed in-house software. This software was usually - * written in assembly language for optimization. - * - * Because of this shortcoming in the Ada programming language, software - * developers in research and development and contractors for project managed - * systems, are mandated by technology to purchase and utilize off-the-shelf - * third party kernel code. The contractor, and eventually the Government, must - * pay a licensing fee for every copy of the kernel code used in an embedded - * system. - * - * The main drawback to this development environment is that the Government - * does not own, nor has the right to modify code contained within the kernel. - * V&V techniques in this situation are more difficult than if the complete - * source code were available. Responsibility for system failures due to faulty - * software is yet another area to be resolved under this environment. - * - * The Guidance and Control Directorate began a software development effort to - * address these problems. A project to develop an experimental run time kernel - * was begun that will eliminate the major drawbacks of the Ada programming - * language mentioned above. The Real Time Executive for Multiprocessor Systems - * (RTEMS) provides full capabilities for management of tasks, interrupts, - * time, and multiple processors in addition to those features typical of - * generic operating systems. The code is Government owned, so no licensing - * fees are necessary. RTEMS has been implemented in both the Ada and C - * programming languages. It has been ported to the following processor - * families: - * - * - Altera NIOS II - * - Analog Devices Blackfin - * - ARM - * - Freescale (formerly Motorola) MC68xxx - * - Freescale (formerly Motorola) MC683xx - * - Freescale (formerly Motorola) ColdFire - * - Intel i386 and above - * - Lattice Semiconductor LM32 - * - MIPS - * - PowerPC - * - Renesas (formerly Hitachi) SuperH - * - Renesas (formerly Hitachi) H8/300 - * - SPARC - * - Texas Instruments C3x/C4x - * - UNIX - * - * Support for other processor families, including RISC, CISC, and DSP, is - * planned. Since almost all of RTEMS is written in a high level language, - * ports to additional processor families require minimal effort. - * - * RTEMS multiprocessor support is capable of handling either homogeneous or - * heterogeneous systems. The kernel automatically compensates for - * architectural differences (byte swapping, etc.) between processors. This - * allows a much easier transition from one processor family to another without - * a major system redesign. - * - * Since the proposed standards are still in draft form, RTEMS cannot and does - * not claim compliance. However, the status of the standard is being carefully - * monitored to guarantee that RTEMS provides the functionality specified in - * the standard. Once approved, RTEMS will be made compliant. - */ - -/** - * @page RTEMSOverview RTEMS Overview - * - * @section RTEMSOverviewSecIntroduction Introduction - * - * RTEMS, Real-Time Executive for Multiprocessor Systems, is a real-time - * executive (kernel) which provides a high performance environment for - * embedded military applications including the following features: - * - * - multitasking capabilities - * - homogeneous and heterogeneous multiprocessor systems - * - event-driven, priority-based, preemptive scheduling - * - optional rate monotonic scheduling - * - intertask communication and synchronization - * - priority inheritance - * - responsive interrupt management - * - dynamic memory allocation - * - high level of user configurability - * - * This manual describes the usage of RTEMS for applications written in the C - * programming language. Those implementation details that are processor - * dependent are provided in the Applications Supplement documents. A - * supplement document which addresses specific architectural issues that - * affect RTEMS is provided for each processor type that is supported. - * - * @section RTEMSOverviewSecRealtimeApplicationSystems Real-time Application Systems - * - * Real-time application systems are a special class of computer applications. - * They have a complex set of characteristics that distinguish them from other - * software problems. Generally, they must adhere to more rigorous - * requirements. The correctness of the system depends not only on the results - * of computations, but also on the time at which the results are produced. The - * most important and complex characteristic of real-time application systems - * is that they must receive and respond to a set of external stimuli within - * rigid and critical time constraints referred to as deadlines. Systems can be - * buried by an avalanche of interdependent, asynchronous or cyclical event - * streams. - * - * Deadlines can be further characterized as either hard or soft based upon the - * value of the results when produced after the deadline has passed. A deadline - * is hard if the results have no value or if their use will result in a - * catastrophic event. In contrast, results which are produced after a soft - * deadline may have some value. - * - * Another distinguishing requirement of real-time application systems is the - * ability to coordinate or manage a large number of concurrent activities. - * Since software is a synchronous entity, this presents special problems. One - * instruction follows another in a repeating synchronous cycle. Even though - * mechanisms have been developed to allow for the processing of external - * asynchronous events, the software design efforts required to process and - * manage these events and tasks are growing more complicated. - * - * The design process is complicated further by spreading this activity over a - * set of processors instead of a single processor. The challenges associated - * with designing and building real-time application systems become very - * complex when multiple processors are involved. New requirements such as - * interprocessor communication channels and global resources that must be - * shared between competing processors are introduced. The ramifications of - * multiple processors complicate each and every characteristic of a real-time - * system. - * - * @section RTEMSOverviewSecRealtimeExecutive Real-time Executive - * - * Fortunately, real-time operating systems or real-time executives serve as a - * cornerstone on which to build the application system. A real-time - * multitasking executive allows an application to be cast into a set of - * logical, autonomous processes or tasks which become quite manageable. Each - * task is internally synchronous, but different tasks execute independently, - * resulting in an asynchronous processing stream. Tasks can be dynamically - * paused for many reasons resulting in a different task being allowed to - * execute for a period of time. The executive also provides an interface to - * other system components such as interrupt handlers and device drivers. - * System components may request the executive to allocate and coordinate - * resources, and to wait for and trigger synchronizing conditions. The - * executive system calls effectively extend the CPU instruction set to support - * efficient multitasking. By causing tasks to travel through well-defined - * state transitions, system calls permit an application to demand-switch - * between tasks in response to real-time events. - * - * By proper grouping of responses to stimuli into separate tasks, a system can - * now asynchronously switch between independent streams of execution, directly - * responding to external stimuli as they occur. This allows the system design - * to meet critical performance specifications which are typically measured by - * guaranteed response time and transaction throughput. The multiprocessor - * extensions of RTEMS provide the features necessary to manage the extra - * requirements introduced by a system distributed across several processors. - * It removes the physical barriers of processor boundaries from the world of - * the system designer, enabling more critical aspects of the system to receive - * the required attention. Such a system, based on an efficient real-time, - * multiprocessor executive, is a more realistic model of the outside world or - * environment for which it is designed. As a result, the system will always be - * more logical, efficient, and reliable. - * - * By using the directives provided by RTEMS, the real-time applications - * developer is freed from the problem of controlling and synchronizing - * multiple tasks and processors. In addition, one need not develop, test, - * debug, and document routines to manage memory, pass messages, or provide - * mutual exclusion. The developer is then able to concentrate solely on the - * application. By using standard software components, the time and cost - * required to develop sophisticated real-time applications is significantly - * reduced. - * - * @section RTEMSOverviewSecApplicationArchitecture RTEMS Application Architecture - * - * One important design goal of RTEMS was to provide a bridge between two - * critical layers of typical real-time systems. As shown in the following - * figure, RTEMS serves as a buffer between the project dependent application - * code and the target hardware. Most hardware dependencies for real-time - * applications can be localized to the low level device drivers. - * - * @todo Image RTEMS Application Architecture - * - * The RTEMS I/O interface manager provides an efficient tool for incorporating - * these hardware dependencies into the system while simultaneously providing a - * general mechanism to the application code that accesses them. A well - * designed real-time system can benefit from this architecture by building a - * rich library of standard application components which can be used repeatedly - * in other real-time projects. - * - * @section RTEMSOverviewSecInternalArchitecture RTEMS Internal Architecture - * - * RTEMS can be viewed as a set of layered components that work in harmony to - * provide a set of services to a real-time application system. The executive - * interface presented to the application is formed by grouping directives into - * logical sets called resource managers. Functions utilized by multiple - * managers such as scheduling, dispatching, and object management are provided - * in the executive core. The executive core depends on a small set of CPU - * dependent routines. Together these components provide a powerful run time - * environment that promotes the development of efficient real-time application - * systems. The following figure illustrates this organization: - * - * @todo Image RTEMS Architecture - * - * Subsequent chapters present a detailed description of the capabilities - * provided by each of the following RTEMS managers: - * - * - initialization - * - task - * - interrupt - * - clock - * - timer - * - semaphore - * - message - * - event - * - signal - * - partition - * - region - * - dual ported memory - * - I/O - * - fatal error - * - rate monotonic - * - user extensions - * - multiprocessing - * - * @section RTEMSOverviewSecUserCustomization User Customization and Extensibility - * - * As 32-bit microprocessors have decreased in cost, they have become - * increasingly common in a variety of embedded systems. A wide range of custom - * and general-purpose processor boards are based on various 32-bit - * processors. RTEMS was designed to make no assumptions concerning the - * characteristics of individual microprocessor families or of specific support - * hardware. In addition, RTEMS allows the system developer a high degree of - * freedom in customizing and extending its features. - * - * RTEMS assumes the existence of a supported microprocessor and sufficient - * memory for both RTEMS and the real-time application. Board dependent - * components such as clocks, interrupt controllers, or I/O devices can be - * easily integrated with RTEMS. The customization and extensibility features - * allow RTEMS to efficiently support as many environments as possible. - * - * @section RTEMSOverviewSecPortability Portability - * - * The issue of portability was the major factor in the creation of RTEMS. - * Since RTEMS is designed to isolate the hardware dependencies in the specific - * board support packages, the real-time application should be easily ported to - * any other processor. The use of RTEMS allows the development of real-time - * applications which can be completely independent of a particular - * microprocessor architecture. - * - * @section RTEMSOverviewSecMemoryRequirements Memory Requirements - * - * Since memory is a critical resource in many real-time embedded systems, - * RTEMS was specifically designed to automatically leave out all services that - * are not required from the run-time environment. Features such as networking, - * various filesystems, and many other features are completely optional. This - * allows the application designer the flexibility to tailor RTEMS to most - * efficiently meet system requirements while still satisfying even the most - * stringent memory constraints. As a result, the size of the RTEMS executive - * is application dependent. - * - * RTEMS requires RAM to manage each instance of an RTEMS object that is - * created. Thus the more RTEMS objects an application needs, the more memory - * that must be reserved. See Configuring a System Determining Memory - * Requirements for more details. - * - * @todo Link to Configuring a SystemDetermining Memory Requirements - * - * RTEMS utilizes memory for both code and data space. Although RTEMS' data - * space must be in RAM, its code space can be located in either ROM or RAM. - * - * @section RTEMSOverviewSecAudience Audience - * - * This manual was written for experienced real-time software developers. - * Although some background is provided, it is assumed that the reader is - * familiar with the concepts of task management as well as intertask - * communication and synchronization. Since directives, user related data - * structures, and examples are presented in C, a basic understanding of the C - * programming language is required to fully understand the material presented. - * However, because of the similarity of the Ada and C RTEMS implementations, - * users will find that the use and behavior of the two implementations is very - * similar. A working knowledge of the target processor is helpful in - * understanding some of RTEMS' features. A thorough understanding of the - * executive cannot be obtained without studying the entire manual because many - * of RTEMS' concepts and features are interrelated. Experienced RTEMS users - * will find that the manual organization facilitates its use as a reference - * document. - */ - -/** - * @addtogroup RTEMSAPIClassic - * - * The facilities provided by RTEMS are built upon a foundation of very - * powerful concepts. These concepts must be understood before the application - * developer can efficiently utilize RTEMS. The purpose of this chapter is to - * familiarize one with these concepts. - * - * @section ClassicRTEMSSecObjects Objects - * - * RTEMS provides directives which can be used to dynamically create, delete, - * and manipulate a set of predefined object types. These types include tasks, - * message queues, semaphores, memory regions, memory partitions, timers, - * ports, and rate monotonic periods. The object-oriented nature of RTEMS - * encourages the creation of modular applications built upon re-usable - * "building block" routines. - * - * All objects are created on the local node as required by the application and - * have an RTEMS assigned ID. All objects have a user-assigned name. Although a - * relationship exists between an object's name and its RTEMS assigned ID, the - * name and ID are not identical. Object names are completely arbitrary and - * selected by the user as a meaningful "tag" which may commonly reflect the - * object's use in the application. Conversely, object IDs are designed to - * facilitate efficient object manipulation by the executive. - * - * @subsection ClassicRTEMSSubSecObjectNames Object Names - * - * An object name is an unsigned 32-bit entity associated with the - * object by the user. The data type @ref rtems_name is used to store object names. - * - * Although not required by RTEMS, object names are often composed of four - * ASCII characters which help identify that object. For example, a task which - * causes a light to blink might be called "LITE". The rtems_build_name() - * routine is provided to build an object name from four ASCII characters. The - * following example illustrates this: - * - * @code - * rtems_name my_name = rtems_build_name('L', 'I', 'T', 'E'); - * @endcode - * - * However, it is not required that the application use ASCII characters to - * build object names. For example, if an application requires one-hundred - * tasks, it would be difficult to assign meaningful ASCII names to each task. - * A more convenient approach would be to name them the binary values one - * through one-hundred, respectively. - * - * RTEMS provides a helper routine, rtems_object_get_name(), which can be used to - * obtain the name of any RTEMS object using just its ID. This routine attempts - * to convert the name into a printable string. - * - * @subsection ClassicRTEMSSubSecObjectIdentifiers Object Identifiers - * - * An object ID is a unique unsigned integer value which uniquely identifies an - * object instance. Object IDs are passed as arguments to many directives in - * RTEMS and RTEMS translates the ID to an internal object pointer. The - * efficient manipulation of object IDs is critical to the performance of RTEMS - * services. Because of this, there are two object ID formats defined. Each - * target architecture specifies which format it will use. There is a 32-bit - * format which is used for most of the supported architectures and supports - * multiprocessor configurations. There is also a simpler 16-bit format which - * is appropriate for smaller target architectures and does not support - * multiprocessor configurations. - * - * @subsubsection ClassicRTEMSSubSec32BitObjectIdentifierFormat 32-Bit Object Identifier Format - * - * The 32-bit format for an object ID is composed of four parts: API, - * object class, node, and index. The data type @ref rtems_id is used to store - * object IDs. - * - * <table> - * <tr> - * <th>Bits</th> - * <td>31</td><td>30</td><td>29</td><td>28</td><td>27</td><td>26</td><td>25</td><td>24</td> - * <td>23</td><td>22</td><td>21</td><td>20</td><td>19</td><td>18</td><td>17</td><td>16</td> - * <td>15</td><td>14</td><td>13</td><td>12</td><td>11</td><td>10</td><td>09</td><td>08</td> - * <td>07</td><td>06</td><td>05</td><td>04</td><td>03</td><td>02</td><td>01</td><td>00</td> - * </tr> - * <tr> - * <th>Contents</th> - * <td colspan=5>Class</td><td colspan=3>API</td><td colspan=8>Node</td><td colspan=16>Object Index</td> - * </tr> - * </table> - * - * The most significant five bits are the object class. The next three bits - * indicate the API to which the object class belongs. The next eight bits - * (16 .. 23) are the number of the node on which this object was created. The - * node number is always one (1) in a single processor system. The least - * significant 16-bits form an identifier within a particular object type. - * This identifier, called the object index, ranges in value from one to the - * maximum number of objects configured for this object type. - * - * @subsubsection ClassicRTEMSSubSec16BitObjectIdentifierFormat 16-Bit Object Identifier Format - * - * The 16-bit format for an object ID is composed of three parts: API, object - * class, and index. The data type @ref rtems_id is used to store object IDs. - * - * <table> - * <tr> - * <th>Bits</th> - * <td>15</td><td>14</td><td>13</td><td>12</td><td>11</td><td>10</td><td>09</td><td>08</td> - * <td>07</td><td>06</td><td>05</td><td>04</td><td>03</td><td>02</td><td>01</td><td>00</td> - * </tr> - * <tr> - * <th>Contents</th> - * <td colspan=5>Class</td><td colspan=3>API</td><td colspan=8>Object Index</td> - * </tr> - * </table> - * - * The 16-bit format is designed to be as similar as possible to the 32-bit - * format. The differences are limited to the elimination of the node field - * and reduction of the index field from 16-bits to 8-bits. Thus the 16-bit - * format only supports up to 255 object instances per API/Class combination - * and single processor systems. As this format is typically utilized by 16-bit - * processors with limited address space, this is more than enough object - * instances. - * - * @subsection ClassicRTEMSSubSecObjectIdentiferDescription Object Identifer Description - * - * The components of an object ID make it possible to quickly locate any object - * in even the most complicated multiprocessor system. Object ID's are - * associated with an object by RTEMS when the object is created and the - * corresponding ID is returned by the appropriate object create directive. The - * object ID is required as input to all directives involving objects, except - * those which create an object or obtain the ID of an object. - * - * The object identification directives can be used to dynamically obtain a - * particular object's ID given its name. This mapping is accomplished by - * searching the name table associated with this object type. If the name is - * non-unique, then the ID associated with the first occurrence of the name - * will be returned to the application. Since object IDs are returned when the - * object is created, the object identification directives are not necessary in - * a properly designed single processor application. - * - * In addition, services are provided to portably examine the subcomponents of - * an RTEMS ID. These services are described in detail later in this manual but - * are prototyped as follows: - * - * - rtems_object_id_get_api() - * - rtems_object_id_get_class() - * - rtems_object_id_get_node() - * - rtems_object_id_get_index() - * - * An object control block is a data structure defined by RTEMS which contains - * the information necessary to manage a particular object type. For efficiency - * reasons, the format of each object type's control block is different. - * However, many of the fields are similar in function. The number of each type - * of control block is application dependent and determined by the values - * specified in the user's Configuration Table. An object control block is - * allocated at object create time and freed when the object is deleted. With - * the exception of user extension routines, object control blocks are not - * directly manipulated by user applications. - * - * @section ClassicRTEMSSecComSync Communication and Synchronization - * - * In real-time multitasking applications, the ability for cooperating - * execution threads to communicate and synchronize with each other is - * imperative. A real-time executive should provide an application with the - * following capabilities - * - * - data transfer between cooperating tasks, - * - data transfer between tasks and ISRs, - * - synchronization of cooperating tasks, and - * - synchronization of tasks and ISRs. - * - * Most RTEMS managers can be used to provide some form of communication and/or - * synchronization. However, managers dedicated specifically to communication - * and synchronization provide well established mechanisms which directly map - * to the application's varying needs. This level of flexibility allows the - * application designer to match the features of a particular manager with the - * complexity of communication and synchronization required. The following - * managers were specifically designed for communication and synchronization: - * - * - @ref ClassicSem - * - @ref ClassicMessageQueue - * - @ref ClassicEvent - * - @ref ClassicSignal - * - * The semaphore manager supports mutual exclusion involving the - * synchronization of access to one or more shared user resources. Binary - * semaphores may utilize the optional priority inheritance algorithm to avoid - * the problem of priority inversion. The message manager supports both - * communication and synchronization, while the event manager primarily - * provides a high performance synchronization mechanism. The signal manager - * supports only asynchronous communication and is typically used for exception - * handling. - * - * @section ClassicRTEMSSecTime Time - * - * The development of responsive real-time applications requires an - * understanding of how RTEMS maintains and supports time-related operations. - * The basic unit of time in RTEMS is known as a tick. The frequency of clock - * ticks is completely application dependent and determines the granularity and - * accuracy of all interval and calendar time operations. - * - * By tracking time in units of ticks, RTEMS is capable of supporting interval - * timing functions such as task delays, timeouts, timeslicing, the delayed - * execution of timer service routines, and the rate monotonic scheduling of - * tasks. An interval is defined as a number of ticks relative to the current - * time. For example, when a task delays for an interval of ten ticks, it is - * implied that the task will not execute until ten clock ticks have occurred. - * All intervals are specified using data type @ref rtems_interval. - * - * A characteristic of interval timing is that the actual interval period may - * be a fraction of a tick less than the interval requested. This occurs - * because the time at which the delay timer is set up occurs at some time - * between two clock ticks. Therefore, the first countdown tick occurs in less - * than the complete time interval for a tick. This can be a problem if the - * clock granularity is large. - * - * The rate monotonic scheduling algorithm is a hard real-time scheduling - * methodology. This methodology provides rules which allows one to guarantee - * that a set of independent periodic tasks will always meet their deadlines -- - * even under transient overload conditions. The rate monotonic manager - * provides directives built upon the Clock Manager's interval timer support - * routines. - * - * Interval timing is not sufficient for the many applications which require - * that time be kept in wall time or true calendar form. Consequently, RTEMS - * maintains the current date and time. This allows selected time operations to - * be scheduled at an actual calendar date and time. For example, a task could - * request to delay until midnight on New Year's Eve before lowering the ball - * at Times Square. The data type @ref rtems_time_of_day is used to specify - * calendar time in RTEMS services. See Clock Manager Time and Date Data - * Structures. - * - * @todo Link to Clock Manager Time and Date Data Structures - * - * Obviously, the directives which use intervals or wall time cannot operate - * without some external mechanism which provides a periodic clock tick. This - * clock tick is typically provided by a real time clock or counter/timer - * device. - * - * @section ClassicRTEMSSecMemoryManagement Memory Management - * - * RTEMS memory management facilities can be grouped into two classes: dynamic - * memory allocation and address translation. Dynamic memory allocation is - * required by applications whose memory requirements vary through the - * application's course of execution. Address translation is needed by - * applications which share memory with another CPU or an intelligent - * Input/Output processor. The following RTEMS managers provide facilities to - * manage memory: - * - * - @ref ClassicRegion - * - @ref ClassicPart - * - @ref ClassicDPMEM - * - * RTEMS memory management features allow an application to create simple - * memory pools of fixed size buffers and/or more complex memory pools of - * variable size segments. The partition manager provides directives to manage - * and maintain pools of fixed size entities such as resource control blocks. - * Alternatively, the region manager provides a more general purpose memory - * allocation scheme that supports variable size blocks of memory which are - * dynamically obtained and freed by the application. The dual-ported memory - * manager provides executive support for address translation between internal - * and external dual-ported RAM address space. - */ - -/** - * @addtogroup RTEMSAPIClassicTasks - * - * @section ClassicTasksSecTaskDefinition Task Definition - * - * Many definitions of a task have been proposed in computer literature. - * Unfortunately, none of these definitions encompasses all facets of the - * concept in a manner which is operating system independent. Several of the - * more common definitions are provided to enable each user to select a - * definition which best matches their own experience and understanding of the - * task concept: - * - * - a "dispatchable" unit. - * - an entity to which the processor is allocated. - * - an atomic unit of a real-time, multiprocessor system. - * - single threads of execution which concurrently compete for resources. - * - a sequence of closely related computations which can execute concurrently - * with other computational sequences. - * - * From RTEMS' perspective, a task is the smallest thread of execution which - * can compete on its own for system resources. A task is manifested by the - * existence of a task control block (TCB). - * - * @section ClassicTasksSecTaskControlBlock Task Control Block - * - * The Task Control Block (TCB) is an RTEMS defined data structure which - * contains all the information that is pertinent to the execution of a task. - * During system initialization, RTEMS reserves a TCB for each task configured. - * A TCB is allocated upon creation of the task and is returned to the TCB free - * list upon deletion of the task. - * - * The TCB's elements are modified as a result of system calls made by the - * application in response to external and internal stimuli. TCBs are the only - * RTEMS internal data structure that can be accessed by an application via - * user extension routines. The TCB contains a task's name, ID, current - * priority, current and starting states, execution mode, TCB user extension - * pointer, scheduling control structures, as well as data required by a - * blocked task. - * - * A task's context is stored in the TCB when a task switch occurs. When the - * task regains control of the processor, its context is restored from the TCB. - * When a task is restarted, the initial state of the task is restored from the - * starting context area in the task's TCB. - * - * @section ClassicTasksSecTaskStates Task States - * - * A task may exist in one of the following five states: - * - * - executing - Currently scheduled to the CPU - * - ready - May be scheduled to the CPU - * - blocked - Unable to be scheduled to the CPU - * - dormant - Created task that is not started - * - non-existent - Uncreated or deleted task - * - * An active task may occupy the executing, ready, blocked or dormant state, - * otherwise the task is considered non-existent. One or more tasks may be - * active in the system simultaneously. Multiple tasks communicate, - * synchronize, and compete for system resources with each other via system - * calls. The multiple tasks appear to execute in parallel, but actually each - * is dispatched to the CPU for periods of time determined by the RTEMS - * scheduling algorithm. The scheduling of a task is based on its current state - * and priority. - * - * @section ClassicTasksSecTaskPriority Task Priority - * - * A task's priority determines its importance in relation to the other tasks - * executing on the same processor. RTEMS supports 255 levels of priority - * ranging from 1 to 255. The data type rtems_task_priority() is used to store - * task priorities. - * - * Tasks of numerically smaller priority values are more important tasks than - * tasks of numerically larger priority values. For example, a task at priority - * level 5 is of higher privilege than a task at priority level 10. There is no - * limit to the number of tasks assigned to the same priority. - * - * Each task has a priority associated with it at all times. The initial value - * of this priority is assigned at task creation time. The priority of a task - * may be changed at any subsequent time. - * - * Priorities are used by the scheduler to determine which ready task will be - * allowed to execute. In general, the higher the logical priority of a task, - * the more likely it is to receive processor execution time. - * - * @section ClassicTasksSecTaskMode Task Mode - * - * A task's execution mode is a combination of the following four components: - * - * - preemption - * - ASR processing - * - timeslicing - * - interrupt level - * - * It is used to modify RTEMS' scheduling process and to alter the execution - * environment of the task. The data type rtems_task_mode() is used to manage - * the task execution mode. - * - * The preemption component allows a task to determine when control of the - * processor is relinquished. If preemption is disabled (@c - * RTEMS_NO_PREEMPT), the task will retain control of the - * processor as long as it is in the executing state -- even if a higher - * priority task is made ready. If preemption is enabled (@c RTEMS_PREEMPT) - * and a higher priority task is made ready, then the processor will be - * taken away from the current task immediately and given to the higher - * priority task. - * - * The timeslicing component is used by the RTEMS scheduler to determine how - * the processor is allocated to tasks of equal priority. If timeslicing is - * enabled (@c RTEMS_TIMESLICE), then RTEMS will limit the amount of time the - * task can execute before the processor is allocated to another ready task of - * equal priority. The length of the timeslice is application dependent and - * specified in the Configuration Table. If timeslicing is disabled (@c - * RTEMS_NO_TIMESLICE), then the task will be allowed to - * execute until a task of higher priority is made ready. If @c - * RTEMS_NO_PREEMPT is selected, then the timeslicing component is ignored by - * the scheduler. - * - * The asynchronous signal processing component is used to determine when - * received signals are to be processed by the task. If signal processing is - * enabled (@c RTEMS_ASR), then signals sent to the task will be processed - * the next time the task executes. If signal processing is disabled (@c - * RTEMS_NO_ASR), then all signals received by the task will - * remain posted until signal processing is enabled. This component affects - * only tasks which have established a routine to process asynchronous signals. - * - * The interrupt level component is used to determine which interrupts will be - * enabled when the task is executing. @c RTEMS_INTERRUPT_LEVEL(n) specifies - * that the task will execute at interrupt level n. - * - * - @ref RTEMS_PREEMPT - enable preemption (default) - * - @ref RTEMS_NO_PREEMPT - disable preemption - * - @ref RTEMS_NO_TIMESLICE - disable timeslicing (default) - * - @ref RTEMS_TIMESLICE - enable timeslicing - * - @ref RTEMS_ASR - enable ASR processing (default) - * - @ref RTEMS_NO_ASR - disable ASR processing - * - @ref RTEMS_INTERRUPT_LEVEL(0) - enable all interrupts (default) - * - @ref RTEMS_INTERRUPT_LEVEL(n) - execute at interrupt level n - * - * The set of default modes may be selected by specifying the @ref - * RTEMS_DEFAULT_MODES constant. - * - * @section ClassicTasksSecAccessingTaskArguments Accessing Task Arguments - * - * All RTEMS tasks are invoked with a single argument which is specified when - * they are started or restarted. The argument is commonly used to communicate - * startup information to the task. The simplest manner in which to define a - * task which accesses it argument is: - * - * @code - * rtems_task user_task( - * rtems_task_argument argument - * ); - * @endcode - * - * Application tasks requiring more information may view this single argument - * as an index into an array of parameter blocks. - * - * @section ClassicTasksSecFloatingPointConsiderations Floating Point Considerations - * - * Creating a task with the @ref RTEMS_FLOATING_POINT attribute flag results in - * additional memory being allocated for the TCB to store the state of the - * numeric coprocessor during task switches. This additional memory is NOT - * allocated for @ref RTEMS_NO_FLOATING_POINT tasks. Saving and restoring the - * context of a @c RTEMS_FLOATING_POINT task takes longer than that of a @c - * RTEMS_NO_FLOATING_POINT task because of the relatively large amount of time - * required for the numeric coprocessor to save or restore its computational - * state. - * - * Since RTEMS was designed specifically for embedded military applications - * which are floating point intensive, the executive is optimized to avoid - * unnecessarily saving and restoring the state of the numeric coprocessor. The - * state of the numeric coprocessor is only saved when a @c - * RTEMS_FLOATING_POINT task is dispatched and that task was not the last task - * to utilize the coprocessor. In a system with only one @c - * RTEMS_FLOATING_POINT task, the state of the numeric coprocessor will never - * be saved or restored. - * - * Although the overhead imposed by @c RTEMS_FLOATING_POINT tasks is minimal, - * some applications may wish to completely avoid the overhead associated with - * @c RTEMS_FLOATING_POINT tasks and still utilize a numeric coprocessor. By - * preventing a task from being preempted while performing a sequence of - * floating point operations, a @c RTEMS_NO_FLOATING_POINT task can utilize - * the numeric coprocessor without incurring the overhead of a @c - * RTEMS_FLOATING_POINT context switch. This approach also avoids the - * allocation of a floating point context area. However, if this approach is - * taken by the application designer, NO tasks should be created as @c - * RTEMS_FLOATING_POINT tasks. Otherwise, the floating point context will not - * be correctly maintained because RTEMS assumes that the state of the numeric - * coprocessor will not be altered by @c RTEMS_NO_FLOATING_POINT tasks. - * - * If the supported processor type does not have hardware floating capabilities - * or a standard numeric coprocessor, RTEMS will not provide built-in support - * for hardware floating point on that processor. In this case, all tasks are - * considered @c RTEMS_NO_FLOATING_POINT whether created as @c - * RTEMS_FLOATING_POINT or @c RTEMS_NO_FLOATING_POINT tasks. A floating point - * emulation software library must be utilized for floating point operations. - * - * On some processors, it is possible to disable the floating point unit - * dynamically. If this capability is supported by the target processor, then - * RTEMS will utilize this capability to enable the floating point unit only - * for tasks which are created with the @c RTEMS_FLOATING_POINT attribute. - * The consequence of a @c RTEMS_NO_FLOATING_POINT task attempting to access - * the floating point unit is CPU dependent but will generally result in an - * exception condition. - * - * @section ClassicTasksSecPerTaskVariables Per Task Variables - * - * Per task variables are no longer available. In particular the - * rtems_task_variable_add(), rtems_task_variable_get() and - * rtems_task_variable_delete() functions are neither declared nor defined - * anymore. Use thread local storage or POSIX Keys instead. - * - * @section ClassicTasksSecBuildingTaskAttributeSet Building a Task Attribute Set - * - * In general, an attribute set is built by a bitwise OR of the desired - * components. The set of valid task attribute components is listed below: - * - * - @ref RTEMS_NO_FLOATING_POINT - does not use coprocessor (default) - * - @ref RTEMS_FLOATING_POINT - uses numeric coprocessor - * - @ref RTEMS_LOCAL - local task (default) - * - @ref RTEMS_GLOBAL - global task - * - * Attribute values are specifically designed to be mutually exclusive, - * therefore bitwise OR and addition operations are equivalent as long as each - * attribute appears exactly once in the component list. A component listed as - * a default is not required to appear in the component list, although it is a - * good programming practice to specify default components. If all defaults are - * desired, then @ref RTEMS_DEFAULT_ATTRIBUTES should be used. This example - * demonstrates the attribute_set parameter needed to create a local task which - * utilizes the numeric coprocessor. The attribute_set parameter could be @c - * RTEMS_FLOATING_POINT or @c RTEMS_LOCAL | @c RTEMS_FLOATING_POINT. The - * attribute_set parameter can be set to @c RTEMS_FLOATING_POINT because @c - * RTEMS_LOCAL is the default for all created tasks. If the task were global - * and used the numeric coprocessor, then the attribute_set parameter would be - * @c RTEMS_GLOBAL | @c RTEMS_FLOATING_POINT. - * - * @section ClassicTasksSecBuildingModeAndMask Building a Mode and Mask - * - * In general, a mode and its corresponding mask is built by a bitwise OR of - * the desired components. The set of valid mode constants and each mode's - * corresponding mask constant is listed below: - * - * <table> - * <tr><th>Mode Constant</th><th>Mask Constant</th><th>Description</th></tr> - * <tr><td>@ref RTEMS_PREEMPT</td><td>@ref RTEMS_PREEMPT_MASK</td><td>enables preemption</td></tr> - * <tr><td>@ref RTEMS_NO_PREEMPT</td><td>@ref RTEMS_PREEMPT_MASK</td><td>disables preemption</td></tr> - * <tr><td>@ref RTEMS_NO_TIMESLICE</td><td>@ref RTEMS_TIMESLICE_MASK</td><td>disables timeslicing</td></tr> - * <tr><td>@ref RTEMS_TIMESLICE</td><td>@ref RTEMS_TIMESLICE_MASK</td><td>enables timeslicing</td></tr> - * <tr><td>@ref RTEMS_ASR</td><td>@ref RTEMS_ASR_MASK</td><td>enables ASR processing</td></tr> - * <tr><td>@ref RTEMS_NO_ASR</td><td>@ref RTEMS_ASR_MASK</td><td>disables ASR processing</td></tr> - * <tr><td>@ref RTEMS_INTERRUPT_LEVEL(0)</td><td>@ref RTEMS_INTERRUPT_MASK</td><td>enables all interrupts</td></tr> - * <tr><td>@ref RTEMS_INTERRUPT_LEVEL(n)</td><td>@ref RTEMS_INTERRUPT_MASK</td><td>sets interrupts level n</td></tr> - * </table> - * - * Mode values are specifically designed to be mutually exclusive, therefore - * bitwise OR and addition operations are equivalent as long as each mode - * appears exactly once in the component list. A mode component listed as a - * default is not required to appear in the mode component list, although it is - * a good programming practice to specify default components. If all defaults - * are desired, the mode @ref RTEMS_DEFAULT_MODES and the mask @ref - * RTEMS_ALL_MODE_MASKS should be used. - * - * The following example demonstrates the mode and mask parameters used with - * the rtems_task_mode() directive to place a task at interrupt level 3 and - * make it non-preemptible. The mode should be set to @c - * RTEMS_INTERRUPT_LEVEL(3) | @c RTEMS_NO_PREEMPT to indicate the desired - * preemption mode and interrupt level, while the mask parameter should be set - * to @c RTEMS_INTERRUPT_MASK | @c RTEMS_PREEMPT_MASK to indicate that - * the calling task's interrupt level and preemption mode are being altered. - */ - - /** - * @defgroup LocalPackages Local Packages - * - * @ingroup RTEMSAPIClassic - * - * @brief Local packages. - */ diff --git a/cpukit/include/rtems/rtems/message.h b/cpukit/include/rtems/rtems/message.h index 0a76b1f9b8..0967430934 100644 --- a/cpukit/include/rtems/rtems/message.h +++ b/cpukit/include/rtems/rtems/message.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -212,14 +212,14 @@ typedef struct { * * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a * message queue. The number of message queue available to the application - * is configured through the #CONFIGURE_MAXIMUM_MESSAGE_QUEUES application - * configuration option. + * is configured through the @ref CONFIGURE_MAXIMUM_MESSAGE_QUEUES + * application configuration option. * * @retval ::RTEMS_TOO_MANY In multiprocessing configurations, there was no * inactive global object available to create a global message queue. The * number of global objects available to the application is configured - * through the #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration - * option. + * through the @ref CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application + * configuration option. * * @retval ::RTEMS_INVALID_NUMBER The product of ``count`` and * ``max_message_size`` is greater than the maximum storage size. @@ -260,16 +260,16 @@ typedef struct { * message to remote nodes. This may preempt the calling task. * * * The number of message queues available to the application is configured - * through the #CONFIGURE_MAXIMUM_MESSAGE_QUEUES application configuration - * option. + * through the @ref CONFIGURE_MAXIMUM_MESSAGE_QUEUES application + * configuration option. * * * Where the object class corresponding to the directive is configured to use * unlimited objects, the directive may allocate memory from the RTEMS * Workspace. * * * The number of global objects available to the application is configured - * through the #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration - * option. + * through the @ref CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application + * configuration option. * @endparblock */ rtems_status_code rtems_message_queue_create( @@ -288,7 +288,8 @@ rtems_status_code rtems_message_queue_create( * @brief Constructs a message queue from the specified the message queue * configuration. * - * @param config is the message queue configuration. + * @param config is the pointer to an rtems_message_queue_config object. It + * configures the message queue. * * @param[out] id is the pointer to an ::rtems_id object. When the directive * call is successful, the identifier of the constructed message queue will @@ -342,8 +343,8 @@ rtems_status_code rtems_message_queue_create( * runtime memory allocators. This can simplify the application architecture * as well as any analysis that may be required. * - * The value for #CONFIGURE_MESSAGE_BUFFER_MEMORY should not include memory for - * message queues constructed by rtems_message_queue_construct(). + * The value for @ref CONFIGURE_MESSAGE_BUFFER_MEMORY should not include memory + * for message queues constructed by rtems_message_queue_construct(). * @endparblock * * @par Constraints @@ -362,16 +363,16 @@ rtems_status_code rtems_message_queue_create( * message to remote nodes. This may preempt the calling task. * * * The number of message queues available to the application is configured - * through the #CONFIGURE_MAXIMUM_MESSAGE_QUEUES application configuration - * option. + * through the @ref CONFIGURE_MAXIMUM_MESSAGE_QUEUES application + * configuration option. * * * Where the object class corresponding to the directive is configured to use * unlimited objects, the directive may allocate memory from the RTEMS * Workspace. * * * The number of global objects available to the application is configured - * through the #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration - * option. + * through the @ref CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application + * configuration option. * @endparblock */ rtems_status_code rtems_message_queue_construct( @@ -655,7 +656,7 @@ rtems_status_code rtems_message_queue_urgent( * * This directive causes all tasks that are waiting at the queue specified by * ``id`` to be unblocked and sent the message contained in ``buffer``. Before - * a task is unblocked, the message ``buffer`` of ``size`` byes in length is + * a task is unblocked, the message ``buffer`` of ``size`` bytes in length is * copied to that task's message buffer. The number of tasks that were * unblocked is returned in ``count``. * diff --git a/cpukit/include/rtems/rtems/messagedata.h b/cpukit/include/rtems/rtems/messagedata.h index ed74abf981..f91fca1b8b 100644 --- a/cpukit/include/rtems/rtems/messagedata.h +++ b/cpukit/include/rtems/rtems/messagedata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_MESSAGEDATA_H diff --git a/cpukit/include/rtems/rtems/messageimpl.h b/cpukit/include/rtems/rtems/messageimpl.h index b9cdd0251d..5fbdcadcf6 100644 --- a/cpukit/include/rtems/rtems/messageimpl.h +++ b/cpukit/include/rtems/rtems/messageimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_MESSAGEIMPL_H @@ -78,14 +97,14 @@ rtems_status_code _Message_queue_Submit( * This routine deallocates a message queue control block into * the inactive chain of free message queue control blocks. */ -RTEMS_INLINE_ROUTINE void _Message_queue_Free ( +static inline void _Message_queue_Free ( Message_queue_Control *the_message_queue ) { _Objects_Free( &_Message_queue_Information, &the_message_queue->Object ); } -RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Get( +static inline Message_queue_Control *_Message_queue_Get( Objects_Id id, Thread_queue_Context *queue_context ) @@ -98,7 +117,7 @@ RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Get( ); } -RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Allocate( void ) +static inline Message_queue_Control *_Message_queue_Allocate( void ) { return (Message_queue_Control *) _Objects_Allocate( &_Message_queue_Information ); diff --git a/cpukit/include/rtems/rtems/modes.h b/cpukit/include/rtems/rtems/modes.h index 559029d2da..f348941b24 100644 --- a/cpukit/include/rtems/rtems/modes.h +++ b/cpukit/include/rtems/rtems/modes.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassicModes + * * @brief This header file provides the task modes API of the Task Manager. */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * Copyright (C) 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/rtems/modesimpl.h b/cpukit/include/rtems/rtems/modesimpl.h index 924e12fbee..8cbf655cbb 100644 --- a/cpukit/include/rtems/rtems/modesimpl.h +++ b/cpukit/include/rtems/rtems/modesimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_MODESIMPL_H @@ -22,6 +41,7 @@ #include <rtems/score/schedulerimpl.h> #include <rtems/score/smpimpl.h> #include <rtems/score/threadimpl.h> +#include <rtems/score/threadcpubudget.h> #include <rtems/config.h> #ifdef __cplusplus @@ -44,7 +64,7 @@ extern "C" { * This function returns TRUE if mode_set indicates that Asynchronous * Signal Processing is disabled, and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Modes_Is_asr_disabled ( +static inline bool _Modes_Is_asr_disabled ( rtems_mode mode_set ) { @@ -57,7 +77,7 @@ RTEMS_INLINE_ROUTINE bool _Modes_Is_asr_disabled ( * This function returns TRUE if mode_set indicates that preemption * is enabled, and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Modes_Is_preempt ( +static inline bool _Modes_Is_preempt ( rtems_mode mode_set ) { @@ -70,7 +90,7 @@ RTEMS_INLINE_ROUTINE bool _Modes_Is_preempt ( * This function returns TRUE if mode_set indicates that timeslicing * is enabled, and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Modes_Is_timeslice ( +static inline bool _Modes_Is_timeslice ( rtems_mode mode_set ) { @@ -82,7 +102,7 @@ RTEMS_INLINE_ROUTINE bool _Modes_Is_timeslice ( * * This function returns the interrupt level portion of the mode_set. */ -RTEMS_INLINE_ROUTINE ISR_Level _Modes_Get_interrupt_level ( +static inline ISR_Level _Modes_Get_interrupt_level ( rtems_mode mode_set ) { @@ -99,7 +119,7 @@ RTEMS_INLINE_ROUTINE ISR_Level _Modes_Get_interrupt_level ( * @return Returns true, if support for the interrupt level is implemented, * otherwise returns false. */ -RTEMS_INLINE_ROUTINE bool _Modes_Is_interrupt_level_supported( +static inline bool _Modes_Is_interrupt_level_supported( rtems_mode mode_set ) { @@ -122,7 +142,7 @@ RTEMS_INLINE_ROUTINE bool _Modes_Is_interrupt_level_supported( * @return Returns true, if support for the preempt mode is implemented, * otherwise returns false. */ -RTEMS_INLINE_ROUTINE bool _Modes_Is_preempt_mode_supported( +static inline bool _Modes_Is_preempt_mode_supported( rtems_mode mode_set, const Thread_Control *the_thread ) @@ -142,16 +162,17 @@ RTEMS_INLINE_ROUTINE bool _Modes_Is_preempt_mode_supported( * * @param[out] the_thread is the thread to apply the timeslice mode. */ -RTEMS_INLINE_ROUTINE void _Modes_Apply_timeslice_to_thread( +static inline void _Modes_Apply_timeslice_to_thread( rtems_mode mode_set, Thread_Control *the_thread ) { if ( _Modes_Is_timeslice( mode_set ) ) { - the_thread->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE; - the_thread->cpu_time_budget = rtems_configuration_get_ticks_per_timeslice(); + the_thread->CPU_budget.operations = &_Thread_CPU_budget_reset_timeslice; + the_thread->CPU_budget.available = + rtems_configuration_get_ticks_per_timeslice(); } else { - the_thread->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE; + the_thread->CPU_budget.operations = NULL; } } diff --git a/cpukit/include/rtems/rtems/mp.h b/cpukit/include/rtems/rtems/mp.h index 91c31047fb..5852f43381 100644 --- a/cpukit/include/rtems/rtems/mp.h +++ b/cpukit/include/rtems/rtems/mp.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassic + * * @brief This header file defines the Multiprocessing Manager API. */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/rtems/msgmp.h b/cpukit/include/rtems/rtems/msgmp.h index a5f5ae8011..ddd5aa11cc 100644 --- a/cpukit/include/rtems/rtems/msgmp.h +++ b/cpukit/include/rtems/rtems/msgmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_MSGMP_H @@ -80,7 +99,7 @@ typedef struct { #define MESSAGE_QUEUE_MP_PACKET_SIZE \ offsetof(Message_queue_MP_Packet, buffer) -RTEMS_INLINE_ROUTINE bool _Message_queue_MP_Is_remote( Objects_Id id ) +static inline bool _Message_queue_MP_Is_remote( Objects_Id id ) { return _Objects_MP_Is_remote( id, &_Message_queue_Information ); } diff --git a/cpukit/include/rtems/rtems/object.h b/cpukit/include/rtems/rtems/object.h index e80303da28..bda9a469ed 100644 --- a/cpukit/include/rtems/rtems/object.h +++ b/cpukit/include/rtems/rtems/object.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassicObject + * * @brief This header file provides the Object Services API. */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2009 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/rtems/objectimpl.h b/cpukit/include/rtems/rtems/objectimpl.h index fc93d1aa3b..b17a6ed4d6 100644 --- a/cpukit/include/rtems/rtems/objectimpl.h +++ b/cpukit/include/rtems/rtems/objectimpl.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/rtems/options.h b/cpukit/include/rtems/rtems/options.h index 60d90f997e..44a8d6ccb8 100644 --- a/cpukit/include/rtems/rtems/options.h +++ b/cpukit/include/rtems/rtems/options.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassic + * * @brief This header file provides the Classic API directive options. */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * Copyright (C) 1989, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/rtems/optionsimpl.h b/cpukit/include/rtems/rtems/optionsimpl.h index 7130b2c31f..24e861bf9d 100644 --- a/cpukit/include/rtems/rtems/optionsimpl.h +++ b/cpukit/include/rtems/rtems/optionsimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_OPTIONSIMPL_H @@ -40,7 +59,7 @@ extern "C" { * This function returns TRUE if the RTEMS_NO_WAIT option is enabled in * option_set, and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Options_Is_no_wait ( +static inline bool _Options_Is_no_wait ( rtems_option option_set ) { @@ -53,7 +72,7 @@ RTEMS_INLINE_ROUTINE bool _Options_Is_no_wait ( * This function returns TRUE if the RTEMS_EVENT_ANY option is enabled in * OPTION_SET, and FALSE otherwise. */ -RTEMS_INLINE_ROUTINE bool _Options_Is_any ( +static inline bool _Options_Is_any ( rtems_option option_set ) { diff --git a/cpukit/include/rtems/rtems/part.h b/cpukit/include/rtems/rtems/part.h index 10091b48f4..8c7b0b5ef3 100644 --- a/cpukit/include/rtems/rtems/part.h +++ b/cpukit/include/rtems/rtems/part.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -168,13 +168,13 @@ extern "C" { * * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a * partition. The number of partitions available to the application is - * configured through the #CONFIGURE_MAXIMUM_PARTITIONS application + * configured through the @ref CONFIGURE_MAXIMUM_PARTITIONS application * configuration option. * * @retval ::RTEMS_TOO_MANY In multiprocessing configurations, there was no * inactive global object available to create a global semaphore. The number * of global objects available to the application is configured through the - * #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration option. + * @ref CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration option. * * @par Notes * @parblock @@ -220,7 +220,7 @@ extern "C" { * message to remote nodes. This may preempt the calling task. * * * The number of partitions available to the application is configured - * through the #CONFIGURE_MAXIMUM_PARTITIONS application configuration + * through the @ref CONFIGURE_MAXIMUM_PARTITIONS application configuration * option. * * * Where the object class corresponding to the directive is configured to use @@ -228,8 +228,8 @@ extern "C" { * Workspace. * * * The number of global objects available to the application is configured - * through the #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration - * option. + * through the @ref CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application + * configuration option. * @endparblock */ rtems_status_code rtems_partition_create( diff --git a/cpukit/include/rtems/rtems/partdata.h b/cpukit/include/rtems/rtems/partdata.h index 196c2142ae..6df4af81c5 100644 --- a/cpukit/include/rtems/rtems/partdata.h +++ b/cpukit/include/rtems/rtems/partdata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_PARTDATA_H @@ -41,11 +60,13 @@ typedef struct { */ Objects_Control Object; +#if defined(RTEMS_SMP) /** * @brief This lock protects the chain of unallocated buffers and the number * of allocated buffers. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; +#endif /** * @brief This member contains the base address of the buffer area. @@ -95,6 +116,8 @@ typedef struct { extern Objects_Information _Partition_Information; #if defined(RTEMS_MULTIPROCESSING) +struct _Thread_Control; + /** * @brief Sends the extract proxy request. * @@ -105,8 +128,8 @@ extern Objects_Information _Partition_Information; * @param id is the partition identifier. */ void _Partition_MP_Send_extract_proxy ( - Thread_Control *the_thread, - Objects_Id id + struct _Thread_Control *the_thread, + Objects_Id id ); #endif diff --git a/cpukit/include/rtems/rtems/partimpl.h b/cpukit/include/rtems/rtems/partimpl.h index 144265df7d..2dcea25b81 100644 --- a/cpukit/include/rtems/rtems/partimpl.h +++ b/cpukit/include/rtems/rtems/partimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_PARTIMPL_H @@ -43,7 +62,7 @@ extern "C" { * * @return See _Objects_Get(). */ -RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get( +static inline Partition_Control *_Partition_Get( Objects_Id id, ISR_lock_Context *lock_context ) @@ -62,7 +81,7 @@ RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get( * * @param[in, out] lock_context is the lock context set up by _Partition_Get(). */ -RTEMS_INLINE_ROUTINE void _Partition_Acquire_critical( +static inline void _Partition_Acquire_critical( Partition_Control *the_partition, ISR_lock_Context *lock_context ) @@ -77,7 +96,7 @@ RTEMS_INLINE_ROUTINE void _Partition_Acquire_critical( * * @param[in, out] lock_context is the lock context set up by _Partition_Get(). */ -RTEMS_INLINE_ROUTINE void _Partition_Release( +static inline void _Partition_Release( Partition_Control *the_partition, ISR_lock_Context *lock_context ) diff --git a/cpukit/include/rtems/rtems/partmp.h b/cpukit/include/rtems/rtems/partmp.h index 103a28f9d5..cffde801d8 100644 --- a/cpukit/include/rtems/rtems/partmp.h +++ b/cpukit/include/rtems/rtems/partmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_PARTMP_H @@ -66,7 +85,7 @@ typedef struct { Objects_Id proxy_id; } Partition_MP_Packet; -RTEMS_INLINE_ROUTINE bool _Partition_MP_Is_remote( Objects_Id id ) +static inline bool _Partition_MP_Is_remote( Objects_Id id ) { return _Objects_MP_Is_remote( id, &_Partition_Information ); } diff --git a/cpukit/include/rtems/rtems/ratemon.h b/cpukit/include/rtems/rtems/ratemon.h index 8823d72c55..4b9255e635 100644 --- a/cpukit/include/rtems/rtems/ratemon.h +++ b/cpukit/include/rtems/rtems/ratemon.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 2017 Kuan-Hsun Chen * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * @@ -245,7 +245,8 @@ struct rtems_printer; * * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a * period. The number of periods available to the application is configured - * through the #CONFIGURE_MAXIMUM_PERIODS application configuration option. + * through the @ref CONFIGURE_MAXIMUM_PERIODS application configuration + * option. * * @par Notes * @parblock @@ -269,7 +270,7 @@ struct rtems_printer; * cause the calling task to be preempted. * * * The number of periods available to the application is configured through - * the #CONFIGURE_MAXIMUM_PERIODS application configuration option. + * the @ref CONFIGURE_MAXIMUM_PERIODS application configuration option. * * * Where the object class corresponding to the directive is configured to use * unlimited objects, the directive may allocate memory from the RTEMS @@ -445,6 +446,10 @@ rtems_status_code rtems_rate_monotonic_delete( rtems_id id ); * * @retval ::RTEMS_TIMEOUT The rate monotonic period has expired. * + * @par Notes + * Resetting the processor usage time of tasks has no impact on the period + * status and statistics. + * * @par Constraints * @parblock * The following constraints apply to this directive: @@ -502,9 +507,6 @@ rtems_status_code rtems_rate_monotonic_period( * * @retval ::RTEMS_INVALID_ADDRESS The ``status`` parameter was NULL. * - * @retval ::RTEMS_NOT_DEFINED There was no status available due to a reset of - * the processor time usage of the owner task of the period. - * * @par Constraints * @parblock * The following constraints apply to this directive: diff --git a/cpukit/include/rtems/rtems/ratemondata.h b/cpukit/include/rtems/rtems/ratemondata.h index f35fa7eb61..3c8077d156 100644 --- a/cpukit/include/rtems/rtems/ratemondata.h +++ b/cpukit/include/rtems/rtems/ratemondata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * On-Line Applications Research Corporation (OAR). * COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen. * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_RATEMONDATA_H @@ -71,10 +90,12 @@ typedef struct { /** This field is the object management portion of a Period instance. */ Objects_Control Object; +#if defined(RTEMS_SMP) /** * @brief Protects the rate monotonic period state. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; +#endif /** This is the timer used to provide the unblocking mechanism. */ Watchdog_Control Timer; diff --git a/cpukit/include/rtems/rtems/ratemonimpl.h b/cpukit/include/rtems/rtems/ratemonimpl.h index 7e42a0437c..191e83f305 100644 --- a/cpukit/include/rtems/rtems/ratemonimpl.h +++ b/cpukit/include/rtems/rtems/ratemonimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,12 +11,29 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). - * Copyright (c) 2016 embedded brains GmbH. + * Copyright (c) 2016 embedded brains GmbH & Co. KG * COPYRIGHT (c) 2016 Kuan-Hsun Chen. * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_RATEMONIMPL_H @@ -48,9 +67,6 @@ extern "C" { #define RATE_MONOTONIC_BLOCKED \ ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_BLOCKED ) -#define RATE_MONOTONIC_READY_AGAIN \ - ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_READY_AGAIN ) - /** * @brief Allocates a period control block from * the inactive chain of free period control blocks. @@ -58,13 +74,13 @@ extern "C" { * This function allocates a period control block from * the inactive chain of free period control blocks. */ -RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void ) +static inline Rate_monotonic_Control *_Rate_monotonic_Allocate( void ) { return (Rate_monotonic_Control *) _Objects_Allocate( &_Rate_monotonic_Information ); } -RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical( +static inline void _Rate_monotonic_Acquire_critical( Rate_monotonic_Control *the_period, ISR_lock_Context *lock_context ) @@ -72,7 +88,7 @@ RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical( _ISR_lock_Acquire( &the_period->Lock, lock_context ); } -RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release( +static inline void _Rate_monotonic_Release( Rate_monotonic_Control *the_period, ISR_lock_Context *lock_context ) @@ -80,7 +96,7 @@ RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release( _ISR_lock_Release_and_ISR_enable( &the_period->Lock, lock_context ); } -RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get( +static inline Rate_monotonic_Control *_Rate_monotonic_Get( Objects_Id id, ISR_lock_Context *lock_context ) @@ -92,7 +108,7 @@ RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get( void _Rate_monotonic_Timeout( Watchdog_Control *watchdog ); /** - * @brief _Rate_monotonic_Get_status( + * @brief Gets the rate monotonic CPU usage status. * * This routine is invoked to compute the elapsed wall time and cpu * time for a period. @@ -102,11 +118,8 @@ void _Rate_monotonic_Timeout( Watchdog_Control *watchdog ); * since the period was initiated. * @param[out] cpu_since_last_period is set to the cpu time used by the * owning thread since the period was initiated. - * - * @retval This routine returns true if the status can be determined - * and false otherwise. */ -bool _Rate_monotonic_Get_status( +void _Rate_monotonic_Get_status( const Rate_monotonic_Control *the_period, Timestamp_Control *wall_since_last_period, Timestamp_Control *cpu_since_last_period @@ -124,14 +137,14 @@ void _Rate_monotonic_Cancel( ISR_lock_Context *lock_context ); -RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_min_time( +static inline void _Rate_monotonic_Reset_min_time( Timestamp_Control *min_time ) { _Timestamp_Set( min_time, 0x7fffffff, 0x7fffffff ); } -RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_statistics( +static inline void _Rate_monotonic_Reset_statistics( Rate_monotonic_Control *the_period ) { diff --git a/cpukit/include/rtems/rtems/region.h b/cpukit/include/rtems/rtems/region.h index 1e35344f7d..3d9c2bd8bc 100644 --- a/cpukit/include/rtems/rtems/region.h +++ b/cpukit/include/rtems/rtems/region.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassicRegion + * * @brief This header file defines the Region Manager API. */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -193,7 +195,8 @@ rtems_status_code rtems_region_get_segment_size( * * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a * region. The number of regions available to the application is configured - * through the #CONFIGURE_MAXIMUM_REGIONS application configuration option. + * through the @ref CONFIGURE_MAXIMUM_REGIONS application configuration + * option. * * @retval ::RTEMS_INVALID_SIZE The ``page_size`` parameter was invalid. * @@ -217,7 +220,7 @@ rtems_status_code rtems_region_get_segment_size( * cause the calling task to be preempted. * * * The number of regions available to the application is configured through - * the #CONFIGURE_MAXIMUM_REGIONS application configuration option. + * the @ref CONFIGURE_MAXIMUM_REGIONS application configuration option. * * * Where the object class corresponding to the directive is configured to use * unlimited objects, the directive may allocate memory from the RTEMS diff --git a/cpukit/include/rtems/rtems/regiondata.h b/cpukit/include/rtems/rtems/regiondata.h index 5852f4cb45..28740d83f8 100644 --- a/cpukit/include/rtems/rtems/regiondata.h +++ b/cpukit/include/rtems/rtems/regiondata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_REGIONDATA_H diff --git a/cpukit/include/rtems/rtems/regionimpl.h b/cpukit/include/rtems/rtems/regionimpl.h index 85facea5e7..adb481f3e7 100644 --- a/cpukit/include/rtems/rtems/regionimpl.h +++ b/cpukit/include/rtems/rtems/regionimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_REGIONIMPL_H @@ -47,7 +66,7 @@ extern "C" { * This function allocates a region control block from * the inactive chain of free region control blocks. */ -RTEMS_INLINE_ROUTINE Region_Control *_Region_Allocate( void ) +static inline Region_Control *_Region_Allocate( void ) { return (Region_Control *) _Objects_Allocate( &_Region_Information ); } @@ -58,7 +77,7 @@ RTEMS_INLINE_ROUTINE Region_Control *_Region_Allocate( void ) * This routine frees a region control block to the * inactive chain of free region control blocks. */ -RTEMS_INLINE_ROUTINE void _Region_Free ( +static inline void _Region_Free ( Region_Control *the_region ) { @@ -66,7 +85,7 @@ RTEMS_INLINE_ROUTINE void _Region_Free ( _Objects_Free( &_Region_Information, &the_region->Object ); } -RTEMS_INLINE_ROUTINE Region_Control *_Region_Get_and_lock( Objects_Id id ) +static inline Region_Control *_Region_Get_and_lock( Objects_Id id ) { Region_Control *the_region; @@ -84,7 +103,7 @@ RTEMS_INLINE_ROUTINE Region_Control *_Region_Get_and_lock( Objects_Id id ) return NULL; } -RTEMS_INLINE_ROUTINE void _Region_Unlock( Region_Control *the_region ) +static inline void _Region_Unlock( Region_Control *the_region ) { (void) the_region; _RTEMS_Unlock_allocator(); @@ -97,7 +116,7 @@ RTEMS_INLINE_ROUTINE void _Region_Unlock( Region_Control *the_region ) * If successful, it returns the address of the allocated segment. * Otherwise, it returns NULL. */ -RTEMS_INLINE_ROUTINE void *_Region_Allocate_segment ( +static inline void *_Region_Allocate_segment ( Region_Control *the_region, uintptr_t size ) @@ -110,7 +129,7 @@ RTEMS_INLINE_ROUTINE void *_Region_Allocate_segment ( * * This function frees the_segment to the_region. */ -RTEMS_INLINE_ROUTINE bool _Region_Free_segment ( +static inline bool _Region_Free_segment ( Region_Control *the_region, void *the_segment ) diff --git a/cpukit/include/rtems/rtems/scheduler.h b/cpukit/include/rtems/rtems/scheduler.h new file mode 100644 index 0000000000..bec4932c6c --- /dev/null +++ b/cpukit/include/rtems/rtems/scheduler.h @@ -0,0 +1,551 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSImplClassicScheduler + * + * @brief This header file defines the main parts of the Scheduler Manager API. + */ + +/* + * Copyright (C) 2013, 2021 embedded brains GmbH & Co. KG + * Copyright (C) 1988, 2017 On-Line Applications Research Corporation (OAR) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +/* Generated from spec:/rtems/scheduler/if/header */ + +#ifndef _RTEMS_RTEMS_SCHEDULER_H +#define _RTEMS_RTEMS_SCHEDULER_H + +#include <stddef.h> +#include <stdint.h> +#include <sys/cpuset.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/types.h> +#include <rtems/score/smp.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Generated from spec:/rtems/scheduler/if/group */ + +/** + * @defgroup RTEMSAPIClassicScheduler Scheduler Manager + * + * @ingroup RTEMSAPIClassic + * + * @brief The scheduling concepts relate to the allocation of processing time + * for tasks. + * + * The concept of scheduling in real-time systems dictates the ability to + * provide an immediate response to specific external events, particularly the + * necessity of scheduling tasks to run within a specified time limit after the + * occurrence of an event. For example, software embedded in life-support + * systems used to monitor hospital patients must take instant action if a + * change in the patient’s status is detected. + * + * The component of RTEMS responsible for providing this capability is + * appropriately called the scheduler. The scheduler’s sole purpose is to + * allocate the all important resource of processor time to the various tasks + * competing for attention. + */ + +/* Generated from spec:/rtems/scheduler/if/ident */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Identifies a scheduler by the object name. + * + * @param name is the scheduler name to look up. + * + * @param[out] id is the pointer to an ::rtems_id object. When the directive + * call is successful, the identifier of the scheduler will be stored in this + * object. + * + * This directive obtains a scheduler identifier associated with the scheduler + * name specified in ``name``. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_NAME There was no scheduler associated with the + * name. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. + * + * @par Notes + * @parblock + * The scheduler name is determined by the scheduler configuration. + * + * The scheduler identifier is used with other scheduler related directives to + * access the scheduler. + * @endparblock + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_ident( rtems_name name, rtems_id *id ); + +/* Generated from spec:/rtems/scheduler/if/ident-by-processor */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Identifies a scheduler by the processor index. + * + * @param cpu_index is the processor index to identify the scheduler. + * + * @param[out] id is the pointer to an ::rtems_id object. When the directive + * call is successful, the identifier of the scheduler will be stored in this + * object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_NAME The processor index was invalid. + * + * @retval ::RTEMS_INCORRECT_STATE The processor index was valid, however, the + * corresponding processor was not owned by a scheduler. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_ident_by_processor( + uint32_t cpu_index, + rtems_id *id +); + +/* Generated from spec:/rtems/scheduler/if/ident-by-processor-set */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Identifies a scheduler by the processor set. + * + * @param cpusetsize is the size of the processor set referenced by ``cpuset`` + * in bytes. The size shall be positive. + * + * @param cpuset is the pointer to a cpu_set_t. The referenced processor set + * will be used to identify the scheduler. + * + * @param[out] id is the pointer to an ::rtems_id object. When the directive + * call is successful, the identifier of the scheduler will be stored in this + * object. + * + * The scheduler is selected according to the highest numbered online processor + * in the specified processor set. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_SIZE The processor set size was invalid. + * + * @retval ::RTEMS_INVALID_NAME The processor set contained no online + * processor. + * + * @retval ::RTEMS_INCORRECT_STATE The processor set was valid, however, the + * highest numbered online processor in the processor set was not owned by a + * scheduler. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_ident_by_processor_set( + size_t cpusetsize, + const cpu_set_t *cpuset, + rtems_id *id +); + +/* Generated from spec:/rtems/scheduler/if/get-maximum-priority */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Gets the maximum task priority of the scheduler. + * + * @param scheduler_id is the scheduler identifier. + * + * @param[out] priority is the pointer to an ::rtems_task_priority object. + * When the directive the maximum priority of the scheduler will be stored in + * this object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_get_maximum_priority( + rtems_id scheduler_id, + rtems_task_priority *priority +); + +/* Generated from spec:/rtems/scheduler/if/map-priority-to-posix */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Maps a Classic API task priority to the corresponding POSIX thread + * priority. + * + * @param scheduler_id is the scheduler identifier. + * + * @param priority is the Classic API task priority to map. + * + * @param[out] posix_priority is the pointer to an ``int`` object. When the + * directive call is successful, the POSIX thread priority value + * corresponding to the specified Classic API task priority value will be + * stored in this object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``posix_priority`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_INVALID_PRIORITY The Classic API task priority was invalid. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_map_priority_to_posix( + rtems_id scheduler_id, + rtems_task_priority priority, + int *posix_priority +); + +/* Generated from spec:/rtems/scheduler/if/map-priority-from-posix */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Maps a POSIX thread priority to the corresponding Classic API task + * priority. + * + * @param scheduler_id is the scheduler identifier. + * + * @param posix_priority is the POSIX thread priority to map. + * + * @param[out] priority is the pointer to an ::rtems_task_priority object. + * When the directive call is successful, the Classic API task priority value + * corresponding to the specified POSIX thread priority value will be stored + * in this object. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_INVALID_PRIORITY The POSIX thread priority was invalid. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_map_priority_from_posix( + rtems_id scheduler_id, + int posix_priority, + rtems_task_priority *priority +); + +/* Generated from spec:/rtems/scheduler/if/get-processor */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Returns the index of the current processor. + * + * Where the system was built with SMP support disabled, this directive + * evaluates to a compile time constant of zero. + * + * Where the system was built with SMP support enabled, this directive returns + * the index of the current processor. The set of processor indices is the + * range of integers starting with zero up to + * rtems_scheduler_get_processor_maximum() minus one. + * + * @return Returns the index of the current processor. + * + * @par Notes + * Outside of sections with disabled thread dispatching the current processor + * index may change after every instruction since the thread may migrate from + * one processor to another. Sections with disabled interrupts are sections + * with thread dispatching disabled. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +uint32_t rtems_scheduler_get_processor( void ); + +/* Generated from spec:/rtems/scheduler/if/get-processor-macro */ +#define rtems_scheduler_get_processor() _SMP_Get_current_processor() + +/* Generated from spec:/rtems/scheduler/if/get-processor-maximum */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Returns the processor maximum supported by the system. + * + * Where the system was built with SMP support disabled, this directive + * evaluates to a compile time constant of one. + * + * Where the system was built with SMP support enabled, this directive returns + * the minimum of the processors (physically or virtually) available at the + * target and the configured processor maximum (see @ref + * CONFIGURE_MAXIMUM_PROCESSORS). Not all processors in the range from + * processor index zero to the last processor index (which is the processor + * maximum minus one) may be configured to be used by a scheduler or may be + * online (online processors have a scheduler assigned). + * + * @return Returns the processor maximum supported by the system. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +uint32_t rtems_scheduler_get_processor_maximum( void ); + +/* Generated from spec:/rtems/scheduler/if/get-processor-maximum-macro */ +#define rtems_scheduler_get_processor_maximum() _SMP_Get_processor_maximum() + +/* Generated from spec:/rtems/scheduler/if/get-processor-set */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Gets the set of processors owned by the scheduler. + * + * @param scheduler_id is the scheduler identifier. + * + * @param cpusetsize is the size of the processor set referenced by ``cpuset`` + * in bytes. + * + * @param[out] cpuset is the pointer to a cpu_set_t object. When the directive + * call is successful, the processor set of the scheduler will be stored in + * this object. A set bit in the processor set means that the corresponding + * processor is owned by the scheduler, otherwise the bit is cleared. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_INVALID_SIZE The provided processor set was too small for + * the set of processors owned by the scheduler. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within any runtime context. + * + * * The directive will not cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_get_processor_set( + rtems_id scheduler_id, + size_t cpusetsize, + cpu_set_t *cpuset +); + +/* Generated from spec:/rtems/scheduler/if/add-processor */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Adds the processor to the set of processors owned by the scheduler. + * + * @param scheduler_id is the scheduler identifier. + * + * @param cpu_index is the index of the processor to add. + * + * This directive adds the processor specified by the ``cpu_index`` to the + * scheduler specified by ``scheduler_id``. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_NOT_CONFIGURED The processor was not configured to be used + * by the application. + * + * @retval ::RTEMS_INCORRECT_STATE The processor was configured to be used by + * the application, however, it was not online. + * + * @retval ::RTEMS_RESOURCE_IN_USE The processor was already assigned to a + * scheduler. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_add_processor( + rtems_id scheduler_id, + uint32_t cpu_index +); + +/* Generated from spec:/rtems/scheduler/if/remove-processor */ + +/** + * @ingroup RTEMSAPIClassicScheduler + * + * @brief Removes the processor from the set of processors owned by the + * scheduler. + * + * @param scheduler_id is the scheduler identifier. + * + * @param cpu_index is the index of the processor to remove. + * + * This directive removes the processor specified by the ``cpu_index`` from the + * scheduler specified by ``scheduler_id``. + * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the + * identifier specified by ``scheduler_id``. + * + * @retval ::RTEMS_INVALID_NUMBER The processor was not owned by the scheduler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The processor was required by at least one + * non-idle task that used the scheduler as its home scheduler. + * + * @retval ::RTEMS_RESOURCE_IN_USE The processor was the last processor owned + * by the scheduler and there was at least one task that used the scheduler + * as a helping scheduler. + * + * @par Notes + * Removing a processor from a scheduler is a complex operation that involves + * all tasks of the system. + * + * @par Constraints + * @parblock + * The following constraints apply to this directive: + * + * * The directive may be called from within device driver initialization + * context. + * + * * The directive may be called from within task context. + * + * * The directive may obtain and release the object allocator mutex. This may + * cause the calling task to be preempted. + * @endparblock + */ +rtems_status_code rtems_scheduler_remove_processor( + rtems_id scheduler_id, + uint32_t cpu_index +); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_RTEMS_SCHEDULER_H */ diff --git a/cpukit/include/rtems/rtems/sem.h b/cpukit/include/rtems/rtems/sem.h index 31156b5e43..73e725f82d 100644 --- a/cpukit/include/rtems/rtems/sem.h +++ b/cpukit/include/rtems/rtems/sem.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -203,13 +203,13 @@ extern "C" { * * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a * semaphore. The number of semaphores available to the application is - * configured through the #CONFIGURE_MAXIMUM_SEMAPHORES application + * configured through the @ref CONFIGURE_MAXIMUM_SEMAPHORES application * configuration option. * * @retval ::RTEMS_TOO_MANY In multiprocessing configurations, there was no * inactive global object available to create a global semaphore. The number * of global objects available to the application is configured through the - * #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration option. + * @ref CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration option. * * @retval ::RTEMS_INVALID_PRIORITY The ``priority_ceiling`` parameter was * invalid. @@ -243,7 +243,7 @@ extern "C" { * message to remote nodes. This may preempt the calling task. * * * The number of semaphores available to the application is configured - * through the #CONFIGURE_MAXIMUM_SEMAPHORES application configuration + * through the @ref CONFIGURE_MAXIMUM_SEMAPHORES application configuration * option. * * * Where the object class corresponding to the directive is configured to use @@ -251,8 +251,8 @@ extern "C" { * Workspace. * * * The number of global objects available to the application is configured - * through the #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration - * option. + * through the @ref CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application + * configuration option. * @endparblock */ rtems_status_code rtems_semaphore_create( diff --git a/cpukit/include/rtems/rtems/semdata.h b/cpukit/include/rtems/rtems/semdata.h index 2612f1a902..88400d3602 100644 --- a/cpukit/include/rtems/rtems/semdata.h +++ b/cpukit/include/rtems/rtems/semdata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2008, 2016. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_SEMDATA_H diff --git a/cpukit/include/rtems/rtems/semimpl.h b/cpukit/include/rtems/rtems/semimpl.h index bc0b4d3a9d..5164c593f7 100644 --- a/cpukit/include/rtems/rtems/semimpl.h +++ b/cpukit/include/rtems/rtems/semimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_SEMIMPL_H @@ -59,7 +78,7 @@ typedef enum { SEMAPHORE_DISCIPLINE_FIFO } Semaphore_Discipline; -RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Get_flags( +static inline uintptr_t _Semaphore_Get_flags( const Semaphore_Control *the_semaphore ) { @@ -67,7 +86,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Get_flags( return (uintptr_t) the_semaphore->Object.Node.previous; } -RTEMS_INLINE_ROUTINE void _Semaphore_Set_flags( +static inline void _Semaphore_Set_flags( Semaphore_Control *the_semaphore, uintptr_t flags ) @@ -76,14 +95,14 @@ RTEMS_INLINE_ROUTINE void _Semaphore_Set_flags( the_semaphore->Object.Node.previous = (Chain_Node *) flags; } -RTEMS_INLINE_ROUTINE Semaphore_Variant _Semaphore_Get_variant( +static inline Semaphore_Variant _Semaphore_Get_variant( uintptr_t flags ) { return (Semaphore_Variant) ( flags & 0x7 ); } -RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Set_variant( +static inline uintptr_t _Semaphore_Set_variant( uintptr_t flags, Semaphore_Variant variant ) @@ -91,14 +110,14 @@ RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Set_variant( return flags | variant; } -RTEMS_INLINE_ROUTINE Semaphore_Discipline _Semaphore_Get_discipline( +static inline Semaphore_Discipline _Semaphore_Get_discipline( uintptr_t flags ) { return (Semaphore_Discipline) ( ( flags >> 3 ) & 0x1 ); } -RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Set_discipline( +static inline uintptr_t _Semaphore_Set_discipline( uintptr_t flags, Semaphore_Discipline discipline ) @@ -107,20 +126,20 @@ RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Set_discipline( } #if defined(RTEMS_MULTIPROCESSING) -RTEMS_INLINE_ROUTINE bool _Semaphore_Is_global( +static inline bool _Semaphore_Is_global( uintptr_t flags ) { return ( flags & 0x10 ) != 0; } -RTEMS_INLINE_ROUTINE uintptr_t _Semaphore_Make_global( uintptr_t flags ) +static inline uintptr_t _Semaphore_Make_global( uintptr_t flags ) { return flags | 0x10; } #endif -RTEMS_INLINE_ROUTINE const Thread_queue_Operations *_Semaphore_Get_operations( +static inline const Thread_queue_Operations *_Semaphore_Get_operations( uintptr_t flags ) { @@ -144,7 +163,7 @@ RTEMS_INLINE_ROUTINE const Thread_queue_Operations *_Semaphore_Get_operations( * This function allocates a semaphore control block from * the inactive chain of free semaphore control blocks. */ -RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Allocate( void ) +static inline Semaphore_Control *_Semaphore_Allocate( void ) { return (Semaphore_Control *) _Objects_Allocate( &_Semaphore_Information ); } @@ -156,14 +175,14 @@ RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Allocate( void ) * This routine frees a semaphore control block to the * inactive chain of free semaphore control blocks. */ -RTEMS_INLINE_ROUTINE void _Semaphore_Free ( +static inline void _Semaphore_Free ( Semaphore_Control *the_semaphore ) { _Objects_Free( &_Semaphore_Information, &the_semaphore->Object ); } -RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get( +static inline Semaphore_Control *_Semaphore_Get( Objects_Id id, Thread_queue_Context *queue_context ) diff --git a/cpukit/include/rtems/rtems/semmp.h b/cpukit/include/rtems/rtems/semmp.h index e69d338ddd..7fbf5c9046 100644 --- a/cpukit/include/rtems/rtems/semmp.h +++ b/cpukit/include/rtems/rtems/semmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_SEMMP_H @@ -64,7 +83,7 @@ typedef struct { Objects_Id proxy_id; } Semaphore_MP_Packet; -RTEMS_INLINE_ROUTINE bool _Semaphore_MP_Is_remote( Objects_Id id ) +static inline bool _Semaphore_MP_Is_remote( Objects_Id id ) { return _Objects_MP_Is_remote( id, &_Semaphore_Information ); } diff --git a/cpukit/include/rtems/rtems/signal.h b/cpukit/include/rtems/rtems/signal.h index c9fbd79b5d..fb5254f5d9 100644 --- a/cpukit/include/rtems/rtems/signal.h +++ b/cpukit/include/rtems/rtems/signal.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassicSignal + * * @brief This header file defines the parts of the Signal Manager API. */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/rtems/signalimpl.h b/cpukit/include/rtems/rtems/signalimpl.h index db1ff71620..1a24580dfb 100644 --- a/cpukit/include/rtems/rtems/signalimpl.h +++ b/cpukit/include/rtems/rtems/signalimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_SIGNALIMPL_H diff --git a/cpukit/include/rtems/rtems/signalmp.h b/cpukit/include/rtems/rtems/signalmp.h index 8e1fb06003..bdd27d9be7 100644 --- a/cpukit/include/rtems/rtems/signalmp.h +++ b/cpukit/include/rtems/rtems/signalmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_SIGNALMP_H diff --git a/cpukit/include/rtems/rtems/status.h b/cpukit/include/rtems/rtems/status.h index 872bb9b2b3..92a8b03c09 100644 --- a/cpukit/include/rtems/rtems/status.h +++ b/cpukit/include/rtems/rtems/status.h @@ -3,12 +3,14 @@ /** * @file * + * @ingroup RTEMSImplClassic + * * @brief This header file provides the status codes of Classic API directives * and support functions. */ /* - * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2014, 2020 embedded brains GmbH & Co. KG * Copyright (C) 1989, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/rtems/statusimpl.h b/cpukit/include/rtems/rtems/statusimpl.h index 8b63eca742..2ea12d9f6c 100644 --- a/cpukit/include/rtems/rtems/statusimpl.h +++ b/cpukit/include/rtems/rtems/statusimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_STATUSIMPL_H @@ -44,14 +63,14 @@ extern "C" { * @{ */ -RTEMS_INLINE_ROUTINE rtems_status_code _Status_Get( +static inline rtems_status_code _Status_Get( Status_Control status ) { return (rtems_status_code) STATUS_GET_CLASSIC( status ); } -RTEMS_INLINE_ROUTINE rtems_status_code _Status_Get_after_wait( +static inline rtems_status_code _Status_Get_after_wait( const Thread_Control *executing ) { diff --git a/cpukit/include/rtems/rtems/support.h b/cpukit/include/rtems/rtems/support.h index 60e090ccec..bb2e6e3633 100644 --- a/cpukit/include/rtems/rtems/support.h +++ b/cpukit/include/rtems/rtems/support.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassic + * * @brief This header file defines support services of the API. */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -113,8 +115,8 @@ static inline bool rtems_is_name_valid( rtems_name name ) * value. * * @par Notes - * The number of clock ticks per second is defined by the - * #CONFIGURE_MICROSECONDS_PER_TICK application configuration option. + * The number of clock ticks per second is defined by the @ref + * CONFIGURE_MICROSECONDS_PER_TICK application configuration option. * * @par Constraints * @parblock @@ -164,8 +166,8 @@ static inline bool rtems_is_name_valid( rtems_name name ) * @return Returns the number of clock ticks for the milliseconds value. * * @par Notes - * The number of clock ticks per second is defined by the - * #CONFIGURE_MICROSECONDS_PER_TICK application configuration option. + * The number of clock ticks per second is defined by the @ref + * CONFIGURE_MICROSECONDS_PER_TICK application configuration option. * * @par Constraints * @parblock diff --git a/cpukit/include/rtems/rtems/taskmp.h b/cpukit/include/rtems/rtems/taskmp.h index d991df0c51..5dfe56d9d0 100644 --- a/cpukit/include/rtems/rtems/taskmp.h +++ b/cpukit/include/rtems/rtems/taskmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2013. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_TASKMP_H diff --git a/cpukit/include/rtems/rtems/tasks.h b/cpukit/include/rtems/rtems/tasks.h index 8c6e8a3bca..84dd646fe7 100644 --- a/cpukit/include/rtems/rtems/tasks.h +++ b/cpukit/include/rtems/rtems/tasks.h @@ -9,8 +9,8 @@ */ /* - * Copyright (C) 2013, 2021 embedded brains GmbH (http://www.embedded-brains.de) - * Copyright (C) 1988, 2017 On-Line Applications Research Corporation (OAR) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG + * Copyright (C) 1988, 2023 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -68,7 +68,6 @@ #include <rtems/score/context.h> #include <rtems/score/cpu.h> #include <rtems/score/object.h> -#include <rtems/score/smp.h> #include <rtems/score/stack.h> #include <rtems/score/watchdogticks.h> @@ -76,29 +75,6 @@ extern "C" { #endif -/* Generated from spec:/rtems/scheduler/if/group */ - -/** - * @defgroup RTEMSAPIClassicScheduler Scheduler Manager - * - * @ingroup RTEMSAPIClassic - * - * @brief The scheduling concepts relate to the allocation of processing time - * for tasks. - * - * The concept of scheduling in real-time systems dictates the ability to - * provide an immediate response to specific external events, particularly the - * necessity of scheduling tasks to run within a specified time limit after the - * occurrence of an event. For example, software embedded in life-support - * systems used to monitor hospital patients must take instant action if a - * change in the patient’s status is detected. - * - * The component of RTEMS responsible for providing this capability is - * appropriately called the scheduler. The scheduler’s sole purpose is to - * allocate the all important resource of processor time to the various tasks - * competing for attention. - */ - /* Generated from spec:/rtems/task/if/group */ /** @@ -184,8 +160,8 @@ typedef struct { * alignment of an application executable. * * The application may configure the maximum thread-local storage size for all - * threads explicitly through the #CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE - * configuration option. + * threads explicitly through the @ref + * CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE configuration option. */ size_t maximum_thread_local_storage_size; @@ -258,7 +234,7 @@ typedef void rtems_task; /** * @ingroup RTEMSAPIClassicTasks * - * @brief This type defines the entry point of an RTEMS task. + * @brief This type defines the task entry point of an RTEMS task. */ typedef rtems_task ( *rtems_task_entry )( rtems_task_argument ); @@ -307,6 +283,25 @@ typedef struct { rtems_task_argument argument; } rtems_initialization_tasks_table; +/* Generated from spec:/rtems/task/if/maximum-priority-impl */ + +/** + * @ingroup RTEMSImplClassicTask + * + * @brief Returns the maximum priority of the scheduler with index zero. + */ +rtems_task_priority _RTEMS_Maximum_priority( void ); + +/* Generated from spec:/rtems/task/if/maximum-priority */ + +/** + * @ingroup RTEMSAPIClassicTasks + * + * @brief This runtime constant represents the lowest (least important) task + * priority of the scheduler with index zero. + */ +#define RTEMS_MAXIMUM_PRIORITY _RTEMS_Maximum_priority() + /* Generated from spec:/rtems/task/if/minimum-priority */ /** @@ -330,8 +325,8 @@ typedef struct { * risk of blown stacks for most user applications. Using this constant when * specifying the task stack size, indicates that the stack size will be at * least RTEMS_MINIMUM_STACK_SIZE bytes in size. If the user configured - * minimum stack size (see #CONFIGURE_MINIMUM_TASK_STACK_SIZE) is larger than - * the recommended minimum, then it will be used. + * minimum stack size (see @ref CONFIGURE_MINIMUM_TASK_STACK_SIZE) is larger + * than the recommended minimum, then it will be used. */ #define RTEMS_MINIMUM_STACK_SIZE STACK_MINIMUM_SIZE @@ -425,474 +420,6 @@ typedef bool( *rtems_task_visitor )( rtems_tcb *, void * ); */ #define RTEMS_YIELD_PROCESSOR WATCHDOG_NO_TIMEOUT -/* Generated from spec:/score/if/maximum-priority */ - -/** - * @brief Returns the maximum priority of the scheduler with index zero. - */ -rtems_task_priority _RTEMS_Maximum_priority( void ); - -/* Generated from spec:/rtems/task/if/maximum-priority */ - -/** - * @ingroup RTEMSAPIClassicTasks - * - * @brief This constant variable provides the lowest (least important) task - * priority of the first configured scheduler. - */ -#define RTEMS_MAXIMUM_PRIORITY _RTEMS_Maximum_priority() - -/* Generated from spec:/rtems/scheduler/if/ident */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Identifies a scheduler by the object name. - * - * @param name is the scheduler name to look up. - * - * @param[out] id is the pointer to an ::rtems_id object. When the directive - * call is successful, the identifier of the scheduler will be stored in this - * object. - * - * This directive obtains a scheduler identifier associated with the scheduler - * name specified in ``name``. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_NAME There was no scheduler associated with the - * name. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. - * - * @par Notes - * @parblock - * The scheduler name is determined by the scheduler configuration. - * - * The scheduler identifier is used with other scheduler related directives to - * access the scheduler. - * @endparblock - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_ident( rtems_name name, rtems_id *id ); - -/* Generated from spec:/rtems/scheduler/if/ident-by-processor */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Identifies a scheduler by the processor index. - * - * @param cpu_index is the processor index to identify the scheduler. - * - * @param[out] id is the pointer to an ::rtems_id object. When the directive - * call is successful, the identifier of the scheduler will be stored in this - * object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_NAME The processor index was invalid. - * - * @retval ::RTEMS_INCORRECT_STATE The processor index was valid, however, the - * corresponding processor was not owned by a scheduler. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_ident_by_processor( - uint32_t cpu_index, - rtems_id *id -); - -/* Generated from spec:/rtems/scheduler/if/ident-by-processor-set */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Identifies a scheduler by the processor set. - * - * @param cpusetsize is the size of the processor set referenced by ``cpuset`` - * in bytes. The size shall be positive. - * - * @param cpuset is the pointer to a cpu_set_t. The referenced processor set - * will be used to identify the scheduler. - * - * @param[out] id is the pointer to an ::rtems_id object. When the directive - * call is successful, the identifier of the scheduler will be stored in this - * object. - * - * The scheduler is selected according to the highest numbered online processor - * in the specified processor set. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``id`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_SIZE The processor set size was invalid. - * - * @retval ::RTEMS_INVALID_NAME The processor set contained no online - * processor. - * - * @retval ::RTEMS_INCORRECT_STATE The processor set was valid, however, the - * highest numbered online processor in the processor set was not owned by a - * scheduler. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_ident_by_processor_set( - size_t cpusetsize, - const cpu_set_t *cpuset, - rtems_id *id -); - -/* Generated from spec:/rtems/scheduler/if/get-maximum-priority */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Gets the maximum task priority of the scheduler. - * - * @param scheduler_id is the scheduler identifier. - * - * @param[out] priority is the pointer to an ::rtems_task_priority object. - * When the directive the maximum priority of the scheduler will be stored in - * this object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_get_maximum_priority( - rtems_id scheduler_id, - rtems_task_priority *priority -); - -/* Generated from spec:/rtems/scheduler/if/map-priority-to-posix */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Maps a Classic API task priority to the corresponding POSIX thread - * priority. - * - * @param scheduler_id is the scheduler identifier. - * - * @param priority is the Classic API task priority to map. - * - * @param[out] posix_priority is the pointer to an ``int`` object. When the - * directive call is successful, the POSIX thread priority value - * corresponding to the specified Classic API task priority value will be - * stored in this object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``posix_priority`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_INVALID_PRIORITY The Classic API task priority was invalid. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_map_priority_to_posix( - rtems_id scheduler_id, - rtems_task_priority priority, - int *posix_priority -); - -/* Generated from spec:/rtems/scheduler/if/map-priority-from-posix */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Maps a POSIX thread priority to the corresponding Classic API task - * priority. - * - * @param scheduler_id is the scheduler identifier. - * - * @param posix_priority is the POSIX thread priority to map. - * - * @param[out] priority is the pointer to an ::rtems_task_priority object. - * When the directive call is successful, the Classic API task priority value - * corresponding to the specified POSIX thread priority value will be stored - * in this object. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``priority`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_INVALID_PRIORITY The POSIX thread priority was invalid. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_map_priority_from_posix( - rtems_id scheduler_id, - int posix_priority, - rtems_task_priority *priority -); - -/* Generated from spec:/rtems/scheduler/if/get-processor */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Returns the index of the current processor. - * - * Where the system was built with SMP support disabled, this directive - * evaluates to a compile time constant of zero. - * - * Where the system was built with SMP support enabled, this directive returns - * the index of the current processor. The set of processor indices is the - * range of integers starting with zero up to - * rtems_scheduler_get_processor_maximum() minus one. - * - * @return Returns the index of the current processor. - * - * @par Notes - * Outside of sections with disabled thread dispatching the current processor - * index may change after every instruction since the thread may migrate from - * one processor to another. Sections with disabled interrupts are sections - * with thread dispatching disabled. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -uint32_t rtems_scheduler_get_processor( void ); - -/* Generated from spec:/rtems/scheduler/if/get-processor-macro */ -#define rtems_scheduler_get_processor() _SMP_Get_current_processor() - -/* Generated from spec:/rtems/scheduler/if/get-processor-maximum */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Returns the processor maximum supported by the system. - * - * Where the system was built with SMP support disabled, this directive - * evaluates to a compile time constant of one. - * - * Where the system was built with SMP support enabled, this directive returns - * the minimum of the processors (physically or virtually) available at the - * target and the configured processor maximum (see - * #CONFIGURE_MAXIMUM_PROCESSORS). Not all processors in the range from - * processor index zero to the last processor index (which is the processor - * maximum minus one) may be configured to be used by a scheduler or may be - * online (online processors have a scheduler assigned). - * - * @return Returns the processor maximum supported by the system. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -uint32_t rtems_scheduler_get_processor_maximum( void ); - -/* Generated from spec:/rtems/scheduler/if/get-processor-maximum-macro */ -#define rtems_scheduler_get_processor_maximum() _SMP_Get_processor_maximum() - -/* Generated from spec:/rtems/scheduler/if/get-processor-set */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Gets the set of processors owned by the scheduler. - * - * @param scheduler_id is the scheduler identifier. - * - * @param cpusetsize is the size of the processor set referenced by ``cpuset`` - * in bytes. - * - * @param[out] cpuset is the pointer to a cpu_set_t object. When the directive - * call is successful, the processor set of the scheduler will be stored in - * this object. A set bit in the processor set means that the corresponding - * processor is owned by the scheduler, otherwise the bit is cleared. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ADDRESS The ``cpuset`` parameter was NULL. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_INVALID_SIZE The provided processor set was too small for - * the set of processors owned by the scheduler. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within any runtime context. - * - * * The directive will not cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_get_processor_set( - rtems_id scheduler_id, - size_t cpusetsize, - cpu_set_t *cpuset -); - -/* Generated from spec:/rtems/scheduler/if/add-processor */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Adds the processor to the set of processors owned by the scheduler. - * - * @param scheduler_id is the scheduler identifier. - * - * @param cpu_index is the index of the processor to add. - * - * This directive adds the processor specified by the ``cpu_index`` to the - * scheduler specified by ``scheduler_id``. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_NOT_CONFIGURED The processor was not configured to be used - * by the application. - * - * @retval ::RTEMS_INCORRECT_STATE The processor was configured to be used by - * the application, however, it was not online. - * - * @retval ::RTEMS_RESOURCE_IN_USE The processor was already assigned to a - * scheduler. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_add_processor( - rtems_id scheduler_id, - uint32_t cpu_index -); - -/* Generated from spec:/rtems/scheduler/if/remove-processor */ - -/** - * @ingroup RTEMSAPIClassicScheduler - * - * @brief Removes the processor from the set of processors owned by the - * scheduler. - * - * @param scheduler_id is the scheduler identifier. - * - * @param cpu_index is the index of the processor to remove. - * - * This directive removes the processor specified by the ``cpu_index`` from the - * scheduler specified by ``scheduler_id``. - * - * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. - * - * @retval ::RTEMS_INVALID_ID There was no scheduler associated with the - * identifier specified by ``scheduler_id``. - * - * @retval ::RTEMS_INVALID_NUMBER The processor was not owned by the scheduler. - * - * @retval ::RTEMS_RESOURCE_IN_USE The set of processors owned by the scheduler - * would have been empty after the processor removal and there was at least - * one non-idle task that used this scheduler as its home scheduler. - * - * @par Notes - * Removing a processor from a scheduler is a complex operation that involves - * all tasks of the system. - * - * @par Constraints - * @parblock - * The following constraints apply to this directive: - * - * * The directive may be called from within device driver initialization - * context. - * - * * The directive may be called from within task context. - * - * * The directive may obtain and release the object allocator mutex. This may - * cause the calling task to be preempted. - * @endparblock - */ -rtems_status_code rtems_scheduler_remove_processor( - rtems_id scheduler_id, - uint32_t cpu_index -); - /* Generated from spec:/rtems/task/if/create */ /** @@ -920,15 +447,15 @@ rtems_status_code rtems_scheduler_remove_processor( * task with other task related directives. * * The **initial priority** of the task is specified in ``initial_priority``. - * The scheduler of the created task is the scheduler of the calling task at - * some point during the task creation. The initial task priority specified in - * ``initial_priority`` shall be valid for this scheduler. + * The home scheduler of the created task is the home scheduler of the calling + * task at some time point during the task creation. The initial task priority + * specified in ``initial_priority`` shall be valid for this scheduler. * * The **stack size** of the task is specified in ``stack_size``. If the * requested stack size is less than the configured minimum stack size, then * RTEMS will use the configured minimum as the stack size for this task. The - * configured minimum stack size is defined by the - * #CONFIGURE_MINIMUM_TASK_STACK_SIZE application configuration option. In + * configured minimum stack size is defined by the @ref + * CONFIGURE_MINIMUM_TASK_STACK_SIZE application configuration option. In * addition to being able to specify the task stack size as a integer, there * are two constants which may be specified: * @@ -1056,12 +583,12 @@ rtems_status_code rtems_scheduler_remove_processor( * * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a * task. The number of tasks available to the application is configured - * through the #CONFIGURE_MAXIMUM_TASKS application configuration option. + * through the @ref CONFIGURE_MAXIMUM_TASKS application configuration option. * * @retval ::RTEMS_TOO_MANY In multiprocessing configurations, there was no * inactive global object available to create a global task. The number of - * global objects available to the application is configured through the - * #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration option. + * global objects available to the application is configured through the @ref + * CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration option. * * @retval ::RTEMS_UNSATISFIED There was not enough memory to allocate the task * storage area. The task storage area contains the task stack, the @@ -1088,7 +615,7 @@ rtems_status_code rtems_scheduler_remove_processor( * The task stack size shall account for an target processor dependent * interrupt stack frame which may be placed on the stack of the interrupted * task while servicing an interrupt. The stack checker may be used to monitor - * the stack usage, see #CONFIGURE_STACK_CHECKER_ENABLED. + * the stack usage, see @ref CONFIGURE_STACK_CHECKER_ENABLED. * * For control and maintenance of the task, RTEMS allocates a TCB from the * local TCB free pool and initializes it. @@ -1117,15 +644,15 @@ rtems_status_code rtems_scheduler_remove_processor( * message to remote nodes. This may preempt the calling task. * * * The number of tasks available to the application is configured through the - * #CONFIGURE_MAXIMUM_TASKS application configuration option. + * @ref CONFIGURE_MAXIMUM_TASKS application configuration option. * * * Where the object class corresponding to the directive is configured to use * unlimited objects, the directive may allocate memory from the RTEMS * Workspace. * * * The number of global objects available to the application is configured - * through the #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration - * option. + * through the @ref CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application + * configuration option. * @endparblock */ rtems_status_code rtems_task_create( @@ -1144,7 +671,8 @@ rtems_status_code rtems_task_create( * * @brief Constructs a task from the specified task configuration. * - * @param config is the task configuration. + * @param config is the pointer to an rtems_task_config object. It configures + * the task. * * @param[out] id is the pointer to an ::rtems_id object. When the directive * call is successful, the identifier of the constructed task will be stored @@ -1163,12 +691,13 @@ rtems_status_code rtems_task_create( * @retval ::RTEMS_INVALID_SIZE The thread-local storage size is greater than * the maximum thread-local storage size specified in the task configuration. * The thread-local storage size is determined by the thread-local variables - * used by the application and #CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE. + * used by the application and @ref + * CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE. * * @retval ::RTEMS_INVALID_SIZE The task storage area was too small to provide - * a task stack of the configured minimum size, see - * #CONFIGURE_MINIMUM_TASK_STACK_SIZE. The task storage area contains the - * task stack, the thread-local storage, and the floating-point context on + * a task stack of the configured minimum size, see @ref + * CONFIGURE_MINIMUM_TASK_STACK_SIZE. The task storage area contains the task + * stack, the thread-local storage, and the floating-point context on * architectures with a separate floating-point context. * * @retval ::RTEMS_TOO_MANY There was no inactive task object available to @@ -1207,13 +736,13 @@ rtems_status_code rtems_task_create( * memory allocators. This can simplify the application architecture as well * as any analysis that may be required. * - * The stack space estimate done by <rtems/confdefs.h> assumes that all tasks - * are created by rtems_task_create(). The estimate can be adjusted to take - * user-provided task storage areas into account through the - * #CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE application - * configuration option. + * The stack space estimate done by ``<rtems/confdefs.h>`` assumes that all + * tasks are created by rtems_task_create(). The estimate can be adjusted to + * take user-provided task storage areas into account through the @ref + * CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE application configuration + * option. * - * The #CONFIGURE_MAXIMUM_TASKS should include tasks constructed by + * The @ref CONFIGURE_MAXIMUM_TASKS should include tasks constructed by * rtems_task_construct(). * @endparblock * @@ -1233,15 +762,15 @@ rtems_status_code rtems_task_create( * message to remote nodes. This may preempt the calling task. * * * The number of tasks available to the application is configured through the - * #CONFIGURE_MAXIMUM_TASKS application configuration option. + * @ref CONFIGURE_MAXIMUM_TASKS application configuration option. * * * Where the object class corresponding to the directive is configured to use * unlimited objects, the directive may allocate memory from the RTEMS * Workspace. * * * The number of global objects available to the application is configured - * through the #CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application configuration - * option. + * through the @ref CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS application + * configuration option. * @endparblock */ rtems_status_code rtems_task_construct( @@ -1267,7 +796,8 @@ rtems_status_code rtems_task_construct( * This directive obtains a task identifier associated with the task name * specified in ``name``. * - * A task may obtain its own identifier by specifying #RTEMS_SELF for the name. + * A task may obtain its own identifier by specifying #RTEMS_WHO_AM_I for the + * name. * * The node to search is specified in ``node``. It shall be * @@ -1367,8 +897,8 @@ rtems_id rtems_task_self( void ); * * This directive readies the task, specified by ``id``, for execution based on * the priority and execution mode specified when the task was created. The - * entry point of the task is given in ``entry_point``. The task's entry point - * argument is contained in ``argument``. + * task entry point of the task is given in ``entry_point``. The task's entry + * point argument is contained in ``argument``. * * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. * @@ -1505,13 +1035,25 @@ rtems_status_code rtems_task_restart( * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from within * interrupt context. * + * @retval ::RTEMS_INCORRECT_STATE The task termination procedure was started, + * however, waiting for the terminating task would have resulted in a + * deadlock. + * * @retval ::RTEMS_ILLEGAL_ON_REMOTE_OBJECT The task resided on a remote node. * * @par Notes * @parblock - * RTEMS stops the execution of the task and reclaims the stack memory, any - * allocated delay or timeout timers, the TCB, and, if the task is - * #RTEMS_FLOATING_POINT, its floating point context area. RTEMS explicitly + * The task deletion is done in several steps. Firstly, the task is marked as + * terminating. While the task life of the terminating task is protected, it + * executes normally until it disables the task life protection or it deletes + * itself. A terminating task will eventually stop its normal execution and + * start its termination procedure. The procedure executes in the context of + * the terminating task. The task termination procedure involves the + * destruction of POSIX key values and running the task termination user + * extensions. Once complete the execution of the task is stopped and + * task-specific resources are reclaimed by the system, such as the stack + * memory, any allocated delay or timeout timers, the TCB, and, if the task is + * #RTEMS_FLOATING_POINT, its floating point context area. RTEMS explicitly * does not reclaim the following resources: region segments, partition * buffers, semaphores, timers, or rate monotonic periods. * @@ -1523,10 +1065,12 @@ rtems_status_code rtems_task_restart( * resources and delete itself by restarting it with a special argument or by * sending it a message, an event, or a signal. * - * Deletion of the current task (#RTEMS_SELF) will force RTEMS to select + * Deletion of the calling task (#RTEMS_SELF) will force RTEMS to select * another task to execute. * - * The TCB for the deleted task is reclaimed by RTEMS. + * When a task deletes another task, the calling task waits until the task + * termination procedure of the task being deleted has completed. The + * terminating task inherits the eligible priorities of the calling task. * * When a global task is deleted, the task identifier must be transmitted to * every node in the system for deletion from the local copy of the global @@ -2000,15 +1544,16 @@ rtems_status_code rtems_task_mode( /** * @ingroup RTEMSAPIClassicTasks * - * @brief Wakes up after an interval in clock ticks or yields the processor. + * @brief Wakes up after a count of clock ticks have occurred or yields the + * processor. * - * @param ticks is the interval in clock ticks to delay the task or + * @param ticks is the count of clock ticks to delay the task or * #RTEMS_YIELD_PROCESSOR to yield the processor. * - * This directive blocks the calling task for the specified ``ticks`` of clock - * ticks if the value is not equal to #RTEMS_YIELD_PROCESSOR. When the - * requested interval has elapsed, the task is made ready. The clock tick - * directives automatically updates the delay period. The calling task may + * This directive blocks the calling task for the specified ``ticks`` count of + * clock ticks if the value is not equal to #RTEMS_YIELD_PROCESSOR. When the + * requested count of ticks have occurred, the task is made ready. The clock + * tick directives automatically update the delay period. The calling task may * give up the processor and remain in the ready state by specifying a value of * #RTEMS_YIELD_PROCESSOR in ``ticks``. * @@ -2017,7 +1562,11 @@ rtems_status_code rtems_task_mode( * @par Notes * Setting the system date and time with the rtems_clock_set() directive and * similar directives which set CLOCK_REALTIME have no effect on a - * rtems_task_wake_after() blocked task. + * rtems_task_wake_after() blocked task. The delay until first clock tick will + * never be a whole clock tick interval since this directive will never execute + * exactly on a clock tick. Applications requiring use of a clock + * (CLOCK_REALTIME or CLOCK_MONOTONIC) instead of clock ticks should make use + * of clock_nanosleep(). * * @par Constraints * @parblock diff --git a/cpukit/include/rtems/rtems/tasksdata.h b/cpukit/include/rtems/rtems/tasksdata.h index fb15453e65..1f4a8c83a5 100644 --- a/cpukit/include/rtems/rtems/tasksdata.h +++ b/cpukit/include/rtems/rtems/tasksdata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_TASKSDATA_H diff --git a/cpukit/include/rtems/rtems/tasksimpl.h b/cpukit/include/rtems/rtems/tasksimpl.h index 62a618b635..8c87cfc93b 100644 --- a/cpukit/include/rtems/rtems/tasksimpl.h +++ b/cpukit/include/rtems/rtems/tasksimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_TASKSIMPL_H @@ -56,7 +75,7 @@ rtems_status_code _RTEMS_tasks_Create( RTEMS_tasks_Prepare_stack prepare_stack ); -RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate(void) +static inline Thread_Control *_RTEMS_tasks_Allocate(void) { _Objects_Allocator_lock(); @@ -80,7 +99,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate(void) * * @return The corresponding SuperCore priority. */ -RTEMS_INLINE_ROUTINE Priority_Control _RTEMS_Priority_To_core( +static inline Priority_Control _RTEMS_Priority_To_core( const Scheduler_Control *scheduler, rtems_task_priority priority, bool *valid @@ -100,7 +119,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _RTEMS_Priority_To_core( * * @return The corresponding RTEMS API priority. */ -RTEMS_INLINE_ROUTINE rtems_task_priority _RTEMS_Priority_From_core( +static inline rtems_task_priority _RTEMS_Priority_From_core( const Scheduler_Control *scheduler, Priority_Control priority ) @@ -111,6 +130,14 @@ RTEMS_INLINE_ROUTINE rtems_task_priority _RTEMS_Priority_From_core( /**@}*/ +/** + * @defgroup RTEMSImplClassicScheduler Scheduler Manager + * + * @ingroup RTEMSImplClassic + * + * @brief This group contains the Scheduler Manager implementation. + */ + #if defined(RTEMS_MULTIPROCESSING) #include <rtems/rtems/taskmp.h> #endif diff --git a/cpukit/include/rtems/rtems/timer.h b/cpukit/include/rtems/rtems/timer.h index 0f13c04bda..6af56c1576 100644 --- a/cpukit/include/rtems/rtems/timer.h +++ b/cpukit/include/rtems/rtems/timer.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -284,7 +284,8 @@ typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )( rtem * * @retval ::RTEMS_TOO_MANY There was no inactive object available to create a * timer. The number of timers available to the application is configured - * through the #CONFIGURE_MAXIMUM_TIMERS application configuration option. + * through the @ref CONFIGURE_MAXIMUM_TIMERS application configuration + * option. * * @par Notes * @parblock @@ -308,7 +309,7 @@ typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )( rtem * cause the calling task to be preempted. * * * The number of timers available to the application is configured through - * the #CONFIGURE_MAXIMUM_TIMERS application configuration option. + * the @ref CONFIGURE_MAXIMUM_TIMERS application configuration option. * * * Where the object class corresponding to the directive is configured to use * unlimited objects, the directive may allocate memory from the RTEMS @@ -600,7 +601,7 @@ rtems_status_code rtems_timer_fire_when( * * The directive may be called from within task context. * * * The number of timers available to the application is configured through - * the #CONFIGURE_MAXIMUM_TIMERS application configuration option. + * the @ref CONFIGURE_MAXIMUM_TIMERS application configuration option. * * * Where the object class corresponding to the directive is configured to use * unlimited objects, the directive may allocate memory from the RTEMS diff --git a/cpukit/include/rtems/rtems/timerdata.h b/cpukit/include/rtems/rtems/timerdata.h index 2a7cc03cb1..c66659fe4a 100644 --- a/cpukit/include/rtems/rtems/timerdata.h +++ b/cpukit/include/rtems/rtems/timerdata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,11 +13,28 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2009, 2016 embedded brains GmbH. + * Copyright (C) 2009, 2016 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_TIMERDATA_H diff --git a/cpukit/include/rtems/rtems/timerimpl.h b/cpukit/include/rtems/rtems/timerimpl.h index 8d245d7e5b..5941616d61 100644 --- a/cpukit/include/rtems/rtems/timerimpl.h +++ b/cpukit/include/rtems/rtems/timerimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,11 +13,28 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2016 embedded brains GmbH. + * Copyright (c) 2016 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_RTEMS_TIMER_INL @@ -61,7 +80,7 @@ extern Timer_server_Control *volatile _Timer_server; * This function allocates a timer control block from * the inactive chain of free timer control blocks. */ -RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Allocate( void ) +static inline Timer_Control *_Timer_Allocate( void ) { return (Timer_Control *) _Objects_Allocate( &_Timer_Information ); } @@ -72,14 +91,14 @@ RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Allocate( void ) * This routine frees a timer control block to the * inactive chain of free timer control blocks. */ -RTEMS_INLINE_ROUTINE void _Timer_Free ( +static inline void _Timer_Free ( Timer_Control *the_timer ) { _Objects_Free( &_Timer_Information, &the_timer->Object ); } -RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get( +static inline Timer_Control *_Timer_Get( Objects_Id id, ISR_lock_Context *lock_context ) @@ -91,7 +110,7 @@ RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get( ); } -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Timer_Acquire_critical( +static inline Per_CPU_Control *_Timer_Acquire_critical( Timer_Control *the_timer, ISR_lock_Context *lock_context ) @@ -104,7 +123,7 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Timer_Acquire_critical( return cpu; } -RTEMS_INLINE_ROUTINE void _Timer_Release( +static inline void _Timer_Release( Per_CPU_Control *cpu, ISR_lock_Context *lock_context ) @@ -113,7 +132,7 @@ RTEMS_INLINE_ROUTINE void _Timer_Release( _ISR_lock_ISR_enable( lock_context ); } -RTEMS_INLINE_ROUTINE bool _Timer_Is_interval_class( +static inline bool _Timer_Is_interval_class( Timer_Classes the_class ) { @@ -123,7 +142,7 @@ RTEMS_INLINE_ROUTINE bool _Timer_Is_interval_class( return ( the_class & mask ) == TIMER_CLASS_BIT_NOT_DORMANT; } -RTEMS_INLINE_ROUTINE bool _Timer_Is_on_task_class( +static inline bool _Timer_Is_on_task_class( Timer_Classes the_class ) { @@ -133,14 +152,14 @@ RTEMS_INLINE_ROUTINE bool _Timer_Is_on_task_class( return ( the_class & mask ) == mask; } -RTEMS_INLINE_ROUTINE Per_CPU_Watchdog_index _Timer_Watchdog_header_index( +static inline Per_CPU_Watchdog_index _Timer_Watchdog_header_index( Timer_Classes the_class ) { return (Per_CPU_Watchdog_index) ( the_class & TIMER_CLASS_BIT_TIME_OF_DAY ); } -RTEMS_INLINE_ROUTINE Watchdog_Interval _Timer_Get_CPU_ticks( +static inline Watchdog_Interval _Timer_Get_CPU_ticks( const Per_CPU_Control *cpu ) { @@ -180,7 +199,7 @@ void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog ); void _Timer_server_Routine_adaptor( Watchdog_Control *the_watchdog ); -RTEMS_INLINE_ROUTINE void _Timer_server_Acquire_critical( +static inline void _Timer_server_Acquire_critical( Timer_server_Control *timer_server, ISR_lock_Context *lock_context ) @@ -188,7 +207,7 @@ RTEMS_INLINE_ROUTINE void _Timer_server_Acquire_critical( _ISR_lock_Acquire( &timer_server->Lock, lock_context ); } -RTEMS_INLINE_ROUTINE void _Timer_server_Release_critical( +static inline void _Timer_server_Release_critical( Timer_server_Control *timer_server, ISR_lock_Context *lock_context ) diff --git a/cpukit/include/rtems/rtems/types.h b/cpukit/include/rtems/rtems/types.h index caa75b4f0d..8f85def7c5 100644 --- a/cpukit/include/rtems/rtems/types.h +++ b/cpukit/include/rtems/rtems/types.h @@ -3,11 +3,13 @@ /** * @file * + * @ingroup RTEMSImplClassic + * * @brief This header file provides types used by the Classic API. */ /* - * Copyright (C) 2009, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2009, 2021 embedded brains GmbH & Co. KG * Copyright (C) 1988, 2017 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -59,12 +61,13 @@ #include <sys/_timeval.h> #include <sys/cpuset.h> #include <rtems/rtems/modes.h> -#include <rtems/score/mppkt.h> +#include <rtems/score/cpuopts.h> #include <rtems/score/object.h> #include <rtems/score/watchdogticks.h> #if defined(RTEMS_MULTIPROCESSING) #include <rtems/score/mpci.h> + #include <rtems/score/mppkt.h> #endif #ifdef __cplusplus diff --git a/cpukit/include/rtems/rtl/dlfcn-shell.h b/cpukit/include/rtems/rtl/dlfcn-shell.h index 9383577d25..bf815da294 100644 --- a/cpukit/include/rtems/rtl/dlfcn-shell.h +++ b/cpukit/include/rtems/rtl/dlfcn-shell.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined(_DLFCN_SHELL_H_) diff --git a/cpukit/include/rtems/rtl/rap-shell.h b/cpukit/include/rtems/rtl/rap-shell.h index c2d9112c0f..30d203f5f9 100644 --- a/cpukit/include/rtems/rtl/rap-shell.h +++ b/cpukit/include/rtems/rtl/rap-shell.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2013 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined(_RAP_SHELL_H_) diff --git a/cpukit/include/rtems/rtl/rap.h b/cpukit/include/rtems/rtl/rap.h index 11f19b14d7..83d47c6659 100644 --- a/cpukit/include/rtems/rtl/rap.h +++ b/cpukit/include/rtems/rtl/rap.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2013, 2018 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtl/rtl-allocator.h b/cpukit/include/rtems/rtl/rtl-allocator.h index da221fef68..7d291c65f4 100644 --- a/cpukit/include/rtems/rtl/rtl-allocator.h +++ b/cpukit/include/rtems/rtl/rtl-allocator.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org> + * COPYRIGHT (c) 2012, 2018, 2023 Chris Johns <chrisj@rtems.org> + * + * 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. * - * 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. + * 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. */ /** * @file @@ -50,6 +69,7 @@ typedef enum rtems_rtl_alloc_tags rtems_rtl_alloc_tag; enum rtems_rtl_alloc_cmd { RTEMS_RTL_ALLOC_NEW, /**< Allocate new memory. */ RTEMS_RTL_ALLOC_DEL, /**< Delete allocated memory. */ + RTEMS_RTL_ALLOC_RESIZE, /**< Resize allocated memory. */ RTEMS_RTL_ALLOC_LOCK, /**< Lock the allocator. */ RTEMS_RTL_ALLOC_UNLOCK, /**< Unlock the allocator. */ RTEMS_RTL_ALLOC_WR_ENABLE, /**< Enable writes to the memory. */ @@ -124,6 +144,25 @@ void* rtems_rtl_alloc_new (rtems_rtl_alloc_tag tag, size_t size, bool zero); void rtems_rtl_alloc_del (rtems_rtl_alloc_tag tag, void* address); /** + * The Runtime Loader allocator resize resizes allocated memory. + * + * This call resizes a previously allocated block of memory. If the + * provided address cannot be resized it is deleted and a new block is + * allocated and the contents of the existing memory is copied. + * + * + * @param tag The type of allocation request. + * @param address The memory address to resize. A NULL is ignored. + * @param size The size of the allocation. + * @param zero If true the memory is cleared. + * @return void* The memory address or NULL is not memory available. + */ +void* rtems_rtl_alloc_resize (rtems_rtl_alloc_tag tag, + void* address, + size_t size, + bool zero); + +/** * The Runtime Loader allocator lock. An allocator that depends on a * separate allocation process, for example the heap, may need to be * locked during loading of an object file to make sure the locality @@ -248,6 +287,30 @@ bool rtems_rtl_alloc_module_new (void** text_base, size_t text_size, void** bss_base, size_t bss_size); /** + * Resize the allocated memory for a module given the new size of the text, + * const, data and bss sections. If any part of the allocation fails the + * allocated is deleted. + * + * @param text_base Pointer to the text base pointer. + * @param text_size The size of the read/exec section. + * @param const_base Pointer to the const base pointer. + * @param const_size The size of the read only section. + * @param eh_base Pointer to the eh base pointer. + * @param eh_size The size of the eh section. + * @param data_base Pointer to the data base pointer. + * @param data_size The size of the read/write secton. + * @param bss_base Pointer to the bss base pointer. + * @param bss_size The size of the read/write. + * @retval true The memory has been allocated. + * @retval false The allocation of memory has failed. + */ +bool rtems_rtl_alloc_module_resize (void** text_base, size_t text_size, + void** const_base, size_t const_size, + void** eh_base, size_t eh_size, + void** data_base, size_t data_size, + void** bss_base, size_t bss_size); + +/** * Free the memory allocated to a module. * * @param text_base Pointer to the text base pointer. diff --git a/cpukit/include/rtems/rtl/rtl-archive.h b/cpukit/include/rtems/rtl/rtl-archive.h index 174bebb68b..6684815c89 100644 --- a/cpukit/include/rtems/rtl/rtl-archive.h +++ b/cpukit/include/rtems/rtl/rtl-archive.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2018 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtl/rtl-fwd.h b/cpukit/include/rtems/rtl/rtl-fwd.h index b5b4eae495..46b0dc6830 100644 --- a/cpukit/include/rtems/rtl/rtl-fwd.h +++ b/cpukit/include/rtems/rtl/rtl-fwd.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtl/rtl-indirect-ptr.h b/cpukit/include/rtems/rtl/rtl-indirect-ptr.h index dbfa70679c..a0e252cdf2 100644 --- a/cpukit/include/rtems/rtl/rtl-indirect-ptr.h +++ b/cpukit/include/rtems/rtl/rtl-indirect-ptr.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtl/rtl-obj-cache.h b/cpukit/include/rtems/rtl/rtl-obj-cache.h index 3613e88246..c80e1f7b09 100644 --- a/cpukit/include/rtems/rtl/rtl-obj-cache.h +++ b/cpukit/include/rtems/rtl/rtl-obj-cache.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtl/rtl-obj-comp.h b/cpukit/include/rtems/rtl/rtl-obj-comp.h index 963824b277..9ff3e5d147 100644 --- a/cpukit/include/rtems/rtl/rtl-obj-comp.h +++ b/cpukit/include/rtems/rtl/rtl-obj-comp.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtl/rtl-obj-fwd.h b/cpukit/include/rtems/rtl/rtl-obj-fwd.h index 6d41483aa2..2c452dcdc6 100644 --- a/cpukit/include/rtems/rtl/rtl-obj-fwd.h +++ b/cpukit/include/rtems/rtl/rtl-obj-fwd.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtl/rtl-obj.h b/cpukit/include/rtems/rtl/rtl-obj.h index f27ae3259d..3523958bfd 100644 --- a/cpukit/include/rtems/rtl/rtl-obj.h +++ b/cpukit/include/rtems/rtl/rtl-obj.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012,2019 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file @@ -179,65 +198,66 @@ typedef bool (*rtems_rtl_obj_depends_iterator) (rtems_rtl_obj* obj, */ struct rtems_rtl_obj { - rtems_chain_node link; /**< The node's link in the chain. */ - uint32_t flags; /**< The status of the object file. */ - size_t users; /**< Users of this object file, number of loads. */ - size_t refs; /**< References to the object file. */ - int format; /**< The format of the object file. */ - const char* fname; /**< The file name for the object. */ - const char* oname; /**< The object file name. Can be - * relative. */ - const char* aname; /**< The archive name containing the - * object. NULL means the object is not - * in a lib */ - off_t ooffset; /**< The object offset in the archive. */ - size_t fsize; /**< Size of the object file. */ - rtems_chain_control sections; /**< The sections of interest in the object - * file. */ - rtems_chain_control dependents; /**< The dependent object files. */ - rtems_rtl_obj_sym* local_table; /**< Local symbol table. */ - size_t local_syms; /**< Local symbol count. */ - size_t local_size; /**< Local symbol memory usage. */ - rtems_rtl_obj_sym* global_table; /**< Global symbol table. */ - size_t global_syms; /**< Global symbol count. */ - size_t global_size; /**< Global symbol memory usage. */ - size_t unresolved; /**< The number of unresolved relocations. */ - void* text_base; /**< The base address of the text section - * in memory. */ - size_t text_size; /**< The size of the text section. */ - void* const_base; /**< The base address of the const section - * in memory. */ - size_t const_size; /**< The size of the const section. */ - void* eh_base; /**< The base address of the eh section in - * memory. */ - size_t eh_size; /**< The size of the eh section. */ - void* data_base; /**< The base address of the data section - * in memory. */ - size_t data_size; /**< The size of the data section. */ - void* bss_base; /**< The base address of the bss section in - * memory. */ - size_t bss_size; /**< The size of the bss section. */ - size_t exec_size; /**< The amount of executable memory - * allocated */ - void* entry; /**< The entry point of the module. */ - uint32_t checksum; /**< The checksum of the text sections. A - * zero means do not checksum. */ - uint32_t* sec_num; /**< The sec nums of each obj. */ - uint32_t obj_num; /**< The count of elf files in an rtl - * obj. */ - void* trampoline; /**< Trampoline memory. Used for fixups or - * veneers */ - size_t tramp_size; /**< Size of a tramopline slot. */ - size_t tramps_size; /**< Size of the trampoline memory. */ - void* tramp_brk; /**< Trampoline memory allocator. MD - * relocators can take memory from the - * break upto the size. */ - size_t tramp_relocs; /**< Number of slots reserved for - * relocs. The remainder are for - * unresolved symbols. */ - struct link_map* linkmap; /**< For GDB. */ - void* loader; /**< The file details specific to a - * loader. */ + rtems_chain_node link; /**< The node's link in the chain. */ + uint32_t flags; /**< The status of the object file. */ + size_t users; /**< Users of this object file, number of loads. */ + size_t refs; /**< References to the object file. */ + int format; /**< The format of the object file. */ + const char* fname; /**< The file name for the object. */ + const char* oname; /**< The object file name. Can be + * relative. */ + const char* aname; /**< The archive name containing the + * object. NULL means the object is not + * in a lib */ + off_t ooffset; /**< The object offset in the archive. */ + size_t fsize; /**< Size of the object file. */ + rtems_chain_control sections; /**< The sections of interest in the object + * file. */ + rtems_chain_control dependents; /**< The dependent object files. */ + rtems_rtl_obj_sym* local_table; /**< Local symbol table. */ + size_t local_syms; /**< Local symbol count. */ + size_t local_size; /**< Local symbol memory usage. */ + rtems_rtl_obj_sym* global_table; /**< Global symbol table. */ + size_t global_syms; /**< Global symbol count. */ + size_t global_size; /**< Global symbol memory usage. */ + size_t unresolved; /**< The number of unresolved relocations. */ + void* text_base; /**< The base address of the text section + * in memory. */ + size_t text_size; /**< The size of the text section. */ + void* const_base; /**< The base address of the const section + * in memory. */ + size_t const_size; /**< The size of the const section. */ + void* eh_base; /**< The base address of the eh section in + * memory. */ + size_t eh_size; /**< The size of the eh section. */ + void* data_base; /**< The base address of the data section + * in memory. */ + size_t data_size; /**< The size of the data section. */ + void* bss_base; /**< The base address of the bss section in + * memory. */ + size_t bss_size; /**< The size of the bss section. */ + size_t exec_size; /**< The amount of executable memory + * allocated */ + void* entry; /**< The entry point of the module. */ + uint32_t checksum; /**< The checksum of the text sections. A + * zero means do not checksum. */ + uint32_t* sec_num; /**< The sec nums of each obj. */ + uint32_t obj_num; /**< The count of elf files in an rtl + * obj. */ + void* tramp_base; /**< Trampoline memory. Used for fixups or + * veneers */ + size_t tramp_size; /**< Size of a trampoline memory. */ + size_t tramp_slots; /**< The number of tampoline slots. */ + size_t tramp_slot_size; /**< The number of tampoline slots. */ + void* tramp_brk; /**< Trampoline memory allocator. MD + * relocators can take memory from the + * break up to the size. */ + size_t tramp_relocs; /**< Number of slots reserved for + * relocs. The remainder are for + * unresolved symbols. */ + struct link_map* linkmap; /**< For GDB. */ + void* loader; /**< The file details specific to a + * loader. */ }; /** @@ -333,7 +353,7 @@ static inline bool rtems_rtl_obj_text_inside (const rtems_rtl_obj* obj, { return (address >= obj->text_base) && - (address < (obj->text_base + obj->text_size)); + ((char*) address < ((char*) obj->text_base + obj->text_size)); } /** @@ -368,6 +388,29 @@ static inline bool rtems_rtl_obj_has_symbol (const rtems_rtl_obj* obj, } /** + * Does the object file have any trampolines? + * + * @param obj The object file's descriptor to check for available space. + * @retval bool Returns @true if the object file has trampolines + */ +static inline size_t rtems_rtl_obj_has_trampolines (const rtems_rtl_obj* obj) +{ + return obj->tramp_slot_size != 0 && obj->tramp_slots != 0; +} + +/** + * Is there space in the trampoline memory for a trapoline. + * + * @param obj The object file's descriptor to check for available space. + * @param size The size to be allocated. + * @retval bool Returns @true if the space is available. + */ +static inline size_t rtems_rtl_obj_tramp_avail_space (const rtems_rtl_obj* obj) +{ + return (char*) obj->tramp_brk - (char*) obj->tramp_base; +} + +/** * Is there space in the trampoline memory for a trapoline. * * @param obj The object file's descriptor to check for available space. @@ -377,8 +420,8 @@ static inline bool rtems_rtl_obj_has_symbol (const rtems_rtl_obj* obj, static inline bool rtems_rtl_obj_has_tramp_space (const rtems_rtl_obj* obj, const size_t size) { - return (obj->trampoline != NULL && - ((obj->tramp_brk - obj->trampoline) + size) <= obj->tramps_size); + return (obj->tramp_base != NULL && + (rtems_rtl_obj_tramp_avail_space (obj) + size) <= obj->tramp_size); } /** @@ -389,20 +432,19 @@ static inline bool rtems_rtl_obj_has_tramp_space (const rtems_rtl_obj* obj, */ static inline size_t rtems_rtl_obj_trampoline_slots (const rtems_rtl_obj* obj) { - return obj->trampoline == NULL || obj->tramp_size == 0 ? - 0 : obj->tramps_size / obj->tramp_size; + return obj->tramp_slots; } /** - * Number of trampolines. + * Number of trampoline slot available. * * @param obj The object file's descriptor. - * @retval size_t The number of trampolines. + * @retval size_t The number of trampoline slots available. */ static inline size_t rtems_rtl_obj_trampolines (const rtems_rtl_obj* obj) { - return obj->trampoline == NULL || obj->tramp_size == 0 ? - 0 : (obj->tramp_brk - obj->trampoline) / obj->tramp_size; + return obj->tramp_base == NULL || obj->tramp_slots == 0 ? + 0 : rtems_rtl_obj_tramp_avail_space (obj) / obj->tramp_slot_size; } /** @@ -541,22 +583,6 @@ rtems_rtl_obj_sect* rtems_rtl_obj_find_section_by_mask (const rtems_rtl_obj* obj uint32_t mask); /** - * Allocate a table for trampoline fixup calls. - * - * @param obj The object file's descriptor. - * @retval true The table was allocated. - * @retval false The alloction failed. - */ -bool rtems_rtl_obj_alloc_trampoline (rtems_rtl_obj* obj); - -/** - * Erase the object file descriptor's trampoline table.. - * - * @param obj The object file's descriptor. - */ -void rtems_rtl_obj_erase_trampoline (rtems_rtl_obj* obj); - -/** * Allocate a table for dependent objects. * * @param obj The object file's descriptor. @@ -719,6 +745,24 @@ size_t rtems_rtl_obj_bss_size (const rtems_rtl_obj* obj); uint32_t rtems_rtl_obj_bss_alignment (const rtems_rtl_obj* obj); /** + * The trampoline size. + * + * @param obj The object file's descriptor. + * @return size_t The size of the trampoline memory of the object file. + */ +size_t rtems_rtl_obj_tramp_size (const rtems_rtl_obj* obj); + +/** + * The trampolinme alignment for the architecture. + * + * This is implemented and set in the architecture backend. + * + * @param obj The object file's descriptor. + * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. + */ +uint32_t rtems_rtl_obj_tramp_alignment (const rtems_rtl_obj* obj); + +/** * Relocate the object file. The object file's section are parsed for any * relocation type sections. * @@ -779,11 +823,19 @@ bool rtems_rtl_obj_load_symbols (rtems_rtl_obj* obj, * @retval true The object has been sucessfully loaded. * @retval false The load failed. The RTL error has been set. */ -bool -rtems_rtl_obj_alloc_sections (rtems_rtl_obj* obj, - int fd, - rtems_rtl_obj_sect_handler handler, - void* data); +bool rtems_rtl_obj_alloc_sections (rtems_rtl_obj* obj, + int fd, + rtems_rtl_obj_sect_handler handler, + void* data); + +/** + * Resize the sections. + * + * @param obj The object file's descriptor. + * @retval true The object has been sucessfully loaded. + * @retval false The load failed. The RTL error has been set. + */ +bool rtems_rtl_obj_resize_sections (rtems_rtl_obj* obj); /** * Load the sections that have been allocated memory in the target. The bss diff --git a/cpukit/include/rtems/rtl/rtl-shell.h b/cpukit/include/rtems/rtl/rtl-shell.h index 9230b619c6..9fcf476138 100644 --- a/cpukit/include/rtems/rtl/rtl-shell.h +++ b/cpukit/include/rtems/rtl/rtl-shell.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtl/rtl-sym.h b/cpukit/include/rtems/rtl/rtl-sym.h index 07cad4cab6..3502b303b8 100644 --- a/cpukit/include/rtems/rtl/rtl-sym.h +++ b/cpukit/include/rtems/rtl/rtl-sym.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012-2014, 2018 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file @@ -44,6 +63,22 @@ typedef struct rtems_rtl_symbols } rtems_rtl_symbols; /** + * A TLS variable offset call. There is one per base image TLS + * variable. + */ +typedef size_t (*rtems_rtl_tls_offset_func)(void); + +/** + * A TLS symbol offset entry. It is used with an exported symbol table + * to find a TSL table offset for a variable at runtime. + */ +typedef struct rtems_rtl_tls_offset +{ + size_t index; /** exported symbol table index */ + rtems_rtl_tls_offset_func offset; /** TLS offset function */ +} rtems_rtl_tls_offset; + +/** * Open a symbol table with the specified number of buckets. * * @param symbols The symbol table to open. @@ -82,10 +117,14 @@ void rtems_rtl_symbol_table_close (rtems_rtl_symbols* symbols); * @param obj The object table the symbols are for. * @param esyms The exported symbol table. * @param size The size of the table in bytes. + * @param tls_offsets The TLS offsets table. If NULL none provided. + * @param tls_size The number TLS offset entries in the table. */ -bool rtems_rtl_symbol_global_add (rtems_rtl_obj* obj, - const unsigned char* esyms, - unsigned int size); +bool rtems_rtl_symbol_global_add (rtems_rtl_obj* obj, + const unsigned char* esyms, + unsigned int size, + rtems_rtl_tls_offset* tls_offsets, + unsigned int tls_size); /** * Find a symbol given the symbol label in the global symbol table. diff --git a/cpukit/include/rtems/rtl/rtl-trace.h b/cpukit/include/rtems/rtl/rtl-trace.h index 196b4ff42e..9f99c78ad9 100644 --- a/cpukit/include/rtems/rtl/rtl-trace.h +++ b/cpukit/include/rtems/rtl/rtl-trace.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012-2014 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtl/rtl-unresolved.h b/cpukit/include/rtems/rtl/rtl-unresolved.h index df07ecb1ba..beff6ff4c4 100644 --- a/cpukit/include/rtems/rtl/rtl-unresolved.h +++ b/cpukit/include/rtems/rtl/rtl-unresolved.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012, 2019 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** * @file diff --git a/cpukit/include/rtems/rtl/rtl.h b/cpukit/include/rtems/rtl/rtl.h index 67d7e96be3..bd3dce588a 100644 --- a/cpukit/include/rtems/rtl/rtl.h +++ b/cpukit/include/rtems/rtl/rtl.h @@ -1,9 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ /** @@ -88,7 +107,7 @@ extern struct r_debug _rtld_debug; * Debugger break function. Call when debugging to have it read the _rtld_debug * variable. */ -extern void _rtld_debug_state (void); +void _rtld_debug_state (void); /** * The type of constructor/destructor function. @@ -374,9 +393,13 @@ bool rtems_rtl_path_prepend (const char* path); * * @param esyms The exported symbol table. * @param count The size of the exported symbol table. + * @param tls_offsets The TLS offsets table. If NULL none provided. + * @param tls_size The number TLS offset entries in the table. */ -void rtems_rtl_base_sym_global_add (const unsigned char* esyms, - unsigned int count); +void rtems_rtl_base_sym_global_add (const unsigned char* esyms, + unsigned int count, + rtems_rtl_tls_offset* tls_offsets, + unsigned int tls_size); /** * Return the object file descriptor for the base image. The object file diff --git a/cpukit/include/rtems/scheduler.h b/cpukit/include/rtems/scheduler.h index 76d84fd787..cf0c562770 100644 --- a/cpukit/include/rtems/scheduler.h +++ b/cpukit/include/rtems/scheduler.h @@ -1,21 +1,37 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Scheduler Configuration API + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief This header file contains interfaces to define a scheduler + * configuration for an application. */ /* - * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved. + * Copyright (C) 2014, 2018 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SAPI_SCHEDULER_H @@ -37,15 +53,61 @@ /* This object doesn't exist and indicates a configuration error */ extern const Scheduler_Control RTEMS_SCHEDULER_INVALID_INDEX; + /** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief This define indicates that default attributes shall be used for a + * processor to scheduler assignment. + * + * This define may be used as an attribute parameter value in the + * RTEMS_SCHEDULER_ASSIGN() macro. + */ #define RTEMS_SCHEDULER_ASSIGN_DEFAULT \ SCHEDULER_ASSIGN_DEFAULT + /** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief This define indicates that the processor is optionally assigned to + * the scheduler. + * + * If the processor is not present during system initialization, then the + * system initialization continues and the processor is marked as not online. + * + * This define may be used as an attribute parameter value in the + * RTEMS_SCHEDULER_ASSIGN() macro. + */ #define RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL \ SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL + /** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief This define indicates that the processor to scheduler assignment is + * mandatory. + * + * If the processor is not present during system initialization, then the + * system terminates with the fatal source of ::RTEMS_FATAL_SOURCE_SMP and + * fatal code of ::SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT. + * + * This define may be used as an attribute parameter value in the + * RTEMS_SCHEDULER_ASSIGN() macro. + */ #define RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY \ SCHEDULER_ASSIGN_PROCESSOR_MANDATORY + /** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a processor to scheduler assignment. + * + * This macro may be used to define entries of the scheduler assignment + * table, see @ref CONFIGURE_SCHEDULER_ASSIGNMENTS. + * + * @param index is the scheduler index. + * + * @param attr is the attribute set of the assignment. + */ #define RTEMS_SCHEDULER_ASSIGN( index, attr ) \ { \ ( index ) < RTEMS_ARRAY_SIZE( _Scheduler_Table ) ? \ @@ -53,6 +115,16 @@ ( attr ) \ } + /** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines that no scheduler is assigned to the processor. + * + * This processor cannot be used by the application. + * + * This macro may be used to define entries of the scheduler assignment + * table, see @ref CONFIGURE_SCHEDULER_ASSIGNMENTS. + */ #define RTEMS_SCHEDULER_ASSIGN_NO_SCHEDULER { NULL, 0 } #endif @@ -64,23 +136,48 @@ * information. */ -#ifdef CONFIGURE_SCHEDULER_CBS - #include <rtems/score/schedulercbs.h> +/** + * @brief Defines a CBS Scheduler context name based on the instantiation + * name. + * + * @param name is the scheduler instantiation name. + */ +#define SCHEDULER_CBS_CONTEXT_NAME( name ) \ + SCHEDULER_CONTEXT_NAME( CBS_ ## name ) - #define SCHEDULER_CBS_CONTEXT_NAME( name ) \ - SCHEDULER_CONTEXT_NAME( CBS_ ## name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a CBS Scheduler instantiation. + * + * @param name is the scheduler instantiation name. + */ +#define RTEMS_SCHEDULER_CBS( name ) \ + static Scheduler_EDF_Context SCHEDULER_CBS_CONTEXT_NAME( name ) - #define RTEMS_SCHEDULER_CBS( name ) \ - static Scheduler_EDF_Context SCHEDULER_CBS_CONTEXT_NAME( name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a CBS Scheduler entry for the scheduler table. + * + * Use this macro to define an entry for the + * @ref CONFIGURE_SCHEDULER_TABLE_ENTRIES application configuration option. + * + * @param name is the scheduler instantiation name. + * + * @param name is the scheduler object name. + */ +#define RTEMS_SCHEDULER_TABLE_CBS( name, obj_name ) \ + { \ + &SCHEDULER_CBS_CONTEXT_NAME( name ).Base, \ + SCHEDULER_CBS_ENTRY_POINTS, \ + SCHEDULER_CBS_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( true ) \ + } - #define RTEMS_SCHEDULER_TABLE_CBS( name, obj_name ) \ - { \ - &SCHEDULER_CBS_CONTEXT_NAME( name ).Base, \ - SCHEDULER_CBS_ENTRY_POINTS, \ - SCHEDULER_CBS_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( true ) \ - } +#ifdef CONFIGURE_SCHEDULER_CBS + #include <rtems/score/schedulercbs.h> /* Provided for backward compatibility */ @@ -91,23 +188,48 @@ RTEMS_SCHEDULER_TABLE_CBS( name, obj_name ) #endif -#ifdef CONFIGURE_SCHEDULER_EDF - #include <rtems/score/scheduleredf.h> +/** + * @brief Defines an EDF Scheduler context name based on the instantiation + * name. + * + * @param name is the scheduler instantiation name. + */ +#define SCHEDULER_EDF_CONTEXT_NAME( name ) \ + SCHEDULER_CONTEXT_NAME( EDF_ ## name ) - #define SCHEDULER_EDF_CONTEXT_NAME( name ) \ - SCHEDULER_CONTEXT_NAME( EDF_ ## name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines an EDF Scheduler instantiation. + * + * @param name is the scheduler instantiation name. + */ +#define RTEMS_SCHEDULER_EDF( name ) \ + static Scheduler_EDF_Context SCHEDULER_EDF_CONTEXT_NAME( name ) - #define RTEMS_SCHEDULER_EDF( name ) \ - static Scheduler_EDF_Context SCHEDULER_EDF_CONTEXT_NAME( name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines an EDF Scheduler entry for the scheduler table. + * + * Use this macro to define an entry for the + * @ref CONFIGURE_SCHEDULER_TABLE_ENTRIES application configuration option. + * + * @param name is the scheduler instantiation name. + * + * @param name is the scheduler object name. + */ +#define RTEMS_SCHEDULER_TABLE_EDF( name, obj_name ) \ + { \ + &SCHEDULER_EDF_CONTEXT_NAME( name ).Base, \ + SCHEDULER_EDF_ENTRY_POINTS, \ + SCHEDULER_EDF_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( true ) \ + } - #define RTEMS_SCHEDULER_TABLE_EDF( name, obj_name ) \ - { \ - &SCHEDULER_EDF_CONTEXT_NAME( name ).Base, \ - SCHEDULER_EDF_ENTRY_POINTS, \ - SCHEDULER_EDF_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( true ) \ - } +#ifdef CONFIGURE_SCHEDULER_EDF + #include <rtems/score/scheduleredf.h> /* Provided for backward compatibility */ @@ -118,30 +240,59 @@ RTEMS_SCHEDULER_TABLE_EDF( name, obj_name ) #endif +/** + * @brief Defines an EDF SMP Scheduler context name based on the instantiation + * name. + * + * @param name is the scheduler instantiation name. + */ +#define SCHEDULER_EDF_SMP_CONTEXT_NAME( name ) \ + SCHEDULER_CONTEXT_NAME( EDF_SMP_ ## name ) + +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines an EDF SMP Scheduler instantiation. + * + * @param name is the scheduler instantiation name. + */ +#define RTEMS_SCHEDULER_EDF_SMP( name ) \ + static struct { \ + Scheduler_EDF_SMP_Context Base; \ + Scheduler_EDF_SMP_Ready_queue Ready[ CONFIGURE_MAXIMUM_PROCESSORS + 1 ]; \ + } SCHEDULER_EDF_SMP_CONTEXT_NAME( name ) + +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines an EDF SMP Scheduler entry for the scheduler table. + * + * Use this macro to define an entry for the + * @ref CONFIGURE_SCHEDULER_TABLE_ENTRIES application configuration option. + * + * @param name is the scheduler instantiation name. + * + * @param name is the scheduler object name. + */ +#define RTEMS_SCHEDULER_TABLE_EDF_SMP( name, obj_name ) \ + { \ + &SCHEDULER_EDF_SMP_CONTEXT_NAME( name ).Base.Base.Base, \ + SCHEDULER_EDF_SMP_ENTRY_POINTS, \ + SCHEDULER_EDF_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \ + } + #ifdef CONFIGURE_SCHEDULER_EDF_SMP - #include <rtems/score/scheduleredfsmp.h> + #ifndef RTEMS_SMP + #error "CONFIGURE_SCHEDULER_EDF_SMP cannot be used if RTEMS_SMP is disabled" + #endif #ifndef CONFIGURE_MAXIMUM_PROCESSORS - #error "CONFIGURE_MAXIMUM_PROCESSORS must be defined to configure the EDF SMP scheduler" + #error "CONFIGURE_MAXIMUM_PROCESSORS must be defined to configure the EDF SMP Scheduler" #endif - #define SCHEDULER_EDF_SMP_CONTEXT_NAME( name ) \ - SCHEDULER_CONTEXT_NAME( EDF_SMP_ ## name ) - - #define RTEMS_SCHEDULER_EDF_SMP( name ) \ - static struct { \ - Scheduler_EDF_SMP_Context Base; \ - Scheduler_EDF_SMP_Ready_queue Ready[ CONFIGURE_MAXIMUM_PROCESSORS + 1 ]; \ - } SCHEDULER_EDF_SMP_CONTEXT_NAME( name ) - - #define RTEMS_SCHEDULER_TABLE_EDF_SMP( name, obj_name ) \ - { \ - &SCHEDULER_EDF_SMP_CONTEXT_NAME( name ).Base.Base.Base, \ - SCHEDULER_EDF_SMP_ENTRY_POINTS, \ - SCHEDULER_EDF_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \ - } + #include <rtems/score/scheduleredfsmp.h> /* Provided for backward compatibility */ @@ -152,28 +303,56 @@ RTEMS_SCHEDULER_TABLE_EDF_SMP( name, obj_name ) #endif -#ifdef CONFIGURE_SCHEDULER_PRIORITY - #include <rtems/score/schedulerpriority.h> +/** + * @brief Defines a Deterministic Priority Scheduler context name based on the + * instantiation name. + * + * @param name is the scheduler instantiation name. + */ +#define SCHEDULER_PRIORITY_CONTEXT_NAME( name ) \ + SCHEDULER_CONTEXT_NAME( priority_ ## name ) - #define SCHEDULER_PRIORITY_CONTEXT_NAME( name ) \ - SCHEDULER_CONTEXT_NAME( priority_ ## name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Deterministic Priority Scheduler instantiation. + * + * @param name is the scheduler instantiation name. + * + * @param prio_count is the count of supported priority levels. + */ +#define RTEMS_SCHEDULER_PRIORITY( name, prio_count ) \ + static struct { \ + Scheduler_priority_Context Base; \ + Chain_Control Ready[ ( prio_count ) ]; \ + } SCHEDULER_PRIORITY_CONTEXT_NAME( name ) - #define RTEMS_SCHEDULER_PRIORITY( name, prio_count ) \ - static struct { \ - Scheduler_priority_Context Base; \ - Chain_Control Ready[ ( prio_count ) ]; \ - } SCHEDULER_PRIORITY_CONTEXT_NAME( name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Deterministic Priority Scheduler entry for the scheduler + * table. + * + * Use this macro to define an entry for the + * @ref CONFIGURE_SCHEDULER_TABLE_ENTRIES application configuration option. + * + * @param name is the scheduler instantiation name. + * + * @param name is the scheduler object name. + */ +#define RTEMS_SCHEDULER_TABLE_PRIORITY( name, obj_name ) \ + { \ + &SCHEDULER_PRIORITY_CONTEXT_NAME( name ).Base.Base, \ + SCHEDULER_PRIORITY_ENTRY_POINTS, \ + RTEMS_ARRAY_SIZE( \ + SCHEDULER_PRIORITY_CONTEXT_NAME( name ).Ready \ + ) - 1, \ + ( obj_name ) \ + SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( true ) \ + } - #define RTEMS_SCHEDULER_TABLE_PRIORITY( name, obj_name ) \ - { \ - &SCHEDULER_PRIORITY_CONTEXT_NAME( name ).Base.Base, \ - SCHEDULER_PRIORITY_ENTRY_POINTS, \ - RTEMS_ARRAY_SIZE( \ - SCHEDULER_PRIORITY_CONTEXT_NAME( name ).Ready \ - ) - 1, \ - ( obj_name ) \ - SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( true ) \ - } +#ifdef CONFIGURE_SCHEDULER_PRIORITY + #include <rtems/score/schedulerpriority.h> /* Provided for backward compatibility */ @@ -184,28 +363,61 @@ RTEMS_SCHEDULER_TABLE_PRIORITY( name, obj_name ) #endif -#ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP - #include <rtems/score/schedulerpriorityaffinitysmp.h> +/** + * @brief Defines a Arbitrary Processor Affinity Priority SMP Scheduler context + * name based on the instantiation name. + * + * @param name is the scheduler instantiation name. + */ +#define SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ) \ + SCHEDULER_CONTEXT_NAME( priority_affinity_SMP_ ## name ) - #define SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ) \ - SCHEDULER_CONTEXT_NAME( priority_affinity_SMP_ ## name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Arbitrary Processor Affinity Priority SMP Scheduler + * instantiation. + * + * @param name is the scheduler instantiation name. + * + * @param prio_count is the count of supported priority levels. + */ +#define RTEMS_SCHEDULER_PRIORITY_AFFINITY_SMP( name, prio_count ) \ + static struct { \ + Scheduler_priority_SMP_Context Base; \ + Chain_Control Ready[ ( prio_count ) ]; \ + } SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ) + +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Arbitrary Processor Affinity Priority SMP Scheduler entry + * for the scheduler table. + * + * Use this macro to define an entry for the + * @ref CONFIGURE_SCHEDULER_TABLE_ENTRIES application configuration option. + * + * @param name is the scheduler instantiation name. + * + * @param name is the scheduler object name. + */ +#define RTEMS_SCHEDULER_TABLE_PRIORITY_AFFINITY_SMP( name, obj_name ) \ + { \ + &SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ).Base.Base.Base, \ + SCHEDULER_PRIORITY_AFFINITY_SMP_ENTRY_POINTS, \ + RTEMS_ARRAY_SIZE( \ + SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ).Ready \ + ) - 1, \ + ( obj_name ) \ + SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \ + } - #define RTEMS_SCHEDULER_PRIORITY_AFFINITY_SMP( name, prio_count ) \ - static struct { \ - Scheduler_priority_SMP_Context Base; \ - Chain_Control Ready[ ( prio_count ) ]; \ - } SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ) +#ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP + #ifndef RTEMS_SMP + #error "CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP cannot be used if RTEMS_SMP is disabled" + #endif - #define RTEMS_SCHEDULER_TABLE_PRIORITY_AFFINITY_SMP( name, obj_name ) \ - { \ - &SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ).Base.Base.Base, \ - SCHEDULER_PRIORITY_AFFINITY_SMP_ENTRY_POINTS, \ - RTEMS_ARRAY_SIZE( \ - SCHEDULER_PRIORITY_AFFINITY_SMP_CONTEXT_NAME( name ).Ready \ - ) - 1, \ - ( obj_name ) \ - SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \ - } + #include <rtems/score/schedulerpriorityaffinitysmp.h> /* Provided for backward compatibility */ @@ -216,28 +428,60 @@ RTEMS_SCHEDULER_TABLE_PRIORITY_AFFINITY_SMP( name, obj_name ) #endif -#ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP - #include <rtems/score/schedulerprioritysmp.h> +/** + * @brief Defines a Deterministic Priority SMP Scheduler context name based on + * the instantiation name. + * + * @param name is the scheduler instantiation name. + */ +#define SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ) \ + SCHEDULER_CONTEXT_NAME( priority_SMP_ ## name ) + +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Deterministic Priority SMP Scheduler instantiation. + * + * @param name is the scheduler instantiation name. + * + * @param prio_count is the count of supported priority levels. + */ +#define RTEMS_SCHEDULER_PRIORITY_SMP( name, prio_count ) \ + static struct { \ + Scheduler_priority_SMP_Context Base; \ + Chain_Control Ready[ ( prio_count ) ]; \ + } SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ) - #define SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ) \ - SCHEDULER_CONTEXT_NAME( priority_SMP_ ## name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Deterministic Priority SMP Scheduler entry for the + * scheduler table. + * + * Use this macro to define an entry for the + * @ref CONFIGURE_SCHEDULER_TABLE_ENTRIES application configuration option. + * + * @param name is the scheduler instantiation name. + * + * @param name is the scheduler object name. + */ +#define RTEMS_SCHEDULER_TABLE_PRIORITY_SMP( name, obj_name ) \ + { \ + &SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ).Base.Base.Base, \ + SCHEDULER_PRIORITY_SMP_ENTRY_POINTS, \ + RTEMS_ARRAY_SIZE( \ + SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ).Ready \ + ) - 1, \ + ( obj_name ) \ + SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \ + } - #define RTEMS_SCHEDULER_PRIORITY_SMP( name, prio_count ) \ - static struct { \ - Scheduler_priority_SMP_Context Base; \ - Chain_Control Ready[ ( prio_count ) ]; \ - } SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ) +#ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP + #ifndef RTEMS_SMP + #error "CONFIGURE_SCHEDULER_PRIORITY_SMP cannot be used if RTEMS_SMP is disabled" + #endif - #define RTEMS_SCHEDULER_TABLE_PRIORITY_SMP( name, obj_name ) \ - { \ - &SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ).Base.Base.Base, \ - SCHEDULER_PRIORITY_SMP_ENTRY_POINTS, \ - RTEMS_ARRAY_SIZE( \ - SCHEDULER_PRIORITY_SMP_CONTEXT_NAME( name ).Ready \ - ) - 1, \ - ( obj_name ) \ - SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \ - } + #include <rtems/score/schedulerprioritysmp.h> /* Provided for backward compatibility */ @@ -248,30 +492,59 @@ RTEMS_SCHEDULER_TABLE_PRIORITY_SMP( name, obj_name ) #endif +/** + * @brief Defines a Strong APA Scheduler context name based on the + * instantiation name. + * + * @param name is the scheduler instantiation name. + */ +#define SCHEDULER_STRONG_APA_CONTEXT_NAME( name ) \ + SCHEDULER_CONTEXT_NAME( strong_APA_ ## name ) + +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Strong APA Scheduler instantiation. + * + * @param name is the scheduler instantiation name. + */ +#define RTEMS_SCHEDULER_STRONG_APA( name, prio_count ) \ + static struct { \ + Scheduler_strong_APA_Context Base; \ + Scheduler_strong_APA_CPU CPU[ CONFIGURE_MAXIMUM_PROCESSORS ]; \ + } SCHEDULER_STRONG_APA_CONTEXT_NAME( name ) + +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Strong APA Scheduler entry for the scheduler table. + * + * Use this macro to define an entry for the + * @ref CONFIGURE_SCHEDULER_TABLE_ENTRIES application configuration option. + * + * @param name is the scheduler instantiation name. + * + * @param name is the scheduler object name. + */ +#define RTEMS_SCHEDULER_TABLE_STRONG_APA( name, obj_name ) \ + { \ + &SCHEDULER_STRONG_APA_CONTEXT_NAME( name ).Base.Base.Base, \ + SCHEDULER_STRONG_APA_ENTRY_POINTS, \ + SCHEDULER_STRONG_APA_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \ + } + #ifdef CONFIGURE_SCHEDULER_STRONG_APA - #include <rtems/score/schedulerstrongapa.h> + #ifndef RTEMS_SMP + #error "CONFIGURE_SCHEDULER_STRONG_APA cannot be used if RTEMS_SMP is disabled" + #endif #ifndef CONFIGURE_MAXIMUM_PROCESSORS - #error "CONFIGURE_MAXIMUM_PROCESSORS must be defined to configure the Strong APA scheduler" + #error "CONFIGURE_MAXIMUM_PROCESSORS must be defined to configure the Strong APA Scheduler" #endif - #define SCHEDULER_STRONG_APA_CONTEXT_NAME( name ) \ - SCHEDULER_CONTEXT_NAME( strong_APA_ ## name ) - - #define RTEMS_SCHEDULER_STRONG_APA( name, prio_count ) \ - static struct { \ - Scheduler_strong_APA_Context Base; \ - Scheduler_strong_APA_CPU CPU[ CONFIGURE_MAXIMUM_PROCESSORS ]; \ - } SCHEDULER_STRONG_APA_CONTEXT_NAME( name ) - - #define RTEMS_SCHEDULER_TABLE_STRONG_APA( name, obj_name ) \ - { \ - &SCHEDULER_STRONG_APA_CONTEXT_NAME( name ).Base.Base.Base, \ - SCHEDULER_STRONG_APA_ENTRY_POINTS, \ - SCHEDULER_STRONG_APA_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \ - } + #include <rtems/score/schedulerstrongapa.h> /* Provided for backward compatibility */ @@ -282,24 +555,49 @@ RTEMS_SCHEDULER_TABLE_STRONG_APA( name, obj_name ) #endif -#ifdef CONFIGURE_SCHEDULER_SIMPLE - #include <rtems/score/schedulersimple.h> +/** + * @brief Defines a Simple Scheduler context name based on the instantiation + * name. + * + * @param name is the scheduler instantiation name. + */ +#define SCHEDULER_SIMPLE_CONTEXT_NAME( name ) \ + SCHEDULER_CONTEXT_NAME( simple_ ## name ) - #define SCHEDULER_SIMPLE_CONTEXT_NAME( name ) \ - SCHEDULER_CONTEXT_NAME( simple_ ## name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Simple Scheduler instantiation. + * + * @param name is the scheduler instantiation name. + */ +#define RTEMS_SCHEDULER_SIMPLE( name ) \ + static Scheduler_simple_Context \ + SCHEDULER_SIMPLE_CONTEXT_NAME( name ) - #define RTEMS_SCHEDULER_SIMPLE( name ) \ - static Scheduler_simple_Context \ - SCHEDULER_SIMPLE_CONTEXT_NAME( name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Simple Scheduler entry for the scheduler table. + * + * Use this macro to define an entry for the + * @ref CONFIGURE_SCHEDULER_TABLE_ENTRIES application configuration option. + * + * @param name is the scheduler instantiation name. + * + * @param name is the scheduler object name. + */ +#define RTEMS_SCHEDULER_TABLE_SIMPLE( name, obj_name ) \ + { \ + &SCHEDULER_SIMPLE_CONTEXT_NAME( name ).Base, \ + SCHEDULER_SIMPLE_ENTRY_POINTS, \ + SCHEDULER_SIMPLE_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( true ) \ + } - #define RTEMS_SCHEDULER_TABLE_SIMPLE( name, obj_name ) \ - { \ - &SCHEDULER_SIMPLE_CONTEXT_NAME( name ).Base, \ - SCHEDULER_SIMPLE_ENTRY_POINTS, \ - SCHEDULER_SIMPLE_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( true ) \ - } +#ifdef CONFIGURE_SCHEDULER_SIMPLE + #include <rtems/score/schedulersimple.h> /* Provided for backward compatibility */ @@ -310,24 +608,53 @@ RTEMS_SCHEDULER_TABLE_SIMPLE( name, obj_name ) #endif -#ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP - #include <rtems/score/schedulersimplesmp.h> +/** + * @brief Defines a Simple SMP Scheduler context name based on the + * instantiation name. + * + * @param name is the scheduler instantiation name. + */ +#define SCHEDULER_SIMPLE_SMP_CONTEXT_NAME( name ) \ + SCHEDULER_CONTEXT_NAME( simple_SMP_ ## name ) - #define SCHEDULER_SIMPLE_SMP_CONTEXT_NAME( name ) \ - SCHEDULER_CONTEXT_NAME( simple_SMP_ ## name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Simple SMP Scheduler instantiation. + * + * @param name is the scheduler instantiation name. + */ +#define RTEMS_SCHEDULER_SIMPLE_SMP( name ) \ + static Scheduler_simple_SMP_Context \ + SCHEDULER_SIMPLE_SMP_CONTEXT_NAME( name ) - #define RTEMS_SCHEDULER_SIMPLE_SMP( name ) \ - static Scheduler_simple_SMP_Context \ - SCHEDULER_SIMPLE_SMP_CONTEXT_NAME( name ) +/** + * @ingroup RTEMSApplConfigGeneralSchedulerConfiguration + * + * @brief Defines a Simple SMP Scheduler entry for the scheduler table. + * + * Use this macro to define an entry for the + * @ref CONFIGURE_SCHEDULER_TABLE_ENTRIES application configuration option. + * + * @param name is the scheduler instantiation name. + * + * @param name is the scheduler object name. + */ +#define RTEMS_SCHEDULER_TABLE_SIMPLE_SMP( name, obj_name ) \ + { \ + &SCHEDULER_SIMPLE_SMP_CONTEXT_NAME( name ).Base.Base, \ + SCHEDULER_SIMPLE_SMP_ENTRY_POINTS, \ + SCHEDULER_SIMPLE_SMP_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \ + } - #define RTEMS_SCHEDULER_TABLE_SIMPLE_SMP( name, obj_name ) \ - { \ - &SCHEDULER_SIMPLE_SMP_CONTEXT_NAME( name ).Base.Base, \ - SCHEDULER_SIMPLE_SMP_ENTRY_POINTS, \ - SCHEDULER_SIMPLE_SMP_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - SCHEDULER_CONTROL_IS_NON_PREEMPT_MODE_SUPPORTED( false ) \ - } +#ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP + #ifndef RTEMS_SMP + #error "CONFIGURE_SCHEDULER_SIMPLE_SMP cannot be used if RTEMS_SMP is disabled" + #endif + + #include <rtems/score/schedulersimplesmp.h> /* Provided for backward compatibility */ diff --git a/cpukit/include/rtems/score/address.h b/cpukit/include/rtems/score/address.h index f963252172..e6a06f5996 100644 --- a/cpukit/include/rtems/score/address.h +++ b/cpukit/include/rtems/score/address.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2006. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_ADDRESS_H @@ -50,7 +69,7 @@ extern "C" { * * @return This method returns the resulting address. */ -RTEMS_INLINE_ROUTINE void *_Addresses_Add_offset ( +static inline void *_Addresses_Add_offset ( const void *base, uintptr_t offset ) @@ -71,7 +90,7 @@ RTEMS_INLINE_ROUTINE void *_Addresses_Add_offset ( * @return This method returns the resulting address. */ -RTEMS_INLINE_ROUTINE void *_Addresses_Subtract_offset ( +static inline void *_Addresses_Subtract_offset ( const void *base, uintptr_t offset ) @@ -90,7 +109,7 @@ RTEMS_INLINE_ROUTINE void *_Addresses_Subtract_offset ( * * @return This method returns the resulting address. */ -RTEMS_INLINE_ROUTINE intptr_t _Addresses_Subtract( +static inline intptr_t _Addresses_Subtract( const void *left, const void *right ) @@ -110,7 +129,7 @@ RTEMS_INLINE_ROUTINE intptr_t _Addresses_Subtract( * @retval true The @a address is aligned. * @retval false The @a address is not aligned. */ -RTEMS_INLINE_ROUTINE bool _Addresses_Is_aligned( +static inline bool _Addresses_Is_aligned( const void *address ) { @@ -133,7 +152,7 @@ RTEMS_INLINE_ROUTINE bool _Addresses_Is_aligned( * @retval true The @a address is within the memory range specified * @retval false The @a address is not within the memory range specified. */ -RTEMS_INLINE_ROUTINE bool _Addresses_Is_in_range ( +static inline bool _Addresses_Is_in_range ( const void *address, const void *base, const void *limit @@ -155,7 +174,7 @@ RTEMS_INLINE_ROUTINE bool _Addresses_Is_in_range ( * * @return Returns the aligned address. */ -RTEMS_INLINE_ROUTINE void *_Addresses_Align_up( +static inline void *_Addresses_Align_up( void *address, size_t alignment ) @@ -177,7 +196,7 @@ RTEMS_INLINE_ROUTINE void *_Addresses_Align_up( * * @return Returns the aligned address. */ -RTEMS_INLINE_ROUTINE void *_Addresses_Align_down( +static inline void *_Addresses_Align_down( void *address, size_t alignment ) diff --git a/cpukit/include/rtems/score/apimutex.h b/cpukit/include/rtems/score/apimutex.h index ea1fe209dd..e1a54d7960 100644 --- a/cpukit/include/rtems/score/apimutex.h +++ b/cpukit/include/rtems/score/apimutex.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_APIMUTEX_H diff --git a/cpukit/include/rtems/score/assert.h b/cpukit/include/rtems/score/assert.h index 6bdb01e2fc..ad92a585fd 100644 --- a/cpukit/include/rtems/score/assert.h +++ b/cpukit/include/rtems/score/assert.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. + * Copyright (C) 2013, 2014 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_ASSERT_H @@ -58,22 +71,7 @@ extern "C" { * @note This is based on the code in newlib's assert.h. */ #ifndef __RTEMS_ASSERT_FUNCTION - /* Use g++'s demangled names in C++. */ - #if defined __cplusplus && defined __GNUC__ - #define __RTEMS_ASSERT_FUNCTION __PRETTY_FUNCTION__ - - /* C99 requires the use of __func__. */ - #elif __STDC_VERSION__ >= 199901L - #define __RTEMS_ASSERT_FUNCTION __func__ - - /* Older versions of gcc don't have __func__ but can use __FUNCTION__. */ - #elif __GNUC__ >= 2 - #define __RTEMS_ASSERT_FUNCTION __FUNCTION__ - - /* failed to detect __func__ support. */ - #else - #define __RTEMS_ASSERT_FUNCTION ((char *) 0) - #endif + #define __RTEMS_ASSERT_FUNCTION RTEMS_FUNCTION_NAME #endif /* !__RTEMS_ASSERT_FUNCTION */ #if !defined( RTEMS_SCHEDSIM ) diff --git a/cpukit/include/rtems/score/atomic.h b/cpukit/include/rtems/score/atomic.h index 2eb8153f3e..9ef1779e60 100644 --- a/cpukit/include/rtems/score/atomic.h +++ b/cpukit/include/rtems/score/atomic.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,35 @@ */ /* + * Copyright (C) 2015 embedded brains GmbH & Co. KG * COPYRIGHT (c) 2012-2013 Deng Hengyi. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_ATOMIC_H #define _RTEMS_SCORE_ATOMIC_H -#include <rtems/score/cpuatomic.h> +#include <rtems/score/basedefs.h> /** * @defgroup RTEMSScoreAtomic Atomic Operations @@ -35,122 +55,935 @@ * @{ */ -typedef CPU_atomic_Uint Atomic_Uint; +#ifdef RTEMS_SMP + #if defined(__cplusplus) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) + /* + * The GCC 4.9 ships its own <stdatomic.h> which is not C++ compatible. The + * suggested solution was to include <atomic> in case C++ is used. This works + * at least with GCC 4.9. See also: + * + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940 + */ + #include <atomic> + #define _RTEMS_SCORE_ATOMIC_USE_ATOMIC + #else + #include <stdatomic.h> + #define _RTEMS_SCORE_ATOMIC_USE_STDATOMIC + #endif +#else + #include <rtems/score/isrlevel.h> +#endif + +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + +typedef std::atomic_uint Atomic_Uint; + +typedef std::atomic_ulong Atomic_Ulong; + +typedef std::atomic_uintptr_t Atomic_Uintptr; + +typedef std::atomic_flag Atomic_Flag; + +typedef std::memory_order Atomic_Order; + +#define ATOMIC_ORDER_RELAXED std::memory_order_relaxed + +#define ATOMIC_ORDER_ACQUIRE std::memory_order_acquire + +#define ATOMIC_ORDER_RELEASE std::memory_order_release + +#define ATOMIC_ORDER_ACQ_REL std::memory_order_acq_rel + +#define ATOMIC_ORDER_SEQ_CST std::memory_order_seq_cst + +#define ATOMIC_INITIALIZER_UINT( value ) ATOMIC_VAR_INIT( value ) + +#define ATOMIC_INITIALIZER_ULONG( value ) ATOMIC_VAR_INIT( value ) + +#define ATOMIC_INITIALIZER_UINTPTR( value ) ATOMIC_VAR_INIT( value ) + +#define ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT + +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + +typedef atomic_uint Atomic_Uint; -typedef CPU_atomic_Ulong Atomic_Ulong; +typedef atomic_ulong Atomic_Ulong; -typedef CPU_atomic_Uintptr Atomic_Uintptr; +typedef atomic_uintptr_t Atomic_Uintptr; -typedef CPU_atomic_Flag Atomic_Flag; +typedef atomic_flag Atomic_Flag; -typedef CPU_atomic_Order Atomic_Order; +typedef memory_order Atomic_Order; -#define ATOMIC_ORDER_RELAXED CPU_ATOMIC_ORDER_RELAXED +#define ATOMIC_ORDER_RELAXED memory_order_relaxed -#define ATOMIC_ORDER_ACQUIRE CPU_ATOMIC_ORDER_ACQUIRE +#define ATOMIC_ORDER_ACQUIRE memory_order_acquire -#define ATOMIC_ORDER_RELEASE CPU_ATOMIC_ORDER_RELEASE +#define ATOMIC_ORDER_RELEASE memory_order_release -#define ATOMIC_ORDER_ACQ_REL CPU_ATOMIC_ORDER_ACQ_REL +#define ATOMIC_ORDER_ACQ_REL memory_order_acq_rel -#define ATOMIC_ORDER_SEQ_CST CPU_ATOMIC_ORDER_SEQ_CST +#define ATOMIC_ORDER_SEQ_CST memory_order_seq_cst -#define ATOMIC_INITIALIZER_UINT( value ) CPU_ATOMIC_INITIALIZER_UINT( value ) +#define ATOMIC_INITIALIZER_UINT( value ) ATOMIC_VAR_INIT( value ) -#define ATOMIC_INITIALIZER_ULONG( value ) CPU_ATOMIC_INITIALIZER_ULONG( value ) +#define ATOMIC_INITIALIZER_ULONG( value ) ATOMIC_VAR_INIT( value ) -#define ATOMIC_INITIALIZER_UINTPTR( value ) CPU_ATOMIC_INITIALIZER_UINTPTR( value ) +#define ATOMIC_INITIALIZER_UINTPTR( value ) ATOMIC_VAR_INIT( value ) -#define ATOMIC_INITIALIZER_FLAG CPU_ATOMIC_INITIALIZER_FLAG +#define ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT -#define _Atomic_Fence( order ) _CPU_atomic_Fence( order ) +#else -#define _Atomic_Init_uint( obj, desired ) \ - _CPU_atomic_Init_uint( obj, desired ) +typedef unsigned int Atomic_Uint; -#define _Atomic_Init_ulong( obj, desired ) \ - _CPU_atomic_Init_ulong( obj, desired ) +typedef unsigned long Atomic_Ulong; -#define _Atomic_Init_uintptr( obj, desired ) \ - _CPU_atomic_Init_uintptr( obj, desired ) +typedef uintptr_t Atomic_Uintptr; -#define _Atomic_Load_uint( obj, order ) \ - _CPU_atomic_Load_uint( obj, order ) +typedef bool Atomic_Flag; -#define _Atomic_Load_ulong( obj, order ) \ - _CPU_atomic_Load_ulong( obj, order ) +typedef int Atomic_Order; -#define _Atomic_Load_uintptr( obj, order ) \ - _CPU_atomic_Load_uintptr( obj, order ) +#define ATOMIC_ORDER_RELAXED 0 -#define _Atomic_Store_uint( obj, desr, order ) \ - _CPU_atomic_Store_uint( obj, desr, order ) +#define ATOMIC_ORDER_ACQUIRE 2 -#define _Atomic_Store_ulong( obj, desr, order ) \ - _CPU_atomic_Store_ulong( obj, desr, order ) +#define ATOMIC_ORDER_RELEASE 3 -#define _Atomic_Store_uintptr( obj, desr, order ) \ - _CPU_atomic_Store_uintptr( obj, desr, order ) +#define ATOMIC_ORDER_ACQ_REL 4 -#define _Atomic_Fetch_add_uint( obj, arg, order ) \ - _CPU_atomic_Fetch_add_uint( obj, arg, order ) +#define ATOMIC_ORDER_SEQ_CST 5 -#define _Atomic_Fetch_add_ulong( obj, arg, order ) \ - _CPU_atomic_Fetch_add_ulong( obj, arg, order ) +#define ATOMIC_INITIALIZER_UINT( value ) ( value ) + +#define ATOMIC_INITIALIZER_ULONG( value ) ( value ) + +#define ATOMIC_INITIALIZER_UINTPTR( value ) ( value ) + +#define ATOMIC_INITIALIZER_FLAG false + +#endif + +/** + * @brief Sets up a cpu fence. + * + * @param[out] order The order for the fence. + */ +static inline void _Atomic_Fence( Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + std::atomic_thread_fence( order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + atomic_thread_fence( order ); +#else + (void) order; + RTEMS_COMPILER_MEMORY_BARRIER(); +#endif +} + +/** + * @brief Initializes Uint. + * + * @param[out] obj The CPU atomic Uint to initialize. + * @param desired The desired value for @a obj. + */ +static inline void _Atomic_Init_uint( Atomic_Uint *obj, unsigned int desired ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + obj->store( desired ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + atomic_init( obj, desired ); +#else + *obj = desired; +#endif +} + +/** + * @brief Initializes Ulong. + * + * @param[out] obj The CPU atomic Ulong to initialize. + * @param desired The desired value for @a obj. + */ +static inline void _Atomic_Init_ulong( Atomic_Ulong *obj, unsigned long desired ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + obj->store( desired ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + atomic_init( obj, desired ); +#else + *obj = desired; +#endif +} + +/** + * @brief Initializes Uintptr. + * + * @param[out] obj The CPU atomic Uintptr to initialize. + * @param desired The desired value for @a obj. + */ +static inline void _Atomic_Init_uintptr( Atomic_Uintptr *obj, uintptr_t desired ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + obj->store( desired ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + atomic_init( obj, desired ); +#else + *obj = desired; +#endif +} + +/** + * @brief Loads value of Uint considering the order. + * + * @param obj The CPU atomic Uint to get the value from. + * @param order The atomic order for getting the value. + * + * @return The value of @a obj considering the @a order. + */ +static inline unsigned int _Atomic_Load_uint( const Atomic_Uint *obj, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->load( order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_load_explicit( obj, order ); +#else + unsigned int val; + + (void) order; + val = *obj; + RTEMS_COMPILER_MEMORY_BARRIER(); + + return val; +#endif +} + +/** + * @brief Loads value of Ulong considering the order. + * + * @param obj The CPU atomic Ulong to get the value from. + * @param order The atomic order for getting the value. + * + * @return The value of @a obj considering the @a order. + */ +static inline unsigned long _Atomic_Load_ulong( const Atomic_Ulong *obj, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->load( order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_load_explicit( obj, order ); +#else + unsigned long val; + + (void) order; + val = *obj; + RTEMS_COMPILER_MEMORY_BARRIER(); + + return val; +#endif +} + +/** + * @brief Loads value of Uintptr considering the order. + * + * @param obj The CPU atomic Uintptr to get the value from. + * @param order The atomic order for getting the value. + * + * @return The value of @a obj considering the @a order. + */ +static inline uintptr_t _Atomic_Load_uintptr( const Atomic_Uintptr *obj, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->load( order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_load_explicit( obj, order ); +#else + uintptr_t val; + + (void) order; + val = *obj; + RTEMS_COMPILER_MEMORY_BARRIER(); + + return val; +#endif +} + +/** + * @brief Stores a value to Uint considering the order. + * + * @param[out] obj The CPU atomic Uint to store a value in. + * @param desired The desired value for @a obj. + * @param order The atomic order for storing the value. + */ +static inline void _Atomic_Store_uint( Atomic_Uint *obj, unsigned int desired, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + obj->store( desired, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + atomic_store_explicit( obj, desired, order ); +#else + (void) order; + RTEMS_COMPILER_MEMORY_BARRIER(); + *obj = desired; +#endif +} + +/** + * @brief Stores a value to Ulong considering the order. + * + * @param[out] obj The CPU atomic Ulong to store a value in. + * @param desired The desired value for @a obj. + * @param order The atomic order for storing the value. + */ +static inline void _Atomic_Store_ulong( Atomic_Ulong *obj, unsigned long desired, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + obj->store( desired, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + atomic_store_explicit( obj, desired, order ); +#else + (void) order; + RTEMS_COMPILER_MEMORY_BARRIER(); + *obj = desired; +#endif +} + +/** + * @brief Stores a value to Uintptr considering the order. + * + * @param[out] obj The CPU atomic Uintptr to store a value in. + * @param desired The desired value for @a obj. + * @param order The atomic order for storing the value. + */ +static inline void _Atomic_Store_uintptr( Atomic_Uintptr *obj, uintptr_t desired, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + obj->store( desired, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + atomic_store_explicit( obj, desired, order ); +#else + (void) order; + RTEMS_COMPILER_MEMORY_BARRIER(); + *obj = desired; +#endif +} + +/** + * @brief Fetches current value of Uint and adds a value to the stored value. + * + * @param[in, out] obj The CPU atomic Uint to get the value from and add @a arg to. + * @param arg The value to add to @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the addition of @a arg. + */ +static inline unsigned int _Atomic_Fetch_add_uint( Atomic_Uint *obj, unsigned int arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_add( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_add_explicit( obj, arg, order ); +#else + unsigned int val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val + arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +/** + * @brief Fetches current value of Ulong and adds a value to the stored value. + * + * @param[in, out] obj The CPU atomic Ulong to get the value from and add @a arg to. + * @param arg The value to add to @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the addition of @a arg. + */ +static inline unsigned long _Atomic_Fetch_add_ulong( Atomic_Ulong *obj, unsigned long arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_add( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_add_explicit( obj, arg, order ); +#else + unsigned long val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val + arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Fetch_add_uintptr( obj, arg, order ) \ - _CPU_atomic_Fetch_add_uintptr( obj, arg, order ) +/** + * @brief Fetches current value of Uintptr and adds a value to the stored value. + * + * @param[in, out] obj The CPU atomic Uintptr to get the value from and add @a arg to. + * @param arg The value to add to @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the addition of @a arg. + */ +static inline uintptr_t _Atomic_Fetch_add_uintptr( Atomic_Uintptr *obj, uintptr_t arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_add( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_add_explicit( obj, arg, order ); +#else + uintptr_t val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val + arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Fetch_sub_uint( obj, arg, order ) \ - _CPU_atomic_Fetch_sub_uint( obj, arg, order ) +/** + * @brief Fetches current value of Uint and subtracts a value from the stored value. + * + * @param[in, out] obj The CPU atomic Uint to get the value from and subtract @a arg from. + * @param arg The value to subtract from @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the subtraction of @a arg. + */ +static inline unsigned int _Atomic_Fetch_sub_uint( Atomic_Uint *obj, unsigned int arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_sub( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_sub_explicit( obj, arg, order ); +#else + unsigned int val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val - arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Fetch_sub_ulong( obj, arg, order ) \ - _CPU_atomic_Fetch_sub_ulong( obj, arg, order ) +/** + * @brief Fetches current value of Ulong and subtracts a value from the stored value. + * + * @param[in, out] obj The CPU atomic Ulong to get the value from and subtract @a arg from. + * @param arg The value to subtract from @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the subtraction of @a arg. + */ +static inline unsigned long _Atomic_Fetch_sub_ulong( Atomic_Ulong *obj, unsigned long arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_sub( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_sub_explicit( obj, arg, order ); +#else + unsigned long val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val - arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Fetch_sub_uintptr( obj, arg, order ) \ - _CPU_atomic_Fetch_sub_uintptr( obj, arg, order ) +/** + * @brief Fetches current value of Uintptr and subtracts a value from the stored value. + * + * @param[in, out] obj The CPU atomic Uintptr to get the value from and subtract @a arg from. + * @param arg The value to subtract from @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the subtraction of @a arg. + */ +static inline uintptr_t _Atomic_Fetch_sub_uintptr( Atomic_Uintptr *obj, uintptr_t arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_sub( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_sub_explicit( obj, arg, order ); +#else + uintptr_t val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val - arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Fetch_or_uint( obj, arg, order ) \ - _CPU_atomic_Fetch_or_uint( obj, arg, order ) +/** + * @brief Fetches current value of Uint and ORs a value with the stored value. + * + * @param[in, out] obj The CPU atomic Uint to get the value from and OR @a arg to. + * @param arg The value to OR with @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the OR operation with @a arg. + */ +static inline unsigned int _Atomic_Fetch_or_uint( Atomic_Uint *obj, unsigned int arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_or( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_or_explicit( obj, arg, order ); +#else + unsigned int val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val | arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Fetch_or_ulong( obj, arg, order ) \ - _CPU_atomic_Fetch_or_ulong( obj, arg, order ) +/** + * @brief Fetches current value of Ulong and ORs a value with the stored value. + * + * @param[in, out] obj The CPU atomic Ulong to get the value from and OR @a arg to. + * @param arg The value to OR with @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the OR operation with @a arg. + */ +static inline unsigned long _Atomic_Fetch_or_ulong( Atomic_Ulong *obj, unsigned long arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_or( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_or_explicit( obj, arg, order ); +#else + unsigned long val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val | arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Fetch_or_uintptr( obj, arg, order ) \ - _CPU_atomic_Fetch_or_uintptr( obj, arg, order ) +/** + * @brief Fetches current value of Uintptr and ORs a value with the stored value. + * + * @param[in, out] obj The CPU atomic Uintptr to get the value from and OR @a arg to. + * @param arg The value to OR with @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the OR operation with @a arg. + */ +static inline uintptr_t _Atomic_Fetch_or_uintptr( Atomic_Uintptr *obj, uintptr_t arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_or( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_or_explicit( obj, arg, order ); +#else + uintptr_t val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val | arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Fetch_and_uint( obj, arg, order ) \ - _CPU_atomic_Fetch_and_uint( obj, arg, order ) +/** + * @brief Fetches current value of Uint and ANDs a value with the stored value. + * + * @param[in, out] obj The CPU atomic Uint to get the value from and AND @a arg to. + * @param arg The value to AND with @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the AND operation with @a arg. + */ +static inline unsigned int _Atomic_Fetch_and_uint( Atomic_Uint *obj, unsigned int arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_and( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_and_explicit( obj, arg, order ); +#else + unsigned int val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val & arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Fetch_and_ulong( obj, arg, order ) \ - _CPU_atomic_Fetch_and_ulong( obj, arg, order ) +/** + * @brief Fetches current value of Ulong and ANDs a value with the stored value. + * + * @param[in, out] obj The CPU atomic Ulong to get the value from and AND @a arg to. + * @param arg The value to AND with @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the AND operation with @a arg. + */ +static inline unsigned long _Atomic_Fetch_and_ulong( Atomic_Ulong *obj, unsigned long arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_and( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_and_explicit( obj, arg, order ); +#else + unsigned long val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val & arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Fetch_and_uintptr( obj, arg, order ) \ - _CPU_atomic_Fetch_and_uintptr( obj, arg, order ) +/** + * @brief Fetches current value of Uintptr and ANDs a value with the stored value. + * + * @param[in, out] obj The CPU atomic Uintptr to get the value from and AND @a arg to. + * @param arg The value to AND with @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the AND operation with @a arg. + */ +static inline uintptr_t _Atomic_Fetch_and_uintptr( Atomic_Uintptr *obj, uintptr_t arg, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->fetch_and( arg, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_fetch_and_explicit( obj, arg, order ); +#else + uintptr_t val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val & arg; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Exchange_uint( obj, desr, order ) \ - _CPU_atomic_Exchange_uint( obj, desr, order ) +/** + * @brief Fetches current value of Uint and sets its value. + * + * @param[in, out] obj The CPU atomic Uint to get the value from and set the value to @a desired. + * @param arg The value to set for @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the exchange with @a desired. + */ +static inline unsigned int _Atomic_Exchange_uint( Atomic_Uint *obj, unsigned int desired, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->exchange( desired, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_exchange_explicit( obj, desired, order ); +#else + unsigned int val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = desired; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Exchange_ulong( obj, desr, order ) \ - _CPU_atomic_Exchange_ulong( obj, desr, order ) +/** + * @brief Fetches current value of Ulong and sets its value. + * + * @param[in, out] obj The CPU atomic Ulong to get the value from and set the value to @a desired. + * @param arg The value to set for @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the exchange with @a desired. + */ +static inline unsigned long _Atomic_Exchange_ulong( Atomic_Ulong *obj, unsigned long desired, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->exchange( desired, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_exchange_explicit( obj, desired, order ); +#else + unsigned long val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = desired; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Exchange_uintptr( obj, desr, order ) \ - _CPU_atomic_Exchange_uintptr( obj, desr, order ) +/** + * @brief Fetches current value of Uintptr and sets its value. + * + * @param[in, out] obj The CPU atomic Uintptr to get the value from and set the value to @a desired. + * @param arg The value to set for @a obj. + * @param order The atomic order for the operation. + * + * @return The value of @a obj prior to the exchange with @a desired. + */ +static inline uintptr_t _Atomic_Exchange_uintptr( Atomic_Uintptr *obj, uintptr_t desired, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->exchange( desired, order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_exchange_explicit( obj, desired, order ); +#else + uintptr_t val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = desired; + _ISR_Local_enable( level ); + + return val; +#endif +} -#define _Atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) \ - _CPU_atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) +/** + * @brief Checks if value of Uint is as expected. + * + * This method checks if the value of @a obj is equal to the value of @a expected. If + * this is the case, the value of @a obj is changed to @a desired. Otherwise, the value + * of @a obj is changed to @a expected. + * + * @param[in, out] obj The CPU atomic Uint to operate upon. + * @param[in, out] expected The expected value of @a obj. If @a obj has a different + * value, @a expected is changed to the actual value of @a obj. + * @param desired The new value of @a obj if the old value of @a obj was as expected. + * @param succ The order if it is successful. + * @param fail The order if it fails. + * + * @retval true The old value of @a obj was as expected. + * @retval false The old value of @a obj was not as expected. + */ +static inline bool _Atomic_Compare_exchange_uint( Atomic_Uint *obj, unsigned int *expected, unsigned int desired, Atomic_Order succ, Atomic_Order fail ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->compare_exchange_strong( *expected, desired, succ, fail ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); +#else + bool success; + ISR_Level level; + unsigned int actual; + + (void) succ; + (void) fail; + _ISR_Local_disable( level ); + actual = *obj; + success = ( actual == *expected ); + if ( success ) { + *obj = desired; + } else { + *expected = actual; + } + _ISR_Local_enable( level ); + + return success; +#endif +} -#define _Atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) \ - _CPU_atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) +/** + * @brief Checks if value of Ulong is as expected. + * + * This method checks if the value of @a obj is equal to the value of @a expected. If + * this is the case, the value of @a obj is changed to @a desired. Otherwise, the value + * of @a obj is changed to @a expected. + * + * @param[in, out] obj The CPU atomic Ulong to operate upon. + * @param[in, out] expected The expected value of @a obj. If @a obj has a different + * value, @a expected is changed to the actual value of @a obj. + * @param desired The new value of @a obj if the old value of @a obj was as expected. + * @param succ The order if it is successful. + * @param fail The order if it fails. + * + * @retval true The old value of @a obj was as expected. + * @retval false The old value of @a obj was not as expected. + */ +static inline bool _Atomic_Compare_exchange_ulong( Atomic_Ulong *obj, unsigned long *expected, unsigned long desired, Atomic_Order succ, Atomic_Order fail ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->compare_exchange_strong( *expected, desired, succ, fail ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); +#else + bool success; + ISR_Level level; + unsigned long actual; + + (void) succ; + (void) fail; + _ISR_Local_disable( level ); + actual = *obj; + success = ( actual == *expected ); + if ( success ) { + *obj = desired; + } else { + *expected = actual; + } + _ISR_Local_enable( level ); + + return success; +#endif +} -#define _Atomic_Compare_exchange_uintptr( obj, expected, desired, succ, fail ) \ - _CPU_atomic_Compare_exchange_uintptr( obj, expected, desired, succ, fail ) +/** + * @brief Checks if value of Uintptr is as expected. + * + * This method checks if the value of @a obj is equal to the value of @a expected. If + * this is the case, the value of @a obj is changed to @a desired. Otherwise, the value + * of @a obj is changed to @a expected. + * + * @param[in, out] obj The CPU atomic Uintptr to operate upon. + * @param[in, out] expected The expected value of @a obj. If @a obj has a different + * value, @a expected is changed to the actual value of @a obj. + * @param desired The new value of @a obj if the old value of @a obj was as expected. + * @param succ The order if it is successful. + * @param fail The order if it fails. + * + * @retval true The old value of @a obj was as expected. + * @retval false The old value of @a obj was not as expected. + */ +static inline bool _Atomic_Compare_exchange_uintptr( Atomic_Uintptr *obj, uintptr_t *expected, uintptr_t desired, Atomic_Order succ, Atomic_Order fail ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->compare_exchange_strong( *expected, desired, succ, fail ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); +#else + bool success; + ISR_Level level; + uintptr_t actual; + + (void) succ; + (void) fail; + _ISR_Local_disable( level ); + actual = *obj; + success = ( actual == *expected ); + if ( success ) { + *obj = desired; + } else { + *expected = actual; + } + _ISR_Local_enable( level ); + + return success; +#endif +} -#define _Atomic_Flag_clear( obj, order ) \ - _CPU_atomic_Flag_clear( obj, order ) +/** + * @brief Clears the atomic flag. + * + * @param[out] obj The atomic flag to be cleared. + * @param order The atomic order for the operation. + */ +static inline void _Atomic_Flag_clear( Atomic_Flag *obj, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + obj->clear( order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + atomic_flag_clear_explicit( obj, order ); +#else + (void) order; + *obj = false; +#endif +} -#define _Atomic_Flag_test_and_set( obj, order ) \ - _CPU_atomic_Flag_test_and_set( obj, order ) +/** + * @brief Returns current flag state and sets it. + * + * @param[in, out] obj The atomic flag to be set. + * @param order The atomic order for the operation. + * + * @retval true @a obj was set prior to this operation. + * @retval false @a obj was not set prior to this operation. + */ +static inline bool _Atomic_Flag_test_and_set( Atomic_Flag *obj, Atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_ATOMIC_USE_ATOMIC) + return obj->test_and_set( order ); +#elif defined(_RTEMS_SCORE_ATOMIC_USE_STDATOMIC) + return atomic_flag_test_and_set_explicit( obj, order ); +#else + bool flag; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + flag = *obj; + *obj = true; + _ISR_Local_enable( level ); + + return flag; +#endif +} /** @} */ diff --git a/cpukit/include/rtems/score/basedefs.h b/cpukit/include/rtems/score/basedefs.h index 7a37299eee..010728d795 100644 --- a/cpukit/include/rtems/score/basedefs.h +++ b/cpukit/include/rtems/score/basedefs.h @@ -3,14 +3,16 @@ /** * @file * + * @ingroup RTEMSScore + * * @brief This header file provides basic definitions used by the API and the * implementation. */ /* - * Copyright (C) 2014 Paval Pisa + * Copyright (C) 2014 Pavel Pisa * Copyright (C) 2011, 2013 On-Line Applications Research Corporation (OAR) - * Copyright (C) 2009, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2009, 2023 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -73,9 +75,8 @@ extern "C" { /** * @defgroup RTEMSAPI API * - * @brief API - * - * This group contains the RTEMS Application Programming Interface (API). + * @brief This group contains the RTEMS Application Programming Interface + * (API). */ /* Generated from spec:/rtems/basedefs/if/group */ @@ -167,9 +168,9 @@ extern "C" { * * @return Returns the alignment requirement of the type. */ -#if __cplusplus >= 201103L +#if defined( __cplusplus ) && __cplusplus >= 201103L #define RTEMS_ALIGNOF( _type_name ) alignof( _type_name ) -#elif __STDC_VERSION__ >= 201112L +#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L #define RTEMS_ALIGNOF( _type_name ) _Alignof( _type_name ) #else #define RTEMS_ALIGNOF( _type_name ) sizeof( _type_name ) @@ -353,6 +354,47 @@ extern "C" { */ #define RTEMS_EXPAND( _token ) _token +/* Generated from spec:/rtems/basedefs/if/function-name */ + +/** + * @ingroup RTEMSAPIBaseDefs + * + * @brief Expands to the name of the function containing the use of this + * define. + */ +#if defined(__cplusplus) && defined(__GNUC__) + #define RTEMS_FUNCTION_NAME __PRETTY_FUNCTION__ +#else + #define RTEMS_FUNCTION_NAME __func__ +#endif + +/* Generated from spec:/rtems/basedefs/if/no-return */ + +/** + * @ingroup RTEMSAPIBaseDefs + * + * @brief Tells the compiler in a function declaration that this function does + * not return. + */ +#if defined( __cplusplus ) && __cplusplus >= 201103L + #define RTEMS_NO_RETURN [[noreturn]] +#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L + #define RTEMS_NO_RETURN _Noreturn +#elif defined(__GNUC__) + #define RTEMS_NO_RETURN __attribute__(( __noreturn__ )) +#else + #define RTEMS_NO_RETURN +#endif + +/* Generated from spec:/rtems/basedefs/if/compiler-no-return-attribute */ + +/** + * @ingroup RTEMSAPIBaseDefs + * + * @brief Provided for backward compatibility. + */ +#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN + /* Generated from spec:/rtems/basedefs/if/section */ /** @@ -390,7 +432,7 @@ extern "C" { * * @brief Gets the pointer reference type. * - * @param _level is the pointer indirection level expressed in *. + * @param _level is the pointer indirection level expressed in ``*``. * * @param _target is the reference target type. * @@ -423,21 +465,33 @@ extern "C" { */ #define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y ) -/* Generated from spec:/score/if/assert-unreachable */ +#if !defined(ASM) && defined(RTEMS_DEBUG) + /* Generated from spec:/score/basedefs/if/debug-unreachable */ -/** - * @brief Asserts that this program point is unreachable. - */ -#if defined(RTEMS_DEBUG) - #define _Assert_Unreachable() _Assert( 0 ) -#else - #define _Assert_Unreachable() do { } while ( 0 ) + /** + * @ingroup RTEMSScore + * + * @brief Terminates the program with a failed assertion. + * + * @param file is the file name. + * + * @param line is the line of the file. + * + * @param func is the function name. + */ + RTEMS_NO_RETURN void _Debug_Unreachable( + const char *file, + int line, + const char *func + ); #endif #if !defined(ASM) - /* Generated from spec:/score/if/dequalify-types-not-compatible */ + /* Generated from spec:/score/basedefs/if/dequalify-types-not-compatible */ /** + * @ingroup RTEMSScore + * * @brief A not implemented function to trigger compile time errors with an * error message. */ @@ -457,7 +511,7 @@ extern "C" { * @brief Performs a type cast which removes qualifiers without warnings to the * type for the variable. * - * @param _ptr_level is the pointer indirection level expressed in *. + * @param _ptr_level is the pointer indirection level expressed in ``*``. * * @param _type is the target type of the cast. * @@ -468,12 +522,18 @@ extern "C" { ( const_cast<_type>( _var ) ) #elif defined(__GNUC__) #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ - __builtin_choose_expr( __builtin_types_compatible_p( \ + __builtin_choose_expr( \ + __builtin_types_compatible_p( \ RTEMS_TYPEOF_REFX( _ptr_level, _var ), \ RTEMS_TYPEOF_REFX( _ptr_level, _type ) \ - ) || __builtin_types_compatible_p( _type, void * ), \ - (_type) ( _var ), \ - RTEMS_DEQUALIFY_types_not_compatible() ) + ) || \ + __builtin_types_compatible_p( \ + _type, \ + void * \ + ), \ + (_type) ( _var ), \ + RTEMS_DEQUALIFY_types_not_compatible() \ + ) #else #define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ ( (_type) (uintptr_t) (const volatile void *)( _var ) ) @@ -602,33 +662,6 @@ extern "C" { #define RTEMS_NO_INLINE #endif -/* Generated from spec:/rtems/basedefs/if/no-return */ - -/** - * @ingroup RTEMSAPIBaseDefs - * - * @brief Tells the compiler in a function declaration that this function does - * not return. - */ -#if __cplusplus >= 201103L - #define RTEMS_NO_RETURN [[noreturn]] -#elif __STDC_VERSION__ >= 201112L - #define RTEMS_NO_RETURN _Noreturn -#elif defined(__GNUC__) - #define RTEMS_NO_RETURN __attribute__(( __noreturn__ )) -#else - #define RTEMS_NO_RETURN -#endif - -/* Generated from spec:/rtems/basedefs/if/compiler-no-return-attribute */ - -/** - * @ingroup RTEMSAPIBaseDefs - * - * @brief Provided for backward compatibility. - */ -#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN - /* Generated from spec:/rtems/basedefs/if/noinit */ /** @@ -800,9 +833,9 @@ extern "C" { * * @param _msg is the error message in case the static assertion fails. */ -#if __cplusplus >= 201103L +#if defined( __cplusplus ) && __cplusplus >= 201103L #define RTEMS_STATIC_ASSERT( _cond, _msg ) static_assert( _cond, # _msg ) -#elif __STDC_VERSION__ >= 201112L +#elif defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 201112L #define RTEMS_STATIC_ASSERT( _cond, _msg ) _Static_assert( _cond, # _msg ) #else #define RTEMS_STATIC_ASSERT( _cond, _msg ) \ @@ -846,14 +879,13 @@ extern "C" { * * @brief Tells the compiler that this program point is unreachable. */ -#if defined(__GNUC__) +#if defined(RTEMS_DEBUG) #define RTEMS_UNREACHABLE() \ - do { \ - __builtin_unreachable(); \ - _Assert_Unreachable(); \ - } while ( 0 ) + _Debug_Unreachable( __FILE__, __LINE__, RTEMS_FUNCTION_NAME ) +#elif defined(__GNUC__) + #define RTEMS_UNREACHABLE() __builtin_unreachable() #else - #define RTEMS_UNREACHABLE() _Assert_Unreachable() + #define RTEMS_UNREACHABLE() do { } while ( 0 ) #endif /* Generated from spec:/rtems/basedefs/if/unused */ @@ -967,11 +999,12 @@ extern "C" { * * @param _value is the value of the symbol. On the value a macro expansion is * performed and afterwards it is stringified. It shall expand to an integer - * expression understood by the assembler. + * expression understood by the assembler. The value shall be representable + * in the code model of the target architecture. * * This macro shall be placed at file scope. */ -#if defined(__USER_LABEL_PREFIX__) +#if defined(__GNUC__) #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \ __asm__( \ "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \ diff --git a/cpukit/include/rtems/score/chain.h b/cpukit/include/rtems/score/chain.h index bdd457228e..0b1ede75cf 100644 --- a/cpukit/include/rtems/score/chain.h +++ b/cpukit/include/rtems/score/chain.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,14 +10,31 @@ */ /* - * Copyright (c) 2010 embedded brains GmbH. + * Copyright (c) 2010 embedded brains GmbH & Co. KG * * COPYRIGHT (c) 1989-2006. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_CHAIN_H @@ -42,17 +61,7 @@ extern "C" { */ /** - * @typedef Chain_Node - * - * This type definition promotes the name for the Chain Node used by - * all RTEMS code. It is a separate type definition because a forward - * reference is required to define it. See @ref Chain_Node_struct for - * detailed information. - */ -typedef struct Chain_Node_struct Chain_Node; - -/** - * @struct Chain_Node_struct + * @brief This structure represents a chain node. * * This is used to manage each element (node) which is placed * on a chain. @@ -66,15 +75,15 @@ typedef struct Chain_Node_struct Chain_Node; * so the user can cast the pointers back and forth. * */ -struct Chain_Node_struct { +typedef struct Chain_Node { /** This points to the node after this one on this chain. */ - Chain_Node *next; + struct Chain_Node *next; /** This points to the node immediate prior to this one on this chain. */ - Chain_Node *previous; -}; + struct Chain_Node *previous; +} Chain_Node; /** - * @struct Chain_Control + * @brief This union represents a chain control block. * * This is used to manage a chain. A chain consists of a doubly * linked list of zero or more nodes. diff --git a/cpukit/include/rtems/score/chainimpl.h b/cpukit/include/rtems/score/chainimpl.h index 234dd1d74e..a2ea5e2645 100644 --- a/cpukit/include/rtems/score/chainimpl.h +++ b/cpukit/include/rtems/score/chainimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,14 +10,31 @@ */ /* - * Copyright (c) 2010 embedded brains GmbH. + * Copyright (c) 2010 embedded brains GmbH & Co. KG * * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_CHAINIMPL_H @@ -102,7 +121,7 @@ size_t _Chain_Node_count_unprotected( const Chain_Control *chain ); * * @param[out] node The node to set off chain. */ -RTEMS_INLINE_ROUTINE void _Chain_Set_off_chain( +static inline void _Chain_Set_off_chain( Chain_Node *node ) { @@ -120,7 +139,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Set_off_chain( * * @param[out] the_node The chain node to initialize. */ -RTEMS_INLINE_ROUTINE void _Chain_Initialize_node( Chain_Node *the_node ) +static inline void _Chain_Initialize_node( Chain_Node *the_node ) { #if defined(RTEMS_DEBUG) _Chain_Set_off_chain( the_node ); @@ -140,7 +159,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Initialize_node( Chain_Node *the_node ) * @retval true The @a node is off chain. * @retval false The @a node is not off chain. */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_node_off_chain( +static inline bool _Chain_Is_node_off_chain( const Chain_Node *node ) { @@ -159,7 +178,7 @@ RTEMS_INLINE_ROUTINE bool _Chain_Is_node_off_chain( * @retval true @a left and @a right are equal. * @retval false @a left and @a right are not equal. */ -RTEMS_INLINE_ROUTINE bool _Chain_Are_nodes_equal( +static inline bool _Chain_Are_nodes_equal( const Chain_Node *left, const Chain_Node *right ) @@ -176,7 +195,7 @@ RTEMS_INLINE_ROUTINE bool _Chain_Are_nodes_equal( * * @return This method returns the permanent head node of the chain. */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Head( +static inline Chain_Node *_Chain_Head( Chain_Control *the_chain ) { @@ -192,7 +211,7 @@ RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Head( * * @return This method returns the permanent head node of the chain. */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_head( +static inline const Chain_Node *_Chain_Immutable_head( const Chain_Control *the_chain ) { @@ -208,7 +227,7 @@ RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_head( * * @return This method returns the permanent tail node of the chain. */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Tail( +static inline Chain_Node *_Chain_Tail( Chain_Control *the_chain ) { @@ -224,7 +243,7 @@ RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Tail( * * @return This method returns the permanent tail node of the chain. */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_tail( +static inline const Chain_Node *_Chain_Immutable_tail( const Chain_Control *the_chain ) { @@ -241,7 +260,7 @@ RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_tail( * * @return This method returns the first node of the chain. */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_First( +static inline Chain_Node *_Chain_First( const Chain_Control *the_chain ) { @@ -258,7 +277,7 @@ RTEMS_INLINE_ROUTINE Chain_Node *_Chain_First( * * @return This method returns the first node of the chain. */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_first( +static inline const Chain_Node *_Chain_Immutable_first( const Chain_Control *the_chain ) { @@ -275,7 +294,7 @@ RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_first( * * @return This method returns the last node of the chain. */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Last( +static inline Chain_Node *_Chain_Last( const Chain_Control *the_chain ) { @@ -292,7 +311,7 @@ RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Last( * * @return This method returns the last node of the chain. */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_last( +static inline const Chain_Node *_Chain_Immutable_last( const Chain_Control *the_chain ) { @@ -308,7 +327,7 @@ RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_last( * * @return This method returns the next node on the chain. */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Next( +static inline Chain_Node *_Chain_Next( const Chain_Node *the_node ) { @@ -324,7 +343,7 @@ RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Next( * * @return This method returns the next node on the chain. */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_next( +static inline const Chain_Node *_Chain_Immutable_next( const Chain_Node *the_node ) { @@ -340,7 +359,7 @@ RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_next( * * @return This method returns the previous node on the chain. */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Previous( +static inline Chain_Node *_Chain_Previous( const Chain_Node *the_node ) { @@ -356,7 +375,7 @@ RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Previous( * * @return This method returns the previous node on the chain. */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_previous( +static inline const Chain_Node *_Chain_Immutable_previous( const Chain_Node *the_node ) { @@ -374,7 +393,7 @@ RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_previous( * @retval true There are no nodes on @a the_chain. * @retval false There are nodes on @a the_chain. */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_empty( +static inline bool _Chain_Is_empty( const Chain_Control *the_chain ) { @@ -394,7 +413,7 @@ RTEMS_INLINE_ROUTINE bool _Chain_Is_empty( * @retval true @a the_node is the first node on a chain. * @retval false @a the_node is not the first node on a chain. */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_first( +static inline bool _Chain_Is_first( const Chain_Node *the_node ) { @@ -413,7 +432,7 @@ RTEMS_INLINE_ROUTINE bool _Chain_Is_first( * @retval true @a the_node is the last node on a chain. * @retval false @a the_node is not the last node on a chain. */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_last( +static inline bool _Chain_Is_last( const Chain_Node *the_node ) { @@ -431,7 +450,7 @@ RTEMS_INLINE_ROUTINE bool _Chain_Is_last( * @retval true There is only one node on @a the_chain. * @retval false There is more than one node on @a the_chain. */ -RTEMS_INLINE_ROUTINE bool _Chain_Has_only_one_node( +static inline bool _Chain_Has_only_one_node( const Chain_Control *the_chain ) { @@ -451,7 +470,7 @@ RTEMS_INLINE_ROUTINE bool _Chain_Has_only_one_node( * @retval true @a the_node is the head of @a the_chain. * @retval false @a the_node is not the head of @a the_chain. */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_head( +static inline bool _Chain_Is_head( const Chain_Control *the_chain, const Chain_Node *the_node ) @@ -471,7 +490,7 @@ RTEMS_INLINE_ROUTINE bool _Chain_Is_head( * @retval true @a the_node is the tail of @a the_chain. * @retval false @a the_node is not the tail of @a the_chain. */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_tail( +static inline bool _Chain_Is_tail( const Chain_Control *the_chain, const Chain_Node *the_node ) @@ -486,7 +505,7 @@ RTEMS_INLINE_ROUTINE bool _Chain_Is_tail( * * @param[out] the_chain The chain to be initialized. */ -RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty( +static inline void _Chain_Initialize_empty( Chain_Control *the_chain ) { @@ -509,7 +528,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty( * @param[out] the_chain The chain to be initialized to contain exactly the specified node. * @param[out] the_node The one and only node of the chain to be initialized. */ -RTEMS_INLINE_ROUTINE void _Chain_Initialize_one( +static inline void _Chain_Initialize_one( Chain_Control *the_chain, Chain_Node *the_node ) @@ -539,7 +558,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Initialize_one( * * @param[out] the_node The node to be extracted. */ -RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected( +static inline void _Chain_Extract_unprotected( Chain_Node *the_node ) { @@ -573,7 +592,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected( * @note This routine assumes that there is at least one node on the chain * and always returns a node even if it is the Chain Tail. */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Get_first_unprotected( +static inline Chain_Node *_Chain_Get_first_unprotected( Chain_Control *the_chain ) { @@ -611,7 +630,7 @@ RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Get_first_unprotected( * @note It does NOT disable interrupts to ensure the atomicity of the * get operation. */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Get_unprotected( +static inline Chain_Node *_Chain_Get_unprotected( Chain_Control *the_chain ) { @@ -634,7 +653,7 @@ RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Get_unprotected( * @note It does NOT disable interrupts to ensure the atomicity * of the extract operation. */ -RTEMS_INLINE_ROUTINE void _Chain_Insert_unprotected( +static inline void _Chain_Insert_unprotected( Chain_Node *after_node, Chain_Node *the_node ) @@ -661,7 +680,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Insert_unprotected( * @note It does NOT disable interrupts to ensure the atomicity of the * append operation. */ -RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected( +static inline void _Chain_Append_unprotected( Chain_Control *the_chain, Chain_Node *the_node ) @@ -692,7 +711,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected( * * @see _Chain_Append_unprotected() and _Chain_Is_node_off_chain(). */ -RTEMS_INLINE_ROUTINE void _Chain_Append_if_is_off_chain_unprotected( +static inline void _Chain_Append_if_is_off_chain_unprotected( Chain_Control *the_chain, Chain_Node *the_node ) @@ -713,7 +732,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Append_if_is_off_chain_unprotected( * @note It does NOT disable interrupts to ensure the atomicity of the * prepend operation. */ -RTEMS_INLINE_ROUTINE void _Chain_Prepend_unprotected( +static inline void _Chain_Prepend_unprotected( Chain_Control *the_chain, Chain_Node *the_node ) @@ -735,7 +754,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Prepend_unprotected( * @retval true The chain was empty before. * @retval false The chain contained at least one node before. */ -RTEMS_INLINE_ROUTINE bool _Chain_Append_with_empty_check_unprotected( +static inline bool _Chain_Append_with_empty_check_unprotected( Chain_Control *the_chain, Chain_Node *the_node ) @@ -761,7 +780,7 @@ RTEMS_INLINE_ROUTINE bool _Chain_Append_with_empty_check_unprotected( * @retval true The chain was empty before. * @retval false The chain contained at least one node before. */ -RTEMS_INLINE_ROUTINE bool _Chain_Prepend_with_empty_check_unprotected( +static inline bool _Chain_Prepend_with_empty_check_unprotected( Chain_Control *the_chain, Chain_Node *the_node ) @@ -791,7 +810,7 @@ RTEMS_INLINE_ROUTINE bool _Chain_Prepend_with_empty_check_unprotected( * @retval true The chain is empty now. * @retval false The chain contains at least one node now. */ -RTEMS_INLINE_ROUTINE bool _Chain_Get_with_empty_check_unprotected( +static inline bool _Chain_Get_with_empty_check_unprotected( Chain_Control *the_chain, Chain_Node **the_node ) @@ -826,7 +845,8 @@ RTEMS_INLINE_ROUTINE bool _Chain_Get_with_empty_check_unprotected( * @retval false Otherwise. */ typedef bool ( *Chain_Node_order )( - const void *left, + const void *key, + const Chain_Node *left, const Chain_Node *right ); @@ -845,21 +865,23 @@ typedef bool ( *Chain_Node_order )( * variable. * @param order The order relation. */ -RTEMS_INLINE_ROUTINE void _Chain_Insert_ordered_unprotected( +static inline void _Chain_Insert_ordered_unprotected( Chain_Control *the_chain, Chain_Node *to_insert, - const void *left, + const void *key, Chain_Node_order order ) { const Chain_Node *tail = _Chain_Immutable_tail( the_chain ); + Chain_Node *previous = _Chain_Head( the_chain ); Chain_Node *next = _Chain_First( the_chain ); - while ( next != tail && !( *order )( left, next ) ) { + while ( next != tail && !( *order )( key, to_insert, next ) ) { + previous = next; next = _Chain_Next( next ); } - _Chain_Insert_unprotected( _Chain_Previous( next ), to_insert ); + _Chain_Insert_unprotected( previous, to_insert ); } /** @@ -932,7 +954,7 @@ typedef struct { * * @param[out] the_registry The chain iterator registry to be initialized. */ -RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_initialize( +static inline void _Chain_Iterator_registry_initialize( Chain_Iterator_registry *the_registry ) { @@ -951,7 +973,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_initialize( * @param[in, out] the_registry the chain iterator registry. * @param[out] the_node_to_extract The node that will be extracted. */ -RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_update( +static inline void _Chain_Iterator_registry_update( Chain_Iterator_registry *the_registry, Chain_Node *the_node_to_extract ) @@ -1038,7 +1060,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_update( * implementation is unfit for use in performance relevant components, due to * the linear time complexity in _Chain_Iterator_registry_update(). */ -RTEMS_INLINE_ROUTINE void _Chain_Iterator_initialize( +static inline void _Chain_Iterator_initialize( Chain_Control *the_chain, Chain_Iterator_registry *the_registry, Chain_Iterator *the_iterator, @@ -1070,7 +1092,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Iterator_initialize( * * @return The next node in the iterator direction */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Iterator_next( +static inline Chain_Node *_Chain_Iterator_next( const Chain_Iterator *the_iterator ) { @@ -1087,7 +1109,7 @@ RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Iterator_next( * @param[out] the_iterator The chain iterator. * @param[out] the_node The new iterator position. */ -RTEMS_INLINE_ROUTINE void _Chain_Iterator_set_position( +static inline void _Chain_Iterator_set_position( Chain_Iterator *the_iterator, Chain_Node *the_node ) @@ -1102,7 +1124,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Iterator_set_position( * * @param[out] the_iterator The chain iterator. */ -RTEMS_INLINE_ROUTINE void _Chain_Iterator_destroy( +static inline void _Chain_Iterator_destroy( Chain_Iterator *the_iterator ) { diff --git a/cpukit/include/rtems/score/context.h b/cpukit/include/rtems/score/context.h index b65c15e73b..123ee4f88e 100644 --- a/cpukit/include/rtems/score/context.h +++ b/cpukit/include/rtems/score/context.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_CONTEXT_H diff --git a/cpukit/include/rtems/score/copyrt.h b/cpukit/include/rtems/score/copyrt.h index 870d7b6353..21c4bec635 100644 --- a/cpukit/include/rtems/score/copyrt.h +++ b/cpukit/include/rtems/score/copyrt.h @@ -1,7 +1,9 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @ingroup RTEMSSuperCoreCopyright + * @ingroup RTEMSScoreCopyright * * @brief This header file provides the interfaces of the * @ref RTEMSScoreCopyright. @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_COPYRT_H diff --git a/cpukit/include/rtems/score/corebarrier.h b/cpukit/include/rtems/score/corebarrier.h index 7cfaeddca7..0b3c5e37fa 100644 --- a/cpukit/include/rtems/score/corebarrier.h +++ b/cpukit/include/rtems/score/corebarrier.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_COREBARRIER_H diff --git a/cpukit/include/rtems/score/corebarrierimpl.h b/cpukit/include/rtems/score/corebarrierimpl.h index 4e7f07d8e9..b58bc44b4c 100644 --- a/cpukit/include/rtems/score/corebarrierimpl.h +++ b/cpukit/include/rtems/score/corebarrierimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2006. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_COREBARRIERIMPL_H @@ -70,7 +89,7 @@ void _CORE_barrier_Initialize( * * @param[out] the_barrier The barrier to destroy. */ -RTEMS_INLINE_ROUTINE void _CORE_barrier_Destroy( +static inline void _CORE_barrier_Destroy( CORE_barrier_Control *the_barrier ) { @@ -83,7 +102,7 @@ RTEMS_INLINE_ROUTINE void _CORE_barrier_Destroy( * @param[in, out] the_barrier The barrier to acquire. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_barrier_Acquire_critical( +static inline void _CORE_barrier_Acquire_critical( CORE_barrier_Control *the_barrier, Thread_queue_Context *queue_context ) @@ -97,7 +116,7 @@ RTEMS_INLINE_ROUTINE void _CORE_barrier_Acquire_critical( * @param[in, out] the_barrier The barrier to release. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_barrier_Release( +static inline void _CORE_barrier_Release( CORE_barrier_Control *the_barrier, Thread_queue_Context *queue_context ) @@ -138,7 +157,7 @@ Status_Control _CORE_barrier_Seize( * * @return The number of unblocked threads. */ -RTEMS_INLINE_ROUTINE uint32_t _CORE_barrier_Surrender( +static inline uint32_t _CORE_barrier_Surrender( CORE_barrier_Control *the_barrier, Thread_queue_Context *queue_context ) @@ -157,7 +176,7 @@ RTEMS_INLINE_ROUTINE uint32_t _CORE_barrier_Surrender( * @param[in, out] the_barrier The barrier to flush. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_barrier_Flush( +static inline void _CORE_barrier_Flush( CORE_barrier_Control *the_barrier, Thread_queue_Context *queue_context ) diff --git a/cpukit/include/rtems/score/coremsg.h b/cpukit/include/rtems/score/coremsg.h index c4320a11a3..3b7ab1b222 100644 --- a/cpukit/include/rtems/score/coremsg.h +++ b/cpukit/include/rtems/score/coremsg.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_COREMSG_H diff --git a/cpukit/include/rtems/score/coremsgbuffer.h b/cpukit/include/rtems/score/coremsgbuffer.h index 330a480423..cceb80bdf5 100644 --- a/cpukit/include/rtems/score/coremsgbuffer.h +++ b/cpukit/include/rtems/score/coremsgbuffer.h @@ -11,7 +11,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * Copyright (C) 1989, 2009 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/include/rtems/score/coremsgimpl.h b/cpukit/include/rtems/score/coremsgimpl.h index 7f01769010..a11beef938 100644 --- a/cpukit/include/rtems/score/coremsgimpl.h +++ b/cpukit/include/rtems/score/coremsgimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_COREMSGIMPL_H @@ -353,7 +372,7 @@ void _CORE_message_queue_Insert_message( * @retval STATUS_MESSAGE_QUEUE_WAIT_IN_ISR The caller is in an ISR, do not block! * @retval STATUS_TIMEOUT A timeout occurred. */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Send( +static inline Status_Control _CORE_message_queue_Send( CORE_message_queue_Control *the_message_queue, const void *buffer, size_t size, @@ -389,7 +408,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Send( * @retval STATUS_MESSAGE_QUEUE_WAIT_IN_ISR The caller is in an ISR, do not block! * @retval STATUS_TIMEOUT A timeout occurred. */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Urgent( +static inline Status_Control _CORE_message_queue_Urgent( CORE_message_queue_Control *the_message_queue, const void *buffer, size_t size, @@ -411,10 +430,10 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Urgent( /** * @brief Acquires the message queue. * - * @param[in, out] the_message_queue Rhe message queue to acquire. + * @param[in, out] the_message_queue The message queue to acquire. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_message_queue_Acquire( +static inline void _CORE_message_queue_Acquire( CORE_message_queue_Control *the_message_queue, Thread_queue_Context *queue_context ) @@ -428,7 +447,7 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Acquire( * @param[in, out] the_message_queue The message queue to acquire critical. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_message_queue_Acquire_critical( +static inline void _CORE_message_queue_Acquire_critical( CORE_message_queue_Control *the_message_queue, Thread_queue_Context *queue_context ) @@ -442,7 +461,7 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Acquire_critical( * @param[in, out] the_message_queue The message queue to release. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_message_queue_Release( +static inline void _CORE_message_queue_Release( CORE_message_queue_Control *the_message_queue, Thread_queue_Context *queue_context ) @@ -460,7 +479,7 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Release( * @param[out] destination The destination messag buffer to copy the source to. * @param size The size of the source buffer. */ -RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer ( +static inline void _CORE_message_queue_Copy_buffer ( const void *source, void *destination, size_t size @@ -480,7 +499,7 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer ( * @retval pointer The allocated message buffer. * @retval NULL The inactive message buffer chain is empty. */ -RTEMS_INLINE_ROUTINE CORE_message_queue_Buffer * +static inline CORE_message_queue_Buffer * _CORE_message_queue_Allocate_message_buffer ( CORE_message_queue_Control *the_message_queue ) @@ -498,7 +517,7 @@ _CORE_message_queue_Allocate_message_buffer ( * @param[in, out] the_message_queue The message queue to free the message buffer to. * @param[out] the_message The message to be freed. */ -RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer ( +static inline void _CORE_message_queue_Free_message_buffer ( CORE_message_queue_Control *the_message_queue, CORE_message_queue_Buffer *the_message ) @@ -519,7 +538,7 @@ RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer ( * @note It encapsulates the optional behavior that message priority is * disabled if no API requires it. */ -RTEMS_INLINE_ROUTINE int _CORE_message_queue_Get_message_priority ( +static inline int _CORE_message_queue_Get_message_priority ( const CORE_message_queue_Buffer *the_message ) { @@ -541,7 +560,7 @@ RTEMS_INLINE_ROUTINE int _CORE_message_queue_Get_message_priority ( * @retval pointer The first message if the message queue is not empty. * @retval NULL The message queue is empty. */ -RTEMS_INLINE_ROUTINE +static inline CORE_message_queue_Buffer *_CORE_message_queue_Get_pending_message ( CORE_message_queue_Control *the_message_queue ) @@ -562,7 +581,7 @@ RTEMS_INLINE_ROUTINE * @retval true Notification is enabled on this message queue. * @retval false Notification is not enabled on this message queue. */ - RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_notify_enabled ( + static inline bool _CORE_message_queue_Is_notify_enabled ( CORE_message_queue_Control *the_message_queue ) { @@ -580,7 +599,7 @@ RTEMS_INLINE_ROUTINE * @param[out] the_handler The notification information for the message queue. */ #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) - RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify ( + static inline void _CORE_message_queue_Set_notify ( CORE_message_queue_Control *the_message_queue, CORE_message_queue_Notify_Handler the_handler ) @@ -608,7 +627,7 @@ RTEMS_INLINE_ROUTINE * @retval thread The Thread_Control for the first locked thread, if there is a locked thread. * @retval NULL There are pending messages or no thread waiting to receive. */ -RTEMS_INLINE_ROUTINE Thread_Control *_CORE_message_queue_Dequeue_receiver( +static inline Thread_Control *_CORE_message_queue_Dequeue_receiver( CORE_message_queue_Control *the_message_queue, const void *buffer, size_t size, diff --git a/cpukit/include/rtems/score/coremutex.h b/cpukit/include/rtems/score/coremutex.h index 2f65d6c8c0..f3afe6c698 100644 --- a/cpukit/include/rtems/score/coremutex.h +++ b/cpukit/include/rtems/score/coremutex.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_COREMUTEX_H diff --git a/cpukit/include/rtems/score/coremuteximpl.h b/cpukit/include/rtems/score/coremuteximpl.h index 757efbde9b..bcdd1adceb 100644 --- a/cpukit/include/rtems/score/coremuteximpl.h +++ b/cpukit/include/rtems/score/coremuteximpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_COREMUTEXIMPL_H @@ -46,7 +65,7 @@ extern "C" { * * @param[out] the_mutex The mutex to initialize. */ -RTEMS_INLINE_ROUTINE void _CORE_mutex_Initialize( +static inline void _CORE_mutex_Initialize( CORE_mutex_Control *the_mutex ) { @@ -58,7 +77,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Initialize( * * @param[out] the_mutex the mutex to destroy. */ -RTEMS_INLINE_ROUTINE void _CORE_mutex_Destroy( CORE_mutex_Control *the_mutex ) +static inline void _CORE_mutex_Destroy( CORE_mutex_Control *the_mutex ) { _Thread_queue_Destroy( &the_mutex->Wait_queue ); } @@ -69,7 +88,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Destroy( CORE_mutex_Control *the_mutex ) * @param[in, out] the_mutex The mutex to acquire critical. * @param queue_context The queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_mutex_Acquire_critical( +static inline void _CORE_mutex_Acquire_critical( CORE_mutex_Control *the_mutex, Thread_queue_Context *queue_context ) @@ -83,7 +102,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Acquire_critical( * @param[in, out] the_mutex The mutex to release. * @param queue_context The queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_mutex_Release( +static inline void _CORE_mutex_Release( CORE_mutex_Control *the_mutex, Thread_queue_Context *queue_context ) @@ -98,7 +117,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Release( * * @return The owner of the mutex. */ -RTEMS_INLINE_ROUTINE Thread_Control *_CORE_mutex_Get_owner( +static inline Thread_Control *_CORE_mutex_Get_owner( const CORE_mutex_Control *the_mutex ) { @@ -116,7 +135,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_CORE_mutex_Get_owner( * @retval true The mutex is locked. * @retval false The mutex is not locked. */ -RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_locked( +static inline bool _CORE_mutex_Is_locked( const CORE_mutex_Control *the_mutex ) { @@ -149,7 +168,7 @@ Status_Control _CORE_mutex_Seize_slow( * @param[out] the_mutex The mutex to set the owner from. * @param owner The new owner of the mutex. */ -RTEMS_INLINE_ROUTINE void _CORE_mutex_Set_owner( +static inline void _CORE_mutex_Set_owner( CORE_mutex_Control *the_mutex, Thread_Control *owner ) @@ -166,7 +185,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Set_owner( * @retval true @a the_thread is the owner of @a the_mutex. * @retval false @a the_thread is not the owner of @a the_mutex. */ -RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_owner( +static inline bool _CORE_mutex_Is_owner( const CORE_mutex_Control *the_mutex, const Thread_Control *the_thread ) @@ -179,7 +198,7 @@ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_owner( * * @param[out] the_mutex The recursive mutex to initialize. */ -RTEMS_INLINE_ROUTINE void _CORE_recursive_mutex_Initialize( +static inline void _CORE_recursive_mutex_Initialize( CORE_recursive_mutex_Control *the_mutex ) { @@ -194,7 +213,7 @@ RTEMS_INLINE_ROUTINE void _CORE_recursive_mutex_Initialize( * * @return STATUS_SUCCESSFUL, this method is always successful. */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_nested( +static inline Status_Control _CORE_recursive_mutex_Seize_nested( CORE_recursive_mutex_Control *the_mutex ) { @@ -217,7 +236,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_nested( * @retval _Thread_Wait_get_status The status of the executing thread. * @retval STATUS_UNAVAILABLE The calling thread is not willing to wait. */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize( +static inline Status_Control _CORE_recursive_mutex_Seize( CORE_recursive_mutex_Control *the_mutex, const Thread_queue_Operations *operations, Thread_Control *executing, @@ -267,7 +286,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize( * @retval STATUS_SUCCESSFUL @a the_mutex is successfully surrendered. * @retval STATUS_NOT_OWNER The executing thread does not own @a the_mutex. */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Surrender( +static inline Status_Control _CORE_recursive_mutex_Surrender( CORE_recursive_mutex_Control *the_mutex, const Thread_queue_Operations *operations, Thread_Control *executing, @@ -320,7 +339,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Surrender( * Only needed if RTEMS_SMP is defined * @param priority_ceiling The priority ceiling for the initialized mutex. */ -RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Initialize( +static inline void _CORE_ceiling_mutex_Initialize( CORE_ceiling_mutex_Control *the_mutex, const Scheduler_Control *scheduler, Priority_Control priority_ceiling @@ -340,7 +359,7 @@ RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Initialize( * * @return The scheduler of the mutex. If RTEMS_SMP is not defined, the first entry of the _Scheduler_Table is returned. */ -RTEMS_INLINE_ROUTINE const Scheduler_Control * +static inline const Scheduler_Control * _CORE_ceiling_mutex_Get_scheduler( const CORE_ceiling_mutex_Control *the_mutex ) @@ -357,12 +376,10 @@ _CORE_ceiling_mutex_Get_scheduler( * * @param[out] the_mutex The ceiling mutex to set the priority of. * @param priority_ceiling The new priority ceiling of the mutex. - * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority( +static inline void _CORE_ceiling_mutex_Set_priority( CORE_ceiling_mutex_Control *the_mutex, - Priority_Control priority_ceiling, - Thread_queue_Context *queue_context + Priority_Control priority_ceiling ) { Thread_Control *owner; @@ -370,15 +387,19 @@ RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority( owner = _CORE_mutex_Get_owner( &the_mutex->Recursive.Mutex ); if ( owner != NULL ) { - _Thread_Wait_acquire( owner, queue_context ); + Thread_queue_Context queue_context; + + _Thread_queue_Context_initialize( &queue_context ); + _Thread_queue_Context_clear_priority_updates( &queue_context ); + _Thread_Wait_acquire_critical( owner, &queue_context ); _Thread_Priority_change( owner, &the_mutex->Priority_ceiling, priority_ceiling, PRIORITY_GROUP_LAST, - queue_context + &queue_context ); - _Thread_Wait_release( owner, queue_context ); + _Thread_Wait_release_critical( owner, &queue_context ); } else { the_mutex->Priority_ceiling.priority = priority_ceiling; } @@ -391,7 +412,7 @@ RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority( * * @return The priority ceiling of @a the_mutex. */ -RTEMS_INLINE_ROUTINE Priority_Control _CORE_ceiling_mutex_Get_priority( +static inline Priority_Control _CORE_ceiling_mutex_Get_priority( const CORE_ceiling_mutex_Control *the_mutex ) { @@ -409,7 +430,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _CORE_ceiling_mutex_Get_priority( * @retval STATUS_MUTEX_CEILING_VIOLATED The owners wait priority * is smaller than the priority of the ceiling mutex. */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Set_owner( +static inline Status_Control _CORE_ceiling_mutex_Set_owner( CORE_ceiling_mutex_Control *the_mutex, Thread_Control *owner, Thread_queue_Context *queue_context @@ -463,7 +484,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Set_owner( * is smaller than the priority of the ceiling mutex. * @retval other Return value of @a nested. */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize( +static inline Status_Control _CORE_ceiling_mutex_Seize( CORE_ceiling_mutex_Control *the_mutex, Thread_Control *executing, bool wait, @@ -475,19 +496,19 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize( _CORE_mutex_Acquire_critical( &the_mutex->Recursive.Mutex, queue_context ); - owner = _CORE_mutex_Get_owner( &the_mutex->Recursive.Mutex ); - - if ( owner == NULL ) { #if defined(RTEMS_SMP) - if ( - _Thread_Scheduler_get_home( executing ) - != _CORE_ceiling_mutex_Get_scheduler( the_mutex ) - ) { - _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); - return STATUS_NOT_DEFINED; - } + if ( + _Thread_Scheduler_get_home( executing ) + != _CORE_ceiling_mutex_Get_scheduler( the_mutex ) + ) { + _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); + return STATUS_NOT_DEFINED; + } #endif + owner = _CORE_mutex_Get_owner( &the_mutex->Recursive.Mutex ); + + if ( owner == NULL ) { _Thread_queue_Context_clear_priority_updates( queue_context ); return _CORE_ceiling_mutex_Set_owner( the_mutex, @@ -523,7 +544,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize( * @retval STATUS_SUCCESSFUL The ceiling mutex was successfullysurrendered. * @retval STATUS_NOT_OWNER The executing thread is not the owner of @a the_mutex. */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Surrender( +static inline Status_Control _CORE_ceiling_mutex_Surrender( CORE_ceiling_mutex_Control *the_mutex, Thread_Control *executing, Thread_queue_Context *queue_context diff --git a/cpukit/include/rtems/score/corerwlockimpl.h b/cpukit/include/rtems/score/corerwlockimpl.h index dc1f375be6..0cb2965199 100644 --- a/cpukit/include/rtems/score/corerwlockimpl.h +++ b/cpukit/include/rtems/score/corerwlockimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_CORERWLOCKIMPL_H @@ -105,7 +124,7 @@ void _CORE_RWLock_Initialize( * * @param[out] the_rwlock is the RWLock to destroy. */ -RTEMS_INLINE_ROUTINE void _CORE_RWLock_Destroy( +static inline void _CORE_RWLock_Destroy( CORE_RWLock_Control *the_rwlock ) { @@ -120,7 +139,7 @@ RTEMS_INLINE_ROUTINE void _CORE_RWLock_Destroy( * * @return The executing thread. */ -RTEMS_INLINE_ROUTINE Thread_Control *_CORE_RWLock_Acquire( +static inline Thread_Control *_CORE_RWLock_Acquire( CORE_RWLock_Control *the_rwlock, Thread_queue_Context *queue_context ) @@ -146,7 +165,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_CORE_RWLock_Acquire( * @param[in, out] the_rwlock The RWlock to release. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release( +static inline void _CORE_RWLock_Release( CORE_RWLock_Control *the_rwlock, Thread_queue_Context *queue_context ) diff --git a/cpukit/include/rtems/score/coresem.h b/cpukit/include/rtems/score/coresem.h index 1d2a1fd91a..a6b955f1aa 100644 --- a/cpukit/include/rtems/score/coresem.h +++ b/cpukit/include/rtems/score/coresem.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_CORESEM_H diff --git a/cpukit/include/rtems/score/coresemimpl.h b/cpukit/include/rtems/score/coresemimpl.h index 40b58cbda7..ca952a4570 100644 --- a/cpukit/include/rtems/score/coresemimpl.h +++ b/cpukit/include/rtems/score/coresemimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2006. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_CORESEMIMPL_H @@ -62,7 +81,7 @@ void _CORE_semaphore_Initialize( * @param[in, out] the_semaphore The semaphore to acquire. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_semaphore_Acquire_critical( +static inline void _CORE_semaphore_Acquire_critical( CORE_semaphore_Control *the_semaphore, Thread_queue_Context *queue_context ) @@ -78,7 +97,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Acquire_critical( * @param[in, out] the_semaphore The semaphore to release. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_semaphore_Release( +static inline void _CORE_semaphore_Release( CORE_semaphore_Control *the_semaphore, Thread_queue_Context *queue_context ) @@ -95,7 +114,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Release( * @param operations The thread queue operations. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy( +static inline void _CORE_semaphore_Destroy( CORE_semaphore_Control *the_semaphore, const Thread_queue_Operations *operations, Thread_queue_Context *queue_context @@ -126,7 +145,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy( * @retval STATUS_SUCCESSFUL The unit was successfully freed to the semaphore. * @retval STATUS_MAXIMUM_COUNT_EXCEEDED The maximum number of units was exceeded. */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Surrender( +static inline Status_Control _CORE_semaphore_Surrender( CORE_semaphore_Control *the_semaphore, const Thread_queue_Operations *operations, uint32_t maximum_count, @@ -168,7 +187,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Surrender( * * @return the current count of this semaphore. */ -RTEMS_INLINE_ROUTINE uint32_t _CORE_semaphore_Get_count( +static inline uint32_t _CORE_semaphore_Get_count( const CORE_semaphore_Control *the_semaphore ) { @@ -195,7 +214,7 @@ RTEMS_INLINE_ROUTINE uint32_t _CORE_semaphore_Get_count( * calling thread not willing to wait. * @retval STATUS_TIMEOUT A timeout occurred. */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize( +static inline Status_Control _CORE_semaphore_Seize( CORE_semaphore_Control *the_semaphore, const Thread_queue_Operations *operations, Thread_Control *executing, diff --git a/cpukit/include/rtems/score/cpustdatomic.h b/cpukit/include/rtems/score/cpustdatomic.h deleted file mode 100644 index 5e1319037e..0000000000 --- a/cpukit/include/rtems/score/cpustdatomic.h +++ /dev/null @@ -1,965 +0,0 @@ -/** - * @file - * - * @brief This header file provides the interfaces of the - * @ref RTEMSScoreAtomicCPU. - */ - -/* - * COPYRIGHT (c) 2013 Deng Hengyi. - * Copyright (c) 2015 embedded brains GmbH. - * - * 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_CPUSTDATOMIC_H -#define _RTEMS_SCORE_CPUSTDATOMIC_H - -#include <rtems/score/basedefs.h> - -/** - * @defgroup RTEMSScoreAtomicCPU C11/C++11 Atomic Operations - * - * @ingroup RTEMSScoreAtomic - * - * @brief This group contains the atomic operations implementation using - * functions provided by the C11/C++11. - * - * @{ - */ - -#ifdef RTEMS_SMP - #if defined(__cplusplus) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) - /* - * The GCC 4.9 ships its own <stdatomic.h> which is not C++ compatible. The - * suggested solution was to include <atomic> in case C++ is used. This works - * at least with GCC 4.9. See also: - * - * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 - * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940 - */ - #include <atomic> - #define _RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC - #else - #include <stdatomic.h> - #define _RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC - #endif -#else - #include <rtems/score/isrlevel.h> -#endif - -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - -typedef std::atomic_uint CPU_atomic_Uint; - -typedef std::atomic_ulong CPU_atomic_Ulong; - -typedef std::atomic_uintptr_t CPU_atomic_Uintptr; - -typedef std::atomic_flag CPU_atomic_Flag; - -typedef std::memory_order CPU_atomic_Order; - -#define CPU_ATOMIC_ORDER_RELAXED std::memory_order_relaxed - -#define CPU_ATOMIC_ORDER_ACQUIRE std::memory_order_acquire - -#define CPU_ATOMIC_ORDER_RELEASE std::memory_order_release - -#define CPU_ATOMIC_ORDER_ACQ_REL std::memory_order_acq_rel - -#define CPU_ATOMIC_ORDER_SEQ_CST std::memory_order_seq_cst - -#define CPU_ATOMIC_INITIALIZER_UINT( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT - -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - -typedef atomic_uint CPU_atomic_Uint; - -typedef atomic_ulong CPU_atomic_Ulong; - -typedef atomic_uintptr_t CPU_atomic_Uintptr; - -typedef atomic_flag CPU_atomic_Flag; - -typedef memory_order CPU_atomic_Order; - -#define CPU_ATOMIC_ORDER_RELAXED memory_order_relaxed - -#define CPU_ATOMIC_ORDER_ACQUIRE memory_order_acquire - -#define CPU_ATOMIC_ORDER_RELEASE memory_order_release - -#define CPU_ATOMIC_ORDER_ACQ_REL memory_order_acq_rel - -#define CPU_ATOMIC_ORDER_SEQ_CST memory_order_seq_cst - -#define CPU_ATOMIC_INITIALIZER_UINT( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT - -#else - -typedef unsigned int CPU_atomic_Uint; - -typedef unsigned long CPU_atomic_Ulong; - -typedef uintptr_t CPU_atomic_Uintptr; - -typedef bool CPU_atomic_Flag; - -typedef int CPU_atomic_Order; - -#define CPU_ATOMIC_ORDER_RELAXED 0 - -#define CPU_ATOMIC_ORDER_ACQUIRE 2 - -#define CPU_ATOMIC_ORDER_RELEASE 3 - -#define CPU_ATOMIC_ORDER_ACQ_REL 4 - -#define CPU_ATOMIC_ORDER_SEQ_CST 5 - -#define CPU_ATOMIC_INITIALIZER_UINT( value ) ( value ) - -#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ( value ) - -#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ( value ) - -#define CPU_ATOMIC_INITIALIZER_FLAG false - -#endif - -/** - * @brief Sets up a cpu fence. - * - * @param[out] order The order for the fence. - */ -static inline void _CPU_atomic_Fence( CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - std::atomic_thread_fence( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_thread_fence( order ); -#else - (void) order; - RTEMS_COMPILER_MEMORY_BARRIER(); -#endif -} - -/** - * @brief Initializes Uint. - * - * @param[out] obj The CPU atomic Uint to initialize. - * @param desired The desired value for @a obj. - */ -static inline void _CPU_atomic_Init_uint( CPU_atomic_Uint *obj, unsigned int desired ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_init( obj, desired ); -#else - *obj = desired; -#endif -} - -/** - * @brief Initializes Ulong. - * - * @param[out] obj The CPU atomic Ulong to initialize. - * @param desired The desired value for @a obj. - */ -static inline void _CPU_atomic_Init_ulong( CPU_atomic_Ulong *obj, unsigned long desired ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_init( obj, desired ); -#else - *obj = desired; -#endif -} - -/** - * @brief Initializes Uintptr. - * - * @param[out] obj The CPU atomic Uintptr to initialize. - * @param desired The desired value for @a obj. - */ -static inline void _CPU_atomic_Init_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_init( obj, desired ); -#else - *obj = desired; -#endif -} - -/** - * @brief Loads value of Uint considering the order. - * - * @param obj The CPU atomic Uint to get the value from. - * @param order The atomic order for getting the value. - * - * @return The value of @a obj considering the @a order. - */ -static inline unsigned int _CPU_atomic_Load_uint( const CPU_atomic_Uint *obj, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->load( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_load_explicit( obj, order ); -#else - unsigned int val; - - (void) order; - val = *obj; - RTEMS_COMPILER_MEMORY_BARRIER(); - - return val; -#endif -} - -/** - * @brief Loads value of Ulong considering the order. - * - * @param obj The CPU atomic Ulong to get the value from. - * @param order The atomic order for getting the value. - * - * @return The value of @a obj considering the @a order. - */ -static inline unsigned long _CPU_atomic_Load_ulong( const CPU_atomic_Ulong *obj, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->load( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_load_explicit( obj, order ); -#else - unsigned long val; - - (void) order; - val = *obj; - RTEMS_COMPILER_MEMORY_BARRIER(); - - return val; -#endif -} - -/** - * @brief Loads value of Uintptr considering the order. - * - * @param obj The CPU atomic Uintptr to get the value from. - * @param order The atomic order for getting the value. - * - * @return The value of @a obj considering the @a order. - */ -static inline uintptr_t _CPU_atomic_Load_uintptr( const CPU_atomic_Uintptr *obj, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->load( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_load_explicit( obj, order ); -#else - uintptr_t val; - - (void) order; - val = *obj; - RTEMS_COMPILER_MEMORY_BARRIER(); - - return val; -#endif -} - -/** - * @brief Stores a value to Uint considering the order. - * - * @param[out] obj The CPU atomic Uint to store a value in. - * @param desired The desired value for @a obj. - * @param order The atomic order for storing the value. - */ -static inline void _CPU_atomic_Store_uint( CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_store_explicit( obj, desired, order ); -#else - (void) order; - RTEMS_COMPILER_MEMORY_BARRIER(); - *obj = desired; -#endif -} - -/** - * @brief Stores a value to Ulong considering the order. - * - * @param[out] obj The CPU atomic Ulong to store a value in. - * @param desired The desired value for @a obj. - * @param order The atomic order for storing the value. - */ -static inline void _CPU_atomic_Store_ulong( CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_store_explicit( obj, desired, order ); -#else - (void) order; - RTEMS_COMPILER_MEMORY_BARRIER(); - *obj = desired; -#endif -} - -/** - * @brief Stores a value to Uintptr considering the order. - * - * @param[out] obj The CPU atomic Uintptr to store a value in. - * @param desired The desired value for @a obj. - * @param order The atomic order for storing the value. - */ -static inline void _CPU_atomic_Store_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_store_explicit( obj, desired, order ); -#else - (void) order; - RTEMS_COMPILER_MEMORY_BARRIER(); - *obj = desired; -#endif -} - -/** - * @brief Fetches current value of Uint and adds a value to the stored value. - * - * @param[in, out] obj The CPU atomic Uint to get the value from and add @a arg to. - * @param arg The value to add to @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the addition of @a arg. - */ -static inline unsigned int _CPU_atomic_Fetch_add_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_add( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_add_explicit( obj, arg, order ); -#else - unsigned int val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val + arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Ulong and adds a value to the stored value. - * - * @param[in, out] obj The CPU atomic Ulong to get the value from and add @a arg to. - * @param arg The value to add to @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the addition of @a arg. - */ -static inline unsigned long _CPU_atomic_Fetch_add_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_add( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_add_explicit( obj, arg, order ); -#else - unsigned long val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val + arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Uintptr and adds a value to the stored value. - * - * @param[in, out] obj The CPU atomic Uintptr to get the value from and add @a arg to. - * @param arg The value to add to @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the addition of @a arg. - */ -static inline uintptr_t _CPU_atomic_Fetch_add_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_add( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_add_explicit( obj, arg, order ); -#else - uintptr_t val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val + arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Uint and subtracts a value from the stored value. - * - * @param[in, out] obj The CPU atomic Uint to get the value from and subtract @a arg from. - * @param arg The value to subtract from @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the subtraction of @a arg. - */ -static inline unsigned int _CPU_atomic_Fetch_sub_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_sub( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_sub_explicit( obj, arg, order ); -#else - unsigned int val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val - arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Ulong and subtracts a value from the stored value. - * - * @param[in, out] obj The CPU atomic Ulong to get the value from and subtract @a arg from. - * @param arg The value to subtract from @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the subtraction of @a arg. - */ -static inline unsigned long _CPU_atomic_Fetch_sub_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_sub( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_sub_explicit( obj, arg, order ); -#else - unsigned long val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val - arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Uintptr and subtracts a value from the stored value. - * - * @param[in, out] obj The CPU atomic Uintptr to get the value from and subtract @a arg from. - * @param arg The value to subtract from @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the subtraction of @a arg. - */ -static inline uintptr_t _CPU_atomic_Fetch_sub_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_sub( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_sub_explicit( obj, arg, order ); -#else - uintptr_t val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val - arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Uint and ORs a value with the stored value. - * - * @param[in, out] obj The CPU atomic Uint to get the value from and OR @a arg to. - * @param arg The value to OR with @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the OR operation with @a arg. - */ -static inline unsigned int _CPU_atomic_Fetch_or_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_or( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_or_explicit( obj, arg, order ); -#else - unsigned int val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val | arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Ulong and ORs a value with the stored value. - * - * @param[in, out] obj The CPU atomic Ulong to get the value from and OR @a arg to. - * @param arg The value to OR with @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the OR operation with @a arg. - */ -static inline unsigned long _CPU_atomic_Fetch_or_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_or( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_or_explicit( obj, arg, order ); -#else - unsigned long val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val | arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Uintptr and ORs a value with the stored value. - * - * @param[in, out] obj The CPU atomic Uintptr to get the value from and OR @a arg to. - * @param arg The value to OR with @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the OR operation with @a arg. - */ -static inline uintptr_t _CPU_atomic_Fetch_or_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_or( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_or_explicit( obj, arg, order ); -#else - uintptr_t val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val | arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Uint and ANDs a value with the stored value. - * - * @param[in, out] obj The CPU atomic Uint to get the value from and AND @a arg to. - * @param arg The value to AND with @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the AND operation with @a arg. - */ -static inline unsigned int _CPU_atomic_Fetch_and_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_and( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_and_explicit( obj, arg, order ); -#else - unsigned int val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val & arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Ulong and ANDs a value with the stored value. - * - * @param[in, out] obj The CPU atomic Ulong to get the value from and AND @a arg to. - * @param arg The value to AND with @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the AND operation with @a arg. - */ -static inline unsigned long _CPU_atomic_Fetch_and_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_and( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_and_explicit( obj, arg, order ); -#else - unsigned long val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val & arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Uintptr and ANDs a value with the stored value. - * - * @param[in, out] obj The CPU atomic Uintptr to get the value from and AND @a arg to. - * @param arg The value to AND with @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the AND operation with @a arg. - */ -static inline uintptr_t _CPU_atomic_Fetch_and_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_and( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_and_explicit( obj, arg, order ); -#else - uintptr_t val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val & arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Uint and sets its value. - * - * @param[in, out] obj The CPU atomic Uint to get the value from and set the value to @a desired. - * @param arg The value to set for @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the exchange with @a desired. - */ -static inline unsigned int _CPU_atomic_Exchange_uint( CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->exchange( desired, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_exchange_explicit( obj, desired, order ); -#else - unsigned int val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = desired; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Ulong and sets its value. - * - * @param[in, out] obj The CPU atomic Ulong to get the value from and set the value to @a desired. - * @param arg The value to set for @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the exchange with @a desired. - */ -static inline unsigned long _CPU_atomic_Exchange_ulong( CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->exchange( desired, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_exchange_explicit( obj, desired, order ); -#else - unsigned long val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = desired; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Fetches current value of Uintptr and sets its value. - * - * @param[in, out] obj The CPU atomic Uintptr to get the value from and set the value to @a desired. - * @param arg The value to set for @a obj. - * @param order The atomic order for the operation. - * - * @return The value of @a obj prior to the exchange with @a desired. - */ -static inline uintptr_t _CPU_atomic_Exchange_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->exchange( desired, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_exchange_explicit( obj, desired, order ); -#else - uintptr_t val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = desired; - _ISR_Local_enable( level ); - - return val; -#endif -} - -/** - * @brief Checks if value of Uint is as expected. - * - * This method checks if the value of @a obj is equal to the value of @a expected. If - * this is the case, the value of @a obj is changed to @a desired. Otherwise, the value - * of @a obj is changed to @a expected. - * - * @param[in, out] obj The CPU atomic Uint to operate upon. - * @param[in, out] expected The expected value of @a obj. If @a obj has a different - * value, @a expected is changed to the actual value of @a obj. - * @param desired The new value of @a obj if the old value of @a obj was as expected. - * @param succ The order if it is successful. - * @param fail The order if it fails. - * - * @retval true The old value of @a obj was as expected. - * @retval false The old value of @a obj was not as expected. - */ -static inline bool _CPU_atomic_Compare_exchange_uint( CPU_atomic_Uint *obj, unsigned int *expected, unsigned int desired, CPU_atomic_Order succ, CPU_atomic_Order fail ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->compare_exchange_strong( *expected, desired, succ, fail ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); -#else - bool success; - ISR_Level level; - unsigned int actual; - - (void) succ; - (void) fail; - _ISR_Local_disable( level ); - actual = *obj; - success = ( actual == *expected ); - if ( success ) { - *obj = desired; - } else { - *expected = actual; - } - _ISR_Local_enable( level ); - - return success; -#endif -} - -/** - * @brief Checks if value of Ulong is as expected. - * - * This method checks if the value of @a obj is equal to the value of @a expected. If - * this is the case, the value of @a obj is changed to @a desired. Otherwise, the value - * of @a obj is changed to @a expected. - * - * @param[in, out] obj The CPU atomic Ulong to operate upon. - * @param[in, out] expected The expected value of @a obj. If @a obj has a different - * value, @a expected is changed to the actual value of @a obj. - * @param desired The new value of @a obj if the old value of @a obj was as expected. - * @param succ The order if it is successful. - * @param fail The order if it fails. - * - * @retval true The old value of @a obj was as expected. - * @retval false The old value of @a obj was not as expected. - */ -static inline bool _CPU_atomic_Compare_exchange_ulong( CPU_atomic_Ulong *obj, unsigned long *expected, unsigned long desired, CPU_atomic_Order succ, CPU_atomic_Order fail ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->compare_exchange_strong( *expected, desired, succ, fail ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); -#else - bool success; - ISR_Level level; - unsigned long actual; - - (void) succ; - (void) fail; - _ISR_Local_disable( level ); - actual = *obj; - success = ( actual == *expected ); - if ( success ) { - *obj = desired; - } else { - *expected = actual; - } - _ISR_Local_enable( level ); - - return success; -#endif -} - -/** - * @brief Checks if value of Uintptr is as expected. - * - * This method checks if the value of @a obj is equal to the value of @a expected. If - * this is the case, the value of @a obj is changed to @a desired. Otherwise, the value - * of @a obj is changed to @a expected. - * - * @param[in, out] obj The CPU atomic Uintptr to operate upon. - * @param[in, out] expected The expected value of @a obj. If @a obj has a different - * value, @a expected is changed to the actual value of @a obj. - * @param desired The new value of @a obj if the old value of @a obj was as expected. - * @param succ The order if it is successful. - * @param fail The order if it fails. - * - * @retval true The old value of @a obj was as expected. - * @retval false The old value of @a obj was not as expected. - */ -static inline bool _CPU_atomic_Compare_exchange_uintptr( CPU_atomic_Uintptr *obj, uintptr_t *expected, uintptr_t desired, CPU_atomic_Order succ, CPU_atomic_Order fail ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->compare_exchange_strong( *expected, desired, succ, fail ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); -#else - bool success; - ISR_Level level; - uintptr_t actual; - - (void) succ; - (void) fail; - _ISR_Local_disable( level ); - actual = *obj; - success = ( actual == *expected ); - if ( success ) { - *obj = desired; - } else { - *expected = actual; - } - _ISR_Local_enable( level ); - - return success; -#endif -} - -/** - * @brief Clears the atomic flag. - * - * @param[out] obj The atomic flag to be cleared. - * @param order The atomic order for the operation. - */ -static inline void _CPU_atomic_Flag_clear( CPU_atomic_Flag *obj, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->clear( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_flag_clear_explicit( obj, order ); -#else - (void) order; - *obj = false; -#endif -} - -/** - * @brief Returns current flag state and sets it. - * - * @param[in, out] obj The atomic flag to be set. - * @param order The atomic order for the operation. - * - * @retval true @a obj was set prior to this operation. - * @retval false @a obj was not set prior to this operation. - */ -static inline bool _CPU_atomic_Flag_test_and_set( CPU_atomic_Flag *obj, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->test_and_set( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_flag_test_and_set_explicit( obj, order ); -#else - bool flag; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - flag = *obj; - *obj = true; - _ISR_Local_enable( level ); - - return flag; -#endif -} - -/** @} */ - -#endif /* _RTEMS_SCORE_CPUSTDATOMIC_H */ diff --git a/cpukit/include/rtems/score/exception.h b/cpukit/include/rtems/score/exception.h new file mode 100644 index 0000000000..979a5aae7e --- /dev/null +++ b/cpukit/include/rtems/score/exception.h @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreException + * + * @brief This header file provides the interfaces for mapping + * exceptions to signsls. + */ + +/* + * Copyright (C) 2021 On-Line Applications Research Corporation (OAR) + * + * 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. + */ + +#ifndef _RTEMS_EXCEPTION_H +#define _RTEMS_EXCEPTION_H + +#include <rtems/fatal.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup RTEMSScoreException Exception Mapping Interfaces + * + * @ingroup RTEMSScore + * + * @brief This group contains the interfaces for mapping machine exceptions to + * signals using the fatal error handler. + */ + +/** + * @brief Handle an exception frame for the purpose of mapping signals + * + * See CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING documentation in the + * "RTEMS Classic API Guide". + */ +void _Exception_Raise_signal( + Internal_errors_Source source, + bool always_set_to_false, + Internal_errors_t code +); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_EXCEPTION_H */ diff --git a/cpukit/include/rtems/score/freechain.h b/cpukit/include/rtems/score/freechain.h index 2c0cc1aa06..27ea7ac4a7 100644 --- a/cpukit/include/rtems/score/freechain.h +++ b/cpukit/include/rtems/score/freechain.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* * Copyright (c) 2013 Gedare Bloom. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_FREECHAIN_H diff --git a/cpukit/include/rtems/score/freechainimpl.h b/cpukit/include/rtems/score/freechainimpl.h index 6c3f1bb6d7..3f02472961 100644 --- a/cpukit/include/rtems/score/freechainimpl.h +++ b/cpukit/include/rtems/score/freechainimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* * Copyright (c) 2013 Gedare Bloom. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_FREECHAINIMPL_H @@ -49,7 +68,7 @@ typedef void *( *Freechain_Allocator )( size_t size ); * @param number_nodes The initial number of nodes. * @param node_size The node size. */ -RTEMS_INLINE_ROUTINE void _Freechain_Initialize( +static inline void _Freechain_Initialize( Freechain_Control *freechain, void *initial_nodes, size_t number_nodes, @@ -69,7 +88,7 @@ RTEMS_INLINE_ROUTINE void _Freechain_Initialize( * * @param freechain The freechain control. */ -RTEMS_INLINE_ROUTINE bool _Freechain_Is_empty( +static inline bool _Freechain_Is_empty( const Freechain_Control *freechain ) { @@ -83,7 +102,7 @@ RTEMS_INLINE_ROUTINE bool _Freechain_Is_empty( * * @param freechain The freechain control. */ -RTEMS_INLINE_ROUTINE void *_Freechain_Pop( Freechain_Control *freechain ) +static inline void *_Freechain_Pop( Freechain_Control *freechain ) { return _Chain_Get_first_unprotected( &freechain->Free ); } @@ -94,7 +113,7 @@ RTEMS_INLINE_ROUTINE void *_Freechain_Pop( Freechain_Control *freechain ) * @param freechain The freechain control. * @param node The node to push back. The node shall not be @c NULL. */ -void RTEMS_INLINE_ROUTINE _Freechain_Push( +void static inline _Freechain_Push( Freechain_Control *freechain, void *node ) diff --git a/cpukit/include/rtems/score/hash.h b/cpukit/include/rtems/score/hash.h index c6f9ebf463..666407a791 100644 --- a/cpukit/include/rtems/score/hash.h +++ b/cpukit/include/rtems/score/hash.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2021 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -84,7 +84,7 @@ typedef struct { * * @return Returns the hash value as a NUL-terminated string. */ -RTEMS_INLINE_ROUTINE const char *_Hash_Get_string( const Hash_Control *hash ) +static inline const char *_Hash_Get_string( const Hash_Control *hash ) { return &hash->chars[ 0 ]; } @@ -114,7 +114,7 @@ typedef struct { * * @param[out] context is the hash context to initialize. */ -RTEMS_INLINE_ROUTINE void _Hash_Initialize( Hash_Context *context ) +static inline void _Hash_Initialize( Hash_Context *context ) { SHA256_Init( &context->Context ); } @@ -128,7 +128,7 @@ RTEMS_INLINE_ROUTINE void _Hash_Initialize( Hash_Context *context ) * * @param size is the size of the data in bytes. */ -RTEMS_INLINE_ROUTINE void _Hash_Add_data( +static inline void _Hash_Add_data( Hash_Context *context, const void *begin, size_t size @@ -144,7 +144,7 @@ RTEMS_INLINE_ROUTINE void _Hash_Add_data( * * @param str is the string to add. */ -RTEMS_INLINE_ROUTINE void _Hash_Add_string( +static inline void _Hash_Add_string( Hash_Context *context, const char *str ) diff --git a/cpukit/include/rtems/score/heap.h b/cpukit/include/rtems/score/heap.h index 62a81cbad9..8777e8b548 100644 --- a/cpukit/include/rtems/score/heap.h +++ b/cpukit/include/rtems/score/heap.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2006. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_HEAP_H @@ -412,7 +431,7 @@ uintptr_t _Heap_No_extend( * * @return The @a value aligned to the given @a alignment, rounded up. */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_up( +static inline uintptr_t _Heap_Align_up( uintptr_t value, uintptr_t alignment ) @@ -433,7 +452,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_up( * * @return The minimal Heap Block size for the given @a page_size. */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Min_block_size( uintptr_t page_size ) +static inline uintptr_t _Heap_Min_block_size( uintptr_t page_size ) { return _Heap_Align_up( sizeof( Heap_Block ), page_size ); } @@ -445,7 +464,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Min_block_size( uintptr_t page_size ) * * @return The worst case overhead to manage a memory area. */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Area_overhead( +static inline uintptr_t _Heap_Area_overhead( uintptr_t page_size ) { @@ -474,7 +493,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Area_overhead( * * @return The size with administration and alignment overhead for one allocation. */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Size_with_overhead( +static inline uintptr_t _Heap_Size_with_overhead( uintptr_t page_size, uintptr_t size, uintptr_t alignment diff --git a/cpukit/include/rtems/score/heapimpl.h b/cpukit/include/rtems/score/heapimpl.h index 4403f186c7..91326c6577 100644 --- a/cpukit/include/rtems/score/heapimpl.h +++ b/cpukit/include/rtems/score/heapimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_HEAPIMPL_H @@ -137,7 +156,7 @@ void *_Heap_Allocate_aligned_with_boundary( * @retval pointer The starting address of the allocated memory area. * @retval NULL No memory is available of the parameters are inconsistent. */ -RTEMS_INLINE_ROUTINE void *_Heap_Allocate_aligned( +static inline void *_Heap_Allocate_aligned( Heap_Control *heap, uintptr_t size, uintptr_t alignment @@ -158,7 +177,7 @@ RTEMS_INLINE_ROUTINE void *_Heap_Allocate_aligned( * @retval pointer The starting address of the allocated memory area. * @retval NULL No memory is available of the parameters are inconsistent. */ -RTEMS_INLINE_ROUTINE void *_Heap_Allocate( Heap_Control *heap, uintptr_t size ) +static inline void *_Heap_Allocate( Heap_Control *heap, uintptr_t size ) { return _Heap_Allocate_aligned_with_boundary( heap, size, 0, 0 ); } @@ -408,15 +427,7 @@ Heap_Block *_Heap_Block_allocate( (*heap->Protection.block_error)( heap, block, reason ); } - static inline void _Heap_Protection_free_all_delayed_blocks( Heap_Control *heap ) - { - uintptr_t large = 0 - - (uintptr_t) HEAP_BLOCK_HEADER_SIZE - - (uintptr_t) HEAP_ALLOC_BONUS - - (uintptr_t) 1; - void *p = _Heap_Allocate( heap, large ); - _Heap_Free( heap, p ); - } + void _Heap_Protection_free_all_delayed_blocks( Heap_Control *heap ); #endif /** @@ -429,7 +440,7 @@ Heap_Block *_Heap_Block_allocate( * @param[in, out] heap The heap control. * @param fraction The fraction is one divided by this fraction value. */ -RTEMS_INLINE_ROUTINE void _Heap_Protection_set_delayed_free_fraction( +static inline void _Heap_Protection_set_delayed_free_fraction( Heap_Control *heap, uintptr_t fraction ) @@ -449,7 +460,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Protection_set_delayed_free_fraction( * * @return The head of the free list. */ -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_head( Heap_Control *heap ) +static inline Heap_Block *_Heap_Free_list_head( Heap_Control *heap ) { return &heap->free_list; } @@ -461,7 +472,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_head( Heap_Control *heap ) * * @return The tail of the free list. */ -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_tail( Heap_Control *heap ) +static inline Heap_Block *_Heap_Free_list_tail( Heap_Control *heap ) { return &heap->free_list; } @@ -473,7 +484,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_tail( Heap_Control *heap ) * * @return The first block of the free list. */ -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_first( Heap_Control *heap ) +static inline Heap_Block *_Heap_Free_list_first( Heap_Control *heap ) { return _Heap_Free_list_head(heap)->next; } @@ -485,7 +496,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_first( Heap_Control *heap ) * * @return The last block of the free list. */ -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_last( Heap_Control *heap ) +static inline Heap_Block *_Heap_Free_list_last( Heap_Control *heap ) { return _Heap_Free_list_tail(heap)->prev; } @@ -495,7 +506,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_last( Heap_Control *heap ) * * @param block The block to be removed. */ -RTEMS_INLINE_ROUTINE void _Heap_Free_list_remove( Heap_Block *block ) +static inline void _Heap_Free_list_remove( Heap_Block *block ) { Heap_Block *next = block->next; Heap_Block *prev = block->prev; @@ -510,7 +521,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Free_list_remove( Heap_Block *block ) * @param old_block The block in the free list to replace. * @param new_block The block that should replace @a old_block. */ -RTEMS_INLINE_ROUTINE void _Heap_Free_list_replace( +static inline void _Heap_Free_list_replace( Heap_Block *old_block, Heap_Block *new_block ) @@ -531,7 +542,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Free_list_replace( * @param block_before The block that is already in the free list. * @param new_block The block to be inserted after @a block_before. */ -RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_after( +static inline void _Heap_Free_list_insert_after( Heap_Block *block_before, Heap_Block *new_block ) @@ -550,7 +561,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_after( * @param block_before The block that is already in the free list. * @param new_block The block to be inserted before @a block_before. */ -RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_before( +static inline void _Heap_Free_list_insert_before( Heap_Block *block_next, Heap_Block *new_block ) @@ -572,7 +583,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_before( * @retval true The value is aligned to the given alignment. * @retval false The value is not aligned to the given alignment. */ -RTEMS_INLINE_ROUTINE bool _Heap_Is_aligned( +static inline bool _Heap_Is_aligned( uintptr_t value, uintptr_t alignment ) @@ -588,7 +599,7 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_aligned( * * @return The aligned value, truncated. */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_down( +static inline uintptr_t _Heap_Align_down( uintptr_t value, uintptr_t alignment ) @@ -604,7 +615,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_down( * * @return The address of the block which is @a offset away from @a block. */ -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_at( +static inline Heap_Block *_Heap_Block_at( const Heap_Block *block, uintptr_t offset ) @@ -619,7 +630,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_at( * * @return The address of the previous block. */ -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Prev_block( +static inline Heap_Block *_Heap_Prev_block( const Heap_Block *block ) { @@ -633,7 +644,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Prev_block( * * @return The first address after the heap header. */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Alloc_area_of_block( +static inline uintptr_t _Heap_Alloc_area_of_block( const Heap_Block *block ) { @@ -648,7 +659,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Alloc_area_of_block( * * @return The Starting address of the corresponding block of the allocatable area. */ -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_of_alloc_area( +static inline Heap_Block *_Heap_Block_of_alloc_area( uintptr_t alloc_begin, uintptr_t page_size ) @@ -664,7 +675,7 @@ RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_of_alloc_area( * * @return The block size. */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Block_size( const Heap_Block *block ) +static inline uintptr_t _Heap_Block_size( const Heap_Block *block ) { return block->size_and_flag & ~HEAP_PREV_BLOCK_USED; } @@ -675,7 +686,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Block_size( const Heap_Block *block ) * @param[in, out] block The block of which the size shall be set. * @param size The new size of the block. */ -RTEMS_INLINE_ROUTINE void _Heap_Block_set_size( +static inline void _Heap_Block_set_size( Heap_Block *block, uintptr_t size ) @@ -694,7 +705,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Block_set_size( * @retval true The previous block is used. * @retval false The previous block is not used. */ -RTEMS_INLINE_ROUTINE bool _Heap_Is_prev_used( const Heap_Block *block ) +static inline bool _Heap_Is_prev_used( const Heap_Block *block ) { return block->size_and_flag & HEAP_PREV_BLOCK_USED; } @@ -707,7 +718,7 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_prev_used( const Heap_Block *block ) * @retval true The block is used. * @retval false The block is not used. */ -RTEMS_INLINE_ROUTINE bool _Heap_Is_used( +static inline bool _Heap_Is_used( const Heap_Block *block ) { @@ -725,7 +736,7 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_used( * @retval true The block is free. * @retval false The block is not free. */ -RTEMS_INLINE_ROUTINE bool _Heap_Is_free( +static inline bool _Heap_Is_free( const Heap_Block *block ) { @@ -741,7 +752,7 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_free( * @retval true The block is part of the heap. * @retval false The block is not part of the heap. */ -RTEMS_INLINE_ROUTINE bool _Heap_Is_block_in_heap( +static inline bool _Heap_Is_block_in_heap( const Heap_Control *heap, const Heap_Block *block ) @@ -763,7 +774,7 @@ RTEMS_INLINE_ROUTINE bool _Heap_Is_block_in_heap( * * @param[in, out] heap The heap to set the last block size of. */ -RTEMS_INLINE_ROUTINE void _Heap_Set_last_block_size( Heap_Control *heap ) +static inline void _Heap_Set_last_block_size( Heap_Control *heap ) { _Heap_Block_set_size( heap->last_block, @@ -780,7 +791,7 @@ RTEMS_INLINE_ROUTINE void _Heap_Set_last_block_size( Heap_Control *heap ) * * @return The size of the allocatable area in @a heap in bytes. */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Get_size( const Heap_Control *heap ) +static inline uintptr_t _Heap_Get_size( const Heap_Control *heap ) { return heap->stats.size; } @@ -794,7 +805,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Get_size( const Heap_Control *heap ) * @retval a If a > b. * @retval b If b >= a */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Max( uintptr_t a, uintptr_t b ) +static inline uintptr_t _Heap_Max( uintptr_t a, uintptr_t b ) { return a > b ? a : b; } @@ -808,7 +819,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Heap_Max( uintptr_t a, uintptr_t b ) * @retval a If a < b. * @retval b If b <= a */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Min( uintptr_t a, uintptr_t b ) +static inline uintptr_t _Heap_Min( uintptr_t a, uintptr_t b ) { return a < b ? a : b; } diff --git a/cpukit/include/rtems/score/heapinfo.h b/cpukit/include/rtems/score/heapinfo.h index 9bba83cd90..282d3257de 100644 --- a/cpukit/include/rtems/score/heapinfo.h +++ b/cpukit/include/rtems/score/heapinfo.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2006. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_HEAPINFO_H diff --git a/cpukit/include/rtems/score/interr.h b/cpukit/include/rtems/score/interr.h index 65cac29500..003e80e0bd 100644 --- a/cpukit/include/rtems/score/interr.h +++ b/cpukit/include/rtems/score/interr.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_INTERR_H @@ -156,7 +175,7 @@ typedef enum { * This enum value ensures that the enum type needs at least 32-bits for * architectures with short enums. */ - RTEMS_FATAL_SOURCE_LAST = 0xffffffff + RTEMS_FATAL_SOURCE_LAST = 0x7fffffff } Internal_errors_Source; /** @@ -188,8 +207,8 @@ typedef enum { /* INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_FROM_BAD_STATE = 18, */ /* INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0 = 19, */ /* INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP = 20, */ - INTERNAL_ERROR_GXX_KEY_ADD_FAILED = 21, - INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED = 22, + /* INTERNAL_ERROR_GXX_KEY_ADD_FAILED = 21, */ + /* INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED = 22, */ INTERNAL_ERROR_NO_MEMORY_FOR_HEAP = 23, INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR = 24, INTERNAL_ERROR_RESOURCE_IN_USE = 25, @@ -210,6 +229,9 @@ typedef enum { INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA = 40, INTERNAL_ERROR_TOO_LARGE_TLS_SIZE = 41, INTERNAL_ERROR_RTEMS_INIT_TASK_CONSTRUCT_FAILED = 42, + INTERNAL_ERROR_IDLE_THREAD_CREATE_FAILED = 43, + INTERNAL_ERROR_NO_MEMORY_FOR_IDLE_TASK_STORAGE = 44, + INTERNAL_ERROR_IDLE_THREAD_STACK_TOO_SMALL = 45 } Internal_errors_Core_list; typedef CPU_Uint32ptr Internal_errors_t; diff --git a/cpukit/include/rtems/score/io.h b/cpukit/include/rtems/score/io.h deleted file mode 100644 index f7b576fddd..0000000000 --- a/cpukit/include/rtems/score/io.h +++ /dev/null @@ -1,129 +0,0 @@ -/** - * @file - * - * @ingroup RTEMSScoreIO - * - * @brief This header file provides the interfaces of the - * @ref RTEMSScoreIO. - */ - -/* - * Copyright (c) 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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_IO_H -#define _RTEMS_SCORE_IO_H - -#include <rtems/score/basedefs.h> - -#include <stdarg.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup RTEMSScoreIO IO Handler - * - * @ingroup RTEMSScore - * - * @brief This group contains the IO Handler implementation. - * - * @{ - */ - -typedef void ( *IO_Put_char )( int c, void *arg ); - -int _IO_Printf( - IO_Put_char put_char, - void *arg, - char const *fmt, - ... -) RTEMS_PRINTFLIKE( 3, 4 ); - -int _IO_Vprintf( - IO_Put_char put_char, - void *arg, - char const *fmt, - va_list ap -); - -/** - * @brief Outputs the source buffer in base64 encoding. - * - * After word length of output characters produced by the encoding a word break - * is produced. - * - * @param put_char is the put character function used to output the encoded - * source buffer. - * - * @param arg is the argument passed to the put character function. - * - * @param src is the pointer to the source buffer begin. - * - * @param srclen is the length of the source buffer in bytes. - * - * @param wordbreak is the word break string. - * - * @param wordlen is the word length in bytes. If the word length is less than - * four, then a word length of four will be used. - * - * @return Returns the count of output characters. - */ -int _IO_Base64( - IO_Put_char put_char, - void *arg, - const void *src, - size_t len, - const char *wordbreak, - int wordlen -); - -/** - * @brief Outputs the source buffer in base64url encoding. - * - * After word length of output characters produced by the encoding a word break - * is produced. - * - * @param put_char is the put character function used to output the encoded - * source buffer. - * - * @param arg is the argument passed to the put character function. - * - * @param src is the pointer to the source buffer begin. - * - * @param srclen is the length of the source buffer in bytes. - * - * @param wordbreak is the word break string. - * - * @param wordlen is the word length in bytes. If the word length is less than - * four, then a word length of four will be used. - * - * @return Returns the count of output characters. - */ -int _IO_Base64url( - IO_Put_char put_char, - void *arg, - const void *src, - size_t len, - const char *wordbreak, - int wordlen -); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_IO_H */ diff --git a/cpukit/include/rtems/score/isr.h b/cpukit/include/rtems/score/isr.h index 47c24f3a72..96ad816245 100644 --- a/cpukit/include/rtems/score/isr.h +++ b/cpukit/include/rtems/score/isr.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2012. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_ISR_H @@ -79,7 +98,11 @@ extern ISR_Handler_entry _ISR_Vector_table[ CPU_INTERRUPT_NUMBER_OF_VECTORS ]; #endif /** - * @brief Global symbol with a value equal to the configure interrupt stack size. + * @brief Provides the configured interrupt stack size through an address. + * + * The address of this global symbol is equal to the configured interrupt stack + * size. The address of this symbol has an arbitrary value an may not be + * representable in the code model used by the compiler. * * This global symbol is defined by the application configuration option * CONFIGURE_INIT_TASK_STACK_SIZE via <rtems/confdefs.h>. @@ -87,6 +110,14 @@ extern ISR_Handler_entry _ISR_Vector_table[ CPU_INTERRUPT_NUMBER_OF_VECTORS ]; RTEMS_DECLARE_GLOBAL_SYMBOL( _ISR_Stack_size ); /** + * @brief Provides the configured interrupt stack size through an object. + * + * This object is provided to avoid issues with the _ISR_Stack_size symbol + * address and the code model used by the compiler. + */ +extern const char * const volatile _ISR_Stack_size_object; + +/** * @brief The interrupt stack area begin. * * The interrupt stack area is defined by the application configuration via diff --git a/cpukit/include/rtems/score/isrlevel.h b/cpukit/include/rtems/score/isrlevel.h index d578a32c48..216e5d8650 100644 --- a/cpukit/include/rtems/score/isrlevel.h +++ b/cpukit/include/rtems/score/isrlevel.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_ISR_LEVEL_h diff --git a/cpukit/include/rtems/score/isrlock.h b/cpukit/include/rtems/score/isrlock.h index d787aba9ae..7586624f9d 100644 --- a/cpukit/include/rtems/score/isrlock.h +++ b/cpukit/include/rtems/score/isrlock.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2013, 2019 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. + * Copyright (C) 2013, 2019 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_SCORE_ISR_LOCK_H @@ -159,7 +172,7 @@ typedef struct { * @param[out] context The ISR lock context. * @param level The ISR level. */ -RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level( +static inline void _ISR_lock_Context_set_level( ISR_lock_Context *context, ISR_Level level ) diff --git a/cpukit/include/rtems/score/memory.h b/cpukit/include/rtems/score/memory.h index 5761402711..a593d98d76 100644 --- a/cpukit/include/rtems/score/memory.h +++ b/cpukit/include/rtems/score/memory.h @@ -10,7 +10,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 2019, 2022 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -115,7 +115,7 @@ typedef struct { * * @return The memory area count. */ -RTEMS_INLINE_ROUTINE size_t _Memory_Get_count( +static inline size_t _Memory_Get_count( const Memory_Information *information ) { @@ -130,7 +130,7 @@ RTEMS_INLINE_ROUTINE size_t _Memory_Get_count( * * @return The memory area of the specified index. */ -RTEMS_INLINE_ROUTINE Memory_Area *_Memory_Get_area( +static inline Memory_Area *_Memory_Get_area( const Memory_Information *information, size_t index ) @@ -146,7 +146,7 @@ RTEMS_INLINE_ROUTINE Memory_Area *_Memory_Get_area( * @param begin The begin of the memory area. * @param end The end of the memory area. */ -RTEMS_INLINE_ROUTINE void _Memory_Initialize( +static inline void _Memory_Initialize( Memory_Area *area, void *begin, void *end @@ -164,7 +164,7 @@ RTEMS_INLINE_ROUTINE void _Memory_Initialize( * @param begin The begin of the memory area. * @param size The size of the memory area in bytes. */ -RTEMS_INLINE_ROUTINE void _Memory_Initialize_by_size( +static inline void _Memory_Initialize_by_size( Memory_Area *area, void *begin, uintptr_t size @@ -182,7 +182,7 @@ RTEMS_INLINE_ROUTINE void _Memory_Initialize_by_size( * * @return The memory area begin. */ -RTEMS_INLINE_ROUTINE const void *_Memory_Get_begin( const Memory_Area *area ) +static inline const void *_Memory_Get_begin( const Memory_Area *area ) { return area->begin; } @@ -193,7 +193,7 @@ RTEMS_INLINE_ROUTINE const void *_Memory_Get_begin( const Memory_Area *area ) * @param area The memory area. * @param begin The memory area begin. */ -RTEMS_INLINE_ROUTINE void _Memory_Set_begin( +static inline void _Memory_Set_begin( Memory_Area *area, const void *begin ) @@ -208,7 +208,7 @@ RTEMS_INLINE_ROUTINE void _Memory_Set_begin( * * @return The memory area end. */ -RTEMS_INLINE_ROUTINE const void *_Memory_Get_end( const Memory_Area *area ) +static inline const void *_Memory_Get_end( const Memory_Area *area ) { return area->end; } @@ -219,7 +219,7 @@ RTEMS_INLINE_ROUTINE const void *_Memory_Get_end( const Memory_Area *area ) * @param area The memory area. * @param end The memory area end. */ -RTEMS_INLINE_ROUTINE void _Memory_Set_end( +static inline void _Memory_Set_end( Memory_Area *area, const void *end ) @@ -234,7 +234,7 @@ RTEMS_INLINE_ROUTINE void _Memory_Set_end( * * @return The memory area size in bytes. */ -RTEMS_INLINE_ROUTINE uintptr_t _Memory_Get_size( const Memory_Area *area ) +static inline uintptr_t _Memory_Get_size( const Memory_Area *area ) { return (uintptr_t) area->end - (uintptr_t) area->begin; } @@ -246,7 +246,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Memory_Get_size( const Memory_Area *area ) * * @return The free memory area begin the memory area. */ -RTEMS_INLINE_ROUTINE void *_Memory_Get_free_begin( const Memory_Area *area ) +static inline void *_Memory_Get_free_begin( const Memory_Area *area ) { return area->free; } @@ -257,7 +257,7 @@ RTEMS_INLINE_ROUTINE void *_Memory_Get_free_begin( const Memory_Area *area ) * @param area The memory area. * @param begin The free memory area begin the memory area. */ -RTEMS_INLINE_ROUTINE void _Memory_Set_free_begin( +static inline void _Memory_Set_free_begin( Memory_Area *area, void *begin ) @@ -272,7 +272,7 @@ RTEMS_INLINE_ROUTINE void _Memory_Set_free_begin( * * @return The free memory area size in bytes of the memory area. */ -RTEMS_INLINE_ROUTINE uintptr_t _Memory_Get_free_size( const Memory_Area *area ) +static inline uintptr_t _Memory_Get_free_size( const Memory_Area *area ) { return (uintptr_t) area->end - (uintptr_t) area->free; } @@ -285,7 +285,7 @@ RTEMS_INLINE_ROUTINE uintptr_t _Memory_Get_free_size( const Memory_Area *area ) * @param consume The bytes to consume from the free memory area of the memory * area. */ -RTEMS_INLINE_ROUTINE void _Memory_Consume( +static inline void _Memory_Consume( Memory_Area *area, uintptr_t consume ) @@ -352,6 +352,18 @@ void _Memory_Zero_free_areas( void ); */ void _Memory_Dirty_free_areas( void ); +/** + * @brief This symbol marks the begin of the non-initialized section used by + * RTEMS. + */ +extern char _Memory_Noinit_begin[]; + +/** + * @brief This symbol marks the end of the non-initialized section used by + * RTEMS. + */ +extern char _Memory_Noinit_end[]; + /** @} */ #ifdef __cplusplus diff --git a/cpukit/include/rtems/score/mpci.h b/cpukit/include/rtems/score/mpci.h index 5fda858b1c..796c881929 100644 --- a/cpukit/include/rtems/score/mpci.h +++ b/cpukit/include/rtems/score/mpci.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,18 +14,32 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_MPCI_H #define _RTEMS_SCORE_MPCI_H #include <rtems/score/mppkt.h> -#include <rtems/score/thread.h> -#include <rtems/score/threadq.h> -#include <rtems/score/watchdog.h> #ifdef __cplusplus extern "C" { diff --git a/cpukit/include/rtems/score/mpciimpl.h b/cpukit/include/rtems/score/mpciimpl.h index 4cede136bd..d0c2d0558a 100644 --- a/cpukit/include/rtems/score/mpciimpl.h +++ b/cpukit/include/rtems/score/mpciimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,15 +13,35 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_MPCIIMPL_H #define _RTEMS_SCORE_MPCIIMPL_H #include <rtems/score/mpci.h> +#include <rtems/score/thread.h> +#include <rtems/score/threadq.h> +#include <rtems/score/watchdog.h> #include <rtems/score/status.h> #ifdef __cplusplus @@ -318,7 +340,7 @@ MPCI_Internal_packet *_MPCI_Internal_packets_Get_packet ( void ); * because this enum starts at lower bound of zero. */ -RTEMS_INLINE_ROUTINE bool _Mp_packet_Is_valid_packet_class ( +static inline bool _Mp_packet_Is_valid_packet_class ( MP_packet_Classes the_packet_class ) { diff --git a/cpukit/include/rtems/score/mppkt.h b/cpukit/include/rtems/score/mppkt.h index 101f1ed31d..5c1916e021 100644 --- a/cpukit/include/rtems/score/mppkt.h +++ b/cpukit/include/rtems/score/mppkt.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_MPPKT_H diff --git a/cpukit/include/rtems/score/mrsp.h b/cpukit/include/rtems/score/mrsp.h index 24464520bc..cd9b0a046d 100644 --- a/cpukit/include/rtems/score/mrsp.h +++ b/cpukit/include/rtems/score/mrsp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,17 +11,28 @@ */ /* - * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2014, 2016 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_MRSP_H diff --git a/cpukit/include/rtems/score/mrspimpl.h b/cpukit/include/rtems/score/mrspimpl.h index 3e64ad94e6..fd783bf2a0 100644 --- a/cpukit/include/rtems/score/mrspimpl.h +++ b/cpukit/include/rtems/score/mrspimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2014, 2019 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. + * Copyright (C) 2014, 2019 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_SCORE_MRSPIMPL_H @@ -51,7 +64,7 @@ extern "C" { * @param mrsp The MrsP control for the operation. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _MRSP_Acquire_critical( +static inline void _MRSP_Acquire_critical( MRSP_Control *mrsp, Thread_queue_Context *queue_context ) @@ -65,7 +78,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Acquire_critical( * @param mrsp The MrsP control for the operation. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _MRSP_Release( +static inline void _MRSP_Release( MRSP_Control *mrsp, Thread_queue_Context *queue_context ) @@ -80,7 +93,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Release( * * @return The owner of the Mrsp control. */ -RTEMS_INLINE_ROUTINE Thread_Control *_MRSP_Get_owner( +static inline Thread_Control *_MRSP_Get_owner( const MRSP_Control *mrsp ) { @@ -93,7 +106,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_MRSP_Get_owner( * @param[out] mrsp The MrsP control to set the owner of. * @param owner The desired new owner for @a mrsp. */ -RTEMS_INLINE_ROUTINE void _MRSP_Set_owner( +static inline void _MRSP_Set_owner( MRSP_Control *mrsp, Thread_Control *owner ) @@ -109,7 +122,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Set_owner( * * @return The priority of the MrsP control. */ -RTEMS_INLINE_ROUTINE Priority_Control _MRSP_Get_priority( +static inline Priority_Control _MRSP_Get_priority( const MRSP_Control *mrsp, const Scheduler_Control *scheduler ) @@ -117,6 +130,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _MRSP_Get_priority( uint32_t scheduler_index; scheduler_index = _Scheduler_Get_index( scheduler ); + _Assert( scheduler_index < _Scheduler_Count ); return mrsp->ceiling_priorities[ scheduler_index ]; } @@ -127,7 +141,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _MRSP_Get_priority( * @param schedulger The corresponding scheduler. * @param new_priority The new priority for the MrsP control */ -RTEMS_INLINE_ROUTINE void _MRSP_Set_priority( +static inline void _MRSP_Set_priority( MRSP_Control *mrsp, const Scheduler_Control *scheduler, Priority_Control new_priority @@ -136,6 +150,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Set_priority( uint32_t scheduler_index; scheduler_index = _Scheduler_Get_index( scheduler ); + _Assert( scheduler_index < _Scheduler_Count ); mrsp->ceiling_priorities[ scheduler_index ] = new_priority; } @@ -152,7 +167,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Set_priority( * @retval STATUS_MUTEX_CEILING_VIOLATED The wait priority of the thread * exceeds the ceiling priority. */ -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Raise_priority( +static inline Status_Control _MRSP_Raise_priority( MRSP_Control *mrsp, Thread_Control *thread, Priority_Node *priority_node, @@ -194,7 +209,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Raise_priority( * @param priority_node The priority node to remove from the thread * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _MRSP_Remove_priority( +static inline void _MRSP_Remove_priority( Thread_Control *thread, Priority_Node *priority_node, Thread_queue_Context *queue_context @@ -216,7 +231,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Remove_priority( * @param[out] thread The thread to replace the priorities. * @param ceiling_priority The node to be replaced. */ -RTEMS_INLINE_ROUTINE void _MRSP_Replace_priority( +static inline void _MRSP_Replace_priority( MRSP_Control *mrsp, Thread_Control *thread, Priority_Node *ceiling_priority @@ -244,7 +259,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Replace_priority( * @retval STATUS_MUTEX_CEILING_VIOLATED The wait priority of the executing * thread exceeds the ceiling priority. */ -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Claim_ownership( +static inline Status_Control _MRSP_Claim_ownership( MRSP_Control *mrsp, Thread_Control *executing, Thread_queue_Context *queue_context @@ -268,7 +283,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Claim_ownership( _MRSP_Set_owner( mrsp, executing ); cpu_self = _Thread_queue_Dispatch_disable( queue_context ); _MRSP_Release( mrsp, queue_context ); - _Thread_Priority_and_sticky_update( executing, 1 ); + _Thread_Priority_update_and_make_sticky( executing ); _Thread_Dispatch_enable( cpu_self ); return STATUS_SUCCESSFUL; } @@ -287,7 +302,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Claim_ownership( * @retval STATUS_INVALID_NUMBER The MrsP control is initially locked. * @retval STATUS_NO_MEMORY There is not enough memory to allocate. */ -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Initialize( +static inline Status_Control _MRSP_Initialize( MRSP_Control *mrsp, const Scheduler_Control *scheduler, Priority_Control ceiling_priority, @@ -348,7 +363,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Initialize( * @retval STATUS_DEADLOCK A deadlock occurred. * @retval STATUS_TIMEOUT A timeout occurred. */ -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership( +static inline Status_Control _MRSP_Wait_for_ownership( MRSP_Control *mrsp, Thread_Control *executing, Thread_queue_Context *queue_context @@ -384,13 +399,6 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership( _MRSP_Replace_priority( mrsp, executing, &ceiling_priority ); } else { Per_CPU_Control *cpu_self; - int sticky_level_change; - - if ( status != STATUS_DEADLOCK ) { - sticky_level_change = -1; - } else { - sticky_level_change = 0; - } _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context ); _MRSP_Remove_priority( executing, &ceiling_priority, queue_context ); @@ -398,7 +406,13 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership( &queue_context->Lock_context.Lock_context ); _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context ); - _Thread_Priority_and_sticky_update( executing, sticky_level_change ); + + if ( status != STATUS_DEADLOCK ) { + _Thread_Priority_update_and_clean_sticky( executing ); + } else { + _Thread_Priority_update_ignore_sticky( executing ); + } + _Thread_Dispatch_enable( cpu_self ); } @@ -427,7 +441,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership( * @retval STATUS_MUTEX_CEILING_VIOLATED The current priority of the executing * thread exceeds the ceiling priority of the mutex. */ -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize( +static inline Status_Control _MRSP_Seize( MRSP_Control *mrsp, Thread_Control *executing, bool wait, @@ -466,7 +480,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize( * @retval STATUS_SUCCESSFUL The operation succeeded. * @retval STATUS_NOT_OWNER The executing thread does not own the MrsP control. */ -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Surrender( +static inline Status_Control _MRSP_Surrender( MRSP_Control *mrsp, Thread_Control *executing, Thread_queue_Context *queue_context @@ -493,7 +507,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Surrender( &queue_context->Lock_context.Lock_context ); _MRSP_Release( mrsp, queue_context ); - _Thread_Priority_and_sticky_update( executing, -1 ); + _Thread_Priority_update_and_clean_sticky( executing ); _Thread_Dispatch_enable( cpu_self ); return STATUS_SUCCESSFUL; } @@ -518,7 +532,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Surrender( * @retval STATUS_RESOURCE_IN_USE The MrsP control is in use, * it cannot be destroyed. */ -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Can_destroy( MRSP_Control *mrsp ) +static inline Status_Control _MRSP_Can_destroy( MRSP_Control *mrsp ) { if ( _MRSP_Get_owner( mrsp ) != NULL ) { return STATUS_RESOURCE_IN_USE; @@ -533,7 +547,7 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Can_destroy( MRSP_Control *mrsp ) * @param[in, out] The mrsp that is about to be destroyed. * @param queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _MRSP_Destroy( +static inline void _MRSP_Destroy( MRSP_Control *mrsp, Thread_queue_Context *queue_context ) diff --git a/cpukit/include/rtems/score/muteximpl.h b/cpukit/include/rtems/score/muteximpl.h index c75a9ab657..aa76b7e7b8 100644 --- a/cpukit/include/rtems/score/muteximpl.h +++ b/cpukit/include/rtems/score/muteximpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_MUTEXIMPL_H diff --git a/cpukit/include/rtems/score/object.h b/cpukit/include/rtems/score/object.h index c8243323a6..cdb554b39c 100644 --- a/cpukit/include/rtems/score/object.h +++ b/cpukit/include/rtems/score/object.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_OBJECT_H @@ -254,7 +273,7 @@ typedef enum { * * @return An object Id constructed from the arguments. */ -RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API( +static inline Objects_APIs _Objects_Get_API( Objects_Id id ) { @@ -268,7 +287,7 @@ RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API( * * @return The class portion of the ID. */ -RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_class( +static inline uint32_t _Objects_Get_class( Objects_Id id ) { @@ -283,7 +302,7 @@ RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_class( * * @return Returns the node portion of an object ID. */ -RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node( +static inline uint32_t _Objects_Get_node( Objects_Id id ) { @@ -297,7 +316,7 @@ RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node( * * @return Returns the index portion of the specified object ID. */ -RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index( +static inline Objects_Maximum _Objects_Get_index( Objects_Id id ) { diff --git a/cpukit/include/rtems/score/objectdata.h b/cpukit/include/rtems/score/objectdata.h index 149498df9c..4bdd30f2c6 100644 --- a/cpukit/include/rtems/score/objectdata.h +++ b/cpukit/include/rtems/score/objectdata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_OBJECTDATA_H @@ -286,7 +305,7 @@ struct Objects_Information { #if defined(RTEMS_MULTIPROCESSING) /** - * @brief This method is used by _Thread_queue_Extract_with_proxy(). + * @brief This method is used by _Thread_MP_Extract_proxy(). * * This member is statically initialized and read-only. */ @@ -430,7 +449,9 @@ Objects_Information name##_Information = { \ #define OBJECTS_INFORMATION_DEFINE( name, api, cls, type, max, nl, ex ) \ static Objects_Control * \ name##_Local_table[ _Objects_Maximum_per_allocation( max ) ]; \ -static type name##_Objects[ _Objects_Maximum_per_allocation( max ) ]; \ +static RTEMS_SECTION( ".noinit.rtems.content.objects." #name ) \ +type \ +name##_Objects[ _Objects_Maximum_per_allocation( max ) ]; \ Objects_Information name##_Information = { \ _Objects_Build_id( api, cls, 1, _Objects_Maximum_per_allocation( max ) ), \ name##_Local_table, \ diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h index 54db4577bc..a1a87b5ccb 100644 --- a/cpukit/include/rtems/score/objectimpl.h +++ b/cpukit/include/rtems/score/objectimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_OBJECTIMPL_H @@ -377,7 +396,7 @@ Objects_Information *_Objects_Get_information_id( * @retval true The object has a string name. * @retval false The object does not have a string name. */ -RTEMS_INLINE_ROUTINE bool _Objects_Has_string_name( +static inline bool _Objects_Has_string_name( const Objects_Information *information ) { @@ -452,7 +471,7 @@ Status_Control _Objects_Set_name( * @param information The corresponding object information table. * @param[out] the_object The object to operate upon. */ -RTEMS_INLINE_ROUTINE void _Objects_Namespace_remove_u32( +static inline void _Objects_Namespace_remove_u32( const Objects_Information *information, Objects_Control *the_object ) @@ -504,7 +523,7 @@ Objects_Maximum _Objects_Active_count( * * @return The number of objects per block of @a information. */ -RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size( +static inline Objects_Maximum _Objects_Extend_size( const Objects_Information *information ) { @@ -519,13 +538,11 @@ RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size( * @retval true The specified api value is valid. * @retval false The specified api value is not valid. */ -RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid( +static inline bool _Objects_Is_api_valid( uint32_t the_api ) { - if ( !the_api || the_api > OBJECTS_APIS_LAST ) - return false; - return true; + return ( 1 <= the_api && the_api <= OBJECTS_APIS_LAST ); } /** @@ -537,7 +554,7 @@ RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid( * @retval true The specified node is the local node. * @retval false The specified node is not the local node. */ -RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node( +static inline bool _Objects_Is_local_node( uint32_t node ) { @@ -554,7 +571,7 @@ RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node( * * @note On a single processor configuration, this always returns true. */ -RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id( +static inline bool _Objects_Is_local_id( #if defined(RTEMS_MULTIPROCESSING) Objects_Id id #else @@ -578,7 +595,7 @@ RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id( * @retval true The specified object IDs are equal. * @retval false The specified object IDs are not equal. */ -RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal( +static inline bool _Objects_Are_ids_equal( Objects_Id left, Objects_Id right ) @@ -595,7 +612,7 @@ RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal( * * @return The corresponding ID with the minimum index. */ -RTEMS_INLINE_ROUTINE Objects_Id _Objects_Get_minimum_id( Objects_Id id ) +static inline Objects_Id _Objects_Get_minimum_id( Objects_Id id ) { id &= ~OBJECTS_INDEX_MASK; id += (Objects_Id) OBJECTS_INDEX_MINIMUM << OBJECTS_INDEX_START_BIT; @@ -609,7 +626,7 @@ RTEMS_INLINE_ROUTINE Objects_Id _Objects_Get_minimum_id( Objects_Id id ) * * @return The maximum index of the specified object class. */ -RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_maximum_index( +static inline Objects_Maximum _Objects_Get_maximum_index( const Objects_Information *information ) { @@ -622,7 +639,7 @@ RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_maximum_index( * @retval NULL No inactive object is available. * @retval object An inactive object. */ -RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Get_inactive( +static inline Objects_Control *_Objects_Get_inactive( Objects_Information *information ) { @@ -638,7 +655,7 @@ RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Get_inactive( * @retval true The automatic object extension (unlimited objects) is enabled. * @retval false The automatic object extension (unlimited objects) is not enabled. */ -RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Is_auto_extend( +static inline Objects_Maximum _Objects_Is_auto_extend( const Objects_Information *information ) { @@ -659,7 +676,7 @@ RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Is_auto_extend( * or delete/destroy operations. */ -RTEMS_INLINE_ROUTINE void _Objects_Set_local_object( +static inline void _Objects_Set_local_object( const Objects_Information *information, uint32_t index, Objects_Control *the_object @@ -692,7 +709,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Set_local_object( * or delete/destroy operations. */ -RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id( +static inline void _Objects_Invalidate_Id( const Objects_Information *information, Objects_Control *the_object ) @@ -719,7 +736,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id( * * @return Returns the identifier of the object which is now valid. */ -RTEMS_INLINE_ROUTINE Objects_Id _Objects_Open_u32( +static inline Objects_Id _Objects_Open_u32( const Objects_Information *information, Objects_Control *the_object, uint32_t name @@ -750,7 +767,7 @@ RTEMS_INLINE_ROUTINE Objects_Id _Objects_Open_u32( * * @param name is the name of the object to open. */ -RTEMS_INLINE_ROUTINE void _Objects_Open_string( +static inline void _Objects_Open_string( const Objects_Information *information, Objects_Control *the_object, const char *name @@ -783,7 +800,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Open_string( * * @see _Objects_Allocator_unlock() and _Objects_Allocate(). */ -RTEMS_INLINE_ROUTINE void _Objects_Allocator_lock( void ) +static inline void _Objects_Allocator_lock( void ) { _RTEMS_Lock_allocator(); } @@ -795,7 +812,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Allocator_lock( void ) * previous thread life protection state and thus may not return if the * executing thread was restarted or deleted in the mean-time. */ -RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock( void ) +static inline void _Objects_Allocator_unlock( void ) { _RTEMS_Unlock_allocator(); } @@ -806,7 +823,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock( void ) * @retval true The allocator is the owner of the object allocator mutex. * @retval false The allocato is not the owner of the object allocator mutex. */ -RTEMS_INLINE_ROUTINE bool _Objects_Allocator_is_owner( void ) +static inline bool _Objects_Allocator_is_owner( void ) { return _RTEMS_Allocator_is_owner(); } @@ -826,7 +843,7 @@ RTEMS_INLINE_ROUTINE bool _Objects_Allocator_is_owner( void ) * * @see _Objects_Allocate() and _Objects_Free(). */ -RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Allocate_unprotected( +static inline Objects_Control *_Objects_Allocate_unprotected( Objects_Information *information ) { @@ -882,7 +899,7 @@ RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Allocate_unprotected( * } * @endcode */ -RTEMS_INLINE_ROUTINE void _Objects_Free( +static inline void _Objects_Free( Objects_Information *information, Objects_Control *the_object ) @@ -893,6 +910,25 @@ RTEMS_INLINE_ROUTINE void _Objects_Free( } /** + * @brief Returns true, if the object associated with the zero-based index is + * contained in an allocated block of objects, otherwise false. + * + * @param index is the zero-based object index. + * @param objects_per_block is the object count per block. + * + * @retval true The object associated with the zero-based index is in an + * allocated block of objects. + * @retval false Otherwise. + */ +static inline bool _Objects_Is_in_allocated_block( + Objects_Maximum index, + Objects_Maximum objects_per_block +) +{ + return index >= objects_per_block; +} + +/** * @brief Activate the object. * * This function must be only used in case this objects information supports @@ -901,21 +937,23 @@ RTEMS_INLINE_ROUTINE void _Objects_Free( * @param information The object information block. * @param the_object The object to activate. */ -RTEMS_INLINE_ROUTINE void _Objects_Activate_unlimited( +static inline void _Objects_Activate_unlimited( Objects_Information *information, Objects_Control *the_object ) { Objects_Maximum objects_per_block; - Objects_Maximum block; + Objects_Maximum index; _Assert( _Objects_Is_auto_extend( information ) ); objects_per_block = information->objects_per_block; - block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM; + index = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM; + + if ( _Objects_Is_in_allocated_block( index, objects_per_block ) ) { + Objects_Maximum block; - if ( block > objects_per_block ) { - block /= objects_per_block; + block = index / objects_per_block; information->inactive_per_block[ block ]--; information->inactive--; @@ -931,7 +969,7 @@ RTEMS_INLINE_ROUTINE void _Objects_Activate_unlimited( * @param information The object information block. * @param extend The object information extend handler. */ -RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Allocate_with_extend( +static inline Objects_Control *_Objects_Allocate_with_extend( Objects_Information *information, void ( *extend )( Objects_Information * ) ) diff --git a/cpukit/include/rtems/score/objectmp.h b/cpukit/include/rtems/score/objectmp.h index 9107e2b3b6..26e7a07880 100644 --- a/cpukit/include/rtems/score/objectmp.h +++ b/cpukit/include/rtems/score/objectmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_OBJECTMP_H diff --git a/cpukit/include/rtems/score/onceimpl.h b/cpukit/include/rtems/score/onceimpl.h index bac19f0f20..9552cc0a67 100644 --- a/cpukit/include/rtems/score/onceimpl.h +++ b/cpukit/include/rtems/score/onceimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2014, 2019 embedded brains GmbH. All rights reserved. + * Copyright (C) 2014, 2019 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_ONCE_H diff --git a/cpukit/include/rtems/score/percpu.h b/cpukit/include/rtems/score/percpu.h index 6081653a86..288445bc6f 100644 --- a/cpukit/include/rtems/score/percpu.h +++ b/cpukit/include/rtems/score/percpu.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,11 +13,28 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2012, 2018 embedded brains GmbH + * Copyright (C) 2012, 2018 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_PERCPU_H @@ -38,18 +57,31 @@ extern "C" { #endif -#if defined(RTEMS_SMP) - #if defined(RTEMS_PROFILING) - #define PER_CPU_CONTROL_SIZE_APPROX \ - ( 512 + CPU_PER_CPU_CONTROL_SIZE + CPU_INTERRUPT_FRAME_SIZE ) - #elif defined(RTEMS_DEBUG) || CPU_SIZEOF_POINTER > 4 - #define PER_CPU_CONTROL_SIZE_APPROX \ - ( 256 + CPU_PER_CPU_CONTROL_SIZE + CPU_INTERRUPT_FRAME_SIZE ) +#if defined( RTEMS_SMP ) + #if defined( RTEMS_PROFILING ) + #define PER_CPU_CONTROL_SIZE_PROFILING 332 #else - #define PER_CPU_CONTROL_SIZE_APPROX \ - ( 180 + CPU_PER_CPU_CONTROL_SIZE + CPU_INTERRUPT_FRAME_SIZE ) + #define PER_CPU_CONTROL_SIZE_PROFILING 0 #endif + #if defined( RTEMS_DEBUG ) + #define PER_CPU_CONTROL_SIZE_DEBUG 76 + #else + #define PER_CPU_CONTROL_SIZE_DEBUG 0 + #endif + + #if CPU_SIZEOF_POINTER > 4 + #define PER_CPU_CONTROL_SIZE_BIG_POINTER 76 + #else + #define PER_CPU_CONTROL_SIZE_BIG_POINTER 0 + #endif + + #define PER_CPU_CONTROL_SIZE_BASE 180 + #define PER_CPU_CONTROL_SIZE_APPROX \ + ( PER_CPU_CONTROL_SIZE_BASE + CPU_PER_CPU_CONTROL_SIZE + \ + CPU_INTERRUPT_FRAME_SIZE + PER_CPU_CONTROL_SIZE_PROFILING + \ + PER_CPU_CONTROL_SIZE_DEBUG + PER_CPU_CONTROL_SIZE_BIG_POINTER ) + /* * This ensures that on SMP configurations the individual per-CPU controls * are on different cache lines to prevent false sharing. This define can be @@ -230,6 +262,13 @@ typedef struct Per_CPU_Job { /** * @brief Per-CPU statistics. */ + +/* + * This was added to address the following warning: + * warning: struct has no members + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" typedef struct { #if defined( RTEMS_PROFILING ) /** @@ -298,6 +337,7 @@ typedef struct { uint64_t total_interrupt_time; #endif /* defined( RTEMS_PROFILING ) */ } Per_CPU_Stats; +#pragma GCC diagnostic pop /** * @brief Per-CPU watchdog header index. @@ -452,10 +492,12 @@ typedef struct Per_CPU_Control { * @brief Watchdog state for this processor. */ struct { +#if defined(RTEMS_SMP) /** * @brief Protects all watchdog operations on this processor. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; +#endif /** * @brief Watchdog ticks on this processor used for monotonic clock @@ -713,7 +755,7 @@ static inline bool _Per_CPU_Is_boot_processor( #endif } -RTEMS_INLINE_ROUTINE void _Per_CPU_Acquire_all( +static inline void _Per_CPU_Acquire_all( ISR_lock_Context *lock_context ) { @@ -740,7 +782,7 @@ RTEMS_INLINE_ROUTINE void _Per_CPU_Acquire_all( #endif } -RTEMS_INLINE_ROUTINE void _Per_CPU_Release_all( +static inline void _Per_CPU_Release_all( ISR_lock_Context *lock_context ) { @@ -917,7 +959,7 @@ void _Per_CPU_Wait_for_job( * * @return The thread control block of the executing thread. */ -RTEMS_INLINE_ROUTINE struct _Thread_Control *_Thread_Get_executing( void ) +static inline struct _Thread_Control *_Thread_Get_executing( void ) { struct _Thread_Control *executing; diff --git a/cpukit/include/rtems/score/percpudata.h b/cpukit/include/rtems/score/percpudata.h index da454fd7bf..817adde232 100644 --- a/cpukit/include/rtems/score/percpudata.h +++ b/cpukit/include/rtems/score/percpudata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2018 embedded brains GmbH. All rights reserved. + * Copyright (c) 2018 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_PERCPUDATA_H diff --git a/cpukit/include/rtems/score/priority.h b/cpukit/include/rtems/score/priority.h index 8d54e1d85f..bbb8fd03f2 100644 --- a/cpukit/include/rtems/score/priority.h +++ b/cpukit/include/rtems/score/priority.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,11 +14,28 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2016, 2017 embedded brains GmbH. + * Copyright (C) 2016, 2017 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_PRIORITY_H @@ -26,12 +45,12 @@ #include <rtems/score/cpu.h> #include <rtems/score/rbtree.h> -struct _Scheduler_Control; - #ifdef __cplusplus extern "C" { #endif +struct _Scheduler_Control; + /** * @defgroup RTEMSScorePriority Priority Handler * @@ -77,13 +96,6 @@ typedef uint64_t Priority_Control; #define PRIORITY_MINIMUM 0 /** - * @brief The priority value of pseudo-ISR threads. - * - * Examples are the MPCI and timer server threads. - */ -#define PRIORITY_PSEUDO_ISR PRIORITY_MINIMUM - -/** * @brief The default lowest (least important) thread priority value. * * This value is CPU port dependent. diff --git a/cpukit/include/rtems/score/prioritybitmap.h b/cpukit/include/rtems/score/prioritybitmap.h index 30d96ba4c7..58a86e0a78 100644 --- a/cpukit/include/rtems/score/prioritybitmap.h +++ b/cpukit/include/rtems/score/prioritybitmap.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2010. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_PRIORITYBITMAP_H diff --git a/cpukit/include/rtems/score/prioritybitmapimpl.h b/cpukit/include/rtems/score/prioritybitmapimpl.h index da55d988ba..eda19357c4 100644 --- a/cpukit/include/rtems/score/prioritybitmapimpl.h +++ b/cpukit/include/rtems/score/prioritybitmapimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2010. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_PRIORITYBITMAPIMPL_H @@ -53,7 +72,7 @@ extern const unsigned char _Bitfield_Leading_zeros[256]; * * @see _Priority_Bits_index() and _Priority_Mask(). */ -RTEMS_INLINE_ROUTINE unsigned int _Bitfield_Find_first_bit( +static inline unsigned int _Bitfield_Find_first_bit( unsigned int value ) { @@ -83,7 +102,7 @@ RTEMS_INLINE_ROUTINE unsigned int _Bitfield_Find_first_bit( * * @return The priority bit mask. */ -RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Mask( +static inline Priority_bit_map_Word _Priority_Mask( unsigned int bit_number ) { @@ -102,7 +121,7 @@ RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Mask( * * @return The corresponding array index into the priority bit map. */ -RTEMS_INLINE_ROUTINE unsigned int _Priority_Bits_index( +static inline unsigned int _Priority_Bits_index( unsigned int bit_number ) { @@ -120,7 +139,7 @@ RTEMS_INLINE_ROUTINE unsigned int _Priority_Bits_index( * * @return The major portion of the priority. */ -RTEMS_INLINE_ROUTINE unsigned int _Priority_Major( unsigned int the_priority ) +static inline unsigned int _Priority_Major( unsigned int the_priority ) { return the_priority / 16; } @@ -132,7 +151,7 @@ RTEMS_INLINE_ROUTINE unsigned int _Priority_Major( unsigned int the_priority ) * * @return The minor portion of the priority. */ -RTEMS_INLINE_ROUTINE unsigned int _Priority_Minor( unsigned int the_priority ) +static inline unsigned int _Priority_Minor( unsigned int the_priority ) { return the_priority % 16; } @@ -142,7 +161,7 @@ RTEMS_INLINE_ROUTINE unsigned int _Priority_Minor( unsigned int the_priority ) * * @param[out] bit_map The bit map to initialize. */ -RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize( +static inline void _Priority_bit_map_Initialize( Priority_bit_map_Control *bit_map ) { @@ -157,7 +176,7 @@ RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize( * @param[out] bit_map The bit map to be altered by @a bit_map_info. * @param bit_map_info The information with which to alter @a bit_map. */ -RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add ( +static inline void _Priority_bit_map_Add ( Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info ) @@ -174,7 +193,7 @@ RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add ( * @param[out] bit_map The bit map to be altered by @a bit_map_info. * @param bit_map_info The information with which to alter @a bit_map. */ -RTEMS_INLINE_ROUTINE void _Priority_bit_map_Remove ( +static inline void _Priority_bit_map_Remove ( Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info ) @@ -191,7 +210,7 @@ RTEMS_INLINE_ROUTINE void _Priority_bit_map_Remove ( * * @return The highest portion of the bitmap. */ -RTEMS_INLINE_ROUTINE unsigned int _Priority_bit_map_Get_highest( +static inline unsigned int _Priority_bit_map_Get_highest( const Priority_bit_map_Control *bit_map ) { @@ -213,7 +232,7 @@ RTEMS_INLINE_ROUTINE unsigned int _Priority_bit_map_Get_highest( * @retval true The Priority queue bit map is empty * @retval false The Priority queue bit map is not empty. */ -RTEMS_INLINE_ROUTINE bool _Priority_bit_map_Is_empty( +static inline bool _Priority_bit_map_Is_empty( const Priority_bit_map_Control *bit_map ) { @@ -229,7 +248,7 @@ RTEMS_INLINE_ROUTINE bool _Priority_bit_map_Is_empty( * @param new_priority The new priority for the initialization * of the bit map information. */ -RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information( +static inline void _Priority_bit_map_Initialize_information( Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info, unsigned int new_priority diff --git a/cpukit/include/rtems/score/priorityimpl.h b/cpukit/include/rtems/score/priorityimpl.h index 2895a0c4a5..2a95ea605c 100644 --- a/cpukit/include/rtems/score/priorityimpl.h +++ b/cpukit/include/rtems/score/priorityimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. + * Copyright (c) 2016 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_SCORE_PRIORITYIMPL_H @@ -65,7 +78,7 @@ typedef enum { * * @param[out] actions The actions to be initialized empty. */ -RTEMS_INLINE_ROUTINE void _Priority_Actions_initialize_empty( +static inline void _Priority_Actions_initialize_empty( Priority_Actions *actions ) { @@ -80,7 +93,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Actions_initialize_empty( * @param node The action node for the @a actions to be initialized. * @param type The action type for the @a actions to be initialized. */ -RTEMS_INLINE_ROUTINE void _Priority_Actions_initialize_one( +static inline void _Priority_Actions_initialize_one( Priority_Actions *actions, Priority_Aggregation *aggregation, Priority_Node *node, @@ -104,7 +117,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Actions_initialize_one( * @retval true The priority actions @a actions is empty. * @retval false The priority actions @a actions is empty. */ -RTEMS_INLINE_ROUTINE bool _Priority_Actions_is_empty( +static inline bool _Priority_Actions_is_empty( const Priority_Actions *actions ) { @@ -112,33 +125,13 @@ RTEMS_INLINE_ROUTINE bool _Priority_Actions_is_empty( } /** - * @brief Checks if the priority actions is valid. - * - * @param aggregation The aggregation of the priority action. - * - * @retval true The @a aggregation is valid. - * @retval false The @a aggregation is not valid. - */ -RTEMS_INLINE_ROUTINE bool _Priority_Actions_is_valid( - const Priority_Aggregation *aggregation -) -{ -#if defined(RTEMS_SMP) - return aggregation != NULL; -#else - (void) aggregation; - return false; -#endif -} - -/** * @brief Moves the priority actions' actions. * * @param[in, out] actions The priority actions to move the actions away from. * * @return The former actions of @a actions that were moved. */ -RTEMS_INLINE_ROUTINE Priority_Aggregation *_Priority_Actions_move( +static inline Priority_Aggregation *_Priority_Actions_move( Priority_Actions *actions ) { @@ -156,7 +149,7 @@ RTEMS_INLINE_ROUTINE Priority_Aggregation *_Priority_Actions_move( * @param[in, out] actions The priority actions to add actions to. * @param[out] aggregation The actions to add to @a actions. */ -RTEMS_INLINE_ROUTINE void _Priority_Actions_add( +static inline void _Priority_Actions_add( Priority_Actions *actions, Priority_Aggregation *aggregation ) @@ -177,7 +170,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Actions_add( * @param[out] node The priority node to be initialized. * @param priority The priority to initialize @a node to. */ -RTEMS_INLINE_ROUTINE void _Priority_Node_initialize( +static inline void _Priority_Node_initialize( Priority_Node *node, Priority_Control priority ) @@ -192,7 +185,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Node_initialize( * @param[out] node The priority node to set the priority of. * @param priority The new priority for @a node. */ -RTEMS_INLINE_ROUTINE void _Priority_Node_set_priority( +static inline void _Priority_Node_set_priority( Priority_Node *node, Priority_Control priority ) @@ -205,7 +198,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Node_set_priority( * * @param[in, out] node The priority node to set inactive. */ -RTEMS_INLINE_ROUTINE void _Priority_Node_set_inactive( +static inline void _Priority_Node_set_inactive( Priority_Node *node ) { @@ -220,7 +213,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Node_set_inactive( * @retval true The priority node is active. * @retval false The priority node is inactive. */ -RTEMS_INLINE_ROUTINE bool _Priority_Node_is_active( +static inline bool _Priority_Node_is_active( const Priority_Node *node ) { @@ -232,7 +225,7 @@ RTEMS_INLINE_ROUTINE bool _Priority_Node_is_active( * * @param[out] aggregation The priority aggregaton to initialize empty. */ -RTEMS_INLINE_ROUTINE void _Priority_Initialize_empty( +static inline void _Priority_Initialize_empty( Priority_Aggregation *aggregation ) { @@ -253,7 +246,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Initialize_empty( * @param[out] aggregation The priority aggregaton to initialize. * @param node The priority node to initialize @a aggregation with. */ -RTEMS_INLINE_ROUTINE void _Priority_Initialize_one( +static inline void _Priority_Initialize_one( Priority_Aggregation *aggregation, Priority_Node *node ) @@ -277,7 +270,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Initialize_one( * @retval true The priority aggregation is empty. * @retval false The priority aggregation is not empty. */ -RTEMS_INLINE_ROUTINE bool _Priority_Is_empty( +static inline bool _Priority_Is_empty( const Priority_Aggregation *aggregation ) { @@ -291,7 +284,7 @@ RTEMS_INLINE_ROUTINE bool _Priority_Is_empty( * * @return The priority of @a aggregation. */ -RTEMS_INLINE_ROUTINE Priority_Control _Priority_Get_priority( +static inline Priority_Control _Priority_Get_priority( const Priority_Aggregation *aggregation ) { @@ -305,7 +298,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Priority_Get_priority( * * @return The scheduler of @a aggregation. */ -RTEMS_INLINE_ROUTINE const Scheduler_Control *_Priority_Get_scheduler( +static inline const Scheduler_Control *_Priority_Get_scheduler( const Priority_Aggregation *aggregation ) { @@ -323,7 +316,7 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_Priority_Get_scheduler( * * @return The minimum node of @a aggregation */ -RTEMS_INLINE_ROUTINE Priority_Node *_Priority_Get_minimum_node( +static inline Priority_Node *_Priority_Get_minimum_node( const Priority_Aggregation *aggregation ) { @@ -336,7 +329,7 @@ RTEMS_INLINE_ROUTINE Priority_Node *_Priority_Get_minimum_node( * @param[out] aggregation The priority aggregation to set the action node of. * @param node The new priority node for @a aggregation. */ -RTEMS_INLINE_ROUTINE void _Priority_Set_action_node( +static inline void _Priority_Set_action_node( Priority_Aggregation *aggregation, Priority_Node *node ) @@ -350,7 +343,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Set_action_node( * @param[out] aggregation The priority aggregation to set the action type of. * @param type The new action type for @a aggregation. */ -RTEMS_INLINE_ROUTINE void _Priority_Set_action_type( +static inline void _Priority_Set_action_type( Priority_Aggregation *aggregation, Priority_Action_type type ) @@ -366,7 +359,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Set_action_type( * @param node The new action node for @a aggregation. * @param type The new action type for @a aggregation. */ -RTEMS_INLINE_ROUTINE void _Priority_Set_action( +static inline void _Priority_Set_action( Priority_Aggregation *aggregation, Priority_Node *node, Priority_Action_type type @@ -376,25 +369,22 @@ RTEMS_INLINE_ROUTINE void _Priority_Set_action( aggregation->Action.type = type; } +#if defined(RTEMS_SMP) /** * @brief Gets the next action of the priority aggregation. * - * @param aggregation The priority aggregation to get the next action of. + * @param aggregation is the priority aggregation to get the next action of. * - * @retval next_action The next action of @a aggregation if RTEMS_SMP is defined. - * @retval NULL RTEMS_SMP is not defined. + * @return Returns the next action of the priority aggregation or NULL if there + * is no next action. */ -RTEMS_INLINE_ROUTINE Priority_Aggregation *_Priority_Get_next_action( +static inline Priority_Aggregation *_Priority_Get_next_action( const Priority_Aggregation *aggregation ) { -#if defined(RTEMS_SMP) return aggregation->Action.next; -#else - (void) aggregation; - return NULL; -#endif } +#endif /** * @brief Compares two priorities. @@ -405,7 +395,7 @@ RTEMS_INLINE_ROUTINE Priority_Aggregation *_Priority_Get_next_action( * @retval true The priority on the left hand side of the comparison is smaller. * @retval false The priority on the left hand side of the comparison is greater of equal. */ -RTEMS_INLINE_ROUTINE bool _Priority_Less( +static inline bool _Priority_Less( const void *left, const RBTree_Node *right ) @@ -413,7 +403,7 @@ RTEMS_INLINE_ROUTINE bool _Priority_Less( const Priority_Control *the_left; const Priority_Node *the_right; - the_left = left; + the_left = (const Priority_Control *) left; the_right = RTEMS_CONTAINER_OF( right, Priority_Node, Node.RBTree ); return *the_left < the_right->priority; @@ -432,7 +422,7 @@ RTEMS_INLINE_ROUTINE bool _Priority_Less( * @retval true The inserted node with its priority is the minimum of the RBTree. * @retval false The inserted node with its priority is not the minimum of the RBTree. */ -RTEMS_INLINE_ROUTINE bool _Priority_Plain_insert( +static inline bool _Priority_Plain_insert( Priority_Aggregation *aggregation, Priority_Node *node, Priority_Control priority @@ -454,7 +444,7 @@ RTEMS_INLINE_ROUTINE bool _Priority_Plain_insert( * @param[in, out] aggregation The aggregation to extract the node from. * @param node The node to be extracted. */ -RTEMS_INLINE_ROUTINE void _Priority_Plain_extract( +static inline void _Priority_Plain_extract( Priority_Aggregation *aggregation, Priority_Node *node ) @@ -471,7 +461,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Plain_extract( * @param[in, out] aggregation The aggregation to change the node in. * @param node The node that has a new priority and will be reinserted in the aggregation. */ -RTEMS_INLINE_ROUTINE void _Priority_Plain_changed( +static inline void _Priority_Plain_changed( Priority_Aggregation *aggregation, Priority_Node *node ) @@ -509,7 +499,7 @@ typedef void ( *Priority_Remove_handler )( * @param actions Is ignored by the method. * @param arg Is ignored by the method. */ -RTEMS_INLINE_ROUTINE void _Priority_Change_nothing( +static inline void _Priority_Change_nothing( Priority_Aggregation *aggregation, Priority_Group_order group_order, Priority_Actions *actions, @@ -531,7 +521,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Change_nothing( * @param actions Is ignored by the method. * @param arg Is ignored by the method. */ -RTEMS_INLINE_ROUTINE void _Priority_Remove_nothing( +static inline void _Priority_Remove_nothing( Priority_Aggregation *aggregation, Priority_Actions *actions, void *arg @@ -555,7 +545,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Remove_nothing( * @param arg Arguments for @a change that is used if the node is the new * minimum. */ -RTEMS_INLINE_ROUTINE void _Priority_Non_empty_insert( +static inline void _Priority_Non_empty_insert( Priority_Aggregation *aggregation, Priority_Node *node, Priority_Actions *actions, @@ -586,7 +576,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Non_empty_insert( * insert and @a node is the new minimum of the aggregation. * @param arg The arguments for @a change. */ -RTEMS_INLINE_ROUTINE void _Priority_Insert( +static inline void _Priority_Insert( Priority_Aggregation *aggregation, Priority_Node *node, Priority_Actions *actions, @@ -620,7 +610,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Insert( * @param change Is called in the case that the minimal node was extracted. * @param arg The arguments for @a remove and @a change. */ -RTEMS_INLINE_ROUTINE void _Priority_Extract( +static inline void _Priority_Extract( Priority_Aggregation *aggregation, Priority_Node *node, Priority_Actions *actions, @@ -660,7 +650,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Extract( * @param change Is called in the case that the minimal node was extracted. * @param arg The arguments for @a change. */ -RTEMS_INLINE_ROUTINE void _Priority_Extract_non_empty( +static inline void _Priority_Extract_non_empty( Priority_Aggregation *aggregation, Priority_Node *node, Priority_Actions *actions, @@ -695,7 +685,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Extract_non_empty( * @param change Is called if the minimal priority is incorrectly set after the change. * @param arg The arguments for @a change. */ -RTEMS_INLINE_ROUTINE void _Priority_Changed( +static inline void _Priority_Changed( Priority_Aggregation *aggregation, Priority_Node *node, Priority_Group_order group_order, @@ -731,7 +721,7 @@ RTEMS_INLINE_ROUTINE void _Priority_Changed( * @param[out] replacement The node that replaces @a victim. It obtains its priority * from @a victim. */ -RTEMS_INLINE_ROUTINE void _Priority_Replace( +static inline void _Priority_Replace( Priority_Aggregation *aggregation, Priority_Node *victim, Priority_Node *replacement diff --git a/cpukit/include/rtems/score/processormask.h b/cpukit/include/rtems/score/processormask.h index b9eae8b54c..71ed37cd0e 100644 --- a/cpukit/include/rtems/score/processormask.h +++ b/cpukit/include/rtems/score/processormask.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2016, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. + * Copyright (C) 2016, 2017 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_SCORE_PROCESSORMASK_H @@ -26,14 +39,68 @@ #include <rtems/score/cpu.h> -#include <sys/cpuset.h> - -#include <strings.h> +#include <sys/_bitset.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +/* + * Recent Newlib versions provide the bitset defines in the system reserved + * namespace. + */ +#ifndef __BIT_AND2 +#define __BIT_AND2 BIT_AND2 +#endif +#ifndef __BIT_CLR +#define __BIT_CLR BIT_CLR +#endif +#ifndef __BIT_CMP +#define __BIT_CMP BIT_CMP +#endif +#ifndef __BIT_COPY +#define __BIT_COPY BIT_COPY +#endif +#ifndef __BIT_COUNT +#define __BIT_COUNT BIT_COUNT +#endif +#ifndef __BITSET_DEFINE +#define __BITSET_DEFINE BITSET_DEFINE +#endif +#ifndef __BIT_EMPTY +#define __BIT_EMPTY BIT_EMPTY +#endif +#ifndef __BIT_FILL +#define __BIT_FILL BIT_FILL +#endif +#ifndef __BIT_FLS +#define __BIT_FLS BIT_FLS +#endif +#ifndef __BIT_ISSET +#define __BIT_ISSET BIT_ISSET +#endif +#ifndef __BIT_OR2 +#define __BIT_OR2 BIT_OR2 +#endif +#ifndef __BIT_OVERLAP +#define __BIT_OVERLAP BIT_OVERLAP +#endif +#ifndef __BIT_SET +#define __BIT_SET BIT_SET +#endif +#ifndef __BIT_SETOF +#define __BIT_SETOF BIT_SETOF +#endif +#ifndef __BIT_SUBSET +#define __BIT_SUBSET BIT_SUBSET +#endif +#ifndef __BIT_XOR2 +#define __BIT_XOR2 BIT_XOR2 +#endif +#ifndef __BIT_ZERO +#define __BIT_ZERO BIT_ZERO +#endif + /** * @defgroup RTEMSScoreProcessorMask Processor Mask * @@ -52,398 +119,7 @@ extern "C" { * @brief A bit map which is large enough to provide one bit for each processor * in the system. */ -typedef BITSET_DEFINE( Processor_mask, CPU_MAXIMUM_PROCESSORS ) Processor_mask; - -/** - * @brief Sets the bits of the mask to zero, also considers CPU_MAXIMUM_PROCESSORS. - * - * @param[out] mask The mask to set to zero. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Zero( Processor_mask *mask ) -{ - BIT_ZERO( CPU_MAXIMUM_PROCESSORS, mask ); -} - -/** - * @brief Checks if the mask is zero, also considers CPU_MAXIMUM_PROCESSORS. - * - * @param mask The mask to check whether is is zero - * - * @retval true The mask is zero. - * @retval false The mask is not zero. - */ -RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_zero( const Processor_mask *mask ) -{ - return BIT_EMPTY( CPU_MAXIMUM_PROCESSORS, mask ); -} - -/** - * @brief Fills the mask, also considers CPU_MAXIMUM_PROCESSORS. - * - * @param[out] mask The mask to fill - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Fill( Processor_mask *mask ) -{ - BIT_FILL( CPU_MAXIMUM_PROCESSORS, mask ); -} - -/** - * @brief Copies the mask to another mask, also considers CPU_MAXIMUM_PROCESSORS. - * - * @param[out] dst The mask to copy @a src to. - * @param src The mask to copy to @a dst. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Assign( - Processor_mask *dst, const Processor_mask *src -) -{ - BIT_COPY( CPU_MAXIMUM_PROCESSORS, src, dst ); -} - -/** - * @brief Sets the specified index bit of the mask. - * - * @param[out] mask The mask to set the bit of. - * @param index The index of the bit that shall be set. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Set( - Processor_mask *mask, - uint32_t index -) -{ - BIT_SET( CPU_MAXIMUM_PROCESSORS, index, mask ); -} - -/** - * @brief Clears the specified index bit of the mask. - * - * @param[out] mask The mask to clear the bit of. - * @param index The index of the bit that shall be cleared. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Clear( - Processor_mask *mask, - uint32_t index -) -{ - BIT_CLR( CPU_MAXIMUM_PROCESSORS, index, mask ); -} - -/** - * @brief Checks if the specified index bit of the mask is set. - * - * @param mask The mask to check if the specified bit is set. - * @param index The index of the bit that is checked. - * - * @retval true The specified index bit is set. - * @retval false The specified index bit is not set. - */ -RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_set( - const Processor_mask *mask, - uint32_t index -) -{ - return BIT_ISSET( CPU_MAXIMUM_PROCESSORS, index, mask ); -} - -/** - * @brief Checks if the processor sets a and b are equal. - * - * @param a The first processor set. - * @param b The seconde processor set. - * - * @retval true The processor sets a and b are equal. - * @retval false The processor sets a and b are not equal. - */ -RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_equal( - const Processor_mask *a, - const Processor_mask *b -) -{ - return !BIT_CMP( CPU_MAXIMUM_PROCESSORS, a, b ); -} - -/** - * @brief Checks if the intersection of the processor sets a and b is - * non-empty. - * - * @param a The first processor set. - * @param b The second processor set. - * - * @retval true The intersection of the processor sets a and b is non-empty. - * @retval false The intersection of the processor sets a and b is empty. - */ -RTEMS_INLINE_ROUTINE bool _Processor_mask_Has_overlap( - const Processor_mask *a, - const Processor_mask *b -) -{ - return BIT_OVERLAP( CPU_MAXIMUM_PROCESSORS, a, b ); -} - -/** - * @brief Checks if the processor set small is a subset of processor set - * big. - * - * @param big The bigger processor set. - * @param small The smaller processor set. - * - * @retval true @a small is a subset of @a big. - * @retval false @a small is not a subset of @a big. - */ -RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_subset( - const Processor_mask *big, - const Processor_mask *small -) -{ - return BIT_SUBSET( CPU_MAXIMUM_PROCESSORS, big, small ); -} - -/** - * @brief Performs a bitwise a = b & c. - * - * @param[out] a The processor mask that is set by this operation. - * @param b The first parameter of the AND-operation. - * @param c The second parameter of the AND-operation. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_And( - Processor_mask *a, - const Processor_mask *b, - const Processor_mask *c -) -{ - BIT_AND2( CPU_MAXIMUM_PROCESSORS, a, b, c ); -} - -/** - * @brief Performs a bitwise a = b & ~c. - * - * @param[out] a The processor mask that is set by this operation. - * @param b The first parameter of the operation. - * @param c The second parameter of the operation. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Nand( - Processor_mask *a, - const Processor_mask *b, - const Processor_mask *c -) -{ - BIT_NAND2( CPU_MAXIMUM_PROCESSORS, a, b, c ); -} - -/** - * @brief Performs a bitwise a = b | c. - * - * @param[out] a The processor mask that is set by this operation. - * @param b The first parameter of the OR-operation. - * @param c The second parameter of the OR-operation. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Or( - Processor_mask *a, - const Processor_mask *b, - const Processor_mask *c -) -{ - BIT_OR2( CPU_MAXIMUM_PROCESSORS, a, b, c ); -} - -/** - * @brief Performs a bitwise a = b ^ c. - * - * @param[out] a The processor mask that is set by this operation. - * @param b The first parameter of the XOR-operation. - * @param c The second parameter of the XOR-operation. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Xor( - Processor_mask *a, - const Processor_mask *b, - const Processor_mask *c -) -{ - BIT_XOR2( CPU_MAXIMUM_PROCESSORS, a, b, c ); -} - -/** - * @brief Gets the number of set bits in the processor mask. - * - * @param a The processor mask of which the set bits are counted. - * - * @return The number of set bits in @a a. - */ -RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_Count( const Processor_mask *a ) -{ - return (uint32_t) BIT_COUNT( CPU_MAXIMUM_PROCESSORS, a ); -} - -/** - * @brief Finds the last set of the processor mask. - * - * @param a The processor mask wo find the last set of. - * - * @return The last set of @a a. - */ -RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_Find_last_set( const Processor_mask *a ) -{ - return (uint32_t) BIT_FLS( CPU_MAXIMUM_PROCESSORS, a ); -} - -/** - * @brief Returns the subset of 32 processors containing the specified index as - * an unsigned 32-bit integer. - * - * @param mask The processor mask. - * @param index The specified index. - * - * @return The subset containing the specified index as an unsigned 32-bit integer. - */ -RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_To_uint32_t( - const Processor_mask *mask, - uint32_t index -) -{ - long bits = mask->__bits[ __bitset_words( index ) ]; - - return (uint32_t) (bits >> (32 * (index % _BITSET_BITS) / 32)); -} - -/** - * @brief Creates a processor set from an unsigned 32-bit integer relative to - * the specified index. - * - * @param[out] mask The mask that is created. - * @param bits The bits for creating the mask. - * @param index The index to which the mask is relative. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_From_uint32_t( - Processor_mask *mask, - uint32_t bits, - uint32_t index -) -{ - _Processor_mask_Zero( mask ); - mask->__bits[ __bitset_words( index ) ] = ((long) bits) << (32 * (index % _BITSET_BITS) / 32); -} - -/** - * @brief Creates a processor set from the specified index. - * - * @param[out] The mask that is created. - * @param index The specified index. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_From_index( - Processor_mask *mask, - uint32_t index -) -{ - BIT_SETOF( CPU_MAXIMUM_PROCESSORS, (int) index, mask ); -} - -typedef enum { - PROCESSOR_MASK_COPY_LOSSLESS, - PROCESSOR_MASK_COPY_PARTIAL_LOSS, - PROCESSOR_MASK_COPY_COMPLETE_LOSS, - PROCESSOR_MASK_COPY_INVALID_SIZE -} Processor_mask_Copy_status; - -/** - * @brief Checks if the copy status guarantees at most partial loss. - * - * @param status The copy status to check. - * - * @retval true At most partial loss can be guaranteed. - * @retval false The status indicates more than partial loss. - */ -RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_at_most_partial_loss( - Processor_mask_Copy_status status -) -{ - return (unsigned int) status <= PROCESSOR_MASK_COPY_PARTIAL_LOSS; -} - -/** - * @brief Copies one mask to another. - * - * @param[out] dst The destination of the copy operation. - * @param dst_size The size of @a dst. - * @param src The source of the copy operation. - * @param src_size The size of @a src. - * - * @retval PROCESSOR_MASK_COPY_LOSSLESS It is guaranteed that the copy - * operation is lossless. - * @retval PROCESSOR_MASK_COPY_PARTIAL_LOSS Partial loss happened due - * to the sizes of @a src and @a dst. - * @retval PROCESSOR_MASK_COPY_COMPLETE_LOSS Complete loss happened due - * to the sizes of @a src and @a dst. - * @retval PROCESSOR_MASK_COPY_INVALID_SIZE One of the arguments sizes - * is invalid (bigger than the size of a long). - */ -Processor_mask_Copy_status _Processor_mask_Copy( - long *dst, - size_t dst_size, - const long *src, - size_t src_size -); - -/** - * @brief Copies one mask to another. - * - * @param src The source for the copy operation. - * @param dst_size The size of @a dst. - * @param[out] dst The destination for the copy operation. - * - * @retval PROCESSOR_MASK_COPY_LOSSLESS It is guaranteed that the copy - * operation is lossless. - * @retval PROCESSOR_MASK_COPY_PARTIAL_LOSS Partial loss happened due - * to the sizes of @a src and @a dst. - * @retval PROCESSOR_MASK_COPY_COMPLETE_LOSS Complete loss happened due - * to the sizes of @a src and @a dst. - * @retval PROCESSOR_MASK_COPY_INVALID_SIZE One of the arguments sizes - * is invalid (bigger than the size of a long). - */ -RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_To_cpu_set_t( - const Processor_mask *src, - size_t dst_size, - cpu_set_t *dst -) -{ - return _Processor_mask_Copy( - &dst->__bits[ 0 ], - dst_size, - &src->__bits[ 0 ], - sizeof( *src ) - ); -} - -/** - * @brief Copies one mask to another. - * - * @param src The source for the copy operation. - * @param src_size The size of @a src. - * @param[out] dst The destination for the copy operation. - * - * @retval PROCESSOR_MASK_COPY_LOSSLESS It is guaranteed that the copy - * operation is lossless. - * @retval PROCESSOR_MASK_COPY_PARTIAL_LOSS Partial loss happened due - * to the sizes of @a src and @a dst. - * @retval PROCESSOR_MASK_COPY_COMPLETE_LOSS Complete loss happened due - * to the sizes of @a src and @a dst. - * @retval PROCESSOR_MASK_COPY_INVALID_SIZE One of the arguments sizes - * is invalid (bigger than the size of a long). - */ -RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_From_cpu_set_t( - Processor_mask *dst, - size_t src_size, - const cpu_set_t *src -) -{ - return _Processor_mask_Copy( - &dst->__bits[ 0 ], - sizeof( *dst ), - &src->__bits[ 0 ], - src_size - ); -} - -extern const Processor_mask _Processor_mask_The_one_and_only; +typedef __BITSET_DEFINE( Processor_mask, CPU_MAXIMUM_PROCESSORS ) Processor_mask; /** @} */ diff --git a/cpukit/include/rtems/score/processormaskimpl.h b/cpukit/include/rtems/score/processormaskimpl.h new file mode 100644 index 0000000000..bc997edfd4 --- /dev/null +++ b/cpukit/include/rtems/score/processormaskimpl.h @@ -0,0 +1,437 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreProcessorMask + * + * @brief This header file provides the interfaces of the + * @ref RTEMSScoreProcessorMask. + */ + +/* + * Copyright (C) 2016, 2017 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_SCORE_PROCESSORMASKIMPL_H +#define _RTEMS_SCORE_PROCESSORMASKIMPL_H + +#include <rtems/score/processormask.h> + +#include <sys/cpuset.h> + +#include <strings.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup RTEMSScoreProcessorMask + * + * @{ + */ + +/** + * @brief Sets the bits of the mask to zero, also considers CPU_MAXIMUM_PROCESSORS. + * + * @param[out] mask The mask to set to zero. + */ +static inline void _Processor_mask_Zero( Processor_mask *mask ) +{ + __BIT_ZERO( CPU_MAXIMUM_PROCESSORS, mask ); +} + +/** + * @brief Checks if the mask is zero, also considers CPU_MAXIMUM_PROCESSORS. + * + * @param mask The mask to check whether is is zero + * + * @retval true The mask is zero. + * @retval false The mask is not zero. + */ +static inline bool _Processor_mask_Is_zero( const Processor_mask *mask ) +{ + return __BIT_EMPTY( CPU_MAXIMUM_PROCESSORS, mask ); +} + +/** + * @brief Fills the mask, also considers CPU_MAXIMUM_PROCESSORS. + * + * @param[out] mask The mask to fill + */ +static inline void _Processor_mask_Fill( Processor_mask *mask ) +{ + __BIT_FILL( CPU_MAXIMUM_PROCESSORS, mask ); +} + +/** + * @brief Copies the mask to another mask, also considers CPU_MAXIMUM_PROCESSORS. + * + * @param[out] dst The mask to copy @a src to. + * @param src The mask to copy to @a dst. + */ +static inline void _Processor_mask_Assign( + Processor_mask *dst, const Processor_mask *src +) +{ + __BIT_COPY( CPU_MAXIMUM_PROCESSORS, src, dst ); +} + +/** + * @brief Sets the specified index bit of the mask. + * + * @param[out] mask The mask to set the bit of. + * @param index The index of the bit that shall be set. + */ +static inline void _Processor_mask_Set( + Processor_mask *mask, + uint32_t index +) +{ + __BIT_SET( CPU_MAXIMUM_PROCESSORS, index, mask ); +} + +/** + * @brief Clears the specified index bit of the mask. + * + * @param[out] mask The mask to clear the bit of. + * @param index The index of the bit that shall be cleared. + */ +static inline void _Processor_mask_Clear( + Processor_mask *mask, + uint32_t index +) +{ + __BIT_CLR( CPU_MAXIMUM_PROCESSORS, index, mask ); +} + +/** + * @brief Checks if the specified index bit of the mask is set. + * + * @param mask The mask to check if the specified bit is set. + * @param index The index of the bit that is checked. + * + * @retval true The specified index bit is set. + * @retval false The specified index bit is not set. + */ +static inline bool _Processor_mask_Is_set( + const Processor_mask *mask, + uint32_t index +) +{ + return __BIT_ISSET( CPU_MAXIMUM_PROCESSORS, index, mask ); +} + +/** + * @brief Checks if the processor sets a and b are equal. + * + * @param a The first processor set. + * @param b The seconde processor set. + * + * @retval true The processor sets a and b are equal. + * @retval false The processor sets a and b are not equal. + */ +static inline bool _Processor_mask_Is_equal( + const Processor_mask *a, + const Processor_mask *b +) +{ + return !__BIT_CMP( CPU_MAXIMUM_PROCESSORS, a, b ); +} + +/** + * @brief Checks if the intersection of the processor sets a and b is + * non-empty. + * + * @param a The first processor set. + * @param b The second processor set. + * + * @retval true The intersection of the processor sets a and b is non-empty. + * @retval false The intersection of the processor sets a and b is empty. + */ +static inline bool _Processor_mask_Has_overlap( + const Processor_mask *a, + const Processor_mask *b +) +{ + return __BIT_OVERLAP( CPU_MAXIMUM_PROCESSORS, a, b ); +} + +/** + * @brief Checks if the processor set small is a subset of processor set + * big. + * + * @param big The bigger processor set. + * @param small The smaller processor set. + * + * @retval true @a small is a subset of @a big. + * @retval false @a small is not a subset of @a big. + */ +static inline bool _Processor_mask_Is_subset( + const Processor_mask *big, + const Processor_mask *small +) +{ + return __BIT_SUBSET( CPU_MAXIMUM_PROCESSORS, big, small ); +} + +/** + * @brief Performs a bitwise a = b & c. + * + * @param[out] a The processor mask that is set by this operation. + * @param b The first parameter of the AND-operation. + * @param c The second parameter of the AND-operation. + */ +static inline void _Processor_mask_And( + Processor_mask *a, + const Processor_mask *b, + const Processor_mask *c +) +{ + __BIT_AND2( CPU_MAXIMUM_PROCESSORS, a, b, c ); +} + +/** + * @brief Performs a bitwise a = b | c. + * + * @param[out] a The processor mask that is set by this operation. + * @param b The first parameter of the OR-operation. + * @param c The second parameter of the OR-operation. + */ +static inline void _Processor_mask_Or( + Processor_mask *a, + const Processor_mask *b, + const Processor_mask *c +) +{ + __BIT_OR2( CPU_MAXIMUM_PROCESSORS, a, b, c ); +} + +/** + * @brief Performs a bitwise a = b ^ c. + * + * @param[out] a The processor mask that is set by this operation. + * @param b The first parameter of the XOR-operation. + * @param c The second parameter of the XOR-operation. + */ +static inline void _Processor_mask_Xor( + Processor_mask *a, + const Processor_mask *b, + const Processor_mask *c +) +{ + __BIT_XOR2( CPU_MAXIMUM_PROCESSORS, a, b, c ); +} + +/** + * @brief Gets the number of set bits in the processor mask. + * + * @param a The processor mask of which the set bits are counted. + * + * @return The number of set bits in @a a. + */ +static inline uint32_t _Processor_mask_Count( const Processor_mask *a ) +{ + return (uint32_t) __BIT_COUNT( CPU_MAXIMUM_PROCESSORS, a ); +} + +/** + * @brief Finds the last set of the processor mask. + * + * @param a The processor mask wo find the last set of. + * + * @return The last set of @a a. + */ +static inline uint32_t _Processor_mask_Find_last_set( const Processor_mask *a ) +{ + return (uint32_t) __BIT_FLS( CPU_MAXIMUM_PROCESSORS, a ); +} + +/** + * @brief Returns the subset of 32 processors containing the specified index as + * an unsigned 32-bit integer. + * + * @param mask The processor mask. + * @param index The specified index. + * + * @return The subset containing the specified index as an unsigned 32-bit integer. + */ +static inline uint32_t _Processor_mask_To_uint32_t( + const Processor_mask *mask, + uint32_t index +) +{ + long bits = mask->__bits[ index / _BITSET_BITS ]; + + return (uint32_t) ( bits >> ( 32 * ( ( index % _BITSET_BITS ) / 32 ) ) ); +} + +/** + * @brief Creates a processor set from an unsigned 32-bit integer relative to + * the specified index. + * + * @param[out] mask The mask that is created. + * @param bits The bits for creating the mask. + * @param index The index to which the mask is relative. + */ +static inline void _Processor_mask_From_uint32_t( + Processor_mask *mask, + uint32_t bits, + uint32_t index +) +{ + _Processor_mask_Zero( mask ); + mask->__bits[ __bitset_words( index ) ] = ((long) bits) << (32 * (index % _BITSET_BITS) / 32); +} + +/** + * @brief Creates a processor set from the specified index. + * + * @param[out] The mask that is created. + * @param index The specified index. + */ +static inline void _Processor_mask_From_index( + Processor_mask *mask, + uint32_t index +) +{ + __BIT_SETOF( CPU_MAXIMUM_PROCESSORS, (int) index, mask ); +} + +typedef enum { + PROCESSOR_MASK_COPY_LOSSLESS, + PROCESSOR_MASK_COPY_PARTIAL_LOSS, + PROCESSOR_MASK_COPY_COMPLETE_LOSS, + PROCESSOR_MASK_COPY_INVALID_SIZE +} Processor_mask_Copy_status; + +/** + * @brief Checks if the copy status guarantees at most partial loss. + * + * @param status The copy status to check. + * + * @retval true At most partial loss can be guaranteed. + * @retval false The status indicates more than partial loss. + */ +static inline bool _Processor_mask_Is_at_most_partial_loss( + Processor_mask_Copy_status status +) +{ + return (unsigned int) status <= PROCESSOR_MASK_COPY_PARTIAL_LOSS; +} + +/** + * @brief Copies one mask to another. + * + * @param[out] dst The destination of the copy operation. + * @param dst_size The size of @a dst. + * @param src The source of the copy operation. + * @param src_size The size of @a src. + * + * @retval PROCESSOR_MASK_COPY_LOSSLESS It is guaranteed that the copy + * operation is lossless. + * @retval PROCESSOR_MASK_COPY_PARTIAL_LOSS Partial loss happened due + * to the sizes of @a src and @a dst. + * @retval PROCESSOR_MASK_COPY_COMPLETE_LOSS Complete loss happened due + * to the sizes of @a src and @a dst. + * @retval PROCESSOR_MASK_COPY_INVALID_SIZE One of the arguments sizes + * is invalid (bigger than the size of a long). + */ +Processor_mask_Copy_status _Processor_mask_Copy( + long *dst, + size_t dst_size, + const long *src, + size_t src_size +); + +/** + * @brief Copies one mask to another. + * + * @param src The source for the copy operation. + * @param dst_size The size of @a dst. + * @param[out] dst The destination for the copy operation. + * + * @retval PROCESSOR_MASK_COPY_LOSSLESS It is guaranteed that the copy + * operation is lossless. + * @retval PROCESSOR_MASK_COPY_PARTIAL_LOSS Partial loss happened due + * to the sizes of @a src and @a dst. + * @retval PROCESSOR_MASK_COPY_COMPLETE_LOSS Complete loss happened due + * to the sizes of @a src and @a dst. + * @retval PROCESSOR_MASK_COPY_INVALID_SIZE One of the arguments sizes + * is invalid (bigger than the size of a long). + */ +static inline Processor_mask_Copy_status _Processor_mask_To_cpu_set_t( + const Processor_mask *src, + size_t dst_size, + cpu_set_t *dst +) +{ + return _Processor_mask_Copy( + &dst->__bits[ 0 ], + dst_size, + &src->__bits[ 0 ], + sizeof( *src ) + ); +} + +/** + * @brief Copies one mask to another. + * + * @param src The source for the copy operation. + * @param src_size The size of @a src. + * @param[out] dst The destination for the copy operation. + * + * @retval PROCESSOR_MASK_COPY_LOSSLESS It is guaranteed that the copy + * operation is lossless. + * @retval PROCESSOR_MASK_COPY_PARTIAL_LOSS Partial loss happened due + * to the sizes of @a src and @a dst. + * @retval PROCESSOR_MASK_COPY_COMPLETE_LOSS Complete loss happened due + * to the sizes of @a src and @a dst. + * @retval PROCESSOR_MASK_COPY_INVALID_SIZE One of the arguments sizes + * is invalid (bigger than the size of a long). + */ +static inline Processor_mask_Copy_status _Processor_mask_From_cpu_set_t( + Processor_mask *dst, + size_t src_size, + const cpu_set_t *src +) +{ + return _Processor_mask_Copy( + &dst->__bits[ 0 ], + sizeof( *dst ), + &src->__bits[ 0 ], + src_size + ); +} + +extern const Processor_mask _Processor_mask_The_one_and_only; + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_PROCESSORMASKIMPL_H */ diff --git a/cpukit/include/rtems/score/profiling.h b/cpukit/include/rtems/score/profiling.h index 71bd797158..af26970dcd 100644 --- a/cpukit/include/rtems/score/profiling.h +++ b/cpukit/include/rtems/score/profiling.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 2014 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_PROFILING @@ -116,10 +129,7 @@ static inline void _Profiling_Thread_dispatch_enable( if ( new_thread_dispatch_disable_level == 0 ) { Per_CPU_Stats *stats = &cpu->Stats; CPU_Counter_ticks now = _CPU_Counter_read(); - CPU_Counter_ticks delta = _CPU_Counter_difference( - now, - stats->thread_dispatch_disabled_instant - ); + CPU_Counter_ticks delta = now - stats->thread_dispatch_disabled_instant; stats->total_thread_dispatch_disabled_time += delta; diff --git a/cpukit/include/rtems/score/protectedheap.h b/cpukit/include/rtems/score/protectedheap.h index a8b9718ac3..287108568a 100644 --- a/cpukit/include/rtems/score/protectedheap.h +++ b/cpukit/include/rtems/score/protectedheap.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_PROTECTED_HEAP_H @@ -46,7 +65,7 @@ extern "C" { * @param area_size The size of the heap area. * @param page_size The page size for the heap. */ -RTEMS_INLINE_ROUTINE uintptr_t _Protected_heap_Initialize( +static inline uintptr_t _Protected_heap_Initialize( Heap_Control *heap, void *area_begin, uintptr_t area_size, @@ -112,7 +131,7 @@ void *_Protected_heap_Allocate_aligned_with_boundary( * @retval pointer The starting address of the allocated memory area. * @retval NULL No memory is available of the parameters are inconsistent. */ -RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate_aligned( +static inline void *_Protected_heap_Allocate_aligned( Heap_Control *heap, uintptr_t size, uintptr_t alignment @@ -135,7 +154,7 @@ RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate_aligned( * @retval pointer The starting address of the allocated memory area. * @retval NULL No memory is available of the parameters are inconsistent. */ -RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate( +static inline void *_Protected_heap_Allocate( Heap_Control *heap, uintptr_t size ) @@ -144,59 +163,6 @@ RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate( } /** - * @brief Returns the size of the allocatable memory area. - * - * The size value may be greater than the initially requested size in - * _Heap_Allocate_aligned_with_boundary(). - * - * Inappropriate values for @a addr will not corrupt the heap, but may yield - * invalid size values. - * - * This method first locks the allocator and after the operation, unlocks it again. - * - * @param heap The heap to operate upon. - * @param addr The starting address of the allocatable memory area. - * @param[out] size Stores the size of the allocatable memory area after the method call. - * - * @retval true The operation was successful. - * @retval false The operation was not successful. - */ -bool _Protected_heap_Get_block_size( - Heap_Control *heap, - void *addr, - uintptr_t *size -); - -/** - * @brief Resizes the block of the allocated memory area. - * - * Inappropriate values for @a addr may corrupt the heap. - * - * This method first locks the allocator and after the resize, unlocks it again. - * - * @param[in, out] heap The heap to operate upon. - * @param addr The starting address of the allocated memory area to be resized. - * @param size The least possible size for the new memory area. Resize may be - * impossible and depends on the current heap usage. - * @param[out] old_size Stores the size available for allocation in the current - * block before the resize after the method call. - * @param[out] new_size Stores the size available for allocation in the resized - * block after the method call. In the case of an unsuccessful resize, - * zero is returned in this parameter - * - * @retval HEAP_RESIZE_SUCCESSFUL The resize was successful. - * @retval HEAP_RESIZE_UNSATISFIED The least possible size @a size was too big. - * Resize not possible. - * @retval HEAP_RESIZE_FATAL_ERROR The block starting at @a addr is not part of - * the heap. - */ -bool _Protected_heap_Resize_block( - Heap_Control *heap, - void *addr, - uintptr_t size -); - -/** * @brief Frees the allocated memory area. * * Inappropriate values for @a addr may corrupt the heap. This method first locks @@ -226,22 +192,6 @@ bool _Protected_heap_Free( Heap_Control *heap, void *addr ); bool _Protected_heap_Walk( Heap_Control *heap, int source, bool dump ); /** - * @brief Iterates over all blocks of the heap. - * - * This method first locks the allocator and after the operation, unlocks it again. - * - * @param[in, out] heap The heap to iterate over. - * @param visitor This will be called for each heap block with - * the argument @a visitor_arg. - * @param[in, out] visitor_arg The argument for all calls of @a visitor. - */ -void _Protected_heap_Iterate( - Heap_Control *heap, - Heap_Block_visitor visitor, - void *visitor_arg -); - -/** * @brief Returns information about used and free blocks for the heap. * * This method first locks the allocator and after the operation, unlocks it again. diff --git a/cpukit/include/rtems/score/rbtree.h b/cpukit/include/rtems/score/rbtree.h index 6b0674eecc..253ef296bc 100644 --- a/cpukit/include/rtems/score/rbtree.h +++ b/cpukit/include/rtems/score/rbtree.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* * Copyright (c) 2010 Gedare Bloom. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_RBTREE_H @@ -84,7 +103,7 @@ typedef RB_HEAD(RBTree_Control, RBTree_Node) RBTree_Control; * * @see _RBTree_Is_node_off_tree(). */ -RTEMS_INLINE_ROUTINE void _RBTree_Set_off_tree( RBTree_Node *the_node ) +static inline void _RBTree_Set_off_tree( RBTree_Node *the_node ) { RB_COLOR( the_node, Node ) = -1; } @@ -99,7 +118,7 @@ RTEMS_INLINE_ROUTINE void _RBTree_Set_off_tree( RBTree_Node *the_node ) * * @see _RBTree_Set_off_tree(). */ -RTEMS_INLINE_ROUTINE bool _RBTree_Is_node_off_tree( +static inline bool _RBTree_Is_node_off_tree( const RBTree_Node *the_node ) { @@ -125,7 +144,7 @@ void _RBTree_Insert_color( * * @param[out] the_node The red-black tree node to initialize. */ -RTEMS_INLINE_ROUTINE void _RBTree_Initialize_node( RBTree_Node *the_node ) +static inline void _RBTree_Initialize_node( RBTree_Node *the_node ) { #if defined(RTEMS_DEBUG) _RBTree_Set_off_tree( the_node ); @@ -141,7 +160,7 @@ RTEMS_INLINE_ROUTINE void _RBTree_Initialize_node( RBTree_Node *the_node ) * @param[out] parent The parent node. * @param[out] link The child node link of the parent node. */ -RTEMS_INLINE_ROUTINE void _RBTree_Add_child( +static inline void _RBTree_Add_child( RBTree_Node *child, RBTree_Node *parent, RBTree_Node **link @@ -202,7 +221,7 @@ RTEMS_INLINE_ROUTINE void _RBTree_Add_child( * } * @endcode */ -RTEMS_INLINE_ROUTINE void _RBTree_Insert_with_parent( +static inline void _RBTree_Insert_with_parent( RBTree_Control *the_rbtree, RBTree_Node *the_node, RBTree_Node *parent, @@ -242,7 +261,7 @@ void _RBTree_Extract( * * @see _RBTree_Is_root(). */ -RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Root( +static inline RBTree_Node *_RBTree_Root( const RBTree_Control *the_rbtree ) { @@ -257,7 +276,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Root( * @retval pointer Pointer to the root node. * @retval NULL The tree is empty. */ -RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Root_reference( +static inline RBTree_Node **_RBTree_Root_reference( RBTree_Control *the_rbtree ) { @@ -272,7 +291,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Root_reference( * @retval pointer Pointer to the root node. * @retval NULL The tree is empty. */ -RTEMS_INLINE_ROUTINE RBTree_Node * const *_RBTree_Root_const_reference( +static inline RBTree_Node * const *_RBTree_Root_const_reference( const RBTree_Control *the_rbtree ) { @@ -291,7 +310,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node * const *_RBTree_Root_const_reference( * @retval parent The parent of this node. * @retval undefined The node is the root node or not part of a tree. */ -RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Parent( +static inline RBTree_Node *_RBTree_Parent( const RBTree_Node *the_node ) { @@ -307,7 +326,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Parent( * * @return This method returns the left node on the rbtree. */ -RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Left( +static inline RBTree_Node *_RBTree_Left( const RBTree_Node *the_node ) { @@ -322,7 +341,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Left( * * @return This method returns a reference to the left child pointer on the rbtree. */ -RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Left_reference( +static inline RBTree_Node **_RBTree_Left_reference( RBTree_Node *the_node ) { @@ -338,7 +357,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Left_reference( * * @return This method returns the right node on the rbtree. */ -RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Right( +static inline RBTree_Node *_RBTree_Right( const RBTree_Node *the_node ) { @@ -353,7 +372,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Right( * * @return This method returns a reference to the right child pointer on the rbtree. */ -RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Right_reference( +static inline RBTree_Node **_RBTree_Right_reference( RBTree_Node *the_node ) { @@ -371,7 +390,7 @@ RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Right_reference( * @retval true There are no nodes on @a the_rbtree. * @retval false There are nodes on @a the_rbtree. */ -RTEMS_INLINE_ROUTINE bool _RBTree_Is_empty( +static inline bool _RBTree_Is_empty( const RBTree_Control *the_rbtree ) { @@ -392,7 +411,7 @@ RTEMS_INLINE_ROUTINE bool _RBTree_Is_empty( * * @see _RBTree_Root(). */ -RTEMS_INLINE_ROUTINE bool _RBTree_Is_root( +static inline bool _RBTree_Is_root( const RBTree_Node *the_node ) { @@ -406,7 +425,7 @@ RTEMS_INLINE_ROUTINE bool _RBTree_Is_root( * * @param[out] the_rbtree The rbtree to initialize. */ -RTEMS_INLINE_ROUTINE void _RBTree_Initialize_empty( +static inline void _RBTree_Initialize_empty( RBTree_Control *the_rbtree ) { @@ -420,7 +439,7 @@ RTEMS_INLINE_ROUTINE void _RBTree_Initialize_empty( * @param[out] the_rbtree The red-black tree control. * @param[out] the_node The one and only node. */ -RTEMS_INLINE_ROUTINE void _RBTree_Initialize_one( +static inline void _RBTree_Initialize_one( RBTree_Control *the_rbtree, RBTree_Node *the_node ) @@ -504,7 +523,7 @@ void _RBTree_Replace_node( * @retval false The inserted node is not the new minimum node according to the * specified less order function. */ -RTEMS_INLINE_ROUTINE bool _RBTree_Insert_inline( +static inline bool _RBTree_Insert_inline( RBTree_Control *the_rbtree, RBTree_Node *the_node, const void *key, @@ -553,7 +572,7 @@ RTEMS_INLINE_ROUTINE bool _RBTree_Insert_inline( * @retval object An object with the specified key. * @retval NULL No object with the specified key exists in the red-black tree. */ -RTEMS_INLINE_ROUTINE void *_RBTree_Find_inline( +static inline void *_RBTree_Find_inline( const RBTree_Control *the_rbtree, const void *key, bool ( *equal )( const void *, const RBTree_Node * ), diff --git a/cpukit/include/rtems/score/rbtreeimpl.h b/cpukit/include/rtems/score/rbtreeimpl.h index 597c24d771..eca605ba6d 100644 --- a/cpukit/include/rtems/score/rbtreeimpl.h +++ b/cpukit/include/rtems/score/rbtreeimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* * Copyright (c) 2010-2012 Gedare Bloom. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_RBTREEIMPL_H @@ -31,6 +50,32 @@ extern "C" { */ /** + * @brief Appends the node to the red-black tree. + * + * The appended node is the new maximum node of the tree. The caller shall + * ensure that the appended node is indeed the maximum node with respect to the + * tree order. + * + * @param[in, out] the_rbtree is the red-black tree control. + * + * @param the_node[out] is the node to append. + */ +void _RBTree_Append( RBTree_Control *the_rbtree, RBTree_Node *the_node ); + +/** + * @brief Prepends the node to the red-black tree. + * + * The prepended node is the new minimum node of the tree. The caller shall + * ensure that the prepended node is indeed the minimum node with respect to the + * tree order. + * + * @param[in, out] the_rbtree is the red-black tree control. + * + * @param the_node[out] is the node to prepend. + */ +void _RBTree_Prepend( RBTree_Control *the_rbtree, RBTree_Node *the_node ); + +/** * @brief Red-black tree visitor. * * @param[in] node The node. diff --git a/cpukit/include/rtems/score/scheduler.h b/cpukit/include/rtems/score/scheduler.h index df9477fbeb..d0fe2a8626 100644 --- a/cpukit/include/rtems/score/scheduler.h +++ b/cpukit/include/rtems/score/scheduler.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * Copyright (C) 2010 Gedare Bloom. * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULER_H @@ -135,6 +154,61 @@ typedef struct { ); /** + * @brief Makes the node sticky. + * + * This operation is used by _Thread_Priority_update_and_make_sticky(). It + * is only called for the scheduler node of the home scheduler. + * + * Uniprocessor schedulers schould provide + * _Scheduler_default_Sticky_do_nothing() for this operation. + * + * SMP schedulers should provide this operation using + * _Scheduler_SMP_Make_sticky(). + * + * The make and clean sticky operations are an optimization to simplify the + * control flow in the update priority operation. The update priority + * operation is used for all scheduler nodes and not just the scheduler node + * of home schedulers. The update priority operation is a commonly used + * operations together with block and unblock. The make and clean sticky + * operations are used only in specific scenarios. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to make sticky. + */ + void ( *make_sticky )( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node + ); + + /** + * @brief Cleans the sticky property from the node. + * + * This operation is used by _Thread_Priority_update_and_clean_sticky(). It + * is only called for the scheduler node of the home scheduler. + * + * Uniprocessor schedulers schould provide + * _Scheduler_default_Sticky_do_nothing() for this operation. + * + * SMP schedulers should provide this operation using + * _Scheduler_SMP_Clean_sticky(). + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to clean the sticky property. + */ + void ( *clean_sticky )( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node + ); + + /** * @brief Pin thread operation. * * @param[in] scheduler The scheduler instance of the specified processor. @@ -217,9 +291,6 @@ typedef struct { Thread_queue_Context * ); - /** @see _Scheduler_Tick() */ - void ( *tick )( const Scheduler_Control *, Thread_Control * ); - /** @see _Scheduler_Start_idle() */ void ( *start_idle )( const Scheduler_Control *, @@ -245,12 +316,12 @@ typedef struct { * this structure at the begin of its context structure. */ typedef struct Scheduler_Context { +#if defined(RTEMS_SMP) /** * @brief Lock to protect this scheduler instance. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; -#if defined(RTEMS_SMP) /** * @brief The set of processors owned by this scheduler instance. */ @@ -403,6 +474,24 @@ Priority_Control _Scheduler_default_Unmap_priority( /** * @brief Does nothing. * + * This default implementation for the make and clean sticky operations + * should be used by uniprocessor schedulers if SMP support is enabled. + * + * @param scheduler is an unused parameter. + * + * @param the_thread is an unused parameter. + * + * @param node is an unused parameter. + */ + void _Scheduler_default_Sticky_do_nothing( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node + ); + + /** + * @brief Does nothing. + * * This default implementation for the thread pin or unpin operations should * be used by uniprocessor schedulers if SMP support is enabled. * @@ -462,6 +551,8 @@ Priority_Control _Scheduler_default_Unmap_priority( NULL, \ NULL, \ NULL, \ + _Scheduler_default_Sticky_do_nothing, \ + _Scheduler_default_Sticky_do_nothing, \ _Scheduler_default_Pin_or_unpin_do_nothing, \ _Scheduler_default_Pin_or_unpin_do_nothing, \ NULL, \ @@ -544,20 +635,6 @@ void _Scheduler_default_Cancel_job( ); /** - * @brief Performs tick operations depending on the CPU budget algorithm for - * each executing thread. - * - * This routine is invoked as part of processing each clock tick. - * - * @param scheduler The scheduler. - * @param[in, out] executing An executing thread. - */ -void _Scheduler_default_Tick( - const Scheduler_Control *scheduler, - Thread_Control *executing -); - -/** * @brief Starts an idle thread. * * @param scheduler This parameter is unused. diff --git a/cpukit/include/rtems/score/schedulercbs.h b/cpukit/include/rtems/score/schedulercbs.h index 4b7efc8340..a45a7fe6b8 100644 --- a/cpukit/include/rtems/score/schedulercbs.h +++ b/cpukit/include/rtems/score/schedulercbs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * Copryight (c) 2011 Petr Benes. * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERCBS_H @@ -67,7 +86,6 @@ extern "C" { _Scheduler_default_Node_destroy, /* node destroy entry point */ \ _Scheduler_CBS_Release_job, /* new period of task */ \ _Scheduler_CBS_Cancel_job, /* cancel period of task */ \ - _Scheduler_default_Tick, /* tick entry point */ \ _Scheduler_default_Start_idle /* start idle entry point */ \ SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \ } @@ -394,15 +412,9 @@ int _Scheduler_CBS_Set_parameters ( ); /** - * @brief Invoked when a limited time quantum is exceeded. - * - * This routine is invoked when a limited time quantum is exceeded. - * - * @param the_thread The thread that exceeded a limited time quantum. + * @brief These are the CBS CPU budget operations. */ -void _Scheduler_CBS_Budget_callout( - Thread_Control *the_thread -); +extern const Thread_CPU_budget_operations _Scheduler_CBS_Budget; /** * @brief Initializes a CBS specific scheduler node of @a the_thread. diff --git a/cpukit/include/rtems/score/schedulercbsimpl.h b/cpukit/include/rtems/score/schedulercbsimpl.h index 2c8a20ea42..95e19f149d 100644 --- a/cpukit/include/rtems/score/schedulercbsimpl.h +++ b/cpukit/include/rtems/score/schedulercbsimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 2014 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERCBSIMPL_H @@ -44,7 +57,7 @@ extern "C" { * * @return Pointer to the scheduler node of @a the_thread. */ -RTEMS_INLINE_ROUTINE Scheduler_CBS_Node *_Scheduler_CBS_Thread_get_node( +static inline Scheduler_CBS_Node *_Scheduler_CBS_Thread_get_node( Thread_Control *the_thread ) { @@ -58,7 +71,7 @@ RTEMS_INLINE_ROUTINE Scheduler_CBS_Node *_Scheduler_CBS_Thread_get_node( * * @return CBS Node pointer to @a node. */ -RTEMS_INLINE_ROUTINE Scheduler_CBS_Node *_Scheduler_CBS_Node_downcast( +static inline Scheduler_CBS_Node *_Scheduler_CBS_Node_downcast( Scheduler_Node *node ) { diff --git a/cpukit/include/rtems/score/scheduleredf.h b/cpukit/include/rtems/score/scheduleredf.h index 9e643b93eb..8c50a3ab1e 100644 --- a/cpukit/include/rtems/score/scheduleredf.h +++ b/cpukit/include/rtems/score/scheduleredf.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * Copryight (c) 2011 Petr Benes. * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULEREDF_H @@ -66,7 +85,6 @@ extern "C" { _Scheduler_default_Node_destroy, /* node destroy entry point */ \ _Scheduler_EDF_Release_job, /* new period of task */ \ _Scheduler_EDF_Cancel_job, /* cancel period of task */ \ - _Scheduler_default_Tick, /* tick entry point */ \ _Scheduler_default_Start_idle /* start idle entry point */ \ SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \ } diff --git a/cpukit/include/rtems/score/scheduleredfimpl.h b/cpukit/include/rtems/score/scheduleredfimpl.h index f87102d913..8aa0388537 100644 --- a/cpukit/include/rtems/score/scheduleredfimpl.h +++ b/cpukit/include/rtems/score/scheduleredfimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,16 +13,33 @@ * Copryight (c) 2011 Petr Benes. * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULEREDFIMPL_H #define _RTEMS_SCORE_SCHEDULEREDFIMPL_H #include <rtems/score/scheduleredf.h> -#include <rtems/score/schedulerimpl.h> +#include <rtems/score/scheduleruniimpl.h> #ifdef __cplusplus extern "C" { @@ -48,7 +67,7 @@ extern "C" { * * @return The scheduler context of @a scheduler. */ -RTEMS_INLINE_ROUTINE Scheduler_EDF_Context * +static inline Scheduler_EDF_Context * _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler ) { return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler ); @@ -61,7 +80,7 @@ RTEMS_INLINE_ROUTINE Scheduler_EDF_Context * * * @return The EDF scheduler node of @a the_thread. */ -RTEMS_INLINE_ROUTINE Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node( +static inline Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node( Thread_Control *the_thread ) { @@ -75,7 +94,7 @@ RTEMS_INLINE_ROUTINE Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node( * * @return The corresponding scheduler EDF node. */ -RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast( +static inline Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast( Scheduler_Node *node ) { @@ -91,7 +110,7 @@ RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast( * @retval true @a left is less than the priority of @a right. * @retval false @a left is greater or equal than the priority of @a right. */ -RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less( +static inline bool _Scheduler_EDF_Less( const void *left, const RBTree_Node *right ) @@ -101,7 +120,7 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less( Priority_Control prio_left; Priority_Control prio_right; - the_left = left; + the_left = (const Priority_Control *) left; the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node ); prio_left = *the_left; @@ -119,7 +138,7 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less( * @retval true @a left is less or equal than the priority of @a right. * @retval false @a left is greater than the priority of @a right. */ -RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Priority_less_equal( +static inline bool _Scheduler_EDF_Priority_less_equal( const void *left, const RBTree_Node *right ) @@ -129,7 +148,7 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Priority_less_equal( Priority_Control prio_left; Priority_Control prio_right; - the_left = left; + the_left = (const Priority_Control *) left; the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node ); prio_left = *the_left; @@ -146,7 +165,7 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Priority_less_equal( * @param node The node to be inserted. * @param insert_priority The priority with which the node will be inserted. */ -RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue( +static inline void _Scheduler_EDF_Enqueue( Scheduler_EDF_Context *context, Scheduler_EDF_Node *node, Priority_Control insert_priority @@ -166,7 +185,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue( * @param[in, out] context The context to extract the node from. * @param[in, out] node The node to extract. */ -RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract( +static inline void _Scheduler_EDF_Extract( Scheduler_EDF_Context *context, Scheduler_EDF_Node *node ) @@ -181,7 +200,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract( * @param the_thread The thread is not used in this method. * @param[in, out] node The node to be extracted. */ -RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract_body( +static inline void _Scheduler_EDF_Extract_body( const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node @@ -197,30 +216,23 @@ RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract_body( } /** - * @brief Schedules the next ready thread as the heir. + * @brief Gets the highest priority ready thread of the scheduler. * - * @param scheduler The scheduler instance to schedule the minimum of the context of. - * @param the_thread This parameter is not used. - * @param force_dispatch Indicates whether the current heir is blocked even if it is - * not set as preemptible. + * @param scheduler is the scheduler. */ -RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - bool force_dispatch +static inline Thread_Control *_Scheduler_EDF_Get_highest_ready( + const Scheduler_Control *scheduler ) { Scheduler_EDF_Context *context; RBTree_Node *first; Scheduler_EDF_Node *node; - (void) the_thread; - context = _Scheduler_EDF_Get_context( scheduler ); first = _RBTree_Minimum( &context->Ready ); node = RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node ); - _Scheduler_Update_heir( node->Base.owner, force_dispatch ); + return node->Base.owner; } /** @} */ diff --git a/cpukit/include/rtems/score/scheduleredfsmp.h b/cpukit/include/rtems/score/scheduleredfsmp.h index 1841aa4a7b..f915154241 100644 --- a/cpukit/include/rtems/score/scheduleredfsmp.h +++ b/cpukit/include/rtems/score/scheduleredfsmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,11 +10,28 @@ */ /* - * Copyright (c) 2017, 2018 embedded brains GmbH. + * Copyright (C) 2017, 2018 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULEREDFSMP_H @@ -79,9 +98,18 @@ typedef struct { RBTree_Control Queue; /** - * @brief The scheduled thread of the corresponding processor. + * @brief If this member is not NULL, then it references the scheduled thread + * affine only to the corresponding processor, otherwise the processor is + * allocated to a thread which may execute on any of the processors owned + * by the scheduler. */ - Scheduler_EDF_SMP_Node *scheduled; + Scheduler_EDF_SMP_Node *affine_scheduled; + + /** + * @brief This member references the thread allocated to the corresponding + * processor. + */ + Scheduler_EDF_SMP_Node *allocated; } Scheduler_EDF_SMP_Ready_queue; typedef struct { @@ -120,6 +148,8 @@ typedef struct { _Scheduler_EDF_SMP_Ask_for_help, \ _Scheduler_EDF_SMP_Reconsider_help_request, \ _Scheduler_EDF_SMP_Withdraw_node, \ + _Scheduler_EDF_SMP_Make_sticky, \ + _Scheduler_EDF_SMP_Clean_sticky, \ _Scheduler_EDF_SMP_Pin, \ _Scheduler_EDF_SMP_Unpin, \ _Scheduler_EDF_SMP_Add_processor, \ @@ -128,7 +158,6 @@ typedef struct { _Scheduler_default_Node_destroy, \ _Scheduler_EDF_Release_job, \ _Scheduler_EDF_Cancel_job, \ - _Scheduler_default_Tick, \ _Scheduler_EDF_SMP_Start_idle, \ _Scheduler_EDF_SMP_Set_affinity \ } @@ -241,6 +270,36 @@ void _Scheduler_EDF_SMP_Withdraw_node( ); /** + * @brief Makes the node sticky. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to make sticky. + */ +void _Scheduler_EDF_SMP_Make_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** + * @brief Cleans the sticky property from the node. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to clean the sticky property. + */ +void _Scheduler_EDF_SMP_Clean_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** * @brief Pin thread operation. * * @param scheduler The scheduler instance of the specified processor. diff --git a/cpukit/include/rtems/score/schedulerimpl.h b/cpukit/include/rtems/score/schedulerimpl.h index 98f8e337fd..2ca3e6e8b7 100644 --- a/cpukit/include/rtems/score/schedulerimpl.h +++ b/cpukit/include/rtems/score/schedulerimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,11 +12,28 @@ /* * Copyright (C) 2010 Gedare Bloom. * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * Copyright (c) 2014, 2017 embedded brains GmbH - * - * 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. + * Copyright (C) 2014, 2017 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERIMPL_H @@ -82,7 +101,7 @@ void _Scheduler_Handler_initialization( void ); * * @return The context of @a scheduler. */ -RTEMS_INLINE_ROUTINE Scheduler_Context *_Scheduler_Get_context( +static inline Scheduler_Context *_Scheduler_Get_context( const Scheduler_Control *scheduler ) { @@ -96,7 +115,7 @@ RTEMS_INLINE_ROUTINE Scheduler_Context *_Scheduler_Get_context( * * @return The scheduler for the cpu. */ -RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU( +static inline const Scheduler_Control *_Scheduler_Get_by_CPU( const Per_CPU_Control *cpu ) { @@ -116,7 +135,7 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU( * @param lock_context The lock context to use for * _Scheduler_Release_critical(). */ -RTEMS_INLINE_ROUTINE void _Scheduler_Acquire_critical( +static inline void _Scheduler_Acquire_critical( const Scheduler_Control *scheduler, ISR_lock_Context *lock_context ) @@ -140,7 +159,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Acquire_critical( * @param lock_context The lock context used for * _Scheduler_Acquire_critical(). */ -RTEMS_INLINE_ROUTINE void _Scheduler_Release_critical( +static inline void _Scheduler_Release_critical( const Scheduler_Control *scheduler, ISR_lock_Context *lock_context ) @@ -166,7 +185,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Release_critical( * @return True if the non-preempt mode for threads is supported by the * scheduler, otherwise false. */ -RTEMS_INLINE_ROUTINE bool _Scheduler_Is_non_preempt_mode_supported( +static inline bool _Scheduler_Is_non_preempt_mode_supported( const Scheduler_Control *scheduler ) { @@ -174,30 +193,6 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_Is_non_preempt_mode_supported( } #endif -#if defined(RTEMS_SMP) -void _Scheduler_Request_ask_for_help( Thread_Control *the_thread ); - -/** - * @brief Registers an ask for help request if necessary. - * - * The actual ask for help operation is carried out during - * _Thread_Do_dispatch() on a processor related to the thread. This yields a - * better separation of scheduler instances. A thread of one scheduler - * instance should not be forced to carry out too much work for threads on - * other scheduler instances. - * - * @param the_thread The thread in need for help. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Ask_for_help( Thread_Control *the_thread ) -{ - _Assert( _Thread_State_is_owner( the_thread ) ); - - if ( the_thread->Scheduler.helping_nodes > 0 ) { - _Scheduler_Request_ask_for_help( the_thread ); - } -} -#endif - /** * The preferred method to add a new scheduler is to define the jump table * entries and add a case to the _Scheduler_Initialize routine. @@ -221,7 +216,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Ask_for_help( Thread_Control *the_thread ) * * @param the_thread The thread which state changed previously. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( Thread_Control *the_thread ) +static inline void _Scheduler_Schedule( Thread_Control *the_thread ) { const Scheduler_Control *scheduler; ISR_lock_Context lock_context; @@ -242,7 +237,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( Thread_Control *the_thread ) * * @param the_thread The yielding thread. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Yield( Thread_Control *the_thread ) +static inline void _Scheduler_Yield( Thread_Control *the_thread ) { const Scheduler_Control *scheduler; ISR_lock_Context lock_context; @@ -267,7 +262,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Yield( Thread_Control *the_thread ) * * @param the_thread The thread. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Block( Thread_Control *the_thread ) +static inline void _Scheduler_Block( Thread_Control *the_thread ) { #if defined(RTEMS_SMP) Chain_Node *node; @@ -329,7 +324,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Block( Thread_Control *the_thread ) * * @see _Scheduler_Node_get_priority(). */ -RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( Thread_Control *the_thread ) +static inline void _Scheduler_Unblock( Thread_Control *the_thread ) { Scheduler_Node *scheduler_node; const Scheduler_Control *scheduler; @@ -364,7 +359,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( Thread_Control *the_thread ) * * @see _Scheduler_Node_get_priority(). */ -RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority( Thread_Control *the_thread ) +static inline void _Scheduler_Update_priority( Thread_Control *the_thread ) { #if defined(RTEMS_SMP) Chain_Node *node; @@ -405,65 +400,6 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority( Thread_Control *the_thread #endif } -#if defined(RTEMS_SMP) -/** - * @brief Changes the sticky level of the home scheduler node and propagates a - * priority change of a thread to the scheduler. - * - * @param the_thread The thread changing its priority or sticky level. - * - * @see _Scheduler_Update_priority(). - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Priority_and_sticky_update( - Thread_Control *the_thread, - int sticky_level_change -) -{ - Chain_Node *node; - const Chain_Node *tail; - Scheduler_Node *scheduler_node; - const Scheduler_Control *scheduler; - ISR_lock_Context lock_context; - - _Thread_Scheduler_process_requests( the_thread ); - - node = _Chain_First( &the_thread->Scheduler.Scheduler_nodes ); - scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); - scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); - - _Scheduler_Acquire_critical( scheduler, &lock_context ); - - scheduler_node->sticky_level += sticky_level_change; - _Assert( scheduler_node->sticky_level >= 0 ); - - ( *scheduler->Operations.update_priority )( - scheduler, - the_thread, - scheduler_node - ); - - _Scheduler_Release_critical( scheduler, &lock_context ); - - tail = _Chain_Immutable_tail( &the_thread->Scheduler.Scheduler_nodes ); - node = _Chain_Next( node ); - - while ( node != tail ) { - scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); - scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); - - _Scheduler_Acquire_critical( scheduler, &lock_context ); - ( *scheduler->Operations.update_priority )( - scheduler, - the_thread, - scheduler_node - ); - _Scheduler_Release_critical( scheduler, &lock_context ); - - node = _Chain_Next( node ); - } -} -#endif - /** * @brief Maps a thread priority from the user domain to the scheduler domain. * @@ -477,7 +413,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Priority_and_sticky_update( * * @return The corresponding thread priority of the scheduler domain is returned. */ -RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Map_priority( +static inline Priority_Control _Scheduler_Map_priority( const Scheduler_Control *scheduler, Priority_Control priority ) @@ -493,7 +429,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Map_priority( * * @return The corresponding thread priority of the user domain is returned. */ -RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Unmap_priority( +static inline Priority_Control _Scheduler_Unmap_priority( const Scheduler_Control *scheduler, Priority_Control priority ) @@ -514,7 +450,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Unmap_priority( * @param the_thread The thread of the scheduler node to initialize. * @param priority The thread priority. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize( +static inline void _Scheduler_Node_initialize( const Scheduler_Control *scheduler, Scheduler_Node *node, Thread_Control *the_thread, @@ -538,7 +474,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize( * @param scheduler The scheduler instance. * @param[out] node The scheduler node to destroy. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy( +static inline void _Scheduler_Node_destroy( const Scheduler_Control *scheduler, Scheduler_Node *node ) @@ -555,7 +491,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy( * @param queue_context The thread queue context to provide the set of * threads for _Thread_Priority_update(). */ -RTEMS_INLINE_ROUTINE void _Scheduler_Release_job( +static inline void _Scheduler_Release_job( Thread_Control *the_thread, Priority_Node *priority_node, uint64_t deadline, @@ -582,7 +518,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Release_job( * @param queue_context The thread queue context to provide the set of * threads for _Thread_Priority_update(). */ -RTEMS_INLINE_ROUTINE void _Scheduler_Cancel_job( +static inline void _Scheduler_Cancel_job( Thread_Control *the_thread, Priority_Node *priority_node, Thread_queue_Context *queue_context @@ -600,44 +536,6 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Cancel_job( } /** - * @brief Scheduler method invoked at each clock tick. - * - * This method is invoked at each clock tick to allow the scheduler - * implementation to perform any activities required. For the - * scheduler which support standard RTEMS features, this includes - * time-slicing management. - * - * @param cpu The cpu control for the operation. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Tick( const Per_CPU_Control *cpu ) -{ - const Scheduler_Control *scheduler; - Thread_Control *executing; - - scheduler = _Scheduler_Get_by_CPU( cpu ); - -#if defined(RTEMS_SMP) - if ( scheduler == NULL ) { - /* - * In SMP configurations, processors may be removed/added at runtime - * from/to a scheduler. There may be still clock interrupts on currently - * unassigned processors. - */ - return; - } -#endif - - /* - * Each online processor has at least an idle thread as the executing thread - * even in case it has currently no scheduler assigned. Clock interrupts on - * processors which are not online would be a severe bug of the Clock Driver. - */ - executing = _Per_CPU_Get_executing( cpu ); - _Assert( executing != NULL ); - ( *scheduler->Operations.tick )( scheduler, executing ); -} - -/** * @brief Starts the idle thread for a particular processor. * * @param scheduler The scheduler instance. @@ -646,7 +544,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Tick( const Per_CPU_Control *cpu ) * * @see _Thread_Create_idle(). */ -RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle( +static inline void _Scheduler_Start_idle( const Scheduler_Control *scheduler, Thread_Control *the_thread, Per_CPU_Control *cpu @@ -665,7 +563,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle( * @retval true The scheduler of the cpu is the given @a scheduler. * @retval false The scheduler of the cpu is not the given @a scheduler. */ -RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership( +static inline bool _Scheduler_Has_processor_ownership( const Scheduler_Control *scheduler, uint32_t cpu_index ) @@ -693,7 +591,7 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership( * * @return The processors of the context of the given scheduler. */ -RTEMS_INLINE_ROUTINE const Processor_mask *_Scheduler_Get_processors( +static inline const Processor_mask *_Scheduler_Get_processors( const Scheduler_Control *scheduler ) { @@ -734,7 +632,7 @@ Status_Control _Scheduler_Get_affinity( * @retval STATUS_INVALID_NUMBER The affinity is not a subset of the online * processors. */ -RTEMS_INLINE_ROUTINE Status_Control _Scheduler_default_Set_affinity_body( +static inline Status_Control _Scheduler_default_Set_affinity_body( const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node, @@ -771,47 +669,13 @@ Status_Control _Scheduler_Set_affinity( ); /** - * @brief Blocks the thread. - * - * @param scheduler The scheduler instance. - * @param the_thread The thread to block. - * @param node The corresponding scheduler node. - * @param extract Method to extract the thread. - * @param schedule Method for scheduling threads. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Generic_block( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node, - void ( *extract )( - const Scheduler_Control *, - Thread_Control *, - Scheduler_Node * - ), - void ( *schedule )( - const Scheduler_Control *, - Thread_Control *, - bool - ) -) -{ - ( *extract )( scheduler, the_thread, node ); - - /* TODO: flash critical section? */ - - if ( _Thread_Is_executing( the_thread ) || _Thread_Is_heir( the_thread ) ) { - ( *schedule )( scheduler, the_thread, true ); - } -} - -/** * @brief Gets the number of processors of the scheduler. * * @param scheduler The scheduler instance to get the number of processors of. * * @return The number of processors. */ -RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_processor_count( +static inline uint32_t _Scheduler_Get_processor_count( const Scheduler_Control *scheduler ) { @@ -833,7 +697,7 @@ RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_processor_count( * * @return The build id. */ -RTEMS_INLINE_ROUTINE Objects_Id _Scheduler_Build_id( uint32_t scheduler_index ) +static inline Objects_Id _Scheduler_Build_id( uint32_t scheduler_index ) { return _Objects_Build_id( OBJECTS_FAKE_OBJECTS_API, @@ -850,7 +714,7 @@ RTEMS_INLINE_ROUTINE Objects_Id _Scheduler_Build_id( uint32_t scheduler_index ) * * @return The scheduler index. */ -RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index_by_id( Objects_Id id ) +static inline uint32_t _Scheduler_Get_index_by_id( Objects_Id id ) { uint32_t minimum_id = _Scheduler_Build_id( 0 ); @@ -864,7 +728,7 @@ RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index_by_id( Objects_Id id ) * * @return The scheduler to the object id. */ -RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_id( +static inline const Scheduler_Control *_Scheduler_Get_by_id( Objects_Id id ) { @@ -886,7 +750,7 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_id( * * @return The index of the given scheduler. */ -RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index( +static inline uint32_t _Scheduler_Get_index( const Scheduler_Control *scheduler ) { @@ -895,26 +759,26 @@ RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index( #if defined(RTEMS_SMP) /** - * @brief Gets an idle thread from the scheduler instance. + * @brief Gets a scheduler node which is owned by an unused idle thread. * - * @param context The scheduler instance context. + * @param arg is the handler argument. * - * @return idle An idle thread for use. This function must always return an - * idle thread. If none is available, then this is a fatal error. + * @return Returns a scheduler node owned by an idle thread for use. This + * handler must always return a node. If none is available, then this is a + * fatal error. */ -typedef Thread_Control *( *Scheduler_Get_idle_thread )( - Scheduler_Context *context -); +typedef Scheduler_Node *( *Scheduler_Get_idle_node )( void *arg ); /** - * @brief Releases an idle thread to the scheduler instance for reuse. + * @brief Releases the scheduler node which is owned by an idle thread. + * + * @param node is the node to release. * - * @param context The scheduler instance context. - * @param idle The idle thread to release. + * @param arg is the handler argument. */ -typedef void ( *Scheduler_Release_idle_thread )( - Scheduler_Context *context, - Thread_Control *idle +typedef void ( *Scheduler_Release_idle_node )( + Scheduler_Node *node, + void *arg ); /** @@ -923,7 +787,7 @@ typedef void ( *Scheduler_Release_idle_thread )( * @param[out] the_thread The thread to change the state of. * @param new_state The new state for @a the_thread. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Thread_change_state( +static inline void _Scheduler_Thread_change_state( Thread_Control *the_thread, Thread_Scheduler_state new_state ) @@ -938,353 +802,122 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Thread_change_state( } /** - * @brief Sets the scheduler node's idle thread. + * @brief Uses an idle thread for the scheduler node. * - * @param[in, out] node The node to receive an idle thread. - * @param idle The idle thread control for the operation. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Set_idle_thread( - Scheduler_Node *node, - Thread_Control *idle -) -{ - _Assert( _Scheduler_Node_get_idle( node ) == NULL ); - _Assert( - _Scheduler_Node_get_owner( node ) == _Scheduler_Node_get_user( node ) - ); - - _Scheduler_Node_set_user( node, idle ); - node->idle = idle; -} - -/** - * @brief Uses an idle thread for this scheduler node. + * @param[in, out] node is the node which wants to use an idle thread. * - * A thread whose home scheduler node has a sticky level greater than zero may - * use an idle thread in the home scheduler instance in the case it executes - * currently in another scheduler instance or in the case it is in a blocking - * state. + * @param get_idle_node is the get idle node handler. * - * @param context The scheduler instance context. - * @param[in, out] node The node which wants to use the idle thread. - * @param cpu The processor for the idle thread. - * @param get_idle_thread Function to get an idle thread. + * @param arg is the handler argument. */ -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Use_idle_thread( - Scheduler_Context *context, - Scheduler_Node *node, - Per_CPU_Control *cpu, - Scheduler_Get_idle_thread get_idle_thread +static inline Thread_Control *_Scheduler_Use_idle_thread( + Scheduler_Node *node, + Scheduler_Get_idle_node get_idle_node, + void *arg ) { - Thread_Control *idle = ( *get_idle_thread )( context ); + Scheduler_Node *idle_node; + Thread_Control *idle; + + idle_node = ( *get_idle_node )( arg ); + idle = _Scheduler_Node_get_owner( idle_node ); + _Assert( idle->is_idle ); + _Scheduler_Node_set_idle_user( node, idle ); - _Scheduler_Set_idle_thread( node, idle ); - _Thread_Set_CPU( idle, cpu ); return idle; } /** - * @brief This enumeration defines what a scheduler should do with a node which - * could be scheduled. - */ -typedef enum { - SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE, - SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE, - SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK -} Scheduler_Try_to_schedule_action; - -/** - * @brief Tries to schedule the scheduler node. - * - * When a scheduler needs to schedule a node, it shall use this function to - * determine what it shall do with the node. The node replaces a victim node if - * it can be scheduled. - * - * This function uses the state of the node and the scheduler state of the owner - * thread to determine what shall be done. Each scheduler maintains its nodes - * independent of other schedulers. This function ensures that a thread is - * scheduled by at most one scheduler. If a node requires an executing thread - * due to some locking protocol and the owner thread is already scheduled by - * another scheduler, then an idle thread shall be attached to the node. - * - * @param[in, out] context is the scheduler context. - * @param[in, out] node is the node which could be scheduled. - * @param idle is an idle thread used by the victim node or NULL. - * @param get_idle_thread points to a function to get an idle thread. - * - * @retval SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE The node shall be scheduled. - * - * @retval SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE The node shall be - * scheduled and the provided idle thread shall be attached to the node. This - * action is returned, if the node cannot use the owner thread and shall use - * an idle thread instead. In this case, the idle thread is provided by the - * victim node. - * - * @retval SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK The node shall be blocked. This - * action is returned, if the owner thread is already scheduled by another - * scheduler. + * @brief Releases the idle thread used by the scheduler node. + * + * @param[in, out] node is the node which wants to release the idle thread. + * + * @param idle is the idle thread to release. + * + * @param release_idle_node is the release idle node handler. + * + * @param arg is the handler argument. */ -RTEMS_INLINE_ROUTINE Scheduler_Try_to_schedule_action -_Scheduler_Try_to_schedule_node( - Scheduler_Context *context, - Scheduler_Node *node, - const Thread_Control *idle, - Scheduler_Get_idle_thread get_idle_thread +static inline void _Scheduler_Release_idle_thread( + Scheduler_Node *node, + const Thread_Control *idle, + Scheduler_Release_idle_node release_idle_node, + void *arg ) { - ISR_lock_Context lock_context; - Scheduler_Try_to_schedule_action action; - Thread_Control *owner; + Thread_Control *owner; + Scheduler_Node *idle_node; - action = SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE; owner = _Scheduler_Node_get_owner( node ); - _Assert( _Scheduler_Node_get_user( node ) == owner ); - _Assert( _Scheduler_Node_get_idle( node ) == NULL ); - - _Thread_Scheduler_acquire_critical( owner, &lock_context ); - - if ( owner->Scheduler.state == THREAD_SCHEDULER_READY ) { - _Thread_Scheduler_cancel_need_for_help( owner, _Thread_Get_CPU( owner ) ); - _Scheduler_Thread_change_state( owner, THREAD_SCHEDULER_SCHEDULED ); - } else if ( - owner->Scheduler.state == THREAD_SCHEDULER_SCHEDULED - && node->sticky_level <= 1 - ) { - action = SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK; - } else if ( node->sticky_level == 0 ) { - action = SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK; - } else if ( idle != NULL ) { - action = SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE; - } else { - _Scheduler_Use_idle_thread( - context, - node, - _Thread_Get_CPU( owner ), - get_idle_thread - ); - } - - _Thread_Scheduler_release_critical( owner, &lock_context ); - return action; + _Assert( _Scheduler_Node_get_user( node ) == idle ); + _Scheduler_Node_set_user( node, owner ); + node->idle = NULL; + idle_node = _Thread_Scheduler_get_home_node( idle ); + ( *release_idle_node )( idle_node, arg ); } /** - * @brief Releases an idle thread using this scheduler node. + * @brief Releases the idle thread used by the scheduler node if the node uses + * an idle thread. * - * @param context The scheduler instance context. - * @param[in, out] node The node which may have an idle thread as user. - * @param release_idle_thread Function to release an idle thread. + * @param[in, out] node is the node which wants to release the idle thread. * - * @retval idle The idle thread which used this node. - * @retval NULL This node had no idle thread as an user. + * @param release_idle_node is the release idle node handler. + * + * @param arg is the handler argument. + * + * @retval NULL The scheduler node did not use an idle thread. + * + * @return Returns the idle thread used by the scheduler node. */ -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Release_idle_thread( - Scheduler_Context *context, - Scheduler_Node *node, - Scheduler_Release_idle_thread release_idle_thread +static inline Thread_Control *_Scheduler_Release_idle_thread_if_necessary( + Scheduler_Node *node, + Scheduler_Release_idle_node release_idle_node, + void *arg ) { - Thread_Control *idle = _Scheduler_Node_get_idle( node ); + Thread_Control *idle; - if ( idle != NULL ) { - Thread_Control *owner = _Scheduler_Node_get_owner( node ); + idle = _Scheduler_Node_get_idle( node ); - node->idle = NULL; - _Scheduler_Node_set_user( node, owner ); - ( *release_idle_thread )( context, idle ); + if ( idle != NULL ) { + _Scheduler_Release_idle_thread( node, idle, release_idle_node, arg ); } return idle; } /** - * @brief Exchanges an idle thread from the scheduler node that uses it - * right now to another scheduler node. + * @brief Discards the idle thread used by the scheduler node. * - * @param needs_idle The scheduler node that needs an idle thread. - * @param uses_idle The scheduler node that used the idle thread. - * @param idle The idle thread that is exchanged. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Exchange_idle_thread( - Scheduler_Node *needs_idle, - Scheduler_Node *uses_idle, - Thread_Control *idle -) -{ - uses_idle->idle = NULL; - _Scheduler_Node_set_user( - uses_idle, - _Scheduler_Node_get_owner( uses_idle ) - ); - _Scheduler_Set_idle_thread( needs_idle, idle ); -} - -/** - * @brief Blocks this scheduler node. - * - * @param context The scheduler instance context. - * @param[in, out] thread The thread which wants to get blocked referencing this - * node. This is not necessarily the user of this node in case the node - * participates in the scheduler helping protocol. - * @param[in, out] node The node which wants to get blocked. - * @param is_scheduled This node is scheduled. - * @param get_idle_thread Function to get an idle thread. - * - * @retval thread_cpu The processor of the thread. Indicates to continue with - * the blocking operation. - * @retval NULL Otherwise. - */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Scheduler_Block_node( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - bool is_scheduled, - Scheduler_Get_idle_thread get_idle_thread -) -{ - int sticky_level; - ISR_lock_Context lock_context; - Per_CPU_Control *thread_cpu; - - sticky_level = node->sticky_level; - --sticky_level; - node->sticky_level = sticky_level; - _Assert( sticky_level >= 0 ); - - _Thread_Scheduler_acquire_critical( thread, &lock_context ); - thread_cpu = _Thread_Get_CPU( thread ); - _Thread_Scheduler_cancel_need_for_help( thread, thread_cpu ); - _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_BLOCKED ); - _Thread_Scheduler_release_critical( thread, &lock_context ); - - if ( sticky_level > 0 ) { - if ( is_scheduled && _Scheduler_Node_get_idle( node ) == NULL ) { - Thread_Control *idle; - - idle = _Scheduler_Use_idle_thread( - context, - node, - thread_cpu, - get_idle_thread - ); - _Thread_Dispatch_update_heir( _Per_CPU_Get(), thread_cpu, idle ); - } - - return NULL; - } - - _Assert( thread == _Scheduler_Node_get_user( node ) ); - return thread_cpu; -} - -/** - * @brief Discard the idle thread from the scheduler node. + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the node which wants to release the idle thread. + * + * @param release_idle_node is the release idle node handler. * - * @param context The scheduler context. - * @param[in, out] the_thread The thread for the operation. - * @param[in, out] node The scheduler node to discard the idle thread from. - * @param release_idle_thread Method to release the idle thread from the context. + * @param arg is the handler argument. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Discard_idle_thread( - Scheduler_Context *context, - Thread_Control *the_thread, - Scheduler_Node *node, - Scheduler_Release_idle_thread release_idle_thread +static inline void _Scheduler_Discard_idle_thread( + Thread_Control *the_thread, + Scheduler_Node *node, + Scheduler_Release_idle_node release_idle_node, + void *arg ) { Thread_Control *idle; - Thread_Control *owner; Per_CPU_Control *cpu; idle = _Scheduler_Node_get_idle( node ); - owner = _Scheduler_Node_get_owner( node ); - - node->idle = NULL; - _Assert( _Scheduler_Node_get_user( node ) == idle ); - _Scheduler_Node_set_user( node, owner ); - ( *release_idle_thread )( context, idle ); + _Scheduler_Release_idle_thread( node, idle, release_idle_node, arg ); cpu = _Thread_Get_CPU( idle ); _Thread_Set_CPU( the_thread, cpu ); _Thread_Dispatch_update_heir( _Per_CPU_Get(), cpu, the_thread ); } - -/** - * @brief Unblocks this scheduler node. - * - * @param context The scheduler instance context. - * @param[in, out] the_thread The thread which wants to get unblocked. - * @param[in, out] node The node which wants to get unblocked. - * @param is_scheduled This node is scheduled. - * @param release_idle_thread Function to release an idle thread. - * - * @retval true Continue with the unblocking operation. - * @retval false Do not continue with the unblocking operation. - */ -RTEMS_INLINE_ROUTINE bool _Scheduler_Unblock_node( - Scheduler_Context *context, - Thread_Control *the_thread, - Scheduler_Node *node, - bool is_scheduled, - Scheduler_Release_idle_thread release_idle_thread -) -{ - bool unblock; - - ++node->sticky_level; - _Assert( node->sticky_level > 0 ); - - if ( is_scheduled ) { - _Scheduler_Discard_idle_thread( - context, - the_thread, - node, - release_idle_thread - ); - _Scheduler_Thread_change_state( the_thread, THREAD_SCHEDULER_SCHEDULED ); - unblock = false; - } else { - _Scheduler_Thread_change_state( the_thread, THREAD_SCHEDULER_READY ); - unblock = true; - } - - return unblock; -} #endif /** - * @brief Updates the heir. - * - * @param[in, out] new_heir The new heir. - * @param force_dispatch Indicates whether the dispatch happens also if the - * currently running thread is set as not preemptible. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir( - Thread_Control *new_heir, - bool force_dispatch -) -{ - Thread_Control *heir = _Thread_Heir; - - if ( heir != new_heir && ( heir->is_preemptible || force_dispatch ) ) { -#if defined(RTEMS_SMP) - /* - * We need this state only for _Thread_Get_CPU_time_used(). Cannot use - * _Scheduler_Thread_change_state() since THREAD_SCHEDULER_BLOCKED to - * THREAD_SCHEDULER_BLOCKED state changes are illegal for the real SMP - * schedulers. - */ - heir->Scheduler.state = THREAD_SCHEDULER_BLOCKED; - new_heir->Scheduler.state = THREAD_SCHEDULER_SCHEDULED; -#endif - _Thread_Update_CPU_time_used( heir, _Thread_Get_CPU( heir ) ); - _Thread_Heir = new_heir; - _Thread_Dispatch_necessary = true; - } -} - -/** * @brief Sets a new scheduler. * * @param new_scheduler The new scheduler to set. @@ -1295,7 +928,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir( * @retval STATUS_RESOURCE_IN_USE The thread's wait queue is not empty. * @retval STATUS_UNSATISFIED The new scheduler has no processors. */ -RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set( +static inline Status_Control _Scheduler_Set( const Scheduler_Control *new_scheduler, Thread_Control *the_thread, Priority_Control priority diff --git a/cpukit/include/rtems/score/schedulernode.h b/cpukit/include/rtems/score/schedulernode.h index e344479718..65a33a1485 100644 --- a/cpukit/include/rtems/score/schedulernode.h +++ b/cpukit/include/rtems/score/schedulernode.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,17 +11,28 @@ */ /* - * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2014, 2016 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERNODE_H diff --git a/cpukit/include/rtems/score/schedulernodeimpl.h b/cpukit/include/rtems/score/schedulernodeimpl.h index e222de953b..db14184723 100644 --- a/cpukit/include/rtems/score/schedulernodeimpl.h +++ b/cpukit/include/rtems/score/schedulernodeimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,17 +11,28 @@ */ /* - * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2014, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERNODEIMPL_H @@ -87,7 +100,7 @@ extern "C" { * * @param priority is the initial priority of the node. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize( +static inline void _Scheduler_Node_do_initialize( const struct _Scheduler_Control *scheduler, Scheduler_Node *node, Thread_Control *the_thread, @@ -119,7 +132,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize( * * @param[in, out] node is the node to destroy. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_destroy( +static inline void _Scheduler_Node_do_destroy( const struct _Scheduler_Control *scheduler, Scheduler_Node *node ) @@ -140,7 +153,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_destroy( * * @return The scheduler of the node. */ -RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Node_get_scheduler( +static inline const Scheduler_Control *_Scheduler_Node_get_scheduler( const Scheduler_Node *node ) { @@ -154,7 +167,7 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Node_get_scheduler( * * @return The owner of the node. */ -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner( +static inline Thread_Control *_Scheduler_Node_get_owner( const Scheduler_Node *node ) { @@ -168,7 +181,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner( * * @return The priority of the node. */ -RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority( +static inline Priority_Control _Scheduler_Node_get_priority( Scheduler_Node *node ) { @@ -201,7 +214,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority( * @param group_order is the priority group order, see #PRIORITY_GROUP_FIRST * and #PRIORITY_GROUP_LAST. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority( +static inline void _Scheduler_Node_set_priority( Scheduler_Node *node, Priority_Control new_priority, Priority_Group_order group_order @@ -230,7 +243,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority( * * @return The user of the node. */ -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_user( +static inline Thread_Control *_Scheduler_Node_get_user( const Scheduler_Node *node ) { @@ -243,7 +256,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_user( * @param[out] node The node to set the user of. * @param user The new user for @a node. */ -RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_user( +static inline void _Scheduler_Node_set_user( Scheduler_Node *node, Thread_Control *user ) @@ -258,12 +271,33 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_user( * * @return The idle thread of @a node. */ -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_idle( +static inline Thread_Control *_Scheduler_Node_get_idle( const Scheduler_Node *node ) { return node->idle; } + +/** + * @brief Sets the scheduler node's user to the idle thread. + * + * @param[in, out] node is the node to receive an idle thread. + * + * @param idle is the idle thread to use. + */ +static inline void _Scheduler_Node_set_idle_user( + Scheduler_Node *node, + Thread_Control *idle +) +{ + _Assert( _Scheduler_Node_get_idle( node ) == NULL ); + _Assert( + _Scheduler_Node_get_owner( node ) == _Scheduler_Node_get_user( node ) + ); + + _Scheduler_Node_set_user( node, idle ); + node->idle = idle; +} #endif #ifdef __cplusplus diff --git a/cpukit/include/rtems/score/schedulerpriority.h b/cpukit/include/rtems/score/schedulerpriority.h index e0991f5e31..86681cd201 100644 --- a/cpukit/include/rtems/score/schedulerpriority.h +++ b/cpukit/include/rtems/score/schedulerpriority.h @@ -1,10 +1,12 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @ingroup RTEMSScoreSchedulerDPS + * @ingroup RTEMSScoreSchedulerPriority * * @brief This header file provides interfaces of the - * @ref RTEMSScoreSchedulerDPS which are used by the implementation and the + * @ref RTEMSScoreSchedulerPriority which are used by the implementation and the * @ref RTEMSImplApplConfig. */ @@ -12,9 +14,26 @@ * Copryight (c) 2010 Gedare Bloom. * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERPRIORITY_H @@ -29,7 +48,7 @@ extern "C" { #endif /** - * @defgroup RTEMSScoreSchedulerDPS Deterministic Priority Scheduler + * @defgroup RTEMSScoreSchedulerPriority Deterministic Priority Scheduler * * @ingroup RTEMSScoreScheduler * @@ -57,7 +76,6 @@ extern "C" { _Scheduler_default_Node_destroy, /* node destroy entry point */ \ _Scheduler_default_Release_job, /* new period of task */ \ _Scheduler_default_Cancel_job, /* cancel period of task */ \ - _Scheduler_default_Tick, /* tick entry point */ \ _Scheduler_default_Start_idle /* start idle entry point */ \ SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \ } @@ -76,7 +94,7 @@ typedef struct { /** * @brief One ready queue per priority level. */ - Chain_Control Ready[ 0 ]; + Chain_Control Ready[ RTEMS_ZERO_LENGTH_ARRAY ]; } Scheduler_priority_Context; /** diff --git a/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h b/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h index 1b660fa296..2279fddaf7 100644 --- a/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h +++ b/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 2014. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H @@ -56,7 +75,7 @@ extern "C" { { \ _Scheduler_priority_SMP_Initialize, \ _Scheduler_default_Schedule, \ - _Scheduler_priority_SMP_Yield, \ + _Scheduler_priority_affinity_SMP_Yield, \ _Scheduler_priority_affinity_SMP_Block, \ _Scheduler_priority_affinity_SMP_Unblock, \ _Scheduler_priority_affinity_SMP_Update_priority, \ @@ -65,6 +84,8 @@ extern "C" { _Scheduler_priority_affinity_SMP_Ask_for_help, \ _Scheduler_priority_affinity_SMP_Reconsider_help_request, \ _Scheduler_priority_affinity_SMP_Withdraw_node, \ + _Scheduler_priority_affinity_SMP_Make_sticky, \ + _Scheduler_priority_affinity_SMP_Clean_sticky, \ _Scheduler_default_Pin_or_unpin_not_supported, \ _Scheduler_default_Pin_or_unpin_not_supported, \ _Scheduler_priority_affinity_SMP_Add_processor, \ @@ -73,7 +94,6 @@ extern "C" { _Scheduler_default_Node_destroy, \ _Scheduler_default_Release_job, \ _Scheduler_default_Cancel_job, \ - _Scheduler_default_Tick, \ _Scheduler_SMP_Start_idle, \ _Scheduler_priority_affinity_SMP_Set_affinity \ } @@ -109,6 +129,12 @@ void _Scheduler_priority_affinity_SMP_Block( Scheduler_Node *node ); +void _Scheduler_priority_affinity_SMP_Yield( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + /** * @brief Unblocks a thread. * @@ -182,6 +208,36 @@ void _Scheduler_priority_affinity_SMP_Withdraw_node( ); /** + * @brief Makes the node sticky. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to make sticky. + */ +void _Scheduler_priority_affinity_SMP_Make_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** + * @brief Cleans the sticky property from the node. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to clean the sticky property. + */ +void _Scheduler_priority_affinity_SMP_Clean_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** * @brief Adds @a idle to @a scheduler. * * @param[in, out] scheduler The scheduler instance to add the processor to. diff --git a/cpukit/include/rtems/score/schedulerpriorityimpl.h b/cpukit/include/rtems/score/schedulerpriorityimpl.h index 64901d52b7..5e80918b20 100644 --- a/cpukit/include/rtems/score/schedulerpriorityimpl.h +++ b/cpukit/include/rtems/score/schedulerpriorityimpl.h @@ -1,19 +1,38 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @ingroup RTEMSScoreSchedulerDPS + * @ingroup RTEMSScoreSchedulerPriority * * @brief This header file provides interfaces of the - * @ref RTEMSScoreSchedulerDPS which are only used by the implementation. + * @ref RTEMSScoreSchedulerPriority which are only used by the implementation. */ /* * Copyright (C) 2010 Gedare Bloom. * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H @@ -22,7 +41,7 @@ #include <rtems/score/schedulerpriority.h> #include <rtems/score/chainimpl.h> #include <rtems/score/prioritybitmapimpl.h> -#include <rtems/score/schedulerimpl.h> +#include <rtems/score/scheduleruniimpl.h> #include <rtems/score/thread.h> #ifdef __cplusplus @@ -30,7 +49,7 @@ extern "C" { #endif /** - * @addtogroup RTEMSScoreSchedulerDPS + * @addtogroup RTEMSScoreSchedulerPriority * * @{ */ @@ -42,7 +61,7 @@ extern "C" { * * @return The context of the scheduler. */ -RTEMS_INLINE_ROUTINE Scheduler_priority_Context * +static inline Scheduler_priority_Context * _Scheduler_priority_Get_context( const Scheduler_Control *scheduler ) { return (Scheduler_priority_Context *) _Scheduler_Get_context( scheduler ); @@ -55,7 +74,7 @@ RTEMS_INLINE_ROUTINE Scheduler_priority_Context * * * @return The scheduler node of @a the_thread. */ -RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Thread_get_node( +static inline Scheduler_priority_Node *_Scheduler_priority_Thread_get_node( Thread_Control *the_thread ) { @@ -69,7 +88,7 @@ RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Thread_get_nod * * @return The priority node. */ -RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Node_downcast( +static inline Scheduler_priority_Node *_Scheduler_priority_Node_downcast( Scheduler_Node *node ) { @@ -84,7 +103,7 @@ RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Node_downcast( * @param[out] ready_queues The ready queue to initialize. * @param maximum_priority The maximum priority in the ready queue. */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize( +static inline void _Scheduler_priority_Ready_queue_initialize( Chain_Control *ready_queues, Priority_Control maximum_priority ) @@ -105,7 +124,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize( * @param[in, out] ready_queue The ready queue. * @param[out] bit_map The priority bit map of the scheduler instance. */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue( +static inline void _Scheduler_priority_Ready_queue_enqueue( Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map @@ -126,7 +145,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue( * @param[in, out] ready_queue The ready queue. * @param[out] bit_map The priority bit map of the scheduler instance. */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first( +static inline void _Scheduler_priority_Ready_queue_enqueue_first( Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map @@ -145,7 +164,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first( * @param[in, out] ready_queue The ready queue. * @param[out] bit_map The priority bit map of the scheduler instance. */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract( +static inline void _Scheduler_priority_Ready_queue_extract( Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map @@ -169,7 +188,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract( * @param the_thread The thread of which the node will be extracted. * @param[in, out] The node which preserves the ready queue. */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body( +static inline void _Scheduler_priority_Extract_body( const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node @@ -198,7 +217,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body( * * @return This method returns the first node. */ -RTEMS_INLINE_ROUTINE Chain_Node *_Scheduler_priority_Ready_queue_first( +static inline Chain_Node *_Scheduler_priority_Ready_queue_first( Priority_bit_map_Control *bit_map, Chain_Control *ready_queues ) @@ -212,33 +231,21 @@ RTEMS_INLINE_ROUTINE Chain_Node *_Scheduler_priority_Ready_queue_first( } /** - * @brief Scheduling decision logic. + * @brief Gets the highest priority ready thread of the scheduler. * - * This kernel routine implements scheduling decision logic - * for priority-based scheduling. - * - * @param[in, out] scheduler The scheduler instance. - * @param the_thread This parameter is unused. - * @param force_dispatch Indicates whether the dispatch happens also if - * the currently executing thread is set as not preemptible. + * @param scheduler is the scheduler. */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - bool force_dispatch +static inline Thread_Control *_Scheduler_priority_Get_highest_ready( + const Scheduler_Control *scheduler ) { Scheduler_priority_Context *context = _Scheduler_priority_Get_context( scheduler ); - Thread_Control *heir = (Thread_Control *) - _Scheduler_priority_Ready_queue_first( - &context->Bit_map, - &context->Ready[ 0 ] - ); - - ( void ) the_thread; - _Scheduler_Update_heir( heir, force_dispatch ); + return (Thread_Control *) _Scheduler_priority_Ready_queue_first( + &context->Bit_map, + &context->Ready[ 0 ] + ); } /** @@ -250,7 +257,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body( * @param bit_map The priority bit map of the scheduler instance. * @param ready_queues The ready queues of the scheduler instance. */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_update( +static inline void _Scheduler_priority_Ready_queue_update( Scheduler_priority_Ready_queue *ready_queue, unsigned int new_priority, Priority_bit_map_Control *bit_map, diff --git a/cpukit/include/rtems/score/schedulerprioritysmp.h b/cpukit/include/rtems/score/schedulerprioritysmp.h index 56f4aa5a5b..476036b3bd 100644 --- a/cpukit/include/rtems/score/schedulerprioritysmp.h +++ b/cpukit/include/rtems/score/schedulerprioritysmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,17 +11,28 @@ */ /* - * Copyright (c) 2013, 2018 embedded brains GmbH. All rights reserved. + * Copyright (C) 2013, 2018 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERPRIORITYSMP_H @@ -57,6 +70,7 @@ extern "C" { */ typedef struct { Scheduler_SMP_Context Base; + Chain_Control *idle_ready_queue; Priority_bit_map_Control Bit_map; Chain_Control Ready[ RTEMS_ZERO_LENGTH_ARRAY ]; } Scheduler_priority_SMP_Context; @@ -93,6 +107,8 @@ typedef struct { _Scheduler_priority_SMP_Ask_for_help, \ _Scheduler_priority_SMP_Reconsider_help_request, \ _Scheduler_priority_SMP_Withdraw_node, \ + _Scheduler_priority_SMP_Make_sticky, \ + _Scheduler_priority_SMP_Clean_sticky, \ _Scheduler_default_Pin_or_unpin_not_supported, \ _Scheduler_default_Pin_or_unpin_not_supported, \ _Scheduler_priority_SMP_Add_processor, \ @@ -101,7 +117,6 @@ typedef struct { _Scheduler_default_Node_destroy, \ _Scheduler_default_Release_job, \ _Scheduler_default_Cancel_job, \ - _Scheduler_default_Tick, \ _Scheduler_SMP_Start_idle \ SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \ } @@ -216,6 +231,36 @@ void _Scheduler_priority_SMP_Withdraw_node( ); /** + * @brief Makes the node sticky. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to make sticky. + */ +void _Scheduler_priority_SMP_Make_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** + * @brief Cleans the sticky property from the node. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to clean the sticky property. + */ +void _Scheduler_priority_SMP_Clean_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** * @brief Adds @a idle to @a scheduler. * * @param[in, out] scheduler The scheduler instance to add the processor to. diff --git a/cpukit/include/rtems/score/schedulerprioritysmpimpl.h b/cpukit/include/rtems/score/schedulerprioritysmpimpl.h index 6e14200840..12fe6b1004 100644 --- a/cpukit/include/rtems/score/schedulerprioritysmpimpl.h +++ b/cpukit/include/rtems/score/schedulerprioritysmpimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,17 +11,28 @@ */ /* - * Copyright (c) 2013, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2013, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H @@ -156,6 +169,41 @@ static inline void _Scheduler_priority_SMP_Extract_from_ready( ); } +static inline Scheduler_Node *_Scheduler_priority_SMP_Get_idle( void *arg ) +{ + Scheduler_priority_SMP_Context *self; + Scheduler_priority_SMP_Node *lowest_ready; + + self = _Scheduler_priority_SMP_Get_self( arg ); + lowest_ready = (Scheduler_priority_SMP_Node *) + _Chain_Last( self->idle_ready_queue ); + _Scheduler_priority_Ready_queue_extract( + &lowest_ready->Base.Base.Node.Chain, + &lowest_ready->Ready_queue, + &self->Bit_map + ); + + return &lowest_ready->Base.Base; +} + +static inline void _Scheduler_priority_SMP_Release_idle( + Scheduler_Node *node_base, + void *arg +) +{ + Scheduler_priority_SMP_Context *self; + Scheduler_priority_SMP_Node *node; + + self = _Scheduler_priority_SMP_Get_self( arg ); + node = _Scheduler_priority_SMP_Node_downcast( node_base ); + + _Scheduler_priority_Ready_queue_enqueue( + &node->Base.Base.Node.Chain, + &node->Ready_queue, + &self->Bit_map + ); +} + static inline void _Scheduler_priority_SMP_Do_update( Scheduler_Context *context, Scheduler_Node *node_to_update, diff --git a/cpukit/include/rtems/score/schedulersimple.h b/cpukit/include/rtems/score/schedulersimple.h index 63310e9796..d9acd3dea0 100644 --- a/cpukit/include/rtems/score/schedulersimple.h +++ b/cpukit/include/rtems/score/schedulersimple.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ /* * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_H @@ -56,7 +75,6 @@ extern "C" { _Scheduler_default_Node_destroy, /* node destroy entry point */ \ _Scheduler_default_Release_job, /* new period of task */ \ _Scheduler_default_Cancel_job, /* cancel period of task */ \ - _Scheduler_default_Tick, /* tick entry point */ \ _Scheduler_default_Start_idle /* start idle entry point */ \ SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \ } diff --git a/cpukit/include/rtems/score/schedulersimpleimpl.h b/cpukit/include/rtems/score/schedulersimpleimpl.h index 08ad7b8c66..da052ba1b4 100644 --- a/cpukit/include/rtems/score/schedulersimpleimpl.h +++ b/cpukit/include/rtems/score/schedulersimpleimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ /* * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H @@ -20,7 +39,7 @@ #include <rtems/score/schedulersimple.h> #include <rtems/score/chainimpl.h> -#include <rtems/score/schedulerimpl.h> +#include <rtems/score/scheduleruniimpl.h> #ifdef __cplusplus extern "C" { @@ -39,7 +58,7 @@ extern "C" { * * @return The context of @a scheduler. */ -RTEMS_INLINE_ROUTINE Scheduler_simple_Context * +static inline Scheduler_simple_Context * _Scheduler_simple_Get_context( const Scheduler_Control *scheduler ) { return (Scheduler_simple_Context *) _Scheduler_Get_context( scheduler ); @@ -48,21 +67,26 @@ RTEMS_INLINE_ROUTINE Scheduler_simple_Context * /** * @brief Checks if the priority is less or equal than the priority of the node. * - * @param to_insert The priority to check whether it is less or equal than @a next. - * @param next The Chain node to compare the priority of. + * @param key is the priority to compare. + * + * @param to_insert is the chain node to insert. + * + * @param next is the chain node to compare the priority of. * * @retval true @a to_insert is smaller or equal than the priority of @a next. * @retval false @a to_insert is greater than the priority of @a next. */ -RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Priority_less_equal( - const void *to_insert, +static inline bool _Scheduler_simple_Priority_less_equal( + const void *key, + const Chain_Node *to_insert, const Chain_Node *next ) { const unsigned int *priority_to_insert; const Thread_Control *thread_next; - priority_to_insert = (const unsigned int *) to_insert; + (void) to_insert; + priority_to_insert = (const unsigned int *) key; thread_next = (const Thread_Control *) next; return *priority_to_insert <= _Thread_Get_priority( thread_next ); @@ -75,7 +99,7 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Priority_less_equal( * @param[in, out] to_insert The node to insert into @a chain. * @param insert_priority The priority to insert @a to_insert with. */ -RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert( +static inline void _Scheduler_simple_Insert( Chain_Control *chain, Thread_Control *to_insert, unsigned int insert_priority @@ -96,7 +120,7 @@ RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert( * @param[in, out] the_thread The thread of which to extract the node out of its chain. * @param node This parameter is unused. */ -RTEMS_INLINE_ROUTINE void _Scheduler_simple_Extract( +static inline void _Scheduler_simple_Extract( const Scheduler_Control *scheduler, Thread_Control *the_thread, Scheduler_Node *node @@ -109,28 +133,18 @@ RTEMS_INLINE_ROUTINE void _Scheduler_simple_Extract( } /** - * @brief Scheduling decision logic. + * @brief Gets the highest priority ready thread of the scheduler. * - * This kernel routine implements scheduling decision logic for the simple scheduler. - * - * @param[in, out] scheduler The scheduler instance. - * @param the_thread This parameter is unused. - * @param force_dispatch Indicates whether the dispatch happens also if - * the currently executing thread is set as not preemptible. + * @param scheduler is the scheduler. */ -RTEMS_INLINE_ROUTINE void _Scheduler_simple_Schedule_body( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - bool force_dispatch +static inline Thread_Control *_Scheduler_simple_Get_highest_ready( + const Scheduler_Control *scheduler ) { Scheduler_simple_Context *context = _Scheduler_simple_Get_context( scheduler ); - Thread_Control *heir = (Thread_Control *) _Chain_First( &context->Ready ); - - ( void ) the_thread; - _Scheduler_Update_heir( heir, force_dispatch ); + return (Thread_Control *) _Chain_First( &context->Ready ); } /** @} */ diff --git a/cpukit/include/rtems/score/schedulersimplesmp.h b/cpukit/include/rtems/score/schedulersimplesmp.h index 961e60ae73..4ef34847b8 100644 --- a/cpukit/include/rtems/score/schedulersimplesmp.h +++ b/cpukit/include/rtems/score/schedulersimplesmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,11 +12,28 @@ /* * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2013, 2018 embedded brains GmbH. + * Copyright (C) 2013, 2018 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H @@ -75,6 +94,8 @@ typedef struct { _Scheduler_simple_SMP_Ask_for_help, \ _Scheduler_simple_SMP_Reconsider_help_request, \ _Scheduler_simple_SMP_Withdraw_node, \ + _Scheduler_simple_SMP_Make_sticky, \ + _Scheduler_simple_SMP_Clean_sticky, \ _Scheduler_default_Pin_or_unpin_not_supported, \ _Scheduler_default_Pin_or_unpin_not_supported, \ _Scheduler_simple_SMP_Add_processor, \ @@ -83,7 +104,6 @@ typedef struct { _Scheduler_default_Node_destroy, \ _Scheduler_default_Release_job, \ _Scheduler_default_Cancel_job, \ - _Scheduler_default_Tick, \ _Scheduler_SMP_Start_idle \ SCHEDULER_DEFAULT_SET_AFFINITY_OPERATION \ } @@ -196,6 +216,36 @@ void _Scheduler_simple_SMP_Withdraw_node( ); /** + * @brief Makes the node sticky. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to make sticky. + */ +void _Scheduler_simple_SMP_Make_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** + * @brief Cleans the sticky property from the node. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to clean the sticky property. + */ +void _Scheduler_simple_SMP_Clean_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** * @brief Adds @a idle to @a scheduler. * * @param[in, out] scheduler The scheduler instance to add the processor to. diff --git a/cpukit/include/rtems/score/schedulersmp.h b/cpukit/include/rtems/score/schedulersmp.h index 1d5294b4f0..3d1fe86582 100644 --- a/cpukit/include/rtems/score/schedulersmp.h +++ b/cpukit/include/rtems/score/schedulersmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,17 +11,28 @@ */ /* - * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. + * Copyright (C) 2013, 2014 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERSMP_H @@ -55,15 +68,6 @@ typedef struct { * @brief The chain of scheduled nodes. */ Chain_Control Scheduled; - - /** - * @brief Chain of the available idle threads. - * - * Idle threads are used for the scheduler helping protocol. It is crucial - * that the idle threads preserve their relative order. This is the case for - * this priority based scheduler. - */ - Chain_Control Idle_threads; } Scheduler_SMP_Context; /** diff --git a/cpukit/include/rtems/score/schedulersmpimpl.h b/cpukit/include/rtems/score/schedulersmpimpl.h index dbfc241b18..c1839c4517 100644 --- a/cpukit/include/rtems/score/schedulersmpimpl.h +++ b/cpukit/include/rtems/score/schedulersmpimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2013, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. + * Copyright (C) 2013, 2021 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_SCORE_SCHEDULERSMPIMPL_H @@ -282,7 +295,11 @@ typedef bool ( *Scheduler_SMP_Has_ready )( typedef Scheduler_Node *( *Scheduler_SMP_Get_highest_ready )( Scheduler_Context *context, - Scheduler_Node *node + Scheduler_Node *filter +); + +typedef Scheduler_Node *( *Scheduler_SMP_Get_lowest_ready )( + Scheduler_Context *context ); typedef Scheduler_Node *( *Scheduler_SMP_Get_lowest_scheduled )( @@ -330,11 +347,16 @@ typedef bool ( *Scheduler_SMP_Enqueue )( Priority_Control priority ); +typedef void ( *Scheduler_SMP_Enqueue_scheduled )( + Scheduler_Context *context, + Scheduler_Node *node_to_enqueue, + Priority_Control priority +); + typedef void ( *Scheduler_SMP_Allocate_processor )( Scheduler_Context *context, Scheduler_Node *scheduled, - Scheduler_Node *victim, - Per_CPU_Control *victim_cpu + Per_CPU_Control *cpu ); typedef void ( *Scheduler_SMP_Register_idle )( @@ -364,21 +386,26 @@ static inline void _Scheduler_SMP_Do_nothing_register_idle( /** * @brief Checks if @a to_insert is less or equal than the priority of the chain node. * - * @param to_insert The priority to compare. - * @param next The chain node to compare the priority of. + * @param key is the priority to compare. + * + * @param to_insert is the chain node to insert. + * + * @param next is the chain node to compare the priority of. * * @retval true @a to_insert is less or equal than the priority of @a next. * @retval false @a to_insert is greater than the priority of @a next. */ static inline bool _Scheduler_SMP_Priority_less_equal( - const void *to_insert, + const void *key, + const Chain_Node *to_insert, const Chain_Node *next ) { const Priority_Control *priority_to_insert; const Scheduler_SMP_Node *node_next; - priority_to_insert = (const Priority_Control *) to_insert; + (void) to_insert; + priority_to_insert = (const Priority_Control *) key; node_next = (const Scheduler_SMP_Node *) next; return *priority_to_insert <= node_next->priority; @@ -408,7 +435,6 @@ static inline void _Scheduler_SMP_Initialize( ) { _Chain_Initialize_empty( &self->Scheduled ); - _Chain_Initialize_empty( &self->Idle_threads ); } /** @@ -550,205 +576,300 @@ static inline bool _Scheduler_SMP_Is_processor_owned_by_us( } /** - * @brief Gets The first idle thread of the given context. + * @brief Removes the thread's ask for help request from the processor. + * + * The caller must be the owner of the thread's scheduler lock. * - * @param context The scheduler context to get the first idle thread from. + * @param[in, out] thread is the thread of the ask for help request. * - * @return The first idle thread of @a context. + * @param[in, out] cpu is the processor from which the ask for help request + * should be removed. */ -static inline Thread_Control *_Scheduler_SMP_Get_idle_thread( - Scheduler_Context *context -) +void _Scheduler_SMP_Remove_ask_for_help_from_processor( + Thread_Control *thread, + Per_CPU_Control *cpu +); + +/** + * @brief Cancels the thread's ask for help request. + * + * The caller must be the owner of the thread's scheduler lock. + * + * @param[in, out] thread is the thread of the ask help request. + */ +static inline void _Scheduler_SMP_Cancel_ask_for_help( Thread_Control *thread ) { - Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); - Thread_Control *idle = (Thread_Control *) - _Chain_Get_first_unprotected( &self->Idle_threads ); + Per_CPU_Control *cpu; - _Assert( &idle->Object.Node != _Chain_Tail( &self->Idle_threads ) ); + _Assert( _ISR_lock_Is_owner( &thread->Scheduler.Lock ) ); + cpu = thread->Scheduler.ask_for_help_cpu; - return idle; + if ( RTEMS_PREDICT_FALSE( cpu != NULL ) ) { + _Scheduler_SMP_Remove_ask_for_help_from_processor( thread, cpu ); + } } /** - * @brief Releases the thread and adds it to the idle threads. + * @brief Requests to ask for help for the thread. * - * @param[in, out] context The scheduler context instance. - * @param idle The thread to add to the idle threads. + * The actual ask for help operations are carried out during + * _Thread_Do_dispatch() on the current processor. + * + * An alternative approach would be to carry out the requests on a processor + * related to the thread. This could reduce the overhead for the preempting + * thread a bit, however, there are at least two problems with this approach. + * Firstly, we have to figure out what is a processor related to the thread. + * Secondly, we may need an inter-processor interrupt. + * + * @param[in, out] thread is the thread in need for help. */ -static inline void _Scheduler_SMP_Release_idle_thread( - Scheduler_Context *context, - Thread_Control *idle -) +static inline void _Scheduler_SMP_Request_ask_for_help( Thread_Control *thread ) { - Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); + ISR_lock_Context lock_context; + Per_CPU_Control *cpu_self; + + cpu_self = _Per_CPU_Get(); - _Chain_Prepend_unprotected( &self->Idle_threads, &idle->Object.Node ); + _Assert( thread->Scheduler.ask_for_help_cpu == NULL ); + thread->Scheduler.ask_for_help_cpu = cpu_self; + cpu_self->dispatch_necessary = true; + + _Per_CPU_Acquire( cpu_self, &lock_context ); + _Chain_Append_unprotected( + &cpu_self->Threads_in_need_for_help, + &thread->Scheduler.Help_node + ); + _Per_CPU_Release( cpu_self, &lock_context ); } /** - * @brief Extracts the node of the idle thread. + * @brief This enumeration defines what a scheduler should do with a node which + * could be scheduled. + */ +typedef enum { + SCHEDULER_SMP_DO_SCHEDULE, + SCHEDULER_SMP_DO_NOT_SCHEDULE +} Scheduler_SMP_Action; + +/** + * @brief Tries to schedule the scheduler node. + * + * When an SMP scheduler needs to schedule a node, it shall use this function + * to determine what it shall do with the node. + * + * This function uses the state of the node and the scheduler state of the + * owner thread to determine what shall be done. Each scheduler maintains its + * nodes independent of other schedulers. This function ensures that a thread + * is scheduled by at most one scheduler. If a node requires an executing + * thread due to some locking protocol and the owner thread is already + * scheduled by another scheduler, then an idle thread will be attached to the + * node. + * + * @param[in, out] node is the node which should be scheduled. + * + * @param get_idle_node is the get idle node handler. * - * @param[in, out] idle The thread to extract the node of. + * @param arg is the get idle node handler argument. + * + * @retval SCHEDULER_SMP_DO_SCHEDULE The node shall be scheduled. + * + * @retval SCHEDULER_SMP_DO_NOT_SCHEDULE The node shall be blocked. This + * action is returned, if the owner thread is already scheduled by another + * scheduler. */ -static inline void _Scheduler_SMP_Exctract_idle_thread( - Thread_Control *idle +static inline Scheduler_SMP_Action _Scheduler_SMP_Try_to_schedule( + Scheduler_Node *node, + Scheduler_Get_idle_node get_idle_node, + void *arg ) { - _Chain_Extract_unprotected( &idle->Object.Node ); + ISR_lock_Context lock_context; + Thread_Control *owner; + Thread_Scheduler_state owner_state; + int owner_sticky_level; + + owner = _Scheduler_Node_get_owner( node ); + _Assert( _Scheduler_Node_get_idle( node ) == NULL ); + + _Thread_Scheduler_acquire_critical( owner, &lock_context ); + owner_state = owner->Scheduler.state; + owner_sticky_level = node->sticky_level; + + if ( RTEMS_PREDICT_TRUE( owner_state == THREAD_SCHEDULER_READY ) ) { + _Scheduler_SMP_Cancel_ask_for_help( owner ); + _Scheduler_Thread_change_state( owner, THREAD_SCHEDULER_SCHEDULED ); + _Thread_Scheduler_release_critical( owner, &lock_context ); + return SCHEDULER_SMP_DO_SCHEDULE; + } + + _Thread_Scheduler_release_critical( owner, &lock_context ); + + if ( + ( owner_state == THREAD_SCHEDULER_SCHEDULED && owner_sticky_level <= 1 ) || + owner_sticky_level == 0 + ) { + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); + + return SCHEDULER_SMP_DO_NOT_SCHEDULE; + } + + (void) _Scheduler_Use_idle_thread( node, get_idle_node, arg ); + + return SCHEDULER_SMP_DO_SCHEDULE; } /** - * @brief Allocates the cpu for the scheduled thread. + * @brief Allocates a processor to the user of the scheduled node. * * Attempts to prevent migrations but does not take into account affinity. * - * @param context The scheduler context instance. - * @param scheduled The scheduled node that should be executed next. - * @param victim If the heir is this node's thread, no processor is allocated. - * @param[in, out] victim_cpu The cpu to allocate. + * @param[in, out] context is the scheduler context. + * + * @param[in, out] scheduled is the scheduled node that gets the processor allocated. + * + * @param[in, out] cpu is the processor to allocate. */ static inline void _Scheduler_SMP_Allocate_processor_lazy( Scheduler_Context *context, Scheduler_Node *scheduled, - Scheduler_Node *victim, - Per_CPU_Control *victim_cpu + Per_CPU_Control *cpu ) { Thread_Control *scheduled_thread = _Scheduler_Node_get_user( scheduled ); - Thread_Control *victim_thread = _Scheduler_Node_get_user( victim ); Per_CPU_Control *scheduled_cpu = _Thread_Get_CPU( scheduled_thread ); Per_CPU_Control *cpu_self = _Per_CPU_Get(); - Thread_Control *heir; _Assert( _ISR_Get_level() != 0 ); - if ( _Thread_Is_executing_on_a_processor( scheduled_thread ) ) { - if ( _Scheduler_SMP_Is_processor_owned_by_us( context, scheduled_cpu ) ) { - heir = scheduled_cpu->heir; - _Thread_Dispatch_update_heir( - cpu_self, - scheduled_cpu, - scheduled_thread - ); - } else { - /* We have to force a migration to our processor set */ - heir = scheduled_thread; - } - } else { - heir = scheduled_thread; + if ( cpu == scheduled_cpu ) { + _Thread_Set_CPU( scheduled_thread, cpu ); + _Thread_Dispatch_update_heir( cpu_self, cpu, scheduled_thread ); + + return; } - if ( heir != victim_thread ) { - _Thread_Set_CPU( heir, victim_cpu ); - _Thread_Dispatch_update_heir( cpu_self, victim_cpu, heir ); + if ( + _Thread_Is_executing_on_a_processor( scheduled_thread ) && + _Scheduler_SMP_Is_processor_owned_by_us( context, scheduled_cpu ) + ) { + Thread_Control *heir = scheduled_cpu->heir; + _Thread_Dispatch_update_heir( cpu_self, scheduled_cpu, scheduled_thread ); + _Thread_Set_CPU( heir, cpu ); + _Thread_Dispatch_update_heir( cpu_self, cpu, heir ); + + return; } + + _Thread_Set_CPU( scheduled_thread, cpu ); + _Thread_Dispatch_update_heir( cpu_self, cpu, scheduled_thread ); } /** - * @brief Allocates the cpu for the scheduled thread. + * @brief Allocates exactly the processor to the user of the scheduled node. * * This method is slightly different from * _Scheduler_SMP_Allocate_processor_lazy() in that it does what it is asked to * do. _Scheduler_SMP_Allocate_processor_lazy() attempts to prevent migrations * but does not take into account affinity. * - * @param context This parameter is unused. - * @param scheduled The scheduled node whose thread should be executed next. - * @param victim This parameter is unused. - * @param[in, out] victim_cpu The cpu to allocate. + * @param[in, out] context is the scheduler context. + * + * @param[in, out] scheduled is the scheduled node that gets the processor allocated. + * + * @param[in, out] cpu is the processor to allocate. */ static inline void _Scheduler_SMP_Allocate_processor_exact( Scheduler_Context *context, Scheduler_Node *scheduled, - Scheduler_Node *victim, - Per_CPU_Control *victim_cpu + Per_CPU_Control *cpu ) { Thread_Control *scheduled_thread = _Scheduler_Node_get_user( scheduled ); Per_CPU_Control *cpu_self = _Per_CPU_Get(); (void) context; - (void) victim; - _Thread_Set_CPU( scheduled_thread, victim_cpu ); - _Thread_Dispatch_update_heir( cpu_self, victim_cpu, scheduled_thread ); + _Thread_Set_CPU( scheduled_thread, cpu ); + _Thread_Dispatch_update_heir( cpu_self, cpu, scheduled_thread ); } /** - * @brief Allocates the cpu for the scheduled thread using the given allocation function. + * @brief Allocates the processor to the user of the scheduled node using the + * given allocation handler. * - * @param context The scheduler context instance. - * @param scheduled The scheduled node that should be executed next. - * @param victim If the heir is this node's thread, no processor is allocated. - * @param[in, out] victim_cpu The cpu to allocate. - * @param allocate_processor The function to use for the allocation of @a victim_cpu. + * @param[in, out] context is the scheduler context. + * + * @param[in, out] scheduled is the scheduled node that gets the processor allocated. + * + * @param[in, out] cpu is the processor to allocate. + * + * @param allocate_processor is the handler which should allocate the processor. */ static inline void _Scheduler_SMP_Allocate_processor( Scheduler_Context *context, Scheduler_Node *scheduled, - Scheduler_Node *victim, - Per_CPU_Control *victim_cpu, + Per_CPU_Control *cpu, Scheduler_SMP_Allocate_processor allocate_processor ) { _Scheduler_SMP_Node_change_state( scheduled, SCHEDULER_SMP_NODE_SCHEDULED ); - ( *allocate_processor )( context, scheduled, victim, victim_cpu ); + ( *allocate_processor )( context, scheduled, cpu ); } /** - * @brief Preempts the victim's thread and allocates a cpu for the scheduled thread. + * @brief Preempts the victim's thread and allocates a processor for the user + * of the scheduled node. * - * @param context The scheduler context instance. - * @param scheduled Node of the scheduled thread that is about to be executed. - * @param[in, out] victim Node of the thread to preempt. - * @param allocate_processor The function for allocation of a processor for the new thread. + * @param[in, out] context is the scheduler context. + * + * @param scheduled[in, out] is the node of the user thread that is about to + * get a processor allocated. + * + * @param[in, out] victim is the victim node of the thread to preempt. + * + * @param[in, out] victim_idle is the idle thread used by the victim node or NULL. * - * @return The preempted thread. + * @param allocate_processor The function for allocation of a processor for the new thread. */ -static inline Thread_Control *_Scheduler_SMP_Preempt( +static inline void _Scheduler_SMP_Preempt( Scheduler_Context *context, Scheduler_Node *scheduled, Scheduler_Node *victim, + Thread_Control *victim_idle, Scheduler_SMP_Allocate_processor allocate_processor ) { - Thread_Control *victim_thread; - ISR_lock_Context scheduler_lock_context; - Per_CPU_Control *victim_cpu; + Thread_Control *victim_owner; + ISR_lock_Context lock_context; + Per_CPU_Control *cpu; - victim_thread = _Scheduler_Node_get_user( victim ); _Scheduler_SMP_Node_change_state( victim, SCHEDULER_SMP_NODE_READY ); - _Thread_Scheduler_acquire_critical( victim_thread, &scheduler_lock_context ); - - victim_cpu = _Thread_Get_CPU( victim_thread ); + victim_owner = _Scheduler_Node_get_owner( victim ); + _Thread_Scheduler_acquire_critical( victim_owner, &lock_context ); - if ( victim_thread->Scheduler.state == THREAD_SCHEDULER_SCHEDULED ) { - _Scheduler_Thread_change_state( victim_thread, THREAD_SCHEDULER_READY ); + if ( RTEMS_PREDICT_TRUE( victim_idle == NULL ) ) { + if ( victim_owner->Scheduler.state == THREAD_SCHEDULER_SCHEDULED ) { + _Scheduler_Thread_change_state( victim_owner, THREAD_SCHEDULER_READY ); - if ( victim_thread->Scheduler.helping_nodes > 0 ) { - ISR_lock_Context per_cpu_lock_context; - - _Per_CPU_Acquire( victim_cpu, &per_cpu_lock_context ); - _Chain_Append_unprotected( - &victim_cpu->Threads_in_need_for_help, - &victim_thread->Scheduler.Help_node - ); - _Per_CPU_Release( victim_cpu, &per_cpu_lock_context ); + if ( victim_owner->Scheduler.helping_nodes > 0 ) { + _Scheduler_SMP_Request_ask_for_help( victim_owner ); + } } + + cpu = _Thread_Get_CPU( victim_owner ); + } else { + cpu = _Thread_Get_CPU( victim_idle ); } - _Thread_Scheduler_release_critical( victim_thread, &scheduler_lock_context ); + _Thread_Scheduler_release_critical( victim_owner, &lock_context ); _Scheduler_SMP_Allocate_processor( context, scheduled, - victim, - victim_cpu, + cpu, allocate_processor ); - - return victim_thread; } /** @@ -764,16 +885,19 @@ static inline Scheduler_Node *_Scheduler_SMP_Get_lowest_scheduled( Scheduler_Node *filter ) { - Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); - Chain_Control *scheduled = &self->Scheduled; - Scheduler_Node *lowest_scheduled = - (Scheduler_Node *) _Chain_Last( scheduled ); + Scheduler_SMP_Context *self; + Scheduler_Node *lowest_scheduled; (void) filter; - _Assert( &lowest_scheduled->Node.Chain != _Chain_Tail( scheduled ) ); + self = _Scheduler_SMP_Get_self( context ); + + _Assert( !_Chain_Is_empty( &self->Scheduled ) ); + lowest_scheduled = (Scheduler_Node *) _Chain_Last( &self->Scheduled ); + _Assert( - _Chain_Next( &lowest_scheduled->Node.Chain ) == _Chain_Tail( scheduled ) + _Chain_Next( &lowest_scheduled->Node.Chain ) == + _Chain_Tail( &self->Scheduled ) ); return lowest_scheduled; @@ -802,52 +926,43 @@ static inline void _Scheduler_SMP_Enqueue_to_scheduled( Scheduler_Node *lowest_scheduled, Scheduler_SMP_Insert insert_scheduled, Scheduler_SMP_Move move_from_scheduled_to_ready, - Scheduler_SMP_Allocate_processor allocate_processor + Scheduler_SMP_Move move_from_ready_to_scheduled, + Scheduler_SMP_Allocate_processor allocate_processor, + Scheduler_Get_idle_node get_idle_node, + Scheduler_Release_idle_node release_idle_node ) { - Scheduler_Try_to_schedule_action action; + Thread_Control *lowest_scheduled_idle; + Scheduler_SMP_Action action; - action = _Scheduler_Try_to_schedule_node( - context, - node, - _Scheduler_Node_get_idle( lowest_scheduled ), - _Scheduler_SMP_Get_idle_thread + lowest_scheduled_idle = _Scheduler_Release_idle_thread_if_necessary( + lowest_scheduled, + release_idle_node, + context ); - if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { + ( *move_from_scheduled_to_ready )( context, lowest_scheduled ); + + action = _Scheduler_SMP_Try_to_schedule( node, get_idle_node, context ); + + if ( RTEMS_PREDICT_TRUE( action == SCHEDULER_SMP_DO_SCHEDULE ) ) { _Scheduler_SMP_Preempt( context, node, lowest_scheduled, + lowest_scheduled_idle, allocate_processor ); ( *insert_scheduled )( context, node, priority ); - ( *move_from_scheduled_to_ready )( context, lowest_scheduled ); - - _Scheduler_Release_idle_thread( - context, - lowest_scheduled, - _Scheduler_SMP_Release_idle_thread - ); - } else if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE ) { - _Scheduler_SMP_Node_change_state( - lowest_scheduled, - SCHEDULER_SMP_NODE_READY - ); - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_SCHEDULED ); + } else { + _Assert( action == SCHEDULER_SMP_DO_NOT_SCHEDULE ); - ( *insert_scheduled )( context, node, priority ); - ( *move_from_scheduled_to_ready )( context, lowest_scheduled ); + if ( lowest_scheduled_idle != NULL ) { + (void) _Scheduler_Use_idle_thread( lowest_scheduled, get_idle_node, context ); + } - _Scheduler_Exchange_idle_thread( - node, - lowest_scheduled, - _Scheduler_Node_get_idle( lowest_scheduled ) - ); - } else { - _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); + ( *move_from_ready_to_scheduled )( context, lowest_scheduled ); } } @@ -881,8 +996,11 @@ static inline bool _Scheduler_SMP_Enqueue( Scheduler_SMP_Insert insert_ready, Scheduler_SMP_Insert insert_scheduled, Scheduler_SMP_Move move_from_scheduled_to_ready, + Scheduler_SMP_Move move_from_ready_to_scheduled, Scheduler_SMP_Get_lowest_scheduled get_lowest_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor + Scheduler_SMP_Allocate_processor allocate_processor, + Scheduler_Get_idle_node get_idle_node, + Scheduler_Release_idle_node release_idle_node ) { bool needs_help; @@ -890,7 +1008,13 @@ static inline bool _Scheduler_SMP_Enqueue( lowest_scheduled = ( *get_lowest_scheduled )( context, node ); - if ( ( *order )( &insert_priority, &lowest_scheduled->Node.Chain ) ) { + if ( + ( *order )( + &insert_priority, + &node->Node.Chain, + &lowest_scheduled->Node.Chain + ) + ) { _Scheduler_SMP_Enqueue_to_scheduled( context, node, @@ -898,10 +1022,14 @@ static inline bool _Scheduler_SMP_Enqueue( lowest_scheduled, insert_scheduled, move_from_scheduled_to_ready, - allocate_processor + move_from_ready_to_scheduled, + allocate_processor, + get_idle_node, + release_idle_node ); needs_help = false; } else { + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); ( *insert_ready )( context, node, insert_priority ); needs_help = true; } @@ -928,7 +1056,7 @@ static inline bool _Scheduler_SMP_Enqueue( * @param allocate_processor Function to allocate a processor to a node * based on the rules of the scheduler. */ -static inline bool _Scheduler_SMP_Enqueue_scheduled( +static inline void _Scheduler_SMP_Enqueue_scheduled( Scheduler_Context *context, Scheduler_Node *const node, Priority_Control insert_priority, @@ -938,12 +1066,22 @@ static inline bool _Scheduler_SMP_Enqueue_scheduled( Scheduler_SMP_Insert insert_ready, Scheduler_SMP_Insert insert_scheduled, Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor + Scheduler_SMP_Allocate_processor allocate_processor, + Scheduler_Get_idle_node get_idle_node, + Scheduler_Release_idle_node release_idle_node ) { + Thread_Control *node_idle; + + node_idle = _Scheduler_Release_idle_thread_if_necessary( + node, + release_idle_node, + context + ); + while ( true ) { - Scheduler_Node *highest_ready; - Scheduler_Try_to_schedule_action action; + Scheduler_Node *highest_ready; + Scheduler_SMP_Action action; highest_ready = ( *get_highest_ready )( context, node ); @@ -952,12 +1090,13 @@ static inline bool _Scheduler_SMP_Enqueue_scheduled( * it now on the scheduled or ready set. */ if ( - node->sticky_level > 0 - && ( *order )( &insert_priority, &highest_ready->Node.Chain ) + node->sticky_level > 0 && ( *order )( + &insert_priority, + &node->Node.Chain, + &highest_ready->Node.Chain + ) ) { - ( *insert_scheduled )( context, node, insert_priority ); - - if ( _Scheduler_Node_get_idle( node ) != NULL ) { + if ( node_idle != NULL ) { Thread_Control *owner; ISR_lock_Context lock_context; @@ -965,77 +1104,50 @@ static inline bool _Scheduler_SMP_Enqueue_scheduled( _Thread_Scheduler_acquire_critical( owner, &lock_context ); if ( owner->Scheduler.state == THREAD_SCHEDULER_READY ) { - _Thread_Scheduler_cancel_need_for_help( - owner, - _Thread_Get_CPU( owner ) - ); - _Scheduler_Discard_idle_thread( - context, - owner, - node, - _Scheduler_SMP_Release_idle_thread - ); + Per_CPU_Control *cpu; + + _Scheduler_SMP_Cancel_ask_for_help( owner ); _Scheduler_Thread_change_state( owner, THREAD_SCHEDULER_SCHEDULED ); + cpu = _Thread_Get_CPU( node_idle ); + _Thread_Set_CPU( owner, cpu ); + _Thread_Scheduler_release_critical( owner, &lock_context ); + _Thread_Dispatch_update_heir( _Per_CPU_Get(), cpu, owner ); + } else { + Thread_Control *new_idle; + + _Thread_Scheduler_release_critical( owner, &lock_context ); + new_idle = _Scheduler_Use_idle_thread( node, get_idle_node, context ); + _Assert_Unused_variable_equals( new_idle, node_idle ); } - - _Thread_Scheduler_release_critical( owner, &lock_context ); } - return false; + ( *insert_scheduled )( context, node, insert_priority ); + + return; } - action = _Scheduler_Try_to_schedule_node( - context, + action = _Scheduler_SMP_Try_to_schedule( highest_ready, - _Scheduler_Node_get_idle( node ), - _Scheduler_SMP_Get_idle_thread + get_idle_node, + context ); - if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { - Thread_Control *idle; - + if ( RTEMS_PREDICT_TRUE( action == SCHEDULER_SMP_DO_SCHEDULE ) ) { _Scheduler_SMP_Preempt( context, highest_ready, node, + node_idle, allocate_processor ); - ( *insert_ready )( context, node, insert_priority ); ( *move_from_ready_to_scheduled )( context, highest_ready ); - - idle = _Scheduler_Release_idle_thread( - context, - node, - _Scheduler_SMP_Release_idle_thread - ); - return ( idle == NULL ); - } else if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE ) { - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); - _Scheduler_SMP_Node_change_state( - highest_ready, - SCHEDULER_SMP_NODE_SCHEDULED - ); - ( *insert_ready )( context, node, insert_priority ); - ( *move_from_ready_to_scheduled )( context, highest_ready ); - - _Scheduler_Exchange_idle_thread( - highest_ready, - node, - _Scheduler_Node_get_idle( node ) - ); - return false; - } else { - _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); - - _Scheduler_SMP_Node_change_state( - highest_ready, - SCHEDULER_SMP_NODE_BLOCKED - ); - - ( *extract_from_ready )( context, highest_ready ); + return; } + + _Assert( action == SCHEDULER_SMP_DO_NOT_SCHEDULE ); + ( *extract_from_ready )( context, highest_ready ); } } @@ -1059,7 +1171,9 @@ static inline void _Scheduler_SMP_Extract_from_scheduled( * * @param context The scheduler context instance. * @param victim The node of the thread that is repressed by the newly scheduled thread. - * @param victim_cpu The cpu to allocate. + * @param cpu is the processor to allocate. + * @param extract_from_scheduled Function to extract a node from the set of + * scheduled nodes. * @param extract_from_ready Function to extract a node from the set of * ready nodes. * @param get_highest_ready Function to get the highest ready node. @@ -1071,46 +1185,44 @@ static inline void _Scheduler_SMP_Extract_from_scheduled( static inline void _Scheduler_SMP_Schedule_highest_ready( Scheduler_Context *context, Scheduler_Node *victim, - Per_CPU_Control *victim_cpu, + Per_CPU_Control *cpu, + Scheduler_SMP_Extract extract_from_scheduled, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor + Scheduler_SMP_Allocate_processor allocate_processor, + Scheduler_Get_idle_node get_idle_node ) { - Scheduler_Try_to_schedule_action action; + Scheduler_SMP_Action action; - do { + _Scheduler_SMP_Node_change_state( victim, SCHEDULER_SMP_NODE_BLOCKED ); + ( *extract_from_scheduled )( context, victim ); + + while ( true ) { Scheduler_Node *highest_ready = ( *get_highest_ready )( context, victim ); - action = _Scheduler_Try_to_schedule_node( - context, + action = _Scheduler_SMP_Try_to_schedule( highest_ready, - NULL, - _Scheduler_SMP_Get_idle_thread + get_idle_node, + context ); - if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { + if ( RTEMS_PREDICT_TRUE( action == SCHEDULER_SMP_DO_SCHEDULE ) ) { _Scheduler_SMP_Allocate_processor( context, highest_ready, - victim, - victim_cpu, + cpu, allocate_processor ); ( *move_from_ready_to_scheduled )( context, highest_ready ); - } else { - _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); - - _Scheduler_SMP_Node_change_state( - highest_ready, - SCHEDULER_SMP_NODE_BLOCKED - ); - - ( *extract_from_ready )( context, highest_ready ); + return; } - } while ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); + + _Assert( action == SCHEDULER_SMP_DO_NOT_SCHEDULE ); + ( *extract_from_ready )( context, highest_ready ); + } } /** @@ -1118,7 +1230,6 @@ static inline void _Scheduler_SMP_Schedule_highest_ready( * * @param context The scheduler context instance. * @param victim The node of the thread that is repressed by the newly scheduled thread. - * @param victim_cpu The cpu to allocate. * @param extract_from_ready Function to extract a node from the set of * ready nodes. * @param get_highest_ready Function to get the highest ready node. @@ -1130,45 +1241,49 @@ static inline void _Scheduler_SMP_Schedule_highest_ready( static inline void _Scheduler_SMP_Preempt_and_schedule_highest_ready( Scheduler_Context *context, Scheduler_Node *victim, - Per_CPU_Control *victim_cpu, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor + Scheduler_SMP_Allocate_processor allocate_processor, + Scheduler_Get_idle_node get_idle_node, + Scheduler_Release_idle_node release_idle_node ) { - Scheduler_Try_to_schedule_action action; + Thread_Control *victim_idle; + Scheduler_SMP_Action action; - do { + _Scheduler_SMP_Node_change_state( victim, SCHEDULER_SMP_NODE_READY ); + victim_idle = _Scheduler_Release_idle_thread_if_necessary( + victim, + release_idle_node, + context + ); + + while ( true ) { Scheduler_Node *highest_ready = ( *get_highest_ready )( context, victim ); - action = _Scheduler_Try_to_schedule_node( - context, + action = _Scheduler_SMP_Try_to_schedule( highest_ready, - NULL, - _Scheduler_SMP_Get_idle_thread + get_idle_node, + context ); - if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { + if ( RTEMS_PREDICT_TRUE( action == SCHEDULER_SMP_DO_SCHEDULE ) ) { _Scheduler_SMP_Preempt( context, highest_ready, victim, + victim_idle, allocate_processor ); ( *move_from_ready_to_scheduled )( context, highest_ready ); - } else { - _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); - - _Scheduler_SMP_Node_change_state( - highest_ready, - SCHEDULER_SMP_NODE_BLOCKED - ); - - ( *extract_from_ready )( context, highest_ready ); + return; } - } while ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); + + _Assert( action == SCHEDULER_SMP_DO_NOT_SCHEDULE ); + ( *extract_from_ready )( context, highest_ready ); + } } /** @@ -1195,39 +1310,61 @@ static inline void _Scheduler_SMP_Block( Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor + Scheduler_SMP_Allocate_processor allocate_processor, + Scheduler_Get_idle_node get_idle_node ) { + int sticky_level; + ISR_lock_Context lock_context; Scheduler_SMP_Node_state node_state; - Per_CPU_Control *thread_cpu; + Per_CPU_Control *cpu; - node_state = _Scheduler_SMP_Node_state( node ); + sticky_level = node->sticky_level; + --sticky_level; + node->sticky_level = sticky_level; + _Assert( sticky_level >= 0 ); - thread_cpu = _Scheduler_Block_node( - context, - thread, - node, - node_state == SCHEDULER_SMP_NODE_SCHEDULED, - _Scheduler_SMP_Get_idle_thread - ); + _Thread_Scheduler_acquire_critical( thread, &lock_context ); + _Scheduler_SMP_Cancel_ask_for_help( thread ); + cpu = _Thread_Get_CPU( thread ); + _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_BLOCKED ); + _Thread_Scheduler_release_critical( thread, &lock_context ); - if ( thread_cpu != NULL ) { - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); + node_state = _Scheduler_SMP_Node_state( node ); - if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - ( *extract_from_scheduled )( context, node ); - _Scheduler_SMP_Schedule_highest_ready( - context, - node, - thread_cpu, - extract_from_ready, - get_highest_ready, - move_from_ready_to_scheduled, - allocate_processor - ); - } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { - ( *extract_from_ready )( context, node ); + if ( RTEMS_PREDICT_FALSE( sticky_level > 0 ) ) { + if ( + node_state == SCHEDULER_SMP_NODE_SCHEDULED && + _Scheduler_Node_get_idle( node ) == NULL + ) { + Thread_Control *idle; + + idle = _Scheduler_Use_idle_thread( node, get_idle_node, context ); + _Thread_Set_CPU( idle, cpu ); + _Thread_Dispatch_update_heir( _Per_CPU_Get(), cpu, idle ); } + + return; + } + + _Assert( _Scheduler_Node_get_user( node ) == thread ); + _Assert( _Scheduler_Node_get_idle( node ) == NULL ); + + if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { + _Scheduler_SMP_Schedule_highest_ready( + context, + node, + cpu, + extract_from_scheduled, + extract_from_ready, + get_highest_ready, + move_from_ready_to_scheduled, + allocate_processor, + get_idle_node + ); + } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); + ( *extract_from_ready )( context, node ); } } @@ -1242,52 +1379,60 @@ static inline void _Scheduler_SMP_Block( * of a context. */ static inline void _Scheduler_SMP_Unblock( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - Scheduler_SMP_Update update, - Scheduler_SMP_Enqueue enqueue + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + Scheduler_SMP_Update update, + Scheduler_SMP_Enqueue enqueue, + Scheduler_Release_idle_node release_idle_node ) { Scheduler_SMP_Node_state node_state; - bool unblock; + Priority_Control priority; + + _Assert( _Chain_Is_node_off_chain( &thread->Scheduler.Help_node ) ); + + ++node->sticky_level; + _Assert( node->sticky_level > 0 ); node_state = _Scheduler_SMP_Node_state( node ); - unblock = _Scheduler_Unblock_node( - context, - thread, - node, - node_state == SCHEDULER_SMP_NODE_SCHEDULED, - _Scheduler_SMP_Release_idle_thread - ); - if ( unblock ) { - Priority_Control priority; - bool needs_help; + if ( RTEMS_PREDICT_FALSE( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) ) { + _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED ); + _Scheduler_Discard_idle_thread( + thread, + node, + release_idle_node, + context + ); - priority = _Scheduler_Node_get_priority( node ); - priority = SCHEDULER_PRIORITY_PURIFY( priority ); + return; + } - if ( priority != _Scheduler_SMP_Node_priority( node ) ) { - ( *update )( context, node, priority ); - } + _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_READY ); - if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) { - Priority_Control insert_priority; + priority = _Scheduler_Node_get_priority( node ); + priority = SCHEDULER_PRIORITY_PURIFY( priority ); - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); - insert_priority = SCHEDULER_PRIORITY_APPEND( priority ); - needs_help = ( *enqueue )( context, node, insert_priority ); - } else { - _Assert( node_state == SCHEDULER_SMP_NODE_READY ); - _Assert( node->sticky_level > 0 ); - _Assert( node->idle == NULL ); - needs_help = true; - } + if ( priority != _Scheduler_SMP_Node_priority( node ) ) { + ( *update )( context, node, priority ); + } + + if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) { + Priority_Control insert_priority; + bool needs_help; + + insert_priority = SCHEDULER_PRIORITY_APPEND( priority ); + needs_help = ( *enqueue )( context, node, insert_priority ); - if ( needs_help ) { - _Scheduler_Ask_for_help( thread ); + if ( needs_help && thread->Scheduler.helping_nodes > 0 ) { + _Scheduler_SMP_Request_ask_for_help( thread ); } + } else { + _Assert( node_state == SCHEDULER_SMP_NODE_READY ); + _Assert( node->sticky_level > 0 ); + _Assert( node->idle == NULL ); + _Scheduler_SMP_Request_ask_for_help( thread ); } } @@ -1302,6 +1447,8 @@ static inline void _Scheduler_SMP_Unblock( * @param context The scheduler instance context. * @param thread The thread for the operation. * @param[in, out] node The node to update the priority of. + * @param extract_from_scheduled Function to extract a node from the set of + * scheduled nodes. * @param extract_from_ready Function to extract a node from the ready * queue of the scheduler context. * @param update Function to update the priority of a node in the scheduler @@ -1311,14 +1458,15 @@ static inline void _Scheduler_SMP_Unblock( * @param ask_for_help Function to perform a help request. */ static inline void _Scheduler_SMP_Update_priority( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Update update, - Scheduler_SMP_Enqueue enqueue, - Scheduler_SMP_Enqueue enqueue_scheduled, - Scheduler_SMP_Ask_for_help ask_for_help + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + Scheduler_SMP_Extract extract_from_scheduled, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Update update, + Scheduler_SMP_Enqueue enqueue, + Scheduler_SMP_Enqueue_scheduled enqueue_scheduled, + Scheduler_SMP_Ask_for_help ask_for_help ) { Priority_Control priority; @@ -1339,7 +1487,7 @@ static inline void _Scheduler_SMP_Update_priority( node_state = _Scheduler_SMP_Node_state( node ); if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - _Scheduler_SMP_Extract_from_scheduled( context, node ); + ( *extract_from_scheduled )( context, node ); ( *update )( context, node, priority ); ( *enqueue_scheduled )( context, node, insert_priority ); } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { @@ -1361,21 +1509,23 @@ static inline void _Scheduler_SMP_Update_priority( * @param context The scheduler instance context. * @param thread The thread for the operation. * @param node The node of the thread that yields. + * @param extract_from_scheduled Function to extract a node from the set of + * scheduled nodes. * @param extract_from_ready Function to extract a node from the ready * queue of the scheduler context. * @param enqueue Function to enqueue a node with a given priority. * @param enqueue_scheduled Function to enqueue a scheduled node. */ static inline void _Scheduler_SMP_Yield( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Enqueue enqueue, - Scheduler_SMP_Enqueue enqueue_scheduled + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + Scheduler_SMP_Extract extract_from_scheduled, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Enqueue enqueue, + Scheduler_SMP_Enqueue_scheduled enqueue_scheduled ) { - bool needs_help; Scheduler_SMP_Node_state node_state; Priority_Control insert_priority; @@ -1384,19 +1534,11 @@ static inline void _Scheduler_SMP_Yield( insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - _Scheduler_SMP_Extract_from_scheduled( context, node ); + ( *extract_from_scheduled )( context, node ); ( *enqueue_scheduled )( context, node, insert_priority ); - needs_help = false; } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { ( *extract_from_ready )( context, node ); - - needs_help = ( *enqueue )( context, node, insert_priority ); - } else { - needs_help = true; - } - - if ( needs_help ) { - _Scheduler_Ask_for_help( thread ); + (void) ( *enqueue )( context, node, insert_priority ); } } @@ -1456,7 +1598,8 @@ static inline bool _Scheduler_SMP_Ask_for_help( Scheduler_SMP_Insert insert_scheduled, Scheduler_SMP_Move move_from_scheduled_to_ready, Scheduler_SMP_Get_lowest_scheduled get_lowest_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor + Scheduler_SMP_Allocate_processor allocate_processor, + Scheduler_Release_idle_node release_idle_node ) { Scheduler_Node *lowest_scheduled; @@ -1485,49 +1628,54 @@ static inline bool _Scheduler_SMP_Ask_for_help( insert_priority = _Scheduler_SMP_Node_priority( node ); - if ( ( *order )( &insert_priority, &lowest_scheduled->Node.Chain ) ) { - _Thread_Scheduler_cancel_need_for_help( - thread, - _Thread_Get_CPU( thread ) - ); + if ( + ( *order )( + &insert_priority, + &node->Node.Chain, + &lowest_scheduled->Node.Chain + ) + ) { + Thread_Control *lowest_scheduled_idle; + + _Scheduler_SMP_Cancel_ask_for_help( thread ); _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED ); _Thread_Scheduler_release_critical( thread, &lock_context ); + lowest_scheduled_idle = _Scheduler_Release_idle_thread_if_necessary( + lowest_scheduled, + release_idle_node, + context + ); + _Scheduler_SMP_Preempt( context, node, lowest_scheduled, + lowest_scheduled_idle, allocate_processor ); - ( *insert_scheduled )( context, node, insert_priority ); ( *move_from_scheduled_to_ready )( context, lowest_scheduled ); + ( *insert_scheduled )( context, node, insert_priority ); - _Scheduler_Release_idle_thread( - context, - lowest_scheduled, - _Scheduler_SMP_Release_idle_thread - ); success = true; } else { _Thread_Scheduler_release_critical( thread, &lock_context ); + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); ( *insert_ready )( context, node, insert_priority ); success = false; } } else if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - _Thread_Scheduler_cancel_need_for_help( - thread, - _Thread_Get_CPU( thread ) - ); + _Scheduler_SMP_Cancel_ask_for_help( thread ); + _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED ); + _Thread_Scheduler_release_critical( thread, &lock_context ); _Scheduler_Discard_idle_thread( - context, thread, node, - _Scheduler_SMP_Release_idle_thread + release_idle_node, + context ); - _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED ); - _Thread_Scheduler_release_critical( thread, &lock_context ); success = true; } else { _Thread_Scheduler_release_critical( thread, &lock_context ); @@ -1580,6 +1728,8 @@ static inline void _Scheduler_SMP_Reconsider_help_request( * @param[in, out] thread The thread to change to @a next_state. * @param[in, out] node The node to withdraw. * @param next_state The new state for @a thread. + * @param extract_from_scheduled Function to extract a node from the set of + * scheduled nodes. * @param extract_from_ready Function to extract a node from the ready queue * of the scheduler context. * @param get_highest_ready Function to get the highest ready node. @@ -1593,10 +1743,12 @@ static inline void _Scheduler_SMP_Withdraw_node( Thread_Control *thread, Scheduler_Node *node, Thread_Scheduler_state next_state, + Scheduler_SMP_Extract extract_from_scheduled, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor + Scheduler_SMP_Allocate_processor allocate_processor, + Scheduler_Get_idle_node get_idle_node ) { ISR_lock_Context lock_context; @@ -1605,27 +1757,32 @@ static inline void _Scheduler_SMP_Withdraw_node( _Thread_Scheduler_acquire_critical( thread, &lock_context ); node_state = _Scheduler_SMP_Node_state( node ); - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - Per_CPU_Control *thread_cpu; + Per_CPU_Control *cpu; - thread_cpu = _Thread_Get_CPU( thread ); + _Assert( thread == _Scheduler_Node_get_user( node ) ); + cpu = _Thread_Get_CPU( thread ); _Scheduler_Thread_change_state( thread, next_state ); _Thread_Scheduler_release_critical( thread, &lock_context ); - _Scheduler_SMP_Extract_from_scheduled( context, node ); + _Assert( _Scheduler_Node_get_user( node ) == thread ); + _Assert( _Scheduler_Node_get_idle( node ) == NULL ); + _Scheduler_SMP_Schedule_highest_ready( context, node, - thread_cpu, + cpu, + extract_from_scheduled, extract_from_ready, get_highest_ready, move_from_ready_to_scheduled, - allocate_processor + allocate_processor, + get_idle_node ); } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { _Thread_Scheduler_release_critical( thread, &lock_context ); + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); ( *extract_from_ready )( context, node ); } else { _Assert( node_state == SCHEDULER_SMP_NODE_BLOCKED ); @@ -1634,6 +1791,97 @@ static inline void _Scheduler_SMP_Withdraw_node( } /** + * @brief Makes the node sticky. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to make sticky. + */ +static inline void _Scheduler_SMP_Make_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + Scheduler_SMP_Update update, + Scheduler_SMP_Enqueue enqueue +) +{ + Scheduler_SMP_Node_state node_state; + + node_state = _Scheduler_SMP_Node_state( node ); + + if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) { + Scheduler_Context *context; + Priority_Control insert_priority; + Priority_Control priority; + + context = _Scheduler_Get_context( scheduler ); + priority = _Scheduler_Node_get_priority( node ); + priority = SCHEDULER_PRIORITY_PURIFY( priority ); + + if ( priority != _Scheduler_SMP_Node_priority( node ) ) { + ( *update )( context, node, priority ); + } + + insert_priority = SCHEDULER_PRIORITY_APPEND( priority ); + (void) ( *enqueue )( context, node, insert_priority ); + } +} + +/** + * @brief Cleans the sticky property from the node. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to clean the sticky property. + */ +static inline void _Scheduler_SMP_Clean_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + Scheduler_SMP_Extract extract_from_scheduled, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Get_highest_ready get_highest_ready, + Scheduler_SMP_Move move_from_ready_to_scheduled, + Scheduler_SMP_Allocate_processor allocate_processor, + Scheduler_Get_idle_node get_idle_node, + Scheduler_Release_idle_node release_idle_node +) +{ + Scheduler_SMP_Node_state node_state; + + node_state = _Scheduler_SMP_Node_state( node ); + + if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { + Thread_Control *idle; + + idle = _Scheduler_Node_get_idle( node ); + + if ( idle != NULL ) { + Scheduler_Context *context; + + context = _Scheduler_Get_context( scheduler ); + + _Scheduler_Release_idle_thread( node, idle, release_idle_node, context ); + _Scheduler_SMP_Schedule_highest_ready( + context, + node, + _Thread_Get_CPU( idle ), + extract_from_scheduled, + extract_from_ready, + get_highest_ready, + move_from_ready_to_scheduled, + allocate_processor, + get_idle_node + ); + } + } +} + +/** * @brief Starts the idle thread on the given processor. * * @param context The scheduler context instance. @@ -1660,7 +1908,6 @@ static inline void _Scheduler_SMP_Do_start_idle( _Thread_Set_CPU( idle, cpu ); ( *register_idle )( context, &node->Base, cpu ); _Chain_Append_unprotected( &self->Scheduled, &node->Base.Node.Chain ); - _Scheduler_SMP_Release_idle_thread( &self->Base, idle ); } /** @@ -1673,11 +1920,11 @@ static inline void _Scheduler_SMP_Do_start_idle( * @param register_idle Function to register the idle thread for a cpu. */ static inline void _Scheduler_SMP_Add_processor( - Scheduler_Context *context, - Thread_Control *idle, - Scheduler_SMP_Has_ready has_ready, - Scheduler_SMP_Enqueue enqueue_scheduled, - Scheduler_SMP_Register_idle register_idle + Scheduler_Context *context, + Thread_Control *idle, + Scheduler_SMP_Has_ready has_ready, + Scheduler_SMP_Enqueue_scheduled enqueue_scheduled, + Scheduler_SMP_Register_idle register_idle ) { Scheduler_SMP_Context *self; @@ -1685,7 +1932,6 @@ static inline void _Scheduler_SMP_Add_processor( self = _Scheduler_SMP_Get_self( context ); idle->Scheduler.state = THREAD_SCHEDULER_SCHEDULED; - _Scheduler_SMP_Release_idle_thread( &self->Base, idle ); node = _Thread_Scheduler_get_home_node( idle ); _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_SCHEDULED ); ( *register_idle )( context, node, _Thread_Get_CPU( idle ) ); @@ -1706,6 +1952,8 @@ static inline void _Scheduler_SMP_Add_processor( * * @param context The scheduler context instance. * @param cpu The processor to remove from. + * @param extract_from_scheduled Function to extract a node from the set of + * scheduled nodes. * @param extract_from_ready Function to extract a node from the ready queue * of the scheduler context. * @param enqueue Function to enqueue a node with a given priority. @@ -1713,10 +1961,13 @@ static inline void _Scheduler_SMP_Add_processor( * @return The idle thread of @a cpu. */ static inline Thread_Control *_Scheduler_SMP_Remove_processor( - Scheduler_Context *context, - Per_CPU_Control *cpu, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Enqueue enqueue + Scheduler_Context *context, + Per_CPU_Control *cpu, + Scheduler_SMP_Extract extract_from_scheduled, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Enqueue enqueue, + Scheduler_Get_idle_node get_idle_node, + Scheduler_Release_idle_node release_idle_node ) { Scheduler_SMP_Context *self; @@ -1736,39 +1987,37 @@ static inline Thread_Control *_Scheduler_SMP_Remove_processor( chain_node = _Chain_Next( chain_node ); } while ( _Thread_Get_CPU( victim_user ) != cpu ); - _Scheduler_SMP_Extract_from_scheduled( context, victim_node ); + ( *extract_from_scheduled )( &self->Base, victim_node ); victim_owner = _Scheduler_Node_get_owner( victim_node ); if ( !victim_owner->is_idle ) { - Scheduler_Node *idle_node; + Thread_Control *victim_idle; + Scheduler_Node *idle_node; + Priority_Control insert_priority; - _Scheduler_Release_idle_thread( - &self->Base, + victim_idle = _Scheduler_Release_idle_thread_if_necessary( victim_node, - _Scheduler_SMP_Release_idle_thread + release_idle_node, + &self->Base ); - idle = _Scheduler_SMP_Get_idle_thread( &self->Base ); - idle_node = _Thread_Scheduler_get_home_node( idle ); - ( *extract_from_ready )( &self->Base, idle_node ); + idle_node = ( *get_idle_node )( &self->Base ); + idle = _Scheduler_Node_get_owner( idle_node ); _Scheduler_SMP_Preempt( &self->Base, idle_node, victim_node, + victim_idle, _Scheduler_SMP_Allocate_processor_exact ); - if ( !_Chain_Is_empty( &self->Scheduled ) ) { - Priority_Control insert_priority; - - insert_priority = _Scheduler_SMP_Node_priority( victim_node ); - insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); - ( *enqueue )( context, victim_node, insert_priority ); - } + _Assert( !_Chain_Is_empty( &self->Scheduled ) ); + insert_priority = _Scheduler_SMP_Node_priority( victim_node ); + insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); + ( *enqueue )( &self->Base, victim_node, insert_priority ); } else { _Assert( victim_owner == victim_user ); _Assert( _Scheduler_Node_get_idle( victim_node ) == NULL ); idle = victim_owner; - _Scheduler_SMP_Exctract_idle_thread( idle ); } return idle; @@ -1784,6 +2033,8 @@ static inline Thread_Control *_Scheduler_SMP_Remove_processor( * @param[in, out] node The node to set the affinity of. * @param arg The affinity for @a node. * @param set_affinity Function to set the affinity of a node. + * @param extract_from_scheduled Function to extract a node from the set of + * scheduled nodes. * @param extract_from_ready Function to extract a node from the ready queue * of the scheduler context. * @param get_highest_ready Function to get the highest ready node. @@ -1799,11 +2050,14 @@ static inline void _Scheduler_SMP_Set_affinity( Scheduler_Node *node, void *arg, Scheduler_SMP_Set_affinity set_affinity, + Scheduler_SMP_Extract extract_from_scheduled, Scheduler_SMP_Extract extract_from_ready, Scheduler_SMP_Get_highest_ready get_highest_ready, Scheduler_SMP_Move move_from_ready_to_scheduled, Scheduler_SMP_Enqueue enqueue, - Scheduler_SMP_Allocate_processor allocate_processor + Scheduler_SMP_Allocate_processor allocate_processor, + Scheduler_Get_idle_node get_idle_node, + Scheduler_Release_idle_node release_idle_node ) { Scheduler_SMP_Node_state node_state; @@ -1814,15 +2068,16 @@ static inline void _Scheduler_SMP_Set_affinity( insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - _Scheduler_SMP_Extract_from_scheduled( context, node ); + ( *extract_from_scheduled )( context, node ); _Scheduler_SMP_Preempt_and_schedule_highest_ready( context, node, - _Thread_Get_CPU( thread ), extract_from_ready, get_highest_ready, move_from_ready_to_scheduled, - allocate_processor + allocate_processor, + get_idle_node, + release_idle_node ); ( *set_affinity )( context, node, arg ); ( *enqueue )( context, node, insert_priority ); diff --git a/cpukit/include/rtems/score/schedulerstrongapa.h b/cpukit/include/rtems/score/schedulerstrongapa.h index a3a19d80c1..9bf0e615b6 100644 --- a/cpukit/include/rtems/score/schedulerstrongapa.h +++ b/cpukit/include/rtems/score/schedulerstrongapa.h @@ -11,7 +11,7 @@ /* * Copyright (C) 2020 Richi Dubey - * Copyright (C) 2013, 2018 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2013, 2018 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -161,6 +161,8 @@ typedef struct { _Scheduler_strong_APA_Ask_for_help, \ _Scheduler_strong_APA_Reconsider_help_request, \ _Scheduler_strong_APA_Withdraw_node, \ + _Scheduler_strong_APA_Make_sticky, \ + _Scheduler_strong_APA_Clean_sticky, \ _Scheduler_default_Pin_or_unpin_not_supported, \ _Scheduler_default_Pin_or_unpin_not_supported, \ _Scheduler_strong_APA_Add_processor, \ @@ -169,7 +171,6 @@ typedef struct { _Scheduler_default_Node_destroy, \ _Scheduler_default_Release_job, \ _Scheduler_default_Cancel_job, \ - _Scheduler_default_Tick, \ _Scheduler_strong_APA_Start_idle, \ _Scheduler_strong_APA_Set_affinity \ } @@ -280,6 +281,66 @@ void _Scheduler_strong_APA_Withdraw_node( ); /** + * @brief Makes the node sticky. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to make sticky. + */ +void _Scheduler_strong_APA_Make_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** + * @brief Cleans the sticky property from the node. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to clean the sticky property. + */ +void _Scheduler_strong_APA_Clean_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** + * @brief Makes the node sticky. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to make sticky. + */ +void _Scheduler_strong_APA_Make_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** + * @brief Cleans the sticky property from the node. + * + * @param scheduler is the scheduler of the node. + * + * @param[in, out] the_thread is the thread owning the node. + * + * @param[in, out] node is the scheduler node to clean the sticky property. + */ +void _Scheduler_strong_APA_sticky( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** * @brief Adds the idle thread to a processor. * * @param scheduler The scheduler control instance. diff --git a/cpukit/include/rtems/score/scheduleruniimpl.h b/cpukit/include/rtems/score/scheduleruniimpl.h new file mode 100644 index 0000000000..9fe9ec394c --- /dev/null +++ b/cpukit/include/rtems/score/scheduleruniimpl.h @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreScheduler + * + * @brief This header file provides interfaces of the supporting the + * implementation of uniprocessor schedulers. + */ + +/* + * Copyright (C) 2010 Gedare Bloom. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * Copyright (C) 2014, 2022 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERUNIIMPL_H +#define _RTEMS_SCORE_SCHEDULERUNIIMPL_H + +#include <rtems/score/schedulerimpl.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSScoreScheduler + * + * @{ + */ + +/** + * @brief Updates the heir thread of the processor. + * + * @param[in, out] heir is the current heir thread. + * @param[in, out] new_heir is the new heir thread. + */ +static inline void _Scheduler_uniprocessor_Update_heir( + Thread_Control *heir, + Thread_Control *new_heir +) +{ + _Assert( heir != new_heir ); +#if defined(RTEMS_SMP) + /* + * We need this state only for _Thread_Get_CPU_time_used_locked(). Cannot + * use _Scheduler_Thread_change_state() since THREAD_SCHEDULER_BLOCKED to + * THREAD_SCHEDULER_BLOCKED state changes are illegal for the real SMP + * schedulers. + */ + heir->Scheduler.state = THREAD_SCHEDULER_BLOCKED; + new_heir->Scheduler.state = THREAD_SCHEDULER_SCHEDULED; +#endif + _Thread_Update_CPU_time_used( heir, _Thread_Get_CPU( heir ) ); + _Thread_Heir = new_heir; + _Thread_Dispatch_necessary = true; +} + +/** + * @brief Updates the heir thread of the processor if the current heir is + * not equal to the new heir thread. + * + * The update takes place even if the current heir thread is not preemptible. + * + * @param[in, out] new_heir is the new heir thread. + */ +static inline void _Scheduler_uniprocessor_Update_heir_if_necessary( + Thread_Control *new_heir +) +{ + Thread_Control *heir = _Thread_Heir; + + if ( heir != new_heir ) { + _Scheduler_uniprocessor_Update_heir( heir, new_heir ); + } +} + +/** + * @brief Updates the heir thread of the processor if the current heir thread + * is preemptible. + * + * @param[in, out] heir is the current heir thread. + * @param[in, out] new_heir is the new heir thread. + */ +static inline void _Scheduler_uniprocessor_Update_heir_if_preemptible( + Thread_Control *heir, + Thread_Control *new_heir +) +{ + if ( heir != new_heir && heir->is_preemptible ) { + _Scheduler_uniprocessor_Update_heir( heir, new_heir ); + } +} + +/** + * @brief Blocks the thread. + * + * @param scheduler is the scheduler. + * @param the_thread is the thread to block. + * @param node is the scheduler node of the thread. + * @param extract is the handler to extract the thread. + * @param get_highest_ready is the handler to get the highest ready thread. + */ +static inline void _Scheduler_uniprocessor_Block( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + void ( *extract )( + const Scheduler_Control *, + Thread_Control *, + Scheduler_Node * + ), + Thread_Control *( *get_highest_ready )( const Scheduler_Control * ) +) +{ + ( *extract )( scheduler, the_thread, node ); + + /* TODO: flash critical section? */ + + if ( _Thread_Is_heir( the_thread ) ) { + Thread_Control *highest_ready; + + highest_ready = ( *get_highest_ready )( scheduler ); + _Scheduler_uniprocessor_Update_heir( _Thread_Heir, highest_ready ); + } +} + +/** + * @brief Schedule the unblocked thread if it is the highest ready thread. + * + * @param scheduler is the scheduler. + * @param the_thread is the thread. + * @param priority is the priority of the thread. + */ +static inline void _Scheduler_uniprocessor_Unblock( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Priority_Control priority +) +{ + Thread_Control *heir; + + heir = _Thread_Heir; + + /* + * If the thread is more important than the heir, then we have a new heir. + * This may or may not result in a context switch. If the current heir + * thread is preemptible, then we need to do a context switch. + */ + if ( priority < _Thread_Get_priority( heir ) ) { + _Scheduler_uniprocessor_Update_heir_if_preemptible( heir, the_thread ); + } +} + +/** + * @brief Schedules the highest ready thread if the current heir thread of the + * processor is preemptible. + * + * @param scheduler is the scheduler. + * @param get_highest_ready is the handler to get the highest ready thread. + */ +static inline void _Scheduler_uniprocessor_Schedule( + const Scheduler_Control *scheduler, + Thread_Control *( *get_highest_ready )( const Scheduler_Control * ) +) +{ + Thread_Control *highest_ready; + + highest_ready = ( *get_highest_ready )( scheduler ); + _Scheduler_uniprocessor_Update_heir_if_preemptible( + _Thread_Heir, + highest_ready + ); +} + +/** + * @brief Yields to the highest ready thread. + * + * @param scheduler is the scheduler. + * @param get_highest_ready is the handler to get the highest ready thread. + */ +static inline void _Scheduler_uniprocessor_Yield( + const Scheduler_Control *scheduler, + Thread_Control *( *get_highest_ready )( const Scheduler_Control * ) +) +{ + Thread_Control *highest_ready; + + highest_ready = ( *get_highest_ready )( scheduler ); + _Scheduler_uniprocessor_Update_heir_if_necessary( highest_ready ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_SCHEDULERUNIIMPL_H */ diff --git a/cpukit/include/rtems/score/semaphoreimpl.h b/cpukit/include/rtems/score/semaphoreimpl.h index 05bf9b20ee..6c0b62adcd 100644 --- a/cpukit/include/rtems/score/semaphoreimpl.h +++ b/cpukit/include/rtems/score/semaphoreimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SEMAPHOREIMPL_H diff --git a/cpukit/include/rtems/score/smp.h b/cpukit/include/rtems/score/smp.h index bd9cfaa5a6..2ca6ecc8fc 100644 --- a/cpukit/include/rtems/score/smp.h +++ b/cpukit/include/rtems/score/smp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SMP_H diff --git a/cpukit/include/rtems/score/smpbarrier.h b/cpukit/include/rtems/score/smpbarrier.h index 3d66003fd3..fc14859c41 100644 --- a/cpukit/include/rtems/score/smpbarrier.h +++ b/cpukit/include/rtems/score/smpbarrier.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. + * Copyright (C) 2013, 2014 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SMPBARRIER_H diff --git a/cpukit/include/rtems/score/smpimpl.h b/cpukit/include/rtems/score/smpimpl.h index e259105084..a8e3a3be15 100644 --- a/cpukit/include/rtems/score/smpimpl.h +++ b/cpukit/include/rtems/score/smpimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SMPIMPL_H @@ -21,7 +40,7 @@ #include <rtems/score/smp.h> #include <rtems/score/percpu.h> -#include <rtems/score/processormask.h> +#include <rtems/score/processormaskimpl.h> #include <rtems/fatal.h> #ifdef __cplusplus @@ -73,7 +92,8 @@ typedef enum { SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED, SMP_FATAL_SCHEDULER_PIN_OR_UNPIN_NOT_SUPPORTED, SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS, - SMP_FATAL_SCHEDULER_REQUIRES_EXACTLY_ONE_PROCESSOR + SMP_FATAL_SCHEDULER_REQUIRES_EXACTLY_ONE_PROCESSOR, + SMP_FATAL_MULTITASKING_START_ON_NOT_ONLINE_PROCESSOR } SMP_Fatal_code; /** @@ -146,12 +166,9 @@ RTEMS_NO_RETURN void _SMP_Start_multitasking_on_secondary_processor( * @param[in, out] cpu_self is the processor control of the processor executing * this function. * - * @return Returns the processed message. + * @param message is the message to process. */ -long unsigned _SMP_Process_message( - Per_CPU_Control *cpu_self, - long unsigned message -); +void _SMP_Process_message( Per_CPU_Control *cpu_self, long unsigned message ); /** * @brief Tries to process the current SMP message. @@ -180,10 +197,8 @@ void _SMP_Try_to_process_message( * * @param[in, out] cpu_self is the processor control of the processor executing * this function. - * - * @return Returns the processed message. */ -static inline long unsigned _SMP_Inter_processor_interrupt_handler( +static inline void _SMP_Inter_processor_interrupt_handler( Per_CPU_Control *cpu_self ) { @@ -202,10 +217,8 @@ static inline long unsigned _SMP_Inter_processor_interrupt_handler( ); if ( RTEMS_PREDICT_FALSE( message != 0 ) ) { - return _SMP_Process_message( cpu_self, message ); + _SMP_Process_message( cpu_self, message ); } - - return message; } /** @@ -335,7 +348,7 @@ void _SMP_Synchronize( void ); * * @return The processor mask with all online processors. */ -RTEMS_INLINE_ROUTINE const Processor_mask *_SMP_Get_online_processors( void ) +static inline const Processor_mask *_SMP_Get_online_processors( void ) { #if defined(RTEMS_SMP) return &_SMP_Online_processors; @@ -350,7 +363,7 @@ RTEMS_INLINE_ROUTINE const Processor_mask *_SMP_Get_online_processors( void ) * @return True if inter-processor interrupts are needed for the correct system * operation, otherwise false. */ -RTEMS_INLINE_ROUTINE bool _SMP_Need_inter_processor_interrupts( void ) +static inline bool _SMP_Need_inter_processor_interrupts( void ) { /* * Use the configured processor maximum instead of the actual to allow diff --git a/cpukit/include/rtems/score/smplock.h b/cpukit/include/rtems/score/smplock.h index 5290358834..52324fc76c 100644 --- a/cpukit/include/rtems/score/smplock.h +++ b/cpukit/include/rtems/score/smplock.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,11 +13,28 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2013, 2016 embedded brains GmbH + * Copyright (C) 2013, 2016 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SMPLOCK_H diff --git a/cpukit/include/rtems/score/smplockmcs.h b/cpukit/include/rtems/score/smplockmcs.h index 512be44dda..89c66e9ebf 100644 --- a/cpukit/include/rtems/score/smplockmcs.h +++ b/cpukit/include/rtems/score/smplockmcs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,11 +10,28 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH + * Copyright (c) 2016 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SMPLOCKMCS_H diff --git a/cpukit/include/rtems/score/smplockseq.h b/cpukit/include/rtems/score/smplockseq.h index c64d128320..be0225b4dc 100644 --- a/cpukit/include/rtems/score/smplockseq.h +++ b/cpukit/include/rtems/score/smplockseq.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,11 +10,28 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH - * - * 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. + * Copyright (c) 2016 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_SCORE_SMPLOCKSEQ_H diff --git a/cpukit/include/rtems/score/smplockstats.h b/cpukit/include/rtems/score/smplockstats.h index 5ff47ec01e..913d551418 100644 --- a/cpukit/include/rtems/score/smplockstats.h +++ b/cpukit/include/rtems/score/smplockstats.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,11 +10,28 @@ */ /* - * Copyright (c) 2013, 2018 embedded brains GmbH + * Copyright (C) 2013, 2018 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SMPLOCKSTATS_H @@ -216,7 +235,7 @@ static inline void _SMP_lock_Stats_acquire_end( second = _CPU_Counter_read(); stats_context->acquire_instant = second; - delta = _CPU_Counter_difference( second, acquire_context->first ); + delta = second - acquire_context->first; ++stats->usage_count; @@ -251,7 +270,7 @@ static inline void _SMP_lock_Stats_release_update( stats = stats_context->stats; first = stats_context->acquire_instant; second = _CPU_Counter_read(); - delta = _CPU_Counter_difference( second, first ); + delta = second - first; stats->total_section_time += delta; diff --git a/cpukit/include/rtems/score/smplockticket.h b/cpukit/include/rtems/score/smplockticket.h index 4d2c4da372..d317ea5dd2 100644 --- a/cpukit/include/rtems/score/smplockticket.h +++ b/cpukit/include/rtems/score/smplockticket.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,11 +10,28 @@ */ /* - * Copyright (c) 2013, 2016 embedded brains GmbH + * Copyright (C) 2013, 2016 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SMPLOCKTICKET_H diff --git a/cpukit/include/rtems/score/stack.h b/cpukit/include/rtems/score/stack.h index ffa6368ba5..6746d6991b 100644 --- a/cpukit/include/rtems/score/stack.h +++ b/cpukit/include/rtems/score/stack.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,12 +11,29 @@ */ /* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * 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. + * Copyright (C) 2022 embedded brains GmbH & Co. KG + * Copyright (C) 1989, 2021 On-Line Applications Research Corporation (OAR) + * + * 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. */ #ifndef _RTEMS_SCORE_STACK_H @@ -86,15 +105,22 @@ typedef void ( *Stack_Allocator_free )( void *addr ); * The allocate for idle handler is optional even when the user thread stack * allocator and deallocator are configured. * - * @param cpu Index of the CPU for the IDLE thread using this stack - * @param stack_size The size of the stack area to allocate in bytes. + * @param cpu is the index of the CPU for the IDLE thread using this stack. * - * @retval NULL Not enough memory. - * @retval other Pointer to begin of stack area. + * @param stack_size[in, out] is pointer to a size_t object. On function + * entry, the object contains the proposed size of the stack area to allocate + * in bytes. The proposed size does not take the actual thread-local storage + * size of the application into account. The stack allocator can modify the + * size to ensure that there is enough space available in the stack area for + * the thread-local storage. + * + * @retval NULL There was not enough memory available to allocate a stack area. + * + * @return Returns the pointer to begin of the allocated stack area. */ typedef void *( *Stack_Allocator_allocate_for_idle )( uint32_t cpu, - size_t stack_size + size_t *stack_size ); /** @@ -146,7 +172,57 @@ extern const Stack_Allocator_free _Stack_Allocator_free; */ void _Stack_Allocator_do_initialize( void ); -/** @} */ +/** + * @brief Allocates the IDLE thread storage area from the workspace. + * + * If the thread storage area cannot be allocated, then the + * ::INTERNAL_ERROR_NO_MEMORY_FOR_IDLE_TASK_STACK fatal error will occur. + * + * @param unused is an unused parameter. + * + * @param stack_size[in] is pointer to a size_t object. On function entry, the + * object contains the size of the task storage area to allocate in bytes. + * + * @return Returns a pointer to the begin of the allocated task storage area. + */ +void *_Stack_Allocator_allocate_for_idle_workspace( + uint32_t unused, + size_t *storage_size +); + +/** + * @brief The size in bytes of the idle thread storage area used by + * _Stack_Allocator_allocate_for_idle_static(). + * + * Application provided via <rtems/confdefs.h>. + */ +extern const size_t _Stack_Allocator_allocate_for_idle_storage_size; + +/** + * @brief The thread storage areas used by + * _Stack_Allocator_allocate_for_idle_static(). + * + * Application provided via <rtems/confdefs.h>. + */ +extern char _Stack_Allocator_allocate_for_idle_storage_areas[]; + +/** + * @brief Allocates the IDLE thread storage from the memory statically + * allocated by <rtems/confdefs.h>. + * + * @param cpu_index is the index of the CPU for the IDLE thread using this stack. + * + * @param stack_size[out] is pointer to a size_t object. On function return, the + * object value is set to the value of + * ::_Stack_Allocator_allocate_for_idle_storage_size. + * + * @return Returns a pointer to the begin of the allocated task storage area. + */ +void *_Stack_Allocator_allocate_for_idle_static( + uint32_t cpu_index, + size_t *storage_size +); + /** * @brief The stack allocator allocate stack for idle thread handler. * @@ -155,6 +231,8 @@ void _Stack_Allocator_do_initialize( void ); extern const Stack_Allocator_allocate_for_idle _Stack_Allocator_allocate_for_idle; +/** @} */ + #ifdef __cplusplus } #endif diff --git a/cpukit/include/rtems/score/stackimpl.h b/cpukit/include/rtems/score/stackimpl.h index 330fd32be7..1df2f151e1 100644 --- a/cpukit/include/rtems/score/stackimpl.h +++ b/cpukit/include/rtems/score/stackimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2006. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_STACKIMPL_H @@ -44,7 +63,7 @@ extern "C" { * @param starting_address The starting_address for the new stack. * @param size The size of the stack in bytes. */ -RTEMS_INLINE_ROUTINE void _Stack_Initialize ( +static inline void _Stack_Initialize ( Stack_Control *the_stack, void *starting_address, size_t size @@ -62,7 +81,7 @@ RTEMS_INLINE_ROUTINE void _Stack_Initialize ( * * @return The minimum stack size. */ -RTEMS_INLINE_ROUTINE uint32_t _Stack_Minimum (void) +static inline uint32_t _Stack_Minimum (void) { return rtems_minimum_stack_size; } @@ -79,7 +98,7 @@ RTEMS_INLINE_ROUTINE uint32_t _Stack_Minimum (void) * @retval true @a size is large enough. * @retval false @a size is not large enough. */ -RTEMS_INLINE_ROUTINE bool _Stack_Is_enough( +static inline bool _Stack_Is_enough( size_t size, bool is_fp ) @@ -109,7 +128,7 @@ RTEMS_INLINE_ROUTINE bool _Stack_Is_enough( * * @return The appropriate stack size. */ -RTEMS_INLINE_ROUTINE size_t _Stack_Ensure_minimum ( +static inline size_t _Stack_Ensure_minimum ( size_t size ) { @@ -129,7 +148,7 @@ RTEMS_INLINE_ROUTINE size_t _Stack_Ensure_minimum ( * * @return Returns the extended stack size. */ -RTEMS_INLINE_ROUTINE size_t _Stack_Extend_size( +static inline size_t _Stack_Extend_size( size_t stack_size, bool is_fp ) diff --git a/cpukit/include/rtems/score/states.h b/cpukit/include/rtems/score/states.h index 6d996f3649..922ddb6e2b 100644 --- a/cpukit/include/rtems/score/states.h +++ b/cpukit/include/rtems/score/states.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2006. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_STATES_H diff --git a/cpukit/include/rtems/score/statesimpl.h b/cpukit/include/rtems/score/statesimpl.h index a3178b298c..aa90f3c27f 100644 --- a/cpukit/include/rtems/score/statesimpl.h +++ b/cpukit/include/rtems/score/statesimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2012. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_STATESIMPL_H @@ -152,7 +171,7 @@ extern "C" { * * @return This method returns the updated states value. */ -RTEMS_INLINE_ROUTINE States_Control _States_Set ( +static inline States_Control _States_Set ( States_Control states_to_set, States_Control current_state ) @@ -171,7 +190,7 @@ RTEMS_INLINE_ROUTINE States_Control _States_Set ( * * @return This method returns the updated states value. */ -RTEMS_INLINE_ROUTINE States_Control _States_Clear ( +static inline States_Control _States_Clear ( States_Control states_to_clear, States_Control current_state ) @@ -190,7 +209,7 @@ RTEMS_INLINE_ROUTINE States_Control _States_Clear ( * @retval true The state is ready. * @retval false The state is not ready. */ -RTEMS_INLINE_ROUTINE bool _States_Is_ready ( +static inline bool _States_Is_ready ( States_Control the_states ) { @@ -208,7 +227,7 @@ RTEMS_INLINE_ROUTINE bool _States_Is_ready ( * @retval true DORMANT state is set in @a the_states. * @retval false DORMANT state is not set in @a the_states. */ -RTEMS_INLINE_ROUTINE bool _States_Is_dormant ( +static inline bool _States_Is_dormant ( States_Control the_states ) { @@ -226,7 +245,7 @@ RTEMS_INLINE_ROUTINE bool _States_Is_dormant ( * @retval true SUSPENDED state is set in @a the_states. * @retval false SUSPENDED state is not set in @a the_states. */ -RTEMS_INLINE_ROUTINE bool _States_Is_suspended ( +static inline bool _States_Is_suspended ( States_Control the_states ) { @@ -244,7 +263,7 @@ RTEMS_INLINE_ROUTINE bool _States_Is_suspended ( * @retval true WAITING_FOR_TIME state is set in @a the_states. * @retval false WAITING_FOR_TIME state is not set in @a the_states. */ -RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_rpc_reply ( +static inline bool _States_Is_waiting_for_rpc_reply ( States_Control the_states ) { @@ -262,7 +281,7 @@ RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_rpc_reply ( * @retval true WAITING_FOR_JOIN_AT_EXIT state is set in @a the_states. * @retval false WAITING_FOR_JOIN_AT_EXIT state is not set in @a the_states. */ -RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_join_at_exit( +static inline bool _States_Is_waiting_for_join_at_exit( States_Control the_states ) { @@ -280,7 +299,7 @@ RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_join_at_exit( * @retval true @a the_states is interruptible. * @retval false @a the_states is not interruptible. */ -RTEMS_INLINE_ROUTINE bool _States_Is_interruptible_by_signal ( +static inline bool _States_Is_interruptible_by_signal ( States_Control the_states ) { @@ -301,7 +320,7 @@ RTEMS_INLINE_ROUTINE bool _States_Is_interruptible_by_signal ( * @retval false The state indicates that the task is not blocked waiting on a * local resource. */ -RTEMS_INLINE_ROUTINE bool _States_Is_locally_blocked ( +static inline bool _States_Is_locally_blocked ( States_Control the_states ) { diff --git a/cpukit/include/rtems/score/status.h b/cpukit/include/rtems/score/status.h index 236ae52d7b..7fdf6a9017 100644 --- a/cpukit/include/rtems/score/status.h +++ b/cpukit/include/rtems/score/status.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * Copyright (c) 2016 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_STATUS_H @@ -106,6 +119,8 @@ typedef enum { STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EINVAL ), STATUS_INTERRUPTED = STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EINTR ), + STATUS_INTERNAL_ERROR = + STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, ENOTSUP ), STATUS_INVALID_ADDRESS = STATUS_BUILD( STATUS_CLASSIC_INVALID_ADDRESS, EFAULT ), STATUS_INVALID_ID = diff --git a/cpukit/include/rtems/score/sysstate.h b/cpukit/include/rtems/score/sysstate.h index 59affe7432..1086569867 100644 --- a/cpukit/include/rtems/score/sysstate.h +++ b/cpukit/include/rtems/score/sysstate.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_SYSSTATE_H @@ -76,7 +95,7 @@ extern System_state_Codes _System_state_Current; * * @param state The state to set. */ -RTEMS_INLINE_ROUTINE void _System_state_Set ( +static inline void _System_state_Set ( System_state_Codes state ) { @@ -88,7 +107,7 @@ RTEMS_INLINE_ROUTINE void _System_state_Set ( * * @return The current system state. */ -RTEMS_INLINE_ROUTINE System_state_Codes _System_state_Get ( void ) +static inline System_state_Codes _System_state_Get ( void ) { return _System_state_Current; } @@ -101,7 +120,7 @@ RTEMS_INLINE_ROUTINE System_state_Codes _System_state_Get ( void ) * @retval true @a state is before initialization. * @retval false @a state is not before initialization. */ -RTEMS_INLINE_ROUTINE bool _System_state_Is_before_initialization ( +static inline bool _System_state_Is_before_initialization ( System_state_Codes state ) { @@ -116,7 +135,7 @@ RTEMS_INLINE_ROUTINE bool _System_state_Is_before_initialization ( * @retval true @a state is before multitasking. * @retval false @a state is not before multitasking. */ -RTEMS_INLINE_ROUTINE bool _System_state_Is_before_multitasking ( +static inline bool _System_state_Is_before_multitasking ( System_state_Codes state ) { @@ -131,7 +150,7 @@ RTEMS_INLINE_ROUTINE bool _System_state_Is_before_multitasking ( * @retval true @a state is up. * @retval false @a state is not up. */ -RTEMS_INLINE_ROUTINE bool _System_state_Is_up ( +static inline bool _System_state_Is_up ( System_state_Codes state ) { @@ -146,7 +165,7 @@ RTEMS_INLINE_ROUTINE bool _System_state_Is_up ( * @retval true @a state is terminated. * @retval false @a state is not terminated. */ -RTEMS_INLINE_ROUTINE bool _System_state_Is_terminated ( +static inline bool _System_state_Is_terminated ( System_state_Codes state ) { diff --git a/cpukit/include/rtems/score/thread.h b/cpukit/include/rtems/score/thread.h index e23261701a..8ca7d85205 100644 --- a/cpukit/include/rtems/score/thread.h +++ b/cpukit/include/rtems/score/thread.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,11 +14,28 @@ * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2014, 2016 embedded brains GmbH. + * Copyright (C) 2014, 2016 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_THREAD_H @@ -76,14 +95,6 @@ extern "C" { *@{ */ -#define RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE - -/* - * With the addition of the Constant Block Scheduler (CBS), - * this feature is needed even when POSIX is disabled. - */ -#define RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT - #if defined(RTEMS_DEBUG) #define RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT #endif @@ -148,27 +159,47 @@ typedef struct { } Thread_Entry_information; /** - * The following lists the algorithms used to manage the thread cpu budget. - * - * Reset Timeslice: At each context switch, reset the time quantum. - * Exhaust Timeslice: Only reset the quantum once it is consumed. - * Callout: Execute routine when budget is consumed. + * @brief This structure contains operations which manage the CPU budget of a + * thread. */ -typedef enum { - THREAD_CPU_BUDGET_ALGORITHM_NONE, - THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE, - #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE) - THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE, - #endif - #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT) - THREAD_CPU_BUDGET_ALGORITHM_CALLOUT - #endif -} Thread_CPU_budget_algorithms; +typedef struct { + /** + * @brief This operation is called at each clock tick for the executing + * thread. + */ + void ( *at_tick )( Thread_Control * ); + + /** + * @brief This operation is called right before a context switch to the + * thread is performed. + */ + void ( *at_context_switch )( Thread_Control * ); -/** This defines thes the entry point for the thread specific timeslice - * budget management algorithm. + /** + * @brief This operation is called to initialize the CPU budget of the + * thread. + */ + void ( *initialize )( Thread_Control * ); +} Thread_CPU_budget_operations; + +/** + * @brief This structure is used to control the CPU budget of a thread. */ -typedef void (*Thread_CPU_budget_algorithm_callout )( Thread_Control * ); +typedef struct { + /** + * @brief If this member is not NULL, then it references the CPU budget + * operations used to manage the CPU budget of the thread, otherwise it is + * NULL. + */ + const Thread_CPU_budget_operations *operations; + + /** + * @brief This member contains the count of the time quantum that this thread + * is allowed to consume until an action takes place defined by the CPU + * budget operations. + */ + uint32_t available; +} Thread_CPU_budget_control; /** * The following structure contains the information which defines @@ -182,12 +213,13 @@ typedef struct { * it started. */ bool is_preemptible; - /** This field indicates the CPU budget algorith. */ - Thread_CPU_budget_algorithms budget_algorithm; - /** This field is the routine to invoke when the CPU allotment is - * consumed. + + /** + * @brief This member may provide the CPU budget operations activated when a + * thread is initialized before it is started or restarted. */ - Thread_CPU_budget_algorithm_callout budget_callout; + const Thread_CPU_budget_operations *cpu_budget_operations; + /** This field is the initial ISR disable level of this thread. */ uint32_t isr_level; /** This field is the initial priority. */ @@ -293,10 +325,24 @@ typedef struct { Chain_Control Scheduler_nodes; /** - * @brief Node for the Per_CPU_Control::Threads_in_need_for_help chain. + * @brief If an ask for help request for the thread is pending, then this + * member references the processor on which the ask for help request is + * registered, otherwise it is NULL. + * + * Depending on the state of the thread and usage context, this member is + * protected by the Per_CPU_Control::Lock lock of the referenced processor, + * the scheduler lock of the thread (Thread_Scheduler_control::Lock), or the + * thread state lock. + */ + struct Per_CPU_Control *ask_for_help_cpu; + + /** + * @brief This member is the node for the + * Per_CPU_Control::Threads_in_need_for_help chain. * - * This chain is protected by the Per_CPU_Control::Lock lock of the assigned - * processor. + * This chain is protected by the Per_CPU_Control::Lock lock of the processor + * on which the ask for help request is registered + * (Thread_Scheduler_control::ask_for_help_cpu). */ Chain_Node Help_node; @@ -377,7 +423,7 @@ typedef union { * The mutually exclusive wait state flags are * - @ref THREAD_WAIT_STATE_INTEND_TO_BLOCK, * - @ref THREAD_WAIT_STATE_BLOCKED, and - * - @ref THREAD_WAIT_STATE_READY_AGAIN. + * - @ref THREAD_WAIT_STATE_READY. */ typedef unsigned int Thread_Wait_flags; @@ -646,10 +692,12 @@ typedef struct { */ RBTree_Control Key_value_pairs; +#if defined(RTEMS_SMP) /** * @brief Lock to protect the tree operations. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; +#endif } Thread_Keys_information; /** @@ -671,50 +719,50 @@ typedef struct { * The individual state flags must be a power of two to allow use of bit * operations to manipulate and evaluate the thread life state. */ -typedef enum { - /** - * @brief Indicates that the thread life is protected. - * - * If this flag is set, then the thread restart or delete requests are deferred - * until the protection and deferred change flags are cleared. It is used by - * _Thread_Set_life_protection(). - */ - THREAD_LIFE_PROTECTED = 0x1, +typedef unsigned int Thread_Life_state; - /** - * @brief Indicates that thread is restarting. - * - * If this flag is set, then a thread restart request is in pending. See - * _Thread_Restart_self() and _Thread_Restart_other(). - */ - THREAD_LIFE_RESTARTING = 0x2, +/** + * @brief Indicates that the thread life is protected. + * + * If this flag is set, then the thread restart or delete requests are deferred + * until the protection and deferred change flags are cleared. It is used by + * _Thread_Set_life_protection(). + */ +#define THREAD_LIFE_PROTECTED 0x1U - /** - * @brief Indicates that thread is terminating. - * - * If this flag is set, then a thread termination request is in pending. See - * _Thread_Exit() and _Thread_Cancel(). - */ - THREAD_LIFE_TERMINATING = 0x4, +/** + * @brief Indicates that thread is restarting. + * + * If this flag is set, then a thread restart request is in pending. See + * _Thread_Restart_self() and _Thread_Restart_other(). + */ +#define THREAD_LIFE_RESTARTING 0x2U - /** - * @brief Indicates that thread life changes are deferred. - * - * If this flag is set, then the thread restart or delete requests are deferred - * until the protection and deferred change flags are cleared. It is used by - * pthread_setcanceltype(). - */ - THREAD_LIFE_CHANGE_DEFERRED = 0x8, +/** + * @brief Indicates that thread is terminating. + * + * If this flag is set, then a thread termination request is in pending. See + * _Thread_Exit() and _Thread_Cancel(). + */ +#define THREAD_LIFE_TERMINATING 0x4U - /** - * @brief Indicates that thread is detached. - * - * If this flag is set, then the thread is detached. Detached threads do not - * wait during termination for other threads to join. See rtems_task_delete(), - * rtems_task_exit(), and pthread_detach(). - */ - THREAD_LIFE_DETACHED = 0x10 -} Thread_Life_state; +/** + * @brief Indicates that thread life changes are deferred. + * + * If this flag is set, then the thread restart or delete requests are deferred + * until the protection and deferred change flags are cleared. It is used by + * pthread_setcanceltype(). + */ +#define THREAD_LIFE_CHANGE_DEFERRED 0x8U + +/** + * @brief Indicates that thread is detached. + * + * If this flag is set, then the thread is detached. Detached threads do not + * wait during termination for other threads to join. See rtems_task_delete(), + * rtems_task_exit(), and pthread_detach(). + */ +#define THREAD_LIFE_DETACHED 0x10U /** * @brief Thread life control. @@ -772,9 +820,7 @@ struct _Thread_Control { * the following fields * * - RTEMS_API_Control::Signal, - * - Thread_Control::budget_algorithm, - * - Thread_Control::budget_callout, - * - Thread_Control::cpu_time_budget, + * - Thread_Control::CPU_budget, * - Thread_Control::current_state, * - Thread_Control::Post_switch_actions, * - Thread_Control::Scheduler::control, and @@ -812,6 +858,15 @@ struct _Thread_Control { #endif /*================= end of common block =================*/ + /** + * @brief This member contains the context of this thread. + * + * This member is placed directly after the end of the common block so that + * the structure offsets are as small as possible. This helps on instruction + * set architectures with a very limited range for intermediate values. + */ + Context_Control Registers; + #if defined(RTEMS_SMP) && defined(RTEMS_PROFILING) /** * @brief Potpourri lock statistics. @@ -841,22 +896,24 @@ struct _Thread_Control { */ bool was_created_with_inherited_scheduler; - /** This field is the length of the time quantum that this thread is - * allowed to consume. The algorithm used to manage limits on CPU usage - * is specified by budget_algorithm. + /** + * @brief This member contains the CPU budget control used to manage the CPU + * budget of the thread. */ - uint32_t cpu_time_budget; - /** This field is the algorithm used to manage this thread's time - * quantum. The algorithm may be specified as none which case, - * no limit is in place. + Thread_CPU_budget_control CPU_budget; + + /** + * @brief This member contains the amount of CPU time consumed by this thread + * since it was created. */ - Thread_CPU_budget_algorithms budget_algorithm; - /** This field is the method invoked with the budgeted time is consumed. */ - Thread_CPU_budget_algorithm_callout budget_callout; - /** This field is the amount of CPU time consumed by this thread - * since it was created. + Timestamp_Control cpu_time_used; + + /** + * @brief This member contains the amount of CPU time consumed by this thread + * at the time of the last reset of the CPU usage by + * rtems_cpu_usage_reset(). */ - Timestamp_Control cpu_time_used; + Timestamp_Control cpu_time_used_at_last_reset; /** This field contains information about the starting state of * this thread. @@ -865,16 +922,18 @@ struct _Thread_Control { Thread_Action_control Post_switch_actions; - /** This field contains the context of this thread. */ - Context_Control Registers; #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) /** This field points to the floating point context for this thread. * If NULL, the thread is integer only. */ Context_Control_fp *fp_context; #endif + +#ifndef _REENT_THREAD_LOCAL /** This field points to the newlib reentrancy structure for this thread. */ struct _reent *libc_reent; +#endif + /** This array contains the API extension area pointers. */ void *API_Extensions[ THREAD_API_LAST + 1 ]; @@ -1099,9 +1158,11 @@ Objects_Control *_Thread_Allocate_unlimited( Objects_Information *information ); #define THREAD_INFORMATION_DEFINE( name, api, cls, max ) \ static Objects_Control * \ name##_Local_table[ _Objects_Maximum_per_allocation( max ) ]; \ -static Thread_Configured_control \ +static RTEMS_SECTION( ".noinit.rtems.content.objects." #name ) \ +Thread_Configured_control \ name##_Objects[ _Objects_Maximum_per_allocation( max ) ]; \ -static Thread_queue_Configured_heads \ +static RTEMS_SECTION( ".noinit.rtems.content.objects." #name ) \ +Thread_queue_Configured_heads \ name##_Heads[ _Objects_Maximum_per_allocation( max ) ]; \ Thread_Information name##_Information = { \ { \ @@ -1125,13 +1186,6 @@ Thread_Information name##_Information = { \ } \ } -/** - * @brief The idle thread stacks. - * - * Provided by the application via <rtems/confdefs.h>. - */ -extern char _Thread_Idle_stacks[]; - #if defined(RTEMS_MULTIPROCESSING) /** * @brief The configured thread control block. diff --git a/cpukit/include/rtems/score/threadcpubudget.h b/cpukit/include/rtems/score/threadcpubudget.h new file mode 100644 index 0000000000..e1d18ef6ed --- /dev/null +++ b/cpukit/include/rtems/score/threadcpubudget.h @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreThread + * + * @brief This header file provides interfaces used to implement the CPU budget + * management of threads. + */ + +/* + * Copyright (C) 2021 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_SCORE_THREADCPUBUDGET_H +#define _RTEMS_SCORE_THREADCPUBUDGET_H + +#include <rtems/score/thread.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSScoreThread + * + * @{ + */ + +/** + * @brief Does nothing. + * + * @param the_thread is an unused parameter. + */ +void _Thread_CPU_budget_do_nothing( Thread_Control *the_thread ); + +/** + * @brief Sets the available CPU budget of the thread to the configured clock + * ticks per timeslice. + * + * @param the_thread is the thread to set the available CPU budget. + */ +void _Thread_CPU_budget_set_to_ticks_per_timeslice( + Thread_Control *the_thread +); + +/** + * @brief Consumes one time quantum of the available CPU budget of the thread + * and yields the thread if the available CPU budget is fully consumed. + * + * While the thread enabled the non-preemptive mode or is not ready, no time + * quantum is consumed. + * + * @param the_thread is the thread to operate on. + */ +void _Thread_CPU_budget_consume_and_yield( Thread_Control *the_thread ); + +/** + * @brief These CPU budget operations allocate timeslices to the thread. + * + * The timeslice is not reset at a context switch to the thread. Once a + * timeslice is consumed, the thread yields. + */ +extern const Thread_CPU_budget_operations _Thread_CPU_budget_exhaust_timeslice; + +/** + * @brief These CPU budget operations allocate timeslices to the thread. + * + * The timeslice is reset at a context switch to the thread. Once a timeslice + * is consumed, the thread yields. + */ +extern const Thread_CPU_budget_operations _Thread_CPU_budget_reset_timeslice; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_THREADCPUBUDGET_H */ diff --git a/cpukit/include/rtems/score/threaddispatch.h b/cpukit/include/rtems/score/threaddispatch.h index 7f3673a0d5..b06ebe8fec 100644 --- a/cpukit/include/rtems/score/threaddispatch.h +++ b/cpukit/include/rtems/score/threaddispatch.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_THREADDISPATCH_H @@ -53,7 +72,7 @@ extern "C" { * @retval false The executing thread is inside a thread dispatch critical * section and dispatching is not allowed. */ -RTEMS_INLINE_ROUTINE bool _Thread_Dispatch_is_enabled(void) +static inline bool _Thread_Dispatch_is_enabled(void) { bool enabled; @@ -77,7 +96,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Dispatch_is_enabled(void) * * @return The value of the thread dispatch level. */ -RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_get_disable_level(void) +static inline uint32_t _Thread_Dispatch_get_disable_level(void) { return _Thread_Dispatch_disable_level; } @@ -87,7 +106,7 @@ RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_get_disable_level(void) * * This routine initializes the thread dispatching subsystem. */ -RTEMS_INLINE_ROUTINE void _Thread_Dispatch_initialization( void ) +static inline void _Thread_Dispatch_initialization( void ) { _Thread_Dispatch_disable_level = 1; } @@ -161,7 +180,7 @@ void _Thread_Do_dispatch( Per_CPU_Control *cpu_self, ISR_Level level ); * * @return The current processor. */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable_with_CPU( +static inline Per_CPU_Control *_Thread_Dispatch_disable_with_CPU( Per_CPU_Control *cpu_self, const ISR_lock_Context *lock_context ) @@ -188,7 +207,7 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable_with_CPU( * * @return The current processor. */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable_critical( +static inline Per_CPU_Control *_Thread_Dispatch_disable_critical( const ISR_lock_Context *lock_context ) { @@ -200,19 +219,20 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable_critical( * * @return The current processor. */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable( void ) +static inline Per_CPU_Control *_Thread_Dispatch_disable( void ) { Per_CPU_Control *cpu_self; - ISR_lock_Context lock_context; #if defined( RTEMS_SMP ) || defined( RTEMS_PROFILING ) + ISR_lock_Context lock_context; + _ISR_lock_ISR_disable( &lock_context ); -#endif cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); -#if defined( RTEMS_SMP ) || defined( RTEMS_PROFILING ) _ISR_lock_ISR_enable( &lock_context ); +#else + cpu_self = _Thread_Dispatch_disable_critical( NULL ); #endif return cpu_self; @@ -232,7 +252,7 @@ void _Thread_Dispatch_enable( Per_CPU_Control *cpu_self ); * * @param[in, out] cpu_self The current processor. */ -RTEMS_INLINE_ROUTINE void _Thread_Dispatch_unnest( Per_CPU_Control *cpu_self ) +static inline void _Thread_Dispatch_unnest( Per_CPU_Control *cpu_self ) { _Assert( cpu_self->thread_dispatch_disable_level > 0 ); --cpu_self->thread_dispatch_disable_level; @@ -244,7 +264,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Dispatch_unnest( Per_CPU_Control *cpu_self ) * @param[in, out] cpu_self The current processor. * @param[in, out] cpu_target The target processor to request a thread dispatch. */ -RTEMS_INLINE_ROUTINE void _Thread_Dispatch_request( +static inline void _Thread_Dispatch_request( Per_CPU_Control *cpu_self, Per_CPU_Control *cpu_target ) diff --git a/cpukit/include/rtems/score/threadidledata.h b/cpukit/include/rtems/score/threadidledata.h index 4f2a785ccd..8e458de345 100644 --- a/cpukit/include/rtems/score/threadidledata.h +++ b/cpukit/include/rtems/score/threadidledata.h @@ -11,7 +11,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h index ace42d8023..36ddb785e9 100644 --- a/cpukit/include/rtems/score/threadimpl.h +++ b/cpukit/include/rtems/score/threadimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,11 +13,28 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2014, 2017 embedded brains GmbH. - * - * 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. + * Copyright (C) 2014, 2017 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_SCORE_THREADIMPL_H @@ -176,19 +195,9 @@ typedef struct { Priority_Control priority; /** - * @brief The thread's budget algorithm. - */ - Thread_CPU_budget_algorithms budget_algorithm; - - /** - * @brief The thread's initial budget callout. - */ - Thread_CPU_budget_algorithm_callout budget_callout; - - /** - * @brief The thread's initial CPU time budget. + * @brief The thread's initial CPU budget operations. */ - uint32_t cpu_time_budget; + const Thread_CPU_budget_operations *cpu_budget_operations; /** * @brief 32-bit unsigned integer name of the object for the thread. @@ -371,15 +380,23 @@ RTEMS_NO_RETURN void _Thread_Exit( ); /** - * @brief Joins the currently executing thread with the given thread to wait - * for. + * @brief Joins the currently executing thread with the thread. * - * @param[in, out] the_thread The thread to wait for. - * @param waiting_for_join The states control for the join. - * @param[in, out] executing The currently executing thread. - * @param queue_context The thread queue context. + * @param[in, out] the_thread is the thread to join. + * + * @param waiting_for_join is the thread state for the currently executing + * thread. + * + * @param[in, out] executing is the currently executing thread. + * + * @param queue_context[in, out] is the thread queue context. The caller shall + * have acquired the thread state lock using the thread queue context. + * + * @retval STATUS_SUCCESSFUL The operation was successful. + * + * @retval STATUS_DEADLOCK A deadlock occurred. */ -void _Thread_Join( +Status_Control _Thread_Join( Thread_Control *the_thread, States_Control waiting_for_join, Thread_Control *executing, @@ -387,23 +404,38 @@ void _Thread_Join( ); /** + * @brief Indicates the resulting state of _Thread_Cancel(). + */ +typedef enum { + /** + * @brief Indicates that the thread cancel operation is done. + */ + THREAD_CANCEL_DONE, + + /** + * @brief Indicates that the thread cancel operation is in progress. + * + * The cancelled thread is terminating. It may be joined. + */ + THREAD_CANCEL_IN_PROGRESS +} Thread_Cancel_state; + +/** * @brief Cancels the thread. * - * @param[in, out] the_thread The thread to cancel. - * @param executing The currently executing thread. - * @param exit_value The exit value for the thread. + * @param[in, out] the_thread is the thread to cancel. + + * @param[in, out] executing is the currently executing thread. + + * @param[in, out] life_states_to_clear is the set of thread life states to + * clear for the thread to cancel. */ -void _Thread_Cancel( - Thread_Control *the_thread, - Thread_Control *executing, - void *exit_value +Thread_Cancel_state _Thread_Cancel( + Thread_Control *the_thread, + Thread_Control *executing, + Thread_Life_state life_states_to_clear ); -typedef struct { - Thread_queue_Context Base; - Thread_Control *cancel; -} Thread_Close_context; - /** * @brief Closes the thread. * @@ -411,14 +443,21 @@ typedef struct { * case the executing thread is not terminated, then this function waits until * the terminating thread reached the zombie state. * - * @param the_thread The thread to close. - * @param executing The currently executing thread. - * @param[in, out] context The thread close context. + * @param the_thread is the thread to close. + * + * @param[in, out] executing is the currently executing thread. + * + * @param[in, out] queue_context is the thread queue context. The caller shall + * have disabled interrupts using the thread queue context. + * + * @retval STATUS_SUCCESSFUL The operation was successful. + * + * @retval STATUS_DEADLOCK A deadlock occurred. */ -void _Thread_Close( +Status_Control _Thread_Close( Thread_Control *the_thread, Thread_Control *executing, - Thread_Close_context *context + Thread_queue_Context *queue_context ); /** @@ -429,7 +468,7 @@ void _Thread_Close( * @retval true The thread is currently in the ready state. * @retval false The thread is currently not ready. */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_ready( const Thread_Control *the_thread ) +static inline bool _Thread_Is_ready( const Thread_Control *the_thread ) { return _States_Is_ready( the_thread->current_state ); } @@ -556,7 +595,7 @@ void _Thread_Handler( void ); * @param the_thread The thread to acquire the lock context. * @param lock_context The lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_State_acquire_critical( +static inline void _Thread_State_acquire_critical( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -570,7 +609,7 @@ RTEMS_INLINE_ROUTINE void _Thread_State_acquire_critical( * @param the_thread The thread to acquire the lock context. * @param lock_context The lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_State_acquire( +static inline void _Thread_State_acquire( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -587,7 +626,7 @@ RTEMS_INLINE_ROUTINE void _Thread_State_acquire( * * @return The currently executing thread. */ -RTEMS_INLINE_ROUTINE Thread_Control *_Thread_State_acquire_for_executing( +static inline Thread_Control *_Thread_State_acquire_for_executing( ISR_lock_Context *lock_context ) { @@ -606,7 +645,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_State_acquire_for_executing( * @param the_thread The thread to release the lock context. * @param lock_context The lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_State_release_critical( +static inline void _Thread_State_release_critical( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -620,7 +659,7 @@ RTEMS_INLINE_ROUTINE void _Thread_State_release_critical( * @param[in, out] the_thread The thread to release the lock context. * @param[out] lock_context The lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_State_release( +static inline void _Thread_State_release( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -638,7 +677,7 @@ RTEMS_INLINE_ROUTINE void _Thread_State_release( * @retval false The thread is not owner of the lock of the join queue. */ #if defined(RTEMS_DEBUG) -RTEMS_INLINE_ROUTINE bool _Thread_State_is_owner( +static inline bool _Thread_State_is_owner( const Thread_Control *the_thread ) { @@ -752,7 +791,7 @@ void _Thread_Priority_changed( * * @see _Thread_Wait_acquire(). */ -RTEMS_INLINE_ROUTINE void _Thread_Priority_change( +static inline void _Thread_Priority_change( Thread_Control *the_thread, Priority_Node *priority_node, Priority_Control new_priority, @@ -769,6 +808,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Priority_change( ); } +#if defined(RTEMS_SMP) /** * @brief Replaces the victim priority node with the replacement priority node * in the corresponding thread priority aggregation. @@ -786,6 +826,7 @@ void _Thread_Priority_replace( Priority_Node *victim_node, Priority_Node *replacement_node ); +#endif /** * @brief Updates the priority of all threads in the set @@ -800,17 +841,29 @@ void _Thread_Priority_replace( */ void _Thread_Priority_update( Thread_queue_Context *queue_context ); +#if defined(RTEMS_SMP) /** - * @brief Updates the priority of the thread and changes it sticky level. + * @brief Updates the priority of the thread and makes its home scheduler node + * sticky. * - * @param the_thread The thread. - * @param sticky_level_change The new value for the sticky level. + * @param the_thread is the thread to work on. */ -#if defined(RTEMS_SMP) -void _Thread_Priority_and_sticky_update( - Thread_Control *the_thread, - int sticky_level_change -); +void _Thread_Priority_update_and_make_sticky( Thread_Control *the_thread ); + +/** + * @brief Updates the priority of the thread and cleans the sticky property of + * its home scheduler node. + * + * @param the_thread is the thread to work on. + */ +void _Thread_Priority_update_and_clean_sticky( Thread_Control *the_thread ); + +/** + * @brief Updates the priority of the thread. + * + * @param the_thread is the thread to update the priority. + */ +void _Thread_Priority_update_ignore_sticky( Thread_Control *the_thread ); #endif /** @@ -823,7 +876,7 @@ void _Thread_Priority_and_sticky_update( * @retval true The left priority is less in the intuitive sense. * @retval false The left priority is greater or equal in the intuitive sense. */ -RTEMS_INLINE_ROUTINE bool _Thread_Priority_less_than( +static inline bool _Thread_Priority_less_than( Priority_Control left, Priority_Control right ) @@ -840,7 +893,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Priority_less_than( * * @return The highest priority in the intuitive sense of priority. */ -RTEMS_INLINE_ROUTINE Priority_Control _Thread_Priority_highest( +static inline Priority_Control _Thread_Priority_highest( Priority_Control left, Priority_Control right ) @@ -860,7 +913,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Priority_highest( * @return Returns the thread object information associated with the API of the * object identifier. */ -RTEMS_INLINE_ROUTINE Objects_Information *_Thread_Get_objects_information_by_id( +static inline Objects_Information *_Thread_Get_objects_information_by_id( Objects_Id id ) { @@ -888,7 +941,7 @@ RTEMS_INLINE_ROUTINE Objects_Information *_Thread_Get_objects_information_by_id( * * @return Returns the thread object information of the thread. */ -RTEMS_INLINE_ROUTINE Thread_Information *_Thread_Get_objects_information( +static inline Thread_Information *_Thread_Get_objects_information( Thread_Control *the_thread ) { @@ -932,7 +985,7 @@ Objects_Id _Thread_Self_id( void ); * * @return The cpu of the thread's scheduler. */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Get_CPU( +static inline Per_CPU_Control *_Thread_Get_CPU( const Thread_Control *thread ) { @@ -951,7 +1004,7 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Get_CPU( * @param[out] thread The thread. * @param cpu The cpu to set. */ -RTEMS_INLINE_ROUTINE void _Thread_Set_CPU( +static inline void _Thread_Set_CPU( Thread_Control *thread, Per_CPU_Control *cpu ) @@ -975,7 +1028,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Set_CPU( * @retval true @a the_thread is the currently executing one. * @retval false @a the_thread is not the currently executing one. */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_executing ( +static inline bool _Thread_Is_executing ( const Thread_Control *the_thread ) { @@ -995,7 +1048,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_executing ( * @retval true @a the_thread is the currently executing one. * @retval false @a the_thread is not the currently executing one. */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_executing_on_a_processor( +static inline bool _Thread_Is_executing_on_a_processor( const Thread_Control *the_thread ) { @@ -1014,7 +1067,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_executing_on_a_processor( * @retval true @a the_thread is the heir. * @retval false @a the_thread is not the heir. */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_heir ( +static inline bool _Thread_Is_heir ( const Thread_Control *the_thread ) { @@ -1030,7 +1083,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_heir ( * * @param[in, out] the_thread The thread to unblock. */ -RTEMS_INLINE_ROUTINE void _Thread_Unblock ( +static inline void _Thread_Unblock ( Thread_Control *the_thread ) { @@ -1053,7 +1106,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Unblock ( * loaded in the floating point unit. */ #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -RTEMS_INLINE_ROUTINE bool _Thread_Is_allocated_fp ( +static inline bool _Thread_Is_allocated_fp ( const Thread_Control *the_thread ) { @@ -1079,7 +1132,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_allocated_fp ( * * @param executing The currently executing thread. */ -RTEMS_INLINE_ROUTINE void _Thread_Save_fp( Thread_Control *executing ) +static inline void _Thread_Save_fp( Thread_Control *executing ) { #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) #if ( CPU_USE_DEFERRED_FP_SWITCH != TRUE ) @@ -1094,7 +1147,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Save_fp( Thread_Control *executing ) * * @param executing The currently executing thread. */ -RTEMS_INLINE_ROUTINE void _Thread_Restore_fp( Thread_Control *executing ) +static inline void _Thread_Restore_fp( Thread_Control *executing ) { #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) #if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE ) @@ -1119,7 +1172,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Restore_fp( Thread_Control *executing ) * point context is now longer associated with an active thread. */ #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -RTEMS_INLINE_ROUTINE void _Thread_Deallocate_fp( void ) +static inline void _Thread_Deallocate_fp( void ) { _Thread_Allocated_fp = NULL; } @@ -1134,7 +1187,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Deallocate_fp( void ) * @retval true Dispatching is disabled. * @retval false Dispatching is enabled. */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_context_switch_necessary( void ) +static inline bool _Thread_Is_context_switch_necessary( void ) { return ( _Thread_Dispatch_necessary ); } @@ -1144,7 +1197,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_context_switch_necessary( void ) * * @return The maximum number of internal threads. */ -RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_maximum_internal_threads(void) +static inline uint32_t _Thread_Get_maximum_internal_threads(void) { /* Idle threads */ uint32_t maximum_internal_threads = @@ -1166,7 +1219,7 @@ RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_maximum_internal_threads(void) * @retval pointer Pointer to the allocated Thread_Control. * @retval NULL The operation failed. */ -RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Internal_allocate( void ) +static inline Thread_Control *_Thread_Internal_allocate( void ) { return (Thread_Control *) _Objects_Allocate_unprotected( &_Thread_Information.Objects ); @@ -1185,7 +1238,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Internal_allocate( void ) * @see _Thread_Dispatch(), _Thread_Start_multitasking() and * _Thread_Dispatch_update_heir(). */ -RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_heir_and_make_it_executing( +static inline Thread_Control *_Thread_Get_heir_and_make_it_executing( Per_CPU_Control *cpu_self ) { @@ -1205,7 +1258,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_heir_and_make_it_executing( * used. * @param cpu The cpu. */ -RTEMS_INLINE_ROUTINE void _Thread_Update_CPU_time_used( +static inline void _Thread_Update_CPU_time_used( Thread_Control *the_thread, Per_CPU_Control *cpu ) @@ -1227,7 +1280,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Update_CPU_time_used( * @param heir The new heir for @a cpu_for_heir. */ #if defined( RTEMS_SMP ) -RTEMS_INLINE_ROUTINE void _Thread_Dispatch_update_heir( +static inline void _Thread_Dispatch_update_heir( Per_CPU_Control *cpu_self, Per_CPU_Control *cpu_for_heir, Thread_Control *heir @@ -1242,15 +1295,41 @@ RTEMS_INLINE_ROUTINE void _Thread_Dispatch_update_heir( #endif /** - * @brief Gets the used cpu time of the thread and stores it in the given - * Timestamp_Control. + * @brief Gets the used processor time of the thread throughout its entire + * lifetime. * - * @param the_thread The thread to get the used cpu time of. - * @param[out] cpu_time_used Stores the used cpu time of @a the_thread. + * @param[in, out] the_thread is the thread. + * + * @return Returns the used processor time of the thread throughout its entire + * lifetime. */ -void _Thread_Get_CPU_time_used( - Thread_Control *the_thread, - Timestamp_Control *cpu_time_used +Timestamp_Control _Thread_Get_CPU_time_used( Thread_Control *the_thread ); + +/** + * @brief Gets the used processor time of the thread throughout its entire + * lifetime if the caller already acquired the thread state and home + * scheduler locks. + * + * @param[in, out] the_thread is the thread. + * + * @return Returns the used processor time of the thread throughout its entire + * lifetime. + */ +Timestamp_Control _Thread_Get_CPU_time_used_locked( + Thread_Control *the_thread +); + +/** + * @brief Gets the used processor time of the thread after the last CPU usage + * reset. + * + * @param[in, out] the_thread is the thread. + * + * @return Returns the used processor time of the thread after the last CPU usage + * reset. + */ +Timestamp_Control _Thread_Get_CPU_time_used_after_last_reset( + Thread_Control *the_thread ); /** @@ -1258,7 +1337,7 @@ void _Thread_Get_CPU_time_used( * * @param[out] action_control The action control to initialize. */ -RTEMS_INLINE_ROUTINE void _Thread_Action_control_initialize( +static inline void _Thread_Action_control_initialize( Thread_Action_control *action_control ) { @@ -1270,7 +1349,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Action_control_initialize( * * @param[out] action The Thread_Action to initialize. */ -RTEMS_INLINE_ROUTINE void _Thread_Action_initialize( +static inline void _Thread_Action_initialize( Thread_Action *action ) { @@ -1289,7 +1368,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Action_initialize( * * @param handler is the handler for the action. */ -RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action( +static inline void _Thread_Add_post_switch_action( Thread_Control *the_thread, Thread_Action *action, Thread_Action_handler handler @@ -1322,7 +1401,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action( * * @param[in, out] action is the action to add. */ -RTEMS_INLINE_ROUTINE void _Thread_Append_post_switch_action( +static inline void _Thread_Append_post_switch_action( Thread_Control *the_thread, Thread_Action *action ) @@ -1344,7 +1423,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Append_post_switch_action( * @retval true @a life_state is restarting. * @retval false @a life_state is not restarting. */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_life_restarting( +static inline bool _Thread_Is_life_restarting( Thread_Life_state life_state ) { @@ -1359,7 +1438,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_restarting( * @retval true @a life_state is terminating. * @retval false @a life_state is not terminating. */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_life_terminating( +static inline bool _Thread_Is_life_terminating( Thread_Life_state life_state ) { @@ -1374,7 +1453,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_terminating( * @retval true @a life_state allows life change. * @retval false @a life_state does not allow life change. */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_life_change_allowed( +static inline bool _Thread_Is_life_change_allowed( Thread_Life_state life_state ) { @@ -1390,7 +1469,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_change_allowed( * @retval true @a life_state is life changing. * @retval false @a life_state is not life changing. */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing( +static inline bool _Thread_Is_life_changing( Thread_Life_state life_state ) { @@ -1406,7 +1485,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing( * @retval true @a life_state is joinable. * @retval false @a life_state is not joinable. */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_joinable( +static inline bool _Thread_Is_joinable( const Thread_Control *the_thread ) { @@ -1419,7 +1498,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_joinable( * * @param[in, out] the_thread The thread to increase the resource count of. */ -RTEMS_INLINE_ROUTINE void _Thread_Resource_count_increment( +static inline void _Thread_Resource_count_increment( Thread_Control *the_thread ) { @@ -1435,7 +1514,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Resource_count_increment( * * @param[in, out] the_thread The thread to decrement the resource count of. */ -RTEMS_INLINE_ROUTINE void _Thread_Resource_count_decrement( +static inline void _Thread_Resource_count_decrement( Thread_Control *the_thread ) { @@ -1458,7 +1537,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Resource_count_decrement( * @retval true The thread owns resources. * @retval false The thread does not own resources. */ -RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources( +static inline bool _Thread_Owns_resources( const Thread_Control *the_thread ) { @@ -1466,32 +1545,6 @@ RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources( } #endif -#if defined(RTEMS_SMP) -/** - * @brief Cancels the thread's need for help. - * - * @param the_thread The thread to cancel the help request of. - * @param cpu The cpu to get the lock context of in order to - * cancel the help request. - */ -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_cancel_need_for_help( - Thread_Control *the_thread, - Per_CPU_Control *cpu -) -{ - ISR_lock_Context lock_context; - - _Per_CPU_Acquire( cpu, &lock_context ); - - if ( !_Chain_Is_node_off_chain( &the_thread->Scheduler.Help_node ) ) { - _Chain_Extract_unprotected( &the_thread->Scheduler.Help_node ); - _Chain_Set_off_chain( &the_thread->Scheduler.Help_node ); - } - - _Per_CPU_Release( cpu, &lock_context ); -} -#endif - /** * @brief Gets the home scheduler of the thread. * @@ -1499,7 +1552,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_cancel_need_for_help( * * @return The thread's home scheduler. */ -RTEMS_INLINE_ROUTINE const Scheduler_Control *_Thread_Scheduler_get_home( +static inline const Scheduler_Control *_Thread_Scheduler_get_home( const Thread_Control *the_thread ) { @@ -1518,7 +1571,7 @@ RTEMS_INLINE_ROUTINE const Scheduler_Control *_Thread_Scheduler_get_home( * * @return The thread's home node. */ -RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_home_node( +static inline Scheduler_Node *_Thread_Scheduler_get_home_node( const Thread_Control *the_thread ) { @@ -1540,17 +1593,17 @@ RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_home_node( * * @return The scheduler node with the specified index. */ -RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_node_by_index( +static inline Scheduler_Node *_Thread_Scheduler_get_node_by_index( const Thread_Control *the_thread, size_t scheduler_index ) { + _Assert( scheduler_index < _Scheduler_Count ); #if defined(RTEMS_SMP) return (Scheduler_Node *) ( (uintptr_t) the_thread->Scheduler.nodes + scheduler_index * _Scheduler_Node_size ); #else - _Assert( scheduler_index == 0 ); (void) scheduler_index; return the_thread->Scheduler.nodes; #endif @@ -1563,7 +1616,7 @@ RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_node_by_index( * @param the_thread The thread to acquire the lock context. * @param lock_context The lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_acquire_critical( +static inline void _Thread_Scheduler_acquire_critical( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -1577,7 +1630,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_acquire_critical( * @param the_thread The thread to release the lock context. * @param lock_context The lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_release_critical( +static inline void _Thread_Scheduler_release_critical( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -1599,7 +1652,7 @@ void _Thread_Scheduler_process_requests( Thread_Control *the_thread ); * @param[in, out] scheduler_node The scheduler node for the request. * @param request The request to add. */ -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_request( +static inline void _Thread_Scheduler_add_request( Thread_Control *the_thread, Scheduler_Node *scheduler_node, Scheduler_Node_request request @@ -1642,7 +1695,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_request( * @param[in, out] the_thread The thread to add the wait node to. * @param scheduler_node The scheduler node which provides the wait node. */ -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_wait_node( +static inline void _Thread_Scheduler_add_wait_node( Thread_Control *the_thread, Scheduler_Node *scheduler_node ) @@ -1665,7 +1718,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_wait_node( * @param the_thread The thread to add the request to remove a wait node. * @param scheduler_node The scheduler node to remove a wait node from. */ -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_remove_wait_node( +static inline void _Thread_Scheduler_remove_wait_node( Thread_Control *the_thread, Scheduler_Node *scheduler_node ) @@ -1690,7 +1743,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Scheduler_remove_wait_node( * * @return The priority of the thread. */ -RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_priority( +static inline Priority_Control _Thread_Get_priority( const Thread_Control *the_thread ) { @@ -1707,7 +1760,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_priority( * * @return The unmapped priority of the thread. */ -RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_unmapped_priority( +static inline Priority_Control _Thread_Get_unmapped_priority( const Thread_Control *the_thread ) { @@ -1721,7 +1774,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_unmapped_priority( * * @return The unmapped real priority of the thread. */ -RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_unmapped_real_priority( +static inline Priority_Control _Thread_Get_unmapped_real_priority( const Thread_Control *the_thread ) { @@ -1738,7 +1791,7 @@ RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_unmapped_real_priority( * * @see _Thread_Wait_release_default_critical(). */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default_critical( +static inline void _Thread_Wait_acquire_default_critical( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -1757,7 +1810,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default_critical( * * @see _Thread_Wait_release_default(). */ -RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Wait_acquire_default_for_executing( +static inline Thread_Control *_Thread_Wait_acquire_default_for_executing( ISR_lock_Context *lock_context ) { @@ -1779,7 +1832,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Wait_acquire_default_for_executing( * * @see _Thread_Wait_release_default(). */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default( +static inline void _Thread_Wait_acquire_default( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -1798,7 +1851,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default( * @param lock_context The lock context used for the corresponding lock * acquire. */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default_critical( +static inline void _Thread_Wait_release_default_critical( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -1814,7 +1867,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default_critical( * @param[out] lock_context The lock context used for the corresponding lock * acquire. */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default( +static inline void _Thread_Wait_release_default( Thread_Control *the_thread, ISR_lock_Context *lock_context ) @@ -1833,7 +1886,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default( * @param the_thread The thread to remove the request from. * @param queue_lock_context The queue lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request_locked( +static inline void _Thread_Wait_remove_request_locked( Thread_Control *the_thread, Thread_queue_Lock_context *queue_lock_context ) @@ -1854,7 +1907,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request_locked( * @param queue The queue that acquires. * @param queue_lock_context The queue lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_queue_critical( +static inline void _Thread_Wait_acquire_queue_critical( Thread_queue_Queue *queue, Thread_queue_Lock_context *queue_lock_context ) @@ -1872,7 +1925,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_queue_critical( * @param queue The queue that releases. * @param queue_lock_context The queue lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_release_queue_critical( +static inline void _Thread_Wait_release_queue_critical( Thread_queue_Queue *queue, Thread_queue_Lock_context *queue_lock_context ) @@ -1892,7 +1945,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_queue_critical( * @param[in, out] queue_context The thread queue context for the corresponding * _Thread_Wait_release_critical(). */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_critical( +static inline void _Thread_Wait_acquire_critical( Thread_Control *the_thread, Thread_queue_Context *queue_context ) @@ -1948,7 +2001,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_critical( * @param[in, out] queue_context The thread queue context for the corresponding * _Thread_Wait_release(). */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire( +static inline void _Thread_Wait_acquire( Thread_Control *the_thread, Thread_queue_Context *queue_context ) @@ -1967,7 +2020,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire( * @param[in, out] queue_context The thread queue context used for corresponding * _Thread_Wait_acquire_critical(). */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_release_critical( +static inline void _Thread_Wait_release_critical( Thread_Control *the_thread, Thread_queue_Context *queue_context ) @@ -2009,7 +2062,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release_critical( * @param[in, out] queue_context The thread queue context used for corresponding * _Thread_Wait_acquire(). */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_release( +static inline void _Thread_Wait_release( Thread_Control *the_thread, Thread_queue_Context *queue_context ) @@ -2032,7 +2085,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_release( * * @see _Thread_Wait_claim_finalize() and _Thread_Wait_restore_default(). */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_claim( +static inline void _Thread_Wait_claim( Thread_Control *the_thread, Thread_queue_Queue *queue ) @@ -2061,7 +2114,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_claim( * @param[in, out] the_thread The thread. * @param operations The corresponding thread queue operations. */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_claim_finalize( +static inline void _Thread_Wait_claim_finalize( Thread_Control *the_thread, const Thread_queue_Operations *operations ) @@ -2080,7 +2133,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_claim_finalize( * @param[in, out] queue_lock_context The thread queue lock context used for * corresponding _Thread_Wait_acquire(). */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request( +static inline void _Thread_Wait_remove_request( Thread_Control *the_thread, Thread_queue_Lock_context *queue_lock_context ) @@ -2109,7 +2162,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request( * * @see _Thread_Wait_claim(). */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default( +static inline void _Thread_Wait_restore_default( Thread_Control *the_thread ) { @@ -2168,7 +2221,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default( * * @param the_thread The thread. */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_tranquilize( +static inline void _Thread_Wait_tranquilize( Thread_Control *the_thread ) { @@ -2186,7 +2239,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_tranquilize( * @param queue_context The thread queue context used for corresponding * _Thread_Wait_acquire(). */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel( +static inline void _Thread_Wait_cancel( Thread_Control *the_thread, Thread_queue_Context *queue_context ) @@ -2215,14 +2268,18 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel( } /** - * @brief The initial thread wait flags value set by _Thread_Initialize(). + * @brief Mask to get the thread wait state flags. */ -#define THREAD_WAIT_FLAGS_INITIAL 0x0U +#define THREAD_WAIT_STATE_MASK 0xffU /** - * @brief Mask to get the thread wait state flags. + * @brief Indicates that the thread does not wait on something. + * + * In this wait state, the wait class is zero. This wait state is set + * initially by _Thread_Initialize() and after each wait operation once the + * thread is ready again. */ -#define THREAD_WAIT_STATE_MASK 0xffU +#define THREAD_WAIT_STATE_READY 0x0U /** * @brief Indicates that the thread begins with the blocking operation. @@ -2239,13 +2296,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel( #define THREAD_WAIT_STATE_BLOCKED 0x2U /** - * @brief Indicates that a condition to end the thread wait occurred. - * - * This could be a timeout, a signal, an event or a resource availability. - */ -#define THREAD_WAIT_STATE_READY_AGAIN 0x4U - -/** * @brief Mask to get the thread wait class flags. */ #define THREAD_WAIT_CLASS_MASK 0xff00U @@ -2276,7 +2326,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel( * @param[in, out] the_thread The thread to set the wait flags of. * @param flags The flags to set. */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_flags_set( +static inline void _Thread_Wait_flags_set( Thread_Control *the_thread, Thread_Wait_flags flags ) @@ -2295,7 +2345,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Wait_flags_set( * * @return The thread's wait flags. */ -RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get( +static inline Thread_Wait_flags _Thread_Wait_flags_get( const Thread_Control *the_thread ) { @@ -2313,7 +2363,7 @@ RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get( * * @return The thread's wait flags. */ -RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get_acquire( +static inline Thread_Wait_flags _Thread_Wait_flags_get_acquire( const Thread_Control *the_thread ) { @@ -2340,7 +2390,7 @@ RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get_acquire( * @retval true The wait flags were equal to the expected wait flags. * @retval false The wait flags were not equal to the expected wait flags. */ -RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_release( +static inline bool _Thread_Wait_flags_try_change_release( Thread_Control *the_thread, Thread_Wait_flags expected_flags, Thread_Wait_flags desired_flags @@ -2380,7 +2430,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_release( * @retval true The wait flags were equal to the expected wait flags. * @retval false The wait flags were not equal to the expected wait flags. */ -RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_acquire( +static inline bool _Thread_Wait_flags_try_change_acquire( Thread_Control *the_thread, Thread_Wait_flags expected_flags, Thread_Wait_flags desired_flags @@ -2434,7 +2484,7 @@ Objects_Id _Thread_Wait_get_id( const Thread_Control *the_thread ); * * @param the_thread The thread to get the status of the wait return code of. */ -RTEMS_INLINE_ROUTINE Status_Control _Thread_Wait_get_status( +static inline Status_Control _Thread_Wait_get_status( const Thread_Control *the_thread ) { @@ -2468,7 +2518,7 @@ void _Thread_Timeout( Watchdog_Control *the_watchdog ); * @param [in, out] timer The timer to initialize. * @param cpu The cpu for the operation. */ -RTEMS_INLINE_ROUTINE void _Thread_Timer_initialize( +static inline void _Thread_Timer_initialize( Thread_Timer_information *timer, Per_CPU_Control *cpu ) @@ -2485,7 +2535,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Timer_initialize( * @param cpu The cpu for the operation. * @param ticks The ticks to add to the timeout ticks. */ -RTEMS_INLINE_ROUTINE void _Thread_Add_timeout_ticks( +static inline void _Thread_Add_timeout_ticks( Thread_Control *the_thread, Per_CPU_Control *cpu, Watchdog_Interval ticks @@ -2511,7 +2561,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Add_timeout_ticks( * @param routine The watchdog routine for the thread. * @param expire Expiration for the watchdog. */ -RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_realtime( +static inline void _Thread_Timer_insert_realtime( Thread_Control *the_thread, Per_CPU_Control *cpu, Watchdog_Service_routine_entry routine, @@ -2536,7 +2586,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_realtime( * * @param[in, out] the_thread The thread to remove the watchdog from. */ -RTEMS_INLINE_ROUTINE void _Thread_Timer_remove( Thread_Control *the_thread ) +static inline void _Thread_Timer_remove( Thread_Control *the_thread ) { ISR_lock_Context lock_context; @@ -2562,7 +2612,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Timer_remove( Thread_Control *the_thread ) * if necessary. * @param queue The thread queue. */ -RTEMS_INLINE_ROUTINE void _Thread_Remove_timer_and_unblock( +static inline void _Thread_Remove_timer_and_unblock( Thread_Control *the_thread, Thread_queue_Queue *queue ) @@ -2633,10 +2683,10 @@ void _Thread_Do_unpin( * * @param executing The currently executing thread. */ -RTEMS_INLINE_ROUTINE void _Thread_Pin( Thread_Control *executing ) +static inline void _Thread_Pin( Thread_Control *executing ) { #if defined(RTEMS_SMP) - _Assert( executing == _Thread_Executing ); + _Assert( executing == _Thread_Get_executing() ); executing->Scheduler.pin_level += THREAD_PIN_STEP; #else @@ -2650,7 +2700,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Pin( Thread_Control *executing ) * @param executing The currently executing thread. * @param cpu_self The cpu for the operation. */ -RTEMS_INLINE_ROUTINE void _Thread_Unpin( +static inline void _Thread_Unpin( Thread_Control *executing, Per_CPU_Control *cpu_self ) @@ -2658,7 +2708,7 @@ RTEMS_INLINE_ROUTINE void _Thread_Unpin( #if defined(RTEMS_SMP) unsigned int pin_level; - _Assert( executing == _Thread_Executing ); + _Assert( executing == _Per_CPU_Get_executing( cpu_self ) ); pin_level = executing->Scheduler.pin_level; _Assert( pin_level > 0 ); @@ -2688,5 +2738,35 @@ RTEMS_INLINE_ROUTINE void _Thread_Unpin( #include <rtems/score/threadmp.h> #endif +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup RTEMSScoreThread + * + * @brief Removes the watchdog timer from the thread and lets the thread + * continue its execution. + * + * @param[in, out] the_thread is the thread. + * + * @param status is the thread wait status. + */ +static inline void _Thread_Timer_remove_and_continue( + Thread_Control *the_thread, + Status_Control status +) +{ + _Thread_Timer_remove( the_thread ); +#if defined(RTEMS_MULTIPROCESSING) + _Thread_MP_Extract_proxy( the_thread ); +#endif + _Thread_Continue( the_thread, status ); +} + +#ifdef __cplusplus +} +#endif + #endif /* end of include file */ diff --git a/cpukit/include/rtems/score/threadmp.h b/cpukit/include/rtems/score/threadmp.h index 6cc68e6320..30c7c84bd4 100644 --- a/cpukit/include/rtems/score/threadmp.h +++ b/cpukit/include/rtems/score/threadmp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_THREADMP_H @@ -98,6 +117,19 @@ Thread_Control *_Thread_MP_Find_proxy ( ((_the_thread) == _MPCI_Receive_server_tcb) /** + * @brief Extracts the proxy of the thread if necessary. + * + * This routine ensures that if there is a proxy for this thread on another + * node, it is also dealt with. A proxy is a data that is on the thread queue + * on the remote node and acts as a proxy for the local thread. If the local + * thread was waiting on a remote operation, then the remote side of the + * operation must be cleaned up. + * + * @param[in, out] the_thread is the thread to determine the proxy. + */ +void _Thread_MP_Extract_proxy( Thread_Control *the_thread ); + +/** * @brief Trees a proxy control block to the inactive chain of free proxy * control blocks. */ @@ -113,7 +145,7 @@ void _Thread_MP_Free_proxy( Thread_Control *the_thread ); * @retval false The object if is not valid or the thread MP with this object * id is not remote. */ -RTEMS_INLINE_ROUTINE bool _Thread_MP_Is_remote( Objects_Id id ) +static inline bool _Thread_MP_Is_remote( Objects_Id id ) { Objects_Information *information; diff --git a/cpukit/include/rtems/score/threadq.h b/cpukit/include/rtems/score/threadq.h index 2fbfcd0199..20633d4341 100644 --- a/cpukit/include/rtems/score/threadq.h +++ b/cpukit/include/rtems/score/threadq.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_THREADQ_H diff --git a/cpukit/include/rtems/score/threadqimpl.h b/cpukit/include/rtems/score/threadqimpl.h index 7e6f2665be..44b2010226 100644 --- a/cpukit/include/rtems/score/threadqimpl.h +++ b/cpukit/include/rtems/score/threadqimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_THREADQIMPL_H @@ -147,7 +166,7 @@ void _Thread_queue_Deadlock_fatal( Thread_Control *the_thread ); * * @param[out] queue_context The thread queue context to initialize. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize( +static inline void _Thread_queue_Context_initialize( Thread_queue_Context *queue_context ) { @@ -172,7 +191,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize( * * @see _Thread_queue_Enqueue(). */ -RTEMS_INLINE_ROUTINE void +static inline void _Thread_queue_Context_set_thread_state( Thread_queue_Context *queue_context, States_Control thread_state @@ -189,7 +208,7 @@ _Thread_queue_Context_set_thread_state( * * @see _Thread_queue_Enqueue(). */ -RTEMS_INLINE_ROUTINE void +static inline void _Thread_queue_Context_set_timeout_ticks( Thread_queue_Context *queue_context, Watchdog_Interval ticks @@ -210,7 +229,7 @@ _Thread_queue_Context_set_timeout_ticks( * * @see _Thread_queue_Enqueue(). */ -RTEMS_INLINE_ROUTINE void +static inline void _Thread_queue_Context_set_timeout_argument( Thread_queue_Context *queue_context, const void *arg, @@ -229,7 +248,7 @@ _Thread_queue_Context_set_timeout_argument( * * @see _Thread_queue_Enqueue(). */ -RTEMS_INLINE_ROUTINE void +static inline void _Thread_queue_Context_set_enqueue_callout( Thread_queue_Context *queue_context, Thread_queue_Enqueue_callout enqueue_callout @@ -245,7 +264,7 @@ _Thread_queue_Context_set_enqueue_callout( * * @see _Thread_queue_Enqueue(). */ -RTEMS_INLINE_ROUTINE void +static inline void _Thread_queue_Context_set_enqueue_do_nothing_extra( Thread_queue_Context *queue_context ) @@ -262,7 +281,7 @@ _Thread_queue_Context_set_enqueue_do_nothing_extra( * * @see _Thread_queue_Enqueue(). */ -RTEMS_INLINE_ROUTINE void +static inline void _Thread_queue_Context_set_enqueue_timeout_ticks( Thread_queue_Context *queue_context, Watchdog_Interval ticks @@ -285,7 +304,7 @@ _Thread_queue_Context_set_enqueue_timeout_ticks( * * @see _Thread_queue_Enqueue(). */ -RTEMS_INLINE_ROUTINE void +static inline void _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec( Thread_queue_Context *queue_context, const struct timespec *timeout, @@ -311,7 +330,7 @@ _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec( * * @see _Thread_queue_Enqueue(). */ -RTEMS_INLINE_ROUTINE void +static inline void _Thread_queue_Context_set_enqueue_timeout_realtime_timespec( Thread_queue_Context *queue_context, const struct timespec *timeout, @@ -337,7 +356,7 @@ _Thread_queue_Context_set_enqueue_timeout_realtime_timespec( * * @see _Thread_queue_Enqueue(). */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_deadlock_callout( +static inline void _Thread_queue_Context_set_deadlock_callout( Thread_queue_Context *queue_context, Thread_queue_Deadlock_callout deadlock_callout ) @@ -351,7 +370,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_deadlock_callout( * @param[out] queue_context The thread queue context to clear the priority * update count. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates( +static inline void _Thread_queue_Context_clear_priority_updates( Thread_queue_Context *queue_context ) { @@ -366,7 +385,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates( * * @return The priority update count of @a queue_context. */ -RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_get_priority_updates( +static inline size_t _Thread_queue_Context_get_priority_updates( const Thread_queue_Context *queue_context ) { @@ -380,7 +399,7 @@ RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_get_priority_updates( * update count of. * @param update_count The priority update count. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_restore_priority_updates( +static inline void _Thread_queue_Context_restore_priority_updates( Thread_queue_Context *queue_context, size_t update_count ) @@ -396,7 +415,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_restore_priority_updates( * array. * @param the_thread The thread for the priority update. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_add_priority_update( +static inline void _Thread_queue_Context_add_priority_update( Thread_queue_Context *queue_context, Thread_Control *the_thread ) @@ -424,7 +443,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_add_priority_update( * @param[out] queue_context The thread queue context to set the ISR level of. * @param level The ISR level to set @a queue_context to. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_ISR_level( +static inline void _Thread_queue_Context_set_ISR_level( Thread_queue_Context *queue_context, ISR_Level level ) @@ -442,7 +461,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_ISR_level( * * @return The current processor. */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_queue_Dispatch_disable( +static inline Per_CPU_Control *_Thread_queue_Dispatch_disable( Thread_queue_Context *queue_context ) { @@ -461,7 +480,7 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_queue_Dispatch_disable( * objects with multiprocessing (MP) support. */ #if defined(RTEMS_MULTIPROCESSING) -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_MP_callout( +static inline void _Thread_queue_Context_set_MP_callout( Thread_queue_Context *queue_context, Thread_queue_MP_callout mp_callout ) @@ -481,7 +500,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_MP_callout( * * @param[out] gate The gate to close. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_close( +static inline void _Thread_queue_Gate_close( Thread_queue_Gate *gate ) { @@ -494,7 +513,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_close( * @param[in, out] chain The chain to add the gate to. * @param gate The gate to add to the chain. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_add( +static inline void _Thread_queue_Gate_add( Chain_Control *chain, Thread_queue_Gate *gate ) @@ -507,7 +526,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_add( * * @param[out] gate The gate to open. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_open( +static inline void _Thread_queue_Gate_open( Thread_queue_Gate *gate ) { @@ -521,7 +540,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_open( * * @param gate The gate to wait for. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_wait( +static inline void _Thread_queue_Gate_wait( Thread_queue_Gate *gate ) { @@ -536,7 +555,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_wait( * * @param[out] heads The thread queue heads to initialize. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize( +static inline void _Thread_queue_Heads_initialize( Thread_queue_Heads *heads ) { @@ -560,7 +579,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize( * @param[out] queue The thread queue queue to initialize. * @param name The name for the @a queue. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize( +static inline void _Thread_queue_Queue_initialize( Thread_queue_Queue *queue, const char *name ) @@ -580,7 +599,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize( * @param lock_stats The lock statistics. * @param[out] lock_context The interrupt lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical( +static inline void _Thread_queue_Queue_do_acquire_critical( Thread_queue_Queue *queue, #if defined(RTEMS_SMP) && defined(RTEMS_PROFILING) SMP_lock_Stats *lock_stats, @@ -616,7 +635,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical( * @param queue The thread queue queue to release in a critical section. * @param[out] lock_context The interrupt lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release_critical( +static inline void _Thread_queue_Queue_release_critical( Thread_queue_Queue *queue, ISR_lock_Context *lock_context ) @@ -638,7 +657,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release_critical( * @param queue The thread queue queue to release. * @param[out] lock_context The interrupt lock context to enable interrupts. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release( +static inline void _Thread_queue_Queue_release( Thread_queue_Queue *queue, ISR_lock_Context *lock_context ) @@ -678,7 +697,7 @@ void _Thread_queue_Do_acquire_critical( ISR_lock_Context *lock_context ); #else -RTEMS_INLINE_ROUTINE void _Thread_queue_Do_acquire_critical( +static inline void _Thread_queue_Do_acquire_critical( Thread_queue_Control *the_thread_queue, ISR_lock_Context *lock_context ) @@ -694,7 +713,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Do_acquire_critical( * @param the_thread_queue The thread queue control to acquire. * @param[out] lock_context The interrupt lock context. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical( +static inline void _Thread_queue_Acquire_critical( Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context ) @@ -717,7 +736,7 @@ void _Thread_queue_Acquire( Thread_queue_Context *queue_context ); #else -RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire( +static inline void _Thread_queue_Acquire( Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context ) @@ -736,7 +755,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire( * @retval false The thread queue control is not the owner of the lock. */ #if defined(RTEMS_DEBUG) -RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_lock_owner( +static inline bool _Thread_queue_Is_lock_owner( const Thread_queue_Control *the_thread_queue ) { @@ -760,7 +779,7 @@ void _Thread_queue_Do_release_critical( ISR_lock_Context *lock_context ); #else -RTEMS_INLINE_ROUTINE void _Thread_queue_Do_release_critical( +static inline void _Thread_queue_Do_release_critical( Thread_queue_Control *the_thread_queue, ISR_lock_Context *lock_context ) @@ -777,7 +796,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Do_release_critical( * @param the_thread_queue The thread queue control to release. * @param[out] queue_context The thread queue context. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Release_critical( +static inline void _Thread_queue_Release_critical( Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context ) @@ -800,7 +819,7 @@ void _Thread_queue_Release( Thread_queue_Context *queue_context ); #else -RTEMS_INLINE_ROUTINE void _Thread_queue_Release( +static inline void _Thread_queue_Release( Thread_queue_Control *the_thread_queue, Thread_queue_Context *queue_context ) @@ -984,24 +1003,6 @@ void _Thread_queue_Resume( void _Thread_queue_Extract( Thread_Control *the_thread ); /** - * @brief Extracts the_thread from the_thread_queue. - * - * This routine extracts the_thread from the_thread_queue - * and ensures that if there is a proxy for this task on - * another node, it is also dealt with. A proxy is a data - * data that is on the thread queue on the remote node and - * acts as a proxy for the local thread. If the local thread - * was waiting on a remote operation, then the remote side - * of the operation must be cleaned up. - * - * @param[in, out] the_thread The pointer to a thread control block that - * is to be removed - */ -void _Thread_queue_Extract_with_proxy( - Thread_Control *the_thread -); - -/** * @brief Surrenders the thread queue previously owned by the thread to the * first enqueued thread. * @@ -1106,7 +1107,7 @@ void _Thread_queue_Surrender_sticky( * @retval true @a queue is empty. * @retval false @a queue is not empty. */ -RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_empty( +static inline bool _Thread_queue_Is_empty( const Thread_queue_Queue *queue ) { @@ -1304,7 +1305,7 @@ void _Thread_queue_Initialize( * * @param[out] the_thread_queue The thread queue to destroy. */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy( +static inline void _Thread_queue_Destroy( Thread_queue_Control *the_thread_queue ) { @@ -1314,18 +1315,23 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy( #endif } +#if defined(RTEMS_MULTIPROCESSING) /** * @brief Does nothing. * * @param the_proxy This parameter is unused. * @param mp_id This parameter is unused. */ -#if defined(RTEMS_MULTIPROCESSING) void _Thread_queue_MP_callout_do_nothing( Thread_Control *the_proxy, Objects_Id mp_id ); +bool _Thread_queue_MP_set_callout( + Thread_Control *the_thread, + const Thread_queue_Context *queue_context +); + /** * @brief Unblocks the proxy of the thread. * diff --git a/cpukit/include/rtems/score/threadqops.h b/cpukit/include/rtems/score/threadqops.h index 504383e98d..d05823eefb 100644 --- a/cpukit/include/rtems/score/threadqops.h +++ b/cpukit/include/rtems/score/threadqops.h @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2021 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/score/timecounter.h b/cpukit/include/rtems/score/timecounter.h index 8185140f9b..ced3d7c60c 100644 --- a/cpukit/include/rtems/score/timecounter.h +++ b/cpukit/include/rtems/score/timecounter.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. + * Copyright (C) 2015, 2021 embedded brains GmbH & Co. KG + * + * 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. */ #ifndef _RTEMS_SCORE_TIMECOUNTER_H @@ -248,6 +261,62 @@ extern volatile int32_t _Timecounter_Time_uptime; */ extern struct timecounter *_Timecounter; +/** + * @brief Handler doing the NTP update second processing shall have this type. + * + * @param[in, out] adjustment is the NTP time adjustment. + * + * @param[in, out] newsec is the number of seconds since Unix epoch. + */ +typedef void ( *Timecounter_NTP_update_second )( + int64_t *adjustment, + time_t *newsec +); + +/** + * @brief Sets the NTP update second handler. + * + * @param handler is the new NTP update second handler used to carry out the + * NTP update second processing. + */ +void _Timecounter_Set_NTP_update_second( + Timecounter_NTP_update_second handler +); + +/** + * @brief Updates the time adjustment and seconds according to the NTP state. + * + * @param[in, out] adjustment is the NTP time adjustment. + * + * @param[in, out] newsec is the number of seconds since Unix epoch. + */ +void _Timecounter_NTP_update_second(int64_t *adjustment, time_t *newsec); + +/** + * @brief Gets the frequency in Hz of the current timecounter at some time + * point during the call. + * + * @return Returns the frequency in Hz. + */ +uint64_t _Timecounter_Get_frequency(void); + +/** + * @brief Updates the timecounter frequency adjustment used by + * _Timecounter_Set_NTP_update_second(). + * + * This function is part of the time synchronization using a PPS + * (Pulse Per Second) signal. + * + * When an event (a rising or falling edge of the PPS signal) occurs, the + * functions pps_capture() and pps_event() are executed. Only if the kernel + * consumer is configured to be PPS_KC_HARDPPS, the timecounter is disciplined. + * + * @param[in] tsp is the time at PPS event + * + * @param[i] nsec is the time in nanoseconds from the last PPS event + */ +void _Timecounter_Discipline(struct timespec *tsp, long nsec); + /** @} */ #ifdef __cplusplus diff --git a/cpukit/include/rtems/score/timecounterimpl.h b/cpukit/include/rtems/score/timecounterimpl.h index ab5cd82bf6..ee8f795bba 100644 --- a/cpukit/include/rtems/score/timecounterimpl.h +++ b/cpukit/include/rtems/score/timecounterimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,17 +10,28 @@ */ /* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * Copyright (c) 2015 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_TIMECOUNTERIMPL_H diff --git a/cpukit/include/rtems/score/timespec.h b/cpukit/include/rtems/score/timespec.h index 2090f19b32..2e419d69de 100644 --- a/cpukit/include/rtems/score/timespec.h +++ b/cpukit/include/rtems/score/timespec.h @@ -3,7 +3,7 @@ /** * @file * - * @ingroup Timespec + * @ingroup RTEMSScoreTimespec * * @brief This header file provides the interfaces of the * @ref RTEMSScoreTimespec. diff --git a/cpukit/include/rtems/score/timestamp.h b/cpukit/include/rtems/score/timestamp.h index 512c26a147..49d2f9af24 100644 --- a/cpukit/include/rtems/score/timestamp.h +++ b/cpukit/include/rtems/score/timestamp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_TIMESTAMP_H diff --git a/cpukit/include/rtems/score/timestampimpl.h b/cpukit/include/rtems/score/timestampimpl.h index 5d90779ee4..fee1994bfd 100644 --- a/cpukit/include/rtems/score/timestampimpl.h +++ b/cpukit/include/rtems/score/timestampimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_TIMESTAMPIMPL_H @@ -44,7 +63,7 @@ extern "C" { * @param _seconds The seconds portion of the timestamp. * @param _nanoseconds The nanoseconds portion of the timestamp. */ -RTEMS_INLINE_ROUTINE void _Timestamp_Set( +static inline void _Timestamp_Set( Timestamp_Control *_time, time_t _seconds, long _nanoseconds @@ -67,7 +86,7 @@ RTEMS_INLINE_ROUTINE void _Timestamp_Set( * @param[out] _time The timestamp instance to zero. */ -RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero( +static inline void _Timestamp_Set_to_zero( Timestamp_Control *_time ) { @@ -86,7 +105,7 @@ RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero( * @retval false @a _lhs is greater or equal than @a rhs. */ -RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than( +static inline bool _Timestamp_Less_than( const Timestamp_Control *_lhs, const Timestamp_Control *_rhs ) @@ -106,7 +125,7 @@ RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than( * @retval false @a _lhs is less or equal than @a _rhs. */ -RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than( +static inline bool _Timestamp_Greater_than( const Timestamp_Control *_lhs, const Timestamp_Control *_rhs ) @@ -126,7 +145,7 @@ RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than( * @retval false @a _lhs is not equal to @a _rhs. */ -RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to( +static inline bool _Timestamp_Equal_to( const Timestamp_Control *_lhs, const Timestamp_Control *_rhs ) @@ -143,7 +162,7 @@ RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to( * @param[in, out] _time The base time to be added to. * @param _add points The timestamp to add to the first argument. */ -RTEMS_INLINE_ROUTINE void _Timestamp_Add_to( +static inline void _Timestamp_Add_to( Timestamp_Control *_time, const Timestamp_Control *_add ) @@ -162,7 +181,7 @@ RTEMS_INLINE_ROUTINE void _Timestamp_Add_to( * @param[out] _result Contains the difference between starting and ending * time after the method call. */ -RTEMS_INLINE_ROUTINE void _Timestamp_Subtract( +static inline void _Timestamp_Subtract( const Timestamp_Control *_start, const Timestamp_Control *_end, Timestamp_Control *_result @@ -182,7 +201,7 @@ RTEMS_INLINE_ROUTINE void _Timestamp_Subtract( * @param[out] _ival_percentage The integer portion of the average. * @param[out] _fval_percentage The thousandths of percentage. */ -RTEMS_INLINE_ROUTINE void _Timestamp_Divide( +static inline void _Timestamp_Divide( const Timestamp_Control *_lhs, const Timestamp_Control *_rhs, uint32_t *_ival_percentage, @@ -212,7 +231,7 @@ RTEMS_INLINE_ROUTINE void _Timestamp_Divide( * * @return The seconds portion of @a _time. */ -RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds( +static inline time_t _Timestamp_Get_seconds( const Timestamp_Control *_time ) { @@ -228,7 +247,7 @@ RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds( * * @return The nanoseconds portion of @a _time. */ -RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds( +static inline uint32_t _Timestamp_Get_nanoseconds( const Timestamp_Control *_time ) { @@ -248,7 +267,7 @@ RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds( * * @return The time in nanoseconds. */ -RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_as_nanoseconds( +static inline uint64_t _Timestamp_Get_as_nanoseconds( const Timestamp_Control *_time ) { @@ -265,7 +284,7 @@ RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_as_nanoseconds( * @param _timestamp The timestamp. * @param[out] _timespec The timespec to be filled in by the method. */ -RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec( +static inline void _Timestamp_To_timespec( const Timestamp_Control *_timestamp, struct timespec *_timespec ) @@ -279,7 +298,7 @@ RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec( * @param _timestamp The timestamp. * @param[out] _timeval The timeval to be filled in by the method. */ -RTEMS_INLINE_ROUTINE void _Timestamp_To_timeval( +static inline void _Timestamp_To_timeval( const Timestamp_Control *_timestamp, struct timeval *_timeval ) diff --git a/cpukit/include/rtems/score/tls.h b/cpukit/include/rtems/score/tls.h index 7725a003ca..8716c5230c 100644 --- a/cpukit/include/rtems/score/tls.h +++ b/cpukit/include/rtems/score/tls.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,23 +10,34 @@ */ /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * Copyright (C) 2014, 2023 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_TLS_H #define _RTEMS_SCORE_TLS_H -#include <rtems/score/cpu.h> +#include <rtems/score/cpuimpl.h> #include <string.h> @@ -46,31 +59,51 @@ extern "C" { * @{ */ -extern char _TLS_Data_begin[]; - -extern char _TLS_Data_end[]; +/** + * @brief Represents the TLS configuration. + */ +typedef struct { + /** + * @brief This member is initialized to _TLS_Data_begin. + */ + const char *data_begin; -extern char _TLS_Data_size[]; + /** + * @brief This member is initialized to _TLS_Data_size. + */ + const char *data_size; -extern char _TLS_BSS_begin[]; + /** + * @brief This member is initialized to _TLS_BSS_begin. + */ + const char *bss_begin; -extern char _TLS_BSS_end[]; + /** + * @brief This member is initialized to _TLS_BSS_size. + */ + const char *bss_size; -extern char _TLS_BSS_size[]; + /** + * @brief This member is initialized to _TLS_Size. + */ + const char *size; -extern char _TLS_Size[]; + /** + * @brief This member is initialized to _TLS_Alignment. + */ + const char *alignment; +} TLS_Configuration; /** - * @brief The TLS section alignment. + * @brief Provides the TLS configuration. * - * This symbol is provided by the linker command file as the maximum alignment - * of the .tdata and .tbss sections. The linker ensures that the first TLS - * output section is aligned to the maximum alignment of all TLS output - * sections, see function _bfd_elf_tls_setup() in bfd/elflink.c of the GNU - * Binutils sources. The linker command file must take into account the case - * that the .tdata section is empty and the .tbss section is non-empty. + * Directly using symbols with an arbitrary absolute address such as + * _TLS_Alignment may not work with all code models (for example the AArch64 + * tiny and small code models). Store the addresses in a read-only object. + * Using the volatile qualifier ensures that the compiler actually loads the + * address from the object. */ -extern char _TLS_Alignment[]; +extern const volatile TLS_Configuration _TLS_Configuration; typedef struct { /* @@ -103,101 +136,71 @@ typedef struct { } TLS_Index; /** - * @brief Gets the TLS size. - * - * @return The TLS size. - */ -static inline uintptr_t _TLS_Get_size( void ) -{ - uintptr_t size; - - /* - * We must be careful with using _TLS_Size here since this could lead GCC to - * assume that this symbol is not 0 and the tests for 0 will be optimized - * away. - */ - size = (uintptr_t) _TLS_Size; - RTEMS_OBFUSCATE_VARIABLE( size ); - return size; -} - -/** - * @brief Returns the value aligned up to the stack alignment. - * - * @param val The value to align. - * - * @return The value aligned to the stack alignment. - */ -static inline uintptr_t _TLS_Align_up( uintptr_t val ) -{ - uintptr_t alignment = CPU_STACK_ALIGNMENT; - - return RTEMS_ALIGN_UP( val, alignment ); -} - -/** - * @brief Returns the size of the thread control block area size for this - * alignment, or the minimum size if alignment is too small. + * @brief Gets the size of the thread control block area in bytes. * - * @param alignment The alignment for the operation. + * @param config is the TLS configuration. * - * @return The size of the thread control block area. + * @return Returns the size of the thread control block area in bytes. */ static inline uintptr_t _TLS_Get_thread_control_block_area_size( - uintptr_t alignment + const volatile TLS_Configuration *config ) { - return alignment <= sizeof(TLS_Thread_control_block) ? - sizeof(TLS_Thread_control_block) : alignment; +#if CPU_THREAD_LOCAL_STORAGE_VARIANT == 11 + uintptr_t alignment; + + alignment = (uintptr_t) config->alignment; + + return RTEMS_ALIGN_UP( sizeof( TLS_Thread_control_block ), alignment ); +#else + (void) config; + return sizeof( TLS_Thread_control_block ); +#endif } /** - * @brief Return the TLS area allocation size. + * @brief Gets the allocation size of the thread-local storage area in bytes. * - * @return The TLS area allocation size. + * @return Returns the allocation size of the thread-local storage area in + * bytes. */ uintptr_t _TLS_Get_allocation_size( void ); /** - * @brief Copies TLS size bytes from the address tls_area and returns a pointer - * to the start of the area after clearing it. + * @brief Initializes the thread-local storage data. * - * @param tls_area The starting address of the area to clear. + * @param config is the TLS configuration. * - * @return The pointer to the beginning of the cleared section. + * @param[out] tls_data is the thread-local storage data to initialize. */ -static inline void *_TLS_Copy_and_clear( void *tls_area ) +static inline void _TLS_Copy_and_clear( + const volatile TLS_Configuration *config, + void *tls_data +) { - tls_area = memcpy( - tls_area, - _TLS_Data_begin, - (size_t) ((uintptr_t)_TLS_Data_size) - ); - + tls_data = + memcpy( tls_data, config->data_begin, (uintptr_t) config->data_size ); memset( - (char *) tls_area + (size_t)((intptr_t) _TLS_BSS_begin) - - (size_t)((intptr_t) _TLS_Data_begin), + (char *) tls_data + + (uintptr_t) config->bss_begin - (uintptr_t) config->data_begin, 0, - ((size_t) (intptr_t)_TLS_BSS_size) + (uintptr_t) config->bss_size ); - - return tls_area; } /** - * @brief Initializes the dynamic thread vector. + * @brief Initializes the thread control block and the dynamic thread vector. * - * @param tls_block The tls block for @a dtv. - * @param tcb The thread control block for @a dtv. - * @param[out] dtv The dynamic thread vector to initialize. + * @param tls_data is the thread-local storage data address. * - * @return Pointer to an area that was copied and cleared from tls_block - * onwards (@see _TLS_Copy_and_clear). + * @param[out] tcb is the thread control block to initialize. + * + * @param[out] dtv is the dynamic thread vector to initialize. */ -static inline void *_TLS_Initialize( - void *tls_block, - TLS_Thread_control_block *tcb, +static inline void _TLS_Initialize_TCB_and_DTV( + void *tls_data, + TLS_Thread_control_block *tcb, TLS_Dynamic_thread_vector *dtv ) { @@ -207,86 +210,72 @@ static inline void *_TLS_Initialize( #else tcb->dtv = dtv; dtv->generation_number = 1; - dtv->tls_blocks[0] = tls_block; + dtv->tls_blocks[0] = tls_data; #endif - - return _TLS_Copy_and_clear( tls_block ); } /** - * @brief Initializes a dynamic thread vector beginning at the given starting - * address. + * @brief Initializes the thread-local storage area. * - * Use Variant I, TLS offsets emitted by linker takes the TCB into account. + * @param tls_area[out] is the thread-local storage area to initialize. * - * @param tls_area The tls area for the initialization. - * - * @return Pointer to an area that was copied and cleared from tls_block - * onwards (@see _TLS_Copy_and_clear). + * @return Where the architectures uses Variant I and the TLS offsets emitted + * by the linker neglect the TCB, returns the address of the thread-local + * storage data. Otherwise, returns the address of the thread control block. */ -static inline void *_TLS_TCB_at_area_begin_initialize( void *tls_area ) +static inline void *_TLS_Initialize_area( void *tls_area ) { - void *tls_block = (char *) tls_area - + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment ); - TLS_Thread_control_block *tcb = tls_area; - uintptr_t aligned_size = _TLS_Align_up( (uintptr_t) _TLS_Size ); - TLS_Dynamic_thread_vector *dtv = (TLS_Dynamic_thread_vector *) - ((char *) tls_block + aligned_size); - - return _TLS_Initialize( tls_block, tcb, dtv ); -} + const volatile TLS_Configuration *config; + uintptr_t alignment; + void *tls_data; + TLS_Thread_control_block *tcb; + TLS_Dynamic_thread_vector *dtv; + void *return_value; +#if CPU_THREAD_LOCAL_STORAGE_VARIANT == 11 + uintptr_t tcb_size; +#endif +#if CPU_THREAD_LOCAL_STORAGE_VARIANT == 20 + uintptr_t size; + uintptr_t alignment_2; +#endif -/** - * @brief Initializes a dynamic thread vector with the area before a given - * starting address as thread control block. - * - * Use Variant I, TLS offsets emitted by linker neglects the TCB. - * - * @param tls_area The tls area for the initialization. - * - * @return Pointer to an area that was copied and cleared from tls_block - * onwards (@see _TLS_Copy_and_clear). - */ -static inline void *_TLS_TCB_before_TLS_block_initialize( void *tls_area ) -{ - void *tls_block = (char *) tls_area - + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment ); - TLS_Thread_control_block *tcb = (TLS_Thread_control_block *) - ((char *) tls_block - sizeof(*tcb)); - uintptr_t aligned_size = _TLS_Align_up( (uintptr_t) _TLS_Size ); - TLS_Dynamic_thread_vector *dtv = (TLS_Dynamic_thread_vector *) - ((char *) tls_block + aligned_size); - - return _TLS_Initialize( tls_block, tcb, dtv ); -} + config = &_TLS_Configuration; + alignment = (uintptr_t) config->alignment; -/** - * @brief Initializes a dynamic thread vector with the area after a given - * starting address as thread control block. - * - * Use Variant II - * - * @param tls_area The tls area for the initialization. - * - * @return Pointer to an area that was copied and cleared from tls_block - * onwards (@see _TLS_Copy_and_clear). - */ -static inline void *_TLS_TCB_after_TLS_block_initialize( void *tls_area ) -{ - uintptr_t size = (uintptr_t) _TLS_Size; - uintptr_t tls_align = (uintptr_t) _TLS_Alignment; - uintptr_t tls_mask = tls_align - 1; - uintptr_t heap_align = _TLS_Align_up( tls_align ); - uintptr_t heap_mask = heap_align - 1; - TLS_Thread_control_block *tcb = (TLS_Thread_control_block *) - ((char *) tls_area + ((size + heap_mask) & ~heap_mask)); - void *tls_block = (char *) tcb - ((size + tls_mask) & ~tls_mask); - TLS_Dynamic_thread_vector *dtv = (TLS_Dynamic_thread_vector *) - ((char *) tcb + sizeof(*tcb)); - - _TLS_Initialize( tls_block, tcb, dtv ); - - return tcb; +#ifdef __i386__ + dtv = NULL; +#else + dtv = (TLS_Dynamic_thread_vector *) tls_area; + tls_area = (char *) tls_area + sizeof( *dtv ); +#endif + +#if CPU_THREAD_LOCAL_STORAGE_VARIANT == 10 + tls_data = (void *) + RTEMS_ALIGN_UP( (uintptr_t) tls_area + sizeof( *tcb ), alignment ); + tcb = (TLS_Thread_control_block *) ((char *) tls_data - sizeof( *tcb )); + return_value = tls_data; +#elif CPU_THREAD_LOCAL_STORAGE_VARIANT == 11 + tcb_size = RTEMS_ALIGN_UP( sizeof( *tcb ), alignment ); + tls_data = (void *) + RTEMS_ALIGN_UP( (uintptr_t) tls_area + tcb_size, alignment ); + tcb = (TLS_Thread_control_block *) ((char *) tls_data - tcb_size); + return_value = tcb; +#elif CPU_THREAD_LOCAL_STORAGE_VARIANT == 20 + alignment_2 = RTEMS_ALIGN_UP( alignment, CPU_SIZEOF_POINTER ); + tls_area = (void *) RTEMS_ALIGN_UP( (uintptr_t) tls_area, alignment_2 ); + size = (uintptr_t) config->size; + tcb = (TLS_Thread_control_block *) + ((char *) tls_area + RTEMS_ALIGN_UP( size, alignment_2 )); + tls_data = (char *) tcb - RTEMS_ALIGN_UP( size, alignment ); + return_value = tcb; +#else +#error "unexpected CPU_THREAD_LOCAL_STORAGE_VARIANT value" +#endif + + _TLS_Initialize_TCB_and_DTV( tls_data, tcb, dtv ); + _TLS_Copy_and_clear( config, tls_data ); + + return return_value; } /** @} */ diff --git a/cpukit/include/rtems/score/todimpl.h b/cpukit/include/rtems/score/todimpl.h index acfec00186..565e047c7f 100644 --- a/cpukit/include/rtems/score/todimpl.h +++ b/cpukit/include/rtems/score/todimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_TODIMPL_H @@ -355,7 +374,7 @@ static inline uint32_t _TOD_Seconds_since_epoch( void ) * * @param[out] time The timeval to be filled in by the method. */ -RTEMS_INLINE_ROUTINE void _TOD_Get_timeval( +static inline void _TOD_Get_timeval( struct timeval *time ) { @@ -363,27 +382,12 @@ RTEMS_INLINE_ROUTINE void _TOD_Get_timeval( } /** - * @brief Adjusts the Time of Time. - * - * This method is used to adjust the current time of day by the - * specified amount. - * - * @param delta is the amount to adjust. - * - * @retval STATUS_SUCCESSFUL Successful operation. - * @retval other Some error occurred. - */ -Status_Control _TOD_Adjust( - const struct timespec *delta -); - -/** * @brief Check if the TOD is Set * * @retval true The time is set. * @retval false The time is not set. */ -RTEMS_INLINE_ROUTINE bool _TOD_Is_set( void ) +static inline bool _TOD_Is_set( void ) { return _TOD.is_set; } diff --git a/cpukit/include/rtems/score/userext.h b/cpukit/include/rtems/score/userext.h index 28b90a06ad..63fc80afeb 100644 --- a/cpukit/include/rtems/score/userext.h +++ b/cpukit/include/rtems/score/userext.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_USEREXT_H diff --git a/cpukit/include/rtems/score/userextdata.h b/cpukit/include/rtems/score/userextdata.h index 446c7e01dd..62e50e2029 100644 --- a/cpukit/include/rtems/score/userextdata.h +++ b/cpukit/include/rtems/score/userextdata.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,9 +15,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_USEREXTDATA_H diff --git a/cpukit/include/rtems/score/userextimpl.h b/cpukit/include/rtems/score/userextimpl.h index fd075a94ec..70a612f402 100644 --- a/cpukit/include/rtems/score/userextimpl.h +++ b/cpukit/include/rtems/score/userextimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_USEREXTIMPL_H @@ -60,11 +79,13 @@ typedef struct { */ Chain_Iterator_registry Iterators; +#if defined(RTEMS_SMP) /** * @brief Lock to protect User_extensions_List::Active and * User_extensions_List::Iterators. */ - ISR_LOCK_MEMBER( Lock ) + ISR_lock_Control Lock; +#endif } User_extensions_List; /** @@ -102,7 +123,7 @@ void _User_extensions_Add_set( * * @param extension The user extension to add. */ -RTEMS_INLINE_ROUTINE void _User_extensions_Add_API_set( +static inline void _User_extensions_Add_API_set( User_extensions_Control *extension ) { @@ -115,7 +136,7 @@ RTEMS_INLINE_ROUTINE void _User_extensions_Add_API_set( * @param[in, out] extension The user extension to add. * @param extension_table Is set as callouts for @a extension. */ -RTEMS_INLINE_ROUTINE void _User_extensions_Add_set_with_table( +static inline void _User_extensions_Add_set_with_table( User_extensions_Control *extension, const User_extensions_Table *extension_table ) diff --git a/cpukit/include/rtems/score/watchdog.h b/cpukit/include/rtems/score/watchdog.h index 8e946866f6..dc880299cc 100644 --- a/cpukit/include/rtems/score/watchdog.h +++ b/cpukit/include/rtems/score/watchdog.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_WATCHDOG_H diff --git a/cpukit/include/rtems/score/watchdogimpl.h b/cpukit/include/rtems/score/watchdogimpl.h index 7b364b8828..df479aeeed 100644 --- a/cpukit/include/rtems/score/watchdogimpl.h +++ b/cpukit/include/rtems/score/watchdogimpl.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2004. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_WATCHDOGIMPL_H @@ -95,7 +114,7 @@ typedef enum { * * @param[out] header The header to initialize. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Header_initialize( +static inline void _Watchdog_Header_initialize( Watchdog_Header *header ) { @@ -110,7 +129,7 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Header_initialize( * * @return The first of @a header. */ -RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_Header_first( +static inline Watchdog_Control *_Watchdog_Header_first( const Watchdog_Header *header ) { @@ -122,7 +141,7 @@ RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_Header_first( * * @param header The watchdog header to destroy. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Header_destroy( +static inline void _Watchdog_Header_destroy( Watchdog_Header *header ) { @@ -144,7 +163,7 @@ void _Watchdog_Tick( struct Per_CPU_Control *cpu ); * * @return The RB_COLOR of @a the_watchdog. */ -RTEMS_INLINE_ROUTINE Watchdog_State _Watchdog_Get_state( +static inline Watchdog_State _Watchdog_Get_state( const Watchdog_Control *the_watchdog ) { @@ -157,7 +176,7 @@ RTEMS_INLINE_ROUTINE Watchdog_State _Watchdog_Get_state( * @param[out] the_watchdog The watchdog to set the state of. * @param state The state to set the watchdog to. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Set_state( +static inline void _Watchdog_Set_state( Watchdog_Control *the_watchdog, Watchdog_State state ) @@ -172,7 +191,7 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Set_state( * * @return The cpu of the watchdog. */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Watchdog_Get_CPU( +static inline Per_CPU_Control *_Watchdog_Get_CPU( const Watchdog_Control *the_watchdog ) { @@ -189,7 +208,7 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Watchdog_Get_CPU( * @param[out] the_watchdog The watchdog to set the cpu of. * @param cpu The cpu to be set as @a the_watchdog's cpu. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Set_CPU( +static inline void _Watchdog_Set_CPU( Watchdog_Control *the_watchdog, Per_CPU_Control *cpu ) @@ -209,7 +228,7 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Set_CPU( * * @param[out] the_watchdog The uninitialized watchdog. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Preinitialize( +static inline void _Watchdog_Preinitialize( Watchdog_Control *the_watchdog, Per_CPU_Control *cpu ) @@ -231,7 +250,7 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Preinitialize( * @param[out] the_watchdog The watchdog to initialize. * @param routing The service routine for @a the_watchdog. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Initialize( +static inline void _Watchdog_Initialize( Watchdog_Control *the_watchdog, Watchdog_Service_routine_entry routine ) @@ -313,7 +332,7 @@ void _Watchdog_Remove( * @retval 0 The now time is greater than or equal to the expiration time of * the watchdog. */ -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Cancel( +static inline uint64_t _Watchdog_Cancel( Watchdog_Header *header, Watchdog_Control *the_watchdog, uint64_t now @@ -343,7 +362,7 @@ RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Cancel( * @retval true The watchdog is scheduled. * @retval false The watchdog is inactive. */ -RTEMS_INLINE_ROUTINE bool _Watchdog_Is_scheduled( +static inline bool _Watchdog_Is_scheduled( const Watchdog_Control *the_watchdog ) { @@ -351,33 +370,50 @@ RTEMS_INLINE_ROUTINE bool _Watchdog_Is_scheduled( } /** - * @brief Sets the first node of the header. + * @brief Sets the first watchdog of the watchdog collection to the next + * watchdog of the current first watchdog. + * + * This function may be used during watchdog removals, see _Watchdog_Remove() + * and _Watchdog_Tickle(). * - * Sets the first node of the header to either the leftmost child node of the - * watchdog control node, or if not present sets it to the right child node of - * the watchdog control node. if both are not present, the new first node is - * the parent node of the current first node. + * @param[in, out] header is the watchdog collection header. * - * @param[in, out] header The watchdog header. - * @param the_watchdog The watchdog control node for the operation. + * @param first is the current first watchdog which should be removed + * afterwards. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Next_first( - Watchdog_Header *header, - Watchdog_Control *the_watchdog +static inline void _Watchdog_Next_first( + Watchdog_Header *header, + const Watchdog_Control *first ) { - RBTree_Node *node = _RBTree_Right( &the_watchdog->Node.RBTree ); - - if ( node != NULL ) { - RBTree_Node *left; - - while ( ( left = _RBTree_Left( node ) ) != NULL ) { - node = left; - } + RBTree_Node *right; - header->first = node; + /* + * This function uses the following properties of red-black trees: + * + * 1. Every leaf (NULL) is black. + * + * 2. If a node is red, then both its children are black. + * + * 3. Every simple path from a node to a descendant leaf contains the same + * number of black nodes. + * + * The first node has no left child. So every path from the first node has + * exactly one black node (including leafs). The first node cannot have a + * non-leaf black right child. It may have a red right child. In this case + * both children must be leafs. + */ + _Assert( header->first == &first->Node.RBTree ); + _Assert( _RBTree_Left( &first->Node.RBTree ) == NULL ); + right = _RBTree_Right( &first->Node.RBTree ); + + if ( right != NULL ) { + _Assert( RB_COLOR( right, Node ) == RB_RED ); + _Assert( _RBTree_Left( right ) == NULL ); + _Assert( _RBTree_Right( right ) == NULL ); + header->first = right; } else { - header->first = _RBTree_Parent( &the_watchdog->Node.RBTree ); + header->first = _RBTree_Parent( &first->Node.RBTree ); } } @@ -414,7 +450,7 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Next_first( * @retval true The timespec is a valid timespec. * @retval false The timespec is invalid. */ -RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_timespec( +static inline bool _Watchdog_Is_valid_timespec( const struct timespec *ts ) { @@ -430,7 +466,7 @@ RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_timespec( * @retval true The timespec is a valid interval timespec. * @retval false The timespec is invalid. */ -RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_interval_timespec( +static inline bool _Watchdog_Is_valid_interval_timespec( const struct timespec *ts ) { @@ -447,7 +483,7 @@ RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_interval_timespec( * @retval pointer Pointer to the now timespec. * @retval NULL @a delta is not a valid interval timespec. */ -RTEMS_INLINE_ROUTINE const struct timespec * _Watchdog_Future_timespec( +static inline const struct timespec * _Watchdog_Future_timespec( struct timespec *now, const struct timespec *delta ) @@ -485,7 +521,7 @@ RTEMS_INLINE_ROUTINE const struct timespec * _Watchdog_Future_timespec( * @retval true @a ts is too far in the future. * @retval false @a ts is not too far in the future. */ -RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_timespec( +static inline bool _Watchdog_Is_far_future_timespec( const struct timespec *ts ) { @@ -499,7 +535,7 @@ RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_timespec( * * @return @a seconds converted to ticks. */ -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_seconds( +static inline uint64_t _Watchdog_Ticks_from_seconds( uint32_t seconds ) { @@ -517,7 +553,7 @@ RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_seconds( * * @return @a ts converted to ticks. */ -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_timespec( +static inline uint64_t _Watchdog_Ticks_from_timespec( const struct timespec *ts ) { @@ -541,7 +577,7 @@ RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_timespec( * * @param[out] ts is the timespec to return the converted ticks. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Ticks_to_timespec( +static inline void _Watchdog_Ticks_to_timespec( uint64_t ticks, struct timespec *ts ) @@ -557,7 +593,7 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Ticks_to_timespec( * * @return @a sbt converted to ticks. */ -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_sbintime( int64_t sbt ) +static inline uint64_t _Watchdog_Ticks_from_sbintime( int64_t sbt ) { uint64_t ticks = ( sbt >> 32 ) << WATCHDOG_BITS_FOR_1E9_NANOSECONDS; @@ -572,7 +608,7 @@ RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_sbintime( int64_t sbt ) * @param cpu The cpu to acquire the watchdog lock of. * @param lock_context The lock context. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_acquire_critical( +static inline void _Watchdog_Per_CPU_acquire_critical( Per_CPU_Control *cpu, ISR_lock_Context *lock_context ) @@ -586,7 +622,7 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_acquire_critical( * @param cpu The cpu to release the watchdog lock of. * @param lock_context The lock context. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_release_critical( +static inline void _Watchdog_Per_CPU_release_critical( Per_CPU_Control *cpu, ISR_lock_Context *lock_context ) @@ -604,7 +640,7 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_release_critical( * * @return The new expiration time of the watchdog. */ -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_ticks( +static inline uint64_t _Watchdog_Per_CPU_insert_ticks( Watchdog_Control *the_watchdog, Per_CPU_Control *cpu, Watchdog_Interval ticks @@ -636,7 +672,7 @@ RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_ticks( * * @return The expiration time of the watchdog. */ -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert( +static inline uint64_t _Watchdog_Per_CPU_insert( Watchdog_Control *the_watchdog, Per_CPU_Control *cpu, Watchdog_Header *header, @@ -660,7 +696,7 @@ RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert( * @param cpu The cpu to remove the watchdog from. * @param[in, out] The scheduled watchdogs. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove( +static inline void _Watchdog_Per_CPU_remove( Watchdog_Control *the_watchdog, Per_CPU_Control *cpu, Watchdog_Header *header @@ -681,7 +717,7 @@ RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove( * * @param[in, out] the_watchdog The watchdog to remove. */ -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove_ticks( +static inline void _Watchdog_Per_CPU_remove_ticks( Watchdog_Control *the_watchdog ) { diff --git a/cpukit/include/rtems/score/watchdogticks.h b/cpukit/include/rtems/score/watchdogticks.h index a4f952406e..4540a853e4 100644 --- a/cpukit/include/rtems/score/watchdogticks.h +++ b/cpukit/include/rtems/score/watchdogticks.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_WATCHDOGTICKS_H diff --git a/cpukit/include/rtems/score/wkspace.h b/cpukit/include/rtems/score/wkspace.h index a3af86e878..b58d6ed459 100644 --- a/cpukit/include/rtems/score/wkspace.h +++ b/cpukit/include/rtems/score/wkspace.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,17 +13,32 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SCORE_WKSPACE_H #define _RTEMS_SCORE_WKSPACE_H #include <rtems/score/heap.h> -#include <rtems/score/interr.h> -#include <rtems/score/memory.h> #ifdef __cplusplus extern "C" { @@ -42,17 +59,11 @@ extern "C" { extern Heap_Control _Workspace_Area; /** - * @brief Initilizes the workspace handler. + * @brief Initializes the workspace handler. * * This routine performs the initialization necessary for this handler. - * - * @param mem The memory information - * @param extend The extension handler for the new workspace. */ -void _Workspace_Handler_initialization( - const Memory_Information *mem, - Heap_Initialization_or_extend_handler extend -); +void _Workspace_Handler_initialization( void ); /** * @brief Allocates a memory block of the specified size from the workspace. diff --git a/cpukit/include/rtems/score/wkspacedata.h b/cpukit/include/rtems/score/wkspacedata.h index f1ca524fa0..6d809ca788 100644 --- a/cpukit/include/rtems/score/wkspacedata.h +++ b/cpukit/include/rtems/score/wkspacedata.h @@ -11,7 +11,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/include/rtems/score/wkspaceinitmulti.h b/cpukit/include/rtems/score/wkspaceinitmulti.h new file mode 100644 index 0000000000..dfb2b3cbde --- /dev/null +++ b/cpukit/include/rtems/score/wkspaceinitmulti.h @@ -0,0 +1,129 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreWorkspace + * + * @brief This header file provides the implementation of + * _Workspace_Initialize_for_multiple_areas(). + */ + +/* + * Copyright (C) 2012, 2020 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_SCORE_WKSPACEINITMULTI_H +#define _RTEMS_SCORE_WKSPACEINITMULTI_H + +#include <rtems/score/wkspace.h> +#include <rtems/score/heapimpl.h> +#include <rtems/score/interr.h> +#include <rtems/score/memory.h> +#include <rtems/config.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup RTEMSScoreWorkspace + * + * @brief Initializes the RTEMS Workspace with support for more than one memory + * area. + * + * This implementation should be used by BSPs which provide more than one + * memory area via _Memory_Get() to implement + * _Workspace_Handler_initialization(). + */ +static inline void _Workspace_Initialize_for_multiple_areas( void ) +{ + const Memory_Information *mem; + Heap_Initialization_or_extend_handler init_or_extend; + uintptr_t remaining; + bool unified; + uintptr_t page_size; + uintptr_t overhead; + size_t i; + + mem = _Memory_Get(); + page_size = CPU_HEAP_ALIGNMENT; + remaining = rtems_configuration_get_work_space_size(); + init_or_extend = _Heap_Initialize; + unified = rtems_configuration_get_unified_work_area(); + overhead = _Heap_Area_overhead( page_size ); + + for ( i = 0; i < _Memory_Get_count( mem ); ++i ) { + Memory_Area *area; + uintptr_t free_size; + + area = _Memory_Get_area( mem, i ); + free_size = _Memory_Get_free_size( area ); + + if ( free_size > overhead ) { + uintptr_t space_available; + uintptr_t size; + + if ( unified ) { + size = free_size; + } else { + if ( remaining > 0 ) { + size = remaining < free_size - overhead ? + remaining + overhead : free_size; + } else { + size = 0; + } + } + + space_available = ( *init_or_extend )( + &_Workspace_Area, + _Memory_Get_free_begin( area ), + size, + page_size + ); + + _Memory_Consume( area, size ); + + if ( space_available < remaining ) { + remaining -= space_available; + } else { + remaining = 0; + } + + init_or_extend = _Heap_Extend; + } + } + + if ( remaining > 0 ) { + _Internal_error( INTERNAL_ERROR_TOO_LITTLE_WORKSPACE ); + } + + _Heap_Protection_set_delayed_free_fraction( &_Workspace_Area, 1 ); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_WKSPACEINITMULTI_H */ diff --git a/cpukit/include/rtems/score/wkspaceinitone.h b/cpukit/include/rtems/score/wkspaceinitone.h new file mode 100644 index 0000000000..0dc252ad43 --- /dev/null +++ b/cpukit/include/rtems/score/wkspaceinitone.h @@ -0,0 +1,119 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreWorkspace + * + * @brief This header file provides the implementation of + * _Workspace_Initialize_for_one_area(). + */ + +/* + * Copyright (C) 2012, 2020 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_SCORE_WKSPACEINITONE_H +#define _RTEMS_SCORE_WKSPACEINITONE_H + +#include <rtems/score/wkspace.h> +#include <rtems/score/assert.h> +#include <rtems/score/heapimpl.h> +#include <rtems/score/interr.h> +#include <rtems/score/memory.h> +#include <rtems/config.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup RTEMSScoreWorkspace + * + * @brief Initializes the RTEMS Workspace with support for exactly one memory + * area. + * + * This implementation should be used by BSPs which provide exactly one memory + * area via _Memory_Get() to implement _Workspace_Handler_initialization(). + */ +static inline void _Workspace_Initialize_for_one_area( void ) +{ + uintptr_t page_size; + uintptr_t wkspace_size; + uintptr_t wkspace_size_with_overhead; + const Memory_Information *mem; + Memory_Area *area; + uintptr_t free_size; + uintptr_t available_size; + + page_size = CPU_HEAP_ALIGNMENT; + wkspace_size = rtems_configuration_get_work_space_size(); + wkspace_size_with_overhead = wkspace_size + _Heap_Area_overhead( page_size ); + + mem = _Memory_Get(); + _Assert( _Memory_Get_count( mem ) == 1 ); + + area = _Memory_Get_area( mem, 0 ); + free_size = _Memory_Get_free_size( area ); + + if ( + wkspace_size < wkspace_size_with_overhead && + free_size >= wkspace_size_with_overhead + ) { + uintptr_t size; + + if ( rtems_configuration_get_unified_work_area() ) { + size = free_size; + } else { + size = wkspace_size_with_overhead; + } + + available_size = _Heap_Initialize( + &_Workspace_Area, + _Memory_Get_free_begin( area ), + size, + page_size + ); + + _Memory_Consume( area, size ); + } else { + /* + * An unsigned integer overflow happened, or the available free memory is + * not enough. + */ + available_size = 0; + } + + if ( wkspace_size > available_size ) { + _Internal_error( INTERNAL_ERROR_TOO_LITTLE_WORKSPACE ); + } + + _Heap_Protection_set_delayed_free_fraction( &_Workspace_Area, 1 ); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_WKSPACEINITONE_H */ diff --git a/cpukit/include/rtems/serdbg.h b/cpukit/include/rtems/serdbg.h deleted file mode 100644 index fe106bce44..0000000000 --- a/cpukit/include/rtems/serdbg.h +++ /dev/null @@ -1,151 +0,0 @@ -/*===============================================================*\ -| Project: RTEMS remote gdb over serial line | -+-----------------------------------------------------------------+ -| File: serdbg.h | -+-----------------------------------------------------------------+ -| Copyright (c) 2002 IMD | -| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | -| <Thomas.Doerfler@imd-systems.de> | -| all rights reserved | -+-----------------------------------------------------------------+ -| this file declares intialization functions to add | -| a gdb remote debug stub to an RTEMS system | -| | -+-----------------------------------------------------------------+ -| date history ID | -| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | -| 04.04.02 creation doe | -\*===============================================================*/ -#ifndef _SERDBG_H -#define _SERDBG_H - -#include <rtems.h> -#include <termios.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - uint32_t baudrate; /* debug baud rate, e.g. 57600 */ - void (*callout)(void); /* callout pointer during polling */ - int (*open_io)(const char *dev_name, uint32_t baudrate); /* I/O open fnc */ - const char *devname; /* debug device, e.g. "/dev/tty01" */ - bool skip_init_bkpt; /* if TRUE, do not stop when initializing */ -} serdbg_conf_t; - -/* - * must be defined in init module... - */ -extern serdbg_conf_t serdbg_conf; - - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -void putDebugChar -( -/*-------------------------------------------------------------------------*\ -| Purpose: | -| send character to remote debugger | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ - char c /* char to send */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| <none> | -\*=========================================================================*/ - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -int getDebugChar -( -/*-------------------------------------------------------------------------*\ -| Purpose: | -| get character from remote debugger | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ - void /* <none> */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| <none> | -\*=========================================================================*/ - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -void serdbg_exceptionHandler -( -/*-------------------------------------------------------------------------*\ -| Purpose: | -| hook directly to an exception vector | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ - int vecnum, /* vector index to hook at */ - void *vector /* address of handler function */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| <none> | -\*=========================================================================*/ - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -int serdbg_init -( -/*-------------------------------------------------------------------------*\ -| Purpose: | -| initialize remote gdb session over serial line | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ - void - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| rtems_status_code | -\*=========================================================================*/ - -/* - * stuff from serdbgio.c - */ -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -int serdbg_open - -/*-------------------------------------------------------------------------*\ -| Purpose: | -| try to open given serial debug port | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ -( - const char *dev_name, /* name of device to open */ - uint32_t baudrate /* baud rate to use */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| 0 on success, -1 and errno otherwise | -\*=========================================================================*/ - - -extern int serdbg_init_dbg(void); - -/* - * Assumed to be provided by the BSP - */ -extern void set_debug_traps(void); -extern void breakpoint(void); -#ifdef __cplusplus -} -#endif - -#endif /* _SERDBG_H */ diff --git a/cpukit/include/rtems/serdbgcnf.h b/cpukit/include/rtems/serdbgcnf.h deleted file mode 100644 index 9d4087ae69..0000000000 --- a/cpukit/include/rtems/serdbgcnf.h +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @file - * - * @brief Adds a GDB remote Debug Stub to an RTEMS System - */ - -/*===============================================================*\ -| Project: RTEMS configure remote gdb over serial line | -+-----------------------------------------------------------------+ -| File: serdbgcnf.h | -+-----------------------------------------------------------------+ -| Copyright (c) 2002 IMD | -| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | -| <Thomas.Doerfler@imd-systems.de> | -| all rights reserved | -+-----------------------------------------------------------------+ -| this file declares intialization functions to add | -| a gdb remote debug stub to an RTEMS system | -| | -+-----------------------------------------------------------------+ -| date history ID | -| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | -| 13.05.02 creation doe | -\*===============================================================*/ -#ifndef _SERDBGCNF_H -#define _SERDBGCNF_H - -#include <rtems/serdbg.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef CONFIGURE_INIT - -/* - * fallback for baud rate to use - */ -#ifndef CONFIGURE_SERDBG_BAUDRATE -#define CONFIGURE_SERDBG_BAUDRATE 9600 -#endif - -/* - * fallback for device name to use - */ -#ifndef CONFIGURE_SERDBG_DEVNAME -#define CONFIGURE_SERDBG_DEVNAME "/dev/tty01" -#endif - -/* - * fill in serdbg_conf structure - */ -serdbg_conf_t serdbg_conf = { - CONFIGURE_SERDBG_BAUDRATE, - -#ifdef CONFIGURE_SERDBG_CALLOUT - CONFIGURE_SERDBG_CALLOUT, -#else - NULL, -#endif - -#ifdef CONFIGURE_SERDBG_USE_POLLED_TERMIOS - serdbg_open, -#else - NULL, -#endif - - CONFIGURE_SERDBG_DEVNAME, - -#ifdef CONFIGURE_SERDBG_SKIP_INIT_BKPT - true, -#else - false, -#endif -}; - -int serdbg_init(void) { -#ifdef CONFIGURE_USE_SERDBG - return serdbg_init_dbg(); -#else - return 0; -#endif -} - -#endif /* CONFIGURE_INIT */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SERDBGCNF_H */ diff --git a/cpukit/include/rtems/serial_mouse.h b/cpukit/include/rtems/serial_mouse.h index 174fcfb909..9765b5af3d 100644 --- a/cpukit/include/rtems/serial_mouse.h +++ b/cpukit/include/rtems/serial_mouse.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -16,9 +18,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef __SERIAL_MOUSE_h__ diff --git a/cpukit/include/rtems/seterr.h b/cpukit/include/rtems/seterr.h index adce762dc9..6fec3be369 100644 --- a/cpukit/include/rtems/seterr.h +++ b/cpukit/include/rtems/seterr.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -11,9 +13,26 @@ * COPYRIGHT (c) 1989-2006. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SETERR_H diff --git a/cpukit/include/rtems/shell.h b/cpukit/include/rtems/shell.h index d705dcb0a7..f8b677d5cd 100644 --- a/cpukit/include/rtems/shell.h +++ b/cpukit/include/rtems/shell.h @@ -5,13 +5,12 @@ */ /* - * Author: + * Copyright (c) 2001 Fernando Ruiz Casas <fruizcasas@gmail.com> * - * WORK: fernando.ruiz@ctv.es - * HOME: correo@fernando-ruiz.com - * - * Thanks at: - * Chris Johns + * 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_SHELL_H__ @@ -255,6 +254,31 @@ bool rtems_shell_main_loop( rtems_shell_env_t *rtems_shell_env ); +/** + * @brief Runs the shell main loop. + * + * The caller shall initialize the shell environment. It is recommended that + * the caller duplicates the current shell environment using + * rtems_shell_dup_current_env() and then performs the required customization. + * Shell commands will use the stdin, stdout, and stderr file streams set up by + * the caller. + * + * @param interactive indicates if the shell main loop interfaces with an + * interactive user. For an interactive user, a welcome message using + * "/etc/motd" is presented and command prompt is displayed. + * + * @param[in, out] line_editor_output is the optional line editor output file + * stream. It may be NULL, to disable the line editor output. + * + * @return Returns true, if no error occurred and a shell exit was requested, + * otherwise false. + */ +bool rtems_shell_run_main_loop( + rtems_shell_env_t *shell_env, + bool interactive, + FILE *line_editor_output +); + extern const rtems_shell_env_t rtems_global_shell_env; rtems_shell_env_t *rtems_shell_get_current_env(void); diff --git a/cpukit/include/rtems/shellconfig.h b/cpukit/include/rtems/shellconfig.h index c5fcf4a45e..489f281400 100644 --- a/cpukit/include/rtems/shellconfig.h +++ b/cpukit/include/rtems/shellconfig.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,9 +10,26 @@ * COPYRIGHT (c) 1989-2012. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SHELL_CONFIG_h @@ -79,6 +98,7 @@ extern rtems_shell_cmd_t rtems_shell_MD5_Command; extern rtems_shell_cmd_t rtems_shell_RTC_Command; extern rtems_shell_cmd_t rtems_shell_SPI_Command; +extern rtems_shell_cmd_t rtems_shell_FLASHDEV_Command; extern rtems_shell_cmd_t rtems_shell_I2CDETECT_Command; extern rtems_shell_cmd_t rtems_shell_I2CGET_Command; extern rtems_shell_cmd_t rtems_shell_I2CSET_Command; @@ -91,6 +111,7 @@ extern rtems_shell_cmd_t rtems_shell_STACKUSE_Command; extern rtems_shell_cmd_t rtems_shell_PERIODUSE_Command; extern rtems_shell_cmd_t rtems_shell_PROFREPORT_Command; extern rtems_shell_cmd_t rtems_shell_WKSPACE_INFO_Command; +extern rtems_shell_cmd_t rtems_shell_RTEMS_Command; extern rtems_shell_cmd_t rtems_shell_MALLOC_INFO_Command; extern rtems_shell_cmd_t rtems_shell_RTRACE_Command; #if RTEMS_NETWORKING @@ -470,6 +491,11 @@ extern rtems_shell_alias_t * const rtems_shell_Initial_aliases[]; defined(CONFIGURE_SHELL_COMMAND_WKSPACE_INFO) &rtems_shell_WKSPACE_INFO_Command, #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_RTEMS)) || \ + defined(CONFIGURE_SHELL_COMMAND_RTEMS) + &rtems_shell_RTEMS_Command, + #endif /* * Malloc family commands @@ -532,6 +558,12 @@ extern rtems_shell_alias_t * const rtems_shell_Initial_aliases[]; #endif #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) \ + && !defined(CONFIGURE_SHELL_NO_COMMAND_FLASHDEV)) \ + || defined(CONFIGURE_SHELL_COMMAND_FLASHDEV) + &rtems_shell_FLASHDEV_Command, + #endif + + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) \ && !defined(CONFIGURE_SHELL_NO_COMMAND_I2CDETECT)) \ || defined(CONFIGURE_SHELL_COMMAND_I2CDETECT) &rtems_shell_I2CDETECT_Command, diff --git a/cpukit/include/rtems/sparse-disk.h b/cpukit/include/rtems/sparse-disk.h index 7233c756ba..7bf448afbd 100644 --- a/cpukit/include/rtems/sparse-disk.h +++ b/cpukit/include/rtems/sparse-disk.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * Copyright (c) 2012 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef SPARSE_DISK_H diff --git a/cpukit/include/rtems/spurious.h b/cpukit/include/rtems/spurious.h index 2bddeeb3c8..e866098df2 100644 --- a/cpukit/include/rtems/spurious.h +++ b/cpukit/include/rtems/spurious.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,9 +10,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_SPURIOUS_H diff --git a/cpukit/include/rtems/stackchk.h b/cpukit/include/rtems/stackchk.h index b600bae3a7..c836263925 100644 --- a/cpukit/include/rtems/stackchk.h +++ b/cpukit/include/rtems/stackchk.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -13,17 +15,32 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_STACKCHK_H #define _RTEMS_STACKCHK_H -#include <stdbool.h> /* bool */ - -#include <rtems/score/thread.h> /* Thread_Control */ +#include <rtems.h> #include <rtems/print.h> /** @@ -73,6 +90,81 @@ void rtems_stack_checker_report_usage_with_plugin( const rtems_printer *printer ); +/** + * @brief This structure contains the stack information provided by the stack + * checker for a stack. + */ +typedef struct { + /** + * @brief This member contains the object identifier associated with the + * object using the stack. + * + * For interrupt stacks, the object identifier is the processor index. + */ + rtems_id id; + + /** + * @brief This member provides the object name associated with the + * object using the stack. + * + * For interrupt stacks, the object name is "Interrupt Stack". + */ + const char *name; + + /** + * @brief This member provides the begin address of the stack area. + */ + const void *begin; + + /** + * @brief This member contains the size in byes of the stack area. + */ + uintptr_t size; + + /** + * @brief This member provides the current stack pointer of the stack. + * + * If the current stack pointer is not available, then the value is set to + * NULL. + */ + const void *current; + + /** + * @brief This member contains the size in byes of the used stack area. + * + * If the stack checker is not initialized, then the value is set to + * UINTPTR_MAX. + */ + uintptr_t used; +} rtems_stack_checker_info; + +/** + * @brief Visitor routines invoked by rtems_stack_checker_iterate() shall have + * this type. + * + * @param info is the stack information. + * + * @param arg is the argument passed to rtems_stack_checker_iterate(). + */ +typedef void ( *rtems_stack_checker_visitor )( + const rtems_stack_checker_info *info, + void *arg +); + +/** + * @brief Iterates over all stacks used by the system and invokes the visitor + * routine for each stack. + * + * This method prints a stack usage report for the curently executing + * task. + * + * @param visitor is the visitor routine invoked for each stack. + * + * @param arg is the argument passed to each visitor routine invocation during + * the iteration. + */ +void rtems_stack_checker_iterate( rtems_stack_checker_visitor visit, void *arg ); + /************************************************************* ************************************************************* ** Prototyped only so the user extension can be installed ** @@ -91,11 +183,11 @@ void rtems_stack_checker_report_usage_with_plugin( * will automatically intialize itself. */ bool rtems_stack_checker_create_extension( - Thread_Control *running, - Thread_Control *the_thread + rtems_tcb *running, + rtems_tcb *the_thread ); -void rtems_stack_checker_begin_extension( Thread_Control *executing ); +void rtems_stack_checker_begin_extension( rtems_tcb *executing ); /** * @brief Stack Checker Task Context Switch Extension @@ -109,8 +201,8 @@ void rtems_stack_checker_begin_extension( Thread_Control *executing ); * @note This is called from the internal method _Thread_Dispatch. */ void rtems_stack_checker_switch_extension( - Thread_Control *running, - Thread_Control *heir + rtems_tcb *running, + rtems_tcb *heir ); /** diff --git a/cpukit/include/rtems/status-checks.h b/cpukit/include/rtems/status-checks.h index 51dba23aa6..762899e845 100644 --- a/cpukit/include/rtems/status-checks.h +++ b/cpukit/include/rtems/status-checks.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,16 +10,27 @@ */ /* - * Copyright (c) 2008 - * Embedded Brains GmbH - * Obere Lagerstr. 30 - * D-82178 Puchheim - * Germany - * rtems@embedded-brains.de + * Copyright (c) 2008 embedded brains GmbH & Co. KG + * 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. * - * 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. + * 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. */ #ifndef RTEMS_STATUS_CHECKS_H diff --git a/cpukit/include/rtems/stringto.h b/cpukit/include/rtems/stringto.h index 8389219fe8..0f98710946 100644 --- a/cpukit/include/rtems/stringto.h +++ b/cpukit/include/rtems/stringto.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 2009-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_STRINGTO_H diff --git a/cpukit/include/rtems/sysinit.h b/cpukit/include/rtems/sysinit.h index e3d70230c7..3e6f4d9933 100644 --- a/cpukit/include/rtems/sysinit.h +++ b/cpukit/include/rtems/sysinit.h @@ -1,15 +1,36 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSAPISystemInit + * + * @brief This header file provides the API of the @ref RTEMSAPISystemInit. + */ + /* - * Copyright (c) 2015, 2020 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 2023 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_SYSINIT_H @@ -21,6 +42,54 @@ extern "C" { #endif /* __cplusplus */ +/** + * @ingroup RTEMSImpl + * + * @brief Enables a verbose system initialization. + */ +void _Sysinit_Verbose( void ); + +/** + * @ingroup RTEMSImpl + * + * @brief Creates the system initialization item associated with the handler + * and index. + * + * The enum helps to detect typos in the module and order parameters of + * RTEMS_SYSINIT_ITEM(). + */ +#define _RTEMS_SYSINIT_INDEX_ITEM( handler, index ) \ + enum { _Sysinit_##handler = index }; \ + RTEMS_LINKER_ROSET_ITEM_ORDERED( \ + _Sysinit, \ + rtems_sysinit_item, \ + handler, \ + index \ + ) = { handler } + +/** + * @ingroup RTEMSImpl + * + * @brief Creates the system initialization item associated with the handler, + * module, and order. + * + * This helper macro is used to perform parameter expansion in + * RTEMS_SYSINIT_ITEM(). + */ +#define _RTEMS_SYSINIT_ITEM( handler, module, order ) \ + _RTEMS_SYSINIT_INDEX_ITEM( handler, 0x##module##order ) + +/** + * @defgroup RTEMSAPISystemInit System Initialization Support + * + * @ingroup RTEMSAPI + * + * @brief The system initialization support provides an ordered invocation of + * system initialization handlers registered in a linker set. + * + * @{ + */ + /* * The value of each module define must consist of exactly six hexadecimal * digits without a 0x-prefix. A 0x-prefix is concatenated with the module and @@ -120,29 +189,22 @@ typedef struct { rtems_sysinit_handler handler; } rtems_sysinit_item; -/* The enum helps to detect typos in the module and order parameters */ -#define _RTEMS_SYSINIT_INDEX_ITEM( handler, index ) \ - enum { _Sysinit_##handler = index }; \ - RTEMS_LINKER_ROSET_ITEM_ORDERED( \ - _Sysinit, \ - rtems_sysinit_item, \ - handler, \ - index \ - ) = { handler } - -/* Create index from module and order */ -#define _RTEMS_SYSINIT_ITEM( handler, module, order ) \ - _RTEMS_SYSINIT_INDEX_ITEM( handler, 0x##module##order ) - -/* Perform parameter expansion */ +/** + * @brief Creates the system initialization item associated with the handler, + * module, and order. + * + * @param handler is the system initialization handler. + * + * @param module is the system initialization module. It shall be a 6-digit + * hex number without a 0x-prefix. + * + * @param order is the system initialization order with respect to the module. + * It shall be a 2-digit hex number without a 0x-prefix. + */ #define RTEMS_SYSINIT_ITEM( handler, module, order ) \ _RTEMS_SYSINIT_ITEM( handler, module, order ) -/** - * @brief System initialization handler to enable a verbose system - * initialization. - */ -void _Sysinit_Verbose( void ); +/** @} */ #ifdef __cplusplus } diff --git a/cpukit/include/rtems/telnetd.h b/cpukit/include/rtems/telnetd.h index 1f8e1c55c3..3f20207e0c 100644 --- a/cpukit/include/rtems/telnetd.h +++ b/cpukit/include/rtems/telnetd.h @@ -1,15 +1,13 @@ +/** + * @file + * + * @brief Telnet Daemon Interface + */ + /* - * Original Author: Fernando RUIZ CASAS (fernando.ruiz@ctv.es) - * May 2001 - * Reworked by Till Straumann and .h overhauled by Joel Sherrill. - * - * Copyright (c) 2009 embedded brains GmbH and others. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * D-82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * Copyright (c) 2001 Fernando Ruiz Casas <fruizcasas@gmail.com> + * Reworked by Till Straumann and .h overhauled by Joel Sherrill. + * Copyright (c) 2009 embedded brains GmbH & Co. KG * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at diff --git a/cpukit/include/rtems/termios_printk.h b/cpukit/include/rtems/termios_printk.h deleted file mode 100644 index dcb183533a..0000000000 --- a/cpukit/include/rtems/termios_printk.h +++ /dev/null @@ -1,101 +0,0 @@ -/*===============================================================*\ -| Project: RTEMS remote gdb over serial line | -+-----------------------------------------------------------------+ -| File: termios_printk.h | -+-----------------------------------------------------------------+ -| Copyright (c) 2002 IMD | -| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | -| <Thomas.Doerfler@imd-systems.de> | -| all rights reserved | -+-----------------------------------------------------------------+ -| this file declares intialization functions to add | -| printk polled output via termios polled drivers | -| | -+-----------------------------------------------------------------+ -| date history ID | -| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | -| 13.04.02 creation doe | -\*===============================================================*/ -#ifndef _TERMIOS_PRINTK_H -#define _TERMIOS_PRINTK_H - -#include <rtems.h> -#include <termios.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - uint32_t baudrate; /* debug baud rate, e.g. 57600 */ - void (*callout)(void); /* callout pointer during polling */ - const char *devname; /* debug device, e.g. "/dev/tty01" */ -} termios_printk_conf_t; - -/* - * must be defined in init module... - */ -extern termios_printk_conf_t termios_printk_conf; - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -void termios_printk_outputchar -/*-------------------------------------------------------------------------*\ -| Purpose: | -| send one character to serial port | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ -( - char c /* character to print */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| <none> | -\*=========================================================================*/ - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -int termios_printk_inputchar -/*-------------------------------------------------------------------------*\ -| Purpose: | -| wait for one character from serial port | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ -( - void /* none */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| received character | -\*=========================================================================*/ - - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -int termios_printk_open - -/*-------------------------------------------------------------------------*\ -| Purpose: | -| try to open given serial debug port | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ -( - const char *dev_name, /* name of device to open */ - uint32_t baudrate /* baud rate to use */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| 0 on success, -1 and errno otherwise | -\*=========================================================================*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _TERMIOS_PRINTK_H */ diff --git a/cpukit/include/rtems/termios_printk_cnf.h b/cpukit/include/rtems/termios_printk_cnf.h deleted file mode 100644 index 03c3090c38..0000000000 --- a/cpukit/include/rtems/termios_printk_cnf.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @file - * - * @brief Adds printk Support via Polled termios - */ - -/*===============================================================*\ -| Project: RTEMS configure remote gdb over serial line | -+-----------------------------------------------------------------+ -| File: termios_printk_cnf.h | -+-----------------------------------------------------------------+ -| Copyright (c) 2002 IMD | -| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | -| <Thomas.Doerfler@imd-systems.de> | -| all rights reserved | -+-----------------------------------------------------------------+ -| this file declares intialization functions to add | -| printk support via polled termios | -| | -+-----------------------------------------------------------------+ -| date history ID | -| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | -| 13.05.02 creation doe | -\*===============================================================*/ -#ifndef _TERMIOS_PRINTK_CNF_H -#define _TERMIOS_PRINTK_CNF_H - -#include <rtems/termios_printk.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef CONFIGURE_INIT - -/* - * fallback for baud rate to use - */ -#ifndef CONFIGURE_TERMIOS_PRINTK_BAUDRATE -#define CONFIGURE_TERMIOS_PRINTK_BAUDRATE 9600 -#endif - -/* - * fallback for device name to use - */ -#ifndef CONFIGURE_TERMIOS_PRINTK_DEVNAME -#define CONFIGURE_TERMIOS_PRINTK_DEVNAME "/dev/console" -#endif - -#ifdef CONFIGURE_USE_TERMIOS_PRINTK -/* - * fill in termios_printk_conf structure - */ -termios_printk_conf_t termios_printk_conf = { - CONFIGURE_TERMIOS_PRINTK_BAUDRATE, - -#ifdef CONFIGURE_TERMIOS_PRINTK_CALLOUT - CONFIGURE_TERMIOS_PRINTK_CALLOUT, -#else - NULL, -#endif - CONFIGURE_TERMIOS_PRINTK_DEVNAME, -}; -#endif - -int termios_printk_init(void) { -#ifdef CONFIGURE_USE_TERMIOS_PRINTK - return termios_printk_open(termios_printk_conf.devname, - termios_printk_conf.baudrate); -#else - return 0; -#endif -} - -#endif /* CONFIGURE_INIT */ - -#ifdef __cplusplus -} -#endif - -#endif /* _TERMIOS_PRINTK_CNF_H */ diff --git a/cpukit/include/rtems/termiosdevice.h b/cpukit/include/rtems/termiosdevice.h new file mode 100644 index 0000000000..17d05e61f6 --- /dev/null +++ b/cpukit/include/rtems/termiosdevice.h @@ -0,0 +1,300 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup TermiostypesSupport + * + * @brief This header file provides the interfaces of the + * @ref TermiostypesSupport. + */ + +/* + * Copyright (C) 2014, 2017 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_TERMIOSDEVICE_H +#define _RTEMS_TERMIOSDEVICE_H + +#include <rtems/thread.h> +#include <rtems/rtems/intr.h> + +#include <sys/ioccom.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +struct rtems_libio_open_close_args; +struct rtems_termios_tty; +struct termios; + +/** + * @defgroup TermiostypesSupport RTEMS Termios Device Support + * + * @ingroup libcsupport + * + * @brief This group contains the Termios Device Support provided by RTEMS. + */ + +/** + * @brief Termios device context. + * + * @see RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER(), + * rtems_termios_device_context_initialize() and + * rtems_termios_device_install(). + */ +typedef struct rtems_termios_device_context { + union { + /* Used for TERMIOS_POLLED and TERMIOS_IRQ_DRIVEN */ + rtems_interrupt_lock interrupt; + + /* Used for TERMIOS_IRQ_SERVER_DRIVEN and TERMIOS_TASK_DRIVEN */ + rtems_mutex mutex; + } lock; + + void ( *lock_acquire )( + struct rtems_termios_device_context *, + rtems_interrupt_lock_context * + ); + + void ( *lock_release )( + struct rtems_termios_device_context *, + rtems_interrupt_lock_context * + ); +} rtems_termios_device_context; + +typedef enum { + TERMIOS_POLLED, + TERMIOS_IRQ_DRIVEN, + TERMIOS_TASK_DRIVEN, + TERMIOS_IRQ_SERVER_DRIVEN +} rtems_termios_device_mode; + +/** + * @brief Termios device handler. + * + * @see rtems_termios_device_install(). + */ +typedef struct { + /** + * @brief First open of this device. + * + * @param[in] tty The Termios control. This parameter may be passed to + * interrupt service routines since it must be provided for the + * rtems_termios_enqueue_raw_characters() and + * rtems_termios_dequeue_characters() functions. + * @param[in] context The Termios device context. + * @param[in] term The current Termios attributes. + * @param[in] args The open/close arguments. This is parameter provided to + * support legacy drivers. It must not be used by new drivers. + * + * @retval true Successful operation. + * @retval false Cannot open device. + * + * @see rtems_termios_get_device_context() and rtems_termios_set_best_baud(). + */ + bool (*first_open)( + struct rtems_termios_tty *tty, + rtems_termios_device_context *context, + struct termios *term, + struct rtems_libio_open_close_args *args + ); + + /** + * @brief Last close of this device. + * + * @param[in] tty The Termios control. + * @param[in] context The Termios device context. + * @param[in] args The open/close arguments. This is parameter provided to + * support legacy drivers. It must not be used by new drivers. + */ + void (*last_close)( + struct rtems_termios_tty *tty, + rtems_termios_device_context *context, + struct rtems_libio_open_close_args *args + ); + + /** + * @brief Polled read. + * + * In case mode is TERMIOS_IRQ_DRIVEN, TERMIOS_IRQ_SERVER_DRIVEN or + * TERMIOS_TASK_DRIVEN, then data is received via + * rtems_termios_enqueue_raw_characters(). + * + * @param[in] context The Termios device context. + * + * @retval char The received data encoded as unsigned char. + * @retval -1 No data currently available. + */ + int (*poll_read)(rtems_termios_device_context *context); + + /** + * @brief Polled write in case mode is TERMIOS_POLLED or write support + * otherwise. + * + * @param[in] context The Termios device context. + * @param[in] buf The output buffer. + * @param[in] len The output buffer length in characters. + */ + void (*write)( + rtems_termios_device_context *context, + const char *buf, + size_t len + ); + + /** + * @brief Set attributes after a Termios settings change. + * + * @param[in] context The Termios device context. + * @param[in] term The new Termios attributes. + * + * @retval true Successful operation. + * @retval false Invalid attributes. + */ + bool (*set_attributes)( + rtems_termios_device_context *context, + const struct termios *term + ); + + /** + * @brief IO control handler. + * + * Invoked in case the Termios layer cannot deal with the IO request. + * + * @param[in] context The Termios device context. + * @param[in] request The IO control request. + * @param[in] buffer The IO control buffer. + */ + int (*ioctl)( + rtems_termios_device_context *context, + ioctl_command_t request, + void *buffer + ); + + /** + * @brief Termios device mode. + */ + rtems_termios_device_mode mode; +} rtems_termios_device_handler; + +/** + * @brief Termios device flow control handler. + * + * @see rtems_termios_device_install(). + */ +typedef struct { + /** + * @brief Indicate to stop remote transmitter. + * + * @param[in] context The Termios device context. + */ + void (*stop_remote_tx)(rtems_termios_device_context *context); + + /** + * @brief Indicate to start remote transmitter. + * + * @param[in] context The Termios device context. + */ + void (*start_remote_tx)(rtems_termios_device_context *context); +} rtems_termios_device_flow; + +void rtems_termios_device_lock_acquire_default( + rtems_termios_device_context *ctx, + rtems_interrupt_lock_context *lock_context +); + +void rtems_termios_device_lock_release_default( + rtems_termios_device_context *ctx, + rtems_interrupt_lock_context *lock_context +); + +/** + * @brief Initializes a device context. + * + * @param[in] context The Termios device context. + * @param[in] name The name for the interrupt lock. This name must be a + * string persistent throughout the life time of this lock. The name is only + * used if profiling is enabled. + */ +static inline void rtems_termios_device_context_initialize( + rtems_termios_device_context *context, + const char *name +) +{ + rtems_interrupt_lock_initialize( &context->lock.interrupt, name ); + context->lock_acquire = rtems_termios_device_lock_acquire_default; + context->lock_release = rtems_termios_device_lock_release_default; +} + +/** + * @brief Initializer for static initialization of Termios device contexts. + * + * @param name The name for the interrupt lock. It must be a string. The name + * is only used if profiling is enabled. + */ +#define RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( name ) \ + { \ + { RTEMS_INTERRUPT_LOCK_INITIALIZER( name ) }, \ + rtems_termios_device_lock_acquire_default, \ + rtems_termios_device_lock_release_default \ + } + +/** + * @brief Acquires the device lock. + * + * @param[in] context The device context. + * @param[in] lock_context The local interrupt lock context for an acquire and + * release pair. + */ +static inline void rtems_termios_device_lock_acquire( + rtems_termios_device_context *context, + rtems_interrupt_lock_context *lock_context +) +{ + ( *context->lock_acquire )( context, lock_context ); +} + +/** + * @brief Releases the device lock. + * + * @param[in] context The device context. + * @param[in] lock_context The local interrupt lock context for an acquire and + * release pair. + */ +static inline void rtems_termios_device_lock_release( + rtems_termios_device_context *context, + rtems_interrupt_lock_context *lock_context +) +{ + ( *context->lock_release )( context, lock_context ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_TERMIOSDEVICE_H */ diff --git a/cpukit/include/rtems/termiostypes.h b/cpukit/include/rtems/termiostypes.h index ef2c958271..5cf418a5eb 100644 --- a/cpukit/include/rtems/termiostypes.h +++ b/cpukit/include/rtems/termiostypes.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,9 +10,26 @@ * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef __TERMIOSTYPES_H @@ -20,8 +39,7 @@ #include <rtems/libio.h> #include <rtems/assoc.h> #include <rtems/chain.h> -#include <rtems/thread.h> -#include <sys/ioccom.h> +#include <rtems/termiosdevice.h> #include <stdint.h> #include <termios.h> @@ -30,11 +48,9 @@ extern "C" { #endif /** - * @defgroup TermiostypesSupport RTEMS Termios Device Support - * - * @ingroup libcsupport + * @addtogroup TermiostypesSupport * - * @brief RTEMS Termios Device Support Internal Data Structures + * @{ */ /* @@ -56,211 +72,6 @@ struct rtems_termios_rawbuf { rtems_binary_semaphore Semaphore; }; -typedef enum { - TERMIOS_POLLED, - TERMIOS_IRQ_DRIVEN, - TERMIOS_TASK_DRIVEN, - TERMIOS_IRQ_SERVER_DRIVEN -} rtems_termios_device_mode; - -struct rtems_termios_tty; - -/** - * @brief Termios device context. - * - * @see RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER(), - * rtems_termios_device_context_initialize() and - * rtems_termios_device_install(). - */ -typedef struct rtems_termios_device_context { - union { - /* Used for TERMIOS_POLLED and TERMIOS_IRQ_DRIVEN */ - rtems_interrupt_lock interrupt; - - /* Used for TERMIOS_IRQ_SERVER_DRIVEN or TERMIOS_TASK_DRIVEN */ - rtems_mutex mutex; - } lock; - - void ( *lock_acquire )( - struct rtems_termios_device_context *, - rtems_interrupt_lock_context * - ); - - void ( *lock_release )( - struct rtems_termios_device_context *, - rtems_interrupt_lock_context * - ); -} rtems_termios_device_context; - -void rtems_termios_device_lock_acquire_default( - rtems_termios_device_context *ctx, - rtems_interrupt_lock_context *lock_context -); - -void rtems_termios_device_lock_release_default( - rtems_termios_device_context *ctx, - rtems_interrupt_lock_context *lock_context -); - -/** - * @brief Initializes a device context. - * - * @param[in] context The Termios device context. - * @param[in] name The name for the interrupt lock. This name must be a - * string persistent throughout the life time of this lock. The name is only - * used if profiling is enabled. - */ -RTEMS_INLINE_ROUTINE void rtems_termios_device_context_initialize( - rtems_termios_device_context *context, - const char *name -) -{ - rtems_interrupt_lock_initialize( &context->lock.interrupt, name ); - context->lock_acquire = rtems_termios_device_lock_acquire_default; - context->lock_release = rtems_termios_device_lock_release_default; -} - -/** - * @brief Initializer for static initialization of Termios device contexts. - * - * @param name The name for the interrupt lock. It must be a string. The name - * is only used if profiling is enabled. - */ -#define RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( name ) \ - { \ - { RTEMS_INTERRUPT_LOCK_INITIALIZER( name ) }, \ - rtems_termios_device_lock_acquire_default, \ - rtems_termios_device_lock_release_default \ - } - -/** - * @brief Termios device handler. - * - * @see rtems_termios_device_install(). - */ -typedef struct { - /** - * @brief First open of this device. - * - * @param[in] tty The Termios control. This parameter may be passed to - * interrupt service routines since it must be provided for the - * rtems_termios_enqueue_raw_characters() and - * rtems_termios_dequeue_characters() functions. - * @param[in] context The Termios device context. - * @param[in] term The current Termios attributes. - * @param[in] args The open/close arguments. This is parameter provided to - * support legacy drivers. It must not be used by new drivers. - * - * @retval true Successful operation. - * @retval false Cannot open device. - * - * @see rtems_termios_get_device_context() and rtems_termios_set_best_baud(). - */ - bool (*first_open)( - struct rtems_termios_tty *tty, - rtems_termios_device_context *context, - struct termios *term, - rtems_libio_open_close_args_t *args - ); - - /** - * @brief Last close of this device. - * - * @param[in] tty The Termios control. - * @param[in] context The Termios device context. - * @param[in] args The open/close arguments. This is parameter provided to - * support legacy drivers. It must not be used by new drivers. - */ - void (*last_close)( - struct rtems_termios_tty *tty, - rtems_termios_device_context *context, - rtems_libio_open_close_args_t *args - ); - - /** - * @brief Polled read. - * - * In case mode is TERMIOS_IRQ_DRIVEN, TERMIOS_IRQ_SERVER_DRIVEN or - * TERMIOS_TASK_DRIVEN, then data is received via - * rtems_termios_enqueue_raw_characters(). - * - * @param[in] context The Termios device context. - * - * @retval char The received data encoded as unsigned char. - * @retval -1 No data currently available. - */ - int (*poll_read)(rtems_termios_device_context *context); - - /** - * @brief Polled write in case mode is TERMIOS_POLLED or write support - * otherwise. - * - * @param[in] context The Termios device context. - * @param[in] buf The output buffer. - * @param[in] len The output buffer length in characters. - */ - void (*write)( - rtems_termios_device_context *context, - const char *buf, - size_t len - ); - - /** - * @brief Set attributes after a Termios settings change. - * - * @param[in] context The Termios device context. - * @param[in] term The new Termios attributes. - * - * @retval true Successful operation. - * @retval false Invalid attributes. - */ - bool (*set_attributes)( - rtems_termios_device_context *context, - const struct termios *term - ); - - /** - * @brief IO control handler. - * - * Invoked in case the Termios layer cannot deal with the IO request. - * - * @param[in] context The Termios device context. - * @param[in] request The IO control request. - * @param[in] buffer The IO control buffer. - */ - int (*ioctl)( - rtems_termios_device_context *context, - ioctl_command_t request, - void *buffer - ); - - /** - * @brief Termios device mode. - */ - rtems_termios_device_mode mode; -} rtems_termios_device_handler; - -/** - * @brief Termios device flow control handler. - * - * @see rtems_termios_device_install(). - */ -typedef struct { - /** - * @brief Indicate to stop remote transmitter. - * - * @param[in] context The Termios device context. - */ - void (*stop_remote_tx)(rtems_termios_device_context *context); - - /** - * @brief Indicate to start remote transmitter. - * - * @param[in] context The Termios device context. - */ - void (*start_remote_tx)(rtems_termios_device_context *context); -} rtems_termios_device_flow; - /** * @brief Termios device node for installed devices. * @@ -367,6 +178,10 @@ typedef struct rtems_termios_tty { */ rtems_id rxTaskId; rtems_id txTaskId; + /* + * Information for the tx task how many characters have been dequeued. + */ + int txTaskCharsDequeued; /* * line discipline related stuff @@ -425,7 +240,7 @@ rtems_status_code rtems_termios_device_install( * * @param[in] tty The Termios control. */ -RTEMS_INLINE_ROUTINE void *rtems_termios_get_device_context( +static inline void *rtems_termios_get_device_context( const rtems_termios_tty *tty ) { @@ -433,36 +248,6 @@ RTEMS_INLINE_ROUTINE void *rtems_termios_get_device_context( } /** - * @brief Acquires the device lock. - * - * @param[in] context The device context. - * @param[in] lock_context The local interrupt lock context for an acquire and - * release pair. - */ -RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_acquire( - rtems_termios_device_context *context, - rtems_interrupt_lock_context *lock_context -) -{ - ( *context->lock_acquire )( context, lock_context ); -} - -/** - * @brief Releases the device lock. - * - * @param[in] context The device context. - * @param[in] lock_context The local interrupt lock context for an acquire and - * release pair. - */ -RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_release( - rtems_termios_device_context *context, - rtems_interrupt_lock_context *lock_context -) -{ - ( *context->lock_release )( context, lock_context ); -} - -/** * @brief Sets the best baud value in the Termios control. * * The valid Termios baud values are between 0 and 460800. The Termios baud @@ -482,7 +267,7 @@ struct rtems_termios_linesw { int (*l_read )(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args); int (*l_write)(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args); int (*l_rint )(int c,struct rtems_termios_tty *tp); - int (*l_start)(struct rtems_termios_tty *tp); + int (*l_start)(struct rtems_termios_tty *tp,int len); int (*l_ioctl)(struct rtems_termios_tty *tp,rtems_libio_ioctl_args_t *args); int (*l_modem)(struct rtems_termios_tty *tp,int flags); }; diff --git a/cpukit/include/rtems/test-gcov.h b/cpukit/include/rtems/test-gcov.h new file mode 100644 index 0000000000..3664e91c64 --- /dev/null +++ b/cpukit/include/rtems/test-gcov.h @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSImplGcov + * + * @brief This header file provides the interfaces of the @ref RTEMSImplGcov. + */ + +/* + * Copyright (C) 2013, 2014 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_TEST_GCOV_H +#define _RTEMS_TEST_GCOV_H + +#include <gcov.h> + +#include <rtems/linkersets.h> +#include <rtems/dev/io.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup RTEMSImplGcov Gcov Support + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This group contains the gocv support. + * + * @{ + */ + +RTEMS_LINKER_ROSET_DECLARE( gcov_info, const struct gcov_info * ); + +/** + * @brief Dumps the gcov information as a binary gcfn and gcda data + * stream using the put character handler. + * + * @param put_char is the put character handler used to output the data stream. + * + * @param arg is the argument passed to the put character handler. + */ +void _Gcov_Dump_info( IO_Put_char put_char, void *arg ); + +/** + * @brief Dumps the gcov information as a base64 encoded gcfn and gcda data + * stream using the put character handler. + * + * @param put_char is the put character handler used to output the data stream. + * + * @param arg is the argument passed to the put character handler. + */ +void _Gcov_Dump_info_base64( IO_Put_char put_char, void *arg ); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_TEST_GCOV_H */ diff --git a/cpukit/include/rtems/test-info.h b/cpukit/include/rtems/test-info.h index c4b6041403..a5c00c423a 100644 --- a/cpukit/include/rtems/test-info.h +++ b/cpukit/include/rtems/test-info.h @@ -1,22 +1,42 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTest + * + * @brief This header file provides interfaces of the RTEMS Test Support. + */ + /* - * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved. + * Copyright (C) 2014, 2018 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_TEST_H #define _RTEMS_TEST_H #include <rtems.h> -#include <rtems/printer.h> #include <rtems/score/atomic.h> #include <rtems/score/smpbarrier.h> @@ -40,11 +60,6 @@ extern "C" { extern const char rtems_test_name[]; /** - * @brief Each test must define a printer. - */ -extern rtems_printer rtems_test_printer; - -/** * @brief Fatal extension for tests. */ void rtems_test_fatal_extension( @@ -57,7 +72,7 @@ void rtems_test_fatal_extension( * @brief Initial extension for tests. */ #define RTEMS_TEST_INITIAL_EXTENSION \ - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, rtems_test_fatal_extension } + { NULL, NULL, NULL, NULL, NULL, NULL, NULL, rtems_test_fatal_extension, NULL } /** * @brief Test states. @@ -95,14 +110,14 @@ typedef enum /** * @brief Prints a begin of test message using printf(). * - * @returns As specified by printf(). + * @return As specified by printf(). */ int rtems_test_begin(const char* name, const RTEMS_TEST_STATE state); /** * @brief Prints an end of test message using printf(). * - * @returns As specified by printf(). + * @return As specified by printf(). */ int rtems_test_end(const char* name); @@ -112,13 +127,6 @@ int rtems_test_end(const char* name); */ RTEMS_NO_RETURN void rtems_test_exit(int status); -/** - * @brief Prints via the RTEMS printer. - * - * @returns As specified by printf(). - */ -int rtems_test_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2); - #define RTEMS_TEST_PARALLEL_PROCESSOR_MAX 32 typedef struct rtems_test_parallel_job rtems_test_parallel_job; @@ -318,6 +326,12 @@ RTEMS_NO_RETURN void rtems_test_run( const RTEMS_TEST_STATE state ); +/** + * @brief Dumps the gcov information as a base64 encoded gcfn and gcda data + * stream using rtems_put_char(). + */ +void rtems_test_gcov_dump_info( void ); + /** @} */ #ifdef __cplusplus diff --git a/cpukit/include/rtems/test-printer.h b/cpukit/include/rtems/test-printer.h new file mode 100644 index 0000000000..6625aa5a29 --- /dev/null +++ b/cpukit/include/rtems/test-printer.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTest + * + * @brief This header file provides interfaces of the RTEMS Test Support. + */ + +/* + * Copyright (C) 2014, 2023 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_TEST_PRINTER_H +#define _RTEMS_TEST_PRINTER_H + +#include <rtems/printer.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup RTEMSTest + * + * @{ + */ + +/** + * @brief Provides an RTEMS printer for tests. + */ +extern rtems_printer rtems_test_printer; + +/** + * @brief Prints via the RTEMS test printer. + * + * @return Returns the count of output characters as specified by printf(). + */ +int rtems_test_printf( const char *format, ... ) RTEMS_PRINTFLIKE( 1, 2 ); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_TEST_PRINTER_H */ diff --git a/cpukit/include/rtems/test-scheduler.h b/cpukit/include/rtems/test-scheduler.h new file mode 100644 index 0000000000..39474cf250 --- /dev/null +++ b/cpukit/include/rtems/test-scheduler.h @@ -0,0 +1,290 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFramework + * + * @brief This header file defines the scheduler test support API. + */ + +/* + * Copyright (C) 2021 embedded brains GmbH & Co. KG + * + * 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. + */ + +#ifndef _RTEMS_TEST_SCHEDULER_H +#define _RTEMS_TEST_SCHEDULER_H + +#include <rtems/test.h> +#include <rtems/score/processormask.h> +#include <rtems/score/scheduler.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup RTEMSTestFramework + * + * @{ + */ + +typedef enum { + T_SCHEDULER_NOP, + T_SCHEDULER_ADD_PROCESSOR, + T_SCHEDULER_ANY, + T_SCHEDULER_ASK_FOR_HELP, + T_SCHEDULER_BLOCK, + T_SCHEDULER_CANCEL_JOB, + T_SCHEDULER_CLEAN_STICKY, + T_SCHEDULER_INITIALIZE, + T_SCHEDULER_MAKE_STICKY, + T_SCHEDULER_MAP_PRIORITY, + T_SCHEDULER_NODE_DESTROY, + T_SCHEDULER_NODE_INITIALIZE, + T_SCHEDULER_PIN, + T_SCHEDULER_RECONSIDER_HELP_REQUEST, + T_SCHEDULER_RELEASE_JOB, + T_SCHEDULER_REMOVE_PROCESSOR, + T_SCHEDULER_SCHEDULE, + T_SCHEDULER_SET_AFFINITY, + T_SCHEDULER_START_IDLE, + T_SCHEDULER_UNBLOCK, + T_SCHEDULER_UNMAP_PRIORITY, + T_SCHEDULER_UNPIN, + T_SCHEDULER_UPDATE_PRIORITY, + T_SCHEDULER_WITHDRAW_NODE, + T_SCHEDULER_YIELD +} T_scheduler_operation; + +typedef struct { + Thread_Control *executing; + uint32_t cpu; + T_time instant; + T_scheduler_operation operation; + Thread_Control *thread; + Scheduler_Node *node; + union { + struct { + Priority_Control in; + Priority_Control out; + } map_unmap_priority; + struct { + bool success; + } ask_for_help; + struct { +#ifdef RTEMS_SMP + Thread_Scheduler_state next_state; +#else + int next_state; +#endif + } withdraw_node; + struct { + struct Per_CPU_Control *cpu; + } pin_unpin; + struct { + Thread_Control *idle; + } add_processor; + struct { + struct Per_CPU_Control *cpu; + Thread_Control *idle; + } remove_processor; + struct { + Priority_Node *priority; + uint64_t deadline; + } release_job; + struct { + Priority_Node *priority; + } cancel_job; + struct { + Processor_mask affinity; + Status_Control status; + } set_affinity; + }; +} T_scheduler_event; + +typedef struct { + size_t recorded; + size_t capacity; + uint64_t operations; +} T_scheduler_header; + +typedef struct { + T_scheduler_header header; + T_scheduler_event events[T_ZERO_LENGTH_ARRAY]; +} T_scheduler_log; + +typedef struct { + T_scheduler_header header; + T_scheduler_event events[2]; +} T_scheduler_log_2; + +typedef struct { + T_scheduler_header header; + T_scheduler_event events[4]; +} T_scheduler_log_4; + +typedef struct { + T_scheduler_header header; + T_scheduler_event events[10]; +} T_scheduler_log_10; + +typedef struct { + T_scheduler_header header; + T_scheduler_event events[20]; +} T_scheduler_log_20; + +typedef struct { + T_scheduler_header header; + T_scheduler_event events[40]; +} T_scheduler_log_40; + +T_scheduler_log *T_scheduler_record(T_scheduler_log *); + +T_scheduler_log *T_scheduler_record_2(T_scheduler_log_2 *); + +T_scheduler_log *T_scheduler_record_4(T_scheduler_log_4 *); + +T_scheduler_log *T_scheduler_record_10(T_scheduler_log_10 *); + +T_scheduler_log *T_scheduler_record_20(T_scheduler_log_20 *); + +T_scheduler_log *T_scheduler_record_40(T_scheduler_log_40 *); + +typedef enum { + T_SCHEDULER_BEFORE, + T_SCHEDULER_AFTER +} T_scheduler_when; + +typedef void (*T_scheduler_event_handler)(void *, const T_scheduler_event *, + T_scheduler_when); + +void T_scheduler_set_event_handler(T_scheduler_event_handler, void *); + +extern const T_scheduler_event T_scheduler_event_null; + +const T_scheduler_event *T_scheduler_next(T_scheduler_header *, + T_scheduler_operation, size_t *); + +const T_scheduler_event *T_scheduler_next_any(T_scheduler_header *, + size_t *); + +void T_scheduler_initialize(const Scheduler_Control *); + +void T_scheduler_schedule(const Scheduler_Control *, Thread_Control *); + +void T_scheduler_yield(const Scheduler_Control *, Thread_Control *, + Scheduler_Node *); + +void T_scheduler_block(const Scheduler_Control *, Thread_Control *, + Scheduler_Node *); + +void T_scheduler_unblock(const Scheduler_Control *, Thread_Control *, + Scheduler_Node *); + +void T_scheduler_update_priority(const Scheduler_Control *, Thread_Control *, + Scheduler_Node *); + +Priority_Control T_scheduler_map_priority(const Scheduler_Control *, + Priority_Control); + +Priority_Control T_scheduler_unmap_priority(const Scheduler_Control *, + Priority_Control); + +void T_scheduler_node_initialize(const Scheduler_Control *, Scheduler_Node *, + Thread_Control *, Priority_Control); + +void T_scheduler_node_destroy(const Scheduler_Control *, Scheduler_Node *); + +void T_scheduler_release_job(const Scheduler_Control *, Thread_Control *, + Priority_Node *, uint64_t, Thread_queue_Context *); + +void T_scheduler_cancel_job(const Scheduler_Control *, Thread_Control *, + Priority_Node *, Thread_queue_Context *); + +void T_scheduler_start_idle(const Scheduler_Control *, Thread_Control *, + struct Per_CPU_Control *); + +#ifdef RTEMS_SMP +bool T_scheduler_ask_for_help(const Scheduler_Control *, Thread_Control *, + Scheduler_Node *); + +void T_scheduler_reconsider_help_request(const Scheduler_Control *, + Thread_Control *, Scheduler_Node *); + +void T_scheduler_withdraw_node(const Scheduler_Control *, Thread_Control *, + Scheduler_Node *, Thread_Scheduler_state); + +void T_scheduler_make_sticky(const Scheduler_Control *, Thread_Control *, + Scheduler_Node *); + +void T_scheduler_clean_sticky(const Scheduler_Control *, Thread_Control *, + Scheduler_Node *); + +void T_scheduler_pin(const Scheduler_Control *, Thread_Control *, + Scheduler_Node *, struct Per_CPU_Control *); + +void T_scheduler_unpin(const Scheduler_Control *, Thread_Control *, + Scheduler_Node *, struct Per_CPU_Control *); + +void T_scheduler_add_processor(const Scheduler_Control *, Thread_Control *); + +Thread_Control *T_scheduler_remove_processor(const Scheduler_Control *, + struct Per_CPU_Control *); + +Status_Control T_scheduler_set_affinity(const Scheduler_Control *, + Thread_Control *, Scheduler_Node *, const Processor_mask *); +#endif + +#ifdef RTEMS_SMP +#define T_SCHEDULER_ENTRY_POINTS { T_scheduler_initialize, \ + T_scheduler_schedule, T_scheduler_yield, T_scheduler_block, \ + T_scheduler_unblock, T_scheduler_update_priority, \ + T_scheduler_map_priority, T_scheduler_unmap_priority, \ + T_scheduler_ask_for_help, T_scheduler_reconsider_help_request, \ + T_scheduler_withdraw_node, T_scheduler_make_sticky, \ + T_scheduler_clean_sticky, T_scheduler_pin, T_scheduler_unpin, \ + T_scheduler_add_processor, T_scheduler_remove_processor, \ + T_scheduler_node_initialize, T_scheduler_node_destroy, \ + T_scheduler_release_job, T_scheduler_cancel_job, \ + T_scheduler_start_idle, T_scheduler_set_affinity } +#else +#define T_SCHEDULER_ENTRY_POINTS { T_scheduler_initialize, \ + T_scheduler_schedule, T_scheduler_yield, T_scheduler_block, \ + T_scheduler_unblock, T_scheduler_update_priority, \ + T_scheduler_map_priority, T_scheduler_unmap_priority, \ + T_scheduler_node_initialize, T_scheduler_node_destroy, \ + T_scheduler_release_job, T_scheduler_cancel_job, \ + T_scheduler_start_idle } +#endif + +extern const Scheduler_Operations T_scheduler_operations[]; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_TEST_SCHEDULER_H */ diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index 305fe3f5f3..b8e7934883 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * Copyright (C) 2017, 2021 embedded brains GmbH + * @ingroup RTEMSTestFramework + * + * @brief This header file provides interfaces of the + * RTEMS Test Framework. + */ + +/* + * Copyright (C) 2017, 2021 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -77,6 +86,11 @@ typedef struct T_fixture_node { unsigned int failures; } T_fixture_node; +typedef struct T_remark { + struct T_remark *next; + const char *remark; +} T_remark; + #define T_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) /* @@ -98,7 +112,7 @@ typedef struct T_fixture_node { /** * @defgroup RTEMSTestFrameworkImpl RTEMS Test Framework Implementation * - * @ingroup RTEMSTestFramework + * @ingroup RTEMSImpl * * @brief Implementation details. * @@ -187,42 +201,42 @@ extern const T_check_context T_special; T_flags_true(flags, \ (a) != (T_VA_ARGS_FIRST(__VA_ARGS__)) T_VA_ARGS_MORE(__VA_ARGS__)) -void T_check_eq_ptr(const T_check_context_msg *, const void *, const void *); +void T_check_eq_ptr(const T_check_context_msg *, uintptr_t, uintptr_t); #define T_flags_eq_ptr(a, e, flags, sa, se) \ { \ static const T_check_context_msg T_check_instance = { \ { T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, \ sa " == " se }; \ - T_check_eq_ptr(&T_check_instance, a, e); \ + T_check_eq_ptr(&T_check_instance, (uintptr_t)a, (uintptr_t)e); \ } -void T_check_ne_ptr(const T_check_context_msg *, const void *, const void *); +void T_check_ne_ptr(const T_check_context_msg *, uintptr_t, uintptr_t); #define T_flags_ne_ptr(a, e, flags, sa, se) \ { \ static const T_check_context_msg T_check_instance = { \ { T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, \ sa " != " se }; \ - T_check_ne_ptr(&T_check_instance, a, e); \ + T_check_ne_ptr(&T_check_instance, (uintptr_t)a, (uintptr_t)e); \ } -void T_check_null(const T_check_context_msg *, const void *); +void T_check_null(const T_check_context_msg *, uintptr_t); #define T_flags_null(a, flags, sa) \ { \ static const T_check_context_msg T_check_instance = { \ { T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, sa }; \ - T_check_null(&T_check_instance, a); \ + T_check_null(&T_check_instance, (uintptr_t)a); \ } -void T_check_not_null(const T_check_context_msg *, const void *); +void T_check_not_null(const T_check_context_msg *, uintptr_t); #define T_flags_not_null(a, flags, sa) \ { \ static const T_check_context_msg T_check_instance = { \ { T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, sa }; \ - T_check_not_null(&T_check_instance, a); \ + T_check_not_null(&T_check_instance, (uintptr_t)a); \ } void T_check_eq_mem(const T_check_context_msg *, const void *, const void *, @@ -1322,7 +1336,7 @@ T_verbosity T_set_verbosity(T_verbosity); /** @} */ /** - * @defgroup RTEMSTestFrameworkChecksLong Signed Long Long Integer Checks + * @defgroup RTEMSTestFrameworkChecksLongLong Signed Long Long Integer Checks * * @ingroup RTEMSTestFramework * @@ -2318,6 +2332,8 @@ void *T_fixture_context(void); void T_set_fixture_context(void *); +void T_add_remark(T_remark *); + void *T_push_fixture(T_fixture_node *, const T_fixture *); void T_pop_fixture(void); @@ -2365,8 +2381,8 @@ T_case_context T_case_instance_##name = { \ NULL \ }; \ static T_case_context * const T_case_item_##name \ -__attribute((__section__(".rtemsroset._T.content.0." #name))) \ -__attribute((__used__)) = &T_case_instance_##name; \ +__attribute__((__section__(".rtemsroset._T.content.0." #name))) \ +__attribute__((__used__)) = &T_case_instance_##name; \ void T_case_body_##name(void) #else /* __rtems__ */ #define T_TEST_CASE_FIXTURE(name, fixture) \ @@ -2377,7 +2393,7 @@ T_case_context T_case_instance_##name = { \ fixture, \ NULL \ }; \ -__attribute((__constructor__)) static void \ +__attribute__((__constructor__)) static void \ T_case_register_##name(void) \ { \ T_case_register(&T_case_instance_##name); \ @@ -2464,6 +2480,8 @@ T_thread_switch_log *T_thread_switch_record_10(T_thread_switch_log_10 *); void T_report_hash_sha256(T_event, const char *); +void T_report_hash_sha256_update(char c); + void T_check_heap(T_event, const char *); #ifdef __rtems__ diff --git a/cpukit/include/rtems/tftp.h b/cpukit/include/rtems/tftp.h index ed3ebd7865..6df3866711 100644 --- a/cpukit/include/rtems/tftp.h +++ b/cpukit/include/rtems/tftp.h @@ -1,23 +1,41 @@ -/* - * Trivial File Transfer Protocol (TFTP) +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSImplTFTPFS * - * Transfer file to/from remote host + * @brief This header file provides interfaces and functions used to + * implement the TFTP file system. * - * W. Eric Norum - * Saskatchewan Accelerator Laboratory - * University of Saskatchewan - * Saskatoon, Saskatchewan, CANADA - * eric@skatter.usask.ca + * This file declares the public functions of the Trivial File + * Transfer Protocol (TFTP) file system. */ /* - * Usage: + * Copyright (C) 1998 W. Eric Norum <eric@norum.ca> + * Copyright (C) 2022 embedded brains GmbH & Co. KG * - * To open `/bootfiles/image' on `hostname' for reading: - * fd = open ("/TFTP/hostname/bootfiles/image", O_RDONLY); + * 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. * - * The 'TFTP' is the mount path and the `hostname' must be four dot-separated - * decimal values. + * 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. */ #ifndef _RTEMS_TFTP_H @@ -27,9 +45,14 @@ extern "C" { #endif +#include <stdint.h> #include <rtems/fs.h> -/* +/** + * @brief Do not call directly, use mount(). + * + * @ingroup RTEMSImplTFTPFS + * * Filesystem Mount table entry. */ int rtems_tftpfs_initialize( @@ -37,6 +60,383 @@ int rtems_tftpfs_initialize( const void *data ); +/** + * @defgroup RTEMSAPITFTPFS Trivial File Transfer Protocol (TFTP) API + * + * @ingroup RTEMSAPIIO + * + * @brief The TFTP client library provides an API to read files from and + * to write files to remote servers using the Trivial File Transfer + * Protocol (TFTP). + * + * See the _RTEMS Filesystem Design Guide_ Chapter _Trivial FTP Client + * Filesystem_. + * + * Usage as TFTP File System + * ========================= + * + * To open `/bootfiles/image` on `hostname` for reading: + * + * fd = open ("/TFTP/hostname:bootfiles/image", O_RDONLY); + * + * The `TFTP` is the mount path and the `hostname` must be + * + * + an IPv4 address (like `127.0.0.1`) or + * + the (full-qualified) name of an IPv4 host (acceptable to + * `gethostbyname()`) + * + * IPv6 is currently not supported. `bootfiles/image` is a path on the + * TFTP server `hostname` where the file (here `image`) can be found. + * + * Usage of TFTP Client + * ==================== + * + * The pseudo-code below shows the principal usage for reading a file. + * + * @code + * int res; + * ssize_t bytes; + * void *tftp_handle; + * tftp_net_config config; + * const size_t buffer_size = 4000; + * char data_buffer[buffer_size]; + * + * tftp_initialize_net_config( &config ); + * config.options.window_size = 1; // Set desired config values + * + * res = tftp_open( + * "127.0.0.1", + * "filename.txt", + * true, // is_for_reading + * &config, + * &tftp_handle + * ); + * + * if ( res != 0 || tftp_handle == NULL ) { + * // Error + * } + * + * // Use tftp_read() (probably in a loop) ... + * bytes = tftp_read( + * tftp_handle, + * data_buffer, + * buffer_size + * ); + * // ... or use tftp_write() instead when the file is open for writing. + * + * res = tftp_close( tftp_handle ); + * + * if ( res != 0 ) { + * // Error ... check! Especially when writing! + * } + * @endcode + * + * @{ + */ + +/* + * The functions below use of the TFTP client library standalone + * - i.e. without going through the file system. + */ + +/** + * @brief This block size meets RFC 1350 and avoids the sending of + * the `blksize` option to the TFTP server. + */ +#define TFTP_RFC1350_BLOCK_SIZE 512 + +/** + * @brief This window size avoids the sending of the `windowsize` + * option to the TFTP server. + * + * This effectively mimics the operation defined in RFC 1350 which + * does not know any window size. + */ +#define TFTP_RFC1350_WINDOW_SIZE 1 + +/** + * @brief This block size is suggested in RFC 2348 and is used as + * default if no different block size is provided. + */ +#define TFTP_DEFAULT_BLOCK_SIZE 1456 + +/** + * @brief This window size is suggested in RFC 2348 and is used as + * default if no different window size is provided. + */ +#define TFTP_DEFAULT_WINDOW_SIZE 8 + +/** + * @brief This structure represents TFTP options negotiated between + * client and server. + * + * RFC 2347 is the basis for the TFTP option. + */ +typedef struct tftp_options { + /** + * @brief This member represents the desired size of a data block. + * + * The TFTP blocksize option is introduced in RFC 2348. It defines the + * number of octets in the data packets transferred. Valid values + * range between 8 and 65464 octets, inclusive. Values larger + * than 1468 may cause packet fragmentation over standard Ethernet. + * A value of 512 will prevent this option from being sent to + * the server. + * + * The default value is 1456. + */ + uint16_t block_size; + + /** + * @brief This member represents the desired size of a window. + * + * The TFTP windowsize option is introduced in RFC 7440. It defines the + * number of data packets send before the receiver must send an + * acknowledgment packet. Valid values range between 1 and 65535 + * packets, inclusive. Simple TFTP servers usually do not support this + * option. This option may negatively contribute to network + * congestion. This can be avoided by using a window size of 1. + * A value of 1 will prevent this option from being sent to + * the server. + * + * The default value is 8. + */ + uint16_t window_size; +} tftp_options; + +/** + * @brief This structure represents configuration value used by the TFTP + * client. + * + * As defaults the values suggested in RFC 7440 are used. + */ +typedef struct tftp_net_config { + /** + * @brief This member defines how many attempts are made to send a + * network packet to the server. + * + * Repetitions occur when the server does not response to a packet + * send by the client within a timeout period. When the here defined + * number of repetitions is reached and the server does still not + * respond, the connection is considered broken and the file transfer + * is ended with an error. + * + * The default value is 6. + */ + uint16_t retransmissions; + + /** + * @brief This member defines the port on which the server is listening + * for incoming connections. + * + * The default port number is 69. + */ + uint16_t server_port; + + /** + * @brief This member defines the maximum time in milliseconds the + * client waits for an answer packet from the server. + * + * If the time out is exceeded, the client will re-transmit the last + * packet it send to the server. In case @c window_size is larger one, + * several packets may subject to re-transmission. + * + * Note that this timeout applies only after the first re-transmission + * of a packet. The timeout till the first re-transmission is + * @c first_timeout. + * + * The default value is 1000ms. + */ + uint32_t timeout; + + /** + * @brief This member defines the maximum time in milliseconds the + * client waits for the first answer packet from the server. + * + * The @c first_timeout is used instead of the regular @c timeout + * for the first wait-period directly after the client sends a packet + * for the first time to the server. That is, this is the timeout + * of the first re-transmission. For any following re-transmissions + * of the current packet the regular @c timeout is used. + * + * The default value is 400ms. + */ + uint32_t first_timeout; + + /** + * @brief This member represents the options to be sent to the server. + * + * These option values are sent to the server. Yet, the server may + * + * + ignore one or all options + * + ask the client to use a different value for an option + * + reject the whole request with an error + * + * If the server rejects a request with options, the current client + * implementation will automatically send a second request without + * options. Hence, the user should be aware that the actual file + * transfer may not use the option values specified here. + */ + tftp_options options; +} tftp_net_config; + +/** + * @brief Set all members of a @c tftp_net_config structure to their + * default values. + * + * @param config references a @c tftp_net_config structure. + * The values are set to the defaults defined in + * @ref tftp_net_config "`type tftp_net_config`". + */ +void tftp_initialize_net_config( + tftp_net_config *config +); + +/** + * @brief Opens and starts a TFTP client session to read or write a + * single file. + * + * This directive resolves the hostname or IP address, establishes a connection + * to the TFTP server and initiates the data transfer. It will not return + * before an error is encountered or the TFTP server has responded to the + * read or write request with a network packet. + * + * TFTP uses timeouts (of unspecified length). It does not know keep-alive + * messages. If the client does not respond to the server in due time, + * the server sets the connection faulty and drops it. To avoid this + * the user of this code must read or write enough data fast enough. + * + * "Enough data" means at least so much data which fills a single data + * packet or all packets of a window if windows are used. The data + * can be read or written in anything from one single large chunk to + * byte-by-byte pieces. The point is, one cannot pause the reading + * or writing for longer periods of time. + * + * @param hostname is the IPv4 address as string or the name of the TFTP + * server to connect to. + * @param path is the pathname at the TFTP server side of the file to + * read or write. According to RFC 1350 the path must be in + * NETASCII. This is ASCII as defined in "USA Standard Code for + * Information Interchange" with the modifications specified in "Telnet + * Protocol Specification". + * @param is_for_reading indicated whether the file is to be read or written. + * A value of @c true indicates that the file is intended to be read from + * the server. A value of @c false indicates that the file is to be + * written to the server. + * @param config either references a structure defining the configuration + * values for this file transfer or is @c NULL. If it is @c NULL, default + * configuration values are used. See @ref tftp_net_config + * "type tftp_net_config" for a description and the defaults values. + * This function copies the data so that the memory pointed to by + * @c config can be used for other purposes after the call returns. + * @param[out] tftp_handle references a place where a handle of the connection + * can be stored. On success a pointer to a handle is stored. On failure + * (return value other than 0) a @c NULL pointer is stored. This handle + * must be provided to all further calls to @c tftp_read(), + * @c tftp_write(), and @c tftp_close(). + * + * When this directive stores a non-NULL pointer in this place, a call + * to @c tftp_close() is mandatory to release allocated resources. + * This parameter cannot be @c NULL. + * + * @retval 0 When the client session was opened successfully. + * @return Returns a POSIX @c errno value in case an error occurred. + */ +int tftp_open( + const char *hostname, + const char *path, + bool is_for_reading, + const tftp_net_config *config, + void **tftp_handle +); + +/** + * @brief Read data from a TFTP server. + * + * This directive attempts to read data from a TFTP connection open for + * reading. + * + * Upon success, the buffer is always filled with @c count bytes of received + * data with the exception when the end of the file has been reached. + * + * TFTP cannot recover from errors. Once an error is reported, the + * connection must be and can only be closed. + * + * @param tftp_handle is the reference returned by a call to tftp_open(). + * The file must be opened for reading. + * @param[out] buffer references a memory area into which the received + * data is written. + * @param count defines the size of the @c buffer in bytes. + * + * @retval 0 The end of the file has been reached. There is no more data. + * @return If greater or equal to 0, returns the number of bytes written + * into the buffer. If the return value is negative, an error occurred. + * In this case the negated value is a POSIX @c errno value. + */ +ssize_t tftp_read( + void *tftp_handle, + void *buffer, + size_t count +); + +/** + * @brief Write data to a TFTP server. + * + * This directive attempts to write data to a TFTP connection open for + * writing. + * + * On a successful call, all data in the @c buffer will be used. Yet, this + * does not imply that all data is actually sent. This depends on + * whether a whole data packet or window can be filled. + * + * TFTP cannot recover from errors. Once an error is reported, the connection + * must be and can only be closed. + * + * @param tftp_handle is the reference returned by a call to tftp_open(). + * The file must be opened for writing. + * @param buffer references a memory area which contains the data to be + * sent. + * @param count defines the size of the data in @c buffer in bytes. + * + * @return If greater or equal to 0, returns the number of bytes used + * from the buffer. The value is always @c count on a successful call. + * If the return value is negative, an error occurred. In this case + * the negated value is a POSIX @c errno value. + */ +ssize_t tftp_write( + void *tftp_handle, + const void *buffer, + size_t count +); + +/** + * @brief Close a TFTP client connection. + * + * This directive sends all data which are still stored in a write buffer + * to the server (if any), tells the server that the connection ends (if + * required by RFC 1350) and releases any resources allocated at the + * client side. + * + * @note Especially, when writing a file to the server, the return + * code of `tftp_close()` should be checked. Invoking + * `tftp_close()` triggers the sending of the last -- not + * completely filled -- data block. This may fail the same way as any + * `tftp_write()` may fail. Therefore, an error returned by + * `tftp_close()` likely indicates that the file was not + * completely transferred. + * + * @param tftp_handle is the reference returned by a call to tftp_open(). + * If this parameter is @c NULL, the directive call is a no-op. + * + * @retval 0 When the client session was closed successfully. + * @return Returns a POSIX @c errno value in case an error occurred. + */ +int tftp_close( + void *tftp_handle +); + +/** @} */ + #ifdef __cplusplus } #endif diff --git a/cpukit/include/rtems/thread.h b/cpukit/include/rtems/thread.h index 4988b46faa..c3d7de67f4 100644 --- a/cpukit/include/rtems/thread.h +++ b/cpukit/include/rtems/thread.h @@ -1,15 +1,37 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSAPISelfContainedObjects + * + * @brief This header file provides the API of + * @ref RTEMSAPISelfContainedObjects. + */ + /* - * Copyright (c) 2017 embedded brains GmbH. All rights reserved. + * Copyright (c) 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_THREAD_H @@ -32,6 +54,16 @@ void _Semaphore_Post_binary(struct _Semaphore_Control *); typedef struct _Mutex_Control rtems_mutex; +/** + * @defgroup RTEMSAPISelfContainedObjects Self-Contained Objects + * + * @ingroup RTEMSAPI + * + * @brief This group contains the self-contained objects API. + * + * @{ + */ + #define RTEMS_MUTEX_INITIALIZER( name ) _MUTEX_NAMED_INITIALIZER( name ) static __inline void rtems_mutex_init( rtems_mutex *mutex, const char *name ) @@ -296,6 +328,8 @@ static __inline void rtems_binary_semaphore_destroy( _Semaphore_Destroy( &binary_semaphore->Semaphore ); } +/** @} */ + __END_DECLS #endif /* _RTEMS_THREAD_H */ diff --git a/cpukit/include/rtems/thread.hpp b/cpukit/include/rtems/thread.hpp index cdef690740..56e301c0bc 100644 --- a/cpukit/include/rtems/thread.hpp +++ b/cpukit/include/rtems/thread.hpp @@ -220,6 +220,12 @@ namespace rtems /* affinity, cpu set size is? */ }; + template <class T> + inline typename std::decay<T>::type + decay_copy(T&& t) { + return std::forward<T>(t); + } + /** * @brief Create a thread with thread attributes. * @@ -310,7 +316,14 @@ namespace rtems */ template <typename A, typename F, typename ...Args, class = enable_if_attributes<A>> - explicit thread(A&& attr, F&& func, Args&&... args); + explicit thread(A&& attr, F&& func, Args&&... args) + : id_(0) { + start_thread( + make_state(attr, + make_invoker(decay_copy(std::forward<F>(func)), + decay_copy(std::forward<Args>(args))...)) + ); + } /** * Move the thread id to this instance. @@ -428,12 +441,6 @@ namespace rtems void start_thread(state_ptr s); }; - template <class T> - inline typename std::decay<T>::type - decay_copy(T&& t) { - return std::forward<T>(t); - } - template<typename F, typename... Args> thread::thread(F&& func, Args&&... args) : id_(0) { @@ -445,17 +452,6 @@ namespace rtems ); } - template<typename A, typename F, typename... Args, - class = thread::enable_if_attributes<A>> - thread::thread(A&& attr, F&& func, Args&&... args) - : id_(0) { - start_thread( - make_state(attr, - make_invoker(decay_copy(std::forward<F>(func)), - decay_copy(std::forward<Args>(args))...)) - ); - } - inline std::thread::id thread::get_id() const noexcept { return std::thread::id(id_.id_); } diff --git a/cpukit/include/rtems/timecounter.h b/cpukit/include/rtems/timecounter.h index d5025d8b1a..891f8d6afd 100644 --- a/cpukit/include/rtems/timecounter.h +++ b/cpukit/include/rtems/timecounter.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * Copyright (c) 2015 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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. + * 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. */ #ifndef _RTEMS_TIMECOUNTER_H @@ -73,7 +86,7 @@ extern "C" { * } * @endcode */ -RTEMS_INLINE_ROUTINE void rtems_timecounter_install( +static inline void rtems_timecounter_install( struct timecounter *tc ) { @@ -83,7 +96,7 @@ RTEMS_INLINE_ROUTINE void rtems_timecounter_install( /** * @copydoc _Timecounter_Tick() */ -RTEMS_INLINE_ROUTINE void rtems_timecounter_tick(void) +static inline void rtems_timecounter_tick(void) { _Timecounter_Tick(); } @@ -206,7 +219,7 @@ void rtems_timecounter_simple_install( * * @return The scaled value. */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_scale( +static inline uint32_t rtems_timecounter_simple_scale( const rtems_timecounter_simple *tc, uint32_t value ) @@ -222,7 +235,7 @@ RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_scale( * @param[in] at_tick The method to perform work under timecounter lock * protection at this tick, e.g. clear a pending flag. */ -RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_downcounter_tick( +static inline void rtems_timecounter_simple_downcounter_tick( rtems_timecounter_simple *tc, rtems_timecounter_simple_get get, rtems_timecounter_simple_at_tick at_tick @@ -251,7 +264,7 @@ RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_downcounter_tick( * @param[in] at_tick The method to perform work under timecounter lock * protection at this tick, e.g. clear a pending flag. */ -RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_upcounter_tick( +static inline void rtems_timecounter_simple_upcounter_tick( rtems_timecounter_simple *tc, rtems_timecounter_simple_get get, rtems_timecounter_simple_at_tick at_tick @@ -278,7 +291,7 @@ RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_upcounter_tick( * @param[in] is_pending The method which indicates if the interrupt of the * simple timecounter is pending. */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_downcounter_get( +static inline uint32_t rtems_timecounter_simple_downcounter_get( struct timecounter *tc_base, rtems_timecounter_simple_get get, rtems_timecounter_simple_is_pending is_pending @@ -309,7 +322,7 @@ RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_downcounter_get( * @param[in] is_pending The method which indicates if the interrupt of the * simple timecounter is pending. */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_upcounter_get( +static inline uint32_t rtems_timecounter_simple_upcounter_get( struct timecounter *tc_base, rtems_timecounter_simple_get get, rtems_timecounter_simple_is_pending is_pending diff --git a/cpukit/include/rtems/timespec.h b/cpukit/include/rtems/timespec.h index 1e9eea71c5..8d49a8e6c2 100644 --- a/cpukit/include/rtems/timespec.h +++ b/cpukit/include/rtems/timespec.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ * Copyright (c) 2012. * Krzysztof Miesowicz <krzysztof.miesowicz@gmail.com> * - * 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. + * 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. */ #ifndef _RTEMS_TIMESPEC_H @@ -45,7 +64,7 @@ extern "C" { * @retval true The timespec is valid. * @retval false The timespec is not valid. */ -RTEMS_INLINE_ROUTINE bool rtems_timespec_is_valid( +static inline bool rtems_timespec_is_valid( const struct timespec *time ) { @@ -64,7 +83,7 @@ RTEMS_INLINE_ROUTINE bool rtems_timespec_is_valid( * @retval false @a lhs is not less than @a rhs. * */ -RTEMS_INLINE_ROUTINE bool rtems_timespec_less_than( +static inline bool rtems_timespec_less_than( const struct timespec *lhs, const struct timespec *rhs ) @@ -83,7 +102,7 @@ RTEMS_INLINE_ROUTINE bool rtems_timespec_less_than( * * @return This method returns the number of seconds @a time increased by. */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_add_to( +static inline uint32_t rtems_timespec_add_to( struct timespec *time, const struct timespec *add ) @@ -101,7 +120,7 @@ RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_add_to( * * @return This method returns the number of ticks computed. */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_to_ticks( +static inline uint32_t rtems_timespec_to_ticks( const struct timespec *time ) { @@ -118,7 +137,7 @@ RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_to_ticks( * @param[in] ticks is the number of ticks to convert */ -RTEMS_INLINE_ROUTINE void rtems_timespec_from_ticks( +static inline void rtems_timespec_from_ticks( uint32_t ticks, struct timespec *time ) @@ -138,7 +157,7 @@ RTEMS_INLINE_ROUTINE void rtems_timespec_from_ticks( * * @return This method fills in @a result. */ -RTEMS_INLINE_ROUTINE void rtems_timespec_subtract( +static inline void rtems_timespec_subtract( const struct timespec *start, const struct timespec *end, struct timespec *result @@ -160,7 +179,7 @@ RTEMS_INLINE_ROUTINE void rtems_timespec_subtract( * * @return This method fills in @a result. */ -RTEMS_INLINE_ROUTINE void rtems_timespec_divide_by_integer( +static inline void rtems_timespec_divide_by_integer( const struct timespec *time, uint32_t iterations, struct timespec *result @@ -182,7 +201,7 @@ RTEMS_INLINE_ROUTINE void rtems_timespec_divide_by_integer( * * @return This method fills in @a result. */ -RTEMS_INLINE_ROUTINE void rtems_timespec_divide( +static inline void rtems_timespec_divide( const struct timespec *lhs, const struct timespec *rhs, uint32_t *ival_percentage, @@ -202,7 +221,7 @@ RTEMS_INLINE_ROUTINE void rtems_timespec_divide( * @param[in] _seconds is the seconds portion of the timespec * @param[in] _nanoseconds is the nanoseconds portion of the timespec */ -RTEMS_INLINE_ROUTINE void rtems_timespec_set( +static inline void rtems_timespec_set( struct timespec *_time, time_t _seconds, uint32_t _nanoseconds @@ -219,7 +238,7 @@ RTEMS_INLINE_ROUTINE void rtems_timespec_set( * * @param[in] _time points to the timespec instance to zero. */ -RTEMS_INLINE_ROUTINE void rtems_timespec_zero( +static inline void rtems_timespec_zero( struct timespec *_time ) { @@ -235,7 +254,7 @@ RTEMS_INLINE_ROUTINE void rtems_timespec_zero( * * @return The seconds portion of @a _time. */ -RTEMS_INLINE_ROUTINE time_t rtems_timespec_get_seconds( +static inline time_t rtems_timespec_get_seconds( struct timespec *_time ) { @@ -251,7 +270,7 @@ RTEMS_INLINE_ROUTINE time_t rtems_timespec_get_seconds( * * @return The nanoseconds portion of @a _time. */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_get_nanoseconds( +static inline uint32_t rtems_timespec_get_nanoseconds( struct timespec *_time ) { @@ -269,7 +288,7 @@ RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_get_nanoseconds( * @retval true @a _lhs is greater than @a _rhs. * @retval false @a _lhs is not greater than @a _rhs. */ -RTEMS_INLINE_ROUTINE bool rtems_timespec_greater_than( +static inline bool rtems_timespec_greater_than( const struct timespec *_lhs, const struct timespec *_rhs ) @@ -287,7 +306,7 @@ RTEMS_INLINE_ROUTINE bool rtems_timespec_greater_than( * @retval true @a lhs is equal to @a rhs. * @retval false @a lhs is not equal to @a rhs. */ -RTEMS_INLINE_ROUTINE bool rtems_timespec_equal_to( +static inline bool rtems_timespec_equal_to( const struct timespec *lhs, const struct timespec *rhs ) diff --git a/cpukit/include/rtems/tm27-default.h b/cpukit/include/rtems/tm27-default.h index 099f5a6805..8cfec48575 100644 --- a/cpukit/include/rtems/tm27-default.h +++ b/cpukit/include/rtems/tm27-default.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,9 +9,26 @@ */ /* - * 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. + * 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. */ #ifndef _RTEMS_TMTEST27 diff --git a/cpukit/include/rtems/trace/rtems-trace-buffer-vars.h b/cpukit/include/rtems/trace/rtems-trace-buffer-vars.h index c6a13b9a2b..d10b25c730 100644 --- a/cpukit/include/rtems/trace/rtems-trace-buffer-vars.h +++ b/cpukit/include/rtems/trace/rtems-trace-buffer-vars.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -8,9 +10,26 @@ /* * Copyright (c) 2015 Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #if !defined (_RTEMS_TRACE_BUFFER_VARS_H_) diff --git a/cpukit/include/rtems/untar.h b/cpukit/include/rtems/untar.h index 5c30e750d3..81ab0e91ff 100644 --- a/cpukit/include/rtems/untar.h +++ b/cpukit/include/rtems/untar.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -9,9 +11,26 @@ /* * Written by: Jake Janovetz <janovetz@tempest.ece.uiuc.edu> * - * 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. + * 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. */ #ifndef _RTEMS_UNTAR_H diff --git a/cpukit/include/rtems/userenv.h b/cpukit/include/rtems/userenv.h index 2b66ee0951..cd9524110d 100644 --- a/cpukit/include/rtems/userenv.h +++ b/cpukit/include/rtems/userenv.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,11 +12,28 @@ * On-Line Applications Research Corporation (OAR). * * Modifications to support reference counting in the file system are - * Copyright (c) 2012 embedded brains GmbH. + * Copyright (c) 2012 embedded brains GmbH & Co. KG + * + * 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. * - * 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. + * 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. */ #ifndef _RTEMS_USERENV_H diff --git a/cpukit/include/rtems/version.h b/cpukit/include/rtems/version.h index cdd8905735..7fd4c4198e 100644 --- a/cpukit/include/rtems/version.h +++ b/cpukit/include/rtems/version.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -10,9 +12,26 @@ * Copyright (C) 2017. * Chris Johns <chrisj@rtems.org> * - * 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. + * 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. */ #ifndef _RTEMS_VERSION_H diff --git a/cpukit/include/rtems/vmeintr.h b/cpukit/include/rtems/vmeintr.h index 74bda9bf08..0c9f94ac2f 100644 --- a/cpukit/include/rtems/vmeintr.h +++ b/cpukit/include/rtems/vmeintr.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-1999. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_VMEINTR_H diff --git a/cpukit/include/rtems/watchdogdrv.h b/cpukit/include/rtems/watchdogdrv.h index f05ea80938..c30e764969 100644 --- a/cpukit/include/rtems/watchdogdrv.h +++ b/cpukit/include/rtems/watchdogdrv.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -12,9 +14,26 @@ * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * - * 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. + * 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. */ #ifndef _RTEMS_WATCHDOGDRV_H |