Changeset b5e68c8 in mainline for uspace/lib/c/generic/devmap.c


Ignore:
Timestamp:
2011-05-12T16:49:44Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f36787d7
Parents:
e80329d6 (diff), 750636a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/devmap.c

    re80329d6 rb5e68c8  
    2929
    3030#include <str.h>
    31 #include <ipc/ipc.h>
    3231#include <ipc/services.h>
     32#include <ipc/ns.h>
    3333#include <ipc/devmap.h>
    3434#include <devmap.h>
     
    5050               
    5151                if (flags & IPC_FLAG_BLOCKING)
    52                         devmap_phone_driver = ipc_connect_me_to_blocking(PHONE_NS,
    53                             SERVICE_DEVMAP, DEVMAP_DRIVER, 0);
     52                        devmap_phone_driver = service_connect_blocking(SERVICE_DEVMAP,
     53                            DEVMAP_DRIVER, 0);
    5454                else
    55                         devmap_phone_driver = ipc_connect_me_to(PHONE_NS,
    56                             SERVICE_DEVMAP, DEVMAP_DRIVER, 0);
     55                        devmap_phone_driver = service_connect(SERVICE_DEVMAP,
     56                            DEVMAP_DRIVER, 0);
    5757               
    5858                return devmap_phone_driver;
     
    6262               
    6363                if (flags & IPC_FLAG_BLOCKING)
    64                         devmap_phone_client = ipc_connect_me_to_blocking(PHONE_NS,
    65                             SERVICE_DEVMAP, DEVMAP_CLIENT, 0);
     64                        devmap_phone_client = service_connect_blocking(SERVICE_DEVMAP,
     65                            DEVMAP_CLIENT, 0);
    6666                else
    67                         devmap_phone_client = ipc_connect_me_to(PHONE_NS,
    68                             SERVICE_DEVMAP, DEVMAP_CLIENT, 0);
     67                        devmap_phone_client = service_connect(SERVICE_DEVMAP,
     68                            DEVMAP_CLIENT, 0);
    6969               
    7070                return devmap_phone_client;
     
    7979        case DEVMAP_DRIVER:
    8080                if (devmap_phone_driver >= 0) {
    81                         ipc_hangup(devmap_phone_driver);
     81                        async_hangup(devmap_phone_driver);
    8282                        devmap_phone_driver = -1;
    8383                }
     
    8585        case DEVMAP_CLIENT:
    8686                if (devmap_phone_client >= 0) {
    87                         ipc_hangup(devmap_phone_client);
     87                        async_hangup(devmap_phone_client);
    8888                        devmap_phone_client = -1;
    8989                }
     
    107107        aid_t req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
    108108       
    109         ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
     109        sysarg_t retval = async_data_write_start(phone, name, str_size(name));
    110110        if (retval != EOK) {
    111111                async_wait_for(req, NULL);
     
    116116        async_set_client_connection(conn);
    117117       
    118         ipcarg_t callback_phonehash;
    119         ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash);
     118        async_connect_to_me(phone, 0, 0, 0, NULL);
    120119        async_wait_for(req, &retval);
    121120       
     
    127126/** Register new device.
    128127 *
    129  * @param namespace Namespace name.
     128 * The @p interface is used when forwarding connection to the driver.
     129 * If not 0, the first argument is the interface and the second argument
     130 * is the devmap handle of the device.
     131 * When the interface is zero (default), the first argument is directly
     132 * the handle (to ensure backward compatibility).
     133 *
     134 * @param fqdn Fully qualified device name.
     135 * @param[out] handle Handle to the created instance of device.
     136 * @param interface Interface when forwarding.
     137 *
     138 */
     139int devmap_device_register_with_iface(const char *fqdn,
     140    devmap_handle_t *handle, sysarg_t interface)
     141{
     142        int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING);
     143       
     144        if (phone < 0)
     145                return phone;
     146       
     147        async_serialize_start();
     148       
     149        ipc_call_t answer;
     150        aid_t req = async_send_2(phone, DEVMAP_DEVICE_REGISTER, interface, 0,
     151            &answer);
     152       
     153        sysarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
     154        if (retval != EOK) {
     155                async_wait_for(req, NULL);
     156                async_serialize_end();
     157                return retval;
     158        }
     159       
     160        async_wait_for(req, &retval);
     161       
     162        async_serialize_end();
     163       
     164        if (retval != EOK) {
     165                if (handle != NULL)
     166                        *handle = -1;
     167                return retval;
     168        }
     169       
     170        if (handle != NULL)
     171                *handle = (devmap_handle_t) IPC_GET_ARG1(answer);
     172       
     173        return retval;
     174}
     175
     176/** Register new device.
     177 *
    130178 * @param fqdn      Fully qualified device name.
    131179 * @param handle    Output: Handle to the created instance of device.
    132180 *
    133181 */
    134 int devmap_device_register(const char *fqdn, dev_handle_t *handle)
    135 {
    136         int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING);
    137        
    138         if (phone < 0)
    139                 return phone;
    140        
    141         async_serialize_start();
    142        
    143         ipc_call_t answer;
    144         aid_t req = async_send_2(phone, DEVMAP_DEVICE_REGISTER, 0, 0,
    145             &answer);
    146        
    147         ipcarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
    148         if (retval != EOK) {
    149                 async_wait_for(req, NULL);
    150                 async_serialize_end();
    151                 return retval;
    152         }
    153        
    154         async_wait_for(req, &retval);
    155        
    156         async_serialize_end();
    157        
    158         if (retval != EOK) {
    159                 if (handle != NULL)
    160                         *handle = -1;
    161                 return retval;
    162         }
    163        
    164         if (handle != NULL)
    165                 *handle = (dev_handle_t) IPC_GET_ARG1(answer);
    166        
    167         return retval;
    168 }
    169 
    170 int devmap_device_get_handle(const char *fqdn, dev_handle_t *handle, unsigned int flags)
     182int devmap_device_register(const char *fqdn, devmap_handle_t *handle)
     183{
     184        return devmap_device_register_with_iface(fqdn, handle, 0);
     185}
     186
     187
     188int devmap_device_get_handle(const char *fqdn, devmap_handle_t *handle, unsigned int flags)
    171189{
    172190        int phone = devmap_get_phone(DEVMAP_CLIENT, flags);
     
    181199            &answer);
    182200       
    183         ipcarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
     201        sysarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
    184202        if (retval != EOK) {
    185203                async_wait_for(req, NULL);
     
    194212        if (retval != EOK) {
    195213                if (handle != NULL)
    196                         *handle = (dev_handle_t) -1;
     214                        *handle = (devmap_handle_t) -1;
    197215                return retval;
    198216        }
    199217       
    200218        if (handle != NULL)
    201                 *handle = (dev_handle_t) IPC_GET_ARG1(answer);
     219                *handle = (devmap_handle_t) IPC_GET_ARG1(answer);
    202220       
    203221        return retval;
    204222}
    205223
    206 int devmap_namespace_get_handle(const char *name, dev_handle_t *handle, unsigned int flags)
     224int devmap_namespace_get_handle(const char *name, devmap_handle_t *handle, unsigned int flags)
    207225{
    208226        int phone = devmap_get_phone(DEVMAP_CLIENT, flags);
     
    217235            &answer);
    218236       
    219         ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
     237        sysarg_t retval = async_data_write_start(phone, name, str_size(name));
    220238        if (retval != EOK) {
    221239                async_wait_for(req, NULL);
     
    230248        if (retval != EOK) {
    231249                if (handle != NULL)
    232                         *handle = (dev_handle_t) -1;
     250                        *handle = (devmap_handle_t) -1;
    233251                return retval;
    234252        }
    235253       
    236254        if (handle != NULL)
    237                 *handle = (dev_handle_t) IPC_GET_ARG1(answer);
     255                *handle = (devmap_handle_t) IPC_GET_ARG1(answer);
    238256       
    239257        return retval;
    240258}
    241259
    242 devmap_handle_type_t devmap_handle_probe(dev_handle_t handle)
     260devmap_handle_type_t devmap_handle_probe(devmap_handle_t handle)
    243261{
    244262        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     
    247265                return phone;
    248266       
    249         ipcarg_t type;
     267        sysarg_t type;
    250268        int retval = async_req_1_1(phone, DEVMAP_HANDLE_PROBE, handle, &type);
    251269        if (retval != EOK)
     
    255273}
    256274
    257 int devmap_device_connect(dev_handle_t handle, unsigned int flags)
     275int devmap_device_connect(devmap_handle_t handle, unsigned int flags)
    258276{
    259277        int phone;
    260278       
    261279        if (flags & IPC_FLAG_BLOCKING) {
    262                 phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,
     280                phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,
    263281                    DEVMAP_CONNECT_TO_DEVICE, handle);
    264282        } else {
    265                 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
     283                phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
    266284                    DEVMAP_CONNECT_TO_DEVICE, handle);
    267285        }
     
    277295                return -1;
    278296       
    279         ipcarg_t null_id;
     297        sysarg_t null_id;
    280298        int retval = async_req_0_1(phone, DEVMAP_NULL_CREATE, &null_id);
    281299        if (retval != EOK)
     
    292310                return;
    293311       
    294         async_req_1_0(phone, DEVMAP_NULL_DESTROY, (ipcarg_t) null_id);
     312        async_req_1_0(phone, DEVMAP_NULL_DESTROY, (sysarg_t) null_id);
    295313}
    296314
    297315static size_t devmap_count_namespaces_internal(int phone)
    298316{
    299         ipcarg_t count;
     317        sysarg_t count;
    300318        int retval = async_req_0_1(phone, DEVMAP_GET_NAMESPACE_COUNT, &count);
    301319        if (retval != EOK)
     
    305323}
    306324
    307 static size_t devmap_count_devices_internal(int phone, dev_handle_t ns_handle)
    308 {
    309         ipcarg_t count;
     325static size_t devmap_count_devices_internal(int phone, devmap_handle_t ns_handle)
     326{
     327        sysarg_t count;
    310328        int retval = async_req_1_1(phone, DEVMAP_GET_DEVICE_COUNT, ns_handle, &count);
    311329        if (retval != EOK)
     
    325343}
    326344
    327 size_t devmap_count_devices(dev_handle_t ns_handle)
     345size_t devmap_count_devices(devmap_handle_t ns_handle)
    328346{
    329347        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     
    375393                }
    376394               
    377                 ipcarg_t retval;
     395                sysarg_t retval;
    378396                async_wait_for(req, &retval);
    379397                async_serialize_end();
     
    387405}
    388406
    389 size_t devmap_get_devices(dev_handle_t ns_handle, dev_desc_t **data)
     407size_t devmap_get_devices(devmap_handle_t ns_handle, dev_desc_t **data)
    390408{
    391409        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     
    427445                }
    428446               
    429                 ipcarg_t retval;
     447                sysarg_t retval;
    430448                async_wait_for(req, &retval);
    431449                async_serialize_end();
Note: See TracChangeset for help on using the changeset viewer.