Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSImplApplConfig
0007  *
0008  * @brief This header file evaluates configuration options related to the
0009  *   Classic API initialization task configuration.
0010  *
0011  * This header file defines _CONFIGURE_INIT_TASK_STACK_EXTRA for use by other
0012  * configuration header files.
0013  */
0014 
0015 /*
0016  * Copyright (C) 2020 embedded brains GmbH & Co. KG
0017  *
0018  * Redistribution and use in source and binary forms, with or without
0019  * modification, are permitted provided that the following conditions
0020  * are met:
0021  * 1. Redistributions of source code must retain the above copyright
0022  *    notice, this list of conditions and the following disclaimer.
0023  * 2. Redistributions in binary form must reproduce the above copyright
0024  *    notice, this list of conditions and the following disclaimer in the
0025  *    documentation and/or other materials provided with the distribution.
0026  *
0027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0037  * POSSIBILITY OF SUCH DAMAGE.
0038  */
0039 
0040 #ifndef _RTEMS_CONFDEFS_INITTASK_H
0041 #define _RTEMS_CONFDEFS_INITTASK_H
0042 
0043 #ifndef __CONFIGURATION_TEMPLATE_h
0044 #error "Do not include this file directly, use <rtems/confdefs.h> instead"
0045 #endif
0046 
0047 #ifdef CONFIGURE_INIT
0048 
0049 #define _CONFIGURE_ASSERT_NOT_NULL( _type, _value ) \
0050   ( ( _value ) != NULL ? ( _value ) : \
0051     ( _type ) sizeof( int[ ( _value ) != NULL ? 1 : -1 ] ) )
0052 
0053 #ifdef CONFIGURE_RTEMS_INIT_TASKS_TABLE
0054 
0055 #include <rtems/confdefs/percpu.h>
0056 #include <rtems/confdefs/threads.h>
0057 #include <rtems/rtems/object.h>
0058 #include <rtems/rtems/tasksdata.h>
0059 #include <rtems/sysinit.h>
0060 
0061 #ifndef CONFIGURE_INIT_TASK_ATTRIBUTES
0062   #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES
0063 #endif
0064 
0065 #ifndef CONFIGURE_INIT_TASK_INITIAL_MODES
0066   #ifdef RTEMS_SMP
0067     #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
0068   #else
0069     #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_NO_PREEMPT
0070   #endif
0071 #endif
0072 
0073 #ifndef CONFIGURE_INIT_TASK_NAME
0074   #define CONFIGURE_INIT_TASK_NAME rtems_build_name( 'U', 'I', '1', ' ' )
0075 #endif
0076 
0077 #ifndef CONFIGURE_INIT_TASK_PRIORITY
0078   #define CONFIGURE_INIT_TASK_PRIORITY 1
0079 #endif
0080 
0081 #ifdef __cplusplus
0082 extern "C" {
0083 #endif
0084 
0085 #ifndef CONFIGURE_INIT_TASK_ENTRY_POINT
0086   rtems_task Init( rtems_task_argument );
0087   #define CONFIGURE_INIT_TASK_ENTRY_POINT Init
0088 
0089   #ifndef CONFIGURE_INIT_TASK_ARGUMENTS
0090     extern const char *bsp_boot_cmdline;
0091     #define CONFIGURE_INIT_TASK_ARGUMENTS \
0092       ( (rtems_task_argument) &bsp_boot_cmdline )
0093   #endif
0094 #endif
0095 
0096 #ifndef CONFIGURE_INIT_TASK_ARGUMENTS
0097   #define CONFIGURE_INIT_TASK_ARGUMENTS 0
0098 #endif
0099 
0100 /*
0101  * Ignore the following warnings from g++ and clang in the uses of
0102  * _CONFIGURE_ASSERT_NOT_NULL() below:
0103  *
0104  * warning: the address of 'void Init()' will never be NULL [-Waddress]
0105  *
0106  * warning: comparison of function 'Init' not equal to a null pointer is always
0107  * true [-Wtautological-pointer-compare]
0108  */
0109 #pragma GCC diagnostic push
0110 #pragma GCC diagnostic ignored "-Waddress"
0111 #pragma GCC diagnostic ignored "-Wpragmas"
0112 #pragma GCC diagnostic ignored "-Wtautological-pointer-compare"
0113 
0114 #ifdef CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE
0115 
0116 #ifdef CONFIGURE_INIT_TASK_STACK_SIZE
0117   #error "CONFIGURE_INIT_TASK_STACK_SIZE and CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE are mutually exclusive"
0118 #endif
0119 
0120 RTEMS_STATIC_ASSERT(
0121   CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE >= CONFIGURE_MINIMUM_TASK_STACK_SIZE,
0122   CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE_IS_TOO_SMALL
0123 );
0124 
0125 static RTEMS_SECTION( ".rtemsstack.userinit" )
0126 RTEMS_ALIGNED( RTEMS_TASK_STORAGE_ALIGNMENT )
0127 char _RTEMS_tasks_User_task_storage[ CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE ];
0128 
0129 const RTEMS_tasks_User_task_config _RTEMS_tasks_User_task_config = {
0130   {
0131     CONFIGURE_INIT_TASK_NAME,
0132     CONFIGURE_INIT_TASK_PRIORITY,
0133     _RTEMS_tasks_User_task_storage,
0134     sizeof( _RTEMS_tasks_User_task_storage ),
0135     CONFIGURE_MAXIMUM_THREAD_LOCAL_STORAGE_SIZE,
0136     NULL,
0137     CONFIGURE_INIT_TASK_INITIAL_MODES,
0138     CONFIGURE_INIT_TASK_ATTRIBUTES,
0139   },
0140   _CONFIGURE_ASSERT_NOT_NULL(
0141     rtems_task_entry,
0142     CONFIGURE_INIT_TASK_ENTRY_POINT
0143   ),
0144   CONFIGURE_INIT_TASK_ARGUMENTS
0145 };
0146 
0147 RTEMS_SYSINIT_ITEM(
0148   _RTEMS_tasks_Construct_user_task,
0149   RTEMS_SYSINIT_CLASSIC_USER_TASKS,
0150   RTEMS_SYSINIT_ORDER_MIDDLE
0151 );
0152 
0153 #else /* CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE */
0154 
0155 #ifndef CONFIGURE_INIT_TASK_STACK_SIZE
0156   #define CONFIGURE_INIT_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE
0157 #elif CONFIGURE_INIT_TASK_STACK_SIZE < CONFIGURE_MINIMUM_TASK_STACK_SIZE
0158   #error "CONFIGURE_INIT_TASK_STACK_SIZE must be greater than or equal to CONFIGURE_MINIMUM_TASK_STACK_SIZE"
0159 #endif
0160 
0161 #if CONFIGURE_INIT_TASK_STACK_SIZE > CONFIGURE_MINIMUM_TASK_STACK_SIZE
0162   #define _CONFIGURE_INIT_TASK_STACK_EXTRA \
0163     ( CONFIGURE_INIT_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE )
0164 #endif
0165 
0166 const rtems_initialization_tasks_table _RTEMS_tasks_User_task_table = {
0167   CONFIGURE_INIT_TASK_NAME,
0168   CONFIGURE_INIT_TASK_STACK_SIZE,
0169   CONFIGURE_INIT_TASK_PRIORITY,
0170   CONFIGURE_INIT_TASK_ATTRIBUTES,
0171   _CONFIGURE_ASSERT_NOT_NULL(
0172     rtems_task_entry,
0173     CONFIGURE_INIT_TASK_ENTRY_POINT
0174   ),
0175   CONFIGURE_INIT_TASK_INITIAL_MODES,
0176   CONFIGURE_INIT_TASK_ARGUMENTS
0177 };
0178 
0179 RTEMS_SYSINIT_ITEM(
0180   _RTEMS_tasks_Initialize_user_task,
0181   RTEMS_SYSINIT_CLASSIC_USER_TASKS,
0182   RTEMS_SYSINIT_ORDER_MIDDLE
0183 );
0184 
0185 #endif /* CONFIGURE_INIT_TASK_CONSTRUCT_STORAGE_SIZE */
0186 
0187 #pragma GCC diagnostic pop
0188 
0189 #ifdef __cplusplus
0190 }
0191 #endif
0192 
0193 #endif /* CONFIGURE_RTEMS_INIT_TASKS_TABLE */
0194 
0195 #ifndef _CONFIGURE_INIT_TASK_STACK_EXTRA
0196   #define _CONFIGURE_INIT_TASK_STACK_EXTRA 0
0197 #endif
0198 
0199 #endif /* CONFIGURE_INIT */
0200 
0201 #endif /* _RTEMS_CONFDEFS_INITTASK_H */