Rev 4338 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4338 | Rev 4691 | ||
---|---|---|---|
Line 25... | Line 25... | ||
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 | /** @addtogroup console |
29 | /** @addtogroup console |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #include <ipc/fb.h> |
35 | #include <ipc/fb.h> |
Line 37... | Line 37... | ||
37 | #include <async.h> |
37 | #include <async.h> |
38 | #include <stdio.h> |
38 | #include <stdio.h> |
39 | #include <sys/mman.h> |
39 | #include <sys/mman.h> |
40 | #include <string.h> |
40 | #include <string.h> |
41 | #include <align.h> |
41 | #include <align.h> |
- | 42 | #include <bool.h> |
|
42 | 43 | ||
43 | #include "console.h" |
44 | #include "console.h" |
44 | #include "gcons.h" |
45 | #include "gcons.h" |
45 | 46 | ||
46 | #define CONSOLE_TOP 66 |
47 | #define CONSOLE_TOP 66 |
47 | #define CONSOLE_MARGIN 6 |
48 | #define CONSOLE_MARGIN 6 |
48 | 49 | ||
49 | #define STATUS_START 110 |
50 | #define STATUS_START 110 |
50 | #define STATUS_TOP 8 |
51 | #define STATUS_TOP 8 |
51 | #define STATUS_SPACE 4 |
52 | #define STATUS_SPACE 4 |
52 | #define STATUS_WIDTH 48 |
53 | #define STATUS_WIDTH 48 |
53 | #define STATUS_HEIGHT 48 |
54 | #define STATUS_HEIGHT 48 |
54 | 55 | ||
55 | #define MAIN_COLOR 0xffffff |
56 | #define MAIN_COLOR 0xffffff |
56 | 57 | ||
57 | static int use_gcons = 0; |
58 | static bool use_gcons = false; |
- | 59 | static ipcarg_t xres; |
|
58 | static ipcarg_t xres,yres; |
60 | static ipcarg_t yres; |
59 | 61 | ||
60 | enum butstate { |
62 | enum butstate { |
61 | CONS_DISCONNECTED = 0, |
63 | CONS_DISCONNECTED = 0, |
62 | CONS_SELECTED, |
64 | CONS_SELECTED, |
63 | CONS_IDLE, |
65 | CONS_IDLE, |
Line 75... | Line 77... | ||
75 | 77 | ||
76 | /** List of pixmaps identifying these icons */ |
78 | /** List of pixmaps identifying these icons */ |
77 | static int ic_pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1}; |
79 | static int ic_pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1}; |
78 | static int animation = -1; |
80 | static int animation = -1; |
79 | 81 | ||
80 | static int active_console = 0; |
82 | static size_t active_console = 0; |
- | 83 | ||
- | 84 | size_t mouse_x; |
|
- | 85 | size_t mouse_y; |
|
- | 86 | ||
- | 87 | bool btn_pressed; |
|
- | 88 | size_t btn_x; |
|
- | 89 | size_t btn_y; |
|
81 | 90 | ||
82 | static void vp_switch(int vp) |
91 | static void vp_switch(int vp) |
83 | { |
92 | { |
84 | async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp); |
93 | async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp); |
85 | } |
94 | } |
86 | 95 | ||
87 | /** Create view port */ |
96 | /** Create view port */ |
88 | static int vp_create(unsigned int x, unsigned int y, unsigned int width, |
97 | static int vp_create(size_t x, size_t y, size_t width, size_t height) |
89 | unsigned int height) |
- | |
90 | { |
98 | { |
91 | return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y, |
99 | return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y, |
92 | (width << 16) | height); |
100 | (width << 16) | height); |
93 | } |
101 | } |
94 | 102 | ||
95 | static void clear(void) |
103 | static void clear(void) |
96 | { |
104 | { |
97 | async_msg_0(fbphone, FB_CLEAR); |
105 | async_msg_0(fbphone, FB_CLEAR); |
98 | } |
106 | } |
99 | 107 | ||
100 | static void set_rgb_color(int fgcolor, int bgcolor) |
108 | static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor) |
101 | { |
109 | { |
102 | async_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor); |
110 | async_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor); |
103 | } |
111 | } |
104 | 112 | ||
105 | /** Transparent putchar */ |
113 | /** Transparent putchar */ |
106 | static void tran_putch(char c, int row, int col) |
114 | static void tran_putch(wchar_t ch, size_t col, size_t row) |
107 | { |
115 | { |
108 | async_msg_3(fbphone, FB_PUTCHAR, c, row, col); |
116 | async_msg_3(fbphone, FB_PUTCHAR, ch, col, row); |
109 | } |
117 | } |
110 | 118 | ||
111 | /** Redraw the button showing state of a given console */ |
119 | /** Redraw the button showing state of a given console */ |
112 | static void redraw_state(int consnum) |
120 | static void redraw_state(size_t index) |
113 | { |
121 | { |
114 | char data[5]; |
122 | vp_switch(cstatus_vp[index]); |
115 | int i; |
123 | |
116 | enum butstate state = console_state[consnum]; |
124 | enum butstate state = console_state[index]; |
117 | 125 | ||
118 | vp_switch(cstatus_vp[consnum]); |
- | |
119 | if (ic_pixmaps[state] != -1) |
126 | if (ic_pixmaps[state] != -1) |
120 | async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], |
127 | async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index], |
121 | ic_pixmaps[state]); |
128 | ic_pixmaps[state]); |
122 | 129 | ||
123 | if (state != CONS_DISCONNECTED && state != CONS_KERNEL && |
130 | if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL) |
124 | state != CONS_DISCONNECTED_SEL) { |
131 | && (state != CONS_DISCONNECTED_SEL)) { |
- | 132 | ||
- | 133 | char data[5]; |
|
125 | snprintf(data, 5, "%d", consnum + 1); |
134 | snprintf(data, 5, "%u", index + 1); |
- | 135 | ||
- | 136 | size_t i; |
|
126 | for (i = 0; data[i]; i++) |
137 | for (i = 0; data[i] != 0; i++) |
127 | tran_putch(data[i], 1, 2 + i); |
138 | tran_putch(data[i], 2 + i, 1); |
128 | } |
139 | } |
129 | } |
140 | } |
130 | 141 | ||
131 | /** Notification run on changing console (except kernel console) */ |
142 | /** Notification run on changing console (except kernel console) */ |
132 | void gcons_change_console(int consnum) |
143 | void gcons_change_console(size_t index) |
133 | { |
144 | { |
134 | int i; |
- | |
135 | - | ||
136 | if (!use_gcons) |
145 | if (!use_gcons) |
137 | return; |
146 | return; |
138 | 147 | ||
139 | if (active_console == KERNEL_CONSOLE) { |
148 | if (active_console == KERNEL_CONSOLE) { |
- | 149 | size_t i; |
|
- | 150 | ||
140 | for (i = 0; i < CONSOLE_COUNT; i++) |
151 | for (i = 0; i < CONSOLE_COUNT; i++) |
141 | redraw_state(i); |
152 | redraw_state(i); |
- | 153 | ||
142 | if (animation != -1) |
154 | if (animation != -1) |
143 | async_msg_1(fbphone, FB_ANIM_START, animation); |
155 | async_msg_1(fbphone, FB_ANIM_START, animation); |
144 | } else { |
156 | } else { |
145 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
157 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
146 | console_state[active_console] = CONS_DISCONNECTED; |
158 | console_state[active_console] = CONS_DISCONNECTED; |
147 | else |
159 | else |
148 | console_state[active_console] = CONS_IDLE; |
160 | console_state[active_console] = CONS_IDLE; |
- | 161 | ||
149 | redraw_state(active_console); |
162 | redraw_state(active_console); |
150 | } |
163 | } |
- | 164 | ||
151 | active_console = consnum; |
165 | active_console = index; |
152 | 166 | ||
153 | if (console_state[consnum] == CONS_DISCONNECTED) { |
167 | if ((console_state[index] == CONS_DISCONNECTED) |
154 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
168 | || (console_state[index] == CONS_DISCONNECTED_SEL)) |
155 | redraw_state(consnum); |
169 | console_state[index] = CONS_DISCONNECTED_SEL; |
156 | } else |
170 | else |
157 | console_state[consnum] = CONS_SELECTED; |
171 | console_state[index] = CONS_SELECTED; |
- | 172 | ||
158 | redraw_state(consnum); |
173 | redraw_state(index); |
159 | - | ||
160 | vp_switch(console_vp); |
174 | vp_switch(console_vp); |
161 | } |
175 | } |
162 | 176 | ||
163 | /** Notification function that gets called on new output to virtual console */ |
177 | /** Notification function that gets called on new output to virtual console */ |
164 | void gcons_notify_char(int consnum) |
178 | void gcons_notify_char(size_t index) |
165 | { |
179 | { |
166 | if (!use_gcons) |
180 | if (!use_gcons) |
167 | return; |
181 | return; |
168 | 182 | ||
169 | if (consnum == active_console || |
183 | if ((index == active_console) |
170 | console_state[consnum] == CONS_HAS_DATA) |
184 | || (console_state[index] == CONS_HAS_DATA)) |
171 | return; |
185 | return; |
172 | 186 | ||
173 | console_state[consnum] = CONS_HAS_DATA; |
187 | console_state[index] = CONS_HAS_DATA; |
174 | 188 | ||
175 | if (active_console == KERNEL_CONSOLE) |
189 | if (active_console == KERNEL_CONSOLE) |
176 | return; |
190 | return; |
177 | - | ||
178 | redraw_state(consnum); |
- | |
179 | 191 | ||
- | 192 | redraw_state(index); |
|
180 | vp_switch(console_vp); |
193 | vp_switch(console_vp); |
181 | } |
194 | } |
182 | 195 | ||
183 | /** Notification function called on service disconnect from console */ |
196 | /** Notification function called on service disconnect from console */ |
184 | void gcons_notify_disconnect(int consnum) |
197 | void gcons_notify_disconnect(size_t index) |
185 | { |
198 | { |
186 | if (!use_gcons) |
199 | if (!use_gcons) |
187 | return; |
200 | return; |
- | 201 | ||
188 | if (active_console == consnum) |
202 | if (index == active_console) |
189 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
203 | console_state[index] = CONS_DISCONNECTED_SEL; |
190 | else |
204 | else |
191 | console_state[consnum] = CONS_DISCONNECTED; |
205 | console_state[index] = CONS_DISCONNECTED; |
192 | 206 | ||
193 | if (active_console == KERNEL_CONSOLE) |
207 | if (active_console == KERNEL_CONSOLE) |
194 | return; |
208 | return; |
195 | 209 | ||
196 | redraw_state(consnum); |
210 | redraw_state(index); |
197 | vp_switch(console_vp); |
211 | vp_switch(console_vp); |
198 | } |
212 | } |
199 | 213 | ||
200 | /** Notification function called on console connect */ |
214 | /** Notification function called on console connect */ |
201 | void gcons_notify_connect(int consnum) |
215 | void gcons_notify_connect(size_t index) |
202 | { |
216 | { |
203 | if (!use_gcons) |
217 | if (!use_gcons) |
204 | return; |
218 | return; |
- | 219 | ||
205 | if (active_console == consnum) |
220 | if (index == active_console) |
206 | console_state[consnum] = CONS_SELECTED; |
221 | console_state[index] = CONS_SELECTED; |
207 | else |
222 | else |
208 | console_state[consnum] = CONS_IDLE; |
223 | console_state[index] = CONS_IDLE; |
209 | 224 | ||
210 | if (active_console == KERNEL_CONSOLE) |
225 | if (active_console == KERNEL_CONSOLE) |
211 | return; |
226 | return; |
212 | 227 | ||
213 | redraw_state(consnum); |
228 | redraw_state(index); |
214 | vp_switch(console_vp); |
229 | vp_switch(console_vp); |
215 | } |
230 | } |
216 | 231 | ||
217 | /** Change to kernel console */ |
232 | /** Change to kernel console */ |
218 | void gcons_in_kernel(void) |
233 | void gcons_in_kernel(void) |
Line 222... | Line 237... | ||
222 | 237 | ||
223 | active_console = KERNEL_CONSOLE; |
238 | active_console = KERNEL_CONSOLE; |
224 | vp_switch(0); |
239 | vp_switch(0); |
225 | } |
240 | } |
226 | 241 | ||
227 | /** Return x, where left <= x <= right && |a-x|==min(|a-x|) is smallest */ |
242 | /** Return x, where left <= x <= right && |a-x| == min(|a-x|) is smallest */ |
228 | static inline int limit(int a,int left, int right) |
243 | static inline int limit(size_t a, size_t left, size_t right) |
229 | { |
244 | { |
230 | if (a < left) |
245 | if (a < left) |
231 | a = left; |
246 | a = left; |
- | 247 | ||
232 | if (a >= right) |
248 | if (a >= right) |
233 | a = right - 1; |
249 | a = right - 1; |
- | 250 | ||
234 | return a; |
251 | return a; |
235 | } |
252 | } |
236 | 253 | ||
237 | int mouse_x, mouse_y; |
- | |
238 | int btn_pressed, btn_x, btn_y; |
- | |
239 | - | ||
240 | /** Handle mouse move |
254 | /** Handle mouse move |
241 | * |
255 | * |
242 | * @param dx Delta X of mouse move |
256 | * @param dx Delta X of mouse move |
243 | * @param dy Delta Y of mouse move |
257 | * @param dy Delta Y of mouse move |
244 | */ |
258 | */ |
245 | void gcons_mouse_move(int dx, int dy) |
259 | void gcons_mouse_move(ssize_t dx, ssize_t dy) |
246 | { |
260 | { |
247 | mouse_x = limit(mouse_x + dx, 0, xres); |
261 | mouse_x = limit(mouse_x + dx, 0, xres); |
248 | mouse_y = limit(mouse_y + dy, 0, yres); |
262 | mouse_y = limit(mouse_y + dy, 0, yres); |
249 | 263 | ||
250 | async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); |
264 | async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); |
251 | } |
265 | } |
252 | 266 | ||
253 | static int gcons_find_conbut(int x, int y) |
267 | static int gcons_find_conbut(int x, int y) |
254 | { |
268 | { |
255 | int status_start = STATUS_START + (xres - 800) / 2; |
269 | int status_start = STATUS_START + (xres - 800) / 2; |
256 | 270 | ||
257 | if (y < STATUS_TOP || y >= STATUS_TOP + STATUS_HEIGHT) |
271 | if ((y < STATUS_TOP) || (y >= STATUS_TOP + STATUS_HEIGHT)) |
258 | return -1; |
272 | return -1; |
259 | 273 | ||
260 | if (x < status_start) |
274 | if (x < status_start) |
261 | return -1; |
275 | return -1; |
262 | 276 | ||
Line 268... | Line 282... | ||
268 | return (x - status_start) / (STATUS_WIDTH + STATUS_SPACE); |
282 | return (x - status_start) / (STATUS_WIDTH + STATUS_SPACE); |
269 | } |
283 | } |
270 | 284 | ||
271 | /** Handle mouse click |
285 | /** Handle mouse click |
272 | * |
286 | * |
273 | * @param state New state (1-pressed, 0-depressed) |
287 | * @param state New state (true - pressed, false - depressed) |
274 | */ |
288 | */ |
275 | int gcons_mouse_btn(int state) |
289 | int gcons_mouse_btn(bool state) |
276 | { |
290 | { |
277 | int conbut; |
291 | int conbut; |
278 | 292 | ||
279 | if (state) { |
293 | if (state) { |
280 | conbut = gcons_find_conbut(mouse_x, mouse_y); |
294 | conbut = gcons_find_conbut(mouse_x, mouse_y); |
281 | if (conbut != -1) { |
295 | if (conbut != -1) { |
282 | btn_pressed = 1; |
296 | btn_pressed = true; |
283 | btn_x = mouse_x; |
297 | btn_x = mouse_x; |
284 | btn_y = mouse_y; |
298 | btn_y = mouse_y; |
285 | } |
299 | } |
286 | return -1; |
300 | return -1; |
287 | } |
301 | } |
- | 302 | ||
288 | if (!state && !btn_pressed) |
303 | if ((!state) && (!btn_pressed)) |
289 | return -1; |
304 | return -1; |
- | 305 | ||
290 | btn_pressed = 0; |
306 | btn_pressed = false; |
291 | 307 | ||
292 | conbut = gcons_find_conbut(mouse_x, mouse_y); |
308 | conbut = gcons_find_conbut(mouse_x, mouse_y); |
293 | if (conbut == gcons_find_conbut(btn_x, btn_y)) |
309 | if (conbut == gcons_find_conbut(btn_x, btn_y)) |
294 | return conbut; |
310 | return conbut; |
- | 311 | ||
295 | return -1; |
312 | return -1; |
296 | } |
313 | } |
297 | 314 | ||
298 | 315 | ||
299 | /** Draw a PPM pixmap to framebuffer |
316 | /** Draw a PPM pixmap to framebuffer |
Line 305... | Line 322... | ||
305 | */ |
322 | */ |
306 | static void draw_pixmap(char *logo, size_t size, int x, int y) |
323 | static void draw_pixmap(char *logo, size_t size, int x, int y) |
307 | { |
324 | { |
308 | char *shm; |
325 | char *shm; |
309 | int rc; |
326 | int rc; |
310 | 327 | ||
311 | /* Create area */ |
328 | /* Create area */ |
312 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | |
329 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | |
313 | MAP_ANONYMOUS, 0, 0); |
330 | MAP_ANONYMOUS, 0, 0); |
314 | if (shm == MAP_FAILED) |
331 | if (shm == MAP_FAILED) |
315 | return; |
332 | return; |
316 | 333 | ||
317 | memcpy(shm, logo, size); |
334 | memcpy(shm, logo, size); |
- | 335 | ||
318 | /* Send area */ |
336 | /* Send area */ |
319 | rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); |
337 | rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); |
320 | if (rc) |
338 | if (rc) |
321 | goto exit; |
339 | goto exit; |
- | 340 | ||
322 | rc = ipc_share_out_start(fbphone, shm, PROTO_READ); |
341 | rc = ipc_share_out_start(fbphone, shm, PROTO_READ); |
323 | if (rc) |
342 | if (rc) |
324 | goto drop; |
343 | goto drop; |
- | 344 | ||
325 | /* Draw logo */ |
345 | /* Draw logo */ |
326 | async_msg_2(fbphone, FB_DRAW_PPM, x, y); |
346 | async_msg_2(fbphone, FB_DRAW_PPM, x, y); |
- | 347 | ||
327 | drop: |
348 | drop: |
328 | /* Drop area */ |
349 | /* Drop area */ |
329 | async_msg_0(fbphone, FB_DROP_SHM); |
350 | async_msg_0(fbphone, FB_DROP_SHM); |
- | 351 | ||
330 | exit: |
352 | exit: |
331 | /* Remove area */ |
353 | /* Remove area */ |
332 | munmap(shm, size); |
354 | munmap(shm, size); |
333 | } |
355 | } |
334 | 356 | ||
335 | extern char _binary_helenos_ppm_start[0]; |
357 | extern char _binary_gfx_helenos_ppm_start[0]; |
336 | extern int _binary_helenos_ppm_size; |
358 | extern int _binary_gfx_helenos_ppm_size; |
337 | extern char _binary_nameic_ppm_start[0]; |
359 | extern char _binary_gfx_nameic_ppm_start[0]; |
338 | extern int _binary_nameic_ppm_size; |
360 | extern int _binary_gfx_nameic_ppm_size; |
339 | 361 | ||
340 | /** Redraws console graphics */ |
362 | /** Redraws console graphics */ |
341 | void gcons_redraw_console(void) |
363 | void gcons_redraw_console(void) |
342 | { |
364 | { |
343 | int i; |
365 | int i; |
Line 346... | Line 368... | ||
346 | return; |
368 | return; |
347 | 369 | ||
348 | vp_switch(0); |
370 | vp_switch(0); |
349 | set_rgb_color(MAIN_COLOR, MAIN_COLOR); |
371 | set_rgb_color(MAIN_COLOR, MAIN_COLOR); |
350 | clear(); |
372 | clear(); |
351 | draw_pixmap(_binary_helenos_ppm_start, |
373 | draw_pixmap(_binary_gfx_helenos_ppm_start, |
352 | (size_t) &_binary_helenos_ppm_size, xres - 66, 2); |
374 | (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2); |
353 | draw_pixmap(_binary_nameic_ppm_start, |
375 | draw_pixmap(_binary_gfx_nameic_ppm_start, |
354 | (size_t) &_binary_nameic_ppm_size, 5, 17); |
376 | (size_t) &_binary_gfx_nameic_ppm_size, 5, 17); |
355 | 377 | ||
356 | for (i = 0; i < CONSOLE_COUNT; i++) |
378 | for (i = 0; i < CONSOLE_COUNT; i++) |
357 | redraw_state(i); |
379 | redraw_state(i); |
- | 380 | ||
358 | vp_switch(console_vp); |
381 | vp_switch(console_vp); |
359 | } |
382 | } |
360 | 383 | ||
361 | /** Creates a pixmap on framebuffer |
384 | /** Creates a pixmap on framebuffer |
362 | * |
385 | * |
363 | * @param data PPM data |
386 | * @param data PPM data |
364 | * @param size PPM data size |
387 | * @param size PPM data size |
- | 388 | * |
|
365 | * @return Pixmap identification |
389 | * @return Pixmap identification |
- | 390 | * |
|
366 | */ |
391 | */ |
367 | static int make_pixmap(char *data, int size) |
392 | static int make_pixmap(char *data, size_t size) |
368 | { |
393 | { |
369 | char *shm; |
394 | char *shm; |
370 | int rc; |
395 | int rc; |
371 | int pxid = -1; |
396 | int pxid = -1; |
372 | 397 | ||
373 | /* Create area */ |
398 | /* Create area */ |
374 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | |
399 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | |
375 | MAP_ANONYMOUS, 0, 0); |
400 | MAP_ANONYMOUS, 0, 0); |
376 | if (shm == MAP_FAILED) |
401 | if (shm == MAP_FAILED) |
377 | return -1; |
402 | return -1; |
378 | 403 | ||
379 | memcpy(shm, data, size); |
404 | memcpy(shm, data, size); |
- | 405 | ||
380 | /* Send area */ |
406 | /* Send area */ |
381 | rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); |
407 | rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); |
382 | if (rc) |
408 | if (rc) |
383 | goto exit; |
409 | goto exit; |
- | 410 | ||
384 | rc = ipc_share_out_start(fbphone, shm, PROTO_READ); |
411 | rc = ipc_share_out_start(fbphone, shm, PROTO_READ); |
385 | if (rc) |
412 | if (rc) |
386 | goto drop; |
413 | goto drop; |
387 | 414 | ||
388 | /* Obtain pixmap */ |
415 | /* Obtain pixmap */ |
389 | rc = async_req_0_0(fbphone, FB_SHM2PIXMAP); |
416 | rc = async_req_0_0(fbphone, FB_SHM2PIXMAP); |
390 | if (rc < 0) |
417 | if (rc < 0) |
391 | goto drop; |
418 | goto drop; |
- | 419 | ||
392 | pxid = rc; |
420 | pxid = rc; |
- | 421 | ||
393 | drop: |
422 | drop: |
394 | /* Drop area */ |
423 | /* Drop area */ |
395 | async_msg_0(fbphone, FB_DROP_SHM); |
424 | async_msg_0(fbphone, FB_DROP_SHM); |
- | 425 | ||
396 | exit: |
426 | exit: |
397 | /* Remove area */ |
427 | /* Remove area */ |
398 | munmap(shm, size); |
428 | munmap(shm, size); |
399 | 429 | ||
400 | return pxid; |
430 | return pxid; |
401 | } |
431 | } |
402 | 432 | ||
403 | extern char _binary_anim_1_ppm_start[0]; |
433 | extern char _binary_gfx_anim_1_ppm_start[0]; |
404 | extern int _binary_anim_1_ppm_size; |
434 | extern int _binary_gfx_anim_1_ppm_size; |
405 | extern char _binary_anim_2_ppm_start[0]; |
435 | extern char _binary_gfx_anim_2_ppm_start[0]; |
406 | extern int _binary_anim_2_ppm_size; |
436 | extern int _binary_gfx_anim_2_ppm_size; |
407 | extern char _binary_anim_3_ppm_start[0]; |
437 | extern char _binary_gfx_anim_3_ppm_start[0]; |
408 | extern int _binary_anim_3_ppm_size; |
438 | extern int _binary_gfx_anim_3_ppm_size; |
409 | extern char _binary_anim_4_ppm_start[0]; |
439 | extern char _binary_gfx_anim_4_ppm_start[0]; |
410 | extern int _binary_anim_4_ppm_size; |
440 | extern int _binary_gfx_anim_4_ppm_size; |
411 | 441 | ||
412 | static void make_anim(void) |
442 | static void make_anim(void) |
413 | { |
443 | { |
414 | int an; |
- | |
415 | int pm; |
- | |
416 | - | ||
417 | an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); |
444 | int an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); |
418 | if (an < 0) |
445 | if (an < 0) |
419 | return; |
446 | return; |
420 | 447 | ||
421 | pm = make_pixmap(_binary_anim_1_ppm_start, |
448 | int pm = make_pixmap(_binary_gfx_anim_1_ppm_start, |
422 | (int) &_binary_anim_1_ppm_size); |
449 | (int) &_binary_gfx_anim_1_ppm_size); |
423 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
450 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
424 | 451 | ||
425 | pm = make_pixmap(_binary_anim_2_ppm_start, |
452 | pm = make_pixmap(_binary_gfx_anim_2_ppm_start, |
426 | (int) &_binary_anim_2_ppm_size); |
453 | (int) &_binary_gfx_anim_2_ppm_size); |
427 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
454 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
428 | 455 | ||
429 | pm = make_pixmap(_binary_anim_3_ppm_start, |
456 | pm = make_pixmap(_binary_gfx_anim_3_ppm_start, |
430 | (int) &_binary_anim_3_ppm_size); |
457 | (int) &_binary_gfx_anim_3_ppm_size); |
431 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
458 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
432 | 459 | ||
433 | pm = make_pixmap(_binary_anim_4_ppm_start, |
460 | pm = make_pixmap(_binary_gfx_anim_4_ppm_start, |
434 | (int) &_binary_anim_4_ppm_size); |
461 | (int) &_binary_gfx_anim_4_ppm_size); |
435 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
462 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
436 | 463 | ||
437 | async_msg_1(fbphone, FB_ANIM_START, an); |
464 | async_msg_1(fbphone, FB_ANIM_START, an); |
438 | 465 | ||
439 | animation = an; |
466 | animation = an; |
440 | } |
467 | } |
441 | 468 | ||
442 | extern char _binary_cons_selected_ppm_start[0]; |
469 | extern char _binary_gfx_cons_selected_ppm_start[0]; |
443 | extern int _binary_cons_selected_ppm_size; |
470 | extern int _binary_gfx_cons_selected_ppm_size; |
444 | extern char _binary_cons_idle_ppm_start[0]; |
471 | extern char _binary_gfx_cons_idle_ppm_start[0]; |
445 | extern int _binary_cons_idle_ppm_size; |
472 | extern int _binary_gfx_cons_idle_ppm_size; |
446 | extern char _binary_cons_has_data_ppm_start[0]; |
473 | extern char _binary_gfx_cons_has_data_ppm_start[0]; |
447 | extern int _binary_cons_has_data_ppm_size; |
474 | extern int _binary_gfx_cons_has_data_ppm_size; |
448 | extern char _binary_cons_kernel_ppm_start[0]; |
475 | extern char _binary_gfx_cons_kernel_ppm_start[0]; |
449 | extern int _binary_cons_kernel_ppm_size; |
476 | extern int _binary_gfx_cons_kernel_ppm_size; |
450 | 477 | ||
451 | /** Initialize nice graphical console environment */ |
478 | /** Initialize nice graphical console environment */ |
452 | void gcons_init(int phone) |
479 | void gcons_init(int phone) |
453 | { |
480 | { |
454 | int rc; |
- | |
455 | int i; |
- | |
456 | int status_start = STATUS_START; |
- | |
457 | - | ||
458 | fbphone = phone; |
481 | fbphone = phone; |
459 | 482 | ||
460 | rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres); |
483 | int rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres); |
461 | if (rc) |
484 | if (rc) |
462 | return; |
485 | return; |
463 | 486 | ||
464 | if ((xres < 800) || (yres < 600)) |
487 | if ((xres < 800) || (yres < 600)) |
465 | return; |
488 | return; |
466 | 489 | ||
467 | /* create console viewport */ |
490 | /* Create console viewport */ |
- | 491 | ||
468 | /* Align width & height to character size */ |
492 | /* Align width & height to character size */ |
469 | console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
493 | console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
470 | ALIGN_DOWN(xres - 2 * CONSOLE_MARGIN, 8), |
494 | ALIGN_DOWN(xres - 2 * CONSOLE_MARGIN, 8), |
471 | ALIGN_DOWN(yres - (CONSOLE_TOP + CONSOLE_MARGIN), 16)); |
495 | ALIGN_DOWN(yres - (CONSOLE_TOP + CONSOLE_MARGIN), 16)); |
- | 496 | ||
472 | if (console_vp < 0) |
497 | if (console_vp < 0) |
473 | return; |
498 | return; |
474 | 499 | ||
475 | /* Create status buttons */ |
500 | /* Create status buttons */ |
476 | status_start += (xres - 800) / 2; |
501 | size_t status_start = STATUS_START + (xres - 800) / 2; |
- | 502 | size_t i; |
|
477 | for (i = 0; i < CONSOLE_COUNT; i++) { |
503 | for (i = 0; i < CONSOLE_COUNT; i++) { |
478 | cstatus_vp[i] = vp_create(status_start + CONSOLE_MARGIN + |
504 | cstatus_vp[i] = vp_create(status_start + CONSOLE_MARGIN + |
479 | i * (STATUS_WIDTH + STATUS_SPACE), STATUS_TOP, |
505 | i * (STATUS_WIDTH + STATUS_SPACE), STATUS_TOP, |
480 | STATUS_WIDTH, STATUS_HEIGHT); |
506 | STATUS_WIDTH, STATUS_HEIGHT); |
- | 507 | ||
481 | if (cstatus_vp[i] < 0) |
508 | if (cstatus_vp[i] < 0) |
482 | return; |
509 | return; |
- | 510 | ||
483 | vp_switch(cstatus_vp[i]); |
511 | vp_switch(cstatus_vp[i]); |
484 | set_rgb_color(0x202020, 0xffffff); |
512 | set_rgb_color(0x202020, 0xffffff); |
485 | } |
513 | } |
486 | 514 | ||
487 | /* Initialize icons */ |
515 | /* Initialize icons */ |
488 | ic_pixmaps[CONS_SELECTED] = |
516 | ic_pixmaps[CONS_SELECTED] = |
489 | make_pixmap(_binary_cons_selected_ppm_start, |
517 | make_pixmap(_binary_gfx_cons_selected_ppm_start, |
490 | (int) &_binary_cons_selected_ppm_size); |
518 | (size_t) &_binary_gfx_cons_selected_ppm_size); |
- | 519 | ic_pixmaps[CONS_IDLE] = |
|
491 | ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, |
520 | make_pixmap(_binary_gfx_cons_idle_ppm_start, |
492 | (int) &_binary_cons_idle_ppm_size); |
521 | (size_t) &_binary_gfx_cons_idle_ppm_size); |
493 | ic_pixmaps[CONS_HAS_DATA] = |
522 | ic_pixmaps[CONS_HAS_DATA] = |
494 | make_pixmap(_binary_cons_has_data_ppm_start, |
523 | make_pixmap(_binary_gfx_cons_has_data_ppm_start, |
495 | (int) &_binary_cons_has_data_ppm_size); |
524 | (size_t) &_binary_gfx_cons_has_data_ppm_size); |
496 | ic_pixmaps[CONS_DISCONNECTED] = |
525 | ic_pixmaps[CONS_DISCONNECTED] = |
497 | make_pixmap(_binary_cons_idle_ppm_start, |
526 | make_pixmap(_binary_gfx_cons_idle_ppm_start, |
498 | (int) &_binary_cons_idle_ppm_size); |
527 | (size_t) &_binary_gfx_cons_idle_ppm_size); |
- | 528 | ic_pixmaps[CONS_KERNEL] = |
|
499 | ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, |
529 | make_pixmap(_binary_gfx_cons_kernel_ppm_start, |
500 | (int) &_binary_cons_kernel_ppm_size); |
530 | (size_t) &_binary_gfx_cons_kernel_ppm_size); |
501 | ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
531 | ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
502 | 532 | ||
503 | make_anim(); |
533 | make_anim(); |
504 | 534 | ||
505 | use_gcons = 1; |
535 | use_gcons = true; |
506 | console_state[0] = CONS_DISCONNECTED_SEL; |
536 | console_state[0] = CONS_DISCONNECTED_SEL; |
507 | console_state[KERNEL_CONSOLE] = CONS_KERNEL; |
537 | console_state[KERNEL_CONSOLE] = CONS_KERNEL; |
- | 538 | ||
508 | gcons_redraw_console(); |
539 | vp_switch(console_vp); |
509 | } |
540 | } |
510 | 541 | ||
511 | /** @} |
542 | /** @} |
512 | */ |
543 | */ |