Changeset c1403ef1 in rtems for c


Ignore:
Timestamp:
08/11/95 14:30:27 (28 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
4e58d80
Parents:
aa9f194
Message:

Added flush of output on exit. On some UNIX's using the native library
resulted in no output when the output was redirected until this was done.
Redirection is important because runtest redirects test output.

Added support for numerous environment variables which make it easier
to run a multi-node system using a single executable and to tailor
the size of the workspace and heap.

Location:
c/src/lib/libbsp/unix/posix/startup
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/unix/posix/startup/bspclean.c

    raa9f194 rc1403ef1  
    2323#include <bsp.h>
    2424
     25#include <stdio.h>
     26
    2527/*
    2628 * The app has "exited" (called rtems_shutdown_executive)
     
    3436     */
    3537
     38fflush(stdout);
     39fflush(stderr);
     40
    3641    rtems_fatal_error_occurred(0);
    3742}
  • c/src/lib/libbsp/unix/posix/startup/bspstart.c

    raa9f194 rc1403ef1  
    3434#include <fcntl.h>
    3535#include <unistd.h>
    36 #include <sys/stat.h>
    3736
    3837#include <bsp.h>
     
    5958char                       **rtems_envp;
    6059
    61 
    62 #define WORKSPACE_SIZE (WORKSPACE_MB * (1024 * 1024))
    63 #define HEAPSPACE_SIZE (HEAPSPACE_MB * (1024 * 1024))
    64 
    65 rtems_unsigned8   MY_WORK_SPACE[ WORKSPACE_SIZE ] CPU_STRUCTURE_ALIGNMENT;
     60/*
     61 * May be overridden by RTEMS_WORKSPACE_SIZE and RTEMS_HEAPSPACE_SIZE
     62 * environment variables; see below.
     63 */
     64
     65#define DEFAULT_WORKSPACE_SIZE (WORKSPACE_MB * (1024 * 1024))
     66#define DEFAULT_HEAPSPACE_SIZE (HEAPSPACE_MB * (1024 * 1024))
    6667
    6768/*
     
    103104    void *heap_start;
    104105
    105     Heap_size = HEAPSPACE_SIZE;
     106    if (getenv("RTEMS_HEAPSPACE_SIZE"))
     107        Heap_size = strtol(getenv("RTEMS_HEAPSPACE_SIZE"), 0, 0);
     108    else
     109        Heap_size = DEFAULT_HEAPSPACE_SIZE;
     110 
    106111    heap_start = 0;
    107112
     
    186191bsp_start(void)
    187192{
    188     struct stat  stat_buf;
    189     char         buf[256];
    190     char         node[6];
    191     char        *home;
    192     int          fd;
     193    unsigned32 workspace_ptr;
    193194
    194195    /*
     
    199200 
    200201    /*
    201      * If the node number is -1 then the application better provide
    202      * it through the file $HOME/rtems_node
    203      */
    204 
    205     BSP_Multiprocessing.node = -1;
     202     *  If the node number is -1 then the application better provide
     203     *  it through environment variables RTEMS_NODE.
     204     *  Ditto for RTEMS_MAXIMUM_NODES
     205     */
    206206
    207207    if (BSP_Configuration.User_multiprocessing_table) {
    208       if (BSP_Configuration.User_multiprocessing_table->node == -1) {
    209         home = getenv("HOME");
    210         sprintf(buf, "%s/%s", home, "rtems_node");
    211         if ((stat(buf, &stat_buf)) == 0) {
    212           fd = open(buf, O_RDONLY);
    213           read(fd, node, 5);
    214           close(fd);
    215           unlink(buf);
    216           BSP_Multiprocessing = *BSP_Configuration.User_multiprocessing_table;
    217           BSP_Multiprocessing.node = atoi(node);
    218           BSP_Configuration.User_multiprocessing_table = &BSP_Multiprocessing;
     208        char *p;
     209 
     210        /* make a copy for possible editing */
     211        BSP_Multiprocessing = *BSP_Configuration.User_multiprocessing_table;
     212        BSP_Configuration.User_multiprocessing_table = &BSP_Multiprocessing;
     213 
     214        if (BSP_Multiprocessing.node == -1)
     215        {
     216            p = getenv("RTEMS_NODE");
     217            BSP_Multiprocessing.node = p ? atoi(p) : 1;
    219218        }
    220         if (BSP_Configuration.User_multiprocessing_table->maximum_nodes == -1) {
    221           home = getenv("HOME");
    222           sprintf(buf, "%s/%s", home, "rtems_max_node");
    223           if ((stat(buf, &stat_buf)) == 0) {
    224             fd = open(buf, O_RDONLY);
    225             read(fd, node, 5);
    226             close(fd);
    227             BSP_Multiprocessing.maximum_nodes = atoi(node);
    228           }
     219 
     220        /* If needed provide maximum_nodes also */
     221        if (BSP_Multiprocessing.maximum_nodes == -1)
     222        {
     223            p = getenv("RTEMS_MAXIMUM_NODES");
     224            BSP_Multiprocessing.maximum_nodes = p ? atoi(p) : 1;
    229225        }
    230       }
    231226    }
    232227
     
    240235        cpu_number = 0;
    241236
    242     BSP_Configuration.work_space_start = (void *)MY_WORK_SPACE;
    243     if (BSP_Configuration.work_space_size)
    244         BSP_Configuration.work_space_size = WORKSPACE_SIZE;
    245 
     237    if (getenv("RTEMS_WORKSPACE_SIZE"))
     238        BSP_Configuration.work_space_size =
     239           strtol(getenv("RTEMS_WORKSPACE_SIZE"), 0, 0);
     240    else
     241        BSP_Configuration.work_space_size = DEFAULT_WORKSPACE_SIZE;
     242 
     243    /*
     244     * Allocate workspace memory, ensuring it is properly aligned
     245     */
     246 
     247    workspace_ptr =
     248      (unsigned32) sbrk(BSP_Configuration.work_space_size + CPU_ALIGNMENT);
     249    workspace_ptr += CPU_ALIGNMENT - 1;
     250    workspace_ptr &= ~(CPU_ALIGNMENT - 1);
     251
     252    BSP_Configuration.work_space_start = (void *) workspace_ptr;
     253 
    246254    /*
    247255     * Set up our hooks
  • c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc

    raa9f194 rc1403ef1  
    11//      @(#)rtems-ctor.cc       1.6 - 95/04/25
    2 //      
     2//
    33//
    44
     
    77 *
    88 *  Description:
    9  *      This file exists solely to (try to) ensure RTEMS is initialized
     9 *  This file exists solely to (try to) ensure RTEMS is initialized
    1010 *      before any global constructors are run.
    1111 *
     
    5050
    5151#include <bsp.h>
     52#include <stdio.h>
     53#include <stdlib.h>
    5254
    5355/*
     
    6264class RTEMS {
    6365    public:
    64         RTEMS();
     66         RTEMS();
    6567        ~RTEMS();
    6668};
     
    8486         char **environp)
    8587    {
    86         rtems_argc = argc;
    87         rtems_argv = argv;
    88         rtems_envp = environp;
     88        rtems_argc = argc;
     89        rtems_argv = argv;
     90        rtems_envp = environp;
    8991
    9092        if ((argc > 0) && argv && argv[0])
     
    104106         */
    105107
     108        fflush( stdout );
     109        fflush( stderr );
    106110        return 0;
    107111    }
  • c/src/lib/libbsp/unix/posix/startup/setvec.c

    raa9f194 rc1403ef1  
    3838 */
    3939
    40 unix_isr_entry
     40rtems_isr_entry
    4141set_vector(                                     /* returns old vector */
    4242    rtems_isr_entry     handler,                /* isr routine        */
     
    5050    if ( type ) {
    5151      rtems_interrupt_catch( handler, vector, &rtems_isr_ptr );
    52       return (unix_isr_entry) rtems_isr_ptr;
     52      return rtems_isr_ptr;
    5353    } else {
    5454      _CPU_ISR_install_vector( vector, (proc_ptr) handler, &raw_isr_ptr );
    55       return (unix_isr_entry) raw_isr_ptr;
     55      return raw_isr_ptr;
    5656    }
    5757   
Note: See TracChangeset for help on using the changeset viewer.