Rev 2393 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2435 | jelen | 1 | /* |
2 | * Copyright (c) 2007 Konopa-Jelen-Majer |
||
3 | * All rights reserved. |
||
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions |
||
7 | * are met: |
||
8 | * |
||
9 | * - Redistributions of source code must retain the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer. |
||
11 | * - Redistributions in binary form must reproduce the above copyright |
||
12 | * notice, this list of conditions and the following disclaimer in the |
||
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 |
||
15 | * derived from this software without specific prior written permission. |
||
16 | * |
||
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 |
||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
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 |
||
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 |
||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | */ |
||
2393 | konopa | 28 | |
2435 | jelen | 29 | /** @addtogroup FileSystemTask |
30 | * @{ |
||
2393 | konopa | 31 | */ |
32 | |||
2435 | jelen | 33 | /** |
34 | * @file connect.h |
||
35 | * @brief Functions for connecting to some services, which is needed for FS. |
||
36 | */ |
||
37 | |||
2393 | konopa | 38 | #include <ipc/ipc.h> |
39 | #include <ipc/services.h> |
||
40 | #include "../fs/fs.h" |
||
41 | |||
2435 | jelen | 42 | /** |
43 | * Includes common aspects for connecting to some services |
||
44 | */ |
||
2393 | konopa | 45 | int common_connection(int *phone, int service, int attempts) |
46 | { |
||
47 | |||
48 | int i; |
||
49 | |||
50 | if (service <= 0 || attempts <= 0) |
||
51 | return FALSE; |
||
52 | |||
53 | for (i = 1; i <= attempts; i++) { |
||
54 | *phone = ipc_connect_me_to(PHONE_NS, service, 0); |
||
55 | |||
56 | if (*phone > 0) |
||
57 | return TRUE; |
||
58 | |||
59 | usleep(10000); |
||
60 | } |
||
61 | |||
62 | if (*phone >= 0) |
||
63 | return TRUE; |
||
64 | |||
65 | return FALSE; |
||
66 | } |
||
67 | |||
2435 | jelen | 68 | /** |
69 | * Connects to SERVICE_CONSOLE |
||
70 | */ |
||
2393 | konopa | 71 | int connect_to_con(int *phone, int attempts) |
72 | { |
||
73 | |||
74 | if (common_connection(phone, SERVICE_CONSOLE, attempts)) |
||
75 | return TRUE; |
||
76 | |||
77 | return FALSE; |
||
78 | } |
||
79 | |||
2435 | jelen | 80 | /** |
81 | * Connects to SERVICE_RD |
||
82 | */ |
||
2393 | konopa | 83 | int connect_to_rd(int *phone, int attempts) |
84 | { |
||
85 | |||
86 | if (common_connection(phone, SERVICE_RD, attempts)) |
||
87 | return TRUE; |
||
88 | |||
89 | return FALSE; |
||
90 | } |
||
91 | |||
2435 | jelen | 92 | /** |
93 | * Connects to SERVICE_FS |
||
94 | */ |
||
2393 | konopa | 95 | int connect_to_fs(int *phone, int attempts) |
96 | { |
||
97 | |||
98 | if (common_connection(phone, SERVICE_FS, attempts)) |
||
99 | return TRUE; |
||
100 | |||
101 | return FALSE; |
||
102 | } |
||
2435 | jelen | 103 | |
104 | /** |
||
105 | *} |
||
106 | */ |
||
107 |