Subversion Repositories HelenOS

Rev

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

Rev 4167 Rev 4211
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_putchar(wchar_t ch)
-
 
106
{
-
 
107
    (*putc_function)(ch);
-
 
108
}
-
 
109
 
105
void serial_goto(const unsigned int row, const unsigned int col)
110
void serial_goto(const unsigned int row, const unsigned int col)
106
{
111
{
107
    if ((row > scr_height) || (col > scr_width))
112
    if ((row > scr_height) || (col > scr_width))
108
        return;
113
        return;
109
   
114
   
110
    char control[MAX_CONTROL];
115
    char control[MAX_CONTROL];
111
    snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1);
116
    snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1);
112
    serial_puts(control);
117
    serial_puts(control);
113
}
118
}
114
 
119
 
115
void serial_clrscr(void)
120
void serial_clrscr(void)
116
{
121
{
117
    /* Initialize graphic rendition attributes. */
122
    /* Initialize graphic rendition attributes. */
118
    serial_sgr(SGR_RESET);
123
    serial_sgr(SGR_RESET);
119
    if (color) {
124
    if (color) {
120
        serial_sgr(SGR_FGCOLOR + CI_BLACK);
125
        serial_sgr(SGR_FGCOLOR + CI_BLACK);
121
        serial_sgr(SGR_BGCOLOR + CI_WHITE);
126
        serial_sgr(SGR_BGCOLOR + CI_WHITE);
122
    }
127
    }
123
 
128
 
124
    serial_puts("\033[2J");
129
    serial_puts("\033[2J");
125
}
130
}
126
 
131
 
127
void serial_scroll(int i)
132
void serial_scroll(int i)
128
{
133
{
129
    if (i > 0) {
134
    if (i > 0) {
130
        serial_goto(scr_height - 1, 0);
135
        serial_goto(scr_height - 1, 0);
131
        while (i--)
136
        while (i--)
132
            serial_puts("\033D");
137
            serial_puts("\033D");
133
    } else if (i < 0) {
138
    } else if (i < 0) {
134
        serial_goto(0, 0);
139
        serial_goto(0, 0);
135
        while (i++)
140
        while (i++)
136
            serial_puts("\033M");
141
            serial_puts("\033M");
137
    }
142
    }
138
}
143
}
139
 
144
 
140
/** ECMA-48 Set Graphics Rendition. */
145
/** ECMA-48 Set Graphics Rendition. */
141
static void serial_sgr(const unsigned int mode)
146
static void serial_sgr(const unsigned int mode)
142
{
147
{
143
    char control[MAX_CONTROL];
148
    char control[MAX_CONTROL];
144
    snprintf(control, MAX_CONTROL, "\033[%um", mode);
149
    snprintf(control, MAX_CONTROL, "\033[%um", mode);
145
    serial_puts(control);
150
    serial_puts(control);
146
}
151
}
147
 
152
 
148
/** Set scrolling region. */
153
/** Set scrolling region. */
149
void serial_set_scroll_region(unsigned last_row)
154
void serial_set_scroll_region(unsigned last_row)
150
{
155
{
151
    char control[MAX_CONTROL];
156
    char control[MAX_CONTROL];
152
    snprintf(control, MAX_CONTROL, "\033[0;%ur", last_row);
157
    snprintf(control, MAX_CONTROL, "\033[0;%ur", last_row);
153
    serial_puts(control);
158
    serial_puts(control);
154
}
159
}
155
 
160
 
156
void serial_cursor_disable(void)
161
void serial_cursor_disable(void)
157
{
162
{
158
    serial_puts("\033[?25l");
163
    serial_puts("\033[?25l");
159
}
164
}
160
 
165
 
161
void serial_cursor_enable(void)
166
void serial_cursor_enable(void)
162
{
167
{
163
    serial_puts("\033[?25h");
168
    serial_puts("\033[?25h");
164
}
169
}
165
 
170
 
166
void serial_console_init(putc_function_t putc_fn, uint32_t w, uint32_t h)
171
void serial_console_init(putc_function_t putc_fn, uint32_t w, uint32_t h)
167
{
172
{
168
    scr_width = w;
173
    scr_width = w;
169
    scr_height = h;
174
    scr_height = h;
170
    putc_function = putc_fn;
175
    putc_function = putc_fn;
171
}
176
}
172
 
177
 
173
static void serial_set_style(int style)
178
static void serial_set_style(int style)
174
{
179
{
175
    if (style == STYLE_EMPHASIS) {
180
    if (style == STYLE_EMPHASIS) {
176
        if (color) {
181
        if (color) {
177
            serial_sgr(SGR_RESET);
182
            serial_sgr(SGR_RESET);
178
            serial_sgr(SGR_FGCOLOR + CI_RED);
183
            serial_sgr(SGR_FGCOLOR + CI_RED);
179
            serial_sgr(SGR_BGCOLOR + CI_WHITE);
184
            serial_sgr(SGR_BGCOLOR + CI_WHITE);
180
        }
185
        }
181
        serial_sgr(SGR_BOLD);
186
        serial_sgr(SGR_BOLD);
182
    } else {
187
    } else {
183
        if (color) {
188
        if (color) {
184
            serial_sgr(SGR_RESET);
189
            serial_sgr(SGR_RESET);
185
            serial_sgr(SGR_FGCOLOR + CI_BLACK);
190
            serial_sgr(SGR_FGCOLOR + CI_BLACK);
186
            serial_sgr(SGR_BGCOLOR + CI_WHITE);
191
            serial_sgr(SGR_BGCOLOR + CI_WHITE);
187
        }
192
        }
188
        serial_sgr(SGR_NORMAL_INT);
193
        serial_sgr(SGR_NORMAL_INT);
189
    }
194
    }
190
}
195
}
191
 
196
 
192
static void serial_set_idx(unsigned fgcolor, unsigned bgcolor,
197
static void serial_set_idx(unsigned fgcolor, unsigned bgcolor,
193
    unsigned flags)
198
    unsigned flags)
194
{
199
{
195
    if (color) {
200
    if (color) {
196
        serial_sgr(SGR_RESET);
201
        serial_sgr(SGR_RESET);
197
        serial_sgr(SGR_FGCOLOR + color_map[fgcolor]);
202
        serial_sgr(SGR_FGCOLOR + color_map[fgcolor]);
198
        serial_sgr(SGR_BGCOLOR + color_map[bgcolor]);
203
        serial_sgr(SGR_BGCOLOR + color_map[bgcolor]);
199
    } else {
204
    } else {
200
        if (fgcolor < bgcolor)
205
        if (fgcolor < bgcolor)
201
            serial_sgr(SGR_RESET);
206
            serial_sgr(SGR_RESET);
202
        else
207
        else
203
            serial_sgr(SGR_REVERSE);
208
            serial_sgr(SGR_REVERSE);
204
    }  
209
    }  
205
}
210
}
206
 
211
 
207
static void serial_set_rgb(uint32_t fgcolor, uint32_t bgcolor)
212
static void serial_set_rgb(uint32_t fgcolor, uint32_t bgcolor)
208
{
213
{
209
    if (fgcolor < bgcolor)
214
    if (fgcolor < bgcolor)
210
        serial_sgr(SGR_REVERSE_OFF);
215
        serial_sgr(SGR_REVERSE_OFF);
211
    else
216
    else
212
        serial_sgr(SGR_REVERSE);   
217
        serial_sgr(SGR_REVERSE);   
213
}
218
}
214
 
219
 
215
static void serial_set_attrs(const attrs_t *a)
220
static void serial_set_attrs(const attrs_t *a)
216
{
221
{
217
    switch (a->t) {
222
    switch (a->t) {
218
    case at_style: serial_set_style(a->a.s.style); break;
223
    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;
224
    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,
225
    case at_idx: serial_set_idx(a->a.i.fg_color,
221
        a->a.i.bg_color, a->a.i.flags); break;
226
        a->a.i.bg_color, a->a.i.flags); break;
222
    default: break;
227
    default: break;
223
    }
228
    }
224
}
229
}
225
 
230
 
226
/** Draw text data to viewport.
231
/** Draw text data to viewport.
227
 *
232
 *
228
 * @param vport Viewport id
233
 * @param vport Viewport id
229
 * @param data  Text data.
234
 * @param data  Text data.
230
 * @param x Leftmost column of the area.
235
 * @param x Leftmost column of the area.
231
 * @param y Topmost row of the area.
236
 * @param y Topmost row of the area.
232
 * @param w Number of rows.
237
 * @param w Number of rows.
233
 * @param h Number of columns.
238
 * @param h Number of columns.
234
 */
239
 */
235
static void draw_text_data(keyfield_t *data, unsigned int x,
240
static void draw_text_data(keyfield_t *data, unsigned int x,
236
    unsigned int y, unsigned int w, unsigned int h)
241
    unsigned int y, unsigned int w, unsigned int h)
237
{
242
{
238
    unsigned int i, j;
243
    unsigned int i, j;
239
    keyfield_t *field;
244
    keyfield_t *field;
240
    attrs_t *a0, *a1;
245
    attrs_t *a0, *a1;
241
 
246
 
242
    serial_goto(y, x);
247
    serial_goto(y, x);
243
    a0 = &data[0].attrs;
248
    a0 = &data[0].attrs;
244
    serial_set_attrs(a0);
249
    serial_set_attrs(a0);
245
 
250
 
246
    for (j = 0; j < h; j++) {
251
    for (j = 0; j < h; j++) {
247
        if (j > 0 && w != scr_width)
252
        if (j > 0 && w != scr_width)
248
            serial_goto(y, x);
253
            serial_goto(y, x);
249
 
254
 
250
        for (i = 0; i < w; i++) {
255
        for (i = 0; i < w; i++) {
251
            unsigned int col = x + i;
256
            unsigned int col = x + i;
252
            unsigned int row = y + j;
257
            unsigned int row = y + j;
253
 
258
 
254
            field = &data[j * w + i];
259
            field = &data[j * w + i];
255
 
260
 
256
            a1 = &field->attrs;
261
            a1 = &field->attrs;
257
            if (!attrs_same(*a0, *a1))
262
            if (!attrs_same(*a0, *a1))
258
                serial_set_attrs(a1);
263
                serial_set_attrs(a1);
259
            (*putc_function)(field->character);
264
            serial_putchar(field->character);
260
            a0 = a1;
265
            a0 = a1;
261
        }
266
        }
262
    }
267
    }
263
}
268
}
264
 
269
 
265
int lastcol = 0;
270
int lastcol = 0;
266
int lastrow = 0;
271
int lastrow = 0;
267
 
272
 
268
/**
273
/**
269
 * Main function of the thread serving client connections.
274
 * Main function of the thread serving client connections.
270
 */
275
 */
271
void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall)
276
void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall)
272
{
277
{
273
    int retval;
278
    int retval;
274
    ipc_callid_t callid;
279
    ipc_callid_t callid;
275
    ipc_call_t call;
280
    ipc_call_t call;
276
    keyfield_t *interbuf = NULL;
281
    keyfield_t *interbuf = NULL;
277
    size_t intersize = 0;
282
    size_t intersize = 0;
278
 
283
 
279
    char c;
284
    wchar_t c;
280
    int col, row, w, h;
285
    int col, row, w, h;
281
    int fgcolor;
286
    int fgcolor;
282
    int bgcolor;
287
    int bgcolor;
283
    int flags;
288
    int flags;
284
    int style;
289
    int style;
285
    int i;
290
    int i;
286
 
291
 
287
   
292
   
288
    if (client_connected) {
293
    if (client_connected) {
289
        ipc_answer_0(iid, ELIMIT);
294
        ipc_answer_0(iid, ELIMIT);
290
        return;
295
        return;
291
    }
296
    }
292
   
297
   
293
    client_connected = 1;
298
    client_connected = 1;
294
    ipc_answer_0(iid, EOK);
299
    ipc_answer_0(iid, EOK);
295
   
300
   
296
    /* Clear the terminal, set scrolling region
301
    /* Clear the terminal, set scrolling region
297
       to 0 - height rows. */
302
       to 0 - height rows. */
298
    serial_clrscr();
303
    serial_clrscr();
299
    serial_goto(0, 0);
304
    serial_goto(0, 0);
300
    serial_set_scroll_region(scr_height);
305
    serial_set_scroll_region(scr_height);
301
   
306
   
302
    while (true) {
307
    while (true) {
303
        callid = async_get_call(&call);
308
        callid = async_get_call(&call);
304
        switch (IPC_GET_METHOD(call)) {
309
        switch (IPC_GET_METHOD(call)) {
305
        case IPC_M_PHONE_HUNGUP:
310
        case IPC_M_PHONE_HUNGUP:
306
            client_connected = 0;
311
            client_connected = 0;
307
            ipc_answer_0(callid, EOK);
312
            ipc_answer_0(callid, EOK);
308
            return;
313
            return;
309
        case IPC_M_SHARE_OUT:
314
        case IPC_M_SHARE_OUT:
310
            /* We accept one area for data interchange */
315
            /* We accept one area for data interchange */
311
            intersize = IPC_GET_ARG2(call);
316
            intersize = IPC_GET_ARG2(call);
312
            if (intersize >= scr_width * scr_height *
317
            if (intersize >= scr_width * scr_height *
313
                sizeof(*interbuf)) {
318
                sizeof(*interbuf)) {
314
                receive_comm_area(callid, &call,
319
                receive_comm_area(callid, &call,
315
                    (void *) &interbuf);
320
                    (void *) &interbuf);
316
                continue;
321
                continue;
317
            }
322
            }
318
            retval = EINVAL;
323
            retval = EINVAL;
319
            break;
324
            break;
320
        case FB_DRAW_TEXT_DATA:
325
        case FB_DRAW_TEXT_DATA:
321
            col = IPC_GET_ARG1(call);
326
            col = IPC_GET_ARG1(call);
322
            row = IPC_GET_ARG2(call);
327
            row = IPC_GET_ARG2(call);
323
            w = IPC_GET_ARG3(call);
328
            w = IPC_GET_ARG3(call);
324
            h = IPC_GET_ARG4(call);
329
            h = IPC_GET_ARG4(call);
325
            if (!interbuf) {
330
            if (!interbuf) {
326
                retval = EINVAL;
331
                retval = EINVAL;
327
                break;
332
                break;
328
            }
333
            }
329
            if (col + w > scr_width || row + h > scr_height) {
334
            if (col + w > scr_width || row + h > scr_height) {
330
                retval = EINVAL;
335
                retval = EINVAL;
331
                break;
336
                break;
332
            }
337
            }
333
            draw_text_data(interbuf, col, row, w, h);
338
            draw_text_data(interbuf, col, row, w, h);
334
            lastrow = row + h - 1;
339
            lastrow = row + h - 1;
335
            lastcol = col + w;
340
            lastcol = col + w;
336
            retval = 0;
341
            retval = 0;
337
            break;
342
            break;
338
        case FB_PUTCHAR:
343
        case FB_PUTCHAR:
339
            c = IPC_GET_ARG1(call);
344
            c = IPC_GET_ARG1(call);
340
            row = IPC_GET_ARG2(call);
345
            row = IPC_GET_ARG2(call);
341
            col = IPC_GET_ARG3(call);
346
            col = IPC_GET_ARG3(call);
342
            if ((lastcol != col) || (lastrow != row))
347
            if ((lastcol != col) || (lastrow != row))
343
                serial_goto(row, col);
348
                serial_goto(row, col);
344
            lastcol = col + 1;
349
            lastcol = col + 1;
345
            lastrow = row;
350
            lastrow = row;
346
            (*putc_function)(c);
351
            serial_putchar(c);
347
            retval = 0;
352
            retval = 0;
348
            break;
353
            break;
349
        case FB_CURSOR_GOTO:
354
        case FB_CURSOR_GOTO:
350
            row = IPC_GET_ARG1(call);
355
            row = IPC_GET_ARG1(call);
351
            col = IPC_GET_ARG2(call);
356
            col = IPC_GET_ARG2(call);
352
            serial_goto(row, col);
357
            serial_goto(row, col);
353
            lastrow = row;
358
            lastrow = row;
354
            lastcol = col;
359
            lastcol = col;
355
            retval = 0;
360
            retval = 0;
356
            break;
361
            break;
357
        case FB_GET_CSIZE:
362
        case FB_GET_CSIZE:
358
            ipc_answer_2(callid, EOK, scr_height, scr_width);
363
            ipc_answer_2(callid, EOK, scr_height, scr_width);
359
            continue;
364
            continue;
360
        case FB_CLEAR:
365
        case FB_CLEAR:
361
            serial_clrscr();
366
            serial_clrscr();
362
            retval = 0;
367
            retval = 0;
363
            break;
368
            break;
364
        case FB_SET_STYLE:
369
        case FB_SET_STYLE:
365
            style = IPC_GET_ARG1(call);
370
            style = IPC_GET_ARG1(call);
366
            serial_set_style(style);
371
            serial_set_style(style);
367
            retval = 0;
372
            retval = 0;
368
            break;
373
            break;
369
        case FB_SET_COLOR:
374
        case FB_SET_COLOR:
370
            fgcolor = IPC_GET_ARG1(call);
375
            fgcolor = IPC_GET_ARG1(call);
371
            bgcolor = IPC_GET_ARG2(call);
376
            bgcolor = IPC_GET_ARG2(call);
372
            flags = IPC_GET_ARG3(call);
377
            flags = IPC_GET_ARG3(call);
373
 
378
 
374
            serial_set_idx(fgcolor, bgcolor, flags);
379
            serial_set_idx(fgcolor, bgcolor, flags);
375
            retval = 0;
380
            retval = 0;
376
            break;
381
            break;
377
        case FB_SET_RGB_COLOR:
382
        case FB_SET_RGB_COLOR:
378
            fgcolor = IPC_GET_ARG1(call);
383
            fgcolor = IPC_GET_ARG1(call);
379
            bgcolor = IPC_GET_ARG2(call);
384
            bgcolor = IPC_GET_ARG2(call);
380
 
385
 
381
            serial_set_rgb(fgcolor, bgcolor);
386
            serial_set_rgb(fgcolor, bgcolor);
382
            retval = 0;
387
            retval = 0;
383
            break;
388
            break;
384
        case FB_SCROLL:
389
        case FB_SCROLL:
385
            i = IPC_GET_ARG1(call);
390
            i = IPC_GET_ARG1(call);
386
            if ((i > scr_height) || (i < -scr_height)) {
391
            if ((i > scr_height) || (i < -scr_height)) {
387
                retval = EINVAL;
392
                retval = EINVAL;
388
                break;
393
                break;
389
            }
394
            }
390
            serial_scroll(i);
395
            serial_scroll(i);
391
            serial_goto(lastrow, lastcol);
396
            serial_goto(lastrow, lastcol);
392
            retval = 0;
397
            retval = 0;
393
            break;
398
            break;
394
        case FB_CURSOR_VISIBILITY:
399
        case FB_CURSOR_VISIBILITY:
395
            if(IPC_GET_ARG1(call))
400
            if(IPC_GET_ARG1(call))
396
                serial_cursor_enable();
401
                serial_cursor_enable();
397
            else
402
            else
398
                serial_cursor_disable();
403
                serial_cursor_disable();
399
            retval = 0;
404
            retval = 0;
400
            break;
405
            break;
401
        default:
406
        default:
402
            retval = ENOENT;
407
            retval = ENOENT;
403
        }
408
        }
404
        ipc_answer_0(callid, retval);
409
        ipc_answer_0(callid, retval);
405
    }
410
    }
406
}
411
}
407
 
412
 
408
/**
413
/**
409
 * @}
414
 * @}
410
 */
415
 */
411
 
416