source: rtems/testsuites/sptests/spsize/size.c @ 3652ad35

4.104.114.84.9
Last change on this file since 3652ad35 was 3652ad35, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 19, 1995 at 2:53:29 PM

Minor bug fixes to get all targets compilable and running. The
single biggest changes were the expansion of the workspace size
macro to include other types of objects and the increase in the
minimum stack size for most CPUs.

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