Changeset 1601f3c in mainline for uspace/srv/console/gcons.c


Ignore:
Timestamp:
2009-05-21T15:32:42Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7d158097
Parents:
a095d20
Message:

console cleanup (no functional changes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/console/gcons.c

    ra095d20 r1601f3c  
    2828
    2929/** @addtogroup console
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
     
    4444#include "gcons.h"
    4545
    46 #define CONSOLE_TOP      66
    47 #define CONSOLE_MARGIN   6
    48 
    49 #define STATUS_START    110
    50 #define STATUS_TOP      8
    51 #define STATUS_SPACE    4
    52 #define STATUS_WIDTH    48
    53 #define STATUS_HEIGHT   48
    54 
    55 #define MAIN_COLOR      0xffffff
     46#define CONSOLE_TOP     66
     47#define CONSOLE_MARGIN  6
     48
     49#define STATUS_START   110
     50#define STATUS_TOP     8
     51#define STATUS_SPACE   4
     52#define STATUS_WIDTH   48
     53#define STATUS_HEIGHT  48
     54
     55#define MAIN_COLOR  0xffffff
    5656
    5757static int use_gcons = 0;
     
    115115        int i;
    116116        enum butstate state = console_state[consnum];
    117 
     117       
    118118        vp_switch(cstatus_vp[consnum]);
    119119        if (ic_pixmaps[state] != -1)
    120120                async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum],
    121121                    ic_pixmaps[state]);
    122 
    123         if (state != CONS_DISCONNECTED && state != CONS_KERNEL &&
    124                 state != CONS_DISCONNECTED_SEL) {
    125                 snprintf(data, 5, "%d", consnum + 1);
    126                 for (i = 0; data[i]; i++)
    127                         tran_putch(data[i], 1, 2 + i);
    128         }
     122       
     123        if (state != CONS_DISCONNECTED && state != CONS_KERNEL &&
     124            state != CONS_DISCONNECTED_SEL) {
     125                snprintf(data, 5, "%d", consnum + 1);
     126                for (i = 0; data[i]; i++)
     127                        tran_putch(data[i], 1, 2 + i);
     128        }
    129129}
    130130
     
    133133{
    134134        int i;
    135 
     135       
    136136        if (!use_gcons)
    137137                return;
    138 
     138       
    139139        if (active_console == KERNEL_CONSOLE) {
    140140                for (i = 0; i < CONSOLE_COUNT; i++)
     
    150150        }
    151151        active_console = consnum;
    152 
     152       
    153153        if (console_state[consnum] == CONS_DISCONNECTED) {
    154154                console_state[consnum] = CONS_DISCONNECTED_SEL;
     
    157157                console_state[consnum] = CONS_SELECTED;
    158158        redraw_state(consnum);
    159 
     159       
    160160        vp_switch(console_vp);
    161161}
     
    166166        if (!use_gcons)
    167167                return;
    168 
    169         if (consnum == active_console ||
    170                 console_state[consnum] == CONS_HAS_DATA)
    171                 return;
    172 
     168       
     169        if ((consnum == active_console) ||
     170            (console_state[consnum] == CONS_HAS_DATA))
     171                return;
     172       
    173173        console_state[consnum] = CONS_HAS_DATA;
    174 
     174       
    175175        if (active_console == KERNEL_CONSOLE)
    176176                return;
    177 
     177       
    178178        redraw_state(consnum);
    179179       
     
    186186        if (!use_gcons)
    187187                return;
     188       
    188189        if (active_console == consnum)
    189190                console_state[consnum] = CONS_DISCONNECTED_SEL;
     
    203204        if (!use_gcons)
    204205                return;
     206       
    205207        if (active_console == consnum)
    206208                console_state[consnum] = CONS_SELECTED;
    207209        else
    208210                console_state[consnum] = CONS_IDLE;
    209 
     211       
    210212        if (active_console == KERNEL_CONSOLE)
    211213                return;
    212 
     214       
    213215        redraw_state(consnum);
    214216        vp_switch(console_vp);
     
    226228
    227229/** Return x, where left <= x <= right && |a-x|==min(|a-x|) is smallest */
    228 static inline int limit(int a,int left, int right)
     230static inline int limit(int a, int left, int right)
    229231{
    230232        if (a < left)
     
    247249        mouse_x = limit(mouse_x + dx, 0, xres);
    248250        mouse_y = limit(mouse_y + dy, 0, yres);
    249 
     251       
    250252        async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
    251253}
     
    254256{
    255257        int status_start = STATUS_START + (xres - 800) / 2;
    256 
    257         if (y < STATUS_TOP || y >= STATUS_TOP + STATUS_HEIGHT)
     258       
     259        if ((y < STATUS_TOP) || (y >= STATUS_TOP + STATUS_HEIGHT))
    258260                return -1;
    259261       
     
    276278{
    277279        int conbut;
    278 
     280       
    279281        if (state) {
    280282                conbut = gcons_find_conbut(mouse_x, mouse_y);
     
    285287                }
    286288                return -1;
    287         }
    288         if (!state && !btn_pressed)
    289                 return -1;
     289        }
     290       
     291        if ((!state) && (!btn_pressed))
     292                return -1;
     293       
    290294        btn_pressed = 0;
    291 
     295       
    292296        conbut = gcons_find_conbut(mouse_x, mouse_y);
    293297        if (conbut == gcons_find_conbut(btn_x, btn_y))
    294298                return conbut;
     299       
    295300        return -1;
    296301}
     
    308313        char *shm;
    309314        int rc;
    310 
     315       
    311316        /* Create area */
    312317        shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
     
    314319        if (shm == MAP_FAILED)
    315320                return;
    316 
     321       
    317322        memcpy(shm, logo, size);
     323       
    318324        /* Send area */
    319325        rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);
    320326        if (rc)
    321327                goto exit;
     328       
    322329        rc = ipc_share_out_start(fbphone, shm, PROTO_READ);
    323330        if (rc)
    324331                goto drop;
     332       
    325333        /* Draw logo */
    326334        async_msg_2(fbphone, FB_DRAW_PPM, x, y);
     335       
    327336drop:
    328337        /* Drop area */
    329338        async_msg_0(fbphone, FB_DROP_SHM);
    330 exit:       
     339       
     340exit:
    331341        /* Remove area */
    332342        munmap(shm, size);
    333343}
    334344
    335 extern char _binary_helenos_ppm_start[0];
    336 extern int _binary_helenos_ppm_size;
    337 extern char _binary_nameic_ppm_start[0];
    338 extern int _binary_nameic_ppm_size;
     345extern char _binary_gfx_helenos_ppm_start[0];
     346extern int _binary_gfx_helenos_ppm_size;
     347extern char _binary_gfx_nameic_ppm_start[0];
     348extern int _binary_gfx_nameic_ppm_size;
    339349
    340350/** Redraws console graphics */
     
    349359        set_rgb_color(MAIN_COLOR, MAIN_COLOR);
    350360        clear();
    351         draw_pixmap(_binary_helenos_ppm_start,
    352             (size_t) &_binary_helenos_ppm_size, xres - 66, 2);
    353         draw_pixmap(_binary_nameic_ppm_start,
    354             (size_t) &_binary_nameic_ppm_size, 5, 17);
     361        draw_pixmap(_binary_gfx_helenos_ppm_start,
     362            (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2);
     363        draw_pixmap(_binary_gfx_nameic_ppm_start,
     364            (size_t) &_binary_gfx_nameic_ppm_size, 5, 17);
    355365       
    356366        for (i = 0; i < CONSOLE_COUNT; i++)
    357367                redraw_state(i);
     368       
    358369        vp_switch(console_vp);
    359370}
     
    370381        int rc;
    371382        int pxid = -1;
    372 
     383       
    373384        /* Create area */
    374385        shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
     
    376387        if (shm == MAP_FAILED)
    377388                return -1;
    378 
     389       
    379390        memcpy(shm, data, size);
     391       
    380392        /* Send area */
    381393        rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);
    382394        if (rc)
    383395                goto exit;
     396       
    384397        rc = ipc_share_out_start(fbphone, shm, PROTO_READ);
    385398        if (rc)
    386399                goto drop;
    387 
     400       
    388401        /* Obtain pixmap */
    389402        rc = async_req_0_0(fbphone, FB_SHM2PIXMAP);
    390403        if (rc < 0)
    391404                goto drop;
     405       
    392406        pxid = rc;
     407       
    393408drop:
    394409        /* Drop area */
    395410        async_msg_0(fbphone, FB_DROP_SHM);
    396 exit:       
     411       
     412exit:
    397413        /* Remove area */
    398414        munmap(shm, size);
    399 
     415       
    400416        return pxid;
    401417}
    402418
    403 extern char _binary_anim_1_ppm_start[0];
    404 extern int _binary_anim_1_ppm_size;
    405 extern char _binary_anim_2_ppm_start[0];
    406 extern int _binary_anim_2_ppm_size;
    407 extern char _binary_anim_3_ppm_start[0];
    408 extern int _binary_anim_3_ppm_size;
    409 extern char _binary_anim_4_ppm_start[0];
    410 extern int _binary_anim_4_ppm_size;
     419extern char _binary_gfx_anim_1_ppm_start[0];
     420extern int _binary_gfx_anim_1_ppm_size;
     421extern char _binary_gfx_anim_2_ppm_start[0];
     422extern int _binary_gfx_anim_2_ppm_size;
     423extern char _binary_gfx_anim_3_ppm_start[0];
     424extern int _binary_gfx_anim_3_ppm_size;
     425extern char _binary_gfx_anim_4_ppm_start[0];
     426extern int _binary_gfx_anim_4_ppm_size;
    411427
    412428static void make_anim(void)
    413429{
    414         int an;
    415         int pm;
    416 
    417         an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]);
     430        int an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]);
    418431        if (an < 0)
    419432                return;
    420 
    421         pm = make_pixmap(_binary_anim_1_ppm_start,
    422             (int) &_binary_anim_1_ppm_size);
     433       
     434        int pm = make_pixmap(_binary_gfx_anim_1_ppm_start,
     435            (int) &_binary_gfx_anim_1_ppm_size);
    423436        async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    424 
    425         pm = make_pixmap(_binary_anim_2_ppm_start,
    426             (int) &_binary_anim_2_ppm_size);
     437       
     438        pm = make_pixmap(_binary_gfx_anim_2_ppm_start,
     439            (int) &_binary_gfx_anim_2_ppm_size);
    427440        async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    428 
    429         pm = make_pixmap(_binary_anim_3_ppm_start,
    430             (int) &_binary_anim_3_ppm_size);
     441       
     442        pm = make_pixmap(_binary_gfx_anim_3_ppm_start,
     443            (int) &_binary_gfx_anim_3_ppm_size);
    431444        async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    432 
    433         pm = make_pixmap(_binary_anim_4_ppm_start,
    434             (int) &_binary_anim_4_ppm_size);
     445       
     446        pm = make_pixmap(_binary_gfx_anim_4_ppm_start,
     447            (int) &_binary_gfx_anim_4_ppm_size);
    435448        async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    436 
     449       
    437450        async_msg_1(fbphone, FB_ANIM_START, an);
    438 
     451       
    439452        animation = an;
    440453}
    441454
    442 extern char _binary_cons_selected_ppm_start[0];
    443 extern int _binary_cons_selected_ppm_size;
    444 extern char _binary_cons_idle_ppm_start[0];
    445 extern int _binary_cons_idle_ppm_size;
    446 extern char _binary_cons_has_data_ppm_start[0];
    447 extern int _binary_cons_has_data_ppm_size;
    448 extern char _binary_cons_kernel_ppm_start[0];
    449 extern int _binary_cons_kernel_ppm_size;
     455extern char _binary_gfx_cons_selected_ppm_start[0];
     456extern int _binary_gfx_cons_selected_ppm_size;
     457extern char _binary_gfx_cons_idle_ppm_start[0];
     458extern int _binary_gfx_cons_idle_ppm_size;
     459extern char _binary_gfx_cons_has_data_ppm_start[0];
     460extern int _binary_gfx_cons_has_data_ppm_size;
     461extern char _binary_gfx_cons_kernel_ppm_start[0];
     462extern int _binary_gfx_cons_kernel_ppm_size;
    450463
    451464/** Initialize nice graphical console environment */
     
    465478                return;
    466479       
    467         /* create console viewport */
     480        /* Create console viewport */
     481       
    468482        /* Align width & height to character size */
    469483        console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP,
     
    487501        /* Initialize icons */
    488502        ic_pixmaps[CONS_SELECTED] =
    489             make_pixmap(_binary_cons_selected_ppm_start,
    490             (int) &_binary_cons_selected_ppm_size);
    491         ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start,
    492             (int) &_binary_cons_idle_ppm_size);
     503            make_pixmap(_binary_gfx_cons_selected_ppm_start,
     504            (int) &_binary_gfx_cons_selected_ppm_size);
     505        ic_pixmaps[CONS_IDLE] =
     506            make_pixmap(_binary_gfx_cons_idle_ppm_start,
     507            (int) &_binary_gfx_cons_idle_ppm_size);
    493508        ic_pixmaps[CONS_HAS_DATA] =
    494             make_pixmap(_binary_cons_has_data_ppm_start,
    495             (int) &_binary_cons_has_data_ppm_size);
     509            make_pixmap(_binary_gfx_cons_has_data_ppm_start,
     510            (int) &_binary_gfx_cons_has_data_ppm_size);
    496511        ic_pixmaps[CONS_DISCONNECTED] =
    497             make_pixmap(_binary_cons_idle_ppm_start,
    498             (int) &_binary_cons_idle_ppm_size);
    499         ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start,
    500             (int) &_binary_cons_kernel_ppm_size);
     512            make_pixmap(_binary_gfx_cons_idle_ppm_start,
     513            (int) &_binary_gfx_cons_idle_ppm_size);
     514        ic_pixmaps[CONS_KERNEL] =
     515            make_pixmap(_binary_gfx_cons_kernel_ppm_start,
     516            (int) &_binary_gfx_cons_kernel_ppm_size);
    501517        ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
    502518       
Note: See TracChangeset for help on using the changeset viewer.