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