Subversion Repositories HelenOS

Rev

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

Rev 1530 Rev 1534
Line 38... Line 38...
38
#include <ipc/ipc.h>
38
#include <ipc/ipc.h>
39
#include <ipc/ns.h>
39
#include <ipc/ns.h>
40
#include <ipc/services.h>
40
#include <ipc/services.h>
41
 
41
 
42
#include "ega.h"
42
#include "ega.h"
-
 
43
#include "../console/screenbuffer.h"
-
 
44
#include "main.h"
43
 
45
 
44
/* Allow only 1 connection */
46
/* Allow only 1 connection */
45
static int client_connected = 0;
47
static int client_connected = 0;
46
 
48
 
47
static unsigned int scr_width;
49
static unsigned int scr_width;
48
static unsigned int scr_height;
50
static unsigned int scr_height;
49
static char *scr_addr;
51
static char *scr_addr;
50
 
52
 
-
 
53
static unsigned int style = 0x0f;
-
 
54
 
51
static void clrscr(void)
55
static void clrscr(void)
52
{
56
{
53
    int i;
57
    int i;
54
   
58
   
55
    for (i=0; i < scr_width*scr_height; i++)
59
    for (i=0; i < scr_width*scr_height; i++) {
56
        scr_addr[i*2] = ' ';
60
        scr_addr[i*2] = ' ';
-
 
61
        scr_addr[i*2+1] = style;
-
 
62
    }
57
}
63
}
58
 
64
 
59
static void printchar(char c, unsigned int row, unsigned int col)
65
static void printchar(char c, unsigned int row, unsigned int col)
60
{
66
{
61
    scr_addr[(row*scr_width + col)*2] = c;
67
    scr_addr[(row*scr_width + col)*2] = c;
-
 
68
    scr_addr[(row*scr_width + col)*2+1] = style;
-
 
69
}
-
 
70
 
-
 
71
static void draw_text_data(keyfield_t *data)
-
 
72
{
-
 
73
    int i;
-
 
74
 
-
 
75
    for (i=0; i < scr_width*scr_height; i++) {
-
 
76
        scr_addr[i*2] = data[i].character;
-
 
77
        if (data[i].style.fg_color > data[i].style.bg_color)
-
 
78
            scr_addr[i*2+1] = 0x0f;
-
 
79
        else
-
 
80
            scr_addr[i*2+1] = 0xf0;
-
 
81
    }
62
}
82
}
63
 
83
 
64
static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall)
84
static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall)
65
{
85
{
66
    int retval;
86
    int retval;
67
    ipc_callid_t callid;
87
    ipc_callid_t callid;
68
    ipc_call_t call;
88
    ipc_call_t call;
69
    char c;
89
    char c;
70
    unsigned int row, col;
90
    unsigned int row, col;
-
 
91
    int bgcolor,fgcolor;
-
 
92
    keyfield_t *interbuf = NULL;
-
 
93
    size_t intersize = 0;
71
 
94
 
72
    if (client_connected) {
95
    if (client_connected) {
73
        ipc_answer_fast(iid, ELIMIT, 0,0);
96
        ipc_answer_fast(iid, ELIMIT, 0,0);
74
        return;
97
        return;
75
    }
98
    }
Line 81... Line 104...
81
        switch (IPC_GET_METHOD(call)) {
104
        switch (IPC_GET_METHOD(call)) {
82
        case IPC_M_PHONE_HUNGUP:
105
        case IPC_M_PHONE_HUNGUP:
83
            client_connected = 0;
106
            client_connected = 0;
84
            ipc_answer_fast(callid,0,0,0);
107
            ipc_answer_fast(callid,0,0,0);
85
            return; /* Exit thread */
108
            return; /* Exit thread */
-
 
109
        case IPC_M_AS_AREA_SEND:
-
 
110
            /* We accept one area for data interchange */
-
 
111
            intersize = IPC_GET_ARG2(call);
-
 
112
            if (intersize >= scr_width*scr_height*sizeof(*interbuf)) {
-
 
113
                receive_comm_area(callid,&call,(void **)&interbuf, scr_width*scr_height*sizeof(*interbuf));
-
 
114
                continue;
-
 
115
            }
-
 
116
            retval = EINVAL;
-
 
117
            break;
-
 
118
        case FB_DRAW_TEXT_DATA:
-
 
119
            if (!interbuf) {
-
 
120
                retval = EINVAL;
-
 
121
                break;
-
 
122
            }
-
 
123
            draw_text_data(interbuf);
-
 
124
            retval = 0;
-
 
125
            break;
86
        case FB_GET_CSIZE:
126
        case FB_GET_CSIZE:
87
            ipc_answer_fast(callid, 0, scr_height, scr_width);
127
            ipc_answer_fast(callid, 0, scr_height, scr_width);
88
            continue;
128
            continue;
89
        case FB_CLEAR:
129
        case FB_CLEAR:
90
            clrscr();
130
            clrscr();
Line 92... Line 132...
92
            break;
132
            break;
93
        case FB_PUTCHAR:
133
        case FB_PUTCHAR:
94
            c = IPC_GET_ARG1(call);
134
            c = IPC_GET_ARG1(call);
95
            row = IPC_GET_ARG2(call);
135
            row = IPC_GET_ARG2(call);
96
            col = IPC_GET_ARG3(call);
136
            col = IPC_GET_ARG3(call);
97
            if (row >= scr_width || col >= scr_height) {
137
            if (col >= scr_width || row >= scr_height) {
98
                retval = EINVAL;
138
                retval = EINVAL;
99
                break;
139
                break;
100
            }
140
            }
101
            printchar(c,row,col);
141
            printchar(c,row,col);
102
            retval = 0;
142
            retval = 0;
103
            break;
143
            break;
-
 
144
        case FB_SET_STYLE:
-
 
145
            fgcolor = IPC_GET_ARG1(call);
-
 
146
            bgcolor = IPC_GET_ARG2(call);
-
 
147
            if (fgcolor > bgcolor)
-
 
148
                style = 0x0f;
-
 
149
            else
-
 
150
                style = 0xf0;
104
        default:
151
        default:
105
            retval = ENOENT;
152
            retval = ENOENT;
106
        }
153
        }
107
        ipc_answer_fast(callid,retval,0,0);
154
        ipc_answer_fast(callid,retval,0,0);
108
    }
155
    }