Rev 2568 | Rev 2618 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2568 | Rev 2615 | ||
|---|---|---|---|
| Line 82... | Line 82... | ||
| 82 | 82 | ||
| 83 | static atomic_t ipc_futex = FUTEX_INITIALIZER; |
83 | static atomic_t ipc_futex = FUTEX_INITIALIZER; |
| 84 | 84 | ||
| 85 | /** Make a fast synchronous call. |
85 | /** Make a fast synchronous call. |
| 86 | * |
86 | * |
| 87 | * Only one payload argument can be passed using this function. However, this |
87 | * Only three payload arguments can be passed using this function. However, this |
| 88 | * function is faster than the generic ipc_call_sync_3(). |
88 | * function is faster than the generic ipc_call_sync_slow() because the payload |
| - | 89 | * is passed directly in registers. |
|
| 89 | * |
90 | * |
| 90 | * @param phoneid Phone handle for the call. |
91 | * @param phoneid Phone handle for the call. |
| 91 | * @param method Requested method. |
92 | * @param method Requested method. |
| 92 | * @param arg1 Service-defined payload argument. |
93 | * @param arg1 Service-defined payload argument. |
| - | 94 | * @param arg2 Service-defined payload argument. |
|
| - | 95 | * @param arg3 Service-defined payload argument. |
|
| 93 | * @param result If non-NULL, the return ARG1 will be stored there. |
96 | * @param result1 If non-NULL, the return ARG1 will be stored there. |
| - | 97 | * @param result2 If non-NULL, the return ARG2 will be stored there. |
|
| - | 98 | * @param result3 If non-NULL, the return ARG3 will be stored there. |
|
| - | 99 | * @param result4 If non-NULL, the return ARG4 will be stored there. |
|
| - | 100 | * @param result5 If non-NULL, the return ARG5 will be stored there. |
|
| 94 | * |
101 | * |
| 95 | * @return Negative values represent errors returned by IPC. |
102 | * @return Negative values represent errors returned by IPC. |
| 96 | * Otherwise the RETVAL of the answer is returned. |
103 | * Otherwise the RETVAL of the answer is returned. |
| 97 | */ |
104 | */ |
| - | 105 | int |
|
| 98 | int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t *result) |
106 | ipc_call_sync_fast(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, |
| - | 107 | ipcarg_t arg3, ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3, |
|
| - | 108 | ipcarg_t *result4, ipcarg_t *result5) |
|
| 99 | { |
109 | { |
| 100 | ipc_call_t resdata; |
110 | ipc_call_t resdata; |
| 101 | int callres; |
111 | int callres; |
| 102 | 112 | ||
| 103 | callres = __SYSCALL4(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1, |
113 | callres = __SYSCALL6(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1, |
| 104 | (sysarg_t) &resdata); |
114 | arg2, arg3, (sysarg_t) &resdata); |
| 105 | if (callres) |
115 | if (callres) |
| 106 | return callres; |
116 | return callres; |
| 107 | if (result) |
117 | if (result1) |
| 108 | *result = IPC_GET_ARG1(resdata); |
118 | *result1 = IPC_GET_ARG1(resdata); |
| - | 119 | if (result2) |
|
| - | 120 | *result2 = IPC_GET_ARG2(resdata); |
|
| - | 121 | if (result3) |
|
| - | 122 | *result3 = IPC_GET_ARG3(resdata); |
|
| - | 123 | if (result4) |
|
| - | 124 | *result4 = IPC_GET_ARG4(resdata); |
|
| - | 125 | if (result5) |
|
| - | 126 | *result5 = IPC_GET_ARG5(resdata); |
|
| - | 127 | ||
| 109 | return IPC_GET_RETVAL(resdata); |
128 | return IPC_GET_RETVAL(resdata); |
| 110 | } |
129 | } |
| 111 | 130 | ||
| 112 | /** Make a synchronous call transmitting 3 arguments of payload. |
131 | /** Make a synchronous call transmitting 5 arguments of payload. |
| 113 | * |
132 | * |
| 114 | * @param phoneid Phone handle for the call. |
133 | * @param phoneid Phone handle for the call. |
| 115 | * @param method Requested method. |
134 | * @param method Requested method. |
| 116 | * @param arg1 Service-defined payload argument. |
135 | * @param arg1 Service-defined payload argument. |
| 117 | * @param arg2 Service-defined payload argument. |
136 | * @param arg2 Service-defined payload argument. |
| 118 | * @param arg3 Service-defined payload argument. |
137 | * @param arg3 Service-defined payload argument. |
| - | 138 | * @param arg4 Service-defined payload argument. |
|
| - | 139 | * @param arg5 Service-defined payload argument. |
|
| 119 | * @param result1 If non-NULL, storage for the first return argument. |
140 | * @param result1 If non-NULL, storage for the first return argument. |
| 120 | * @param result2 If non-NULL, storage for the second return argument. |
141 | * @param result2 If non-NULL, storage for the second return argument. |
| 121 | * @param result3 If non-NULL, storage for the third return argument. |
142 | * @param result3 If non-NULL, storage for the third return argument. |
| - | 143 | * @param result4 If non-NULL, storage for the fourth return argument. |
|
| - | 144 | * @param result5 If non-NULL, storage for the fifth return argument. |
|
| 122 | * |
145 | * |
| 123 | * @return Negative value means IPC error. |
146 | * @return Negative value means IPC error. |
| 124 | * Otherwise the RETVAL of the answer. |
147 | * Otherwise the RETVAL of the answer. |
| 125 | */ |
148 | */ |
| - | 149 | int |
|
| 126 | int ipc_call_sync_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, |
150 | ipc_call_sync_slow(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, |
| - | 151 | ipcarg_t arg3, ipcarg_t arg4, ipcarg_t arg5, ipcarg_t *result1, |
|
| 127 | ipcarg_t arg3, ipcarg_t *result1, ipcarg_t *result2, ipcarg_t *result3) |
152 | ipcarg_t *result2, ipcarg_t *result3, ipcarg_t *result4, ipcarg_t *result5) |
| 128 | { |
153 | { |
| 129 | ipc_call_t data; |
154 | ipc_call_t data; |
| 130 | int callres; |
155 | int callres; |
| 131 | 156 | ||
| 132 | IPC_SET_METHOD(data, method); |
157 | IPC_SET_METHOD(data, method); |
| 133 | IPC_SET_ARG1(data, arg1); |
158 | IPC_SET_ARG1(data, arg1); |
| 134 | IPC_SET_ARG2(data, arg2); |
159 | IPC_SET_ARG2(data, arg2); |
| 135 | IPC_SET_ARG3(data, arg3); |
160 | IPC_SET_ARG3(data, arg3); |
| - | 161 | IPC_SET_ARG4(data, arg4); |
|
| - | 162 | IPC_SET_ARG5(data, arg5); |
|
| 136 | 163 | ||
| 137 | callres = __SYSCALL3(SYS_IPC_CALL_SYNC, phoneid, (sysarg_t) &data, |
164 | callres = __SYSCALL3(SYS_IPC_CALL_SYNC_SLOW, phoneid, (sysarg_t) &data, |
| 138 | (sysarg_t) &data); |
165 | (sysarg_t) &data); |
| 139 | if (callres) |
166 | if (callres) |
| 140 | return callres; |
167 | return callres; |
| 141 | 168 | ||
| 142 | if (result1) |
169 | if (result1) |
| 143 | *result1 = IPC_GET_ARG1(data); |
170 | *result1 = IPC_GET_ARG1(data); |
| 144 | if (result2) |
171 | if (result2) |
| 145 | *result2 = IPC_GET_ARG2(data); |
172 | *result2 = IPC_GET_ARG2(data); |
| 146 | if (result3) |
173 | if (result3) |
| 147 | *result3 = IPC_GET_ARG3(data); |
174 | *result3 = IPC_GET_ARG3(data); |
| - | 175 | if (result4) |
|
| - | 176 | *result4 = IPC_GET_ARG4(data); |
|
| - | 177 | if (result5) |
|
| - | 178 | *result5 = IPC_GET_ARG5(data); |
|
| - | 179 | ||
| 148 | return IPC_GET_RETVAL(data); |
180 | return IPC_GET_RETVAL(data); |
| 149 | } |
181 | } |
| 150 | 182 | ||
| 151 | /** Syscall to send asynchronous message. |
183 | /** Syscall to send asynchronous message. |
| 152 | * |
184 | * |
| Line 513... | Line 545... | ||
| 513 | * |
545 | * |
| 514 | * @return Zero on success or a negative error code. |
546 | * @return Zero on success or a negative error code. |
| 515 | */ |
547 | */ |
| 516 | int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phonehash) |
548 | int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phonehash) |
| 517 | { |
549 | { |
| 518 | return ipc_call_sync_3(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2, 0, 0, |
550 | return ipc_call_sync_2_3(phoneid, IPC_M_CONNECT_TO_ME, arg1, arg2, |
| 519 | 0, phonehash); |
551 | NULL, NULL, phonehash); |
| 520 | } |
552 | } |
| 521 | 553 | ||
| 522 | /** Ask through phone for a new connection to some service. |
554 | /** Ask through phone for a new connection to some service. |
| 523 | * |
555 | * |
| 524 | * @param phoneid Phone handle used for contacting the other side. |
556 | * @param phoneid Phone handle used for contacting the other side. |
| Line 530... | Line 562... | ||
| 530 | int ipc_connect_me_to(int phoneid, int arg1, int arg2) |
562 | int ipc_connect_me_to(int phoneid, int arg1, int arg2) |
| 531 | { |
563 | { |
| 532 | ipcarg_t newphid; |
564 | ipcarg_t newphid; |
| 533 | int res; |
565 | int res; |
| 534 | 566 | ||
| 535 | res = ipc_call_sync_3(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, 0, 0, 0, |
567 | res = ipc_call_sync_2_3(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, NULL, |
| 536 | &newphid); |
568 | NULL, &newphid); |
| 537 | if (res) |
569 | if (res) |
| 538 | return res; |
570 | return res; |
| 539 | return newphid; |
571 | return newphid; |
| 540 | } |
572 | } |
| 541 | 573 | ||
| Line 603... | Line 635... | ||
| 603 | * |
635 | * |
| 604 | * @return Zero on success or a negative error code from errno.h. |
636 | * @return Zero on success or a negative error code from errno.h. |
| 605 | */ |
637 | */ |
| 606 | int ipc_data_send(int phoneid, void *src, size_t size) |
638 | int ipc_data_send(int phoneid, void *src, size_t size) |
| 607 | { |
639 | { |
| 608 | return ipc_call_sync_3(phoneid, IPC_M_DATA_SEND, 0, (ipcarg_t) src, |
640 | return ipc_call_sync_3_0(phoneid, IPC_M_DATA_SEND, 0, (ipcarg_t) src, |
| 609 | (ipcarg_t) size, NULL, NULL, NULL); |
641 | (ipcarg_t) size); |
| 610 | } |
642 | } |
| 611 | 643 | ||
| 612 | /** Wrapper for receiving the IPC_M_DATA_SEND calls. |
644 | /** Wrapper for receiving the IPC_M_DATA_SEND calls. |
| 613 | * |
645 | * |
| 614 | * This wrapper only makes it more comfortable to receive IPC_M_DATA_SEND calls |
646 | * This wrapper only makes it more comfortable to receive IPC_M_DATA_SEND calls |