Subversion Repositories HelenOS

Rev

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

Rev 3602 Rev 3742
Line 84... Line 84...
84
static keyfield_t *interbuffer = NULL;      /**< Pointer to memory shared
84
static keyfield_t *interbuffer = NULL;      /**< Pointer to memory shared
85
                         * with framebufer used for
85
                         * with framebufer used for
86
                         * faster virtual console
86
                         * faster virtual console
87
                         * switching */
87
                         * switching */
88
 
88
 
89
static int kernel_pixmap = -1;  /**< Number of fb pixmap, where kernel
-
 
90
                 * console is stored */
-
 
91
 
-
 
92
 
89
 
93
/** Find unused virtual console.
90
/** Find unused virtual console.
94
 *
91
 *
95
 */
92
 */
96
static int find_free_connection(void)
93
static int find_free_connection(void)
Line 185... Line 182...
185
    if (console == active_console)
182
    if (console == active_console)
186
        curs_goto(scr->position_y, scr->position_x);
183
        curs_goto(scr->position_y, scr->position_x);
187
   
184
   
188
}
185
}
189
 
186
 
190
/** Save current screen to pixmap, draw old pixmap
-
 
191
 *
-
 
192
 * @param oldpixmap Old pixmap
-
 
193
 * @return ID of pixmap of current screen
-
 
194
 */
-
 
195
static int switch_screens(int oldpixmap)
-
 
196
{
-
 
197
    int newpmap;
-
 
198
       
-
 
199
    /* Save screen */
-
 
200
    newpmap = async_req_0_0(fb_info.phone, FB_VP2PIXMAP);
-
 
201
    if (newpmap < 0)
-
 
202
        return -1;
-
 
203
 
-
 
204
    if (oldpixmap != -1) {
-
 
205
        /* Show old screen */
-
 
206
        async_msg_2(fb_info.phone, FB_VP_DRAW_PIXMAP, 0, oldpixmap);
-
 
207
        /* Drop old pixmap */
-
 
208
        async_msg_1(fb_info.phone, FB_DROP_PIXMAP, oldpixmap);
-
 
209
    }
-
 
210
   
-
 
211
    return newpmap;
-
 
212
}
-
 
213
 
-
 
214
/** Switch to new console */
187
/** Switch to new console */
215
static void change_console(int newcons)
188
static void change_console(int newcons)
216
{
189
{
217
    connection_t *conn;
190
    connection_t *conn;
218
    static int console_pixmap = -1;
-
 
219
    int i, j, rc;
191
    int i, j, rc;
220
    keyfield_t *field;
192
    keyfield_t *field;
221
    style_t *style;
193
    style_t *style;
222
 
194
   
223
    if (newcons == active_console)
195
    if (newcons == active_console)
224
        return;
196
        return;
225
 
197
   
226
    if (newcons == KERNEL_CONSOLE) {
198
    if (newcons == KERNEL_CONSOLE) {
227
        if (active_console == KERNEL_CONSOLE)
-
 
228
            return;
-
 
229
        active_console = KERNEL_CONSOLE;
-
 
230
        curs_visibility(0);
-
 
231
 
-
 
232
        async_serialize_start();
199
        async_serialize_start();
233
        if (kernel_pixmap == -1) {
-
 
234
            /* store/restore unsupported */
-
 
235
            set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
-
 
236
            clrscr();
200
        curs_visibility(0);
237
        } else {
-
 
238
            gcons_in_kernel();
201
        gcons_in_kernel();
239
            console_pixmap = switch_screens(kernel_pixmap);
-
 
240
            kernel_pixmap = -1;
-
 
241
        }
-
 
242
        async_serialize_end();
202
        async_serialize_end();
243
 
203
       
244
        __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
204
        if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE))
245
        return;
-
 
246
    }
-
 
247
   
-
 
248
    async_serialize_start();
-
 
249
 
-
 
250
    if (console_pixmap != -1) {
205
            active_console = KERNEL_CONSOLE;
251
        kernel_pixmap = switch_screens(console_pixmap);
-
 
252
        console_pixmap = -1;
-
 
253
    }
206
        else
254
    active_console = newcons;
-
 
255
    gcons_change_console(newcons);
-
 
256
    conn = &connections[active_console];
207
            newcons == active_console;
257
 
-
 
258
    set_style(&conn->screenbuffer.style);
-
 
259
    curs_visibility(0);
-
 
260
    if (interbuffer) {
-
 
261
        for (i = 0; i < conn->screenbuffer.size_x; i++)
-
 
262
            for (j = 0; j < conn->screenbuffer.size_y; j++) {
-
 
263
                unsigned int size_x;
-
 
264
 
-
 
265
                size_x = conn->screenbuffer.size_x;
-
 
266
                interbuffer[i + j * size_x] =
-
 
267
                    *get_field_at(&conn->screenbuffer, i, j);
-
 
268
            }
-
 
269
        /* This call can preempt, but we are already at the end */
-
 
270
        rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA);      
-
 
271
    }
208
    }
272
   
209
   
273
    if ((!interbuffer) || (rc != 0)) {
210
    if (newcons != KERNEL_CONSOLE) {
-
 
211
        async_serialize_start();
-
 
212
       
-
 
213
        if (active_console == KERNEL_CONSOLE)
-
 
214
            gcons_redraw_console();
-
 
215
       
-
 
216
        active_console = newcons;
-
 
217
        gcons_change_console(newcons);
-
 
218
        conn = &connections[active_console];
-
 
219
       
274
        set_style(&conn->screenbuffer.style);
220
        set_style(&conn->screenbuffer.style);
-
 
221
        curs_visibility(0);
-
 
222
        if (interbuffer) {
-
 
223
            for (i = 0; i < conn->screenbuffer.size_x; i++)
-
 
224
                for (j = 0; j < conn->screenbuffer.size_y; j++) {
-
 
225
                    unsigned int size_x;
-
 
226
                   
-
 
227
                    size_x = conn->screenbuffer.size_x;
-
 
228
                    interbuffer[i + j * size_x] =
-
 
229
                        *get_field_at(&conn->screenbuffer, i, j);
-
 
230
                }
-
 
231
            /* This call can preempt, but we are already at the end */
-
 
232
            rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA);      
-
 
233
        }
-
 
234
       
-
 
235
        if ((!interbuffer) || (rc != 0)) {
-
 
236
            set_style(&conn->screenbuffer.style);
275
        clrscr();
237
            clrscr();
276
        style = &conn->screenbuffer.style;
238
            style = &conn->screenbuffer.style;
277
 
239
           
278
        for (j = 0; j < conn->screenbuffer.size_y; j++)
240
            for (j = 0; j < conn->screenbuffer.size_y; j++)
279
            for (i = 0; i < conn->screenbuffer.size_x; i++) {
241
                for (i = 0; i < conn->screenbuffer.size_x; i++) {
280
                field = get_field_at(&conn->screenbuffer, i, j);
242
                    field = get_field_at(&conn->screenbuffer, i, j);
281
                if (!style_same(*style, field->style))
243
                    if (!style_same(*style, field->style))
282
                    set_style(&field->style);
244
                        set_style(&field->style);
283
                style = &field->style;
245
                    style = &field->style;
284
                if ((field->character == ' ') &&
246
                    if ((field->character == ' ') &&
285
                    (style_same(field->style,
247
                        (style_same(field->style,
286
                    conn->screenbuffer.style)))
248
                        conn->screenbuffer.style)))
287
                    continue;
249
                        continue;
288
 
250
                   
289
                prtchr(field->character, j, i);
251
                    prtchr(field->character, j, i);
290
            }
252
                }
-
 
253
        }
-
 
254
       
-
 
255
        curs_goto(conn->screenbuffer.position_y,
-
 
256
            conn->screenbuffer.position_x);
-
 
257
        curs_visibility(conn->screenbuffer.is_cursor_visible);
-
 
258
       
-
 
259
        async_serialize_end();
291
    }
260
    }
292
   
-
 
293
    curs_goto(conn->screenbuffer.position_y,
-
 
294
        conn->screenbuffer.position_x);
-
 
295
    curs_visibility(conn->screenbuffer.is_cursor_visible);
-
 
296
 
-
 
297
    async_serialize_end();
-
 
298
}
261
}
299
 
262
 
300
/** Handler for keyboard */
263
/** Handler for keyboard */
301
static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
264
static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
302
{
265
{
Line 495... Line 458...
495
    if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0)
458
    if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0)
496
        return -1;
459
        return -1;
497
    async_new_connection(phonehash, 0, NULL, keyboard_events);
460
    async_new_connection(phonehash, 0, NULL, keyboard_events);
498
   
461
   
499
    /* Connect to framebuffer driver */
462
    /* Connect to framebuffer driver */
500
   
-
 
501
    fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0, 0);
463
    fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0, 0);
502
    while (fb_info.phone < 0) {
464
    while (fb_info.phone < 0) {
503
        usleep(10000);
465
        usleep(10000);
504
        fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0, 0);
466
        fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0, 0);
505
    }
467
    }
506
   
468
   
507
    /* Save old kernel screen */
-
 
508
    kernel_pixmap = switch_screens(-1);
-
 
509
 
-
 
510
    /* Initialize gcons */
469
    /* Initialize gcons */
511
    gcons_init(fb_info.phone);
470
    gcons_init(fb_info.phone);
512
    /* Synchronize, the gcons can have something in queue */
471
    /* Synchronize, the gcons can have something in queue */
513
    async_req_0_0(fb_info.phone, FB_FLUSH);
472
    async_req_0_0(fb_info.phone, FB_FLUSH);
514
    /* Enable double buffering */
-
 
515
    async_msg_2(fb_info.phone, FB_VIEWPORT_DB, (sysarg_t) -1, 1);
-
 
516
   
473
   
517
    async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.rows,
474
    async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.rows,
518
        &fb_info.cols);
475
        &fb_info.cols);
519
    set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
476
    set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
520
    clrscr();
477
    clrscr();