Ignore:
File:
1 edited

Legend:

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

    rc6f08726 r306061a  
    3535#include <ipc/fb.h>
    3636#include <async.h>
    37 #include <async_obsolete.h>
    3837#include <stdio.h>
    3938#include <sys/mman.h>
     
    4140#include <align.h>
    4241#include <bool.h>
    43 #include <imgmap.h>
    4442
    4543#include "console.h"
    4644#include "gcons.h"
    47 #include "images.h"
    4845
    4946#define CONSOLE_TOP     66
     
    6057#define COLOR_BACKGROUND  0xffffff
    6158
     59extern char _binary_gfx_helenos_ppm_start[0];
     60extern int _binary_gfx_helenos_ppm_size;
     61extern char _binary_gfx_nameic_ppm_start[0];
     62extern int _binary_gfx_nameic_ppm_size;
     63
     64extern char _binary_gfx_anim_1_ppm_start[0];
     65extern int _binary_gfx_anim_1_ppm_size;
     66extern char _binary_gfx_anim_2_ppm_start[0];
     67extern int _binary_gfx_anim_2_ppm_size;
     68extern char _binary_gfx_anim_3_ppm_start[0];
     69extern int _binary_gfx_anim_3_ppm_size;
     70extern char _binary_gfx_anim_4_ppm_start[0];
     71extern int _binary_gfx_anim_4_ppm_size;
     72
     73extern char _binary_gfx_cons_selected_ppm_start[0];
     74extern int _binary_gfx_cons_selected_ppm_size;
     75extern char _binary_gfx_cons_idle_ppm_start[0];
     76extern int _binary_gfx_cons_idle_ppm_size;
     77extern char _binary_gfx_cons_has_data_ppm_start[0];
     78extern int _binary_gfx_cons_has_data_ppm_size;
     79extern char _binary_gfx_cons_kernel_ppm_start[0];
     80extern int _binary_gfx_cons_kernel_ppm_size;
     81
    6282static bool use_gcons = false;
    6383static sysarg_t xres;
    6484static sysarg_t yres;
    65 
    66 static imgmap_t *helenos_img;
    67 static imgmap_t *nameic_img;
    68 
    69 static imgmap_t *anim_1_img;
    70 static imgmap_t *anim_2_img;
    71 static imgmap_t *anim_3_img;
    72 static imgmap_t *anim_4_img;
    73 
    74 static imgmap_t *cons_has_data_img;
    75 static imgmap_t *cons_idle_img;
    76 static imgmap_t *cons_kernel_img;
    77 static imgmap_t *cons_selected_img;
    7885
    7986enum butstate {
     
    93100static int fbphone;
    94101
    95 /** List of image maps identifying these icons */
    96 static int ic_imgmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
     102/** List of pixmaps identifying these icons */
     103static int ic_pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
    97104static int animation = -1;
    98105
     
    108115static void vp_switch(int vp)
    109116{
    110         async_obsolete_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);
     117        async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);
    111118}
    112119
     
    114121static int vp_create(sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height)
    115122{
    116         return async_obsolete_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
     123        return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
    117124            (width << 16) | height);
    118125}
     
    120127static void clear(void)
    121128{
    122         async_obsolete_msg_0(fbphone, FB_CLEAR);
     129        async_msg_0(fbphone, FB_CLEAR);
    123130}
    124131
    125132static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor)
    126133{
    127         async_obsolete_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
     134        async_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
    128135}
    129136
     
    131138static void tran_putch(wchar_t ch, sysarg_t col, sysarg_t row)
    132139{
    133         async_obsolete_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
     140        async_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
    134141}
    135142
     
    141148        enum butstate state = console_state[index];
    142149       
    143         if (ic_imgmaps[state] != -1)
    144                 async_obsolete_msg_2(fbphone, FB_VP_DRAW_IMGMAP, cstatus_vp[index],
    145                     ic_imgmaps[state]);
     150        if (ic_pixmaps[state] != -1)
     151                async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index],
     152                    ic_pixmaps[state]);
    146153       
    147154        if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL)
     
    160167void gcons_change_console(size_t index)
    161168{
    162         if (!use_gcons) {
    163                 active_console = index;
    164                 return;
    165         }
     169        if (!use_gcons)
     170                return;
    166171       
    167172        if (active_console == KERNEL_CONSOLE) {
     
    172177               
    173178                if (animation != -1)
    174                         async_obsolete_msg_1(fbphone, FB_ANIM_START, animation);
     179                        async_msg_1(fbphone, FB_ANIM_START, animation);
    175180        } else {
    176181                if (console_state[active_console] == CONS_DISCONNECTED_SEL)
     
    253258{
    254259        if (animation != -1)
    255                 async_obsolete_msg_1(fbphone, FB_ANIM_STOP, animation);
     260                async_msg_1(fbphone, FB_ANIM_STOP, animation);
    256261       
    257262        active_console = KERNEL_CONSOLE;
     
    289294       
    290295        if (active_console != KERNEL_CONSOLE)
    291                 async_obsolete_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
     296                async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
    292297}
    293298
     
    350355}
    351356
    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  */
    359 static void draw_imgmap(imgmap_t *img, sysarg_t x, sysarg_t y)
    360 {
    361         if (img == NULL)
    362                 return;
    363        
     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 */
     365static void draw_pixmap(char *logo, size_t size, sysarg_t x, sysarg_t y)
     366{
    364367        /* Create area */
    365         char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
     368        char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    366369            MAP_ANONYMOUS, 0, 0);
    367370        if (shm == MAP_FAILED)
    368371                return;
    369372       
    370         memcpy(shm, img, img->size);
     373        memcpy(shm, logo, size);
    371374       
    372375        /* Send area */
    373         int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
     376        int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
    374377        if (rc)
    375378                goto exit;
    376379       
    377         rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ);
     380        rc = async_share_out_start(fbphone, shm, PROTO_READ);
    378381        if (rc)
    379382                goto drop;
    380383       
    381384        /* Draw logo */
    382         async_obsolete_msg_2(fbphone, FB_DRAW_IMGMAP, x, y);
     385        async_msg_2(fbphone, FB_DRAW_PPM, x, y);
    383386       
    384387drop:
    385388        /* Drop area */
    386         async_obsolete_msg_0(fbphone, FB_DROP_SHM);
     389        async_msg_0(fbphone, FB_DROP_SHM);
    387390       
    388391exit:
    389392        /* Remove area */
    390         munmap(shm, img->size);
     393        munmap(shm, size);
    391394}
    392395
     
    400403        set_rgb_color(COLOR_MAIN, COLOR_MAIN);
    401404        clear();
    402         draw_imgmap(helenos_img, xres - 66, 2);
    403         draw_imgmap(nameic_img, 5, 17);
     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);
    404409       
    405410        unsigned int i;
     
    410415}
    411416
    412 /** Create an image map on framebuffer
    413  *
    414  * @param img Image map.
    415  *
    416  * @return Image map identification
    417  *
    418  */
    419 static int make_imgmap(imgmap_t *img)
    420 {
    421         if (img == NULL)
    422                 return -1;
    423        
     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 */
     425static int make_pixmap(char *data, size_t size)
     426{
    424427        /* Create area */
    425         char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE,
    426             MAP_SHARED | MAP_ANONYMOUS, 0, 0);
     428        char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
     429            MAP_ANONYMOUS, 0, 0);
    427430        if (shm == MAP_FAILED)
    428431                return -1;
    429432       
    430         memcpy(shm, img, img->size);
    431        
    432         int id = -1;
     433        memcpy(shm, data, size);
     434       
     435        int pxid = -1;
    433436       
    434437        /* Send area */
    435         int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
     438        int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);
    436439        if (rc)
    437440                goto exit;
    438441       
    439         rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ);
     442        rc = async_share_out_start(fbphone, shm, PROTO_READ);
    440443        if (rc)
    441444                goto drop;
    442445       
    443         /* Obtain image map identifier */
    444         rc = async_obsolete_req_0_0(fbphone, FB_SHM2IMGMAP);
     446        /* Obtain pixmap */
     447        rc = async_req_0_0(fbphone, FB_SHM2PIXMAP);
    445448        if (rc < 0)
    446449                goto drop;
    447450       
    448         id = rc;
     451        pxid = rc;
    449452       
    450453drop:
    451454        /* Drop area */
    452         async_obsolete_msg_0(fbphone, FB_DROP_SHM);
     455        async_msg_0(fbphone, FB_DROP_SHM);
    453456       
    454457exit:
    455458        /* Remove area */
    456         munmap(shm, img->size);
    457        
    458         return id;
     459        munmap(shm, size);
     460       
     461        return pxid;
    459462}
    460463
    461464static void make_anim(void)
    462465{
    463         int an = async_obsolete_req_1_0(fbphone, FB_ANIM_CREATE,
     466        int an = async_req_1_0(fbphone, FB_ANIM_CREATE,
    464467            cstatus_vp[KERNEL_CONSOLE]);
    465468        if (an < 0)
    466469                return;
    467470       
    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);
     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);
    481488       
    482489        animation = an;
     
    488495        fbphone = phone;
    489496       
    490         int rc = async_obsolete_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);
     497        int rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);
    491498        if (rc)
    492499                return;
     
    494501        if ((xres < 800) || (yres < 600))
    495502                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);
    520503       
    521504        /* Create console viewport */
     
    545528       
    546529        /* Initialize icons */
    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];
     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];
    553546       
    554547        make_anim();
Note: See TracChangeset for help on using the changeset viewer.