Changeset 66babbd in mainline for uspace/srv


Ignore:
Timestamp:
2010-03-25T09:55:09Z (15 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a087f2e
Parents:
d347b53
Message:

child device registration - match ids

Location:
uspace/srv
Files:
2 edited

Legend:

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

    rd347b53 r66babbd  
    120120}
    121121
     122static int devman_receive_match_id(match_id_list_t *match_ids) {
     123       
     124        match_id_t *match_id = create_match_id();
     125        ipc_callid_t callid;
     126        ipc_call_t call;
     127        int rc = 0;
     128       
     129        callid = async_get_call(&call);
     130        if (DEVMAN_ADD_MATCH_ID != IPC_GET_METHOD(call)) {
     131                printf(NAME ": ERROR: devman_receive_match_id - invalid protocol.\n");
     132                ipc_answer_0(callid, EINVAL);
     133                delete_match_id(match_id);
     134                return EINVAL;
     135        }
     136       
     137        if (NULL == match_id) {
     138                printf(NAME ": ERROR: devman_receive_match_id - failed to allocate match id.\n");
     139                ipc_answer_0(callid, ENOMEM);
     140                return ENOMEM;
     141        }
     142       
     143        match_id->score = IPC_GET_ARG1(call);
     144       
     145        rc = async_string_receive(&match_id->id, DEVMAN_NAME_MAXLEN, NULL);     
     146        if (EOK != rc) {
     147                delete_match_id(match_id);
     148                return rc;
     149        }
     150       
     151        list_append(&match_id->link, &match_ids->ids);
     152        return rc;
     153}
     154
     155static int devman_receive_match_ids(ipcarg_t match_count, match_id_list_t *match_ids)
     156{
     157        int ret = EOK;
     158        int i;
     159        for (i = 0; i < match_count; i++) {
     160                if (EOK != (ret = devman_receive_match_id(match_ids))) {
     161                        return ret;
     162                }
     163        }
     164        return ret;
     165}
     166
    122167static void devman_add_child(ipc_callid_t callid, ipc_call_t *call, driver_t *driver)
    123168{
    124169        printf(NAME ": devman_add_child\n");
    125 
     170       
    126171        device_handle_t parent_handle = IPC_GET_ARG1(*call);
     172        ipcarg_t match_count = IPC_GET_ARG2(*call);
     173       
    127174        node_t *parent =  find_dev_node(&device_tree, parent_handle);
    128175       
     
    130177                ipc_answer_0(callid, ENOENT);
    131178                return;
    132         }
     179        }       
    133180       
    134181        char *dev_name = NULL;
    135182        int rc = async_string_receive(&dev_name, DEVMAN_NAME_MAXLEN, NULL);     
    136         if (rc != EOK) {
     183        if (EOK != rc) {
    137184                ipc_answer_0(callid, rc);
    138185                return;
     
    147194        }       
    148195       
    149         // TODO match ids
     196        devman_receive_match_ids(match_count, &node->match_ids);
    150197       
    151198        // return device handle to parent's driver
  • uspace/srv/drivers/root/root.c

    rd347b53 r66babbd  
    5555static bool root_init();
    5656
     57/** The root device driver's standard operations.
     58 */
    5759static driver_ops_t root_ops = {
    5860        .add_device = &root_add_device
    5961};
    6062
     63/** The root device driver structure.
     64 */
    6165static driver_t root_driver = {
    6266        .name = NAME,
     
    6468};
    6569
     70/** Create the device which represents the root of HW device tree.
     71 * @param parent parent of the newly created device.
     72 */
    6673static bool add_platform_child(device_t *parent) {
    6774        printf(NAME ": adding new child for platform device.\n");
     
    107114}
    108115
     116/** Get the root device.
     117 * @param dev the device which is root of the whole device tree (both of HW and pseudo devices).
     118 */
    109119static bool root_add_device(device_t *dev)
    110120{
Note: See TracChangeset for help on using the changeset viewer.