Changeset 1601f3c in mainline


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)

Location:
uspace/srv/console
Files:
7 edited
10 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/console/Makefile

    ra095d20 r1601f3c  
    4343
    4444OUTPUT = console
     45
    4546GENERIC_SOURCES = \
    4647        console.c \
     
    4950        gcons.c
    5051
    51 IMAGES = helenos.ppm nameic.ppm cons_selected.ppm cons_idle.ppm \
    52         cons_has_data.ppm cons_kernel.ppm anim_1.ppm anim_2.ppm anim_3.ppm \
    53         anim_4.ppm
    54 
    55 ARCH_SOURCES =
     52IMAGES = \
     53        gfx/helenos.ppm \
     54        gfx/nameic.ppm \
     55        gfx/cons_selected.ppm \
     56        gfx/cons_idle.ppm \
     57        gfx/cons_has_data.ppm \
     58        gfx/cons_kernel.ppm \
     59        gfx/anim_1.ppm \
     60        gfx/anim_2.ppm \
     61        gfx/anim_3.ppm \
     62        gfx/anim_4.ppm
    5663
    5764GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) \
    58                         $(addsuffix .o,$(basename $(IMAGES)))   
    59 ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
     65        $(addsuffix .o,$(basename $(IMAGES)))
    6066
    61 OBJECTS := $(GENERIC_OBJECTS) $(ARCH_OBJECTS)
     67OBJECTS := $(GENERIC_OBJECTS)
    6268
    6369.PHONY: all clean depend disasm
  • uspace/srv/console/console.c

    ra095d20 r1601f3c  
    2828
    2929/** @addtogroup console
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
     
    5656#include "gcons.h"
    5757
    58 #define MAX_KEYREQUESTS_BUFFERED 32
    59 
    60 #define NAME "console"
     58#define NAME  "console"
     59
     60#define MAX_KEYREQUESTS_BUFFERED  32
     61
     62/** Size of cwrite_buf. */
     63#define CWRITE_BUF_SIZE  256
    6164
    6265/** Index of currently used virtual console.
     
    7073/** Information about framebuffer */
    7174struct {
    72         int phone;              /**< Framebuffer phone */
    73         ipcarg_t rows;          /**< Framebuffer rows */
    74         ipcarg_t cols;          /**< Framebuffer columns */
     75        int phone;      /**< Framebuffer phone */
     76        ipcarg_t rows;  /**< Framebuffer rows */
     77        ipcarg_t cols;  /**< Framebuffer columns */
    7578} fb_info;
    7679
    7780typedef struct {
    78         keybuffer_t keybuffer;          /**< Buffer for incoming keys. */
     81        keybuffer_t keybuffer;        /**< Buffer for incoming keys. */
     82       
    7983        /** Buffer for unsatisfied request for keys. */
    8084        FIFO_CREATE_STATIC(keyrequests, ipc_callid_t,
    81                 MAX_KEYREQUESTS_BUFFERED);     
    82         int keyrequest_counter;         /**< Number of requests in buffer. */
    83         int client_phone;               /**< Phone to connected client. */
    84         int used;                       /**< 1 if this virtual console is
    85                                          * connected to some client.*/
    86         screenbuffer_t screenbuffer;    /**< Screenbuffer for saving screen
    87                                          * contents and related settings. */
     85            MAX_KEYREQUESTS_BUFFERED);
     86       
     87        int keyrequest_counter;       /**< Number of requests in buffer. */
     88        int client_phone;             /**< Phone to connected client. */
     89        int used;                     /**< 1 if this virtual console is
     90                                           connected to some client. */
     91        screenbuffer_t screenbuffer;  /**< Screenbuffer for saving screen
     92                                           contents and related settings. */
    8893} connection_t;
    8994
    90 static connection_t connections[CONSOLE_COUNT]; /**< Array of data for virtual
    91                                                  * consoles */
    92 static keyfield_t *interbuffer = NULL;          /**< Pointer to memory shared
    93                                                  * with framebufer used for
    94                                                  * faster virtual console
    95                                                  * switching */
     95/** Array of data for virtual consoles */
     96static connection_t connections[CONSOLE_COUNT];
     97
     98/** Pointer to memory shared with framebufer used for
     99    faster virtual console switching */
     100static keyfield_t *interbuffer = NULL;
    96101
    97102/** Information on row-span yet unsent to FB driver. */
    98103struct {
    99         int row;                /**< Row where the span lies. */
    100         int col;                /**< Leftmost column of the span. */
    101         int n;                  /**< Width of the span. */
     104        int row;  /**< Row where the span lies. */
     105        int col;  /**< Leftmost column of the span. */
     106        int cnt;  /**< Width of the span. */
    102107} fb_pending;
    103 
    104 /** Size of cwrite_buf. */
    105 #define CWRITE_BUF_SIZE 256
    106108
    107109/** Buffer for receiving data via the CONSOLE_WRITE call from the client. */
    108110static char cwrite_buf[CWRITE_BUF_SIZE];
    109 
    110 static void fb_putchar(wchar_t c, int row, int col);
    111 
    112111
    113112/** Find unused virtual console.
     
    122121                        return i;
    123122        }
     123       
    124124        return -1;
    125125}
     
    186186                set_style(attrs->a.s.style);
    187187                break;
    188 
    189188        case at_idx:
    190189                set_color(attrs->a.i.fg_color, attrs->a.i.bg_color,
    191190                    attrs->a.i.flags);
    192191                break;
    193 
    194192        case at_rgb:
    195193                set_rgb_color(attrs->a.r.fg_color, attrs->a.r.bg_color);
     
    201199static void fb_update_area(connection_t *conn, int x, int y, int w, int h)
    202200{
    203         int i, j;
    204         int rc;
     201        int i;
     202        int j;
    205203        attrs_t *attrs;
    206204        keyfield_t *field;
    207 
     205       
    208206        if (interbuffer) {
    209207                for (j = 0; j < h; j++) {
    210208                        for (i = 0; i < w; i++) {
    211209                                interbuffer[i + j * w] =
    212                                     *get_field_at(&conn->screenbuffer,
    213                                         x + i, y + j);
     210                                    *get_field_at(&conn->screenbuffer, x + i, y + j);
    214211                        }
    215212                }
    216 
    217                 rc = async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
     213               
     214                async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
    218215                    x, y, w, h);
    219         } else {
    220                 rc = ENOTSUP;
    221         }
    222 
    223         if (rc != 0) {
    224                 /*
    225                 attrs = &conn->screenbuffer.attrs;
    226 
    227                 for (j = 0; j < h; j++) {
    228                         for (i = 0; i < w; i++) {
    229                                 field = get_field_at(&conn->screenbuffer,
    230                                     x + i, y + j);
    231                                 if (!attrs_same(*attrs, field->attrs))
    232                                         set_attrs(&field->attrs);
    233                                 attrs = &field->attrs;
    234 
    235                                 fb_putchar(field->character, y + j, x + i);
    236                         }
    237                 }*/
    238216        }
    239217}
     
    242220static void fb_pending_flush(void)
    243221{
    244         screenbuffer_t *scr;
    245 
    246         scr = &(connections[active_console].screenbuffer);
    247 
    248         if (fb_pending.n > 0) {
     222        screenbuffer_t *scr
     223            = &(connections[active_console].screenbuffer);
     224       
     225        if (fb_pending.cnt > 0) {
    249226                fb_update_area(&connections[active_console], fb_pending.col,
    250                     fb_pending.row, fb_pending.n, 1);
    251                 fb_pending.n = 0;
     227                    fb_pending.row, fb_pending.cnt, 1);
     228                fb_pending.cnt = 0;
    252229        }
    253230}
     
    257234 * This adds the cell to the pending rowspan if possible. Otherwise
    258235 * the old span is flushed first.
     236 *
    259237 */
    260238static void cell_mark_changed(int row, int col)
    261239{
    262         if (fb_pending.n != 0) {
    263                 if (row != fb_pending.row ||
    264                     col != fb_pending.col + fb_pending.n) {
     240        if (fb_pending.cnt != 0) {
     241                if ((row != fb_pending.row)
     242                    || (col != fb_pending.col + fb_pending.cnt)) {
    265243                        fb_pending_flush();
    266244                }
    267245        }
    268 
    269         if (fb_pending.n == 0) {
     246       
     247        if (fb_pending.cnt == 0) {
    270248                fb_pending.row = row;
    271249                fb_pending.col = col;
    272250        }
    273 
    274         ++fb_pending.n;
    275 }
    276 
     251       
     252        fb_pending.cnt++;
     253}
    277254
    278255/** Print a character to the active VC with buffering. */
     
    287264        bool flush_cursor = false;
    288265        screenbuffer_t *scr = &(connections[console].screenbuffer);
    289 
     266       
    290267        switch (ch) {
    291268        case '\n':
     
    299276        case '\t':
    300277                scr->position_x += 8;
    301                 scr->position_x -= scr->position_x % 8; 
     278                scr->position_x -= scr->position_x % 8;
    302279                break;
    303280        case '\b':
     
    309286                screenbuffer_putchar(scr, ' ');
    310287                break;
    311         default:       
     288        default:
    312289                if (console == active_console)
    313290                        cell_mark_changed(scr->position_y, scr->position_x);
    314 
     291               
    315292                screenbuffer_putchar(scr, ch);
    316293                scr->position_x++;
    317294        }
    318 
     295       
    319296        if (scr->position_x >= scr->size_x) {
    320297                flush_cursor = true;
     
    330307                        async_msg_1(fb_info.phone, FB_SCROLL, 1);
    331308        }
    332 
     309       
    333310        scr->position_x = scr->position_x % scr->size_x;
    334 
     311       
    335312        if (console == active_console && flush_cursor)
    336313                curs_goto(scr->position_y, scr->position_x);
     
    341318{
    342319        connection_t *conn;
    343         int i, j, rc;
     320        int i;
     321        int j;
     322        int rc;
    344323        keyfield_t *field;
    345324        attrs_t *attrs;
     
    347326        if (newcons == active_console)
    348327                return;
    349 
     328       
    350329        fb_pending_flush();
    351 
     330       
    352331        if (newcons == KERNEL_CONSOLE) {
    353332                async_serialize_start();
     
    357336                kbd_yield();
    358337                async_serialize_end();
    359 
     338               
    360339               
    361340                if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {
     
    409388                                        attrs = &field->attrs;
    410389                                        if ((field->character == ' ') &&
    411                                             (attrs_same(field->attrs,
    412                                             conn->screenbuffer.attrs)))
     390                                            (attrs_same(field->attrs, conn->screenbuffer.attrs)))
    413391                                                continue;
    414 
     392                                       
    415393                                        fb_putchar(field->character, j, i);
    416394                                }
     
    436414       
    437415        /* Ignore parameters, the connection is alread opened */
    438         while (1) {
     416        while (true) {
    439417                callid = async_get_call(&call);
    440418                switch (IPC_GET_METHOD(call)) {
     
    461439                        ev.c = IPC_GET_ARG4(call);
    462440                       
    463                         /* switch to another virtual console */
    464                        
     441                        /* Switch to another virtual console */
    465442                        conn = &connections[active_console];
    466 
     443                       
    467444                        if ((ev.key >= KC_F1) && (ev.key < KC_F1 +
    468445                            CONSOLE_COUNT) && ((ev.mods & KM_CTRL) == 0)) {
     
    474451                        }
    475452                       
    476                         /* if client is awaiting key, send it */
    477                         if (conn->keyrequest_counter > 0) {             
     453                        /* If client is awaiting key, send it */
     454                        if (conn->keyrequest_counter > 0) {
    478455                                conn->keyrequest_counter--;
    479456                                ipc_answer_4(fifo_pop(conn->keyrequests), EOK,
     
    481458                                break;
    482459                        }
    483 
     460                       
    484461                        keybuffer_push(&conn->keybuffer, &ev);
    485462                        retval = 0;
    486 
     463                       
    487464                        break;
    488465                default:
     
    500477        wchar_t ch;
    501478        size_t off;
    502 
     479       
    503480        if (!ipc_data_write_receive(&callid, &size)) {
    504481                ipc_answer_0(callid, EINVAL);
     
    506483                return;
    507484        }
    508 
     485       
    509486        if (size > CWRITE_BUF_SIZE)
    510487                size = CWRITE_BUF_SIZE;
    511 
     488       
    512489        (void) ipc_data_write_finalize(callid, cwrite_buf, size);
    513 
     490       
    514491        async_serialize_start();
    515 
     492       
    516493        off = 0;
    517494        while (off < size) {
     
    519496                write_char(consnum, ch);
    520497        }
    521 
     498       
    522499        async_serialize_end();
    523 
     500       
    524501        gcons_notify_char(consnum);
    525502        ipc_answer_1(rid, EOK, size);
     
    553530        ipc_answer_0(iid, EOK);
    554531       
    555         while (1) {
     532        while (true) {
    556533                async_serialize_end();
    557534                callid = async_get_call(&call);
     
    562539                arg3 = 0;
    563540                arg4 = 0;
    564 
     541               
    565542                switch (IPC_GET_METHOD(call)) {
    566543                case IPC_M_PHONE_HUNGUP:
     
    609586                        if (consnum == active_console) {
    610587                                async_req_0_0(fb_info.phone, FB_FLUSH);
    611 
     588                               
    612589                                scr = &(connections[consnum].screenbuffer);
    613590                                curs_goto(scr->position_y, scr->position_x);
     
    651628                                /* buffer is empty -> store request */
    652629                                if (conn->keyrequest_counter <
    653                                         MAX_KEYREQUESTS_BUFFERED) {     
     630                                        MAX_KEYREQUESTS_BUFFERED) {
    654631                                        fifo_push(conn->keyrequests, callid);
    655632                                        conn->keyrequest_counter++;
     
    744721        }
    745722        connections[KERNEL_CONSOLE].used = 1;
    746 
     723       
    747724        /* Set up shared memory buffer. */
    748725        ib_size = sizeof(keyfield_t) * fb_info.cols * fb_info.rows;
    749726        interbuffer = as_get_mappable_page(ib_size);
    750 
    751         fb_pending.n = 0;
    752 
     727       
     728        fb_pending.cnt = 0;
     729       
    753730        if (as_area_create(interbuffer, ib_size, AS_AREA_READ |
    754731            AS_AREA_WRITE | AS_AREA_CACHEABLE) != interbuffer) {
    755732                interbuffer = NULL;
    756733        }
    757 
     734       
    758735        if (interbuffer) {
    759736                if (ipc_share_out_start(fb_info.phone, interbuffer,
     
    775752        if (event_subscribe(EVENT_KCONSOLE, 0) != EOK)
    776753                printf(NAME ": Error registering kconsole notifications\n");
    777                
     754       
    778755        async_set_interrupt_received(interrupt_received);
    779756       
  • uspace/srv/console/console.h

    ra095d20 r1601f3c  
    2828
    2929/** @addtogroup console
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
     
    3636#define __CONSOLE_H__
    3737
    38 #define KERNEL_CONSOLE 11
    39 
    40 #define CONSOLE_COUNT 12
     38#define CONSOLE_COUNT   12
     39#define KERNEL_CONSOLE  11
    4140
    4241#endif
    43  
     42
    4443/** @}
    4544 */
  • 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       
  • uspace/srv/console/gcons.h

    ra095d20 r1601f3c  
    2828
    2929/** @addtogroup console
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
     
    4747
    4848#endif
    49  
     49
    5050/** @}
    5151 */
  • uspace/srv/console/screenbuffer.c

    ra095d20 r1601f3c  
    2828
    2929/** @addtogroup console
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
     
    3838#include <unistd.h>
    3939
    40 /** Store one character to screenbuffer. Its position is determined by
    41  * scr->position_x and scr->position_y.
     40/** Store one character to screenbuffer.
    4241 *
    43  * @param scr   screenbuffer
    44  * @param c     stored character
     42 * Its position is determined by scr->position_x
     43 * and scr->position_y.
     44 *
     45 * @param scr Screenbuffer
     46 * @param c   Stored character
     47 *
    4548 */
    4649void screenbuffer_putchar(screenbuffer_t *scr, wchar_t ch)
    4750{
    48         keyfield_t *field;
    49 
    50         field = get_field_at(scr, scr->position_x, scr->position_y);
    51 
     51        keyfield_t *field =
     52            get_field_at(scr, scr->position_x, scr->position_y);
     53       
    5254        field->character = ch;
    5355        field->attrs = scr->attrs;
    5456}
    5557
    56 /** Initilize screenbuffer. Allocate space for screen content in accordance to given size.
    57  * @param scr           initialized screenbuffer
    58  * @param size_x        width in characters             
    59  * @param size_y        height in characters
    60  * @return pointer to screenbuffer (same as scr parameter) or NULL
     58/** Initilize screenbuffer.
     59 *
     60 * Allocate space for screen content in accordance to given size.
     61 *
     62 * @param scr    Initialized screenbuffer
     63 * @param size_x Width in characters
     64 * @param size_y Height in characters
     65 *
     66 * @return Pointer to screenbuffer (same as scr parameter) or NULL
     67 *
    6168 */
    6269screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y)
    6370{
    6471        scr->buffer = (keyfield_t *) malloc(sizeof(keyfield_t) * size_x * size_y);
    65         if (!scr->buffer) {
     72        if (!scr->buffer)
    6673                return NULL;
    67         }
    6874       
    6975        scr->size_x = size_x;
     
    7884}
    7985
    80 /** Clear screenbuffer.
    81  * @param scr screenbuffer
     86/** Clear screenbuffer.
     87 *
     88 * @param scr Screenbuffer
     89 *
    8290 */
    8391void screenbuffer_clear(screenbuffer_t *scr)
     
    8997                scr->buffer[i].attrs = scr->attrs;
    9098        }
    91 
     99       
    92100        scr->top_line = 0;
    93101        scr->position_y = 0;
     
    96104
    97105/** Clear one buffer line.
     106 *
    98107 * @param scr
    99108 * @param line One buffer line (not a screen line!)
     109 *
    100110 */
    101111void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line)
     
    110120
    111121/** Copy content buffer from screenbuffer to given memory.
    112  * @param scr   source screenbuffer
    113  * @param dest  destination
     122 *
     123 * @param scr  Source screenbuffer
     124 * @param dest Destination
     125 *
    114126 */
    115127void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest)
     
    117129        unsigned int i;
    118130       
    119         for (i = 0; i < scr->size_x * scr->size_y; i++) {
     131        for (i = 0; i < scr->size_x * scr->size_y; i++)
    120132                dest[i] = scr->buffer[i];
    121         }
    122133}
    123134
    124135/** Set new cursor position in screenbuffer.
     136 *
    125137 * @param scr
    126138 * @param x
    127139 * @param y
     140 *
    128141 */
    129142void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y)
     
    134147
    135148/** Set new style.
     149 *
    136150 * @param scr
    137151 * @param fg_color
    138152 * @param bg_color
     153 *
    139154 */
    140155void screenbuffer_set_style(screenbuffer_t *scr, int style)
     
    145160
    146161/** Set new color.
     162 *
    147163 * @param scr
    148164 * @param fg_color
    149165 * @param bg_color
     166 *
    150167 */
    151168void screenbuffer_set_color(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color, unsigned int flags)
     
    158175
    159176/** Set new RGB color.
     177 *
    160178 * @param scr
    161179 * @param fg_color
    162180 * @param bg_color
     181 *
    163182 */
    164183void screenbuffer_set_rgb_color(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color)
     
    169188}
    170189
    171  
    172190/** @}
    173191 */
  • uspace/srv/console/screenbuffer.h

    ra095d20 r1601f3c  
    2828
    2929/** @addtogroup console
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
    3333 */
    3434
    35 #ifndef __SCREENBUFFER_H__
    36 #define __SCREENBUFFER_H__
     35#ifndef SCREENBUFFER_H__
     36#define SCREENBUFFER_H__
    3737
    3838#include <stdint.h>
    3939#include <sys/types.h>
    4040
    41 #define DEFAULT_FOREGROUND 0x0  /**< default console foreground color */
    42 #define DEFAULT_BACKGROUND 0xf0f0f0     /**< default console background color */
     41#define DEFAULT_FOREGROUND 0x0       /**< default console foreground color */
     42#define DEFAULT_BACKGROUND 0xf0f0f0  /**< default console background color */
    4343
    4444typedef struct {
     
    5353
    5454typedef struct {
    55         uint32_t bg_color;      /**< background color */
    56         uint32_t fg_color;      /**< foreground color */
     55        uint32_t bg_color;  /**< background color */
     56        uint32_t fg_color;  /**< foreground color */
    5757} attr_rgb_t;
    5858
     
    6767                attr_idx_t i;
    6868                attr_rgb_t r;
    69         } a; 
     69        } a;
    7070} attrs_t;
    7171
    7272/** One field on screen. It contain one character and its attributes. */
    7373typedef struct {
    74         wchar_t character;              /**< Character itself */
    75         attrs_t attrs;                  /**< Character`s attributes */
     74        wchar_t character;  /**< Character itself */
     75        attrs_t attrs;      /**< Character`s attributes */
    7676} keyfield_t;
    7777
     
    7979 */
    8080typedef struct {
    81         keyfield_t *buffer;                     /**< Screen content - characters and their attributes. Used as a circular buffer. */
    82         unsigned int size_x, size_y;            /**< Number of columns and rows */
    83         unsigned int position_x, position_y;    /**< Coordinates of last printed character for determining cursor position */
    84         attrs_t attrs;                          /**< Current attributes. */
    85         unsigned int top_line;                  /**< Points to buffer[][] line that will be printed at screen as the first line */
    86         unsigned char is_cursor_visible;        /**< Cursor state - default is visible */
     81        keyfield_t *buffer;               /**< Screen content - characters and
     82                                               their attributes (used as a circular buffer) */
     83        unsigned int size_x;              /**< Number of columns  */
     84        unsigned int size_y;              /**< Number of rows */
     85       
     86        /** Coordinates of last printed character for determining cursor position */
     87        unsigned int position_x;
     88        unsigned int position_y;
     89       
     90        attrs_t attrs;                    /**< Current attributes. */
     91        unsigned int top_line;            /**< Points to buffer[][] line that will
     92                                               be printed at screen as the first line */
     93        unsigned char is_cursor_visible;  /**< Cursor state - default is visible */
    8794} screenbuffer_t;
    8895
    89 /** Returns keyfield for position on screen. Screenbuffer->buffer is cyclic buffer so we must couted in index of the topmost line.
    90  * @param scr   screenbuffer
    91  * @param x     position on screen
    92  * @param y     position on screen
    93  * @return      keyfield structure with character and its attributes on x,y
     96/** Returns keyfield for position on screen
     97 *
     98 * Screenbuffer->buffer is cyclic buffer so we
     99 * must couted in index of the topmost line.
     100 *
     101 * @param scr Screenbuffer
     102 * @param x   Position on screen
     103 * @param y   Position on screen
     104 *
     105 * @return Keyfield structure with character and its attributes on x, y
     106 *
    94107 */
    95108static inline keyfield_t *get_field_at(screenbuffer_t *scr, unsigned int x, unsigned int y)
     
    99112
    100113/** Compares two sets of attributes.
    101  * @param s1 first style
    102  * @param s2 second style
    103  * @return nonzero on equality
     114 *
     115 * @param s1 First style
     116 * @param s2 Second style
     117 *
     118 * @return Nonzero on equality
     119 *
    104120 */
    105121static inline int attrs_same(attrs_t a1, attrs_t a2)
    106122{
    107         if (a1.t != a2.t) return 0;
    108 
     123        if (a1.t != a2.t)
     124                return 0;
     125       
    109126        switch (a1.t) {
    110         case at_style: return a1.a.s.style == a2.a.s.style;
    111         case at_idx: return a1.a.i.fg_color == a2.a.i.fg_color &&
    112             a1.a.i.bg_color == a2.a.i.bg_color &&
    113             a1.a.i.flags == a2.a.i.flags;
    114         case at_rgb: return a1.a.r.fg_color == a2.a.r.fg_color &&
    115             a1.a.r.bg_color == a2.a.r.bg_color;
     127        case at_style:
     128                return (a1.a.s.style == a2.a.s.style);
     129        case at_idx:
     130                return (a1.a.i.fg_color == a2.a.i.fg_color)
     131                    && (a1.a.i.bg_color == a2.a.i.bg_color)
     132                    && (a1.a.i.flags == a2.a.i.flags);
     133        case at_rgb:
     134                return (a1.a.r.fg_color == a2.a.r.fg_color)
     135                    && (a1.a.r.bg_color == a2.a.r.bg_color);
    116136        }
    117137}
     
    133153#endif
    134154
    135  
    136155/** @}
    137156 */
    138 
Note: See TracChangeset for help on using the changeset viewer.