fusion.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. #ifndef __LINUX__FUSION_H__
  2. #define __LINUX__FUSION_H__
  3. #include <asm/ioctl.h>
  4. /*
  5. * Fusion Kernel Device API Version
  6. */
  7. #define FUSION_API_MAJOR 3 /* Increased if backward compatibility is dropped. */
  8. #define FUSION_API_MINOR 2 /* Increased if new features are added. */
  9. /*
  10. * The Fusion ID is a unique identifier for one process consisting of threads.
  11. */
  12. typedef unsigned long FusionID;
  13. #define FUSION_ID_MASTER 1 /* This is the fusion id of the master (first process). */
  14. /*
  15. * Entering a world
  16. */
  17. typedef struct {
  18. struct {
  19. int major; /* Must be set to FUSION_API_MAJOR before entering. */
  20. int minor; /* Must be set to FUSION_API_MINOR before entering. */
  21. } api;
  22. FusionID fusion_id; /* Returns the fusion id of the entering process. */
  23. } FusionEnter;
  24. /*
  25. * Forking in world
  26. */
  27. typedef struct {
  28. FusionID fusion_id; /* Returns the fusion id of the new (forked) fusionee. */
  29. } FusionFork;
  30. /*
  31. * Sending a message
  32. */
  33. typedef struct {
  34. FusionID fusion_id; /* recipient */
  35. int msg_id; /* optional message identifier */
  36. int msg_size; /* message size, must be greater than zero */
  37. const void *msg_data; /* message data, must not be NULL */
  38. } FusionSendMessage;
  39. /*
  40. * Receiving a message
  41. */
  42. typedef enum {
  43. FMT_SEND, /* msg_id is an optional custom id */
  44. FMT_CALL, /* msg_id is the call id */
  45. FMT_REACTOR, /* msg_id is the reactor id */
  46. FMT_SHMPOOL /* msg_id is the pool id */
  47. } FusionMessageType;
  48. typedef struct {
  49. FusionMessageType msg_type; /* type (origin) of message */
  50. int msg_id; /* message id (custom id or call/reactor/pool id) */
  51. int msg_size; /* size of the following message data */
  52. /* message data follows */
  53. } FusionReadMessage;
  54. /*
  55. * Dispatching a message via a reactor
  56. */
  57. typedef struct {
  58. int reactor_id;
  59. int self;
  60. int msg_size; /* message size, must be greater than zero */
  61. const void *msg_data; /* message data, must not be NULL */
  62. } FusionReactorDispatch;
  63. /*
  64. * Calling (synchronous RPC)
  65. */
  66. typedef struct {
  67. int call_id; /* new call id returned */
  68. void *handler; /* function pointer of handler to install */
  69. void *ctx; /* optional handler context */
  70. } FusionCallNew;
  71. typedef enum {
  72. FCEF_NONE = 0x00000000,
  73. FCEF_ONEWAY = 0x00000001,
  74. FCEF_ALL = 0x00000001
  75. } FusionCallExecFlags;
  76. typedef struct {
  77. int ret_val; /* return value of the call */
  78. int call_id; /* id of the requested call, each call has a fixed owner */
  79. int call_arg; /* optional int argument */
  80. void *call_ptr; /* optional pointer argument (shared memory) */
  81. FusionCallExecFlags flags; /* execution flags */
  82. } FusionCallExecute;
  83. typedef struct {
  84. int call_id; /* id of currently executing call */
  85. int val; /* value to return */
  86. } FusionCallReturn;
  87. typedef struct {
  88. void *handler; /* function pointer of handler to call */
  89. void *ctx; /* optional handler context */
  90. int caller; /* fusion id of the caller or zero if called from Fusion */
  91. int call_arg; /* optional call parameter */
  92. void *call_ptr; /* optional call parameter */
  93. } FusionCallMessage;
  94. /*
  95. * Watching a reference
  96. *
  97. * This information is needed to have a specific call being executed if the
  98. * reference count reaches zero. Currently one watch per reference is allowed.
  99. *
  100. * The call is made by Fusion and therefor has a caller id of zero.
  101. *
  102. */
  103. typedef struct {
  104. int id; /* id of the reference to watch */
  105. int call_id; /* id of the call to execute */
  106. int call_arg; /* optional call parameter, e.g. the id of a user
  107. space resource associated with that reference */
  108. } FusionRefWatch;
  109. /*
  110. * Inheriting local count from other reference
  111. */
  112. typedef struct {
  113. int id; /* own reference id */
  114. int from; /* id of the reference to inherit from */
  115. } FusionRefInherit;
  116. /*
  117. * Killing other fusionees (experimental)
  118. */
  119. typedef struct {
  120. FusionID fusion_id; /* fusionee to kill, zero means all but ourself */
  121. int signal; /* signal to be delivered, e.g. SIGTERM */
  122. int timeout_ms; /* -1 means no timeout, 0 means infinite, otherwise the
  123. max. time to wait until the fusionee(s) terminated */
  124. } FusionKill;
  125. /*
  126. * Shared memory pools
  127. */
  128. typedef struct {
  129. int max_size; /* Maximum size that this pool will be allowed to grow to. */
  130. int pool_id; /* Returns the new pool id. */
  131. void *addr_base; /* Returns the base of the reserved virtual memory address space. */
  132. } FusionSHMPoolNew;
  133. typedef struct {
  134. int pool_id; /* The id of the pool to attach to. */
  135. void *addr_base; /* Returns the base of the reserved virtual memory address space. */
  136. int size; /* Returns the current size of the pool. */
  137. } FusionSHMPoolAttach;
  138. typedef struct {
  139. int pool_id; /* The id of the pool to notify. */
  140. int size; /* New size of the pool. */
  141. } FusionSHMPoolDispatch;
  142. typedef enum {
  143. FSMT_REMAP, /* Remap the pool due to a change of its size. */
  144. FSMT_UNMAP /* Unmap the pool due to its destruction. */
  145. } FusionSHMPoolMessageType;
  146. typedef struct {
  147. FusionSHMPoolMessageType type; /* Type of the message. */
  148. int size; /* New size of the pool, if type is FSMT_REMAP. */
  149. } FusionSHMPoolMessage;
  150. /*
  151. * Fusion types
  152. */
  153. typedef enum {
  154. FT_LOUNGE,
  155. FT_MESSAGING,
  156. FT_CALL,
  157. FT_REF,
  158. FT_SKIRMISH,
  159. FT_PROPERTY,
  160. FT_REACTOR,
  161. FT_SHMPOOL
  162. } FusionType;
  163. /*
  164. * Set attributes like 'name' for an entry of the specified type.
  165. */
  166. #define FUSION_ENTRY_INFO_NAME_LENGTH 24
  167. typedef struct {
  168. FusionType type;
  169. int id;
  170. char name[FUSION_ENTRY_INFO_NAME_LENGTH];
  171. } FusionEntryInfo;
  172. #define FUSION_ENTER _IOR(FT_LOUNGE, 0x00, FusionEnter)
  173. #define FUSION_UNBLOCK _IO (FT_LOUNGE, 0x01)
  174. #define FUSION_KILL _IOW(FT_LOUNGE, 0x02, FusionKill)
  175. #define FUSION_ENTRY_SET_INFO _IOW(FT_LOUNGE, 0x03, FusionEntryInfo)
  176. #define FUSION_ENTRY_GET_INFO _IOW(FT_LOUNGE, 0x04, FusionEntryInfo)
  177. #define FUSION_FORK _IOW(FT_LOUNGE, 0x05, FusionFork)
  178. #define FUSION_SEND_MESSAGE _IOW(FT_MESSAGING, 0x00, FusionSendMessage)
  179. #define FUSION_CALL_NEW _IOW(FT_CALL, 0x00, FusionCallNew)
  180. #define FUSION_CALL_EXECUTE _IOW(FT_CALL, 0x01, FusionCallExecute)
  181. #define FUSION_CALL_RETURN _IOW(FT_CALL, 0x02, FusionCallReturn)
  182. #define FUSION_CALL_DESTROY _IOW(FT_CALL, 0x03, int)
  183. #define FUSION_REF_NEW _IOW(FT_REF, 0x00, int)
  184. #define FUSION_REF_UP _IOW(FT_REF, 0x01, int)
  185. #define FUSION_REF_UP_GLOBAL _IOW(FT_REF, 0x02, int)
  186. #define FUSION_REF_DOWN _IOW(FT_REF, 0x03, int)
  187. #define FUSION_REF_DOWN_GLOBAL _IOW(FT_REF, 0x04, int)
  188. #define FUSION_REF_ZERO_LOCK _IOW(FT_REF, 0x05, int)
  189. #define FUSION_REF_ZERO_TRYLOCK _IOW(FT_REF, 0x06, int)
  190. #define FUSION_REF_UNLOCK _IOW(FT_REF, 0x07, int)
  191. #define FUSION_REF_STAT _IOW(FT_REF, 0x08, int)
  192. #define FUSION_REF_WATCH _IOW(FT_REF, 0x09, FusionRefWatch)
  193. #define FUSION_REF_INHERIT _IOW(FT_REF, 0x0A, FusionRefInherit)
  194. #define FUSION_REF_DESTROY _IOW(FT_REF, 0x0B, int)
  195. #define FUSION_SKIRMISH_NEW _IOW(FT_SKIRMISH, 0x00, int)
  196. #define FUSION_SKIRMISH_PREVAIL _IOW(FT_SKIRMISH, 0x01, int)
  197. #define FUSION_SKIRMISH_SWOOP _IOW(FT_SKIRMISH, 0x02, int)
  198. #define FUSION_SKIRMISH_DISMISS _IOW(FT_SKIRMISH, 0x03, int)
  199. #define FUSION_SKIRMISH_DESTROY _IOW(FT_SKIRMISH, 0x04, int)
  200. #define FUSION_SKIRMISH_LOCK_COUNT _IOW(FT_SKIRMISH, 0x05, int)
  201. #define FUSION_PROPERTY_NEW _IOW(FT_PROPERTY, 0x00, int)
  202. #define FUSION_PROPERTY_LEASE _IOW(FT_PROPERTY, 0x01, int)
  203. #define FUSION_PROPERTY_PURCHASE _IOW(FT_PROPERTY, 0x02, int)
  204. #define FUSION_PROPERTY_CEDE _IOW(FT_PROPERTY, 0x03, int)
  205. #define FUSION_PROPERTY_HOLDUP _IOW(FT_PROPERTY, 0x04, int)
  206. #define FUSION_PROPERTY_DESTROY _IOW(FT_PROPERTY, 0x05, int)
  207. #define FUSION_REACTOR_NEW _IOW(FT_REACTOR, 0x00, int)
  208. #define FUSION_REACTOR_ATTACH _IOW(FT_REACTOR, 0x01, int)
  209. #define FUSION_REACTOR_DETACH _IOW(FT_REACTOR, 0x02, int)
  210. #define FUSION_REACTOR_DISPATCH _IOW(FT_REACTOR, 0x03, FusionReactorDispatch)
  211. #define FUSION_REACTOR_DESTROY _IOW(FT_REACTOR, 0x04, int)
  212. #define FUSION_SHMPOOL_NEW _IOW(FT_SHMPOOL, 0x00, FusionSHMPoolNew)
  213. #define FUSION_SHMPOOL_ATTACH _IOW(FT_SHMPOOL, 0x01, FusionSHMPoolAttach)
  214. #define FUSION_SHMPOOL_DETACH _IOW(FT_SHMPOOL, 0x02, int)
  215. #define FUSION_SHMPOOL_DISPATCH _IOW(FT_SHMPOOL, 0x03, FusionSHMPoolDispatch)
  216. #define FUSION_SHMPOOL_DESTROY _IOW(FT_SHMPOOL, 0x04, int)
  217. #endif