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