Changeset 7f3e3e7 in mainline
- Timestamp:
- 2007-11-09T09:08:52Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6c4ff8a
- Parents:
- 44358c1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devmap/devmap.c
r44358c1 r7f3e3e7 155 155 } 156 156 157 /** Unregister device and free it. Its assumed that driver's device list158 * is already locked.159 * 157 /** 158 * Unregister device and free it. It's assumed that driver's device list is 159 * already locked. 160 160 */ 161 161 static int devmap_device_unregister_core(devmap_device_t *device) … … 172 172 } 173 173 174 /** Read info about new driver and add it into linked list of registered drivers. 174 /** 175 * Read info about new driver and add it into linked list of registered 176 * drivers. 175 177 */ 176 178 static void devmap_driver_register(devmap_driver_t **odriver) … … 192 194 } 193 195 194 if (NULL == (driver = (devmap_driver_t *)malloc(sizeof(devmap_driver_t)))) { 196 if (NULL == 197 (driver = (devmap_driver_t *)malloc(sizeof(devmap_driver_t)))) { 195 198 ipc_answer_fast(iid, ENOMEM, 0, 0); 196 199 return; … … 209 212 210 213 if (name_size > DEVMAP_NAME_MAXLEN) { 211 printf("Too logn name: %u: maximum is %u.\n", name_size, DEVMAP_NAME_MAXLEN); 214 printf("Too logn name: %u: maximum is %u.\n", name_size, 215 DEVMAP_NAME_MAXLEN); 212 216 free(driver); 213 217 ipc_answer_fast(callid, EINVAL, 0, 0); … … 243 247 244 248 /* Initialize futex for list of devices owned by this driver */ 245 futex_initialize(&(driver->devices_futex) ,1);249 futex_initialize(&(driver->devices_futex), 1); 246 250 247 251 /* … … 256 260 257 261 if (IPC_M_CONNECT_TO_ME != IPC_GET_METHOD(call)) { 258 printf("DevMap: Unexpected method: %u.\n", \259 262 printf("DevMap: Unexpected method: %u.\n", 263 IPC_GET_METHOD(call)); 260 264 ipc_answer_fast(callid, ENOTSUP, 0, 0); 261 265 … … 274 278 futex_down(&drivers_list_futex); 275 279 276 /* TODO: check that no driver with name equals to driver->name is registered */ 280 /* TODO: 281 * check that no driver with name equal to driver->name is registered 282 */ 277 283 278 284 /* … … 315 321 316 322 while (!list_empty(&(driver->devices))) { 317 device = list_get_instance(driver->devices.next, devmap_device_t, driver_devices); 323 device = list_get_instance(driver->devices.next, 324 devmap_device_t, driver_devices); 318 325 printf("Unregister device '%s'.\n", device->name); 319 326 devmap_device_unregister_core(device); … … 355 362 356 363 /* Create new device entry */ 357 if (NULL == (device = (devmap_device_t *)malloc(sizeof(devmap_device_t)))) { 364 if (NULL == 365 (device = (devmap_device_t *)malloc(sizeof(devmap_device_t)))) { 358 366 printf("Cannot allocate new device.\n"); 359 367 ipc_answer_fast(iid, ENOMEM, 0, 0); … … 457 465 458 466 if (NULL == dev) { 459 printf("DevMap: No registered device with handle %d.\n", handle); 467 printf("DevMap: No registered device with handle %d.\n", 468 handle); 460 469 ipc_answer_fast(callid, ENOENT, 0, 0); 461 470 return; 462 471 } 463 472 464 /* FIXME: is this correct method how to pass argument on forwarding ?*/ 465 ipc_forward_fast(callid, dev->driver->phone, (ipcarg_t)(dev->handle), 0); 473 /* FIXME: is this correct method how to pass argument on forwarding ?*/ 474 ipc_forward_fast(callid, dev->driver->phone, (ipcarg_t)(dev->handle), 475 0); 466 476 return; 467 477 } … … 509 519 * Send confirmation to sender and get data into buffer. 510 520 */ 511 if (EOK != (retval = ipc_data_deliver(callid, &call, name, name_size))) { 521 if (EOK != (retval = ipc_data_deliver(callid, &call, name, 522 name_size))) { 512 523 ipc_answer_fast(iid, EREFUSED, 0, 0); 513 524 return; … … 664 675 case DEVMAP_DEVICE_CONNECT_ME_TO: 665 676 /* Connect client to selected device */ 666 printf("DevMap: connect to device %d.\n", IPC_GET_ARG1(call)); 677 printf("DevMap: connect to device %d.\n", 678 IPC_GET_ARG1(call)); 667 679 devmap_forward(callid, &call); 668 680 break; … … 695 707 /* Select interface */ 696 708 switch ((ipcarg_t)(IPC_GET_ARG1(*icall))) { 697 698 699 700 701 702 703 704 705 printf("DevMap: Unknown interface %u.\n", \706 709 case DEVMAP_DRIVER: 710 devmap_connection_driver(iid, icall); 711 break; 712 case DEVMAP_CLIENT: 713 devmap_connection_client(iid, icall); 714 break; 715 default: 716 ipc_answer_fast(iid, ENOENT, 0, 0); /* No such interface */ 717 printf("DevMap: Unknown interface %u.\n", 718 (ipcarg_t)(IPC_GET_ARG1(*icall))); 707 719 } 708 720 … … 730 742 async_set_client_connection(devmap_connection); 731 743 732 744 /* Register device mapper at naming service */ 733 745 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, &phonead) != 0) 734 746 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.