Changeset e1c4849 in mainline


Ignore:
Timestamp:
2006-06-02T17:16:59Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0c6984e
Parents:
3756912
Message:

Added slighyly graphical console.

Location:
console
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • console/Makefile

    r3756912 re1c4849  
    4545        console.c \
    4646        screenbuffer.c \
    47         ../kbd/generic/key_buffer.c
     47        ../kbd/generic/key_buffer.c \
     48        gcons.c
    4849
    4950ARCH_SOURCES =
  • console/console.c

    r3756912 re1c4849  
    4242#include <sys/mman.h>
    4343
     44#include "gcons.h"
     45
    4446#define MAX_KEYREQUESTS_BUFFERED 32
    4547
     
    178180//                      if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) {
    179181                        if ((c >= '0') && (c < '0' + CONSOLE_COUNT)) {
    180                                
    181182                                if (c == '0') {
    182183                                        /* switch to kernel console*/
     
    193194                                                break;
    194195                                        active_console = c;
     196                                        gcons_change_console(c);
     197                               
    195198                                }
    196199                               
     
    337340                usleep(10000);
    338341        }
     342
     343        /* Initialize gcons */
     344        gcons_init(fb_info.phone);
     345        /* Synchronize, the gcons can have something in queue */
     346        sync_send_2(fb_info.phone, FB_GET_CSIZE, 0, 0, NULL, NULL);
     347
    339348       
    340349        ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols));
     
    368377        async_new_connection(phonehash, 0, NULL, keyboard_events);
    369378       
    370         nsend_call_2(fb_info.phone, FB_CURSOR_GOTO, 0, 0);
     379        sync_send_2(fb_info.phone, FB_CURSOR_GOTO, 0, 0, NULL, NULL);
    371380        nsend_call(fb_info.phone, FB_CURSOR_VISIBILITY, 1);
    372381
  • console/gcons.c

    r3756912 re1c4849  
    2929#include <ipc/fb.h>
    3030#include <ipc/ipc.h>
     31#include <async.h>
     32#include <stdio.h>
    3133
    3234#include "console.h"
     35#include "gcons.h"
    3336
    3437#define CONSOLE_TOP      50
     
    3942#define STATUS_HEIGHT   30
    4043
     44#define MAIN_COLOR      0x118811
     45
    4146static int use_gcons = 0;
    4247static ipcarg_t xres,yres;
     
    4449static int console_vp;
    4550static int cstatus_vp[CONSOLE_COUNT];
     51static int cstat_row, cstat_col; /* Size of cstatus buttons */
    4652
    4753static int fbphone;
    4854
     55enum butstate {
     56        CONS_ACTIVE = 0,
     57        CONS_IDLE,
     58        CONS_HAS_INPUT
     59};
     60
     61static struct {
     62        int fgcolor;
     63        int bgcolor;
     64} stat_colors[] = {
     65        {0xd0d0d0, 0x808080},
     66        {0xd0d0d0, 0x0},
     67        {0xd0d0d0, 0xa04040}
     68};
     69
     70static int active_console = 0;
     71
    4972static void vp_switch(int vp)
    5073{
    51         ipc_call_sync_2(fbphone,FB_VIEWPORT_SWITCH, vp, 0, NULL, NULL);
     74        nsend_call(fbphone,FB_VIEWPORT_SWITCH, vp);
    5275}
    5376
     77/** Create view port */
    5478static int vp_create(unsigned int x, unsigned int y,
    55                      unsigned int width, unsgined int height)
     79                     unsigned int width, unsigned int height)
    5680{
    57         return  ipc_call_sync_2(fbphone, (x << 16) | y, (width << 16) | height,
    58                                 NULL, NULL);
     81        /* Init function, use ipc_call_sync */
     82        return ipc_call_sync_2(fbphone, FB_VIEWPORT_CREATE,
     83                               (x << 16) | y, (width << 16) | height,
     84                               NULL, NULL);
    5985}
    6086
    61 static void fb_clear(void)
     87static void clear(void)
    6288{
    63         ipc_call_sync_2(fbphone, FB_CLEAR, 0, 0, NULL, NULL);
     89        nsend_call(fbphone, FB_CLEAR, 0);
    6490       
    6591}
    6692
    67 static void fb_set_style(int fgcolor, int bgcolor)
     93static void set_style(int fgcolor, int bgcolor)
    6894{
    69         ipc_call_sync_2(fbphone, );
     95        nsend_call_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor);
     96}
     97
     98static void putch(char c, int row, int col)
     99{
     100        nsend_call_3(fbphone, FB_PUTCHAR, c, row, col);
     101}
     102
     103static void draw_stat(int consnum, enum butstate state)
     104{
     105        char data[5];
     106        int i;
     107       
     108        vp_switch(cstatus_vp[consnum]);
     109        set_style(stat_colors[state].fgcolor, stat_colors[state].bgcolor);
     110        clear();
     111        snprintf(data, 5, "%d", consnum+1);
     112        for (i=0;data[i];i++)
     113                putch(data[i], 0, i);
    70114}
    71115
     
    74118        if (!use_gcons)
    75119                return;
    76 
     120       
     121        draw_stat(active_console, CONS_IDLE);
     122        active_console = consnum;
     123        draw_stat(consnum, CONS_ACTIVE);
    77124        vp_switch(console_vp);
    78125}
     
    86133}
    87134
    88 void gcons_redraw_console(int phone)
     135void gcons_redraw_console(void)
    89136{
     137        int i;
     138
    90139        if (!use_gcons)
    91140                return;
    92141       
    93142        vp_switch(0);
    94         /* Set style...*/
    95         fb_clear();
    96        
     143        set_style(MAIN_COLOR, MAIN_COLOR);
     144        clear();
     145
     146        for (i=0;i < CONSOLE_COUNT; i++)
     147                draw_stat(i, i == active_console ? CONS_ACTIVE : CONS_IDLE);
    97148        vp_switch(console_vp);
    98149}
     
    121172        /* Create status buttons */
    122173        for (i=0; i < CONSOLE_COUNT; i++) {
    123                 cstatus_vp[i] = vp_create(phone, CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
     174                cstatus_vp[i] = vp_create(CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
    124175                                          CONSOLE_MARGIN, STATUS_WIDTH, STATUS_HEIGHT);
    125176                if (cstatus_vp[i] < 0)
     
    128179       
    129180        use_gcons = 1;
    130         gcons_draw_console();
     181        gcons_redraw_console();
    131182}
Note: See TracChangeset for help on using the changeset viewer.