Changeset 084ff99 in mainline for uspace/lib/libdrv/generic/driver.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/lib/libdrv/generic/driver.c

    r67ba309 r084ff99  
    5050#include <devman.h>
    5151#include <ipc/devman.h>
     52#include <ipc/driver.h>
    5253
    5354#include "driver.h"
    5455
    5556static driver_t *driver;
     57LIST_INITIALIZE(devices);
     58
     59static device_t* driver_create_device()
     60{
     61        device_t *dev = (device_t *)malloc(sizeof(device_t));
     62        if (NULL != dev) {
     63                memset(dev, 0, sizeof(device_t));               
     64        }       
     65        return dev;     
     66}
     67
     68static void driver_add_device(ipc_callid_t iid, ipc_call_t *icall)
     69{
     70        printf("%s: driver_add_device\n", driver->name);
     71       
     72        // result of the operation - device was added, device is not present etc.
     73        ipcarg_t ret = 0;       
     74        ipcarg_t dev_handle =  IPC_GET_ARG1(*icall);
     75       
     76        printf("%s: adding device with handle = %x \n", driver->name, dev_handle);
     77       
     78        device_t *dev = driver_create_device();
     79        dev->handle = dev_handle;
     80        if (driver->driver_ops->add_device(dev)) {
     81                list_append(&dev->link, &devices);
     82                // TODO set return value
     83        }
     84       
     85        ipc_answer_1(iid, EOK, ret);
     86}
    5687
    5788static void driver_connection_devman(ipc_callid_t iid, ipc_call_t *icall)
    5889{
     90        printf("%s: driver_connection_devman \n", driver->name);
     91       
    5992        /* Accept connection */
    6093        ipc_answer_0(iid, EOK);
     
    70103                        continue;
    71104                case DRIVER_ADD_DEVICE:
    72                         // TODO
     105                        driver_add_device(callid, &call);
    73106                        break;
    74107                default:
Note: See TracChangeset for help on using the changeset viewer.