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