1 | /*
|
---|
2 | * Copyright (c) 2007 Josef Cejka
|
---|
3 | * Copyright (c) 2009 Jiri Svoboda
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * - Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | * - The name of the author may not be used to endorse or promote products
|
---|
16 | * derived from this software without specific prior written permission.
|
---|
17 | *
|
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #include <str.h>
|
---|
31 | #include <ipc/services.h>
|
---|
32 | #include <ns.h>
|
---|
33 | #include <ns_obsolete.h>
|
---|
34 | #include <ipc/devmap.h>
|
---|
35 | #include <devmap_obsolete.h>
|
---|
36 | #include <async.h>
|
---|
37 | #include <async_obsolete.h>
|
---|
38 | #include <errno.h>
|
---|
39 | #include <malloc.h>
|
---|
40 | #include <bool.h>
|
---|
41 |
|
---|
42 | static int devmap_phone_driver = -1;
|
---|
43 | static int devmap_phone_client = -1;
|
---|
44 |
|
---|
45 | /** Get phone to device mapper task. */
|
---|
46 | int devmap_obsolete_get_phone(devmap_interface_t iface, unsigned int flags)
|
---|
47 | {
|
---|
48 | switch (iface) {
|
---|
49 | case DEVMAP_DRIVER:
|
---|
50 | if (devmap_phone_driver >= 0)
|
---|
51 | return devmap_phone_driver;
|
---|
52 |
|
---|
53 | if (flags & IPC_FLAG_BLOCKING)
|
---|
54 | devmap_phone_driver = service_obsolete_connect_blocking(SERVICE_DEVMAP,
|
---|
55 | DEVMAP_DRIVER, 0);
|
---|
56 | else
|
---|
57 | devmap_phone_driver = service_obsolete_connect(SERVICE_DEVMAP,
|
---|
58 | DEVMAP_DRIVER, 0);
|
---|
59 |
|
---|
60 | return devmap_phone_driver;
|
---|
61 | case DEVMAP_CLIENT:
|
---|
62 | if (devmap_phone_client >= 0)
|
---|
63 | return devmap_phone_client;
|
---|
64 |
|
---|
65 | if (flags & IPC_FLAG_BLOCKING)
|
---|
66 | devmap_phone_client = service_obsolete_connect_blocking(SERVICE_DEVMAP,
|
---|
67 | DEVMAP_CLIENT, 0);
|
---|
68 | else
|
---|
69 | devmap_phone_client = service_obsolete_connect(SERVICE_DEVMAP,
|
---|
70 | DEVMAP_CLIENT, 0);
|
---|
71 |
|
---|
72 | return devmap_phone_client;
|
---|
73 | default:
|
---|
74 | return -1;
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | void devmap_obsolete_hangup_phone(devmap_interface_t iface)
|
---|
79 | {
|
---|
80 | switch (iface) {
|
---|
81 | case DEVMAP_DRIVER:
|
---|
82 | if (devmap_phone_driver >= 0) {
|
---|
83 | async_obsolete_hangup(devmap_phone_driver);
|
---|
84 | devmap_phone_driver = -1;
|
---|
85 | }
|
---|
86 | break;
|
---|
87 | case DEVMAP_CLIENT:
|
---|
88 | if (devmap_phone_client >= 0) {
|
---|
89 | async_obsolete_hangup(devmap_phone_client);
|
---|
90 | devmap_phone_client = -1;
|
---|
91 | }
|
---|
92 | break;
|
---|
93 | default:
|
---|
94 | break;
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | int devmap_obsolete_device_connect(devmap_handle_t handle, unsigned int flags)
|
---|
99 | {
|
---|
100 | int phone;
|
---|
101 |
|
---|
102 | if (flags & IPC_FLAG_BLOCKING) {
|
---|
103 | phone = service_obsolete_connect_blocking(SERVICE_DEVMAP,
|
---|
104 | DEVMAP_CONNECT_TO_DEVICE, handle);
|
---|
105 | } else {
|
---|
106 | phone = service_obsolete_connect(SERVICE_DEVMAP,
|
---|
107 | DEVMAP_CONNECT_TO_DEVICE, handle);
|
---|
108 | }
|
---|
109 |
|
---|
110 | return phone;
|
---|
111 | }
|
---|
112 |
|
---|
113 | /** @}
|
---|
114 | */
|
---|