Changeset d347b53 in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2010-03-21T19:33:58Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
66babbd
Parents:
bda60d9
Message:

child device registration - parts of code

File:
1 edited

Legend:

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

    rbda60d9 rd347b53  
    5151#include <ctype.h>
    5252#include <ipc/devman.h>
     53#include <thread.h>
    5354
    5455#include "devman.h"
     
    9697                return NULL;
    9798        }
    98         printf(NAME ": registering the running instance of the %s driver.\n", driver->name);
    9999       
    100100        // Create connection to the driver
     
    123123{
    124124        printf(NAME ": devman_add_child\n");
    125        
    126         // TODO
    127        
     125
     126        device_handle_t parent_handle = IPC_GET_ARG1(*call);
     127        node_t *parent =  find_dev_node(&device_tree, parent_handle);
     128       
     129        if (NULL == parent) {
     130                ipc_answer_0(callid, ENOENT);
     131                return;
     132        }
     133       
     134        char *dev_name = NULL;
     135        int rc = async_string_receive(&dev_name, DEVMAN_NAME_MAXLEN, NULL);     
     136        if (rc != EOK) {
     137                ipc_answer_0(callid, rc);
     138                return;
     139        }
     140        printf(NAME ": newly added child device's name is '%s'.\n", dev_name);
     141       
     142        node_t *node = create_dev_node();
     143        if (!insert_dev_node(&device_tree, node, dev_name, parent)) {
     144                delete_dev_node(node);
     145                ipc_answer_0(callid, ENOMEM);
     146                return;
     147        }       
     148       
     149        // TODO match ids
     150       
     151        // return device handle to parent's driver
     152        ipc_answer_1(callid, EOK, node->handle);
     153       
     154        // try to find suitable driver and assign it to the device     
     155        assign_driver(node, &drivers_list);
     156}
     157
     158static int init_running_drv(void *drv)
     159{
     160        driver_t *driver = (driver_t *)drv;
     161        initialize_running_driver(driver);     
     162        printf(NAME ": the %s driver was successfully initialized. \n", driver->name);
     163        return 0;
    128164}
    129165
     
    137173       
    138174        driver_t *driver = devman_driver_register();
    139         if (driver == NULL)
    140                 return;
    141                
    142         initialize_running_driver(driver);
     175        if (NULL == driver)
     176                return;
     177       
     178        fid_t fid = fibril_create(init_running_drv, driver);
     179        if (fid == 0) {
     180                printf(NAME ": Error creating fibril for the initialization of the newly registered running driver.\n");
     181                exit(1);
     182        }
     183        fibril_add_ready(fid);
     184       
     185        /*thread_id_t tid;
     186        if (0 != thread_create(init_running_drv, driver, "init_running_drv", &tid)) {
     187                printf(NAME ": failed to start the initialization of the newly registered running driver.\n");
     188        }*/
    143189       
    144190        ipc_callid_t callid;
Note: See TracChangeset for help on using the changeset viewer.