Changeset a92cf94f in mainline for uspace/lib/c
- Timestamp:
- 2011-08-18T18:45:42Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f44b056
- Parents:
- ee24574 (diff), f55b12b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/lib/c
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/devman.c
ree24574 ra92cf94f 271 271 } 272 272 273 int devman_add_device_to_c lass(devman_handle_t devman_handle,274 const char *c lass_name)273 int devman_add_device_to_category(devman_handle_t devman_handle, 274 const char *cat_name) 275 275 { 276 276 async_exch_t *exch = devman_exchange_begin_blocking(DEVMAN_DRIVER); 277 277 278 278 ipc_call_t answer; 279 aid_t req = async_send_1(exch, DEVMAN_ADD_DEVICE_TO_C LASS,279 aid_t req = async_send_1(exch, DEVMAN_ADD_DEVICE_TO_CATEGORY, 280 280 devman_handle, &answer); 281 sysarg_t retval = async_data_write_start(exch, c lass_name,282 str_size(c lass_name));281 sysarg_t retval = async_data_write_start(exch, cat_name, 282 str_size(cat_name)); 283 283 284 284 devman_exchange_end(exch); … … 333 333 exch = devman_exchange_begin(DEVMAN_CLIENT); 334 334 if (exch == NULL) 335 return errno;335 return ENOMEM; 336 336 } 337 337 … … 364 364 } 365 365 366 int devman_device_get_handle_by_class(const char *classname,367 const char *devname, devman_handle_t *handle, unsigned int flags)368 {369 async_exch_t *exch;370 371 if (flags & IPC_FLAG_BLOCKING)372 exch = devman_exchange_begin_blocking(DEVMAN_CLIENT);373 else {374 exch = devman_exchange_begin(DEVMAN_CLIENT);375 if (exch == NULL)376 return errno;377 }378 379 ipc_call_t answer;380 aid_t req = async_send_1(exch, DEVMAN_DEVICE_GET_HANDLE_BY_CLASS,381 flags, &answer);382 sysarg_t retval = async_data_write_start(exch, classname,383 str_size(classname));384 385 if (retval != EOK) {386 devman_exchange_end(exch);387 async_wait_for(req, NULL);388 return retval;389 }390 391 retval = async_data_write_start(exch, devname,392 str_size(devname));393 394 devman_exchange_end(exch);395 396 if (retval != EOK) {397 async_wait_for(req, NULL);398 return retval;399 }400 401 async_wait_for(req, &retval);402 403 if (retval != EOK) {404 if (handle != NULL)405 *handle = (devman_handle_t) -1;406 407 return retval;408 }409 410 if (handle != NULL)411 *handle = (devman_handle_t) IPC_GET_ARG1(answer);412 413 return retval;414 }415 416 366 int devman_get_device_path(devman_handle_t handle, char *path, size_t path_size) 417 367 { 418 368 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 419 369 if (exch == NULL) 420 return errno;370 return ENOMEM; 421 371 422 372 ipc_call_t answer; … … 463 413 } 464 414 415 int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle) 416 { 417 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 418 if (exch == NULL) 419 return ENOMEM; 420 421 sysarg_t retval = async_req_1_1(exch, DEVMAN_FUN_SID_TO_HANDLE, 422 sid, handle); 423 424 devman_exchange_end(exch); 425 return (int) retval; 426 } 427 465 428 /** @} 466 429 */ -
uspace/lib/c/generic/loc.c
ree24574 ra92cf94f 45 45 static FIBRIL_MUTEX_INITIALIZE(loc_consumer_mutex); 46 46 47 static FIBRIL_MUTEX_INITIALIZE(loc_callback_mutex); 48 static bool loc_callback_created = false; 49 47 50 static async_sess_t *loc_supp_block_sess = NULL; 48 51 static async_sess_t *loc_cons_block_sess = NULL; … … 51 54 static async_sess_t *loc_consumer_sess = NULL; 52 55 56 static loc_cat_change_cb_t cat_change_cb = NULL; 57 58 static void loc_cb_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 59 { 60 loc_cat_change_cb_t cb_fun; 61 62 while (true) { 63 ipc_call_t call; 64 ipc_callid_t callid = async_get_call(&call); 65 66 if (!IPC_GET_IMETHOD(call)) { 67 /* TODO: Handle hangup */ 68 return; 69 } 70 71 int retval; 72 73 switch (IPC_GET_IMETHOD(call)) { 74 case LOC_EVENT_CAT_CHANGE: 75 fibril_mutex_lock(&loc_callback_mutex); 76 cb_fun = cat_change_cb; 77 if (cb_fun != NULL) { 78 (*cb_fun)(); 79 } 80 fibril_mutex_unlock(&loc_callback_mutex); 81 retval = 0; 82 break; 83 default: 84 retval = ENOTSUP; 85 } 86 87 async_answer_0(callid, retval); 88 } 89 } 90 91 53 92 static void clone_session(fibril_mutex_t *mtx, async_sess_t *src, 54 93 async_sess_t **dst) … … 60 99 61 100 fibril_mutex_unlock(mtx); 101 } 102 103 static int loc_callback_create(void) 104 { 105 async_exch_t *exch; 106 sysarg_t retval; 107 int rc = EOK; 108 109 fibril_mutex_lock(&loc_callback_mutex); 110 111 if (!loc_callback_created) { 112 exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER); 113 114 ipc_call_t answer; 115 aid_t req = async_send_0(exch, LOC_CALLBACK_CREATE, &answer); 116 async_connect_to_me(exch, 0, 0, 0, loc_cb_conn, NULL); 117 loc_exchange_end(exch); 118 119 async_wait_for(req, &retval); 120 if (rc != EOK) 121 goto done; 122 123 if (retval != EOK) { 124 rc = retval; 125 goto done; 126 } 127 128 loc_callback_created = true; 129 } 130 131 rc = EOK; 132 done: 133 fibril_mutex_unlock(&loc_callback_mutex); 134 return rc; 62 135 } 63 136 … … 291 364 } 292 365 293 /** Get service name. 294 * 295 * Provided ID of a service, return its name. 296 * 297 * @param svc_id Service ID 366 /** Get object name. 367 * 368 * Provided ID of an object, return its name. 369 * 370 * @param method IPC method 371 * @param id Object ID 298 372 * @param name Place to store pointer to new string. Caller should 299 373 * free it using free(). 300 374 * @return EOK on success or negative error code 301 375 */ 302 int loc_service_get_name(service_id_t svc_id, char **name)376 static int loc_get_name_internal(sysarg_t method, sysarg_t id, char **name) 303 377 { 304 378 async_exch_t *exch; … … 312 386 313 387 ipc_call_t answer; 314 aid_t req = async_send_1(exch, LOC_SERVICE_GET_NAME, svc_id, &answer);388 aid_t req = async_send_1(exch, method, id, &answer); 315 389 aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, 316 390 &dreply); … … 341 415 } 342 416 417 /** Get category name. 418 * 419 * Provided ID of a service, return its name. 420 * 421 * @param cat_id Category ID 422 * @param name Place to store pointer to new string. Caller should 423 * free it using free(). 424 * @return EOK on success or negative error code 425 */ 426 int loc_category_get_name(category_id_t cat_id, char **name) 427 { 428 return loc_get_name_internal(LOC_CATEGORY_GET_NAME, cat_id, name); 429 } 430 431 /** Get service name. 432 * 433 * Provided ID of a service, return its name. 434 * 435 * @param svc_id Service ID 436 * @param name Place to store pointer to new string. Caller should 437 * free it using free(). 438 * @return EOK on success or negative error code 439 */ 440 int loc_service_get_name(service_id_t svc_id, char **name) 441 { 442 return loc_get_name_internal(LOC_SERVICE_GET_NAME, svc_id, name); 443 } 343 444 344 445 int loc_namespace_get_id(const char *name, service_id_t *handle, … … 749 850 data, count); 750 851 } 852 853 int loc_register_cat_change_cb(loc_cat_change_cb_t cb_fun) 854 { 855 if (loc_callback_create() != EOK) 856 return EIO; 857 858 cat_change_cb = cb_fun; 859 return EOK; 860 } -
uspace/lib/c/include/devman.h
ree24574 ra92cf94f 38 38 39 39 #include <ipc/devman.h> 40 #include <ipc/loc.h> 40 41 #include <async.h> 41 42 #include <bool.h> … … 56 57 extern int devman_device_get_handle(const char *, devman_handle_t *, 57 58 unsigned int); 58 extern int devman_device_get_handle_by_class(const char *, const char *,59 devman_handle_t *, unsigned int);60 59 extern int devman_get_device_path(devman_handle_t, char *, size_t); 61 60 62 extern int devman_add_device_to_class(devman_handle_t, const char *); 61 extern int devman_add_device_to_category(devman_handle_t, const char *); 62 extern int devman_fun_sid_to_handle(service_id_t, devman_handle_t *); 63 63 64 64 #endif -
uspace/lib/c/include/ipc/devman.h
ree24574 ra92cf94f 138 138 DEVMAN_ADD_FUNCTION, 139 139 DEVMAN_ADD_MATCH_ID, 140 DEVMAN_ADD_DEVICE_TO_C LASS140 DEVMAN_ADD_DEVICE_TO_CATEGORY 141 141 142 142 } driver_to_devman_t; … … 149 149 typedef enum { 150 150 DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD, 151 DEVMAN_DEVICE_GET_ HANDLE_BY_CLASS,152 DEVMAN_ DEVICE_GET_DEVICE_PATH151 DEVMAN_DEVICE_GET_DEVICE_PATH, 152 DEVMAN_FUN_SID_TO_HANDLE 153 153 } client_to_devman_t; 154 154 -
uspace/lib/c/include/ipc/loc.h
ree24574 ra92cf94f 57 57 LOC_SERVICE_GET_NAME, 58 58 LOC_NAMESPACE_GET_ID, 59 LOC_CALLBACK_CREATE, 59 60 LOC_CATEGORY_GET_ID, 61 LOC_CATEGORY_GET_NAME, 60 62 LOC_CATEGORY_GET_SVCS, 61 63 LOC_ID_PROBE, … … 68 70 LOC_GET_SERVICES 69 71 } loc_request_t; 72 73 typedef enum { 74 LOC_EVENT_CAT_CHANGE = IPC_FIRST_USER_METHOD 75 } loc_event_t; 70 76 71 77 /** Ports provided by location service. -
uspace/lib/c/include/loc.h
ree24574 ra92cf94f 40 40 #include <bool.h> 41 41 42 typedef void (*loc_cat_change_cb_t)(void); 43 42 44 extern async_exch_t *loc_exchange_begin_blocking(loc_interface_t); 43 45 extern async_exch_t *loc_exchange_begin(loc_interface_t); … … 73 75 extern size_t loc_get_services(service_id_t, loc_sdesc_t **); 74 76 extern int loc_get_categories(category_id_t **, size_t *); 77 extern int loc_register_cat_change_cb(loc_cat_change_cb_t); 75 78 76 79
Note:
See TracChangeset
for help on using the changeset viewer.