Rev 1646 | Rev 1649 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1646 | Rev 1647 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2006 Ondrej Palkovsky |
2 | * Copyright (C) 2006 Ondrej Palkovsky |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <ipc/fb.h> |
29 | #include <ipc/fb.h> |
30 | #include <ipc/ipc.h> |
30 | #include <ipc/ipc.h> |
31 | #include <async.h> |
31 | #include <async.h> |
32 | #include <stdio.h> |
32 | #include <stdio.h> |
33 | #include <sys/mman.h> |
33 | #include <sys/mman.h> |
34 | #include <string.h> |
34 | #include <string.h> |
35 | #include <align.h> |
35 | #include <align.h> |
36 | 36 | ||
37 | #include "console.h" |
37 | #include "console.h" |
38 | #include "gcons.h" |
38 | #include "gcons.h" |
39 | 39 | ||
40 | #define CONSOLE_TOP 65 |
40 | #define CONSOLE_TOP 65 |
41 | #define CONSOLE_MARGIN 6 |
41 | #define CONSOLE_MARGIN 6 |
42 | 42 | ||
43 | #define STATUS_START 110 |
43 | #define STATUS_START 110 |
44 | #define STATUS_TOP 8 |
44 | #define STATUS_TOP 8 |
45 | #define STATUS_SPACE 3 |
45 | #define STATUS_SPACE 3 |
46 | #define STATUS_WIDTH 48 |
46 | #define STATUS_WIDTH 48 |
47 | #define STATUS_HEIGHT 48 |
47 | #define STATUS_HEIGHT 48 |
48 | 48 | ||
49 | #define MAIN_COLOR 0xffffff |
49 | #define MAIN_COLOR 0xffffff |
50 | 50 | ||
51 | static int use_gcons = 0; |
51 | static int use_gcons = 0; |
52 | static ipcarg_t xres,yres; |
52 | static ipcarg_t xres,yres; |
53 | 53 | ||
54 | enum butstate { |
54 | enum butstate { |
55 | CONS_DISCONNECTED = 0, |
55 | CONS_DISCONNECTED = 0, |
56 | CONS_SELECTED, |
56 | CONS_SELECTED, |
57 | CONS_IDLE, |
57 | CONS_IDLE, |
58 | CONS_HAS_DATA, |
58 | CONS_HAS_DATA, |
59 | CONS_KERNEL, |
59 | CONS_KERNEL, |
60 | CONS_DISCONNECTED_SEL, |
60 | CONS_DISCONNECTED_SEL, |
61 | CONS_LAST |
61 | CONS_LAST |
62 | }; |
62 | }; |
63 | 63 | ||
64 | static int console_vp; |
64 | static int console_vp; |
65 | static int cstatus_vp[CONSOLE_COUNT]; |
65 | static int cstatus_vp[CONSOLE_COUNT]; |
66 | static int cstat_row, cstat_col; /* Size of cstatus buttons */ |
66 | static int cstat_row, cstat_col; /* Size of cstatus buttons */ |
67 | static enum butstate console_state[CONSOLE_COUNT]; |
67 | static enum butstate console_state[CONSOLE_COUNT]; |
68 | 68 | ||
69 | static int fbphone; |
69 | static int fbphone; |
70 | 70 | ||
71 | /** List of pixmaps identifying these icons */ |
71 | /** List of pixmaps identifying these icons */ |
72 | static int ic_pixmaps[CONS_LAST] = {-1,-1,-1,-1,-1,-1}; |
72 | static int ic_pixmaps[CONS_LAST] = {-1,-1,-1,-1,-1,-1}; |
73 | static int animation = -1; |
73 | static int animation = -1; |
74 | 74 | ||
75 | static int active_console = 0; |
75 | static int active_console = 0; |
76 | 76 | ||
77 | static void vp_switch(int vp) |
77 | static void vp_switch(int vp) |
78 | { |
78 | { |
79 | async_msg(fbphone,FB_VIEWPORT_SWITCH, vp); |
79 | async_msg(fbphone,FB_VIEWPORT_SWITCH, vp); |
80 | } |
80 | } |
81 | 81 | ||
82 | /** Create view port */ |
82 | /** Create view port */ |
83 | static int vp_create(unsigned int x, unsigned int y, |
83 | static int vp_create(unsigned int x, unsigned int y, |
84 | unsigned int width, unsigned int height) |
84 | unsigned int width, unsigned int height) |
85 | { |
85 | { |
86 | /* Init function, use ipc_call_sync */ |
86 | /* Init function, use ipc_call_sync */ |
87 | return ipc_call_sync_2(fbphone, FB_VIEWPORT_CREATE, |
87 | return ipc_call_sync_2(fbphone, FB_VIEWPORT_CREATE, |
88 | (x << 16) | y, (width << 16) | height, |
88 | (x << 16) | y, (width << 16) | height, |
89 | NULL, NULL); |
89 | NULL, NULL); |
90 | } |
90 | } |
91 | 91 | ||
92 | static void clear(void) |
92 | static void clear(void) |
93 | { |
93 | { |
94 | async_msg(fbphone, FB_CLEAR, 0); |
94 | async_msg(fbphone, FB_CLEAR, 0); |
95 | 95 | ||
96 | } |
96 | } |
97 | 97 | ||
98 | static void set_style(int fgcolor, int bgcolor) |
98 | static void set_style(int fgcolor, int bgcolor) |
99 | { |
99 | { |
100 | async_msg_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor); |
100 | async_msg_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor); |
101 | } |
101 | } |
102 | 102 | ||
103 | /** Transparent putchar */ |
103 | /** Transparent putchar */ |
104 | static void tran_putch(char c, int row, int col) |
104 | static void tran_putch(char c, int row, int col) |
105 | { |
105 | { |
106 | async_msg_3(fbphone, FB_TRANS_PUTCHAR, c, row, col); |
106 | async_msg_3(fbphone, FB_TRANS_PUTCHAR, c, row, col); |
107 | } |
107 | } |
108 | 108 | ||
109 | /** Redraw the button showing state of a given console */ |
109 | /** Redraw the button showing state of a given console */ |
110 | static void redraw_state(int consnum) |
110 | static void redraw_state(int consnum) |
111 | { |
111 | { |
112 | char data[5]; |
112 | char data[5]; |
113 | int i; |
113 | int i; |
114 | enum butstate state = console_state[consnum]; |
114 | enum butstate state = console_state[consnum]; |
115 | 115 | ||
116 | vp_switch(cstatus_vp[consnum]); |
116 | vp_switch(cstatus_vp[consnum]); |
117 | if (ic_pixmaps[state] != -1) |
117 | if (ic_pixmaps[state] != -1) |
118 | async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]); |
118 | async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]); |
119 | 119 | ||
120 | if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) { |
120 | if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) { |
121 | snprintf(data, 5, "%d", consnum+1); |
121 | snprintf(data, 5, "%d", consnum+1); |
122 | for (i=0;data[i];i++) |
122 | for (i=0;data[i];i++) |
123 | tran_putch(data[i], 1, 2+i); |
123 | tran_putch(data[i], 1, 2+i); |
124 | } |
124 | } |
125 | } |
125 | } |
126 | 126 | ||
127 | /** Notification run on changing console (except kernel console) */ |
127 | /** Notification run on changing console (except kernel console) */ |
128 | void gcons_change_console(int consnum) |
128 | void gcons_change_console(int consnum) |
129 | { |
129 | { |
130 | int i; |
130 | int i; |
131 | 131 | ||
132 | if (!use_gcons) |
132 | if (!use_gcons) |
133 | return; |
133 | return; |
134 | 134 | ||
135 | if (active_console == KERNEL_CONSOLE) { |
135 | if (active_console == KERNEL_CONSOLE) { |
136 | for (i=0; i < CONSOLE_COUNT; i++) |
136 | for (i=0; i < CONSOLE_COUNT; i++) |
137 | redraw_state(i); |
137 | redraw_state(i); |
- | 138 | if (animation != -1) |
|
- | 139 | async_msg(fbphone, FB_ANIM_START, animation); |
|
138 | } else { |
140 | } else { |
139 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
141 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
140 | console_state[active_console] = CONS_DISCONNECTED; |
142 | console_state[active_console] = CONS_DISCONNECTED; |
141 | else |
143 | else |
142 | console_state[active_console] = CONS_IDLE; |
144 | console_state[active_console] = CONS_IDLE; |
143 | redraw_state(active_console); |
145 | redraw_state(active_console); |
144 | } |
146 | } |
145 | active_console = consnum; |
147 | active_console = consnum; |
146 | 148 | ||
147 | if (console_state[consnum] == CONS_DISCONNECTED) { |
149 | if (console_state[consnum] == CONS_DISCONNECTED) { |
148 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
150 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
149 | redraw_state(consnum); |
151 | redraw_state(consnum); |
150 | } else |
152 | } else |
151 | console_state[consnum] = CONS_SELECTED; |
153 | console_state[consnum] = CONS_SELECTED; |
152 | redraw_state(consnum); |
154 | redraw_state(consnum); |
153 | 155 | ||
154 | vp_switch(console_vp); |
156 | vp_switch(console_vp); |
155 | } |
157 | } |
156 | 158 | ||
157 | /** Notification function that gets called on new output to virtual console */ |
159 | /** Notification function that gets called on new output to virtual console */ |
158 | void gcons_notify_char(int consnum) |
160 | void gcons_notify_char(int consnum) |
159 | { |
161 | { |
160 | if (!use_gcons) |
162 | if (!use_gcons) |
161 | return; |
163 | return; |
162 | 164 | ||
163 | if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA) |
165 | if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA) |
164 | return; |
166 | return; |
165 | 167 | ||
166 | console_state[consnum] = CONS_HAS_DATA; |
168 | console_state[consnum] = CONS_HAS_DATA; |
167 | 169 | ||
168 | if (active_console == KERNEL_CONSOLE) |
170 | if (active_console == KERNEL_CONSOLE) |
169 | return; |
171 | return; |
170 | 172 | ||
171 | redraw_state(consnum); |
173 | redraw_state(consnum); |
172 | 174 | ||
173 | vp_switch(console_vp); |
175 | vp_switch(console_vp); |
174 | } |
176 | } |
175 | 177 | ||
176 | /** Notification function called on service disconnect from console */ |
178 | /** Notification function called on service disconnect from console */ |
177 | void gcons_notify_disconnect(int consnum) |
179 | void gcons_notify_disconnect(int consnum) |
178 | { |
180 | { |
179 | if (!use_gcons) |
181 | if (!use_gcons) |
180 | return; |
182 | return; |
181 | if (active_console == consnum) |
183 | if (active_console == consnum) |
182 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
184 | console_state[consnum] = CONS_DISCONNECTED_SEL; |
183 | else |
185 | else |
184 | console_state[consnum] = CONS_DISCONNECTED; |
186 | console_state[consnum] = CONS_DISCONNECTED; |
185 | 187 | ||
186 | if (active_console == KERNEL_CONSOLE) |
188 | if (active_console == KERNEL_CONSOLE) |
187 | return; |
189 | return; |
188 | 190 | ||
189 | redraw_state(consnum); |
191 | redraw_state(consnum); |
190 | vp_switch(console_vp); |
192 | vp_switch(console_vp); |
191 | } |
193 | } |
192 | 194 | ||
193 | /** Notification function called on console connect */ |
195 | /** Notification function called on console connect */ |
194 | void gcons_notify_connect(int consnum) |
196 | void gcons_notify_connect(int consnum) |
195 | { |
197 | { |
196 | if (!use_gcons) |
198 | if (!use_gcons) |
197 | return; |
199 | return; |
198 | if (active_console == consnum) |
200 | if (active_console == consnum) |
199 | console_state[consnum] = CONS_SELECTED; |
201 | console_state[consnum] = CONS_SELECTED; |
200 | else |
202 | else |
201 | console_state[consnum] = CONS_IDLE; |
203 | console_state[consnum] = CONS_IDLE; |
202 | 204 | ||
203 | if (active_console == KERNEL_CONSOLE) |
205 | if (active_console == KERNEL_CONSOLE) |
204 | return; |
206 | return; |
205 | 207 | ||
206 | redraw_state(consnum); |
208 | redraw_state(consnum); |
207 | vp_switch(console_vp); |
209 | vp_switch(console_vp); |
208 | } |
210 | } |
209 | 211 | ||
210 | /** Change to kernel console */ |
212 | /** Change to kernel console */ |
211 | void gcons_in_kernel(void) |
213 | void gcons_in_kernel(void) |
212 | { |
214 | { |
213 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
215 | if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
214 | console_state[active_console] = CONS_DISCONNECTED; |
216 | console_state[active_console] = CONS_DISCONNECTED; |
215 | else |
217 | else |
216 | console_state[active_console] = CONS_IDLE; |
218 | console_state[active_console] = CONS_IDLE; |
217 | redraw_state(active_console); |
219 | redraw_state(active_console); |
218 | 220 | ||
- | 221 | if (animation != -1) |
|
- | 222 | async_msg(fbphone, FB_ANIM_STOP, animation); |
|
- | 223 | ||
219 | active_console = KERNEL_CONSOLE; /* Set to kernel console */ |
224 | active_console = KERNEL_CONSOLE; /* Set to kernel console */ |
220 | vp_switch(0); |
225 | vp_switch(0); |
221 | } |
226 | } |
222 | 227 | ||
223 | /** Draw a PPM pixmap to framebuffer |
228 | /** Draw a PPM pixmap to framebuffer |
224 | * |
229 | * |
225 | * @param logo Pointer to PPM data |
230 | * @param logo Pointer to PPM data |
226 | * @param size Size of PPM data |
231 | * @param size Size of PPM data |
227 | * @param x Coordinate of upper left corner |
232 | * @param x Coordinate of upper left corner |
228 | * @param y Coordinate of upper left corner |
233 | * @param y Coordinate of upper left corner |
229 | */ |
234 | */ |
230 | static void draw_pixmap(char *logo, size_t size, int x, int y) |
235 | static void draw_pixmap(char *logo, size_t size, int x, int y) |
231 | { |
236 | { |
232 | char *shm; |
237 | char *shm; |
233 | int rc; |
238 | int rc; |
234 | 239 | ||
235 | /* Create area */ |
240 | /* Create area */ |
236 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); |
241 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); |
237 | if (shm == MAP_FAILED) |
242 | if (shm == MAP_FAILED) |
238 | return; |
243 | return; |
239 | 244 | ||
240 | memcpy(shm, logo, size); |
245 | memcpy(shm, logo, size); |
241 | /* Send area */ |
246 | /* Send area */ |
242 | rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
247 | rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
243 | if (rc) |
248 | if (rc) |
244 | goto exit; |
249 | goto exit; |
245 | rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
250 | rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
246 | if (rc) |
251 | if (rc) |
247 | goto drop; |
252 | goto drop; |
248 | /* Draw logo */ |
253 | /* Draw logo */ |
249 | async_msg_2(fbphone, FB_DRAW_PPM, x, y); |
254 | async_msg_2(fbphone, FB_DRAW_PPM, x, y); |
250 | drop: |
255 | drop: |
251 | /* Drop area */ |
256 | /* Drop area */ |
252 | async_msg(fbphone, FB_DROP_SHM, 0); |
257 | async_msg(fbphone, FB_DROP_SHM, 0); |
253 | exit: |
258 | exit: |
254 | /* Remove area */ |
259 | /* Remove area */ |
255 | munmap(shm, size); |
260 | munmap(shm, size); |
256 | } |
261 | } |
257 | 262 | ||
258 | extern char _binary_helenos_ppm_start[0]; |
263 | extern char _binary_helenos_ppm_start[0]; |
259 | extern int _binary_helenos_ppm_size; |
264 | extern int _binary_helenos_ppm_size; |
260 | extern char _binary_nameic_ppm_start[0]; |
265 | extern char _binary_nameic_ppm_start[0]; |
261 | extern int _binary_nameic_ppm_size; |
266 | extern int _binary_nameic_ppm_size; |
262 | /** Redraws console graphics */ |
267 | /** Redraws console graphics */ |
263 | static void gcons_redraw_console(void) |
268 | static void gcons_redraw_console(void) |
264 | { |
269 | { |
265 | int i; |
270 | int i; |
266 | size_t hsize = (size_t)&_binary_helenos_ppm_size; |
271 | size_t hsize = (size_t)&_binary_helenos_ppm_size; |
267 | 272 | ||
268 | if (!use_gcons) |
273 | if (!use_gcons) |
269 | return; |
274 | return; |
270 | 275 | ||
271 | vp_switch(0); |
276 | vp_switch(0); |
272 | set_style(MAIN_COLOR, MAIN_COLOR); |
277 | set_style(MAIN_COLOR, MAIN_COLOR); |
273 | clear(); |
278 | clear(); |
274 | draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2); |
279 | draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2); |
275 | draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17); |
280 | draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17); |
276 | 281 | ||
277 | for (i=0;i < CONSOLE_COUNT; i++) |
282 | for (i=0;i < CONSOLE_COUNT; i++) |
278 | redraw_state(i); |
283 | redraw_state(i); |
279 | vp_switch(console_vp); |
284 | vp_switch(console_vp); |
280 | } |
285 | } |
281 | 286 | ||
282 | /** Creates a pixmap on framebuffer |
287 | /** Creates a pixmap on framebuffer |
283 | * |
288 | * |
284 | * @param data PPM data |
289 | * @param data PPM data |
285 | * @param size PPM data size |
290 | * @param size PPM data size |
286 | * @return Pixmap identification |
291 | * @return Pixmap identification |
287 | */ |
292 | */ |
288 | static int make_pixmap(char *data, int size) |
293 | static int make_pixmap(char *data, int size) |
289 | { |
294 | { |
290 | char *shm; |
295 | char *shm; |
291 | int rc; |
296 | int rc; |
292 | int pxid = -1; |
297 | int pxid = -1; |
293 | 298 | ||
294 | /* Create area */ |
299 | /* Create area */ |
295 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); |
300 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); |
296 | if (shm == MAP_FAILED) |
301 | if (shm == MAP_FAILED) |
297 | return -1; |
302 | return -1; |
298 | 303 | ||
299 | memcpy(shm, data, size); |
304 | memcpy(shm, data, size); |
300 | /* Send area */ |
305 | /* Send area */ |
301 | rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
306 | rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
302 | if (rc) |
307 | if (rc) |
303 | goto exit; |
308 | goto exit; |
304 | rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
309 | rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
305 | if (rc) |
310 | if (rc) |
306 | goto drop; |
311 | goto drop; |
307 | 312 | ||
308 | /* Obtain pixmap */ |
313 | /* Obtain pixmap */ |
309 | rc = async_req(fbphone, FB_SHM2PIXMAP, 0, NULL); |
314 | rc = async_req(fbphone, FB_SHM2PIXMAP, 0, NULL); |
310 | if (rc < 0) |
315 | if (rc < 0) |
311 | goto drop; |
316 | goto drop; |
312 | pxid = rc; |
317 | pxid = rc; |
313 | drop: |
318 | drop: |
314 | /* Drop area */ |
319 | /* Drop area */ |
315 | async_msg(fbphone, FB_DROP_SHM, 0); |
320 | async_msg(fbphone, FB_DROP_SHM, 0); |
316 | exit: |
321 | exit: |
317 | /* Remove area */ |
322 | /* Remove area */ |
318 | munmap(shm, size); |
323 | munmap(shm, size); |
319 | 324 | ||
320 | return pxid; |
325 | return pxid; |
321 | } |
326 | } |
322 | 327 | ||
323 | extern char _binary_anim_1_ppm_start[0]; |
328 | extern char _binary_anim_1_ppm_start[0]; |
324 | extern int _binary_anim_1_ppm_size; |
329 | extern int _binary_anim_1_ppm_size; |
325 | extern char _binary_anim_2_ppm_start[0]; |
330 | extern char _binary_anim_2_ppm_start[0]; |
326 | extern int _binary_anim_2_ppm_size; |
331 | extern int _binary_anim_2_ppm_size; |
327 | extern char _binary_anim_3_ppm_start[0]; |
332 | extern char _binary_anim_3_ppm_start[0]; |
328 | extern int _binary_anim_3_ppm_size; |
333 | extern int _binary_anim_3_ppm_size; |
329 | extern char _binary_anim_4_ppm_start[0]; |
334 | extern char _binary_anim_4_ppm_start[0]; |
330 | extern int _binary_anim_4_ppm_size; |
335 | extern int _binary_anim_4_ppm_size; |
331 | static void make_anim(void) |
336 | static void make_anim(void) |
332 | { |
337 | { |
333 | int an; |
338 | int an; |
334 | int pm; |
339 | int pm; |
335 | 340 | ||
336 | an = async_req(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE], NULL); |
341 | an = async_req(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE], NULL); |
337 | if (an < 0) |
342 | if (an < 0) |
338 | return; |
343 | return; |
339 | 344 | ||
340 | pm = make_pixmap(_binary_anim_1_ppm_start, (int)&_binary_anim_1_ppm_size); |
345 | pm = make_pixmap(_binary_anim_1_ppm_start, (int)&_binary_anim_1_ppm_size); |
341 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
346 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
342 | 347 | ||
343 | pm = make_pixmap(_binary_anim_2_ppm_start, (int)&_binary_anim_2_ppm_size); |
348 | pm = make_pixmap(_binary_anim_2_ppm_start, (int)&_binary_anim_2_ppm_size); |
344 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
349 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
345 | 350 | ||
346 | pm = make_pixmap(_binary_anim_3_ppm_start, (int)&_binary_anim_3_ppm_size); |
351 | pm = make_pixmap(_binary_anim_3_ppm_start, (int)&_binary_anim_3_ppm_size); |
347 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
352 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
348 | 353 | ||
349 | pm = make_pixmap(_binary_anim_4_ppm_start, (int)&_binary_anim_4_ppm_size); |
354 | pm = make_pixmap(_binary_anim_4_ppm_start, (int)&_binary_anim_4_ppm_size); |
350 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
355 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); |
351 | 356 | ||
352 | async_msg(fbphone, FB_ANIM_START, an); |
357 | async_msg(fbphone, FB_ANIM_START, an); |
353 | 358 | ||
354 | animation = an; |
359 | animation = an; |
355 | } |
360 | } |
356 | 361 | ||
357 | extern char _binary_cons_selected_ppm_start[0]; |
362 | extern char _binary_cons_selected_ppm_start[0]; |
358 | extern int _binary_cons_selected_ppm_size; |
363 | extern int _binary_cons_selected_ppm_size; |
359 | extern char _binary_cons_idle_ppm_start[0]; |
364 | extern char _binary_cons_idle_ppm_start[0]; |
360 | extern int _binary_cons_idle_ppm_size; |
365 | extern int _binary_cons_idle_ppm_size; |
361 | extern char _binary_cons_has_data_ppm_start[0]; |
366 | extern char _binary_cons_has_data_ppm_start[0]; |
362 | extern int _binary_cons_has_data_ppm_size; |
367 | extern int _binary_cons_has_data_ppm_size; |
363 | extern char _binary_cons_kernel_ppm_start[0]; |
368 | extern char _binary_cons_kernel_ppm_start[0]; |
364 | extern int _binary_cons_kernel_ppm_size; |
369 | extern int _binary_cons_kernel_ppm_size; |
365 | /** Initialize nice graphical console environment */ |
370 | /** Initialize nice graphical console environment */ |
366 | void gcons_init(int phone) |
371 | void gcons_init(int phone) |
367 | { |
372 | { |
368 | int rc; |
373 | int rc; |
369 | int i; |
374 | int i; |
370 | int status_start = STATUS_START; |
375 | int status_start = STATUS_START; |
371 | 376 | ||
372 | fbphone = phone; |
377 | fbphone = phone; |
373 | 378 | ||
374 | rc = ipc_call_sync_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres); |
379 | rc = ipc_call_sync_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres); |
375 | if (rc) |
380 | if (rc) |
376 | return; |
381 | return; |
377 | 382 | ||
378 | if (xres < 800 || yres < 600) |
383 | if (xres < 800 || yres < 600) |
379 | return; |
384 | return; |
380 | 385 | ||
381 | /* create console viewport */ |
386 | /* create console viewport */ |
382 | /* Align width & height to character size */ |
387 | /* Align width & height to character size */ |
383 | console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
388 | console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
384 | ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8), |
389 | ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8), |
385 | ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16)); |
390 | ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16)); |
386 | if (console_vp < 0) |
391 | if (console_vp < 0) |
387 | return; |
392 | return; |
388 | 393 | ||
389 | /* Create status buttons */ |
394 | /* Create status buttons */ |
390 | status_start += (xres-800) / 2; |
395 | status_start += (xres-800) / 2; |
391 | for (i=0; i < CONSOLE_COUNT; i++) { |
396 | for (i=0; i < CONSOLE_COUNT; i++) { |
392 | cstatus_vp[i] = vp_create(status_start+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE), |
397 | cstatus_vp[i] = vp_create(status_start+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE), |
393 | STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT); |
398 | STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT); |
394 | if (cstatus_vp[i] < 0) |
399 | if (cstatus_vp[i] < 0) |
395 | return; |
400 | return; |
396 | vp_switch(cstatus_vp[i]); |
401 | vp_switch(cstatus_vp[i]); |
397 | set_style(0x202020, 0xffffff); |
402 | set_style(0x202020, 0xffffff); |
398 | } |
403 | } |
399 | 404 | ||
400 | /* Initialize icons */ |
405 | /* Initialize icons */ |
401 | ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start, |
406 | ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start, |
402 | (int)&_binary_cons_selected_ppm_size); |
407 | (int)&_binary_cons_selected_ppm_size); |
403 | ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, |
408 | ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, |
404 | (int)&_binary_cons_idle_ppm_size); |
409 | (int)&_binary_cons_idle_ppm_size); |
405 | ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start, |
410 | ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start, |
406 | (int)&_binary_cons_has_data_ppm_size); |
411 | (int)&_binary_cons_has_data_ppm_size); |
407 | ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start, |
412 | ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start, |
408 | (int)&_binary_cons_idle_ppm_size); |
413 | (int)&_binary_cons_idle_ppm_size); |
409 | ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, |
414 | ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, |
410 | (int)&_binary_cons_kernel_ppm_size); |
415 | (int)&_binary_cons_kernel_ppm_size); |
411 | ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
416 | ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
412 | 417 | ||
413 | make_anim(); |
418 | make_anim(); |
414 | 419 | ||
415 | use_gcons = 1; |
420 | use_gcons = 1; |
416 | console_state[0] = CONS_DISCONNECTED_SEL; |
421 | console_state[0] = CONS_DISCONNECTED_SEL; |
417 | console_state[KERNEL_CONSOLE] = CONS_KERNEL; |
422 | console_state[KERNEL_CONSOLE] = CONS_KERNEL; |
418 | gcons_redraw_console(); |
423 | gcons_redraw_console(); |
419 | } |
424 | } |
420 | 425 |