summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/unix/posix/startup
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/unix/posix/startup')
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/bspclean.c5
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/bspstart.c86
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc16
-rw-r--r--c/src/lib/libbsp/unix/posix/startup/setvec.c6
4 files changed, 65 insertions, 48 deletions
diff --git a/c/src/lib/libbsp/unix/posix/startup/bspclean.c b/c/src/lib/libbsp/unix/posix/startup/bspclean.c
index 22feedb7ad..47d9548694 100644
--- a/c/src/lib/libbsp/unix/posix/startup/bspclean.c
+++ b/c/src/lib/libbsp/unix/posix/startup/bspclean.c
@@ -22,6 +22,8 @@
#include <rtems.h>
#include <bsp.h>
+#include <stdio.h>
+
/*
* 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.
*/
+fflush(stdout);
+fflush(stderr);
+
rtems_fatal_error_occurred(0);
}
diff --git a/c/src/lib/libbsp/unix/posix/startup/bspstart.c b/c/src/lib/libbsp/unix/posix/startup/bspstart.c
index a2ec1b1911..d4279c5818 100644
--- a/c/src/lib/libbsp/unix/posix/startup/bspstart.c
+++ b/c/src/lib/libbsp/unix/posix/startup/bspstart.c
@@ -33,7 +33,6 @@
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
-#include <sys/stat.h>
#include <bsp.h>
#include <libcsupport.h>
@@ -58,11 +57,13 @@ int rtems_argc;
char **rtems_argv;
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 HEAPSPACE_SIZE (HEAPSPACE_MB * (1024 * 1024))
-
-rtems_unsigned8 MY_WORK_SPACE[ WORKSPACE_SIZE ] CPU_STRUCTURE_ALIGNMENT;
+#define DEFAULT_WORKSPACE_SIZE (WORKSPACE_MB * (1024 * 1024))
+#define DEFAULT_HEAPSPACE_SIZE (HEAPSPACE_MB * (1024 * 1024))
/*
* Amount to increment itimer by each pass
@@ -102,7 +103,11 @@ bsp_libc_init(void)
{
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;
RTEMS_Malloc_Initialize((void *)heap_start, Heap_size, 1024 * 1024);
@@ -185,11 +190,7 @@ bsp_pretasking_hook(void)
void
bsp_start(void)
{
- struct stat stat_buf;
- char buf[256];
- char node[6];
- char *home;
- int fd;
+ unsigned32 workspace_ptr;
/*
* Copy the table
@@ -198,36 +199,30 @@ bsp_start(void)
BSP_Configuration = Configuration;
/*
- * If the node number is -1 then the application better provide
- * it through the file $HOME/rtems_node
+ * If the node number is -1 then the application better provide
+ * 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->node == -1) {
- home = getenv("HOME");
- sprintf(buf, "%s/%s", home, "rtems_node");
- 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.node = atoi(node);
- BSP_Configuration.User_multiprocessing_table = &BSP_Multiprocessing;
+ char *p;
+
+ /* make a copy for possible editing */
+ BSP_Multiprocessing = *BSP_Configuration.User_multiprocessing_table;
+ 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");
- sprintf(buf, "%s/%s", home, "rtems_max_node");
- if ((stat(buf, &stat_buf)) == 0) {
- fd = open(buf, O_RDONLY);
- read(fd, node, 5);
- close(fd);
- BSP_Multiprocessing.maximum_nodes = atoi(node);
- }
+
+ /* If needed provide maximum_nodes also */
+ if (BSP_Multiprocessing.maximum_nodes == -1)
+ {
+ p = getenv("RTEMS_MAXIMUM_NODES");
+ BSP_Multiprocessing.maximum_nodes = p ? atoi(p) : 1;
}
- }
}
/*
@@ -239,10 +234,23 @@ bsp_start(void)
else
cpu_number = 0;
- BSP_Configuration.work_space_start = (void *)MY_WORK_SPACE;
- if (BSP_Configuration.work_space_size)
- BSP_Configuration.work_space_size = WORKSPACE_SIZE;
+ if (getenv("RTEMS_WORKSPACE_SIZE"))
+ BSP_Configuration.work_space_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
* Make sure libc_init is done before drivers init'd so that
diff --git a/c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc b/c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc
index 4c55f3798f..3831f9456f 100644
--- a/c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc
+++ b/c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc
@@ -1,12 +1,12 @@
// @(#)rtems-ctor.cc 1.6 - 95/04/25
-//
+//
//
/*
* rtems-ctor.cc
*
* Description:
- * This file exists solely to (try to) ensure RTEMS is initialized
+ * This file exists solely to (try to) ensure RTEMS is initialized
* before any global constructors are run.
*
* The problem:
@@ -49,6 +49,8 @@
*/
#include <bsp.h>
+#include <stdio.h>
+#include <stdlib.h>
/*
* RTEMS program name
@@ -61,7 +63,7 @@ char *rtems_progname;
class RTEMS {
public:
- RTEMS();
+ RTEMS();
~RTEMS();
};
@@ -83,9 +85,9 @@ extern "C" {
char **argv,
char **environp)
{
- rtems_argc = argc;
- rtems_argv = argv;
- rtems_envp = environp;
+ rtems_argc = argc;
+ rtems_argv = argv;
+ rtems_envp = environp;
if ((argc > 0) && argv && argv[0])
rtems_progname = argv[0];
@@ -103,6 +105,8 @@ extern "C" {
* This allows our destructors to get run normally
*/
+ fflush( stdout );
+ fflush( stderr );
return 0;
}
}
diff --git a/c/src/lib/libbsp/unix/posix/startup/setvec.c b/c/src/lib/libbsp/unix/posix/startup/setvec.c
index fef64752d5..8d3aedceb9 100644
--- a/c/src/lib/libbsp/unix/posix/startup/setvec.c
+++ b/c/src/lib/libbsp/unix/posix/startup/setvec.c
@@ -37,7 +37,7 @@
* We decide which based on the vector number
*/
-unix_isr_entry
+rtems_isr_entry
set_vector( /* returns old vector */
rtems_isr_entry handler, /* isr routine */
rtems_vector_number vector, /* vector number */
@@ -49,10 +49,10 @@ set_vector( /* returns old vector */
if ( type ) {
rtems_interrupt_catch( handler, vector, &rtems_isr_ptr );
- return (unix_isr_entry) rtems_isr_ptr;
+ return rtems_isr_ptr;
} else {
_CPU_ISR_install_vector( vector, (proc_ptr) handler, &raw_isr_ptr );
- return (unix_isr_entry) raw_isr_ptr;
+ return raw_isr_ptr;
}
}