Subversion Repositories HelenOS

Rev

Rev 1517 | Rev 1520 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1517 Rev 1518
Line 39... Line 39...
39
#include <async.h>
39
#include <async.h>
40
#include <libadt/fifo.h>
40
#include <libadt/fifo.h>
41
#include <screenbuffer.h>
41
#include <screenbuffer.h>
42
#include <sys/mman.h>
42
#include <sys/mman.h>
43
 
43
 
44
#define CONSOLE_COUNT 12 
-
 
45
#define MAX_KEYREQUESTS_BUFFERED 32
44
#define MAX_KEYREQUESTS_BUFFERED 32
46
 
45
 
47
#define NAME "CONSOLE"
46
#define NAME "CONSOLE"
48
 
47
 
49
int active_console = 0;
48
int active_console = 0;
Line 116... Line 115...
116
                break;
115
                break;
117
 
116
 
118
            scr->position_x--;
117
            scr->position_x--;
119
 
118
 
120
            if (console == active_console) {
119
            if (console == active_console) {
121
                ipc_call_async_3(fb_info.phone, FB_PUTCHAR, ' ', scr->position_y, scr->position_x, NULL, NULL);
120
                nsend_call_3(fb_info.phone, FB_PUTCHAR, ' ', scr->position_y, scr->position_x);
122
            }
121
            }
123
   
122
   
124
            screenbuffer_putchar(scr, ' ');
123
            screenbuffer_putchar(scr, ' ');
125
           
124
           
126
            break;
125
            break;
127
        default:   
126
        default:   
128
            if (console == active_console) {
127
            if (console == active_console) {
129
                ipc_call_async_3(fb_info.phone, FB_PUTCHAR, key, scr->position_y, scr->position_x, NULL, NULL);
128
                nsend_call_3(fb_info.phone, FB_PUTCHAR, key, scr->position_y, scr->position_x);
130
            }
129
            }
131
   
130
   
132
            screenbuffer_putchar(scr, key);
131
            screenbuffer_putchar(scr, key);
133
            scr->position_x++;
132
            scr->position_x++;
134
    }
133
    }
Line 136... Line 135...
136
    scr->position_y += (scr->position_x >= scr->size_x);
135
    scr->position_y += (scr->position_x >= scr->size_x);
137
   
136
   
138
    if (scr->position_y >= scr->size_y) {
137
    if (scr->position_y >= scr->size_y) {
139
        scr->position_y = scr->size_y - 1;
138
        scr->position_y = scr->size_y - 1;
140
        screenbuffer_clear_line(scr, scr->top_line++);
139
        screenbuffer_clear_line(scr, scr->top_line++);
-
 
140
        if (console == active_console)
141
        ipc_call_async(fb_info.phone, FB_SCROLL, 1, NULL, NULL);
141
            nsend_call(fb_info.phone, FB_SCROLL, 1);
142
    }
142
    }
143
   
143
   
144
    scr->position_x = scr->position_x % scr->size_x;
144
    scr->position_x = scr->position_x % scr->size_x;
145
   
145
   
146
    if (console == active_console) 
146
    if (console == active_console) 
147
        ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, scr->position_y, scr->position_x, NULL, NULL);
147
        send_call_2(fb_info.phone, FB_CURSOR_GOTO, scr->position_y, scr->position_x);
148
   
148
   
149
}
149
}
150
 
150
 
151
 
151
 
152
/* Handler for keyboard */
152
/* Handler for keyboard */
Line 190... Line 190...
190
                }
190
                }
191
               
191
               
192
               
192
               
193
                conn = &connections[active_console];
193
                conn = &connections[active_console];
194
 
194
 
195
                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL);
195
                nsend_call(fb_info.phone, FB_CURSOR_VISIBILITY, 0);
196
       
196
       
197
                if (interbuffer) {
197
                if (interbuffer) {
198
                    for (i = 0; i < conn->screenbuffer.size_x; i++)
198
                    for (i = 0; i < conn->screenbuffer.size_x; i++)
199
                        for (j = 0; j < conn->screenbuffer.size_y; j++)
199
                        for (j = 0; j < conn->screenbuffer.size_y; j++)
200
                            interbuffer[i + j*conn->screenbuffer.size_x] = *get_field_at(&(conn->screenbuffer),i, j);
200
                            interbuffer[i + j*conn->screenbuffer.size_x] = *get_field_at(&(conn->screenbuffer),i, j);
201
                           
201
                           
202
                    sync_send_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, NULL);       
202
                    sync_send_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, NULL);       
203
                } else {
203
                } else {
204
 
-
 
205
                    ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
204
                    nsend_call(fb_info.phone, FB_CLEAR, 0);
206
               
205
               
207
                   
206
                   
208
                    for (i = 0; i < conn->screenbuffer.size_x; i++)
207
                    for (i = 0; i < conn->screenbuffer.size_x; i++)
209
                        for (j = 0; j < conn->screenbuffer.size_y; j++) {
208
                        for (j = 0; j < conn->screenbuffer.size_y; j++) {
210
                            d = get_field_at(&(conn->screenbuffer),i, j)->character;
209
                            d = get_field_at(&(conn->screenbuffer),i, j)->character;
211
                            if (d && d != ' ')
210
                            if (d && d != ' ')
212
                                ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL);
211
                                nsend_call_3(fb_info.phone, FB_PUTCHAR, d, j, i);
213
                        }
212
                        }
214
 
213
 
215
                }
214
                }
216
                ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x, NULL, NULL);
215
                nsend_call_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x);
217
                ipc_call_async_2(fb_info.phone, FB_SET_STYLE, conn->screenbuffer.style.fg_color, \
216
                nsend_call_2(fb_info.phone, FB_SET_STYLE, conn->screenbuffer.style.fg_color, \
218
                        conn->screenbuffer.style.bg_color, NULL, NULL);
217
                        conn->screenbuffer.style.bg_color);
219
                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL, NULL);
218
                send_call(fb_info.phone, FB_CURSOR_VISIBILITY, 1);
220
 
219
 
221
                break;
220
                break;
222
            }
221
            }
223
           
222
           
224
            /* if client is awaiting key, send it */
223
            /* if client is awaiting key, send it */
Line 238... Line 237...
238
        ipc_answer_fast(callid, retval, 0, 0);
237
        ipc_answer_fast(callid, retval, 0, 0);
239
    }
238
    }
240
}
239
}
241
 
240
 
242
/** Default thread for new connections */
241
/** Default thread for new connections */
243
void client_connection(ipc_callid_t iid, ipc_call_t *icall)
242
static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
244
{
243
{
245
    ipc_callid_t callid;
244
    ipc_callid_t callid;
246
    ipc_call_t call;
245
    ipc_call_t call;
247
    int consnum;
246
    int consnum;
248
    ipcarg_t arg1;
247
    ipcarg_t arg1;
Line 270... Line 269...
270
            write_char(consnum, IPC_GET_ARG1(call));
269
            write_char(consnum, IPC_GET_ARG1(call));
271
            break;
270
            break;
272
        case CONSOLE_CLEAR:
271
        case CONSOLE_CLEAR:
273
            /* Send message to fb */
272
            /* Send message to fb */
274
            if (consnum == active_console) {
273
            if (consnum == active_console) {
275
                ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
274
                send_call(fb_info.phone, FB_CLEAR, 0);
276
            }
275
            }
277
           
276
           
278
            screenbuffer_clear(&(connections[consnum].screenbuffer));
277
            screenbuffer_clear(&(connections[consnum].screenbuffer));
279
           
278
           
280
            break;
279
            break;
Line 328... Line 327...
328
    while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) {
327
    while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) {
329
        usleep(10000);
328
        usleep(10000);
330
    }
329
    }
331
   
330
   
332
    ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols));
331
    ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols));
333
    ipc_call_async_2(fb_info.phone, FB_SET_STYLE, DEFAULT_FOREGROUND_COLOR, DEFAULT_BACKGROUND_COLOR, NULL, NULL);
332
    nsend_call_2(fb_info.phone, FB_SET_STYLE, DEFAULT_FOREGROUND_COLOR, DEFAULT_BACKGROUND_COLOR);
334
    ipc_call_sync(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL);
333
    nsend_call(fb_info.phone, FB_CURSOR_VISIBILITY, 1);
335
   
334
   
336
    /* Init virtual consoles */
335
    /* Init virtual consoles */
337
    for (i = 0; i < CONSOLE_COUNT; i++) {
336
    for (i = 0; i < CONSOLE_COUNT; i++) {
338
        connections[i].used = 0;
337
        connections[i].used = 0;
339
        keybuffer_init(&(connections[i].keybuffer));
338
        keybuffer_init(&(connections[i].keybuffer));
Line 359... Line 358...
359
*/
358
*/
360
    }
359
    }
361
   
360
   
362
    async_new_connection(phonehash, 0, NULL, keyboard_events);
361
    async_new_connection(phonehash, 0, NULL, keyboard_events);
363
   
362
   
364
    ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, 0, 0, NULL, NULL);
363
    nsend_call_2(fb_info.phone, FB_CURSOR_GOTO, 0, 0);
365
 
364
 
-
 
365
    /* Register at NS */
366
    if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) {
366
    if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) {
367
        return -1;
367
        return -1;
368
    };
368
    };
369
   
369
   
370
    async_manager();
370
    async_manager();