Changeset f9b2cb4c in mainline for uspace/lib/drv/generic/driver.c


Ignore:
Timestamp:
2015-08-23T12:50:23Z (9 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9ef495f
Parents:
0dd16778
Message:

unify interface API

  • introduce new interfaces
  • unify location service clients to always expect service ID as the second argument
  • remove obsolete methods that take explicit exchange management arguments (first phase)
  • use interfaces in device drivers, devman, location service, logger, inet
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/driver.c

    r0dd16778 rf9b2cb4c  
    5353#include <devman.h>
    5454
    55 #include <ipc/driver.h>
    56 
    5755#include "dev_iface.h"
    5856#include "ddf/driver.h"
     
    130128       
    131129        char *dev_name = NULL;
    132         async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
     130        int rc = async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
     131        if (rc != EOK) {
     132                async_answer_0(iid, rc);
     133                return;
     134        }
     135       
    133136        dev->name = dev_name;
    134137       
     
    278281}
    279282
    280 static void driver_connection_devman(ipc_callid_t iid, ipc_call_t *icall)
     283static void driver_connection_devman(ipc_callid_t iid, ipc_call_t *icall,
     284    void *arg)
    281285{
    282286        /* Accept connection */
     
    436440}
    437441
    438 static void driver_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
     442static void driver_connection_driver(ipc_callid_t iid, ipc_call_t *icall,
     443    void *arg)
    439444{
    440445        driver_connection_gen(iid, icall, true);
    441446}
    442447
    443 static void driver_connection_client(ipc_callid_t iid, ipc_call_t *icall)
     448static void driver_connection_client(ipc_callid_t iid, ipc_call_t *icall,
     449    void *arg)
    444450{
    445451        driver_connection_gen(iid, icall, false);
    446 }
    447 
    448 /** Function for handling connections to device driver. */
    449 static void driver_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    450 {
    451         sysarg_t conn_type;
    452 
    453         if (iid == 0) {
    454                 /* Callback connection from devman */
    455                 /* XXX Use separate handler for this type of connection */
    456                 conn_type = DRIVER_DEVMAN;
    457         } else {
    458                 conn_type = IPC_GET_ARG1(*icall);
    459         }
    460 
    461         /* Select interface */
    462         switch (conn_type) {
    463         case DRIVER_DEVMAN:
    464                 /* Handle request from device manager */
    465                 driver_connection_devman(iid, icall);
    466                 break;
    467         case DRIVER_DRIVER:
    468                 /* Handle request from drivers of child devices */
    469                 driver_connection_driver(iid, icall);
    470                 break;
    471         case DRIVER_CLIENT:
    472                 /* Handle request from client applications */
    473                 driver_connection_client(iid, icall);
    474                 break;
    475         default:
    476                 /* No such interface */
    477                 async_answer_0(iid, ENOENT);
    478         }
    479452}
    480453
     
    620593 * The session will be automatically closed when @a dev is destroyed.
    621594 *
    622  * @param dev   Device
    623  * @param mgmt  Exchange management style
    624  * @return      New session or NULL if session could not be created
    625  */
    626 async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev, exch_mgmt_t mgmt)
     595 * @param dev Device
     596 *
     597 * @return New session or NULL if session could not be created
     598 *
     599 */
     600async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev)
    627601{
    628602        assert(dev->parent_sess == NULL);
    629         dev->parent_sess = devman_parent_device_connect(mgmt, dev->handle,
     603        dev->parent_sess = devman_parent_device_connect(dev->handle,
    630604            IPC_FLAG_BLOCKING);
    631605
     
    955929         * incoming connections.
    956930         */
    957         async_set_fallback_port_handler(driver_connection, NULL);
    958         int rc = devman_driver_register(driver->name);
     931        port_id_t port;
     932        int rc = async_create_port(INTERFACE_DDF_DRIVER, driver_connection_driver,
     933            NULL, &port);
     934        if (rc != EOK)
     935                return rc;
     936       
     937        rc = async_create_port(INTERFACE_DDF_DEVMAN, driver_connection_devman,
     938            NULL, &port);
     939        if (rc != EOK)
     940                return rc;
     941       
     942        async_set_fallback_port_handler(driver_connection_client, NULL);
     943       
     944        rc = devman_driver_register(driver->name);
    959945        if (rc != EOK) {
    960946                printf("Error: Failed to register driver with device manager "
Note: See TracChangeset for help on using the changeset viewer.