Subversion Repositories HelenOS-historic

Rev

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

Rev 1312 Rev 1316
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
 
28
 
29
#include <genarch/fb/font-8x16.h>
29
#include <genarch/fb/font-8x16.h>
30
#include <genarch/fb/fb.h>
30
#include <genarch/fb/fb.h>
31
#include <console/chardev.h>
31
#include <console/chardev.h>
32
#include <console/console.h>
32
#include <console/console.h>
-
 
33
#include <mm/slab.h>
33
#include <panic.h>
34
#include <panic.h>
34
#include <memstr.h>
35
#include <memstr.h>
-
 
36
#include <config.h>
35
 
37
 
36
#include "helenos.xbm"
38
#include "helenos.xbm"
37
 
39
 
38
SPINLOCK_INITIALIZE(fb_lock);
40
SPINLOCK_INITIALIZE(fb_lock);
39
 
41
 
40
static __u8 *fbaddress = NULL;
42
static __u8 *fbaddress = NULL;
41
 
43
 
-
 
44
static __u8 *blankline = NULL;
-
 
45
 
42
static unsigned int xres = 0;
46
static unsigned int xres = 0;
43
static unsigned int yres = 0;
47
static unsigned int yres = 0;
44
static unsigned int scanline = 0;
48
static unsigned int scanline = 0;
45
static unsigned int pixelbytes = 0;
49
static unsigned int pixelbytes = 0;
46
 
50
 
47
static unsigned int position = 0;
51
static unsigned int position = 0;
48
static unsigned int columns = 0;
52
static unsigned int columns = 0;
49
static unsigned int rows = 0;
53
static unsigned int rows = 0;
50
 
54
 
51
 
55
 
52
#define COL_WIDTH   8
56
#define COL_WIDTH   8
53
#define ROW_BYTES   (scanline * FONT_SCANLINES)
57
#define ROW_BYTES   (scanline * FONT_SCANLINES)
54
 
58
 
55
#define BGCOLOR     0x000080
59
#define BGCOLOR     0x000080
56
#define FGCOLOR     0xffff00
60
#define FGCOLOR     0xffff00
57
#define LOGOCOLOR   0x2020b0
61
#define LOGOCOLOR   0x2020b0
58
 
62
 
59
#define RED(x, bits)    ((x >> (16 + 8 - bits)) & ((1 << bits) - 1))
63
#define RED(x, bits)    ((x >> (16 + 8 - bits)) & ((1 << bits) - 1))
60
#define GREEN(x, bits)  ((x >> (8 + 8 - bits)) & ((1 << bits) - 1))
64
#define GREEN(x, bits)  ((x >> (8 + 8 - bits)) & ((1 << bits) - 1))
61
#define BLUE(x, bits)   ((x >> (8 - bits)) & ((1 << bits) - 1))
65
#define BLUE(x, bits)   ((x >> (8 - bits)) & ((1 << bits) - 1))
62
 
66
 
63
#define POINTPOS(x, y)  (y * scanline + x * pixelbytes)
67
#define POINTPOS(x, y)  (y * scanline + x * pixelbytes)
64
 
68
 
65
/***************************************************************/
69
/***************************************************************/
66
/* Pixel specific fuctions */
70
/* Pixel specific fuctions */
67
 
71
 
68
static void (*putpixel)(unsigned int x, unsigned int y, int color);
72
static void (*putpixel)(unsigned int x, unsigned int y, int color);
69
static int (*getpixel)(unsigned int x, unsigned int y);
73
static int (*getpixel)(unsigned int x, unsigned int y);
70
 
74
 
71
/** Put pixel - 24-bit depth, 1 free byte */
75
/** Put pixel - 24-bit depth, 1 free byte */
72
static void putpixel_4byte(unsigned int x, unsigned int y, int color)
76
static void putpixel_4byte(unsigned int x, unsigned int y, int color)
73
{
77
{
74
    *((__u32 *)(fbaddress + POINTPOS(x, y))) = color;
78
    *((__u32 *)(fbaddress + POINTPOS(x, y))) = color;
75
}
79
}
76
 
80
 
77
/** Return pixel color - 24-bit depth, 1 free byte */
81
/** Return pixel color - 24-bit depth, 1 free byte */
78
static int getpixel_4byte(unsigned int x, unsigned int y)
82
static int getpixel_4byte(unsigned int x, unsigned int y)
79
{
83
{
80
    return *((__u32 *)(fbaddress + POINTPOS(x, y))) & 0xffffff;
84
    return *((__u32 *)(fbaddress + POINTPOS(x, y))) & 0xffffff;
81
}
85
}
82
 
86
 
83
/** Put pixel - 24-bit depth */
87
/** Put pixel - 24-bit depth */
84
static void putpixel_3byte(unsigned int x, unsigned int y, int color)
88
static void putpixel_3byte(unsigned int x, unsigned int y, int color)
85
{
89
{
86
    unsigned int startbyte = POINTPOS(x, y);
90
    unsigned int startbyte = POINTPOS(x, y);
87
 
91
 
88
#ifdef BIG_ENDIAN
92
#ifdef BIG_ENDIAN
89
    fbaddress[startbyte] = RED(color, 8);
93
    fbaddress[startbyte] = RED(color, 8);
90
    fbaddress[startbyte + 1] = GREEN(color, 8);
94
    fbaddress[startbyte + 1] = GREEN(color, 8);
91
    fbaddress[startbyte + 2] = BLUE(color, 8);
95
    fbaddress[startbyte + 2] = BLUE(color, 8);
92
#else
96
#else
93
    fbaddress[startbyte + 2] = RED(color, 8);
97
    fbaddress[startbyte + 2] = RED(color, 8);
94
    fbaddress[startbyte + 1] = GREEN(color, 8);
98
    fbaddress[startbyte + 1] = GREEN(color, 8);
95
    fbaddress[startbyte + 0] = BLUE(color, 8);
99
    fbaddress[startbyte + 0] = BLUE(color, 8);
96
#endif  
100
#endif  
97
}
101
}
98
 
102
 
99
/** Return pixel color - 24-bit depth */
103
/** Return pixel color - 24-bit depth */
100
static int getpixel_3byte(unsigned int x, unsigned int y)
104
static int getpixel_3byte(unsigned int x, unsigned int y)
101
{
105
{
102
    unsigned int startbyte = POINTPOS(x, y);
106
    unsigned int startbyte = POINTPOS(x, y);
103
 
107
 
104
#ifdef BIG_ENDIAN
108
#ifdef BIG_ENDIAN
105
    return fbaddress[startbyte] << 16 | fbaddress[startbyte + 1] << 8 | fbaddress[startbyte + 2];
109
    return fbaddress[startbyte] << 16 | fbaddress[startbyte + 1] << 8 | fbaddress[startbyte + 2];
106
#else
110
#else
107
    return fbaddress[startbyte + 2] << 16 | fbaddress[startbyte + 1] << 8 | fbaddress[startbyte + 0];
111
    return fbaddress[startbyte + 2] << 16 | fbaddress[startbyte + 1] << 8 | fbaddress[startbyte + 0];
108
#endif  
112
#endif  
109
}
113
}
110
 
114
 
111
/** Put pixel - 16-bit depth (5:6:6) */
115
/** Put pixel - 16-bit depth (5:6:6) */
112
static void putpixel_2byte(unsigned int x, unsigned int y, int color)
116
static void putpixel_2byte(unsigned int x, unsigned int y, int color)
113
{
117
{
114
    /* 5-bit, 5-bits, 5-bits */
118
    /* 5-bit, 5-bits, 5-bits */
115
    *((__u16 *)(fbaddress + POINTPOS(x, y))) = RED(color, 5) << 11 | GREEN(color, 6) << 5 | BLUE(color, 5);
119
    *((__u16 *)(fbaddress + POINTPOS(x, y))) = RED(color, 5) << 11 | GREEN(color, 6) << 5 | BLUE(color, 5);
116
}
120
}
117
 
121
 
118
/** Return pixel color - 16-bit depth (5:6:6) */
122
/** Return pixel color - 16-bit depth (5:6:6) */
119
static int getpixel_2byte(unsigned int x, unsigned int y)
123
static int getpixel_2byte(unsigned int x, unsigned int y)
120
{
124
{
121
    int color = *((__u16 *)(fbaddress + POINTPOS(x, y)));
125
    int color = *((__u16 *)(fbaddress + POINTPOS(x, y)));
122
    return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
126
    return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
123
}
127
}
124
 
128
 
125
/** Put pixel - 8-bit depth (3:2:3) */
129
/** Put pixel - 8-bit depth (3:2:3) */
126
static void putpixel_1byte(unsigned int x, unsigned int y, int color)
130
static void putpixel_1byte(unsigned int x, unsigned int y, int color)
127
{
131
{
128
    fbaddress[POINTPOS(x, y)] = RED(color, 3) << 5 | GREEN(color, 2) << 3 | BLUE(color, 3);
132
    fbaddress[POINTPOS(x, y)] = RED(color, 3) << 5 | GREEN(color, 2) << 3 | BLUE(color, 3);
129
}
133
}
130
 
134
 
131
/** Return pixel color - 8-bit depth (3:2:3) */
135
/** Return pixel color - 8-bit depth (3:2:3) */
132
static int getpixel_1byte(unsigned int x, unsigned int y)
136
static int getpixel_1byte(unsigned int x, unsigned int y)
133
{
137
{
134
    int color = fbaddress[POINTPOS(x, y)];
138
    int color = fbaddress[POINTPOS(x, y)];
135
    return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
139
    return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
136
}
140
}
137
 
141
 
138
/** Fill line with color BGCOLOR */
142
/** Fill line with color BGCOLOR */
139
static void clear_line(unsigned int y)
143
static void clear_line(unsigned int y)
140
{
144
{
141
    unsigned int x;
145
    unsigned int x;
142
   
146
   
143
    for (x = 0; x < xres; x++)
147
    for (x = 0; x < xres; x++)
144
        (*putpixel)(x, y, BGCOLOR);
148
        (*putpixel)(x, y, BGCOLOR);
145
}
149
}
146
 
150
 
147
 
151
 
148
/** Fill screen with background color */
152
/** Fill screen with background color */
149
static void clear_screen(void)
153
static void clear_screen(void)
150
{
154
{
151
    unsigned int y;
155
    unsigned int y;
152
 
156
 
153
    for (y = 0; y < yres; y++)
157
    for (y = 0; y < yres; y++)
154
        clear_line(y);
158
        clear_line(y);
155
}
159
}
156
 
160
 
157
 
161
 
158
/** Scroll screen one row up */
162
/** Scroll screen one row up */
159
static void scroll_screen(void)
163
static void scroll_screen(void)
160
{
164
{
161
    unsigned int i;
165
    unsigned int i;
-
 
166
    __u8 *lastline = &fbaddress[(rows - 1) * ROW_BYTES];
162
 
167
 
163
    memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], scanline * yres - ROW_BYTES);
168
    memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], scanline * yres - ROW_BYTES);
164
 
169
 
165
    /* Clear last row */
170
    /* Clear last row */
-
 
171
    if (blankline) {
-
 
172
        memcpy((void *) lastline, (void *) blankline, ROW_BYTES);
-
 
173
    } else {
166
    for (i = 0; i < FONT_SCANLINES; i++)
174
        for (i = 0; i < FONT_SCANLINES; i++)
167
        clear_line((rows - 1) * FONT_SCANLINES + i);
175
            clear_line((rows - 1) * FONT_SCANLINES + i);
-
 
176
 
-
 
177
        if (config.mm_initialized) {
-
 
178
            /* Save a blank line aside. */
-
 
179
            blankline = (__u8 *) malloc(ROW_BYTES, FRAME_ATOMIC);
-
 
180
            if (blankline)
-
 
181
                memcpy((void *) blankline, (void *) lastline, ROW_BYTES);
-
 
182
        }
-
 
183
    }
168
}
184
}
169
 
185
 
170
 
186
 
171
static void invert_pixel(unsigned int x, unsigned int y)
187
static void invert_pixel(unsigned int x, unsigned int y)
172
{
188
{
173
    (*putpixel)(x, y, ~(*getpixel)(x, y));
189
    (*putpixel)(x, y, ~(*getpixel)(x, y));
174
}
190
}
175
 
191
 
176
 
192
 
177
/** Draw one line of glyph at a given position */
193
/** Draw one line of glyph at a given position */
178
static void draw_glyph_line(unsigned int glline, unsigned int x, unsigned int y)
194
static void draw_glyph_line(unsigned int glline, unsigned int x, unsigned int y)
179
{
195
{
180
    unsigned int i;
196
    unsigned int i;
181
 
197
 
182
    for (i = 0; i < 8; i++)
198
    for (i = 0; i < 8; i++)
183
        if (glline & (1 << (7 - i))) {
199
        if (glline & (1 << (7 - i))) {
184
            (*putpixel)(x + i, y, FGCOLOR);
200
            (*putpixel)(x + i, y, FGCOLOR);
185
        } else
201
        } else
186
            (*putpixel)(x + i, y, BGCOLOR);
202
            (*putpixel)(x + i, y, BGCOLOR);
187
}
203
}
188
 
204
 
189
/***************************************************************/
205
/***************************************************************/
190
/* Character-console functions */
206
/* Character-console functions */
191
 
207
 
192
/** Draw character at given position */
208
/** Draw character at given position */
193
static void draw_glyph(__u8 glyph, unsigned int col, unsigned int row)
209
static void draw_glyph(__u8 glyph, unsigned int col, unsigned int row)
194
{
210
{
195
    unsigned int y;
211
    unsigned int y;
196
 
212
 
197
    for (y = 0; y < FONT_SCANLINES; y++)
213
    for (y = 0; y < FONT_SCANLINES; y++)
198
        draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y);
214
        draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y);
199
}
215
}
200
 
216
 
201
/** Invert character at given position */
217
/** Invert character at given position */
202
static void invert_char(unsigned int col, unsigned int row)
218
static void invert_char(unsigned int col, unsigned int row)
203
{
219
{
204
    unsigned int x;
220
    unsigned int x;
205
    unsigned int y;
221
    unsigned int y;
206
 
222
 
207
    for (x = 0; x < COL_WIDTH; x++)
223
    for (x = 0; x < COL_WIDTH; x++)
208
        for (y = 0; y < FONT_SCANLINES; y++)
224
        for (y = 0; y < FONT_SCANLINES; y++)
209
            invert_pixel(col * COL_WIDTH + x, row * FONT_SCANLINES + y);
225
            invert_pixel(col * COL_WIDTH + x, row * FONT_SCANLINES + y);
210
}
226
}
211
 
227
 
212
/** Draw character at default position */
228
/** Draw character at default position */
213
static void draw_char(char chr)
229
static void draw_char(char chr)
214
{
230
{
215
    draw_glyph(chr, position % columns, position / columns);
231
    draw_glyph(chr, position % columns, position / columns);
216
}
232
}
217
 
233
 
218
static void draw_logo(unsigned int startx, unsigned int starty)
234
static void draw_logo(unsigned int startx, unsigned int starty)
219
{
235
{
220
    unsigned int x;
236
    unsigned int x;
221
    unsigned int y;
237
    unsigned int y;
222
    unsigned int byte;
238
    unsigned int byte;
223
    unsigned int rowbytes;
239
    unsigned int rowbytes;
224
 
240
 
225
    rowbytes = (helenos_width - 1) / 8 + 1;
241
    rowbytes = (helenos_width - 1) / 8 + 1;
226
 
242
 
227
    for (y = 0; y < helenos_height; y++)
243
    for (y = 0; y < helenos_height; y++)
228
        for (x = 0; x < helenos_width; x++) {
244
        for (x = 0; x < helenos_width; x++) {
229
            byte = helenos_bits[rowbytes * y + x / 8];
245
            byte = helenos_bits[rowbytes * y + x / 8];
230
            byte >>= x % 8;
246
            byte >>= x % 8;
231
            if (byte & 1)
247
            if (byte & 1)
232
                (*putpixel)(startx + x, starty + y, LOGOCOLOR);
248
                (*putpixel)(startx + x, starty + y, LOGOCOLOR);
233
        }
249
        }
234
}
250
}
235
 
251
 
236
/***************************************************************/
252
/***************************************************************/
237
/* Stdout specific functions */
253
/* Stdout specific functions */
238
 
254
 
239
static void invert_cursor(void)
255
static void invert_cursor(void)
240
{
256
{
241
    invert_char(position % columns, position / columns);
257
    invert_char(position % columns, position / columns);
242
}
258
}
243
 
259
 
244
/** Print character to screen
260
/** Print character to screen
245
 *
261
 *
246
 *  Emulate basic terminal commands
262
 *  Emulate basic terminal commands
247
 */
263
 */
248
static void fb_putchar(chardev_t *dev, char ch)
264
static void fb_putchar(chardev_t *dev, char ch)
249
{
265
{
250
    spinlock_lock(&fb_lock);
266
    spinlock_lock(&fb_lock);
251
   
267
   
252
    switch (ch) {
268
    switch (ch) {
253
        case '\n':
269
        case '\n':
254
            invert_cursor();
270
            invert_cursor();
255
            position += columns;
271
            position += columns;
256
            position -= position % columns;
272
            position -= position % columns;
257
            break;
273
            break;
258
        case '\r':
274
        case '\r':
259
            invert_cursor();
275
            invert_cursor();
260
            position -= position % columns;
276
            position -= position % columns;
261
            break;
277
            break;
262
        case '\b':
278
        case '\b':
263
            invert_cursor();
279
            invert_cursor();
264
            if (position % columns)
280
            if (position % columns)
265
                position--;
281
                position--;
266
            break;
282
            break;
267
        case '\t':
283
        case '\t':
268
            invert_cursor();
284
            invert_cursor();
269
            do {
285
            do {
270
                draw_char(' ');
286
                draw_char(' ');
271
                position++;
287
                position++;
272
            } while ((position % 8) && position < columns * rows);
288
            } while ((position % 8) && position < columns * rows);
273
            break;
289
            break;
274
        default:
290
        default:
275
            draw_char(ch);
291
            draw_char(ch);
276
            position++;
292
            position++;
277
    }
293
    }
278
   
294
   
279
    if (position >= columns * rows) {
295
    if (position >= columns * rows) {
280
        position -= columns;
296
        position -= columns;
281
        scroll_screen();
297
        scroll_screen();
282
    }
298
    }
283
   
299
   
284
    invert_cursor();
300
    invert_cursor();
285
   
301
   
286
    spinlock_unlock(&fb_lock);
302
    spinlock_unlock(&fb_lock);
287
}
303
}
288
 
304
 
289
static chardev_t framebuffer;
305
static chardev_t framebuffer;
290
static chardev_operations_t fb_ops = {
306
static chardev_operations_t fb_ops = {
291
    .write = fb_putchar,
307
    .write = fb_putchar,
292
};
308
};
293
 
309
 
294
 
310
 
295
/** Initialize framebuffer as a chardev output device
311
/** Initialize framebuffer as a chardev output device
296
 *
312
 *
297
 * @param addr Address of theframebuffer
313
 * @param addr Address of theframebuffer
298
 * @param x    Screen width in pixels
314
 * @param x    Screen width in pixels
299
 * @param y    Screen height in pixels
315
 * @param y    Screen height in pixels
300
 * @param bpp  Bits per pixel (8, 16, 24, 32)
316
 * @param bpp  Bits per pixel (8, 16, 24, 32)
301
 * @param scan Bytes per one scanline
317
 * @param scan Bytes per one scanline
302
 *
318
 *
303
 */
319
 */
304
void fb_init(__address addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan)
320
void fb_init(__address addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan)
305
{
321
{
306
    switch (bpp) {
322
    switch (bpp) {
307
        case 8:
323
        case 8:
308
            putpixel = putpixel_1byte;
324
            putpixel = putpixel_1byte;
309
            getpixel = getpixel_1byte;
325
            getpixel = getpixel_1byte;
310
            pixelbytes = 1;
326
            pixelbytes = 1;
311
            break;
327
            break;
312
        case 16:
328
        case 16:
313
            putpixel = putpixel_2byte;
329
            putpixel = putpixel_2byte;
314
            getpixel = getpixel_2byte;
330
            getpixel = getpixel_2byte;
315
            pixelbytes = 2;
331
            pixelbytes = 2;
316
            break;
332
            break;
317
        case 24:
333
        case 24:
318
            putpixel = putpixel_3byte;
334
            putpixel = putpixel_3byte;
319
            getpixel = getpixel_3byte;
335
            getpixel = getpixel_3byte;
320
            pixelbytes = 3;
336
            pixelbytes = 3;
321
            break;
337
            break;
322
        case 32:
338
        case 32:
323
            putpixel = putpixel_4byte;
339
            putpixel = putpixel_4byte;
324
            getpixel = getpixel_4byte;
340
            getpixel = getpixel_4byte;
325
            pixelbytes = 4;
341
            pixelbytes = 4;
326
            break;
342
            break;
327
        default:
343
        default:
328
            panic("Unsupported bpp");
344
            panic("Unsupported bpp");
329
    }
345
    }
330
       
346
       
331
    fbaddress = (unsigned char *) addr;
347
    fbaddress = (unsigned char *) addr;
332
    xres = x;
348
    xres = x;
333
    yres = y;
349
    yres = y;
334
    scanline = scan;
350
    scanline = scan;
335
   
351
   
336
    rows = y / FONT_SCANLINES;
352
    rows = y / FONT_SCANLINES;
337
    columns = x / COL_WIDTH;
353
    columns = x / COL_WIDTH;
338
 
354
 
339
    clear_screen();
355
    clear_screen();
340
    draw_logo(xres - helenos_width, 0);
356
    draw_logo(xres - helenos_width, 0);
341
    invert_cursor();
357
    invert_cursor();
342
 
358
 
343
    chardev_initialize("fb", &framebuffer, &fb_ops);
359
    chardev_initialize("fb", &framebuffer, &fb_ops);
344
    stdout = &framebuffer;
360
    stdout = &framebuffer;
345
}
361
}
346
 
362