Subversion Repositories HelenOS

Rev

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

Rev 4148 Rev 4164
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
/** @addtogroup console
29
/** @addtogroup console
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#include <libc.h>
35
#include <libc.h>
36
#include <fb.h>
36
#include <fb.h>
37
#include <ipc/ipc.h>
37
#include <ipc/ipc.h>
38
#include <kbd.h>
38
#include <kbd.h>
39
#include <kbd/keycode.h>
39
#include <kbd/keycode.h>
40
#include <ipc/fb.h>
40
#include <ipc/fb.h>
41
#include <ipc/services.h>
41
#include <ipc/services.h>
42
#include <errno.h>
42
#include <errno.h>
43
#include <key_buffer.h>
43
#include <key_buffer.h>
44
#include <ipc/console.h>
44
#include <ipc/console.h>
45
#include <unistd.h>
45
#include <unistd.h>
46
#include <async.h>
46
#include <async.h>
47
#include <libadt/fifo.h>
47
#include <libadt/fifo.h>
48
#include <screenbuffer.h>
48
#include <screenbuffer.h>
49
#include <sys/mman.h>
49
#include <sys/mman.h>
50
#include <stdio.h>
50
#include <stdio.h>
51
#include <sysinfo.h>
51
#include <sysinfo.h>
52
 
52
 
53
#include "console.h"
53
#include "console.h"
54
#include "gcons.h"
54
#include "gcons.h"
55
 
55
 
56
#define MAX_KEYREQUESTS_BUFFERED 32
56
#define MAX_KEYREQUESTS_BUFFERED 32
57
 
57
 
58
#define NAME "console"
58
#define NAME "console"
59
 
59
 
60
/** Index of currently used virtual console.
60
/** Index of currently used virtual console.
61
 */
61
 */
62
int active_console = 0;
62
int active_console = 0;
63
int prev_console = 0;
63
int prev_console = 0;
64
 
64
 
65
/** Information about framebuffer
65
/** Information about framebuffer
66
 */
66
 */
67
struct {
67
struct {
68
    int phone;      /**< Framebuffer phone */
68
    int phone;      /**< Framebuffer phone */
69
    ipcarg_t rows;      /**< Framebuffer rows */
69
    ipcarg_t rows;      /**< Framebuffer rows */
70
    ipcarg_t cols;      /**< Framebuffer columns */
70
    ipcarg_t cols;      /**< Framebuffer columns */
71
} fb_info;
71
} fb_info;
72
 
72
 
73
typedef struct {
73
typedef struct {
74
    keybuffer_t keybuffer;      /**< Buffer for incoming keys. */
74
    keybuffer_t keybuffer;      /**< Buffer for incoming keys. */
75
    /** Buffer for unsatisfied request for keys. */
75
    /** Buffer for unsatisfied request for keys. */
76
    FIFO_CREATE_STATIC(keyrequests, ipc_callid_t,
76
    FIFO_CREATE_STATIC(keyrequests, ipc_callid_t,
77
        MAX_KEYREQUESTS_BUFFERED); 
77
        MAX_KEYREQUESTS_BUFFERED); 
78
    int keyrequest_counter;     /**< Number of requests in buffer. */
78
    int keyrequest_counter;     /**< Number of requests in buffer. */
79
    int client_phone;       /**< Phone to connected client. */
79
    int client_phone;       /**< Phone to connected client. */
80
    int used;           /**< 1 if this virtual console is
80
    int used;           /**< 1 if this virtual console is
81
                     * connected to some client.*/
81
                     * connected to some client.*/
82
    screenbuffer_t screenbuffer;    /**< Screenbuffer for saving screen
82
    screenbuffer_t screenbuffer;    /**< Screenbuffer for saving screen
83
                     * contents and related settings. */
83
                     * contents and related settings. */
84
} connection_t;
84
} connection_t;
85
 
85
 
86
static connection_t connections[CONSOLE_COUNT]; /**< Array of data for virtual
86
static connection_t connections[CONSOLE_COUNT]; /**< Array of data for virtual
87
                         * consoles */
87
                         * consoles */
88
static keyfield_t *interbuffer = NULL;      /**< Pointer to memory shared
88
static keyfield_t *interbuffer = NULL;      /**< Pointer to memory shared
89
                         * with framebufer used for
89
                         * with framebufer used for
90
                         * faster virtual console
90
                         * faster virtual console
91
                         * switching */
91
                         * switching */
-
 
92
/** Size of fb_buf. */
-
 
93
#define FB_BUF_SIZE 256
-
 
94
 
-
 
95
/** Buffer for sending characters to FB driver. */
-
 
96
static char fb_buf[FB_BUF_SIZE];
-
 
97
 
-
 
98
/* Properties of fb_buf data. */
-
 
99
static int fb_buf_row;      /**< Row where fb_buf data belong. */
-
 
100
static int fb_buf_col;      /**< Column where fb_buf data start. */
-
 
101
static int fb_console;      /**< VC to which fb_buf data belong. */
-
 
102
int fb_bi = 0;          /**< Number of valid chars in fb_buf. */
-
 
103
 
-
 
104
/** Size of cwrite_buf. */
-
 
105
#define CWRITE_BUF_SIZE 256
-
 
106
 
-
 
107
/** Buffer for receiving data via the CONSOLE_WRITE call from the client. */
-
 
108
static char cwrite_buf[CWRITE_BUF_SIZE];
92
 
109
 
93
 
110
 
94
/** Find unused virtual console.
111
/** Find unused virtual console.
95
 *
112
 *
96
 */
113
 */
97
static int find_free_connection(void)
114
static int find_free_connection(void)
98
{
115
{
99
    int i;
116
    int i;
100
   
117
   
101
    for (i = 0; i < CONSOLE_COUNT; i++) {
118
    for (i = 0; i < CONSOLE_COUNT; i++) {
102
        if (!connections[i].used)
119
        if (!connections[i].used)
103
            return i;
120
            return i;
104
    }
121
    }
105
    return -1;
122
    return -1;
106
}
123
}
107
 
124
 
108
static void clrscr(void)
125
static void clrscr(void)
109
{
126
{
110
    async_msg_0(fb_info.phone, FB_CLEAR);
127
    async_msg_0(fb_info.phone, FB_CLEAR);
111
}
128
}
112
 
129
 
113
static void curs_visibility(bool visible)
130
static void curs_visibility(bool visible)
114
{
131
{
115
    async_msg_1(fb_info.phone, FB_CURSOR_VISIBILITY, visible);
132
    async_msg_1(fb_info.phone, FB_CURSOR_VISIBILITY, visible);
116
}
133
}
117
 
134
 
118
static void curs_hide_sync(void)
135
static void curs_hide_sync(void)
119
{
136
{
120
    ipc_call_sync_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false);
137
    ipc_call_sync_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false);
121
}
138
}
122
 
139
 
123
static void curs_goto(int row, int col)
140
static void curs_goto(int row, int col)
124
{
141
{
125
    async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col);
142
    async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col);
126
}
143
}
127
 
144
 
128
static void set_style(int style)
145
static void set_style(int style)
129
{
146
{
130
    async_msg_1(fb_info.phone, FB_SET_STYLE, style);
147
    async_msg_1(fb_info.phone, FB_SET_STYLE, style);
131
}
148
}
132
 
149
 
133
static void set_color(int fgcolor, int bgcolor, int flags)
150
static void set_color(int fgcolor, int bgcolor, int flags)
134
{
151
{
135
    async_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags);
152
    async_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags);
136
}
153
}
137
 
154
 
138
static void set_rgb_color(int fgcolor, int bgcolor)
155
static void set_rgb_color(int fgcolor, int bgcolor)
139
{
156
{
140
    async_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
157
    async_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
141
}
158
}
142
 
159
 
143
static void set_attrs(attrs_t *attrs)
160
static void set_attrs(attrs_t *attrs)
144
{
161
{
145
    switch (attrs->t) {
162
    switch (attrs->t) {
146
    case at_style:
163
    case at_style:
147
        set_style(attrs->a.s.style);
164
        set_style(attrs->a.s.style);
148
        break;
165
        break;
149
 
166
 
150
    case at_idx:
167
    case at_idx:
151
        set_color(attrs->a.i.fg_color, attrs->a.i.bg_color,
168
        set_color(attrs->a.i.fg_color, attrs->a.i.bg_color,
152
            attrs->a.i.flags);
169
            attrs->a.i.flags);
153
        break;
170
        break;
154
 
171
 
155
    case at_rgb:
172
    case at_rgb:
156
        set_rgb_color(attrs->a.r.fg_color, attrs->a.r.bg_color);
173
        set_rgb_color(attrs->a.r.fg_color, attrs->a.r.bg_color);
157
        break;
174
        break;
158
    }
175
    }
159
}
176
}
160
 
177
 
-
 
178
/** Write a character vector to FB driver via IPC. */
-
 
179
static ssize_t fb_write(const char *buf, size_t nbyte, int row, int col)
-
 
180
{
-
 
181
    ipcarg_t rc;
-
 
182
    ipc_call_t answer;
-
 
183
    aid_t req;
-
 
184
 
-
 
185
    async_serialize_start();
-
 
186
   
-
 
187
    req = async_send_2(fb_info.phone, FB_WRITE, row, col, &answer);
-
 
188
    rc = ipc_data_write_start(fb_info.phone, (void *) buf, nbyte);
-
 
189
 
-
 
190
    if (rc != EOK) {
-
 
191
        async_wait_for(req, NULL);
-
 
192
        async_serialize_end();
-
 
193
        return (ssize_t) rc;
-
 
194
    }
-
 
195
 
-
 
196
    async_wait_for(req, &rc);
-
 
197
    async_serialize_end();
-
 
198
 
-
 
199
    if (rc == EOK)
-
 
200
        return (ssize_t) IPC_GET_ARG1(answer);
-
 
201
    else
-
 
202
        return -1;
-
 
203
}
-
 
204
 
-
 
205
/** Flush buffered characters to FB. */
-
 
206
static void fb_buf_flush(void)
-
 
207
{
-
 
208
    screenbuffer_t *scr;
-
 
209
    int i;
-
 
210
 
-
 
211
    scr = &(connections[fb_console].screenbuffer);
-
 
212
 
-
 
213
    if (fb_bi > 0) {
-
 
214
        if (fb_write(fb_buf, fb_bi, fb_buf_row, fb_buf_col) < 0) {
-
 
215
            /* Try falling back to char-by-char. */
-
 
216
            for (i = 0; i < fb_bi; i++) {
-
 
217
                async_msg_3(fb_info.phone, FB_PUTCHAR, fb_buf[i],
-
 
218
                    fb_buf_row, fb_buf_col + i);
-
 
219
            }
-
 
220
        }
-
 
221
        fb_bi = 0;
-
 
222
    }
-
 
223
}
-
 
224
 
-
 
225
/** Print a character to the active VC with buffering. */
161
static void prtchr(char c, int row, int col)
226
static void prtchr(char c, int row, int col)
162
{
227
{
-
 
228
    if (fb_bi >= FB_BUF_SIZE)
-
 
229
        fb_buf_flush();
-
 
230
 
-
 
231
    if (fb_bi == 0) {
-
 
232
        fb_buf_row = row;
-
 
233
        fb_buf_col = col;
163
    async_msg_3(fb_info.phone, FB_PUTCHAR, c, row, col);
234
        fb_console = active_console;
-
 
235
    }
-
 
236
 
-
 
237
    fb_buf[fb_bi++] = c;
164
}
238
}
165
 
239
 
166
/** Check key and process special keys.
240
/** Check key and process special keys.
167
 *
241
 *
168
 *
242
 *
169
 */
243
 */
170
static void write_char(int console, char key)
244
static void write_char(int console, char key)
171
{
245
{
-
 
246
    bool flush_cursor = false;
172
    screenbuffer_t *scr = &(connections[console].screenbuffer);
247
    screenbuffer_t *scr = &(connections[console].screenbuffer);
173
   
248
 
174
    switch (key) {
249
    switch (key) {
175
    case '\n':
250
    case '\n':
-
 
251
        fb_buf_flush();
-
 
252
        flush_cursor = true;
176
        scr->position_y++;
253
        scr->position_y++;
177
        scr->position_x = 0;
254
        scr->position_x = 0;
178
        break;
255
        break;
179
    case '\r':
256
    case '\r':
-
 
257
        fb_buf_flush();
180
        break;
258
        break;
181
    case '\t':
259
    case '\t':
-
 
260
        fb_buf_flush();
182
        scr->position_x += 8;
261
        scr->position_x += 8;
183
        scr->position_x -= scr->position_x % 8;
262
        scr->position_x -= scr->position_x % 8;
184
        break;
263
        break;
185
    case '\b':
264
    case '\b':
-
 
265
        fb_buf_flush();
186
        if (scr->position_x == 0)
266
        if (scr->position_x == 0)
187
            break;
267
            break;
188
        scr->position_x--;
268
        scr->position_x--;
189
        if (console == active_console)
269
        if (console == active_console)
190
            prtchr(' ', scr->position_y, scr->position_x);
270
            prtchr(' ', scr->position_y, scr->position_x);
191
        screenbuffer_putchar(scr, ' ');
271
        screenbuffer_putchar(scr, ' ');
192
        break;
272
        break;
193
    default:   
273
    default:   
194
        if (console == active_console)
274
        if (console == active_console)
195
            prtchr(key, scr->position_y, scr->position_x);
275
            prtchr(key, scr->position_y, scr->position_x);
196
 
276
 
197
        screenbuffer_putchar(scr, key);
277
        screenbuffer_putchar(scr, key);
198
        scr->position_x++;
278
        scr->position_x++;
199
    }
279
    }
200
   
280
 
201
    scr->position_y += (scr->position_x >= scr->size_x);
281
    if (scr->position_x >= scr->size_x) {
-
 
282
        fb_buf_flush();
-
 
283
        flush_cursor = true;
-
 
284
        scr->position_y++;
-
 
285
    }
202
   
286
   
203
    if (scr->position_y >= scr->size_y) {
287
    if (scr->position_y >= scr->size_y) {
204
        scr->position_y = scr->size_y - 1;
288
        scr->position_y = scr->size_y - 1;
205
        screenbuffer_clear_line(scr, scr->top_line);
289
        screenbuffer_clear_line(scr, scr->top_line);
206
        scr->top_line = (scr->top_line + 1) % scr->size_y;
290
        scr->top_line = (scr->top_line + 1) % scr->size_y;
207
        if (console == active_console)
291
        if (console == active_console)
208
            async_msg_1(fb_info.phone, FB_SCROLL, 1);
292
            async_msg_1(fb_info.phone, FB_SCROLL, 1);
209
    }
293
    }
210
   
294
 
211
    scr->position_x = scr->position_x % scr->size_x;
295
    scr->position_x = scr->position_x % scr->size_x;
212
   
296
 
213
    if (console == active_console)
297
    if (console == active_console && flush_cursor)
214
        curs_goto(scr->position_y, scr->position_x);
298
        curs_goto(scr->position_y, scr->position_x);
215
   
-
 
216
}
299
}
217
 
300
 
218
/** Switch to new console */
301
/** Switch to new console */
219
static void change_console(int newcons)
302
static void change_console(int newcons)
220
{
303
{
221
    connection_t *conn;
304
    connection_t *conn;
222
    int i, j, rc;
305
    int i, j, rc;
223
    keyfield_t *field;
306
    keyfield_t *field;
224
    attrs_t *attrs;
307
    attrs_t *attrs;
225
   
308
   
226
    if (newcons == active_console)
309
    if (newcons == active_console)
227
        return;
310
        return;
-
 
311
 
-
 
312
    fb_buf_flush();
228
   
313
 
229
    if (newcons == KERNEL_CONSOLE) {
314
    if (newcons == KERNEL_CONSOLE) {
230
        async_serialize_start();
315
        async_serialize_start();
231
        curs_hide_sync();
316
        curs_hide_sync();
232
        gcons_in_kernel();
317
        gcons_in_kernel();
233
        async_serialize_end();
318
        async_serialize_end();
234
       
319
       
235
        if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {
320
        if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {
236
            prev_console = active_console;
321
            prev_console = active_console;
237
            active_console = KERNEL_CONSOLE;
322
            active_console = KERNEL_CONSOLE;
238
        } else
323
        } else
239
            newcons = active_console;
324
            newcons = active_console;
240
    }
325
    }
241
   
326
   
242
    if (newcons != KERNEL_CONSOLE) {
327
    if (newcons != KERNEL_CONSOLE) {
243
        async_serialize_start();
328
        async_serialize_start();
244
       
329
       
245
        if (active_console == KERNEL_CONSOLE)
330
        if (active_console == KERNEL_CONSOLE)
246
            gcons_redraw_console();
331
            gcons_redraw_console();
247
       
332
       
248
        active_console = newcons;
333
        active_console = newcons;
249
        gcons_change_console(newcons);
334
        gcons_change_console(newcons);
250
        conn = &connections[active_console];
335
        conn = &connections[active_console];
251
       
336
       
252
        set_attrs(&conn->screenbuffer.attrs);
337
        set_attrs(&conn->screenbuffer.attrs);
253
        curs_visibility(false);
338
        curs_visibility(false);
254
        if (interbuffer) {
339
        if (interbuffer) {
255
            for (i = 0; i < conn->screenbuffer.size_x; i++)
340
            for (i = 0; i < conn->screenbuffer.size_x; i++)
256
                for (j = 0; j < conn->screenbuffer.size_y; j++) {
341
                for (j = 0; j < conn->screenbuffer.size_y; j++) {
257
                    unsigned int size_x;
342
                    unsigned int size_x;
258
                   
343
                   
259
                    size_x = conn->screenbuffer.size_x;
344
                    size_x = conn->screenbuffer.size_x;
260
                    interbuffer[i + j * size_x] =
345
                    interbuffer[i + j * size_x] =
261
                        *get_field_at(&conn->screenbuffer, i, j);
346
                        *get_field_at(&conn->screenbuffer, i, j);
262
                }
347
                }
263
            /* This call can preempt, but we are already at the end */
348
            /* This call can preempt, but we are already at the end */
264
            rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA);
349
            rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA);
265
        }
350
        }
266
       
351
       
267
        if ((!interbuffer) || (rc != 0)) {
352
        if ((!interbuffer) || (rc != 0)) {
268
            set_attrs(&conn->screenbuffer.attrs);
353
            set_attrs(&conn->screenbuffer.attrs);
269
            clrscr();
354
            clrscr();
270
            attrs = &conn->screenbuffer.attrs;
355
            attrs = &conn->screenbuffer.attrs;
271
           
356
           
272
            for (j = 0; j < conn->screenbuffer.size_y; j++)
357
            for (j = 0; j < conn->screenbuffer.size_y; j++)
273
                for (i = 0; i < conn->screenbuffer.size_x; i++) {
358
                for (i = 0; i < conn->screenbuffer.size_x; i++) {
274
                    field = get_field_at(&conn->screenbuffer, i, j);
359
                    field = get_field_at(&conn->screenbuffer, i, j);
275
                    if (!attrs_same(*attrs, field->attrs))
360
                    if (!attrs_same(*attrs, field->attrs))
276
                        set_attrs(&field->attrs);
361
                        set_attrs(&field->attrs);
277
                    attrs = &field->attrs;
362
                    attrs = &field->attrs;
278
                    if ((field->character == ' ') &&
363
                    if ((field->character == ' ') &&
279
                        (attrs_same(field->attrs,
364
                        (attrs_same(field->attrs,
280
                        conn->screenbuffer.attrs)))
365
                        conn->screenbuffer.attrs)))
281
                        continue;
366
                        continue;
282
 
367
 
283
                    prtchr(field->character, j, i);
368
                    prtchr(field->character, j, i);
284
                }
369
                }
285
        }
370
        }
286
       
371
       
287
        curs_goto(conn->screenbuffer.position_y,
372
        curs_goto(conn->screenbuffer.position_y,
288
            conn->screenbuffer.position_x);
373
            conn->screenbuffer.position_x);
289
        curs_visibility(conn->screenbuffer.is_cursor_visible);
374
        curs_visibility(conn->screenbuffer.is_cursor_visible);
290
       
375
       
291
        async_serialize_end();
376
        async_serialize_end();
292
    }
377
    }
293
}
378
}
294
 
379
 
295
/** Handler for keyboard */
380
/** Handler for keyboard */
296
static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
381
static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
297
{
382
{
298
    ipc_callid_t callid;
383
    ipc_callid_t callid;
299
    ipc_call_t call;
384
    ipc_call_t call;
300
    int retval;
385
    int retval;
301
    kbd_event_t ev;
386
    kbd_event_t ev;
302
    connection_t *conn;
387
    connection_t *conn;
303
    int newcon;
388
    int newcon;
304
   
389
   
305
    /* Ignore parameters, the connection is alread opened */
390
    /* Ignore parameters, the connection is alread opened */
306
    while (1) {
391
    while (1) {
307
        callid = async_get_call(&call);
392
        callid = async_get_call(&call);
308
        switch (IPC_GET_METHOD(call)) {
393
        switch (IPC_GET_METHOD(call)) {
309
        case IPC_M_PHONE_HUNGUP:
394
        case IPC_M_PHONE_HUNGUP:
310
            /* TODO: Handle hangup */
395
            /* TODO: Handle hangup */
311
            return;
396
            return;
312
        case KBD_MS_LEFT:
397
        case KBD_MS_LEFT:
313
            newcon = gcons_mouse_btn(IPC_GET_ARG1(call));
398
            newcon = gcons_mouse_btn(IPC_GET_ARG1(call));
314
            if (newcon != -1)
399
            if (newcon != -1)
315
                change_console(newcon);
400
                change_console(newcon);
316
            retval = 0;
401
            retval = 0;
317
            break;
402
            break;
318
        case KBD_MS_MOVE:
403
        case KBD_MS_MOVE:
319
            gcons_mouse_move(IPC_GET_ARG1(call),
404
            gcons_mouse_move(IPC_GET_ARG1(call),
320
                IPC_GET_ARG2(call));
405
                IPC_GET_ARG2(call));
321
            retval = 0;
406
            retval = 0;
322
            break;
407
            break;
323
        case KBD_EVENT:
408
        case KBD_EVENT:
324
            /* Got event from keyboard driver. */
409
            /* Got event from keyboard driver. */
325
            retval = 0;
410
            retval = 0;
326
            ev.type = IPC_GET_ARG1(call);
411
            ev.type = IPC_GET_ARG1(call);
327
            ev.key = IPC_GET_ARG2(call);
412
            ev.key = IPC_GET_ARG2(call);
328
            ev.mods = IPC_GET_ARG3(call);
413
            ev.mods = IPC_GET_ARG3(call);
329
            ev.c = IPC_GET_ARG4(call);
414
            ev.c = IPC_GET_ARG4(call);
330
           
415
           
331
            /* switch to another virtual console */
416
            /* switch to another virtual console */
332
           
417
           
333
            conn = &connections[active_console];
418
            conn = &connections[active_console];
334
 
419
 
335
            if ((ev.key >= KC_F1) && (ev.key < KC_F1 +
420
            if ((ev.key >= KC_F1) && (ev.key < KC_F1 +
336
                CONSOLE_COUNT)) {
421
                CONSOLE_COUNT)) {
337
                if (ev.key == KC_F12)
422
                if (ev.key == KC_F12)
338
                    change_console(KERNEL_CONSOLE);
423
                    change_console(KERNEL_CONSOLE);
339
                else
424
                else
340
                    change_console(ev.key - KC_F1);
425
                    change_console(ev.key - KC_F1);
341
                break;
426
                break;
342
            }
427
            }
343
           
428
           
344
            /* if client is awaiting key, send it */
429
            /* if client is awaiting key, send it */
345
            if (conn->keyrequest_counter > 0) {    
430
            if (conn->keyrequest_counter > 0) {    
346
                conn->keyrequest_counter--;
431
                conn->keyrequest_counter--;
347
                ipc_answer_4(fifo_pop(conn->keyrequests), EOK,
432
                ipc_answer_4(fifo_pop(conn->keyrequests), EOK,
348
                    ev.type, ev.key, ev.mods, ev.c);
433
                    ev.type, ev.key, ev.mods, ev.c);
349
                break;
434
                break;
350
            }
435
            }
351
 
436
 
352
            keybuffer_push(&conn->keybuffer, &ev);
437
            keybuffer_push(&conn->keybuffer, &ev);
353
            retval = 0;
438
            retval = 0;
354
 
439
 
355
            break;
440
            break;
356
        default:
441
        default:
357
            retval = ENOENT;
442
            retval = ENOENT;
358
        }
443
        }
359
        ipc_answer_0(callid, retval);
444
        ipc_answer_0(callid, retval);
360
    }
445
    }
361
}
446
}
362
 
447
 
-
 
448
/** Handle CONSOLE_WRITE call. */
-
 
449
static void cons_write(int consnum, ipc_callid_t rid, ipc_call_t *request)
-
 
450
{
-
 
451
    ipc_callid_t callid;
-
 
452
    size_t len;
-
 
453
    size_t i;
-
 
454
 
-
 
455
    if (!ipc_data_write_receive(&callid, &len)) {
-
 
456
        ipc_answer_0(callid, EINVAL);
-
 
457
        ipc_answer_0(rid, EINVAL);
-
 
458
    }
-
 
459
 
-
 
460
    if (len > CWRITE_BUF_SIZE)
-
 
461
        len = CWRITE_BUF_SIZE;
-
 
462
 
-
 
463
    (void) ipc_data_write_finalize(callid, cwrite_buf, len);
-
 
464
 
-
 
465
    for (i = 0; i < len; i++) {
-
 
466
        write_char(consnum, cwrite_buf[i]);
-
 
467
    }
-
 
468
 
-
 
469
    gcons_notify_char(consnum);
-
 
470
    ipc_answer_1(rid, EOK, len);
-
 
471
}
-
 
472
 
363
/** Default thread for new connections */
473
/** Default thread for new connections */
364
static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
474
static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
365
{
475
{
366
    ipc_callid_t callid;
476
    ipc_callid_t callid;
367
    ipc_call_t call;
477
    ipc_call_t call;
368
    int consnum;
478
    int consnum;
369
    ipcarg_t arg1, arg2, arg3, arg4;
479
    ipcarg_t arg1, arg2, arg3, arg4;
370
    connection_t *conn;
480
    connection_t *conn;
371
   
481
   
372
    if ((consnum = find_free_connection()) == -1) {
482
    if ((consnum = find_free_connection()) == -1) {
373
        ipc_answer_0(iid, ELIMIT);
483
        ipc_answer_0(iid, ELIMIT);
374
        return;
484
        return;
375
    }
485
    }
376
    conn = &connections[consnum];
486
    conn = &connections[consnum];
377
    conn->used = 1;
487
    conn->used = 1;
378
   
488
   
379
    async_serialize_start();
489
    async_serialize_start();
380
    gcons_notify_connect(consnum);
490
    gcons_notify_connect(consnum);
381
    conn->client_phone = IPC_GET_ARG5(*icall);
491
    conn->client_phone = IPC_GET_ARG5(*icall);
382
    screenbuffer_clear(&conn->screenbuffer);
492
    screenbuffer_clear(&conn->screenbuffer);
383
   
493
   
384
    /* Accept the connection */
494
    /* Accept the connection */
385
    ipc_answer_0(iid, EOK);
495
    ipc_answer_0(iid, EOK);
386
   
496
   
387
    while (1) {
497
    while (1) {
388
        async_serialize_end();
498
        async_serialize_end();
389
        callid = async_get_call(&call);
499
        callid = async_get_call(&call);
390
        async_serialize_start();
500
        async_serialize_start();
391
       
501
       
392
        arg1 = 0;
502
        arg1 = 0;
393
        arg2 = 0;
503
        arg2 = 0;
394
        arg3 = 0;
504
        arg3 = 0;
395
        arg4 = 0;
505
        arg4 = 0;
396
 
506
 
397
        switch (IPC_GET_METHOD(call)) {
507
        switch (IPC_GET_METHOD(call)) {
398
        case IPC_M_PHONE_HUNGUP:
508
        case IPC_M_PHONE_HUNGUP:
399
            gcons_notify_disconnect(consnum);
509
            gcons_notify_disconnect(consnum);
400
           
510
           
401
            /* Answer all pending requests */
511
            /* Answer all pending requests */
402
            while (conn->keyrequest_counter > 0) {
512
            while (conn->keyrequest_counter > 0) {
403
                conn->keyrequest_counter--;
513
                conn->keyrequest_counter--;
404
                ipc_answer_0(fifo_pop(conn->keyrequests),
514
                ipc_answer_0(fifo_pop(conn->keyrequests),
405
                    ENOENT);
515
                    ENOENT);
406
                break;
516
                break;
407
            }
517
            }
408
            conn->used = 0;
518
            conn->used = 0;
409
            return;
519
            return;
410
        case CONSOLE_PUTCHAR:
520
        case CONSOLE_PUTCHAR:
411
            write_char(consnum, IPC_GET_ARG1(call));
521
            write_char(consnum, IPC_GET_ARG1(call));
412
            gcons_notify_char(consnum);
522
            gcons_notify_char(consnum);
413
            break;
523
            break;
-
 
524
        case CONSOLE_WRITE:
-
 
525
            cons_write(consnum, callid, &call);
-
 
526
            continue;
414
        case CONSOLE_CLEAR:
527
        case CONSOLE_CLEAR:
415
            /* Send message to fb */
528
            /* Send message to fb */
416
            if (consnum == active_console) {
529
            if (consnum == active_console) {
417
                async_msg_0(fb_info.phone, FB_CLEAR);
530
                async_msg_0(fb_info.phone, FB_CLEAR);
418
            }
531
            }
419
           
532
           
420
            screenbuffer_clear(&conn->screenbuffer);
533
            screenbuffer_clear(&conn->screenbuffer);
421
           
534
           
422
            break;
535
            break;
423
        case CONSOLE_GOTO:
536
        case CONSOLE_GOTO:
-
 
537
            fb_buf_flush();
424
            screenbuffer_goto(&conn->screenbuffer,
538
            screenbuffer_goto(&conn->screenbuffer,
425
                IPC_GET_ARG2(call), IPC_GET_ARG1(call));
539
                IPC_GET_ARG2(call), IPC_GET_ARG1(call));
426
            if (consnum == active_console)
540
            if (consnum == active_console)
427
                curs_goto(IPC_GET_ARG1(call),
541
                curs_goto(IPC_GET_ARG1(call),
428
                    IPC_GET_ARG2(call));
542
                    IPC_GET_ARG2(call));
429
            break;
543
            break;
430
        case CONSOLE_GETSIZE:
544
        case CONSOLE_GETSIZE:
431
            arg1 = fb_info.rows;
545
            arg1 = fb_info.rows;
432
            arg2 = fb_info.cols;
546
            arg2 = fb_info.cols;
433
            break;
547
            break;
434
        case CONSOLE_FLUSH:
548
        case CONSOLE_FLUSH:
-
 
549
            fb_buf_flush();
435
            if (consnum == active_console)
550
            if (consnum == active_console)
436
                async_req_0_0(fb_info.phone, FB_FLUSH);
551
                async_req_0_0(fb_info.phone, FB_FLUSH);
437
            break;
552
            break;
438
        case CONSOLE_SET_STYLE:
553
        case CONSOLE_SET_STYLE:
-
 
554
            fb_buf_flush();
439
            arg1 = IPC_GET_ARG1(call);
555
            arg1 = IPC_GET_ARG1(call);
440
            screenbuffer_set_style(&conn->screenbuffer, arg1);
556
            screenbuffer_set_style(&conn->screenbuffer, arg1);
441
            if (consnum == active_console)
557
            if (consnum == active_console)
442
                set_style(arg1);
558
                set_style(arg1);
443
            break;
559
            break;
444
        case CONSOLE_SET_COLOR:
560
        case CONSOLE_SET_COLOR:
-
 
561
            fb_buf_flush();
445
            arg1 = IPC_GET_ARG1(call);
562
            arg1 = IPC_GET_ARG1(call);
446
            arg2 = IPC_GET_ARG2(call);
563
            arg2 = IPC_GET_ARG2(call);
447
            arg3 = IPC_GET_ARG3(call);
564
            arg3 = IPC_GET_ARG3(call);
448
            screenbuffer_set_color(&conn->screenbuffer, arg1,
565
            screenbuffer_set_color(&conn->screenbuffer, arg1,
449
                arg2, arg3);
566
                arg2, arg3);
450
            if (consnum == active_console)
567
            if (consnum == active_console)
451
                set_color(arg1, arg2, arg3);
568
                set_color(arg1, arg2, arg3);
452
            break;
569
            break;
453
        case CONSOLE_SET_RGB_COLOR:
570
        case CONSOLE_SET_RGB_COLOR:
-
 
571
            fb_buf_flush();
454
            arg1 = IPC_GET_ARG1(call);
572
            arg1 = IPC_GET_ARG1(call);
455
            arg2 = IPC_GET_ARG2(call);
573
            arg2 = IPC_GET_ARG2(call);
456
            screenbuffer_set_rgb_color(&conn->screenbuffer, arg1,
574
            screenbuffer_set_rgb_color(&conn->screenbuffer, arg1,
457
                arg2);
575
                arg2);
458
            if (consnum == active_console)
576
            if (consnum == active_console)
459
                set_rgb_color(arg1, arg2);
577
                set_rgb_color(arg1, arg2);
460
            break;
578
            break;
461
        case CONSOLE_CURSOR_VISIBILITY:
579
        case CONSOLE_CURSOR_VISIBILITY:
-
 
580
            fb_buf_flush();
462
            arg1 = IPC_GET_ARG1(call);
581
            arg1 = IPC_GET_ARG1(call);
463
            conn->screenbuffer.is_cursor_visible = arg1;
582
            conn->screenbuffer.is_cursor_visible = arg1;
464
            if (consnum == active_console)
583
            if (consnum == active_console)
465
                curs_visibility(arg1);
584
                curs_visibility(arg1);
466
            break;
585
            break;
467
        case CONSOLE_GETKEY:
586
        case CONSOLE_GETKEY:
468
            if (keybuffer_empty(&conn->keybuffer)) {
587
            if (keybuffer_empty(&conn->keybuffer)) {
469
                /* buffer is empty -> store request */
588
                /* buffer is empty -> store request */
470
                if (conn->keyrequest_counter <
589
                if (conn->keyrequest_counter <
471
                    MAX_KEYREQUESTS_BUFFERED) {
590
                    MAX_KEYREQUESTS_BUFFERED) {
472
                    fifo_push(conn->keyrequests, callid);
591
                    fifo_push(conn->keyrequests, callid);
473
                    conn->keyrequest_counter++;
592
                    conn->keyrequest_counter++;
474
                } else {
593
                } else {
475
                    /*
594
                    /*
476
                     * No key available and too many
595
                     * No key available and too many
477
                     * requests => fail.
596
                     * requests => fail.
478
                    */
597
                    */
479
                    ipc_answer_0(callid, ELIMIT);
598
                    ipc_answer_0(callid, ELIMIT);
480
                }
599
                }
481
                continue;
600
                continue;
482
            }
601
            }
483
            kbd_event_t ev;
602
            kbd_event_t ev;
484
            keybuffer_pop(&conn->keybuffer, &ev);
603
            keybuffer_pop(&conn->keybuffer, &ev);
485
            arg1 = ev.type;
604
            arg1 = ev.type;
486
            arg2 = ev.key;
605
            arg2 = ev.key;
487
            arg3 = ev.mods;
606
            arg3 = ev.mods;
488
            arg4 = ev.c;
607
            arg4 = ev.c;
489
            break;
608
            break;
490
        }
609
        }
491
        ipc_answer_4(callid, EOK, arg1, arg2, arg3, arg4);
610
        ipc_answer_4(callid, EOK, arg1, arg2, arg3, arg4);
492
    }
611
    }
493
}
612
}
494
 
613
 
495
static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
614
static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
496
{
615
{
497
    change_console(prev_console);
616
    change_console(prev_console);
498
}
617
}
499
 
618
 
500
int main(int argc, char *argv[])
619
int main(int argc, char *argv[])
501
{
620
{
502
    printf(NAME ": HelenOS Console service\n");
621
    printf(NAME ": HelenOS Console service\n");
503
   
622
   
504
    ipcarg_t phonehash;
623
    ipcarg_t phonehash;
505
    int kbd_phone;
624
    int kbd_phone;
506
    size_t ib_size;
625
    size_t ib_size;
507
    int i;
626
    int i;
508
   
627
   
509
    async_set_client_connection(client_connection);
628
    async_set_client_connection(client_connection);
510
   
629
   
511
    /* Connect to keyboard driver */
630
    /* Connect to keyboard driver */
512
    kbd_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_KEYBOARD, 0, 0);
631
    kbd_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_KEYBOARD, 0, 0);
513
    if (kbd_phone < 0) {
632
    if (kbd_phone < 0) {
514
        printf(NAME ": Failed to connect to keyboard service\n");
633
        printf(NAME ": Failed to connect to keyboard service\n");
515
        return -1;
634
        return -1;
516
    }
635
    }
517
   
636
   
518
    if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
637
    if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
519
        printf(NAME ": Failed to create callback from keyboard service\n");
638
        printf(NAME ": Failed to create callback from keyboard service\n");
520
        return -1;
639
        return -1;
521
    }
640
    }
522
   
641
   
523
    async_new_connection(phonehash, 0, NULL, keyboard_events);
642
    async_new_connection(phonehash, 0, NULL, keyboard_events);
524
   
643
   
525
    /* Connect to framebuffer driver */
644
    /* Connect to framebuffer driver */
526
    fb_info.phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VIDEO, 0, 0);
645
    fb_info.phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VIDEO, 0, 0);
527
    if (fb_info.phone < 0) {
646
    if (fb_info.phone < 0) {
528
        printf(NAME ": Failed to connect to video service\n");
647
        printf(NAME ": Failed to connect to video service\n");
529
        return -1;
648
        return -1;
530
    }
649
    }
531
   
650
   
532
    /* Disable kernel output to the console */
651
    /* Disable kernel output to the console */
533
    __SYSCALL0(SYS_DEBUG_DISABLE_CONSOLE);
652
    __SYSCALL0(SYS_DEBUG_DISABLE_CONSOLE);
534
   
653
   
535
    /* Initialize gcons */
654
    /* Initialize gcons */
536
    gcons_init(fb_info.phone);
655
    gcons_init(fb_info.phone);
537
    /* Synchronize, the gcons can have something in queue */
656
    /* Synchronize, the gcons can have something in queue */
538
    async_req_0_0(fb_info.phone, FB_FLUSH);
657
    async_req_0_0(fb_info.phone, FB_FLUSH);
539
   
658
   
540
    async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.rows,
659
    async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.rows,
541
        &fb_info.cols);
660
        &fb_info.cols);
542
    set_rgb_color(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
661
    set_rgb_color(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
543
    clrscr();
662
    clrscr();
544
   
663
   
545
    /* Init virtual consoles */
664
    /* Init virtual consoles */
546
    for (i = 0; i < CONSOLE_COUNT; i++) {
665
    for (i = 0; i < CONSOLE_COUNT; i++) {
547
        connections[i].used = 0;
666
        connections[i].used = 0;
548
        keybuffer_init(&connections[i].keybuffer);
667
        keybuffer_init(&connections[i].keybuffer);
549
       
668
       
550
        connections[i].keyrequests.head = 0;
669
        connections[i].keyrequests.head = 0;
551
        connections[i].keyrequests.tail = 0;
670
        connections[i].keyrequests.tail = 0;
552
        connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED;
671
        connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED;
553
        connections[i].keyrequest_counter = 0;
672
        connections[i].keyrequest_counter = 0;
554
       
673
       
555
        if (screenbuffer_init(&connections[i].screenbuffer,
674
        if (screenbuffer_init(&connections[i].screenbuffer,
556
            fb_info.cols, fb_info.rows) == NULL) {
675
            fb_info.cols, fb_info.rows) == NULL) {
557
            /* FIXME: handle error */
676
            /* FIXME: handle error */
558
            return -1;
677
            return -1;
559
        }
678
        }
560
    }
679
    }
561
    connections[KERNEL_CONSOLE].used = 1;
680
    connections[KERNEL_CONSOLE].used = 1;
562
 
681
 
563
    /* Set up shared memory buffer. */
682
    /* Set up shared memory buffer. */
564
    ib_size = sizeof(keyfield_t) * fb_info.cols * fb_info.rows;
683
    ib_size = sizeof(keyfield_t) * fb_info.cols * fb_info.rows;
565
    interbuffer = as_get_mappable_page(ib_size);
684
    interbuffer = as_get_mappable_page(ib_size);
566
 
685
 
567
    if (as_area_create(interbuffer, ib_size, AS_AREA_READ |
686
    if (as_area_create(interbuffer, ib_size, AS_AREA_READ |
568
        AS_AREA_WRITE | AS_AREA_CACHEABLE) != interbuffer) {
687
        AS_AREA_WRITE | AS_AREA_CACHEABLE) != interbuffer) {
569
        interbuffer = NULL;
688
        interbuffer = NULL;
570
    }
689
    }
571
 
690
 
572
    if (interbuffer) {
691
    if (interbuffer) {
573
        if (ipc_share_out_start(fb_info.phone, interbuffer,
692
        if (ipc_share_out_start(fb_info.phone, interbuffer,
574
            AS_AREA_READ) != EOK) {
693
            AS_AREA_READ) != EOK) {
575
            as_area_destroy(interbuffer);
694
            as_area_destroy(interbuffer);
576
            interbuffer = NULL;
695
            interbuffer = NULL;
577
        }
696
        }
578
    }
697
    }
579
   
698
   
580
    curs_goto(0, 0);
699
    curs_goto(0, 0);
581
    curs_visibility(
700
    curs_visibility(
582
        connections[active_console].screenbuffer.is_cursor_visible);
701
        connections[active_console].screenbuffer.is_cursor_visible);
583
   
702
   
584
    /* Register at NS */
703
    /* Register at NS */
585
    if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, 0, &phonehash) != 0)
704
    if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, 0, &phonehash) != 0)
586
        return -1;
705
        return -1;
587
   
706
   
588
    /* Receive kernel notifications */
707
    /* Receive kernel notifications */
589
//  if (sysinfo_value("kconsole.present")) {
708
//  if (sysinfo_value("kconsole.present")) {
590
//      int inr = sysinfo_value("kconsole.inr");
709
//      int inr = sysinfo_value("kconsole.inr");
591
//      if (ipc_register_irq(inr, device_assign_devno(), 0, NULL) != EOK)
710
//      if (ipc_register_irq(inr, device_assign_devno(), 0, NULL) != EOK)
592
//          printf(NAME ": Error registering kconsole notifications\n");
711
//          printf(NAME ": Error registering kconsole notifications\n");
593
//      
712
//      
594
//      async_set_interrupt_received(interrupt_received);
713
//      async_set_interrupt_received(interrupt_received);
595
//  }
714
//  }
596
   
715
   
597
    // FIXME: avoid connectiong to itself, keep using klog
716
    // FIXME: avoid connectiong to itself, keep using klog
598
    // printf(NAME ": Accepting connections\n");
717
    // printf(NAME ": Accepting connections\n");
599
    async_manager();
718
    async_manager();
600
   
719
   
601
    return 0;
720
    return 0;
602
}
721
}
603
 
722
 
604
/** @}
723
/** @}
605
 */
724
 */
606
 
725