Subversion Repositories HelenOS

Rev

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

Rev 4142 Rev 4164
1
/*
1
/*
2
 * Copyright (c) 2006 Ondrej Palkovsky
2
 * Copyright (c) 2006 Ondrej Palkovsky
3
 * Copyright (c) 2008 Martin Decky
3
 * Copyright (c) 2008 Martin Decky
4
 * Copyright (c) 2008 Pavel Rimsky
4
 * Copyright (c) 2008 Pavel Rimsky
5
 * All rights reserved.
5
 * All rights reserved.
6
 *
6
 *
7
 * Redistribution and use in source and binary forms, with or without
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
8
 * modification, are permitted provided that the following conditions
9
 * are met:
9
 * are met:
10
 *
10
 *
11
 * - Redistributions of source code must retain the above copyright
11
 * - Redistributions of source code must retain the above copyright
12
 *   notice, this list of conditions and the following disclaimer.
12
 *   notice, this list of conditions and the following disclaimer.
13
 * - Redistributions in binary form must reproduce the above copyright
13
 * - Redistributions in binary form must reproduce the above copyright
14
 *   notice, this list of conditions and the following disclaimer in the
14
 *   notice, this list of conditions and the following disclaimer in the
15
 *   documentation and/or other materials provided with the distribution.
15
 *   documentation and/or other materials provided with the distribution.
16
 * - The name of the author may not be used to endorse or promote products
16
 * - The name of the author may not be used to endorse or promote products
17
 *   derived from this software without specific prior written permission.
17
 *   derived from this software without specific prior written permission.
18
 *
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
29
 */
30
 
30
 
31
/**
31
/**
32
 * @defgroup serial Serial console
32
 * @defgroup serial Serial console
33
 * @brief    Serial console services (putc, puts, clear screen, cursor goto,...)
33
 * @brief    Serial console services (putc, puts, clear screen, cursor goto,...)
34
 * @{
34
 * @{
35
 */
35
 */
36
 
36
 
37
/** @file
37
/** @file
38
 */
38
 */
39
 
39
 
40
#include <stdio.h>
40
#include <stdio.h>
41
#include <ipc/ipc.h>
41
#include <ipc/ipc.h>
42
#include <async.h>
42
#include <async.h>
43
#include <ipc/fb.h>
43
#include <ipc/fb.h>
44
#include <bool.h>
44
#include <bool.h>
45
#include <errno.h>
45
#include <errno.h>
46
#include <console/color.h>
46
#include <console/color.h>
47
#include <console/style.h>
47
#include <console/style.h>
48
 
48
 
49
#include "../console/screenbuffer.h"
49
#include "../console/screenbuffer.h"
50
#include "main.h"
50
#include "main.h"
51
#include "serial_console.h"
51
#include "serial_console.h"
52
 
52
 
53
#define MAX_CONTROL 20
53
#define MAX_CONTROL 20
54
 
54
 
55
static void serial_sgr(const unsigned int mode);
55
static void serial_sgr(const unsigned int mode);
56
 
56
 
57
static int scr_width;
57
static int scr_width;
58
static int scr_height;
58
static int scr_height;
59
static bool color = true;   /** True if producing color output. */
59
static bool color = true;   /** True if producing color output. */
60
static putc_function_t putc_function;
60
static putc_function_t putc_function;
61
 
61
 
62
/* Allow only 1 connection */
62
/* Allow only 1 connection */
63
static int client_connected = 0;
63
static int client_connected = 0;
64
 
64
 
65
enum sgr_color_index {
65
enum sgr_color_index {
66
    CI_BLACK    = 0,
66
    CI_BLACK    = 0,
67
    CI_RED      = 1,
67
    CI_RED      = 1,
68
    CI_GREEN    = 2,
68
    CI_GREEN    = 2,
69
    CI_BROWN    = 3,
69
    CI_BROWN    = 3,
70
    CI_BLUE     = 4,
70
    CI_BLUE     = 4,
71
    CI_MAGENTA  = 5,
71
    CI_MAGENTA  = 5,
72
    CI_CYAN     = 6,
72
    CI_CYAN     = 6,
73
    CI_WHITE    = 7,
73
    CI_WHITE    = 7,
74
};
74
};
75
 
75
 
76
enum sgr_command {
76
enum sgr_command {
77
    SGR_RESET   = 0,
77
    SGR_RESET   = 0,
78
    SGR_BOLD    = 1,
78
    SGR_BOLD    = 1,
79
    SGR_BLINK   = 5,
79
    SGR_BLINK   = 5,
80
    SGR_REVERSE = 7,
80
    SGR_REVERSE = 7,
81
    SGR_NORMAL_INT  = 22,
81
    SGR_NORMAL_INT  = 22,
82
    SGR_BLINK_OFF   = 25,
82
    SGR_BLINK_OFF   = 25,
83
    SGR_REVERSE_OFF = 27,
83
    SGR_REVERSE_OFF = 27,
84
    SGR_FGCOLOR = 30,
84
    SGR_FGCOLOR = 30,
85
    SGR_BGCOLOR = 40
85
    SGR_BGCOLOR = 40
86
};
86
};
87
 
87
 
88
static int color_map[] = {
88
static int color_map[] = {
89
    [COLOR_BLACK]   = CI_BLACK,
89
    [COLOR_BLACK]   = CI_BLACK,
90
    [COLOR_BLUE]    = CI_RED,
90
    [COLOR_BLUE]    = CI_RED,
91
    [COLOR_GREEN]   = CI_GREEN,
91
    [COLOR_GREEN]   = CI_GREEN,
92
    [COLOR_CYAN]    = CI_CYAN,
92
    [COLOR_CYAN]    = CI_CYAN,
93
    [COLOR_RED] = CI_RED,
93
    [COLOR_RED] = CI_RED,
94
    [COLOR_MAGENTA] = CI_MAGENTA,
94
    [COLOR_MAGENTA] = CI_MAGENTA,
95
    [COLOR_YELLOW]  = CI_BROWN,
95
    [COLOR_YELLOW]  = CI_BROWN,
96
    [COLOR_WHITE]   = CI_WHITE
96
    [COLOR_WHITE]   = CI_WHITE
97
};
97
};
98
 
98
 
99
void serial_puts(char *str)
99
void serial_puts(char *str)
100
{
100
{
101
    while (*str)
101
    while (*str)
102
        putc_function(*(str++));
102
        putc_function(*(str++));
103
}
103
}
104
 
104
 
105
void serial_goto(const unsigned int row, const unsigned int col)
105
void serial_goto(const unsigned int row, const unsigned int col)
106
{
106
{
107
    if ((row > scr_height) || (col > scr_width))
107
    if ((row > scr_height) || (col > scr_width))
108
        return;
108
        return;
109
   
109
   
110
    char control[MAX_CONTROL];
110
    char control[MAX_CONTROL];
111
    snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1);
111
    snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1);
112
    serial_puts(control);
112
    serial_puts(control);
113
}
113
}
114
 
114
 
115
void serial_clrscr(void)
115
void serial_clrscr(void)
116
{
116
{
117
    /* Initialize graphic rendition attributes. */
117
    /* Initialize graphic rendition attributes. */
118
    serial_sgr(SGR_RESET);
118
    serial_sgr(SGR_RESET);
119
    if (color) {
119
    if (color) {
120
        serial_sgr(SGR_FGCOLOR + CI_BLACK);
120
        serial_sgr(SGR_FGCOLOR + CI_BLACK);
121
        serial_sgr(SGR_BGCOLOR + CI_WHITE);
121
        serial_sgr(SGR_BGCOLOR + CI_WHITE);
122
    }
122
    }
123
 
123
 
124
    serial_puts("\033[2J");
124
    serial_puts("\033[2J");
125
}
125
}
126
 
126
 
127
void serial_scroll(int i)
127
void serial_scroll(int i)
128
{
128
{
129
    if (i > 0) {
129
    if (i > 0) {
130
        serial_goto(scr_height - 1, 0);
130
        serial_goto(scr_height - 1, 0);
131
        while (i--)
131
        while (i--)
132
            serial_puts("\033D");
132
            serial_puts("\033D");
133
    } else if (i < 0) {
133
    } else if (i < 0) {
134
        serial_goto(0, 0);
134
        serial_goto(0, 0);
135
        while (i++)
135
        while (i++)
136
            serial_puts("\033M");
136
            serial_puts("\033M");
137
    }
137
    }
138
}
138
}
139
 
139
 
140
/** ECMA-48 Set Graphics Rendition. */
140
/** ECMA-48 Set Graphics Rendition. */
141
static void serial_sgr(const unsigned int mode)
141
static void serial_sgr(const unsigned int mode)
142
{
142
{
143
    char control[MAX_CONTROL];
143
    char control[MAX_CONTROL];
144
    snprintf(control, MAX_CONTROL, "\033[%um", mode);
144
    snprintf(control, MAX_CONTROL, "\033[%um", mode);
145
    serial_puts(control);
145
    serial_puts(control);
146
}
146
}
147
 
147
 
148
/** Set scrolling region. */
148
/** Set scrolling region. */
149
void serial_set_scroll_region(unsigned last_row)
149
void serial_set_scroll_region(unsigned last_row)
150
{
150
{
151
    char control[MAX_CONTROL];
151
    char control[MAX_CONTROL];
152
    snprintf(control, MAX_CONTROL, "\033[0;%ur", last_row);
152
    snprintf(control, MAX_CONTROL, "\033[0;%ur", last_row);
153
    serial_puts(control);
153
    serial_puts(control);
154
}
154
}
155
 
155
 
156
void serial_cursor_disable(void)
156
void serial_cursor_disable(void)
157
{
157
{
158
    serial_puts("\033[?25l");
158
    serial_puts("\033[?25l");
159
}
159
}
160
 
160
 
161
void serial_cursor_enable(void)
161
void serial_cursor_enable(void)
162
{
162
{
163
    serial_puts("\033[?25h");
163
    serial_puts("\033[?25h");
164
}
164
}
165
 
165
 
166
void serial_console_init(putc_function_t putc_fn, uint32_t w, uint32_t h)
166
void serial_console_init(putc_function_t putc_fn, uint32_t w, uint32_t h)
167
{
167
{
168
    scr_width = w;
168
    scr_width = w;
169
    scr_height = h;
169
    scr_height = h;
170
    putc_function = putc_fn;
170
    putc_function = putc_fn;
171
}
171
}
172
 
172
 
173
static void serial_set_style(int style)
173
static void serial_set_style(int style)
174
{
174
{
175
    if (style == STYLE_EMPHASIS) {
175
    if (style == STYLE_EMPHASIS) {
176
        if (color) {
176
        if (color) {
177
            serial_sgr(SGR_RESET);
177
            serial_sgr(SGR_RESET);
178
            serial_sgr(SGR_FGCOLOR + CI_RED);
178
            serial_sgr(SGR_FGCOLOR + CI_RED);
179
            serial_sgr(SGR_BGCOLOR + CI_WHITE);
179
            serial_sgr(SGR_BGCOLOR + CI_WHITE);
180
        }
180
        }
181
        serial_sgr(SGR_BOLD);
181
        serial_sgr(SGR_BOLD);
182
    } else {
182
    } else {
183
        if (color) {
183
        if (color) {
184
            serial_sgr(SGR_RESET);
184
            serial_sgr(SGR_RESET);
185
            serial_sgr(SGR_FGCOLOR + CI_BLACK);
185
            serial_sgr(SGR_FGCOLOR + CI_BLACK);
186
            serial_sgr(SGR_BGCOLOR + CI_WHITE);
186
            serial_sgr(SGR_BGCOLOR + CI_WHITE);
187
        }
187
        }
188
        serial_sgr(SGR_NORMAL_INT);
188
        serial_sgr(SGR_NORMAL_INT);
189
    }
189
    }
190
}
190
}
191
 
191
 
192
static void serial_set_idx(unsigned fgcolor, unsigned bgcolor,
192
static void serial_set_idx(unsigned fgcolor, unsigned bgcolor,
193
    unsigned flags)
193
    unsigned flags)
194
{
194
{
195
    if (color) {
195
    if (color) {
196
        serial_sgr(SGR_RESET);
196
        serial_sgr(SGR_RESET);
197
        serial_sgr(SGR_FGCOLOR + color_map[fgcolor]);
197
        serial_sgr(SGR_FGCOLOR + color_map[fgcolor]);
198
        serial_sgr(SGR_BGCOLOR + color_map[bgcolor]);
198
        serial_sgr(SGR_BGCOLOR + color_map[bgcolor]);
199
    } else {
199
    } else {
200
        if (fgcolor < bgcolor)
200
        if (fgcolor < bgcolor)
201
            serial_sgr(SGR_RESET);
201
            serial_sgr(SGR_RESET);
202
        else
202
        else
203
            serial_sgr(SGR_REVERSE);
203
            serial_sgr(SGR_REVERSE);
204
    }  
204
    }  
205
}
205
}
206
 
206
 
207
static void serial_set_rgb(uint32_t fgcolor, uint32_t bgcolor)
207
static void serial_set_rgb(uint32_t fgcolor, uint32_t bgcolor)
208
{
208
{
209
    if (fgcolor < bgcolor)
209
    if (fgcolor < bgcolor)
210
        serial_sgr(SGR_REVERSE_OFF);
210
        serial_sgr(SGR_REVERSE_OFF);
211
    else
211
    else
212
        serial_sgr(SGR_REVERSE);   
212
        serial_sgr(SGR_REVERSE);   
213
}
213
}
214
 
214
 
215
static void serial_set_attrs(const attrs_t *a)
215
static void serial_set_attrs(const attrs_t *a)
216
{
216
{
217
    switch (a->t) {
217
    switch (a->t) {
218
    case at_style: serial_set_style(a->a.s.style); break;
218
    case at_style: serial_set_style(a->a.s.style); break;
219
    case at_rgb: serial_set_rgb(a->a.r.fg_color, a->a.r.bg_color); break;
219
    case at_rgb: serial_set_rgb(a->a.r.fg_color, a->a.r.bg_color); break;
220
    case at_idx: serial_set_idx(a->a.i.fg_color,
220
    case at_idx: serial_set_idx(a->a.i.fg_color,
221
        a->a.i.bg_color, a->a.i.flags); break;
221
        a->a.i.bg_color, a->a.i.flags); break;
222
    default: break;
222
    default: break;
223
    }
223
    }
224
}
224
}
225
 
225
 
226
static void draw_text_data(keyfield_t *data)
226
static void draw_text_data(keyfield_t *data)
227
{
227
{
228
    int i, j;
228
    int i, j;
229
    attrs_t *a0, *a1;
229
    attrs_t *a0, *a1;
230
 
230
 
231
    serial_goto(0, 0);
231
    serial_goto(0, 0);
232
    a0 = &data[0].attrs;
232
    a0 = &data[0].attrs;
233
    serial_set_attrs(a0);
233
    serial_set_attrs(a0);
234
 
234
 
235
    for (i = 0; i < scr_height; i++) {
235
    for (i = 0; i < scr_height; i++) {
236
        for (j = 0; j < scr_width; j++) {
236
        for (j = 0; j < scr_width; j++) {
237
            a1 = &data[i * scr_width + j].attrs;
237
            a1 = &data[i * scr_width + j].attrs;
238
            if (!attrs_same(*a0, *a1))
238
            if (!attrs_same(*a0, *a1))
239
                serial_set_attrs(a1);
239
                serial_set_attrs(a1);
240
            (*putc_function)(data[i * scr_width + j].character);
240
            (*putc_function)(data[i * scr_width + j].character);
241
            a0 = a1;
241
            a0 = a1;
242
        }
242
        }
243
    }
243
    }
244
}
244
}
245
 
245
 
-
 
246
int lastcol = 0;
-
 
247
int lastrow = 0;
-
 
248
 
-
 
249
#define FB_WRITE_BUF_SIZE 256
-
 
250
static char fb_write_buf[FB_WRITE_BUF_SIZE];
-
 
251
 
-
 
252
static void fb_write(ipc_callid_t rid, ipc_call_t *request)
-
 
253
{
-
 
254
    int row, col;
-
 
255
    ipc_callid_t callid;
-
 
256
    size_t len;
-
 
257
    size_t i;
-
 
258
 
-
 
259
    row = IPC_GET_ARG1(*request);
-
 
260
    col = IPC_GET_ARG2(*request);
-
 
261
 
-
 
262
    if ((col >= scr_width) || (row >= scr_height)) {
-
 
263
        ipc_answer_0(callid, EINVAL);
-
 
264
        ipc_answer_0(rid, EINVAL);
-
 
265
        return;
-
 
266
    }
-
 
267
 
-
 
268
    if (!ipc_data_write_receive(&callid, &len)) {
-
 
269
        ipc_answer_0(callid, EINVAL);
-
 
270
        ipc_answer_0(rid, EINVAL);
-
 
271
        return;
-
 
272
    }
-
 
273
 
-
 
274
    if (len > FB_WRITE_BUF_SIZE)
-
 
275
        len = FB_WRITE_BUF_SIZE;
-
 
276
    if (len >= scr_width - col)
-
 
277
        len = scr_width - col;
-
 
278
 
-
 
279
    (void) ipc_data_write_finalize(callid, fb_write_buf, len);
-
 
280
 
-
 
281
    if ((lastcol != col) || (lastrow != row))
-
 
282
        serial_goto(row, col);
-
 
283
 
-
 
284
    for (i = 0; i < len; i++) {
-
 
285
        (*putc_function)(fb_write_buf[i]);
-
 
286
    }
-
 
287
 
-
 
288
    lastcol = col + len;
-
 
289
    lastrow = row;
-
 
290
 
-
 
291
    ipc_answer_1(rid, EOK, len);
-
 
292
}
-
 
293
 
246
/**
294
/**
247
 * Main function of the thread serving client connections.
295
 * Main function of the thread serving client connections.
248
 */
296
 */
249
void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall)
297
void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall)
250
{
298
{
251
    int retval;
299
    int retval;
252
    ipc_callid_t callid;
300
    ipc_callid_t callid;
253
    ipc_call_t call;
301
    ipc_call_t call;
254
    keyfield_t *interbuf = NULL;
302
    keyfield_t *interbuf = NULL;
255
    size_t intersize = 0;
303
    size_t intersize = 0;
256
 
304
 
257
    char c;
305
    char c;
258
    int lastcol = 0;
-
 
259
    int lastrow = 0;
-
 
260
    int newcol;
306
    int newcol;
261
    int newrow;
307
    int newrow;
262
    int fgcolor;
308
    int fgcolor;
263
    int bgcolor;
309
    int bgcolor;
264
    int flags;
310
    int flags;
265
    int style;
311
    int style;
266
    int i;
312
    int i;
267
 
313
 
268
   
314
   
269
    if (client_connected) {
315
    if (client_connected) {
270
        ipc_answer_0(iid, ELIMIT);
316
        ipc_answer_0(iid, ELIMIT);
271
        return;
317
        return;
272
    }
318
    }
273
   
319
   
274
    client_connected = 1;
320
    client_connected = 1;
275
    ipc_answer_0(iid, EOK);
321
    ipc_answer_0(iid, EOK);
276
   
322
   
277
    /* Clear the terminal, set scrolling region
323
    /* Clear the terminal, set scrolling region
278
       to 0 - height rows. */
324
       to 0 - height rows. */
279
    serial_clrscr();
325
    serial_clrscr();
280
    serial_goto(0, 0);
326
    serial_goto(0, 0);
281
    serial_set_scroll_region(scr_height);
327
    serial_set_scroll_region(scr_height);
282
   
328
   
283
    while (true) {
329
    while (true) {
284
        callid = async_get_call(&call);
330
        callid = async_get_call(&call);
285
        switch (IPC_GET_METHOD(call)) {
331
        switch (IPC_GET_METHOD(call)) {
286
        case IPC_M_PHONE_HUNGUP:
332
        case IPC_M_PHONE_HUNGUP:
287
            client_connected = 0;
333
            client_connected = 0;
288
            ipc_answer_0(callid, EOK);
334
            ipc_answer_0(callid, EOK);
289
            return;
335
            return;
290
        case IPC_M_SHARE_OUT:
336
        case IPC_M_SHARE_OUT:
291
            /* We accept one area for data interchange */
337
            /* We accept one area for data interchange */
292
            intersize = IPC_GET_ARG2(call);
338
            intersize = IPC_GET_ARG2(call);
293
            if (intersize >= scr_width * scr_height *
339
            if (intersize >= scr_width * scr_height *
294
                sizeof(*interbuf)) {
340
                sizeof(*interbuf)) {
295
                receive_comm_area(callid, &call,
341
                receive_comm_area(callid, &call,
296
                    (void *) &interbuf);
342
                    (void *) &interbuf);
297
                continue;
343
                continue;
298
            }
344
            }
299
            retval = EINVAL;
345
            retval = EINVAL;
300
            break;
346
            break;
301
        case FB_DRAW_TEXT_DATA:
347
        case FB_DRAW_TEXT_DATA:
302
            if (!interbuf) {
348
            if (!interbuf) {
303
                retval = EINVAL;
349
                retval = EINVAL;
304
                break;
350
                break;
305
            }
351
            }
306
            draw_text_data(interbuf);
352
            draw_text_data(interbuf);
307
            retval = 0;
353
            retval = 0;
308
            break;
354
            break;
309
        case FB_PUTCHAR:
355
        case FB_PUTCHAR:
310
            c = IPC_GET_ARG1(call);
356
            c = IPC_GET_ARG1(call);
311
            newrow = IPC_GET_ARG2(call);
357
            newrow = IPC_GET_ARG2(call);
312
            newcol = IPC_GET_ARG3(call);
358
            newcol = IPC_GET_ARG3(call);
313
            if ((lastcol != newcol) || (lastrow != newrow))
359
            if ((lastcol != newcol) || (lastrow != newrow))
314
                serial_goto(newrow, newcol);
360
                serial_goto(newrow, newcol);
315
            lastcol = newcol + 1;
361
            lastcol = newcol + 1;
316
            lastrow = newrow;
362
            lastrow = newrow;
317
            (*putc_function)(c);
363
            (*putc_function)(c);
318
            retval = 0;
364
            retval = 0;
319
            break;
365
            break;
-
 
366
        case FB_WRITE:
-
 
367
            fb_write(callid, &call);
-
 
368
           
-
 
369
            /* Message already answered */
-
 
370
            continue;
320
        case FB_CURSOR_GOTO:
371
        case FB_CURSOR_GOTO:
321
            newrow = IPC_GET_ARG1(call);
372
            newrow = IPC_GET_ARG1(call);
322
            newcol = IPC_GET_ARG2(call);
373
            newcol = IPC_GET_ARG2(call);
323
            serial_goto(newrow, newcol);
374
            serial_goto(newrow, newcol);
324
            lastrow = newrow;
375
            lastrow = newrow;
325
            lastcol = newcol;
376
            lastcol = newcol;
326
            retval = 0;
377
            retval = 0;
327
            break;
378
            break;
328
        case FB_GET_CSIZE:
379
        case FB_GET_CSIZE:
329
            ipc_answer_2(callid, EOK, scr_height, scr_width);
380
            ipc_answer_2(callid, EOK, scr_height, scr_width);
330
            continue;
381
            continue;
331
        case FB_CLEAR:
382
        case FB_CLEAR:
332
            serial_clrscr();
383
            serial_clrscr();
333
            retval = 0;
384
            retval = 0;
334
            break;
385
            break;
335
        case FB_SET_STYLE:
386
        case FB_SET_STYLE:
336
            style = IPC_GET_ARG1(call);
387
            style = IPC_GET_ARG1(call);
337
            serial_set_style(style);
388
            serial_set_style(style);
338
            retval = 0;
389
            retval = 0;
339
            break;
390
            break;
340
        case FB_SET_COLOR:
391
        case FB_SET_COLOR:
341
            fgcolor = IPC_GET_ARG1(call);
392
            fgcolor = IPC_GET_ARG1(call);
342
            bgcolor = IPC_GET_ARG2(call);
393
            bgcolor = IPC_GET_ARG2(call);
343
            flags = IPC_GET_ARG3(call);
394
            flags = IPC_GET_ARG3(call);
344
 
395
 
345
            serial_set_idx(fgcolor, bgcolor, flags);
396
            serial_set_idx(fgcolor, bgcolor, flags);
346
            retval = 0;
397
            retval = 0;
347
            break;
398
            break;
348
        case FB_SET_RGB_COLOR:
399
        case FB_SET_RGB_COLOR:
349
            fgcolor = IPC_GET_ARG1(call);
400
            fgcolor = IPC_GET_ARG1(call);
350
            bgcolor = IPC_GET_ARG2(call);
401
            bgcolor = IPC_GET_ARG2(call);
351
 
402
 
352
            serial_set_rgb(fgcolor, bgcolor);
403
            serial_set_rgb(fgcolor, bgcolor);
353
            retval = 0;
404
            retval = 0;
354
            break;
405
            break;
355
        case FB_SCROLL:
406
        case FB_SCROLL:
356
            i = IPC_GET_ARG1(call);
407
            i = IPC_GET_ARG1(call);
357
            if ((i > scr_height) || (i < -scr_height)) {
408
            if ((i > scr_height) || (i < -scr_height)) {
358
                retval = EINVAL;
409
                retval = EINVAL;
359
                break;
410
                break;
360
            }
411
            }
361
            serial_scroll(i);
412
            serial_scroll(i);
362
            serial_goto(lastrow, lastcol);
413
            serial_goto(lastrow, lastcol);
363
            retval = 0;
414
            retval = 0;
364
            break;
415
            break;
365
        case FB_CURSOR_VISIBILITY:
416
        case FB_CURSOR_VISIBILITY:
366
            if(IPC_GET_ARG1(call))
417
            if(IPC_GET_ARG1(call))
367
                serial_cursor_enable();
418
                serial_cursor_enable();
368
            else
419
            else
369
                serial_cursor_disable();
420
                serial_cursor_disable();
370
            retval = 0;
421
            retval = 0;
371
            break;
422
            break;
372
        default:
423
        default:
373
            retval = ENOENT;
424
            retval = ENOENT;
374
        }
425
        }
375
        ipc_answer_0(callid, retval);
426
        ipc_answer_0(callid, retval);
376
    }
427
    }
377
}
428
}
378
 
429
 
379
/**
430
/**
380
 * @}
431
 * @}
381
 */
432
 */
382
 
433