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