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