Rev 2025 | Rev 2070 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2025 | Rev 2069 | ||
---|---|---|---|
Line 84... | Line 84... | ||
84 | static connection_t connections[CONSOLE_COUNT]; /**< Array of data for virtual |
84 | static connection_t connections[CONSOLE_COUNT]; /**< Array of data for virtual |
85 | * consoles */ |
85 | * consoles */ |
86 | static keyfield_t *interbuffer = NULL; /**< Pointer to memory shared |
86 | static keyfield_t *interbuffer = NULL; /**< Pointer to memory shared |
87 | * with framebufer used for |
87 | * with framebufer used for |
88 | * faster virtual console |
88 | * faster virtual console |
89 | *switching */ |
89 | * switching */ |
90 | 90 | ||
91 | static int kernel_pixmap = -1; /**< Number of fb pixmap, where kernel |
91 | static int kernel_pixmap = -1; /**< Number of fb pixmap, where kernel |
92 | * console is stored */ |
92 | * console is stored */ |
93 | 93 | ||
94 | 94 | ||
95 | /** Find unused virtual console. |
95 | /** Find unused virtual console. |
96 | * |
96 | * |
97 | */ |
97 | */ |
98 | static int find_free_connection(void) |
98 | static int find_free_connection(void) |
99 | { |
99 | { |
100 | int i = 0; |
100 | int i; |
101 | 101 | ||
102 | for (i=0; i < CONSOLE_COUNT; i++) { |
102 | for (i = 0; i < CONSOLE_COUNT; i++) { |
103 | if (!connections[i].used) |
103 | if (!connections[i].used) |
104 | return i; |
104 | return i; |
105 | } |
105 | } |
106 | return -1; |
106 | return -1; |
107 | } |
107 | } |
Line 146... | Line 146... | ||
146 | { |
146 | { |
147 | screenbuffer_t *scr = &(connections[console].screenbuffer); |
147 | screenbuffer_t *scr = &(connections[console].screenbuffer); |
148 | 148 | ||
149 | switch (key) { |
149 | switch (key) { |
150 | case '\n': |
150 | case '\n': |
151 | scr->position_y += 1; |
151 | scr->position_y++; |
152 | scr->position_x = 0; |
152 | scr->position_x = 0; |
153 | break; |
153 | break; |
154 | case '\r': |
154 | case '\r': |
155 | break; |
155 | break; |
156 | case '\t': |
156 | case '\t': |
157 | scr->position_x += 8; |
157 | scr->position_x += 8; |
Line 176... | Line 176... | ||
176 | scr->position_y += (scr->position_x >= scr->size_x); |
176 | scr->position_y += (scr->position_x >= scr->size_x); |
177 | 177 | ||
178 | if (scr->position_y >= scr->size_y) { |
178 | if (scr->position_y >= scr->size_y) { |
179 | scr->position_y = scr->size_y - 1; |
179 | scr->position_y = scr->size_y - 1; |
180 | screenbuffer_clear_line(scr, scr->top_line); |
180 | screenbuffer_clear_line(scr, scr->top_line); |
181 | scr->top_line = (scr->top_line+1) % scr->size_y; |
181 | scr->top_line = (scr->top_line + 1) % scr->size_y; |
182 | if (console == active_console) |
182 | if (console == active_console) |
183 | async_msg(fb_info.phone, FB_SCROLL, 1); |
183 | async_msg(fb_info.phone, FB_SCROLL, 1); |
184 | } |
184 | } |
185 | 185 | ||
186 | scr->position_x = scr->position_x % scr->size_x; |
186 | scr->position_x = scr->position_x % scr->size_x; |
Line 261... | Line 261... | ||
261 | set_style(&conn->screenbuffer.style); |
261 | set_style(&conn->screenbuffer.style); |
262 | curs_visibility(0); |
262 | curs_visibility(0); |
263 | if (interbuffer) { |
263 | if (interbuffer) { |
264 | for (i = 0; i < conn->screenbuffer.size_x; i++) |
264 | for (i = 0; i < conn->screenbuffer.size_x; i++) |
265 | for (j = 0; j < conn->screenbuffer.size_y; j++) |
265 | for (j = 0; j < conn->screenbuffer.size_y; j++) |
266 | interbuffer[i + j * conn->screenbuffer.size_x] |
266 | interbuffer[i + j * conn->screenbuffer.size_x] = |
267 | = *get_field_at(&(conn->screenbuffer), |
267 | *get_field_at(&(conn->screenbuffer), |
268 | i, j); |
268 | i, j); |
269 | /* This call can preempt, but we are already at the end */ |
269 | /* This call can preempt, but we are already at the end */ |
270 | rc = async_req_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, |
270 | rc = async_req_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, |
271 | NULL); |
271 | NULL); |
272 | }; |
272 | }; |
Line 386... | Line 386... | ||
386 | gcons_notify_connect(consnum); |
386 | gcons_notify_connect(consnum); |
387 | conn->client_phone = IPC_GET_ARG3(call); |
387 | conn->client_phone = IPC_GET_ARG3(call); |
388 | screenbuffer_clear(&conn->screenbuffer); |
388 | screenbuffer_clear(&conn->screenbuffer); |
389 | 389 | ||
390 | /* Accept the connection */ |
390 | /* Accept the connection */ |
391 | ipc_answer_fast(iid,0,0,0); |
391 | ipc_answer_fast(iid, 0, 0, 0); |
392 | 392 | ||
393 | while (1) { |
393 | while (1) { |
394 | async_serialize_end(); |
394 | async_serialize_end(); |
395 | callid = async_get_call(&call); |
395 | callid = async_get_call(&call); |
396 | async_serialize_start(); |
396 | async_serialize_start(); |
Line 439... | Line 439... | ||
439 | NULL, NULL); |
439 | NULL, NULL); |
440 | break; |
440 | break; |
441 | case CONSOLE_SET_STYLE: |
441 | case CONSOLE_SET_STYLE: |
442 | arg1 = IPC_GET_ARG1(call); |
442 | arg1 = IPC_GET_ARG1(call); |
443 | arg2 = IPC_GET_ARG2(call); |
443 | arg2 = IPC_GET_ARG2(call); |
444 | screenbuffer_set_style(&conn->screenbuffer,arg1, arg2); |
444 | screenbuffer_set_style(&conn->screenbuffer, arg1, arg2); |
445 | if (consnum == active_console) |
445 | if (consnum == active_console) |
446 | set_style_col(arg1, arg2); |
446 | set_style_col(arg1, arg2); |
447 | break; |
447 | break; |
448 | case CONSOLE_CURSOR_VISIBILITY: |
448 | case CONSOLE_CURSOR_VISIBILITY: |
449 | arg1 = IPC_GET_ARG1(call); |
449 | arg1 = IPC_GET_ARG1(call); |
Line 482... | Line 482... | ||
482 | 482 | ||
483 | async_set_client_connection(client_connection); |
483 | async_set_client_connection(client_connection); |
484 | 484 | ||
485 | /* Connect to keyboard driver */ |
485 | /* Connect to keyboard driver */ |
486 | 486 | ||
487 | while ((kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) |
487 | kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0); |
488 | < 0) { |
488 | while (kbd_phone < 0) { |
489 | usleep(10000); |
489 | usleep(10000); |
- | 490 | kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0); |
|
490 | } |
491 | } |
491 | 492 | ||
492 | if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phonehash) != 0) |
493 | if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phonehash) != 0) |
493 | { |
- | |
494 | return -1; |
494 | return -1; |
495 | } |
- | |
496 | async_new_connection(phonehash, 0, NULL, keyboard_events); |
495 | async_new_connection(phonehash, 0, NULL, keyboard_events); |
497 | 496 | ||
498 | /* Connect to framebuffer driver */ |
497 | /* Connect to framebuffer driver */ |
499 | 498 | ||
500 | while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) |
499 | fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0); |
501 | < 0) { |
500 | while (fb_info.phone < 0) { |
502 | usleep(10000); |
501 | usleep(10000); |
- | 502 | fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0); |
|
503 | } |
503 | } |
504 | 504 | ||
505 | /* Save old kernel screen */ |
505 | /* Save old kernel screen */ |
506 | kernel_pixmap = switch_screens(-1); |
506 | kernel_pixmap = switch_screens(-1); |
507 | 507 | ||
508 | /* Initialize gcons */ |
508 | /* Initialize gcons */ |
509 | gcons_init(fb_info.phone); |
509 | gcons_init(fb_info.phone); |
510 | /* Synchronize, the gcons can have something in queue */ |
510 | /* Synchronize, the gcons can have something in queue */ |
511 | async_req(fb_info.phone, FB_FLUSH, 0, NULL); |
511 | async_req(fb_info.phone, FB_FLUSH, 0, NULL); |
512 | /* Enable double buffering */ |
512 | /* Enable double buffering */ |
513 | async_msg_2(fb_info.phone, FB_VIEWPORT_DB, (sysarg_t)-1, 1); |
513 | async_msg_2(fb_info.phone, FB_VIEWPORT_DB, (sysarg_t) -1, 1); |
514 | 514 | ||
515 | async_req_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), |
515 | async_req_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), |
516 | &(fb_info.cols)); |
516 | &(fb_info.cols)); |
517 | set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND); |
517 | set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND); |
518 | clrscr(); |
518 | clrscr(); |
Line 527... | Line 527... | ||
527 | connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED; |
527 | connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED; |
528 | connections[i].keyrequest_counter = 0; |
528 | connections[i].keyrequest_counter = 0; |
529 | 529 | ||
530 | if (screenbuffer_init(&(connections[i].screenbuffer), |
530 | if (screenbuffer_init(&(connections[i].screenbuffer), |
531 | fb_info.cols, fb_info.rows) == NULL) { |
531 | fb_info.cols, fb_info.rows) == NULL) { |
532 | /*FIXME: handle error */ |
532 | /* FIXME: handle error */ |
533 | return -1; |
533 | return -1; |
534 | } |
534 | } |
535 | } |
535 | } |
536 | connections[KERNEL_CONSOLE].used = 1; |
536 | connections[KERNEL_CONSOLE].used = 1; |
537 | 537 | ||
- | 538 | interbuffer = mmap(NULL, |
|
538 | if ((interbuffer = mmap(NULL, sizeof(keyfield_t) * fb_info.cols * |
539 | sizeof(keyfield_t) * fb_info.cols * fb_info.rows, |
539 | fb_info.rows, PROTO_READ | PROTO_WRITE, MAP_ANONYMOUS | |
540 | PROTO_READ | PROTO_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); |
540 | MAP_PRIVATE, 0, 0)) != NULL) { |
541 | if (!interbuffer) { |
541 | if (async_req_3(fb_info.phone, IPC_M_AS_AREA_SEND, (ipcarg_t) |
542 | if (async_req_3(fb_info.phone, IPC_M_AS_AREA_SEND, (ipcarg_t) |
542 | interbuffer, 0, AS_AREA_READ, NULL, NULL, NULL) != 0) { |
543 | interbuffer, 0, AS_AREA_READ, NULL, NULL, NULL) != 0) { |
543 | munmap(interbuffer, sizeof(keyfield_t) * fb_info.cols |
544 | munmap(interbuffer, sizeof(keyfield_t) * fb_info.cols |
544 | * fb_info.rows); |
545 | * fb_info.rows); |
545 | interbuffer = NULL; |
546 | interbuffer = NULL; |
546 | } |
547 | } |
547 | } |
548 | } |
548 | 549 | ||
549 | curs_goto(0,0); |
550 | curs_goto(0, 0); |
550 | curs_visibility(connections[active_console].screenbuffer.is_cursor_visible); |
551 | curs_visibility(connections[active_console].screenbuffer.is_cursor_visible); |
551 | 552 | ||
552 | /* Register at NS */ |
553 | /* Register at NS */ |
553 | if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) { |
554 | if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) { |
554 | return -1; |
555 | return -1; |