Rev 1668 | Rev 1707 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1668 | Rev 1689 | ||
---|---|---|---|
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 | /** @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> |
36 | #include <ipc/ipc.h> |
36 | #include <ipc/ipc.h> |
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 | 42 | ||
43 | #include "console.h" |
43 | #include "console.h" |
44 | #include "gcons.h" |
44 | #include "gcons.h" |
45 | 45 | ||
46 | #define CONSOLE_TOP 66 |
46 | #define CONSOLE_TOP 66 |
47 | #define CONSOLE_MARGIN 6 |
47 | #define CONSOLE_MARGIN 6 |
48 | 48 | ||
49 | #define STATUS_START 110 |
49 | #define STATUS_START 110 |
50 | #define STATUS_TOP 8 |
50 | #define STATUS_TOP 8 |
51 | #define STATUS_SPACE 4 |
51 | #define STATUS_SPACE 4 |
52 | #define STATUS_WIDTH 48 |
52 | #define STATUS_WIDTH 48 |
53 | #define STATUS_HEIGHT 48 |
53 | #define STATUS_HEIGHT 48 |
54 | 54 | ||
55 | #define MAIN_COLOR 0xffffff |
55 | #define MAIN_COLOR 0xffffff |
56 | 56 | ||
57 | static int use_gcons = 0; |
57 | static int use_gcons = 0; |
58 | static ipcarg_t xres,yres; |
58 | static ipcarg_t xres,yres; |
59 | 59 | ||
60 | enum butstate { |
60 | enum butstate { |
61 | CONS_DISCONNECTED = 0, |
61 | CONS_DISCONNECTED = 0, |
62 | CONS_SELECTED, |
62 | CONS_SELECTED, |
63 | CONS_IDLE, |
63 | CONS_IDLE, |
64 | CONS_HAS_DATA, |
64 | CONS_HAS_DATA, |
65 | CONS_KERNEL, |
65 | CONS_KERNEL, |
66 | CONS_DISCONNECTED_SEL, |
66 | CONS_DISCONNECTED_SEL, |
67 | CONS_LAST |
67 | CONS_LAST |
68 | }; |
68 | }; |
69 | 69 | ||
70 | static int console_vp; |
70 | static int console_vp; |
71 | static int cstatus_vp[CONSOLE_COUNT]; |
71 | static int cstatus_vp[CONSOLE_COUNT]; |
72 | static int cstat_row, cstat_col; /* Size of cstatus buttons */ |
72 | static int cstat_row, cstat_col; /* Size of cstatus buttons */ |
73 | static enum butstate console_state[CONSOLE_COUNT]; |
73 | static enum butstate console_state[CONSOLE_COUNT]; |
74 | 74 | ||
75 | static int fbphone; |
75 | static int fbphone; |
76 | 76 | ||
77 | /** List of pixmaps identifying these icons */ |
77 | /** List of pixmaps identifying these icons */ |
78 | static int ic_pixmaps[CONS_LAST] = {-1,-1,-1,-1,-1,-1}; |
78 | static int ic_pixmaps[CONS_LAST] = {-1,-1,-1,-1,-1,-1}; |
79 | static int animation = -1; |
79 | static int animation = -1; |
80 | 80 | ||
81 | static int active_console = 0; |
81 | static int active_console = 0; |
82 | 82 | ||
83 | static void vp_switch(int vp) |
83 | static void vp_switch(int vp) |
84 | { |
84 | { |
85 | async_msg(fbphone,FB_VIEWPORT_SWITCH, vp); |
85 | async_msg(fbphone,FB_VIEWPORT_SWITCH, vp); |
86 | } |
86 | } |
87 | 87 | ||
88 | /** Create view port */ |
88 | /** Create view port */ |
89 | static int vp_create(unsigned int x, unsigned int y, |
89 | static int vp_create(unsigned int x, unsigned int y, |
90 | unsigned int width, unsigned int height) |
90 | unsigned int width, unsigned int height) |
91 | { |
91 | { |
92 | /* Init function, use ipc_call_sync */ |
- | |
93 | return ipc_call_sync_2(fbphone, FB_VIEWPORT_CREATE, |
92 | return async_req_2(fbphone, FB_VIEWPORT_CREATE, |
94 | (x << 16) | y, (width << 16) | height, |
93 | (x << 16) | y, (width << 16) | height, |
95 | NULL, NULL); |
94 | NULL, NULL); |
96 | } |
95 | } |
97 | 96 | ||
98 | static void clear(void) |
97 | static void clear(void) |
99 | { |
98 | { |
100 | async_msg(fbphone, FB_CLEAR, 0); |
99 | async_msg(fbphone, FB_CLEAR, 0); |
101 | 100 | ||
102 | } |
101 | } |
103 | 102 | ||
104 | static void set_style(int fgcolor, int bgcolor) |
103 | static void set_style(int fgcolor, int bgcolor) |
105 | { |
104 | { |
106 | async_msg_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor); |
105 | async_msg_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor); |
107 | } |
106 | } |
108 | 107 | ||
109 | /** Transparent putchar */ |
108 | /** Transparent putchar */ |
110 | static void tran_putch(char c, int row, int col) |
109 | static void tran_putch(char c, int row, int col) |
111 | { |
110 | { |
112 | async_msg_3(fbphone, FB_TRANS_PUTCHAR, c, row, col); |
111 | async_msg_3(fbphone, FB_TRANS_PUTCHAR, c, row, col); |
113 | } |
112 | } |
114 | 113 | ||
115 | /** Redraw the button showing state of a given console */ |
114 | /** Redraw the button showing state of a given console */ |
116 | static void redraw_state(int consnum) |
115 | static void redraw_state(int consnum) |
117 | { |
116 | { |
118 | char data[5]; |
117 | char data[5]; |
119 | int i; |
118 | int i; |
120 | enum butstate state = console_state[consnum]; |
119 | enum butstate state = console_state[consnum]; |
121 | 120 | ||
122 | vp_switch(cstatus_vp[consnum]); |
121 | vp_switch(cstatus_vp[consnum]); |
123 | if (ic_pixmaps[state] != -1) |
122 | if (ic_pixmaps[state] != -1) |
124 | async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]); |
123 | async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]); |
125 | 124 | ||
126 | if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) { |
125 | if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) { |
127 | snprintf(data, 5, "%d", consnum+1); |
126 | snprintf(data, 5, "%d", consnum+1); |
128 | for (i=0;data[i];i++) |
127 | for (i=0;data[i];i++) |
129 | tran_putch(data[i], 1, 2+i); |
128 | tran_putch(data[i], 1, 2+i); |
130 | } |
129 | } |
131 | } |
130 | } |
132 | 131 | ||
133 | /** Notification run on changing console (except kernel console) */ |
132 | /** Notification run on changing console (except kernel console) */ |
134 | void gcons_change_console(int consnum) |
133 | void gcons_change_console(int consnum) |
135 | { |
134 | { |
136 | int i; |
135 | int i; |
137 | 136 | ||
138 | if (!use_gcons) |
137 | if (!use_gcons) |
139 | return; |
138 | return; |
140 | 139 | ||
141 | if (active_console == KERNEL_CONSOLE) { |
140 | if (active_console == KERNEL_CONSOLE) { |
142 | for (i=0; i < CONSOLE_COUNT; i++) |
141 | for (i=0; i < CONSOLE_COUNT; i++) |
143 | redraw_state(i); |
142 | redraw_state(i); |
144 | if (animation != -1) |
143 | if (animation != -1) |
145 | async_msg(fbphone, FB_ANIM_START, animation); |
144 | async_msg(fbphone, FB_ANIM_START, animation); |
146 | } else { |
145 | } else { |
147 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
146 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
148 | console_state[active_console] = CONS_DISCONNECTED; |
147 | console_state[active_console] = CONS_DISCONNECTED; |
149 | else |
148 | else |
150 | console_state[active_console] = CONS_IDLE; |
149 | console_state[active_console] = CONS_IDLE; |
151 | redraw_state(active_console); |
150 | redraw_state(active_console); |
152 | } |
151 | } |
153 | active_console = consnum; |
152 | active_console = consnum; |
154 | 153 | ||
155 | if (console_state[consnum] == CONS_DISCONNECTED) { |
154 | if (console_state[consnum] == CONS_DISCONNECTED) { |
156 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
155 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
157 | redraw_state(consnum); |
156 | redraw_state(consnum); |
158 | } else |
157 | } else |
159 | console_state[consnum] = CONS_SELECTED; |
158 | console_state[consnum] = CONS_SELECTED; |
160 | redraw_state(consnum); |
159 | redraw_state(consnum); |
161 | 160 | ||
162 | vp_switch(console_vp); |
161 | vp_switch(console_vp); |
163 | } |
162 | } |
164 | 163 | ||
165 | /** Notification function that gets called on new output to virtual console */ |
164 | /** Notification function that gets called on new output to virtual console */ |
166 | void gcons_notify_char(int consnum) |
165 | void gcons_notify_char(int consnum) |
167 | { |
166 | { |
168 | if (!use_gcons) |
167 | if (!use_gcons) |
169 | return; |
168 | return; |
170 | 169 | ||
171 | if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA) |
170 | if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA) |
172 | return; |
171 | return; |
173 | 172 | ||
174 | console_state[consnum] = CONS_HAS_DATA; |
173 | console_state[consnum] = CONS_HAS_DATA; |
175 | 174 | ||
176 | if (active_console == KERNEL_CONSOLE) |
175 | if (active_console == KERNEL_CONSOLE) |
177 | return; |
176 | return; |
178 | 177 | ||
179 | redraw_state(consnum); |
178 | redraw_state(consnum); |
180 | 179 | ||
181 | vp_switch(console_vp); |
180 | vp_switch(console_vp); |
182 | } |
181 | } |
183 | 182 | ||
184 | /** Notification function called on service disconnect from console */ |
183 | /** Notification function called on service disconnect from console */ |
185 | void gcons_notify_disconnect(int consnum) |
184 | void gcons_notify_disconnect(int consnum) |
186 | { |
185 | { |
187 | if (!use_gcons) |
186 | if (!use_gcons) |
188 | return; |
187 | return; |
189 | if (active_console == consnum) |
188 | if (active_console == consnum) |
190 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
189 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
191 | else |
190 | else |
192 | console_state[consnum] = CONS_DISCONNECTED; |
191 | console_state[consnum] = CONS_DISCONNECTED; |
193 | 192 | ||
194 | if (active_console == KERNEL_CONSOLE) |
193 | if (active_console == KERNEL_CONSOLE) |
195 | return; |
194 | return; |
196 | 195 | ||
197 | redraw_state(consnum); |
196 | redraw_state(consnum); |
198 | vp_switch(console_vp); |
197 | vp_switch(console_vp); |
199 | } |
198 | } |
200 | 199 | ||
201 | /** Notification function called on console connect */ |
200 | /** Notification function called on console connect */ |
202 | void gcons_notify_connect(int consnum) |
201 | void gcons_notify_connect(int consnum) |
203 | { |
202 | { |
204 | if (!use_gcons) |
203 | if (!use_gcons) |
205 | return; |
204 | return; |
206 | if (active_console == consnum) |
205 | if (active_console == consnum) |
207 | console_state[consnum] = CONS_SELECTED; |
206 | console_state[consnum] = CONS_SELECTED; |
208 | else |
207 | else |
209 | console_state[consnum] = CONS_IDLE; |
208 | console_state[consnum] = CONS_IDLE; |
210 | 209 | ||
211 | if (active_console == KERNEL_CONSOLE) |
210 | if (active_console == KERNEL_CONSOLE) |
212 | return; |
211 | return; |
213 | 212 | ||
214 | redraw_state(consnum); |
213 | redraw_state(consnum); |
215 | vp_switch(console_vp); |
214 | vp_switch(console_vp); |
216 | } |
215 | } |
217 | 216 | ||
218 | /** Change to kernel console */ |
217 | /** Change to kernel console */ |
219 | void gcons_in_kernel(void) |
218 | void gcons_in_kernel(void) |
220 | { |
219 | { |
221 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
220 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
222 | console_state[active_console] = CONS_DISCONNECTED; |
221 | console_state[active_console] = CONS_DISCONNECTED; |
223 | else |
222 | else |
224 | console_state[active_console] = CONS_IDLE; |
223 | console_state[active_console] = CONS_IDLE; |
225 | redraw_state(active_console); |
224 | redraw_state(active_console); |
226 | 225 | ||
227 | if (animation != -1) |
226 | if (animation != -1) |
228 | async_msg(fbphone, FB_ANIM_STOP, animation); |
227 | async_msg(fbphone, FB_ANIM_STOP, animation); |
229 | 228 | ||
230 | active_console = KERNEL_CONSOLE; /* Set to kernel console */ |
229 | active_console = KERNEL_CONSOLE; /* Set to kernel console */ |
231 | vp_switch(0); |
230 | vp_switch(0); |
232 | } |
231 | } |
233 | 232 | ||
234 | /** Draw a PPM pixmap to framebuffer |
233 | /** Draw a PPM pixmap to framebuffer |
235 | * |
234 | * |
236 | * @param logo Pointer to PPM data |
235 | * @param logo Pointer to PPM data |
237 | * @param size Size of PPM data |
236 | * @param size Size of PPM data |
238 | * @param x Coordinate of upper left corner |
237 | * @param x Coordinate of upper left corner |
239 | * @param y Coordinate of upper left corner |
238 | * @param y Coordinate of upper left corner |
240 | */ |
239 | */ |
241 | static void draw_pixmap(char *logo, size_t size, int x, int y) |
240 | static void draw_pixmap(char *logo, size_t size, int x, int y) |
242 | { |
241 | { |
243 | char *shm; |
242 | char *shm; |
244 | int rc; |
243 | int rc; |
245 | 244 | ||
246 | /* Create area */ |
245 | /* Create area */ |
247 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); |
246 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); |
248 | if (shm == MAP_FAILED) |
247 | if (shm == MAP_FAILED) |
249 | return; |
248 | return; |
250 | 249 | ||
251 | memcpy(shm, logo, size); |
250 | memcpy(shm, logo, size); |
252 | /* Send area */ |
251 | /* Send area */ |
253 | rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
252 | rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
254 | if (rc) |
253 | if (rc) |
255 | goto exit; |
254 | goto exit; |
256 | rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
255 | rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
257 | if (rc) |
256 | if (rc) |
258 | goto drop; |
257 | goto drop; |
259 | /* Draw logo */ |
258 | /* Draw logo */ |
260 | async_msg_2(fbphone, FB_DRAW_PPM, x, y); |
259 | async_msg_2(fbphone, FB_DRAW_PPM, x, y); |
261 | drop: |
260 | drop: |
262 | /* Drop area */ |
261 | /* Drop area */ |
263 | async_msg(fbphone, FB_DROP_SHM, 0); |
262 | async_msg(fbphone, FB_DROP_SHM, 0); |
264 | exit: |
263 | exit: |
265 | /* Remove area */ |
264 | /* Remove area */ |
266 | munmap(shm, size); |
265 | munmap(shm, size); |
267 | } |
266 | } |
268 | 267 | ||
269 | extern char _binary_helenos_ppm_start[0]; |
268 | extern char _binary_helenos_ppm_start[0]; |
270 | extern int _binary_helenos_ppm_size; |
269 | extern int _binary_helenos_ppm_size; |
271 | extern char _binary_nameic_ppm_start[0]; |
270 | extern char _binary_nameic_ppm_start[0]; |
272 | extern int _binary_nameic_ppm_size; |
271 | extern int _binary_nameic_ppm_size; |
273 | /** Redraws console graphics */ |
272 | /** Redraws console graphics */ |
274 | static void gcons_redraw_console(void) |
273 | static void gcons_redraw_console(void) |
275 | { |
274 | { |
276 | int i; |
275 | int i; |
277 | size_t hsize = (size_t)&_binary_helenos_ppm_size; |
276 | size_t hsize = (size_t)&_binary_helenos_ppm_size; |
278 | 277 | ||
279 | if (!use_gcons) |
278 | if (!use_gcons) |
280 | return; |
279 | return; |
281 | 280 | ||
282 | vp_switch(0); |
281 | vp_switch(0); |
283 | set_style(MAIN_COLOR, MAIN_COLOR); |
282 | set_style(MAIN_COLOR, MAIN_COLOR); |
284 | clear(); |
283 | clear(); |
285 | draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2); |
284 | draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2); |
286 | draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17); |
285 | draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17); |
287 | 286 | ||
288 | for (i=0;i < CONSOLE_COUNT; i++) |
287 | for (i=0;i < CONSOLE_COUNT; i++) |
289 | redraw_state(i); |
288 | redraw_state(i); |
290 | vp_switch(console_vp); |
289 | vp_switch(console_vp); |
291 | } |
290 | } |
292 | 291 | ||
293 | /** Creates a pixmap on framebuffer |
292 | /** Creates a pixmap on framebuffer |
294 | * |
293 | * |
295 | * @param data PPM data |
294 | * @param data PPM data |
296 | * @param size PPM data size |
295 | * @param size PPM data size |
297 | * @return Pixmap identification |
296 | * @return Pixmap identification |
298 | */ |
297 | */ |
299 | static int make_pixmap(char *data, int size) |
298 | static int make_pixmap(char *data, int size) |
300 | { |
299 | { |
301 | char *shm; |
300 | char *shm; |
302 | int rc; |
301 | int rc; |
303 | int pxid = -1; |
302 | int pxid = -1; |
304 | 303 | ||
305 | /* Create area */ |
304 | /* Create area */ |
306 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); |
305 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); |
307 | if (shm == MAP_FAILED) |
306 | if (shm == MAP_FAILED) |
308 | return -1; |
307 | return -1; |
309 | 308 | ||
310 | memcpy(shm, data, size); |
309 | memcpy(shm, data, size); |
311 | /* Send area */ |
310 | /* Send area */ |
312 | rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
311 | rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
313 | if (rc) |
312 | if (rc) |
314 | goto exit; |
313 | goto exit; |
315 | rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
314 | rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
316 | if (rc) |
315 | if (rc) |
317 | goto drop; |
316 | goto drop; |
318 | 317 | ||
319 | /* Obtain pixmap */ |
318 | /* Obtain pixmap */ |
320 | rc = async_req(fbphone, FB_SHM2PIXMAP, 0, NULL); |
319 | rc = async_req(fbphone, FB_SHM2PIXMAP, 0, NULL); |
321 | if (rc < 0) |
320 | if (rc < 0) |
322 | goto drop; |
321 | goto drop; |
323 | pxid = rc; |
322 | pxid = rc; |
324 | drop: |
323 | drop: |
325 | /* Drop area */ |
324 | /* Drop area */ |
326 | async_msg(fbphone, FB_DROP_SHM, 0); |
325 | async_msg(fbphone, FB_DROP_SHM, 0); |
327 | exit: |
326 | exit: |
328 | /* Remove area */ |
327 | /* Remove area */ |
329 | munmap(shm, size); |
328 | munmap(shm, size); |
330 | 329 | ||
331 | return pxid; |
330 | return pxid; |
332 | } |
331 | } |
333 | 332 | ||
334 | extern char _binary_anim_1_ppm_start[0]; |
333 | extern char _binary_anim_1_ppm_start[0]; |
335 | extern int _binary_anim_1_ppm_size; |
334 | extern int _binary_anim_1_ppm_size; |
336 | extern char _binary_anim_2_ppm_start[0]; |
335 | extern char _binary_anim_2_ppm_start[0]; |
337 | extern int _binary_anim_2_ppm_size; |
336 | extern int _binary_anim_2_ppm_size; |
338 | extern char _binary_anim_3_ppm_start[0]; |
337 | extern char _binary_anim_3_ppm_start[0]; |
339 | extern int _binary_anim_3_ppm_size; |
338 | extern int _binary_anim_3_ppm_size; |
340 | extern char _binary_anim_4_ppm_start[0]; |
339 | extern char _binary_anim_4_ppm_start[0]; |
341 | extern int _binary_anim_4_ppm_size; |
340 | extern int _binary_anim_4_ppm_size; |
342 | static void make_anim(void) |
341 | static void make_anim(void) |
343 | { |
342 | { |
344 | int an; |
343 | int an; |
345 | int pm; |
344 | int pm; |
346 | 345 | ||
347 | an = async_req(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE], NULL); |
346 | an = async_req(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE], NULL); |
348 | if (an < 0) |
347 | if (an < 0) |
349 | return; |
348 | return; |
350 | 349 | ||
351 | pm = make_pixmap(_binary_anim_1_ppm_start, (int)&_binary_anim_1_ppm_size); |
350 | pm = make_pixmap(_binary_anim_1_ppm_start, (int)&_binary_anim_1_ppm_size); |
352 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
351 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
353 | 352 | ||
354 | pm = make_pixmap(_binary_anim_2_ppm_start, (int)&_binary_anim_2_ppm_size); |
353 | pm = make_pixmap(_binary_anim_2_ppm_start, (int)&_binary_anim_2_ppm_size); |
355 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
354 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
356 | 355 | ||
357 | pm = make_pixmap(_binary_anim_3_ppm_start, (int)&_binary_anim_3_ppm_size); |
356 | pm = make_pixmap(_binary_anim_3_ppm_start, (int)&_binary_anim_3_ppm_size); |
358 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
357 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
359 | 358 | ||
360 | pm = make_pixmap(_binary_anim_4_ppm_start, (int)&_binary_anim_4_ppm_size); |
359 | pm = make_pixmap(_binary_anim_4_ppm_start, (int)&_binary_anim_4_ppm_size); |
361 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
360 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
362 | 361 | ||
363 | async_msg(fbphone, FB_ANIM_START, an); |
362 | async_msg(fbphone, FB_ANIM_START, an); |
364 | 363 | ||
365 | animation = an; |
364 | animation = an; |
366 | } |
365 | } |
367 | 366 | ||
368 | extern char _binary_cons_selected_ppm_start[0]; |
367 | extern char _binary_cons_selected_ppm_start[0]; |
369 | extern int _binary_cons_selected_ppm_size; |
368 | extern int _binary_cons_selected_ppm_size; |
370 | extern char _binary_cons_idle_ppm_start[0]; |
369 | extern char _binary_cons_idle_ppm_start[0]; |
371 | extern int _binary_cons_idle_ppm_size; |
370 | extern int _binary_cons_idle_ppm_size; |
372 | extern char _binary_cons_has_data_ppm_start[0]; |
371 | extern char _binary_cons_has_data_ppm_start[0]; |
373 | extern int _binary_cons_has_data_ppm_size; |
372 | extern int _binary_cons_has_data_ppm_size; |
374 | extern char _binary_cons_kernel_ppm_start[0]; |
373 | extern char _binary_cons_kernel_ppm_start[0]; |
375 | extern int _binary_cons_kernel_ppm_size; |
374 | extern int _binary_cons_kernel_ppm_size; |
376 | /** Initialize nice graphical console environment */ |
375 | /** Initialize nice graphical console environment */ |
377 | void gcons_init(int phone) |
376 | void gcons_init(int phone) |
378 | { |
377 | { |
379 | int rc; |
378 | int rc; |
380 | int i; |
379 | int i; |
381 | int status_start = STATUS_START; |
380 | int status_start = STATUS_START; |
382 | 381 | ||
383 | fbphone = phone; |
382 | fbphone = phone; |
384 | 383 | ||
385 | rc = ipc_call_sync_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres); |
384 | rc = async_req_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres); |
386 | if (rc) |
385 | if (rc) |
387 | return; |
386 | return; |
388 | 387 | ||
389 | if (xres < 800 || yres < 600) |
388 | if (xres < 800 || yres < 600) |
390 | return; |
389 | return; |
391 | 390 | ||
392 | /* create console viewport */ |
391 | /* create console viewport */ |
393 | /* Align width & height to character size */ |
392 | /* Align width & height to character size */ |
394 | console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
393 | console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
395 | ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8), |
394 | ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8), |
396 | ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16)); |
395 | ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16)); |
397 | if (console_vp < 0) |
396 | if (console_vp < 0) |
398 | return; |
397 | return; |
399 | 398 | ||
400 | /* Create status buttons */ |
399 | /* Create status buttons */ |
401 | status_start += (xres-800) / 2; |
400 | status_start += (xres-800) / 2; |
402 | for (i=0; i < CONSOLE_COUNT; i++) { |
401 | for (i=0; i < CONSOLE_COUNT; i++) { |
403 | cstatus_vp[i] = vp_create(status_start+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE), |
402 | cstatus_vp[i] = vp_create(status_start+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE), |
404 | STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT); |
403 | STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT); |
405 | if (cstatus_vp[i] < 0) |
404 | if (cstatus_vp[i] < 0) |
406 | return; |
405 | return; |
407 | vp_switch(cstatus_vp[i]); |
406 | vp_switch(cstatus_vp[i]); |
408 | set_style(0x202020, 0xffffff); |
407 | set_style(0x202020, 0xffffff); |
409 | } |
408 | } |
410 | 409 | ||
411 | /* Initialize icons */ |
410 | /* Initialize icons */ |
412 | ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start, |
411 | ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start, |
413 | (int)&_binary_cons_selected_ppm_size); |
412 | (int)&_binary_cons_selected_ppm_size); |
414 | ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, |
413 | ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, |
415 | (int)&_binary_cons_idle_ppm_size); |
414 | (int)&_binary_cons_idle_ppm_size); |
416 | ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start, |
415 | ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start, |
417 | (int)&_binary_cons_has_data_ppm_size); |
416 | (int)&_binary_cons_has_data_ppm_size); |
418 | ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start, |
417 | ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start, |
419 | (int)&_binary_cons_idle_ppm_size); |
418 | (int)&_binary_cons_idle_ppm_size); |
420 | ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, |
419 | ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, |
421 | (int)&_binary_cons_kernel_ppm_size); |
420 | (int)&_binary_cons_kernel_ppm_size); |
422 | ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
421 | ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
423 | 422 | ||
424 | make_anim(); |
423 | make_anim(); |
425 | 424 | ||
426 | use_gcons = 1; |
425 | use_gcons = 1; |
427 | console_state[0] = CONS_DISCONNECTED_SEL; |
426 | console_state[0] = CONS_DISCONNECTED_SEL; |
428 | console_state[KERNEL_CONSOLE] = CONS_KERNEL; |
427 | console_state[KERNEL_CONSOLE] = CONS_KERNEL; |
429 | gcons_redraw_console(); |
428 | gcons_redraw_console(); |
430 | } |
429 | } |
431 | 430 | ||
432 | /** @} |
431 | /** @} |
433 | */ |
432 | */ |
434 | 433 | ||
435 | 434 |