Changes in uspace/lib/c/generic/devmap.c [64d2b10:63f8966] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/devmap.c
r64d2b10 r63f8966 29 29 30 30 #include <str.h> 31 #include <ipc/ipc.h> 31 32 #include <ipc/services.h> 32 #include <ipc/ns.h>33 33 #include <ipc/devmap.h> 34 34 #include <devmap.h> … … 50 50 51 51 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); 54 54 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); 57 57 58 58 return devmap_phone_driver; … … 62 62 63 63 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); 66 66 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); 69 69 70 70 return devmap_phone_client; … … 79 79 case DEVMAP_DRIVER: 80 80 if (devmap_phone_driver >= 0) { 81 async_hangup(devmap_phone_driver);81 ipc_hangup(devmap_phone_driver); 82 82 devmap_phone_driver = -1; 83 83 } … … 85 85 case DEVMAP_CLIENT: 86 86 if (devmap_phone_client >= 0) { 87 async_hangup(devmap_phone_client);87 ipc_hangup(devmap_phone_client); 88 88 devmap_phone_client = -1; 89 89 } … … 107 107 aid_t req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer); 108 108 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)); 110 110 if (retval != EOK) { 111 111 async_wait_for(req, NULL); … … 116 116 async_set_client_connection(conn); 117 117 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); 119 120 async_wait_for(req, &retval); 120 121 … … 126 127 /** Register new device. 127 128 * 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. 178 130 * @param fqdn Fully qualified device name. 179 131 * @param handle Output: Handle to the created instance of device. 180 132 * 181 133 */ 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) 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) 189 171 { 190 172 int phone = devmap_get_phone(DEVMAP_CLIENT, flags); … … 199 181 &answer); 200 182 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)); 202 184 if (retval != EOK) { 203 185 async_wait_for(req, NULL); … … 212 194 if (retval != EOK) { 213 195 if (handle != NULL) 214 *handle = (dev map_handle_t) -1;196 *handle = (dev_handle_t) -1; 215 197 return retval; 216 198 } 217 199 218 200 if (handle != NULL) 219 *handle = (dev map_handle_t) IPC_GET_ARG1(answer);201 *handle = (dev_handle_t) IPC_GET_ARG1(answer); 220 202 221 203 return retval; 222 204 } 223 205 224 int devmap_namespace_get_handle(const char *name, dev map_handle_t *handle, unsigned int flags)206 int devmap_namespace_get_handle(const char *name, dev_handle_t *handle, unsigned int flags) 225 207 { 226 208 int phone = devmap_get_phone(DEVMAP_CLIENT, flags); … … 235 217 &answer); 236 218 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)); 238 220 if (retval != EOK) { 239 221 async_wait_for(req, NULL); … … 248 230 if (retval != EOK) { 249 231 if (handle != NULL) 250 *handle = (dev map_handle_t) -1;232 *handle = (dev_handle_t) -1; 251 233 return retval; 252 234 } 253 235 254 236 if (handle != NULL) 255 *handle = (dev map_handle_t) IPC_GET_ARG1(answer);237 *handle = (dev_handle_t) IPC_GET_ARG1(answer); 256 238 257 239 return retval; 258 240 } 259 241 260 devmap_handle_type_t devmap_handle_probe(dev map_handle_t handle)242 devmap_handle_type_t devmap_handle_probe(dev_handle_t handle) 261 243 { 262 244 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); … … 265 247 return phone; 266 248 267 sysarg_t type;249 ipcarg_t type; 268 250 int retval = async_req_1_1(phone, DEVMAP_HANDLE_PROBE, handle, &type); 269 251 if (retval != EOK) … … 273 255 } 274 256 275 int devmap_device_connect(dev map_handle_t handle, unsigned int flags)257 int devmap_device_connect(dev_handle_t handle, unsigned int flags) 276 258 { 277 259 int phone; 278 260 279 261 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, 281 263 DEVMAP_CONNECT_TO_DEVICE, handle); 282 264 } else { 283 phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAP,265 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, 284 266 DEVMAP_CONNECT_TO_DEVICE, handle); 285 267 } … … 295 277 return -1; 296 278 297 sysarg_t null_id;279 ipcarg_t null_id; 298 280 int retval = async_req_0_1(phone, DEVMAP_NULL_CREATE, &null_id); 299 281 if (retval != EOK) … … 310 292 return; 311 293 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); 313 295 } 314 296 315 297 static size_t devmap_count_namespaces_internal(int phone) 316 298 { 317 sysarg_t count;299 ipcarg_t count; 318 300 int retval = async_req_0_1(phone, DEVMAP_GET_NAMESPACE_COUNT, &count); 319 301 if (retval != EOK) … … 323 305 } 324 306 325 static size_t devmap_count_devices_internal(int phone, dev map_handle_t ns_handle)326 { 327 sysarg_t count;307 static size_t devmap_count_devices_internal(int phone, dev_handle_t ns_handle) 308 { 309 ipcarg_t count; 328 310 int retval = async_req_1_1(phone, DEVMAP_GET_DEVICE_COUNT, ns_handle, &count); 329 311 if (retval != EOK) … … 343 325 } 344 326 345 size_t devmap_count_devices(dev map_handle_t ns_handle)327 size_t devmap_count_devices(dev_handle_t ns_handle) 346 328 { 347 329 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); … … 393 375 } 394 376 395 sysarg_t retval;377 ipcarg_t retval; 396 378 async_wait_for(req, &retval); 397 379 async_serialize_end(); … … 405 387 } 406 388 407 size_t devmap_get_devices(dev map_handle_t ns_handle, dev_desc_t **data)389 size_t devmap_get_devices(dev_handle_t ns_handle, dev_desc_t **data) 408 390 { 409 391 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); … … 445 427 } 446 428 447 sysarg_t retval;429 ipcarg_t retval; 448 430 async_wait_for(req, &retval); 449 431 async_serialize_end();
Note:
See TracChangeset
for help on using the changeset viewer.