Changeset f9b2cb4c in mainline for uspace/lib/drv/generic


Ignore:
Timestamp:
2015-08-23T12:50:23Z (10 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
Location:
uspace/lib/drv/generic
Files:
4 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 "
  • uspace/lib/drv/generic/remote_ahci.c

    r0dd16778 rf9b2cb4c  
    7272       
    7373        if ((devn_size > 5) && (str_lcmp(devn, "ahci_", 5) == 0)) {
    74                 async_sess_t *sess = devman_device_connect(EXCHANGE_PARALLEL,
    75                     funh, IPC_FLAG_BLOCKING);
     74                async_sess_t *sess = devman_device_connect(funh, IPC_FLAG_BLOCKING);
    7675               
    7776                if (sess) {
  • uspace/lib/drv/generic/remote_audio_pcm.c

    r0dd16778 rf9b2cb4c  
    146146        if (ret != EOK)
    147147                return NULL;
    148         return devman_device_connect(EXCHANGE_SERIALIZE, device_handle,
    149             IPC_FLAG_BLOCKING);
     148        return devman_device_connect(device_handle, IPC_FLAG_BLOCKING);
    150149}
    151150
     
    158157audio_pcm_sess_t *audio_pcm_open_service(service_id_t id)
    159158{
    160         return loc_service_connect(EXCHANGE_SERIALIZE, id, IPC_FLAG_BLOCKING);
     159        return loc_service_connect(id, INTERFACE_DDF, IPC_FLAG_BLOCKING);
    161160}
    162161
     
    322321
    323322        async_exch_t *exch = async_exchange_begin(sess);
     323       
    324324        int ret = async_req_1_0(exch, DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
    325325            IPC_M_AUDIO_PCM_REGISTER_EVENTS);
    326326        if (ret == EOK) {
    327                 ret = async_connect_to_me(exch, 0, 0, 0, event_callback, arg);
    328         }
     327                port_id_t port;
     328                ret = async_create_callback_port(exch, INTERFACE_AUDIO_PCM_CB, 0, 0,
     329                    event_callback, arg, &port);
     330        }
     331       
    329332        async_exchange_end(exch);
    330333        return ret;
  • uspace/lib/drv/generic/remote_nic.c

    r0dd16778 rf9b2cb4c  
    137137            NIC_CALLBACK_CREATE, &answer);
    138138       
    139         rc = async_connect_to_me(exch, 0, 0, 0, cfun, carg);
     139        port_id_t port;
     140        rc = async_create_callback_port(exch, INTERFACE_NIC_CB, 0, 0,
     141            cfun, carg, &port);
    140142        if (rc != EOK) {
    141143                async_forget(req);
Note: See TracChangeset for help on using the changeset viewer.