Changeset 79ae36dd in mainline for uspace/srv/devman/devman.c


Ignore:
Timestamp:
2011-06-08T19:01:55Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0eff68e
Parents:
764d71e
Message:

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
File:
1 edited

Legend:

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

    r764d71e r79ae36dd  
    564564        dev_node_t *dev;
    565565        link_t *link;
    566         int phone;
    567566
    568567        log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")",
     
    570569
    571570        fibril_mutex_lock(&driver->driver_mutex);
    572 
    573         phone = async_connect_me_to(driver->phone, DRIVER_DEVMAN, 0, 0);
    574 
    575         if (phone < 0) {
     571       
     572        async_exch_t *exch = async_exchange_begin(driver->sess);
     573        async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch,
     574            DRIVER_DEVMAN, 0, 0);
     575        async_exchange_end(exch);
     576
     577        if (!sess) {
    576578                fibril_mutex_unlock(&driver->driver_mutex);
    577579                return;
     
    602604                fibril_mutex_unlock(&driver->driver_mutex);
    603605
    604                 add_device(phone, driver, dev, tree);
     606                add_device(sess, driver, dev, tree);
    605607
    606608                /*
     
    623625        }
    624626
    625         async_hangup(phone);
     627        async_hangup(sess);
    626628
    627629        /*
     
    673675        list_initialize(&drv->devices);
    674676        fibril_mutex_initialize(&drv->driver_mutex);
    675         drv->phone = -1;
     677        drv->sess = NULL;
    676678}
    677679
     
    737739 * @param node          The device's node in the device tree.
    738740 */
    739 void add_device(int phone, driver_t *drv, dev_node_t *dev, dev_tree_t *tree)
     741void add_device(async_sess_t *sess, driver_t *drv, dev_node_t *dev,
     742    dev_tree_t *tree)
    740743{
    741744        /*
     
    746749            drv->name, dev->pfun->name);
    747750       
    748         sysarg_t rc;
    749         ipc_call_t answer;
    750        
    751751        /* Send the device to the driver. */
    752752        devman_handle_t parent_handle;
     
    756756                parent_handle = 0;
    757757        }
    758 
    759         aid_t req = async_send_2(phone, DRIVER_ADD_DEVICE, dev->handle,
     758       
     759        async_exch_t *exch = async_exchange_begin(sess);
     760       
     761        ipc_call_t answer;
     762        aid_t req = async_send_2(exch, DRIVER_ADD_DEVICE, dev->handle,
    760763            parent_handle, &answer);
    761764       
    762         /* Send the device's name to the driver. */
    763         rc = async_data_write_start(phone, dev->pfun->name,
     765        /* Send the device name to the driver. */
     766        sysarg_t rc = async_data_write_start(exch, dev->pfun->name,
    764767            str_size(dev->pfun->name) + 1);
     768       
     769        async_exchange_end(exch);
     770       
    765771        if (rc != EOK) {
    766772                /* TODO handle error */
     
    823829        if (is_running) {
    824830                /* Notify the driver about the new device. */
    825                 int phone = async_connect_me_to(drv->phone, DRIVER_DEVMAN, 0, 0);
    826                 if (phone >= 0) {
    827                         add_device(phone, drv, dev, tree);
    828                         async_hangup(phone);
     831                async_exch_t *exch = async_exchange_begin(drv->sess);
     832                async_sess_t *sess = async_connect_me_to(EXCHANGE_SERIALIZE, exch,
     833                    DRIVER_DEVMAN, 0, 0);
     834                async_exchange_end(exch);
     835               
     836                if (sess) {
     837                        add_device(sess, drv, dev, tree);
     838                        async_hangup(sess);
    829839                }
    830840        }
Note: See TracChangeset for help on using the changeset viewer.