Subversion Repositories HelenOS

Rev

Rev 1490 | Rev 1499 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1490 Rev 1497
1
/*
1
/*
2
 * Copyright (C) 2006 Josef Cejka
2
 * Copyright (C) 2006 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
#include <kbd.h>
30
#include <kbd.h>
31
#include <fb.h>
31
#include <fb.h>
32
#include <ipc/ipc.h>
32
#include <ipc/ipc.h>
33
#include <ipc/fb.h>
33
#include <ipc/fb.h>
34
#include <ipc/services.h>
34
#include <ipc/services.h>
35
#include <errno.h>
35
#include <errno.h>
36
#include <key_buffer.h>
36
#include <key_buffer.h>
37
#include <console.h>
37
#include <console.h>
38
#include <unistd.h>
38
#include <unistd.h>
39
#include <async.h>
39
#include <async.h>
40
#include <libadt/fifo.h>
40
#include <libadt/fifo.h>
41
#include <screenbuffer.h>
41
#include <screenbuffer.h>
42
 
42
 
43
#define CONSOLE_COUNT 8
43
#define CONSOLE_COUNT 12 
44
#define MAX_KEYREQUESTS_BUFFERED 32
44
#define MAX_KEYREQUESTS_BUFFERED 32
45
 
45
 
46
#define NAME "CONSOLE"
46
#define NAME "CONSOLE"
47
 
47
 
48
int active_console = 1;
48
int active_console = 1;
49
 
49
 
50
struct {
50
struct {
51
    int phone;      /**< Framebuffer phone */
51
    int phone;      /**< Framebuffer phone */
52
    int rows;       /**< Framebuffer rows */
52
    int rows;       /**< Framebuffer rows */
53
    int cols;       /**< Framebuffer columns */
53
    int cols;       /**< Framebuffer columns */
54
} fb_info;
54
} fb_info;
55
 
55
 
56
typedef struct {
56
typedef struct {
57
    keybuffer_t keybuffer;
57
    keybuffer_t keybuffer;
58
    FIFO_CREATE_STATIC(keyrequests, ipc_callid_t , MAX_KEYREQUESTS_BUFFERED);
58
    FIFO_CREATE_STATIC(keyrequests, ipc_callid_t , MAX_KEYREQUESTS_BUFFERED);
59
    int keyrequest_counter;
59
    int keyrequest_counter;
60
    int client_phone;
60
    int client_phone;
61
    int used;
61
    int used;
62
    screenbuffer_t screenbuffer;
62
    screenbuffer_t screenbuffer;
63
} connection_t;
63
} connection_t;
64
 
64
 
65
connection_t connections[CONSOLE_COUNT];
65
connection_t connections[CONSOLE_COUNT];
66
 
66
 
67
static int find_free_connection()
67
static int find_free_connection()
68
{
68
{
69
    int i = 0;
69
    int i = 0;
70
   
70
   
71
    while (i < CONSOLE_COUNT) {
71
    while (i < CONSOLE_COUNT) {
72
        if (connections[i].used == 0)
72
        if (connections[i].used == 0)
73
            return i;
73
            return i;
74
        ++i;
74
        ++i;
75
    }
75
    }
76
    return CONSOLE_COUNT;
76
    return CONSOLE_COUNT;
77
}
77
}
78
 
78
 
79
 
79
 
80
static int find_connection(int client_phone)
80
static int find_connection(int client_phone)
81
{
81
{
82
    int i = 0;
82
    int i = 0;
83
   
83
   
84
    while (i < CONSOLE_COUNT) {
84
    while (i < CONSOLE_COUNT) {
85
        if (connections[i].client_phone == client_phone)
85
        if (connections[i].client_phone == client_phone)
86
            return i;
86
            return i;
87
        ++i;
87
        ++i;
88
    }
88
    }
89
    return  CONSOLE_COUNT;
89
    return  CONSOLE_COUNT;
90
}
90
}
91
 
91
 
-
 
92
/** Check key and process special keys.
-
 
93
 *
-
 
94
 * */
-
 
95
static void write_char(int console, char key)
-
 
96
{
-
 
97
    screenbuffer_t *scr = &(connections[console].screenbuffer);
-
 
98
   
-
 
99
    switch (key) {
-
 
100
        case '\n':
-
 
101
            scr->position_y += 1;
-
 
102
            scr->position_x =  0;
-
 
103
            break;
-
 
104
        case '\r':
-
 
105
            break;
-
 
106
        case '\t':
-
 
107
            scr->position_x += 8;
-
 
108
            scr->position_x -= scr->position_x % 8;
-
 
109
            break;
-
 
110
        case '\b':
-
 
111
            if (scr->position_x == 0)
-
 
112
                break;
-
 
113
 
-
 
114
            scr->position_x--;
-
 
115
 
-
 
116
            if (console == active_console) {
-
 
117
                ipc_call_async_3(fb_info.phone, FB_PUTCHAR, ' ', scr->position_y, scr->position_x, NULL, NULL);
-
 
118
            }
-
 
119
   
-
 
120
            screenbuffer_putchar(scr, ' ');
-
 
121
           
-
 
122
            break;
-
 
123
        default:   
-
 
124
            if (console == active_console) {
-
 
125
                ipc_call_async_3(fb_info.phone, FB_PUTCHAR, key, scr->position_y, scr->position_x, NULL, NULL);
-
 
126
            }
-
 
127
   
-
 
128
            screenbuffer_putchar(scr, key);
-
 
129
            scr->position_x++;
-
 
130
    }
-
 
131
   
-
 
132
    scr->position_y += (scr->position_x >= scr->size_x);
-
 
133
   
-
 
134
    if (scr->position_y >= scr->size_y) {
-
 
135
        scr->position_y = scr->size_y - 1;
-
 
136
        screenbuffer_clear_line(scr, scr->top_line++);
-
 
137
        ipc_call_async(fb_info.phone, FB_SCROLL, 1, NULL, NULL);
-
 
138
    }
-
 
139
   
-
 
140
    scr->position_x = scr->position_x % scr->size_x;
-
 
141
    scr->position_y = scr->position_y  % scr->size_y;
-
 
142
   
-
 
143
}
-
 
144
 
-
 
145
 
92
/* Handler for keyboard */
146
/* Handler for keyboard */
93
static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
147
static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
94
{
148
{
95
    ipc_callid_t callid;
149
    ipc_callid_t callid;
96
    ipc_call_t call;
150
    ipc_call_t call;
97
    int retval;
151
    int retval;
98
    int i, j;
152
    int i, j;
99
    char c,d;
153
    char c,d;
100
    connection_t *conn;
154
    connection_t *conn;
101
 
155
 
102
    /* Ignore parameters, the connection is alread opened */
156
    /* Ignore parameters, the connection is alread opened */
103
    while (1) {
157
    while (1) {
104
        callid = async_get_call(&call);
158
        callid = async_get_call(&call);
105
        switch (IPC_GET_METHOD(call)) {
159
        switch (IPC_GET_METHOD(call)) {
106
        case IPC_M_PHONE_HUNGUP:
160
        case IPC_M_PHONE_HUNGUP:
107
            ipc_answer_fast(callid,0,0,0);
161
            ipc_answer_fast(callid,0,0,0);
108
            /* TODO: Handle hangup */
162
            /* TODO: Handle hangup */
109
            return;
163
            return;
110
        case KBD_PUSHCHAR:
164
        case KBD_PUSHCHAR:
111
            /* got key from keyboard driver */
165
            /* got key from keyboard driver */
112
           
166
           
113
            retval = 0;
167
            retval = 0;
114
            c = IPC_GET_ARG1(call);
168
            c = IPC_GET_ARG1(call);
115
            /* switch to another virtual console */
169
            /* switch to another virtual console */
116
           
170
           
117
            conn = &connections[active_console];
171
            conn = &connections[active_console];
118
//          if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) {
172
//          if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) {
119
            if ((c >= '1') && (c < '1' + CONSOLE_COUNT)) {
173
            if ((c >= '1') && (c < '1' + CONSOLE_COUNT)) {
120
                /*FIXME: draw another console content from buffer */
174
                /*FIXME: draw another console content from buffer */
-
 
175
                if (c - KBD_KEY_F1 == active_console)
121
 
176
                        break;
122
                active_console = c - '1';
177
                active_console = c - '1';
123
                conn = &connections[active_console];
178
                conn = &connections[active_console];
124
 
179
 
125
                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL);
180
                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL);
126
                ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
181
                ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
-
 
182
               
127
                for (i = 0; i < conn->screenbuffer.size_x; i++)
183
                for (i = 0; i < conn->screenbuffer.size_x; i++)
128
                    for (j = 0; j < conn->screenbuffer.size_y; j++) {
184
                    for (j = 0; j < conn->screenbuffer.size_y; j++) {
129
                        d = get_field_at(&(conn->screenbuffer),i, j)->character;
185
                        d = get_field_at(&(conn->screenbuffer),i, j)->character;
130
                        if (d && d != ' ')
186
                        if (d && d != ' ')
131
                            ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL);
187
                            ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL);
132
                    }
188
                    }
133
                ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x, NULL, NULL);
189
                ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x, NULL, NULL);
134
                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL, NULL);
190
                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL, NULL);
135
 
191
 
136
                break;
192
                break;
137
            }
193
            }
138
           
194
           
139
            /* if client is awaiting key, send it */
195
            /* if client is awaiting key, send it */
140
            if (conn->keyrequest_counter > 0) {    
196
            if (conn->keyrequest_counter > 0) {    
141
                conn->keyrequest_counter--;
197
                conn->keyrequest_counter--;
142
                ipc_answer_fast(fifo_pop(conn->keyrequests), 0, c, 0);
198
                ipc_answer_fast(fifo_pop(conn->keyrequests), 0, c, 0);
143
                break;
199
                break;
144
            }
200
            }
145
           
201
           
146
            /*FIXME: else store key to its buffer */
202
            /*FIXME: else store key to its buffer */
147
            keybuffer_push(&conn->keybuffer, c);
203
            keybuffer_push(&conn->keybuffer, c);
148
           
204
           
149
            break;
205
            break;
150
        default:
206
        default:
151
            retval = ENOENT;
207
            retval = ENOENT;
152
        }      
208
        }      
153
        ipc_answer_fast(callid, retval, 0, 0);
209
        ipc_answer_fast(callid, retval, 0, 0);
154
    }
210
    }
155
}
211
}
156
 
212
 
157
/** Default thread for new connections */
213
/** Default thread for new connections */
158
void client_connection(ipc_callid_t iid, ipc_call_t *icall)
214
void client_connection(ipc_callid_t iid, ipc_call_t *icall)
159
{
215
{
160
    ipc_callid_t callid;
216
    ipc_callid_t callid;
161
    ipc_call_t call;
217
    ipc_call_t call;
162
    int consnum;
218
    int consnum;
163
    ipcarg_t arg1;
219
    ipcarg_t arg1;
164
 
220
 
165
    if ((consnum = find_free_connection()) == CONSOLE_COUNT) {
221
    if ((consnum = find_free_connection()) == CONSOLE_COUNT) {
166
        ipc_answer_fast(iid,ELIMIT,0,0);
222
        ipc_answer_fast(iid,ELIMIT,0,0);
167
        return;
223
        return;
168
    }
224
    }
169
   
225
 
170
    connections[consnum].used = 1;
226
    connections[consnum].used = 1;
171
    connections[consnum].client_phone = IPC_GET_ARG3(call);
227
    connections[consnum].client_phone = IPC_GET_ARG3(call);
172
    screenbuffer_clear(&(connections[consnum].screenbuffer));
228
    screenbuffer_clear(&(connections[consnum].screenbuffer));
173
 
229
   
174
    /* Accept the connection */
230
    /* Accept the connection */
175
    ipc_answer_fast(iid,0,0,0);
231
    ipc_answer_fast(iid,0,0,0);
176
   
232
   
177
    while (1) {
233
    while (1) {
178
        callid = async_get_call(&call);
234
        callid = async_get_call(&call);
179
        switch (IPC_GET_METHOD(call)) {
235
        switch (IPC_GET_METHOD(call)) {
180
        case IPC_M_PHONE_HUNGUP:
236
        case IPC_M_PHONE_HUNGUP:
181
            /* TODO */
237
            /* TODO */
182
            ipc_answer_fast(callid, 0,0,0);
238
            ipc_answer_fast(callid, 0,0,0);
183
            return;
239
            return;
184
        case CONSOLE_PUTCHAR:
240
        case CONSOLE_PUTCHAR:
185
           
-
 
186
            /* Send message to fb */
-
 
187
            if (consnum == active_console) {
-
 
188
                ipc_call_async_3(fb_info.phone, FB_PUTCHAR, IPC_GET_ARG2(call), connections[consnum].screenbuffer.position_y, \
-
 
189
                        connections[consnum].screenbuffer.position_x, NULL, NULL);
-
 
190
            }
-
 
191
           
-
 
192
            screenbuffer_putchar(&(connections[consnum].screenbuffer), IPC_GET_ARG2(call));
241
            write_char(consnum, IPC_GET_ARG1(call));
193
            break;
242
            break;
194
        case CONSOLE_CLEAR:
243
        case CONSOLE_CLEAR:
195
            /* Send message to fb */
244
            /* Send message to fb */
196
            if (consnum == active_console) {
245
            if (consnum == active_console) {
197
                ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
246
                ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
198
            }
247
            }
199
           
248
           
200
            screenbuffer_clear(&(connections[consnum].screenbuffer));
249
            screenbuffer_clear(&(connections[consnum].screenbuffer));
201
           
250
           
202
            break;
251
            break;
203
        case CONSOLE_GOTO:
252
        case CONSOLE_GOTO:
204
           
253
           
205
            screenbuffer_goto(&(connections[consnum].screenbuffer), IPC_GET_ARG1(call), IPC_GET_ARG2(call));
254
            screenbuffer_goto(&(connections[consnum].screenbuffer), IPC_GET_ARG1(call), IPC_GET_ARG2(call));
206
           
255
           
207
            break;
256
            break;
208
 
257
 
209
        case CONSOLE_GETCHAR:
258
        case CONSOLE_GETCHAR:
210
            if (keybuffer_empty(&(connections[consnum].keybuffer))) {
259
            if (keybuffer_empty(&(connections[consnum].keybuffer))) {
211
                /* buffer is empty -> store request */
260
                /* buffer is empty -> store request */
212
                if (connections[consnum].keyrequest_counter < MAX_KEYREQUESTS_BUFFERED) {      
261
                if (connections[consnum].keyrequest_counter < MAX_KEYREQUESTS_BUFFERED) {      
213
                    fifo_push(connections[consnum].keyrequests, callid);
262
                    fifo_push(connections[consnum].keyrequests, callid);
214
                    connections[consnum].keyrequest_counter++;
263
                    connections[consnum].keyrequest_counter++;
215
                } else {
264
                } else {
216
                    /* no key available and too many requests => fail */
265
                    /* no key available and too many requests => fail */
217
                    ipc_answer_fast(callid, ELIMIT, 0, 0);
266
                    ipc_answer_fast(callid, ELIMIT, 0, 0);
218
                }
267
                }
219
                continue;
268
                continue;
220
            };
269
            };
221
            keybuffer_pop(&(connections[consnum].keybuffer), (char *)&arg1);
270
            keybuffer_pop(&(connections[consnum].keybuffer), (char *)&arg1);
222
           
271
           
223
            break;
272
            break;
224
        }
273
        }
225
        ipc_answer_fast(callid, 0, arg1, 0);
274
        ipc_answer_fast(callid, 0, arg1, 0);
226
    }
275
    }
227
}
276
}
228
 
277
 
229
int main(int argc, char *argv[])
278
int main(int argc, char *argv[])
230
{
279
{
231
    ipcarg_t phonehash;
280
    ipcarg_t phonehash;
232
    int kbd_phone, fb_phone;
281
    int kbd_phone, fb_phone;
233
    ipcarg_t retval, arg1 = 0xdead, arg2 = 0xbeef;
282
    ipcarg_t retval, arg1 = 0xdead, arg2 = 0xbeef;
234
    int i;
283
    int i;
235
 
284
 
236
    async_set_client_connection(client_connection);
285
    async_set_client_connection(client_connection);
237
   
286
   
238
    /* Connect to keyboard driver */
287
    /* Connect to keyboard driver */
239
 
288
 
240
    while ((kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) {
289
    while ((kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) {
241
        usleep(10000);
290
        usleep(10000);
242
    };
291
    };
243
   
292
   
244
    if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phonehash) != 0) {
293
    if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phonehash) != 0) {
245
        return -1;
294
        return -1;
246
    };
295
    };
247
    async_new_connection(phonehash, 0, NULL, keyboard_events);
296
    async_new_connection(phonehash, 0, NULL, keyboard_events);
248
 
297
 
249
    /* Connect to framebuffer driver */
298
    /* Connect to framebuffer driver */
250
   
299
   
251
    while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) {
300
    while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) {
252
        usleep(10000);
301
        usleep(10000);
253
    }
302
    }
254
   
303
   
255
    ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols));
304
    ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols));
256
    ipc_call_sync(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL);
305
    ipc_call_sync(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL);
257
   
306
   
258
    /* Init virtual consoles */
307
    /* Init virtual consoles */
259
    for (i = 0; i < CONSOLE_COUNT; i++) {
308
    for (i = 0; i < CONSOLE_COUNT; i++) {
260
        connections[i].used = 0;
309
        connections[i].used = 0;
261
        keybuffer_init(&(connections[i].keybuffer));
310
        keybuffer_init(&(connections[i].keybuffer));
262
       
311
       
263
        connections[i].keyrequests.head = connections[i].keyrequests.tail = 0;
312
        connections[i].keyrequests.head = connections[i].keyrequests.tail = 0;
264
        connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED;
313
        connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED;
265
        connections[i].keyrequest_counter = 0;
314
        connections[i].keyrequest_counter = 0;
266
       
315
       
267
        if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) {
316
        if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) {
268
            /*FIXME: handle error */
317
            /*FIXME: handle error */
269
            return -1;
318
            return -1;
270
        }
319
        }
271
    }
320
    }
272
   
321
   
-
 
322
 
273
    if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) {
323
    if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) {
274
        return -1;
324
        return -1;
275
    };
325
    };
276
   
326
   
277
    async_manager();
327
    async_manager();
278
 
328
 
279
    return 0;  
329
    return 0;  
280
}
330
}
281
 
331