Xenomai  3.0.8
task.h
1 /*
2  * Copyright (C) 2008 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13 
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 
19 #ifndef _PSOS_TASK_H
20 #define _PSOS_TASK_H
21 
22 #include <boilerplate/hash.h>
23 #include <copperplate/threadobj.h>
24 #include <copperplate/syncobj.h>
25 #include <copperplate/cluster.h>
26 
27 struct psos_task_args {
28  void (*entry)(u_long a0, u_long a1, u_long a2, u_long a3);
29  u_long arg0;
30  u_long arg1;
31  u_long arg2;
32  u_long arg3;
33 };
34 
35 #define PSOSTASK_NR_REGS 16
36 
37 struct psos_task {
38 
39  int flags;
40  int mode;
41  u_long events;
42  u_long notepad[PSOSTASK_NR_REGS];
43  struct pvlistobj timer_list; /* Private. Never accessed remotely. */
44 
45  char name[XNOBJECT_NAME_LEN];
46  struct psos_task_args args;
47 
48  struct threadobj thobj;
49  struct syncobj sobj; /* For events. */
50  struct clusterobj cobj;
51 };
52 
53 #define task_magic 0x8181fafa
54 
55 static inline struct psos_task *psos_task_current(void)
56 {
57  struct threadobj *thobj = threadobj_current();
58 
59  if (thobj == NULL ||
60  threadobj_get_magic(thobj) != task_magic)
61  return NULL;
62 
63  return container_of(thobj, struct psos_task, thobj);
64 }
65 
66 struct psos_task *get_psos_task(u_long tid, int *err_r);
67 
68 struct psos_task *get_psos_task_or_self(u_long tid, int *err_r);
69 
70 void put_psos_task(struct psos_task *task);
71 
72 int __ev_send(struct psos_task *task, unsigned long events);
73 
74 extern struct cluster psos_task_table;
75 
76 #endif /* _PSOS_TASK_H */