From 200748bfa01558cc072562d5f9d8e1bbf33fe8bc Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 11 Dec 2007 15:46:10 +0000 Subject: 2007-12-11 Joel Sherrill * clock/clock.c, include/bsp.h, startup/bspstart.c, startup/rtems-ctor.cc: Eliminate copies of the Configuration Table. Use the RTEMS provided accessor macros to obtain configuration fields. --- c/src/lib/libbsp/unix/posix/ChangeLog | 7 +++ c/src/lib/libbsp/unix/posix/clock/clock.c | 2 +- c/src/lib/libbsp/unix/posix/include/bsp.h | 7 --- c/src/lib/libbsp/unix/posix/startup/bspstart.c | 57 +++++------------------ c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc | 19 ++++---- 5 files changed, 29 insertions(+), 63 deletions(-) (limited to 'c/src/lib/libbsp/unix') diff --git a/c/src/lib/libbsp/unix/posix/ChangeLog b/c/src/lib/libbsp/unix/posix/ChangeLog index e4bd88520b..c1537b18fd 100644 --- a/c/src/lib/libbsp/unix/posix/ChangeLog +++ b/c/src/lib/libbsp/unix/posix/ChangeLog @@ -1,3 +1,10 @@ +2007-12-11 Joel Sherrill + + * clock/clock.c, include/bsp.h, startup/bspstart.c, + startup/rtems-ctor.cc: Eliminate copies of the Configuration Table. + Use the RTEMS provided accessor macros to obtain configuration + fields. + 2007-12-04 Joel Sherrill * include/bsp.h, startup/bspstart.c: Move interrupt_stack_size field diff --git a/c/src/lib/libbsp/unix/posix/clock/clock.c b/c/src/lib/libbsp/unix/posix/clock/clock.c index ac4e6fb211..3abf8d54d3 100644 --- a/c/src/lib/libbsp/unix/posix/clock/clock.c +++ b/c/src/lib/libbsp/unix/posix/clock/clock.c @@ -36,7 +36,7 @@ void Install_clock(rtems_isr_entry clock_isr) (void) set_vector( clock_isr, Clock_driver_vector, 1 ); - _CPU_Start_clock( BSP_Configuration.microseconds_per_tick ); + _CPU_Start_clock( rtems_configuration_get_microseconds_per_tick() ); atexit(Clock_exit); } diff --git a/c/src/lib/libbsp/unix/posix/include/bsp.h b/c/src/lib/libbsp/unix/posix/include/bsp.h index 4e262de946..062f19cc07 100644 --- a/c/src/lib/libbsp/unix/posix/include/bsp.h +++ b/c/src/lib/libbsp/unix/posix/include/bsp.h @@ -31,8 +31,6 @@ extern "C" { /* miscellaneous stuff assumed to exist */ -extern rtems_configuration_table BSP_Configuration; - /* * Device Driver Table Entries */ @@ -53,14 +51,9 @@ void bsp_cleanup( void ); /* miscellaneous stuff assumed to exist */ -extern rtems_configuration_table BSP_Configuration; /* owned by BSP */ extern int rtems_argc; extern char **rtems_argv; -extern uint32_t bsp_isr_level; - -extern char *rtems_progname; /* UNIX executable name */ - extern int cpu_number; #ifdef __cplusplus diff --git a/c/src/lib/libbsp/unix/posix/startup/bspstart.c b/c/src/lib/libbsp/unix/posix/startup/bspstart.c index 977b355ef6..45001c68ef 100644 --- a/c/src/lib/libbsp/unix/posix/startup/bspstart.c +++ b/c/src/lib/libbsp/unix/posix/startup/bspstart.c @@ -24,16 +24,6 @@ #include #include -extern rtems_configuration_table Configuration; - -/* - * A copy of the configuration table from the application - * with some changes applied to it. - */ - -rtems_configuration_table BSP_Configuration; -rtems_multiprocessing_table BSP_Multiprocessing; -uint32_t bsp_isr_level; uint32_t Heap_size; int rtems_argc; char **rtems_argv; @@ -118,36 +108,24 @@ void bsp_start(void) { uintptr_t workspace_ptr; - /* - * Copy the table (normally done in shared main). - */ - - BSP_Configuration = Configuration; - /* * If the node number is -1 then the application better provide * it through environment variables RTEMS_NODE. * Ditto for RTEMS_MAXIMUM_NODES */ - if (BSP_Configuration.User_multiprocessing_table) { + if (Configuration.User_multiprocessing_table) { 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) - { + if (Configuration.User_multiprocessing_table->node == -1) { p = getenv("RTEMS_NODE"); - BSP_Multiprocessing.node = p ? atoi(p) : 1; + Configuration.User_multiprocessing_table->node = p ? atoi(p) : 1; } /* If needed provide maximum_nodes also */ - if (BSP_Multiprocessing.maximum_nodes == -1) - { + if (Configuration.User_multiprocessing_table->maximum_nodes == -1) { p = getenv("RTEMS_MAXIMUM_NODES"); - BSP_Multiprocessing.maximum_nodes = p ? atoi(p) : 1; + Configuration.User_multiprocessing_table->maximum_nodes = p ? atoi(p) : 1; } } @@ -155,41 +133,28 @@ void bsp_start(void) * Set cpu_number to accurately reflect our cpu number */ - if (BSP_Configuration.User_multiprocessing_table) - cpu_number = BSP_Configuration.User_multiprocessing_table->node - 1; + if (Configuration.User_multiprocessing_table->User_multiprocessing_table) + cpu_number = Configuration.User_multiprocessing_table->node - 1; else cpu_number = 0; if (getenv("RTEMS_WORKSPACE_SIZE")) - BSP_Configuration.work_space_size = + rtems_configuration_get_work_space_size() = strtol(getenv("RTEMS_WORKSPACE_SIZE"), 0, 0); else - BSP_Configuration.work_space_size = DEFAULT_WORKSPACE_SIZE; + rtems_configuration_get_work_space_size() = DEFAULT_WORKSPACE_SIZE; /* * Allocate workspace memory, ensuring it is properly aligned */ workspace_ptr = - (uintptr_t) sbrk(BSP_Configuration.work_space_size + CPU_ALIGNMENT); + (uintptr_t) sbrk(rtems_configuration_get_work_space_size() + CPU_ALIGNMENT); workspace_ptr += CPU_ALIGNMENT - 1; workspace_ptr &= ~(CPU_ALIGNMENT - 1); - BSP_Configuration.work_space_start = (void *) workspace_ptr; - - /* - * Add 1 extension for MPCI_fatal - */ - - if (BSP_Configuration.User_multiprocessing_table) - BSP_Configuration.maximum_extensions++; + Configuration.work_space_start = (void *) workspace_ptr; CPU_CLICKS_PER_TICK = 1; - /* - * Start most of RTEMS - * main() will start the rest - */ - - bsp_isr_level = rtems_initialize_executive_early( &BSP_Configuration ); } 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 8878c51e41..7d04ceafc6 100644 --- a/c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc +++ b/c/src/lib/libbsp/unix/posix/startup/rtems-ctor.cc @@ -49,15 +49,6 @@ #include #include -/* - * RTEMS program name - * Probably not used by anyone, but it is nice to have it. - * Actually the UNIX version of CPU_INVOKE_DEBUGGER will probably - * need to use it - */ - -char *rtems_progname; - class RTEMS { public: RTEMS(); @@ -89,6 +80,14 @@ extern "C" { rtems_argc = argc; rtems_argv = argv; + rtems_interrupt_level bsp_isr_level; + + /* + * Make sure interrupts are disabled. + */ + + rtems_interrupt_disable( bsp_isr_level ); + if ((argc > 0) && argv && argv[0]) rtems_progname = argv[0]; else @@ -102,6 +101,8 @@ extern "C" { invoke_non_gnu_constructors(); #endif + rtems_initialize_executive_early( &Configuration ); + /* * Start multitasking */ -- cgit v1.2.3