Rev 4419 | Rev 4439 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4419 | Rev 4420 | ||
|---|---|---|---|
| Line 62... | Line 62... | ||
| 62 | /** Index of currently used virtual console. |
62 | /** Index of currently used virtual console. |
| 63 | */ |
63 | */ |
| 64 | int active_console = 0; |
64 | int active_console = 0; |
| 65 | int prev_console = 0; |
65 | int prev_console = 0; |
| 66 | 66 | ||
| - | 67 | /** Phone to the keyboard driver. */ |
|
| - | 68 | static int kbd_phone; |
|
| - | 69 | ||
| 67 | /** Information about framebuffer */ |
70 | /** Information about framebuffer */ |
| 68 | struct { |
71 | struct { |
| 69 | int phone; /**< Framebuffer phone */ |
72 | int phone; /**< Framebuffer phone */ |
| 70 | ipcarg_t rows; /**< Framebuffer rows */ |
73 | ipcarg_t rows; /**< Framebuffer rows */ |
| 71 | ipcarg_t cols; /**< Framebuffer columns */ |
74 | ipcarg_t cols; /**< Framebuffer columns */ |
| Line 139... | Line 142... | ||
| 139 | static void curs_goto(int row, int col) |
142 | static void curs_goto(int row, int col) |
| 140 | { |
143 | { |
| 141 | async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col); |
144 | async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col); |
| 142 | } |
145 | } |
| 143 | 146 | ||
| - | 147 | static void screen_yield(void) |
|
| - | 148 | { |
|
| - | 149 | ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_YIELD); |
|
| - | 150 | } |
|
| - | 151 | ||
| - | 152 | static void screen_reclaim(void) |
|
| - | 153 | { |
|
| - | 154 | ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_RECLAIM); |
|
| - | 155 | } |
|
| - | 156 | ||
| - | 157 | static void kbd_yield(void) |
|
| - | 158 | { |
|
| - | 159 | ipc_call_sync_0_0(kbd_phone, KBD_YIELD); |
|
| - | 160 | } |
|
| - | 161 | ||
| - | 162 | static void kbd_reclaim(void) |
|
| - | 163 | { |
|
| - | 164 | ipc_call_sync_0_0(kbd_phone, KBD_RECLAIM); |
|
| - | 165 | } |
|
| - | 166 | ||
| 144 | static void set_style(int style) |
167 | static void set_style(int style) |
| 145 | { |
168 | { |
| 146 | async_msg_1(fb_info.phone, FB_SET_STYLE, style); |
169 | async_msg_1(fb_info.phone, FB_SET_STYLE, style); |
| 147 | } |
170 | } |
| 148 | 171 | ||
| Line 328... | Line 351... | ||
| 328 | 351 | ||
| 329 | if (newcons == KERNEL_CONSOLE) { |
352 | if (newcons == KERNEL_CONSOLE) { |
| 330 | async_serialize_start(); |
353 | async_serialize_start(); |
| 331 | curs_hide_sync(); |
354 | curs_hide_sync(); |
| 332 | gcons_in_kernel(); |
355 | gcons_in_kernel(); |
| - | 356 | screen_yield(); |
|
| - | 357 | kbd_yield(); |
|
| 333 | async_serialize_end(); |
358 | async_serialize_end(); |
| - | 359 | ||
| 334 | 360 | ||
| 335 | if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) { |
361 | if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) { |
| 336 | prev_console = active_console; |
362 | prev_console = active_console; |
| 337 | active_console = KERNEL_CONSOLE; |
363 | active_console = KERNEL_CONSOLE; |
| 338 | } else |
364 | } else |
| Line 340... | Line 366... | ||
| 340 | } |
366 | } |
| 341 | 367 | ||
| 342 | if (newcons != KERNEL_CONSOLE) { |
368 | if (newcons != KERNEL_CONSOLE) { |
| 343 | async_serialize_start(); |
369 | async_serialize_start(); |
| 344 | 370 | ||
| 345 | if (active_console == KERNEL_CONSOLE) |
371 | if (active_console == KERNEL_CONSOLE) { |
| - | 372 | screen_reclaim(); |
|
| - | 373 | kbd_reclaim(); |
|
| 346 | gcons_redraw_console(); |
374 | gcons_redraw_console(); |
| - | 375 | } |
|
| 347 | 376 | ||
| 348 | active_console = newcons; |
377 | active_console = newcons; |
| 349 | gcons_change_console(newcons); |
378 | gcons_change_console(newcons); |
| 350 | conn = &connections[active_console]; |
379 | conn = &connections[active_console]; |
| 351 | 380 | ||
| Line 472... | Line 501... | ||
| 472 | size_t off; |
501 | size_t off; |
| 473 | 502 | ||
| 474 | if (!ipc_data_write_receive(&callid, &size)) { |
503 | if (!ipc_data_write_receive(&callid, &size)) { |
| 475 | ipc_answer_0(callid, EINVAL); |
504 | ipc_answer_0(callid, EINVAL); |
| 476 | ipc_answer_0(rid, EINVAL); |
505 | ipc_answer_0(rid, EINVAL); |
| - | 506 | return; |
|
| 477 | } |
507 | } |
| 478 | 508 | ||
| 479 | if (size > CWRITE_BUF_SIZE) |
509 | if (size > CWRITE_BUF_SIZE) |
| 480 | size = CWRITE_BUF_SIZE; |
510 | size = CWRITE_BUF_SIZE; |
| 481 | 511 | ||
| 482 | (void) ipc_data_write_finalize(callid, cwrite_buf, size); |
512 | (void) ipc_data_write_finalize(callid, cwrite_buf, size); |
| 483 | 513 | ||
| - | 514 | async_serialize_start(); |
|
| - | 515 | ||
| 484 | off = 0; |
516 | off = 0; |
| 485 | while (off < size) { |
517 | while (off < size) { |
| 486 | ch = str_decode(cwrite_buf, &off, size); |
518 | ch = str_decode(cwrite_buf, &off, size); |
| 487 | write_char(consnum, ch); |
519 | write_char(consnum, ch); |
| 488 | } |
520 | } |
| 489 | 521 | ||
| - | 522 | async_serialize_end(); |
|
| - | 523 | ||
| 490 | gcons_notify_char(consnum); |
524 | gcons_notify_char(consnum); |
| 491 | ipc_answer_1(rid, EOK, size); |
525 | ipc_answer_1(rid, EOK, size); |
| 492 | } |
526 | } |
| 493 | 527 | ||
| 494 | /** Default thread for new connections */ |
528 | /** Default thread for new connections */ |
| Line 510... | Line 544... | ||
| 510 | 544 | ||
| 511 | async_serialize_start(); |
545 | async_serialize_start(); |
| 512 | gcons_notify_connect(consnum); |
546 | gcons_notify_connect(consnum); |
| 513 | conn->client_phone = IPC_GET_ARG5(*icall); |
547 | conn->client_phone = IPC_GET_ARG5(*icall); |
| 514 | screenbuffer_clear(&conn->screenbuffer); |
548 | screenbuffer_clear(&conn->screenbuffer); |
| - | 549 | if (consnum == active_console) |
|
| - | 550 | clrscr(); |
|
| 515 | 551 | ||
| 516 | /* Accept the connection */ |
552 | /* Accept the connection */ |
| 517 | ipc_answer_0(iid, EOK); |
553 | ipc_answer_0(iid, EOK); |
| 518 | 554 | ||
| 519 | while (1) { |
555 | while (1) { |
| Line 542... | Line 578... | ||
| 542 | case CONSOLE_PUTCHAR: |
578 | case CONSOLE_PUTCHAR: |
| 543 | write_char(consnum, IPC_GET_ARG1(call)); |
579 | write_char(consnum, IPC_GET_ARG1(call)); |
| 544 | gcons_notify_char(consnum); |
580 | gcons_notify_char(consnum); |
| 545 | break; |
581 | break; |
| 546 | case CONSOLE_WRITE: |
582 | case CONSOLE_WRITE: |
| - | 583 | async_serialize_end(); |
|
| 547 | cons_write(consnum, callid, &call); |
584 | cons_write(consnum, callid, &call); |
| - | 585 | async_serialize_start(); |
|
| 548 | continue; |
586 | continue; |
| 549 | case CONSOLE_CLEAR: |
587 | case CONSOLE_CLEAR: |
| 550 | /* Send message to fb */ |
588 | /* Send message to fb */ |
| 551 | if (consnum == active_console) { |
589 | if (consnum == active_console) { |
| 552 | async_msg_0(fb_info.phone, FB_CLEAR); |
590 | async_msg_0(fb_info.phone, FB_CLEAR); |
| Line 647... | Line 685... | ||
| 647 | int main(int argc, char *argv[]) |
685 | int main(int argc, char *argv[]) |
| 648 | { |
686 | { |
| 649 | printf(NAME ": HelenOS Console service\n"); |
687 | printf(NAME ": HelenOS Console service\n"); |
| 650 | 688 | ||
| 651 | ipcarg_t phonehash; |
689 | ipcarg_t phonehash; |
| 652 | int kbd_phone; |
- | |
| 653 | size_t ib_size; |
690 | size_t ib_size; |
| 654 | int i; |
691 | int i; |
| 655 | 692 | ||
| 656 | async_set_client_connection(client_connection); |
693 | async_set_client_connection(client_connection); |
| 657 | 694 | ||