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