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 user
0009  *   extensions configuration.
0010  */
0011 
0012 /*
0013  * Copyright (C) 2024 Mohamed Hassan <muhammad.hamdy.hassan@gmail.com>
0014  * Copyright (C) 2020 embedded brains GmbH & Co. KG
0015  *
0016  * Redistribution and use in source and binary forms, with or without
0017  * modification, are permitted provided that the following conditions
0018  * are met:
0019  * 1. Redistributions of source code must retain the above copyright
0020  *    notice, this list of conditions and the following disclaimer.
0021  * 2. Redistributions in binary form must reproduce the above copyright
0022  *    notice, this list of conditions and the following disclaimer in the
0023  *    documentation and/or other materials provided with the distribution.
0024  *
0025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0026  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0028  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0029  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0030  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0031  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0032  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0033  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0034  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0035  * POSSIBILITY OF SUCH DAMAGE.
0036  */
0037 
0038 #ifndef _RTEMS_CONFDEFS_EXTENSIONS_H
0039 #define _RTEMS_CONFDEFS_EXTENSIONS_H
0040 
0041 #ifndef __CONFIGURATION_TEMPLATE_h
0042 #error "Do not include this file directly, use <rtems/confdefs.h> instead"
0043 #endif
0044 
0045 #ifdef CONFIGURE_INIT
0046 
0047 #include <rtems/confdefs/bsp.h>
0048 #include <rtems/confdefs/newlib.h>
0049 #include <rtems/score/userextimpl.h>
0050 #include <rtems/sysinit.h>
0051 
0052 #ifndef CONFIGURE_MAXIMUM_USER_EXTENSIONS
0053   #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 0
0054 #endif
0055 
0056 #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
0057   #include <rtems/extensiondata.h>
0058 #endif
0059 
0060 #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY
0061   #include <rtems/libcsupport.h>
0062 #endif
0063 
0064 #if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS > 0
0065   #if (CONFIGURE_RECORD_PER_PROCESSOR_ITEMS & (CONFIGURE_RECORD_PER_PROCESSOR_ITEMS - 1)) != 0
0066     #error "CONFIGURE_RECORD_PER_PROCESSOR_ITEMS must be a power of two"
0067   #endif
0068 
0069   #if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS < 16
0070     #error "CONFIGURE_RECORD_PER_PROCESSOR_ITEMS must be at least 16"
0071   #endif
0072 
0073   #if defined(CONFIGURE_RECORD_EXTENSIONS_ENABLED) \
0074     || defined(CONFIGURE_RECORD_FATAL_DUMP_BASE64) \
0075     || defined(CONFIGURE_RECORD_FATAL_DUMP_BASE64_ZLIB)
0076     #define _CONFIGURE_RECORD_NEED_EXTENSION
0077   #endif
0078 
0079   #include <rtems/confdefs/percpu.h>
0080   #include <rtems/record.h>
0081 #else
0082   #ifdef CONFIGURE_RECORD_EXTENSIONS_ENABLED
0083     #warning "CONFIGURE_RECORD_EXTENSIONS_ENABLED defined without CONFIGURE_RECORD_PER_PROCESSOR_ITEMS"
0084   #endif
0085   #ifdef CONFIGURE_RECORD_FATAL_DUMP_BASE64
0086     #warning "CONFIGURE_RECORD_FATAL_DUMP_BASE64 defined without CONFIGURE_RECORD_PER_PROCESSOR_ITEMS"
0087   #endif
0088   #ifdef CONFIGURE_RECORD_FATAL_DUMP_BASE64_ZLIB
0089     #warning "CONFIGURE_RECORD_FATAL_DUMP_BASE64_ZLIB defined without CONFIGURE_RECORD_PER_PROCESSOR_ITEMS"
0090   #endif
0091 #endif
0092 
0093 #if !defined(CONFIGURE_STACK_CHECKER_ENABLED) && defined(CONFIGURE_STACK_CHECKER_REPORTER)
0094   #error "Stack checker is disabled but a custom reporter is configured"
0095 #endif
0096 
0097 #ifdef CONFIGURE_STACK_CHECKER_ENABLED
0098   #include <rtems/stackchk.h>
0099 #endif
0100 
0101 #ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING
0102   #include <rtems/score/exception.h>
0103 #endif
0104 
0105 #ifdef __cplusplus
0106 extern "C" {
0107 #endif
0108 
0109 #if defined(_CONFIGURE_RECORD_NEED_EXTENSION) \
0110   || defined(_CONFIGURE_ENABLE_NEWLIB_REENTRANCY) \
0111   || defined(CONFIGURE_STACK_CHECKER_ENABLED) \
0112   || defined(CONFIGURE_INITIAL_EXTENSIONS) \
0113   || defined(BSP_INITIAL_EXTENSION)
0114   const User_extensions_Table _User_extensions_Initial_extensions[] = {
0115     #ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING
0116       { .fatal = _Exception_Raise_signal },
0117     #endif
0118     #ifdef _CONFIGURE_RECORD_NEED_EXTENSION
0119       {
0120         #ifdef CONFIGURE_RECORD_EXTENSIONS_ENABLED
0121           _Record_Thread_create,
0122           _Record_Thread_start,
0123           _Record_Thread_restart,
0124           _Record_Thread_delete,
0125           _Record_Thread_switch,
0126           _Record_Thread_begin,
0127           _Record_Thread_exitted,
0128         #else
0129            NULL, NULL, NULL, NULL, NULL, NULL, NULL,
0130         #endif
0131         #ifdef CONFIGURE_RECORD_FATAL_DUMP_BASE64_ZLIB
0132           _Record_Fatal_dump_base64_zlib,
0133         #elif defined(CONFIGURE_RECORD_FATAL_DUMP_BASE64)
0134           _Record_Fatal_dump_base64,
0135         #else
0136           NULL,
0137         #endif
0138         #ifdef CONFIGURE_RECORD_EXTENSIONS_ENABLED
0139           _Record_Thread_terminate
0140         #else
0141           NULL
0142         #endif
0143       },
0144     #endif
0145     #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY
0146       RTEMS_NEWLIB_EXTENSION,
0147     #endif
0148     #ifdef CONFIGURE_STACK_CHECKER_ENABLED
0149       RTEMS_STACK_CHECKER_EXTENSION,
0150     #endif
0151     #ifdef CONFIGURE_INITIAL_EXTENSIONS
0152       CONFIGURE_INITIAL_EXTENSIONS,
0153     #endif
0154     #if !defined(CONFIGURE_DISABLE_BSP_SETTINGS) && \
0155       defined(BSP_INITIAL_EXTENSION)
0156       BSP_INITIAL_EXTENSION
0157     #endif
0158   };
0159 
0160   const size_t _User_extensions_Initial_count =
0161     RTEMS_ARRAY_SIZE( _User_extensions_Initial_extensions );
0162 
0163   User_extensions_Switch_control _User_extensions_Initial_switch_controls[
0164     RTEMS_ARRAY_SIZE( _User_extensions_Initial_extensions )
0165   ];
0166 
0167   RTEMS_SYSINIT_ITEM(
0168     _User_extensions_Handler_initialization,
0169     RTEMS_SYSINIT_INITIAL_EXTENSIONS,
0170     RTEMS_SYSINIT_ORDER_MIDDLE
0171   );
0172 #endif
0173 
0174 #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
0175   EXTENSION_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_USER_EXTENSIONS );
0176 #endif
0177 
0178 #if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS > 0
0179   typedef struct {
0180     Record_Control    Control;
0181     rtems_record_item Items[ CONFIGURE_RECORD_PER_PROCESSOR_ITEMS ];
0182   } Record_Configured_control;
0183 
0184   static Record_Configured_control _Record_Controls[ _CONFIGURE_MAXIMUM_PROCESSORS ];
0185 
0186   const Record_Configuration _Record_Configuration = {
0187     CONFIGURE_RECORD_PER_PROCESSOR_ITEMS,
0188     &_Record_Controls[ 0 ].Control
0189   };
0190 
0191   RTEMS_SYSINIT_ITEM(
0192     _Record_Initialize,
0193     RTEMS_SYSINIT_RECORD,
0194     RTEMS_SYSINIT_ORDER_MIDDLE
0195   );
0196 
0197   #ifdef CONFIGURE_RECORD_INTERRUPTS_ENABLED
0198     RTEMS_SYSINIT_ITEM(
0199       _Record_Interrupt_initialize,
0200       RTEMS_SYSINIT_LAST,
0201       RTEMS_SYSINIT_ORDER_MIDDLE
0202     );
0203   #endif
0204 #endif
0205 
0206 #ifdef CONFIGURE_VERBOSE_SYSTEM_INITIALIZATION
0207   RTEMS_SYSINIT_ITEM(
0208     _Sysinit_Verbose,
0209     RTEMS_SYSINIT_RECORD,
0210     RTEMS_SYSINIT_ORDER_LAST
0211   );
0212 #endif
0213 
0214 #ifdef CONFIGURE_STACK_CHECKER_ENABLED
0215   #ifdef CONFIGURE_STACK_CHECKER_REPORTER
0216     const Stack_checker_Reporter_handler Stack_checker_Reporter =
0217       CONFIGURE_STACK_CHECKER_REPORTER;
0218   #else
0219     const Stack_checker_Reporter_handler Stack_checker_Reporter =
0220       rtems_stack_checker_reporter_quiet;
0221   #endif
0222 #endif
0223 
0224 #ifdef __cplusplus
0225 }
0226 #endif
0227 
0228 #endif /* CONFIGURE_INIT */
0229 
0230 #endif /* _RTEMS_CONFDEFS_EXTENSIONS_H */