Changeset eadaeae8 in mainline for uspace/lib/c/generic/async.c
- Timestamp:
- 2018-03-21T20:58:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3be9d10
- Parents:
- 874381a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
r874381a readaeae8 133 133 134 134 /** Session identification */ 135 int phone;135 cap_phone_handle_t phone; 136 136 137 137 /** First clone connection argument */ … … 169 169 170 170 /** Exchange identification */ 171 int phone;171 cap_phone_handle_t phone; 172 172 }; 173 173 … … 185 185 link_t link; 186 186 187 cap_ handle_t chandle;187 cap_call_handle_t chandle; 188 188 ipc_call_t call; 189 189 } msg_t; … … 237 237 238 238 /** Identification of the opening call. */ 239 cap_ handle_t chandle;239 cap_call_handle_t chandle; 240 240 241 241 /** Call data of the opening call. */ … … 243 243 244 244 /** Identification of the closing call. */ 245 cap_ handle_t close_chandle;245 cap_call_handle_t close_chandle; 246 246 247 247 /** Fibril function that will be used to handle the connection. */ … … 382 382 * 383 383 */ 384 static void default_fallback_port_handler(cap_ handle_t chandle,384 static void default_fallback_port_handler(cap_call_handle_t chandle, 385 385 ipc_call_t *call, void *arg) 386 386 { … … 786 786 */ 787 787 static fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash, 788 cap_ handle_t chandle, ipc_call_t *call, async_port_handler_t handler,788 cap_call_handle_t chandle, ipc_call_t *call, async_port_handler_t handler, 789 789 void *data) 790 790 { … … 968 968 * 969 969 */ 970 static bool route_call(cap_ handle_t chandle, ipc_call_t *call)970 static bool route_call(cap_call_handle_t chandle, ipc_call_t *call) 971 971 { 972 972 assert(call); … … 1057 1057 */ 1058 1058 errno_t async_irq_subscribe(int inr, async_notification_handler_t handler, 1059 void *data, const irq_code_t *ucode, cap_ handle_t *handle)1059 void *data, const irq_code_t *ucode, cap_irq_handle_t *handle) 1060 1060 { 1061 1061 notification_t *notification = … … 1077 1077 futex_up(&async_futex); 1078 1078 1079 cap_ handle_t cap;1080 errno_t rc = ipc_irq_subscribe(inr, imethod, ucode, & cap);1079 cap_irq_handle_t ihandle; 1080 errno_t rc = ipc_irq_subscribe(inr, imethod, ucode, &ihandle); 1081 1081 if (rc == EOK && handle != NULL) { 1082 *handle = cap;1082 *handle = ihandle; 1083 1083 } 1084 1084 return rc; … … 1087 1087 /** Unsubscribe from IRQ notification. 1088 1088 * 1089 * @param capIRQ capability handle.1089 * @param handle IRQ capability handle. 1090 1090 * 1091 1091 * @return Zero on success or an error code. 1092 1092 * 1093 1093 */ 1094 errno_t async_irq_unsubscribe( int cap)1094 errno_t async_irq_unsubscribe(cap_irq_handle_t ihandle) 1095 1095 { 1096 1096 // TODO: Remove entry from hash table 1097 1097 // to avoid memory leak 1098 1098 1099 return ipc_irq_unsubscribe( cap);1099 return ipc_irq_unsubscribe(ihandle); 1100 1100 } 1101 1101 … … 1200 1200 * message. In that case zero CAP_NIL is returned. 1201 1201 */ 1202 cap_ handle_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs)1202 cap_call_handle_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs) 1203 1203 { 1204 1204 assert(call); … … 1267 1267 list_remove(&msg->link); 1268 1268 1269 cap_ handle_t chandle = msg->chandle;1269 cap_call_handle_t chandle = msg->chandle; 1270 1270 *call = msg->call; 1271 1271 free(msg); … … 1339 1339 * 1340 1340 */ 1341 static void handle_call(cap_ handle_t chandle, ipc_call_t *call)1341 static void handle_call(cap_call_handle_t chandle, ipc_call_t *call) 1342 1342 { 1343 1343 assert(call); … … 2042 2042 } 2043 2043 2044 errno_t async_answer_0(cap_ handle_t chandle, errno_t retval)2044 errno_t async_answer_0(cap_call_handle_t chandle, errno_t retval) 2045 2045 { 2046 2046 return ipc_answer_0(chandle, retval); 2047 2047 } 2048 2048 2049 errno_t async_answer_1(cap_ handle_t chandle, errno_t retval, sysarg_t arg1)2049 errno_t async_answer_1(cap_call_handle_t chandle, errno_t retval, sysarg_t arg1) 2050 2050 { 2051 2051 return ipc_answer_1(chandle, retval, arg1); 2052 2052 } 2053 2053 2054 errno_t async_answer_2(cap_ handle_t chandle, errno_t retval, sysarg_t arg1,2054 errno_t async_answer_2(cap_call_handle_t chandle, errno_t retval, sysarg_t arg1, 2055 2055 sysarg_t arg2) 2056 2056 { … … 2058 2058 } 2059 2059 2060 errno_t async_answer_3(cap_ handle_t chandle, errno_t retval, sysarg_t arg1,2060 errno_t async_answer_3(cap_call_handle_t chandle, errno_t retval, sysarg_t arg1, 2061 2061 sysarg_t arg2, sysarg_t arg3) 2062 2062 { … … 2064 2064 } 2065 2065 2066 errno_t async_answer_4(cap_ handle_t chandle, errno_t retval, sysarg_t arg1,2066 errno_t async_answer_4(cap_call_handle_t chandle, errno_t retval, sysarg_t arg1, 2067 2067 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 2068 2068 { … … 2070 2070 } 2071 2071 2072 errno_t async_answer_5(cap_ handle_t chandle, errno_t retval, sysarg_t arg1,2072 errno_t async_answer_5(cap_call_handle_t chandle, errno_t retval, sysarg_t arg1, 2073 2073 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5) 2074 2074 { … … 2076 2076 } 2077 2077 2078 errno_t async_forward_fast(cap_ handle_t chandle, async_exch_t *exch,2078 errno_t async_forward_fast(cap_call_handle_t chandle, async_exch_t *exch, 2079 2079 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode) 2080 2080 { … … 2085 2085 } 2086 2086 2087 errno_t async_forward_slow(cap_ handle_t chandle, async_exch_t *exch,2087 errno_t async_forward_slow(cap_call_handle_t chandle, async_exch_t *exch, 2088 2088 sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 2089 2089 sysarg_t arg4, sysarg_t arg5, unsigned int mode) … … 2126 2126 } 2127 2127 2128 static errno_t async_connect_me_to_internal(int phone, sysarg_t arg1, sysarg_t arg2, 2129 sysarg_t arg3, sysarg_t arg4, int *out_phone) 2128 static errno_t async_connect_me_to_internal(cap_phone_handle_t phone, 2129 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, 2130 cap_phone_handle_t *out_phone) 2130 2131 { 2131 2132 ipc_call_t result; … … 2133 2134 // XXX: Workaround for GCC's inability to infer association between 2134 2135 // rc == EOK and *out_phone being assigned. 2135 *out_phone = -1;2136 *out_phone = CAP_NIL; 2136 2137 2137 2138 amsg_t *msg = amsg_create(); … … 2151 2152 return rc; 2152 2153 2153 *out_phone = ( int) IPC_GET_ARG5(result);2154 *out_phone = (cap_phone_handle_t) IPC_GET_ARG5(result); 2154 2155 return EOK; 2155 2156 } … … 2182 2183 } 2183 2184 2184 int phone;2185 cap_phone_handle_t phone; 2185 2186 errno_t rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3, 2186 2187 0, &phone); … … 2235 2236 } 2236 2237 2237 int phone;2238 cap_phone_handle_t phone; 2238 2239 errno_t rc = async_connect_me_to_internal(exch->phone, iface, arg2, 2239 2240 arg3, 0, &phone); … … 2306 2307 } 2307 2308 2308 int phone;2309 cap_phone_handle_t phone; 2309 2310 errno_t rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3, 2310 2311 IPC_FLAG_BLOCKING, &phone); … … 2360 2361 } 2361 2362 2362 int phone;2363 cap_phone_handle_t phone; 2363 2364 errno_t rc = async_connect_me_to_internal(exch->phone, iface, arg2, 2364 2365 arg3, IPC_FLAG_BLOCKING, &phone); … … 2396 2397 } 2397 2398 2398 cap_ handle_t phone;2399 cap_phone_handle_t phone; 2399 2400 errno_t rc = ipc_connect_kbox(id, &phone); 2400 2401 if (rc != EOK) { … … 2421 2422 } 2422 2423 2423 static errno_t async_hangup_internal( int phone)2424 static errno_t async_hangup_internal(cap_phone_handle_t phone) 2424 2425 { 2425 2426 return ipc_hangup(phone); … … 2515 2516 } 2516 2517 } else if (mgmt == EXCHANGE_PARALLEL) { 2517 int phone;2518 cap_phone_handle_t phone; 2518 2519 errno_t rc; 2519 2520 … … 2645 2646 * 2646 2647 */ 2647 bool async_share_in_receive(cap_ handle_t *chandle, size_t *size)2648 bool async_share_in_receive(cap_call_handle_t *chandle, size_t *size) 2648 2649 { 2649 2650 assert(chandle); … … 2673 2674 * 2674 2675 */ 2675 errno_t async_share_in_finalize(cap_handle_t chandle, void *src, unsigned int flags) 2676 errno_t async_share_in_finalize(cap_call_handle_t chandle, void *src, 2677 unsigned int flags) 2676 2678 { 2677 2679 return ipc_answer_3(chandle, EOK, (sysarg_t) src, (sysarg_t) flags, … … 2712 2714 * 2713 2715 */ 2714 bool async_share_out_receive(cap_ handle_t *chandle, size_t *size,2716 bool async_share_out_receive(cap_call_handle_t *chandle, size_t *size, 2715 2717 unsigned int *flags) 2716 2718 { … … 2743 2745 * 2744 2746 */ 2745 errno_t async_share_out_finalize(cap_ handle_t chandle, void **dst)2747 errno_t async_share_out_finalize(cap_call_handle_t chandle, void **dst) 2746 2748 { 2747 2749 return ipc_answer_2(chandle, EOK, (sysarg_t) __entry, (sysarg_t) dst); … … 2797 2799 * 2798 2800 */ 2799 bool async_data_read_receive(cap_ handle_t *chandle, size_t *size)2801 bool async_data_read_receive(cap_call_handle_t *chandle, size_t *size) 2800 2802 { 2801 2803 ipc_call_t data; … … 2817 2819 * 2818 2820 */ 2819 bool async_data_read_receive_call(cap_ handle_t *chandle, ipc_call_t *data,2821 bool async_data_read_receive_call(cap_call_handle_t *chandle, ipc_call_t *data, 2820 2822 size_t *size) 2821 2823 { … … 2848 2850 * 2849 2851 */ 2850 errno_t async_data_read_finalize(cap_handle_t chandle, const void *src, size_t size) 2852 errno_t async_data_read_finalize(cap_call_handle_t chandle, const void *src, 2853 size_t size) 2851 2854 { 2852 2855 return ipc_answer_2(chandle, EOK, (sysarg_t) src, (sysarg_t) size); … … 2863 2866 return ENOENT; 2864 2867 2865 cap_ handle_t chandle;2868 cap_call_handle_t chandle; 2866 2869 if (!async_data_read_receive(&chandle, NULL)) { 2867 2870 ipc_answer_0(chandle, EINVAL); … … 2922 2925 * 2923 2926 */ 2924 bool async_data_write_receive(cap_ handle_t *chandle, size_t *size)2927 bool async_data_write_receive(cap_call_handle_t *chandle, size_t *size) 2925 2928 { 2926 2929 ipc_call_t data; … … 2943 2946 * 2944 2947 */ 2945 bool async_data_write_receive_call(cap_ handle_t *chandle, ipc_call_t *data,2948 bool async_data_write_receive_call(cap_call_handle_t *chandle, ipc_call_t *data, 2946 2949 size_t *size) 2947 2950 { … … 2973 2976 * 2974 2977 */ 2975 errno_t async_data_write_finalize(cap_handle_t chandle, void *dst, size_t size) 2978 errno_t async_data_write_finalize(cap_call_handle_t chandle, void *dst, 2979 size_t size) 2976 2980 { 2977 2981 return ipc_answer_2(chandle, EOK, (sysarg_t) dst, (sysarg_t) size); … … 3005 3009 assert(data); 3006 3010 3007 cap_ handle_t chandle;3011 cap_call_handle_t chandle; 3008 3012 size_t size; 3009 3013 if (!async_data_write_receive(&chandle, &size)) { … … 3064 3068 void async_data_write_void(errno_t retval) 3065 3069 { 3066 cap_ handle_t chandle;3070 cap_call_handle_t chandle; 3067 3071 async_data_write_receive(&chandle, NULL); 3068 3072 ipc_answer_0(chandle, retval); … … 3079 3083 return ENOENT; 3080 3084 3081 cap_ handle_t chandle;3085 cap_call_handle_t chandle; 3082 3086 if (!async_data_write_receive(&chandle, NULL)) { 3083 3087 ipc_answer_0(chandle, EINVAL); … … 3121 3125 /* Accept the phone */ 3122 3126 ipc_call_t call; 3123 cap_handle_t chandle = async_get_call(&call); 3124 cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(call); 3125 3126 if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) || (phandle < 0)) { 3127 cap_call_handle_t chandle = async_get_call(&call); 3128 cap_phone_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(call); 3129 3130 if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) || 3131 !CAP_HANDLE_VALID((phandle))) { 3127 3132 async_answer_0(chandle, EINVAL); 3128 3133 return NULL; … … 3171 3176 async_sess_t *async_callback_receive_start(exch_mgmt_t mgmt, ipc_call_t *call) 3172 3177 { 3173 cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*call); 3174 3175 if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) || (phandle < 0)) 3178 cap_phone_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*call); 3179 3180 if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) || 3181 !CAP_HANDLE_VALID((phandle))) 3176 3182 return NULL; 3177 3183 … … 3201 3207 { 3202 3208 return async_req_5_0(exch, IPC_M_STATE_CHANGE_AUTHORIZE, 3203 arg1, arg2, arg3, 0, other_exch->phone);3204 } 3205 3206 bool async_state_change_receive(cap_ handle_t *chandle, sysarg_t *arg1,3209 arg1, arg2, arg3, 0, CAP_HANDLE_RAW(other_exch->phone)); 3210 } 3211 3212 bool async_state_change_receive(cap_call_handle_t *chandle, sysarg_t *arg1, 3207 3213 sysarg_t *arg2, sysarg_t *arg3) 3208 3214 { … … 3225 3231 } 3226 3232 3227 errno_t async_state_change_finalize(cap_handle_t chandle, async_exch_t *other_exch) 3228 { 3229 return ipc_answer_1(chandle, EOK, other_exch->phone); 3233 errno_t async_state_change_finalize(cap_call_handle_t chandle, 3234 async_exch_t *other_exch) 3235 { 3236 return ipc_answer_1(chandle, EOK, CAP_HANDLE_RAW(other_exch->phone)); 3230 3237 } 3231 3238
Note:
See TracChangeset
for help on using the changeset viewer.