source: rtems/cpukit/sapi/include/confdefs.h @ 03acc59

4.115
Last change on this file since 03acc59 was 03acc59, checked in by Chris Johns <chrisj@…>, on 08/14/13 at 00:21:41

posix: Change pthread_once to be SMP safe.

Change pthread_once from using disabled pre-emption to using a
pthread mutex making it SMP safe. GCC using a posix threading
model uses pthread_once.

The pthread mutex requires at least 1 mutex is configured so
confdefs.h has been updated to account for the internal
mutex.

  • Property mode set to 100644
File size: 89.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief Configuration Table Template that will be Instantiated
5 * by an Application
6 *
7 * This include file contains the configuration table template that will
8 * be instantiated by an application based on the setting of a number
9 * of macros.  The macros are documented in the Configuring a System
10 * chapter of the Classic API User's Guide
11 *
12 * The model is to estimate the memory required for each configured item
13 * and sum those estimates.  The estimate can be too high or too low for
14 * a variety of reasons:
15 *
16 * Reasons estimate is too high:
17 *   + FP contexts (not all tasks are FP)
18 *
19 * Reasons estimate is too low:
20 *   + stacks greater than minimum size
21 *   + messages
22 *   + application must account for device driver resources
23 *   + application must account for add-on library resource requirements
24 *
25 * NOTE:  Eventually this may be able to take into account some of
26 *        the above.  This procedure has evolved from just enough to
27 *        support the RTEMS Test Suites into something that can be
28 *        used remarkably reliably by most applications.
29 */
30
31/*
32 *  COPYRIGHT (c) 1989-2011.
33 *  On-Line Applications Research Corporation (OAR).
34 *
35 *  The license and distribution terms for this file may be
36 *  found in the file LICENSE in this distribution or at
37 *  http://www.rtems.com/license/LICENSE.
38 */
39
40#ifndef __CONFIGURATION_TEMPLATE_h
41#define __CONFIGURATION_TEMPLATE_h
42
43/*
44 * Include the executive's configuration
45 */
46#include <rtems.h>
47#include <rtems/score/apimutex.h>
48#include <rtems/score/wkspace.h>
49
50#ifdef CONFIGURE_DISABLE_BSP_SETTINGS
51  #undef BSP_DEFAULT_UNIFIED_WORK_AREAS
52  #undef BSP_IDLE_TASK_BODY
53  #undef BSP_IDLE_TASK_STACK_SIZE
54  #undef BSP_INITIAL_EXTENSION
55  #undef BSP_INTERRUPT_STACK_SIZE
56  #undef BSP_MAXIMUM_DEVICES
57  #undef BSP_ZERO_WORKSPACE_AUTOMATICALLY
58  #undef CONFIGURE_BSP_PREREQUISITE_DRIVERS
59  #undef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
60#else
61  #include <bsp.h>
62#endif
63
64#ifdef RTEMS_NEWLIB
65  #include <sys/reent.h>
66#endif
67
68#ifdef __cplusplus
69extern "C" {
70#endif
71
72extern rtems_initialization_tasks_table Initialization_tasks[];
73extern rtems_driver_address_table       Device_drivers[];
74#if defined(RTEMS_MULTIPROCESSING)
75  extern rtems_multiprocessing_table      Multiprocessing_configuration;
76#endif
77#ifdef RTEMS_POSIX_API
78  extern posix_api_configuration_table    Configuration_POSIX_API;
79#endif
80
81/**
82 * This macro determines whether the RTEMS reentrancy support for
83 * the Newlib C Library is enabled.
84 */
85#ifdef RTEMS_SCHEDSIM
86  #undef RTEMS_NEWLIB
87#endif
88
89#if (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY))
90  #define CONFIGURE_NEWLIB_EXTENSION 1
91#else
92  #define CONFIGURE_NEWLIB_EXTENSION 0
93#endif
94
95#ifndef RTEMS_SCHEDSIM
96#include <rtems/libio.h>
97
98#ifdef CONFIGURE_INIT
99const rtems_libio_helper rtems_libio_init_helper =
100  #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
101    rtems_libio_helper_null;
102  #else
103    rtems_libio_init;
104  #endif
105
106const rtems_libio_helper rtems_libio_post_driver_helper =
107  #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
108    rtems_libio_helper_null;
109  #else
110    rtems_libio_post_driver;
111  #endif
112
113const rtems_libio_helper rtems_libio_exit_helper =
114  #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
115    rtems_libio_helper_null;
116  #else
117    rtems_libio_exit;
118  #endif
119
120const rtems_libio_helper rtems_fs_init_helper =
121  #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
122    rtems_libio_helper_null;
123  #else
124    rtems_filesystem_initialize;
125  #endif
126#endif
127#endif
128
129/*
130 *  If the application disables the filesystem, they will not need
131 *  a mount table, so do not produce one.
132 */
133#ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
134  #define CONFIGURE_HAS_OWN_MOUNT_TABLE
135#endif
136
137/**
138 * This macro defines the number of POSIX file descriptors allocated
139 * and managed by libio.  These are the "integer" file descriptors that
140 * are used by calls like open(2) and read(2).
141 */
142#ifndef CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS
143  #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 3
144#endif
145
146/**
147 * Semaphore count used by the IO library.
148 */
149#define CONFIGURE_LIBIO_SEMAPHORES 1
150
151#ifdef CONFIGURE_INIT
152  /**
153   * When instantiating the configuration tables, this variable is
154   * initialized to specify the maximum number of file descriptors.
155   */
156  uint32_t rtems_libio_number_iops = CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS;
157#endif
158
159/**
160 * This macro determines if termios is disabled by this application.
161 * This only means that resources will not be reserved.  If you end
162 * up using termios, it will fail.
163 */
164#ifdef CONFIGURE_TERMIOS_DISABLED
165  #define CONFIGURE_TERMIOS_SEMAPHORES 0
166#else
167  /**
168   * This macro specifies the number of serial or PTY ports that will
169   * use termios.
170   */
171  #ifndef CONFIGURE_NUMBER_OF_TERMIOS_PORTS
172  #define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 1
173  #endif
174
175  /**
176   * This macro reserves the number of semaphores required by termios
177   * based upon the number of communication ports that will use it.
178   */
179  #define CONFIGURE_TERMIOS_SEMAPHORES \
180    ((CONFIGURE_NUMBER_OF_TERMIOS_PORTS * 4) + 1)
181#endif
182
183/**
184 * This macro specifies the number of PTYs that can be concurrently
185 * active.
186 */
187#ifndef CONFIGURE_MAXIMUM_PTYS
188  #define CONFIGURE_MAXIMUM_PTYS 0
189#endif
190
191/**
192 * This variable contains the maximum number of PTYs that can be
193 * concurrently active.
194 */
195#ifdef CONFIGURE_INIT
196  int rtems_telnetd_maximum_ptys = CONFIGURE_MAXIMUM_PTYS;
197#else
198  extern int rtems_telnetd_maximum_ptys;
199#endif
200
201#if defined(RTEMS_SMP)
202  /*
203   *  If configured for SMP, then we need to know the maximum CPU cores.
204   */
205  #if !defined(CONFIGURE_SMP_APPLICATION)
206    #if !defined(CONFIGURE_SMP_MAXIMUM_PROCESSORS)
207      #define CONFIGURE_SMP_MAXIMUM_PROCESSORS 1
208    #endif
209  #else
210    #if !defined(CONFIGURE_SMP_MAXIMUM_PROCESSORS)
211      #error "CONFIGURE_SMP_MAXIMUM_PROCESSORS not specified for SMP Application"
212    #endif
213  #endif
214#endif
215
216/*
217 *  Filesystems and Mount Table Configuration.
218 *
219 *  Defines to control the file system:
220 *
221 *   CONFIGURE_APPLICATION_DISABLE_FILESYSTEM:
222 *     Disable the RTEMS filesystems. You get an empty DEVFS.
223 *
224 *   CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM:
225 *     Use the DEVFS as the root file system. Limited functions are
226 *     provided when this is used.
227 *
228 *   CONFIGURE_FILESYSTEM_ALL:
229 *     Add file filesystems to the default filesystem table.
230 *
231 *   List of available file systems. You can define as many as you like:
232 *     CONFIGURE_FILESYSTEM_MINIIMFS - MiniIMFS, use DEVFS now
233 *     CONFIGURE_FILESYSTEM_IMFS     - In Memory File System (IMFS)
234 *     CONFIGURE_FILESYSTEM_DEVFS    - Device File System (DSVFS)
235 *     CONFIGURE_FILESYSTEM_TFTPFS   - TFTP File System, networking enabled
236 *     CONFIGURE_FILESYSTEM_FTPFS    - FTP File System, networking enabled
237 *     CONFIGURE_FILESYSTEM_NFS      - Network File System, networking enabled
238 *     CONFIGURE_FILESYSTEM_DOSFS    - DOS File System, uses libblock
239 *     CONFIGURE_FILESYSTEM_RFS      - RTEMS File System (RFS), uses libblock
240 *
241 *   Combinations:
242 *
243 *    - If nothing is defined the base file system is the IMFS.
244 *
245 *    - If CONFIGURE_APPLICATION_DISABLE_FILESYSTEM is defined all filesystem
246 *      are disabled by force and an empty DEVFS is created.
247 *
248 *    - If CONFIGURE_USE_DEV_AS_BASE_FILESYSTEM is defined all filesystem
249 *      are disabled by force and DEVFS is defined.
250 */
251
252#ifdef CONFIGURE_INIT
253
254  /*
255   * Include all file systems. Do this before checking if the filesystem has
256   * been disabled.
257   */
258  #ifdef CONFIGURE_FILESYSTEM_ALL
259    #define CONFIGURE_FILESYSTEM_MINIIMFS
260    #define CONFIGURE_FILESYSTEM_IMFS
261    #define CONFIGURE_FILESYSTEM_DEVFS
262    #define CONFIGURE_FILESYSTEM_TFTPFS
263    #define CONFIGURE_FILESYSTEM_FTPFS
264    #define CONFIGURE_FILESYSTEM_NFS
265    #define CONFIGURE_FILESYSTEM_DOSFS
266    #define CONFIGURE_FILESYSTEM_RFS
267  #endif
268
269  /*
270   * If disabling the file system, give a compile error if the user has
271   * configured other filesystem parameters.
272   */
273  #if defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM)
274     #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) || \
275         defined(CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM)
276       #error "Filesystem disabled but a base filesystem configured."
277     #endif
278
279    #if defined(CONFIGURE_FILESYSTEM_MINIIMFS) || \
280        defined(CONFIGURE_FILESYSTEM_IMFS) || \
281        defined(CONFIGURE_FILESYSTEM_DEVFS) || \
282        defined(CONFIGURE_FILESYSTEM_TFTPFS) || \
283        defined(CONFIGURE_FILESYSTEM_FTPFS) || \
284        defined(CONFIGURE_FILESYSTEM_NFS) || \
285        defined(CONFIGURE_FILESYSTEM_DOSFS) || \
286        defined(CONFIGURE_FILESYSTEM_RFS)
287        #error "Configured filesystems but root filesystem was not IMFS!"
288        #error "Filesystems could be disabled, DEVFS is root, or"
289        #error "  miniIMFS is root!"
290     #endif
291  #endif
292
293  /*
294   * If the base filesystem is DEVFS define it else define IMFS.
295   * We will have either DEVFS or IMFS defined after this.
296   */
297  #if !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM)
298    #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
299      #define CONFIGURE_FILESYSTEM_DEVFS
300    #elif defined(CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM)
301      #define CONFIGURE_FILESYSTEM_MINIIMFS
302    #elif !defined(CONFIGURE_FILESYSTEM_IMFS)
303      #define CONFIGURE_FILESYSTEM_IMFS
304    #endif
305  #endif
306
307#endif
308
309#ifndef RTEMS_SCHEDSIM
310/**
311 * IMFS
312 */
313#include <rtems/imfs.h>
314
315/**
316 * This specifies the number of bytes per block for files within the IMFS.
317 * There are a maximum number of blocks per file so this dictates the maximum
318 * size of a file.  This has to be balanced with the unused portion of each
319 * block that might be wasted.
320 */
321#ifndef CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK
322  #define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK \
323                    IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK
324#endif
325
326/**
327 * This defines the miniIMFS file system table entry.
328 */
329#if !defined(CONFIGURE_FILESYSTEM_ENTRY_miniIMFS) && \
330    defined(CONFIGURE_FILESYSTEM_MINIIMFS)
331  #define CONFIGURE_FILESYSTEM_ENTRY_miniIMFS \
332    { RTEMS_FILESYSTEM_TYPE_MINIIMFS, miniIMFS_initialize }
333#endif
334#endif
335
336/**
337 * Internall it is called FIFOs not pipes
338 */
339#if defined(CONFIGURE_PIPES_ENABLED)
340  #define CONFIGURE_FIFOS_ENABLED
341#endif
342
343#ifndef RTEMS_SCHEDSIM
344/**
345 * This defines the IMFS file system table entry.
346 */
347#if !defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS) && \
348    defined(CONFIGURE_FILESYSTEM_IMFS)
349  #if defined(CONFIGURE_FIFOS_ENABLED)
350    #define CONFIGURE_FILESYSTEM_ENTRY_IMFS \
351      { RTEMS_FILESYSTEM_TYPE_IMFS, fifoIMFS_initialize }
352  #else
353    #define CONFIGURE_FILESYSTEM_ENTRY_IMFS \
354      { RTEMS_FILESYSTEM_TYPE_IMFS, IMFS_initialize }
355  #endif
356#endif
357#endif
358
359/**
360 * This sets up the resources for the PIPES/FIFOs
361 */
362#if defined(CONFIGURE_FIFOS_ENABLED)
363  #if !defined(CONFIGURE_MAXIMUM_FIFOS) && !defined(CONFIGURE_MAXIMUM_PIPES)
364     #error "No FIFOs or PIPES configured"
365  #endif
366  #if !defined(CONFIGURE_MAXIMUM_FIFOS)
367    #define CONFIGURE_MAXIMUM_FIFOS 0
368  #endif
369  #if !defined(CONFIGURE_MAXIMUM_PIPES)
370    #define CONFIGURE_MAXIMUM_PIPES 0
371  #endif
372  #define CONFIGURE_BARRIERS_FOR_FIFOS \
373    (2 * (CONFIGURE_MAXIMUM_FIFOS + CONFIGURE_MAXIMUM_PIPES))
374  #define CONFIGURE_SEMAPHORES_FOR_FIFOS \
375    (1 + (CONFIGURE_MAXIMUM_FIFOS + CONFIGURE_MAXIMUM_PIPES))
376#else
377  #define CONFIGURE_BARRIERS_FOR_FIFOS   0
378  #define CONFIGURE_SEMAPHORES_FOR_FIFOS 0
379#endif
380
381/**
382 * DEVFS
383 */
384#if !defined(CONFIGURE_FILESYSTEM_ENTRY_DEVFS) && \
385    defined(CONFIGURE_FILESYSTEM_DEVFS)
386#include <rtems/devfs.h>
387  #define CONFIGURE_FILESYSTEM_ENTRY_DEVFS \
388    { RTEMS_FILESYSTEM_TYPE_DEVFS, devFS_initialize }
389#endif
390
391#ifdef RTEMS_NETWORKING
392  /**
393   * FTPFS
394   */
395  #if !defined(CONFIGURE_FILESYSTEM_ENTRY_FTPFS) && \
396      defined(CONFIGURE_FILESYSTEM_FTPFS)
397    #include <rtems/ftpfs.h>
398    #define CONFIGURE_FILESYSTEM_ENTRY_FTPFS \
399      { RTEMS_FILESYSTEM_TYPE_FTPFS, rtems_ftpfs_initialize }
400  #endif
401
402  /**
403   * TFTPFS
404   */
405  #if !defined(CONFIGURE_FILESYSTEM_ENTRY_TFTPFS) && \
406      defined(CONFIGURE_FILESYSTEM_TFTPFS)
407    #include <rtems/tftp.h>
408    #define CONFIGURE_FILESYSTEM_ENTRY_TFTPFS \
409      { RTEMS_FILESYSTEM_TYPE_TFTPFS, rtems_tftpfs_initialize }
410  #endif
411
412  /**
413   * NFS
414   */
415  #if !defined(CONFIGURE_FILESYSTEM_ENTRY_NFS) && \
416      defined(CONFIGURE_FILESYSTEM_NFS)
417    #include <librtemsNfs.h>
418    #define CONFIGURE_FILESYSTEM_ENTRY_NFS \
419      { RTEMS_FILESYSTEM_TYPE_NFS, rtems_nfs_initialize }
420  #endif
421#endif
422
423/**
424 * DOSFS
425 */
426#if !defined(CONFIGURE_FILESYSTEM_ENTRY_DOSFS) && \
427    defined(CONFIGURE_FILESYSTEM_DOSFS)
428  #include <rtems/dosfs.h>
429  #define CONFIGURE_FILESYSTEM_ENTRY_DOSFS \
430    { RTEMS_FILESYSTEM_TYPE_DOSFS, rtems_dosfs_initialize }
431#endif
432
433/**
434 * RFS
435 */
436#if !defined(CONFIGURE_FILESYSTEM_ENTRY_RFS) && \
437    defined(CONFIGURE_FILESYSTEM_RFS)
438  #include <rtems/rtems-rfs.h>
439  #define CONFIGURE_FILESYSTEM_ENTRY_RFS \
440    { RTEMS_FILESYSTEM_TYPE_RFS, rtems_rfs_rtems_initialise }
441#endif
442
443#ifdef CONFIGURE_INIT
444
445  /**
446   * DEVFS variables.
447   *
448   * The number of individual devices that may be registered
449   * in the system or the CONFIGURE_MAXIMUM_DEVICES variable
450   * is defaulted to 4 when a filesystem is enabled, unless
451   * the bsp overwrides this.  In which case the value is set
452   * to BSP_MAXIMUM_DEVICES.
453   */
454  #ifdef CONFIGURE_FILESYSTEM_DEVFS
455    #ifndef CONFIGURE_MAXIMUM_DEVICES
456      #if defined(BSP_MAXIMUM_DEVICES)
457        #define CONFIGURE_MAXIMUM_DEVICES BSP_MAXIMUM_DEVICES
458      #else
459        #define CONFIGURE_MAXIMUM_DEVICES 4
460      #endif
461    #endif
462    #include <rtems/devfs.h>
463  #endif
464
465#ifndef RTEMS_SCHEDSIM
466  #if defined(CONFIGURE_FILESYSTEM_IMFS) || \
467      defined(CONFIGURE_FILESYSTEM_MINIIMFS)
468    int imfs_rq_memfile_bytes_per_block = CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK;
469  #endif
470#endif
471
472  /**
473   * Table termination record.
474   */
475  #define CONFIGURE_FILESYSTEM_NULL { NULL, NULL }
476
477#ifndef RTEMS_SCHEDSIM
478  /**
479   * The default file system table. Must be terminated with the NULL entry if
480   * you provide your own.
481   */
482  #ifndef CONFIGURE_HAS_OWN_FILESYSTEM_TABLE
483    const rtems_filesystem_table_t rtems_filesystem_table[] = {
484      #if defined(CONFIGURE_FILESYSTEM_MINIIMFS) && \
485          defined(CONFIGURE_FILESYSTEM_ENTRY_miniIMFS)
486        CONFIGURE_FILESYSTEM_ENTRY_miniIMFS,
487      #endif
488      #if defined(CONFIGURE_FILESYSTEM_IMFS) && \
489          defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS)
490        CONFIGURE_FILESYSTEM_ENTRY_IMFS,
491      #endif
492      #if defined(CONFIGURE_FILESYSTEM_DEVFS) && \
493          defined(CONFIGURE_FILESYSTEM_ENTRY_DEVFS)
494        CONFIGURE_FILESYSTEM_ENTRY_DEVFS,
495      #endif
496      #if defined(CONFIGURE_FILESYSTEM_TFTPFS) && \
497          defined(CONFIGURE_FILESYSTEM_ENTRY_TFTPFS)
498        CONFIGURE_FILESYSTEM_ENTRY_TFTPFS,
499      #endif
500      #if defined(CONFIGURE_FILESYSTEM_FTPFS) && \
501          defined(CONFIGURE_FILESYSTEM_ENTRY_FTPFS)
502        CONFIGURE_FILESYSTEM_ENTRY_FTPFS,
503      #endif
504      #if defined(CONFIGURE_FILESYSTEM_NFS) && \
505          defined(CONFIGURE_FILESYSTEM_ENTRY_NFS)
506        CONFIGURE_FILESYSTEM_ENTRY_NFS,
507      #endif
508      #if defined(CONFIGURE_FILESYSTEM_DOSFS) && \
509          defined(CONFIGURE_FILESYSTEM_ENTRY_DOSFS)
510        CONFIGURE_FILESYSTEM_ENTRY_DOSFS,
511      #endif
512      #if defined(CONFIGURE_FILESYSTEM_RFS) && \
513          defined(CONFIGURE_FILESYSTEM_ENTRY_RFS)
514        CONFIGURE_FILESYSTEM_ENTRY_RFS,
515      #endif
516      CONFIGURE_FILESYSTEM_NULL
517    };
518  #endif
519
520  #ifndef CONFIGURE_HAS_OWN_MOUNT_TABLE
521    #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
522      static devFS_node devFS_root_filesystem_nodes [CONFIGURE_MAXIMUM_DEVICES];
523      static const devFS_data devFS_root_filesystem_data = {
524        devFS_root_filesystem_nodes,
525        CONFIGURE_MAXIMUM_DEVICES
526      };
527    #endif
528    const rtems_filesystem_mount_configuration
529      rtems_filesystem_root_configuration = {
530      NULL,
531      NULL,
532      #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
533        RTEMS_FILESYSTEM_TYPE_DEVFS,
534      #elif defined(CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM)
535        RTEMS_FILESYSTEM_TYPE_MINIIMFS,
536      #else
537        RTEMS_FILESYSTEM_TYPE_IMFS,
538      #endif
539      RTEMS_FILESYSTEM_READ_WRITE,
540      #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
541        &devFS_root_filesystem_data
542      #else
543        NULL
544      #endif
545    };
546  #endif
547
548#endif
549#endif
550
551/*
552 *  STACK_CHECKER_ON was still available in 4.9 so give a warning for now.
553 */
554#if defined(STACK_CHECKER_ON)
555  #define CONFIGURE_STACK_CHECKER_ENABLED
556  #warning "STACK_CHECKER_ON deprecated -- use CONFIGURE_STACK_CHECKER_ENABLED"
557#endif
558
559/**
560 * This configures the stack checker user extension.
561 */
562#ifdef CONFIGURE_STACK_CHECKER_ENABLED
563  #define CONFIGURE_STACK_CHECKER_EXTENSION 1
564#else
565  #define CONFIGURE_STACK_CHECKER_EXTENSION 0
566#endif
567
568/**
569 * @brief Maximum priority configuration.
570 *
571 * This configures the maximum priority value that
572 * a task may have.
573 *
574 * The following applies to the data space requirements
575 * of the Priority Scheduler.
576 *
577 * By reducing the number of priorities in a system,
578 * the amount of RAM required by RTEMS can be significantly
579 * reduced.  RTEMS allocates a Chain_Control structure per
580 * priority and this structure contains 3 pointers.  So
581 * the default is (256 * 12) = 3K on 32-bit architectures.
582 *
583 * This must be one less than a power of 2 between
584 * 4 and 256.  Valid values along with the application
585 * priority levels and memory saved when pointers are
586 * 32-bits in size are:
587 *
588 *   + 3,  2 application priorities, 3024 bytes saved
589 *   + 7, 5 application priorities, 2976 bytes saved
590 *   + 15, 13 application priorities, 2880 bytes saved
591 *   + 31, 29 application priorities, 2688 bytes saved
592 *   + 63, 61 application priorities, 2304 bytes saved
593 *   + 127, 125 application priorities, 1536 bytes saved
594 *   + 255, 253 application priorities, 0 bytes saved
595 *
596 * It is specified in terms of Classic API priority values.
597 */
598#ifndef CONFIGURE_MAXIMUM_PRIORITY
599  #define CONFIGURE_MAXIMUM_PRIORITY PRIORITY_DEFAULT_MAXIMUM
600#endif
601
602/*
603 * Scheduler configuration.
604 *
605 * The scheduler configuration allows an application to select the
606 * scheduling policy to use.  The supported configurations are:
607 *  CONFIGURE_SCHEDULER_USER       - user provided scheduler
608 *  CONFIGURE_SCHEDULER_PRIORITY   - Deterministic Priority Scheduler
609 *  CONFIGURE_SCHEDULER_SIMPLE     - Light-weight Priority Scheduler
610 *  CONFIGURE_SCHEDULER_SIMPLE_SMP - Simple SMP Priority Scheduler
611 *  CONFIGURE_SCHEDULER_EDF        - EDF Scheduler
612 *  CONFIGURE_SCHEDULER_CBS        - CBS Scheduler
613 *
614 * If no configuration is specified by the application, then
615 * CONFIGURE_SCHEDULER_PRIORITY is assumed to be the default.
616 *
617 * An application can define its own scheduling policy by defining
618 * CONFIGURE_SCHEDULER_USER and the following:
619 *    - CONFIGURE_SCHEDULER_ENTRY_POINTS
620 *    - CONFIGURE_MEMORY_FOR_SCHEDULER - base memory
621 *    - CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER - per task memory
622 */
623#include <rtems/score/scheduler.h>
624
625#if !defined(RTEMS_SMP)
626  #undef CONFIGURE_SCHEDULER_SIMPLE_SMP
627#endif
628
629/* If no scheduler is specified, the priority scheduler is default. */
630#if !defined(CONFIGURE_SCHEDULER_USER) && \
631    !defined(CONFIGURE_SCHEDULER_PRIORITY) && \
632    !defined(CONFIGURE_SCHEDULER_SIMPLE) && \
633    !defined(CONFIGURE_SCHEDULER_SIMPLE_SMP) && \
634    !defined(CONFIGURE_SCHEDULER_EDF) && \
635    !defined(CONFIGURE_SCHEDULER_CBS)
636  #if defined(RTEMS_SMP) && defined(CONFIGURE_SMP_APPLICATION)
637    #define CONFIGURE_SCHEDULER_SIMPLE_SMP
638  #else
639    #define CONFIGURE_SCHEDULER_PRIORITY
640  #endif
641#endif
642
643/*
644 * If the Priority Scheduler is selected, then configure for it.
645 */
646#if defined(CONFIGURE_SCHEDULER_PRIORITY)
647  #include <rtems/score/schedulerpriority.h>
648  #define CONFIGURE_SCHEDULER_ENTRY_POINTS SCHEDULER_PRIORITY_ENTRY_POINTS
649
650  /**
651   * This defines the memory used by the priority scheduler.
652   */
653  #define CONFIGURE_MEMORY_FOR_SCHEDULER ( \
654    _Configure_From_workspace( \
655      ((CONFIGURE_MAXIMUM_PRIORITY+1) * sizeof(Chain_Control)) ) \
656  )
657  #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \
658    _Configure_From_workspace(sizeof(Scheduler_priority_Per_thread)) )
659#endif
660
661/*
662 * If the Simple Priority Scheduler is selected, then configure for it.
663 */
664#if defined(CONFIGURE_SCHEDULER_SIMPLE)
665  #include <rtems/score/schedulersimple.h>
666  #define CONFIGURE_SCHEDULER_ENTRY_POINTS SCHEDULER_SIMPLE_ENTRY_POINTS
667
668  /**
669   * define the memory used by the simple scheduler
670   */
671  #define CONFIGURE_MEMORY_FOR_SCHEDULER ( \
672    _Configure_From_workspace( sizeof(Chain_Control) ) \
673  )
674  #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER (0)
675#endif
676
677/*
678 * If the Simple SMP Priority Scheduler is selected, then configure for it.
679 */
680#if defined(CONFIGURE_SCHEDULER_SIMPLE_SMP)
681  #include <rtems/score/schedulersimplesmp.h>
682  #define CONFIGURE_SCHEDULER_ENTRY_POINTS SCHEDULER_SIMPLE_SMP_ENTRY_POINTS
683
684  /**
685   * Define the memory used by the Simple SMP Scheduler
686   *
687   * NOTE: This is the same as the Simple Scheduler
688   */
689  #define CONFIGURE_MEMORY_FOR_SCHEDULER ( \
690    _Configure_From_workspace( sizeof( Scheduler_simple_smp_Control ) ) \
691  )
692  #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER (0)
693#endif
694
695/*
696 * If the EDF Scheduler is selected, then configure for it.
697 */
698#if defined(CONFIGURE_SCHEDULER_EDF)
699  #include <rtems/score/scheduleredf.h>
700  #define CONFIGURE_SCHEDULER_ENTRY_POINTS SCHEDULER_EDF_ENTRY_POINTS
701
702  /**
703   * define the memory used by the EDF scheduler
704   */
705  #define CONFIGURE_MEMORY_FOR_SCHEDULER ( \
706    _Configure_From_workspace(0))
707  #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \
708    _Configure_From_workspace(sizeof(Scheduler_EDF_Per_thread)))
709#endif
710
711/*
712 * If the CBS Scheduler is selected, then configure for it.
713 */
714#if defined(CONFIGURE_SCHEDULER_CBS)
715  #include <rtems/score/schedulercbs.h>
716  #define CONFIGURE_SCHEDULER_ENTRY_POINTS SCHEDULER_CBS_ENTRY_POINTS
717
718  #ifndef CONFIGURE_CBS_MAXIMUM_SERVERS
719    #define CONFIGURE_CBS_MAXIMUM_SERVERS CONFIGURE_MAXIMUM_TASKS
720  #endif
721
722  #ifdef CONFIGURE_INIT
723    uint32_t _Scheduler_CBS_Maximum_servers = CONFIGURE_CBS_MAXIMUM_SERVERS;
724  #endif
725
726  /**
727   * define the memory used by the CBS scheduler
728   */
729  #define CONFIGURE_MEMORY_FOR_SCHEDULER ( \
730    _Configure_From_workspace((sizeof(Scheduler_CBS_Server) + \
731        sizeof(Scheduler_CBS_Server*)) * CONFIGURE_CBS_MAXIMUM_SERVERS))
732  #define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER ( \
733    _Configure_From_workspace(sizeof(Scheduler_CBS_Per_thread)))
734#endif
735
736/*
737 * Set up the scheduler entry points table.  The scheduling code uses
738 * this code to know which scheduler is configured by the user.
739 */
740#ifdef CONFIGURE_INIT
741  Scheduler_Control  _Scheduler = {
742    NULL,                             /* Scheduler Specific Data Pointer */
743    CONFIGURE_SCHEDULER_ENTRY_POINTS  /* Scheduler Operations */
744  };
745#endif
746
747/*
748 *  If you said the IDLE task was going to do application initialization
749 *  and didn't override the IDLE body, then something is amiss.
750 */
751#if (defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) && \
752     !defined(CONFIGURE_IDLE_TASK_BODY))
753  #error "CONFIGURE_ERROR: You did not override the IDLE task body."
754#endif
755
756/**
757 * @brief Idle task body configuration.
758 *
759 * There is a default IDLE thread body provided by RTEMS which
760 * has the possibility of being CPU specific.  There may be a
761 * BSP specific override of the RTEMS default body and in turn,
762 * the application may override and provide its own.
763 */
764#ifndef CONFIGURE_IDLE_TASK_BODY
765  #if defined(BSP_IDLE_TASK_BODY)
766    #define CONFIGURE_IDLE_TASK_BODY BSP_IDLE_TASK_BODY
767  #elif (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE)
768    #define CONFIGURE_IDLE_TASK_BODY _CPU_Thread_Idle_body
769  #else
770    /* only instantiate and compile if used */
771    #ifdef CONFIGURE_INIT
772      void *_Thread_Idle_body(uintptr_t ignored)
773      {
774        for( ; ; ) ;
775        return 0;   /* to avoid warning */
776      }
777    #endif
778    #define CONFIGURE_IDLE_TASK_BODY _Thread_Idle_body
779  #endif
780#endif
781
782/**
783 * By default, use the minimum stack size requested by this port.
784 */
785#ifndef CONFIGURE_MINIMUM_TASK_STACK_SIZE
786  #define CONFIGURE_MINIMUM_TASK_STACK_SIZE CPU_STACK_MINIMUM_SIZE
787#endif
788
789#define CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE \
790  (2 * CONFIGURE_MINIMUM_TASK_STACK_SIZE)
791
792/**
793 * @brief Idle task stack size configuration.
794 *
795 * By default, the IDLE task will have a stack of minimum size.
796 * The BSP or application may override this value.
797 */
798#ifndef CONFIGURE_IDLE_TASK_STACK_SIZE
799  #ifdef BSP_IDLE_TASK_STACK_SIZE
800    #define CONFIGURE_IDLE_TASK_STACK_SIZE BSP_IDLE_TASK_STACK_SIZE
801  #else
802    #define CONFIGURE_IDLE_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE
803  #endif
804#endif
805#if CONFIGURE_IDLE_TASK_STACK_SIZE < CONFIGURE_MINIMUM_TASK_STACK_SIZE
806  #error "CONFIGURE_IDLE_TASK_STACK_SIZE less than CONFIGURE_MINIMUM_TASK_STACK_SIZE"
807#endif
808
809/**
810 * @brief Interrupt stack size configuration.
811 *
812 * By default, the interrupt stack will be of minimum size.
813 * The BSP or application may override this value.
814 */
815#ifndef CONFIGURE_INTERRUPT_STACK_SIZE
816  #ifdef BSP_INTERRUPT_STACK_SIZE
817    #define CONFIGURE_INTERRUPT_STACK_SIZE BSP_INTERRUPT_STACK_SIZE
818  #else
819    #define CONFIGURE_INTERRUPT_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE
820  #endif
821#endif
822
823/**
824 * This reserves memory for the interrupt stack if it is to be allocated
825 * by RTEMS rather than the BSP.
826 *
827 * @todo Try to get to the point where all BSPs support allocating the
828 *       memory from the Workspace.
829 */
830#if (CPU_ALLOCATE_INTERRUPT_STACK == 0)
831  #define CONFIGURE_INTERRUPT_STACK_MEMORY 0
832#else
833  #define CONFIGURE_INTERRUPT_STACK_MEMORY \
834     _Configure_From_workspace( CONFIGURE_INTERRUPT_STACK_SIZE )
835#endif
836
837/**
838 * Configure the very much optional task stack allocator initialization
839 */
840#ifndef CONFIGURE_TASK_STACK_ALLOCATOR_INIT
841  #define CONFIGURE_TASK_STACK_ALLOCATOR_INIT NULL
842#endif
843
844/*
845 *  Configure the very much optional task stack allocator and deallocator.
846 */
847#if !defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
848  && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)
849  #define CONFIGURE_TASK_STACK_ALLOCATOR _Workspace_Allocate
850  #define CONFIGURE_TASK_STACK_DEALLOCATOR _Workspace_Free
851#elif (defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
852  && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) \
853    || (!defined(CONFIGURE_TASK_STACK_ALLOCATOR) \
854      && defined(CONFIGURE_TASK_STACK_DEALLOCATOR))
855  #error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined"
856#endif
857
858/**
859 * Should the RTEMS Workspace and C Program Heap be cleared automatically
860 * at system start up?
861 */
862#ifndef CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY
863  #ifdef BSP_ZERO_WORKSPACE_AUTOMATICALLY
864    #define CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY \
865            BSP_ZERO_WORKSPACE_AUTOMATICALLY
866  #else
867    #define CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY FALSE
868  #endif
869#endif
870
871/*
872 *  RTEMS Malloc configuration
873 */
874
875#include <rtems/malloc.h>
876
877#ifdef CONFIGURE_INIT
878  /**
879   * By default, RTEMS uses separate heaps for the RTEMS Workspace and
880   * the C Program Heap.  The application can choose optionally to combine
881   * these to provide one larger memory pool. This is particularly
882   * useful in combination with the unlimited objects configuration.
883   */
884  #ifdef CONFIGURE_UNIFIED_WORK_AREAS
885    Heap_Control  *RTEMS_Malloc_Heap = &_Workspace_Area;
886  #else
887    Heap_Control   RTEMS_Malloc_Area;
888    Heap_Control  *RTEMS_Malloc_Heap = &RTEMS_Malloc_Area;
889  #endif
890#endif
891
892#ifdef CONFIGURE_INIT
893  /**
894   * This configures the malloc family statistics to be available.
895   * By default only function call counts are kept.
896   */
897  rtems_malloc_statistics_functions_t *rtems_malloc_statistics_helpers =
898    #ifndef CONFIGURE_MALLOC_STATISTICS
899      NULL;
900    #else
901      &rtems_malloc_statistics_helpers_table;
902    #endif
903#endif
904
905#ifdef CONFIGURE_INIT
906  /**
907   * This configures the sbrk() support for the malloc family.
908   * By default it is assumed that the BSP provides all available
909   * RAM to the malloc family implementation so sbrk()'ing to get
910   * more memory would always fail anyway.
911   */
912  const rtems_heap_extend_handler rtems_malloc_extend_handler =
913    #ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
914      rtems_heap_extend_via_sbrk;
915    #else
916      rtems_heap_null_extend;
917    #endif
918#endif
919
920#ifdef CONFIGURE_INIT
921  /**
922   * This configures the malloc family plugin which dirties memory
923   * allocated.  This is helpful for finding unitialized data structure
924   * problems.
925   */
926  rtems_malloc_dirtier_t rtems_malloc_dirty_helper =
927    #if defined(CONFIGURE_MALLOC_DIRTY)
928      rtems_malloc_dirty_memory;
929    #else
930      NULL;
931    #endif
932#endif
933
934/**
935 * This is a helper macro used in calculations in this file.  It is used
936 * to noted when an element is allocated from the RTEMS Workspace and adds
937 * a factor to account for heap overhead plus an alignment factor that
938 * may be applied.
939 */
940#define _Configure_From_workspace(_size) \
941  (ssize_t)((_size) + HEAP_BLOCK_HEADER_SIZE + CPU_HEAP_ALIGNMENT - 1)
942
943/**
944 * This is a helper macro used in stack space calculations in this file.  It
945 * may be provided by the application in case a special task stack allocator
946 * is used.  The default is allocation from the RTEMS Workspace.
947 */
948#ifdef CONFIGURE_TASK_STACK_FROM_ALLOCATOR
949  #define _Configure_From_stackspace(_stack_size) \
950    CONFIGURE_TASK_STACK_FROM_ALLOCATOR(_stack_size)
951#else
952  #define _Configure_From_stackspace(_stack_size) \
953    _Configure_From_workspace(_stack_size)
954#endif
955
956/**
957 * Do not use the unlimited bit as part of the multiplication
958 * for memory usage.
959 */
960#define _Configure_Max_Objects(_max) \
961  rtems_resource_maximum_per_allocation(_max)
962
963/**
964 * This macro accounts for how memory for a set of configured objects is
965 * allocated from the Executive Workspace.
966 *
967 * NOTE: It does NOT attempt to address the more complex case of unlimited
968 *       objects.
969 */
970#define _Configure_Object_RAM(_number, _size) \
971  ( _Configure_From_workspace(_Configure_Max_Objects(_number) * (_size)) + \
972    _Configure_From_workspace( \
973      ((_Configure_Max_Objects(_number) + 1) * sizeof(Objects_Control *)) + \
974      (sizeof(void *) + sizeof(uint32_t) + sizeof(Objects_Name *)) \
975    ) \
976  )
977
978/*
979 *  Default User Initialization Task Table.  This table guarantees that
980 *  one user initialization table is defined.
981 */
982
983#ifdef CONFIGURE_RTEMS_INIT_TASKS_TABLE
984
985#ifdef CONFIGURE_HAS_OWN_INIT_TASK_TABLE
986
987/*
988 *  The user is defining their own table information and setting the
989 *  appropriate variables.
990 */
991
992#else
993
994#ifndef CONFIGURE_INIT_TASK_NAME
995  #define CONFIGURE_INIT_TASK_NAME          rtems_build_name('U', 'I', '1', ' ')
996#endif
997
998#ifndef CONFIGURE_INIT_TASK_STACK_SIZE
999  #define CONFIGURE_INIT_TASK_STACK_SIZE    CONFIGURE_MINIMUM_TASK_STACK_SIZE
1000#endif
1001
1002#ifndef CONFIGURE_INIT_TASK_PRIORITY
1003  #define CONFIGURE_INIT_TASK_PRIORITY      1
1004#endif
1005
1006#ifndef CONFIGURE_INIT_TASK_ATTRIBUTES
1007  #define CONFIGURE_INIT_TASK_ATTRIBUTES    RTEMS_DEFAULT_ATTRIBUTES
1008#endif
1009
1010#ifndef CONFIGURE_INIT_TASK_ENTRY_POINT
1011  #ifdef __cplusplus
1012  extern "C" {
1013  #endif
1014    rtems_task Init (rtems_task_argument );
1015  #ifdef __cplusplus
1016  }
1017  #endif
1018  #define CONFIGURE_INIT_TASK_ENTRY_POINT   Init
1019  extern const char* bsp_boot_cmdline;
1020  #define CONFIGURE_INIT_TASK_ARGUMENTS     ((rtems_task_argument) &bsp_boot_cmdline)
1021#endif
1022
1023#ifndef CONFIGURE_INIT_TASK_INITIAL_MODES
1024  #if defined(RTEMS_SMP) && defined(CONFIGURE_SMP_APPLICATION)
1025    #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
1026  #else
1027    #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_NO_PREEMPT
1028  #endif
1029#endif
1030
1031#ifndef CONFIGURE_INIT_TASK_ARGUMENTS
1032  #define CONFIGURE_INIT_TASK_ARGUMENTS     0
1033#endif
1034
1035#ifdef CONFIGURE_INIT
1036  rtems_initialization_tasks_table Initialization_tasks[] = {
1037    { CONFIGURE_INIT_TASK_NAME,
1038      CONFIGURE_INIT_TASK_STACK_SIZE,
1039      CONFIGURE_INIT_TASK_PRIORITY,
1040      CONFIGURE_INIT_TASK_ATTRIBUTES,
1041      CONFIGURE_INIT_TASK_ENTRY_POINT,
1042      CONFIGURE_INIT_TASK_INITIAL_MODES,
1043      CONFIGURE_INIT_TASK_ARGUMENTS
1044    }
1045  };
1046#endif
1047
1048#define CONFIGURE_INIT_TASK_TABLE Initialization_tasks
1049
1050#define CONFIGURE_INIT_TASK_TABLE_SIZE \
1051  RTEMS_ARRAY_SIZE(CONFIGURE_INIT_TASK_TABLE)
1052
1053#endif    /* CONFIGURE_HAS_OWN_INIT_TASK_TABLE */
1054
1055#else     /* CONFIGURE_RTEMS_INIT_TASKS_TABLE */
1056
1057#define CONFIGURE_INIT_TASK_TABLE      NULL
1058#define CONFIGURE_INIT_TASK_TABLE_SIZE 0
1059#define CONFIGURE_INIT_TASK_STACK_SIZE 0
1060
1061#endif
1062
1063/*
1064 *  Default Device Driver Table.  Each driver needed by the test is explicitly
1065 *  choosen by that test.  There is always a null driver entry.
1066 */
1067
1068#define NULL_DRIVER_TABLE_ENTRY \
1069 { NULL, NULL, NULL, NULL, NULL, NULL }
1070
1071#ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
1072  #include <rtems/console.h>
1073#endif
1074
1075#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
1076  #include <rtems/clockdrv.h>
1077#endif
1078
1079#ifdef CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
1080  #include <rtems/timerdrv.h>
1081#endif
1082
1083#ifdef CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER
1084  #include <rtems/rtc.h>
1085#endif
1086
1087#ifdef CONFIGURE_APPLICATION_NEEDS_WATCHDOG_DRIVER
1088  #include <rtems/watchdogdrv.h>
1089#endif
1090
1091#ifdef CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER
1092  #include <rtems/framebuffer.h>
1093#endif
1094
1095#ifdef CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
1096  #include <rtems/devnull.h>
1097#endif
1098
1099#ifdef CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER
1100  #include <rtems/devzero.h>
1101#endif
1102
1103#ifdef CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
1104  /* the ide driver needs the ATA driver */
1105  #ifndef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
1106    #define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
1107  #endif
1108  #include <libchip/ide_ctrl.h>
1109#endif
1110
1111#ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
1112  #include <libchip/ata.h>
1113#endif
1114
1115#ifndef CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
1116
1117#ifdef CONFIGURE_INIT
1118  rtems_driver_address_table Device_drivers[] = {
1119    #ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS
1120      CONFIGURE_BSP_PREREQUISITE_DRIVERS,
1121    #endif
1122    #ifdef CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS
1123      CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS,
1124    #endif
1125    #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
1126      CONSOLE_DRIVER_TABLE_ENTRY,
1127    #endif
1128    #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
1129      CLOCK_DRIVER_TABLE_ENTRY,
1130    #endif
1131    #ifdef CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER
1132      RTC_DRIVER_TABLE_ENTRY,
1133    #endif
1134    #ifdef CONFIGURE_APPLICATION_NEEDS_WATCHDOG_DRIVER
1135      WATCHDOG_DRIVER_TABLE_ENTRY,
1136    #endif
1137    #ifdef CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
1138      DEVNULL_DRIVER_TABLE_ENTRY,
1139    #endif
1140    #ifdef CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER
1141      DEVZERO_DRIVER_TABLE_ENTRY,
1142    #endif
1143    #ifdef CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
1144      IDE_CONTROLLER_DRIVER_TABLE_ENTRY,
1145    #endif
1146    #ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
1147      ATA_DRIVER_TABLE_ENTRY,
1148    #endif
1149    #ifdef CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER
1150      FRAME_BUFFER_DRIVER_TABLE_ENTRY,
1151    #endif
1152    #ifdef CONFIGURE_APPLICATION_EXTRA_DRIVERS
1153      CONFIGURE_APPLICATION_EXTRA_DRIVERS,
1154    #endif
1155    #ifdef CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER
1156      NULL_DRIVER_TABLE_ENTRY
1157    #elif !defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) && \
1158        !defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) && \
1159        !defined(CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER) && \
1160        !defined(CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER) && \
1161        !defined(CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER) && \
1162        !defined(CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER) && \
1163        !defined(CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER) && \
1164        !defined(CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER) && \
1165        !defined(CONFIGURE_APPLICATION_EXTRA_DRIVERS)
1166      NULL_DRIVER_TABLE_ENTRY
1167    #endif
1168  };
1169#endif
1170
1171#endif  /* CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE */
1172
1173/*
1174 *  Default the number of drivers per node.  This value may be
1175 *  overridden by the user.
1176 */
1177
1178#define CONFIGURE_NUMBER_OF_DRIVERS \
1179  RTEMS_ARRAY_SIZE(Device_drivers)
1180
1181/**
1182 * This specifies the maximum number of device drivers that
1183 * can be installed in the system at one time.  It must account
1184 * for both the statically and dynamically installed drivers.
1185 */
1186#ifndef CONFIGURE_MAXIMUM_DRIVERS
1187  #define CONFIGURE_MAXIMUM_DRIVERS CONFIGURE_NUMBER_OF_DRIVERS
1188#endif
1189
1190
1191#ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
1192  /*
1193   * configure the priority of the ATA driver task
1194   */
1195  #ifndef CONFIGURE_ATA_DRIVER_TASK_PRIORITY
1196    #define CONFIGURE_ATA_DRIVER_TASK_PRIORITY ATA_DRIVER_TASK_DEFAULT_PRIORITY
1197  #endif
1198  #ifdef CONFIGURE_INIT
1199    rtems_task_priority rtems_ata_driver_task_priority
1200      = CONFIGURE_ATA_DRIVER_TASK_PRIORITY;
1201  #endif /* CONFIGURE_INIT */
1202#endif
1203
1204/*
1205 * add bdbuf configuration and values for swapout task priority
1206 */
1207#ifdef CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
1208  #include <rtems/bdbuf.h>
1209  /*
1210   * configure the bdbuf cache parameters
1211   */
1212  #ifndef CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS
1213    #define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS \
1214                              RTEMS_BDBUF_MAX_READ_AHEAD_BLOCKS_DEFAULT
1215  #endif
1216  #ifndef CONFIGURE_BDBUF_MAX_WRITE_BLOCKS
1217    #define CONFIGURE_BDBUF_MAX_WRITE_BLOCKS \
1218                              RTEMS_BDBUF_MAX_WRITE_BLOCKS_DEFAULT
1219  #endif
1220  #ifndef CONFIGURE_SWAPOUT_TASK_PRIORITY
1221    #define CONFIGURE_SWAPOUT_TASK_PRIORITY \
1222                              RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT
1223  #endif
1224  #ifndef CONFIGURE_SWAPOUT_SWAP_PERIOD
1225    #define CONFIGURE_SWAPOUT_SWAP_PERIOD \
1226                              RTEMS_BDBUF_SWAPOUT_TASK_SWAP_PERIOD_DEFAULT
1227  #endif
1228  #ifndef CONFIGURE_SWAPOUT_BLOCK_HOLD
1229    #define CONFIGURE_SWAPOUT_BLOCK_HOLD \
1230                              RTEMS_BDBUF_SWAPOUT_TASK_BLOCK_HOLD_DEFAULT
1231  #endif
1232  #ifndef CONFIGURE_SWAPOUT_WORKER_TASKS
1233    #define CONFIGURE_SWAPOUT_WORKER_TASKS \
1234                              RTEMS_BDBUF_SWAPOUT_WORKER_TASKS_DEFAULT
1235  #endif
1236  #ifndef CONFIGURE_SWAPOUT_WORKER_TASK_PRIORITY
1237    #define CONFIGURE_SWAPOUT_WORKER_TASK_PRIORITY \
1238                              RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT
1239  #endif
1240  #ifndef CONFIGURE_BDBUF_TASK_STACK_SIZE
1241    #define CONFIGURE_BDBUF_TASK_STACK_SIZE \
1242                              RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT
1243  #endif
1244  #ifndef CONFIGURE_BDBUF_CACHE_MEMORY_SIZE
1245    #define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE \
1246                              RTEMS_BDBUF_CACHE_MEMORY_SIZE_DEFAULT
1247  #endif
1248  #ifndef CONFIGURE_BDBUF_BUFFER_MIN_SIZE
1249    #define CONFIGURE_BDBUF_BUFFER_MIN_SIZE \
1250                              RTEMS_BDBUF_BUFFER_MIN_SIZE_DEFAULT
1251  #endif
1252  #ifndef CONFIGURE_BDBUF_BUFFER_MAX_SIZE
1253    #define CONFIGURE_BDBUF_BUFFER_MAX_SIZE \
1254                              RTEMS_BDBUF_BUFFER_MAX_SIZE_DEFAULT
1255  #endif
1256  #ifndef CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY
1257    #define CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY \
1258                              RTEMS_BDBUF_READ_AHEAD_TASK_PRIORITY_DEFAULT
1259  #endif
1260  #ifdef CONFIGURE_INIT
1261    const rtems_bdbuf_config rtems_bdbuf_configuration = {
1262      CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS,
1263      CONFIGURE_BDBUF_MAX_WRITE_BLOCKS,
1264      CONFIGURE_SWAPOUT_TASK_PRIORITY,
1265      CONFIGURE_SWAPOUT_SWAP_PERIOD,
1266      CONFIGURE_SWAPOUT_BLOCK_HOLD,
1267      CONFIGURE_SWAPOUT_WORKER_TASKS,
1268      CONFIGURE_SWAPOUT_WORKER_TASK_PRIORITY,
1269      CONFIGURE_BDBUF_TASK_STACK_SIZE,
1270      CONFIGURE_BDBUF_CACHE_MEMORY_SIZE,
1271      CONFIGURE_BDBUF_BUFFER_MIN_SIZE,
1272      CONFIGURE_BDBUF_BUFFER_MAX_SIZE,
1273      CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY
1274    };
1275  #endif
1276
1277  #define CONFIGURE_LIBBLOCK_TASKS \
1278    (1 + CONFIGURE_SWAPOUT_WORKER_TASKS + \
1279    (CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS != 0))
1280
1281  #define CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS \
1282    (CONFIGURE_LIBBLOCK_TASKS * \
1283    (CONFIGURE_BDBUF_TASK_STACK_SIZE <= CONFIGURE_MINIMUM_TASK_STACK_SIZE ? \
1284    0 : CONFIGURE_BDBUF_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE))
1285
1286  /*
1287   *  Semaphores:
1288   *    o disk lock
1289   *    o bdbuf lock
1290   *    o bdbuf sync lock
1291   *    o bdbuf access condition
1292   *    o bdbuf transfer condition
1293   *    o bdbuf buffer condition
1294   */
1295  #define CONFIGURE_LIBBLOCK_SEMAPHORES 6
1296
1297  #if defined(CONFIGURE_HAS_OWN_BDBUF_TABLE) || \
1298      defined(CONFIGURE_BDBUF_BUFFER_SIZE) || \
1299      defined(CONFIGURE_BDBUF_BUFFER_COUNT)
1300    #error BDBUF Cache does not use a buffer configuration table. Please remove.
1301  #endif
1302#else
1303  #define CONFIGURE_LIBBLOCK_TASKS 0
1304  #define CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS 0
1305  #define CONFIGURE_LIBBLOCK_SEMAPHORES 0
1306#endif /* CONFIGURE_APPLICATION_NEEDS_LIBBLOCK */
1307
1308#ifndef CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK
1309  #define CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK 0
1310#endif
1311
1312#if defined(RTEMS_MULTIPROCESSING)
1313  /*
1314   *  Default Multiprocessing Configuration Table.  The defaults are
1315   *  appropriate for most of the RTEMS Multiprocessor Test Suite.  Each
1316   *  value may be overridden within each test to customize the environment.
1317   */
1318
1319  #ifdef CONFIGURE_MP_APPLICATION
1320    #define CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER 1
1321
1322    #ifndef CONFIGURE_HAS_OWN_MULTIPROCESSING_TABLE
1323
1324      #ifndef CONFIGURE_MP_NODE_NUMBER
1325        #define CONFIGURE_MP_NODE_NUMBER                NODE_NUMBER
1326      #endif
1327
1328      #ifndef CONFIGURE_MP_MAXIMUM_NODES
1329        #define CONFIGURE_MP_MAXIMUM_NODES              2
1330      #endif
1331
1332      #ifndef CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS
1333        #define CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS     32
1334      #endif
1335      #define CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS(_global_objects) \
1336        _Configure_Object_RAM((_global_objects), sizeof(Objects_MP_Control))
1337
1338      #ifndef CONFIGURE_MP_MAXIMUM_PROXIES
1339        #define CONFIGURE_MP_MAXIMUM_PROXIES            32
1340      #endif
1341      #define CONFIGURE_MEMORY_FOR_PROXIES(_proxies) \
1342        _Configure_Object_RAM((_proxies) + 1, sizeof(Thread_Proxy_control) )
1343
1344      #ifndef CONFIGURE_MP_MPCI_TABLE_POINTER
1345        #include <mpci.h>
1346        #define CONFIGURE_MP_MPCI_TABLE_POINTER         &MPCI_table
1347      #endif
1348
1349      #ifdef CONFIGURE_INIT
1350        rtems_multiprocessing_table Multiprocessing_configuration = {
1351          CONFIGURE_MP_NODE_NUMBER,               /* local node number */
1352          CONFIGURE_MP_MAXIMUM_NODES,             /* maximum # nodes */
1353          CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS,    /* maximum # global objects */
1354          CONFIGURE_MP_MAXIMUM_PROXIES,           /* maximum # proxies */
1355          CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK, /* MPCI stack > minimum */
1356          CONFIGURE_MP_MPCI_TABLE_POINTER         /* ptr to MPCI config table */
1357        };
1358      #endif
1359
1360      #define CONFIGURE_MULTIPROCESSING_TABLE    &Multiprocessing_configuration
1361
1362    #endif /* CONFIGURE_HAS_OWN_MULTIPROCESSING_TABLE */
1363
1364  #else
1365
1366    #define CONFIGURE_MULTIPROCESSING_TABLE    NULL
1367
1368  #endif /* CONFIGURE_MP_APPLICATION */
1369#endif /* RTEMS_MULTIPROCESSING */
1370
1371#ifndef CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER
1372  #define CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER 0
1373#endif
1374
1375
1376/**
1377 * This macro specifies that the user wants to use unlimited objects for any
1378 * classic or posix objects that have not already been given resource limits.
1379 */
1380#if defined(CONFIGURE_UNLIMITED_OBJECTS)
1381  #if !defined(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1382  /**
1383   * This macro specifies a default allocation size for when auto-extending
1384   * unlimited objects if none was given by the user.
1385   */
1386    #define CONFIGURE_UNLIMITED_ALLOCATION_SIZE 8
1387  #endif
1388  #if !defined(CONFIGURE_MAXIMUM_TASKS)
1389    #define CONFIGURE_MAXIMUM_TASKS \
1390      rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1391  #endif
1392  #if !defined(CONFIGURE_MAXIMUM_TIMERS)
1393    #define CONFIGURE_MAXIMUM_TIMERS \
1394      rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1395  #endif
1396  #if !defined(CONFIGURE_MAXIMUM_SEMAPHORES)
1397    #define CONFIGURE_MAXIMUM_SEMAPHORES \
1398      rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1399  #endif
1400  #if !defined(CONFIGURE_MAXIMUM_MESSAGE_QUEUES)
1401    #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES \
1402      rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1403  #endif
1404  #if !defined(CONFIGURE_MAXIMUM_PARTITIONS)
1405    #define CONFIGURE_MAXIMUM_PARTITIONS \
1406      rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1407  #endif
1408  #if !defined(CONFIGURE_MAXIMUM_REGIONS)
1409    #define CONFIGURE_MAXIMUM_REGIONS \
1410      rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1411  #endif
1412  #if !defined(CONFIGURE_MAXIMUM_PORTS)
1413    #define CONFIGURE_MAXIMUM_PORTS \
1414      rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1415  #endif
1416  #if !defined(CONFIGURE_MAXIMUM_PERIODS)
1417    #define CONFIGURE_MAXIMUM_PERIODS \
1418      rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1419  #endif
1420  #if !defined(CONFIGURE_MAXIMUM_BARRIERS)
1421    #define CONFIGURE_MAXIMUM_BARRIERS \
1422      rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1423  #endif
1424
1425  #ifdef RTEMS_POSIX_API
1426    #if !defined(CONFIGURE_MAXIMUM_POSIX_THREADS)
1427      #define CONFIGURE_MAXIMUM_POSIX_THREADS \
1428        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1429    #endif
1430    #if !defined(CONFIGURE_MAXIMUM_POSIX_MUTEXES)
1431      #define CONFIGURE_MAXIMUM_POSIX_MUTEXES \
1432        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1433    #endif
1434    #if !defined(CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES)
1435      #define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES \
1436        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1437    #endif
1438/*
1439    #if !defined(CONFIGURE_MAXIMUM_POSIX_KEYS)
1440      #define CONFIGURE_MAXIMUM_POSIX_KEYS \
1441        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1442    #endif
1443*/
1444    #if !defined(CONFIGURE_MAXIMUM_POSIX_TIMERS)
1445      #define CONFIGURE_MAXIMUM_POSIX_TIMERS \
1446        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1447    #endif
1448/*
1449    #if !defined(CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS)
1450      #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS \
1451        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1452    #endif
1453*/
1454    #if !defined(CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES)
1455      #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES \
1456        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1457    #endif
1458    #if !defined(CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS)
1459      #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS \
1460        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1461    #endif
1462    #if !defined(CONFIGURE_MAXIMUM_POSIX_SEMAPHORES)
1463      #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES \
1464        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1465    #endif
1466    #if !defined(CONFIGURE_MAXIMUM_POSIX_BARRIERS)
1467      #define CONFIGURE_MAXIMUM_POSIX_BARRIERS \
1468        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1469    #endif
1470    #if !defined(CONFIGURE_MAXIMUM_POSIX_RWLOCKS)
1471      #define CONFIGURE_MAXIMUM_POSIX_RWLOCKS \
1472        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1473    #endif
1474    #if !defined(CONFIGURE_MAXIMUM_POSIX_SPINLOCKS)
1475      #define CONFIGURE_MAXIMUM_POSIX_SPINLOCKS \
1476        rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
1477    #endif
1478  #endif /* RTEMS_POSIX_API */
1479#endif /* CONFIGURE_UNLIMITED_OBJECTS */
1480
1481
1482/*
1483 *  Default Configuration Table.
1484 */
1485
1486#ifndef CONFIGURE_HAS_OWN_CONFIGURATION_TABLE
1487
1488  #ifndef CONFIGURE_MAXIMUM_TASKS
1489    #define CONFIGURE_MAXIMUM_TASKS               0
1490  #endif
1491
1492  #define CONFIGURE_TASKS \
1493    (CONFIGURE_MAXIMUM_TASKS + CONFIGURE_LIBBLOCK_TASKS)
1494
1495  #ifndef CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS
1496    #define CONFIGURE_NOTEPADS_ENABLED           TRUE
1497  #else
1498    #define CONFIGURE_NOTEPADS_ENABLED           FALSE
1499  #endif
1500
1501  #ifndef CONFIGURE_DISABLE_CLASSIC_API_NOTEPADS
1502    #define CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API \
1503      _Configure_From_workspace( sizeof(RTEMS_API_Control) )
1504  #else
1505    #define CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API \
1506      _Configure_From_workspace( sizeof(RTEMS_API_Control) - \
1507        (RTEMS_NUMBER_NOTEPADS * sizeof(uint32_t)))
1508  #endif
1509
1510  /**
1511   * This macro calculates the memory required for task variables.
1512   *
1513   * NOTE: Each task variable is individually allocated from the Workspace.
1514   *       Hence, we do the multiplication on the configured size.
1515   */
1516  #ifndef CONFIGURE_MAXIMUM_TASK_VARIABLES
1517    #define CONFIGURE_MAXIMUM_TASK_VARIABLES                     0
1518    #define CONFIGURE_MEMORY_FOR_TASK_VARIABLES(_task_variables) 0
1519  #else
1520    #define CONFIGURE_MEMORY_FOR_TASK_VARIABLES(_task_variables) \
1521      (_task_variables) * \
1522         _Configure_From_workspace(sizeof(rtems_task_variable_t))
1523  #endif
1524
1525  #ifndef CONFIGURE_MAXIMUM_TIMERS
1526    #define CONFIGURE_MAXIMUM_TIMERS             0
1527    #define CONFIGURE_MEMORY_FOR_TIMERS(_timers) 0
1528  #else
1529    #define CONFIGURE_MEMORY_FOR_TIMERS(_timers) \
1530      _Configure_Object_RAM(_timers, sizeof(Timer_Control) )
1531  #endif
1532
1533  #ifndef CONFIGURE_MAXIMUM_SEMAPHORES
1534    #define CONFIGURE_MAXIMUM_SEMAPHORES                 0
1535  #endif
1536
1537  #define CONFIGURE_SEMAPHORES \
1538    (CONFIGURE_MAXIMUM_SEMAPHORES + CONFIGURE_LIBIO_SEMAPHORES + \
1539      CONFIGURE_TERMIOS_SEMAPHORES + CONFIGURE_LIBBLOCK_SEMAPHORES + \
1540      CONFIGURE_SEMAPHORES_FOR_FIFOS)
1541
1542  /*
1543   * If there are no user or support semaphores defined, then we can assume
1544   * that no memory need be allocated at all for semaphores.
1545   */
1546  #if CONFIGURE_SEMAPHORES == 0
1547    #define CONFIGURE_MEMORY_FOR_SEMAPHORES(_semaphores) 0
1548  #else
1549    #define CONFIGURE_MEMORY_FOR_SEMAPHORES(_semaphores) \
1550      _Configure_Object_RAM(_semaphores, sizeof(Semaphore_Control) )
1551  #endif
1552
1553  #ifndef CONFIGURE_MAXIMUM_MESSAGE_QUEUES
1554    #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES             0
1555    #define CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(_queues) 0
1556  #else
1557    #define CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(_queues) \
1558      _Configure_Object_RAM(_queues, sizeof(Message_queue_Control) )
1559  #endif
1560
1561  #ifndef CONFIGURE_MAXIMUM_PARTITIONS
1562    #define CONFIGURE_MAXIMUM_PARTITIONS                 0
1563    #define CONFIGURE_MEMORY_FOR_PARTITIONS(_partitions) 0
1564  #else
1565    #define CONFIGURE_MEMORY_FOR_PARTITIONS(_partitions) \
1566      _Configure_Object_RAM(_partitions, sizeof(Partition_Control) )
1567  #endif
1568
1569  #ifndef CONFIGURE_MAXIMUM_REGIONS
1570    #define CONFIGURE_MAXIMUM_REGIONS              0
1571    #define CONFIGURE_MEMORY_FOR_REGIONS(_regions) 0
1572  #else
1573    #define CONFIGURE_MEMORY_FOR_REGIONS(_regions) \
1574      _Configure_Object_RAM(_regions, sizeof(Region_Control) )
1575  #endif
1576
1577  #ifndef CONFIGURE_MAXIMUM_PORTS
1578    #define CONFIGURE_MAXIMUM_PORTS            0
1579    #define CONFIGURE_MEMORY_FOR_PORTS(_ports) 0
1580  #else
1581    #define CONFIGURE_MEMORY_FOR_PORTS(_ports) \
1582      _Configure_Object_RAM(_ports, sizeof(Dual_ported_memory_Control) )
1583  #endif
1584
1585  #ifndef CONFIGURE_MAXIMUM_PERIODS
1586    #define CONFIGURE_MAXIMUM_PERIODS              0
1587    #define CONFIGURE_MEMORY_FOR_PERIODS(_periods) 0
1588  #else
1589    #define CONFIGURE_MEMORY_FOR_PERIODS(_periods) \
1590      _Configure_Object_RAM(_periods, sizeof(Rate_monotonic_Control) )
1591  #endif
1592
1593  #ifndef CONFIGURE_MAXIMUM_BARRIERS
1594    #define CONFIGURE_MAXIMUM_BARRIERS               0
1595  #endif
1596
1597  #define CONFIGURE_BARRIERS \
1598     (CONFIGURE_MAXIMUM_BARRIERS + CONFIGURE_BARRIERS_FOR_FIFOS)
1599
1600  #if CONFIGURE_BARRIERS == 0
1601    #define CONFIGURE_MEMORY_FOR_BARRIERS(_barriers) 0
1602  #else
1603    #define CONFIGURE_MEMORY_FOR_BARRIERS(_barriers) \
1604      _Configure_Object_RAM(_barriers, sizeof(Barrier_Control) )
1605  #endif
1606
1607  #ifndef CONFIGURE_MAXIMUM_USER_EXTENSIONS
1608    #define CONFIGURE_MAXIMUM_USER_EXTENSIONS                 0
1609    #define CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(_extensions) 0
1610  #else
1611    #define CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(_extensions) \
1612      _Configure_Object_RAM(_extensions, sizeof(Extension_Control) )
1613  #endif
1614
1615  #ifndef CONFIGURE_MICROSECONDS_PER_TICK
1616    #define CONFIGURE_MICROSECONDS_PER_TICK \
1617            RTEMS_MILLISECONDS_TO_MICROSECONDS(10)
1618  #endif
1619
1620  #ifndef CONFIGURE_TICKS_PER_TIMESLICE
1621    #define CONFIGURE_TICKS_PER_TIMESLICE        50
1622  #endif
1623
1624/*
1625 *  Initial Extension Set
1626 */
1627
1628#ifdef CONFIGURE_INIT
1629#ifdef CONFIGURE_STACK_CHECKER_ENABLED
1630#include <rtems/stackchk.h>
1631#endif
1632#include <rtems/libcsupport.h>
1633
1634#if defined(BSP_INITIAL_EXTENSION) || \
1635    defined(CONFIGURE_INITIAL_EXTENSIONS) || \
1636    defined(CONFIGURE_STACK_CHECKER_ENABLED) || \
1637    (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY))
1638  static const rtems_extensions_table Configuration_Initial_Extensions[] = {
1639    #if !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)
1640      RTEMS_NEWLIB_EXTENSION,
1641    #endif
1642    #if defined(CONFIGURE_STACK_CHECKER_ENABLED)
1643      RTEMS_STACK_CHECKER_EXTENSION,
1644    #endif
1645    #if defined(CONFIGURE_INITIAL_EXTENSIONS)
1646      CONFIGURE_INITIAL_EXTENSIONS,
1647    #endif
1648    #if defined(BSP_INITIAL_EXTENSION)
1649      BSP_INITIAL_EXTENSION
1650    #endif
1651  };
1652
1653  #define CONFIGURE_INITIAL_EXTENSION_TABLE Configuration_Initial_Extensions
1654  #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \
1655    RTEMS_ARRAY_SIZE(Configuration_Initial_Extensions)
1656#else
1657  #define CONFIGURE_INITIAL_EXTENSION_TABLE NULL
1658  #define CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS 0
1659#endif
1660
1661#if defined(RTEMS_NEWLIB) && defined(__DYNAMIC_REENT__)
1662  struct _reent *__getreent(void)
1663  {
1664    #ifdef CONFIGURE_DISABLE_NEWLIB_REENTRANCY
1665      return _GLOBAL_REENT;
1666    #else
1667      return _Thread_Get_executing()->libc_reent;
1668    #endif
1669  }
1670#endif
1671
1672#endif
1673
1674/*
1675 *  POSIX API Configuration Parameters
1676 */
1677
1678#ifdef RTEMS_POSIX_API
1679
1680  #include <sys/types.h>
1681  #include <signal.h>
1682  #include <limits.h>
1683  #include <mqueue.h>
1684  #include <rtems/posix/barrier.h>
1685  #include <rtems/posix/cond.h>
1686  #include <rtems/posix/mqueue.h>
1687  #include <rtems/posix/mutex.h>
1688  #include <rtems/posix/key.h>
1689  #include <rtems/posix/psignal.h>
1690  #include <rtems/posix/pthread.h>
1691  #include <rtems/posix/rwlock.h>
1692  #include <rtems/posix/semaphore.h>
1693  #include <rtems/posix/spinlock.h>
1694  #include <rtems/posix/threadsup.h>
1695  #include <rtems/posix/timer.h>
1696
1697  /**
1698   * POSIX Once support uses a single mutex.
1699   */
1700  #define CONFIGURE_MAXIMUM_POSIX_INTERNAL_MUTEXES 1
1701
1702  /**
1703   * Account for the object control structures plus the name
1704   * of the object to be duplicated.
1705   */
1706  #define _Configure_POSIX_Named_Object_RAM(_number, _size) \
1707    _Configure_Object_RAM( (_number), _size ) + \
1708    (_Configure_Max_Objects(_number) * _Configure_From_workspace(NAME_MAX) )
1709
1710  #ifndef CONFIGURE_MAXIMUM_POSIX_THREADS
1711    #define CONFIGURE_MAXIMUM_POSIX_THREADS      0
1712  #endif
1713
1714  #define CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API \
1715    _Configure_From_workspace(sizeof(POSIX_API_Control))
1716
1717  #ifndef CONFIGURE_MAXIMUM_POSIX_MUTEXES
1718    #define CONFIGURE_MAXIMUM_POSIX_MUTEXES              0
1719    #define CONFIGURE_MEMORY_FOR_POSIX_MUTEXES(_mutexes) 0
1720  #else
1721    #define CONFIGURE_MEMORY_FOR_POSIX_MUTEXES(_mutexes) \
1722      _Configure_Object_RAM(_mutexes, sizeof(POSIX_Mutex_Control) )
1723  #endif
1724
1725  #ifndef CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES
1726    #define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES               0
1727    #define CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES(_condvars) 0
1728  #else
1729    #define CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES(_condvars) \
1730        _Configure_Object_RAM(_condvars, \
1731                            sizeof(POSIX_Condition_variables_Control) )
1732  #endif
1733
1734  #ifndef CONFIGURE_MAXIMUM_POSIX_KEYS
1735    #define CONFIGURE_MAXIMUM_POSIX_KEYS           0
1736    #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS      0
1737    #define CONFIGURE_MEMORY_FOR_POSIX_KEYS(_keys, _key_value_pairs) 0
1738  #else
1739    #ifndef CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS
1740      #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \
1741        CONFIGURE_MAXIMUM_POSIX_KEYS \
1742        * (CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS)
1743    #endif
1744  #define CONFIGURE_MEMORY_FOR_POSIX_KEYS(_keys, _key_value_pairs)       \
1745      (_Configure_Object_RAM(_keys, sizeof(POSIX_Keys_Control) ) \
1746  + _Configure_From_workspace(_key_value_pairs * sizeof(POSIX_Keys_Key_value_pair)))
1747  #endif
1748
1749  #ifndef CONFIGURE_MAXIMUM_POSIX_TIMERS
1750    #define CONFIGURE_MAXIMUM_POSIX_TIMERS             0
1751    #define CONFIGURE_MEMORY_FOR_POSIX_TIMERS(_timers) 0
1752  #else
1753    #define CONFIGURE_MEMORY_FOR_POSIX_TIMERS(_timers) \
1754      _Configure_Object_RAM(_timers, sizeof(POSIX_Timer_Control) )
1755  #endif
1756
1757  #ifndef CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS
1758    #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS                     0
1759    #define CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS(_queued_signals) 0
1760  #else
1761    #define CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS(_queued_signals) \
1762      _Configure_From_workspace( \
1763        (_queued_signals) * (sizeof(POSIX_signals_Siginfo_node)) )
1764  #endif
1765
1766  #ifndef CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES
1767    #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES                     0
1768    #define CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES(_message_queues) 0
1769    #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS          0
1770    #define CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUE_DESCRIPTORS(_fds) 0
1771  #else
1772    #define CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES(_message_queues) \
1773      _Configure_POSIX_Named_Object_RAM( \
1774         _message_queues, sizeof(POSIX_Message_queue_Control) )
1775
1776    /* default to same number */
1777    #ifndef CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS
1778       #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS \
1779               CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES
1780    #endif
1781
1782    #define CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUE_DESCRIPTORS(_mqueue_fds) \
1783      _Configure_Object_RAM( \
1784         _mqueue_fds, sizeof(POSIX_Message_queue_Control_fd) )
1785  #endif
1786
1787  #ifndef CONFIGURE_MAXIMUM_POSIX_SEMAPHORES
1788    #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES                 0
1789    #define CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES(_semaphores) 0
1790  #else
1791    #define CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES(_semaphores) \
1792      _Configure_POSIX_Named_Object_RAM( \
1793         _semaphores, sizeof(POSIX_Semaphore_Control) )
1794  #endif
1795
1796  #ifndef CONFIGURE_MAXIMUM_POSIX_BARRIERS
1797    #define CONFIGURE_MAXIMUM_POSIX_BARRIERS               0
1798    #define CONFIGURE_MEMORY_FOR_POSIX_BARRIERS(_barriers) 0
1799  #else
1800    #define CONFIGURE_MEMORY_FOR_POSIX_BARRIERS(_barriers) \
1801      _Configure_Object_RAM(_barriers, sizeof(POSIX_Barrier_Control) )
1802  #endif
1803
1804  #ifndef CONFIGURE_MAXIMUM_POSIX_SPINLOCKS
1805    #define CONFIGURE_MAXIMUM_POSIX_SPINLOCKS                0
1806    #define CONFIGURE_MEMORY_FOR_POSIX_SPINLOCKS(_spinlocks) 0
1807  #else
1808    #define CONFIGURE_MEMORY_FOR_POSIX_SPINLOCKS(_spinlocks) \
1809      _Configure_Object_RAM(_spinlocks, sizeof(POSIX_Spinlock_Control) )
1810  #endif
1811
1812  #ifndef CONFIGURE_MAXIMUM_POSIX_RWLOCKS
1813    #define CONFIGURE_MAXIMUM_POSIX_RWLOCKS              0
1814    #define CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS(_rwlocks) 0
1815  #else
1816    #define CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS(_rwlocks) \
1817      _Configure_Object_RAM(_rwlocks, sizeof(POSIX_RWLock_Control) )
1818  #endif
1819
1820  #ifdef CONFIGURE_POSIX_INIT_THREAD_TABLE
1821
1822    #ifdef CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE
1823
1824      /*
1825       *  The user is defining their own table information and setting the
1826       *  appropriate variables for the POSIX Initialization Thread Table.
1827       */
1828
1829    #else
1830
1831      #ifndef CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT
1832        #define CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT   POSIX_Init
1833      #endif
1834
1835      #ifndef CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE
1836        #define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE \
1837          CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE
1838      #endif
1839
1840      #ifdef CONFIGURE_INIT
1841        posix_initialization_threads_table POSIX_Initialization_threads[] = {
1842          { CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT, \
1843              CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE }
1844        };
1845      #endif
1846
1847      #define CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME \
1848              POSIX_Initialization_threads
1849
1850      #define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE \
1851              RTEMS_ARRAY_SIZE(CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME)
1852
1853    #endif    /* CONFIGURE_POSIX_HAS_OWN_INIT_TASK_TABLE */
1854
1855  #else     /* CONFIGURE_POSIX_INIT_THREAD_TABLE */
1856
1857    #define CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME NULL
1858    #define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE 0
1859
1860  #endif
1861
1862  #define CONFIGURE_MEMORY_FOR_POSIX \
1863    ( CONFIGURE_MEMORY_FOR_POSIX_MUTEXES( CONFIGURE_MAXIMUM_POSIX_MUTEXES + \
1864          CONFIGURE_MAXIMUM_POSIX_INTERNAL_MUTEXES + \
1865          CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_MUTEXES) + \
1866      CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES( \
1867          CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES + \
1868          CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_CONDITION_VARIABLES) + \
1869      CONFIGURE_MEMORY_FOR_POSIX_KEYS( CONFIGURE_MAXIMUM_POSIX_KEYS, \
1870                                       CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ) + \
1871      CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS( \
1872          CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ) + \
1873      CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( \
1874          CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ) + \
1875      CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUE_DESCRIPTORS( \
1876          CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS ) + \
1877      CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \
1878          CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ) + \
1879      CONFIGURE_MEMORY_FOR_POSIX_BARRIERS(CONFIGURE_MAXIMUM_POSIX_BARRIERS) + \
1880      CONFIGURE_MEMORY_FOR_POSIX_SPINLOCKS( \
1881          CONFIGURE_MAXIMUM_POSIX_SPINLOCKS ) + \
1882      CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( \
1883          CONFIGURE_MAXIMUM_POSIX_RWLOCKS ) + \
1884      CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ) \
1885     )
1886#else
1887
1888  #define CONFIGURE_MAXIMUM_POSIX_THREADS         0
1889  #define CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API 0
1890  #define CONFIGURE_MEMORY_FOR_POSIX              0
1891
1892#endif    /* RTEMS_POSIX_API */
1893
1894#ifndef CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE
1895  #define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE    0
1896#endif
1897
1898/*
1899 *  This block of defines are for applications which use GNAT/RTEMS.
1900 *  GNAT implements each Ada task as a POSIX thread.
1901 */
1902#ifdef CONFIGURE_GNAT_RTEMS
1903
1904  /**
1905   * The GNAT run-time needs something less than (10) POSIX mutexes.
1906   * We may be able to get by with less but why bother.
1907   */
1908  #define CONFIGURE_GNAT_MUTEXES 10
1909
1910  /**
1911   * This is the maximum number of Ada tasks which can be concurrently
1912   * in existence.  Twenty (20) are required to run all tests in the
1913   * ACATS (formerly ACVC).
1914   */
1915  #ifndef CONFIGURE_MAXIMUM_ADA_TASKS
1916    #define CONFIGURE_MAXIMUM_ADA_TASKS  20
1917  #endif
1918
1919  /**
1920   * This is the number of non-Ada tasks which invoked Ada code.
1921   */
1922  #ifndef CONFIGURE_MAXIMUM_FAKE_ADA_TASKS
1923    #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0
1924  #endif
1925
1926#else
1927  #define CONFIGURE_GNAT_MUTEXES           0
1928  #define CONFIGURE_MAXIMUM_ADA_TASKS      0
1929  #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0
1930#endif
1931
1932#ifdef CONFIGURE_ENABLE_GO
1933
1934  #ifndef CONFIGURE_MAXIMUM_POSIX_THREADS
1935    #define CONFIGURE_MAXIMUM_POSIX_THREADS 1
1936  #endif
1937  #ifndef CONFIGURE_MAXIMUM_POSIX_MUTEXES
1938    #define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1
1939  #endif
1940  #ifndef CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES
1941    #define CONFIGURE_MAXIMUM_CONDITION_VARIABLES 1
1942  #endif
1943
1944  #define CONFIGURE_GO_INIT_MUTEXES 77
1945  #define CONFIGURE_GO_INIT_CONDITION_VARIABLES 4
1946
1947  #ifndef CONFIGURE_MAXIMUM_GOROUTINES
1948    #define CONFIGURE_MAXIMUM_GOROUTINES 400
1949  #endif
1950
1951  #define CONFIGURE_GOROUTINES_TASK_VARIABLES \
1952    (2 * CONFIGURE_MAXIMUM_GOROUTINES)
1953
1954  #ifndef CONFIGURE_MAXIMUM_GO_CHANNELS
1955    #define CONFIGURE_MAXIMUM_GO_CHANNELS 500
1956  #endif
1957
1958#else
1959  #define CONFIGURE_GO_INIT_MUTEXES             0
1960  #define CONFIGURE_GO_INIT_CONDITION_VARIABLES 0
1961  #define CONFIGURE_MAXIMUM_GOROUTINES          0
1962  #define CONFIGURE_GOROUTINES_TASK_VARIABLES   0
1963  #define CONFIGURE_MAXIMUM_GO_CHANNELS         0
1964#endif
1965
1966#ifndef RTEMS_SCHEDSIM
1967/**
1968 * This macro specifies the amount of memory to be reserved for the
1969 * Newlib C Library reentrancy structure -- if we are using newlib.
1970 */
1971
1972#if (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY))
1973  #define CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB \
1974    _Configure_From_workspace(sizeof(struct _reent))
1975#else
1976  #define CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB 0
1977#endif
1978
1979#else
1980  #define CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB 0
1981#endif
1982
1983/**
1984 * This is so we can account for tasks with stacks greater than minimum
1985 * size.  This is in bytes.
1986 */
1987#ifndef CONFIGURE_EXTRA_TASK_STACKS
1988  #define CONFIGURE_EXTRA_TASK_STACKS 0
1989#endif
1990
1991/*
1992 *  Calculate the RAM size based on the maximum number of objects configured.
1993 */
1994
1995#ifndef CONFIGURE_EXECUTIVE_RAM_SIZE
1996
1997/**
1998 * Account for allocating the following per object
1999 *   + array of object control structures
2000 *   + local pointer table -- pointer per object plus a zero'th
2001 *     entry in the local pointer table.
2002 */
2003
2004#define CONFIGURE_MEMORY_FOR_TASKS(_tasks, _number_FP_tasks) \
2005  ( \
2006    _Configure_Object_RAM(_tasks, sizeof(Thread_Control)) \
2007      + _Configure_Max_Objects(_tasks) \
2008        * ( \
2009            CONFIGURE_MEMORY_PER_TASK_FOR_CLASSIC_API \
2010              + CONFIGURE_MEMORY_PER_TASK_FOR_NEWLIB \
2011              + CONFIGURE_MEMORY_PER_TASK_FOR_POSIX_API \
2012              + CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER \
2013              + _Configure_From_workspace( \
2014                (CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1) * sizeof(void *) \
2015              ) \
2016          ) \
2017      + _Configure_Max_Objects(_number_FP_tasks) \
2018        * _Configure_From_workspace(CONTEXT_FP_SIZE) \
2019        * (CONTEXT_FP_SIZE != 0) \
2020  )
2021
2022/**
2023 * This defines the amount of memory configured for the multiprocessing
2024 * support required by this application.
2025 */
2026#ifdef CONFIGURE_MP_APPLICATION
2027  #define CONFIGURE_MEMORY_FOR_MP \
2028    (CONFIGURE_MEMORY_FOR_PROXIES(CONFIGURE_MP_MAXIMUM_PROXIES) + \
2029     CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS( \
2030             CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS) + \
2031     CONFIGURE_MEMORY_FOR_TASKS(1, 1) \
2032  )
2033#else
2034  #define CONFIGURE_MEMORY_FOR_MP  0
2035#endif
2036
2037/**
2038 * The following macro is used to calculate the memory allocated by RTEMS
2039 * for the message buffers associated with a particular message queue.
2040 * There is a fixed amount of overhead per message.
2041 */
2042#define CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(_messages, _size) \
2043    _Configure_From_workspace( \
2044      (_messages) * ((_size) + sizeof(CORE_message_queue_Buffer_control)))
2045
2046/**
2047 * This macros is set to the amount of memory required for pending message
2048 * buffers in bytes.  It should be constructed by adding together a
2049 * set of values determined by CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE.
2050 */
2051#ifndef CONFIGURE_MESSAGE_BUFFER_MEMORY
2052  #define CONFIGURE_MESSAGE_BUFFER_MEMORY 0
2053#endif
2054
2055/**
2056 * This macro is available just in case the confdefs.h file underallocates
2057 * memory for a particular application.  This lets the user add some extra
2058 * memory in case something broken and underestimates.
2059 *
2060 * It is also possible for cases where confdefs.h overallocates memory,
2061 * you could substract memory from the allocated.  The estimate is just
2062 * that, an estimate, and assumes worst case alignment and padding on
2063 * each allocated element.  So in some cases it could be too conservative.
2064 *
2065 * NOTE: Historically this was used for message buffers.
2066 */
2067#ifndef CONFIGURE_MEMORY_OVERHEAD
2068  #define CONFIGURE_MEMORY_OVERHEAD 0
2069#endif
2070
2071/**
2072 * On architectures that use Simple Vectored Interrupts, it is RTEMS
2073 * responsibility to allocate the vector table.  This avoids reserving
2074 * the memory on architectures that use the Programmable Interrupt
2075 * Controller Vectored Interrupts.
2076 */
2077#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
2078  /*
2079   *  This is a (hopefully) temporary hack.  On the mips, the number of
2080   *  vectors is NOT statically defined.  But it has to be statically
2081   *  defined for this to work.  This is an issue looking for a nice
2082   *  solution.
2083   */
2084  #if defined(__mips__)
2085    #define CONFIGURE_INTERRUPT_VECTOR_TABLE \
2086      _Configure_From_workspace( (sizeof(ISR_Handler_entry) * 256))
2087  #else
2088    #define CONFIGURE_INTERRUPT_VECTOR_TABLE \
2089      _Configure_From_workspace( \
2090        (sizeof(ISR_Handler_entry) * ISR_NUMBER_OF_VECTORS))
2091  #endif
2092#else
2093  #define CONFIGURE_INTERRUPT_VECTOR_TABLE 0
2094#endif
2095
2096/**
2097 * RTEMS uses one instance of an internal mutex class.  This accounts
2098 * for that mutex
2099 */
2100#define CONFIGURE_API_MUTEX_MEMORY \
2101  _Configure_Object_RAM(1, sizeof(API_Mutex_Control))
2102
2103/**
2104 * This calculates the amount of memory reserved for the IDLE tasks.
2105 * In an SMP system, each CPU core has its own idle task.
2106 */
2107#if defined(RTEMS_SMP)
2108  #define CONFIGURE_IDLE_TASKS_COUNT CONFIGURE_SMP_MAXIMUM_PROCESSORS
2109#else
2110  #define CONFIGURE_IDLE_TASKS_COUNT 1
2111#endif
2112
2113/**
2114 * This defines the formula used to compute the amount of memory
2115 * reserved for IDLE task control structures.
2116 */
2117#define CONFIGURE_MEMORY_FOR_IDLE_TASK \
2118  CONFIGURE_MEMORY_FOR_TASKS(CONFIGURE_IDLE_TASKS_COUNT, 0)
2119
2120/**
2121 * This macro accounts for general RTEMS system overhead.
2122 */
2123#define CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \
2124  ( CONFIGURE_MEMORY_FOR_IDLE_TASK +                /* IDLE and stack */ \
2125    CONFIGURE_MEMORY_FOR_SCHEDULER +                /* Scheduler */ \
2126    CONFIGURE_INTERRUPT_VECTOR_TABLE +             /* interrupt vectors */ \
2127    CONFIGURE_INTERRUPT_STACK_MEMORY +             /* interrupt stack */ \
2128    CONFIGURE_API_MUTEX_MEMORY                     /* allocation mutex */ \
2129  )
2130
2131/**
2132 * This macro provides a summation of the various task and thread
2133 * requirements.
2134 */
2135#define CONFIGURE_TOTAL_TASKS_AND_THREADS \
2136   (CONFIGURE_TASKS + \
2137    CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_ADA_TASKS + \
2138    CONFIGURE_MAXIMUM_GOROUTINES)
2139
2140/**
2141 * This macro reserves the memory required by the statically configured
2142 * user extensions.
2143 */
2144#define CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS \
2145  (CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS == 0 ? 0 : \
2146    _Configure_From_workspace( \
2147      CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \
2148        * sizeof(User_extensions_Switch_control) \
2149    ))
2150
2151/**
2152 * This macro provides a summation of the memory required by the
2153 * Classic API as configured.
2154 */
2155#define CONFIGURE_MEMORY_FOR_CLASSIC \
2156  (CONFIGURE_MEMORY_FOR_TASK_VARIABLES(CONFIGURE_MAXIMUM_TASK_VARIABLES + \
2157    CONFIGURE_GOROUTINES_TASK_VARIABLES) + \
2158   CONFIGURE_MEMORY_FOR_TIMERS(CONFIGURE_MAXIMUM_TIMERS + \
2159    CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER ) + \
2160   CONFIGURE_MEMORY_FOR_SEMAPHORES(CONFIGURE_SEMAPHORES) + \
2161   CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(CONFIGURE_MAXIMUM_MESSAGE_QUEUES) + \
2162   CONFIGURE_MEMORY_FOR_PARTITIONS(CONFIGURE_MAXIMUM_PARTITIONS) + \
2163   CONFIGURE_MEMORY_FOR_REGIONS( CONFIGURE_MAXIMUM_REGIONS ) + \
2164   CONFIGURE_MEMORY_FOR_PORTS(CONFIGURE_MAXIMUM_PORTS) + \
2165   CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS) + \
2166   CONFIGURE_MEMORY_FOR_BARRIERS(CONFIGURE_BARRIERS) + \
2167   CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS) \
2168  )
2169
2170#if defined(RTEMS_SMP)
2171  #define CONFIGURE_MEMORY_FOR_SMP \
2172     (CONFIGURE_SMP_MAXIMUM_PROCESSORS * \
2173      _Configure_From_workspace( CONFIGURE_INTERRUPT_STACK_SIZE ) \
2174     )
2175#else
2176  #define CONFIGURE_MEMORY_FOR_SMP 0
2177#endif
2178
2179/**
2180 * This calculates the memory required for the executive workspace.
2181 */
2182#define CONFIGURE_EXECUTIVE_RAM_SIZE \
2183(( \
2184   CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD + \
2185   CONFIGURE_MEMORY_FOR_TASKS( \
2186     CONFIGURE_TOTAL_TASKS_AND_THREADS, CONFIGURE_TOTAL_TASKS_AND_THREADS) + \
2187   CONFIGURE_MEMORY_FOR_CLASSIC + \
2188   CONFIGURE_MEMORY_FOR_POSIX + \
2189   CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS + \
2190   CONFIGURE_MEMORY_FOR_MP + \
2191   CONFIGURE_MEMORY_FOR_SMP + \
2192   CONFIGURE_MESSAGE_BUFFER_MEMORY + \
2193   (CONFIGURE_MEMORY_OVERHEAD * 1024) \
2194) & ~0x7)
2195
2196/*
2197 *  Now account for any extra memory that initialization tasks or threads
2198 *  may have requested.
2199 */
2200
2201/**
2202 * This accounts for any extra memory required by the Classic API
2203 * Initialization Task.
2204 */
2205#if (CONFIGURE_INIT_TASK_STACK_SIZE > CONFIGURE_MINIMUM_TASK_STACK_SIZE)
2206  #define CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART \
2207      (CONFIGURE_INIT_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE)
2208#else
2209  #define CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART 0
2210#endif
2211
2212/**
2213 * This accounts for any extra memory required by the POSIX API
2214 * Initialization Thread.
2215 */
2216#if defined(RTEMS_POSIX_API) && \
2217    (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE > \
2218      CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE)
2219  #define CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART \
2220    (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE - \
2221      CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE)
2222#else
2223  #define CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART 0
2224#endif
2225
2226/**
2227 * This macro provides a summation of the various initialization task
2228 * and thread stack requirements.
2229 */
2230#define CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS \
2231    (CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART + \
2232    CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART)
2233
2234#define CONFIGURE_IDLE_TASKS_STACK \
2235  (CONFIGURE_IDLE_TASKS_COUNT * \
2236    _Configure_From_stackspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) )
2237
2238#define CONFIGURE_TASKS_STACK \
2239  (_Configure_Max_Objects( CONFIGURE_TASKS ) * \
2240    _Configure_From_stackspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) )
2241
2242#define CONFIGURE_POSIX_THREADS_STACK \
2243  (_Configure_Max_Objects( CONFIGURE_MAXIMUM_POSIX_THREADS ) * \
2244    _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
2245
2246#define CONFIGURE_GOROUTINES_STACK \
2247  (_Configure_Max_Objects( CONFIGURE_MAXIMUM_GOROUTINES ) * \
2248    _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
2249
2250#define CONFIGURE_ADA_TASKS_STACK \
2251  (_Configure_Max_Objects( CONFIGURE_MAXIMUM_ADA_TASKS ) * \
2252    _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) )
2253
2254#else /* CONFIGURE_EXECUTIVE_RAM_SIZE */
2255
2256#define CONFIGURE_IDLE_TASKS_STACK 0
2257#define CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS 0
2258#define CONFIGURE_TASKS_STACK 0
2259#define CONFIGURE_POSIX_THREADS_STACK 0
2260#define CONFIGURE_GOROUTINES_STACK 0
2261#define CONFIGURE_ADA_TASKS_STACK 0
2262
2263#if CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK != 0
2264  #error "CONFIGURE_EXECUTIVE_RAM_SIZE defined with request for CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK"
2265#endif
2266
2267#if CONFIGURE_EXTRA_TASK_STACKS != 0
2268  #error "CONFIGURE_EXECUTIVE_RAM_SIZE defined with request for CONFIGURE_EXTRA_TASK_STACKS"
2269#endif
2270
2271#endif /* CONFIGURE_EXECUTIVE_RAM_SIZE */
2272
2273#define CONFIGURE_STACK_SPACE_SIZE \
2274  ( \
2275    CONFIGURE_IDLE_TASKS_STACK + \
2276    CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS + \
2277    CONFIGURE_TASKS_STACK + \
2278    CONFIGURE_POSIX_THREADS_STACK + \
2279    CONFIGURE_GOROUTINES_STACK + \
2280    CONFIGURE_ADA_TASKS_STACK + \
2281    CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK + \
2282    CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS + \
2283    CONFIGURE_EXTRA_TASK_STACKS \
2284  )
2285
2286#ifdef CONFIGURE_INIT
2287  /**
2288   * This is the Classic API Configuration Table.
2289   */
2290  rtems_api_configuration_table Configuration_RTEMS_API = {
2291    CONFIGURE_TASKS,
2292    CONFIGURE_NOTEPADS_ENABLED,
2293    CONFIGURE_MAXIMUM_TIMERS + CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER,
2294    CONFIGURE_SEMAPHORES,
2295    CONFIGURE_MAXIMUM_MESSAGE_QUEUES,
2296    CONFIGURE_MAXIMUM_PARTITIONS,
2297    CONFIGURE_MAXIMUM_REGIONS,
2298    CONFIGURE_MAXIMUM_PORTS,
2299    CONFIGURE_MAXIMUM_PERIODS,
2300    CONFIGURE_BARRIERS,
2301    CONFIGURE_INIT_TASK_TABLE_SIZE,
2302    CONFIGURE_INIT_TASK_TABLE
2303  };
2304
2305  #ifdef RTEMS_POSIX_API
2306    /**
2307     * This is the POSIX API Configuration Table.
2308     */
2309    posix_api_configuration_table Configuration_POSIX_API = {
2310      CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_ADA_TASKS +
2311        CONFIGURE_MAXIMUM_GOROUTINES,
2312      CONFIGURE_MAXIMUM_POSIX_MUTEXES + CONFIGURE_GNAT_MUTEXES +
2313        CONFIGURE_MAXIMUM_POSIX_INTERNAL_MUTEXES +
2314        CONFIGURE_MAXIMUM_ADA_TASKS + CONFIGURE_MAXIMUM_FAKE_ADA_TASKS +
2315        CONFIGURE_GO_INIT_MUTEXES + CONFIGURE_MAXIMUM_GO_CHANNELS,
2316      CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES +
2317        CONFIGURE_MAXIMUM_ADA_TASKS + CONFIGURE_MAXIMUM_FAKE_ADA_TASKS +
2318        CONFIGURE_GO_INIT_CONDITION_VARIABLES + CONFIGURE_MAXIMUM_GO_CHANNELS,
2319      CONFIGURE_MAXIMUM_POSIX_KEYS,
2320      CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS,
2321      CONFIGURE_MAXIMUM_POSIX_TIMERS,
2322      CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS,
2323      CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES,
2324      CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS,
2325      CONFIGURE_MAXIMUM_POSIX_SEMAPHORES,
2326      CONFIGURE_MAXIMUM_POSIX_BARRIERS,
2327      CONFIGURE_MAXIMUM_POSIX_RWLOCKS,
2328      CONFIGURE_MAXIMUM_POSIX_SPINLOCKS,
2329      CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE,
2330      CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME
2331    };
2332  #endif
2333
2334  /**
2335   * This variable specifies the minimum stack size for tasks in an RTEMS
2336   * application.
2337   *
2338   * NOTE: This is left as a simple uint32_t so it can be externed as
2339   *       needed without requring being high enough logical to
2340   *       include the full configuration table.
2341   */
2342  uint32_t rtems_minimum_stack_size =
2343    CONFIGURE_MINIMUM_TASK_STACK_SIZE;
2344
2345  /**
2346   * This variable specifies the maximum priority value that
2347   * a task may have.  This must be a power of 2 between 4
2348   * and 256 and is specified in terms of Classic API
2349   * priority values.
2350   *
2351   * NOTE: This is left as a simple uint8_t so it can be externed as
2352   *       needed without requring being high enough logical to
2353   *       include the full configuration table.
2354   */
2355  uint8_t rtems_maximum_priority = CONFIGURE_MAXIMUM_PRIORITY;
2356
2357  /**
2358   * This is the primary Configuration Table for this application.
2359   */
2360  const rtems_configuration_table Configuration = {
2361    CONFIGURE_EXECUTIVE_RAM_SIZE,             /* required RTEMS workspace */
2362    CONFIGURE_STACK_SPACE_SIZE,               /* required stack space */
2363    CONFIGURE_MAXIMUM_USER_EXTENSIONS,        /* maximum dynamic extensions */
2364    CONFIGURE_MICROSECONDS_PER_TICK,          /* microseconds per clock tick */
2365    1000 * CONFIGURE_MICROSECONDS_PER_TICK,   /* nanoseconds per clock tick */
2366    CONFIGURE_TICKS_PER_TIMESLICE,            /* ticks per timeslice quantum */
2367    CONFIGURE_IDLE_TASK_BODY,                 /* user's IDLE task */
2368    CONFIGURE_IDLE_TASK_STACK_SIZE,           /* IDLE task stack size */
2369    CONFIGURE_INTERRUPT_STACK_SIZE,           /* interrupt stack size */
2370    CONFIGURE_TASK_STACK_ALLOCATOR_INIT,      /* stack allocator init */
2371    CONFIGURE_TASK_STACK_ALLOCATOR,           /* stack allocator */
2372    CONFIGURE_TASK_STACK_DEALLOCATOR,         /* stack deallocator */
2373    CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY,   /* true to clear memory */
2374    #ifdef CONFIGURE_UNIFIED_WORK_AREAS       /* true for unified work areas */
2375      true,
2376    #else
2377      false,
2378    #endif
2379    #ifdef CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE /* true to avoid
2380                                                 work space for thread stack
2381                                                 allocation */
2382      true,
2383    #else
2384      false,
2385    #endif
2386    #ifdef RTEMS_SMP
2387      #ifdef CONFIGURE_SMP_APPLICATION
2388        true,
2389      #else
2390        false,
2391      #endif
2392    #endif
2393    CONFIGURE_MAXIMUM_DRIVERS,                /* maximum device drivers */
2394    CONFIGURE_NUMBER_OF_DRIVERS,              /* static device drivers */
2395    Device_drivers,                           /* pointer to driver table */
2396    CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS,   /* number of static extensions */
2397    CONFIGURE_INITIAL_EXTENSION_TABLE,        /* pointer to static extensions */
2398    #if defined(RTEMS_MULTIPROCESSING)
2399      CONFIGURE_MULTIPROCESSING_TABLE,        /* pointer to MP config table */
2400    #endif
2401    #ifdef RTEMS_SMP
2402      CONFIGURE_SMP_MAXIMUM_PROCESSORS
2403    #endif
2404  };
2405#endif
2406
2407#endif /* CONFIGURE_HAS_OWN_CONFIGURATION_TABLE */
2408
2409#if defined(RTEMS_SMP)
2410 /*
2411  * Instantiate the Per CPU information based upon the user configuration.
2412  */
2413 #if defined(CONFIGURE_INIT)
2414   Per_CPU_Control_envelope _Per_CPU_Information[CONFIGURE_SMP_MAXIMUM_PROCESSORS];
2415 #endif
2416
2417#endif
2418
2419/*
2420 *  If the user has configured a set of Classic API Initialization Tasks,
2421 *  then we need to install the code that runs that loop.
2422 */
2423#ifdef CONFIGURE_INIT
2424  #if defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) || \
2425      defined(CONFIGURE_HAS_OWN_INIT_TASK_TABLE)
2426    void (*_RTEMS_tasks_Initialize_user_tasks_p)(void) =
2427              _RTEMS_tasks_Initialize_user_tasks_body;
2428  #else
2429    void (*_RTEMS_tasks_Initialize_user_tasks_p)(void) = NULL;
2430  #endif
2431#endif
2432
2433/*
2434 *  If the user has configured a set of POSIX Initialization Threads,
2435 *  then we need to install the code that runs that loop.
2436 */
2437#ifdef RTEMS_POSIX_API
2438  #ifdef CONFIGURE_INIT
2439    #if defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) || \
2440        defined(CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE)
2441      void (*_POSIX_Threads_Initialize_user_threads_p)(void) =
2442                _POSIX_Threads_Initialize_user_threads_body;
2443    #else
2444      void (*_POSIX_Threads_Initialize_user_threads_p)(void) = NULL;
2445    #endif
2446  #endif
2447#endif
2448
2449#ifdef __cplusplus
2450}
2451#endif
2452
2453/******************************************************************
2454 ******************************************************************
2455 ******************************************************************
2456 *         CONFIGURATION WARNINGS AND ERROR CHECKING              *
2457 ******************************************************************
2458 ******************************************************************
2459 ******************************************************************
2460 */
2461
2462#if defined(CONFIGURE_CONFDEFS_DEBUG) && defined(CONFIGURE_INIT)
2463  /**
2464   * This is a debug mechanism, so if you need to, the executable will
2465   * have a structure with various partial values.  Add to this as you
2466   * need to.  Viewing this structure in gdb combined with dumping
2467   * the Configuration structures generated should help a lot in tracing
2468   * down errors and analyzing where over and under allocations are.
2469   */
2470  typedef struct {
2471    uint32_t SYSTEM_OVERHEAD;
2472    uint32_t STATIC_EXTENSIONS;
2473    uint32_t INITIALIZATION_THREADS_STACKS;
2474
2475    uint32_t PER_INTEGER_TASK;
2476    uint32_t FP_OVERHEAD;
2477    uint32_t CLASSIC;
2478    uint32_t POSIX;
2479
2480    /* System overhead pieces */
2481    uint32_t INTERRUPT_VECTOR_TABLE;
2482    uint32_t INTERRUPT_STACK_MEMORY;
2483    uint32_t MEMORY_FOR_IDLE_TASK;
2484    uint32_t MEMORY_FOR_SCHEDULER;
2485    uint32_t MEMORY_PER_TASK_FOR_SCHEDULER;
2486
2487    /* Classic API Pieces */
2488    uint32_t CLASSIC_TASKS;
2489    uint32_t TASK_VARIABLES;
2490    uint32_t TIMERS;
2491    uint32_t SEMAPHORES;
2492    uint32_t MESSAGE_QUEUES;
2493    uint32_t PARTITIONS;
2494    uint32_t REGIONS;
2495    uint32_t PORTS;
2496    uint32_t PERIODS;
2497    uint32_t BARRIERS;
2498    uint32_t USER_EXTENSIONS;
2499
2500#ifdef RTEMS_POSIX_API
2501    /* POSIX API Pieces */
2502    uint32_t POSIX_MUTEXES;
2503    uint32_t POSIX_CONDITION_VARIABLES;
2504    uint32_t POSIX_KEYS;
2505    uint32_t POSIX_TIMERS;
2506    uint32_t POSIX_QUEUED_SIGNALS;
2507    uint32_t POSIX_MESSAGE_QUEUES;
2508    uint32_t POSIX_SEMAPHORES;
2509    uint32_t POSIX_BARRIERS;
2510    uint32_t POSIX_SPINLOCKS;
2511    uint32_t POSIX_RWLOCKS;
2512#endif
2513
2514    /* Stack space sizes */
2515    uint32_t IDLE_TASKS_STACK;
2516    uint32_t INITIALIZATION_THREADS_EXTRA_STACKS;
2517    uint32_t TASKS_STACK;
2518    uint32_t POSIX_THREADS_STACK;
2519    uint32_t GOROUTINES_STACK;
2520    uint32_t ADA_TASKS_STACK;
2521    uint32_t EXTRA_MPCI_RECEIVE_SERVER_STACK;
2522    uint32_t EXTRA_TASK_STACKS;
2523  } Configuration_Debug_t;
2524
2525  Configuration_Debug_t Configuration_Memory_Debug = {
2526    /* General Information */
2527    CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD,
2528    CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS,
2529    CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS,
2530    CONFIGURE_MEMORY_FOR_TASKS(1, 0),
2531    CONFIGURE_MEMORY_FOR_TASKS(0, 1),
2532    CONFIGURE_MEMORY_FOR_CLASSIC,
2533    CONFIGURE_MEMORY_FOR_POSIX,
2534
2535    /* System overhead pieces */
2536    CONFIGURE_INTERRUPT_VECTOR_TABLE,
2537    CONFIGURE_INTERRUPT_STACK_MEMORY,
2538    CONFIGURE_MEMORY_FOR_IDLE_TASK,
2539    CONFIGURE_MEMORY_FOR_SCHEDULER,
2540    CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER,
2541
2542    /* Classic API Pieces */
2543    CONFIGURE_MEMORY_FOR_TASKS(CONFIGURE_MAXIMUM_TASKS, 0),
2544    CONFIGURE_MEMORY_FOR_TASK_VARIABLES(CONFIGURE_MAXIMUM_TASK_VARIABLES +
2545      CONFIGURE_GOROUTINES_TASK_VARIABLES),
2546    CONFIGURE_MEMORY_FOR_TIMERS(CONFIGURE_MAXIMUM_TIMERS),
2547    CONFIGURE_MEMORY_FOR_SEMAPHORES(CONFIGURE_SEMAPHORES),
2548    CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(CONFIGURE_MAXIMUM_MESSAGE_QUEUES),
2549    CONFIGURE_MEMORY_FOR_PARTITIONS(CONFIGURE_MAXIMUM_PARTITIONS),
2550    CONFIGURE_MEMORY_FOR_REGIONS( CONFIGURE_MAXIMUM_REGIONS ),
2551    CONFIGURE_MEMORY_FOR_PORTS(CONFIGURE_MAXIMUM_PORTS),
2552    CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS),
2553    CONFIGURE_MEMORY_FOR_BARRIERS(CONFIGURE_BARRIERS),
2554    CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS),
2555
2556#ifdef RTEMS_POSIX_API
2557    /* POSIX API Pieces */
2558    CONFIGURE_MEMORY_FOR_POSIX_MUTEXES( CONFIGURE_MAXIMUM_POSIX_MUTEXES +
2559      CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_MUTEXES),
2560    CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES(
2561      CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES +
2562      CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_CONDITION_VARIABLES),
2563    CONFIGURE_MEMORY_FOR_POSIX_KEYS( CONFIGURE_MAXIMUM_POSIX_KEYS, \
2564                                     CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ),
2565    CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS(
2566      CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ),
2567    CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES(
2568      CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ),
2569    CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ),
2570    CONFIGURE_MEMORY_FOR_POSIX_BARRIERS( CONFIGURE_MAXIMUM_POSIX_BARRIERS ),
2571    CONFIGURE_MEMORY_FOR_POSIX_SPINLOCKS( CONFIGURE_MAXIMUM_POSIX_SPINLOCKS ),
2572    CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( CONFIGURE_MAXIMUM_POSIX_RWLOCKS ),
2573    CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ),
2574#endif
2575
2576    /* Stack space sizes */
2577    CONFIGURE_IDLE_TASKS_STACK,
2578    CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS,
2579    CONFIGURE_TASKS_STACK,
2580    CONFIGURE_POSIX_THREADS_STACK,
2581    CONFIGURE_GOROUTINES_STACK,
2582    CONFIGURE_ADA_TASKS_STACK,
2583    CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK,
2584    CONFIGURE_EXTRA_TASK_STACKS
2585  };
2586#endif
2587
2588/*
2589 *  Make sure a task/thread of some sort is configured.
2590 *
2591 *  When analyzing RTEMS to find the smallest possible of memory
2592 *  that must be allocated, you probably do want to configure 0
2593 *  tasks/threads so there is a smaller set of calls to _Workspace_Allocate
2594 *  to analyze.
2595 */
2596#if !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION)
2597  #if (CONFIGURE_MAXIMUM_TASKS == 0) && \
2598      (CONFIGURE_MAXIMUM_POSIX_THREADS == 0) && \
2599      (CONFIGURE_MAXIMUM_ADA_TASKS == 0) && \
2600      (CONFIGURE_MAXIMUM_GOROUTINES == 0)
2601    #error "CONFIGURATION ERROR: No tasks or threads configured!!"
2602  #endif
2603#endif
2604
2605#ifndef RTEMS_SCHEDSIM
2606/*
2607 *  Make sure at least one of the initialization task/thread
2608 *  tables was defined.
2609 */
2610#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) && \
2611    !defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) && \
2612    !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION)
2613#error "CONFIGURATION ERROR: No initialization tasks or threads configured!!"
2614#endif
2615#endif
2616
2617/*
2618 *  If the user is trying to configure a multiprocessing application and
2619 *  RTEMS was not configured and built multiprocessing, then error out.
2620 */
2621#if defined(CONFIGURE_MP_APPLICATION) && \
2622    !defined(RTEMS_MULTIPROCESSING)
2623#error "CONFIGURATION ERROR: RTEMS not configured for multiprocessing!!"
2624#endif
2625
2626/*
2627 *  If an attempt was made to configure POSIX objects and
2628 *  the POSIX API was not configured into RTEMS, error out.
2629 */
2630#if !defined(RTEMS_POSIX_API)
2631  #if ((CONFIGURE_MAXIMUM_POSIX_THREADS != 0) || \
2632       (CONFIGURE_MAXIMUM_POSIX_MUTEXES != 0) || \
2633       (CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES != 0) || \
2634       (CONFIGURE_MAXIMUM_POSIX_KEYS != 0) || \
2635       (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS != 0) || \
2636       (CONFIGURE_MAXIMUM_POSIX_TIMERS != 0) || \
2637       (CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS != 0) || \
2638       (CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES != 0) || \
2639       (CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS != 0) || \
2640       (CONFIGURE_MAXIMUM_POSIX_SEMAPHORES != 0) || \
2641       (CONFIGURE_MAXIMUM_POSIX_BARRIERS != 0) || \
2642       (CONFIGURE_MAXIMUM_POSIX_SPINLOCKS != 0) || \
2643       (CONFIGURE_MAXIMUM_POSIX_RWLOCKS != 0) || \
2644      defined(CONFIGURE_POSIX_INIT_THREAD_TABLE))
2645  #error "CONFIGURATION ERROR: POSIX API support not configured!!"
2646  #endif
2647#endif
2648
2649#if !defined(RTEMS_SCHEDSIM)
2650  #if !defined(CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE)
2651    /*
2652     *  You must either explicity include or exclude the clock driver.
2653     *  It is such a common newbie error to leave it out.  Maybe this
2654     *  will put an end to it.
2655     *
2656     *  NOTE: If you are using the timer driver, it is considered
2657     *        mutually exclusive with the clock driver because the
2658     *        drivers are assumed to use the same "timer" hardware
2659     *        on many boards.
2660     */
2661    #if !defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) && \
2662        !defined(CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER) && \
2663        !defined(CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER)
2664      #error "CONFIGURATION ERROR: Do you want the clock driver or not?!?"
2665     #endif
2666
2667    /*
2668     * Only one of the following three configuration parameters should be
2669     * defined at a time.
2670     */
2671    #if ((defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) + \
2672          defined(CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER) + \
2673          defined(CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER)) > 1)
2674       #error "CONFIGURATION ERROR: More than one clock/timer driver configuration parameter specified?!?"
2675    #endif
2676  #endif /* !defined(CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE) */
2677#endif   /* !defined(RTEMS_SCHEDSIM) */
2678
2679/*
2680 *  These names have been obsoleted so make the user application stop compiling
2681 */
2682#if defined(CONFIGURE_TEST_NEEDS_TIMER_DRIVER) || \
2683    defined(CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER) || \
2684    defined(CONFIGURE_TEST_NEEDS_CLOCK_DRIVER) || \
2685    defined(CONFIGURE_TEST_NEEDS_RTC_DRIVER) || \
2686    defined(CONFIGURE_TEST_NEEDS_STUB_DRIVER)
2687#error "CONFIGURATION ERROR: CONFIGURE_TEST_XXX constants are obsolete"
2688#endif
2689
2690/*
2691 *  Validate the configured maximum priority
2692 */
2693#if ((CONFIGURE_MAXIMUM_PRIORITY != 3) && \
2694     (CONFIGURE_MAXIMUM_PRIORITY != 7) && \
2695     (CONFIGURE_MAXIMUM_PRIORITY != 15) && \
2696     (CONFIGURE_MAXIMUM_PRIORITY != 31) && \
2697     (CONFIGURE_MAXIMUM_PRIORITY != 63) && \
2698     (CONFIGURE_MAXIMUM_PRIORITY != 127) && \
2699     (CONFIGURE_MAXIMUM_PRIORITY != 255))
2700  #error "Maximum priority is not 1 less than a power of 2 between 4 and 256"
2701#endif
2702
2703#if (CONFIGURE_MAXIMUM_PRIORITY > PRIORITY_DEFAULT_MAXIMUM)
2704  #error "Maximum priority configured higher than supported by target."
2705#endif
2706
2707/*
2708 *  If you have fewer POSIX Message Queue Descriptors than actual
2709 *  POSIX Message Queues, then you will not be able to open all the
2710 *  queues.
2711 */
2712#if (CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS < \
2713     CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES)
2714  #error "Fewer POSIX Message Queue descriptors than Queues!"
2715#endif
2716
2717/*
2718 * POSIX Key pair shouldn't be less than POSIX Key, which is highly
2719 * likely to be error.
2720 */
2721#if defined(RTEMS_POSIX_API)
2722    #if (CONFIGURE_MAXIMUM_POSIX_KEYS != 0) && \
2723      (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS != 0)
2724      #if (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS < \
2725        CONFIGURE_MAXIMUM_POSIX_KEYS)
2726      #error "Fewer POSIX Key pairs than POSIX Key!"
2727      #endif
2728    #endif
2729#endif
2730
2731#endif
2732/* end of include file */
Note: See TracBrowser for help on using the repository browser.