Changes in kernel/generic/include/ipc/ipc.h [2c0e5d2:5378f99] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/ipc/ipc.h
r2c0e5d2 r5378f99 36 36 #define KERN_IPC_H_ 37 37 38 /* Length of data being transfered with IPC call */ 39 /* - the uspace may not be able to utilize full length */ 40 #define IPC_CALL_LEN 6 41 42 /** Maximum active async calls per thread */ 43 #ifdef CONFIG_DEBUG 44 #define IPC_MAX_ASYNC_CALLS 4 45 #else 46 #define IPC_MAX_ASYNC_CALLS 4000 47 #endif 38 /** Length of data being transfered with IPC call 39 * 40 * The uspace may not be able to utilize full length 41 * 42 */ 43 #define IPC_CALL_LEN 6 44 45 /** Maximum active async calls per phone */ 46 #define IPC_MAX_ASYNC_CALLS 4 48 47 49 48 /* Flags for calls */ 50 49 51 50 /** This is answer to a call */ 52 #define IPC_CALL_ANSWERED (1 << 0) 53 /** This call will not be freed on error */ 54 #define IPC_CALL_STATIC_ALLOC (1 << 1) 51 #define IPC_CALL_ANSWERED (1 << 0) 52 55 53 /** Answer will not be passed to userspace, will be discarded */ 56 #define IPC_CALL_DISCARD_ANSWER (1 << 2) 54 #define IPC_CALL_DISCARD_ANSWER (1 << 1) 55 57 56 /** Call was forwarded */ 58 #define IPC_CALL_FORWARDED (1 << 3) 57 #define IPC_CALL_FORWARDED (1 << 2) 58 59 59 /** Identify connect_me_to answer */ 60 #define IPC_CALL_CONN_ME_TO (1 << 4) 60 #define IPC_CALL_CONN_ME_TO (1 << 3) 61 61 62 /** Interrupt notification */ 62 #define IPC_CALL_NOTIF (1 << 5) 63 64 /* 65 * Bits used in call hashes. 63 #define IPC_CALL_NOTIF (1 << 4) 64 65 66 /** Bits used in call hashes. 67 * 66 68 * The addresses are aligned at least to 4 that is why we can use the 2 least 67 69 * significant bits of the call address. 68 */ 70 * 71 */ 72 69 73 /** Type of this call is 'answer' */ 70 #define IPC_CALLID_ANSWERED 1 74 #define IPC_CALLID_ANSWERED 1 75 71 76 /** Type of this call is 'notification' */ 72 #define IPC_CALLID_NOTIFICATION 77 #define IPC_CALLID_NOTIFICATION 2 73 78 74 79 /* Return values from sys_ipc_call_async(). */ 75 #define IPC_CALLRET_FATAL 76 #define IPC_CALLRET_TEMPORARY 80 #define IPC_CALLRET_FATAL -1 81 #define IPC_CALLRET_TEMPORARY -2 77 82 78 83 79 84 /* Macros for manipulating calling data */ 80 #define IPC_SET_RETVAL(data, retval) 81 #define IPC_SET_ METHOD(data, val)((data).args[0] = (val))82 #define IPC_SET_ARG1(data, val) 83 #define IPC_SET_ARG2(data, val) 84 #define IPC_SET_ARG3(data, val) 85 #define IPC_SET_ARG4(data, val) 86 #define IPC_SET_ARG5(data, val) 87 88 #define IPC_GET_ METHOD(data)((data).args[0])89 #define IPC_GET_RETVAL(data) 90 91 #define IPC_GET_ARG1(data) 92 #define IPC_GET_ARG2(data) 93 #define IPC_GET_ARG3(data) 94 #define IPC_GET_ARG4(data) 95 #define IPC_GET_ARG5(data) 85 #define IPC_SET_RETVAL(data, retval) ((data).args[0] = (retval)) 86 #define IPC_SET_IMETHOD(data, val) ((data).args[0] = (val)) 87 #define IPC_SET_ARG1(data, val) ((data).args[1] = (val)) 88 #define IPC_SET_ARG2(data, val) ((data).args[2] = (val)) 89 #define IPC_SET_ARG3(data, val) ((data).args[3] = (val)) 90 #define IPC_SET_ARG4(data, val) ((data).args[4] = (val)) 91 #define IPC_SET_ARG5(data, val) ((data).args[5] = (val)) 92 93 #define IPC_GET_IMETHOD(data) ((data).args[0]) 94 #define IPC_GET_RETVAL(data) ((data).args[0]) 95 96 #define IPC_GET_ARG1(data) ((data).args[1]) 97 #define IPC_GET_ARG2(data) ((data).args[2]) 98 #define IPC_GET_ARG3(data) ((data).args[3]) 99 #define IPC_GET_ARG4(data) ((data).args[4]) 100 #define IPC_GET_ARG5(data) ((data).args[5]) 96 101 97 102 /* Well known phone descriptors */ 98 #define PHONE_NS 103 #define PHONE_NS 0 99 104 100 105 /* Forwarding flags. */ 101 #define IPC_FF_NONE 0 106 #define IPC_FF_NONE 0 107 102 108 /** 103 109 * The call will be routed as though it was initially sent via the phone used to … … 106 112 * calls that were initially sent by the forwarder to the same destination. This 107 113 * flag has no imapct on routing replies. 108 */ 109 #define IPC_FF_ROUTE_FROM_ME (1 << 0) 110 111 /* System-specific methods - only through special syscalls 112 * These methods have special behaviour 113 */ 114 * 115 */ 116 #define IPC_FF_ROUTE_FROM_ME (1 << 0) 117 118 /** Kernel IPC interfaces 119 * 120 */ 121 #define IPC_IF_KERNEL 0 122 123 /** System-specific methods - only through special syscalls 124 * 125 * These methods have special behaviour. These methods also 126 * have the implicit kernel interface 0. 127 * 128 */ 129 114 130 /** Clone connection. 115 131 * … … 117 133 * 118 134 * - ARG1 - The caller sets ARG1 to the phone of the cloned connection. 119 * - The callee gets the new phone from ARG1. 135 * - The callee gets the new phone from ARG1. 136 * 120 137 * - on answer, the callee acknowledges the new connection by sending EOK back 121 138 * or the kernel closes it 122 */ 123 #define IPC_M_CONNECTION_CLONE 1 139 * 140 */ 141 #define IPC_M_CONNECTION_CLONE 1 142 124 143 /** Protocol for CONNECT - ME 125 144 * 126 145 * Through this call, the recipient learns about the new cloned connection. 127 * 146 * 128 147 * - ARG5 - the kernel sets ARG5 to contain the hash of the used phone 129 148 * - on asnwer, the callee acknowledges the new connection by sending EOK back 130 149 * or the kernel closes it 131 */ 132 #define IPC_M_CONNECT_ME 2 133 /** Protocol for CONNECT - TO - ME 150 * 151 */ 152 #define IPC_M_CONNECT_ME 2 153 154 /** Protocol for CONNECT - TO - ME 134 155 * 135 156 * Calling process asks the callee to create a callback connection, … … 144 165 * error is sent back to caller. Otherwise 145 166 * the call is accepted and the response is sent back. 146 * - the allocated phoneid is passed to userspace 167 * - the hash of the client task is passed to userspace 168 * (on the receiving side) as ARG4 of the call. 169 * - the hash of the allocated phone is passed to userspace 147 170 * (on the receiving side) as ARG5 of the call. 148 */ 149 #define IPC_M_CONNECT_TO_ME 3 171 * 172 */ 173 #define IPC_M_CONNECT_TO_ME 3 174 150 175 /** Protocol for CONNECT - ME - TO 151 176 * … … 165 190 * 166 191 */ 167 #define IPC_M_CONNECT_ME_TO 4 168 /** This message is sent to answerbox when the phone 169 * is hung up 170 */ 171 #define IPC_M_PHONE_HUNGUP 5 192 #define IPC_M_CONNECT_ME_TO 4 193 194 /** This message is sent to answerbox when the phone is hung up 195 * 196 */ 197 #define IPC_M_PHONE_HUNGUP 5 172 198 173 199 /** Send as_area over IPC. … … 175 201 * - ARG2 - size of source as_area (filled automatically by kernel) 176 202 * - ARG3 - flags of the as_area being sent 177 * 203 * 178 204 * on answer, the recipient must set: 179 205 * - ARG1 - dst as_area base adress 180 */ 181 #define IPC_M_SHARE_OUT 6 206 * 207 */ 208 #define IPC_M_SHARE_OUT 6 182 209 183 210 /** Receive as_area over IPC. … … 185 212 * - ARG2 - destination as_area size 186 213 * - ARG3 - user defined argument 187 * 214 * 188 215 * on answer, the recipient must set: 189 216 * 190 217 * - ARG1 - source as_area base address 191 218 * - ARG2 - flags that will be used for sharing 192 */ 193 #define IPC_M_SHARE_IN 7 219 * 220 */ 221 #define IPC_M_SHARE_IN 7 194 222 195 223 /** Send data to another address space over IPC. … … 201 229 * - ARG1 - final destination address space virtual address 202 230 * - ARG2 - final size of data to be copied 203 */ 204 #define IPC_M_DATA_WRITE 8 231 * 232 */ 233 #define IPC_M_DATA_WRITE 8 205 234 206 235 /** Receive data from another address space over IPC. … … 212 241 * - ARG1 - source virtual address in the destination address space 213 242 * - ARG2 - final size of data to be copied 214 */ 215 #define IPC_M_DATA_READ 9 243 * 244 */ 245 #define IPC_M_DATA_READ 9 216 246 217 247 /** Debug the recipient. 218 248 * - ARG1 - specifies the debug method (from udebug_method_t) 219 249 * - other arguments are specific to the debug method 220 */ 221 #define IPC_M_DEBUG_ALL 10 250 * 251 */ 252 #define IPC_M_DEBUG_ALL 10 222 253 223 254 /* Well-known methods */ 224 #define IPC_M_LAST_SYSTEM 511 225 #define IPC_M_PING 512 255 #define IPC_M_LAST_SYSTEM 511 256 #define IPC_M_PING 512 257 226 258 /* User methods */ 227 #define IPC_FIRST_USER_METHOD 259 #define IPC_FIRST_USER_METHOD 1024 228 260 229 261 #ifdef KERNEL 230 262 231 #define IPC_MAX_PHONES 16263 #define IPC_MAX_PHONES 32 232 264 233 265 #include <synch/spinlock.h> … … 261 293 262 294 typedef struct answerbox { 263 SPINLOCK_DECLARE(lock);264 295 IRQ_SPINLOCK_DECLARE(lock); 296 265 297 struct task *task; 266 298 267 299 waitq_t wq; 268 300 301 /** Linkage for the list of task's synchronous answerboxes. */ 302 link_t sync_box_link; 303 269 304 /** Phones connected to this answerbox. */ 270 305 link_t connected_phones; 271 306 /** Received calls. */ 272 link_t calls; 273 link_t dispatched_calls; 274 307 link_t calls; 308 link_t dispatched_calls; /* Should be hash table in the future */ 309 275 310 /** Answered calls. */ 276 311 link_t answers; 277 278 SPINLOCK_DECLARE(irq_lock); 312 313 IRQ_SPINLOCK_DECLARE(irq_lock); 314 279 315 /** Notifications from IRQ handlers. */ 280 316 link_t irq_notifs; … … 284 320 285 321 typedef struct { 286 unative_t args[IPC_CALL_LEN]; 322 sysarg_t args[IPC_CALL_LEN]; 323 /** Task which made or forwarded the call with IPC_FF_ROUTE_FROM_ME. */ 324 struct task *task; 325 /** Phone which made or last masqueraded this call. */ 287 326 phone_t *phone; 288 327 } ipc_data_t; … … 290 329 typedef struct { 291 330 link_t link; 292 293 int flags;294 331 332 unsigned int flags; 333 295 334 /** Identification of the caller. */ 296 335 struct task *sender; 297 /** The caller box is different from sender->answerbox for synchronous 298 * calls. */ 336 337 /* 338 * The caller box is different from sender->answerbox 339 * for synchronous calls. 340 */ 299 341 answerbox_t *callerbox; 300 342 301 343 /** Private data to internal IPC. */ 302 unative_t priv;303 344 sysarg_t priv; 345 304 346 /** Data passed from/to userspace. */ 305 347 ipc_data_t data; 306 348 307 349 /** Buffer for IPC_M_DATA_WRITE and IPC_M_DATA_READ. */ 308 350 uint8_t *buffer; 309 351 310 352 /* 311 353 * The forward operation can masquerade the caller phone. For those … … 316 358 } call_t; 317 359 360 extern answerbox_t *ipc_phone_0; 361 318 362 extern void ipc_init(void); 319 extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, int); 320 extern void ipc_answer(answerbox_t *, call_t *); 363 364 extern call_t *ipc_call_alloc(unsigned int); 365 extern void ipc_call_free(call_t *); 366 321 367 extern int ipc_call(phone_t *, call_t *); 322 368 extern int ipc_call_sync(phone_t *, call_t *); 369 extern call_t * ipc_wait_for_call(answerbox_t *, uint32_t, unsigned int); 370 extern int ipc_forward(call_t *, phone_t *, answerbox_t *, unsigned int); 371 extern void ipc_answer(answerbox_t *, call_t *); 372 323 373 extern void ipc_phone_init(phone_t *); 324 374 extern void ipc_phone_connect(phone_t *, answerbox_t *); 325 extern void ipc_call_free(call_t *);326 extern call_t * ipc_call_alloc(int); 375 extern int ipc_phone_hangup(phone_t *); 376 327 377 extern void ipc_answerbox_init(answerbox_t *, struct task *); 328 extern void ipc_call_static_init(call_t *); 329 extern void task_print_list(void); 330 extern int ipc_forward(call_t *, phone_t *, answerbox_t *, int); 378 331 379 extern void ipc_cleanup(void); 332 extern int ipc_phone_hangup(phone_t *); 333 extern void ipc_backsend_err(phone_t *, call_t *, unative_t); 334 extern void ipc_print_task(task_id_t); 380 extern void ipc_backsend_err(phone_t *, call_t *, sysarg_t); 335 381 extern void ipc_answerbox_slam_phones(answerbox_t *, bool); 336 382 extern void ipc_cleanup_call_list(link_t *); 337 383 338 extern answerbox_t *ipc_phone_0; 384 extern void ipc_print_task(task_id_t); 385 386 #endif /* KERNEL */ 339 387 340 388 #endif 341 389 342 #endif343 344 390 /** @} 345 391 */
Note:
See TracChangeset
for help on using the changeset viewer.