Changeset 76fca31 in mainline for uspace/srv/console


Ignore:
Timestamp:
2008-12-16T19:02:07Z (17 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5ae4443
Parents:
8fe5980
Message:

kconsole is optional
kernel & uspace framebuffer rewrite with speedups (some things are slightly broken yet)

Location:
uspace/srv/console
Files:
4 edited

Legend:

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

    r8fe5980 r76fca31  
    8787                                                 * switching */
    8888
    89 static int kernel_pixmap = -1;  /**< Number of fb pixmap, where kernel
    90                                  * console is stored */
    91 
    9289
    9390/** Find unused virtual console.
     
    188185}
    189186
    190 /** Save current screen to pixmap, draw old pixmap
    191  *
    192  * @param oldpixmap Old pixmap
    193  * @return ID of pixmap of current screen
    194  */
    195 static int switch_screens(int oldpixmap)
    196 {
    197         int newpmap;
    198        
    199         /* Save screen */
    200         newpmap = async_req_0_0(fb_info.phone, FB_VP2PIXMAP);
    201         if (newpmap < 0)
    202                 return -1;
    203 
    204         if (oldpixmap != -1) {
    205                 /* Show old screen */
    206                 async_msg_2(fb_info.phone, FB_VP_DRAW_PIXMAP, 0, oldpixmap);
    207                 /* Drop old pixmap */
    208                 async_msg_1(fb_info.phone, FB_DROP_PIXMAP, oldpixmap);
    209         }
    210        
    211         return newpmap;
    212 }
    213 
    214187/** Switch to new console */
    215188static void change_console(int newcons)
    216189{
    217190        connection_t *conn;
    218         static int console_pixmap = -1;
    219191        int i, j, rc;
    220192        keyfield_t *field;
    221193        style_t *style;
    222 
     194       
    223195        if (newcons == active_console)
    224196                return;
    225 
     197       
    226198        if (newcons == KERNEL_CONSOLE) {
     199                async_serialize_start();
     200                curs_visibility(0);
     201                gcons_in_kernel();
     202                async_serialize_end();
     203               
     204                if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE))
     205                        active_console = KERNEL_CONSOLE;
     206                else
     207                        newcons == active_console;
     208        }
     209       
     210        if (newcons != KERNEL_CONSOLE) {
     211                async_serialize_start();
     212               
    227213                if (active_console == KERNEL_CONSOLE)
    228                         return;
    229                 active_console = KERNEL_CONSOLE;
     214                        gcons_redraw_console();
     215               
     216                active_console = newcons;
     217                gcons_change_console(newcons);
     218                conn = &connections[active_console];
     219               
     220                set_style(&conn->screenbuffer.style);
    230221                curs_visibility(0);
    231 
    232                 async_serialize_start();
    233                 if (kernel_pixmap == -1) {
    234                         /* store/restore unsupported */
    235                         set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
     222                if (interbuffer) {
     223                        for (i = 0; i < conn->screenbuffer.size_x; i++)
     224                                for (j = 0; j < conn->screenbuffer.size_y; j++) {
     225                                        unsigned int size_x;
     226                                       
     227                                        size_x = conn->screenbuffer.size_x;
     228                                        interbuffer[i + j * size_x] =
     229                                            *get_field_at(&conn->screenbuffer, i, j);
     230                                }
     231                        /* This call can preempt, but we are already at the end */
     232                        rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA);           
     233                }
     234               
     235                if ((!interbuffer) || (rc != 0)) {
     236                        set_style(&conn->screenbuffer.style);
    236237                        clrscr();
    237                 } else {
    238                         gcons_in_kernel();
    239                         console_pixmap = switch_screens(kernel_pixmap);
    240                         kernel_pixmap = -1;
     238                        style = &conn->screenbuffer.style;
     239                       
     240                        for (j = 0; j < conn->screenbuffer.size_y; j++)
     241                                for (i = 0; i < conn->screenbuffer.size_x; i++) {
     242                                        field = get_field_at(&conn->screenbuffer, i, j);
     243                                        if (!style_same(*style, field->style))
     244                                                set_style(&field->style);
     245                                        style = &field->style;
     246                                        if ((field->character == ' ') &&
     247                                            (style_same(field->style,
     248                                            conn->screenbuffer.style)))
     249                                                continue;
     250                                       
     251                                        prtchr(field->character, j, i);
     252                                }
    241253                }
     254               
     255                curs_goto(conn->screenbuffer.position_y,
     256                    conn->screenbuffer.position_x);
     257                curs_visibility(conn->screenbuffer.is_cursor_visible);
     258               
    242259                async_serialize_end();
    243 
    244                 __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
    245                 return;
    246         }
    247        
    248         async_serialize_start();
    249 
    250         if (console_pixmap != -1) {
    251                 kernel_pixmap = switch_screens(console_pixmap);
    252                 console_pixmap = -1;
    253         }
    254         active_console = newcons;
    255         gcons_change_console(newcons);
    256         conn = &connections[active_console];
    257 
    258         set_style(&conn->screenbuffer.style);
    259         curs_visibility(0);
    260         if (interbuffer) {
    261                 for (i = 0; i < conn->screenbuffer.size_x; i++)
    262                         for (j = 0; j < conn->screenbuffer.size_y; j++) {
    263                                 unsigned int size_x;
    264 
    265                                 size_x = conn->screenbuffer.size_x;
    266                                 interbuffer[i + j * size_x] =
    267                                     *get_field_at(&conn->screenbuffer, i, j);
    268                         }
    269                 /* This call can preempt, but we are already at the end */
    270                 rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA);           
    271         }
    272        
    273         if ((!interbuffer) || (rc != 0)) {
    274                 set_style(&conn->screenbuffer.style);
    275                 clrscr();
    276                 style = &conn->screenbuffer.style;
    277 
    278                 for (j = 0; j < conn->screenbuffer.size_y; j++)
    279                         for (i = 0; i < conn->screenbuffer.size_x; i++) {
    280                                 field = get_field_at(&conn->screenbuffer, i, j);
    281                                 if (!style_same(*style, field->style))
    282                                         set_style(&field->style);
    283                                 style = &field->style;
    284                                 if ((field->character == ' ') &&
    285                                     (style_same(field->style,
    286                                     conn->screenbuffer.style)))
    287                                         continue;
    288 
    289                                 prtchr(field->character, j, i);
    290                         }
    291         }
    292        
    293         curs_goto(conn->screenbuffer.position_y,
    294             conn->screenbuffer.position_x);
    295         curs_visibility(conn->screenbuffer.is_cursor_visible);
    296 
    297         async_serialize_end();
     260        }
    298261}
    299262
     
    498461       
    499462        /* Connect to framebuffer driver */
    500        
    501463        fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0, 0);
    502464        while (fb_info.phone < 0) {
     
    505467        }
    506468       
    507         /* Save old kernel screen */
    508         kernel_pixmap = switch_screens(-1);
    509 
    510469        /* Initialize gcons */
    511470        gcons_init(fb_info.phone);
    512471        /* Synchronize, the gcons can have something in queue */
    513472        async_req_0_0(fb_info.phone, FB_FLUSH);
    514         /* Enable double buffering */
    515         async_msg_2(fb_info.phone, FB_VIEWPORT_DB, (sysarg_t) -1, 1);
    516473       
    517474        async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.rows,
  • uspace/srv/console/gcons.c

    r8fe5980 r76fca31  
    8282static void vp_switch(int vp)
    8383{
    84         async_msg_1(fbphone,FB_VIEWPORT_SWITCH, vp);
     84        async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);
    8585}
    8686
     
    106106static void tran_putch(char c, int row, int col)
    107107{
    108         async_msg_3(fbphone, FB_TRANS_PUTCHAR, c, row, col);
     108        async_msg_3(fbphone, FB_PUTCHAR, c, row, col);
    109109}
    110110
     
    190190        else
    191191                console_state[consnum] = CONS_DISCONNECTED;
    192 
     192       
    193193        if (active_console == KERNEL_CONSOLE)
    194194                return;
    195 
     195       
    196196        redraw_state(consnum);
    197197        vp_switch(console_vp);
     
    218218void gcons_in_kernel(void)
    219219{
    220         if (console_state[active_console] == CONS_DISCONNECTED_SEL)
    221                 console_state[active_console] = CONS_DISCONNECTED;
    222         else
    223                 console_state[active_console] = CONS_IDLE;
    224         redraw_state(active_console);
    225 
    226220        if (animation != -1)
    227221                async_msg_1(fbphone, FB_ANIM_STOP, animation);
    228 
    229         active_console = KERNEL_CONSOLE; /* Set to kernel console */
     222       
     223        active_console = KERNEL_CONSOLE;
    230224        vp_switch(0);
    231225}
     
    343337extern char _binary_nameic_ppm_start[0];
    344338extern int _binary_nameic_ppm_size;
    345 /** Redraws console graphics  */
    346 static void gcons_redraw_console(void)
     339
     340/** Redraws console graphics */
     341void gcons_redraw_console(void)
    347342{
    348343        int i;
    349 
     344       
    350345        if (!use_gcons)
    351346                return;
     
    358353        draw_pixmap(_binary_nameic_ppm_start,
    359354            (size_t) &_binary_nameic_ppm_size, 5, 17);
    360 
     355       
    361356        for (i = 0; i < CONSOLE_COUNT; i++)
    362357                redraw_state(i);
     
    460455        int i;
    461456        int status_start = STATUS_START;
    462 
     457       
    463458        fbphone = phone;
    464 
     459       
    465460        rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);
    466461        if (rc)
    467462                return;
    468463       
    469         if (xres < 800 || yres < 600)
    470                 return;
    471 
     464        if ((xres < 800) || (yres < 600))
     465                return;
     466       
    472467        /* create console viewport */
    473468        /* Align width & height to character size */
     
    507502       
    508503        make_anim();
    509 
     504       
    510505        use_gcons = 1;
    511506        console_state[0] = CONS_DISCONNECTED_SEL;
     
    513508        gcons_redraw_console();
    514509}
    515  
     510
    516511/** @}
    517512 */
    518 
  • uspace/srv/console/gcons.h

    r8fe5980 r76fca31  
    3737
    3838void gcons_init(int phone);
     39void gcons_redraw_console(void);
    3940void gcons_change_console(int consnum);
    4041void gcons_notify_char(int consnum);
  • uspace/srv/console/screenbuffer.h

    r8fe5980 r76fca31  
    3636#define __SCREENBUFFER_H__
    3737
     38#include <stdint.h>
    3839
    3940#define DEFAULT_FOREGROUND 0x0  /**< default console foreground color */
     
    4142
    4243typedef struct {
    43         unsigned int bg_color;          /**< background color */
    44         unsigned int fg_color;          /**< foreground color */
     44        uint32_t bg_color;      /**< background color */
     45        uint32_t fg_color;      /**< foreground color */
    4546} style_t;
    4647
Note: See TracChangeset for help on using the changeset viewer.