mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-24 07:46:42 +00:00
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:
parent
4556a9e353
commit
f763e5ec2a
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
LIBS += cxx l4 startup
|
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 += ipc/ipc.cc ipc/pager.cc ipc/ipc_marshal_cap.cc
|
||||||
SRC_CC += pager/pager.cc
|
SRC_CC += pager/pager.cc
|
||||||
SRC_CC += avl_tree/avl_tree.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 += $(BASE_DIR)/src/base/thread
|
||||||
INC_DIR += $(REP_DIR)/include/codezero/dummies
|
INC_DIR += $(REP_DIR)/include/codezero/dummies
|
||||||
|
|
||||||
vpath cap_copy.cc $(BASE_DIR)/src/platform
|
vpath main_bootstrap.cc $(REP_DIR)/src/platform
|
||||||
vpath %.cc $(REP_DIR)/src/base
|
vpath cap_copy.cc $(BASE_DIR)/src/platform
|
||||||
vpath %.cc $(BASE_DIR)/src/base
|
vpath %.cc $(REP_DIR)/src/base
|
||||||
|
vpath %.cc $(BASE_DIR)/src/base
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* \brief Platform-specific helper functions for the _main() function
|
* \brief Platform-specific helper functions for the _main() function
|
||||||
* \author Norman Feske
|
* \author Norman Feske
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2009-10-02
|
* \date 2009-10-02
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -11,14 +12,11 @@
|
|||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PLATFORM___MAIN_HELPER_H_
|
/* Genode includes */
|
||||||
#define _PLATFORM___MAIN_HELPER_H_
|
#include <base/stdint.h>
|
||||||
|
|
||||||
#include <base/printf.h>
|
#include <base/printf.h>
|
||||||
|
#include <base/thread.h>
|
||||||
/* make Codezero includes happy */
|
#include <util/string.h>
|
||||||
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);
|
|
||||||
|
|
||||||
/* Codezero includes */
|
/* Codezero includes */
|
||||||
#include <codezero/syscalls.h>
|
#include <codezero/syscalls.h>
|
||||||
@ -59,19 +57,25 @@ extern "C" int printf(const char *format, ...)
|
|||||||
** Startup-code helpers **
|
** Startup-code helpers **
|
||||||
**************************/
|
**************************/
|
||||||
|
|
||||||
|
namespace Genode { void platform_main_bootstrap(); }
|
||||||
|
|
||||||
|
|
||||||
Genode::Native_thread_id main_thread_tid;
|
Genode::Native_thread_id main_thread_tid;
|
||||||
Codezero::l4_mutex main_thread_running_lock;
|
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_init(&main_thread_running_lock);
|
||||||
Codezero::l4_mutex_lock(&main_thread_running_lock); /* block on first mutex lock */
|
Codezero::l4_mutex_lock(&main_thread_running_lock); /* block on first mutex lock */
|
||||||
|
}
|
||||||
|
} bootstrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _PLATFORM___MAIN_HELPER_H_ */
|
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
LIBS += cxx startup
|
LIBS += cxx 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 += ipc/ipc.cc ipc/pager.cc ipc/ipc_marshal_cap.cc
|
||||||
SRC_CC += pager/pager.cc
|
SRC_CC += pager/pager.cc
|
||||||
SRC_CC += avl_tree/avl_tree.cc
|
SRC_CC += avl_tree/avl_tree.cc
|
||||||
@ -25,6 +25,7 @@ SRC_CC += thread/thread.cc thread/thread_bootstrap_empty.cc thread/trace.cc
|
|||||||
INC_DIR += $(REP_DIR)/src/base/lock
|
INC_DIR += $(REP_DIR)/src/base/lock
|
||||||
INC_DIR += $(BASE_DIR)/src/base/thread
|
INC_DIR += $(BASE_DIR)/src/base/thread
|
||||||
|
|
||||||
vpath cap_copy.cc $(BASE_DIR)/src/platform
|
vpath main_bootstrap.cc $(REP_DIR)/src/platform
|
||||||
vpath %.cc $(REP_DIR)/src/base
|
vpath cap_copy.cc $(BASE_DIR)/src/platform
|
||||||
vpath %.cc $(BASE_DIR)/src/base
|
vpath %.cc $(REP_DIR)/src/base
|
||||||
|
vpath %.cc $(BASE_DIR)/src/base
|
||||||
|
@ -11,9 +11,4 @@
|
|||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PLATFORM___MAIN_HELPER_H_
|
namespace Genode { void platform_main_bootstrap() { /* dummy */ } }
|
||||||
#define _PLATFORM___MAIN_HELPER_H_
|
|
||||||
|
|
||||||
static void main_thread_bootstrap() { }
|
|
||||||
|
|
||||||
#endif /* _PLATFORM___MAIN_HELPER_H_ */
|
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
LIBS += cxx syscall startup
|
LIBS += cxx syscall startup
|
||||||
|
|
||||||
|
SRC_CC += main_bootstrap.cc
|
||||||
SRC_CC += ipc/ipc.cc ipc/pager.cc
|
SRC_CC += ipc/ipc.cc ipc/pager.cc
|
||||||
SRC_CC += pager/pager.cc
|
SRC_CC += pager/pager.cc
|
||||||
SRC_CC += avl_tree/avl_tree.cc
|
SRC_CC += avl_tree/avl_tree.cc
|
||||||
@ -26,5 +27,8 @@ INC_DIR += $(REP_DIR)/src/base/lock
|
|||||||
INC_DIR += $(BASE_DIR)/src/base/lock
|
INC_DIR += $(BASE_DIR)/src/base/lock
|
||||||
INC_DIR += $(BASE_DIR)/src/base/thread
|
INC_DIR += $(BASE_DIR)/src/base/thread
|
||||||
|
|
||||||
vpath %.cc $(REP_DIR)/src/base
|
vpath main_bootstrap.cc $(REP_DIR)/src/platform
|
||||||
vpath %.cc $(BASE_DIR)/src/base
|
vpath %.cc $(REP_DIR)/src/base
|
||||||
|
vpath %.cc $(BASE_DIR)/src/base
|
||||||
|
|
||||||
|
# vi: set ft=make :
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* \brief Platform-specific helper functions for the _main() function
|
* \brief Platform-specific helper functions for the _main() function
|
||||||
* \author Christian Prochaska
|
* \author Christian Prochaska
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2009-08-05
|
* \date 2009-08-05
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -11,9 +12,6 @@
|
|||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PLATFORM___MAIN_HELPER_H_
|
|
||||||
#define _PLATFORM___MAIN_HELPER_H_
|
|
||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/stdint.h>
|
#include <base/stdint.h>
|
||||||
#include <base/native_types.h>
|
#include <base/native_types.h>
|
||||||
@ -23,16 +21,21 @@ namespace Fiasco {
|
|||||||
#include <l4/sys/utcb.h>
|
#include <l4/sys/utcb.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { MAIN_THREAD_CAP_ID = 1 };
|
|
||||||
|
|
||||||
static void main_thread_bootstrap() {
|
namespace Genode { void platform_main_bootstrap(); }
|
||||||
using namespace Genode;
|
|
||||||
|
|
||||||
Cap_index *i
|
|
||||||
= cap_map()->insert(MAIN_THREAD_CAP_ID, Fiasco::MAIN_THREAD_CAP);
|
void Genode::platform_main_bootstrap()
|
||||||
Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_BADGE] = (unsigned long) i;
|
{
|
||||||
Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_THREAD_OBJ] = 0;
|
static struct Bootstrap
|
||||||
|
{
|
||||||
|
enum { MAIN_THREAD_CAP_ID = 1 };
|
||||||
|
|
||||||
|
Bootstrap()
|
||||||
|
{
|
||||||
|
Cap_index *i(cap_map()->insert(MAIN_THREAD_CAP_ID, Fiasco::MAIN_THREAD_CAP));
|
||||||
|
Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_BADGE] = (unsigned long) i;
|
||||||
|
Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_THREAD_OBJ] = 0;
|
||||||
|
}
|
||||||
|
} bootstrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* _PLATFORM___MAIN_HELPER_H_ */
|
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
LIBS += cxx syscall
|
LIBS += cxx syscall
|
||||||
|
|
||||||
|
SRC_CC += main_bootstrap.cc
|
||||||
SRC_CC += ipc.cc ipc/ipc_marshal_cap.cc
|
SRC_CC += ipc.cc ipc/ipc_marshal_cap.cc
|
||||||
SRC_CC += avl_tree/avl_tree.cc
|
SRC_CC += avl_tree/avl_tree.cc
|
||||||
SRC_CC += allocator/slab.cc
|
SRC_CC += allocator/slab.cc
|
||||||
@ -24,5 +25,6 @@ INC_DIR += $(REP_DIR)/src/base/lock
|
|||||||
INC_DIR += $(BASE_DIR)/src/base/lock
|
INC_DIR += $(BASE_DIR)/src/base/lock
|
||||||
INC_DIR += $(BASE_DIR)/src/base/thread
|
INC_DIR += $(BASE_DIR)/src/base/thread
|
||||||
|
|
||||||
vpath %.cc $(REP_DIR)/src/base
|
vpath main_bootstrap.cc $(REP_DIR)/src/platform
|
||||||
vpath %.cc $(BASE_DIR)/src/base
|
vpath %.cc $(REP_DIR)/src/base
|
||||||
|
vpath %.cc $(BASE_DIR)/src/base
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* \brief Platform-specific helper functions for the _main() function
|
* \brief Platform-specific helper functions for the _main() function
|
||||||
* \author Martin Stein
|
* \author Martin Stein
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2010-09-13
|
* \date 2010-09-13
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -11,19 +12,20 @@
|
|||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SRC__PLATFORM__MAIN_HELPER_H_
|
/* Genode includes */
|
||||||
#define _SRC__PLATFORM__MAIN_HELPER_H_
|
|
||||||
|
|
||||||
#include <base/native_types.h>
|
#include <base/native_types.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Genode { void platform_main_bootstrap(); }
|
||||||
|
|
||||||
|
|
||||||
Genode::Native_thread_id main_thread_tid;
|
Genode::Native_thread_id main_thread_tid;
|
||||||
|
|
||||||
|
|
||||||
static void main_thread_bootstrap()
|
void Genode::platform_main_bootstrap()
|
||||||
{
|
{
|
||||||
main_thread_tid = Kernel::current_thread_id();
|
static struct Bootstrap
|
||||||
|
{
|
||||||
|
Bootstrap() { main_thread_tid = Kernel::current_thread_id(); }
|
||||||
|
} bootstrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _SRC__PLATFORM__MAIN_HELPER_H_ */
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
LIBS += syscall
|
LIBS += syscall
|
||||||
|
|
||||||
|
SRC_CC += main_bootstrap.cc
|
||||||
SRC_CC += ipc/ipc.cc
|
SRC_CC += ipc/ipc.cc
|
||||||
SRC_CC += avl_tree/avl_tree.cc
|
SRC_CC += avl_tree/avl_tree.cc
|
||||||
SRC_CC += allocator/slab.cc
|
SRC_CC += allocator/slab.cc
|
||||||
@ -27,5 +28,6 @@ INC_DIR += $(REP_DIR)/src/base/env
|
|||||||
INC_DIR += $(REP_DIR)/src/platform $(BASE_DIR)/src/platform
|
INC_DIR += $(REP_DIR)/src/platform $(BASE_DIR)/src/platform
|
||||||
INC_DIR += $(BASE_DIR)/src/base/thread
|
INC_DIR += $(BASE_DIR)/src/base/thread
|
||||||
|
|
||||||
vpath %.cc $(REP_DIR)/src/base
|
vpath main_bootstrap.cc $(REP_DIR)/src/platform
|
||||||
vpath %.cc $(BASE_DIR)/src/base
|
vpath %.cc $(REP_DIR)/src/base
|
||||||
|
vpath %.cc $(BASE_DIR)/src/base
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* \brief Platform-specific helper functions for the _main() function
|
|
||||||
* \author Christian Prochaska
|
|
||||||
* \date 2009-08-05
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2009-2013 Genode Labs GmbH
|
|
||||||
*
|
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
|
||||||
* under the terms of the GNU General Public License version 2.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _PLATFORM___MAIN_HELPER_H_
|
|
||||||
#define _PLATFORM___MAIN_HELPER_H_
|
|
||||||
|
|
||||||
#include <base/thread.h>
|
|
||||||
|
|
||||||
#include <linux_syscalls.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Define 'lx_environ' pointer.
|
|
||||||
*/
|
|
||||||
char **lx_environ;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Natively aligned memory location used in the lock implementation
|
|
||||||
*/
|
|
||||||
int main_thread_futex_counter __attribute__((aligned(sizeof(Genode::addr_t))));
|
|
||||||
|
|
||||||
|
|
||||||
static inline void main_thread_bootstrap()
|
|
||||||
{
|
|
||||||
using namespace Genode;
|
|
||||||
|
|
||||||
extern Genode::addr_t *__initial_sp;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the 'lx_environ' pointer
|
|
||||||
*
|
|
||||||
* environ = &argv[argc + 1]
|
|
||||||
* __initial_sp[0] = argc (always 1 in Genode)
|
|
||||||
* __initial_sp[1] = argv[0]
|
|
||||||
* __initial_sp[2] = NULL
|
|
||||||
* __initial_sp[3] = environ
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
lx_environ = (char**)&__initial_sp[3];
|
|
||||||
|
|
||||||
/* reserve context area */
|
|
||||||
Genode::addr_t base = Native_config::context_area_virtual_base();
|
|
||||||
Genode::size_t size = Native_config::context_area_virtual_size();
|
|
||||||
if (lx_vm_reserve(base, size) != base)
|
|
||||||
PERR("reservation of context area [%lx,%lx) failed",
|
|
||||||
(unsigned long) base, (unsigned long) base + size);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _PLATFORM___MAIN_HELPER_H_ */
|
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <base/crt0.h>
|
#include <base/crt0.h>
|
||||||
#include <base/printf.h>
|
#include <base/printf.h>
|
||||||
#include <_main_helper.h>
|
#include <linux_syscalls.h>
|
||||||
#include <linux_cpu_session/linux_cpu_session.h>
|
#include <linux_cpu_session/linux_cpu_session.h>
|
||||||
|
|
||||||
|
|
||||||
|
71
base-linux/src/platform/main_bootstrap.cc
Normal file
71
base-linux/src/platform/main_bootstrap.cc
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* \brief Platform-specific helper functions for the _main() function
|
||||||
|
* \author Christian Prochaska
|
||||||
|
* \author Christian Helmuth
|
||||||
|
* \date 2009-08-05
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2013 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU General Public License version 2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <base/thread.h>
|
||||||
|
#include <linux_syscalls.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Genode { void platform_main_bootstrap(); }
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define 'lx_environ' pointer.
|
||||||
|
*/
|
||||||
|
char **lx_environ;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Natively aligned memory location used in the lock implementation
|
||||||
|
*/
|
||||||
|
int main_thread_futex_counter __attribute__((aligned(sizeof(Genode::addr_t))));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initial value of SP register (in crt0)
|
||||||
|
*/
|
||||||
|
extern Genode::addr_t *__initial_sp;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platform-specific bootstrap
|
||||||
|
*/
|
||||||
|
void Genode::platform_main_bootstrap()
|
||||||
|
{
|
||||||
|
static struct Bootstrap
|
||||||
|
{
|
||||||
|
Bootstrap()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Initialize the 'lx_environ' pointer
|
||||||
|
*
|
||||||
|
* environ = &argv[argc + 1]
|
||||||
|
* __initial_sp[0] = argc (always 1 in Genode)
|
||||||
|
* __initial_sp[1] = argv[0]
|
||||||
|
* __initial_sp[2] = NULL
|
||||||
|
* __initial_sp[3] = environ
|
||||||
|
*/
|
||||||
|
lx_environ = (char**)&__initial_sp[3];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free context area preserved in linker script
|
||||||
|
*/
|
||||||
|
addr_t base = Native_config::context_area_virtual_base();
|
||||||
|
Genode::size_t size = Native_config::context_area_virtual_size();
|
||||||
|
int ret;
|
||||||
|
if ((ret = lx_munmap((void *)base, size)) < 0)
|
||||||
|
PERR("flushing of context area [%lx,%lx) failed (ret=%d)",
|
||||||
|
(unsigned long) base, (unsigned long) base + size, ret);
|
||||||
|
}
|
||||||
|
} bootstrap;
|
||||||
|
}
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
LIBS += cxx startup
|
LIBS += cxx startup
|
||||||
|
|
||||||
|
SRC_CC += main_bootstrap.cc
|
||||||
SRC_CC += ipc/ipc.cc ipc/pager.cc
|
SRC_CC += ipc/ipc.cc ipc/pager.cc
|
||||||
SRC_CC += avl_tree/avl_tree.cc
|
SRC_CC += avl_tree/avl_tree.cc
|
||||||
SRC_CC += allocator/slab.cc
|
SRC_CC += allocator/slab.cc
|
||||||
@ -24,5 +25,8 @@ INC_DIR += $(REP_DIR)/src/base/lock
|
|||||||
INC_DIR += $(BASE_DIR)/src/base/lock
|
INC_DIR += $(BASE_DIR)/src/base/lock
|
||||||
INC_DIR += $(BASE_DIR)/src/base/thread
|
INC_DIR += $(BASE_DIR)/src/base/thread
|
||||||
|
|
||||||
vpath %.cc $(REP_DIR)/src/base
|
vpath main_bootstrap.cc $(REP_DIR)/src/platform
|
||||||
vpath %.cc $(BASE_DIR)/src/base
|
vpath %.cc $(REP_DIR)/src/base
|
||||||
|
vpath %.cc $(BASE_DIR)/src/base
|
||||||
|
|
||||||
|
# vi: set ft=make :
|
||||||
|
@ -12,11 +12,4 @@
|
|||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PLATFORM___MAIN_HELPER_H_
|
namespace Genode { void platform_main_bootstrap() { /* dummy */ } }
|
||||||
#define _PLATFORM___MAIN_HELPER_H_
|
|
||||||
|
|
||||||
#include <nova/syscalls.h>
|
|
||||||
|
|
||||||
static void main_thread_bootstrap() {};
|
|
||||||
|
|
||||||
#endif /* _PLATFORM___MAIN_HELPER_H_ */
|
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
LIBS += cxx startup
|
LIBS += cxx 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 += ipc/ipc.cc ipc/pager.cc ipc/ipc_marshal_cap.cc
|
||||||
SRC_CC += pager/pager.cc
|
SRC_CC += pager/pager.cc
|
||||||
SRC_CC += avl_tree/avl_tree.cc
|
SRC_CC += avl_tree/avl_tree.cc
|
||||||
@ -25,6 +25,7 @@ SRC_CC += thread/thread.cc thread/thread_bootstrap.cc thread/trace.cc
|
|||||||
INC_DIR += $(REP_DIR)/src/base/lock
|
INC_DIR += $(REP_DIR)/src/base/lock
|
||||||
INC_DIR += $(BASE_DIR)/src/base/thread
|
INC_DIR += $(BASE_DIR)/src/base/thread
|
||||||
|
|
||||||
vpath cap_copy.cc $(BASE_DIR)/src/platform
|
vpath main_bootstrap.cc $(REP_DIR)/src/platform
|
||||||
vpath %.cc $(REP_DIR)/src/base
|
vpath cap_copy.cc $(BASE_DIR)/src/platform
|
||||||
vpath %.cc $(BASE_DIR)/src/base
|
vpath %.cc $(REP_DIR)/src/base
|
||||||
|
vpath %.cc $(BASE_DIR)/src/base
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* \brief Platform-specific helper functions for the _main() function
|
* \brief Platform-specific helper functions for the _main() function
|
||||||
* \author Christian Prochaska
|
* \author Christian Prochaska
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2009-08-05
|
* \date 2009-08-05
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -11,9 +12,8 @@
|
|||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PLATFORM___MAIN_HELPER_H_
|
/* Genode includes */
|
||||||
#define _PLATFORM___MAIN_HELPER_H_
|
#include <base/native_types.h>
|
||||||
|
|
||||||
|
|
||||||
/* OKL4-specific includes and definitions */
|
/* OKL4-specific includes and definitions */
|
||||||
namespace Okl4 { extern "C" {
|
namespace Okl4 { extern "C" {
|
||||||
@ -40,16 +40,23 @@ namespace Okl4 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Genode { void platform_main_bootstrap(); }
|
||||||
|
|
||||||
|
|
||||||
Genode::Native_thread_id main_thread_tid;
|
Genode::Native_thread_id main_thread_tid;
|
||||||
|
|
||||||
|
|
||||||
static void main_thread_bootstrap()
|
void Genode::platform_main_bootstrap()
|
||||||
{
|
{
|
||||||
/* copy thread ID to utcb */
|
static struct Bootstrap
|
||||||
main_thread_tid.raw = Okl4::copy_uregister_to_utcb();
|
{
|
||||||
|
Bootstrap()
|
||||||
|
{
|
||||||
|
/* copy thread ID to utcb */
|
||||||
|
main_thread_tid.raw = Okl4::copy_uregister_to_utcb();
|
||||||
|
|
||||||
if (main_thread_tid.raw == 0) /* core */
|
if (main_thread_tid.raw == 0) /* core */
|
||||||
main_thread_tid.raw = Okl4::L4_rootserver.raw;
|
main_thread_tid.raw = Okl4::L4_rootserver.raw;
|
||||||
|
}
|
||||||
|
} bootstrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _PLATFORM___MAIN_HELPER_H_ */
|
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
LIBS += cxx startup
|
LIBS += cxx 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 += ipc/ipc.cc ipc/pager.cc ipc/ipc_marshal_cap.cc
|
||||||
SRC_CC += pager/pager.cc
|
SRC_CC += pager/pager.cc
|
||||||
SRC_CC += avl_tree/avl_tree.cc
|
SRC_CC += avl_tree/avl_tree.cc
|
||||||
@ -25,6 +25,7 @@ SRC_CC += thread/thread.cc thread/trace.cc thread/thread_bootstrap.cc
|
|||||||
INC_DIR += $(REP_DIR)/src/base/lock
|
INC_DIR += $(REP_DIR)/src/base/lock
|
||||||
INC_DIR += $(BASE_DIR)/src/base/thread
|
INC_DIR += $(BASE_DIR)/src/base/thread
|
||||||
|
|
||||||
vpath cap_copy.cc $(BASE_DIR)/src/platform
|
vpath main_bootstrap.cc $(REP_DIR)/src/platform
|
||||||
vpath %.cc $(REP_DIR)/src/base
|
vpath cap_copy.cc $(BASE_DIR)/src/platform
|
||||||
vpath %.cc $(BASE_DIR)/src/base
|
vpath %.cc $(REP_DIR)/src/base
|
||||||
|
vpath %.cc $(BASE_DIR)/src/base
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* \brief Platform-specific helper functions for the _main() function
|
* \brief Platform-specific helper functions for the _main() function
|
||||||
* \author Christian Prochaska
|
* \author Christian Prochaska
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2009-08-05
|
* \date 2009-08-05
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -11,25 +12,25 @@
|
|||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PLATFORM___MAIN_HELPER_H_
|
/* Genode includes */
|
||||||
#define _PLATFORM___MAIN_HELPER_H_
|
#include <base/native_types.h>
|
||||||
|
|
||||||
/* Pistachio includes */
|
/* Pistachio includes */
|
||||||
namespace Pistachio {
|
namespace Pistachio {
|
||||||
#include <l4/thread.h>
|
#include <l4/thread.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Genode includes */
|
|
||||||
#include <base/native_types.h>
|
namespace Genode { void platform_main_bootstrap(); }
|
||||||
|
|
||||||
|
|
||||||
Genode::Native_thread_id main_thread_tid;
|
Genode::Native_thread_id main_thread_tid;
|
||||||
|
|
||||||
|
|
||||||
static void main_thread_bootstrap()
|
void Genode::platform_main_bootstrap()
|
||||||
{
|
{
|
||||||
main_thread_tid = Pistachio::L4_Myself();
|
static struct Bootstrap
|
||||||
|
{
|
||||||
|
Bootstrap() { main_thread_tid = Pistachio::L4_Myself(); }
|
||||||
|
} bootstrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* _PLATFORM___MAIN_HELPER_H_ */
|
|
@ -25,7 +25,6 @@
|
|||||||
#include <base/printf.h>
|
#include <base/printf.h>
|
||||||
|
|
||||||
/* platform-specific local helper functions */
|
/* platform-specific local helper functions */
|
||||||
#include <_main_helper.h>
|
|
||||||
#include <_main_parent_cap.h>
|
#include <_main_parent_cap.h>
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +34,8 @@ extern int main(int argc, char **argv, char **envp);
|
|||||||
extern void init_exception_handling(); /* implemented in base/cxx */
|
extern void init_exception_handling(); /* implemented in base/cxx */
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
extern Rm_session *env_context_area_rm_session();
|
Rm_session *env_context_area_rm_session();
|
||||||
|
void platform_main_bootstrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -225,10 +225,13 @@ namespace Genode { extern bool inhibit_tracing; }
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* C entry function called by the crt0 startup code
|
* C entry function called by the crt0 startup code
|
||||||
|
*
|
||||||
|
* Note, _main is executed twice when starting dynamic programs: in ld.lib.so
|
||||||
|
* and also in the loaded binary.
|
||||||
*/
|
*/
|
||||||
extern "C" int _main()
|
extern "C" int _main()
|
||||||
{
|
{
|
||||||
main_thread_bootstrap();
|
platform_main_bootstrap();
|
||||||
|
|
||||||
/* call env() explicitly to setup the environment */
|
/* call env() explicitly to setup the environment */
|
||||||
(void*)env();
|
(void*)env();
|
||||||
|
Loading…
Reference in New Issue
Block a user