Subversion Repositories HelenOS-historic

Rev

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

Rev 1506 Rev 1512
Line 37... Line 37...
37
#include <console.h>
37
#include <console.h>
38
#include <unistd.h>
38
#include <unistd.h>
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
 
43
 
43
#define CONSOLE_COUNT 12 
44
#define CONSOLE_COUNT 12 
44
#define MAX_KEYREQUESTS_BUFFERED 32
45
#define MAX_KEYREQUESTS_BUFFERED 32
45
 
46
 
46
#define NAME "CONSOLE"
47
#define NAME "CONSOLE"
47
 
48
 
48
int active_console = 1;
49
int active_console = 0;
49
 
50
 
50
struct {
51
struct {
51
    int phone;      /**< Framebuffer phone */
52
    int phone;      /**< Framebuffer phone */
52
    ipcarg_t rows;      /**< Framebuffer rows */
53
    ipcarg_t rows;      /**< Framebuffer rows */
53
    ipcarg_t cols;      /**< Framebuffer columns */
54
    ipcarg_t cols;      /**< Framebuffer columns */
Line 63... Line 64...
63
} connection_t;
64
} connection_t;
64
 
65
 
65
 
66
 
66
 
67
 
67
connection_t connections[CONSOLE_COUNT];
68
connection_t connections[CONSOLE_COUNT];
-
 
69
keyfield_t *interbuffer = NULL;
68
 
70
   
69
static int find_free_connection()
71
static int find_free_connection()
70
{
72
{
71
    int i = 0;
73
    int i = 0;
72
   
74
   
73
    while (i < CONSOLE_COUNT) {
75
    while (i < CONSOLE_COUNT) {
Line 154... Line 156...
154
    ipc_call_t call;
156
    ipc_call_t call;
155
    int retval;
157
    int retval;
156
    int i, j;
158
    int i, j;
157
    char c,d;
159
    char c,d;
158
    connection_t *conn;
160
    connection_t *conn;
159
    keyfield_t *interbuffer = NULL;
-
 
160
 
-
 
161
//  interbuffer = mmap(,, PROTO_READ|PROTO_WRITE, MAP_ANONYMOUS, , );   
-
 
162
   
161
   
163
    /* Ignore parameters, the connection is alread opened */
162
    /* Ignore parameters, the connection is alread opened */
164
    while (1) {
163
    while (1) {
165
        callid = async_get_call(&call);
164
        callid = async_get_call(&call);
166
        switch (IPC_GET_METHOD(call)) {
165
        switch (IPC_GET_METHOD(call)) {
Line 183... Line 182...
183
                        break;
182
                        break;
184
                active_console = c - '1';
183
                active_console = c - '1';
185
                conn = &connections[active_console];
184
                conn = &connections[active_console];
186
 
185
 
187
                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL);
186
                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL);
-
 
187
       
-
 
188
                if (interbuffer) {
-
 
189
                    for (i = 0; i < fb_info.cols * fb_info.rows; i++)
-
 
190
                        interbuffer[i] = conn->screenbuffer.buffer[i]; 
-
 
191
                    ipc_call_sync(fb_info.phone, FB_DRAW_TEXT_DATA, 0, NULL);      
-
 
192
                } else {
-
 
193
 
188
                ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
194
                    ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
189
               
195
               
-
 
196
                   
190
                for (i = 0; i < conn->screenbuffer.size_x; i++)
197
                    for (i = 0; i < conn->screenbuffer.size_x; i++)
191
                    for (j = 0; j < conn->screenbuffer.size_y; j++) {
198
                        for (j = 0; j < conn->screenbuffer.size_y; j++) {
192
                        d = get_field_at(&(conn->screenbuffer),i, j)->character;
199
                            d = get_field_at(&(conn->screenbuffer),i, j)->character;
193
                        if (d && d != ' ')
200
                            if (d && d != ' ')
194
                            ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL);
201
                                ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL);
195
                    }
202
                        }
196
 
203
 
197
                ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x, NULL, NULL);
204
                    ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x, NULL, NULL);
-
 
205
                }
198
                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL, NULL);
206
                ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL, NULL);
199
 
207
 
200
                break;
208
                break;
201
            }
209
            }
202
           
210
           
Line 324... Line 332...
324
            /*FIXME: handle error */
332
            /*FIXME: handle error */
325
            return -1;
333
            return -1;
326
        }
334
        }
327
    }
335
    }
328
   
336
   
-
 
337
    if ((interbuffer = mmap(NULL, sizeof(keyfield_t) * fb_info.cols * fb_info.rows , PROTO_READ|PROTO_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0 ,0 )) != NULL) {
-
 
338
        if (ipc_call_sync_3(fb_info.phone, IPC_M_AS_AREA_SEND, (ipcarg_t)interbuffer, 0, AS_AREA_READ | AS_AREA_CACHEABLE, NULL, NULL, NULL) != 0) {
-
 
339
//          ipc_call_async_3(fb_info.phone, FB_PUTCHAR, '?', 10, 10, NULL, NULL);
-
 
340
            munmap(interbuffer, sizeof(keyfield_t) * fb_info.cols * fb_info.rows);
-
 
341
            interbuffer = NULL;
-
 
342
        }
-
 
343
/*  } else {
-
 
344
        ipc_call_async_3(fb_info.phone, FB_PUTCHAR, '!', 10, 10, NULL, NULL);
-
 
345
*/
-
 
346
    }
-
 
347
   
329
    async_new_connection(phonehash, 0, NULL, keyboard_events);
348
    async_new_connection(phonehash, 0, NULL, keyboard_events);
330
   
349
   
331
    ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, 0, 0, NULL, NULL);
350
    ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, 0, 0, NULL, NULL);
332
 
351
 
333
    if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) {
352
    if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) {