genode/base-okl4/src/platform/_main_helper.h
Christian Prochaska a99193ad90 Rework the internal lock interface
With this patch, the 'futex' syscall gets used for blocking and unblocking
of threads in the Linux-specific lock implementation.

The 'Native_thread_id' type, which was previously used in the
lock-internal 'Applicant' class to identify a thread to be woken up,
was not suitable anymore for implementing this change. With this patch,
the 'Thread_base*' type gets used instead, which also has the positive
effect of making the public 'cancelable_lock.h' header file
platform-independent.

Fixes #646.
2013-02-25 22:14:21 +01:00

56 lines
1.2 KiB
C++

/*
* \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_
/* OKL4-specific includes and definitions */
namespace Okl4 { extern "C" {
#include <l4/utcb.h>
#include <l4/thread.h>
} }
namespace Okl4 {
/*
* Read global thread ID from user-defined handle and store it
* into a designated UTCB entry.
*/
L4_Word_t copy_uregister_to_utcb()
{
using namespace Okl4;
L4_Word_t my_global_id = L4_UserDefinedHandle();
__L4_TCR_Set_ThreadWord(Genode::UTCB_TCR_THREAD_WORD_MYSELF,
my_global_id);
return my_global_id;
}
}
Genode::Native_thread_id main_thread_tid;
static void main_thread_bootstrap()
{
/* copy thread ID to utcb */
main_thread_tid.raw = Okl4::copy_uregister_to_utcb();
if (main_thread_tid.raw == 0) /* core */
main_thread_tid.raw = Okl4::L4_rootserver.raw;
}
#endif /* _PLATFORM___MAIN_HELPER_H_ */