Subversion Repositories HelenOS

Rev

Rev 3761 | Rev 3791 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3761 Rev 3767
Line 38... Line 38...
38
#include <keys.h>
38
#include <keys.h>
39
#include <ipc/fb.h>
39
#include <ipc/fb.h>
40
#include <ipc/services.h>
40
#include <ipc/services.h>
41
#include <errno.h>
41
#include <errno.h>
42
#include <key_buffer.h>
42
#include <key_buffer.h>
43
#include <console.h>
-
 
44
#include <ipc/console.h>
43
#include <ipc/console.h>
45
#include <unistd.h>
44
#include <unistd.h>
46
#include <async.h>
45
#include <async.h>
47
#include <libadt/fifo.h>
46
#include <libadt/fifo.h>
48
#include <screenbuffer.h>
47
#include <screenbuffer.h>
49
#include <sys/mman.h>
48
#include <sys/mman.h>
50
#include <stdio.h>
49
#include <stdio.h>
51
#include <sysinfo.h>
50
#include <sysinfo.h>
52
 
51
 
-
 
52
#include "console.h"
53
#include "gcons.h"
53
#include "gcons.h"
54
 
54
 
55
#define MAX_KEYREQUESTS_BUFFERED 32
55
#define MAX_KEYREQUESTS_BUFFERED 32
56
 
56
 
57
#define NAME "console"
57
#define NAME "console"
Line 122... Line 122...
122
static void curs_goto(int row, int col)
122
static void curs_goto(int row, int col)
123
{
123
{
124
    async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col);
124
    async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col);
125
}
125
}
126
 
126
 
127
static void set_style(style_t *style)
127
static void set_style(int style)
128
{
128
{
129
    async_msg_2(fb_info.phone, FB_SET_STYLE, style->fg_color,
129
    async_msg_1(fb_info.phone, FB_SET_STYLE, style);
130
        style->bg_color);
-
 
131
}
130
}
132
 
131
 
133
static void set_style_col(int fgcolor, int bgcolor)
132
static void set_color(int fgcolor, int bgcolor, int flags)
134
{
133
{
-
 
134
    async_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags);
-
 
135
}
-
 
136
 
-
 
137
static void set_rgb_color(int fgcolor, int bgcolor)
-
 
138
{
135
    async_msg_2(fb_info.phone, FB_SET_STYLE, fgcolor, bgcolor);
139
    async_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
-
 
140
}
-
 
141
 
-
 
142
static void set_attrs(attrs_t *attrs)
-
 
143
{
-
 
144
    switch (attrs->t) {
-
 
145
    case at_style:
-
 
146
        set_style(attrs->a.s.style);
-
 
147
        break;
-
 
148
 
-
 
149
    case at_idx:
-
 
150
        set_color(attrs->a.i.fg_color, attrs->a.i.bg_color,
-
 
151
            attrs->a.i.flags);
-
 
152
        break;
-
 
153
 
-
 
154
    case at_rgb:
-
 
155
        set_rgb_color(attrs->a.r.fg_color, attrs->a.r.bg_color);
-
 
156
        break;
-
 
157
    }
136
}
158
}
137
 
159
 
138
static void prtchr(char c, int row, int col)
160
static void prtchr(char c, int row, int col)
139
{
161
{
140
    async_msg_3(fb_info.phone, FB_PUTCHAR, c, row, col);
162
    async_msg_3(fb_info.phone, FB_PUTCHAR, c, row, col);
Line 196... Line 218...
196
static void change_console(int newcons)
218
static void change_console(int newcons)
197
{
219
{
198
    connection_t *conn;
220
    connection_t *conn;
199
    int i, j, rc;
221
    int i, j, rc;
200
    keyfield_t *field;
222
    keyfield_t *field;
201
    style_t *style;
223
    attrs_t *attrs;
202
   
224
   
203
    if (newcons == active_console)
225
    if (newcons == active_console)
204
        return;
226
        return;
205
   
227
   
206
    if (newcons == KERNEL_CONSOLE) {
228
    if (newcons == KERNEL_CONSOLE) {
Line 224... Line 246...
224
       
246
       
225
        active_console = newcons;
247
        active_console = newcons;
226
        gcons_change_console(newcons);
248
        gcons_change_console(newcons);
227
        conn = &connections[active_console];
249
        conn = &connections[active_console];
228
       
250
       
229
        set_style(&conn->screenbuffer.style);
251
        set_attrs(&conn->screenbuffer.attrs);
230
        curs_visibility(false);
252
        curs_visibility(false);
231
        if (interbuffer) {
253
        if (interbuffer) {
232
            for (i = 0; i < conn->screenbuffer.size_x; i++)
254
            for (i = 0; i < conn->screenbuffer.size_x; i++)
233
                for (j = 0; j < conn->screenbuffer.size_y; j++) {
255
                for (j = 0; j < conn->screenbuffer.size_y; j++) {
234
                    unsigned int size_x;
256
                    unsigned int size_x;
Line 240... Line 262...
240
            /* This call can preempt, but we are already at the end */
262
            /* This call can preempt, but we are already at the end */
241
            rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA);
263
            rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA);
242
        }
264
        }
243
       
265
       
244
        if ((!interbuffer) || (rc != 0)) {
266
        if ((!interbuffer) || (rc != 0)) {
245
            set_style(&conn->screenbuffer.style);
267
            set_attrs(&conn->screenbuffer.attrs);
246
            clrscr();
268
            clrscr();
247
            style = &conn->screenbuffer.style;
269
            attrs = &conn->screenbuffer.attrs;
248
           
270
           
249
            for (j = 0; j < conn->screenbuffer.size_y; j++)
271
            for (j = 0; j < conn->screenbuffer.size_y; j++)
250
                for (i = 0; i < conn->screenbuffer.size_x; i++) {
272
                for (i = 0; i < conn->screenbuffer.size_x; i++) {
251
                    field = get_field_at(&conn->screenbuffer, i, j);
273
                    field = get_field_at(&conn->screenbuffer, i, j);
252
                    if (!style_same(*style, field->style))
274
                    if (!attrs_same(*attrs, field->attrs))
253
                        set_style(&field->style);
275
                        set_attrs(&field->attrs);
254
                    style = &field->style;
276
                    attrs = &field->attrs;
255
                    if ((field->character == ' ') &&
277
                    if ((field->character == ' ') &&
256
                        (style_same(field->style,
278
                        (attrs_same(field->attrs,
257
                        conn->screenbuffer.style)))
279
                        conn->screenbuffer.attrs)))
258
                        continue;
280
                        continue;
259
                   
281
 
260
                    prtchr(field->character, j, i);
282
                    prtchr(field->character, j, i);
261
                }
283
                }
262
        }
284
        }
263
       
285
       
264
        curs_goto(conn->screenbuffer.position_y,
286
        curs_goto(conn->screenbuffer.position_y,
Line 339... Line 361...
339
static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
361
static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
340
{
362
{
341
    ipc_callid_t callid;
363
    ipc_callid_t callid;
342
    ipc_call_t call;
364
    ipc_call_t call;
343
    int consnum;
365
    int consnum;
344
    ipcarg_t arg1, arg2;
366
    ipcarg_t arg1, arg2, arg3;
345
    connection_t *conn;
367
    connection_t *conn;
346
   
368
   
347
    if ((consnum = find_free_connection()) == -1) {
369
    if ((consnum = find_free_connection()) == -1) {
348
        ipc_answer_0(iid, ELIMIT);
370
        ipc_answer_0(iid, ELIMIT);
349
        return;
371
        return;
Line 407... Line 429...
407
            if (consnum == active_console)
429
            if (consnum == active_console)
408
                async_req_0_0(fb_info.phone, FB_FLUSH);
430
                async_req_0_0(fb_info.phone, FB_FLUSH);
409
            break;
431
            break;
410
        case CONSOLE_SET_STYLE:
432
        case CONSOLE_SET_STYLE:
411
            arg1 = IPC_GET_ARG1(call);
433
            arg1 = IPC_GET_ARG1(call);
-
 
434
            screenbuffer_set_style(&conn->screenbuffer, arg1);
-
 
435
            if (consnum == active_console)
-
 
436
                set_style(arg1);
-
 
437
            break;
-
 
438
        case CONSOLE_SET_COLOR:
-
 
439
            arg1 = IPC_GET_ARG1(call);
-
 
440
            arg2 = IPC_GET_ARG2(call);
-
 
441
            arg3 = IPC_GET_ARG3(call);
-
 
442
            screenbuffer_set_color(&conn->screenbuffer, arg1,
-
 
443
                arg2, arg3);
-
 
444
            if (consnum == active_console)
-
 
445
                set_color(arg1, arg2, arg3);
-
 
446
            break;
-
 
447
        case CONSOLE_SET_RGB_COLOR:
-
 
448
            arg1 = IPC_GET_ARG1(call);
412
            arg2 = IPC_GET_ARG2(call);
449
            arg2 = IPC_GET_ARG2(call);
413
            screenbuffer_set_style(&conn->screenbuffer, arg1,
450
            screenbuffer_set_rgb_color(&conn->screenbuffer, arg1,
414
                arg2);
451
                arg2);
415
            if (consnum == active_console)
452
            if (consnum == active_console)
416
                set_style_col(arg1, arg2);
453
                set_rgb_color(arg1, arg2);
417
            break;
454
            break;
418
        case CONSOLE_CURSOR_VISIBILITY:
455
        case CONSOLE_CURSOR_VISIBILITY:
419
            arg1 = IPC_GET_ARG1(call);
456
            arg1 = IPC_GET_ARG1(call);
420
            conn->screenbuffer.is_cursor_visible = arg1;
457
            conn->screenbuffer.is_cursor_visible = arg1;
421
            if (consnum == active_console)
458
            if (consnum == active_console)
Line 485... Line 522...
485
    /* Synchronize, the gcons can have something in queue */
522
    /* Synchronize, the gcons can have something in queue */
486
    async_req_0_0(fb_info.phone, FB_FLUSH);
523
    async_req_0_0(fb_info.phone, FB_FLUSH);
487
   
524
   
488
    async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.rows,
525
    async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.rows,
489
        &fb_info.cols);
526
        &fb_info.cols);
490
    set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
527
    set_rgb_color(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
491
    clrscr();
528
    clrscr();
492
   
529
   
493
    /* Init virtual consoles */
530
    /* Init virtual consoles */
494
    for (i = 0; i < CONSOLE_COUNT; i++) {
531
    for (i = 0; i < CONSOLE_COUNT; i++) {
495
        connections[i].used = 0;
532
        connections[i].used = 0;