Rev 2547 | Rev 2555 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2547 | Rev 2550 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2007 Josef Cejka |
2 | * Copyright (c) 2007 Josef Cejka |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** |
29 | /** |
30 | * @defgroup devmap Device mapper. |
30 | * @defgroup devmap Device mapper. |
31 | * @brief HelenOS device mapper. |
31 | * @brief HelenOS device mapper. |
32 | * @{ |
32 | * @{ |
33 | */ |
33 | */ |
34 | 34 | ||
35 | /** @file |
35 | /** @file |
36 | */ |
36 | */ |
37 | 37 | ||
38 | #include <ipc/ipc.h> |
- | |
39 | #include <ipc/services.h> |
38 | #include <ipc/services.h> |
40 | #include <ipc/ns.h> |
39 | #include <ipc/ns.h> |
41 | #include <async.h> |
40 | #include <async.h> |
42 | #include <stdio.h> |
41 | #include <stdio.h> |
43 | #include <errno.h> |
42 | #include <errno.h> |
44 | 43 | ||
45 | #include "devmap.h" |
44 | #include "devmap.h" |
46 | 45 | ||
47 | /** Initialize device mapper. |
46 | /** Initialize device mapper. |
48 | * |
47 | * |
49 | * |
48 | * |
50 | */ |
49 | */ |
51 | static int devmap_init() |
50 | static int devmap_init() |
52 | { |
51 | { |
53 | /* */ |
52 | /* */ |
54 | 53 | ||
55 | return 0; |
54 | return 0; |
56 | } |
55 | } |
57 | 56 | ||
58 | 57 | ||
59 | /** Function for handling connections to devmap |
58 | /** Function for handling connections to devmap |
60 | * |
59 | * |
61 | */ |
60 | */ |
62 | static void |
61 | static void |
63 | devmap_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
62 | devmap_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
64 | { |
63 | { |
65 | ipc_callid_t callid; |
64 | ipc_callid_t callid; |
66 | ipc_call_t call; |
65 | ipc_call_t call; |
67 | int retval; |
66 | int retval; |
68 | 67 | ||
69 | ipc_answer_fast(iid, EOK, 0, 0); /* Accept connection */ |
68 | ipc_answer_fast(iid, EOK, 0, 0); /* Accept connection */ |
70 | 69 | ||
71 | while (1) { |
70 | while (1) { |
72 | callid = async_get_call(&call); |
71 | callid = async_get_call(&call); |
73 | 72 | ||
74 | switch (IPC_GET_METHOD(call)) { |
73 | switch (IPC_GET_METHOD(call)) { |
75 | case IPC_M_PHONE_HUNGUP: |
74 | case IPC_M_PHONE_HUNGUP: |
76 | /* TODO: if its a device connection, remove it from table */ |
75 | /* TODO: if its a device connection, remove it from table */ |
77 | return; /* Exit thread */ |
76 | return; /* Exit thread */ |
78 | 77 | ||
79 | case DEVMAP_REGISTER: |
78 | case DEVMAP_REGISTER: |
80 | /* TODO: */ |
79 | /* TODO: */ |
81 | case DEVMAP_UNREGISTER: |
80 | case DEVMAP_UNREGISTER: |
82 | /* TODO: */ |
81 | /* TODO: */ |
83 | case DEVMAP_CONNECT_TO_DEVICE: |
82 | case DEVMAP_CONNECT_TO_DEVICE: |
84 | /* TODO: */ |
83 | /* TODO: */ |
85 | retval = 0; |
84 | retval = 0; |
86 | break; |
85 | break; |
87 | default: |
86 | default: |
88 | retval = ENOENT; |
87 | retval = ENOENT; |
89 | } |
88 | } |
90 | ipc_answer_fast(callid, retval, 0, 0); |
89 | ipc_answer_fast(callid, retval, 0, 0); |
91 | } |
90 | } |
92 | 91 | ||
93 | } |
92 | } |
94 | 93 | ||
95 | 94 | ||
96 | int main(int argc, char *argv[]) |
95 | int main(int argc, char *argv[]) |
97 | { |
96 | { |
98 | 97 | ||
99 | ipcarg_t phonead; |
98 | ipcarg_t phonead; |
100 | 99 | ||
101 | printf("DevMap: HelenOS device mapper.\n"); |
100 | printf("DevMap: HelenOS device mapper.\n"); |
102 | 101 | ||
103 | if (devmap_init() != 0) { |
102 | if (devmap_init() != 0) { |
104 | printf("Error while initializing DevMap service."); |
103 | printf("Error while initializing DevMap service."); |
105 | return -1; |
104 | return -1; |
106 | } |
105 | } |
107 | 106 | ||
108 | /* Set a handler of incomming connections */ |
107 | /* Set a handler of incomming connections */ |
109 | async_set_client_connection(devmap_client_connection); |
108 | async_set_client_connection(devmap_client_connection); |
110 | 109 | ||
111 | /* Register device mapper at naming service */ |
110 | /* Register device mapper at naming service */ |
112 | if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, &phonead) != 0) |
111 | if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, &phonead) != 0) |
113 | return -1; |
112 | return -1; |
114 | 113 | ||
115 | async_manager(); |
114 | async_manager(); |
116 | /* Never reached */ |
115 | /* Never reached */ |
117 | return 0; |
116 | return 0; |
118 | } |
117 | } |
119 | 118 | ||
120 | /** |
119 | /** |
121 | * @} |
120 | * @} |
122 | */ |
121 | */ |
123 | 122 | ||
124 | 123 |