Xenomai 3.3.2
Loading...
Searching...
No Matches
process.h
1/*
2 * Copyright (C) 2013 Philippe Gerum <rpm@xenomai.org>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18#ifndef _COBALT_POSIX_PROCESS_H
19#define _COBALT_POSIX_PROCESS_H
20
21#include <linux/list.h>
22#include <linux/bitmap.h>
23#include <pipeline/thread.h>
24#include <cobalt/kernel/ppd.h>
25
26#define NR_PERSONALITIES 4
27#if BITS_PER_LONG < NR_PERSONALITIES
28#error "NR_PERSONALITIES overflows internal bitmap"
29#endif
30
31struct mm_struct;
32struct xnthread_personality;
33struct cobalt_timer;
34
35struct cobalt_resources {
36 struct list_head condq;
37 struct list_head mutexq;
38 struct list_head semq;
39 struct list_head monitorq;
40 struct list_head eventq;
41 struct list_head schedq;
42};
43
44struct cobalt_process {
45 struct mm_struct *mm;
46 struct hlist_node hlink;
47 struct cobalt_ppd sys_ppd;
48 unsigned long permap;
49 struct rb_root usems;
50 struct list_head sigwaiters;
51 struct cobalt_resources resources;
52 struct list_head thread_list;
53 DECLARE_BITMAP(timers_map, CONFIG_XENO_OPT_NRTIMERS);
54 struct cobalt_timer *timers[CONFIG_XENO_OPT_NRTIMERS];
55 void *priv[NR_PERSONALITIES];
56 int ufeatures;
57 unsigned int debugged_threads;
58};
59
60struct cobalt_resnode {
61 struct cobalt_resources *scope;
62 struct cobalt_process *owner;
63 struct list_head next;
64 xnhandle_t handle;
65};
66
67int cobalt_register_personality(struct xnthread_personality *personality);
68
69int cobalt_unregister_personality(int xid);
70
71struct xnthread_personality *cobalt_push_personality(int xid);
72
73void cobalt_pop_personality(struct xnthread_personality *prev);
74
75int cobalt_bind_core(int ufeatures);
76
77int cobalt_bind_personality(unsigned int magic);
78
79struct cobalt_process *cobalt_search_process(struct mm_struct *mm);
80
81int cobalt_map_user(struct xnthread *thread, __u32 __user *u_winoff);
82
83void *cobalt_get_context(int xid);
84
85int cobalt_yield(xnticks_t min, xnticks_t max);
86
87int cobalt_process_init(void);
88
89extern struct list_head cobalt_global_thread_list;
90
91extern struct cobalt_resources cobalt_global_resources;
92
93static inline struct cobalt_process *cobalt_current_process(void)
94{
95 return pipeline_current()->process;
96}
97
98static inline struct cobalt_process *
99cobalt_set_process(struct cobalt_process *process)
100{
101 struct cobalt_threadinfo *p = pipeline_current();
102 struct cobalt_process *old;
103
104 old = p->process;
105 p->process = process;
106
107 return old;
108}
109
110static inline struct cobalt_ppd *cobalt_ppd_get(int global)
111{
112 struct cobalt_process *process;
113
114 if (global || (process = cobalt_current_process()) == NULL)
115 return &cobalt_kernel_ppd;
116
117 return &process->sys_ppd;
118}
119
120static inline struct cobalt_resources *cobalt_current_resources(int pshared)
121{
122 struct cobalt_process *process;
123
124 if (pshared || (process = cobalt_current_process()) == NULL)
125 return &cobalt_global_resources;
126
127 return &process->resources;
128}
129
130static inline
131void __cobalt_add_resource(struct cobalt_resnode *node, int pshared)
132{
133 node->owner = cobalt_current_process();
134 node->scope = cobalt_current_resources(pshared);
135}
136
137#define cobalt_add_resource(__node, __type, __pshared) \
138 do { \
139 __cobalt_add_resource(__node, __pshared); \
140 list_add_tail(&(__node)->next, \
141 &((__node)->scope)->__type ## q); \
142 } while (0)
143
144static inline
145void cobalt_del_resource(struct cobalt_resnode *node)
146{
147 list_del(&node->next);
148}
149
150void cobalt_remove_process(struct cobalt_process *process);
151
152void cobalt_signal_yield(void);
153
154void cobalt_stop_debugged_process(struct xnthread *thread);
155
156void cobalt_register_debugged_thread(struct xnthread *thread);
157
158void cobalt_unregister_debugged_thread(struct xnthread *thread);
159
160extern struct xnthread_personality *cobalt_personalities[];
161
162extern struct xnthread_personality cobalt_personality;
163
164int cobalt_handle_setaffinity_event(struct task_struct *task);
165
166#ifdef CONFIG_SMP
167void cobalt_adjust_affinity(struct task_struct *task);
168#else
169static inline void cobalt_adjust_affinity(struct task_struct *task) { }
170#endif
171
172int cobalt_handle_taskexit_event(struct task_struct *task);
173
174int cobalt_handle_cleanup_event(struct mm_struct *mm);
175
176int cobalt_handle_user_return(struct task_struct *task);
177
178#endif /* !_COBALT_POSIX_PROCESS_H */