Xenomai  3.0-rc7
internal.h
1 /*
2  * Copyright (C) 2011 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 #ifndef _COPPERPLATE_INTERNAL_H
19 #define _COPPERPLATE_INTERNAL_H
20 
21 #include <sys/types.h>
22 #include <stdarg.h>
23 #include <time.h>
24 #include <pthread.h>
25 #include <semaphore.h>
26 #include <xeno_config.h>
27 #include <boilerplate/list.h>
28 #include <boilerplate/ancillaries.h>
29 #include <boilerplate/limits.h>
30 #include <boilerplate/sched.h>
31 #include <boilerplate/setup.h>
32 #include <copperplate/heapobj.h>
33 #include <copperplate/tunables.h>
34 
35 #ifdef CONFIG_XENO_REGISTRY
36 #define DEFAULT_REGISTRY_ROOT CONFIG_XENO_REGISTRY_ROOT
37 #else
38 #define DEFAULT_REGISTRY_ROOT NULL
39 #endif
40 
41 #define HOBJ_MINLOG2 3
42 #define HOBJ_MAXLOG2 22 /* Must hold pagemap::bcount objects */
43 #define HOBJ_NBUCKETS (HOBJ_MAXLOG2 - HOBJ_MINLOG2 + 2)
44 
45 /*
46  * The struct below has to live in shared memory; no direct reference
47  * to process local memory in there.
48  */
49 struct shared_heap {
50  char name[XNOBJECT_NAME_LEN];
51  pthread_mutex_t lock;
52  struct listobj extents;
53  size_t ubytes;
54  size_t total;
55  size_t maxcont;
56  struct sysgroup_memspec memspec;
57  struct {
58  memoff_t freelist;
59  int fcount;
60  } buckets[HOBJ_NBUCKETS];
61 };
62 
63 struct corethread_attributes {
64  size_t stacksize;
65  int detachstate;
66  int policy;
67  struct sched_param_ex param_ex;
68  int (*prologue)(void *arg);
69  void *(*run)(void *arg);
70  void *arg;
71  struct {
72  int status;
73  sem_t warm;
74  sem_t *released;
75  } __reserved;
76 };
77 
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
82 void copperplate_set_current_name(const char *name);
83 
84 int copperplate_kill_tid(pid_t tid, int sig);
85 
86 int copperplate_create_thread(struct corethread_attributes *cta,
87  pthread_t *ptid);
88 
89 int copperplate_renice_local_thread(pthread_t ptid, int policy,
90  const struct sched_param_ex *param_ex);
91 
92 void copperplate_bootstrap_internal(const char *arg0,
93  char *mountpt, int regflags);
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* _COPPERPLATE_INTERNAL_H */