Rev 1515 | Rev 1552 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1515 | Rev 1547 | ||
|---|---|---|---|
| Line 44... | Line 44... | ||
| 44 | #include "font-8x16.h" |
44 | #include "font-8x16.h" |
| 45 | #include "helenos.xbm" |
45 | #include "helenos.xbm" |
| 46 | #include "fb.h" |
46 | #include "fb.h" |
| 47 | #include "main.h" |
47 | #include "main.h" |
| 48 | #include "../console/screenbuffer.h" |
48 | #include "../console/screenbuffer.h" |
| - | 49 | #include "ppm.h" |
|
| 49 | 50 | ||
| 50 | #define DEFAULT_BGCOLOR 0x000080 |
51 | #define DEFAULT_BGCOLOR 0x000080 |
| 51 | #define DEFAULT_FGCOLOR 0xffff00 |
52 | #define DEFAULT_FGCOLOR 0xffff00 |
| 52 | 53 | ||
| 53 | /***************************************************************/ |
54 | /***************************************************************/ |
| Line 472... | Line 473... | ||
| 472 | draw_glyph(vp, data[i].character, col * COL_WIDTH, row * FONT_SCANLINES, data[i].style); |
473 | draw_glyph(vp, data[i].character, col * COL_WIDTH, row * FONT_SCANLINES, data[i].style); |
| 473 | } |
474 | } |
| 474 | cursor_print(vp); |
475 | cursor_print(vp); |
| 475 | } |
476 | } |
| 476 | 477 | ||
| - | 478 | static int shm_handle(ipc_callid_t callid, ipc_call_t *call, int vp) |
|
| - | 479 | { |
|
| - | 480 | static keyfield_t *interbuffer = NULL; |
|
| - | 481 | static size_t intersize = 0; |
|
| - | 482 | ||
| - | 483 | static char *pixmap = NULL; |
|
| - | 484 | static ipcarg_t pixmap_id = 0; |
|
| - | 485 | static size_t pixmap_size; |
|
| - | 486 | ||
| - | 487 | int handled = 1; |
|
| - | 488 | int retval = 0; |
|
| - | 489 | viewport_t *vport = &viewports[vp]; |
|
| - | 490 | unsigned int x,y; |
|
| - | 491 | ||
| - | 492 | switch (IPC_GET_METHOD(*call)) { |
|
| - | 493 | case IPC_M_AS_AREA_SEND: |
|
| - | 494 | /* We accept one area for data interchange */ |
|
| - | 495 | if (IPC_GET_ARG1(*call) == pixmap_id) { |
|
| - | 496 | void *dest = as_get_mappable_page(IPC_GET_ARG2(*call)); |
|
| - | 497 | pixmap_size = IPC_GET_ARG2(*call); |
|
| - | 498 | if (!ipc_answer_fast(callid, 0, (sysarg_t)dest, 0)) |
|
| - | 499 | pixmap = dest; |
|
| - | 500 | else |
|
| - | 501 | pixmap_id = 0; |
|
| - | 502 | if (pixmap[0] != 'P') |
|
| - | 503 | while (1) |
|
| - | 504 | ; |
|
| - | 505 | return 1; |
|
| - | 506 | } else { |
|
| - | 507 | intersize = IPC_GET_ARG2(*call); |
|
| - | 508 | receive_comm_area(callid,call,(void **)&interbuffer); |
|
| - | 509 | } |
|
| - | 510 | return 1; |
|
| - | 511 | case FB_PREPARE_SHM: |
|
| - | 512 | if (pixmap_id) |
|
| - | 513 | retval = EBUSY; |
|
| - | 514 | else |
|
| - | 515 | pixmap_id = IPC_GET_ARG1(*call); |
|
| - | 516 | break; |
|
| - | 517 | ||
| - | 518 | case FB_DROP_SHM: |
|
| - | 519 | if (pixmap) { |
|
| - | 520 | as_area_destroy(pixmap); |
|
| - | 521 | pixmap = NULL; |
|
| - | 522 | } |
|
| - | 523 | pixmap_id = 0; |
|
| - | 524 | break; |
|
| - | 525 | ||
| - | 526 | case FB_DRAW_PPM: |
|
| - | 527 | if (!pixmap) { |
|
| - | 528 | retval = EINVAL; |
|
| - | 529 | break; |
|
| - | 530 | } |
|
| - | 531 | x = IPC_GET_ARG1(*call); |
|
| - | 532 | y = IPC_GET_ARG2(*call); |
|
| - | 533 | if (x > vport->width || y > vport->height) { |
|
| - | 534 | retval = EINVAL; |
|
| - | 535 | break; |
|
| - | 536 | } |
|
| - | 537 | ||
| - | 538 | draw_ppm(pixmap, pixmap_size, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call), |
|
| - | 539 | vport->width - x, vport->height - y, putpixel, vp); |
|
| - | 540 | break; |
|
| - | 541 | case FB_DRAW_TEXT_DATA: |
|
| - | 542 | if (!interbuffer) { |
|
| - | 543 | retval = EINVAL; |
|
| - | 544 | break; |
|
| - | 545 | } |
|
| - | 546 | if (intersize < vport->cols*vport->rows*sizeof(*interbuffer)) { |
|
| - | 547 | retval = EINVAL; |
|
| - | 548 | break; |
|
| - | 549 | } |
|
| - | 550 | draw_text_data(vp, interbuffer); |
|
| - | 551 | break; |
|
| - | 552 | default: |
|
| - | 553 | handled = 0; |
|
| - | 554 | } |
|
| - | 555 | ||
| - | 556 | if (handled) |
|
| - | 557 | ipc_answer_fast(callid, retval, 0, 0); |
|
| - | 558 | return handled; |
|
| - | 559 | } |
|
| 477 | 560 | ||
| 478 | /** Function for handling connections to FB |
561 | /** Function for handling connections to FB |
| 479 | * |
562 | * |
| 480 | */ |
563 | */ |
| 481 | static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
564 | static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
| Line 484... | Line 567... | ||
| 484 | ipc_call_t call; |
567 | ipc_call_t call; |
| 485 | int retval; |
568 | int retval; |
| 486 | int i; |
569 | int i; |
| 487 | unsigned int row,col; |
570 | unsigned int row,col; |
| 488 | char c; |
571 | char c; |
| 489 | keyfield_t *interbuffer = NULL; |
- | |
| 490 | size_t intersize = 0; |
- | |
| 491 | 572 | ||
| 492 | int vp = 0; |
573 | int vp = 0; |
| 493 | viewport_t *vport = &viewports[0]; |
574 | viewport_t *vport = &viewports[0]; |
| 494 | 575 | ||
| 495 | if (client_connected) { |
576 | if (client_connected) { |
| Line 503... | Line 584... | ||
| 503 | callid = async_get_call_timeout(&call,250000); |
584 | callid = async_get_call_timeout(&call,250000); |
| 504 | if (!callid) { |
585 | if (!callid) { |
| 505 | cursor_blink(vp); |
586 | cursor_blink(vp); |
| 506 | continue; |
587 | continue; |
| 507 | } |
588 | } |
| - | 589 | if (shm_handle(callid, &call, vp)) |
|
| - | 590 | continue; |
|
| - | 591 | ||
| 508 | switch (IPC_GET_METHOD(call)) { |
592 | switch (IPC_GET_METHOD(call)) { |
| 509 | case IPC_M_PHONE_HUNGUP: |
593 | case IPC_M_PHONE_HUNGUP: |
| 510 | client_connected = 0; |
594 | client_connected = 0; |
| 511 | /* cleanup other viewports */ |
595 | /* cleanup other viewports */ |
| 512 | for (i=1; i < MAX_VIEWPORTS; i++) |
596 | for (i=1; i < MAX_VIEWPORTS; i++) |
| 513 | vport->initialized = 0; |
597 | vport->initialized = 0; |
| 514 | ipc_answer_fast(callid,0,0,0); |
598 | ipc_answer_fast(callid,0,0,0); |
| 515 | return; /* Exit thread */ |
599 | return; /* Exit thread */ |
| 516 | case IPC_M_AS_AREA_SEND: |
- | |
| 517 | /* We accept one area for data interchange */ |
- | |
| 518 | intersize = IPC_GET_ARG2(call); |
- | |
| 519 | receive_comm_area(callid,&call,(void **)&interbuffer, |
- | |
| 520 | sizeof(*interbuffer)*viewports[0].cols*viewports[0].rows); |
- | |
| 521 | continue; |
- | |
| 522 | 600 | ||
| 523 | case FB_DRAW_TEXT_DATA: |
- | |
| 524 | if (!interbuffer) { |
- | |
| 525 | retval = EINVAL; |
- | |
| 526 | break; |
- | |
| 527 | } |
- | |
| 528 | if (intersize < vport->cols*vport->rows*sizeof(*interbuffer)) { |
- | |
| 529 | retval = EINVAL; |
- | |
| 530 | break; |
- | |
| 531 | } |
- | |
| 532 | draw_text_data(vp, interbuffer); |
- | |
| 533 | retval = 0; |
- | |
| 534 | break; |
- | |
| 535 | case FB_PUTCHAR: |
601 | case FB_PUTCHAR: |
| 536 | c = IPC_GET_ARG1(call); |
602 | c = IPC_GET_ARG1(call); |
| 537 | row = IPC_GET_ARG2(call); |
603 | row = IPC_GET_ARG2(call); |
| 538 | col = IPC_GET_ARG3(call); |
604 | col = IPC_GET_ARG3(call); |
| 539 | if (row >= vport->rows || col >= vport->cols) { |
605 | if (row >= vport->rows || col >= vport->cols) { |