Subversion Repositories HelenOS-historic

Rev

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

Rev 1501 Rev 1505
1
/*
1
/*
2
 * Copyright (C) 2006 Jakub Vana
2
 * Copyright (C) 2006 Jakub Vana
3
 * Copyright (C) 2006 Ondrej Palkovsky
3
 * Copyright (C) 2006 Ondrej Palkovsky
4
 * All rights reserved.
4
 * All rights reserved.
5
 *
5
 *
6
 * Redistribution and use in source and binary forms, with or without
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
7
 * modification, are permitted provided that the following conditions
8
 * are met:
8
 * are met:
9
 *
9
 *
10
 * - Redistributions of source code must retain the above copyright
10
 * - Redistributions of source code must retain the above copyright
11
 *   notice, this list of conditions and the following disclaimer.
11
 *   notice, this list of conditions and the following disclaimer.
12
 * - Redistributions in binary form must reproduce the above copyright
12
 * - Redistributions in binary form must reproduce the above copyright
13
 *   notice, this list of conditions and the following disclaimer in the
13
 *   notice, this list of conditions and the following disclaimer in the
14
 *   documentation and/or other materials provided with the distribution.
14
 *   documentation and/or other materials provided with the distribution.
15
 * - The name of the author may not be used to endorse or promote products
15
 * - The name of the author may not be used to endorse or promote products
16
 *   derived from this software without specific prior written permission.
16
 *   derived from this software without specific prior written permission.
17
 *
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
28
 */
29
 
29
 
30
#include <stdlib.h>
30
#include <stdlib.h>
31
#include <unistd.h>
31
#include <unistd.h>
32
#include <string.h>
32
#include <string.h>
33
#include <ddi.h>
33
#include <ddi.h>
34
#include <sysinfo.h>
34
#include <sysinfo.h>
35
#include <align.h>
35
#include <align.h>
36
#include <as.h>
36
#include <as.h>
37
#include <ipc/fb.h>
37
#include <ipc/fb.h>
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
#include <kernel/errno.h>
41
#include <kernel/errno.h>
42
#include <async.h>
42
#include <async.h>
-
 
43
 
43
#include "font-8x16.h"
44
#include "font-8x16.h"
44
#include "helenos.xbm"
45
#include "helenos.xbm"
45
#include "fb.h"
46
#include "fb.h"
-
 
47
#include "main.h"
-
 
48
#include "../console/screenbuffer.h"
46
 
49
 
47
#define DEFAULT_BGCOLOR                0x000080
50
#define DEFAULT_BGCOLOR                0x000080
48
#define DEFAULT_FGCOLOR                0xffff00
51
#define DEFAULT_FGCOLOR                0xffff00
49
 
52
 
50
/***************************************************************/
53
/***************************************************************/
51
/* Pixel specific fuctions */
54
/* Pixel specific fuctions */
52
 
55
 
53
typedef void (*putpixel_fn_t)(unsigned int x, unsigned int y, int color);
56
typedef void (*putpixel_fn_t)(unsigned int x, unsigned int y, int color);
54
typedef int (*getpixel_fn_t)(unsigned int x, unsigned int y);
57
typedef int (*getpixel_fn_t)(unsigned int x, unsigned int y);
55
 
58
 
56
struct {
59
struct {
57
    __u8 *fbaddress ;
60
    __u8 *fbaddress ;
58
 
61
 
59
    unsigned int xres ;
62
    unsigned int xres ;
60
    unsigned int yres ;
63
    unsigned int yres ;
61
    unsigned int scanline ;
64
    unsigned int scanline ;
62
    unsigned int pixelbytes ;
65
    unsigned int pixelbytes ;
63
 
66
 
64
    putpixel_fn_t putpixel;
67
    putpixel_fn_t putpixel;
65
    getpixel_fn_t getpixel;
68
    getpixel_fn_t getpixel;
66
} screen;
69
} screen;
67
 
70
 
68
typedef struct {
71
typedef struct {
69
    int initialized;
72
    int initialized;
70
    unsigned int x, y;
73
    unsigned int x, y;
71
    unsigned int width, height;
74
    unsigned int width, height;
72
 
75
 
73
    /* Text support in window */
76
    /* Text support in window */
74
    unsigned int rows, cols;
77
    unsigned int rows, cols;
75
    /* Style for text printing */
78
    /* Style for text printing */
76
    int bgcolor, fgcolor;
79
    int bgcolor, fgcolor;
77
    /* Auto-cursor position */
80
    /* Auto-cursor position */
78
    int cursor_active, cur_col, cur_row;
81
    int cursor_active, cur_col, cur_row;
79
    int cursor_shown;
82
    int cursor_shown;
80
} viewport_t;
83
} viewport_t;
81
 
84
 
82
#define MAX_VIEWPORTS 128
85
#define MAX_VIEWPORTS 128
83
static viewport_t viewports[128];
86
static viewport_t viewports[128];
84
 
87
 
85
/* Allow only 1 connection */
88
/* Allow only 1 connection */
86
static int client_connected = 0;
89
static int client_connected = 0;
87
 
90
 
88
#define RED(x, bits)    ((x >> (16 + 8 - bits)) & ((1 << bits) - 1))
91
#define RED(x, bits)    ((x >> (16 + 8 - bits)) & ((1 << bits) - 1))
89
#define GREEN(x, bits)  ((x >> (8 + 8 - bits)) & ((1 << bits) - 1))
92
#define GREEN(x, bits)  ((x >> (8 + 8 - bits)) & ((1 << bits) - 1))
90
#define BLUE(x, bits)   ((x >> (8 - bits)) & ((1 << bits) - 1))
93
#define BLUE(x, bits)   ((x >> (8 - bits)) & ((1 << bits) - 1))
91
 
94
 
92
#define COL_WIDTH   8
95
#define COL_WIDTH   8
93
#define ROW_BYTES   (screen.scanline * FONT_SCANLINES)
96
#define ROW_BYTES   (screen.scanline * FONT_SCANLINES)
94
 
97
 
95
#define POINTPOS(x, y)  ((y) * screen.scanline + (x) * screen.pixelbytes)
98
#define POINTPOS(x, y)  ((y) * screen.scanline + (x) * screen.pixelbytes)
96
 
99
 
97
/** Put pixel - 24-bit depth, 1 free byte */
100
/** Put pixel - 24-bit depth, 1 free byte */
98
static void putpixel_4byte(unsigned int x, unsigned int y, int color)
101
static void putpixel_4byte(unsigned int x, unsigned int y, int color)
99
{
102
{
100
    *((__u32 *)(screen.fbaddress + POINTPOS(x, y))) = color;
103
    *((__u32 *)(screen.fbaddress + POINTPOS(x, y))) = color;
101
}
104
}
102
 
105
 
103
/** Return pixel color - 24-bit depth, 1 free byte */
106
/** Return pixel color - 24-bit depth, 1 free byte */
104
static int getpixel_4byte(unsigned int x, unsigned int y)
107
static int getpixel_4byte(unsigned int x, unsigned int y)
105
{
108
{
106
    return *((__u32 *)(screen.fbaddress + POINTPOS(x, y))) & 0xffffff;
109
    return *((__u32 *)(screen.fbaddress + POINTPOS(x, y))) & 0xffffff;
107
}
110
}
108
 
111
 
109
/** Put pixel - 24-bit depth */
112
/** Put pixel - 24-bit depth */
110
static void putpixel_3byte(unsigned int x, unsigned int y, int color)
113
static void putpixel_3byte(unsigned int x, unsigned int y, int color)
111
{
114
{
112
    unsigned int startbyte = POINTPOS(x, y);
115
    unsigned int startbyte = POINTPOS(x, y);
113
 
116
 
114
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN))
117
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN))
115
    screen.fbaddress[startbyte] = RED(color, 8);
118
    screen.fbaddress[startbyte] = RED(color, 8);
116
    screen.fbaddress[startbyte + 1] = GREEN(color, 8);
119
    screen.fbaddress[startbyte + 1] = GREEN(color, 8);
117
    screen.fbaddress[startbyte + 2] = BLUE(color, 8);
120
    screen.fbaddress[startbyte + 2] = BLUE(color, 8);
118
#else
121
#else
119
    screen.fbaddress[startbyte + 2] = RED(color, 8);
122
    screen.fbaddress[startbyte + 2] = RED(color, 8);
120
    screen.fbaddress[startbyte + 1] = GREEN(color, 8);
123
    screen.fbaddress[startbyte + 1] = GREEN(color, 8);
121
    screen.fbaddress[startbyte + 0] = BLUE(color, 8);
124
    screen.fbaddress[startbyte + 0] = BLUE(color, 8);
122
#endif
125
#endif
123
 
126
 
124
}
127
}
125
 
128
 
126
/** Return pixel color - 24-bit depth */
129
/** Return pixel color - 24-bit depth */
127
static int getpixel_3byte(unsigned int x, unsigned int y)
130
static int getpixel_3byte(unsigned int x, unsigned int y)
128
{
131
{
129
    unsigned int startbyte = POINTPOS(x, y);
132
    unsigned int startbyte = POINTPOS(x, y);
130
 
133
 
131
 
134
 
132
 
135
 
133
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN))
136
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN))
134
    return screen.fbaddress[startbyte] << 16 | screen.fbaddress[startbyte + 1] << 8 | screen.fbaddress[startbyte + 2];
137
    return screen.fbaddress[startbyte] << 16 | screen.fbaddress[startbyte + 1] << 8 | screen.fbaddress[startbyte + 2];
135
#else
138
#else
136
    return screen.fbaddress[startbyte + 2] << 16 | screen.fbaddress[startbyte + 1] << 8 | screen.fbaddress[startbyte + 0];
139
    return screen.fbaddress[startbyte + 2] << 16 | screen.fbaddress[startbyte + 1] << 8 | screen.fbaddress[startbyte + 0];
137
#endif
140
#endif
138
                               
141
                               
139
 
142
 
140
}
143
}
141
 
144
 
142
/** Put pixel - 16-bit depth (5:6:5) */
145
/** Put pixel - 16-bit depth (5:6:5) */
143
static void putpixel_2byte(unsigned int x, unsigned int y, int color)
146
static void putpixel_2byte(unsigned int x, unsigned int y, int color)
144
{
147
{
145
    /* 5-bit, 6-bits, 5-bits */
148
    /* 5-bit, 6-bits, 5-bits */
146
    *((__u16 *)(screen.fbaddress + POINTPOS(x, y))) = RED(color, 5) << 11 | GREEN(color, 6) << 5 | BLUE(color, 5);
149
    *((__u16 *)(screen.fbaddress + POINTPOS(x, y))) = RED(color, 5) << 11 | GREEN(color, 6) << 5 | BLUE(color, 5);
147
}
150
}
148
 
151
 
149
/** Return pixel color - 16-bit depth (5:6:5) */
152
/** Return pixel color - 16-bit depth (5:6:5) */
150
static int getpixel_2byte(unsigned int x, unsigned int y)
153
static int getpixel_2byte(unsigned int x, unsigned int y)
151
{
154
{
152
    int color = *((__u16 *)(screen.fbaddress + POINTPOS(x, y)));
155
    int color = *((__u16 *)(screen.fbaddress + POINTPOS(x, y)));
153
    return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
156
    return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
154
}
157
}
155
 
158
 
156
/** Put pixel - 8-bit depth (3:2:3) */
159
/** Put pixel - 8-bit depth (3:2:3) */
157
static void putpixel_1byte(unsigned int x, unsigned int y, int color)
160
static void putpixel_1byte(unsigned int x, unsigned int y, int color)
158
{
161
{
159
    screen.fbaddress[POINTPOS(x, y)] = RED(color, 3) << 5 | GREEN(color, 2) << 3 | BLUE(color, 3);
162
    screen.fbaddress[POINTPOS(x, y)] = RED(color, 3) << 5 | GREEN(color, 2) << 3 | BLUE(color, 3);
160
}
163
}
161
 
164
 
162
/** Return pixel color - 8-bit depth (3:2:3) */
165
/** Return pixel color - 8-bit depth (3:2:3) */
163
static int getpixel_1byte(unsigned int x, unsigned int y)
166
static int getpixel_1byte(unsigned int x, unsigned int y)
164
{
167
{
165
    int color = screen.fbaddress[POINTPOS(x, y)];
168
    int color = screen.fbaddress[POINTPOS(x, y)];
166
    return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
169
    return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
167
}
170
}
168
 
171
 
169
/** Put pixel into viewport
172
/** Put pixel into viewport
170
 *
173
 *
171
 * @param vp Viewport identification
174
 * @param vp Viewport identification
172
 * @param x X coord relative to viewport
175
 * @param x X coord relative to viewport
173
 * @param y Y coord relative to viewport
176
 * @param y Y coord relative to viewport
174
 * @param color RGB color
177
 * @param color RGB color
175
 */
178
 */
176
static void putpixel(int vp, unsigned int x, unsigned int y, int color)
179
static void putpixel(int vp, unsigned int x, unsigned int y, int color)
177
{
180
{
178
    screen.putpixel(viewports[vp].x + x, viewports[vp].y + y, color);
181
    screen.putpixel(viewports[vp].x + x, viewports[vp].y + y, color);
179
}
182
}
180
/** Get pixel from viewport */
183
/** Get pixel from viewport */
181
static int getpixel(int vp, unsigned int x, unsigned int y)
184
static int getpixel(int vp, unsigned int x, unsigned int y)
182
{
185
{
183
    return screen.getpixel(viewports[vp].x + x, viewports[vp].y + y);
186
    return screen.getpixel(viewports[vp].x + x, viewports[vp].y + y);
184
}
187
}
185
 
188
 
186
/** Fill line with color BGCOLOR */
189
/** Fill line with color BGCOLOR */
187
static void clear_line(int vp, unsigned int y)
190
static void clear_line(int vp, unsigned int y)
188
{
191
{
189
    unsigned int x;
192
    unsigned int x;
190
    for (x = 0; x < viewports[vp].width; x++)
193
    for (x = 0; x < viewports[vp].width; x++)
191
        putpixel(vp, x, y, viewports[vp].bgcolor);
194
        putpixel(vp, x, y, viewports[vp].bgcolor);
192
}
195
}
193
 
196
 
194
/** Fill viewport with background color */
197
/** Fill viewport with background color */
195
static void clear_port(int vp)
198
static void clear_port(int vp)
196
{
199
{
197
    unsigned int y;
200
    unsigned int y;
198
 
201
 
199
    clear_line(vp, 0);
202
    clear_line(vp, 0);
200
    for (y = viewports[vp].y+1; y < viewports[vp].y+viewports[vp].height; y++) {
203
    for (y = viewports[vp].y+1; y < viewports[vp].y+viewports[vp].height; y++) {
201
        memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)],
204
        memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)],
202
               &screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y)],
205
               &screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y)],
203
               screen.pixelbytes * viewports[vp].width);
206
               screen.pixelbytes * viewports[vp].width);
204
    }  
207
    }  
205
}
208
}
206
 
209
 
207
/** Scroll port up/down
210
/** Scroll port up/down
208
 *
211
 *
209
 * @param vp Viewport to scroll
212
 * @param vp Viewport to scroll
210
 * @param rows Positive number - scroll up, negative - scroll down
213
 * @param rows Positive number - scroll up, negative - scroll down
211
 */
214
 */
212
static void scroll_port(int vp, int rows)
215
static void scroll_port(int vp, int rows)
213
{
216
{
214
    int y;
217
    int y;
215
    int startline;
218
    int startline;
216
    int endline;
219
    int endline;
217
   
220
   
218
    if (rows > 0) {
221
    if (rows > 0) {
219
        for (y=viewports[vp].y; y < viewports[vp].y+viewports[vp].height - rows*FONT_SCANLINES; y++)
222
        for (y=viewports[vp].y; y < viewports[vp].y+viewports[vp].height - rows*FONT_SCANLINES; y++)
220
            memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)],
223
            memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)],
221
                   &screen.fbaddress[POINTPOS(viewports[vp].x,y + rows*FONT_SCANLINES)],
224
                   &screen.fbaddress[POINTPOS(viewports[vp].x,y + rows*FONT_SCANLINES)],
222
                   screen.pixelbytes * viewports[vp].width);
225
                   screen.pixelbytes * viewports[vp].width);
223
        /* Clear last row */
226
        /* Clear last row */
224
        startline = viewports[vp].y+FONT_SCANLINES*(viewports[vp].rows-1);
227
        startline = viewports[vp].y+FONT_SCANLINES*(viewports[vp].rows-1);
225
        endline = viewports[vp].y + viewports[vp].height;
228
        endline = viewports[vp].y + viewports[vp].height;
226
        clear_line(vp, startline);
229
        clear_line(vp, startline);
227
        for (y=startline+1;y < endline; y++)
230
        for (y=startline+1;y < endline; y++)
228
            memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)],
231
            memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)],
229
                   &screen.fbaddress[POINTPOS(viewports[vp].x,startline)],
232
                   &screen.fbaddress[POINTPOS(viewports[vp].x,startline)],
230
                   screen.pixelbytes * viewports[vp].width);
233
                   screen.pixelbytes * viewports[vp].width);
231
                 
234
                 
232
    } else if (rows < 0) {
235
    } else if (rows < 0) {
233
        rows = -rows;
236
        rows = -rows;
234
        for (y=viewports[vp].y + viewports[vp].height-1; y >= viewports[vp].y + rows*FONT_SCANLINES; y--)
237
        for (y=viewports[vp].y + viewports[vp].height-1; y >= viewports[vp].y + rows*FONT_SCANLINES; y--)
235
            memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)],
238
            memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)],
236
                &screen.fbaddress[POINTPOS(viewports[vp].x,y - rows*FONT_SCANLINES)],
239
                &screen.fbaddress[POINTPOS(viewports[vp].x,y - rows*FONT_SCANLINES)],
237
                screen.pixelbytes * viewports[vp].width);
240
                screen.pixelbytes * viewports[vp].width);
238
        /* Clear first row */
241
        /* Clear first row */
239
        clear_line(0, viewports[vp].bgcolor);
242
        clear_line(0, viewports[vp].bgcolor);
240
        for (y=1;y < rows*FONT_SCANLINES; y++)
243
        for (y=1;y < rows*FONT_SCANLINES; y++)
241
            memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y+y)],
244
            memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y+y)],
242
                   &screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y)],
245
                   &screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y)],
243
                   screen.pixelbytes * viewports[vp].width);
246
                   screen.pixelbytes * viewports[vp].width);
244
    }
247
    }
245
}
248
}
246
 
249
 
247
static void invert_pixel(int vp,unsigned int x, unsigned int y)
250
static void invert_pixel(int vp,unsigned int x, unsigned int y)
248
{
251
{
249
    putpixel(vp, x, y, ~getpixel(vp, x, y));
252
    putpixel(vp, x, y, ~getpixel(vp, x, y));
250
}
253
}
251
 
254
 
252
 
255
 
253
/** Draw one line of glyph at a given position */
256
/** Draw one line of glyph at a given position */
254
static void draw_glyph_line(int vp,unsigned int glline, unsigned int x, unsigned int y)
257
static void draw_glyph_line(int vp,unsigned int glline, unsigned int x, unsigned int y)
255
{
258
{
256
    unsigned int i;
259
    unsigned int i;
257
 
260
 
258
    for (i = 0; i < 8; i++)
261
    for (i = 0; i < 8; i++)
259
        if (glline & (1 << (7 - i))) {
262
        if (glline & (1 << (7 - i))) {
260
            putpixel(vp, x + i, y, viewports[vp].fgcolor);
263
            putpixel(vp, x + i, y, viewports[vp].fgcolor);
261
        } else
264
        } else
262
            putpixel(vp, x + i, y, viewports[vp].bgcolor);
265
            putpixel(vp, x + i, y, viewports[vp].bgcolor);
263
}
266
}
264
 
267
 
265
/***************************************************************/
268
/***************************************************************/
266
/* Character-console functions */
269
/* Character-console functions */
267
 
270
 
268
/** Draw character at given position */
271
/** Draw character at given position */
269
static void draw_glyph(int vp,__u8 glyph, unsigned int sx, unsigned int sy)
272
static void draw_glyph(int vp,__u8 glyph, unsigned int sx, unsigned int sy)
270
{
273
{
271
    unsigned int y;
274
    unsigned int y;
272
 
275
 
273
    for (y = 0; y < FONT_SCANLINES; y++)
276
    for (y = 0; y < FONT_SCANLINES; y++)
274
        draw_glyph_line(vp ,fb_font[glyph * FONT_SCANLINES + y], sx, sy + y);
277
        draw_glyph_line(vp ,fb_font[glyph * FONT_SCANLINES + y], sx, sy + y);
275
}
278
}
276
 
279
 
277
/** Invert character at given position */
280
/** Invert character at given position */
278
static void invert_char(int vp,unsigned int row, unsigned int col)
281
static void invert_char(int vp,unsigned int row, unsigned int col)
279
{
282
{
280
    unsigned int x;
283
    unsigned int x;
281
    unsigned int y;
284
    unsigned int y;
282
 
285
 
283
    for (x = 0; x < COL_WIDTH; x++)
286
    for (x = 0; x < COL_WIDTH; x++)
284
        for (y = 0; y < FONT_SCANLINES; y++)
287
        for (y = 0; y < FONT_SCANLINES; y++)
285
            invert_pixel(vp, col * COL_WIDTH + x, row * FONT_SCANLINES + y);
288
            invert_pixel(vp, col * COL_WIDTH + x, row * FONT_SCANLINES + y);
286
}
289
}
287
 
290
 
288
static void draw_logo(int vp,unsigned int startx, unsigned int starty)
291
static void draw_logo(int vp,unsigned int startx, unsigned int starty)
289
{
292
{
290
    unsigned int x;
293
    unsigned int x;
291
    unsigned int y;
294
    unsigned int y;
292
    unsigned int byte;
295
    unsigned int byte;
293
    unsigned int rowbytes;
296
    unsigned int rowbytes;
294
 
297
 
295
    rowbytes = (helenos_width - 1) / 8 + 1;
298
    rowbytes = (helenos_width - 1) / 8 + 1;
296
 
299
 
297
    for (y = 0; y < helenos_height; y++)
300
    for (y = 0; y < helenos_height; y++)
298
        for (x = 0; x < helenos_width; x++) {
301
        for (x = 0; x < helenos_width; x++) {
299
            byte = helenos_bits[rowbytes * y + x / 8];
302
            byte = helenos_bits[rowbytes * y + x / 8];
300
            byte >>= x % 8;
303
            byte >>= x % 8;
301
            if (byte & 1)
304
            if (byte & 1)
302
                putpixel(vp ,startx + x, starty + y, viewports[vp].fgcolor);
305
                putpixel(vp ,startx + x, starty + y, viewports[vp].fgcolor);
303
        }
306
        }
304
}
307
}
305
 
308
 
306
/***************************************************************/
309
/***************************************************************/
307
/* Stdout specific functions */
310
/* Stdout specific functions */
308
 
311
 
309
 
312
 
310
/** Create new viewport
313
/** Create new viewport
311
 *
314
 *
312
 * @return New viewport number
315
 * @return New viewport number
313
 */
316
 */
314
static int viewport_create(unsigned int x, unsigned int y,unsigned int width,
317
static int viewport_create(unsigned int x, unsigned int y,unsigned int width,
315
               unsigned int height)
318
               unsigned int height)
316
{
319
{
317
    int i;
320
    int i;
318
 
321
 
319
for (i=0; i < MAX_VIEWPORTS; i++) {
322
for (i=0; i < MAX_VIEWPORTS; i++) {
320
        if (!viewports[i].initialized)
323
        if (!viewports[i].initialized)
321
            break;
324
            break;
322
    }
325
    }
323
    if (i == MAX_VIEWPORTS)
326
    if (i == MAX_VIEWPORTS)
324
        return ELIMIT;
327
        return ELIMIT;
325
 
328
 
326
    if (width ==0 || height == 0 ||
329
    if (width ==0 || height == 0 ||
327
        x+width > screen.xres || y+height > screen.yres)
330
        x+width > screen.xres || y+height > screen.yres)
328
        return EINVAL;
331
        return EINVAL;
329
    if (width < FONT_SCANLINES || height < COL_WIDTH)
332
    if (width < FONT_SCANLINES || height < COL_WIDTH)
330
        return EINVAL;
333
        return EINVAL;
331
 
334
 
332
    viewports[i].x = x;
335
    viewports[i].x = x;
333
    viewports[i].y = y;
336
    viewports[i].y = y;
334
    viewports[i].width = width;
337
    viewports[i].width = width;
335
    viewports[i].height = height;
338
    viewports[i].height = height;
336
   
339
   
337
    viewports[i].rows = height / FONT_SCANLINES;
340
    viewports[i].rows = height / FONT_SCANLINES;
338
    viewports[i].cols = width / COL_WIDTH;
341
    viewports[i].cols = width / COL_WIDTH;
339
 
342
 
340
    viewports[i].bgcolor = DEFAULT_BGCOLOR;
343
    viewports[i].bgcolor = DEFAULT_BGCOLOR;
341
    viewports[i].fgcolor = DEFAULT_FGCOLOR;
344
    viewports[i].fgcolor = DEFAULT_FGCOLOR;
342
   
345
   
343
    viewports[i].cur_col = 0;
346
    viewports[i].cur_col = 0;
344
    viewports[i].cur_row = 0;
347
    viewports[i].cur_row = 0;
345
    viewports[i].cursor_active = 0;
348
    viewports[i].cursor_active = 0;
346
 
349
 
347
    viewports[i].initialized = 1;
350
    viewports[i].initialized = 1;
348
 
351
 
349
    return i;
352
    return i;
350
}
353
}
351
 
354
 
352
 
355
 
353
/** Initialize framebuffer as a chardev output device
356
/** Initialize framebuffer as a chardev output device
354
 *
357
 *
355
 * @param addr Address of theframebuffer
358
 * @param addr Address of theframebuffer
356
 * @param x    Screen width in pixels
359
 * @param x    Screen width in pixels
357
 * @param y    Screen height in pixels
360
 * @param y    Screen height in pixels
358
 * @param bpp  Bits per pixel (8, 16, 24, 32)
361
 * @param bpp  Bits per pixel (8, 16, 24, 32)
359
 * @param scan Bytes per one scanline
362
 * @param scan Bytes per one scanline
360
 *
363
 *
361
 */
364
 */
362
static void screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan)
365
static void screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan)
363
{
366
{
364
    switch (bpp) {
367
    switch (bpp) {
365
        case 8:
368
        case 8:
366
            screen.putpixel = putpixel_1byte;
369
            screen.putpixel = putpixel_1byte;
367
            screen.getpixel = getpixel_1byte;
370
            screen.getpixel = getpixel_1byte;
368
            screen.pixelbytes = 1;
371
            screen.pixelbytes = 1;
369
            break;
372
            break;
370
        case 16:
373
        case 16:
371
            screen.putpixel = putpixel_2byte;
374
            screen.putpixel = putpixel_2byte;
372
            screen.getpixel = getpixel_2byte;
375
            screen.getpixel = getpixel_2byte;
373
            screen.pixelbytes = 2;
376
            screen.pixelbytes = 2;
374
            break;
377
            break;
375
        case 24:
378
        case 24:
376
            screen.putpixel = putpixel_3byte;
379
            screen.putpixel = putpixel_3byte;
377
            screen.getpixel = getpixel_3byte;
380
            screen.getpixel = getpixel_3byte;
378
            screen.pixelbytes = 3;
381
            screen.pixelbytes = 3;
379
            break;
382
            break;
380
        case 32:
383
        case 32:
381
            screen.putpixel = putpixel_4byte;
384
            screen.putpixel = putpixel_4byte;
382
            screen.getpixel = getpixel_4byte;
385
            screen.getpixel = getpixel_4byte;
383
            screen.pixelbytes = 4;
386
            screen.pixelbytes = 4;
384
            break;
387
            break;
385
    }
388
    }
386
 
389
 
387
       
390
       
388
    screen.fbaddress = (unsigned char *) addr;
391
    screen.fbaddress = (unsigned char *) addr;
389
    screen.xres = xres;
392
    screen.xres = xres;
390
    screen.yres = yres;
393
    screen.yres = yres;
391
    screen.scanline = scan;
394
    screen.scanline = scan;
392
   
395
   
393
    /* Create first viewport */
396
    /* Create first viewport */
394
    viewport_create(0,0,xres,yres);
397
    viewport_create(0,0,xres,yres);
395
 
398
 
396
    clear_port(0);
399
    clear_port(0);
397
}
400
}
398
 
401
 
399
static void cursor_hide(int vp)
402
static void cursor_hide(int vp)
400
{
403
{
401
    viewport_t *vport = &viewports[vp];
404
    viewport_t *vport = &viewports[vp];
402
 
405
 
403
    if (vport->cursor_active && vport->cursor_shown) {
406
    if (vport->cursor_active && vport->cursor_shown) {
404
        invert_char(vp, vport->cur_row, vport->cur_col);
407
        invert_char(vp, vport->cur_row, vport->cur_col);
405
        vport->cursor_shown = 0;
408
        vport->cursor_shown = 0;
406
    }
409
    }
407
}
410
}
408
 
411
 
409
static void cursor_print(int vp)
412
static void cursor_print(int vp)
410
{
413
{
411
    viewport_t *vport = &viewports[vp];
414
    viewport_t *vport = &viewports[vp];
412
 
415
 
413
    /* Do not check for cursor_shown */
416
    /* Do not check for cursor_shown */
414
    if (vport->cursor_active) {
417
    if (vport->cursor_active) {
415
        invert_char(vp, vport->cur_row, vport->cur_col);
418
        invert_char(vp, vport->cur_row, vport->cur_col);
416
        vport->cursor_shown = 1;
419
        vport->cursor_shown = 1;
417
    }
420
    }
418
}
421
}
419
 
422
 
420
static void cursor_blink(int vp)
423
static void cursor_blink(int vp)
421
{
424
{
422
    viewport_t *vport = &viewports[vp];
425
    viewport_t *vport = &viewports[vp];
423
 
426
 
424
    if (vport->cursor_shown)
427
    if (vport->cursor_shown)
425
        cursor_hide(vp);
428
        cursor_hide(vp);
426
    else
429
    else
427
        cursor_print(vp);
430
        cursor_print(vp);
428
}
431
}
429
 
432
 
430
/** Draw character at given position relative to viewport
433
/** Draw character at given position relative to viewport
431
 *
434
 *
432
 * @param vp Viewport identification
435
 * @param vp Viewport identification
433
 * @param c Character to print
436
 * @param c Character to print
434
 * @param row Screen position relative to viewport
437
 * @param row Screen position relative to viewport
435
 * @param col Screen position relative to viewport
438
 * @param col Screen position relative to viewport
436
 */
439
 */
437
static void draw_char(int vp, char c, unsigned int row, unsigned int col)
440
static void draw_char(int vp, char c, unsigned int row, unsigned int col)
438
{
441
{
439
    viewport_t *vport = &viewports[vp];
442
    viewport_t *vport = &viewports[vp];
440
 
443
 
441
    /* Optimize - do not hide cursor if we are going to overwrite it */
444
    /* Optimize - do not hide cursor if we are going to overwrite it */
442
    if (vport->cursor_active && vport->cursor_shown &&
445
    if (vport->cursor_active && vport->cursor_shown &&
443
        (vport->cur_col != col || vport->cur_row != row))
446
        (vport->cur_col != col || vport->cur_row != row))
444
        invert_char(vp, vport->cur_row, vport->cur_col);
447
        invert_char(vp, vport->cur_row, vport->cur_col);
445
   
448
   
446
    draw_glyph(vp, c, col * COL_WIDTH, row * FONT_SCANLINES);
449
    draw_glyph(vp, c, col * COL_WIDTH, row * FONT_SCANLINES);
447
 
450
 
448
    vport->cur_col = col;
451
    vport->cur_col = col;
449
    vport->cur_row = row;
452
    vport->cur_row = row;
450
 
453
 
451
    vport->cur_col++;
454
    vport->cur_col++;
452
    if (vport->cur_col>= vport->cols) {
455
    if (vport->cur_col>= vport->cols) {
453
        vport->cur_col = 0;
456
        vport->cur_col = 0;
454
        vport->cur_row++;
457
        vport->cur_row++;
455
        if (vport->cur_row >= vport->rows)
458
        if (vport->cur_row >= vport->rows)
456
            vport->cur_row--;
459
            vport->cur_row--;
457
    }
460
    }
458
    cursor_print(vp);
461
    cursor_print(vp);
459
}
462
}
460
 
463
 
-
 
464
static void draw_text_data(int vp, keyfield_t *data)
-
 
465
{
-
 
466
    viewport_t *vport = &viewports[vp];
-
 
467
    int i;
-
 
468
    char c;
-
 
469
 
-
 
470
    clear_port(vp);
-
 
471
    for (i=0; i < vport->cols * vport->rows; i++) {
-
 
472
        if (data[i].character == ' ') /* TODO: && data[i].style==vport->style */
-
 
473
            continue;
-
 
474
        draw_char(vp, data[i].character, i/vport->rows, i % vport->cols);
-
 
475
    }
-
 
476
    cursor_print(vp);
-
 
477
}
-
 
478
 
-
 
479
 
461
/** Function for handling connections to FB
480
/** Function for handling connections to FB
462
 *
481
 *
463
 */
482
 */
464
static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall)
483
static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall)
465
{
484
{
466
    ipc_callid_t callid;
485
    ipc_callid_t callid;
467
    ipc_call_t call;
486
    ipc_call_t call;
468
    int retval;
487
    int retval;
469
    int i;
488
    int i;
470
    unsigned int row,col;
489
    unsigned int row,col;
471
    char c;
490
    char c;
-
 
491
    keyfield_t *interbuffer = NULL;
-
 
492
    size_t intersize = 0;
472
 
493
 
473
    int vp = 0;
494
    int vp = 0;
474
    viewport_t *vport = &viewports[0];
495
    viewport_t *vport = &viewports[0];
475
 
496
 
476
    if (client_connected) {
497
    if (client_connected) {
477
        ipc_answer_fast(iid, ELIMIT, 0,0);
498
        ipc_answer_fast(iid, ELIMIT, 0,0);
478
        return;
499
        return;
479
    }
500
    }
480
    client_connected = 1;
501
    client_connected = 1;
481
    ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
502
    ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
482
 
503
 
483
    while (1) {
504
    while (1) {
484
        callid = async_get_call_timeout(&call,250000);
505
        callid = async_get_call_timeout(&call,250000);
485
        if (!callid) {
506
        if (!callid) {
486
            cursor_blink(vp);
507
            cursor_blink(vp);
487
            continue;
508
            continue;
488
        }
509
        }
489
        switch (IPC_GET_METHOD(call)) {
510
        switch (IPC_GET_METHOD(call)) {
490
        case IPC_M_PHONE_HUNGUP:
511
        case IPC_M_PHONE_HUNGUP:
491
            client_connected = 0;
512
            client_connected = 0;
492
            /* cleanup other viewports */
513
            /* cleanup other viewports */
493
            for (i=1; i < MAX_VIEWPORTS; i++)
514
            for (i=1; i < MAX_VIEWPORTS; i++)
494
                vport->initialized = 0;
515
                vport->initialized = 0;
495
            ipc_answer_fast(callid,0,0,0);
516
            ipc_answer_fast(callid,0,0,0);
496
            return; /* Exit thread */
517
            return; /* Exit thread */
-
 
518
        case IPC_M_AS_AREA_SEND:
-
 
519
            /* We accept one area for data interchange */
-
 
520
            intersize = IPC_GET_ARG2(call);
-
 
521
            receive_comm_area(callid,&call,(void **)&interbuffer,
-
 
522
                      sizeof(*interbuffer)*viewports[0].cols*viewports[0].rows);
-
 
523
            continue;
-
 
524
 
-
 
525
        case FB_DRAW_TEXT_DATA:
-
 
526
            if (!interbuffer) {
-
 
527
                retval = EINVAL;
-
 
528
                break;
-
 
529
            }
-
 
530
            if (intersize < vport->cols*vport->rows*sizeof(*interbuffer)) {
-
 
531
                retval = EINVAL;
-
 
532
                break;
-
 
533
            }
-
 
534
            draw_text_data(vp, interbuffer);
-
 
535
            retval = 0;
-
 
536
            break;
497
        case FB_PUTCHAR:
537
        case FB_PUTCHAR:
498
            c = IPC_GET_ARG1(call);
538
            c = IPC_GET_ARG1(call);
499
            row = IPC_GET_ARG2(call);
539
            row = IPC_GET_ARG2(call);
500
            col = IPC_GET_ARG3(call);
540
            col = IPC_GET_ARG3(call);
501
            if (row >= vport->rows || col >= vport->cols) {
541
            if (row >= vport->rows || col >= vport->cols) {
502
                retval = EINVAL;
542
                retval = EINVAL;
503
                break;
543
                break;
504
            }
544
            }
505
            ipc_answer_fast(callid,0,0,0);
545
            ipc_answer_fast(callid,0,0,0);
506
 
546
 
507
            draw_char(vp, c, row, col);
547
            draw_char(vp, c, row, col);
508
            continue; /* msg already answered */
548
            continue; /* msg already answered */
509
        case FB_CLEAR:
549
        case FB_CLEAR:
510
            clear_port(vp);
550
            clear_port(vp);
511
            cursor_print(vp);
551
            cursor_print(vp);
512
            retval = 0;
552
            retval = 0;
513
            break;
553
            break;
514
        case FB_CURSOR_GOTO:
554
        case FB_CURSOR_GOTO:
515
            row = IPC_GET_ARG1(call);
555
            row = IPC_GET_ARG1(call);
516
            col = IPC_GET_ARG2(call);
556
            col = IPC_GET_ARG2(call);
517
            if (row >= vport->rows || col >= vport->cols) {
557
            if (row >= vport->rows || col >= vport->cols) {
518
                retval = EINVAL;
558
                retval = EINVAL;
519
                break;
559
                break;
520
            }
560
            }
521
            retval = 0;
561
            retval = 0;
522
            cursor_hide(vp);
562
            cursor_hide(vp);
523
            vport->cur_col = col;
563
            vport->cur_col = col;
524
            vport->cur_row = row;
564
            vport->cur_row = row;
525
            cursor_print(vp);
565
            cursor_print(vp);
526
            break;
566
            break;
527
        case FB_CURSOR_VISIBILITY:
567
        case FB_CURSOR_VISIBILITY:
528
            cursor_hide(vp);
568
            cursor_hide(vp);
529
            vport->cursor_active = IPC_GET_ARG1(call);
569
            vport->cursor_active = IPC_GET_ARG1(call);
530
            cursor_print(vp);
570
            cursor_print(vp);
531
            retval = 0;
571
            retval = 0;
532
            break;
572
            break;
533
        case FB_GET_CSIZE:
573
        case FB_GET_CSIZE:
534
            ipc_answer_fast(callid, 0, vport->rows, vport->cols);
574
            ipc_answer_fast(callid, 0, vport->rows, vport->cols);
535
            continue;
575
            continue;
536
        case FB_SCROLL:
576
        case FB_SCROLL:
537
            i = IPC_GET_ARG1(call);
577
            i = IPC_GET_ARG1(call);
538
            if (i > vport->rows || i < (- (int)vport->rows)) {
578
            if (i > vport->rows || i < (- (int)vport->rows)) {
539
                retval = EINVAL;
579
                retval = EINVAL;
540
                break;
580
                break;
541
            }
581
            }
542
            cursor_hide(vp);
582
            cursor_hide(vp);
543
            scroll_port(vp, i);
583
            scroll_port(vp, i);
544
            cursor_print(vp);
584
            cursor_print(vp);
545
            retval = 0;
585
            retval = 0;
546
            break;
586
            break;
547
        case FB_VIEWPORT_SWITCH:
587
        case FB_VIEWPORT_SWITCH:
548
            i = IPC_GET_ARG1(call);
588
            i = IPC_GET_ARG1(call);
549
            if (i < 0 || i >= MAX_VIEWPORTS) {
589
            if (i < 0 || i >= MAX_VIEWPORTS) {
550
                retval = EINVAL;
590
                retval = EINVAL;
551
                break;
591
                break;
552
            }
592
            }
553
            if (! viewports[i].initialized ) {
593
            if (! viewports[i].initialized ) {
554
                retval = EADDRNOTAVAIL;
594
                retval = EADDRNOTAVAIL;
555
                break;
595
                break;
556
            }
596
            }
557
            cursor_hide(vp);
597
            cursor_hide(vp);
558
            vp = i;
598
            vp = i;
559
            vport = &viewports[vp];
599
            vport = &viewports[vp];
560
            cursor_print(vp);
600
            cursor_print(vp);
561
            retval = 0;
601
            retval = 0;
562
            break;
602
            break;
563
        case FB_VIEWPORT_CREATE:
603
        case FB_VIEWPORT_CREATE:
564
            retval = viewport_create(IPC_GET_ARG1(call) >> 16,
604
            retval = viewport_create(IPC_GET_ARG1(call) >> 16,
565
                         IPC_GET_ARG1(call) & 0xffff,
605
                         IPC_GET_ARG1(call) & 0xffff,
566
                         IPC_GET_ARG2(call) >> 16,
606
                         IPC_GET_ARG2(call) >> 16,
567
                         IPC_GET_ARG2(call) & 0xffff);
607
                         IPC_GET_ARG2(call) & 0xffff);
568
            break;
608
            break;
569
        case FB_VIEWPORT_DELETE:
609
        case FB_VIEWPORT_DELETE:
570
            i = IPC_GET_ARG1(call);
610
            i = IPC_GET_ARG1(call);
571
            if (i < 0 || i >= MAX_VIEWPORTS) {
611
            if (i < 0 || i >= MAX_VIEWPORTS) {
572
                retval = EINVAL;
612
                retval = EINVAL;
573
                break;
613
                break;
574
            }
614
            }
575
            if (! viewports[i].initialized ) {
615
            if (! viewports[i].initialized ) {
576
                retval = EADDRNOTAVAIL;
616
                retval = EADDRNOTAVAIL;
577
                break;
617
                break;
578
            }
618
            }
579
            viewports[i].initialized = 0;
619
            viewports[i].initialized = 0;
580
            retval = 0;
620
            retval = 0;
581
            break;
621
            break;
582
        case FB_SET_STYLE:
622
        case FB_SET_STYLE:
583
            vport->fgcolor = IPC_GET_ARG1(call);
623
            vport->fgcolor = IPC_GET_ARG1(call);
584
            vport->bgcolor = IPC_GET_ARG2(call);
624
            vport->bgcolor = IPC_GET_ARG2(call);
585
            retval = 0;
625
            retval = 0;
586
            break;
626
            break;
587
        case FB_GET_RESOLUTION:
627
        case FB_GET_RESOLUTION:
588
            ipc_answer_fast(callid, 0, screen.xres,screen.yres);
628
            ipc_answer_fast(callid, 0, screen.xres,screen.yres);
589
            continue;
629
            continue;
590
        default:
630
        default:
591
            retval = ENOENT;
631
            retval = ENOENT;
592
        }
632
        }
593
        ipc_answer_fast(callid,retval,0,0);
633
        ipc_answer_fast(callid,retval,0,0);
594
    }
634
    }
595
}
635
}
596
 
636
 
597
/** Initialization of framebuffer */
637
/** Initialization of framebuffer */
598
int fb_init(void)
638
int fb_init(void)
599
{
639
{
600
    void *fb_ph_addr;
640
    void *fb_ph_addr;
601
    unsigned int fb_width;
641
    unsigned int fb_width;
602
    unsigned int fb_height;
642
    unsigned int fb_height;
603
    unsigned int fb_bpp;
643
    unsigned int fb_bpp;
604
    unsigned int fb_scanline;
644
    unsigned int fb_scanline;
605
    void *fb_addr;
645
    void *fb_addr;
606
    size_t asz;
646
    size_t asz;
607
 
647
 
608
    async_set_client_connection(fb_client_connection);
648
    async_set_client_connection(fb_client_connection);
609
 
649
 
610
    fb_ph_addr=(void *)sysinfo_value("fb.address.physical");
650
    fb_ph_addr=(void *)sysinfo_value("fb.address.physical");
611
    fb_width=sysinfo_value("fb.width");
651
    fb_width=sysinfo_value("fb.width");
612
    fb_height=sysinfo_value("fb.height");
652
    fb_height=sysinfo_value("fb.height");
613
    fb_bpp=sysinfo_value("fb.bpp");
653
    fb_bpp=sysinfo_value("fb.bpp");
614
    fb_scanline=sysinfo_value("fb.scanline");
654
    fb_scanline=sysinfo_value("fb.scanline");
615
 
655
 
616
    asz = fb_scanline*fb_height;
656
    asz = fb_scanline*fb_height;
617
    fb_addr = as_get_mappable_page(asz);
657
    fb_addr = as_get_mappable_page(asz);
618
   
658
   
619
    map_physmem(fb_ph_addr, fb_addr, ALIGN_UP(asz,PAGE_SIZE) >>PAGE_WIDTH,
659
    map_physmem(fb_ph_addr, fb_addr, ALIGN_UP(asz,PAGE_SIZE) >>PAGE_WIDTH,
620
            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
660
            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
621
   
661
   
622
    screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline);
662
    screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline);
623
 
663
 
624
    return 0;
664
    return 0;
625
}
665
}
626
 
666
 
627
 
667