Changes in uspace/srv/devman/main.c [5a6cc679:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
r5a6cc679 ra35b458 71 71 devman_handle_t handle = IPC_GET_ARG2(*icall); 72 72 dev_node_t *dev = NULL; 73 73 74 74 fun_node_t *fun = find_fun_node(&device_tree, handle); 75 75 if (fun == NULL) { … … 77 77 } else { 78 78 fibril_rwlock_read_lock(&device_tree.rwlock); 79 79 80 80 dev = fun->dev; 81 81 if (dev != NULL) 82 82 dev_add_ref(dev); 83 83 84 84 fibril_rwlock_read_unlock(&device_tree.rwlock); 85 85 } 86 86 87 87 /* 88 88 * For a valid function to connect to we need a device. The root … … 97 97 goto cleanup; 98 98 } 99 99 100 100 if (fun == NULL) { 101 101 log_msg(LOG_DEFAULT, LVL_ERROR, NAME ": devman_forward error - cannot " … … 105 105 goto cleanup; 106 106 } 107 107 108 108 fibril_rwlock_read_lock(&device_tree.rwlock); 109 109 110 110 /* Connect to the specified function */ 111 111 driver_t *driver = dev->drv; 112 112 113 113 fibril_rwlock_read_unlock(&device_tree.rwlock); 114 114 115 115 if (driver == NULL) { 116 116 log_msg(LOG_DEFAULT, LVL_ERROR, "IPC forwarding refused - " \ … … 119 119 goto cleanup; 120 120 } 121 121 122 122 if (!driver->sess) { 123 123 log_msg(LOG_DEFAULT, LVL_ERROR, … … 126 126 goto cleanup; 127 127 } 128 128 129 129 if (fun != NULL) { 130 130 log_msg(LOG_DEFAULT, LVL_DEBUG, … … 136 136 dev->pfun->pathname, driver->name); 137 137 } 138 138 139 139 async_exch_t *exch = async_exchange_begin(driver->sess); 140 140 async_forward_fast(iid, exch, INTERFACE_DDF_CLIENT, handle, 0, IPC_FF_NONE); 141 141 async_exchange_end(exch); 142 142 143 143 cleanup: 144 144 if (dev != NULL) 145 145 dev_del_ref(dev); 146 146 147 147 if (fun != NULL) 148 148 fun_del_ref(fun); … … 154 154 devman_handle_t handle = IPC_GET_ARG2(*icall); 155 155 dev_node_t *dev = NULL; 156 156 157 157 fun_node_t *fun = find_fun_node(&device_tree, handle); 158 158 if (fun == NULL) { … … 160 160 } else { 161 161 fibril_rwlock_read_lock(&device_tree.rwlock); 162 162 163 163 dev = fun->dev; 164 164 if (dev != NULL) 165 165 dev_add_ref(dev); 166 166 167 167 fibril_rwlock_read_unlock(&device_tree.rwlock); 168 168 } 169 169 170 170 /* 171 171 * For a valid function to connect to we need a device. The root … … 180 180 goto cleanup; 181 181 } 182 182 183 183 driver_t *driver = NULL; 184 184 185 185 fibril_rwlock_read_lock(&device_tree.rwlock); 186 186 187 187 /* Connect to parent function of a device (or device function). */ 188 188 if (dev->pfun->dev != NULL) 189 189 driver = dev->pfun->dev->drv; 190 190 191 191 devman_handle_t fun_handle = dev->pfun->handle; 192 192 193 193 fibril_rwlock_read_unlock(&device_tree.rwlock); 194 194 195 195 if (driver == NULL) { 196 196 log_msg(LOG_DEFAULT, LVL_ERROR, "IPC forwarding refused - " \ … … 199 199 goto cleanup; 200 200 } 201 201 202 202 if (!driver->sess) { 203 203 log_msg(LOG_DEFAULT, LVL_ERROR, … … 206 206 goto cleanup; 207 207 } 208 208 209 209 if (fun != NULL) { 210 210 log_msg(LOG_DEFAULT, LVL_DEBUG, … … 216 216 dev->pfun->pathname, driver->name); 217 217 } 218 218 219 219 async_exch_t *exch = async_exchange_begin(driver->sess); 220 220 async_forward_fast(iid, exch, INTERFACE_DDF_DRIVER, fun_handle, 0, IPC_FF_NONE); 221 221 async_exchange_end(exch); 222 222 223 223 cleanup: 224 224 if (dev != NULL) 225 225 dev_del_ref(dev); 226 226 227 227 if (fun != NULL) 228 228 fun_del_ref(fun); … … 233 233 iface_t iface = IPC_GET_ARG1(*icall); 234 234 service_id_t service_id = IPC_GET_ARG2(*icall); 235 235 236 236 fun_node_t *fun = find_loc_tree_function(&device_tree, service_id); 237 237 238 238 fibril_rwlock_read_lock(&device_tree.rwlock); 239 239 240 240 if ((fun == NULL) || (fun->dev == NULL) || (fun->dev->drv == NULL)) { 241 241 log_msg(LOG_DEFAULT, LVL_WARN, "devman_forward(): function " … … 245 245 return; 246 246 } 247 247 248 248 dev_node_t *dev = fun->dev; 249 249 driver_t *driver = dev->drv; 250 250 devman_handle_t handle = fun->handle; 251 251 252 252 fibril_rwlock_read_unlock(&device_tree.rwlock); 253 253 254 254 async_exch_t *exch = async_exchange_begin(driver->sess); 255 255 async_forward_fast(iid, exch, iface, handle, 0, IPC_FF_NONE); 256 256 async_exchange_end(exch); 257 257 258 258 log_msg(LOG_DEFAULT, LVL_DEBUG, 259 259 "Forwarding service request for `%s' function to driver `%s'.", 260 260 fun->pathname, driver->name); 261 261 262 262 fun_del_ref(fun); 263 263 } … … 266 266 { 267 267 client_t *client; 268 268 269 269 client = calloc(1, sizeof(client_t)); 270 270 if (client == NULL) 271 271 return NULL; 272 272 273 273 fibril_mutex_initialize(&client->mutex); 274 274 return client; … … 284 284 { 285 285 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_init - looking for available drivers."); 286 286 287 287 /* Initialize list of available drivers. */ 288 288 init_driver_list(&drivers_list); … … 292 292 return false; 293 293 } 294 294 295 295 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_init - list of drivers has been initialized."); 296 296 297 297 /* Create root device node. */ 298 298 if (!init_device_tree(&device_tree, &drivers_list)) { … … 300 300 return false; 301 301 } 302 302 303 303 /* 304 304 * Caution: As the device manager is not a real loc … … 309 309 */ 310 310 loc_server_register(NAME); 311 311 312 312 return true; 313 313 } … … 316 316 { 317 317 printf("%s: HelenOS Device Manager\n", NAME); 318 318 319 319 errno_t rc = log_init(NAME); 320 320 if (rc != EOK) { … … 322 322 return rc; 323 323 } 324 324 325 325 /* Set handlers for incoming connections. */ 326 326 async_set_client_data_constructor(devman_client_data_create); 327 327 async_set_client_data_destructor(devman_client_data_destroy); 328 328 329 329 port_id_t port; 330 330 rc = async_create_port(INTERFACE_DDF_DRIVER, … … 334 334 return rc; 335 335 } 336 336 337 337 rc = async_create_port(INTERFACE_DDF_CLIENT, 338 338 devman_connection_client, NULL, &port); … … 341 341 return rc; 342 342 } 343 343 344 344 rc = async_create_port(INTERFACE_DEVMAN_DEVICE, 345 345 devman_connection_device, NULL, &port); … … 348 348 return rc; 349 349 } 350 350 351 351 rc = async_create_port(INTERFACE_DEVMAN_PARENT, 352 352 devman_connection_parent, NULL, &port); … … 355 355 return rc; 356 356 } 357 357 358 358 async_set_fallback_port_handler(devman_forward, NULL); 359 359 360 360 if (!devman_init()) { 361 361 log_msg(LOG_DEFAULT, LVL_ERROR, "Error while initializing service."); 362 362 return -1; 363 363 } 364 364 365 365 /* Register device manager at naming service. */ 366 366 rc = service_register(SERVICE_DEVMAN); … … 369 369 return rc; 370 370 } 371 371 372 372 printf("%s: Accepting connections.\n", NAME); 373 373 task_retval(0); 374 374 async_manager(); 375 375 376 376 /* Never reached. */ 377 377 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.