Changeset 7b616e2 in mainline for uspace/lib/c
- Timestamp:
- 2017-09-27T22:40:09Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d076f16
- Parents:
- 8d6bcc8c
- Location:
- uspace/lib/c
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/ns.c
r8d6bcc8c r7b616e2 40 40 #include "private/ns.h" 41 41 42 /* 43 * XXX ns does not know about session_ns, so we create an extra session for 44 * actual communicaton 45 */ 46 static async_sess_t *sess_ns = NULL; 47 42 48 int service_register(service_t service) 43 49 { 44 async_exch_t *exch = async_exchange_begin(session_ns); 50 sysarg_t retval; 51 ipc_call_t answer; 52 53 async_sess_t *sess = ns_session_get(); 54 if (sess == NULL) 55 return EIO; 56 57 async_exch_t *exch = async_exchange_begin(sess); 58 aid_t req = async_send_1(exch, NS_REGISTER, service, &answer); 45 59 int rc = async_connect_to_me(exch, 0, service, 0); 60 46 61 async_exchange_end(exch); 47 62 63 if (rc != EOK) { 64 async_forget(req); 65 return rc; 66 } 67 68 async_wait_for(req, &retval); 48 69 return rc; 49 70 } 50 71 51 52 72 async_sess_t *service_connect(service_t service, iface_t iface, sysarg_t arg3) 53 73 { 54 async_ exch_t *exch = async_exchange_begin(session_ns);55 if ( !exch)74 async_sess_t *sess = ns_session_get(); 75 if (sess == NULL) 56 76 return NULL; 57 77 58 async_sess_t *sess = 78 async_exch_t *exch = async_exchange_begin(sess); 79 if (exch == NULL) 80 return NULL; 81 82 async_sess_t *csess = 59 83 async_connect_me_to_iface(exch, iface, service, arg3); 60 84 async_exchange_end(exch); 61 85 62 if ( !sess)86 if (csess == NULL) 63 87 return NULL; 64 88 … … 68 92 * first argument for non-initial connections. 69 93 */ 70 async_sess_args_set( sess, iface, arg3, 0);94 async_sess_args_set(csess, iface, arg3, 0); 71 95 72 return sess;96 return csess; 73 97 } 74 98 … … 76 100 sysarg_t arg3) 77 101 { 78 async_exch_t *exch = async_exchange_begin(session_ns); 79 async_sess_t *sess = 102 async_sess_t *sess = ns_session_get(); 103 if (sess == NULL) 104 return NULL; 105 106 async_exch_t *exch = async_exchange_begin(sess); 107 async_sess_t *csess = 80 108 async_connect_me_to_blocking_iface(exch, iface, service, arg3); 81 109 async_exchange_end(exch); 82 110 83 if ( !sess)111 if (csess == NULL) 84 112 return NULL; 85 113 … … 89 117 * first argument for non-initial connections. 90 118 */ 91 async_sess_args_set( sess, iface, arg3, 0);119 async_sess_args_set(csess, iface, arg3, 0); 92 120 93 return sess;121 return csess; 94 122 } 95 123 … … 97 125 int ns_ping(void) 98 126 { 99 async_exch_t *exch = async_exchange_begin(session_ns); 127 async_sess_t *sess = ns_session_get(); 128 if (sess == NULL) 129 return EIO; 130 131 async_exch_t *exch = async_exchange_begin(sess); 100 132 int rc = async_req_0_0(exch, NS_PING); 101 133 async_exchange_end(exch); … … 106 138 int ns_intro(task_id_t id) 107 139 { 108 async_exch_t *exch = async_exchange_begin(session_ns); 140 async_exch_t *exch; 141 async_sess_t *sess = ns_session_get(); 142 if (sess == NULL) 143 return EIO; 144 145 exch = async_exchange_begin(sess); 109 146 int rc = async_req_2_0(exch, NS_ID_INTRO, LOWER32(id), UPPER32(id)); 110 147 async_exchange_end(exch); … … 113 150 } 114 151 152 async_sess_t *ns_session_get(void) 153 { 154 async_exch_t *exch; 155 156 if (sess_ns == NULL) { 157 exch = async_exchange_begin(session_ns); 158 sess_ns = async_connect_me_to_iface(exch, 0, 0, 0); 159 async_exchange_end(exch); 160 if (sess_ns == NULL) 161 return NULL; 162 } 163 164 return sess_ns; 165 } 166 115 167 /** @} 116 168 */ -
uspace/lib/c/generic/task.c
r8d6bcc8c r7b616e2 44 44 #include <async.h> 45 45 #include <errno.h> 46 #include <ns.h> 46 47 #include <malloc.h> 47 48 #include <libc.h> … … 324 325 int task_setup_wait(task_id_t id, task_wait_t *wait) 325 326 { 326 async_exch_t *exch = async_exchange_begin(session_ns); 327 async_sess_t *sess_ns = ns_session_get(); 328 if (sess_ns == NULL) 329 return EIO; 330 331 async_exch_t *exch = async_exchange_begin(sess_ns); 327 332 wait->aid = async_send_2(exch, NS_TASK_WAIT, LOWER32(id), UPPER32(id), 328 333 &wait->result); … … 401 406 int task_retval(int val) 402 407 { 403 async_exch_t *exch = async_exchange_begin(session_ns); 408 async_sess_t *sess_ns = ns_session_get(); 409 if (sess_ns == NULL) 410 return EIO; 411 412 async_exch_t *exch = async_exchange_begin(sess_ns); 404 413 int rc = (int) async_req_1_0(exch, NS_RETVAL, val); 405 414 async_exchange_end(exch); -
uspace/lib/c/include/ipc/ns.h
r8d6bcc8c r7b616e2 40 40 typedef enum { 41 41 NS_PING = IPC_FIRST_USER_METHOD, 42 NS_REGISTER, 42 43 NS_TASK_WAIT, 43 44 NS_ID_INTRO, -
uspace/lib/c/include/ns.h
r8d6bcc8c r7b616e2 46 46 extern int ns_ping(void); 47 47 extern int ns_intro(task_id_t); 48 extern async_sess_t *ns_session_get(void); 48 49 49 50 #endif
Note:
See TracChangeset
for help on using the changeset viewer.