Changeset 084ff99 in mainline for uspace/srv/devman/devman.c


Ignore:
Timestamp:
2010-03-14T09:14:50Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7707954
Parents:
67ba309
Message:

passing device to driver (parts of code)

File:
1 edited

Legend:

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

    r67ba309 r084ff99  
    3434#include <fcntl.h>
    3535#include <sys/stat.h>
     36#include <ipc/driver.h>
     37#include <ipc/devman.h>
    3638
    3739#include "devman.h"
     
    308310}
    309311
    310 /** Create root device node of the device tree.
    311  *
    312  * @return root device node.
    313  */
    314 node_t * create_root_node()
     312/** Create root device node in the device tree.
     313 *
     314 * @param tree the device tree.
     315 * @return true on success, false otherwise.
     316 */
     317bool create_root_node(dev_tree_t *tree)
    315318{
    316319        printf(NAME ": create_root_node\n");
    317320        node_t *node = create_dev_node();
    318321        if (node) {
    319                 init_dev_node(node, NULL);
     322                insert_dev_node(tree, node, NULL);
    320323                match_id_t *id = create_match_id();
    321324                id->id = "root";
    322325                id->score = 100;
    323326                add_match_id(&node->match_ids, id);
    324         }
    325         return node;   
     327                tree->root_node = node;
     328        }
     329        return node != NULL;   
    326330}
    327331
     
    448452        link_t *link;
    449453       
    450         link = driver->devices.next;
    451         while (link != &driver->devices) {
    452                 dev = list_get_instance(link, node_t, driver_devices);
    453                 add_device(driver, dev);
    454                 link = link->next;
    455         }       
     454        int phone = ipc_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0);
     455       
     456        if (0 < phone) {
     457               
     458                link = driver->devices.next;
     459                while (link != &driver->devices) {
     460                        dev = list_get_instance(link, node_t, driver_devices);
     461                        add_device(phone, driver, dev);
     462                        link = link->next;
     463                }
     464               
     465                ipc_hangup(phone);
     466        }
    456467}
    457468
     
    463474 */
    464475void initialize_running_driver(driver_t *driver)
    465 {
     476{       
    466477        fibril_mutex_lock(&driver->driver_mutex);
    467478       
     
    480491 * @param node the device's node in the device tree.
    481492 */
    482 void add_device(driver_t *drv, node_t *node)
     493void add_device(int phone, driver_t *drv, node_t *node)
    483494{
    484495        printf(NAME ": add_device\n");
    485        
    486         // TODO
    487        
    488         // pass a new device to the running driver, which was previously assigned to it
    489                 // send the phone of the parent's driver and device's handle within the parent's driver to the driver
    490                 // let the driver to probe the device and specify whether the device is actually present
    491                 // if the device is present, remember its handle within the driver
     496
     497        ipcarg_t ret;
     498        ipcarg_t rc = async_req_1_1(phone, DRIVER_ADD_DEVICE, node->handle, &ret);
     499        if (rc != EOK) {
     500                // TODO handle error
     501                return false;
     502        }
     503       
     504        // TODO inspect return value (ret) to find out whether the device was successfully probed and added
    492505       
    493506        return true;
    494507}
    495508
    496 /**
     509/** 
    497510 * Find suitable driver for a device and assign the driver to it.
    498511 *
     
    523536        if (DRIVER_RUNNING == drv->state) {
    524537                // notify driver about new device
    525                 add_device(drv, node);         
     538                int phone = ipc_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0);
     539                if (phone > 0) {
     540                        add_device(phone, drv, node);           
     541                        ipc_hangup(phone);
     542                }
    526543        }
    527544       
     
    542559        printf(NAME ": init_device_tree.\n");
    543560       
     561        atomic_set(&tree->current_handle, 0);
     562       
    544563        // create root node and add it to the device tree
    545         if (NULL == (tree->root_node = create_root_node())) {
     564        if (!create_root_node(tree)) {
    546565                return false;
    547566        }
Note: See TracChangeset for help on using the changeset viewer.