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