Ignore:
File:
1 edited

Legend:

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

    r64d2b10 r63f8966  
    2929
    3030#include <str.h>
     31#include <ipc/ipc.h>
    3132#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 = service_connect_blocking(SERVICE_DEVMAP,
    53                             DEVMAP_DRIVER, 0);
     52                        devmap_phone_driver = ipc_connect_me_to_blocking(PHONE_NS,
     53                            SERVICE_DEVMAP, DEVMAP_DRIVER, 0);
    5454                else
    55                         devmap_phone_driver = service_connect(SERVICE_DEVMAP,
    56                             DEVMAP_DRIVER, 0);
     55                        devmap_phone_driver = ipc_connect_me_to(PHONE_NS,
     56                            SERVICE_DEVMAP, DEVMAP_DRIVER, 0);
    5757               
    5858                return devmap_phone_driver;
     
    6262               
    6363                if (flags & IPC_FLAG_BLOCKING)
    64                         devmap_phone_client = service_connect_blocking(SERVICE_DEVMAP,
    65                             DEVMAP_CLIENT, 0);
     64                        devmap_phone_client = ipc_connect_me_to_blocking(PHONE_NS,
     65                            SERVICE_DEVMAP, DEVMAP_CLIENT, 0);
    6666                else
    67                         devmap_phone_client = service_connect(SERVICE_DEVMAP,
    68                             DEVMAP_CLIENT, 0);
     67                        devmap_phone_client = ipc_connect_me_to(PHONE_NS,
     68                            SERVICE_DEVMAP, DEVMAP_CLIENT, 0);
    6969               
    7070                return devmap_phone_client;
     
    7979        case DEVMAP_DRIVER:
    8080                if (devmap_phone_driver >= 0) {
    81                         async_hangup(devmap_phone_driver);
     81                        ipc_hangup(devmap_phone_driver);
    8282                        devmap_phone_driver = -1;
    8383                }
     
    8585        case DEVMAP_CLIENT:
    8686                if (devmap_phone_client >= 0) {
    87                         async_hangup(devmap_phone_client);
     87                        ipc_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         sysarg_t retval = async_data_write_start(phone, name, str_size(name));
     109        ipcarg_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         async_connect_to_me(phone, 0, 0, 0, NULL);
     118        ipcarg_t callback_phonehash;
     119        ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash);
    119120        async_wait_for(req, &retval);
    120121       
     
    126127/** Register new device.
    127128 *
    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  */
    139 int 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  *
     129 * @param namespace Namespace name.
    178130 * @param fqdn      Fully qualified device name.
    179131 * @param handle    Output: Handle to the created instance of device.
    180132 *
    181133 */
    182 int devmap_device_register(const char *fqdn, devmap_handle_t *handle)
    183 {
    184         return devmap_device_register_with_iface(fqdn, handle, 0);
    185 }
    186 
    187 
    188 int devmap_device_get_handle(const char *fqdn, devmap_handle_t *handle, unsigned int flags)
     134int 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
     170int devmap_device_get_handle(const char *fqdn, dev_handle_t *handle, unsigned int flags)
    189171{
    190172        int phone = devmap_get_phone(DEVMAP_CLIENT, flags);
     
    199181            &answer);
    200182       
    201         sysarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
     183        ipcarg_t retval = async_data_write_start(phone, fqdn, str_size(fqdn));
    202184        if (retval != EOK) {
    203185                async_wait_for(req, NULL);
     
    212194        if (retval != EOK) {
    213195                if (handle != NULL)
    214                         *handle = (devmap_handle_t) -1;
     196                        *handle = (dev_handle_t) -1;
    215197                return retval;
    216198        }
    217199       
    218200        if (handle != NULL)
    219                 *handle = (devmap_handle_t) IPC_GET_ARG1(answer);
     201                *handle = (dev_handle_t) IPC_GET_ARG1(answer);
    220202       
    221203        return retval;
    222204}
    223205
    224 int devmap_namespace_get_handle(const char *name, devmap_handle_t *handle, unsigned int flags)
     206int devmap_namespace_get_handle(const char *name, dev_handle_t *handle, unsigned int flags)
    225207{
    226208        int phone = devmap_get_phone(DEVMAP_CLIENT, flags);
     
    235217            &answer);
    236218       
    237         sysarg_t retval = async_data_write_start(phone, name, str_size(name));
     219        ipcarg_t retval = async_data_write_start(phone, name, str_size(name));
    238220        if (retval != EOK) {
    239221                async_wait_for(req, NULL);
     
    248230        if (retval != EOK) {
    249231                if (handle != NULL)
    250                         *handle = (devmap_handle_t) -1;
     232                        *handle = (dev_handle_t) -1;
    251233                return retval;
    252234        }
    253235       
    254236        if (handle != NULL)
    255                 *handle = (devmap_handle_t) IPC_GET_ARG1(answer);
     237                *handle = (dev_handle_t) IPC_GET_ARG1(answer);
    256238       
    257239        return retval;
    258240}
    259241
    260 devmap_handle_type_t devmap_handle_probe(devmap_handle_t handle)
     242devmap_handle_type_t devmap_handle_probe(dev_handle_t handle)
    261243{
    262244        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     
    265247                return phone;
    266248       
    267         sysarg_t type;
     249        ipcarg_t type;
    268250        int retval = async_req_1_1(phone, DEVMAP_HANDLE_PROBE, handle, &type);
    269251        if (retval != EOK)
     
    273255}
    274256
    275 int devmap_device_connect(devmap_handle_t handle, unsigned int flags)
     257int devmap_device_connect(dev_handle_t handle, unsigned int flags)
    276258{
    277259        int phone;
    278260       
    279261        if (flags & IPC_FLAG_BLOCKING) {
    280                 phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,
     262                phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,
    281263                    DEVMAP_CONNECT_TO_DEVICE, handle);
    282264        } else {
    283                 phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
     265                phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
    284266                    DEVMAP_CONNECT_TO_DEVICE, handle);
    285267        }
     
    295277                return -1;
    296278       
    297         sysarg_t null_id;
     279        ipcarg_t null_id;
    298280        int retval = async_req_0_1(phone, DEVMAP_NULL_CREATE, &null_id);
    299281        if (retval != EOK)
     
    310292                return;
    311293       
    312         async_req_1_0(phone, DEVMAP_NULL_DESTROY, (sysarg_t) null_id);
     294        async_req_1_0(phone, DEVMAP_NULL_DESTROY, (ipcarg_t) null_id);
    313295}
    314296
    315297static size_t devmap_count_namespaces_internal(int phone)
    316298{
    317         sysarg_t count;
     299        ipcarg_t count;
    318300        int retval = async_req_0_1(phone, DEVMAP_GET_NAMESPACE_COUNT, &count);
    319301        if (retval != EOK)
     
    323305}
    324306
    325 static size_t devmap_count_devices_internal(int phone, devmap_handle_t ns_handle)
    326 {
    327         sysarg_t count;
     307static size_t devmap_count_devices_internal(int phone, dev_handle_t ns_handle)
     308{
     309        ipcarg_t count;
    328310        int retval = async_req_1_1(phone, DEVMAP_GET_DEVICE_COUNT, ns_handle, &count);
    329311        if (retval != EOK)
     
    343325}
    344326
    345 size_t devmap_count_devices(devmap_handle_t ns_handle)
     327size_t devmap_count_devices(dev_handle_t ns_handle)
    346328{
    347329        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     
    393375                }
    394376               
    395                 sysarg_t retval;
     377                ipcarg_t retval;
    396378                async_wait_for(req, &retval);
    397379                async_serialize_end();
     
    405387}
    406388
    407 size_t devmap_get_devices(devmap_handle_t ns_handle, dev_desc_t **data)
     389size_t devmap_get_devices(dev_handle_t ns_handle, dev_desc_t **data)
    408390{
    409391        int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING);
     
    445427                }
    446428               
    447                 sysarg_t retval;
     429                ipcarg_t retval;
    448430                async_wait_for(req, &retval);
    449431                async_serialize_end();
Note: See TracChangeset for help on using the changeset viewer.