source: mainline/uspace/lib/device/src/devman.c@ 77a0119

Last change on this file since 77a0119 was 8300c72, checked in by Jiri Svoboda <jiri@…>, 4 months ago

Quiesce devices before proceeding with shutdown.

Only implemented for e1k, uhci and xhci.

  • Property mode set to 100644
File size: 18.5 KB
Line 
1/*
2 * Copyright (c) 2025 Jiri Svoboda
3 * Copyright (c) 2007 Josef Cejka
4 * Copyright (c) 2010 Lenka Trochtova
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * - The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/** @addtogroup libdevice
32 * @{
33 */
34/** @file
35 */
36
37#include <adt/list.h>
38#include <str.h>
39#include <ipc/services.h>
40#include <ns.h>
41#include <ipc/devman.h>
42#include <devman.h>
43#include <fibril_synch.h>
44#include <async.h>
45#include <errno.h>
46#include <stdlib.h>
47
48static FIBRIL_MUTEX_INITIALIZE(devman_driver_block_mutex);
49static FIBRIL_MUTEX_INITIALIZE(devman_client_block_mutex);
50
51static FIBRIL_MUTEX_INITIALIZE(devman_driver_mutex);
52static FIBRIL_MUTEX_INITIALIZE(devman_client_mutex);
53
54static async_sess_t *devman_driver_block_sess = NULL;
55static async_sess_t *devman_client_block_sess = NULL;
56
57static async_sess_t *devman_driver_sess = NULL;
58static async_sess_t *devman_client_sess = NULL;
59
60static void clone_session(fibril_mutex_t *mtx, async_sess_t *src,
61 async_sess_t **dst)
62{
63 fibril_mutex_lock(mtx);
64
65 if ((*dst == NULL) && (src != NULL))
66 *dst = src;
67
68 fibril_mutex_unlock(mtx);
69}
70
71/** Start an async exchange on the devman session (blocking).
72 *
73 * @param iface Device manager interface to choose
74 *
75 * @return New exchange.
76 *
77 */
78async_exch_t *devman_exchange_begin_blocking(iface_t iface)
79{
80 switch (iface) {
81 case INTERFACE_DDF_DRIVER:
82 fibril_mutex_lock(&devman_driver_block_mutex);
83
84 while (devman_driver_block_sess == NULL) {
85 clone_session(&devman_driver_mutex, devman_driver_sess,
86 &devman_driver_block_sess);
87
88 if (devman_driver_block_sess == NULL)
89 devman_driver_block_sess =
90 service_connect_blocking(SERVICE_DEVMAN,
91 INTERFACE_DDF_DRIVER, 0, NULL);
92 }
93
94 fibril_mutex_unlock(&devman_driver_block_mutex);
95
96 clone_session(&devman_driver_mutex, devman_driver_block_sess,
97 &devman_driver_sess);
98
99 return async_exchange_begin(devman_driver_block_sess);
100 case INTERFACE_DDF_CLIENT:
101 fibril_mutex_lock(&devman_client_block_mutex);
102
103 while (devman_client_block_sess == NULL) {
104 clone_session(&devman_client_mutex, devman_client_sess,
105 &devman_client_block_sess);
106
107 if (devman_client_block_sess == NULL)
108 devman_client_block_sess =
109 service_connect_blocking(SERVICE_DEVMAN,
110 INTERFACE_DDF_CLIENT, 0, NULL);
111 }
112
113 fibril_mutex_unlock(&devman_client_block_mutex);
114
115 clone_session(&devman_client_mutex, devman_client_block_sess,
116 &devman_client_sess);
117
118 return async_exchange_begin(devman_client_block_sess);
119 default:
120 return NULL;
121 }
122}
123
124/** Start an async exchange on the devman session.
125 *
126 * @param iface Device manager interface to choose
127 *
128 * @return New exchange.
129 *
130 */
131async_exch_t *devman_exchange_begin(iface_t iface)
132{
133 switch (iface) {
134 case INTERFACE_DDF_DRIVER:
135 fibril_mutex_lock(&devman_driver_mutex);
136
137 if (devman_driver_sess == NULL)
138 devman_driver_sess =
139 service_connect(SERVICE_DEVMAN,
140 INTERFACE_DDF_DRIVER, 0, NULL);
141
142 fibril_mutex_unlock(&devman_driver_mutex);
143
144 if (devman_driver_sess == NULL)
145 return NULL;
146
147 return async_exchange_begin(devman_driver_sess);
148 case INTERFACE_DDF_CLIENT:
149 fibril_mutex_lock(&devman_client_mutex);
150
151 if (devman_client_sess == NULL)
152 devman_client_sess =
153 service_connect(SERVICE_DEVMAN,
154 INTERFACE_DDF_CLIENT, 0, NULL);
155
156 fibril_mutex_unlock(&devman_client_mutex);
157
158 if (devman_client_sess == NULL)
159 return NULL;
160
161 return async_exchange_begin(devman_client_sess);
162 default:
163 return NULL;
164 }
165}
166
167/** Finish an async exchange on the devman session.
168 *
169 * @param exch Exchange to be finished.
170 *
171 */
172void devman_exchange_end(async_exch_t *exch)
173{
174 async_exchange_end(exch);
175}
176
177/** Register running driver with device manager. */
178errno_t devman_driver_register(const char *name)
179{
180 async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER);
181
182 ipc_call_t answer;
183 aid_t req = async_send_2(exch, DEVMAN_DRIVER_REGISTER, 0, 0, &answer);
184 errno_t retval = async_data_write_start(exch, name, str_size(name));
185
186 devman_exchange_end(exch);
187
188 if (retval != EOK) {
189 async_forget(req);
190 return retval;
191 }
192
193 exch = devman_exchange_begin(INTERFACE_DDF_DRIVER);
194 async_connect_to_me(exch, INTERFACE_ANY, 0, 0);
195 devman_exchange_end(exch);
196
197 async_wait_for(req, &retval);
198 return retval;
199}
200
201/** Add function to a device.
202 *
203 * Request devman to add a new function to the specified device owned by
204 * this driver task.
205 *
206 * @param name Name of the new function
207 * @param ftype Function type, fun_inner or fun_exposed
208 * @param match_ids Match IDs (should be empty for fun_exposed)
209 * @param devh Devman handle of the device
210 * @param funh Place to store handle of the new function
211 *
212 * @return EOK on success or an error code.
213 *
214 */
215errno_t devman_add_function(const char *name, fun_type_t ftype,
216 match_id_list_t *match_ids, devman_handle_t devh, devman_handle_t *funh)
217{
218 unsigned long match_count = list_count(&match_ids->ids);
219 async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER);
220
221 ipc_call_t answer;
222 aid_t req = async_send_3(exch, DEVMAN_ADD_FUNCTION, (sysarg_t) ftype,
223 devh, match_count, &answer);
224 errno_t retval = async_data_write_start(exch, name, str_size(name));
225 if (retval != EOK) {
226 devman_exchange_end(exch);
227 async_forget(req);
228 return retval;
229 }
230
231 list_foreach(match_ids->ids, link, match_id_t, match_id) {
232 ipc_call_t answer2;
233 aid_t req2 = async_send_1(exch, DEVMAN_ADD_MATCH_ID,
234 match_id->score, &answer2);
235 retval = async_data_write_start(exch, match_id->id,
236 str_size(match_id->id));
237 if (retval != EOK) {
238 devman_exchange_end(exch);
239 async_forget(req2);
240 async_forget(req);
241 return retval;
242 }
243
244 async_wait_for(req2, &retval);
245 if (retval != EOK) {
246 devman_exchange_end(exch);
247 async_forget(req);
248 return retval;
249 }
250 }
251
252 devman_exchange_end(exch);
253
254 async_wait_for(req, &retval);
255 if (retval == EOK) {
256 if (funh != NULL)
257 *funh = (int) ipc_get_arg1(&answer);
258 } else {
259 if (funh != NULL)
260 *funh = -1;
261 }
262
263 return retval;
264}
265
266errno_t devman_add_device_to_category(devman_handle_t devman_handle,
267 const char *cat_name)
268{
269 async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER);
270
271 ipc_call_t answer;
272 aid_t req = async_send_1(exch, DEVMAN_ADD_DEVICE_TO_CATEGORY,
273 devman_handle, &answer);
274 errno_t retval = async_data_write_start(exch, cat_name,
275 str_size(cat_name));
276
277 devman_exchange_end(exch);
278
279 if (retval != EOK) {
280 async_forget(req);
281 return retval;
282 }
283
284 async_wait_for(req, &retval);
285 return retval;
286}
287
288async_sess_t *devman_device_connect(devman_handle_t handle, unsigned int flags)
289{
290 async_sess_t *sess;
291
292 if (flags & IPC_FLAG_BLOCKING)
293 sess = service_connect_blocking(SERVICE_DEVMAN,
294 INTERFACE_DEVMAN_DEVICE, handle, NULL);
295 else
296 sess = service_connect(SERVICE_DEVMAN,
297 INTERFACE_DEVMAN_DEVICE, handle, NULL);
298
299 return sess;
300}
301
302/** Remove function from device.
303 *
304 * Request devman to remove function owned by this driver task.
305 * @param funh Devman handle of the function
306 *
307 * @return EOK on success or an error code.
308 */
309errno_t devman_remove_function(devman_handle_t funh)
310{
311 async_exch_t *exch;
312 errno_t retval;
313
314 exch = devman_exchange_begin_blocking(INTERFACE_DDF_DRIVER);
315 retval = async_req_1_0(exch, DEVMAN_REMOVE_FUNCTION, (sysarg_t) funh);
316 devman_exchange_end(exch);
317
318 return retval;
319}
320
321errno_t devman_drv_fun_online(devman_handle_t funh)
322{
323 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_DRIVER);
324 if (exch == NULL)
325 return ENOMEM;
326
327 errno_t retval = async_req_1_0(exch, DEVMAN_DRV_FUN_ONLINE, funh);
328
329 devman_exchange_end(exch);
330 return retval;
331}
332
333errno_t devman_drv_fun_offline(devman_handle_t funh)
334{
335 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_DRIVER);
336 if (exch == NULL)
337 return ENOMEM;
338
339 errno_t retval = async_req_1_0(exch, DEVMAN_DRV_FUN_OFFLINE, funh);
340
341 devman_exchange_end(exch);
342 return retval;
343}
344
345errno_t devman_drv_fun_quiesce(devman_handle_t funh)
346{
347 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_DRIVER);
348 if (exch == NULL)
349 return ENOMEM;
350
351 errno_t retval = async_req_1_0(exch, DEVMAN_DRV_FUN_QUIESCE, funh);
352
353 devman_exchange_end(exch);
354 return retval;
355}
356
357errno_t devman_drv_fun_wait_stable(devman_handle_t funh)
358{
359 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_DRIVER);
360 if (exch == NULL)
361 return ENOMEM;
362
363 errno_t retval = async_req_1_0(exch, DEVMAN_DRV_FUN_WAIT_STABLE, funh);
364
365 devman_exchange_end(exch);
366 return retval;
367}
368
369async_sess_t *devman_parent_device_connect(devman_handle_t handle,
370 unsigned int flags)
371{
372 async_sess_t *sess;
373
374 if (flags & IPC_FLAG_BLOCKING)
375 sess = service_connect_blocking(SERVICE_DEVMAN,
376 INTERFACE_DEVMAN_PARENT, handle, NULL);
377 else
378 sess = service_connect(SERVICE_DEVMAN,
379 INTERFACE_DEVMAN_PARENT, handle, NULL);
380
381 return sess;
382}
383
384errno_t devman_fun_get_handle(const char *pathname, devman_handle_t *handle,
385 unsigned int flags)
386{
387 async_exch_t *exch;
388
389 if (flags & IPC_FLAG_BLOCKING)
390 exch = devman_exchange_begin_blocking(INTERFACE_DDF_CLIENT);
391 else {
392 exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
393 if (exch == NULL)
394 return ENOMEM;
395 }
396
397 ipc_call_t answer;
398 aid_t req = async_send_2(exch, DEVMAN_DEVICE_GET_HANDLE, flags, 0,
399 &answer);
400 errno_t retval = async_data_write_start(exch, pathname,
401 str_size(pathname));
402
403 devman_exchange_end(exch);
404
405 if (retval != EOK) {
406 async_forget(req);
407 return retval;
408 }
409
410 async_wait_for(req, &retval);
411
412 if (retval != EOK) {
413 if (handle != NULL)
414 *handle = (devman_handle_t) -1;
415
416 return retval;
417 }
418
419 if (handle != NULL)
420 *handle = (devman_handle_t) ipc_get_arg1(&answer);
421
422 return retval;
423}
424
425static errno_t devman_get_str_internal(sysarg_t method, sysarg_t arg1,
426 sysarg_t arg2, sysarg_t *r1, char *buf, size_t buf_size)
427{
428 async_exch_t *exch;
429 ipc_call_t dreply;
430 size_t act_size;
431 errno_t dretval;
432
433 exch = devman_exchange_begin_blocking(INTERFACE_DDF_CLIENT);
434
435 ipc_call_t answer;
436 aid_t req = async_send_2(exch, method, arg1, arg2, &answer);
437 aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply);
438 async_wait_for(dreq, &dretval);
439
440 devman_exchange_end(exch);
441
442 if (dretval != EOK) {
443 async_forget(req);
444 return dretval;
445 }
446
447 errno_t retval;
448 async_wait_for(req, &retval);
449
450 if (retval != EOK) {
451 return retval;
452 }
453
454 if (r1 != NULL)
455 *r1 = ipc_get_arg1(&answer);
456 act_size = ipc_get_arg2(&dreply);
457 assert(act_size <= buf_size - 1);
458 buf[act_size] = '\0';
459
460 return EOK;
461}
462
463errno_t devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size)
464{
465 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, 0, NULL,
466 buf, buf_size);
467}
468
469errno_t devman_fun_get_match_id(devman_handle_t handle, size_t index, char *buf,
470 size_t buf_size, unsigned int *rscore)
471{
472 errno_t rc;
473 sysarg_t score = 0;
474
475 rc = devman_get_str_internal(DEVMAN_FUN_GET_MATCH_ID, handle, index,
476 &score, buf, buf_size);
477 if (rc != EOK)
478 return rc;
479
480 *rscore = score;
481 return rc;
482}
483
484errno_t devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size)
485{
486 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, 0, NULL,
487 buf, buf_size);
488}
489
490errno_t devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size)
491{
492 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, 0,
493 NULL, buf, buf_size);
494}
495
496errno_t devman_fun_online(devman_handle_t funh)
497{
498 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
499 if (exch == NULL)
500 return ENOMEM;
501
502 errno_t retval = async_req_1_0(exch, DEVMAN_FUN_ONLINE, funh);
503
504 devman_exchange_end(exch);
505 return retval;
506}
507
508errno_t devman_fun_offline(devman_handle_t funh)
509{
510 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
511 if (exch == NULL)
512 return ENOMEM;
513
514 errno_t retval = async_req_1_0(exch, DEVMAN_FUN_OFFLINE, funh);
515
516 devman_exchange_end(exch);
517 return retval;
518}
519
520errno_t devman_fun_quiesce(devman_handle_t funh)
521{
522 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
523 if (exch == NULL)
524 return ENOMEM;
525
526 errno_t retval = async_req_1_0(exch, DEVMAN_FUN_QUIESCE, funh);
527
528 devman_exchange_end(exch);
529 return retval;
530}
531
532static errno_t devman_get_handles_once(sysarg_t method, sysarg_t arg1,
533 devman_handle_t *handle_buf, size_t buf_size, size_t *act_size)
534{
535 async_exch_t *exch = devman_exchange_begin_blocking(INTERFACE_DDF_CLIENT);
536
537 ipc_call_t answer;
538 aid_t req = async_send_1(exch, method, arg1, &answer);
539 errno_t rc = async_data_read_start(exch, handle_buf, buf_size);
540
541 devman_exchange_end(exch);
542
543 if (rc != EOK) {
544 async_forget(req);
545 return rc;
546 }
547
548 errno_t retval;
549 async_wait_for(req, &retval);
550
551 if (retval != EOK) {
552 return retval;
553 }
554
555 *act_size = ipc_get_arg1(&answer);
556 return EOK;
557}
558
559/** Get list of handles.
560 *
561 * Returns an allocated array of handles.
562 *
563 * @param method IPC method
564 * @param arg1 IPC argument 1
565 * @param data Place to store pointer to array of handles
566 * @param count Place to store number of handles
567 * @return EOK on success or an error code
568 */
569static errno_t devman_get_handles_internal(sysarg_t method, sysarg_t arg1,
570 devman_handle_t **data, size_t *count)
571{
572 devman_handle_t *handles;
573 size_t act_size;
574 size_t alloc_size;
575 errno_t rc;
576
577 *data = NULL;
578 act_size = 0; /* silence warning */
579
580 rc = devman_get_handles_once(method, arg1, NULL, 0,
581 &act_size);
582 if (rc != EOK)
583 return rc;
584
585 alloc_size = act_size;
586 handles = malloc(alloc_size);
587 if (handles == NULL)
588 return ENOMEM;
589
590 while (true) {
591 rc = devman_get_handles_once(method, arg1, handles, alloc_size,
592 &act_size);
593 if (rc != EOK)
594 return rc;
595
596 if (act_size <= alloc_size)
597 break;
598
599 alloc_size *= 2;
600 free(handles);
601
602 handles = malloc(alloc_size);
603 if (handles == NULL)
604 return ENOMEM;
605 }
606
607 *count = act_size / sizeof(devman_handle_t);
608 *data = handles;
609 return EOK;
610}
611
612errno_t devman_fun_get_child(devman_handle_t funh, devman_handle_t *devh)
613{
614 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
615 if (exch == NULL)
616 return ENOMEM;
617
618 errno_t retval = async_req_1_1(exch, DEVMAN_FUN_GET_CHILD,
619 funh, devh);
620
621 devman_exchange_end(exch);
622 return retval;
623}
624
625errno_t devman_dev_get_functions(devman_handle_t devh, devman_handle_t **funcs,
626 size_t *count)
627{
628 return devman_get_handles_internal(DEVMAN_DEV_GET_FUNCTIONS,
629 devh, funcs, count);
630}
631
632errno_t devman_dev_get_parent(devman_handle_t devh, devman_handle_t *funh)
633{
634 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
635 if (exch == NULL)
636 return ENOMEM;
637
638 errno_t retval = async_req_1_1(exch, DEVMAN_DEV_GET_PARENT,
639 devh, funh);
640
641 devman_exchange_end(exch);
642 return retval;
643}
644
645errno_t devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle)
646{
647 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
648 if (exch == NULL)
649 return ENOMEM;
650
651 errno_t retval = async_req_1_1(exch, DEVMAN_FUN_SID_TO_HANDLE,
652 sid, handle);
653
654 devman_exchange_end(exch);
655 return retval;
656}
657
658errno_t devman_quiesce_devices(const char *path)
659{
660 devman_handle_t funh;
661 errno_t rc;
662
663 funh = 0;
664 rc = devman_fun_get_handle(path, &funh, 0);
665 if (rc != EOK)
666 return rc;
667
668 return devman_fun_quiesce(funh);
669}
670
671errno_t devman_get_drivers(devman_handle_t **drvs,
672 size_t *count)
673{
674 return devman_get_handles_internal(DEVMAN_GET_DRIVERS, 0, drvs, count);
675}
676
677errno_t devman_driver_get_devices(devman_handle_t drvh, devman_handle_t **devs,
678 size_t *count)
679{
680 return devman_get_handles_internal(DEVMAN_DRIVER_GET_DEVICES,
681 drvh, devs, count);
682}
683
684errno_t devman_driver_get_handle(const char *drvname, devman_handle_t *handle)
685{
686 async_exch_t *exch;
687
688 exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
689 if (exch == NULL)
690 return ENOMEM;
691
692 ipc_call_t answer;
693 aid_t req = async_send_0(exch, DEVMAN_DRIVER_GET_HANDLE, &answer);
694 errno_t retval = async_data_write_start(exch, drvname,
695 str_size(drvname));
696
697 devman_exchange_end(exch);
698
699 if (retval != EOK) {
700 async_forget(req);
701 return retval;
702 }
703
704 async_wait_for(req, &retval);
705
706 if (retval != EOK) {
707 if (handle != NULL)
708 *handle = (devman_handle_t) -1;
709
710 return retval;
711 }
712
713 if (handle != NULL)
714 *handle = (devman_handle_t) ipc_get_arg1(&answer);
715
716 return retval;
717}
718
719errno_t devman_driver_get_match_id(devman_handle_t handle, size_t index, char *buf,
720 size_t buf_size, unsigned int *rscore)
721{
722 errno_t rc;
723 sysarg_t score = 0;
724
725 rc = devman_get_str_internal(DEVMAN_DRIVER_GET_MATCH_ID, handle, index,
726 &score, buf, buf_size);
727 if (rc != EOK)
728 return rc;
729
730 *rscore = score;
731 return rc;
732}
733
734errno_t devman_driver_get_name(devman_handle_t handle, char *buf, size_t buf_size)
735{
736 return devman_get_str_internal(DEVMAN_DRIVER_GET_NAME, handle, 0, NULL,
737 buf, buf_size);
738}
739
740errno_t devman_driver_get_state(devman_handle_t drvh, driver_state_t *rstate)
741{
742 sysarg_t state;
743 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
744 if (exch == NULL)
745 return ENOMEM;
746
747 errno_t rc = async_req_1_1(exch, DEVMAN_DRIVER_GET_STATE, drvh,
748 &state);
749
750 devman_exchange_end(exch);
751 if (rc != EOK)
752 return rc;
753
754 *rstate = state;
755 return rc;
756}
757
758errno_t devman_driver_load(devman_handle_t drvh)
759{
760 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
761 if (exch == NULL)
762 return ENOMEM;
763
764 errno_t rc = async_req_1_0(exch, DEVMAN_DRIVER_LOAD, drvh);
765
766 devman_exchange_end(exch);
767 return rc;
768}
769
770errno_t devman_driver_unload(devman_handle_t drvh)
771{
772 async_exch_t *exch = devman_exchange_begin(INTERFACE_DDF_CLIENT);
773 if (exch == NULL)
774 return ENOMEM;
775
776 errno_t rc = async_req_1_0(exch, DEVMAN_DRIVER_UNLOAD, drvh);
777
778 devman_exchange_end(exch);
779 return rc;
780}
781
782/** @}
783 */
Note: See TracBrowser for help on using the repository browser.