aboutsummaryrefslogtreecommitdiffstats
path: root/package/fusion/fusion.h
blob: d9139fc6d42faed2e9f64c4b1e82badaea6d4328 (plain)
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#ifndef __LINUX__FUSION_H__
#define __LINUX__FUSION_H__

#include <asm/ioctl.h>

/*
 * Fusion Kernel Device API Version
 */
#define FUSION_API_MAJOR      3         /* Increased if backward compatibility is dropped. */
#define FUSION_API_MINOR      2         /* Increased if new features are added. */

/*
 * The Fusion ID is a unique identifier for one process consisting of threads.
 */
typedef unsigned long FusionID;

#define FUSION_ID_MASTER      1         /* This is the fusion id of the master (first process). */

/*
 * Entering a world
 */
typedef struct {
     struct {
          int            major;         /* Must be set to FUSION_API_MAJOR before entering. */
          int            minor;         /* Must be set to FUSION_API_MINOR before entering. */
     } api;

     FusionID            fusion_id;     /* Returns the fusion id of the entering process. */
} FusionEnter;

/*
 * Forking in world
 */
typedef struct {
     FusionID            fusion_id;     /* Returns the fusion id of the new (forked) fusionee. */
} FusionFork;

/*
 * Sending a message
 */
typedef struct {
     FusionID            fusion_id;     /* recipient */

     int                 msg_id;        /* optional message identifier */
     int                 msg_size;      /* message size, must be greater than zero */
     const void         *msg_data;      /* message data, must not be NULL */
} FusionSendMessage;

/*
 * Receiving a message
 */
typedef enum {
     FMT_SEND,                          /* msg_id is an optional custom id */
     FMT_CALL,                          /* msg_id is the call id */
     FMT_REACTOR,                       /* msg_id is the reactor id */
     FMT_SHMPOOL                        /* msg_id is the pool id */
} FusionMessageType;

typedef struct {
     FusionMessageType   msg_type;      /* type (origin) of message */

     int                 msg_id;        /* message id (custom id or call/reactor/pool id) */
     int                 msg_size;      /* size of the following message data */

     /* message data follows */
} FusionReadMessage;

/*
 * Dispatching a message via a reactor
 */
typedef struct {
     int                 reactor_id;
     int                 self;

     int                 msg_size;      /* message size, must be greater than zero */
     const void         *msg_data;      /* message data, must not be NULL */
} FusionReactorDispatch;

/*
 * Calling (synchronous RPC)
 */
typedef struct {
     int                 call_id;       /* new call id returned */

     void               *handler;       /* function pointer of handler to install */
     void               *ctx;           /* optional handler context */
} FusionCallNew;

typedef enum {
     FCEF_NONE   = 0x00000000,
     FCEF_ONEWAY = 0x00000001,
     FCEF_ALL    = 0x00000001
} FusionCallExecFlags;

typedef struct {
     int                 ret_val;       /* return value of the call */

     int                 call_id;       /* id of the requested call, each call has a fixed owner */

     int                 call_arg;      /* optional int argument */
     void               *call_ptr;      /* optional pointer argument (shared memory) */

     FusionCallExecFlags flags;         /* execution flags */
} FusionCallExecute;

typedef struct {
     int                 call_id;       /* id of currently executing call */

     int                 val;           /* value to return */
} FusionCallReturn;

typedef struct {
     void               *handler;       /* function pointer of handler to call */
     void               *ctx;           /* optional handler context */

     int                 caller;        /* fusion id of the caller or zero if called from Fusion */
     int                 call_arg;      /* optional call parameter */
     void               *call_ptr;      /* optional call parameter */
} FusionCallMessage;

/*
 * Watching a reference
 *
 * This information is needed to have a specific call being executed if the
 * reference count reaches zero. Currently one watch per reference is allowed.
 *
 * The call is made by Fusion and therefor has a caller id of zero.
 *
 */
typedef struct {
     int                 id;            /* id of the reference to watch */

     int                 call_id;       /* id of the call to execute */
     int                 call_arg;      /* optional call parameter, e.g. the id of a user
                                           space resource associated with that reference */
} FusionRefWatch;

/*
 * Inheriting local count from other reference
 */
typedef struct {
     int                 id;            /* own reference id */
     int                 from;          /* id of the reference to inherit from */
} FusionRefInherit;

/*
 * Killing other fusionees (experimental)
 */
typedef struct {
     FusionID            fusion_id;     /* fusionee to kill, zero means all but ourself */
     int                 signal;        /* signal to be delivered, e.g. SIGTERM */
     int                 timeout_ms;    /* -1 means no timeout, 0 means infinite, otherwise the
                                           max. time to wait until the fusionee(s) terminated */
} FusionKill;


/*
 * Shared memory pools
 */
typedef struct {
     int                 max_size;      /* Maximum size that this pool will be allowed to grow to. */

     int                 pool_id;       /* Returns the new pool id. */
     void               *addr_base;     /* Returns the base of the reserved virtual memory address space. */
} FusionSHMPoolNew;

typedef struct {
     int                 pool_id;       /* The id of the pool to attach to. */

     void               *addr_base;     /* Returns the base of the reserved virtual memory address space. */
     int                 size;          /* Returns the current size of the pool. */
} FusionSHMPoolAttach;

typedef struct {
     int                 pool_id;       /* The id of the pool to notify. */

     int                 size;          /* New size of the pool. */
} FusionSHMPoolDispatch;

typedef enum {
     FSMT_REMAP,                        /* Remap the pool due to a change of its size. */
     FSMT_UNMAP                         /* Unmap the pool due to its destruction. */
} FusionSHMPoolMessageType;

typedef struct {
     FusionSHMPoolMessageType type;     /* Type of the message. */

     int                      size;     /* New size of the pool, if type is FSMT_REMAP. */
} FusionSHMPoolMessage;


/*
 * Fusion types
 */
typedef enum {
     FT_LOUNGE,
     FT_MESSAGING,
     FT_CALL,
     FT_REF,
     FT_SKIRMISH,
     FT_PROPERTY,
     FT_REACTOR,
     FT_SHMPOOL
} FusionType;


/*
 * Set attributes like 'name' for an entry of the specified type.
 */
#define FUSION_ENTRY_INFO_NAME_LENGTH   24

typedef struct {
     FusionType          type;
     int                 id;

     char                name[FUSION_ENTRY_INFO_NAME_LENGTH];
} FusionEntryInfo;



#define FUSION_ENTER               _IOR(FT_LOUNGE,    0x00, FusionEnter)
#define FUSION_UNBLOCK             _IO (FT_LOUNGE,    0x01)
#define FUSION_KILL                _IOW(FT_LOUNGE,    0x02, FusionKill)

#define FUSION_ENTRY_SET_INFO      _IOW(FT_LOUNGE,    0x03, FusionEntryInfo)
#define FUSION_ENTRY_GET_INFO      _IOW(FT_LOUNGE,    0x04, FusionEntryInfo)

#define FUSION_FORK                _IOW(FT_LOUNGE,    0x05, FusionFork)

#define FUSION_SEND_MESSAGE        _IOW(FT_MESSAGING, 0x00, FusionSendMessage)

#define FUSION_CALL_NEW            _IOW(FT_CALL,      0x00, FusionCallNew)
#define FUSION_CALL_EXECUTE        _IOW(FT_CALL,      0x01, FusionCallExecute)
#define FUSION_CALL_RETURN         _IOW(FT_CALL,      0x02, FusionCallReturn)
#define FUSION_CALL_DESTROY        _IOW(FT_CALL,      0x03, int)

#define FUSION_REF_NEW             _IOW(FT_REF,       0x00, int)
#define FUSION_REF_UP              _IOW(FT_REF,       0x01, int)
#define FUSION_REF_UP_GLOBAL       _IOW(FT_REF,       0x02, int)
#define FUSION_REF_DOWN            _IOW(FT_REF,       0x03, int)
#define FUSION_REF_DOWN_GLOBAL     _IOW(FT_REF,       0x04, int)
#define FUSION_REF_ZERO_LOCK       _IOW(FT_REF,       0x05, int)
#define FUSION_REF_ZERO_TRYLOCK    _IOW(FT_REF,       0x06, int)
#define FUSION_REF_UNLOCK          _IOW(FT_REF,       0x07, int)
#define FUSION_REF_STAT            _IOW(FT_REF,       0x08, int)
#define FUSION_REF_WATCH           _IOW(FT_REF,       0x09, FusionRefWatch)
#define FUSION_REF_INHERIT         _IOW(FT_REF,       0x0A, FusionRefInherit)
#define FUSION_REF_DESTROY         _IOW(FT_REF,       0x0B, int)

#define FUSION_SKIRMISH_NEW        _IOW(FT_SKIRMISH,  0x00, int)
#define FUSION_SKIRMISH_PREVAIL    _IOW(FT_SKIRMISH,  0x01, int)
#define FUSION_SKIRMISH_SWOOP      _IOW(FT_SKIRMISH,  0x02, int)
#define FUSION_SKIRMISH_DISMISS    _IOW(FT_SKIRMISH,  0x03, int)
#define FUSION_SKIRMISH_DESTROY    _IOW(FT_SKIRMISH,  0x04, int)
#define FUSION_SKIRMISH_LOCK_COUNT _IOW(FT_SKIRMISH,  0x05, int)

#define FUSION_PROPERTY_NEW        _IOW(FT_PROPERTY,  0x00, int)
#define FUSION_PROPERTY_LEASE      _IOW(FT_PROPERTY,  0x01, int)
#define FUSION_PROPERTY_PURCHASE   _IOW(FT_PROPERTY,  0x02, int)
#define FUSION_PROPERTY_CEDE       _IOW(FT_PROPERTY,  0x03, int)
#define FUSION_PROPERTY_HOLDUP     _IOW(FT_PROPERTY,  0x04, int)
#define FUSION_PROPERTY_DESTROY    _IOW(FT_PROPERTY,  0x05, int)

#define FUSION_REACTOR_NEW         _IOW(FT_REACTOR,   0x00, int)
#define FUSION_REACTOR_ATTACH      _IOW(FT_REACTOR,   0x01, int)
#define FUSION_REACTOR_DETACH      _IOW(FT_REACTOR,   0x02, int)
#define FUSION_REACTOR_DISPATCH    _IOW(FT_REACTOR,   0x03, FusionReactorDispatch)
#define FUSION_REACTOR_DESTROY     _IOW(FT_REACTOR,   0x04, int)

#define FUSION_SHMPOOL_NEW         _IOW(FT_SHMPOOL,   0x00, FusionSHMPoolNew)
#define FUSION_SHMPOOL_ATTACH      _IOW(FT_SHMPOOL,   0x01, FusionSHMPoolAttach)
#define FUSION_SHMPOOL_DETACH      _IOW(FT_SHMPOOL,   0x02, int)
#define FUSION_SHMPOOL_DISPATCH    _IOW(FT_SHMPOOL,   0x03, FusionSHMPoolDispatch)
#define FUSION_SHMPOOL_DESTROY     _IOW(FT_SHMPOOL,   0x04, int)

#endif