Changeset c1d2c9d in mainline


Ignore:
Timestamp:
2006-06-01T21:51:35Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
da0c91e7
Parents:
3993b3d
Message:

Added integration of console & fb.
Added ipc_call_async_3 call.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • console/console.c

    r3993b3d rc1d2c9d  
    4141#include <screenbuffer.h>
    4242
    43 static void sysput(char c)
    44 {
    45         __SYSCALL3(SYS_IO, 1, &c, 1);
    46 }
    47 
    48 //#define CONSOLE_COUNT VFB_CONNECTIONS
    4943#define CONSOLE_COUNT 8
    5044#define MAX_KEYREQUESTS_BUFFERED 32
     
    10397        int retval;
    10498        int i, j;
    105         char c;
     99        char c,d;
     100        connection_t *conn;
    106101
    107102        /* Ignore parameters, the connection is alread opened */
     
    118113                        retval = 0;
    119114                        c = IPC_GET_ARG1(call);
    120 //                      ipc_call_sync_2(connections[3].vfb_phone, FB_PUTCHAR, 0, c,NULL,NULL);
    121                
    122115                        /* switch to another virtual console */
    123116                       
     117                        conn = &connections[active_console];
    124118                        if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) {
    125119                                /*FIXME: draw another console content from buffer */
    126120
    127121                                active_console = c - KBD_KEY_F1;
     122                                conn = &connections[active_console];
     123
     124                                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL);
    128125                                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                                 }
     126                                for (i = 0; i < conn->screenbuffer.size_x; i++)
     127                                        for (j = 0; j < conn->screenbuffer.size_y; j++) {
     128                                                d = get_field_at(&(conn->screenbuffer),i, j)->character;
     129                                                if (d && d != ' ')
     130                                                        ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL);
     131                                        }
     132                                ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x, NULL, NULL);
     133                                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL, NULL);
    137134
    138135                                break;
     
    140137                       
    141138                        /* if client is awaiting key, send it */
    142                         if (connections[active_console].keyrequest_counter > 0) {               
    143                                 connections[active_console].keyrequest_counter--;
    144                                 ipc_answer_fast(fifo_pop(connections[active_console].keyrequests), 0, c, 0);
     139                        if (conn->keyrequest_counter > 0) {             
     140                                conn->keyrequest_counter--;
     141                                ipc_answer_fast(fifo_pop(conn->keyrequests), 0, c, 0);
    145142                                break;
    146143                        }
    147144                       
    148145                        /*FIXME: else store key to its buffer */
    149                         keybuffer_push(&(connections[active_console].keybuffer), c);
    150                        
    151                         /* Send it to first FB, DEBUG */
    152 //                      ipc_call_async_2(connections[0].vfb_phone, FB_PUTCHAR, 0, IPC_GET_ARG1(call),NULL,NULL);
    153 //                      ipc_call_sync_2(connections[4].vfb_phone, FB_PUTCHAR, 0, c,NULL,NULL);
    154 
     146                        keybuffer_push(&conn->keybuffer, c);
     147                       
    155148                        break;
    156149                default:
     
    192185                        /* Send message to fb */
    193186                        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);
     187                                ipc_call_async_3(fb_info.phone, FB_PUTCHAR, IPC_GET_ARG2(call), connections[consnum].screenbuffer.position_y, \
     188                                                connections[consnum].screenbuffer.position_x, NULL, NULL);
    196189                        }
    197190                       
     
    226219                        };
    227220                        keybuffer_pop(&(connections[consnum].keybuffer), (char *)&arg1);
    228 //                      ipc_call_sync_2(connections[6].vfb_phone, FB_PUTCHAR, 0, arg1,NULL,NULL);
    229221                       
    230222                        break;
     
    258250        }
    259251       
    260         ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '1', 0, 0,NULL,NULL, NULL);
    261252        ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols));
     253        ipc_call_sync(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL);
    262254       
    263255        /* Init virtual consoles */
    264256        for (i = 0; i < CONSOLE_COUNT; i++) {
    265                 ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '$', 2*i, 1,NULL,NULL, NULL);
    266257                connections[i].used = 0;
    267258                keybuffer_init(&(connections[i].keybuffer));
    268                 ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '>', 2*i+1, 1,NULL,NULL, NULL);
    269259               
    270260                connections[i].keyrequests.head = connections[i].keyrequests.tail = 0;
     
    272262                connections[i].keyrequest_counter = 0;
    273263               
    274                 ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, '?', 2*i+1, 1,NULL,NULL, NULL);
    275264                if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) {
    276265                        /*FIXME: handle error */
     
    283272        };
    284273       
    285         ipc_call_sync_3(fb_info.phone, FB_PUTCHAR, 'M', 3, 3,NULL,NULL, NULL);
    286274        async_manager();
    287275
  • fb/fb.c

    r3993b3d rc1d2c9d  
    269269
    270270/** Invert character at given position */
    271 static void invert_char(int vp,unsigned int col, unsigned int row)
     271static void invert_char(int vp,unsigned int row, unsigned int col)
    272272{
    273273        unsigned int x;
     
    334334        viewports[i].fgcolor = DEFAULT_FGCOLOR;
    335335       
     336        viewports[i].cur_col = 0;
     337        viewports[i].cur_row = 0;
     338        viewports[i].cursor_active = 0;
     339
    336340        viewports[i].initialized = 1;
    337341
     
    416420}
    417421
    418 static void draw_char(int vp, char c, unsigned int col, unsigned int row)
     422static void draw_char(int vp, char c, unsigned int row, unsigned int col)
    419423{
    420424        viewport_t *vport = &viewports[vp];
    421425
    422426        if (vport->cursor_active && (vport->cur_col != col || vport->cur_row != row))
    423                 invert_char(vp, vport->cur_col,vport->cur_row);
    424        
    425         draw_glyph(vp, c, col, row);
    426        
    427         if (vport->cursor_active) {
    428                 vport->cur_col++;
    429                 if (vport->cur_col>= vport->cols) {
    430                         vport->cur_col = 0;
    431                         vport->cur_row++;
    432                         if (vport->cur_row >= vport->rows)
    433                                 vport->cur_row--;
    434                 }
    435                 invert_char(vp, vport->cur_col,vport->cur_row);
     427                invert_char(vp, vport->cur_row, vport->cur_col);
     428       
     429        draw_glyph(vp, c, row, col);
     430
     431        vport->cur_col = col;
     432        vport->cur_row = row;
     433
     434        vport->cur_col++;
     435        if (vport->cur_col>= vport->cols) {
     436                vport->cur_col = 0;
     437                vport->cur_row++;
     438                if (vport->cur_row >= vport->rows)
     439                        vport->cur_row--;
    436440        }
     441        if (vport->cursor_active)
     442                invert_char(vp, vport->cur_row, vport->cur_col);
    437443}
    438444
     
    481487                        clear_port(vp);
    482488                        if (vport->cursor_active)
    483                                 invert_char(vp, vport->cur_col,vport->cur_row);
     489                                invert_char(vp, vport->cur_row, vport->cur_col);
    484490                        retval = 0;
    485491                        break;
     
    493499                        retval = 0;
    494500                        if (viewports[vp].cursor_active) {
    495                                 invert_char(vp, vport->cur_col,vport->cur_row);
    496                                 invert_char(vp, col, row);
     501                                invert_char(vp, vport->cur_row, vport->cur_col);
     502                                invert_char(vp, row, col);
    497503                        }
    498504                        vport->cur_col = col;
     
    506512
    507513                        vport->cursor_active = i;
    508                         invert_char(vp, vport->cur_col,vport->cur_row);
     514                        invert_char(vp, vport->cur_row, vport->cur_col);
    509515                        break;
    510516                case FB_GET_CSIZE:
     
    518524                        }
    519525                        if (vport->cursor_active)
    520                                 invert_char(vp, vport->cur_col,vport->cur_row);
     526                                invert_char(vp, vport->cur_row, vport->cur_col);
    521527                        scroll_port(vp, i);
    522528                        if (vport->cursor_active)
    523                                 invert_char(vp, vport->cur_col,vport->cur_row);
     529                                invert_char(vp, vport->cur_row, vport->cur_col);
    524530                        retval = 0;
    525531                        break;
  • init/init.c

    r3993b3d rc1d2c9d  
    446446//      test_async_kbd();
    447447//      test_fb();
    448 //      test_console();
     448        test_console();
    449449
    450450        printf("\nBye.\n");
  • libc/generic/ipc.c

    r3993b3d rc1d2c9d  
    116116}
    117117
    118 /** Send asynchronous message
    119  *
    120  * - if fatal error, call callback handler with proper error code
    121  * - if message cannot be temporarily sent, add to queue
    122  */
    123 void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
    124                       ipcarg_t arg2, void *private,
    125                       ipc_async_callback_t callback)
     118/** Prolog to ipc_async_send functions */
     119static inline async_call_t *ipc_prepare_async(void *private, ipc_async_callback_t callback)
    126120{
    127121        async_call_t *call;
    128         ipc_callid_t callid;
    129122
    130123        call = malloc(sizeof(*call));
     
    132125                if (callback)
    133126                        callback(private, ENOMEM, NULL);
    134                 return;
    135         }
    136 
     127                return NULL;
     128        }
    137129        call->callback = callback;
    138130        call->private = private;
     131
     132        return call;
     133}
     134
     135/** Epilogue of ipc_async_send functions */
     136static inline void ipc_finish_async(ipc_callid_t callid, int phoneid, async_call_t *call)
     137{
     138        if (callid == IPC_CALLRET_FATAL) {
     139                futex_up(&ipc_futex);
     140                /* Call asynchronous handler with error code */
     141                if (call->callback)
     142                        call->callback(call->private, ENOENT, NULL);
     143                free(call);
     144                return;
     145        }
     146
     147        if (callid == IPC_CALLRET_TEMPORARY) {
     148                futex_up(&ipc_futex);
     149
     150                call->u.msg.phoneid = phoneid;
     151
     152                call->ptid = psthread_get_id();
     153                futex_down(&async_futex);
     154                list_append(&call->list, &queued_calls);
     155
     156                psthread_schedule_next_adv(PS_TO_MANAGER);
     157                /* Async futex unlocked by previous call */
     158                return;
     159        }
     160        call->u.callid = callid;
     161        /* Add call to list of dispatched calls */
     162        list_append(&call->list, &dispatched_calls);
     163        futex_up(&ipc_futex);
     164       
     165}
     166
     167/** Send asynchronous message
     168 *
     169 * - if fatal error, call callback handler with proper error code
     170 * - if message cannot be temporarily sent, add to queue
     171 */
     172void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
     173                      ipcarg_t arg2, void *private,
     174                      ipc_async_callback_t callback)
     175{
     176        async_call_t *call;
     177        ipc_callid_t callid;
     178
     179        call = ipc_prepare_async(private, callback);
     180        if (!call)
     181                return;
    139182
    140183        /* We need to make sure that we get callid before
     
    142185        futex_down(&ipc_futex);
    143186        callid = __SYSCALL4(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1, arg2);
    144         if (callid == IPC_CALLRET_FATAL) {
    145                 futex_up(&ipc_futex);
    146                 /* Call asynchronous handler with error code */
    147                 if (callback)
    148                         callback(private, ENOENT, NULL);
    149                 free(call);
    150                 return;
    151         }
    152187
    153188        if (callid == IPC_CALLRET_TEMPORARY) {
    154                 futex_up(&ipc_futex);
    155 
    156                 call->u.msg.phoneid = phoneid;
    157189                IPC_SET_METHOD(call->u.msg.data, method);
    158190                IPC_SET_ARG1(call->u.msg.data, arg1);
    159191                IPC_SET_ARG2(call->u.msg.data, arg2);
    160 
    161                 call->ptid = psthread_get_id();
    162                 futex_down(&async_futex);
    163                 list_append(&call->list, &queued_calls);
    164 
    165                 psthread_schedule_next_adv(PS_TO_MANAGER);
    166                 /* Async futex unlocked by previous call */
     192        }
     193        ipc_finish_async(callid, phoneid, call);
     194}
     195
     196/** Send asynchronous message
     197 *
     198 * - if fatal error, call callback handler with proper error code
     199 * - if message cannot be temporarily sent, add to queue
     200 */
     201void ipc_call_async_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
     202                      ipcarg_t arg2, ipcarg_t arg3, void *private,
     203                      ipc_async_callback_t callback)
     204{
     205        async_call_t *call;
     206        ipc_callid_t callid;
     207
     208        call = ipc_prepare_async(private, callback);
     209        if (!call)
    167210                return;
    168         }
    169         call->u.callid = callid;
    170         /* Add call to list of dispatched calls */
    171         list_append(&call->list, &dispatched_calls);
    172         futex_up(&ipc_futex);
     211
     212        IPC_SET_METHOD(call->u.msg.data, method);
     213        IPC_SET_ARG1(call->u.msg.data, arg1);
     214        IPC_SET_ARG2(call->u.msg.data, arg2);
     215        IPC_SET_ARG3(call->u.msg.data, arg3);
     216        /* We need to make sure that we get callid before
     217         * another thread accesses the queue again */
     218        futex_down(&ipc_futex);
     219        callid = _ipc_call_async(phoneid, &call->u.msg.data);
     220
     221        ipc_finish_async(callid, phoneid, call);
    173222}
    174223
  • libc/include/ipc/ipc.h

    r3993b3d rc1d2c9d  
    7171                      ipcarg_t arg2, void *private,
    7272                      ipc_async_callback_t callback);
     73extern void ipc_call_async_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
     74                             ipcarg_t arg2, ipcarg_t arg3, void *private,
     75                             ipc_async_callback_t callback);
    7376extern int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phone);
    7477extern int ipc_connect_me_to(int phoneid, int arg1, int arg2);
Note: See TracChangeset for help on using the changeset viewer.