[b1f51f0] | 1 | /*
|
---|
[df4ed85] | 2 | * Copyright (c) 2006 Ondrej Palkovsky
|
---|
[b1f51f0] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 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
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 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
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 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
|
---|
| 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
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[ce5bcb4] | 29 | /** @addtogroup console
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[b1f51f0] | 35 | #include <ipc/fb.h>
|
---|
| 36 | #include <ipc/ipc.h>
|
---|
[e1c4849] | 37 | #include <async.h>
|
---|
| 38 | #include <stdio.h>
|
---|
[2def788] | 39 | #include <sys/mman.h>
|
---|
[90f5d64] | 40 | #include <string.h>
|
---|
[a7d2d78] | 41 | #include <align.h>
|
---|
[b1f51f0] | 42 |
|
---|
| 43 | #include "console.h"
|
---|
[e1c4849] | 44 | #include "gcons.h"
|
---|
[b1f51f0] | 45 |
|
---|
[0a9a324] | 46 | #define CONSOLE_TOP 66
|
---|
[a7d2d78] | 47 | #define CONSOLE_MARGIN 6
|
---|
[b1f51f0] | 48 |
|
---|
[a7d2d78] | 49 | #define STATUS_START 110
|
---|
| 50 | #define STATUS_TOP 8
|
---|
[0a9a324] | 51 | #define STATUS_SPACE 4
|
---|
[a7d2d78] | 52 | #define STATUS_WIDTH 48
|
---|
| 53 | #define STATUS_HEIGHT 48
|
---|
[b1f51f0] | 54 |
|
---|
[90f5d64] | 55 | #define MAIN_COLOR 0xffffff
|
---|
[e1c4849] | 56 |
|
---|
[b1f51f0] | 57 | static int use_gcons = 0;
|
---|
| 58 | static ipcarg_t xres,yres;
|
---|
| 59 |
|
---|
[a7d2d78] | 60 | enum butstate {
|
---|
| 61 | CONS_DISCONNECTED = 0,
|
---|
| 62 | CONS_SELECTED,
|
---|
| 63 | CONS_IDLE,
|
---|
| 64 | CONS_HAS_DATA,
|
---|
| 65 | CONS_KERNEL,
|
---|
| 66 | CONS_DISCONNECTED_SEL,
|
---|
| 67 | CONS_LAST
|
---|
| 68 | };
|
---|
| 69 |
|
---|
[b1f51f0] | 70 | static int console_vp;
|
---|
| 71 | static int cstatus_vp[CONSOLE_COUNT];
|
---|
[a7d2d78] | 72 | static enum butstate console_state[CONSOLE_COUNT];
|
---|
[b1f51f0] | 73 |
|
---|
| 74 | static int fbphone;
|
---|
| 75 |
|
---|
[a7d2d78] | 76 | /** List of pixmaps identifying these icons */
|
---|
[00bb6965] | 77 | static int ic_pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
|
---|
[1fd7700] | 78 | static int animation = -1;
|
---|
[e1c4849] | 79 |
|
---|
| 80 | static int active_console = 0;
|
---|
| 81 |
|
---|
[b1f51f0] | 82 | static void vp_switch(int vp)
|
---|
| 83 | {
|
---|
[76fca31] | 84 | async_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);
|
---|
[b1f51f0] | 85 | }
|
---|
| 86 |
|
---|
[e1c4849] | 87 | /** Create view port */
|
---|
[0cc4313] | 88 | static int vp_create(unsigned int x, unsigned int y, unsigned int width,
|
---|
| 89 | unsigned int height)
|
---|
[b1f51f0] | 90 | {
|
---|
[0cc4313] | 91 | return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
|
---|
| 92 | (width << 16) | height);
|
---|
[b1f51f0] | 93 | }
|
---|
| 94 |
|
---|
[e1c4849] | 95 | static void clear(void)
|
---|
[b1f51f0] | 96 | {
|
---|
[0cc4313] | 97 | async_msg_0(fbphone, FB_CLEAR);
|
---|
[b1f51f0] | 98 | }
|
---|
| 99 |
|
---|
[9805cde] | 100 | static void set_rgb_color(int fgcolor, int bgcolor)
|
---|
[e1c4849] | 101 | {
|
---|
[9805cde] | 102 | async_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
|
---|
[e1c4849] | 103 | }
|
---|
| 104 |
|
---|
[d530237a] | 105 | /** Transparent putchar */
|
---|
| 106 | static void tran_putch(char c, int row, int col)
|
---|
[e1c4849] | 107 | {
|
---|
[76fca31] | 108 | async_msg_3(fbphone, FB_PUTCHAR, c, row, col);
|
---|
[e1c4849] | 109 | }
|
---|
| 110 |
|
---|
[d530237a] | 111 | /** Redraw the button showing state of a given console */
|
---|
[a7d2d78] | 112 | static void redraw_state(int consnum)
|
---|
[b1f51f0] | 113 | {
|
---|
[e1c4849] | 114 | char data[5];
|
---|
| 115 | int i;
|
---|
[a7d2d78] | 116 | enum butstate state = console_state[consnum];
|
---|
| 117 |
|
---|
[e1c4849] | 118 | vp_switch(cstatus_vp[consnum]);
|
---|
[a7d2d78] | 119 | if (ic_pixmaps[state] != -1)
|
---|
[00bb6965] | 120 | async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum],
|
---|
[0cc4313] | 121 | ic_pixmaps[state]);
|
---|
[00bb6965] | 122 |
|
---|
[d7baee6] | 123 | if (state != CONS_DISCONNECTED && state != CONS_KERNEL &&
|
---|
| 124 | state != CONS_DISCONNECTED_SEL) {
|
---|
[00bb6965] | 125 | snprintf(data, 5, "%d", consnum + 1);
|
---|
[d7baee6] | 126 | for (i = 0; data[i]; i++)
|
---|
[00bb6965] | 127 | tran_putch(data[i], 1, 2 + i);
|
---|
[a7d2d78] | 128 | }
|
---|
[b1f51f0] | 129 | }
|
---|
| 130 |
|
---|
[a7d2d78] | 131 | /** Notification run on changing console (except kernel console) */
|
---|
[b1f51f0] | 132 | void gcons_change_console(int consnum)
|
---|
| 133 | {
|
---|
[a7d2d78] | 134 | int i;
|
---|
| 135 |
|
---|
[b1f51f0] | 136 | if (!use_gcons)
|
---|
| 137 | return;
|
---|
[429acb9] | 138 |
|
---|
[a7d2d78] | 139 | if (active_console == KERNEL_CONSOLE) {
|
---|
[00bb6965] | 140 | for (i = 0; i < CONSOLE_COUNT; i++)
|
---|
[a7d2d78] | 141 | redraw_state(i);
|
---|
[70178b74] | 142 | if (animation != -1)
|
---|
[0cc4313] | 143 | async_msg_1(fbphone, FB_ANIM_START, animation);
|
---|
[a7d2d78] | 144 | } else {
|
---|
| 145 | if (console_state[active_console] == CONS_DISCONNECTED_SEL)
|
---|
| 146 | console_state[active_console] = CONS_DISCONNECTED;
|
---|
| 147 | else
|
---|
| 148 | console_state[active_console] = CONS_IDLE;
|
---|
| 149 | redraw_state(active_console);
|
---|
| 150 | }
|
---|
[e1c4849] | 151 | active_console = consnum;
|
---|
[a7d2d78] | 152 |
|
---|
| 153 | if (console_state[consnum] == CONS_DISCONNECTED) {
|
---|
| 154 | console_state[consnum] = CONS_DISCONNECTED_SEL;
|
---|
| 155 | redraw_state(consnum);
|
---|
| 156 | } else
|
---|
| 157 | console_state[consnum] = CONS_SELECTED;
|
---|
| 158 | redraw_state(consnum);
|
---|
[d6cc453] | 159 |
|
---|
[b1f51f0] | 160 | vp_switch(console_vp);
|
---|
| 161 | }
|
---|
| 162 |
|
---|
[429acb9] | 163 | /** Notification function that gets called on new output to virtual console */
|
---|
[b1f51f0] | 164 | void gcons_notify_char(int consnum)
|
---|
| 165 | {
|
---|
| 166 | if (!use_gcons)
|
---|
| 167 | return;
|
---|
| 168 |
|
---|
[d7baee6] | 169 | if (consnum == active_console ||
|
---|
| 170 | console_state[consnum] == CONS_HAS_DATA)
|
---|
[d6cc453] | 171 | return;
|
---|
| 172 |
|
---|
[a7d2d78] | 173 | console_state[consnum] = CONS_HAS_DATA;
|
---|
[429acb9] | 174 |
|
---|
[a7d2d78] | 175 | if (active_console == KERNEL_CONSOLE)
|
---|
[429acb9] | 176 | return;
|
---|
| 177 |
|
---|
[a7d2d78] | 178 | redraw_state(consnum);
|
---|
[d6cc453] | 179 |
|
---|
[b1f51f0] | 180 | vp_switch(console_vp);
|
---|
[a7d2d78] | 181 | }
|
---|
[429acb9] | 182 |
|
---|
[e9073f2] | 183 | /** Notification function called on service disconnect from console */
|
---|
| 184 | void gcons_notify_disconnect(int consnum)
|
---|
| 185 | {
|
---|
| 186 | if (!use_gcons)
|
---|
| 187 | return;
|
---|
| 188 | if (active_console == consnum)
|
---|
| 189 | console_state[consnum] = CONS_DISCONNECTED_SEL;
|
---|
| 190 | else
|
---|
| 191 | console_state[consnum] = CONS_DISCONNECTED;
|
---|
[76fca31] | 192 |
|
---|
[e9073f2] | 193 | if (active_console == KERNEL_CONSOLE)
|
---|
| 194 | return;
|
---|
[76fca31] | 195 |
|
---|
[e9073f2] | 196 | redraw_state(consnum);
|
---|
| 197 | vp_switch(console_vp);
|
---|
| 198 | }
|
---|
| 199 |
|
---|
[d530237a] | 200 | /** Notification function called on console connect */
|
---|
[a7d2d78] | 201 | void gcons_notify_connect(int consnum)
|
---|
| 202 | {
|
---|
| 203 | if (!use_gcons)
|
---|
| 204 | return;
|
---|
| 205 | if (active_console == consnum)
|
---|
| 206 | console_state[consnum] = CONS_SELECTED;
|
---|
| 207 | else
|
---|
| 208 | console_state[consnum] = CONS_IDLE;
|
---|
| 209 |
|
---|
| 210 | if (active_console == KERNEL_CONSOLE)
|
---|
| 211 | return;
|
---|
| 212 |
|
---|
| 213 | redraw_state(consnum);
|
---|
| 214 | vp_switch(console_vp);
|
---|
[b1f51f0] | 215 | }
|
---|
| 216 |
|
---|
[429acb9] | 217 | /** Change to kernel console */
|
---|
| 218 | void gcons_in_kernel(void)
|
---|
| 219 | {
|
---|
[70178b74] | 220 | if (animation != -1)
|
---|
[0cc4313] | 221 | async_msg_1(fbphone, FB_ANIM_STOP, animation);
|
---|
[76fca31] | 222 |
|
---|
| 223 | active_console = KERNEL_CONSOLE;
|
---|
[429acb9] | 224 | vp_switch(0);
|
---|
| 225 | }
|
---|
| 226 |
|
---|
[d8b42fb2] | 227 | /** Return x, where left <= x <= right && |a-x|==min(|a-x|) is smallest */
|
---|
[830ac99] | 228 | static inline int limit(int a,int left, int right)
|
---|
| 229 | {
|
---|
| 230 | if (a < left)
|
---|
| 231 | a = left;
|
---|
| 232 | if (a >= right)
|
---|
| 233 | a = right - 1;
|
---|
| 234 | return a;
|
---|
| 235 | }
|
---|
| 236 |
|
---|
[1f83244] | 237 | int mouse_x, mouse_y;
|
---|
| 238 | int btn_pressed, btn_x, btn_y;
|
---|
| 239 |
|
---|
| 240 | /** Handle mouse move
|
---|
| 241 | *
|
---|
| 242 | * @param dx Delta X of mouse move
|
---|
| 243 | * @param dy Delta Y of mouse move
|
---|
| 244 | */
|
---|
[830ac99] | 245 | void gcons_mouse_move(int dx, int dy)
|
---|
| 246 | {
|
---|
[f15cb3c4] | 247 | mouse_x = limit(mouse_x + dx, 0, xres);
|
---|
| 248 | mouse_y = limit(mouse_y + dy, 0, yres);
|
---|
[1f83244] | 249 |
|
---|
| 250 | async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | static int gcons_find_conbut(int x, int y)
|
---|
| 254 | {
|
---|
[f15cb3c4] | 255 | int status_start = STATUS_START + (xres - 800) / 2;
|
---|
[830ac99] | 256 |
|
---|
[00bb6965] | 257 | if (y < STATUS_TOP || y >= STATUS_TOP + STATUS_HEIGHT)
|
---|
[1f83244] | 258 | return -1;
|
---|
| 259 |
|
---|
| 260 | if (x < status_start)
|
---|
| 261 | return -1;
|
---|
| 262 |
|
---|
[00bb6965] | 263 | if (x >= status_start + (STATUS_WIDTH + STATUS_SPACE) * CONSOLE_COUNT)
|
---|
[1f83244] | 264 | return -1;
|
---|
[f15cb3c4] | 265 | if (((x - status_start) % (STATUS_WIDTH + STATUS_SPACE)) < STATUS_SPACE)
|
---|
[1f83244] | 266 | return -1;
|
---|
| 267 |
|
---|
[f15cb3c4] | 268 | return (x - status_start) / (STATUS_WIDTH + STATUS_SPACE);
|
---|
[1f83244] | 269 | }
|
---|
[830ac99] | 270 |
|
---|
[1f83244] | 271 | /** Handle mouse click
|
---|
| 272 | *
|
---|
| 273 | * @param state New state (1-pressed, 0-depressed)
|
---|
| 274 | */
|
---|
| 275 | int gcons_mouse_btn(int state)
|
---|
| 276 | {
|
---|
| 277 | int conbut;
|
---|
| 278 |
|
---|
| 279 | if (state) {
|
---|
| 280 | conbut = gcons_find_conbut(mouse_x, mouse_y);
|
---|
| 281 | if (conbut != -1) {
|
---|
| 282 | btn_pressed = 1;
|
---|
| 283 | btn_x = mouse_x;
|
---|
| 284 | btn_y = mouse_y;
|
---|
| 285 | }
|
---|
| 286 | return -1;
|
---|
| 287 | }
|
---|
| 288 | if (!state && !btn_pressed)
|
---|
| 289 | return -1;
|
---|
| 290 | btn_pressed = 0;
|
---|
| 291 |
|
---|
| 292 | conbut = gcons_find_conbut(mouse_x, mouse_y);
|
---|
| 293 | if (conbut == gcons_find_conbut(btn_x, btn_y))
|
---|
| 294 | return conbut;
|
---|
| 295 | return -1;
|
---|
[830ac99] | 296 | }
|
---|
| 297 |
|
---|
| 298 |
|
---|
[429acb9] | 299 | /** Draw a PPM pixmap to framebuffer
|
---|
| 300 | *
|
---|
| 301 | * @param logo Pointer to PPM data
|
---|
| 302 | * @param size Size of PPM data
|
---|
| 303 | * @param x Coordinate of upper left corner
|
---|
| 304 | * @param y Coordinate of upper left corner
|
---|
| 305 | */
|
---|
[90f5d64] | 306 | static void draw_pixmap(char *logo, size_t size, int x, int y)
|
---|
| 307 | {
|
---|
| 308 | char *shm;
|
---|
| 309 | int rc;
|
---|
| 310 |
|
---|
| 311 | /* Create area */
|
---|
[00bb6965] | 312 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
|
---|
[0cc4313] | 313 | MAP_ANONYMOUS, 0, 0);
|
---|
[90f5d64] | 314 | if (shm == MAP_FAILED)
|
---|
| 315 | return;
|
---|
| 316 |
|
---|
| 317 | memcpy(shm, logo, size);
|
---|
| 318 | /* Send area */
|
---|
[0cc4313] | 319 | rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);
|
---|
[90f5d64] | 320 | if (rc)
|
---|
| 321 | goto exit;
|
---|
[215e375] | 322 | rc = ipc_share_out_start(fbphone, shm, PROTO_READ);
|
---|
[90f5d64] | 323 | if (rc)
|
---|
| 324 | goto drop;
|
---|
| 325 | /* Draw logo */
|
---|
[085bd54] | 326 | async_msg_2(fbphone, FB_DRAW_PPM, x, y);
|
---|
[90f5d64] | 327 | drop:
|
---|
| 328 | /* Drop area */
|
---|
[0cc4313] | 329 | async_msg_0(fbphone, FB_DROP_SHM);
|
---|
[90f5d64] | 330 | exit:
|
---|
| 331 | /* Remove area */
|
---|
| 332 | munmap(shm, size);
|
---|
| 333 | }
|
---|
| 334 |
|
---|
| 335 | extern char _binary_helenos_ppm_start[0];
|
---|
| 336 | extern int _binary_helenos_ppm_size;
|
---|
| 337 | extern char _binary_nameic_ppm_start[0];
|
---|
| 338 | extern int _binary_nameic_ppm_size;
|
---|
[76fca31] | 339 |
|
---|
| 340 | /** Redraws console graphics */
|
---|
| 341 | void gcons_redraw_console(void)
|
---|
[b1f51f0] | 342 | {
|
---|
[e1c4849] | 343 | int i;
|
---|
[76fca31] | 344 |
|
---|
[b1f51f0] | 345 | if (!use_gcons)
|
---|
| 346 | return;
|
---|
| 347 |
|
---|
| 348 | vp_switch(0);
|
---|
[9805cde] | 349 | set_rgb_color(MAIN_COLOR, MAIN_COLOR);
|
---|
[e1c4849] | 350 | clear();
|
---|
[d7baee6] | 351 | draw_pixmap(_binary_helenos_ppm_start,
|
---|
[0cc4313] | 352 | (size_t) &_binary_helenos_ppm_size, xres - 66, 2);
|
---|
[d7baee6] | 353 | draw_pixmap(_binary_nameic_ppm_start,
|
---|
[0cc4313] | 354 | (size_t) &_binary_nameic_ppm_size, 5, 17);
|
---|
[76fca31] | 355 |
|
---|
[0cc4313] | 356 | for (i = 0; i < CONSOLE_COUNT; i++)
|
---|
[a7d2d78] | 357 | redraw_state(i);
|
---|
[b1f51f0] | 358 | vp_switch(console_vp);
|
---|
| 359 | }
|
---|
| 360 |
|
---|
[d530237a] | 361 | /** Creates a pixmap on framebuffer
|
---|
| 362 | *
|
---|
| 363 | * @param data PPM data
|
---|
| 364 | * @param size PPM data size
|
---|
| 365 | * @return Pixmap identification
|
---|
| 366 | */
|
---|
[a7d2d78] | 367 | static int make_pixmap(char *data, int size)
|
---|
| 368 | {
|
---|
| 369 | char *shm;
|
---|
| 370 | int rc;
|
---|
| 371 | int pxid = -1;
|
---|
| 372 |
|
---|
| 373 | /* Create area */
|
---|
[00bb6965] | 374 | shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
|
---|
[0cc4313] | 375 | MAP_ANONYMOUS, 0, 0);
|
---|
[a7d2d78] | 376 | if (shm == MAP_FAILED)
|
---|
| 377 | return -1;
|
---|
| 378 |
|
---|
| 379 | memcpy(shm, data, size);
|
---|
| 380 | /* Send area */
|
---|
[0cc4313] | 381 | rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);
|
---|
[a7d2d78] | 382 | if (rc)
|
---|
| 383 | goto exit;
|
---|
[215e375] | 384 | rc = ipc_share_out_start(fbphone, shm, PROTO_READ);
|
---|
[a7d2d78] | 385 | if (rc)
|
---|
| 386 | goto drop;
|
---|
| 387 |
|
---|
| 388 | /* Obtain pixmap */
|
---|
[0cc4313] | 389 | rc = async_req_0_0(fbphone, FB_SHM2PIXMAP);
|
---|
[a7d2d78] | 390 | if (rc < 0)
|
---|
| 391 | goto drop;
|
---|
| 392 | pxid = rc;
|
---|
| 393 | drop:
|
---|
| 394 | /* Drop area */
|
---|
[0cc4313] | 395 | async_msg_0(fbphone, FB_DROP_SHM);
|
---|
[a7d2d78] | 396 | exit:
|
---|
| 397 | /* Remove area */
|
---|
| 398 | munmap(shm, size);
|
---|
| 399 |
|
---|
| 400 | return pxid;
|
---|
| 401 | }
|
---|
| 402 |
|
---|
[1fd7700] | 403 | extern char _binary_anim_1_ppm_start[0];
|
---|
| 404 | extern int _binary_anim_1_ppm_size;
|
---|
| 405 | extern char _binary_anim_2_ppm_start[0];
|
---|
| 406 | extern int _binary_anim_2_ppm_size;
|
---|
| 407 | extern char _binary_anim_3_ppm_start[0];
|
---|
| 408 | extern int _binary_anim_3_ppm_size;
|
---|
| 409 | extern char _binary_anim_4_ppm_start[0];
|
---|
| 410 | extern int _binary_anim_4_ppm_size;
|
---|
[00bb6965] | 411 |
|
---|
[1fd7700] | 412 | static void make_anim(void)
|
---|
| 413 | {
|
---|
| 414 | int an;
|
---|
| 415 | int pm;
|
---|
| 416 |
|
---|
[0cc4313] | 417 | an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]);
|
---|
[1fd7700] | 418 | if (an < 0)
|
---|
| 419 | return;
|
---|
| 420 |
|
---|
[d7baee6] | 421 | pm = make_pixmap(_binary_anim_1_ppm_start,
|
---|
[0cc4313] | 422 | (int) &_binary_anim_1_ppm_size);
|
---|
[1fd7700] | 423 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
|
---|
| 424 |
|
---|
[d7baee6] | 425 | pm = make_pixmap(_binary_anim_2_ppm_start,
|
---|
[0cc4313] | 426 | (int) &_binary_anim_2_ppm_size);
|
---|
[1fd7700] | 427 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
|
---|
| 428 |
|
---|
[d7baee6] | 429 | pm = make_pixmap(_binary_anim_3_ppm_start,
|
---|
[0cc4313] | 430 | (int) &_binary_anim_3_ppm_size);
|
---|
[1fd7700] | 431 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
|
---|
| 432 |
|
---|
[d7baee6] | 433 | pm = make_pixmap(_binary_anim_4_ppm_start,
|
---|
[0cc4313] | 434 | (int) &_binary_anim_4_ppm_size);
|
---|
[1fd7700] | 435 | async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
|
---|
| 436 |
|
---|
[0cc4313] | 437 | async_msg_1(fbphone, FB_ANIM_START, an);
|
---|
[1fd7700] | 438 |
|
---|
| 439 | animation = an;
|
---|
| 440 | }
|
---|
| 441 |
|
---|
[a7d2d78] | 442 | extern char _binary_cons_selected_ppm_start[0];
|
---|
| 443 | extern int _binary_cons_selected_ppm_size;
|
---|
| 444 | extern char _binary_cons_idle_ppm_start[0];
|
---|
| 445 | extern int _binary_cons_idle_ppm_size;
|
---|
| 446 | extern char _binary_cons_has_data_ppm_start[0];
|
---|
| 447 | extern int _binary_cons_has_data_ppm_size;
|
---|
| 448 | extern char _binary_cons_kernel_ppm_start[0];
|
---|
| 449 | extern int _binary_cons_kernel_ppm_size;
|
---|
[00bb6965] | 450 |
|
---|
[b1f51f0] | 451 | /** Initialize nice graphical console environment */
|
---|
| 452 | void gcons_init(int phone)
|
---|
| 453 | {
|
---|
| 454 | int rc;
|
---|
| 455 | int i;
|
---|
[1fd7700] | 456 | int status_start = STATUS_START;
|
---|
[76fca31] | 457 |
|
---|
[b1f51f0] | 458 | fbphone = phone;
|
---|
[76fca31] | 459 |
|
---|
[0cc4313] | 460 | rc = async_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);
|
---|
[b1f51f0] | 461 | if (rc)
|
---|
| 462 | return;
|
---|
| 463 |
|
---|
[76fca31] | 464 | if ((xres < 800) || (yres < 600))
|
---|
[b1f51f0] | 465 | return;
|
---|
[76fca31] | 466 |
|
---|
[b1f51f0] | 467 | /* create console viewport */
|
---|
[a7d2d78] | 468 | /* Align width & height to character size */
|
---|
[d7baee6] | 469 | console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP,
|
---|
[0cc4313] | 470 | ALIGN_DOWN(xres - 2 * CONSOLE_MARGIN, 8),
|
---|
| 471 | ALIGN_DOWN(yres - (CONSOLE_TOP + CONSOLE_MARGIN), 16));
|
---|
[b1f51f0] | 472 | if (console_vp < 0)
|
---|
| 473 | return;
|
---|
| 474 |
|
---|
| 475 | /* Create status buttons */
|
---|
[00bb6965] | 476 | status_start += (xres - 800) / 2;
|
---|
| 477 | for (i = 0; i < CONSOLE_COUNT; i++) {
|
---|
[d7baee6] | 478 | cstatus_vp[i] = vp_create(status_start + CONSOLE_MARGIN +
|
---|
[0cc4313] | 479 | i * (STATUS_WIDTH + STATUS_SPACE), STATUS_TOP,
|
---|
| 480 | STATUS_WIDTH, STATUS_HEIGHT);
|
---|
[b1f51f0] | 481 | if (cstatus_vp[i] < 0)
|
---|
| 482 | return;
|
---|
[a7d2d78] | 483 | vp_switch(cstatus_vp[i]);
|
---|
[9805cde] | 484 | set_rgb_color(0x202020, 0xffffff);
|
---|
[b1f51f0] | 485 | }
|
---|
| 486 |
|
---|
[a7d2d78] | 487 | /* Initialize icons */
|
---|
[00bb6965] | 488 | ic_pixmaps[CONS_SELECTED] =
|
---|
[0cc4313] | 489 | make_pixmap(_binary_cons_selected_ppm_start,
|
---|
| 490 | (int) &_binary_cons_selected_ppm_size);
|
---|
[d7baee6] | 491 | ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start,
|
---|
[0cc4313] | 492 | (int) &_binary_cons_idle_ppm_size);
|
---|
[00bb6965] | 493 | ic_pixmaps[CONS_HAS_DATA] =
|
---|
[0cc4313] | 494 | make_pixmap(_binary_cons_has_data_ppm_start,
|
---|
| 495 | (int) &_binary_cons_has_data_ppm_size);
|
---|
[00bb6965] | 496 | ic_pixmaps[CONS_DISCONNECTED] =
|
---|
[0cc4313] | 497 | make_pixmap(_binary_cons_idle_ppm_start,
|
---|
| 498 | (int) &_binary_cons_idle_ppm_size);
|
---|
[a7d2d78] | 499 | ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start,
|
---|
[0cc4313] | 500 | (int) &_binary_cons_kernel_ppm_size);
|
---|
[a7d2d78] | 501 | ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
|
---|
[1fd7700] | 502 |
|
---|
| 503 | make_anim();
|
---|
[76fca31] | 504 |
|
---|
[b1f51f0] | 505 | use_gcons = 1;
|
---|
[a7d2d78] | 506 | console_state[0] = CONS_DISCONNECTED_SEL;
|
---|
| 507 | console_state[KERNEL_CONSOLE] = CONS_KERNEL;
|
---|
[e1c4849] | 508 | gcons_redraw_console();
|
---|
[b1f51f0] | 509 | }
|
---|
[76fca31] | 510 |
|
---|
[ce5bcb4] | 511 | /** @}
|
---|
| 512 | */
|
---|