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