Changeset 729fa2d6 in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2010-02-25T14:29:23Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
92413de
Parents:
924c75e1
Message:

parts of root device driver

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/main.c

    r924c75e1 r729fa2d6  
    5959static dev_tree_t device_tree;
    6060
     61/**
     62 *
     63 *
     64 * Driver's mutex must be locked.
     65 */
     66static void pass_devices_to_driver(driver_t *driver)
     67{
     68       
     69
     70       
     71       
     72}
     73
     74static void init_running_driver(driver_t *driver)
     75{
     76        fibril_mutex_lock(&driver->driver_mutex);
     77       
     78        // pass devices which have been already assigned to the driver to the driver
     79        pass_devices_to_driver(driver);
     80       
     81        // change driver's state to running
     82        driver->state = DRIVER_RUNNING;
     83       
     84        fibril_mutex_unlock(&driver->driver_mutex);
     85}
     86
     87/**
     88 * Register running driver.
     89 */
     90static driver_t * devman_driver_register(void)
     91{       
     92        printf(NAME ": devman_driver_register \n");
     93       
     94        ipc_call_t icall;
     95        ipc_callid_t iid = async_get_call(&icall);
     96        driver_t *driver = NULL;
     97       
     98        if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) {
     99                ipc_answer_0(iid, EREFUSED);
     100                return NULL;
     101        }
     102       
     103        char drv_name[DEVMAN_NAME_MAXLEN];
     104       
     105        // Get driver name
     106        int rc = async_string_receive(drv_name, DEVMAN_NAME_MAXLEN, NULL);     
     107        if (rc != EOK) {
     108                ipc_answer_0(iid, rc);
     109                return NULL;
     110        }
     111        printf(NAME ": the %s driver is trying to register by the service.\n", drv_name);
     112       
     113        // Find driver structure
     114        driver = find_driver(&drivers_list, drv_name);
     115        if (NULL == driver) {
     116                printf(NAME ": no driver named %s was found.\n", drv_name);
     117                ipc_answer_0(iid, ENOENT);
     118                return NULL;
     119        }
     120        printf(NAME ": registering the running instance of the %s driver.\n", driver->name);
     121       
     122        // Create connection to the driver
     123        printf(NAME ":  creating connection to the %s driver.\n", driver->name);       
     124        ipc_call_t call;
     125        ipc_callid_t callid = async_get_call(&call);           
     126        if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) {
     127                ipc_answer_0(callid, ENOTSUP);
     128                ipc_answer_0(iid, ENOTSUP);
     129                return NULL;
     130        }
     131       
     132        fibril_mutex_lock(&driver->driver_mutex);
     133        assert(DRIVER_STARTING == driver->state);
     134        driver->phone = IPC_GET_ARG5(call);     
     135        fibril_mutex_unlock(&driver->driver_mutex);     
     136       
     137        printf(NAME ":  the %s driver was successfully registered as running.\n", driver->name);
     138       
     139        ipc_answer_0(callid, EOK);     
     140       
     141        ipc_answer_0(iid, EOK);
     142       
     143        return driver;
     144}
    61145
    62146/** Function for handling connections to device manager.
     
    64148 */
    65149static void devman_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
    66 {
     150{       
     151        /* Accept the connection */
     152        ipc_answer_0(iid, EOK);
     153       
     154        driver_t *driver = devman_driver_register();
     155        if (driver == NULL)
     156                return;
     157               
     158        init_running_driver(driver);
     159       
    67160        ipc_callid_t callid;
    68161        ipc_call_t call;
    69        
    70         /* Accept the connection */
    71         ipc_answer_0(iid, EOK);
    72        
    73         while (1) {
     162        bool cont = true;
     163        while (cont) {
    74164                callid = async_get_call(&call);
    75165               
    76166                switch (IPC_GET_METHOD(call)) {
    77                 case DEVMAN_DRIVER_REGISTER:
    78                         // TODO register running driver instance - remember driver's phone and lookup devices to which it has been assigned
    79                         break;
     167                case IPC_M_PHONE_HUNGUP:
     168                        cont = false;
     169                        continue;
    80170                case DEVMAN_ADD_CHILD_DEVICE:
    81171                        // TODO add new device node to the device tree
Note: See TracChangeset for help on using the changeset viewer.