source: mainline/uspace/srv/devman/main.c@ 96b02eb9

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 96b02eb9 was 96b02eb9, checked in by Martin Decky <martin@…>, 15 years ago

more unification of basic types

  • use sysarg_t and native_t (unsigned and signed variant) in both kernel and uspace
  • remove ipcarg_t in favour of sysarg_t

(no change in functionality)

  • Property mode set to 100644
File size: 16.2 KB
RevLine 
[e2b9a993]1/*
2 * Copyright (c) 2010 Lenka Trochtova
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/**
30 * @defgroup devman Device manager.
31 * @brief HelenOS device manager.
32 * @{
33 */
34
35/** @file
36 */
37
[7e752b2]38#include <inttypes.h>
[e2b9a993]39#include <assert.h>
40#include <ipc/services.h>
41#include <ipc/ns.h>
42#include <async.h>
43#include <stdio.h>
44#include <errno.h>
45#include <bool.h>
46#include <fibril_synch.h>
47#include <stdlib.h>
[c47e1a8]48#include <str.h>
[e2b9a993]49#include <dirent.h>
50#include <fcntl.h>
51#include <sys/stat.h>
52#include <ctype.h>
53#include <ipc/devman.h>
[5cd136ab]54#include <ipc/driver.h>
[d347b53]55#include <thread.h>
[ce89036b]56#include <devmap.h>
[e2b9a993]57
58#include "devman.h"
59
[a79d88d]60#define DRIVER_DEFAULT_STORE "/drv"
[e2b9a993]61
[0c3666d]62static driver_list_t drivers_list;
[e2b9a993]63static dev_tree_t device_tree;
[692c40cb]64static class_list_t class_list;
[e2b9a993]65
[38b3baf]66/** Register running driver. */
67static driver_t *devman_driver_register(void)
68{
[729fa2d6]69 ipc_call_t icall;
[c6c389ed]70 ipc_callid_t iid;
[729fa2d6]71 driver_t *driver = NULL;
[c6c389ed]72
73 printf(NAME ": devman_driver_register \n");
[729fa2d6]74
[c6c389ed]75 iid = async_get_call(&icall);
[729fa2d6]76 if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) {
77 ipc_answer_0(iid, EREFUSED);
78 return NULL;
79 }
80
[92413de]81 char *drv_name = NULL;
[729fa2d6]82
[38b3baf]83 /* Get driver name. */
84 int rc = async_data_write_accept((void **) &drv_name, true, 0, 0, 0, 0);
[729fa2d6]85 if (rc != EOK) {
86 ipc_answer_0(iid, rc);
87 return NULL;
88 }
[c6c389ed]89
[38b3baf]90 printf(NAME ": the %s driver is trying to register by the service.\n",
91 drv_name);
[729fa2d6]92
[38b3baf]93 /* Find driver structure. */
[729fa2d6]94 driver = find_driver(&drivers_list, drv_name);
[92413de]95
[c6c389ed]96 if (driver == NULL) {
[729fa2d6]97 printf(NAME ": no driver named %s was found.\n", drv_name);
[04c7003f]98 free(drv_name);
99 drv_name = NULL;
[729fa2d6]100 ipc_answer_0(iid, ENOENT);
101 return NULL;
102 }
103
[04c7003f]104 free(drv_name);
105 drv_name = NULL;
106
[38b3baf]107 /* Create connection to the driver. */
108 printf(NAME ": creating connection to the %s driver.\n", driver->name);
[729fa2d6]109 ipc_call_t call;
[38b3baf]110 ipc_callid_t callid = async_get_call(&call);
[729fa2d6]111 if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
112 ipc_answer_0(callid, ENOTSUP);
113 ipc_answer_0(iid, ENOTSUP);
114 return NULL;
115 }
116
[38b3baf]117 /* Remember driver's phone. */
[c16cf62]118 set_driver_phone(driver, IPC_GET_ARG5(call));
[729fa2d6]119
[38b3baf]120 printf(NAME ": the %s driver was successfully registered as running.\n",
121 driver->name);
[729fa2d6]122
[38b3baf]123 ipc_answer_0(callid, EOK);
[729fa2d6]124 ipc_answer_0(iid, EOK);
125
126 return driver;
127}
[e2b9a993]128
[38b3baf]129/** Receive device match ID from the device's parent driver and add it to the
130 * list of devices match ids.
131 *
132 * @param match_ids The list of the device's match ids.
133 * @return Zero on success, negative error code otherwise.
[3843ecb]134 */
[38b3baf]135static int devman_receive_match_id(match_id_list_t *match_ids)
136{
[66babbd]137 match_id_t *match_id = create_match_id();
138 ipc_callid_t callid;
139 ipc_call_t call;
140 int rc = 0;
141
142 callid = async_get_call(&call);
143 if (DEVMAN_ADD_MATCH_ID != IPC_GET_METHOD(call)) {
[38b3baf]144 printf(NAME ": ERROR: devman_receive_match_id - invalid "
145 "protocol.\n");
[66babbd]146 ipc_answer_0(callid, EINVAL);
147 delete_match_id(match_id);
148 return EINVAL;
149 }
150
[c6c389ed]151 if (match_id == NULL) {
[38b3baf]152 printf(NAME ": ERROR: devman_receive_match_id - failed to "
153 "allocate match id.\n");
[66babbd]154 ipc_answer_0(callid, ENOMEM);
155 return ENOMEM;
156 }
157
[2480e19]158 ipc_answer_0(callid, EOK);
159
[66babbd]160 match_id->score = IPC_GET_ARG1(call);
161
[c47e1a8]162 char *match_id_str;
[38b3baf]163 rc = async_data_write_accept((void **) &match_id_str, true, 0, 0, 0, 0);
[c47e1a8]164 match_id->id = match_id_str;
[c6c389ed]165 if (rc != EOK) {
[66babbd]166 delete_match_id(match_id);
[38b3baf]167 printf(NAME ": devman_receive_match_id - failed to receive "
168 "match id string.\n");
[66babbd]169 return rc;
170 }
171
172 list_append(&match_id->link, &match_ids->ids);
[a087f2e]173
[38b3baf]174 printf(NAME ": received match id '%s', score = %d \n",
175 match_id->id, match_id->score);
[66babbd]176 return rc;
177}
178
[38b3baf]179/** Receive device match IDs from the device's parent driver and add them to the
180 * list of devices match ids.
181 *
182 * @param match_count The number of device's match ids to be received.
183 * @param match_ids The list of the device's match ids.
184 * @return Zero on success, negative error code otherwise.
[3843ecb]185 */
[96b02eb9]186static int devman_receive_match_ids(sysarg_t match_count,
[c6c389ed]187 match_id_list_t *match_ids)
[38b3baf]188{
[66babbd]189 int ret = EOK;
[5cd136ab]190 size_t i;
[38b3baf]191
[66babbd]192 for (i = 0; i < match_count; i++) {
[38b3baf]193 if (EOK != (ret = devman_receive_match_id(match_ids)))
[66babbd]194 return ret;
195 }
196 return ret;
197}
198
[398c4d7]199static int assign_driver_fibril(void *arg)
200{
201 node_t *node = (node_t *) arg;
202 assign_driver(node, &drivers_list, &device_tree);
203 return EOK;
204}
205
[38b3baf]206/** Handle child device registration.
207 *
[3843ecb]208 * Child devices are registered by their parent's device driver.
209 */
210static void devman_add_child(ipc_callid_t callid, ipc_call_t *call)
[bda60d9]211{
[0b5a4131]212 devman_handle_t parent_handle = IPC_GET_ARG1(*call);
[96b02eb9]213 sysarg_t match_count = IPC_GET_ARG2(*call);
[957cfa58]214 dev_tree_t *tree = &device_tree;
[66babbd]215
[957cfa58]216 fibril_rwlock_write_lock(&tree->rwlock);
[c6c389ed]217 node_t *parent = find_dev_node_no_lock(&device_tree, parent_handle);
[d347b53]218
[c6c389ed]219 if (parent == NULL) {
[957cfa58]220 fibril_rwlock_write_unlock(&tree->rwlock);
[d347b53]221 ipc_answer_0(callid, ENOENT);
222 return;
[c6c389ed]223 }
[d347b53]224
225 char *dev_name = NULL;
[38b3baf]226 int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
[c6c389ed]227 if (rc != EOK) {
[957cfa58]228 fibril_rwlock_write_unlock(&tree->rwlock);
[d347b53]229 ipc_answer_0(callid, rc);
230 return;
231 }
232
233 node_t *node = create_dev_node();
234 if (!insert_dev_node(&device_tree, node, dev_name, parent)) {
[957cfa58]235 fibril_rwlock_write_unlock(&tree->rwlock);
[d347b53]236 delete_dev_node(node);
237 ipc_answer_0(callid, ENOMEM);
238 return;
[c6c389ed]239 }
240
[957cfa58]241 fibril_rwlock_write_unlock(&tree->rwlock);
[d347b53]242
[2480e19]243 printf(NAME ": devman_add_child %s\n", node->pathname);
244
[66babbd]245 devman_receive_match_ids(match_count, &node->match_ids);
[398c4d7]246
247 /*
[4006447]248 * Try to find a suitable driver and assign it to the device. We do
249 * not want to block the current fibril that is used for processing
250 * incoming calls: we will launch a separate fibril to handle the
251 * driver assigning. That is because assign_driver can actually include
252 * task spawning which could take some time.
[398c4d7]253 */
254 fid_t assign_fibril = fibril_create(assign_driver_fibril, node);
255 if (assign_fibril == 0) {
256 /*
257 * Fallback in case we are out of memory.
258 * Probably not needed as we will die soon anyway ;-).
259 */
260 (void) assign_driver_fibril(node);
261 } else {
262 fibril_add_ready(assign_fibril);
263 }
264
[38b3baf]265 /* Return device handle to parent's driver. */
[d347b53]266 ipc_answer_1(callid, EOK, node->handle);
267}
268
[ce89036b]269static void devmap_register_class_dev(dev_class_info_t *cli)
270{
[38b3baf]271 /* Create devmap path and name for the device. */
[ce89036b]272 char *devmap_pathname = NULL;
[c6c389ed]273
[38b3baf]274 asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE,
275 cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name);
[c6c389ed]276 if (devmap_pathname == NULL)
[ce89036b]277 return;
278
[38b3baf]279 /*
280 * Register the device by the device mapper and remember its devmap
281 * handle.
282 */
283 devmap_device_register(devmap_pathname, &cli->devmap_handle);
[ce89036b]284
[38b3baf]285 /*
286 * Add device to the hash map of class devices registered by device
287 * mapper.
288 */
[a32defa]289 class_add_devmap_device(&class_list, cli);
290
[38b3baf]291 free(devmap_pathname);
[ce89036b]292}
293
[692c40cb]294static void devman_add_device_to_class(ipc_callid_t callid, ipc_call_t *call)
[ce89036b]295{
[0b5a4131]296 devman_handle_t handle = IPC_GET_ARG1(*call);
[692c40cb]297
[38b3baf]298 /* Get class name. */
[692c40cb]299 char *class_name;
[38b3baf]300 int rc = async_data_write_accept((void **) &class_name, true,
301 0, 0, 0, 0);
[692c40cb]302 if (rc != EOK) {
303 ipc_answer_0(callid, rc);
304 return;
305 }
306
307 node_t *dev = find_dev_node(&device_tree, handle);
[c6c389ed]308 if (dev == NULL) {
[692c40cb]309 ipc_answer_0(callid, ENOENT);
310 return;
311 }
312
313 dev_class_t *cl = get_dev_class(&class_list, class_name);
314 dev_class_info_t *class_info = add_device_to_class(dev, cl, NULL);
315
[38b3baf]316 /* Register the device's class alias by devmapper. */
[ce89036b]317 devmap_register_class_dev(class_info);
[692c40cb]318
[38b3baf]319 printf(NAME ": device '%s' added to class '%s', class name '%s' was "
320 "asigned to it\n", dev->pathname, class_name, class_info->dev_name);
[398c4d7]321
[38b3baf]322 ipc_answer_0(callid, EOK);
[692c40cb]323}
324
[38b3baf]325/** Initialize driver which has registered itself as running and ready.
326 *
327 * The initialization is done in a separate fibril to avoid deadlocks (if the
328 * driver needed to be served by devman during the driver's initialization).
[3843ecb]329 */
[d347b53]330static int init_running_drv(void *drv)
331{
[38b3baf]332 driver_t *driver = (driver_t *) drv;
333
334 initialize_running_driver(driver, &device_tree);
335 printf(NAME ": the %s driver was successfully initialized. \n",
336 driver->name);
[d347b53]337 return 0;
[bda60d9]338}
339
[38b3baf]340/** Function for handling connections from a driver to the device manager. */
[924c75e1]341static void devman_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
[38b3baf]342{
343 /* Accept the connection. */
[e2b9a993]344 ipc_answer_0(iid, EOK);
345
[729fa2d6]346 driver_t *driver = devman_driver_register();
[c6c389ed]347 if (driver == NULL)
[729fa2d6]348 return;
[d347b53]349
[38b3baf]350 /*
351 * Initialize the driver as running (e.g. pass assigned devices to it)
352 * in a separate fibril; the separate fibril is used to enable the
353 * driver to use devman service during the driver's initialization.
354 */
[d347b53]355 fid_t fid = fibril_create(init_running_drv, driver);
356 if (fid == 0) {
[38b3baf]357 printf(NAME ": Error creating fibril for the initialization of "
358 "the newly registered running driver.\n");
[3843ecb]359 return;
[d347b53]360 }
361 fibril_add_ready(fid);
362
[729fa2d6]363 ipc_callid_t callid;
364 ipc_call_t call;
365 bool cont = true;
366 while (cont) {
[e2b9a993]367 callid = async_get_call(&call);
368
369 switch (IPC_GET_METHOD(call)) {
[729fa2d6]370 case IPC_M_PHONE_HUNGUP:
371 cont = false;
372 continue;
[e2b9a993]373 case DEVMAN_ADD_CHILD_DEVICE:
[3843ecb]374 devman_add_child(callid, &call);
[e2b9a993]375 break;
[692c40cb]376 case DEVMAN_ADD_DEVICE_TO_CLASS:
377 devman_add_device_to_class(callid, &call);
378 break;
[e2b9a993]379 default:
380 ipc_answer_0(callid, EINVAL);
381 break;
382 }
383 }
384}
385
[38b3baf]386/** Find handle for the device instance identified by the device's path in the
387 * device tree. */
[f658458]388static void devman_device_get_handle(ipc_callid_t iid, ipc_call_t *icall)
389{
[38b3baf]390 char *pathname;
391
392 int rc = async_data_write_accept((void **) &pathname, true, 0, 0, 0, 0);
[f658458]393 if (rc != EOK) {
394 ipc_answer_0(iid, rc);
395 return;
396 }
397
[38b3baf]398 node_t * dev = find_dev_node_by_path(&device_tree, pathname);
[f658458]399
400 free(pathname);
401
[c6c389ed]402 if (dev == NULL) {
[f658458]403 ipc_answer_0(iid, ENOENT);
404 return;
405 }
406
407 ipc_answer_1(iid, EOK, dev->handle);
408}
409
410
[38b3baf]411/** Function for handling connections from a client to the device manager. */
[f658458]412static void devman_connection_client(ipc_callid_t iid, ipc_call_t *icall)
413{
[38b3baf]414 /* Accept connection. */
[f658458]415 ipc_answer_0(iid, EOK);
416
417 bool cont = true;
418 while (cont) {
419 ipc_call_t call;
420 ipc_callid_t callid = async_get_call(&call);
421
422 switch (IPC_GET_METHOD(call)) {
423 case IPC_M_PHONE_HUNGUP:
424 cont = false;
425 continue;
426 case DEVMAN_DEVICE_GET_HANDLE:
427 devman_device_get_handle(callid, &call);
428 break;
429 default:
[cb819f9]430 ipc_answer_0(callid, ENOENT);
[f658458]431 }
[c6c389ed]432 }
[f658458]433}
434
[c6c389ed]435static void devman_forward(ipc_callid_t iid, ipc_call_t *icall,
436 bool drv_to_parent)
[38b3baf]437{
[0b5a4131]438 devman_handle_t handle = IPC_GET_ARG2(*icall);
[9a66bc2e]439
[5cd136ab]440 node_t *dev = find_dev_node(&device_tree, handle);
[c6c389ed]441 if (dev == NULL) {
[7e752b2]442 printf(NAME ": devman_forward error - no device with handle %" PRIun
443 " was found.\n", handle);
[5cd136ab]444 ipc_answer_0(iid, ENOENT);
445 return;
446 }
447
448 driver_t *driver = NULL;
449
450 if (drv_to_parent) {
[c6c389ed]451 if (dev->parent != NULL)
[38b3baf]452 driver = dev->parent->drv;
[c6c389ed]453 } else if (dev->state == DEVICE_USABLE) {
[38b3baf]454 driver = dev->drv;
[c6c389ed]455 assert(driver != NULL);
[5cd136ab]456 }
457
[c6c389ed]458 if (driver == NULL) {
[7e752b2]459 printf(NAME ": devman_forward error - the device is not in %" PRIun
460 " usable state.\n", handle);
[5cd136ab]461 ipc_answer_0(iid, ENOENT);
[38b3baf]462 return;
[5cd136ab]463 }
464
[38b3baf]465 int method;
466 if (drv_to_parent)
[5cd136ab]467 method = DRIVER_DRIVER;
[38b3baf]468 else
[5cd136ab]469 method = DRIVER_CLIENT;
470
[9a66bc2e]471 if (driver->phone <= 0) {
[38b3baf]472 printf(NAME ": devman_forward: cound not forward to driver %s ",
473 driver->name);
[7e752b2]474 printf("the driver's phone is %" PRIun ").\n", driver->phone);
[ce89036b]475 ipc_answer_0(iid, EINVAL);
[9a66bc2e]476 return;
477 }
[c6c389ed]478
[38b3baf]479 printf(NAME ": devman_forward: forward connection to device %s to "
480 "driver %s.\n", dev->pathname, driver->name);
481 ipc_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);
[5cd136ab]482}
483
[38b3baf]484/** Function for handling connections from a client forwarded by the device
485 * mapper to the device manager. */
[ce89036b]486static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall)
487{
[991f645]488 devmap_handle_t devmap_handle = IPC_GET_METHOD(*icall);
[c6c389ed]489 node_t *dev;
490
491 dev = find_devmap_tree_device(&device_tree, devmap_handle);
492 if (dev == NULL)
[ce89036b]493 dev = find_devmap_class_device(&class_list, devmap_handle);
494
[c6c389ed]495 if (dev == NULL || dev->drv == NULL) {
[ce89036b]496 ipc_answer_0(iid, ENOENT);
497 return;
498 }
499
[c6c389ed]500 if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
[ce89036b]501 ipc_answer_0(iid, EINVAL);
502 return;
503 }
504
[38b3baf]505 printf(NAME ": devman_connection_devmapper: forward connection to "
506 "device %s to driver %s.\n", dev->pathname, dev->drv->name);
507 ipc_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, dev->handle, 0,
508 IPC_FF_NONE);
[ce89036b]509}
510
[38b3baf]511/** Function for handling connections to device manager. */
[924c75e1]512static void devman_connection(ipc_callid_t iid, ipc_call_t *icall)
[38b3baf]513{
514 /*
515 * Silly hack to enable the device manager to register as a driver by
516 * the device mapper. If the ipc method is not IPC_M_CONNECT_ME_TO, this
517 * is not the forwarded connection from naming service, so it must be a
518 * connection from the devmapper which thinks this is a devmapper-style
519 * driver. So pretend this is a devmapper-style driver. (This does not
520 * work for device with handle == IPC_M_CONNECT_ME_TO, because devmapper
521 * passes device handle to the driver as an ipc method.)
522 */
[c6c389ed]523 if (IPC_GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO)
[ce89036b]524 devman_connection_devmapper(iid, icall);
525
[38b3baf]526 /*
527 * ipc method is IPC_M_CONNECT_ME_TO, so this is forwarded connection
528 * from naming service by which we registered as device manager, so be
529 * device manager.
530 */
[ce89036b]531
[38b3baf]532 /* Select interface. */
[96b02eb9]533 switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
[924c75e1]534 case DEVMAN_DRIVER:
535 devman_connection_driver(iid, icall);
536 break;
[f658458]537 case DEVMAN_CLIENT:
538 devman_connection_client(iid, icall);
539 break;
[924c75e1]540 case DEVMAN_CONNECT_TO_DEVICE:
[38b3baf]541 /* Connect client to selected device. */
[5cd136ab]542 devman_forward(iid, icall, false);
543 break;
544 case DEVMAN_CONNECT_TO_PARENTS_DEVICE:
[38b3baf]545 /* Connect client to selected device. */
[5cd136ab]546 devman_forward(iid, icall, true);
[38b3baf]547 break;
[924c75e1]548 default:
549 /* No such interface */
550 ipc_answer_0(iid, ENOENT);
551 }
552}
553
[38b3baf]554/** Initialize device manager internal structures. */
555static bool devman_init(void)
[e2b9a993]556{
[38b3baf]557 printf(NAME ": devman_init - looking for available drivers.\n");
[08d9c4e6]558
[38b3baf]559 /* Initialize list of available drivers. */
[0c3666d]560 init_driver_list(&drivers_list);
[c6c389ed]561 if (lookup_available_drivers(&drivers_list,
562 DRIVER_DEFAULT_STORE) == 0) {
[e2b9a993]563 printf(NAME " no drivers found.");
564 return false;
565 }
[c6c389ed]566
[38b3baf]567 printf(NAME ": devman_init - list of drivers has been initialized.\n");
[e2b9a993]568
[38b3baf]569 /* Create root device node. */
[e2b9a993]570 if (!init_device_tree(&device_tree, &drivers_list)) {
571 printf(NAME " failed to initialize device tree.");
[38b3baf]572 return false;
[e2b9a993]573 }
574
[692c40cb]575 init_class_list(&class_list);
576
[38b3baf]577 /*
578 * !!! devman_connection ... as the device manager is not a real devmap
579 * driver (it uses a completely different ipc protocol than an ordinary
580 * devmap driver) forwarding a connection from client to the devman by
581 * devmapper would not work.
582 */
583 devmap_driver_register(NAME, devman_connection);
[ce89036b]584
[e2b9a993]585 return true;
586}
587
588int main(int argc, char *argv[])
589{
590 printf(NAME ": HelenOS Device Manager\n");
591
592 if (!devman_init()) {
593 printf(NAME ": Error while initializing service\n");
594 return -1;
595 }
596
[38b3baf]597 /* Set a handler of incomming connections. */
[e2b9a993]598 async_set_client_connection(devman_connection);
599
[38b3baf]600 /* Register device manager at naming service. */
[96b02eb9]601 sysarg_t phonead;
[e2b9a993]602 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, &phonead) != 0)
603 return -1;
604
605 printf(NAME ": Accepting connections\n");
606 async_manager();
607
[38b3baf]608 /* Never reached. */
[e2b9a993]609 return 0;
610}
[c16cf62]611
612/** @}
[38b3baf]613 */
Note: See TracBrowser for help on using the repository browser.