Ignore:
File:
1 edited

Legend:

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

    r306061a rc6f08726  
    3535#include <ipc/fb.h>
    3636#include <async.h>
     37#include <async_obsolete.h>
    3738#include <stdio.h>
    3839#include <sys/mman.h>
     
    4041#include <align.h>
    4142#include <bool.h>
     43#include <imgmap.h>
    4244
    4345#include "console.h"
    4446#include "gcons.h"
     47#include "images.h"
    4548
    4649#define CONSOLE_TOP     66
     
    5760#define COLOR_BACKGROUND  0xffffff
    5861
    59 extern char _binary_gfx_helenos_ppm_start[0];
    60 extern int _binary_gfx_helenos_ppm_size;
    61 extern char _binary_gfx_nameic_ppm_start[0];
    62 extern int _binary_gfx_nameic_ppm_size;
    63 
    64 extern char _binary_gfx_anim_1_ppm_start[0];
    65 extern int _binary_gfx_anim_1_ppm_size;
    66 extern char _binary_gfx_anim_2_ppm_start[0];
    67 extern int _binary_gfx_anim_2_ppm_size;
    68 extern char _binary_gfx_anim_3_ppm_start[0];
    69 extern int _binary_gfx_anim_3_ppm_size;
    70 extern char _binary_gfx_anim_4_ppm_start[0];
    71 extern int _binary_gfx_anim_4_ppm_size;
    72 
    73 extern char _binary_gfx_cons_selected_ppm_start[0];
    74 extern int _binary_gfx_cons_selected_ppm_size;
    75 extern char _binary_gfx_cons_idle_ppm_start[0];
    76 extern int _binary_gfx_cons_idle_ppm_size;
    77 extern char _binary_gfx_cons_has_data_ppm_start[0];
    78 extern int _binary_gfx_cons_has_data_ppm_size;
    79 extern char _binary_gfx_cons_kernel_ppm_start[0];
    80 extern int _binary_gfx_cons_kernel_ppm_size;
    81 
    8262static bool use_gcons = false;
    8363static sysarg_t xres;
    8464static sysarg_t yres;
     65
     66static imgmap_t *helenos_img;
     67static imgmap_t *nameic_img;
     68
     69static imgmap_t *anim_1_img;
     70static imgmap_t *anim_2_img;
     71static imgmap_t *anim_3_img;
     72static imgmap_t *anim_4_img;
     73
     74static imgmap_t *cons_has_data_img;
     75static imgmap_t *cons_idle_img;
     76static imgmap_t *cons_kernel_img;
     77static imgmap_t *cons_selected_img;
    8578
    8679enum butstate {
     
    10093static int fbphone;
    10194
    102 /** List of pixmaps identifying these icons */
    103 static int ic_pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
     95/** List of image maps identifying these icons */
     96static int ic_imgmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
    10497static int animation = -1;
    10598
     
    115108static void vp_switch(int vp)
    116109{
    117         async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);
     110        async_obsolete_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);
    118111}
    119112
     
    121114static int vp_create(sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height)
    122115{
    123         return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
     116        return async_obsolete_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
    124117            (width << 16) | height);
    125118}
     
    127120static void clear(void)
    128121{
    129         async_msg_0(fbphone, FB_CLEAR);
     122        async_obsolete_msg_0(fbphone, FB_CLEAR);
    130123}
    131124
    132125static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor)
    133126{
    134         async_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
     127        async_obsolete_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
    135128}
    136129
     
    138131static void tran_putch(wchar_t ch, sysarg_t col, sysarg_t row)
    139132{
    140         async_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
     133        async_obsolete_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
    141134}
    142135
     
    148141        enum butstate state = console_state[index];
    149142       
    150         if (ic_pixmaps[state] != -1)
    151                 async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index],
    152                     ic_pixmaps[state]);
     143        if (ic_imgmaps[state] != -1)
     144                async_obsolete_msg_2(fbphone, FB_VP_DRAW_IMGMAP, cstatus_vp[index],
     145                    ic_imgmaps[state]);
    153146       
    154147        if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL)
     
    167160void gcons_change_console(size_t index)
    168161{
    169         if (!use_gcons)
    170                 return;
     162        if (!use_gcons) {
     163                active_console = index;
     164                return;
     165        }
    171166       
    172167        if (active_console == KERNEL_CONSOLE) {
     
    177172               
    178173                if (animation != -1)
    179                         async_msg_1(fbphone, FB_ANIM_START, animation);
     174                        async_obsolete_msg_1(fbphone, FB_ANIM_START, animation);
    180175        } else {
    181176                if (console_state[active_console] == CONS_DISCONNECTED_SEL)
     
    258253{
    259254        if (animation != -1)
    260                 async_msg_1(fbphone, FB_ANIM_STOP, animation);
     255                async_obsolete_msg_1(fbphone, FB_ANIM_STOP, animation);
    261256       
    262257        active_console = KERNEL_CONSOLE;
     
    294289       
    295290        if (active_console != KERNEL_CONSOLE)
    296                 async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
     291                async_obsolete_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
    297292}
    298293
     
    355350}
    356351
    357 /** Draw a PPM pixmap to framebuffer
    358  *
    359  * @param logo Pointer to PPM data
    360  * @param size Size of PPM data
    361  * @param x Coordinate of upper left corner
    362  * @param y Coordinate of upper left corner
    363  *
    364  */
    365 static void draw_pixmap(char *logo, size_t size, sysarg_t x, sysarg_t y)
    366 {
     352/** Draw an image map to framebuffer
     353 *
     354 * @param img  Image map
     355 * @param x    Coordinate of upper left corner
     356 * @param y    Coordinate of upper left corner
     357 *
     358 */
     359static void draw_imgmap(imgmap_t *img, sysarg_t x, sysarg_t y)
     360{
     361        if (img == NULL)
     362                return;
     363       
    367364        /* Create area */
    368         char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
     365        char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    369366            MAP_ANONYMOUS, 0, 0);
    370367        if (shm == MAP_FAILED)
    371368                return;
    372369       
    373         memcpy(shm, logo, size);
     370        memcpy(shm, img, img->size);
    374371       
    375372        /* Send area */
    376         int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
     373        int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
    377374        if (rc)
    378375                goto exit;
    379376       
    380         rc = async_share_out_start(fbphone, shm, PROTO_READ);
     377        rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ);
    381378        if (rc)
    382379                goto drop;
    383380       
    384381        /* Draw logo */
    385         async_msg_2(fbphone, FB_DRAW_PPM, x, y);
     382        async_obsolete_msg_2(fbphone, FB_DRAW_IMGMAP, x, y);
    386383       
    387384drop:
    388385        /* Drop area */
    389         async_msg_0(fbphone, FB_DROP_SHM);
     386        async_obsolete_msg_0(fbphone, FB_DROP_SHM);
    390387       
    391388exit:
    392389        /* Remove area */
    393         munmap(shm, size);
     390        munmap(shm, img->size);
    394391}
    395392
     
    403400        set_rgb_color(COLOR_MAIN, COLOR_MAIN);
    404401        clear();
    405         draw_pixmap(_binary_gfx_helenos_ppm_start,
    406             (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2);
    407         draw_pixmap(_binary_gfx_nameic_ppm_start,
    408             (size_t) &_binary_gfx_nameic_ppm_size, 5, 17);
     402        draw_imgmap(helenos_img, xres - 66, 2);
     403        draw_imgmap(nameic_img, 5, 17);
    409404       
    410405        unsigned int i;
     
    415410}
    416411
    417 /** Creates a pixmap on framebuffer
    418  *
    419  * @param data PPM data
    420  * @param size PPM data size
    421  *
    422  * @return Pixmap identification
    423  *
    424  */
    425 static int make_pixmap(char *data, size_t size)
    426 {
     412/** Create an image map on framebuffer
     413 *
     414 * @param img Image map.
     415 *
     416 * @return Image map identification
     417 *
     418 */
     419static int make_imgmap(imgmap_t *img)
     420{
     421        if (img == NULL)
     422                return -1;
     423       
    427424        /* Create area */
    428         char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    429             MAP_ANONYMOUS, 0, 0);
     425        char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE,
     426            MAP_SHARED | MAP_ANONYMOUS, 0, 0);
    430427        if (shm == MAP_FAILED)
    431428                return -1;
    432429       
    433         memcpy(shm, data, size);
    434        
    435         int pxid = -1;
     430        memcpy(shm, img, img->size);
     431       
     432        int id = -1;
    436433       
    437434        /* Send area */
    438         int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
     435        int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
    439436        if (rc)
    440437                goto exit;
    441438       
    442         rc = async_share_out_start(fbphone, shm, PROTO_READ);
     439        rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ);
    443440        if (rc)
    444441                goto drop;
    445442       
    446         /* Obtain pixmap */
    447         rc = async_req_0_0(fbphone, FB_SHM2PIXMAP);
     443        /* Obtain image map identifier */
     444        rc = async_obsolete_req_0_0(fbphone, FB_SHM2IMGMAP);
    448445        if (rc < 0)
    449446                goto drop;
    450447       
    451         pxid = rc;
     448        id = rc;
    452449       
    453450drop:
    454451        /* Drop area */
    455         async_msg_0(fbphone, FB_DROP_SHM);
     452        async_obsolete_msg_0(fbphone, FB_DROP_SHM);
    456453       
    457454exit:
    458455        /* Remove area */
    459         munmap(shm, size);
    460        
    461         return pxid;
     456        munmap(shm, img->size);
     457       
     458        return id;
    462459}
    463460
    464461static void make_anim(void)
    465462{
    466         int an = async_req_1_0(fbphone, FB_ANIM_CREATE,
     463        int an = async_obsolete_req_1_0(fbphone, FB_ANIM_CREATE,
    467464            cstatus_vp[KERNEL_CONSOLE]);
    468465        if (an < 0)
    469466                return;
    470467       
    471         int pm = make_pixmap(_binary_gfx_anim_1_ppm_start,
    472             (size_t) &_binary_gfx_anim_1_ppm_size);
    473         async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    474        
    475         pm = make_pixmap(_binary_gfx_anim_2_ppm_start,
    476             (size_t) &_binary_gfx_anim_2_ppm_size);
    477         async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    478        
    479         pm = make_pixmap(_binary_gfx_anim_3_ppm_start,
    480             (size_t) &_binary_gfx_anim_3_ppm_size);
    481         async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    482        
    483         pm = make_pixmap(_binary_gfx_anim_4_ppm_start,
    484             (size_t) &_binary_gfx_anim_4_ppm_size);
    485         async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    486        
    487         async_msg_1(fbphone, FB_ANIM_START, an);
     468        int pm = make_imgmap(anim_1_img);
     469        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
     470       
     471        pm = make_imgmap(anim_2_img);
     472        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
     473       
     474        pm = make_imgmap(anim_3_img);
     475        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
     476       
     477        pm = make_imgmap(anim_4_img);
     478        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
     479       
     480        async_obsolete_msg_1(fbphone, FB_ANIM_START, an);
    488481       
    489482        animation = an;
     
    495488        fbphone = phone;
    496489       
    497         int rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);
     490        int rc = async_obsolete_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);
    498491        if (rc)
    499492                return;
     
    501494        if ((xres < 800) || (yres < 600))
    502495                return;
     496       
     497        /* Create image maps */
     498        helenos_img = imgmap_decode_tga((void *) helenos_tga,
     499            helenos_tga_size);
     500        nameic_img = imgmap_decode_tga((void *) nameic_tga,
     501            nameic_tga_size);
     502       
     503        anim_1_img = imgmap_decode_tga((void *) anim_1_tga,
     504            anim_1_tga_size);
     505        anim_2_img = imgmap_decode_tga((void *) anim_2_tga,
     506            anim_2_tga_size);
     507        anim_3_img = imgmap_decode_tga((void *) anim_3_tga,
     508            anim_3_tga_size);
     509        anim_4_img = imgmap_decode_tga((void *) anim_4_tga,
     510            anim_4_tga_size);
     511       
     512        cons_has_data_img = imgmap_decode_tga((void *) cons_has_data_tga,
     513            cons_has_data_tga_size);
     514        cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga,
     515            cons_idle_tga_size);
     516        cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga,
     517            cons_kernel_tga_size);
     518        cons_selected_img = imgmap_decode_tga((void *) cons_selected_tga,
     519            cons_selected_tga_size);
    503520       
    504521        /* Create console viewport */
     
    528545       
    529546        /* Initialize icons */
    530         ic_pixmaps[CONS_SELECTED] =
    531             make_pixmap(_binary_gfx_cons_selected_ppm_start,
    532             (size_t) &_binary_gfx_cons_selected_ppm_size);
    533         ic_pixmaps[CONS_IDLE] =
    534             make_pixmap(_binary_gfx_cons_idle_ppm_start,
    535             (size_t) &_binary_gfx_cons_idle_ppm_size);
    536         ic_pixmaps[CONS_HAS_DATA] =
    537             make_pixmap(_binary_gfx_cons_has_data_ppm_start,
    538             (size_t) &_binary_gfx_cons_has_data_ppm_size);
    539         ic_pixmaps[CONS_DISCONNECTED] =
    540             make_pixmap(_binary_gfx_cons_idle_ppm_start,
    541             (size_t) &_binary_gfx_cons_idle_ppm_size);
    542         ic_pixmaps[CONS_KERNEL] =
    543             make_pixmap(_binary_gfx_cons_kernel_ppm_start,
    544             (size_t) &_binary_gfx_cons_kernel_ppm_size);
    545         ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
     547        ic_imgmaps[CONS_SELECTED] = make_imgmap(cons_selected_img);
     548        ic_imgmaps[CONS_IDLE] = make_imgmap(cons_idle_img);
     549        ic_imgmaps[CONS_HAS_DATA] = make_imgmap(cons_has_data_img);
     550        ic_imgmaps[CONS_DISCONNECTED] = make_imgmap(cons_idle_img);
     551        ic_imgmaps[CONS_KERNEL] = make_imgmap(cons_kernel_img);
     552        ic_imgmaps[CONS_DISCONNECTED_SEL] = ic_imgmaps[CONS_SELECTED];
    546553       
    547554        make_anim();
Note: See TracChangeset for help on using the changeset viewer.