diff options
Diffstat (limited to 'cpukit/score/src')
137 files changed, 361 insertions, 1272 deletions
diff --git a/cpukit/score/src/allocatormutex.c b/cpukit/score/src/allocatormutex.c index aec965bb85..8a4a9bdd2c 100644 --- a/cpukit/score/src/allocatormutex.c +++ b/cpukit/score/src/allocatormutex.c @@ -11,7 +11,7 @@ */ /* - * Copyright (c) 2017 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/chainnodecount.c b/cpukit/score/src/chainnodecount.c index 61ddaa0dbb..b70108a567 100644 --- a/cpukit/score/src/chainnodecount.c +++ b/cpukit/score/src/chainnodecount.c @@ -9,7 +9,7 @@ * _Chain_Node_count_unprotected(). */ /* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * 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/score/src/condition.c b/cpukit/score/src/condition.c index 976af5d47b..fffe48ee30 100644 --- a/cpukit/score/src/condition.c +++ b/cpukit/score/src/condition.c @@ -13,7 +13,7 @@ */ /* - * Copyright (c) 2015, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 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 diff --git a/cpukit/score/src/configstackspacesize.c b/cpukit/score/src/configstackspacesize.c index ce3d7d4836..21c69a0304 100644 --- a/cpukit/score/src/configstackspacesize.c +++ b/cpukit/score/src/configstackspacesize.c @@ -9,7 +9,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2014, 2019 embedded brains GmbH + * 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 diff --git a/cpukit/score/src/coremsgwkspace.c b/cpukit/score/src/coremsgwkspace.c index 8441701813..7296ffb4ea 100644 --- a/cpukit/score/src/coremsgwkspace.c +++ b/cpukit/score/src/coremsgwkspace.c @@ -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/score/src/coretodadjust.c b/cpukit/score/src/coretodadjust.c deleted file mode 100644 index 907e5b06d7..0000000000 --- a/cpukit/score/src/coretodadjust.c +++ /dev/null @@ -1,73 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - -/** - * @file - * - * @ingroup RTEMSScoreTOD - * - * @brief This source file contains the implementation of - * _TOD_Adjust(). - */ - -/* - * COPYRIGHT (c) 1989-2014. - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/score/todimpl.h> - -Status_Control _TOD_Adjust( - const struct timespec *delta -) -{ - ISR_lock_Context lock_context; - struct timespec tod; - Status_Control status; - - /* - * Currently, RTEMS does the adjustment in one movement. - * Given interest, requirements, and sponsorship, a future - * enhancement would be to adjust the time in smaller increments - * at each clock tick. Until then, there is no outstanding - * adjustment. - */ - - _TOD_Lock(); - _TOD_Acquire( &lock_context ); - _TOD_Get( &tod ); - _Timespec_Add_to( &tod, delta ); - status = _TOD_Is_valid_new_time_of_day( &tod ); - - if ( status == STATUS_SUCCESSFUL ) { - status = _TOD_Set( &tod, &lock_context ); - } - - _TOD_Unlock(); - - return status; -} diff --git a/cpukit/score/src/coretodcheck.c b/cpukit/score/src/coretodcheck.c index 8c012c5070..1d13d950be 100644 --- a/cpukit/score/src/coretodcheck.c +++ b/cpukit/score/src/coretodcheck.c @@ -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/score/src/debugisthreaddispatchingallowed.c b/cpukit/score/src/debugisthreaddispatchingallowed.c index d7880ef331..5c5cc2b34b 100644 --- a/cpukit/score/src/debugisthreaddispatchingallowed.c +++ b/cpukit/score/src/debugisthreaddispatchingallowed.c @@ -9,7 +9,7 @@ * _Debug_Is_thread_dispatching_allowed(). */ /* - * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/gcovinfoset.c b/cpukit/score/src/debugunreachable.c index 6fd695043b..f6c2bf67ca 100644 --- a/cpukit/score/src/gcovinfoset.c +++ b/cpukit/score/src/debugunreachable.c @@ -3,14 +3,13 @@ /** * @file * - * @ingroup RTEMSScoreIO + * @ingroup RTEMSScore * - * @brief This source file contains the definition of the gcov information - * linker set. + * @brief This source file contains the implementation of _Debug_Unreachable(). */ /* - * Copyright (C) 2021, 2022 embedded brains GmbH + * Copyright (C) 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 @@ -38,6 +37,13 @@ #include "config.h" #endif -#include <rtems/score/gcov.h> +#include <rtems/score/basedefs.h> -RTEMS_LINKER_ROSET( gcov_info, const struct gcov_info * ); +#include <assert.h> + +#if defined(RTEMS_DEBUG) +void _Debug_Unreachable( const char *file, int line, const char *func ) +{ + __assert_func( file, line, func, "reached unreachable code" ); +} +#endif diff --git a/cpukit/score/src/futex.c b/cpukit/score/src/futex.c index ff2bcd853e..e158b61238 100644 --- a/cpukit/score/src/futex.c +++ b/cpukit/score/src/futex.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2015, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 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 diff --git a/cpukit/score/src/gcovdumpinfo.c b/cpukit/score/src/gcovdumpinfo.c deleted file mode 100644 index 8598fce578..0000000000 --- a/cpukit/score/src/gcovdumpinfo.c +++ /dev/null @@ -1,96 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - -/** - * @file - * - * @ingroup RTEMSScoreIO - * - * @brief This source file contains the implementation of _Gcov_Ddump_info(). - */ - -/* - * Copyright (C) 2021, 2022 embedded brains GmbH - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/score/gcov.h> - -typedef struct { - IO_Put_char put_char; - void *arg; -} Gcov_Context; - -static void _Gcov_Dump( const void *data, unsigned length, void *arg ) -{ - Gcov_Context *ctx; - IO_Put_char put_char; - void *ctx_arg; - const char *in; - const void *end; - - ctx = arg; - in = data; - end = in + length; - put_char = ctx->put_char; - ctx_arg = ctx->arg; - - while ( in != end ) { - ( *put_char )( *in, ctx_arg ); - ++in; - } -} - -static void _Gcov_Filename( const char *filename, void *arg ) -{ - __gcov_filename_to_gcfn( filename, _Gcov_Dump, arg ); -} - -static void *_Gcov_Allocate( unsigned length, void *arg ) -{ - (void) length; - (void) arg; - return NULL; -} - -void _Gcov_Dump_info( IO_Put_char put_char, void *arg ) -{ - Gcov_Context ctx; - const struct gcov_info * const *item; - - ctx.put_char = put_char; - ctx.arg = arg; - - RTEMS_LINKER_SET_FOREACH( gcov_info, item ) { - __gcov_info_to_gcda( - *item, - _Gcov_Filename, - _Gcov_Dump, - _Gcov_Allocate, - &ctx - ); - } -} diff --git a/cpukit/score/src/gcovdumpinfobase64.c b/cpukit/score/src/gcovdumpinfobase64.c deleted file mode 100644 index be07f03291..0000000000 --- a/cpukit/score/src/gcovdumpinfobase64.c +++ /dev/null @@ -1,104 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - -/** - * @file - * - * @ingroup RTEMSScoreIO - * - * @brief This source file contains the implementation of - * _Gcov_Dump_info_base64(). - */ - -/* - * Copyright (C) 2021, 2022 embedded brains GmbH - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/score/gcov.h> - -#include <limits.h> -#include <string.h> - -typedef struct { - IO_Put_char put_char; - void *arg; - int out; - size_t index; - char buf[ 57 ]; -} Gcov_Base64_context; - -static void _Gcov_Base64_put_char( int c, void *arg ) -{ - Gcov_Base64_context *ctx; - - ctx = arg; - - ( *ctx->put_char )( c, ctx->arg ); - ++ctx->out; - - if ( ctx->out >= 76 ) { - ctx->out = 0; - ( *ctx->put_char )( '\n', ctx->arg ); - } -} - -static void _Gcov_Base64_encode( int c, void *arg ) -{ - Gcov_Base64_context *ctx; - size_t index; - - ctx = arg; - index = ctx->index; - ctx->buf[ index ] = (char) c; - - if ( index == RTEMS_ARRAY_SIZE( ctx->buf ) - 1 ) { - index = 0; - _IO_Base64( - _Gcov_Base64_put_char, - ctx, - ctx->buf, - sizeof( ctx->buf ), - NULL, - INT_MAX - ); - } else { - ++index; - } - - ctx->index = index; -} - -void _Gcov_Dump_info_base64( IO_Put_char put_char, void *arg ) -{ - Gcov_Base64_context ctx; - - memset( &ctx, 0, sizeof( ctx ) ); - ctx.put_char = put_char; - ctx.arg = arg; - _Gcov_Dump_info( _Gcov_Base64_encode, &ctx ); - _IO_Base64( _Gcov_Base64_put_char, &ctx, ctx.buf, ctx.index, NULL, INT_MAX ); -} diff --git a/cpukit/score/src/hash.c b/cpukit/score/src/hash.c index 42ea7f0582..0b9f127e54 100644 --- a/cpukit/score/src/hash.c +++ b/cpukit/score/src/hash.c @@ -9,7 +9,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 @@ -39,7 +39,7 @@ #include <rtems/score/hash.h> #include <rtems/score/assert.h> -#include <rtems/score/io.h> +#include <rtems/base64.h> #include <limits.h> @@ -64,7 +64,7 @@ void _Hash_Finalize( Hash_Context *context, Hash_Control *hash ) context->hash = hash; context->index = 0; hash->chars[ sizeof( *hash ) - 1 ] = '\0'; - n = _IO_Base64url( + n = _Base64url_Encode( _Hash_Put_char, context, digest, diff --git a/cpukit/score/src/heap.c b/cpukit/score/src/heap.c index c5596adaa7..948e48e5d5 100644 --- a/cpukit/score/src/heap.c +++ b/cpukit/score/src/heap.c @@ -13,7 +13,7 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2009, 2010 embedded brains GmbH. + * Copyright (C) 2009, 2010 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/score/src/heapallocate.c b/cpukit/score/src/heapallocate.c index 049a1279b1..8a93ad17b8 100644 --- a/cpukit/score/src/heapallocate.c +++ b/cpukit/score/src/heapallocate.c @@ -13,7 +13,7 @@ * COPYRIGHT (c) 1989-1999. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2009 embedded brains GmbH. + * Copyright (c) 2009 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/score/src/heapextend.c b/cpukit/score/src/heapextend.c index 02a36aa442..da506d6a39 100644 --- a/cpukit/score/src/heapextend.c +++ b/cpukit/score/src/heapextend.c @@ -13,7 +13,7 @@ * COPYRIGHT (c) 1989-1999. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2010 embedded brains GmbH. + * Copyright (c) 2010 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/score/src/heapgreedy.c b/cpukit/score/src/heapgreedy.c index 47a65dab1b..c8c79cb3ba 100644 --- a/cpukit/score/src/heapgreedy.c +++ b/cpukit/score/src/heapgreedy.c @@ -11,7 +11,7 @@ */ /* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * 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/score/src/heapiterate.c b/cpukit/score/src/heapiterate.c index 4b1cb734a5..77874923da 100644 --- a/cpukit/score/src/heapiterate.c +++ b/cpukit/score/src/heapiterate.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * Copyright (c) 2011 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/score/src/heapnoextend.c b/cpukit/score/src/heapnoextend.c index 11fe0f3ebb..828448b8db 100644 --- a/cpukit/score/src/heapnoextend.c +++ b/cpukit/score/src/heapnoextend.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * 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/score/src/heapresizeblock.c b/cpukit/score/src/heapresizeblock.c index 7f7dc29d51..a94461d0a5 100644 --- a/cpukit/score/src/heapresizeblock.c +++ b/cpukit/score/src/heapresizeblock.c @@ -13,7 +13,7 @@ * COPYRIGHT (c) 1989-1999. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2009 embedded brains GmbH. + * Copyright (c) 2009 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/score/src/iobase64.c b/cpukit/score/src/iobase64.c deleted file mode 100644 index 38bc2cd22c..0000000000 --- a/cpukit/score/src/iobase64.c +++ /dev/null @@ -1,111 +0,0 @@ -/* SPDX-License-Identifier: ISC */ - -/** - * @file - * - * @ingroup RTEMSScoreIO - * - * @brief This source file contains the implementation of - * _IO_Base64() and _IO_Base64url(). - */ - -/* - * Copyright (C) 2020, 2021 embedded brains GmbH (http://www.embedded-brains.de) - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") - * Copyright (C) 1998-2001, 2003 Internet Software Consortium. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include <rtems/score/io.h> - -static void -_IO_Put(int c, void *arg, IO_Put_char put_char) -{ - (*put_char)(c, arg); -} - -static int -_IO_Base64_with_encoding(IO_Put_char put_char, void *arg, const void *src, - size_t srclen, const char *wordbreak, int wordlen, const char *encoding) -{ - unsigned int loops = 0; - const unsigned char *in = src; - int out = 0; - - if (wordlen < 4) { - wordlen = 4; - } - - while (srclen > 2) { - _IO_Put(encoding[(in[0]>>2)&0x3f], arg, put_char); - _IO_Put(encoding[((in[0]<<4)&0x30)| - ((in[1]>>4)&0x0f)], arg, put_char); - _IO_Put(encoding[((in[1]<<2)&0x3c)| - ((in[2]>>6)&0x03)], arg, put_char); - _IO_Put(encoding[in[2]&0x3f], arg, put_char); - in += 3; - srclen -= 3; - out += 4; - - loops++; - if (srclen != 0 && - (int)((loops + 1) * 4) >= wordlen) - { - const char *w = wordbreak; - loops = 0; - while (*w != '\0') { - _IO_Put(*w, arg, put_char); - ++w; - ++out; - } - } - } - if (srclen == 2) { - _IO_Put(encoding[(in[0]>>2)&0x3f], arg, put_char); - _IO_Put(encoding[((in[0]<<4)&0x30)| - ((in[1]>>4)&0x0f)], arg, put_char); - _IO_Put(encoding[((in[1]<<2)&0x3c)], arg, put_char); - _IO_Put('=', arg, put_char); - out += 4; - } else if (srclen == 1) { - _IO_Put(encoding[(in[0]>>2)&0x3f], arg, put_char); - _IO_Put(encoding[((in[0]<<4)&0x30)], arg, put_char); - _IO_Put('=', arg, put_char); - _IO_Put('=', arg, put_char); - out += 4; - } - return out; -} - -static const char base64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - -int -_IO_Base64(IO_Put_char put_char, void *arg, const void *src, size_t srclen, - const char *wordbreak, int wordlen) -{ - return _IO_Base64_with_encoding(put_char, arg, src, srclen, wordbreak, - wordlen, base64); -} - -static const char base64url[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="; - -int -_IO_Base64url(IO_Put_char put_char, void *arg, const void *src, size_t srclen, - const char *wordbreak, int wordlen) -{ - return _IO_Base64_with_encoding(put_char, arg, src, srclen, wordbreak, - wordlen, base64url); -} diff --git a/cpukit/score/src/ioprintf.c b/cpukit/score/src/ioprintf.c deleted file mode 100644 index eb694736ae..0000000000 --- a/cpukit/score/src/ioprintf.c +++ /dev/null @@ -1,53 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - -/** - * @file - * - * @ingroup RTEMSScoreIO - * - * @brief This source file contains the implementation of - * _IO_Printf(). - */ - -/* - * Copyright (c) 2017 embedded brains GmbH. 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/score/io.h> - -int _IO_Printf( IO_Put_char put_char, void *arg, char const *fmt, ... ) -{ - va_list ap; - int len; - - va_start( ap, fmt ); - len = _IO_Vprintf( put_char, arg, fmt, ap ); - va_end( ap ); - - return len; -} diff --git a/cpukit/score/src/iorelax.c b/cpukit/score/src/iorelax.c deleted file mode 100644 index f37d848605..0000000000 --- a/cpukit/score/src/iorelax.c +++ /dev/null @@ -1,53 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - -/** - * @file - * - * @ingroup RTEMSScoreIO - * - * @brief This source file contains the implementation of _IO_Relax(). - */ - -/* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/score/io.h> -#include <rtems/score/cpuimpl.h> - -void _IO_Relax( void ) -{ - _CPU_Instruction_no_operation(); - _CPU_Instruction_no_operation(); - _CPU_Instruction_no_operation(); - _CPU_Instruction_no_operation(); - _CPU_Instruction_no_operation(); - _CPU_Instruction_no_operation(); - _CPU_Instruction_no_operation(); - _CPU_Instruction_no_operation(); -} diff --git a/cpukit/score/src/iovprintf.c b/cpukit/score/src/iovprintf.c deleted file mode 100644 index 0e8eb0b47b..0000000000 --- a/cpukit/score/src/iovprintf.c +++ /dev/null @@ -1,377 +0,0 @@ -/** - * @file - * - * @ingroup RTEMSScoreIO - * - * @brief This source file contains the implementation of - * _IO_Vprintf(). - */ - -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1986, 1988, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94 - */ - -#include <rtems/score/io.h> - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/kern/subr_prf.c 336417 2018-07-17 14:56:54Z markj $"); - -#include <sys/param.h> -#include <string.h> - -/* Max number conversion buffer length: a intmax_t in base 8, plus NUL byte. */ -#define MAXNBUF (howmany(sizeof(intmax_t) * NBBY, 3) + 1) - -static inline int imax(int a, int b) { return (a > b ? a : b); } - -static char const hex2ascii_data[2][16] = { - { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'a', 'b', 'c', 'd', 'e', 'f' }, - { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F' } -}; - -static inline char -hex2ascii(int hex) -{ - - return (hex2ascii_data[0][hex]); -} - -/* - * Put a NUL-terminated ASCII number (base <= 16) in a buffer in reverse - * order; return an optional length and a pointer to the last character - * written in the buffer (i.e., the first character of the string). - * The buffer pointed to by `nbuf' must have length >= MAXNBUF. - */ -static char * -ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper) -{ - char *p; - - p = nbuf; - *p = '\0'; - do { - *++p = hex2ascii_data[upper][num % base]; - } while (num /= base); - if (lenp) - *lenp = p - nbuf; - return (p); -} - -int -_IO_Vprintf(IO_Put_char put_char, void *arg, char const *fmt, va_list ap) -{ -#define PCHAR(c) {int cc=(c); (*put_char)(cc, arg); retval++; } - char nbuf[MAXNBUF]; - const char *p, *percent, *q; - u_char *up; - int ch, n; - uintmax_t num; - int base, lflag, tmp, width, ladjust, sharpflag, neg, sign, dot; - int cflag, hflag, jflag; - RTEMS_STATIC_ASSERT(sizeof(intmax_t) == sizeof(long long), _IO_Vprintf_j); -#if __SIZEOF_PTRDIFF_T__ == __SIZEOF_LONG__ -#define tflag lflag -#else - int tflag; -#endif -#if __SIZEOF_SIZE_T__ == __SIZEOF_LONG__ -#define zflag lflag -#else - int zflag; -#endif - int dwidth, upper; - char padc; - int stop = 0, retval = 0; - - num = 0; - - if (fmt == NULL) - fmt = "(fmt null)\n"; - - for (;;) { - padc = ' '; - width = 0; - while ((ch = (u_char)*fmt++) != '%' || stop) { - if (ch == '\0') - return (retval); - PCHAR(ch); - } - percent = fmt - 1; - lflag = 0; ladjust = 0; sharpflag = 0; neg = 0; - sign = 0; dot = 0; dwidth = 0; upper = 0; - cflag = 0; hflag = 0; jflag = 0; tflag = 0; zflag = 0; -reswitch: switch (ch = (u_char)*fmt++) { - case '.': - dot = 1; - goto reswitch; - case '#': - sharpflag = 1; - goto reswitch; - case '+': - sign = 1; - goto reswitch; - case '-': - ladjust = 1; - goto reswitch; - case '%': - PCHAR(ch); - break; - case '*': - if (!dot) { - width = va_arg(ap, int); - if (width < 0) { - ladjust = !ladjust; - width = -width; - } - } else { - dwidth = va_arg(ap, int); - } - goto reswitch; - case '0': - if (!dot) { - padc = '0'; - goto reswitch; - } - /* FALLTHROUGH */ - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - for (n = 0;; ++fmt) { - n = n * 10 + ch - '0'; - ch = *fmt; - if (ch < '0' || ch > '9') - break; - } - if (dot) - dwidth = n; - else - width = n; - goto reswitch; - case 'c': - width -= 1; - - if (!ladjust && width > 0) - while (width--) - PCHAR(padc); - PCHAR(va_arg(ap, int)); - if (ladjust && width > 0) - while (width--) - PCHAR(padc); - break; - case 'D': - up = va_arg(ap, u_char *); - p = va_arg(ap, char *); - if (!width) - width = 16; - while(width--) { - PCHAR(hex2ascii(*up >> 4)); - PCHAR(hex2ascii(*up & 0x0f)); - up++; - if (width) - for (q=p;*q;q++) - PCHAR(*q); - } - break; - case 'd': - case 'i': - base = 10; - sign = 1; - goto handle_sign; - case 'h': - if (hflag) { - hflag = 0; - cflag = 1; - } else - hflag = 1; - goto reswitch; - case 'j': - jflag = 1; - goto reswitch; - case 'l': - if (lflag) { - jflag = 1; - } else - lflag = 1; - goto reswitch; - case 'o': - base = 8; - goto handle_nosign; - case 'p': - base = 16; - sharpflag = (width == 0); - sign = 0; - num = (uintptr_t)va_arg(ap, void *); - goto number; - case 's': - p = va_arg(ap, char *); - if (p == NULL) - p = "(null)"; - if (!dot) - n = strlen (p); - else - for (n = 0; n < dwidth && p[n]; n++) - continue; - - width -= n; - - if (!ladjust && width > 0) - while (width--) - PCHAR(padc); - while (n--) - PCHAR(*p++); - if (ladjust && width > 0) - while (width--) - PCHAR(padc); - break; - case 't': - tflag = 1; - goto reswitch; - case 'u': - base = 10; - goto handle_nosign; - case 'X': - upper = 1; - case 'x': - base = 16; - goto handle_nosign; - case 'y': - base = 16; - sign = 1; - goto handle_sign; - case 'z': - zflag = 1; - goto reswitch; -handle_nosign: - sign = 0; - if (jflag) - num = va_arg(ap, uintmax_t); -#if __SIZEOF_PTRDIFF_T__ != __SIZEOF_LONG__ - else if (tflag) - num = va_arg(ap, ptrdiff_t); -#endif - else if (lflag) - num = va_arg(ap, u_long); -#if __SIZEOF_SIZE_T__ != __SIZEOF_LONG__ - else if (zflag) - num = va_arg(ap, size_t); -#endif - else if (hflag) - num = (u_short)va_arg(ap, int); - else if (cflag) - num = (u_char)va_arg(ap, int); - else - num = va_arg(ap, u_int); - goto number; -handle_sign: - if (jflag) - num = va_arg(ap, intmax_t); -#if __SIZEOF_PTRDIFF_T__ == __SIZEOF_LONG__ - else if (tflag) - num = va_arg(ap, ptrdiff_t); -#endif - else if (lflag) - num = va_arg(ap, long); -#if __SIZEOF_SIZE_T__ == __SIZEOF_LONG__ - else if (zflag) - num = va_arg(ap, ssize_t); -#endif - else if (hflag) - num = (short)va_arg(ap, int); - else if (cflag) - num = (char)va_arg(ap, int); - else - num = va_arg(ap, int); -number: - if (sign && (intmax_t)num < 0) { - neg = 1; - num = -(intmax_t)num; - } - p = ksprintn(nbuf, num, base, &n, upper); - tmp = 0; - if (sharpflag && num != 0) { - if (base == 8) - tmp++; - else if (base == 16) - tmp += 2; - } - if (neg) - tmp++; - - if (!ladjust && padc == '0') - dwidth = width - tmp; - width -= tmp + imax(dwidth, n); - dwidth -= n; - if (!ladjust) - while (width-- > 0) - PCHAR(' '); - if (neg) - PCHAR('-'); - if (sharpflag && num != 0) { - if (base == 8) { - PCHAR('0'); - } else if (base == 16) { - PCHAR('0'); - PCHAR('x'); - } - } - while (dwidth-- > 0) - PCHAR('0'); - - while (*p) - PCHAR(*p--); - - if (ladjust) - while (width-- > 0) - PCHAR(' '); - - break; - default: - while (percent < fmt) - PCHAR(*percent++); - /* - * Since we ignore a formatting argument it is no - * longer safe to obey the remaining formatting - * arguments as the arguments will no longer match - * the format specs. - */ - stop = 1; - break; - } - } -#undef PCHAR -} diff --git a/cpukit/score/src/isr.c b/cpukit/score/src/isr.c index 75df00e228..7337028b0f 100644 --- a/cpukit/score/src/isr.c +++ b/cpukit/score/src/isr.c @@ -44,6 +44,8 @@ #include <rtems/score/percpu.h> #include <rtems/config.h> +const char * const volatile _ISR_Stack_size_object = _ISR_Stack_size; + void _ISR_Handler_initialization( void ) { uint32_t cpu_max; diff --git a/cpukit/score/src/isrisinprogress.c b/cpukit/score/src/isrisinprogress.c index f1b533c718..036cca4cfa 100644 --- a/cpukit/score/src/isrisinprogress.c +++ b/cpukit/score/src/isrisinprogress.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2013-2015 embedded brains GmbH. All rights reserved. + * Copyright (C) 2013, 2015 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/score/src/isrvectortable.c b/cpukit/score/src/isrvectortable.c index 4bd892757e..86592bc483 100644 --- a/cpukit/score/src/isrvectortable.c +++ b/cpukit/score/src/isrvectortable.c @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2014 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 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 diff --git a/cpukit/score/src/kern_ntptime.c b/cpukit/score/src/kern_ntptime.c index 1233166a61..c6f70079b3 100644 --- a/cpukit/score/src/kern_ntptime.c +++ b/cpukit/score/src/kern_ntptime.c @@ -782,8 +782,7 @@ RTEMS_SYSINIT_ITEM(_NTP_Initialize, RTEMS_SYSINIT_DEVICE_DRIVERS, * is selected by the STA_MODE status bit. */ static void -hardupdate(offset) - long offset; /* clock offset (ns) */ +hardupdate(long offset /* clock offset (ns) */) { long mtemp; l_fp ftemp; @@ -862,11 +861,11 @@ hardupdate(offset) * variables, except for the actual time and frequency variables, which * are determined by this routine and updated atomically. * - * tsp - time at PPS - * nsec - hardware counter at PPS + * tsp - time at current PPS event + * delta_nsec - time elapsed between the previous and current PPS event */ void -hardpps(struct timespec *tsp, long nsec) +hardpps(struct timespec *tsp, long delta_nsec) { long u_sec, u_nsec, v_nsec; /* temps */ l_fp ftemp; @@ -901,19 +900,10 @@ hardpps(struct timespec *tsp, long nsec) pps_tf[0].tv_nsec = u_nsec; /* - * Compute the difference between the current and previous - * counter values. If the difference exceeds 0.5 s, assume it - * has wrapped around, so correct 1.0 s. If the result exceeds - * the tick interval, the sample point has crossed a tick - * boundary during the last second, so correct the tick. Very - * intricate. + * Update the frequency accumulator using the difference between the + * current and previous PPS event measured directly by the timecounter. */ - u_nsec = nsec; - if (u_nsec > (NANOSECOND >> 1)) - u_nsec -= NANOSECOND; - else if (u_nsec < -(NANOSECOND >> 1)) - u_nsec += NANOSECOND; - pps_fcount += u_nsec; + pps_fcount += delta_nsec - NANOSECOND; if (v_nsec > MAXFREQ || v_nsec < -MAXFREQ) goto out; time_status &= ~STA_PPSJITTER; diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c index 643026a1c8..95ae01b5b4 100644 --- a/cpukit/score/src/kern_tc.c +++ b/cpukit/score/src/kern_tc.c @@ -2141,6 +2141,7 @@ void pps_capture(struct pps_state *pps) { struct timehands *th; + struct timecounter *tc; KASSERT(pps != NULL, ("NULL pps pointer in pps_capture")); th = timehands; @@ -2149,19 +2150,18 @@ pps_capture(struct pps_state *pps) #ifdef FFCLOCK pps->capffth = fftimehands; #endif - pps->capcount = th->th_counter->tc_get_timecount(th->th_counter); -#if defined(RTEMS_SMP) - atomic_thread_fence_acq(); - if (pps->capgen != th->th_generation) - pps->capgen = 0; -#endif + tc = th->th_counter; + pps->capcount = tc->tc_get_timecount(tc); } void pps_event(struct pps_state *pps, int event) { + struct timehands *capth; + struct timecounter *captc; + uint64_t capth_scale; struct bintime bt; - struct timespec ts, *tsp, *osp; + struct timespec *tsp, *osp; uint32_t tcount, *pcount; int foff; pps_seq_t *pseq; @@ -2178,13 +2178,21 @@ pps_event(struct pps_state *pps, int event) /* Nothing to do if not currently set to capture this event type. */ if ((event & pps->ppsparam.mode) == 0) return; + + /* Make a snapshot of the captured timehand */ + capth = pps->capth; + captc = capth->th_counter; + capth_scale = capth->th_scale; + tcount = capth->th_offset_count; + bt = capth->th_bintime; + /* If the timecounter was wound up underneath us, bail out. */ + atomic_thread_fence_acq(); #if defined(RTEMS_SMP) - if (pps->capgen == 0 || pps->capgen != + if (pps->capgen == 0 || pps->capgen != capth->th_generation) #else - if (pps->capgen != + if (pps->capgen != capth->th_generation) #endif - atomic_load_acq_int(&pps->capth->th_generation)) return; /* Things would be easier with arrays. */ @@ -2218,32 +2226,25 @@ pps_event(struct pps_state *pps, int event) #endif } + *pcount = pps->capcount; + /* * If the timecounter changed, we cannot compare the count values, so * we have to drop the rest of the PPS-stuff until the next event. */ - if (pps->ppstc != pps->capth->th_counter) { - pps->ppstc = pps->capth->th_counter; - *pcount = pps->capcount; + if (__predict_false(pps->ppstc != captc)) { + pps->ppstc = captc; pps->ppscount[2] = pps->capcount; return; } - /* Convert the count to a timespec. */ - tcount = pps->capcount - pps->capth->th_offset_count; - tcount &= pps->capth->th_counter->tc_counter_mask; - bt = pps->capth->th_bintime; - bintime_addx(&bt, pps->capth->th_scale * tcount); - bintime2timespec(&bt, &ts); - - /* If the timecounter was wound up underneath us, bail out. */ - atomic_thread_fence_acq(); - if (pps->capgen != pps->capth->th_generation) - return; - - *pcount = pps->capcount; (*pseq)++; - *tsp = ts; + + /* Convert the count to a timespec. */ + tcount = pps->capcount - tcount; + tcount &= captc->tc_counter_mask; + bintime_addx(&bt, capth_scale * tcount); + bintime2timespec(&bt, tsp); if (foff) { timespecadd(tsp, osp, tsp); @@ -2258,14 +2259,14 @@ pps_event(struct pps_state *pps, int event) bt = pps->capffth->tick_time; ffclock_convert_delta(tcount, pps->capffth->cest.period, &bt); bintime_add(&bt, &pps->capffth->tick_time); - bintime2timespec(&bt, &ts); (*pseq_ffc)++; - *tsp_ffc = ts; + bintime2timespec(&bt, tsp_ffc); #endif #ifdef PPS_SYNC if (fhard) { - uint64_t scale; + uint64_t delta_nsec; + uint64_t freq; /* * Feed the NTP PLL/FLL. @@ -2274,15 +2275,12 @@ pps_event(struct pps_state *pps, int event) */ tcount = pps->capcount - pps->ppscount[2]; pps->ppscount[2] = pps->capcount; - tcount &= pps->capth->th_counter->tc_counter_mask; - scale = (uint64_t)1 << 63; - scale /= pps->capth->th_counter->tc_frequency; - scale *= 2; - bt.sec = 0; - bt.frac = 0; - bintime_addx(&bt, scale * tcount); - bintime2timespec(&bt, &ts); - hardpps(tsp, ts.tv_nsec + 1000000000 * ts.tv_sec); + tcount &= captc->tc_counter_mask; + delta_nsec = 1000000000; + delta_nsec *= tcount; + freq = captc->tc_frequency; + delta_nsec = (delta_nsec + freq / 2) / freq; + hardpps(tsp, (long)delta_nsec); } #endif @@ -2497,7 +2495,7 @@ SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL); /* Cpu tick handling -------------------------------------------------*/ -static int cpu_tick_variable; +static bool cpu_tick_variable; static uint64_t cpu_tick_frequency; DPCPU_DEFINE_STATIC(uint64_t, tc_cpu_ticks_base); @@ -2590,14 +2588,14 @@ cpu_tick_calibrate(int reset) } void -set_cputicker(cpu_tick_f *func, uint64_t freq, unsigned var) +set_cputicker(cpu_tick_f *func, uint64_t freq, bool isvariable) { if (func == NULL) { cpu_ticks = tc_cpu_ticks; } else { cpu_tick_frequency = freq; - cpu_tick_variable = var; + cpu_tick_variable = isvariable; cpu_ticks = func; } } @@ -2617,20 +2615,14 @@ cpu_tickrate(void) * years) and in 64 bits at 4 GHz (146 years), but if we do a multiply * before divide conversion (to retain precision) we find that the * margin shrinks to 1.5 hours (one millionth of 146y). - * With a three prong approach we never lose significant bits, no - * matter what the cputick rate and length of timeinterval is. */ uint64_t cputick2usec(uint64_t tick) { - - if (tick > 18446744073709551LL) /* floor(2^64 / 1000) */ - return (tick / (cpu_tickrate() / 1000000LL)); - else if (tick > 18446744073709LL) /* floor(2^64 / 1000000) */ - return ((tick * 1000LL) / (cpu_tickrate() / 1000LL)); - else - return ((tick * 1000000LL) / cpu_tickrate()); + uint64_t tr; + tr = cpu_tickrate(); + return ((tick / tr) * 1000000ULL) + ((tick % tr) * 1000000ULL) / tr; } cpu_tick_f *cpu_ticks = tc_cpu_ticks; diff --git a/cpukit/score/src/libatomic.c b/cpukit/score/src/libatomic.c index a586d4815e..fc0e3032ec 100644 --- a/cpukit/score/src/libatomic.c +++ b/cpukit/score/src/libatomic.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/memoryallocate.c b/cpukit/score/src/memoryallocate.c index e2aed7aa1d..791826ca6e 100644 --- a/cpukit/score/src/memoryallocate.c +++ b/cpukit/score/src/memoryallocate.c @@ -10,7 +10,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/score/src/memorydirtyfreeareas.c b/cpukit/score/src/memorydirtyfreeareas.c index 8a817c2208..885c2a503c 100644 --- a/cpukit/score/src/memorydirtyfreeareas.c +++ b/cpukit/score/src/memorydirtyfreeareas.c @@ -10,7 +10,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2020, 2022 embedded brains GmbH + * Copyright (C) 2020, 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 diff --git a/cpukit/score/src/memoryfill.c b/cpukit/score/src/memoryfill.c index 617bf6911e..e9550d52d6 100644 --- a/cpukit/score/src/memoryfill.c +++ b/cpukit/score/src/memoryfill.c @@ -10,7 +10,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/memorynoinit.c b/cpukit/score/src/memorynoinit.c index 19772356cd..22c537820d 100644 --- a/cpukit/score/src/memorynoinit.c +++ b/cpukit/score/src/memorynoinit.c @@ -10,7 +10,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2022 embedded brains GmbH + * Copyright (C) 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 diff --git a/cpukit/score/src/memoryzerobeforeuse.c b/cpukit/score/src/memoryzerobeforeuse.c index 9143cd9c7d..6893600db9 100644 --- a/cpukit/score/src/memoryzerobeforeuse.c +++ b/cpukit/score/src/memoryzerobeforeuse.c @@ -10,7 +10,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2020 embedded brains GmbH + * 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/score/src/memoryzerofreeareas.c b/cpukit/score/src/memoryzerofreeareas.c index b1cef47ef9..08e11c41d4 100644 --- a/cpukit/score/src/memoryzerofreeareas.c +++ b/cpukit/score/src/memoryzerofreeareas.c @@ -10,7 +10,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2020, 2022 embedded brains GmbH + * Copyright (C) 2020, 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 diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c index 6708962b8e..40e6baa12c 100644 --- a/cpukit/score/src/mutex.c +++ b/cpukit/score/src/mutex.c @@ -13,7 +13,7 @@ */ /* - * Copyright (c) 2015, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 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 diff --git a/cpukit/score/src/objectactivecount.c b/cpukit/score/src/objectactivecount.c index 5f0304fead..258ad6b49d 100644 --- a/cpukit/score/src/objectactivecount.c +++ b/cpukit/score/src/objectactivecount.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * 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/score/src/objectallocate.c b/cpukit/score/src/objectallocate.c index ba126d2533..7f3f651ea0 100644 --- a/cpukit/score/src/objectallocate.c +++ b/cpukit/score/src/objectallocate.c @@ -10,7 +10,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2014 embedded brains GmbH + * Copyright (C) 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 diff --git a/cpukit/score/src/objectallocatenone.c b/cpukit/score/src/objectallocatenone.c index a1bead5f79..e8c0b49df4 100644 --- a/cpukit/score/src/objectallocatenone.c +++ b/cpukit/score/src/objectallocatenone.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/objectallocatestatic.c b/cpukit/score/src/objectallocatestatic.c index 0521c8191f..3296e08ce5 100644 --- a/cpukit/score/src/objectallocatestatic.c +++ b/cpukit/score/src/objectallocatestatic.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/objectallocateunlimited.c b/cpukit/score/src/objectallocateunlimited.c index 274a69640b..f317da9668 100644 --- a/cpukit/score/src/objectallocateunlimited.c +++ b/cpukit/score/src/objectallocateunlimited.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2020 embedded brains GmbH + * 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/score/src/objectextendinformation.c b/cpukit/score/src/objectextendinformation.c index 414766f219..9a627b1a7c 100644 --- a/cpukit/score/src/objectextendinformation.c +++ b/cpukit/score/src/objectextendinformation.c @@ -59,7 +59,7 @@ Objects_Maximum _Objects_Extend_information( uint32_t index_base; uint32_t index_end; uint32_t index; - Objects_Maximum extend_count; + uint32_t extend_count; Objects_Maximum old_maximum; uint32_t new_maximum; size_t object_block_size; diff --git a/cpukit/score/src/objectfreenothing.c b/cpukit/score/src/objectfreenothing.c index 0845d4c140..941a7514af 100644 --- a/cpukit/score/src/objectfreenothing.c +++ b/cpukit/score/src/objectfreenothing.c @@ -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/score/src/objectfreestatic.c b/cpukit/score/src/objectfreestatic.c index 4bdc0e1071..94bf906edd 100644 --- a/cpukit/score/src/objectfreestatic.c +++ b/cpukit/score/src/objectfreestatic.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/objectgetlocal.c b/cpukit/score/src/objectgetlocal.c index 16b52150f8..1aad28efa1 100644 --- a/cpukit/score/src/objectgetlocal.c +++ b/cpukit/score/src/objectgetlocal.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/objectinitializeinformation.c b/cpukit/score/src/objectinitializeinformation.c index 3482f2871e..7c1bfd877f 100644 --- a/cpukit/score/src/objectinitializeinformation.c +++ b/cpukit/score/src/objectinitializeinformation.c @@ -42,7 +42,6 @@ #include <rtems/score/objectimpl.h> #include <rtems/score/address.h> #include <rtems/score/chainimpl.h> -#include <rtems/score/interr.h> #include <rtems/score/sysstate.h> void _Objects_Initialize_information( diff --git a/cpukit/score/src/once.c b/cpukit/score/src/once.c index f3a29e5ec5..a395197c3a 100644 --- a/cpukit/score/src/once.c +++ b/cpukit/score/src/once.c @@ -10,7 +10,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 2019 embedded brains GmbH & Co. KG * Copyright (C) 2019 Sebastian Huber * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/score/src/opt_compat.h b/cpukit/score/src/opt_compat.h index 13b719ccf8..db479044f3 100644 --- a/cpukit/score/src/opt_compat.h +++ b/cpukit/score/src/opt_compat.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2015 embedded brains Gmbh (http://www.embedded-brains.de) + * Copyright (C) 2015 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/score/src/opt_ffclock.h b/cpukit/score/src/opt_ffclock.h index 13b719ccf8..db479044f3 100644 --- a/cpukit/score/src/opt_ffclock.h +++ b/cpukit/score/src/opt_ffclock.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2015 embedded brains Gmbh (http://www.embedded-brains.de) + * Copyright (C) 2015 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/score/src/opt_ntp.h b/cpukit/score/src/opt_ntp.h index 13b719ccf8..db479044f3 100644 --- a/cpukit/score/src/opt_ntp.h +++ b/cpukit/score/src/opt_ntp.h @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2015 embedded brains Gmbh (http://www.embedded-brains.de) + * Copyright (C) 2015 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/score/src/percpuasm.c b/cpukit/score/src/percpuasm.c index 6e5a727b76..01ad50a352 100644 --- a/cpukit/score/src/percpuasm.c +++ b/cpukit/score/src/percpuasm.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2012, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2012, 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 @@ -44,7 +44,7 @@ #include <rtems/score/percpu.h> #define PER_CPU_IS_POWER_OF_TWO( value ) \ - ( ( ( ( value ) - 1 ) & ( value ) ) == 0 ) + ( ( value ) > 1 && ( ( ( value ) - 1 ) & ( value ) ) == 0 ) /* * The minimum alignment of two is due to the Heap Handler which uses the @@ -73,6 +73,11 @@ RTEMS_STATIC_ASSERT( ); RTEMS_STATIC_ASSERT( + PER_CPU_IS_POWER_OF_TWO( CPU_STACK_MINIMUM_SIZE ), + CPU_STACK_MINIMUM_SIZE +); + +RTEMS_STATIC_ASSERT( sizeof(void *) == CPU_SIZEOF_POINTER, CPU_SIZEOF_POINTER ); diff --git a/cpukit/score/src/percpudata.c b/cpukit/score/src/percpudata.c index c81c1b6a16..0dda6bdf1d 100644 --- a/cpukit/score/src/percpudata.c +++ b/cpukit/score/src/percpudata.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019, 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2019, 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 @@ -66,14 +66,19 @@ static void _Per_CPU_Data_initialize( void ) size = RTEMS_LINKER_SET_SIZE( _Per_CPU_Data ); if ( size > 0 ) { + char *data_begin; const Memory_Information *mem; Per_CPU_Control *cpu; uint32_t cpu_index; uint32_t cpu_max; + /* Prevent an out of bounds warning in the memcpy() below */ + data_begin = RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ); + RTEMS_OBFUSCATE_VARIABLE( data_begin ); + mem = _Memory_Get(); cpu = _Per_CPU_Get_by_index( 0 ); - cpu->data = RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ); + cpu->data = data_begin; cpu_max = rtems_configuration_get_maximum_processors(); @@ -85,7 +90,7 @@ static void _Per_CPU_Data_initialize( void ) _Internal_error( INTERNAL_ERROR_NO_MEMORY_FOR_PER_CPU_DATA ); } - memcpy( cpu->data, RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ), size); + memcpy( cpu->data, data_begin, size); } } } diff --git a/cpukit/score/src/percpujobs.c b/cpukit/score/src/percpujobs.c index 3de3e4a7bd..0266bd5399 100644 --- a/cpukit/score/src/percpujobs.c +++ b/cpukit/score/src/percpujobs.c @@ -11,7 +11,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/percpustatewait.c b/cpukit/score/src/percpustatewait.c index cfeda7384b..54ab92427f 100644 --- a/cpukit/score/src/percpustatewait.c +++ b/cpukit/score/src/percpustatewait.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 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 diff --git a/cpukit/score/src/pheapiterate.c b/cpukit/score/src/pheapiterate.c deleted file mode 100644 index a709e80335..0000000000 --- a/cpukit/score/src/pheapiterate.c +++ /dev/null @@ -1,52 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - -/** - * @file - * - * @ingroup RTEMSScoreProtHeap - * - * @brief This source file contains the implementation of - * _Protected_heap_Iterate(). - */ - -/* - * Copyright (c) 2011 embedded brains GmbH. 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/score/protectedheap.h> - -void _Protected_heap_Iterate( - Heap_Control *heap, - Heap_Block_visitor visitor, - void *visitor_arg -) -{ - _RTEMS_Lock_allocator(); - _Heap_Iterate( heap, visitor, visitor_arg ); - _RTEMS_Unlock_allocator(); -} diff --git a/cpukit/score/src/pheapresizeblock.c b/cpukit/score/src/pheapresizeblock.c deleted file mode 100644 index ffd765e860..0000000000 --- a/cpukit/score/src/pheapresizeblock.c +++ /dev/null @@ -1,60 +0,0 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - -/** - * @file - * - * @ingroup RTEMSScoreProtHeap - * - * @brief This source file contains the implementation of - * _Protected_heap_Resize_block(). - */ - -/* - * COPYRIGHT (c) 1989-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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/score/protectedheap.h> - -bool _Protected_heap_Resize_block( - Heap_Control *the_heap, - void *starting_address, - uintptr_t size -) -{ - Heap_Resize_status status; - uintptr_t old_mem_size; - uintptr_t avail_mem_size; - - _RTEMS_Lock_allocator(); - status = _Heap_Resize_block( - the_heap, starting_address, size, &old_mem_size, &avail_mem_size ); - _RTEMS_Unlock_allocator(); - return (status == HEAP_RESIZE_SUCCESSFUL); -} - diff --git a/cpukit/score/src/processormaskcopy.c b/cpukit/score/src/processormaskcopy.c index 8697edfa5c..3f1c2cf250 100644 --- a/cpukit/score/src/processormaskcopy.c +++ b/cpukit/score/src/processormaskcopy.c @@ -11,7 +11,7 @@ */ /* - * Copyright (c) 2017 embedded brains GmbH. All rights reserved. + * 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 @@ -39,7 +39,7 @@ #include "config.h" #endif -#include <rtems/score/processormask.h> +#include <rtems/score/processormaskimpl.h> const Processor_mask _Processor_mask_The_one_and_only = { .__bits[ 0 ] = 1 }; diff --git a/cpukit/score/src/profilingisrentryexit.c b/cpukit/score/src/profilingisrentryexit.c index 2619bdc0c0..64905e5a42 100644 --- a/cpukit/score/src/profilingisrentryexit.c +++ b/cpukit/score/src/profilingisrentryexit.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. + * 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 @@ -54,10 +54,7 @@ void _Profiling_Outer_most_interrupt_entry_and_exit( _Assert( cpu->isr_nest_level == 1 ); stats = &cpu->Stats; - delta = _CPU_Counter_difference( - interrupt_exit_instant, - interrupt_entry_instant - ); + delta = interrupt_exit_instant - interrupt_entry_instant; ++stats->interrupt_count; stats->total_interrupt_time += delta; diff --git a/cpukit/score/src/profilingsmplock.c b/cpukit/score/src/profilingsmplock.c index 5c5b4d9196..af9d1cd22b 100644 --- a/cpukit/score/src/profilingsmplock.c +++ b/cpukit/score/src/profilingsmplock.c @@ -12,7 +12,7 @@ */ /* - * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/rbtreeappend.c b/cpukit/score/src/rbtreeappend.c index e36f6bc805..5ce7094b9d 100644 --- a/cpukit/score/src/rbtreeappend.c +++ b/cpukit/score/src/rbtreeappend.c @@ -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/score/src/rbtreeiterate.c b/cpukit/score/src/rbtreeiterate.c index 496c058f32..f13a5db0af 100644 --- a/cpukit/score/src/rbtreeiterate.c +++ b/cpukit/score/src/rbtreeiterate.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * 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/score/src/rbtreemax.c b/cpukit/score/src/rbtreemax.c index f42e42043e..71f856bafd 100644 --- a/cpukit/score/src/rbtreemax.c +++ b/cpukit/score/src/rbtreemax.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2021 embedded brains GmbH + * 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/score/src/rbtreemin.c b/cpukit/score/src/rbtreemin.c index 86e5b6e5c9..d82e1b2280 100644 --- a/cpukit/score/src/rbtreemin.c +++ b/cpukit/score/src/rbtreemin.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2021 embedded brains GmbH + * 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/score/src/rbtreenext.c b/cpukit/score/src/rbtreenext.c index a18b1cec2e..a7314ac095 100644 --- a/cpukit/score/src/rbtreenext.c +++ b/cpukit/score/src/rbtreenext.c @@ -11,7 +11,7 @@ */ /* - * 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/score/src/rbtreepostorder.c b/cpukit/score/src/rbtreepostorder.c index 2239838813..8e5cb2a788 100644 --- a/cpukit/score/src/rbtreepostorder.c +++ b/cpukit/score/src/rbtreepostorder.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2018 embedded brains GmbH. All rights reserved. + * Copyright (c) 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 diff --git a/cpukit/score/src/rbtreeprepend.c b/cpukit/score/src/rbtreeprepend.c index f154f51d36..a637461de5 100644 --- a/cpukit/score/src/rbtreeprepend.c +++ b/cpukit/score/src/rbtreeprepend.c @@ -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/score/src/rbtreeprev.c b/cpukit/score/src/rbtreeprev.c index c23910c085..9d417a79ff 100644 --- a/cpukit/score/src/rbtreeprev.c +++ b/cpukit/score/src/rbtreeprev.c @@ -10,7 +10,7 @@ */ /* - * 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/score/src/rbtreereplace.c b/cpukit/score/src/rbtreereplace.c index b7448d4f3f..4a022f5b69 100644 --- a/cpukit/score/src/rbtreereplace.c +++ b/cpukit/score/src/rbtreereplace.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * Copyright (c) 2015 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/score/src/sched.c b/cpukit/score/src/sched.c index fcc1d399dd..f2ec838bb2 100644 --- a/cpukit/score/src/sched.c +++ b/cpukit/score/src/sched.c @@ -11,7 +11,7 @@ */ /* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * Copyright (c) 2015 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/score/src/schedulerdefaultmakecleansticky.c b/cpukit/score/src/schedulerdefaultmakecleansticky.c index e2b2d659f1..51c893d510 100644 --- a/cpukit/score/src/schedulerdefaultmakecleansticky.c +++ b/cpukit/score/src/schedulerdefaultmakecleansticky.c @@ -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/score/src/schedulerdefaultmappriority.c b/cpukit/score/src/schedulerdefaultmappriority.c index 015aee9fec..309f6b504b 100644 --- a/cpukit/score/src/schedulerdefaultmappriority.c +++ b/cpukit/score/src/schedulerdefaultmappriority.c @@ -10,7 +10,7 @@ */ /* - * 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 diff --git a/cpukit/score/src/schedulerdefaultpinunpin.c b/cpukit/score/src/schedulerdefaultpinunpin.c index df41a29dcb..f39e5f7db5 100644 --- a/cpukit/score/src/schedulerdefaultpinunpin.c +++ b/cpukit/score/src/schedulerdefaultpinunpin.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2018 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 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 diff --git a/cpukit/score/src/schedulerdefaultpinunpindonothing.c b/cpukit/score/src/schedulerdefaultpinunpindonothing.c index f3ecb0b718..b7b2a136a8 100644 --- a/cpukit/score/src/schedulerdefaultpinunpindonothing.c +++ b/cpukit/score/src/schedulerdefaultpinunpindonothing.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2018 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 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 diff --git a/cpukit/score/src/schedulerdefaultschedule.c b/cpukit/score/src/schedulerdefaultschedule.c index a96055cd02..151b50a9fa 100644 --- a/cpukit/score/src/schedulerdefaultschedule.c +++ b/cpukit/score/src/schedulerdefaultschedule.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2014 embedded brains GmbH + * Copyright (c) 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 diff --git a/cpukit/score/src/schedulerdefaultstartidle.c b/cpukit/score/src/schedulerdefaultstartidle.c index 4cd4de2b47..64fc967619 100644 --- a/cpukit/score/src/schedulerdefaultstartidle.c +++ b/cpukit/score/src/schedulerdefaultstartidle.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2013-2014 embedded brains GmbH + * 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 diff --git a/cpukit/score/src/scheduleredfsmp.c b/cpukit/score/src/scheduleredfsmp.c index 59b222df74..07b28042d7 100644 --- a/cpukit/score/src/scheduleredfsmp.c +++ b/cpukit/score/src/scheduleredfsmp.c @@ -18,7 +18,7 @@ */ /* - * 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 diff --git a/cpukit/score/src/schedulergetaffinity.c b/cpukit/score/src/schedulergetaffinity.c index dac73c230f..28dc514499 100644 --- a/cpukit/score/src/schedulergetaffinity.c +++ b/cpukit/score/src/schedulergetaffinity.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/schedulerprioritysmp.c b/cpukit/score/src/schedulerprioritysmp.c index 5858c9a910..1d3ed4f110 100644 --- a/cpukit/score/src/schedulerprioritysmp.c +++ b/cpukit/score/src/schedulerprioritysmp.c @@ -21,7 +21,7 @@ */ /* - * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/schedulersetaffinity.c b/cpukit/score/src/schedulersetaffinity.c index 0563e458c0..45b62d7024 100644 --- a/cpukit/score/src/schedulersetaffinity.c +++ b/cpukit/score/src/schedulersetaffinity.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/schedulersimplesmp.c b/cpukit/score/src/schedulersimplesmp.c index 572252c2fa..eed96617b2 100644 --- a/cpukit/score/src/schedulersimplesmp.c +++ b/cpukit/score/src/schedulersimplesmp.c @@ -19,7 +19,7 @@ */ /* - * 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 diff --git a/cpukit/score/src/schedulersmp.c b/cpukit/score/src/schedulersmp.c index 12a9bda454..e26caac3e3 100644 --- a/cpukit/score/src/schedulersmp.c +++ b/cpukit/score/src/schedulersmp.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2014, 2017 embedded brains GmbH. + * 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 diff --git a/cpukit/score/src/schedulersmpstartidle.c b/cpukit/score/src/schedulersmpstartidle.c index 3e1b2d4820..b53a788ba1 100644 --- a/cpukit/score/src/schedulersmpstartidle.c +++ b/cpukit/score/src/schedulersmpstartidle.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2013, 2017 embedded brains GmbH. + * Copyright (C) 2013, 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 diff --git a/cpukit/score/src/schedulerstrongapa.c b/cpukit/score/src/schedulerstrongapa.c index c897652320..b38a0f96f0 100644 --- a/cpukit/score/src/schedulerstrongapa.c +++ b/cpukit/score/src/schedulerstrongapa.c @@ -38,7 +38,7 @@ /* * Copyright (C) 2020 Richi Dubey - * Copyright (C) 2013, 2016 embedded brains GmbH (http://www.embedded-brains.de) + * 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 diff --git a/cpukit/score/src/semaphore.c b/cpukit/score/src/semaphore.c index f5d8b89bce..77b569db3a 100644 --- a/cpukit/score/src/semaphore.c +++ b/cpukit/score/src/semaphore.c @@ -11,7 +11,7 @@ */ /* - * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 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 diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c index 7c068f3c51..75520829e1 100644 --- a/cpukit/score/src/smp.c +++ b/cpukit/score/src/smp.c @@ -311,10 +311,7 @@ void _SMP_Request_shutdown( void ) } } -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 ) { if ( ( message & SMP_MESSAGE_SHUTDOWN ) != 0 ) { ISR_Level level; @@ -332,8 +329,6 @@ long unsigned _SMP_Process_message( if ( ( message & SMP_MESSAGE_PERFORM_JOBS ) != 0 ) { _Per_CPU_Perform_jobs( cpu_self ); } - - return message; } void _SMP_Try_to_process_message( diff --git a/cpukit/score/src/smpbarrierwait.c b/cpukit/score/src/smpbarrierwait.c index c3cf542016..58293dc566 100644 --- a/cpukit/score/src/smpbarrierwait.c +++ b/cpukit/score/src/smpbarrierwait.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/smpbroadcastaction.c b/cpukit/score/src/smpbroadcastaction.c index 767c6d4c7e..9543bbb9cf 100644 --- a/cpukit/score/src/smpbroadcastaction.c +++ b/cpukit/score/src/smpbroadcastaction.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/smplock.c b/cpukit/score/src/smplock.c index c3a41300bb..31d6ea85c5 100644 --- a/cpukit/score/src/smplock.c +++ b/cpukit/score/src/smplock.c @@ -12,7 +12,7 @@ */ /* - * Copyright (c) 2015, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 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 diff --git a/cpukit/score/src/smpmulticastaction.c b/cpukit/score/src/smpmulticastaction.c index b4068c23c9..4eec04c50d 100644 --- a/cpukit/score/src/smpmulticastaction.c +++ b/cpukit/score/src/smpmulticastaction.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/smpothercastaction.c b/cpukit/score/src/smpothercastaction.c index 4279c4bf54..d4696a78c6 100644 --- a/cpukit/score/src/smpothercastaction.c +++ b/cpukit/score/src/smpothercastaction.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/smpsynchronize.c b/cpukit/score/src/smpsynchronize.c index d01a15cb28..540156af10 100644 --- a/cpukit/score/src/smpsynchronize.c +++ b/cpukit/score/src/smpsynchronize.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/smpunicastaction.c b/cpukit/score/src/smpunicastaction.c index fa5b5bb7c6..2fb06b84ae 100644 --- a/cpukit/score/src/smpunicastaction.c +++ b/cpukit/score/src/smpunicastaction.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/stackallocator.c b/cpukit/score/src/stackallocator.c index 920aee86c1..a0d0f4802a 100644 --- a/cpukit/score/src/stackallocator.c +++ b/cpukit/score/src/stackallocator.c @@ -11,7 +11,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/stackallocatorforidle.c b/cpukit/score/src/stackallocatorforidle.c index 76b6ace1f4..c8c8c0b766 100644 --- a/cpukit/score/src/stackallocatorforidle.c +++ b/cpukit/score/src/stackallocatorforidle.c @@ -1,6 +1,15 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreStack * + * @brief This source file contains the implementation of + * _Stack_Allocator_allocate_for_idle_static(). + */ + +/* * Copyright (C) 2021 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without @@ -30,36 +39,21 @@ #endif #include <rtems/score/stack.h> -#include <rtems/score/thread.h> #include <rtems/score/assert.h> -/** - * @brief Default stack allocator allocate for idle handler. - * - * The allocate for idle handler is optional even when the user thread stack - * allocator and deallocator are configured. - * - * The default allocator for IDLE thread stacks gets the memory from a - * statically allocated area provided via confdefs.h. - * - * @param cpu_index Index of the CPU for the IDLE thread using this stack - * @param stack_size The size of the stack area to allocate in bytes. - * - * @retval NULL Not enough memory (never returned). - * @retval other Pointer to begin of stack area. - */ -static void *_Stack_Allocator_allocate_for_idle_default( +void *_Stack_Allocator_allocate_for_idle_static( uint32_t cpu_index, - size_t stack_size + size_t *storage_size ) { + size_t size; + + size = _Stack_Allocator_allocate_for_idle_storage_size; + *storage_size = size; #if defined(RTEMS_SMP) - return &_Thread_Idle_stacks[ cpu_index * stack_size ]; + return &_Stack_Allocator_allocate_for_idle_storage_areas[ cpu_index * size ]; #else _Assert( cpu_index == 0 ); - return &_Thread_Idle_stacks[ 0 ]; + return &_Stack_Allocator_allocate_for_idle_storage_areas[ 0 ]; #endif } - -const Stack_Allocator_allocate_for_idle _Stack_Allocator_allocate_for_idle = - _Stack_Allocator_allocate_for_idle_default; diff --git a/cpukit/score/src/pheapgetblocksize.c b/cpukit/score/src/stackallocatorforidlewkspace.c index c53a66b5d4..c57f245407 100644 --- a/cpukit/score/src/pheapgetblocksize.c +++ b/cpukit/score/src/stackallocatorforidlewkspace.c @@ -3,15 +3,14 @@ /** * @file * - * @ingroup RTEMSScoreProtHeap + * @ingroup RTEMSScoreStack * * @brief This source file contains the implementation of - * _Protected_heap_Get_block_size(). + * _Stack_Allocator_allocate_for_idle_workspace(). */ /* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 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 @@ -39,18 +38,23 @@ #include "config.h" #endif -#include <rtems/score/protectedheap.h> +#include <rtems/score/stack.h> +#include <rtems/score/interr.h> +#include <rtems/score/wkspace.h> -bool _Protected_heap_Get_block_size( - Heap_Control *the_heap, - void *starting_address, - uintptr_t *size +void *_Stack_Allocator_allocate_for_idle_workspace( + uint32_t unused, + size_t *storage_size ) { - bool status; + void *area; - _RTEMS_Lock_allocator(); - status = _Heap_Size_of_alloc_area( the_heap, starting_address, size ); - _RTEMS_Unlock_allocator(); - return status; + (void) unused; + area = _Workspace_Allocate( *storage_size ); + + if ( area == NULL ) { + _Internal_error( INTERNAL_ERROR_NO_MEMORY_FOR_IDLE_TASK_STORAGE ); + } + + return area; } diff --git a/cpukit/score/src/stackallocatorfree.c b/cpukit/score/src/stackallocatorfree.c index f32912ea9c..54f76e313f 100644 --- a/cpukit/score/src/stackallocatorfree.c +++ b/cpukit/score/src/stackallocatorfree.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019 embedded brains GmbH + * Copyright (C) 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/score/src/stackallocatorinit.c b/cpukit/score/src/stackallocatorinit.c index a57a253301..8f2512bee7 100644 --- a/cpukit/score/src/stackallocatorinit.c +++ b/cpukit/score/src/stackallocatorinit.c @@ -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/score/src/threadallocateunlimited.c b/cpukit/score/src/threadallocateunlimited.c index 6bd3b3ec7a..48e69822a7 100644 --- a/cpukit/score/src/threadallocateunlimited.c +++ b/cpukit/score/src/threadallocateunlimited.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2019, 2020 embedded brains GmbH + * Copyright (C) 2019, 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/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c index 0ddfd1cf9b..78291b7798 100644 --- a/cpukit/score/src/threadchangepriority.c +++ b/cpukit/score/src/threadchangepriority.c @@ -16,7 +16,7 @@ * COPYRIGHT (c) 1989-2014. * 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 @@ -111,6 +111,7 @@ static void _Thread_Priority_action_change( void *arg ) { + (void) arg; _Thread_Set_scheduler_node_priority( priority_aggregation, priority_group_order diff --git a/cpukit/score/src/threadcreateidle.c b/cpukit/score/src/threadcreateidle.c index b5e0cfdc9b..4f16a57099 100644 --- a/cpukit/score/src/threadcreateidle.c +++ b/cpukit/score/src/threadcreateidle.c @@ -39,18 +39,24 @@ #include "config.h" #endif -#include <rtems/score/threadidledata.h> -#include <rtems/score/cpuimpl.h> #include <rtems/score/threadimpl.h> + #include <rtems/score/assert.h> +#include <rtems/score/cpuimpl.h> +#include <rtems/score/interr.h> #include <rtems/score/schedulerimpl.h> #include <rtems/score/stackimpl.h> #include <rtems/score/sysstate.h> +#include <rtems/score/threadidledata.h> +#include <rtems/score/tls.h> #include <rtems/score/userextimpl.h> #include <string.h> -static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu ) +static void _Thread_Create_idle_for_CPU( + Per_CPU_Control *cpu, + uintptr_t storage_size +) { Thread_Configuration config; Thread_Control *idle; @@ -66,18 +72,22 @@ static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu ) config.name = _Objects_Build_name( 'I', 'D', 'L', 'E' ); config.is_fp = CPU_IDLE_TASK_IS_FP; config.is_preemptible = true; - config.stack_size = _Thread_Idle_stack_size - + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE; + config.stack_free = _Objects_Free_nothing; + config.stack_size = storage_size; /* * The IDLE thread stacks may be statically allocated or there may be a * custom allocator provided just as with user threads. */ - config.stack_area = (*_Stack_Allocator_allocate_for_idle)( + config.stack_area = ( *_Stack_Allocator_allocate_for_idle )( _Per_CPU_Get_index( cpu ), - config.stack_size + &config.stack_size ); + if ( config.stack_size < storage_size ) { + _Internal_error( INTERNAL_ERROR_IDLE_THREAD_STACK_TOO_SMALL ); + } + /* * The entire workspace is zeroed during its initialization. Thus, all * fields not explicitly assigned were explicitly zeroed by @@ -87,13 +97,15 @@ static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu ) _Assert( idle != NULL ); status = _Thread_Initialize( &_Thread_Information, idle, &config ); - _Assert_Unused_variable_equals( status, STATUS_SUCCESSFUL ); + if ( status != STATUS_SUCCESSFUL ) { + _Internal_error( INTERNAL_ERROR_IDLE_THREAD_CREATE_FAILED ); + } /* * WARNING!!! This is necessary to "kick" start the system and * MUST be done before _Thread_Start is invoked. */ - cpu->heir = + cpu->heir = idle; cpu->executing = idle; #if defined(RTEMS_SMP) cpu->ancestor = idle; @@ -112,21 +124,28 @@ static void _Thread_Create_idle_for_CPU( Per_CPU_Control *cpu ) void _Thread_Create_idle( void ) { + uintptr_t storage_size; #if defined(RTEMS_SMP) - uint32_t cpu_max; - uint32_t cpu_index; + uint32_t cpu_max; + uint32_t cpu_index; +#endif + storage_size = _TLS_Get_allocation_size() + + CPU_IDLE_TASK_IS_FP * CONTEXT_FP_SIZE + + _Thread_Idle_stack_size; + +#if defined(RTEMS_SMP) cpu_max = _SMP_Get_processor_maximum(); for ( cpu_index = 0 ; cpu_index < cpu_max ; ++cpu_index ) { Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index ); if ( _Per_CPU_Is_processor_online( cpu ) ) { - _Thread_Create_idle_for_CPU( cpu ); + _Thread_Create_idle_for_CPU( cpu, storage_size ); } } #else - _Thread_Create_idle_for_CPU( _Per_CPU_Get() ); + _Thread_Create_idle_for_CPU( _Per_CPU_Get(), storage_size ); #endif _CPU_Use_thread_local_storage( diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c index b2426fa8ac..7c3326803c 100644 --- a/cpukit/score/src/threaddispatch.c +++ b/cpukit/score/src/threaddispatch.c @@ -15,7 +15,7 @@ * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2014, 2018 embedded brains GmbH. + * 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 @@ -301,12 +301,13 @@ void _Thread_Do_dispatch( Per_CPU_Control *cpu_self, ISR_Level level ) heir = _Thread_Get_heir_and_make_it_executing( cpu_self ); /* - * When the heir and executing are the same, then we are being - * requested to do the post switch dispatching. This is normally - * done to dispatch signals. + * If the heir and executing are the same, then there is no need to do a + * context switch. Proceed to run the post switch actions. This is + * normally done to dispatch signals. */ - if ( heir == executing ) - goto post_switch; + if ( heir == executing ) { + break; + } /* * Since heir and executing are not the same, we need to do a real @@ -341,7 +342,11 @@ void _Thread_Do_dispatch( Per_CPU_Control *cpu_self, ISR_Level level ) _ISR_Local_disable( level ); } while ( cpu_self->dispatch_necessary ); -post_switch: + /* + * We are done with context switching. Proceed to run the post switch + * actions. + */ + _Assert( cpu_self->thread_dispatch_disable_level == 1 ); cpu_self->thread_dispatch_disable_level = 0; _Profiling_Thread_dispatch_enable( cpu_self, 0 ); diff --git a/cpukit/score/src/threadentryadaptoridle.c b/cpukit/score/src/threadentryadaptoridle.c index f2fb21b901..912e6c5187 100644 --- a/cpukit/score/src/threadentryadaptoridle.c +++ b/cpukit/score/src/threadentryadaptoridle.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * Copyright (c) 2015 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/score/src/threadentryadaptornumeric.c b/cpukit/score/src/threadentryadaptornumeric.c index 8fbc4f04dc..a0499eb7ce 100644 --- a/cpukit/score/src/threadentryadaptornumeric.c +++ b/cpukit/score/src/threadentryadaptornumeric.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * Copyright (c) 2015 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/score/src/threadentryadaptorpointer.c b/cpukit/score/src/threadentryadaptorpointer.c index 99a758a2e0..3b431ca95a 100644 --- a/cpukit/score/src/threadentryadaptorpointer.c +++ b/cpukit/score/src/threadentryadaptorpointer.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * Copyright (c) 2015 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/score/src/threadexhausttimeslice.c b/cpukit/score/src/threadexhausttimeslice.c index f3f6924e44..4e7503bee6 100644 --- a/cpukit/score/src/threadexhausttimeslice.c +++ b/cpukit/score/src/threadexhausttimeslice.c @@ -11,7 +11,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/score/src/threadgetcputimeused.c b/cpukit/score/src/threadgetcputimeused.c index cefd0f2910..82ad7a3043 100644 --- a/cpukit/score/src/threadgetcputimeused.c +++ b/cpukit/score/src/threadgetcputimeused.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/threadgetcputimeusedafterreset.c b/cpukit/score/src/threadgetcputimeusedafterreset.c index 1ab4aa16fb..40c5d01cc3 100644 --- a/cpukit/score/src/threadgetcputimeusedafterreset.c +++ b/cpukit/score/src/threadgetcputimeusedafterreset.c @@ -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/score/src/threadidledefault.c b/cpukit/score/src/threadidledefault.c index 2386c0317d..bb9d476018 100644 --- a/cpukit/score/src/threadidledefault.c +++ b/cpukit/score/src/threadidledefault.c @@ -10,7 +10,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/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index 9b37206c6d..e1a6c7de93 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -139,7 +139,10 @@ static void _Thread_Initialize_scheduler_and_wait_nodes( * The application configuration ensures that we have at least one scheduler * configured. */ - while ( scheduler_index < _Scheduler_Count ) { + + _Assert ( _Scheduler_Count >= 1 ); + + do { Priority_Control priority; if ( scheduler == config->scheduler ) { @@ -172,7 +175,7 @@ static void _Thread_Initialize_scheduler_and_wait_nodes( ( (uintptr_t) scheduler_node + _Scheduler_Node_size ); ++scheduler; ++scheduler_index; - } + } while ( scheduler_index < _Scheduler_Count ); /* * The thread is initialized to use exactly one scheduler node which is @@ -267,12 +270,8 @@ static bool _Thread_Try_initialize( /* Allocate thread-local storage (TLS) area in stack area */ if ( tls_size > 0 ) { - uintptr_t tls_align; - stack_end -= tls_size; - tls_align = (uintptr_t) _TLS_Alignment; - the_thread->Start.tls_area = (void *) - ( ( (uintptr_t) stack_end + tls_align - 1 ) & ~( tls_align - 1 ) ); + the_thread->Start.tls_area = stack_end; } _Stack_Initialize( diff --git a/cpukit/score/src/threaditerate.c b/cpukit/score/src/threaditerate.c index b82c87ba47..c0a54340e0 100644 --- a/cpukit/score/src/threaditerate.c +++ b/cpukit/score/src/threaditerate.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/threadname.c b/cpukit/score/src/threadname.c index 465f1871fb..55a67e5b6d 100644 --- a/cpukit/score/src/threadname.c +++ b/cpukit/score/src/threadname.c @@ -10,7 +10,7 @@ */ /* - * 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 diff --git a/cpukit/score/src/threadplaindispatch.c b/cpukit/score/src/threadplaindispatch.c index eeb52ec42d..5eca17351f 100644 --- a/cpukit/score/src/threadplaindispatch.c +++ b/cpukit/score/src/threadplaindispatch.c @@ -7,7 +7,7 @@ */ /* - * Copyright (C) 2015, 2017 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2015, 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 diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c index e694029a46..3c6d72bd14 100644 --- a/cpukit/score/src/threadq.c +++ b/cpukit/score/src/threadq.c @@ -179,5 +179,7 @@ void _Thread_queue_MP_callout_do_nothing( ) { /* Do nothing */ + (void) the_proxy; + (void) mp_id; } #endif diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c index 462cb3719a..038c483f65 100644 --- a/cpukit/score/src/threadqenqueue.c +++ b/cpukit/score/src/threadqenqueue.c @@ -19,7 +19,7 @@ * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2015, 2016 embedded brains GmbH. + * Copyright (C) 2015, 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 @@ -400,6 +400,7 @@ void _Thread_queue_Deadlock_status( Thread_Control *the_thread ) void _Thread_queue_Deadlock_fatal( Thread_Control *the_thread ) { + (void) the_thread; _Internal_error( INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK ); } diff --git a/cpukit/score/src/threadqextract.c b/cpukit/score/src/threadqextract.c index e08b902508..32985a0f3a 100644 --- a/cpukit/score/src/threadqextract.c +++ b/cpukit/score/src/threadqextract.c @@ -13,7 +13,7 @@ * COPYRIGHT (c) 1989-2014. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2015, 2016 embedded brains GmbH. + * Copyright (C) 2015, 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 diff --git a/cpukit/score/src/threadqgetnameandid.c b/cpukit/score/src/threadqgetnameandid.c index ea4e2203e6..82c13c4633 100644 --- a/cpukit/score/src/threadqgetnameandid.c +++ b/cpukit/score/src/threadqgetnameandid.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2017 embedded brains GmbH (http://www.embedded-brains.de) + * 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 diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c index fbea9f6de6..9a09b4c442 100644 --- a/cpukit/score/src/threadqops.c +++ b/cpukit/score/src/threadqops.c @@ -12,7 +12,7 @@ */ /* - * Copyright (c) 2015, 2021 embedded brains GmbH. All rights reserved. + * 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 @@ -156,6 +156,8 @@ static void _Thread_queue_FIFO_do_initialize( { Scheduler_Node *scheduler_node; + (void) queue; + (void) queue_context; scheduler_node = _Thread_Scheduler_get_home_node( the_thread ); _Chain_Initialize_node( &scheduler_node->Wait.Priority.Node.Node.Chain ); @@ -291,6 +293,7 @@ static Thread_queue_Priority_queue *_Thread_queue_Priority_queue_by_index( ) { #if defined(RTEMS_SMP) + _Assert( scheduler_index < _Scheduler_Count ); return &heads->Priority[ scheduler_index ]; #else (void) scheduler_index; diff --git a/cpukit/score/src/threadqtimeout.c b/cpukit/score/src/threadqtimeout.c index 10e194f6d8..e30a2ffded 100644 --- a/cpukit/score/src/threadqtimeout.c +++ b/cpukit/score/src/threadqtimeout.c @@ -12,7 +12,7 @@ */ /* - * Copyright (c) 2016, 2021 embedded brains GmbH + * Copyright (C) 2016, 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 @@ -53,6 +53,7 @@ void _Thread_queue_Add_timeout_ticks( { Watchdog_Interval ticks; + (void) queue; ticks = queue_context->Timeout.ticks; if ( ticks != WATCHDOG_NO_TIMEOUT ) { diff --git a/cpukit/score/src/threadresettimeslice.c b/cpukit/score/src/threadresettimeslice.c index ed4d6fb3e3..4697ef74de 100644 --- a/cpukit/score/src/threadresettimeslice.c +++ b/cpukit/score/src/threadresettimeslice.c @@ -12,7 +12,7 @@ */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2021 embedded brains GmbH & Co. KG * Copyright (C) 2010 Gedare Bloom <gedare@rtems.org> * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index 635143427c..72326682ca 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -14,7 +14,7 @@ * COPYRIGHT (c) 1989-1999. * On-Line Applications Research Corporation (OAR). * - * Copyright (C) 2014, 2022 embedded brains GmbH + * 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 @@ -46,10 +46,8 @@ #include <rtems/score/apimutex.h> #include <rtems/score/assert.h> #include <rtems/score/chainimpl.h> -#include <rtems/score/freechainimpl.h> #include <rtems/score/isrlock.h> #include <rtems/score/schedulerimpl.h> -#include <rtems/score/stackimpl.h> #include <rtems/score/sysstate.h> #include <rtems/score/threadqimpl.h> #include <rtems/score/userextimpl.h> @@ -85,6 +83,7 @@ static Thread_Control *_Thread_Join_flush_filter( { Thread_Join_context *join_context; + (void) queue; join_context = (Thread_Join_context *) queue_context; the_thread->Wait.return_argument = join_context->exit_value; diff --git a/cpukit/score/src/threadscheduler.c b/cpukit/score/src/threadscheduler.c index ba4c3ca6f0..6e5812e1ce 100644 --- a/cpukit/score/src/threadscheduler.c +++ b/cpukit/score/src/threadscheduler.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/threadselfid.c b/cpukit/score/src/threadselfid.c index a8b4315f27..ee802c7444 100644 --- a/cpukit/score/src/threadselfid.c +++ b/cpukit/score/src/threadselfid.c @@ -9,7 +9,7 @@ */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2021 embedded brains GmbH & Co. KG * Copyright (C) 1995 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without diff --git a/cpukit/score/src/threadunpin.c b/cpukit/score/src/threadunpin.c index ce97fb14bc..e8ebcbd45b 100644 --- a/cpukit/score/src/threadunpin.c +++ b/cpukit/score/src/threadunpin.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2018 embedded brains GmbH + * Copyright (c) 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 diff --git a/cpukit/score/src/threadwaitgetid.c b/cpukit/score/src/threadwaitgetid.c index 4e6649dc9c..433755f930 100644 --- a/cpukit/score/src/threadwaitgetid.c +++ b/cpukit/score/src/threadwaitgetid.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2016, 2017 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/threadyield.c b/cpukit/score/src/threadyield.c index 144b734436..3cc2f07caf 100644 --- a/cpukit/score/src/threadyield.c +++ b/cpukit/score/src/threadyield.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 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 diff --git a/cpukit/score/src/tlsallocsize.c b/cpukit/score/src/tlsallocsize.c index d761f3b6cf..fa28391b83 100644 --- a/cpukit/score/src/tlsallocsize.c +++ b/cpukit/score/src/tlsallocsize.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de) + * 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 @@ -42,14 +42,47 @@ #include <rtems/score/interr.h> #include <rtems/score/thread.h> +extern char _TLS_Data_begin[]; + +extern char _TLS_Data_size[]; + +extern char _TLS_BSS_begin[]; + +extern char _TLS_BSS_size[]; + +extern char _TLS_Size[]; + +/** + * @brief The TLS section alignment. + * + * 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. + */ +extern char _TLS_Alignment[]; + +const volatile TLS_Configuration _TLS_Configuration = { + .data_begin = _TLS_Data_begin, + .data_size = _TLS_Data_size, + .bss_begin = _TLS_BSS_begin, + .bss_size = _TLS_BSS_size, + .size = _TLS_Size, + .alignment = _TLS_Alignment +}; + static uintptr_t _TLS_Allocation_size; uintptr_t _TLS_Get_allocation_size( void ) { - uintptr_t size; - uintptr_t allocation_size; + const volatile TLS_Configuration *config; + uintptr_t size; + uintptr_t allocation_size; - size = _TLS_Get_size(); + config = &_TLS_Configuration; + size = (uintptr_t) config->size; if ( size == 0 ) { return 0; @@ -58,29 +91,45 @@ uintptr_t _TLS_Get_allocation_size( void ) allocation_size = _TLS_Allocation_size; if ( allocation_size == 0 ) { - uintptr_t alignment; - - alignment = _TLS_Align_up( (uintptr_t) _TLS_Alignment ); - - allocation_size = size; - allocation_size += _TLS_Get_thread_control_block_area_size( alignment ); -#ifndef __i386__ - allocation_size += sizeof( TLS_Dynamic_thread_vector ); -#endif + uintptr_t tls_align; + uintptr_t stack_align; /* * The TLS area is allocated in the thread storage area. Each allocation * shall meet the stack alignment requirement. */ - allocation_size = _TLS_Align_up( allocation_size ); + stack_align = CPU_STACK_ALIGNMENT; + tls_align = RTEMS_ALIGN_UP( (uintptr_t) config->alignment, stack_align ); + +#ifndef __i386__ + /* Reserve space for the dynamic thread vector */ + allocation_size += + RTEMS_ALIGN_UP( sizeof( TLS_Dynamic_thread_vector ), stack_align ); +#endif + + /* Reserve space for the thread control block */ + allocation_size += +#if CPU_THREAD_LOCAL_STORAGE_VARIANT == 11 + RTEMS_ALIGN_UP( sizeof( TLS_Thread_control_block ), tls_align ); +#else + RTEMS_ALIGN_UP( sizeof( TLS_Thread_control_block ), stack_align ); +#endif + + /* Reserve space for the thread-local storage data */ + allocation_size += +#if CPU_THREAD_LOCAL_STORAGE_VARIANT == 20 + RTEMS_ALIGN_UP( size, tls_align ); +#else + RTEMS_ALIGN_UP( size, stack_align ); +#endif /* * The stack allocator does not support aligned allocations. Allocate * enough to do the alignment manually. */ - if ( alignment > CPU_STACK_ALIGNMENT ) { - _Assert( alignment % CPU_STACK_ALIGNMENT == 0 ); - allocation_size += alignment - CPU_STACK_ALIGNMENT; + if ( tls_align > stack_align ) { + _Assert( tls_align % stack_align == 0 ); + allocation_size += tls_align - stack_align; } if ( _Thread_Maximum_TLS_size != 0 ) { diff --git a/cpukit/score/src/userextiterate.c b/cpukit/score/src/userextiterate.c index 5808c4a728..cae76d173c 100644 --- a/cpukit/score/src/userextiterate.c +++ b/cpukit/score/src/userextiterate.c @@ -17,7 +17,7 @@ */ /* - * Copyright (c) 2012, 2019 embedded brains GmbH. All rights reserved. + * Copyright (C) 2012, 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 @@ -47,8 +47,6 @@ #include <rtems/score/userextimpl.h> -#include <pthread.h> - User_extensions_List _User_extensions_List = { CHAIN_INITIALIZER_EMPTY( _User_extensions_List.Active ), CHAIN_ITERATOR_REGISTRY_INITIALIZER( _User_extensions_List.Iterators ) @@ -120,6 +118,8 @@ void _User_extensions_Thread_begin_visitor( { User_extensions_thread_begin_extension callout = callouts->thread_begin; + (void) arg; + if ( callout != NULL ) { (*callout)( executing ); } diff --git a/cpukit/score/src/watchdoginsert.c b/cpukit/score/src/watchdoginsert.c index f75a28b15d..9d07fa01ed 100644 --- a/cpukit/score/src/watchdoginsert.c +++ b/cpukit/score/src/watchdoginsert.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/watchdogremove.c b/cpukit/score/src/watchdogremove.c index d264f793bb..1cb3450a02 100644 --- a/cpukit/score/src/watchdogremove.c +++ b/cpukit/score/src/watchdogremove.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * 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 diff --git a/cpukit/score/src/watchdogtick.c b/cpukit/score/src/watchdogtick.c index 71311b598e..695fee7e0f 100644 --- a/cpukit/score/src/watchdogtick.c +++ b/cpukit/score/src/watchdogtick.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2015, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 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 diff --git a/cpukit/score/src/watchdogtimeslicedefault.c b/cpukit/score/src/watchdogtimeslicedefault.c index 56f6bdb5d5..4b6adf6cba 100644 --- a/cpukit/score/src/watchdogtimeslicedefault.c +++ b/cpukit/score/src/watchdogtimeslicedefault.c @@ -10,7 +10,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/score/src/wkspace.c b/cpukit/score/src/wkspace.c index 5b8c980384..3309658dff 100644 --- a/cpukit/score/src/wkspace.c +++ b/cpukit/score/src/wkspace.c @@ -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/score/src/wkspaceisunifieddefault.c b/cpukit/score/src/wkspaceisunifieddefault.c index db38c968b7..ee1cdf1676 100644 --- a/cpukit/score/src/wkspaceisunifieddefault.c +++ b/cpukit/score/src/wkspaceisunifieddefault.c @@ -10,7 +10,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/score/src/wkspacemallocinitdefault.c b/cpukit/score/src/wkspacemallocinitdefault.c index 6ee951cff1..42f4b5c68b 100644 --- a/cpukit/score/src/wkspacemallocinitdefault.c +++ b/cpukit/score/src/wkspacemallocinitdefault.c @@ -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/score/src/wkspacemallocinitunified.c b/cpukit/score/src/wkspacemallocinitunified.c index d21ef22d19..a35ee73175 100644 --- a/cpukit/score/src/wkspacemallocinitunified.c +++ b/cpukit/score/src/wkspacemallocinitunified.c @@ -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/score/src/wkstringduplicate.c b/cpukit/score/src/wkstringduplicate.c index b8111e1fa7..63ab8c240f 100644 --- a/cpukit/score/src/wkstringduplicate.c +++ b/cpukit/score/src/wkstringduplicate.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * Copyright (c) 2011 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions |