Subversion Repositories HelenOS-historic

Rev

Rev 1577 | Rev 1649 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1577 Rev 1640
1
/*
1
/*
2
 * Copyright (C) 2006 Ondrej Palkovsky
2
 * Copyright (C) 2006 Ondrej Palkovsky
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
#include <stdlib.h>
28
#include <stdlib.h>
29
#include <unistd.h>
29
#include <unistd.h>
30
#include <align.h>
30
#include <align.h>
31
#include <async.h>
31
#include <async.h>
32
#include <ipc/ipc.h>
32
#include <ipc/ipc.h>
33
#include <errno.h>
33
#include <errno.h>
34
#include <stdio.h>
34
#include <stdio.h>
35
#include <ddi.h>
35
#include <ddi.h>
36
#include <sysinfo.h>
36
#include <sysinfo.h>
37
#include <as.h>
37
#include <as.h>
38
#include <ipc/fb.h>
38
#include <ipc/fb.h>
39
#include <ipc/ipc.h>
39
#include <ipc/ipc.h>
40
#include <ipc/ns.h>
40
#include <ipc/ns.h>
41
#include <ipc/services.h>
41
#include <ipc/services.h>
42
 
42
 
43
#include "ega.h"
43
#include "ega.h"
44
#include "../console/screenbuffer.h"
44
#include "../console/screenbuffer.h"
45
#include "main.h"
45
#include "main.h"
46
 
46
 
47
#define MAX_SAVED_SCREENS 256
47
#define MAX_SAVED_SCREENS 256
48
typedef struct saved_screen {
48
typedef struct saved_screen {
49
    short *data;
49
    short *data;
50
} saved_screen;
50
} saved_screen;
51
 
51
 
52
saved_screen saved_screens[MAX_SAVED_SCREENS];
52
saved_screen saved_screens[MAX_SAVED_SCREENS];
53
 
53
 
54
 
54
 
55
#define EGA_IO_ADDRESS 0x3d4
55
#define EGA_IO_ADDRESS 0x3d4
56
#define EGA_IO_SIZE 2
56
#define EGA_IO_SIZE 2
57
 
57
 
-
 
58
#define NORMAL_COLOR       0x0f
-
 
59
#define INVERTED_COLOR     0xf0
-
 
60
 
-
 
61
#define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR)
-
 
62
 
58
typedef unsigned char u8;
63
typedef unsigned char u8;
59
typedef unsigned short u16;
64
typedef unsigned short u16;
60
typedef unsigned int u32;
65
typedef unsigned int u32;
61
 
66
 
62
 
67
 
63
/* Allow only 1 connection */
68
/* Allow only 1 connection */
64
static int client_connected = 0;
69
static int client_connected = 0;
65
 
70
 
66
static unsigned int scr_width;
71
static unsigned int scr_width;
67
static unsigned int scr_height;
72
static unsigned int scr_height;
68
static char *scr_addr;
73
static char *scr_addr;
69
 
74
 
70
static unsigned int style = 0x1e;
75
static unsigned int style = NORMAL_COLOR;
71
 
76
 
72
static inline void outb(u16 port, u8 b)
77
static inline void outb(u16 port, u8 b)
73
{
78
{
74
    asm volatile ("outb %0, %1\n" :: "a" (b), "d" (port));
79
    asm volatile ("outb %0, %1\n" :: "a" (b), "d" (port));
75
}
80
}
76
 
81
 
77
static inline void outw(u16 port, u16 w)
82
static inline void outw(u16 port, u16 w)
78
{
83
{
79
    asm volatile ("outw %0, %1\n" :: "a" (w), "d" (port));
84
    asm volatile ("outw %0, %1\n" :: "a" (w), "d" (port));
80
}
85
}
81
 
86
 
82
static inline void outl(u16 port, u32 l)
87
static inline void outl(u16 port, u32 l)
83
{
88
{
84
    asm volatile ("outl %0, %1\n" :: "a" (l), "d" (port));
89
    asm volatile ("outl %0, %1\n" :: "a" (l), "d" (port));
85
}
90
}
86
 
91
 
87
static inline u8 inb(u16 port)
92
static inline u8 inb(u16 port)
88
{
93
{
89
    u8 val;
94
    u8 val;
90
 
95
 
91
    asm volatile ("inb %1, %0 \n" : "=a" (val) : "d"(port));
96
    asm volatile ("inb %1, %0 \n" : "=a" (val) : "d"(port));
92
    return val;
97
    return val;
93
}
98
}
94
 
99
 
95
static inline u16 inw(u16 port)
100
static inline u16 inw(u16 port)
96
{
101
{
97
    u16 val;
102
    u16 val;
98
 
103
 
99
    asm volatile ("inw %1, %0 \n" : "=a" (val) : "d"(port));
104
    asm volatile ("inw %1, %0 \n" : "=a" (val) : "d"(port));
100
    return val;
105
    return val;
101
}
106
}
102
 
107
 
103
static inline u32 inl(u16 port)
108
static inline u32 inl(u16 port)
104
{
109
{
105
    u32 val;
110
    u32 val;
106
 
111
 
107
    asm volatile ("inl %1, %0 \n" : "=a" (val) : "d"(port));
112
    asm volatile ("inl %1, %0 \n" : "=a" (val) : "d"(port));
108
    return val;
113
    return val;
109
}
114
}
110
 
115
 
111
 
116
 
112
 
117
 
113
 
118
 
114
static void clrscr(void)
119
static void clrscr(void)
115
{
120
{
116
    int i;
121
    int i;
117
   
122
   
118
    for (i=0; i < scr_width*scr_height; i++) {
123
    for (i=0; i < scr_width*scr_height; i++) {
119
        scr_addr[i*2] = ' ';
124
        scr_addr[i*2] = ' ';
120
        scr_addr[i*2+1] = style;
125
        scr_addr[i*2+1] = style;
121
    }
126
    }
122
}
127
}
123
 
128
 
124
static void cursor_goto(unsigned int row, unsigned int col)
129
static void cursor_goto(unsigned int row, unsigned int col)
125
{
130
{
126
    int ega_cursor;
131
    int ega_cursor;
127
 
132
 
128
    ega_cursor=col+scr_width*row;
133
    ega_cursor=col+scr_width*row;
129
   
134
   
130
    outb(EGA_IO_ADDRESS    , 0xe);
135
    outb(EGA_IO_ADDRESS    , 0xe);
131
    outb(EGA_IO_ADDRESS + 1, (ega_cursor >>8) & 0xff);
136
    outb(EGA_IO_ADDRESS + 1, (ega_cursor >>8) & 0xff);
132
    outb(EGA_IO_ADDRESS    , 0xf);
137
    outb(EGA_IO_ADDRESS    , 0xf);
133
    outb(EGA_IO_ADDRESS + 1, ega_cursor & 0xff);
138
    outb(EGA_IO_ADDRESS + 1, ega_cursor & 0xff);
134
}
139
}
135
 
140
 
136
static void cursor_disable(void)
141
static void cursor_disable(void)
137
{
142
{
138
    u8 stat;
143
    u8 stat;
139
    outb(EGA_IO_ADDRESS , 0xa);
144
    outb(EGA_IO_ADDRESS , 0xa);
140
    stat=inb(EGA_IO_ADDRESS + 1);
145
    stat=inb(EGA_IO_ADDRESS + 1);
141
    outb(EGA_IO_ADDRESS , 0xa);
146
    outb(EGA_IO_ADDRESS , 0xa);
142
    outb(EGA_IO_ADDRESS +1 ,stat | (1<<5) );
147
    outb(EGA_IO_ADDRESS +1 ,stat | (1<<5) );
143
}
148
}
144
 
149
 
145
static void cursor_enable(void)
150
static void cursor_enable(void)
146
{
151
{
147
    u8 stat;
152
    u8 stat;
148
    outb(EGA_IO_ADDRESS , 0xa);
153
    outb(EGA_IO_ADDRESS , 0xa);
149
    stat=inb(EGA_IO_ADDRESS + 1);
154
    stat=inb(EGA_IO_ADDRESS + 1);
150
    outb(EGA_IO_ADDRESS , 0xa);
155
    outb(EGA_IO_ADDRESS , 0xa);
151
    outb(EGA_IO_ADDRESS +1 ,stat & (~(1<<5)) );
156
    outb(EGA_IO_ADDRESS +1 ,stat & (~(1<<5)) );
152
}
157
}
153
 
158
 
154
static void scroll(int rows)
159
static void scroll(int rows)
155
{
160
{
156
    int i;
161
    int i;
157
    if (rows > 0) {
162
    if (rows > 0) {
158
        memcpy (scr_addr,((char *)scr_addr) + rows * scr_width * 2, scr_width * scr_height * 2 - rows * scr_width * 2);
163
        memcpy (scr_addr,((char *)scr_addr) + rows * scr_width * 2, scr_width * scr_height * 2 - rows * scr_width * 2);
159
        for (i = 0; i < rows * scr_width ; i ++)
164
        for (i = 0; i < rows * scr_width ; i ++)
160
            (((short *)scr_addr) + scr_width * scr_height - rows * scr_width) [i] = ((style << 8) + ' ');
165
            (((short *)scr_addr) + scr_width * scr_height - rows * scr_width) [i] = ((style << 8) + ' ');
161
    } else if (rows < 0) {
166
    } else if (rows < 0) {
162
 
167
 
163
        memcpy (((char *)scr_addr) - rows * scr_width * 2 ,scr_addr ,scr_width * scr_height * 2 + rows * scr_width * 2);
168
        memcpy (((char *)scr_addr) - rows * scr_width * 2 ,scr_addr ,scr_width * scr_height * 2 + rows * scr_width * 2);
164
        for (i = 0; i < - rows * scr_width ; i++)
169
        for (i = 0; i < - rows * scr_width ; i++)
165
            ((short *)scr_addr) [i] = ((style << 8 ) + ' ');
170
            ((short *)scr_addr) [i] = ((style << 8 ) + ' ');
166
    }
171
    }
167
}
172
}
168
 
173
 
169
static void printchar(char c, unsigned int row, unsigned int col)
174
static void printchar(char c, unsigned int row, unsigned int col)
170
{
175
{
171
    scr_addr[(row*scr_width + col)*2] = c;
176
    scr_addr[(row*scr_width + col)*2] = c;
172
    scr_addr[(row*scr_width + col)*2+1] = style;
177
    scr_addr[(row*scr_width + col)*2+1] = style;
173
   
178
   
174
    cursor_goto(row,col+1);
179
    cursor_goto(row,col+1);
175
}
180
}
176
 
181
 
177
static void draw_text_data(keyfield_t *data)
182
static void draw_text_data(keyfield_t *data)
178
{
183
{
179
    int i;
184
    int i;
180
 
185
 
181
    for (i=0; i < scr_width*scr_height; i++) {
186
    for (i=0; i < scr_width*scr_height; i++) {
182
        scr_addr[i*2] = data[i].character;
187
        scr_addr[i*2] = data[i].character;
183
        if (data[i].style.fg_color > data[i].style.bg_color)
188
        scr_addr[i*2+1] = EGA_STYLE(data[i].style.fg_color, data[i].style.bg_color);
184
            scr_addr[i*2+1] = 0x1e;
-
 
185
        else
-
 
186
            scr_addr[i*2+1] = 0xe1;
-
 
187
    }
189
    }
188
}
190
}
189
 
191
 
190
static int save_screen(void)
192
static int save_screen(void)
191
{
193
{
192
    int i;
194
    int i;
193
    short *mem;
195
    short *mem;
194
    for (i=0 ;( i < MAX_SAVED_SCREENS ) && (saved_screens[i].data); i++);
196
    for (i=0 ;( i < MAX_SAVED_SCREENS ) && (saved_screens[i].data); i++);
195
    if (i == MAX_SAVED_SCREENS)
197
    if (i == MAX_SAVED_SCREENS)
196
        return EINVAL;
198
        return EINVAL;
197
    if (!(saved_screens[i].data=malloc( 2 * scr_width*scr_height )))
199
    if (!(saved_screens[i].data=malloc( 2 * scr_width*scr_height )))
198
        return ENOMEM;
200
        return ENOMEM;
199
    memcpy (saved_screens[i].data ,scr_addr ,2 * scr_width * scr_height)
201
    memcpy (saved_screens[i].data ,scr_addr ,2 * scr_width * scr_height)
200
        ;
202
        ;
201
    return i;
203
    return i;
202
}
204
}
203
 
205
 
204
static int print_screen(int i)
206
static int print_screen(int i)
205
{
207
{
206
    if (saved_screens[i].data)
208
    if (saved_screens[i].data)
207
            memcpy (scr_addr,saved_screens[i].data, 2 * scr_width * scr_height);
209
            memcpy (scr_addr,saved_screens[i].data, 2 * scr_width * scr_height);
208
    else return EINVAL;
210
    else return EINVAL;
209
    return i;
211
    return i;
210
}
212
}
211
 
213
 
212
 
214
 
213
static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall)
215
static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall)
214
{
216
{
215
    int retval;
217
    int retval;
216
    ipc_callid_t callid;
218
    ipc_callid_t callid;
217
    ipc_call_t call;
219
    ipc_call_t call;
218
    char c;
220
    char c;
219
    unsigned int row, col;
221
    unsigned int row, col;
220
    int bgcolor,fgcolor;
222
    int bgcolor,fgcolor;
221
    keyfield_t *interbuf = NULL;
223
    keyfield_t *interbuf = NULL;
222
    size_t intersize = 0;
224
    size_t intersize = 0;
223
    int i;
225
    int i;
224
 
226
 
225
    if (client_connected) {
227
    if (client_connected) {
226
        ipc_answer_fast(iid, ELIMIT, 0,0);
228
        ipc_answer_fast(iid, ELIMIT, 0,0);
227
        return;
229
        return;
228
    }
230
    }
229
    client_connected = 1;
231
    client_connected = 1;
230
    ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
232
    ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
231
 
233
 
232
    while (1) {
234
    while (1) {
233
        callid = async_get_call(&call);
235
        callid = async_get_call(&call);
234
        switch (IPC_GET_METHOD(call)) {
236
        switch (IPC_GET_METHOD(call)) {
235
        case IPC_M_PHONE_HUNGUP:
237
        case IPC_M_PHONE_HUNGUP:
236
            client_connected = 0;
238
            client_connected = 0;
237
            ipc_answer_fast(callid,0,0,0);
239
            ipc_answer_fast(callid,0,0,0);
238
            return; /* Exit thread */
240
            return; /* Exit thread */
239
        case IPC_M_AS_AREA_SEND:
241
        case IPC_M_AS_AREA_SEND:
240
            /* We accept one area for data interchange */
242
            /* We accept one area for data interchange */
241
            intersize = IPC_GET_ARG2(call);
243
            intersize = IPC_GET_ARG2(call);
242
            if (intersize >= scr_width*scr_height*sizeof(*interbuf)) {
244
            if (intersize >= scr_width*scr_height*sizeof(*interbuf)) {
243
                receive_comm_area(callid,&call,(void **)&interbuf);
245
                receive_comm_area(callid,&call,(void **)&interbuf);
244
                continue;
246
                continue;
245
            }
247
            }
246
            retval = EINVAL;
248
            retval = EINVAL;
247
            break;
249
            break;
248
        case FB_DRAW_TEXT_DATA:
250
        case FB_DRAW_TEXT_DATA:
249
            if (!interbuf) {
251
            if (!interbuf) {
250
                retval = EINVAL;
252
                retval = EINVAL;
251
                break;
253
                break;
252
            }
254
            }
253
            draw_text_data(interbuf);
255
            draw_text_data(interbuf);
254
            retval = 0;
256
            retval = 0;
255
            break;
257
            break;
256
        case FB_GET_CSIZE:
258
        case FB_GET_CSIZE:
257
            ipc_answer_fast(callid, 0, scr_height, scr_width);
259
            ipc_answer_fast(callid, 0, scr_height, scr_width);
258
            continue;
260
            continue;
259
        case FB_CLEAR:
261
        case FB_CLEAR:
260
            clrscr();
262
            clrscr();
261
            retval = 0;
263
            retval = 0;
262
            break;
264
            break;
263
        case FB_PUTCHAR:
265
        case FB_PUTCHAR:
264
            c = IPC_GET_ARG1(call);
266
            c = IPC_GET_ARG1(call);
265
            row = IPC_GET_ARG2(call);
267
            row = IPC_GET_ARG2(call);
266
            col = IPC_GET_ARG3(call);
268
            col = IPC_GET_ARG3(call);
267
            if (col >= scr_width || row >= scr_height) {
269
            if (col >= scr_width || row >= scr_height) {
268
                retval = EINVAL;
270
                retval = EINVAL;
269
                break;
271
                break;
270
            }
272
            }
271
            printchar(c,row,col);
273
            printchar(c,row,col);
272
            retval = 0;
274
            retval = 0;
273
            break;
275
            break;
274
        case FB_CURSOR_GOTO:
276
        case FB_CURSOR_GOTO:
275
            row = IPC_GET_ARG1(call);
277
            row = IPC_GET_ARG1(call);
276
            col = IPC_GET_ARG2(call);
278
            col = IPC_GET_ARG2(call);
277
            if (row >= scr_height || col >= scr_width) {
279
            if (row >= scr_height || col >= scr_width) {
278
                retval = EINVAL;
280
                retval = EINVAL;
279
                break;
281
                break;
280
            }
282
            }
281
            cursor_goto(row,col);
283
            cursor_goto(row,col);
282
            retval = 0;
284
            retval = 0;
283
            break;
285
            break;
284
        case FB_SCROLL:
286
        case FB_SCROLL:
285
            i = IPC_GET_ARG1(call);
287
            i = IPC_GET_ARG1(call);
286
            if (i > scr_height || i < (- (int)scr_height)) {
288
            if (i > scr_height || i < (- (int)scr_height)) {
287
                retval = EINVAL;
289
                retval = EINVAL;
288
                break;
290
                break;
289
            }
291
            }
290
            scroll(i);
292
            scroll(i);
291
            retval = 0;
293
            retval = 0;
292
            break;
294
            break;
293
        case FB_CURSOR_VISIBILITY:
295
        case FB_CURSOR_VISIBILITY:
294
            if(IPC_GET_ARG1(call))
296
            if(IPC_GET_ARG1(call))
295
                cursor_enable();
297
                cursor_enable();
296
            else
298
            else
297
                cursor_disable();
299
                cursor_disable();
298
            retval = 0;
300
            retval = 0;
299
            break;
301
            break;
300
        case FB_SET_STYLE:
302
        case FB_SET_STYLE:
301
            fgcolor = IPC_GET_ARG1(call);
303
            fgcolor = IPC_GET_ARG1(call);
302
            bgcolor = IPC_GET_ARG2(call);
304
            bgcolor = IPC_GET_ARG2(call);
303
            if (fgcolor > bgcolor)
305
            style = EGA_STYLE(fgcolor, bgcolor);
304
                style = 0x1e;
-
 
305
            else
-
 
306
                style = 0xe1;
-
 
307
            break;
306
            break;
308
        case FB_VP_DRAW_PIXMAP:
307
        case FB_VP_DRAW_PIXMAP:
309
            i = IPC_GET_ARG2(call);
308
            i = IPC_GET_ARG2(call);
310
            retval = print_screen(i);
309
            retval = print_screen(i);
311
            break;
310
            break;
312
        case FB_VP2PIXMAP:
311
        case FB_VP2PIXMAP:
313
            retval = save_screen();
312
            retval = save_screen();
314
            break;
313
            break;
315
        case FB_DROP_PIXMAP:
314
        case FB_DROP_PIXMAP:
316
            i = IPC_GET_ARG1(call);
315
            i = IPC_GET_ARG1(call);
317
            if (i >= MAX_SAVED_SCREENS) {
316
            if (i >= MAX_SAVED_SCREENS) {
318
                retval = EINVAL;
317
                retval = EINVAL;
319
                break;
318
                break;
320
            }
319
            }
321
            if (saved_screens[i].data) {
320
            if (saved_screens[i].data) {
322
                free(saved_screens[i].data);
321
                free(saved_screens[i].data);
323
                saved_screens[i].data = NULL;
322
                saved_screens[i].data = NULL;
324
            }
323
            }
325
            break;
324
            break;
326
 
325
 
327
        default:
326
        default:
328
            retval = ENOENT;
327
            retval = ENOENT;
329
        }
328
        }
330
        ipc_answer_fast(callid,retval,0,0);
329
        ipc_answer_fast(callid,retval,0,0);
331
    }
330
    }
332
}
331
}
333
 
332
 
334
int ega_init(void)
333
int ega_init(void)
335
{
334
{
336
    void *ega_ph_addr;
335
    void *ega_ph_addr;
337
    size_t sz;
336
    size_t sz;
338
 
337
 
339
 
338
 
340
    ega_ph_addr=(void *)sysinfo_value("fb.address.physical");
339
    ega_ph_addr=(void *)sysinfo_value("fb.address.physical");
341
    scr_width=sysinfo_value("fb.width");
340
    scr_width=sysinfo_value("fb.width");
342
    scr_height=sysinfo_value("fb.height");
341
    scr_height=sysinfo_value("fb.height");
343
    iospace_enable(task_get_id(),(void *)EGA_IO_ADDRESS,2);
342
    iospace_enable(task_get_id(),(void *)EGA_IO_ADDRESS,2);
344
 
343
 
345
    sz = scr_width*scr_height*2;
344
    sz = scr_width*scr_height*2;
346
    scr_addr = as_get_mappable_page(sz);
345
    scr_addr = as_get_mappable_page(sz);
347
 
346
 
348
    map_physmem(ega_ph_addr, scr_addr, ALIGN_UP(sz,PAGE_SIZE)>>PAGE_WIDTH,
347
    map_physmem(ega_ph_addr, scr_addr, ALIGN_UP(sz,PAGE_SIZE)>>PAGE_WIDTH,
349
            AS_AREA_READ | AS_AREA_WRITE);
348
            AS_AREA_READ | AS_AREA_WRITE);
350
 
349
 
351
    async_set_client_connection(ega_client_connection);
350
    async_set_client_connection(ega_client_connection);
352
 
351
 
353
    return 0;
352
    return 0;
354
}
353
}
355
 
354
 
356
 
355