Changeset 3993b3d in mainline for console/console.c


Ignore:
Timestamp:
2006-06-01T15:32:19Z (19 years ago)
Author:
Josef Cejka <malyzelenyhnus@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c1d2c9d
Parents:
88c3151
Message:

Support for multiple virtual consoles with separated screens.
Only test version implemented.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • console/console.c

    r88c3151 r3993b3d  
    3939#include <async.h>
    4040#include <libadt/fifo.h>
     41#include <screenbuffer.h>
    4142
    4243static void sysput(char c)
    4344{
    4445        __SYSCALL3(SYS_IO, 1, &c, 1);
    45 
    46 }
     46}
     47
    4748//#define CONSOLE_COUNT VFB_CONNECTIONS
    4849#define CONSOLE_COUNT 8
     
    5253
    5354int active_console = 1;
     55
     56struct {
     57        int phone;              /**< Framebuffer phone */
     58        int rows;               /**< Framebuffer rows */
     59        int cols;               /**< Framebuffer columns */
     60} fb_info;
    5461
    5562typedef struct {
     
    5865        int keyrequest_counter;
    5966        int client_phone;
    60         int vfb_phone;
    6167        int used;
     68        screenbuffer_t screenbuffer;
    6269} connection_t;
    6370
     
    95102        ipc_call_t call;
    96103        int retval;
    97         int i;
     104        int i, j;
    98105        char c;
    99106
     
    116123                       
    117124                        if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) {
     125                                /*FIXME: draw another console content from buffer */
     126
    118127                                active_console = c - KBD_KEY_F1;
     128                                ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
     129                                ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, 'a', 0, 0,NULL,NULL, NULL);
     130                               
     131                                for (i = 0; i < connections[active_console].screenbuffer.size_x; i++)
     132                                        for (j = 0; j < connections[active_console].screenbuffer.size_y; j++) {
     133                                       
     134                                        ipc_call_async_3(fb_info.phone, FB_PUTCHAR, get_field_at(&(connections[active_console].screenbuffer),\
     135                                                                i, j)->character, j, i, NULL, NULL, NULL);
     136                                }
     137
    119138                                break;
    120139                        }
     
    154173                return;
    155174        }
     175       
    156176        connections[consnum].used = 1;
    157177        connections[consnum].client_phone = IPC_GET_ARG3(call);
     178        screenbuffer_clear(&(connections[consnum].screenbuffer));
    158179
    159180        /* Accept the connection */
     
    168189                        return;
    169190                case CONSOLE_PUTCHAR:
    170                         if (consnum != active_console) {
    171                         }
     191                       
    172192                        /* Send message to fb */
    173                         ipc_call_sync_2(connections[consnum].vfb_phone, FB_PUTCHAR, IPC_GET_ARG1(call), IPC_GET_ARG2(call), NULL, NULL);
    174 //                      ipc_call_sync_2(connections[6].vfb_phone, FB_PUTCHAR, 0, IPC_GET_ARG2(call),NULL,NULL);
     193                        if (consnum == active_console) {
     194                                ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, IPC_GET_ARG2(call), connections[consnum].screenbuffer.position_y, \
     195                                                connections[consnum].screenbuffer.position_x, NULL, NULL, NULL);
     196                        }
     197                       
     198                        screenbuffer_putchar(&(connections[consnum].screenbuffer), IPC_GET_ARG2(call));
    175199                        break;
    176200                case CONSOLE_CLEAR:
     201                        /* Send message to fb */
     202                        if (consnum == active_console) {
     203                                ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
     204                        }
     205                       
     206                        screenbuffer_clear(&(connections[consnum].screenbuffer));
     207                       
    177208                        break;
    178209                case CONSOLE_GOTO:
     210                       
     211                        screenbuffer_goto(&(connections[consnum].screenbuffer), IPC_GET_ARG1(call), IPC_GET_ARG2(call));
     212                       
    179213                        break;
    180214
     
    220254        /* Connect to framebuffer driver */
    221255       
     256        while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) {
     257                usleep(10000);
     258        }
     259       
     260        ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '1', 0, 0,NULL,NULL, NULL);
     261        ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols));
     262       
     263        /* Init virtual consoles */
    222264        for (i = 0; i < CONSOLE_COUNT; i++) {
     265                ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '$', 2*i, 1,NULL,NULL, NULL);
    223266                connections[i].used = 0;
    224267                keybuffer_init(&(connections[i].keybuffer));
     268                ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '>', 2*i+1, 1,NULL,NULL, NULL);
    225269               
    226                 /* TODO: init key_buffer */
    227                 while ((connections[i].vfb_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) {
    228                         usleep(10000);
    229                 }
    230270                connections[i].keyrequests.head = connections[i].keyrequests.tail = 0;
    231271                connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED;
    232272                connections[i].keyrequest_counter = 0;
     273               
     274                ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '?', 2*i+1, 1,NULL,NULL, NULL);
     275                if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) {
     276                        /*FIXME: handle error */
     277                        return -1;
     278                }
    233279        }
    234280       
     
    237283        };
    238284       
     285        ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, 'M', 3, 3,NULL,NULL, NULL);
    239286        async_manager();
    240287
Note: See TracChangeset for help on using the changeset viewer.