source: rtems/testsuites/sptests/spsize/size.c

Last change on this file was 24f8915, checked in by Sebastian Huber <sebastian.huber@…>, on Dec 12, 2019 at 6:11:54 AM

config: Add _MPCI_Configuration

Replace the user MPCI configuration table with a system provided
_MPCI_Configuration.

Update #3735.

  • Property mode set to 100644
File size: 19.5 KB
Line 
1/**
2 *  @file
3 *
4 *  This program is run to determine the data space and work space
5 *  requirements of the current version of RTEMS.
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/config.h>
22#include <rtems/score/copyrt.h>
23#include <rtems/rtems/clock.h>
24#include <rtems/rtems/tasksimpl.h>
25#include <rtems/rtems/dpmemimpl.h>
26#include <rtems/rtems/eventimpl.h>
27#include <rtems/extensionimpl.h>
28#include <rtems/fatal.h>
29#include <rtems/init.h>
30#include <rtems/score/isr.h>
31#include <rtems/rtems/intr.h>
32#include <rtems/io.h>
33#include <rtems/rtems/messageimpl.h>
34#if defined(RTEMS_MULTIPROCESSING)
35#include <rtems/rtems/mp.h>
36#include <rtems/score/mpciimpl.h>
37#endif
38#include <rtems/rtems/partimpl.h>
39#include <rtems/score/priority.h>
40#include <rtems/rtems/ratemonimpl.h>
41#include <rtems/rtems/regionimpl.h>
42#include <rtems/rtems/semimpl.h>
43#include <rtems/rtems/signal.h>
44#include <rtems/score/scheduler.h>
45#include <rtems/score/sysstate.h>
46#include <rtems/score/thread.h>
47#include <rtems/rtems/timerimpl.h>
48#include <rtems/score/todimpl.h>
49#include <rtems/score/userextimpl.h>
50#include <rtems/score/watchdogimpl.h>
51#include <rtems/score/wkspace.h>
52#if defined(RTEMS_SMP)
53  #include <rtems/score/smp.h>
54#endif
55
56#include <stdlib.h>
57#include <stdio.h>
58#include <unistd.h>
59#include <tmacros.h>
60
61#include "system.h"
62
63/* external function prototypes */
64int getint( void );
65void size_rtems(int mode);
66void help_size(void);
67void print_formula(void);
68
69
70/* These are always defined by the executive.
71 *
72 * #include <rtems/copyrt.h>
73 * #include <rtems/tables.h>
74 */
75#define  HEAP_OVHD        16    /* wasted heap space per task stack */
76#define  NAME_PTR_SIZE     8    /* size of name and pointer table entries */
77
78/*
79 *  This assumes the default Priority Scheduler
80 */
81#include <rtems/score/prioritybitmapimpl.h>
82#include <rtems/score/schedulerpriority.h>
83
84/* Priority scheduling per-thread consumption. Gets
85 * included in the PER_TASK consumption.
86 */
87#define SCHEDULER_TASK_WKSP     (sizeof(Scheduler_priority_Node))
88
89/* Priority scheduling workspace consumption
90 *
91 * Include allocation of ready queue.
92 */
93#define SCHEDULER_WKSP_SIZE  \
94    (sizeof(Scheduler_priority_Context) + \
95     RTEMS_MAXIMUM_PRIORITY * sizeof(Chain_Control ))
96/****** END OF MEMORY USAGE OF DEFAULT PRIORITY SCHEDULER ******/
97
98#define PER_TASK      \
99     (long) (sizeof (Thread_Control) + \
100      NAME_PTR_SIZE + HEAP_OVHD + sizeof( RTEMS_API_Control ) + \
101      SCHEDULER_TASK_WKSP )
102#define PER_SEMAPHORE \
103     (long) (sizeof (Semaphore_Control) + NAME_PTR_SIZE)
104#define PER_TIMER     \
105     (long) (sizeof (Timer_Control) + NAME_PTR_SIZE)
106#define PER_MSGQ      \
107     (long) (sizeof (Message_queue_Control) + NAME_PTR_SIZE)
108#define PER_REGN      \
109     (long) (sizeof (Region_Control) + NAME_PTR_SIZE)
110#define PER_PART      \
111     (long) (sizeof (Partition_Control) + NAME_PTR_SIZE)
112#define PER_PERIOD      \
113     (long) (sizeof (Rate_monotonic_Control) + NAME_PTR_SIZE)
114#define PER_PORT      \
115     (long) (sizeof (Dual_ported_memory_Control) + NAME_PTR_SIZE)
116#define PER_EXTENSION     \
117     (long) (sizeof (Extension_Control) + NAME_PTR_SIZE)
118
119#define PER_DRV       (long) (0)
120#define PER_FPTASK    (long) (CONTEXT_FP_SIZE)
121#define PER_GOBTBL    (long) (sizeof (Chain_Control)*4)
122#define PER_NODE      (long) PER_GOBTBL
123#if defined(RTEMS_MULTIPROCESSING)
124#define PER_GOBJECT   (long) (sizeof (Objects_MP_Control))
125#else
126#define PER_GOBJECT   (long) 0
127#endif
128#define PER_PROXY     (long) (sizeof (Thread_Proxy_control))
129
130#if !defined(RTEMS_MULTIPROCESSING) || (CPU_ALL_TASKS_ARE_FP != TRUE)
131#define MPCI_RECEIVE_SERVER_FP (long) 0
132#else
133#define MPCI_RECEIVE_SERVER_FP (long) (sizeof( Context_Control_fp ))
134#endif
135
136#if (CPU_IDLE_TASK_IS_FP == TRUE)
137#define SYSTEM_IDLE_FP (long) (sizeof( Context_Control_fp ))
138#else
139#define SYSTEM_IDLE_FP (long) 0
140#endif
141
142#if !defined(RTEMS_MULTIPROCESSING)
143#define MPCI_RECEIVE_SERVER_STACK_SIZE 0
144#endif
145
146#if defined(RTEMS_MULTIPROCESSING)
147#define MPCI_RECEIVE_SERVER_STACK_SIZE \
148
149#define MP_SYSTEM_TASKS \
150   (STACK_MINIMUM_SIZE + CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK + \
151    sizeof(Thread_Control) + \
152    MPCI_RECEIVE_SERVER_FP)
153
154extern CORE_semaphore_Control _MPCI_Semaphore;
155#else
156#define MP_SYSTEM_TASKS 0
157#endif
158
159/*
160 *  Idle and the MPCI Receive Server Threads
161 */
162
163#define SYSTEM_TASKS  \
164    (STACK_MINIMUM_SIZE + sizeof(Thread_Control) + SYSTEM_IDLE_FP + \
165     MP_SYSTEM_TASKS)
166
167/* FIXME: uint32_t doesn't seem right */
168uint32_t   sys_req;
169
170void size_rtems(
171  int mode
172)
173{
174int uninitialized = 0;
175int initialized = 0;
176
177/*
178 *  The following data is allocated for each Manager:
179 *
180 *    + Per Manager Object Information
181 *      - local pointer table
182 *      - local name table
183 *      - the object's control blocks
184 *      - global name chains
185 *
186 *  The following is the data allocate from the RTEMS Workspace Area.
187 *  The order indicates the order in which RTEMS allocates it.
188 *
189 *    + Object MP
190 *      - Global Object CB's
191 *    + Thread MP
192 *      - Proxies Chain
193 *    + Scheduler
194 *      - Ready queue
195 *    + Interrupt Manager
196 *      - Interrupt Stack
197 *    + Timer Manager
198 *      - per Manager Object Data
199 *    + Extension Manager
200 *      - per Manager Object Data
201 *    + Message Queue Manager
202 *      - per Manager Object Data
203 *      - Message Buffers
204 *    + Semaphore Manager
205 *      - per Manager Object Data
206 *    + Partition Manager
207 *      - per Manager Object Data
208 *    + Region Manager
209 *      - per Manager Object Data
210 *    + Dual Ported Memory Manager
211 *      - per Manager Object Data
212 *    + Rate Monotonic Manager
213 *      - per Manager Object Data
214 *    + Internal Threads Handler
215 *      - MPCI Receive Server Thread TCB
216 *      - IDLE Thread TCB
217 *      - MPCI Receive Server Thread stack
218 *      - MPCI Receive Server Thread FP area (if CPU requires this)
219 *      - IDLE Thread stack
220 *      - IDLE Thread FP area (if CPU requires this)
221 *
222 *  This does not take into account any CPU dependent alignment requirements.
223 *
224 *  The following calculates the overhead needed by RTEMS from the
225 *  Workspace Area.
226 */
227sys_req = SYSTEM_TASKS        +     /* MPCI Receive Server and IDLE */
228          NAME_PTR_SIZE       +     /* Task Overhead */
229          SCHEDULER_WKSP_SIZE +     /* Scheduler Overhead */
230          NAME_PTR_SIZE       +     /* Timer Overhead */
231          NAME_PTR_SIZE       +     /* Semaphore Overhead */
232          NAME_PTR_SIZE       +     /* Message Queue Overhead */
233          NAME_PTR_SIZE       +     /* Region Overhead */
234          NAME_PTR_SIZE       +     /* Partition Overhead */
235          NAME_PTR_SIZE       +     /* Dual-Ported Memory Overhead */
236          NAME_PTR_SIZE       +     /* Rate Monotonic Overhead */
237          NAME_PTR_SIZE       +     /* Extension Overhead */
238          PER_NODE;                 /* Extra Gobject Table */
239
240uninitialized =
241/*address.h*/   0                                         +
242
243/*asr.h*/       0                                         +
244
245/*attr.h*/      0                                         +
246
247/*bitfield.h*/  0                                         +
248
249/*chain.h*/     0                                         +
250
251/*clock.h*/     0                                         +
252
253/*config.h*/    0                                         +
254
255/*context.h*/   (sizeof _Thread_Dispatch_necessary)        +
256
257/*copyrt.h*/    0                                         +
258
259/*dpmemimpl.h*/ (sizeof _Dual_ported_memory_Information)  +
260
261#if defined(RTEMS_MULTIPROCESSING)
262/*eventmp.h*/   0                                         +
263#endif
264
265/*extensionimpl.h*/ (sizeof _Extension_Information)       +
266
267/*fatal.h*/     0                                         +
268
269/*heap.h*/      0                                         +
270
271/*init.h*/      0                                         +
272
273/*interr.h*/    (sizeof _Internal_errors_What_happened)   +
274
275/*intr.h*/      0                                         +
276
277/*isr.h*/       (sizeof _ISR_Nest_level)                  +
278#if (CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE)
279                (sizeof _ISR_Vector_table)                +
280#endif
281
282/*messageimpl.h*/ (sizeof _Message_queue_Information)     +
283
284/*modes.h*/     0                                         +
285
286#if defined(RTEMS_MULTIPROCESSING)
287/*mp.h*/        0                                         +
288#endif
289
290#if defined(RTEMS_MULTIPROCESSING)
291/*mpciimpl.h*/  (sizeof _MPCI_Remote_blocked_threads)     +
292                (sizeof _MPCI_Semaphore)                  +
293                (sizeof _MPCI_table)                      +
294                (sizeof _MPCI_Receive_server_tcb)         +
295                (sizeof _MPCI_Packet_processors)          +
296#endif
297
298#if defined(RTEMS_MULTIPROCESSING)
299/*mppkt.h*/     0                                         +
300#endif
301
302#if defined(RTEMS_MULTIPROCESSING)
303/*mptables.h*/  0                                         +
304#endif
305
306#if defined(RTEMS_MULTIPROCESSING)
307/*msgmp.h*/     0                                         +
308#endif
309
310/*object.h*/    (sizeof _Objects_Local_node)              +
311                (sizeof _Objects_Maximum_nodes)           +
312                (sizeof _Objects_Information_table)       +
313
314/*options.h*/   0                                         +
315
316/*partimpl.h*/  (sizeof _Partition_Information)           +
317
318#if defined(RTEMS_MULTIPROCESSING)
319/*partmp.h*/    0                                         +
320#endif
321
322/*percpu.h*/    (_SMP_Get_processor_maximum() * sizeof(Per_CPU_Control))  +
323
324/*ratemonimpl.h*/ (sizeof _Rate_monotonic_Information)    +
325
326/*regionimpl.h*/ (sizeof _Region_Information)             +
327
328#if defined(RTEMS_MULTIPROCESSING)
329/*regionmp.h*/  0                                         +
330#endif
331
332/*rtems.h*/     /* Not applicable */
333
334/*semimpl.h*/   (sizeof _Semaphore_Information)           +
335
336#if defined(RTEMS_MULTIPROCESSING)
337/*semmp.h*/     0                                         +
338#endif
339
340/*signal.h*/    0                                         +
341
342/*signalmp.h*/  0                                         +
343
344/*stack.h*/     0                                         +
345
346/*states.h*/    0                                         +
347
348/*status.h*/    0                                         +
349
350/*sysstate.h*/  (sizeof _System_state_Current)            +
351#if defined(RTEMS_MULTIPROCESSING)
352                (sizeof _System_state_Is_multiprocessing) +
353#endif
354
355#if defined(RTEMS_MULTIPROCESSING)
356/*taskmp.h*/    0                                         +
357#endif
358
359/*tasksimpl.h*/ (sizeof _RTEMS_tasks_Information)         +
360
361/*thread.h*/    (sizeof _Thread_Dispatch_disable_level)   +
362                (sizeof _Thread_Executing)                +
363                (sizeof _Thread_Heir)                     +
364#if (CPU_HARDWARE_FP == 1) || (CPU_SOFTWARE_FP == 1)
365                (sizeof _Thread_Allocated_fp)             +
366#endif
367                (sizeof _Thread_Information)     +
368
369/*threadq.h*/
370
371/*timerimpl.h*/ (sizeof _Timer_Information)               +
372
373/*tqdata.h*/    0                                         +
374
375/*types.h*/     0                                         +
376
377/*userext.h*/   (sizeof _User_extensions_List)            +
378
379/*watchdog.h*/  (sizeof _Watchdog_Ticks_since_boot)       +
380
381/*wkspace.h*/   (sizeof _Workspace_Area);
382
383#ifndef unix  /* make sure this is not a native compile */
384
385#ifdef __i386__
386
387/* cpu.h */
388uninitialized += (sizeof _CPU_Null_fp_context);
389
390uninitialized += (sizeof _CPU_Interrupt_stack_low) +
391                 (sizeof _CPU_Interrupt_stack_high);
392
393#endif
394
395#ifdef __mc68000__
396
397/* cpu.h */
398uninitialized += (sizeof _CPU_Interrupt_stack_low) +
399                 (sizeof _CPU_Interrupt_stack_high);
400
401#endif
402
403#ifdef __sparc__
404
405/* cpu.h */
406uninitialized += (sizeof _CPU_Interrupt_stack_low) +
407                 (sizeof _CPU_Interrupt_stack_high);
408
409#endif
410
411
412#ifdef no_cpu
413
414/* cpu.h */
415uninitialized += (sizeof _CPU_Null_fp_context) +
416                 (sizeof _CPU_Interrupt_stack_low) +
417                 (sizeof _CPU_Interrupt_stack_high) +
418                 (sizeof _CPU_Thread_dispatch_pointer);
419
420#endif
421
422#ifdef __PPC__
423
424/* cpu.h */
425uninitialized += (sizeof _CPU_Interrupt_stack_low) +
426                 (sizeof _CPU_Interrupt_stack_high);
427
428#endif
429#endif /* !unix */
430
431initialized +=
432/*copyrt.h*/    (strlen(_Copyright_Notice)+1)             +
433                (strlen(_RTEMS_version)+1);
434
435
436
437#ifndef unix /* make sure this is not native */
438#ifdef __sparc__
439
440initialized +=  (sizeof _CPU_Trap_slot_template);
441
442#endif
443#endif /* !unix */
444
445puts( "" );
446
447  if ( mode == 0 ) help_size();
448  else             print_formula();
449
450printf( "\n" );
451printf( "RTEMS uninitialized data consumes %d bytes\n", uninitialized );
452printf( "RTEMS initialized data consumes %d bytes\n", initialized );
453
454}
455
456void help_size()
457{
458int c = '\0';
459int break_loop;
460int total_size;
461int task_stacks;
462int interrupt_stack;
463int maximum_tasks, size_tasks;
464int maximum_sems, size_sems;
465int maximum_timers, size_timers;
466int maximum_msgqs, size_msgqs;
467int maximum_msgs, size_msgs_overhead;
468int maximum_regns, size_regns;
469int maximum_parts, size_parts;
470int maximum_ports, size_ports;
471int maximum_periods, size_periods;
472int maximum_extensions, size_extensions;
473int maximum_drvs, size_drvs;
474int maximum_fps, size_fps;
475int maximum_nodes, size_nodes;
476int maximum_gobjs, size_gobjs;
477int maximum_proxies, size_proxies;
478
479total_size = sys_req;    /* Fixed Overhead */
480printf( "What is maximum_tasks? " );
481maximum_tasks = getint();
482size_tasks = PER_TASK * maximum_tasks;
483total_size += size_tasks;
484
485printf( "What is maximum_semaphores? " );
486maximum_sems = getint();
487size_sems = PER_SEMAPHORE * maximum_sems;
488total_size += size_sems;
489
490printf( "What is maximum_timers? " );
491maximum_timers = getint();
492size_timers = PER_TIMER * maximum_timers;
493total_size += size_timers;
494
495printf( "What is maximum_message_queues? " );
496maximum_msgqs = getint();
497size_msgqs = PER_MSGQ * maximum_msgqs;
498total_size += size_msgqs;
499
500printf( "What is maximum_messages?  XXXX " );
501maximum_msgs = getint();
502size_msgs_overhead = 0;
503total_size += size_msgs_overhead;
504
505printf( "What is maximum_regions? " );
506maximum_regns = getint();
507size_regns = PER_REGN * maximum_regns;
508total_size += size_regns;
509
510printf( "What is maximum_partitions? " );
511maximum_parts = getint();
512size_parts = PER_PART * maximum_parts;
513total_size += size_parts;
514
515printf( "What is maximum_ports? " );
516maximum_ports = getint();
517size_ports = PER_PORT * maximum_ports;
518total_size += size_ports;
519
520printf( "What is maximum_periods? " );
521maximum_periods = getint();
522size_periods = PER_PERIOD * maximum_periods;
523total_size += size_periods;
524
525printf( "What is maximum_extensions? " );
526maximum_extensions = getint();
527size_extensions = PER_EXTENSION * maximum_extensions;
528total_size += size_extensions;
529
530printf( "What is number_of_device_drivers? " );
531maximum_drvs = getint();
532size_drvs = PER_DRV  * maximum_drvs;
533total_size += size_drvs;
534
535printf( "What will be total stack requirement for all tasks? " );
536task_stacks = getint();
537total_size += task_stacks;
538
539printf( "What is the size of the interrupt stack? " );
540interrupt_stack = getint();
541total_size += interrupt_stack;
542
543printf( "How many tasks will be created with the FP flag? " );
544maximum_fps = getint();
545size_fps = PER_FPTASK  * maximum_fps;
546total_size += size_fps;
547
548printf( "Is this a single processor system? " );
549for ( break_loop=0 ; !break_loop; c = getchar() ) {
550  switch ( c ) {
551    case 'Y':  case 'y':
552    case 'N':  case 'n':
553      break_loop = 1;
554      break;
555  }
556}
557printf( "%c\n", c );
558if ( c == 'n' || c == 'N' ) {
559  printf( "What is maximum_nodes? " );
560  maximum_nodes = getint();
561  size_nodes = PER_NODE * maximum_nodes;
562  total_size += size_nodes;
563  printf( "What is maximum_global_objects? " );
564  maximum_gobjs = getint();
565  size_gobjs = PER_GOBJECT * maximum_gobjs;
566  total_size += size_gobjs;
567  printf( "What is maximum_proxies? " );
568  maximum_proxies = getint();
569  size_proxies = PER_PROXY * maximum_proxies;
570  total_size += size_proxies;
571} else {
572  maximum_nodes = 0;
573  size_nodes = PER_NODE * 0;
574  maximum_gobjs = 0;
575  size_gobjs = PER_GOBJECT * 0;
576  maximum_proxies = 0;
577  size_proxies = PER_PROXY * 0;
578}
579
580printf( "\n\n" );
581printf( " ************** EXECUTIVE WORK SPACE REQUIRED **************\n" );
582printf( " Tasks                - %03d * %03ld            =  %ld\n",
583          maximum_tasks, PER_TASK, (long) size_tasks );
584printf( " Semaphores           - %03d * %03ld            =  %ld\n",
585          maximum_sems, PER_SEMAPHORE, (long) size_sems );
586printf( " Timers               - %03d * %03ld            =  %ld\n",
587          maximum_timers, PER_TIMER, (long) size_timers );
588printf( " Msg Queues           - %03d * %03ld            =  %ld\n",
589          maximum_msgqs, PER_MSGQ, (long) size_msgqs );
590printf( " Messages Overhead    - %03d * %03d            =  %ld\n",
591          maximum_msgs, 0 /* PER_MSG_OVERHEAD */, (long) size_msgs_overhead );
592printf( " Regions              - %03d * %03ld            =  %ld\n",
593          maximum_regns, PER_REGN, (long) size_regns);
594printf( " Partitions           - %03d * %03ld            =  %ld\n",
595          maximum_parts, PER_PART, (long) size_parts );
596printf( " Periods              - %03d * %03ld            =  %ld\n",
597          maximum_periods, PER_PERIOD, (long) size_periods );
598printf( " Extensions           - %03d * %03ld            =  %ld\n",
599          maximum_extensions, PER_EXTENSION, (long) size_extensions );
600printf( " Device Drivers       - %03d * %03ld            =  %ld\n",
601          maximum_drvs, PER_DRV, (long) size_drvs );
602
603printf( " System Requirements  - %04" PRIu32 "                 =  %"PRIu32 "\n",
604          sys_req, sys_req );
605
606printf( " Floating Point Tasks - %03d * %03ld            =  %ld\n",
607          maximum_fps, PER_FPTASK, (long) size_fps );
608printf( " Application Task Stacks -                     =  %d\n",
609          task_stacks );
610printf( " Interrupt Stacks -                            =  %d\n",
611          task_stacks );
612printf( " \n" );
613printf( " Global object tables - %03d * %03ld            =  %ld\n",
614          maximum_nodes, PER_NODE, (long) size_nodes );
615printf( " Global objects       - %03d * %03ld            =  %ld\n",
616          maximum_gobjs, PER_GOBJECT, (long) size_gobjs );
617printf( " Proxies              - %03d * %03ld            =  %ld\n",
618          maximum_proxies, PER_PROXY, (long) size_proxies );
619printf( "\n\n" );
620printf( " TOTAL                                       = %d bytes\n",
621      total_size );
622}
623
624void print_formula()
625{
626printf( " ************** EXECUTIVE WORK SPACE FORMULA **************\n" );
627printf( " Tasks                - maximum_tasks * %ld\n",      PER_TASK );
628printf( " Timers               - maximum_timers * %ld\n",     PER_TIMER );
629printf( " Semaphores           - maximum_semaphores * %ld\n", PER_SEMAPHORE);
630printf( " Message Queues       - maximum_message_queues * %ld\n", PER_MSGQ );
631printf( " Messages             -\n");
632printf( " Regions              - maximum_regions * %ld\n",    PER_REGN );
633printf( " Partitions           - maximum_partitions * %ld\n", PER_PART );
634printf( " Ports                - maximum_ports * %ld\n",      PER_PORT );
635printf( " Periods              - maximum_periods * %ld\n",    PER_PORT );
636printf( " Extensions           - maximum_extensions * %ld\n", PER_EXTENSION );
637printf( " Device Drivers       - number_of_device_drivers * %ld\n", PER_DRV);
638printf( " System Requirements  - %" PRIu32 "\n",              sys_req );
639printf( " Floating Point Tasks - FPMASK Tasks * %ld\n",       PER_FPTASK );
640printf( " User's Tasks' Stacks -\n" );
641printf( " Interrupt Stack      -\n" );
642printf( " \n" );
643printf( " Global object tables - maximum_nodes * %ld\n",          PER_NODE );
644printf( " Global objects       - maximum_global_objects * %ld\n", PER_GOBJECT );
645printf( " Proxies              - maximum_proxies * %ld\n",        PER_PROXY );
646}
Note: See TracBrowser for help on using the repository browser.