Changeset 93fb170c in mainline for uspace/srv/devmap/devmap.c
- Timestamp:
- 2011-01-08T18:51:31Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 15be932
- Parents:
- 8f748215 (diff), a523af4 (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
r8f748215 r93fb170c 46 46 #include <str.h> 47 47 #include <ipc/devmap.h> 48 #include <assert.h> 48 49 49 50 #define NAME "devmap" … … 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)); … … 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);
Note:
See TracChangeset
for help on using the changeset viewer.