Changeset 692c40cb in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2010-05-28T09:04:37Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5159ae9
Parents:
c9f3b45c
Message:

Introduce device classes.Device class specifies functional type of the device. Device classes are identified by their string names (actually device class is just a string value). Device classes can be dynamically added. A device can be added to any number of classes.

File:
1 edited

Legend:

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

    rc9f3b45c r692c40cb  
    6060static driver_list_t drivers_list;
    6161static dev_tree_t device_tree;
     62static class_list_t class_list;
    6263
    6364
     
    240241        // try to find suitable driver and assign it to the device     
    241242        assign_driver(node, &drivers_list);     
     243}
     244
     245static void devman_add_device_to_class(ipc_callid_t callid, ipc_call_t *call)
     246{               
     247        device_handle_t handle = IPC_GET_ARG1(*call);
     248       
     249        // Get class name
     250        char *class_name;
     251        int rc = async_data_write_accept((void **)&class_name, true, 0, 0, 0, 0);
     252        if (rc != EOK) {
     253                ipc_answer_0(callid, rc);
     254                return;
     255        }       
     256       
     257        node_t *dev = find_dev_node(&device_tree, handle);
     258        if (NULL == dev) {
     259                ipc_answer_0(callid, ENOENT);
     260                return;
     261        }
     262       
     263        dev_class_t *cl = get_dev_class(&class_list, class_name);
     264       
     265        dev_class_info_t *class_info = add_device_to_class(dev, cl, NULL);
     266       
     267        // TODO register the device's class alias by devmapper
     268       
     269        printf(NAME ": device '%s' added to class '%s', class name '%s' was asigned to it\n", dev->pathname, class_name, class_info->dev_name);
     270       
     271        ipc_answer_0(callid, EOK);     
    242272}
    243273
     
    294324                case DEVMAN_ADD_CHILD_DEVICE:
    295325                        devman_add_child(callid, &call);
     326                        break;
     327                case DEVMAN_ADD_DEVICE_TO_CLASS:
     328                        devman_add_device_to_class(callid, &call);
    296329                        break;
    297330                default:
     
    444477        }
    445478
     479        init_class_list(&class_list);
     480       
    446481        return true;
    447482}
Note: See TracChangeset for help on using the changeset viewer.