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.
This commit is contained in:
Joel Sherrill
1995-08-11 14:30:27 +00:00
parent aa9f19454a
commit c1403ef153
4 changed files with 65 additions and 48 deletions

View File

@@ -22,6 +22,8 @@
#include <rtems.h> #include <rtems.h>
#include <bsp.h> #include <bsp.h>
#include <stdio.h>
/* /*
* The app has "exited" (called rtems_shutdown_executive) * The app has "exited" (called rtems_shutdown_executive)
*/ */
@@ -33,5 +35,8 @@ void bsp_cleanup( void )
* By definition, rtems_fatal_error_occurred does not return. * By definition, rtems_fatal_error_occurred does not return.
*/ */
fflush(stdout);
fflush(stderr);
rtems_fatal_error_occurred(0); rtems_fatal_error_occurred(0);
} }

View File

@@ -33,7 +33,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h>
#include <bsp.h> #include <bsp.h>
#include <libcsupport.h> #include <libcsupport.h>
@@ -58,11 +57,13 @@ int rtems_argc;
char **rtems_argv; char **rtems_argv;
char **rtems_envp; char **rtems_envp;
/*
* May be overridden by RTEMS_WORKSPACE_SIZE and RTEMS_HEAPSPACE_SIZE
* environment variables; see below.
*/
#define WORKSPACE_SIZE (WORKSPACE_MB * (1024 * 1024)) #define DEFAULT_WORKSPACE_SIZE (WORKSPACE_MB * (1024 * 1024))
#define HEAPSPACE_SIZE (HEAPSPACE_MB * (1024 * 1024)) #define DEFAULT_HEAPSPACE_SIZE (HEAPSPACE_MB * (1024 * 1024))
rtems_unsigned8 MY_WORK_SPACE[ WORKSPACE_SIZE ] CPU_STRUCTURE_ALIGNMENT;
/* /*
* Amount to increment itimer by each pass * Amount to increment itimer by each pass
@@ -102,7 +103,11 @@ bsp_libc_init(void)
{ {
void *heap_start; void *heap_start;
Heap_size = HEAPSPACE_SIZE; if (getenv("RTEMS_HEAPSPACE_SIZE"))
Heap_size = strtol(getenv("RTEMS_HEAPSPACE_SIZE"), 0, 0);
else
Heap_size = DEFAULT_HEAPSPACE_SIZE;
heap_start = 0; heap_start = 0;
RTEMS_Malloc_Initialize((void *)heap_start, Heap_size, 1024 * 1024); RTEMS_Malloc_Initialize((void *)heap_start, Heap_size, 1024 * 1024);
@@ -185,11 +190,7 @@ bsp_pretasking_hook(void)
void void
bsp_start(void) bsp_start(void)
{ {
struct stat stat_buf; unsigned32 workspace_ptr;
char buf[256];
char node[6];
char *home;
int fd;
/* /*
* Copy the table * Copy the table
@@ -199,34 +200,28 @@ bsp_start(void)
/* /*
* If the node number is -1 then the application better provide * If the node number is -1 then the application better provide
* it through the file $HOME/rtems_node * it through environment variables RTEMS_NODE.
* Ditto for RTEMS_MAXIMUM_NODES
*/ */
BSP_Multiprocessing.node = -1;
if (BSP_Configuration.User_multiprocessing_table) { if (BSP_Configuration.User_multiprocessing_table) {
if (BSP_Configuration.User_multiprocessing_table->node == -1) { char *p;
home = getenv("HOME");
sprintf(buf, "%s/%s", home, "rtems_node"); /* make a copy for possible editing */
if ((stat(buf, &stat_buf)) == 0) {
fd = open(buf, O_RDONLY);
read(fd, node, 5);
close(fd);
unlink(buf);
BSP_Multiprocessing = *BSP_Configuration.User_multiprocessing_table; BSP_Multiprocessing = *BSP_Configuration.User_multiprocessing_table;
BSP_Multiprocessing.node = atoi(node);
BSP_Configuration.User_multiprocessing_table = &BSP_Multiprocessing; BSP_Configuration.User_multiprocessing_table = &BSP_Multiprocessing;
if (BSP_Multiprocessing.node == -1)
{
p = getenv("RTEMS_NODE");
BSP_Multiprocessing.node = p ? atoi(p) : 1;
} }
if (BSP_Configuration.User_multiprocessing_table->maximum_nodes == -1) {
home = getenv("HOME"); /* If needed provide maximum_nodes also */
sprintf(buf, "%s/%s", home, "rtems_max_node"); if (BSP_Multiprocessing.maximum_nodes == -1)
if ((stat(buf, &stat_buf)) == 0) { {
fd = open(buf, O_RDONLY); p = getenv("RTEMS_MAXIMUM_NODES");
read(fd, node, 5); BSP_Multiprocessing.maximum_nodes = p ? atoi(p) : 1;
close(fd);
BSP_Multiprocessing.maximum_nodes = atoi(node);
}
}
} }
} }
@@ -239,9 +234,22 @@ bsp_start(void)
else else
cpu_number = 0; cpu_number = 0;
BSP_Configuration.work_space_start = (void *)MY_WORK_SPACE; if (getenv("RTEMS_WORKSPACE_SIZE"))
if (BSP_Configuration.work_space_size) BSP_Configuration.work_space_size =
BSP_Configuration.work_space_size = WORKSPACE_SIZE; strtol(getenv("RTEMS_WORKSPACE_SIZE"), 0, 0);
else
BSP_Configuration.work_space_size = DEFAULT_WORKSPACE_SIZE;
/*
* Allocate workspace memory, ensuring it is properly aligned
*/
workspace_ptr =
(unsigned32) sbrk(BSP_Configuration.work_space_size + CPU_ALIGNMENT);
workspace_ptr += CPU_ALIGNMENT - 1;
workspace_ptr &= ~(CPU_ALIGNMENT - 1);
BSP_Configuration.work_space_start = (void *) workspace_ptr;
/* /*
* Set up our hooks * Set up our hooks

View File

@@ -49,6 +49,8 @@
*/ */
#include <bsp.h> #include <bsp.h>
#include <stdio.h>
#include <stdlib.h>
/* /*
* RTEMS program name * RTEMS program name
@@ -103,6 +105,8 @@ extern "C" {
* This allows our destructors to get run normally * This allows our destructors to get run normally
*/ */
fflush( stdout );
fflush( stderr );
return 0; return 0;
} }
} }

View File

@@ -37,7 +37,7 @@
* We decide which based on the vector number * We decide which based on the vector number
*/ */
unix_isr_entry rtems_isr_entry
set_vector( /* returns old vector */ set_vector( /* returns old vector */
rtems_isr_entry handler, /* isr routine */ rtems_isr_entry handler, /* isr routine */
rtems_vector_number vector, /* vector number */ rtems_vector_number vector, /* vector number */
@@ -49,10 +49,10 @@ set_vector( /* returns old vector */
if ( type ) { if ( type ) {
rtems_interrupt_catch( handler, vector, &rtems_isr_ptr ); rtems_interrupt_catch( handler, vector, &rtems_isr_ptr );
return (unix_isr_entry) rtems_isr_ptr; return rtems_isr_ptr;
} else { } else {
_CPU_ISR_install_vector( vector, (proc_ptr) handler, &raw_isr_ptr ); _CPU_ISR_install_vector( vector, (proc_ptr) handler, &raw_isr_ptr );
return (unix_isr_entry) raw_isr_ptr; return raw_isr_ptr;
} }
} }