Changeset 1601f3c in mainline for uspace/srv/console/gcons.c
- Timestamp:
- 2009-05-21T15:32:42Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7d158097
- Parents:
- a095d20
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/console/gcons.c
ra095d20 r1601f3c 28 28 29 29 /** @addtogroup console 30 * @{ 30 * @{ 31 31 */ 32 32 /** @file … … 44 44 #include "gcons.h" 45 45 46 #define CONSOLE_TOP 47 #define CONSOLE_MARGIN 48 49 #define STATUS_START 50 #define STATUS_TOP 51 #define STATUS_SPACE 52 #define STATUS_WIDTH 53 #define STATUS_HEIGHT 54 55 #define MAIN_COLOR 46 #define CONSOLE_TOP 66 47 #define CONSOLE_MARGIN 6 48 49 #define STATUS_START 110 50 #define STATUS_TOP 8 51 #define STATUS_SPACE 4 52 #define STATUS_WIDTH 48 53 #define STATUS_HEIGHT 48 54 55 #define MAIN_COLOR 0xffffff 56 56 57 57 static int use_gcons = 0; … … 115 115 int i; 116 116 enum butstate state = console_state[consnum]; 117 117 118 118 vp_switch(cstatus_vp[consnum]); 119 119 if (ic_pixmaps[state] != -1) 120 120 async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], 121 121 ic_pixmaps[state]); 122 123 124 125 126 127 128 122 123 if (state != CONS_DISCONNECTED && state != CONS_KERNEL && 124 state != CONS_DISCONNECTED_SEL) { 125 snprintf(data, 5, "%d", consnum + 1); 126 for (i = 0; data[i]; i++) 127 tran_putch(data[i], 1, 2 + i); 128 } 129 129 } 130 130 … … 133 133 { 134 134 int i; 135 135 136 136 if (!use_gcons) 137 137 return; 138 138 139 139 if (active_console == KERNEL_CONSOLE) { 140 140 for (i = 0; i < CONSOLE_COUNT; i++) … … 150 150 } 151 151 active_console = consnum; 152 152 153 153 if (console_state[consnum] == CONS_DISCONNECTED) { 154 154 console_state[consnum] = CONS_DISCONNECTED_SEL; … … 157 157 console_state[consnum] = CONS_SELECTED; 158 158 redraw_state(consnum); 159 159 160 160 vp_switch(console_vp); 161 161 } … … 166 166 if (!use_gcons) 167 167 return; 168 169 if ( consnum == active_console||170 console_state[consnum] == CONS_HAS_DATA)171 return; 172 168 169 if ((consnum == active_console) || 170 (console_state[consnum] == CONS_HAS_DATA)) 171 return; 172 173 173 console_state[consnum] = CONS_HAS_DATA; 174 174 175 175 if (active_console == KERNEL_CONSOLE) 176 176 return; 177 177 178 178 redraw_state(consnum); 179 179 … … 186 186 if (!use_gcons) 187 187 return; 188 188 189 if (active_console == consnum) 189 190 console_state[consnum] = CONS_DISCONNECTED_SEL; … … 203 204 if (!use_gcons) 204 205 return; 206 205 207 if (active_console == consnum) 206 208 console_state[consnum] = CONS_SELECTED; 207 209 else 208 210 console_state[consnum] = CONS_IDLE; 209 211 210 212 if (active_console == KERNEL_CONSOLE) 211 213 return; 212 214 213 215 redraw_state(consnum); 214 216 vp_switch(console_vp); … … 226 228 227 229 /** Return x, where left <= x <= right && |a-x|==min(|a-x|) is smallest */ 228 static inline int limit(int a, int left, int right)230 static inline int limit(int a, int left, int right) 229 231 { 230 232 if (a < left) … … 247 249 mouse_x = limit(mouse_x + dx, 0, xres); 248 250 mouse_y = limit(mouse_y + dy, 0, yres); 249 251 250 252 async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); 251 253 } … … 254 256 { 255 257 int status_start = STATUS_START + (xres - 800) / 2; 256 257 if ( y < STATUS_TOP || y >= STATUS_TOP + STATUS_HEIGHT)258 259 if ((y < STATUS_TOP) || (y >= STATUS_TOP + STATUS_HEIGHT)) 258 260 return -1; 259 261 … … 276 278 { 277 279 int conbut; 278 280 279 281 if (state) { 280 282 conbut = gcons_find_conbut(mouse_x, mouse_y); … … 285 287 } 286 288 return -1; 287 } 288 if (!state && !btn_pressed) 289 return -1; 289 } 290 291 if ((!state) && (!btn_pressed)) 292 return -1; 293 290 294 btn_pressed = 0; 291 295 292 296 conbut = gcons_find_conbut(mouse_x, mouse_y); 293 297 if (conbut == gcons_find_conbut(btn_x, btn_y)) 294 298 return conbut; 299 295 300 return -1; 296 301 } … … 308 313 char *shm; 309 314 int rc; 310 315 311 316 /* Create area */ 312 317 shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | … … 314 319 if (shm == MAP_FAILED) 315 320 return; 316 321 317 322 memcpy(shm, logo, size); 323 318 324 /* Send area */ 319 325 rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); 320 326 if (rc) 321 327 goto exit; 328 322 329 rc = ipc_share_out_start(fbphone, shm, PROTO_READ); 323 330 if (rc) 324 331 goto drop; 332 325 333 /* Draw logo */ 326 334 async_msg_2(fbphone, FB_DRAW_PPM, x, y); 335 327 336 drop: 328 337 /* Drop area */ 329 338 async_msg_0(fbphone, FB_DROP_SHM); 330 exit: 339 340 exit: 331 341 /* Remove area */ 332 342 munmap(shm, size); 333 343 } 334 344 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;345 extern char _binary_gfx_helenos_ppm_start[0]; 346 extern int _binary_gfx_helenos_ppm_size; 347 extern char _binary_gfx_nameic_ppm_start[0]; 348 extern int _binary_gfx_nameic_ppm_size; 339 349 340 350 /** Redraws console graphics */ … … 349 359 set_rgb_color(MAIN_COLOR, MAIN_COLOR); 350 360 clear(); 351 draw_pixmap(_binary_ helenos_ppm_start,352 (size_t) &_binary_ helenos_ppm_size, xres - 66, 2);353 draw_pixmap(_binary_ nameic_ppm_start,354 (size_t) &_binary_ nameic_ppm_size, 5, 17);361 draw_pixmap(_binary_gfx_helenos_ppm_start, 362 (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2); 363 draw_pixmap(_binary_gfx_nameic_ppm_start, 364 (size_t) &_binary_gfx_nameic_ppm_size, 5, 17); 355 365 356 366 for (i = 0; i < CONSOLE_COUNT; i++) 357 367 redraw_state(i); 368 358 369 vp_switch(console_vp); 359 370 } … … 370 381 int rc; 371 382 int pxid = -1; 372 383 373 384 /* Create area */ 374 385 shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | … … 376 387 if (shm == MAP_FAILED) 377 388 return -1; 378 389 379 390 memcpy(shm, data, size); 391 380 392 /* Send area */ 381 393 rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); 382 394 if (rc) 383 395 goto exit; 396 384 397 rc = ipc_share_out_start(fbphone, shm, PROTO_READ); 385 398 if (rc) 386 399 goto drop; 387 400 388 401 /* Obtain pixmap */ 389 402 rc = async_req_0_0(fbphone, FB_SHM2PIXMAP); 390 403 if (rc < 0) 391 404 goto drop; 405 392 406 pxid = rc; 407 393 408 drop: 394 409 /* Drop area */ 395 410 async_msg_0(fbphone, FB_DROP_SHM); 396 exit: 411 412 exit: 397 413 /* Remove area */ 398 414 munmap(shm, size); 399 415 400 416 return pxid; 401 417 } 402 418 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;419 extern char _binary_gfx_anim_1_ppm_start[0]; 420 extern int _binary_gfx_anim_1_ppm_size; 421 extern char _binary_gfx_anim_2_ppm_start[0]; 422 extern int _binary_gfx_anim_2_ppm_size; 423 extern char _binary_gfx_anim_3_ppm_start[0]; 424 extern int _binary_gfx_anim_3_ppm_size; 425 extern char _binary_gfx_anim_4_ppm_start[0]; 426 extern int _binary_gfx_anim_4_ppm_size; 411 427 412 428 static void make_anim(void) 413 429 { 414 int an; 415 int pm; 416 417 an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); 430 int an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); 418 431 if (an < 0) 419 432 return; 420 421 pm = make_pixmap(_binary_anim_1_ppm_start,422 (int) &_binary_ anim_1_ppm_size);433 434 int pm = make_pixmap(_binary_gfx_anim_1_ppm_start, 435 (int) &_binary_gfx_anim_1_ppm_size); 423 436 async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 424 425 pm = make_pixmap(_binary_ anim_2_ppm_start,426 (int) &_binary_ anim_2_ppm_size);437 438 pm = make_pixmap(_binary_gfx_anim_2_ppm_start, 439 (int) &_binary_gfx_anim_2_ppm_size); 427 440 async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 428 429 pm = make_pixmap(_binary_ anim_3_ppm_start,430 (int) &_binary_ anim_3_ppm_size);441 442 pm = make_pixmap(_binary_gfx_anim_3_ppm_start, 443 (int) &_binary_gfx_anim_3_ppm_size); 431 444 async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 432 433 pm = make_pixmap(_binary_ anim_4_ppm_start,434 (int) &_binary_ anim_4_ppm_size);445 446 pm = make_pixmap(_binary_gfx_anim_4_ppm_start, 447 (int) &_binary_gfx_anim_4_ppm_size); 435 448 async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 436 449 437 450 async_msg_1(fbphone, FB_ANIM_START, an); 438 451 439 452 animation = an; 440 453 } 441 454 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;455 extern char _binary_gfx_cons_selected_ppm_start[0]; 456 extern int _binary_gfx_cons_selected_ppm_size; 457 extern char _binary_gfx_cons_idle_ppm_start[0]; 458 extern int _binary_gfx_cons_idle_ppm_size; 459 extern char _binary_gfx_cons_has_data_ppm_start[0]; 460 extern int _binary_gfx_cons_has_data_ppm_size; 461 extern char _binary_gfx_cons_kernel_ppm_start[0]; 462 extern int _binary_gfx_cons_kernel_ppm_size; 450 463 451 464 /** Initialize nice graphical console environment */ … … 465 478 return; 466 479 467 /* create console viewport */ 480 /* Create console viewport */ 481 468 482 /* Align width & height to character size */ 469 483 console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, … … 487 501 /* Initialize icons */ 488 502 ic_pixmaps[CONS_SELECTED] = 489 make_pixmap(_binary_cons_selected_ppm_start, 490 (int) &_binary_cons_selected_ppm_size); 491 ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, 492 (int) &_binary_cons_idle_ppm_size); 503 make_pixmap(_binary_gfx_cons_selected_ppm_start, 504 (int) &_binary_gfx_cons_selected_ppm_size); 505 ic_pixmaps[CONS_IDLE] = 506 make_pixmap(_binary_gfx_cons_idle_ppm_start, 507 (int) &_binary_gfx_cons_idle_ppm_size); 493 508 ic_pixmaps[CONS_HAS_DATA] = 494 make_pixmap(_binary_ cons_has_data_ppm_start,495 (int) &_binary_ cons_has_data_ppm_size);509 make_pixmap(_binary_gfx_cons_has_data_ppm_start, 510 (int) &_binary_gfx_cons_has_data_ppm_size); 496 511 ic_pixmaps[CONS_DISCONNECTED] = 497 make_pixmap(_binary_cons_idle_ppm_start, 498 (int) &_binary_cons_idle_ppm_size); 499 ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, 500 (int) &_binary_cons_kernel_ppm_size); 512 make_pixmap(_binary_gfx_cons_idle_ppm_start, 513 (int) &_binary_gfx_cons_idle_ppm_size); 514 ic_pixmaps[CONS_KERNEL] = 515 make_pixmap(_binary_gfx_cons_kernel_ppm_start, 516 (int) &_binary_gfx_cons_kernel_ppm_size); 501 517 ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; 502 518
Note:
See TracChangeset
for help on using the changeset viewer.