1 /**
2  * \file
3  * \brief  Low-level Thread Functions
4  *
5  * \date   1997
6  * \author Sebastian Schönberg */
7 
8 /*
9  * (c) 2003-2009 Author(s)
10  *     economic rights: Technische Universität Dresden (Germany)
11  * This file is part of TUD:OS and distributed under the terms of the
12  * GNU Lesser General Public License 2.1.
13  * Please see the COPYING-LGPL-2.1 file for details.
14  */
15 
16 #ifndef __L4_THREAD_H
17 #define __L4_THREAD_H
18 
19 #include <l4/sys/types.h>
20 #include <l4/sys/scheduler.h>
21 
22 EXTERN_C_BEGIN
23 
24 /**
25  * \defgroup l4util_thread Low-Level Thread Functions
26  * \ingroup l4util_api
27  */
28 
29 /**
30  * \internal
31  * \brief Create an L4 thread.
32  * \ingroup l4util_thread
33  * \note  You should only use this when you know what you're doing, thanks.
34  * \param id          Cap-idx of new thread
35  * \param thread_utcb Utcb of the new thread
36  * \param factory     Factory to create the thread from
37  * \param pc          Initial value of instruction pointer
38  * \param sp          Initial value of stack pointer
39  * \param pager       Pager of the thread
40  * \param task        Task to put thread in
41  * \param scheduler   Scheduler to use, specify L4_INVALID_CAP for not
42  *                    calling the scheduler.
43  * \param sp          Scheduler params to use
44  * \return 0 on success, <0 on error
45  */
46 L4_CV long
47 l4util_create_thread(l4_cap_idx_t id, l4_utcb_t *thread_utcb,
48                      l4_cap_idx_t factory,
49                      l4_umword_t pc, l4_umword_t sp, l4_cap_idx_t pager,
50                      l4_cap_idx_t task,
51                      l4_cap_idx_t scheduler, l4_sched_param_t scp) L4_NOTHROW;
52 
53 EXTERN_C_END
54 
55 #ifndef L4UTIL_THREAD_FUNC
56 /**
57  * Defines a wrapper function that sets up the registers according
58  * to the calling conventions for the architecture.
59  *
60  * Use this as a function header when starting a low-level thread
61  * where only stack and instruction pointer are in a well-defined state.
62  *
63  * Example:
64  *
65  * L4UTIL_THREAD_FUNC(helper_thread)
66  * {
67  *   for(;;);
68  * }
69  *
70  * thread_cap->ex_regs((l4_umword_t)helper_thread, stack_addr);
71  */
72 #define __L4UTIL_THREAD_FUNC(name) void L4_NORETURN name(void)
73 #define L4UTIL_THREAD_FUNC(name) __L4UTIL_THREAD_FUNC(name)
74 #define __L4UTIL_THREAD_STATIC_FUNC(name) static L4_NORETURN void name(void)
75 #define L4UTIL_THREAD_STATIC_FUNC(name) __L4UTIL_THREAD_STATIC_FUNC(name)
76 #endif
77 
78 #endif /* __L4_THREAD_H */
79