Xenomai  3.0-rc3
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 <copperplate/heapobj.h>
32 
33 #ifdef CONFIG_XENO_REGISTRY
34 #define DEFAULT_REGISTRY_ROOT CONFIG_XENO_REGISTRY_ROOT
35 #define DEFAULT_REGISTRY_SESSION "anon"
36 #endif
37 
38 struct coppernode {
39  unsigned int mem_pool;
40  const char *session_label;
41  const char *registry_root;
42  cpu_set_t cpu_affinity;
43  int no_mlock;
44  int no_registry;
45  int no_sanity;
46  int reset_session;
47  int silent_mode;
48 };
49 
50 #define HOBJ_MINLOG2 3
51 #define HOBJ_MAXLOG2 22 /* Must hold pagemap::bcount objects */
52 #define HOBJ_NBUCKETS (HOBJ_MAXLOG2 - HOBJ_MINLOG2 + 2)
53 
54 /*
55  * The struct below has to live in shared memory; no direct reference
56  * to process local memory in there.
57  */
58 struct shared_heap {
59  char name[XNOBJECT_NAME_LEN];
60  pthread_mutex_t lock;
61  struct list extents;
62  size_t extentsize;
63  size_t hdrsize;
64  size_t npages;
65  size_t ubytes;
66  size_t total;
67  size_t maxcont;
68  struct sysgroup_memspec memspec;
69  struct {
70  memoff_t freelist;
71  int fcount;
72  } buckets[HOBJ_NBUCKETS];
73 };
74 
75 struct corethread_attributes {
76  size_t stacksize;
77  int detachstate;
78  int policy;
79  struct sched_param_ex param_ex;
80  int (*prologue)(void *arg);
81  void *(*run)(void *arg);
82  void *arg;
83  struct {
84  int status;
85  sem_t warm;
86  sem_t *released;
87  } __reserved;
88 };
89 
90 extern pid_t __node_id;
91 
92 extern struct coppernode __node_info;
93 
94 static inline void copperplate_set_silent(void)
95 {
96  __node_info.silent_mode = 1;
97 }
98 
99 #ifdef __cplusplus
100 extern "C" {
101 #endif
102 
103 void copperplate_set_current_name(const char *name);
104 
105 int copperplate_kill_tid(pid_t tid, int sig);
106 
107 int copperplate_create_thread(struct corethread_attributes *cta,
108  pthread_t *ptid);
109 
110 int copperplate_renice_local_thread(pthread_t ptid, int policy,
111  const struct sched_param_ex *param_ex);
112 
113 void copperplate_bootstrap_minimal(const char *arg0,
114  char *mountpt, int shared_registry);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* _COPPERPLATE_INTERNAL_H */