summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/confdefs/extensions.h
blob: 6492407934b53f18cfd13dfe528ee1f4523987f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/* SPDX-License-Identifier: BSD-2-Clause */

/**
 * @file
 *
 * @ingroup RTEMSImplApplConfig
 *
 * @brief This header file evaluates configuration options related to the user
 *   extensions configuration.
 */

/*
 * Copyright (C) 2020 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.
 */

#ifndef _RTEMS_CONFDEFS_EXTENSIONS_H
#define _RTEMS_CONFDEFS_EXTENSIONS_H

#ifndef __CONFIGURATION_TEMPLATE_h
#error "Do not include this file directly, use <rtems/confdefs.h> instead"
#endif

#ifdef CONFIGURE_INIT

#include <rtems/confdefs/bsp.h>
#include <rtems/confdefs/newlib.h>
#include <rtems/score/userextimpl.h>
#include <rtems/sysinit.h>

#ifndef CONFIGURE_MAXIMUM_USER_EXTENSIONS
  #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 0
#endif

#if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
  #include <rtems/extensiondata.h>
#endif

#ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY
  #include <rtems/libcsupport.h>
#endif

#if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS > 0
  #if (CONFIGURE_RECORD_PER_PROCESSOR_ITEMS & (CONFIGURE_RECORD_PER_PROCESSOR_ITEMS - 1)) != 0
    #error "CONFIGURE_RECORD_PER_PROCESSOR_ITEMS must be a power of two"
  #endif

  #if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS < 16
    #error "CONFIGURE_RECORD_PER_PROCESSOR_ITEMS must be at least 16"
  #endif

  #if defined(CONFIGURE_RECORD_EXTENSIONS_ENABLED) \
    || defined(CONFIGURE_RECORD_FATAL_DUMP_BASE64) \
    || defined(CONFIGURE_RECORD_FATAL_DUMP_BASE64_ZLIB)
    #define _CONFIGURE_RECORD_NEED_EXTENSION
  #endif

  #include <rtems/confdefs/percpu.h>
  #include <rtems/record.h>
#else
  #ifdef CONFIGURE_RECORD_EXTENSIONS_ENABLED
    #warning "CONFIGURE_RECORD_EXTENSIONS_ENABLED defined without CONFIGURE_RECORD_PER_PROCESSOR_ITEMS"
  #endif
  #ifdef CONFIGURE_RECORD_FATAL_DUMP_BASE64
    #warning "CONFIGURE_RECORD_FATAL_DUMP_BASE64 defined without CONFIGURE_RECORD_PER_PROCESSOR_ITEMS"
  #endif
  #ifdef CONFIGURE_RECORD_FATAL_DUMP_BASE64_ZLIB
    #warning "CONFIGURE_RECORD_FATAL_DUMP_BASE64_ZLIB defined without CONFIGURE_RECORD_PER_PROCESSOR_ITEMS"
  #endif
#endif

#ifdef CONFIGURE_STACK_CHECKER_ENABLED
  #include <rtems/stackchk.h>
#endif

#ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING
  #include <rtems/score/exception.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if defined(_CONFIGURE_RECORD_NEED_EXTENSION) \
  || defined(_CONFIGURE_ENABLE_NEWLIB_REENTRANCY) \
  || defined(CONFIGURE_STACK_CHECKER_ENABLED) \
  || defined(CONFIGURE_INITIAL_EXTENSIONS) \
  || defined(BSP_INITIAL_EXTENSION)
  const User_extensions_Table _User_extensions_Initial_extensions[] = {
    #ifdef CONFIGURE_EXCEPTION_TO_SIGNAL_MAPPING
      { .fatal = _Exception_Raise_signal },
    #endif
    #ifdef _CONFIGURE_RECORD_NEED_EXTENSION
      {
        #ifdef CONFIGURE_RECORD_EXTENSIONS_ENABLED
          _Record_Thread_create,
          _Record_Thread_start,
          _Record_Thread_restart,
          _Record_Thread_delete,
          _Record_Thread_switch,
          _Record_Thread_begin,
          _Record_Thread_exitted,
        #else
           NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        #endif
        #ifdef CONFIGURE_RECORD_FATAL_DUMP_BASE64_ZLIB
          _Record_Fatal_dump_base64_zlib,
        #elif defined(CONFIGURE_RECORD_FATAL_DUMP_BASE64)
          _Record_Fatal_dump_base64,
        #else
          NULL,
        #endif
        #ifdef CONFIGURE_RECORD_EXTENSIONS_ENABLED
          _Record_Thread_terminate
        #else
          NULL
        #endif
      },
    #endif
    #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY
      RTEMS_NEWLIB_EXTENSION,
    #endif
    #ifdef CONFIGURE_STACK_CHECKER_ENABLED
      RTEMS_STACK_CHECKER_EXTENSION,
    #endif
    #ifdef CONFIGURE_INITIAL_EXTENSIONS
      CONFIGURE_INITIAL_EXTENSIONS,
    #endif
    #ifdef BSP_INITIAL_EXTENSION
      BSP_INITIAL_EXTENSION
    #endif
  };

  const size_t _User_extensions_Initial_count =
    RTEMS_ARRAY_SIZE( _User_extensions_Initial_extensions );

  User_extensions_Switch_control _User_extensions_Initial_switch_controls[
    RTEMS_ARRAY_SIZE( _User_extensions_Initial_extensions )
  ];

  RTEMS_SYSINIT_ITEM(
    _User_extensions_Handler_initialization,
    RTEMS_SYSINIT_INITIAL_EXTENSIONS,
    RTEMS_SYSINIT_ORDER_MIDDLE
  );
#endif

#if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
  EXTENSION_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_USER_EXTENSIONS );
#endif

#if CONFIGURE_RECORD_PER_PROCESSOR_ITEMS > 0
  typedef struct {
    Record_Control    Control;
    rtems_record_item Items[ CONFIGURE_RECORD_PER_PROCESSOR_ITEMS ];
  } Record_Configured_control;

  static Record_Configured_control _Record_Controls[ _CONFIGURE_MAXIMUM_PROCESSORS ];

  const Record_Configuration _Record_Configuration = {
    CONFIGURE_RECORD_PER_PROCESSOR_ITEMS,
    &_Record_Controls[ 0 ].Control
  };

  RTEMS_SYSINIT_ITEM(
    _Record_Initialize,
    RTEMS_SYSINIT_RECORD,
    RTEMS_SYSINIT_ORDER_MIDDLE
  );
#endif

#ifdef CONFIGURE_VERBOSE_SYSTEM_INITIALIZATION
  RTEMS_SYSINIT_ITEM(
    _Sysinit_Verbose,
    RTEMS_SYSINIT_RECORD,
    RTEMS_SYSINIT_ORDER_LAST
  );
#endif

#ifdef __cplusplus
}
#endif

#endif /* CONFIGURE_INIT */

#endif /* _RTEMS_CONFDEFS_EXTENSIONS_H */