Changeset f9b2cb4c in mainline for uspace/lib/c/generic/loc.c
- Timestamp:
- 2015-08-23T12:50:23Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9ef495f
- Parents:
- 0dd16778
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/loc.c
r0dd16778 rf9b2cb4c 107 107 if (!loc_callback_created) { 108 108 async_exch_t *exch = 109 loc_exchange_begin_blocking( LOC_PORT_CONSUMER);109 loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 110 110 111 111 ipc_call_t answer; 112 112 aid_t req = async_send_0(exch, LOC_CALLBACK_CREATE, &answer); 113 int rc = async_connect_to_me(exch, 0, 0, 0, loc_cb_conn, NULL); 113 114 port_id_t port; 115 int rc = async_create_callback_port(exch, INTERFACE_LOC_CB, 0, 0, 116 loc_cb_conn, NULL, &port); 117 114 118 loc_exchange_end(exch); 115 119 … … 135 139 * 136 140 */ 137 async_exch_t *loc_exchange_begin_blocking( loc_interface_t iface)141 async_exch_t *loc_exchange_begin_blocking(iface_t iface) 138 142 { 139 143 switch (iface) { 140 case LOC_PORT_SUPPLIER:144 case INTERFACE_LOC_SUPPLIER: 141 145 fibril_mutex_lock(&loc_supp_block_mutex); 142 146 … … 147 151 if (loc_supp_block_sess == NULL) 148 152 loc_supp_block_sess = 149 service_connect_blocking _iface(EXCHANGE_SERIALIZE,150 LOC_PORT_SUPPLIER, SERVICE_LOC, 0);153 service_connect_blocking(SERVICE_LOC, 154 INTERFACE_LOC_SUPPLIER, 0); 151 155 } 152 156 … … 157 161 158 162 return async_exchange_begin(loc_supp_block_sess); 159 case LOC_PORT_CONSUMER:163 case INTERFACE_LOC_CONSUMER: 160 164 fibril_mutex_lock(&loc_cons_block_mutex); 161 165 … … 166 170 if (loc_cons_block_sess == NULL) 167 171 loc_cons_block_sess = 168 service_connect_blocking _iface(EXCHANGE_SERIALIZE,169 LOC_PORT_CONSUMER, SERVICE_LOC, 0);172 service_connect_blocking(SERVICE_LOC, 173 INTERFACE_LOC_CONSUMER, 0); 170 174 } 171 175 … … 188 192 * 189 193 */ 190 async_exch_t *loc_exchange_begin( loc_interface_t iface)194 async_exch_t *loc_exchange_begin(iface_t iface) 191 195 { 192 196 switch (iface) { 193 case LOC_PORT_SUPPLIER:197 case INTERFACE_LOC_SUPPLIER: 194 198 fibril_mutex_lock(&loc_supplier_mutex); 195 199 196 200 if (loc_supplier_sess == NULL) 197 201 loc_supplier_sess = 198 service_connect _iface(EXCHANGE_SERIALIZE, LOC_PORT_SUPPLIER,199 SERVICE_LOC, 0);202 service_connect(SERVICE_LOC, 203 INTERFACE_LOC_SUPPLIER, 0); 200 204 201 205 fibril_mutex_unlock(&loc_supplier_mutex); … … 205 209 206 210 return async_exchange_begin(loc_supplier_sess); 207 case LOC_PORT_CONSUMER:211 case INTERFACE_LOC_CONSUMER: 208 212 fibril_mutex_lock(&loc_consumer_mutex); 209 213 210 214 if (loc_consumer_sess == NULL) 211 215 loc_consumer_sess = 212 service_connect _iface(EXCHANGE_SERIALIZE, LOC_PORT_CONSUMER,213 SERVICE_LOC, 0);216 service_connect(SERVICE_LOC, 217 INTERFACE_LOC_CONSUMER, 0); 214 218 215 219 fibril_mutex_unlock(&loc_consumer_mutex); … … 237 241 int loc_server_register(const char *name) 238 242 { 239 async_exch_t *exch = loc_exchange_begin_blocking( LOC_PORT_SUPPLIER);243 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER); 240 244 241 245 ipc_call_t answer; … … 250 254 } 251 255 252 exch = loc_exchange_begin( LOC_PORT_SUPPLIER);253 async_connect_to_me(exch, 0, 0, 0 , NULL, NULL);256 exch = loc_exchange_begin(INTERFACE_LOC_SUPPLIER); 257 async_connect_to_me(exch, 0, 0, 0); 254 258 loc_exchange_end(exch); 255 259 … … 260 264 /** Register new service. 261 265 * 262 * The @p interface is used when forwarding connection to the server. 263 * If not 0, the first argument is the interface and the second argument 264 * is the service ID. 265 * 266 * When the interface is zero (default), the first argument is directly 267 * the handle (to ensure backward compatibility). 268 * 269 * @param fqsn Fully qualified service name 270 * @param[out] sid Service ID of new service 271 * @param interface Interface when forwarding 272 * 273 */ 274 int loc_service_register_with_iface(const char *fqsn, 275 service_id_t *sid, sysarg_t interface) 276 { 277 async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER); 266 * @param fqsn Fully qualified service name 267 * @param[out] sid Service ID of new service 268 * 269 */ 270 int loc_service_register(const char *fqsn, service_id_t *sid) 271 { 272 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER); 278 273 279 274 ipc_call_t answer; 280 aid_t req = async_send_2(exch, LOC_SERVICE_REGISTER, interface, 0, 281 &answer); 275 aid_t req = async_send_0(exch, LOC_SERVICE_REGISTER, &answer); 282 276 sysarg_t retval = async_data_write_start(exch, fqsn, str_size(fqsn)); 283 277 … … 304 298 } 305 299 306 /** Register new service.307 *308 * @param fqsn Fully qualified service name309 * @param sid Output: ID of new service310 *311 */312 int loc_service_register(const char *fqdn, service_id_t *sid)313 {314 return loc_service_register_with_iface(fqdn, sid, 0);315 }316 317 300 /** Unregister service. 318 301 * … … 324 307 sysarg_t retval; 325 308 326 exch = loc_exchange_begin_blocking( LOC_PORT_SUPPLIER);309 exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER); 327 310 retval = async_req_1_0(exch, LOC_SERVICE_UNREGISTER, sid); 328 311 loc_exchange_end(exch); … … 337 320 338 321 if (flags & IPC_FLAG_BLOCKING) 339 exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);322 exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 340 323 else { 341 exch = loc_exchange_begin( LOC_PORT_CONSUMER);324 exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER); 342 325 if (exch == NULL) 343 326 return errno; … … 390 373 391 374 *name = NULL; 392 exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);375 exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 393 376 394 377 ipc_call_t answer; … … 470 453 471 454 if (flags & IPC_FLAG_BLOCKING) 472 exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);455 exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 473 456 else { 474 exch = loc_exchange_begin( LOC_PORT_CONSUMER);457 exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER); 475 458 if (exch == NULL) 476 459 return errno; … … 519 502 520 503 if (flags & IPC_FLAG_BLOCKING) 521 exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);504 exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 522 505 else { 523 exch = loc_exchange_begin( LOC_PORT_CONSUMER);506 exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER); 524 507 if (exch == NULL) 525 508 return errno; … … 556 539 loc_object_type_t loc_id_probe(service_id_t handle) 557 540 { 558 async_exch_t *exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);541 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 559 542 560 543 sysarg_t type; … … 569 552 } 570 553 571 async_sess_t *loc_service_connect _iface(service_id_t handle, iface_t iface,554 async_sess_t *loc_service_connect(service_id_t handle, iface_t iface, 572 555 unsigned int flags) 573 556 { … … 575 558 576 559 if (flags & IPC_FLAG_BLOCKING) 577 sess = service_connect_blocking _iface_extended(SERVICE_LOC, iface, handle);560 sess = service_connect_blocking(SERVICE_LOC, iface, handle); 578 561 else 579 sess = service_connect _iface_extended(SERVICE_LOC, iface, handle);562 sess = service_connect(SERVICE_LOC, iface, handle); 580 563 581 564 return sess; 582 565 } 583 566 584 async_sess_t *loc_service_connect(exch_mgmt_t mgmt, service_id_t handle,585 unsigned int flags)586 {587 async_sess_t *sess;588 589 if (flags & IPC_FLAG_BLOCKING)590 sess = service_connect_blocking_iface(mgmt, LOC_CONNECT_TO_SERVICE,591 SERVICE_LOC, handle);592 else593 sess = service_connect_iface(mgmt, LOC_CONNECT_TO_SERVICE,594 SERVICE_LOC, handle);595 596 return sess;597 }598 599 567 int loc_null_create(void) 600 568 { 601 async_exch_t *exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);569 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 602 570 603 571 sysarg_t null_id; … … 614 582 void loc_null_destroy(int null_id) 615 583 { 616 async_exch_t *exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);584 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 617 585 async_req_1_0(exch, LOC_NULL_DESTROY, (sysarg_t) null_id); 618 586 loc_exchange_end(exch); … … 640 608 sysarg_t retval; 641 609 642 exch = loc_exchange_begin_blocking( LOC_PORT_SUPPLIER);610 exch = loc_exchange_begin_blocking(INTERFACE_LOC_SUPPLIER); 643 611 retval = async_req_2_0(exch, LOC_SERVICE_ADD_TO_CAT, svc_id, cat_id); 644 612 loc_exchange_end(exch); … … 661 629 size_t loc_count_namespaces(void) 662 630 { 663 async_exch_t *exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);631 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 664 632 size_t size = loc_count_namespaces_internal(exch); 665 633 loc_exchange_end(exch); … … 670 638 size_t loc_count_services(service_id_t ns_handle) 671 639 { 672 async_exch_t *exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);640 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 673 641 size_t size = loc_count_services_internal(exch, ns_handle); 674 642 loc_exchange_end(exch); … … 681 649 /* Loop until read is succesful */ 682 650 while (true) { 683 async_exch_t *exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);651 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 684 652 size_t count = loc_count_namespaces_internal(exch); 685 653 loc_exchange_end(exch); … … 692 660 return 0; 693 661 694 exch = loc_exchange_begin( LOC_PORT_CONSUMER);662 exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER); 695 663 696 664 ipc_call_t answer; … … 730 698 /* Loop until read is succesful */ 731 699 while (true) { 732 async_exch_t *exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);700 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 733 701 size_t count = loc_count_services_internal(exch, ns_handle); 734 702 loc_exchange_end(exch); … … 741 709 return 0; 742 710 743 exch = loc_exchange_begin( LOC_PORT_CONSUMER);711 exch = loc_exchange_begin(INTERFACE_LOC_CONSUMER); 744 712 745 713 ipc_call_t answer; … … 778 746 sysarg_t *id_buf, size_t buf_size, size_t *act_size) 779 747 { 780 async_exch_t *exch = loc_exchange_begin_blocking( LOC_PORT_CONSUMER);748 async_exch_t *exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 781 749 782 750 ipc_call_t answer;
Note:
See TracChangeset
for help on using the changeset viewer.