Changeset ea28272 in mainline for uspace/srv/devmap/devmap.c
- Timestamp:
- 2010-12-30T13:43:27Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d770deb
- Parents:
- d70d80ed (diff), f418e51 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devmap/devmap.c
rd70d80ed rea28272 46 46 #include <str.h> 47 47 #include <ipc/devmap.h> 48 #include <assert.h> 48 49 49 50 #define NAME "devmap" … … 61 62 link_t devices; 62 63 /** Phone asociated with this driver */ 63 ipcarg_t phone;64 sysarg_t phone; 64 65 /** Device driver name */ 65 66 char *name; … … 99 100 /** Device driver handling this device */ 100 101 devmap_driver_t *driver; 102 /** Use this interface when forwarding to driver. */ 103 sysarg_t forward_interface; 101 104 } devmap_device_t; 102 105 … … 206 209 } 207 210 208 /** Find namespace with given name. 209 * 210 * The devices_list_mutex should be already held when 211 * calling this function. 212 * 213 */ 211 /** Find namespace with given name. */ 214 212 static devmap_namespace_t *devmap_namespace_find_name(const char *name) 215 213 { 216 214 link_t *item; 215 216 assert(fibril_mutex_is_locked(&devices_list_mutex)); 217 217 218 for (item = namespaces_list.next; item != &namespaces_list; item = item->next) { 218 219 devmap_namespace_t *namespace = … … 227 228 /** Find namespace with given handle. 228 229 * 229 * The devices_list_mutex should be already held when230 * calling this function.231 *232 230 * @todo: use hash table 233 231 * … … 236 234 { 237 235 link_t *item; 236 237 assert(fibril_mutex_is_locked(&devices_list_mutex)); 238 238 239 for (item = namespaces_list.next; item != &namespaces_list; item = item->next) { 239 240 devmap_namespace_t *namespace = … … 246 247 } 247 248 248 /** Find device with given name. 249 * 250 * The devices_list_mutex should be already held when 251 * calling this function. 252 * 253 */ 249 /** Find device with given name. */ 254 250 static devmap_device_t *devmap_device_find_name(const char *ns_name, 255 251 const char *name) 256 252 { 257 253 link_t *item; 254 255 assert(fibril_mutex_is_locked(&devices_list_mutex)); 256 258 257 for (item = devices_list.next; item != &devices_list; item = item->next) { 259 258 devmap_device_t *device = … … 269 268 /** Find device with given handle. 270 269 * 271 * The devices_list_mutex should be already held when272 * calling this function.273 *274 270 * @todo: use hash table 275 271 * … … 278 274 { 279 275 link_t *item; 276 277 assert(fibril_mutex_is_locked(&devices_list_mutex)); 278 280 279 for (item = devices_list.next; item != &devices_list; item = item->next) { 281 280 devmap_device_t *device = … … 288 287 } 289 288 290 /** Create a namespace (if not already present) 291 * 292 * The devices_list_mutex should be already held when 293 * calling this function. 294 * 295 */ 289 /** Create a namespace (if not already present). */ 296 290 static devmap_namespace_t *devmap_namespace_create(const char *ns_name) 297 291 { 298 devmap_namespace_t *namespace = devmap_namespace_find_name(ns_name); 292 devmap_namespace_t *namespace; 293 294 assert(fibril_mutex_is_locked(&devices_list_mutex)); 295 296 namespace = devmap_namespace_find_name(ns_name); 299 297 if (namespace != NULL) 300 298 return namespace; … … 321 319 } 322 320 323 /** Destroy a namespace (if it is no longer needed) 324 * 325 * The devices_list_mutex should be already held when 326 * calling this function. 327 * 328 */ 321 /** Destroy a namespace (if it is no longer needed). */ 329 322 static void devmap_namespace_destroy(devmap_namespace_t *namespace) 330 323 { 324 assert(fibril_mutex_is_locked(&devices_list_mutex)); 325 331 326 if (namespace->refcnt == 0) { 332 327 list_remove(&(namespace->namespaces)); … … 337 332 } 338 333 339 /** Increase namespace reference count by including device 340 * 341 * The devices_list_mutex should be already held when 342 * calling this function. 343 * 344 */ 334 /** Increase namespace reference count by including device. */ 345 335 static void devmap_namespace_addref(devmap_namespace_t *namespace, 346 336 devmap_device_t *device) 347 337 { 338 assert(fibril_mutex_is_locked(&devices_list_mutex)); 339 348 340 device->namespace = namespace; 349 341 namespace->refcnt++; 350 342 } 351 343 352 /** Decrease namespace reference count 353 * 354 * The devices_list_mutex should be already held when 355 * calling this function. 356 * 357 */ 344 /** Decrease namespace reference count. */ 358 345 static void devmap_namespace_delref(devmap_namespace_t *namespace) 359 346 { 347 assert(fibril_mutex_is_locked(&devices_list_mutex)); 348 360 349 namespace->refcnt--; 361 350 devmap_namespace_destroy(namespace); 362 351 } 363 352 364 /** Unregister device and free it 365 * 366 * The devices_list_mutex should be already held when 367 * calling this function. 368 * 369 */ 353 /** Unregister device and free it. */ 370 354 static void devmap_device_unregister_core(devmap_device_t *device) 371 355 { 356 assert(fibril_mutex_is_locked(&devices_list_mutex)); 357 372 358 devmap_namespace_delref(device->namespace); 373 359 list_remove(&(device->devices)); … … 387 373 ipc_callid_t iid = async_get_call(&icall); 388 374 389 if (IPC_GET_ METHOD(icall) != DEVMAP_DRIVER_REGISTER) {375 if (IPC_GET_IMETHOD(icall) != DEVMAP_DRIVER_REGISTER) { 390 376 ipc_answer_0(iid, EREFUSED); 391 377 return NULL; … … 416 402 ipc_callid_t callid = async_get_call(&call); 417 403 418 if (IPC_GET_ METHOD(call) != IPC_M_CONNECT_TO_ME) {404 if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) { 419 405 free(driver->name); 420 406 free(driver); … … 517 503 } 518 504 505 /* Set the interface, if any. */ 506 device->forward_interface = IPC_GET_ARG1(*icall); 507 519 508 /* Get fqdn */ 520 509 char *fqdn; … … 566 555 /* Get unique device handle */ 567 556 device->handle = devmap_create_handle(); 568 557 569 558 devmap_namespace_addref(namespace, device); 570 559 device->driver = driver; … … 617 606 } 618 607 619 ipc_forward_fast(callid, dev->driver->phone, dev->handle, 620 IPC_GET_ARG3(*call), 0, IPC_FF_NONE); 608 if (dev->forward_interface == 0) { 609 ipc_forward_fast(callid, dev->driver->phone, 610 dev->handle, 0, 0, 611 IPC_FF_NONE); 612 } else { 613 ipc_forward_fast(callid, dev->driver->phone, 614 dev->forward_interface, dev->handle, 0, 615 IPC_FF_NONE); 616 } 621 617 622 618 fibril_mutex_unlock(&devices_list_mutex); … … 823 819 } 824 820 825 ipcarg_t retval = async_data_read_finalize(callid, desc, size);821 sysarg_t retval = async_data_read_finalize(callid, desc, size); 826 822 827 823 free(desc); … … 890 886 } 891 887 892 ipcarg_t retval = async_data_read_finalize(callid, desc, size);888 sysarg_t retval = async_data_read_finalize(callid, desc, size); 893 889 894 890 free(desc); … … 964 960 fibril_mutex_unlock(&null_devices_mutex); 965 961 966 ipc_answer_1(iid, EOK, ( ipcarg_t) i);962 ipc_answer_1(iid, EOK, (sysarg_t) i); 967 963 } 968 964 969 965 static void devmap_null_destroy(ipc_callid_t iid, ipc_call_t *icall) 970 966 { 971 ipcarg_t i = IPC_GET_ARG1(*icall);967 sysarg_t i = IPC_GET_ARG1(*icall); 972 968 if (i >= NULL_DEVICES) { 973 969 ipc_answer_0(iid, ELIMIT); … … 1027 1023 ipc_callid_t callid = async_get_call(&call); 1028 1024 1029 switch (IPC_GET_ METHOD(call)) {1025 switch (IPC_GET_IMETHOD(call)) { 1030 1026 case IPC_M_PHONE_HUNGUP: 1031 1027 cont = false; … … 1078 1074 ipc_callid_t callid = async_get_call(&call); 1079 1075 1080 switch (IPC_GET_ METHOD(call)) {1076 switch (IPC_GET_IMETHOD(call)) { 1081 1077 case IPC_M_PHONE_HUNGUP: 1082 1078 cont = false; … … 1121 1117 { 1122 1118 /* Select interface */ 1123 switch (( ipcarg_t) (IPC_GET_ARG1(*icall))) {1119 switch ((sysarg_t) (IPC_GET_ARG1(*icall))) { 1124 1120 case DEVMAP_DRIVER: 1125 1121 devmap_connection_driver(iid, icall); … … 1154 1150 1155 1151 /* Register device mapper at naming service */ 1156 ipcarg_t phonead;1152 sysarg_t phonead; 1157 1153 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, &phonead) != 0) 1158 1154 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.