source: rtems/cpukit/sapi/include/confdefs.h @ b2b56cb9

4.115
Last change on this file since b2b56cb9 was b2b56cb9, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/09/11 at 06:18:57

2011-02-09 Ralf Corsépius <ralf.corsepius@…>

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