Rev 1489 | Rev 1493 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1489 | Rev 1490 | ||
---|---|---|---|
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 <stdio.h> |
- | |
31 | #include <stdlib.h> |
30 | #include <stdlib.h> |
32 | #include <unistd.h> |
31 | #include <unistd.h> |
33 | #include <string.h> |
32 | #include <string.h> |
34 | #include <ddi.h> |
33 | #include <ddi.h> |
35 | #include <task.h> |
- | |
36 | #include <sysinfo.h> |
34 | #include <sysinfo.h> |
37 | #include <align.h> |
35 | #include <align.h> |
38 | #include <as.h> |
36 | #include <as.h> |
39 | #include <ipc/fb.h> |
37 | #include <ipc/fb.h> |
40 | #include <ipc/ipc.h> |
38 | #include <ipc/ipc.h> |
41 | #include <ipc/ns.h> |
39 | #include <ipc/ns.h> |
42 | #include <ipc/services.h> |
40 | #include <ipc/services.h> |
43 | #include <kernel/errno.h> |
41 | #include <kernel/errno.h> |
44 | #include <async.h> |
42 | #include <async.h> |
45 | #include "font-8x16.h" |
43 | #include "font-8x16.h" |
46 | #include "helenos.xbm" |
44 | #include "helenos.xbm" |
47 | #include "fb.h" |
45 | #include "fb.h" |
48 | 46 | ||
49 | #define DEFAULT_BGCOLOR 0x000080 |
47 | #define DEFAULT_BGCOLOR 0x000080 |
50 | #define DEFAULT_FGCOLOR 0xffff00 |
48 | #define DEFAULT_FGCOLOR 0xffff00 |
51 | 49 | ||
52 | /***************************************************************/ |
50 | /***************************************************************/ |
53 | /* Pixel specific fuctions */ |
51 | /* Pixel specific fuctions */ |
54 | 52 | ||
55 | typedef void (*putpixel_fn_t)(unsigned int x, unsigned int y, int color); |
53 | typedef void (*putpixel_fn_t)(unsigned int x, unsigned int y, int color); |
56 | typedef int (*getpixel_fn_t)(unsigned int x, unsigned int y); |
54 | typedef int (*getpixel_fn_t)(unsigned int x, unsigned int y); |
57 | 55 | ||
58 | struct { |
56 | struct { |
59 | __u8 *fbaddress ; |
57 | __u8 *fbaddress ; |
60 | 58 | ||
61 | unsigned int xres ; |
59 | unsigned int xres ; |
62 | unsigned int yres ; |
60 | unsigned int yres ; |
63 | unsigned int scanline ; |
61 | unsigned int scanline ; |
64 | unsigned int pixelbytes ; |
62 | unsigned int pixelbytes ; |
65 | 63 | ||
66 | putpixel_fn_t putpixel; |
64 | putpixel_fn_t putpixel; |
67 | getpixel_fn_t getpixel; |
65 | getpixel_fn_t getpixel; |
68 | } screen; |
66 | } screen; |
69 | 67 | ||
70 | typedef struct { |
68 | typedef struct { |
71 | int initialized; |
69 | int initialized; |
72 | unsigned int x, y; |
70 | unsigned int x, y; |
73 | unsigned int width, height; |
71 | unsigned int width, height; |
74 | 72 | ||
75 | /* Text support in window */ |
73 | /* Text support in window */ |
76 | unsigned int rows, cols; |
74 | unsigned int rows, cols; |
77 | /* Style for text printing */ |
75 | /* Style for text printing */ |
78 | int bgcolor, fgcolor; |
76 | int bgcolor, fgcolor; |
79 | /* Auto-cursor position */ |
77 | /* Auto-cursor position */ |
80 | int cursor_active, cur_col, cur_row; |
78 | int cursor_active, cur_col, cur_row; |
81 | } viewport_t; |
79 | } viewport_t; |
82 | 80 | ||
83 | #define MAX_VIEWPORTS 128 |
81 | #define MAX_VIEWPORTS 128 |
84 | static viewport_t viewports[128]; |
82 | static viewport_t viewports[128]; |
85 | 83 | ||
86 | /* Allow only 1 connection */ |
84 | /* Allow only 1 connection */ |
87 | static int client_connected = 0; |
85 | static int client_connected = 0; |
88 | 86 | ||
89 | #define RED(x, bits) ((x >> (16 + 8 - bits)) & ((1 << bits) - 1)) |
87 | #define RED(x, bits) ((x >> (16 + 8 - bits)) & ((1 << bits) - 1)) |
90 | #define GREEN(x, bits) ((x >> (8 + 8 - bits)) & ((1 << bits) - 1)) |
88 | #define GREEN(x, bits) ((x >> (8 + 8 - bits)) & ((1 << bits) - 1)) |
91 | #define BLUE(x, bits) ((x >> (8 - bits)) & ((1 << bits) - 1)) |
89 | #define BLUE(x, bits) ((x >> (8 - bits)) & ((1 << bits) - 1)) |
92 | 90 | ||
93 | #define COL_WIDTH 8 |
91 | #define COL_WIDTH 8 |
94 | #define ROW_BYTES (screen.scanline * FONT_SCANLINES) |
92 | #define ROW_BYTES (screen.scanline * FONT_SCANLINES) |
95 | 93 | ||
96 | #define POINTPOS(x, y) ((y) * screen.scanline + (x) * screen.pixelbytes) |
94 | #define POINTPOS(x, y) ((y) * screen.scanline + (x) * screen.pixelbytes) |
97 | 95 | ||
98 | /** Put pixel - 24-bit depth, 1 free byte */ |
96 | /** Put pixel - 24-bit depth, 1 free byte */ |
99 | static void putpixel_4byte(unsigned int x, unsigned int y, int color) |
97 | static void putpixel_4byte(unsigned int x, unsigned int y, int color) |
100 | { |
98 | { |
101 | *((__u32 *)(screen.fbaddress + POINTPOS(x, y))) = color; |
99 | *((__u32 *)(screen.fbaddress + POINTPOS(x, y))) = color; |
102 | } |
100 | } |
103 | 101 | ||
104 | /** Return pixel color - 24-bit depth, 1 free byte */ |
102 | /** Return pixel color - 24-bit depth, 1 free byte */ |
105 | static int getpixel_4byte(unsigned int x, unsigned int y) |
103 | static int getpixel_4byte(unsigned int x, unsigned int y) |
106 | { |
104 | { |
107 | return *((__u32 *)(screen.fbaddress + POINTPOS(x, y))) & 0xffffff; |
105 | return *((__u32 *)(screen.fbaddress + POINTPOS(x, y))) & 0xffffff; |
108 | } |
106 | } |
109 | 107 | ||
110 | /** Put pixel - 24-bit depth */ |
108 | /** Put pixel - 24-bit depth */ |
111 | static void putpixel_3byte(unsigned int x, unsigned int y, int color) |
109 | static void putpixel_3byte(unsigned int x, unsigned int y, int color) |
112 | { |
110 | { |
113 | unsigned int startbyte = POINTPOS(x, y); |
111 | unsigned int startbyte = POINTPOS(x, y); |
114 | 112 | ||
115 | #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) |
113 | #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) |
116 | screen.fbaddress[startbyte] = RED(color, 8); |
114 | screen.fbaddress[startbyte] = RED(color, 8); |
117 | screen.fbaddress[startbyte + 1] = GREEN(color, 8); |
115 | screen.fbaddress[startbyte + 1] = GREEN(color, 8); |
118 | screen.fbaddress[startbyte + 2] = BLUE(color, 8); |
116 | screen.fbaddress[startbyte + 2] = BLUE(color, 8); |
119 | #else |
117 | #else |
120 | screen.fbaddress[startbyte + 2] = RED(color, 8); |
118 | screen.fbaddress[startbyte + 2] = RED(color, 8); |
121 | screen.fbaddress[startbyte + 1] = GREEN(color, 8); |
119 | screen.fbaddress[startbyte + 1] = GREEN(color, 8); |
122 | screen.fbaddress[startbyte + 0] = BLUE(color, 8); |
120 | screen.fbaddress[startbyte + 0] = BLUE(color, 8); |
123 | #endif |
121 | #endif |
124 | 122 | ||
125 | } |
123 | } |
126 | 124 | ||
127 | /** Return pixel color - 24-bit depth */ |
125 | /** Return pixel color - 24-bit depth */ |
128 | static int getpixel_3byte(unsigned int x, unsigned int y) |
126 | static int getpixel_3byte(unsigned int x, unsigned int y) |
129 | { |
127 | { |
130 | unsigned int startbyte = POINTPOS(x, y); |
128 | unsigned int startbyte = POINTPOS(x, y); |
131 | 129 | ||
132 | 130 | ||
133 | 131 | ||
134 | #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) |
132 | #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) |
135 | return screen.fbaddress[startbyte] << 16 | screen.fbaddress[startbyte + 1] << 8 | screen.fbaddress[startbyte + 2]; |
133 | return screen.fbaddress[startbyte] << 16 | screen.fbaddress[startbyte + 1] << 8 | screen.fbaddress[startbyte + 2]; |
136 | #else |
134 | #else |
137 | return screen.fbaddress[startbyte + 2] << 16 | screen.fbaddress[startbyte + 1] << 8 | screen.fbaddress[startbyte + 0]; |
135 | return screen.fbaddress[startbyte + 2] << 16 | screen.fbaddress[startbyte + 1] << 8 | screen.fbaddress[startbyte + 0]; |
138 | #endif |
136 | #endif |
139 | 137 | ||
140 | 138 | ||
141 | } |
139 | } |
142 | 140 | ||
143 | /** Put pixel - 16-bit depth (5:6:5) */ |
141 | /** Put pixel - 16-bit depth (5:6:5) */ |
144 | static void putpixel_2byte(unsigned int x, unsigned int y, int color) |
142 | static void putpixel_2byte(unsigned int x, unsigned int y, int color) |
145 | { |
143 | { |
146 | /* 5-bit, 6-bits, 5-bits */ |
144 | /* 5-bit, 6-bits, 5-bits */ |
147 | *((__u16 *)(screen.fbaddress + POINTPOS(x, y))) = RED(color, 5) << 11 | GREEN(color, 6) << 5 | BLUE(color, 5); |
145 | *((__u16 *)(screen.fbaddress + POINTPOS(x, y))) = RED(color, 5) << 11 | GREEN(color, 6) << 5 | BLUE(color, 5); |
148 | } |
146 | } |
149 | 147 | ||
150 | /** Return pixel color - 16-bit depth (5:6:5) */ |
148 | /** Return pixel color - 16-bit depth (5:6:5) */ |
151 | static int getpixel_2byte(unsigned int x, unsigned int y) |
149 | static int getpixel_2byte(unsigned int x, unsigned int y) |
152 | { |
150 | { |
153 | int color = *((__u16 *)(screen.fbaddress + POINTPOS(x, y))); |
151 | int color = *((__u16 *)(screen.fbaddress + POINTPOS(x, y))); |
154 | return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
152 | return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
155 | } |
153 | } |
156 | 154 | ||
157 | /** Put pixel - 8-bit depth (3:2:3) */ |
155 | /** Put pixel - 8-bit depth (3:2:3) */ |
158 | static void putpixel_1byte(unsigned int x, unsigned int y, int color) |
156 | static void putpixel_1byte(unsigned int x, unsigned int y, int color) |
159 | { |
157 | { |
160 | screen.fbaddress[POINTPOS(x, y)] = RED(color, 3) << 5 | GREEN(color, 2) << 3 | BLUE(color, 3); |
158 | screen.fbaddress[POINTPOS(x, y)] = RED(color, 3) << 5 | GREEN(color, 2) << 3 | BLUE(color, 3); |
161 | } |
159 | } |
162 | 160 | ||
163 | /** Return pixel color - 8-bit depth (3:2:3) */ |
161 | /** Return pixel color - 8-bit depth (3:2:3) */ |
164 | static int getpixel_1byte(unsigned int x, unsigned int y) |
162 | static int getpixel_1byte(unsigned int x, unsigned int y) |
165 | { |
163 | { |
166 | int color = screen.fbaddress[POINTPOS(x, y)]; |
164 | int color = screen.fbaddress[POINTPOS(x, y)]; |
167 | return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
165 | return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
168 | } |
166 | } |
169 | 167 | ||
170 | static void putpixel(int vp, unsigned int x, unsigned int y, int color) |
168 | static void putpixel(int vp, unsigned int x, unsigned int y, int color) |
171 | { |
169 | { |
172 | screen.putpixel(viewports[vp].x + x, viewports[vp].y + y, color); |
170 | screen.putpixel(viewports[vp].x + x, viewports[vp].y + y, color); |
173 | } |
171 | } |
174 | static int getpixel(int vp, unsigned int x, unsigned int y) |
172 | static int getpixel(int vp, unsigned int x, unsigned int y) |
175 | { |
173 | { |
176 | return screen.getpixel(viewports[vp].x + x, viewports[vp].y + y); |
174 | return screen.getpixel(viewports[vp].x + x, viewports[vp].y + y); |
177 | } |
175 | } |
178 | 176 | ||
179 | /** Fill line with color BGCOLOR */ |
177 | /** Fill line with color BGCOLOR */ |
180 | static void clear_line(int vp, unsigned int y) |
178 | static void clear_line(int vp, unsigned int y) |
181 | { |
179 | { |
182 | unsigned int x; |
180 | unsigned int x; |
183 | for (x = 0; x < viewports[vp].width; x++) |
181 | for (x = 0; x < viewports[vp].width; x++) |
184 | putpixel(vp, x, y, viewports[vp].bgcolor); |
182 | putpixel(vp, x, y, viewports[vp].bgcolor); |
185 | } |
183 | } |
186 | 184 | ||
187 | /** Fill viewport with background color */ |
185 | /** Fill viewport with background color */ |
188 | static void clear_port(int vp) |
186 | static void clear_port(int vp) |
189 | { |
187 | { |
190 | unsigned int y; |
188 | unsigned int y; |
191 | 189 | ||
192 | clear_line(vp, 0); |
190 | clear_line(vp, 0); |
193 | for (y = viewports[vp].y+1; y < viewports[vp].y+viewports[vp].height; y++) { |
191 | for (y = viewports[vp].y+1; y < viewports[vp].y+viewports[vp].height; y++) { |
194 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)], |
192 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)], |
195 | &screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y)], |
193 | &screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y)], |
196 | screen.pixelbytes * viewports[vp].width); |
194 | screen.pixelbytes * viewports[vp].width); |
197 | } |
195 | } |
198 | } |
196 | } |
199 | 197 | ||
200 | /** Scroll port up/down |
198 | /** Scroll port up/down |
201 | * |
199 | * |
202 | * @param vp Viewport to scroll |
200 | * @param vp Viewport to scroll |
203 | * @param rows Positive number - scroll up, negative - scroll down |
201 | * @param rows Positive number - scroll up, negative - scroll down |
204 | */ |
202 | */ |
205 | static void scroll_port(int vp, int rows) |
203 | static void scroll_port(int vp, int rows) |
206 | { |
204 | { |
207 | int y; |
205 | int y; |
208 | int startline; |
206 | int startline; |
209 | int endline; |
207 | int endline; |
210 | 208 | ||
211 | if (rows > 0) { |
209 | if (rows > 0) { |
212 | for (y=viewports[vp].y; y < viewports[vp].y+viewports[vp].height - rows*FONT_SCANLINES; y++) |
210 | for (y=viewports[vp].y; y < viewports[vp].y+viewports[vp].height - rows*FONT_SCANLINES; y++) |
213 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)], |
211 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)], |
214 | &screen.fbaddress[POINTPOS(viewports[vp].x,y + rows*FONT_SCANLINES)], |
212 | &screen.fbaddress[POINTPOS(viewports[vp].x,y + rows*FONT_SCANLINES)], |
215 | screen.pixelbytes * viewports[vp].width); |
213 | screen.pixelbytes * viewports[vp].width); |
216 | /* Clear last row */ |
214 | /* Clear last row */ |
217 | startline = viewports[vp].y+FONT_SCANLINES*(viewports[vp].rows-1); |
215 | startline = viewports[vp].y+FONT_SCANLINES*(viewports[vp].rows-1); |
218 | endline = viewports[vp].y + viewports[vp].height; |
216 | endline = viewports[vp].y + viewports[vp].height; |
219 | clear_line(vp, startline); |
217 | clear_line(vp, startline); |
220 | for (y=startline+1;y < endline; y++) |
218 | for (y=startline+1;y < endline; y++) |
221 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)], |
219 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)], |
222 | &screen.fbaddress[POINTPOS(viewports[vp].x,startline)], |
220 | &screen.fbaddress[POINTPOS(viewports[vp].x,startline)], |
223 | screen.pixelbytes * viewports[vp].width); |
221 | screen.pixelbytes * viewports[vp].width); |
224 | 222 | ||
225 | } else if (rows < 0) { |
223 | } else if (rows < 0) { |
226 | rows = -rows; |
224 | rows = -rows; |
227 | for (y=viewports[vp].y + viewports[vp].height-1; y >= viewports[vp].y + rows*FONT_SCANLINES; y--) |
225 | for (y=viewports[vp].y + viewports[vp].height-1; y >= viewports[vp].y + rows*FONT_SCANLINES; y--) |
228 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)], |
226 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,y)], |
229 | &screen.fbaddress[POINTPOS(viewports[vp].x,y - rows*FONT_SCANLINES)], |
227 | &screen.fbaddress[POINTPOS(viewports[vp].x,y - rows*FONT_SCANLINES)], |
230 | screen.pixelbytes * viewports[vp].width); |
228 | screen.pixelbytes * viewports[vp].width); |
231 | /* Clear first row */ |
229 | /* Clear first row */ |
232 | clear_line(0, viewports[vp].bgcolor); |
230 | clear_line(0, viewports[vp].bgcolor); |
233 | for (y=1;y < rows*FONT_SCANLINES; y++) |
231 | for (y=1;y < rows*FONT_SCANLINES; y++) |
234 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y+y)], |
232 | memcpy(&screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y+y)], |
235 | &screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y)], |
233 | &screen.fbaddress[POINTPOS(viewports[vp].x,viewports[vp].y)], |
236 | screen.pixelbytes * viewports[vp].width); |
234 | screen.pixelbytes * viewports[vp].width); |
237 | } |
235 | } |
238 | } |
236 | } |
239 | 237 | ||
240 | static void invert_pixel(int vp,unsigned int x, unsigned int y) |
238 | static void invert_pixel(int vp,unsigned int x, unsigned int y) |
241 | { |
239 | { |
242 | putpixel(vp, x, y, ~getpixel(vp, x, y)); |
240 | putpixel(vp, x, y, ~getpixel(vp, x, y)); |
243 | } |
241 | } |
244 | 242 | ||
245 | 243 | ||
246 | /** Draw one line of glyph at a given position */ |
244 | /** Draw one line of glyph at a given position */ |
247 | static void draw_glyph_line(int vp,unsigned int glline, unsigned int x, unsigned int y) |
245 | static void draw_glyph_line(int vp,unsigned int glline, unsigned int x, unsigned int y) |
248 | { |
246 | { |
249 | unsigned int i; |
247 | unsigned int i; |
250 | 248 | ||
251 | for (i = 0; i < 8; i++) |
249 | for (i = 0; i < 8; i++) |
252 | if (glline & (1 << (7 - i))) { |
250 | if (glline & (1 << (7 - i))) { |
253 | putpixel(vp, x + i, y, viewports[vp].fgcolor); |
251 | putpixel(vp, x + i, y, viewports[vp].fgcolor); |
254 | } else |
252 | } else |
255 | putpixel(vp, x + i, y, viewports[vp].bgcolor); |
253 | putpixel(vp, x + i, y, viewports[vp].bgcolor); |
256 | } |
254 | } |
257 | 255 | ||
258 | /***************************************************************/ |
256 | /***************************************************************/ |
259 | /* Character-console functions */ |
257 | /* Character-console functions */ |
260 | 258 | ||
261 | /** Draw character at given position */ |
259 | /** Draw character at given position */ |
262 | static void draw_glyph(int vp,__u8 glyph, unsigned int row, unsigned int col) |
260 | static void draw_glyph(int vp,__u8 glyph, unsigned int row, unsigned int col) |
263 | { |
261 | { |
264 | unsigned int y; |
262 | unsigned int y; |
265 | 263 | ||
266 | for (y = 0; y < FONT_SCANLINES; y++) |
264 | for (y = 0; y < FONT_SCANLINES; y++) |
267 | draw_glyph_line(vp ,fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y); |
265 | draw_glyph_line(vp ,fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y); |
268 | } |
266 | } |
269 | 267 | ||
270 | /** Invert character at given position */ |
268 | /** Invert character at given position */ |
271 | static void invert_char(int vp,unsigned int row, unsigned int col) |
269 | static void invert_char(int vp,unsigned int row, unsigned int col) |
272 | { |
270 | { |
273 | unsigned int x; |
271 | unsigned int x; |
274 | unsigned int y; |
272 | unsigned int y; |
275 | 273 | ||
276 | for (x = 0; x < COL_WIDTH; x++) |
274 | for (x = 0; x < COL_WIDTH; x++) |
277 | for (y = 0; y < FONT_SCANLINES; y++) |
275 | for (y = 0; y < FONT_SCANLINES; y++) |
278 | invert_pixel(vp, col * COL_WIDTH + x, row * FONT_SCANLINES + y); |
276 | invert_pixel(vp, col * COL_WIDTH + x, row * FONT_SCANLINES + y); |
279 | } |
277 | } |
280 | 278 | ||
281 | static void draw_logo(int vp,unsigned int startx, unsigned int starty) |
279 | static void draw_logo(int vp,unsigned int startx, unsigned int starty) |
282 | { |
280 | { |
283 | unsigned int x; |
281 | unsigned int x; |
284 | unsigned int y; |
282 | unsigned int y; |
285 | unsigned int byte; |
283 | unsigned int byte; |
286 | unsigned int rowbytes; |
284 | unsigned int rowbytes; |
287 | 285 | ||
288 | rowbytes = (helenos_width - 1) / 8 + 1; |
286 | rowbytes = (helenos_width - 1) / 8 + 1; |
289 | 287 | ||
290 | for (y = 0; y < helenos_height; y++) |
288 | for (y = 0; y < helenos_height; y++) |
291 | for (x = 0; x < helenos_width; x++) { |
289 | for (x = 0; x < helenos_width; x++) { |
292 | byte = helenos_bits[rowbytes * y + x / 8]; |
290 | byte = helenos_bits[rowbytes * y + x / 8]; |
293 | byte >>= x % 8; |
291 | byte >>= x % 8; |
294 | if (byte & 1) |
292 | if (byte & 1) |
295 | putpixel(vp ,startx + x, starty + y, viewports[vp].fgcolor); |
293 | putpixel(vp ,startx + x, starty + y, viewports[vp].fgcolor); |
296 | } |
294 | } |
297 | } |
295 | } |
298 | 296 | ||
299 | /***************************************************************/ |
297 | /***************************************************************/ |
300 | /* Stdout specific functions */ |
298 | /* Stdout specific functions */ |
301 | 299 | ||
302 | 300 | ||
303 | /** Create new viewport |
301 | /** Create new viewport |
304 | * |
302 | * |
305 | * @return New viewport number |
303 | * @return New viewport number |
306 | */ |
304 | */ |
307 | static int viewport_create(unsigned int x, unsigned int y,unsigned int width, |
305 | static int viewport_create(unsigned int x, unsigned int y,unsigned int width, |
308 | unsigned int height) |
306 | unsigned int height) |
309 | { |
307 | { |
310 | int i; |
308 | int i; |
311 | 309 | ||
312 | for (i=0; i < MAX_VIEWPORTS; i++) { |
310 | for (i=0; i < MAX_VIEWPORTS; i++) { |
313 | if (!viewports[i].initialized) |
311 | if (!viewports[i].initialized) |
314 | break; |
312 | break; |
315 | } |
313 | } |
316 | if (i == MAX_VIEWPORTS) |
314 | if (i == MAX_VIEWPORTS) |
317 | return ELIMIT; |
315 | return ELIMIT; |
318 | 316 | ||
319 | if (width ==0 || height == 0 || |
317 | if (width ==0 || height == 0 || |
320 | x+width > screen.xres || y+height > screen.yres) |
318 | x+width > screen.xres || y+height > screen.yres) |
321 | return EINVAL; |
319 | return EINVAL; |
322 | if (width < FONT_SCANLINES || height < COL_WIDTH) |
320 | if (width < FONT_SCANLINES || height < COL_WIDTH) |
323 | return EINVAL; |
321 | return EINVAL; |
324 | 322 | ||
325 | viewports[i].x = x; |
323 | viewports[i].x = x; |
326 | viewports[i].y = y; |
324 | viewports[i].y = y; |
327 | viewports[i].width = width; |
325 | viewports[i].width = width; |
328 | viewports[i].height = height; |
326 | viewports[i].height = height; |
329 | 327 | ||
330 | viewports[i].rows = height / FONT_SCANLINES; |
328 | viewports[i].rows = height / FONT_SCANLINES; |
331 | viewports[i].cols = width / COL_WIDTH; |
329 | viewports[i].cols = width / COL_WIDTH; |
332 | 330 | ||
333 | viewports[i].bgcolor = DEFAULT_BGCOLOR; |
331 | viewports[i].bgcolor = DEFAULT_BGCOLOR; |
334 | viewports[i].fgcolor = DEFAULT_FGCOLOR; |
332 | viewports[i].fgcolor = DEFAULT_FGCOLOR; |
335 | 333 | ||
336 | viewports[i].cur_col = 0; |
334 | viewports[i].cur_col = 0; |
337 | viewports[i].cur_row = 0; |
335 | viewports[i].cur_row = 0; |
338 | viewports[i].cursor_active = 0; |
336 | viewports[i].cursor_active = 0; |
339 | 337 | ||
340 | viewports[i].initialized = 1; |
338 | viewports[i].initialized = 1; |
341 | 339 | ||
342 | return i; |
340 | return i; |
343 | } |
341 | } |
344 | 342 | ||
345 | 343 | ||
346 | /** Initialize framebuffer as a chardev output device |
344 | /** Initialize framebuffer as a chardev output device |
347 | * |
345 | * |
348 | * @param addr Address of theframebuffer |
346 | * @param addr Address of theframebuffer |
349 | * @param x Screen width in pixels |
347 | * @param x Screen width in pixels |
350 | * @param y Screen height in pixels |
348 | * @param y Screen height in pixels |
351 | * @param bpp Bits per pixel (8, 16, 24, 32) |
349 | * @param bpp Bits per pixel (8, 16, 24, 32) |
352 | * @param scan Bytes per one scanline |
350 | * @param scan Bytes per one scanline |
353 | * |
351 | * |
354 | */ |
352 | */ |
355 | static void screen_init(__address addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan) |
353 | static void screen_init(__address addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan) |
356 | { |
354 | { |
357 | switch (bpp) { |
355 | switch (bpp) { |
358 | case 8: |
356 | case 8: |
359 | screen.putpixel = putpixel_1byte; |
357 | screen.putpixel = putpixel_1byte; |
360 | screen.getpixel = getpixel_1byte; |
358 | screen.getpixel = getpixel_1byte; |
361 | screen.pixelbytes = 1; |
359 | screen.pixelbytes = 1; |
362 | break; |
360 | break; |
363 | case 16: |
361 | case 16: |
364 | screen.putpixel = putpixel_2byte; |
362 | screen.putpixel = putpixel_2byte; |
365 | screen.getpixel = getpixel_2byte; |
363 | screen.getpixel = getpixel_2byte; |
366 | screen.pixelbytes = 2; |
364 | screen.pixelbytes = 2; |
367 | break; |
365 | break; |
368 | case 24: |
366 | case 24: |
369 | screen.putpixel = putpixel_3byte; |
367 | screen.putpixel = putpixel_3byte; |
370 | screen.getpixel = getpixel_3byte; |
368 | screen.getpixel = getpixel_3byte; |
371 | screen.pixelbytes = 3; |
369 | screen.pixelbytes = 3; |
372 | break; |
370 | break; |
373 | case 32: |
371 | case 32: |
374 | screen.putpixel = putpixel_4byte; |
372 | screen.putpixel = putpixel_4byte; |
375 | screen.getpixel = getpixel_4byte; |
373 | screen.getpixel = getpixel_4byte; |
376 | screen.pixelbytes = 4; |
374 | screen.pixelbytes = 4; |
377 | break; |
375 | break; |
378 | } |
376 | } |
379 | 377 | ||
380 | 378 | ||
381 | screen.fbaddress = (unsigned char *) addr; |
379 | screen.fbaddress = (unsigned char *) addr; |
382 | screen.xres = xres; |
380 | screen.xres = xres; |
383 | screen.yres = yres; |
381 | screen.yres = yres; |
384 | screen.scanline = scan; |
382 | screen.scanline = scan; |
385 | 383 | ||
386 | /* Create first viewport */ |
384 | /* Create first viewport */ |
387 | viewport_create(0,0,xres,yres); |
385 | viewport_create(0,0,xres,yres); |
388 | 386 | ||
389 | clear_port(0); |
387 | clear_port(0); |
390 | } |
388 | } |
391 | 389 | ||
392 | static int init_fb(void) |
- | |
393 | { |
- | |
394 | __address fb_ph_addr; |
- | |
395 | unsigned int fb_width; |
- | |
396 | unsigned int fb_height; |
- | |
397 | unsigned int fb_bpp; |
- | |
398 | unsigned int fb_scanline; |
- | |
399 | __address fb_addr; |
- | |
400 | int a=0; |
- | |
401 | int i,j,k; |
- | |
402 | int w; |
- | |
403 | char text[]="HelenOS Framebuffer driver\non Virtual Framebuffer\nVFB "; |
- | |
404 | - | ||
405 | fb_ph_addr=sysinfo_value("fb.address.physical"); |
- | |
406 | fb_width=sysinfo_value("fb.width"); |
- | |
407 | fb_height=sysinfo_value("fb.height"); |
- | |
408 | fb_bpp=sysinfo_value("fb.bpp"); |
- | |
409 | fb_scanline=sysinfo_value("fb.scanline"); |
- | |
410 | - | ||
411 | fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE); |
- | |
412 | - | ||
413 | map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr, |
- | |
414 | (fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH, |
- | |
415 | AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); |
- | |
416 | - | ||
417 | screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline); |
- | |
418 | - | ||
419 | return 0; |
- | |
420 | } |
- | |
421 | - | ||
422 | static void draw_char(int vp, char c, unsigned int row, unsigned int col) |
390 | static void draw_char(int vp, char c, unsigned int row, unsigned int col) |
423 | { |
391 | { |
424 | viewport_t *vport = &viewports[vp]; |
392 | viewport_t *vport = &viewports[vp]; |
425 | 393 | ||
426 | if (vport->cursor_active && (vport->cur_col != col || vport->cur_row != row)) |
394 | if (vport->cursor_active && (vport->cur_col != col || vport->cur_row != row)) |
427 | invert_char(vp, vport->cur_row, vport->cur_col); |
395 | invert_char(vp, vport->cur_row, vport->cur_col); |
428 | 396 | ||
429 | draw_glyph(vp, c, row, col); |
397 | draw_glyph(vp, c, row, col); |
430 | 398 | ||
431 | vport->cur_col = col; |
399 | vport->cur_col = col; |
432 | vport->cur_row = row; |
400 | vport->cur_row = row; |
433 | 401 | ||
434 | vport->cur_col++; |
402 | vport->cur_col++; |
435 | if (vport->cur_col>= vport->cols) { |
403 | if (vport->cur_col>= vport->cols) { |
436 | vport->cur_col = 0; |
404 | vport->cur_col = 0; |
437 | vport->cur_row++; |
405 | vport->cur_row++; |
438 | if (vport->cur_row >= vport->rows) |
406 | if (vport->cur_row >= vport->rows) |
439 | vport->cur_row--; |
407 | vport->cur_row--; |
440 | } |
408 | } |
441 | if (vport->cursor_active) |
409 | if (vport->cursor_active) |
442 | invert_char(vp, vport->cur_row, vport->cur_col); |
410 | invert_char(vp, vport->cur_row, vport->cur_col); |
443 | } |
411 | } |
444 | 412 | ||
445 | void client_connection(ipc_callid_t iid, ipc_call_t *icall) |
413 | static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
446 | { |
414 | { |
447 | ipc_callid_t callid; |
415 | ipc_callid_t callid; |
448 | ipc_call_t call; |
416 | ipc_call_t call; |
449 | int retval; |
417 | int retval; |
450 | int i; |
418 | int i; |
451 | unsigned int row,col; |
419 | unsigned int row,col; |
452 | char c; |
420 | char c; |
453 | 421 | ||
454 | int vp = 0; |
422 | int vp = 0; |
455 | viewport_t *vport = &viewports[0]; |
423 | viewport_t *vport = &viewports[0]; |
456 | 424 | ||
457 | if (client_connected) { |
425 | if (client_connected) { |
458 | ipc_answer_fast(iid, ELIMIT, 0,0); |
426 | ipc_answer_fast(iid, ELIMIT, 0,0); |
459 | return; |
427 | return; |
460 | } |
428 | } |
461 | client_connected = 1; |
429 | client_connected = 1; |
462 | ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
430 | ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */ |
463 | 431 | ||
464 | while (1) { |
432 | while (1) { |
465 | callid = async_get_call(&call); |
433 | callid = async_get_call(&call); |
466 | switch (IPC_GET_METHOD(call)) { |
434 | switch (IPC_GET_METHOD(call)) { |
467 | case IPC_M_PHONE_HUNGUP: |
435 | case IPC_M_PHONE_HUNGUP: |
468 | client_connected = 0; |
436 | client_connected = 0; |
469 | /* cleanup other viewports */ |
437 | /* cleanup other viewports */ |
470 | for (i=1; i < MAX_VIEWPORTS; i++) |
438 | for (i=1; i < MAX_VIEWPORTS; i++) |
471 | vport->initialized = 0; |
439 | vport->initialized = 0; |
472 | ipc_answer_fast(callid,0,0,0); |
440 | ipc_answer_fast(callid,0,0,0); |
473 | return; /* Exit thread */ |
441 | return; /* Exit thread */ |
474 | case FB_PUTCHAR: |
442 | case FB_PUTCHAR: |
475 | c = IPC_GET_ARG1(call); |
443 | c = IPC_GET_ARG1(call); |
476 | row = IPC_GET_ARG2(call); |
444 | row = IPC_GET_ARG2(call); |
477 | col = IPC_GET_ARG3(call); |
445 | col = IPC_GET_ARG3(call); |
478 | if (row >= vport->rows || col >= vport->cols) { |
446 | if (row >= vport->rows || col >= vport->cols) { |
479 | retval = EINVAL; |
447 | retval = EINVAL; |
480 | break; |
448 | break; |
481 | } |
449 | } |
482 | ipc_answer_fast(callid,0,0,0); |
450 | ipc_answer_fast(callid,0,0,0); |
483 | 451 | ||
484 | draw_char(vp, c, row, col); |
452 | draw_char(vp, c, row, col); |
485 | continue; /* msg already answered */ |
453 | continue; /* msg already answered */ |
486 | case FB_CLEAR: |
454 | case FB_CLEAR: |
487 | clear_port(vp); |
455 | clear_port(vp); |
488 | if (vport->cursor_active) |
456 | if (vport->cursor_active) |
489 | invert_char(vp, vport->cur_row, vport->cur_col); |
457 | invert_char(vp, vport->cur_row, vport->cur_col); |
490 | retval = 0; |
458 | retval = 0; |
491 | break; |
459 | break; |
492 | case FB_CURSOR_GOTO: |
460 | case FB_CURSOR_GOTO: |
493 | row = IPC_GET_ARG1(call); |
461 | row = IPC_GET_ARG1(call); |
494 | col = IPC_GET_ARG2(call); |
462 | col = IPC_GET_ARG2(call); |
495 | if (row >= vport->rows || col >= vport->cols) { |
463 | if (row >= vport->rows || col >= vport->cols) { |
496 | retval = EINVAL; |
464 | retval = EINVAL; |
497 | break; |
465 | break; |
498 | } |
466 | } |
499 | retval = 0; |
467 | retval = 0; |
500 | if (viewports[vp].cursor_active) { |
468 | if (viewports[vp].cursor_active) { |
501 | invert_char(vp, vport->cur_row, vport->cur_col); |
469 | invert_char(vp, vport->cur_row, vport->cur_col); |
502 | invert_char(vp, row, col); |
470 | invert_char(vp, row, col); |
503 | } |
471 | } |
504 | vport->cur_col = col; |
472 | vport->cur_col = col; |
505 | vport->cur_row = row; |
473 | vport->cur_row = row; |
506 | break; |
474 | break; |
507 | case FB_CURSOR_VISIBILITY: |
475 | case FB_CURSOR_VISIBILITY: |
508 | i = IPC_GET_ARG1(call); |
476 | i = IPC_GET_ARG1(call); |
509 | retval = 0; |
477 | retval = 0; |
510 | if ((i && vport->cursor_active) || (!i && !vport->cursor_active)) |
478 | if ((i && vport->cursor_active) || (!i && !vport->cursor_active)) |
511 | break; |
479 | break; |
512 | 480 | ||
513 | vport->cursor_active = i; |
481 | vport->cursor_active = i; |
514 | invert_char(vp, vport->cur_row, vport->cur_col); |
482 | invert_char(vp, vport->cur_row, vport->cur_col); |
515 | break; |
483 | break; |
516 | case FB_GET_CSIZE: |
484 | case FB_GET_CSIZE: |
517 | ipc_answer_fast(callid, 0, vport->rows, vport->cols); |
485 | ipc_answer_fast(callid, 0, vport->rows, vport->cols); |
518 | continue; |
486 | continue; |
519 | case FB_SCROLL: |
487 | case FB_SCROLL: |
520 | i = IPC_GET_ARG1(call); |
488 | i = IPC_GET_ARG1(call); |
521 | if (i > vport->rows || i < (- (int)vport->rows)) { |
489 | if (i > vport->rows || i < (- (int)vport->rows)) { |
522 | retval = EINVAL; |
490 | retval = EINVAL; |
523 | break; |
491 | break; |
524 | } |
492 | } |
525 | if (vport->cursor_active) |
493 | if (vport->cursor_active) |
526 | invert_char(vp, vport->cur_row, vport->cur_col); |
494 | invert_char(vp, vport->cur_row, vport->cur_col); |
527 | scroll_port(vp, i); |
495 | scroll_port(vp, i); |
528 | if (vport->cursor_active) |
496 | if (vport->cursor_active) |
529 | invert_char(vp, vport->cur_row, vport->cur_col); |
497 | invert_char(vp, vport->cur_row, vport->cur_col); |
530 | retval = 0; |
498 | retval = 0; |
531 | break; |
499 | break; |
532 | case FB_VIEWPORT_SWITCH: |
500 | case FB_VIEWPORT_SWITCH: |
533 | i = IPC_GET_ARG1(call); |
501 | i = IPC_GET_ARG1(call); |
534 | if (i < 0 || i >= MAX_VIEWPORTS) { |
502 | if (i < 0 || i >= MAX_VIEWPORTS) { |
535 | retval = EINVAL; |
503 | retval = EINVAL; |
536 | break; |
504 | break; |
537 | } |
505 | } |
538 | if (! viewports[i].initialized ) { |
506 | if (! viewports[i].initialized ) { |
539 | retval = EADDRNOTAVAIL; |
507 | retval = EADDRNOTAVAIL; |
540 | break; |
508 | break; |
541 | } |
509 | } |
542 | vp = i; |
510 | vp = i; |
543 | vport = &viewports[vp]; |
511 | vport = &viewports[vp]; |
544 | retval = 0; |
512 | retval = 0; |
545 | break; |
513 | break; |
546 | case FB_VIEWPORT_CREATE: |
514 | case FB_VIEWPORT_CREATE: |
547 | retval = viewport_create(IPC_GET_ARG1(call) >> 16, |
515 | retval = viewport_create(IPC_GET_ARG1(call) >> 16, |
548 | IPC_GET_ARG1(call) & 0xffff, |
516 | IPC_GET_ARG1(call) & 0xffff, |
549 | IPC_GET_ARG2(call) >> 16, |
517 | IPC_GET_ARG2(call) >> 16, |
550 | IPC_GET_ARG2(call) & 0xffff); |
518 | IPC_GET_ARG2(call) & 0xffff); |
551 | break; |
519 | break; |
552 | case FB_VIEWPORT_DELETE: |
520 | case FB_VIEWPORT_DELETE: |
553 | i = IPC_GET_ARG1(call); |
521 | i = IPC_GET_ARG1(call); |
554 | if (i < 0 || i >= MAX_VIEWPORTS) { |
522 | if (i < 0 || i >= MAX_VIEWPORTS) { |
555 | retval = EINVAL; |
523 | retval = EINVAL; |
556 | break; |
524 | break; |
557 | } |
525 | } |
558 | if (! viewports[i].initialized ) { |
526 | if (! viewports[i].initialized ) { |
559 | retval = EADDRNOTAVAIL; |
527 | retval = EADDRNOTAVAIL; |
560 | break; |
528 | break; |
561 | } |
529 | } |
562 | viewports[i].initialized = 0; |
530 | viewports[i].initialized = 0; |
563 | retval = 0; |
531 | retval = 0; |
564 | break; |
532 | break; |
565 | case FB_SET_STYLE: |
533 | case FB_SET_STYLE: |
566 | vport->fgcolor = IPC_GET_ARG1(call); |
534 | vport->fgcolor = IPC_GET_ARG1(call); |
567 | vport->bgcolor = IPC_GET_ARG2(call); |
535 | vport->bgcolor = IPC_GET_ARG2(call); |
568 | retval = 0; |
536 | retval = 0; |
569 | break; |
537 | break; |
570 | case FB_GET_RESOLUTION: |
538 | case FB_GET_RESOLUTION: |
571 | ipc_answer_fast(callid, 0, screen.xres,screen.yres); |
539 | ipc_answer_fast(callid, 0, screen.xres,screen.yres); |
572 | continue; |
540 | continue; |
573 | default: |
541 | default: |
574 | retval = ENOENT; |
542 | retval = ENOENT; |
575 | } |
543 | } |
576 | ipc_answer_fast(callid,retval,0,0); |
544 | ipc_answer_fast(callid,retval,0,0); |
577 | } |
545 | } |
578 | } |
546 | } |
579 | 547 | ||
580 | int main(int argc, char *argv[]) |
548 | int fb_init(void) |
581 | { |
549 | { |
582 | char connected = 0; |
550 | __address fb_ph_addr; |
- | 551 | unsigned int fb_width; |
|
- | 552 | unsigned int fb_height; |
|
583 | int res; |
553 | unsigned int fb_bpp; |
- | 554 | unsigned int fb_scanline; |
|
584 | ipcarg_t phonead; |
555 | __address fb_addr; |
585 | 556 | ||
- | 557 | async_set_client_connection(fb_client_connection); |
|
- | 558 | ||
- | 559 | fb_ph_addr=sysinfo_value("fb.address.physical"); |
|
- | 560 | fb_width=sysinfo_value("fb.width"); |
|
- | 561 | fb_height=sysinfo_value("fb.height"); |
|
586 | if(!sysinfo_value("fb")) |
562 | fb_bpp=sysinfo_value("fb.bpp"); |
587 | return -1; |
563 | fb_scanline=sysinfo_value("fb.scanline"); |
588 | 564 | ||
589 | if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead)) != 0) |
565 | fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE); |
590 | return -1; |
- | |
591 | 566 | ||
- | 567 | map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr, |
|
592 | if (init_fb() != 0) |
568 | (fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH, |
- | 569 | AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); |
|
593 | return -1; |
570 | |
- | 571 | screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline); |
|
594 | 572 | ||
595 | async_manager(); |
- | |
596 | /* Never reached */ |
- | |
597 | return 0; |
573 | return 0; |
598 | } |
574 | } |
- | 575 | ||
599 | 576 |