File indexing completed on 2025-05-11 08:24:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #ifdef HAVE_CONFIG_H
0037 #include "config.h"
0038 #endif
0039
0040 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
0041
0042 #include <rtems/config.h>
0043 #include <rtems/score/copyrt.h>
0044 #include <rtems/rtems/clock.h>
0045 #include <rtems/rtems/tasksimpl.h>
0046 #include <rtems/rtems/dpmemimpl.h>
0047 #include <rtems/rtems/eventimpl.h>
0048 #include <rtems/extensionimpl.h>
0049 #include <rtems/fatal.h>
0050 #include <rtems/init.h>
0051 #include <rtems/score/isr.h>
0052 #include <rtems/rtems/intr.h>
0053 #include <rtems/io.h>
0054 #include <rtems/rtems/messageimpl.h>
0055 #if defined(RTEMS_MULTIPROCESSING)
0056 #include <rtems/rtems/mp.h>
0057 #include <rtems/score/mpciimpl.h>
0058 #endif
0059 #include <rtems/rtems/partimpl.h>
0060 #include <rtems/score/priority.h>
0061 #include <rtems/rtems/ratemonimpl.h>
0062 #include <rtems/rtems/regionimpl.h>
0063 #include <rtems/rtems/semimpl.h>
0064 #include <rtems/rtems/signal.h>
0065 #include <rtems/score/scheduler.h>
0066 #include <rtems/score/sysstate.h>
0067 #include <rtems/score/thread.h>
0068 #include <rtems/rtems/timerimpl.h>
0069 #include <rtems/score/todimpl.h>
0070 #include <rtems/score/userextimpl.h>
0071 #include <rtems/score/watchdogimpl.h>
0072 #include <rtems/score/wkspace.h>
0073 #if defined(RTEMS_SMP)
0074 #include <rtems/score/smp.h>
0075 #endif
0076
0077 #include <stdlib.h>
0078 #include <stdio.h>
0079 #include <unistd.h>
0080 #include <tmacros.h>
0081
0082 #include "system.h"
0083
0084
0085 int getint( void );
0086 void size_rtems(int mode);
0087 void help_size(void);
0088 void print_formula(void);
0089
0090
0091
0092
0093
0094
0095
0096 #define HEAP_OVHD 16
0097 #define NAME_PTR_SIZE 8
0098
0099
0100
0101
0102 #include <rtems/score/prioritybitmapimpl.h>
0103 #include <rtems/score/schedulerpriority.h>
0104
0105
0106
0107
0108 #define SCHEDULER_TASK_WKSP (sizeof(Scheduler_priority_Node))
0109
0110
0111
0112
0113
0114 #define SCHEDULER_WKSP_SIZE \
0115 (sizeof(Scheduler_priority_Context) + \
0116 RTEMS_MAXIMUM_PRIORITY * sizeof(Chain_Control ))
0117
0118
0119 #define PER_TASK \
0120 (long) (sizeof (Thread_Control) + \
0121 NAME_PTR_SIZE + HEAP_OVHD + sizeof( RTEMS_API_Control ) + \
0122 SCHEDULER_TASK_WKSP )
0123 #define PER_SEMAPHORE \
0124 (long) (sizeof (Semaphore_Control) + NAME_PTR_SIZE)
0125 #define PER_TIMER \
0126 (long) (sizeof (Timer_Control) + NAME_PTR_SIZE)
0127 #define PER_MSGQ \
0128 (long) (sizeof (Message_queue_Control) + NAME_PTR_SIZE)
0129 #define PER_REGN \
0130 (long) (sizeof (Region_Control) + NAME_PTR_SIZE)
0131 #define PER_PART \
0132 (long) (sizeof (Partition_Control) + NAME_PTR_SIZE)
0133 #define PER_PERIOD \
0134 (long) (sizeof (Rate_monotonic_Control) + NAME_PTR_SIZE)
0135 #define PER_PORT \
0136 (long) (sizeof (Dual_ported_memory_Control) + NAME_PTR_SIZE)
0137 #define PER_EXTENSION \
0138 (long) (sizeof (Extension_Control) + NAME_PTR_SIZE)
0139
0140 #define PER_DRV (long) (0)
0141 #define PER_FPTASK (long) (CONTEXT_FP_SIZE)
0142 #define PER_GOBTBL (long) (sizeof (Chain_Control)*4)
0143 #define PER_NODE (long) PER_GOBTBL
0144 #if defined(RTEMS_MULTIPROCESSING)
0145 #define PER_GOBJECT (long) (sizeof (Objects_MP_Control))
0146 #else
0147 #define PER_GOBJECT (long) 0
0148 #endif
0149 #define PER_PROXY (long) (sizeof (Thread_Proxy_control))
0150
0151 #if !defined(RTEMS_MULTIPROCESSING) || (CPU_ALL_TASKS_ARE_FP != TRUE)
0152 #define MPCI_RECEIVE_SERVER_FP (long) 0
0153 #else
0154 #define MPCI_RECEIVE_SERVER_FP (long) (sizeof( Context_Control_fp ))
0155 #endif
0156
0157 #if (CPU_IDLE_TASK_IS_FP == TRUE)
0158 #define SYSTEM_IDLE_FP (long) (sizeof( Context_Control_fp ))
0159 #else
0160 #define SYSTEM_IDLE_FP (long) 0
0161 #endif
0162
0163 #if !defined(RTEMS_MULTIPROCESSING)
0164 #define MPCI_RECEIVE_SERVER_STACK_SIZE 0
0165 #endif
0166
0167 #if defined(RTEMS_MULTIPROCESSING)
0168 #define MPCI_RECEIVE_SERVER_STACK_SIZE \
0169
0170 #define MP_SYSTEM_TASKS \
0171 (STACK_MINIMUM_SIZE + CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK + \
0172 sizeof(Thread_Control) + \
0173 MPCI_RECEIVE_SERVER_FP)
0174
0175 extern CORE_semaphore_Control _MPCI_Semaphore;
0176 #else
0177 #define MP_SYSTEM_TASKS 0
0178 #endif
0179
0180
0181
0182
0183
0184 #define SYSTEM_TASKS \
0185 (STACK_MINIMUM_SIZE + sizeof(Thread_Control) + SYSTEM_IDLE_FP + \
0186 MP_SYSTEM_TASKS)
0187
0188
0189 uint32_t sys_req;
0190
0191 void size_rtems(
0192 int mode
0193 )
0194 {
0195 int uninitialized = 0;
0196 int initialized = 0;
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248 sys_req = SYSTEM_TASKS +
0249 NAME_PTR_SIZE +
0250 SCHEDULER_WKSP_SIZE +
0251 NAME_PTR_SIZE +
0252 NAME_PTR_SIZE +
0253 NAME_PTR_SIZE +
0254 NAME_PTR_SIZE +
0255 NAME_PTR_SIZE +
0256 NAME_PTR_SIZE +
0257 NAME_PTR_SIZE +
0258 NAME_PTR_SIZE +
0259 PER_NODE;
0260
0261 uninitialized =
0262 0 +
0263
0264 0 +
0265
0266 0 +
0267
0268 0 +
0269
0270 0 +
0271
0272 0 +
0273
0274 0 +
0275
0276 (sizeof _Thread_Dispatch_necessary) +
0277
0278 0 +
0279
0280 (sizeof _Dual_ported_memory_Information) +
0281
0282 #if defined(RTEMS_MULTIPROCESSING)
0283 0 +
0284 #endif
0285
0286 (sizeof _Extension_Information) +
0287
0288 0 +
0289
0290 0 +
0291
0292 0 +
0293
0294 0 +
0295
0296 (sizeof _ISR_Nest_level) +
0297 #if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
0298 (sizeof _ISR_Vector_table) +
0299 #endif
0300
0301 (sizeof _Message_queue_Information) +
0302
0303 0 +
0304
0305 #if defined(RTEMS_MULTIPROCESSING)
0306 0 +
0307 #endif
0308
0309 #if defined(RTEMS_MULTIPROCESSING)
0310 (sizeof _MPCI_Remote_blocked_threads) +
0311 (sizeof _MPCI_Semaphore) +
0312 (sizeof _MPCI_table) +
0313 (sizeof _MPCI_Receive_server_tcb) +
0314 (sizeof _MPCI_Packet_processors) +
0315 #endif
0316
0317 #if defined(RTEMS_MULTIPROCESSING)
0318 0 +
0319 #endif
0320
0321 #if defined(RTEMS_MULTIPROCESSING)
0322 0 +
0323 #endif
0324
0325 #if defined(RTEMS_MULTIPROCESSING)
0326 0 +
0327 #endif
0328
0329 (sizeof _Objects_Local_node) +
0330 (sizeof _Objects_Maximum_nodes) +
0331 (sizeof _Objects_Information_table) +
0332
0333 0 +
0334
0335 (sizeof _Partition_Information) +
0336
0337 #if defined(RTEMS_MULTIPROCESSING)
0338 0 +
0339 #endif
0340
0341 (_SMP_Get_processor_maximum() * sizeof(Per_CPU_Control)) +
0342
0343 (sizeof _Rate_monotonic_Information) +
0344
0345 (sizeof _Region_Information) +
0346
0347 #if defined(RTEMS_MULTIPROCESSING)
0348 0 +
0349 #endif
0350
0351
0352
0353 (sizeof _Semaphore_Information) +
0354
0355 #if defined(RTEMS_MULTIPROCESSING)
0356 0 +
0357 #endif
0358
0359 0 +
0360
0361 0 +
0362
0363 0 +
0364
0365 0 +
0366
0367 0 +
0368
0369 (sizeof _System_state_Current) +
0370 #if defined(RTEMS_MULTIPROCESSING)
0371 (sizeof _System_state_Is_multiprocessing) +
0372 #endif
0373
0374 #if defined(RTEMS_MULTIPROCESSING)
0375 0 +
0376 #endif
0377
0378 (sizeof _RTEMS_tasks_Information) +
0379
0380 (sizeof _Thread_Dispatch_disable_level) +
0381 (sizeof _Thread_Executing) +
0382 (sizeof _Thread_Heir) +
0383 #if (CPU_HARDWARE_FP == 1) || (CPU_SOFTWARE_FP == 1)
0384 (sizeof _Thread_Allocated_fp) +
0385 #endif
0386 (sizeof _Thread_Information) +
0387
0388
0389
0390 (sizeof _Timer_Information) +
0391
0392 0 +
0393
0394 0 +
0395
0396 (sizeof _User_extensions_List) +
0397
0398 (sizeof _Watchdog_Ticks_since_boot) +
0399
0400 (sizeof _Workspace_Area);
0401
0402 #ifndef unix
0403
0404 #ifdef __i386__
0405
0406
0407 uninitialized += (sizeof _CPU_Null_fp_context);
0408
0409 uninitialized += (sizeof _CPU_Interrupt_stack_low) +
0410 (sizeof _CPU_Interrupt_stack_high);
0411
0412 #endif
0413
0414 #ifdef __mc68000__
0415
0416
0417 uninitialized += (sizeof _CPU_Interrupt_stack_low) +
0418 (sizeof _CPU_Interrupt_stack_high);
0419
0420 #endif
0421
0422 #ifdef __sparc__
0423
0424
0425 uninitialized += (sizeof _CPU_Interrupt_stack_low) +
0426 (sizeof _CPU_Interrupt_stack_high);
0427
0428 #endif
0429
0430
0431 #ifdef no_cpu
0432
0433
0434 uninitialized += (sizeof _CPU_Null_fp_context) +
0435 (sizeof _CPU_Interrupt_stack_low) +
0436 (sizeof _CPU_Interrupt_stack_high) +
0437 (sizeof _CPU_Thread_dispatch_pointer);
0438
0439 #endif
0440
0441 #ifdef __PPC__
0442
0443
0444 uninitialized += (sizeof _CPU_Interrupt_stack_low) +
0445 (sizeof _CPU_Interrupt_stack_high);
0446
0447 #endif
0448 #endif
0449
0450 initialized +=
0451 (strlen(_Copyright_Notice)+1) +
0452 (strlen(_RTEMS_version)+1);
0453
0454
0455
0456 #ifndef unix
0457 #ifdef __sparc__
0458
0459 initialized += (sizeof _CPU_Trap_slot_template);
0460
0461 #endif
0462 #endif
0463
0464 puts( "" );
0465
0466 if ( mode == 0 ) help_size();
0467 else print_formula();
0468
0469 printf( "\n" );
0470 printf( "RTEMS uninitialized data consumes %d bytes\n", uninitialized );
0471 printf( "RTEMS initialized data consumes %d bytes\n", initialized );
0472
0473 }
0474
0475 void help_size()
0476 {
0477 int c = '\0';
0478 int break_loop;
0479 int total_size;
0480 int task_stacks;
0481 int interrupt_stack;
0482 int maximum_tasks, size_tasks;
0483 int maximum_sems, size_sems;
0484 int maximum_timers, size_timers;
0485 int maximum_msgqs, size_msgqs;
0486 int maximum_msgs, size_msgs_overhead;
0487 int maximum_regns, size_regns;
0488 int maximum_parts, size_parts;
0489 int maximum_ports, size_ports;
0490 int maximum_periods, size_periods;
0491 int maximum_extensions, size_extensions;
0492 int maximum_drvs, size_drvs;
0493 int maximum_fps, size_fps;
0494 int maximum_nodes, size_nodes;
0495 int maximum_gobjs, size_gobjs;
0496 int maximum_proxies, size_proxies;
0497
0498 total_size = sys_req;
0499 printf( "What is maximum_tasks? " );
0500 maximum_tasks = getint();
0501 size_tasks = PER_TASK * maximum_tasks;
0502 total_size += size_tasks;
0503
0504 printf( "What is maximum_semaphores? " );
0505 maximum_sems = getint();
0506 size_sems = PER_SEMAPHORE * maximum_sems;
0507 total_size += size_sems;
0508
0509 printf( "What is maximum_timers? " );
0510 maximum_timers = getint();
0511 size_timers = PER_TIMER * maximum_timers;
0512 total_size += size_timers;
0513
0514 printf( "What is maximum_message_queues? " );
0515 maximum_msgqs = getint();
0516 size_msgqs = PER_MSGQ * maximum_msgqs;
0517 total_size += size_msgqs;
0518
0519 printf( "What is maximum_messages? XXXX " );
0520 maximum_msgs = getint();
0521 size_msgs_overhead = 0;
0522 total_size += size_msgs_overhead;
0523
0524 printf( "What is maximum_regions? " );
0525 maximum_regns = getint();
0526 size_regns = PER_REGN * maximum_regns;
0527 total_size += size_regns;
0528
0529 printf( "What is maximum_partitions? " );
0530 maximum_parts = getint();
0531 size_parts = PER_PART * maximum_parts;
0532 total_size += size_parts;
0533
0534 printf( "What is maximum_ports? " );
0535 maximum_ports = getint();
0536 size_ports = PER_PORT * maximum_ports;
0537 total_size += size_ports;
0538
0539 printf( "What is maximum_periods? " );
0540 maximum_periods = getint();
0541 size_periods = PER_PERIOD * maximum_periods;
0542 total_size += size_periods;
0543
0544 printf( "What is maximum_extensions? " );
0545 maximum_extensions = getint();
0546 size_extensions = PER_EXTENSION * maximum_extensions;
0547 total_size += size_extensions;
0548
0549 printf( "What is number_of_device_drivers? " );
0550 maximum_drvs = getint();
0551 size_drvs = PER_DRV * maximum_drvs;
0552 total_size += size_drvs;
0553
0554 printf( "What will be total stack requirement for all tasks? " );
0555 task_stacks = getint();
0556 total_size += task_stacks;
0557
0558 printf( "What is the size of the interrupt stack? " );
0559 interrupt_stack = getint();
0560 total_size += interrupt_stack;
0561
0562 printf( "How many tasks will be created with the FP flag? " );
0563 maximum_fps = getint();
0564 size_fps = PER_FPTASK * maximum_fps;
0565 total_size += size_fps;
0566
0567 printf( "Is this a single processor system? " );
0568 for ( break_loop=0 ; !break_loop; c = getchar() ) {
0569 switch ( c ) {
0570 case 'Y': case 'y':
0571 case 'N': case 'n':
0572 break_loop = 1;
0573 break;
0574 }
0575 }
0576 printf( "%c\n", c );
0577 if ( c == 'n' || c == 'N' ) {
0578 printf( "What is maximum_nodes? " );
0579 maximum_nodes = getint();
0580 size_nodes = PER_NODE * maximum_nodes;
0581 total_size += size_nodes;
0582 printf( "What is maximum_global_objects? " );
0583 maximum_gobjs = getint();
0584 size_gobjs = PER_GOBJECT * maximum_gobjs;
0585 total_size += size_gobjs;
0586 printf( "What is maximum_proxies? " );
0587 maximum_proxies = getint();
0588 size_proxies = PER_PROXY * maximum_proxies;
0589 total_size += size_proxies;
0590 } else {
0591 maximum_nodes = 0;
0592 size_nodes = PER_NODE * 0;
0593 maximum_gobjs = 0;
0594 size_gobjs = PER_GOBJECT * 0;
0595 maximum_proxies = 0;
0596 size_proxies = PER_PROXY * 0;
0597 }
0598
0599 printf( "\n\n" );
0600 printf( " ************** EXECUTIVE WORK SPACE REQUIRED **************\n" );
0601 printf( " Tasks - %03d * %03ld = %ld\n",
0602 maximum_tasks, PER_TASK, (long) size_tasks );
0603 printf( " Semaphores - %03d * %03ld = %ld\n",
0604 maximum_sems, PER_SEMAPHORE, (long) size_sems );
0605 printf( " Timers - %03d * %03ld = %ld\n",
0606 maximum_timers, PER_TIMER, (long) size_timers );
0607 printf( " Msg Queues - %03d * %03ld = %ld\n",
0608 maximum_msgqs, PER_MSGQ, (long) size_msgqs );
0609 printf( " Messages Overhead - %03d * %03d = %ld\n",
0610 maximum_msgs, 0 , (long) size_msgs_overhead );
0611 printf( " Regions - %03d * %03ld = %ld\n",
0612 maximum_regns, PER_REGN, (long) size_regns);
0613 printf( " Partitions - %03d * %03ld = %ld\n",
0614 maximum_parts, PER_PART, (long) size_parts );
0615 printf( " Periods - %03d * %03ld = %ld\n",
0616 maximum_periods, PER_PERIOD, (long) size_periods );
0617 printf( " Extensions - %03d * %03ld = %ld\n",
0618 maximum_extensions, PER_EXTENSION, (long) size_extensions );
0619 printf( " Device Drivers - %03d * %03ld = %ld\n",
0620 maximum_drvs, PER_DRV, (long) size_drvs );
0621
0622 printf( " System Requirements - %04" PRIu32 " = %"PRIu32 "\n",
0623 sys_req, sys_req );
0624
0625 printf( " Floating Point Tasks - %03d * %03ld = %ld\n",
0626 maximum_fps, PER_FPTASK, (long) size_fps );
0627 printf( " Application Task Stacks - = %d\n",
0628 task_stacks );
0629 printf( " Interrupt Stacks - = %d\n",
0630 task_stacks );
0631 printf( " \n" );
0632 printf( " Global object tables - %03d * %03ld = %ld\n",
0633 maximum_nodes, PER_NODE, (long) size_nodes );
0634 printf( " Global objects - %03d * %03ld = %ld\n",
0635 maximum_gobjs, PER_GOBJECT, (long) size_gobjs );
0636 printf( " Proxies - %03d * %03ld = %ld\n",
0637 maximum_proxies, PER_PROXY, (long) size_proxies );
0638 printf( "\n\n" );
0639 printf( " TOTAL = %d bytes\n",
0640 total_size );
0641 }
0642
0643 void print_formula()
0644 {
0645 printf( " ************** EXECUTIVE WORK SPACE FORMULA **************\n" );
0646 printf( " Tasks - maximum_tasks * %ld\n", PER_TASK );
0647 printf( " Timers - maximum_timers * %ld\n", PER_TIMER );
0648 printf( " Semaphores - maximum_semaphores * %ld\n", PER_SEMAPHORE);
0649 printf( " Message Queues - maximum_message_queues * %ld\n", PER_MSGQ );
0650 printf( " Messages -\n");
0651 printf( " Regions - maximum_regions * %ld\n", PER_REGN );
0652 printf( " Partitions - maximum_partitions * %ld\n", PER_PART );
0653 printf( " Ports - maximum_ports * %ld\n", PER_PORT );
0654 printf( " Periods - maximum_periods * %ld\n", PER_PORT );
0655 printf( " Extensions - maximum_extensions * %ld\n", PER_EXTENSION );
0656 printf( " Device Drivers - number_of_device_drivers * %ld\n", PER_DRV);
0657 printf( " System Requirements - %" PRIu32 "\n", sys_req );
0658 printf( " Floating Point Tasks - FPMASK Tasks * %ld\n", PER_FPTASK );
0659 printf( " User's Tasks' Stacks -\n" );
0660 printf( " Interrupt Stack -\n" );
0661 printf( " \n" );
0662 printf( " Global object tables - maximum_nodes * %ld\n", PER_NODE );
0663 printf( " Global objects - maximum_global_objects * %ld\n", PER_GOBJECT );
0664 printf( " Proxies - maximum_proxies * %ld\n", PER_PROXY );
0665 }