Move main bootstrap to platform-specific object

To prevent multiple execution of main-bootstrap, I moved the code to a
statically initialized object. The reason for this change is that
_main() is exeuted twice when starting dynamic binaries. Now, the object
is part of the base-common library which is linked with ld.lib.so.
This commit is contained in:
Christian Helmuth
2013-09-10 14:33:14 +02:00
parent 4556a9e353
commit f763e5ec2a
19 changed files with 191 additions and 155 deletions

View File

@@ -6,7 +6,7 @@
LIBS += cxx l4 startup
SRC_CC += cap_copy.cc
SRC_CC += cap_copy.cc main_bootstrap.cc
SRC_CC += ipc/ipc.cc ipc/pager.cc ipc/ipc_marshal_cap.cc
SRC_CC += pager/pager.cc
SRC_CC += avl_tree/avl_tree.cc
@@ -28,6 +28,7 @@ INC_DIR += $(REP_DIR)/src/base/lock
INC_DIR += $(BASE_DIR)/src/base/thread
INC_DIR += $(REP_DIR)/include/codezero/dummies
vpath cap_copy.cc $(BASE_DIR)/src/platform
vpath %.cc $(REP_DIR)/src/base
vpath %.cc $(BASE_DIR)/src/base
vpath main_bootstrap.cc $(REP_DIR)/src/platform
vpath cap_copy.cc $(BASE_DIR)/src/platform
vpath %.cc $(REP_DIR)/src/base
vpath %.cc $(BASE_DIR)/src/base

View File

@@ -1,6 +1,7 @@
/*
* \brief Platform-specific helper functions for the _main() function
* \author Norman Feske
* \author Christian Helmuth
* \date 2009-10-02
*/
@@ -11,14 +12,11 @@
* under the terms of the GNU General Public License version 2.
*/
#ifndef _PLATFORM___MAIN_HELPER_H_
#define _PLATFORM___MAIN_HELPER_H_
/* Genode includes */
#include <base/stdint.h>
#include <base/printf.h>
/* make Codezero includes happy */
extern "C" char *strncpy(char *dest, const char *src, Genode::size_t n);
extern "C" void *memcpy(void *dest, const void *src, Genode::size_t n);
#include <base/thread.h>
#include <util/string.h>
/* Codezero includes */
#include <codezero/syscalls.h>
@@ -59,19 +57,25 @@ extern "C" int printf(const char *format, ...)
** Startup-code helpers **
**************************/
namespace Genode { void platform_main_bootstrap(); }
Genode::Native_thread_id main_thread_tid;
Codezero::l4_mutex main_thread_running_lock;
static void main_thread_bootstrap()
void Genode::platform_main_bootstrap()
{
Codezero::__l4_init();
static struct Bootstrap
{
Bootstrap()
{
Codezero::__l4_init();
main_thread_tid = Codezero::thread_myself();
main_thread_tid = Codezero::thread_myself();
Codezero::l4_mutex_init(&main_thread_running_lock);
Codezero::l4_mutex_lock(&main_thread_running_lock); /* block on first mutex lock */
Codezero::l4_mutex_init(&main_thread_running_lock);
Codezero::l4_mutex_lock(&main_thread_running_lock); /* block on first mutex lock */
}
} bootstrap;
}
#endif /* _PLATFORM___MAIN_HELPER_H_ */