Rev 4201 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4201 | Rev 4296 | ||
---|---|---|---|
Line 46... | Line 46... | ||
46 | #include <async.h> |
46 | #include <async.h> |
47 | #include <libadt/fifo.h> |
47 | #include <libadt/fifo.h> |
48 | #include <screenbuffer.h> |
48 | #include <screenbuffer.h> |
49 | #include <sys/mman.h> |
49 | #include <sys/mman.h> |
50 | #include <stdio.h> |
50 | #include <stdio.h> |
- | 51 | #include <string.h> |
|
51 | #include <sysinfo.h> |
52 | #include <sysinfo.h> |
52 | #include <event.h> |
53 | #include <event.h> |
53 | 54 | ||
54 | #include "console.h" |
55 | #include "console.h" |
55 | #include "gcons.h" |
56 | #include "gcons.h" |
Line 101... | Line 102... | ||
101 | #define CWRITE_BUF_SIZE 256 |
102 | #define CWRITE_BUF_SIZE 256 |
102 | 103 | ||
103 | /** Buffer for receiving data via the CONSOLE_WRITE call from the client. */ |
104 | /** Buffer for receiving data via the CONSOLE_WRITE call from the client. */ |
104 | static char cwrite_buf[CWRITE_BUF_SIZE]; |
105 | static char cwrite_buf[CWRITE_BUF_SIZE]; |
105 | 106 | ||
106 | static void fb_putchar(char c, int row, int col); |
107 | static void fb_putchar(wchar_t c, int row, int col); |
107 | 108 | ||
108 | 109 | ||
109 | /** Find unused virtual console. |
110 | /** Find unused virtual console. |
110 | * |
111 | * |
111 | */ |
112 | */ |
Line 195... | Line 196... | ||
195 | } else { |
196 | } else { |
196 | rc = ENOTSUP; |
197 | rc = ENOTSUP; |
197 | } |
198 | } |
198 | 199 | ||
199 | if (rc != 0) { |
200 | if (rc != 0) { |
- | 201 | /* |
|
200 | attrs = &conn->screenbuffer.attrs; |
202 | attrs = &conn->screenbuffer.attrs; |
201 | 203 | ||
202 | for (j = 0; j < h; j++) { |
204 | for (j = 0; j < h; j++) { |
203 | for (i = 0; i < w; i++) { |
205 | for (i = 0; i < w; i++) { |
204 | field = get_field_at(&conn->screenbuffer, |
206 | field = get_field_at(&conn->screenbuffer, |
Line 207... | Line 209... | ||
207 | set_attrs(&field->attrs); |
209 | set_attrs(&field->attrs); |
208 | attrs = &field->attrs; |
210 | attrs = &field->attrs; |
209 | 211 | ||
210 | fb_putchar(field->character, y + j, x + i); |
212 | fb_putchar(field->character, y + j, x + i); |
211 | } |
213 | } |
212 | } |
214 | }*/ |
213 | } |
215 | } |
214 | } |
216 | } |
215 | 217 | ||
216 | /** Flush pending cells to FB. */ |
218 | /** Flush pending cells to FB. */ |
217 | static void fb_pending_flush(void) |
219 | static void fb_pending_flush(void) |
Line 249... | Line 251... | ||
249 | ++fb_pending.n; |
251 | ++fb_pending.n; |
250 | } |
252 | } |
251 | 253 | ||
252 | 254 | ||
253 | /** Print a character to the active VC with buffering. */ |
255 | /** Print a character to the active VC with buffering. */ |
254 | static void fb_putchar(char c, int row, int col) |
256 | static void fb_putchar(wchar_t c, int row, int col) |
255 | { |
257 | { |
256 | async_msg_3(fb_info.phone, FB_PUTCHAR, c, row, col); |
258 | async_msg_3(fb_info.phone, FB_PUTCHAR, c, row, col); |
257 | } |
259 | } |
258 | 260 | ||
259 | /** Process a character from the client (TTY emulation). */ |
261 | /** Process a character from the client (TTY emulation). */ |
260 | static void write_char(int console, char key) |
262 | static void write_char(int console, wchar_t ch) |
261 | { |
263 | { |
262 | bool flush_cursor = false; |
264 | bool flush_cursor = false; |
263 | screenbuffer_t *scr = &(connections[console].screenbuffer); |
265 | screenbuffer_t *scr = &(connections[console].screenbuffer); |
264 | 266 | ||
265 | switch (key) { |
267 | switch (ch) { |
266 | case '\n': |
268 | case '\n': |
267 | fb_pending_flush(); |
269 | fb_pending_flush(); |
268 | flush_cursor = true; |
270 | flush_cursor = true; |
269 | scr->position_y++; |
271 | scr->position_y++; |
270 | scr->position_x = 0; |
272 | scr->position_x = 0; |
Line 285... | Line 287... | ||
285 | break; |
287 | break; |
286 | default: |
288 | default: |
287 | if (console == active_console) |
289 | if (console == active_console) |
288 | cell_mark_changed(scr->position_y, scr->position_x); |
290 | cell_mark_changed(scr->position_y, scr->position_x); |
289 | 291 | ||
290 | screenbuffer_putchar(scr, key); |
292 | screenbuffer_putchar(scr, ch); |
291 | scr->position_x++; |
293 | scr->position_x++; |
292 | } |
294 | } |
293 | 295 | ||
294 | if (scr->position_x >= scr->size_x) { |
296 | if (scr->position_x >= scr->size_x) { |
295 | flush_cursor = true; |
297 | flush_cursor = true; |
Line 432... | Line 434... | ||
432 | /* switch to another virtual console */ |
434 | /* switch to another virtual console */ |
433 | 435 | ||
434 | conn = &connections[active_console]; |
436 | conn = &connections[active_console]; |
435 | 437 | ||
436 | if ((ev.key >= KC_F1) && (ev.key < KC_F1 + |
438 | if ((ev.key >= KC_F1) && (ev.key < KC_F1 + |
437 | CONSOLE_COUNT)) { |
439 | CONSOLE_COUNT) && ((ev.mods & KM_CTRL) == 0)) { |
438 | if (ev.key == KC_F12) |
440 | if (ev.key == KC_F12) |
439 | change_console(KERNEL_CONSOLE); |
441 | change_console(KERNEL_CONSOLE); |
440 | else |
442 | else |
441 | change_console(ev.key - KC_F1); |
443 | change_console(ev.key - KC_F1); |
442 | break; |
444 | break; |
Line 463... | Line 465... | ||
463 | 465 | ||
464 | /** Handle CONSOLE_WRITE call. */ |
466 | /** Handle CONSOLE_WRITE call. */ |
465 | static void cons_write(int consnum, ipc_callid_t rid, ipc_call_t *request) |
467 | static void cons_write(int consnum, ipc_callid_t rid, ipc_call_t *request) |
466 | { |
468 | { |
467 | ipc_callid_t callid; |
469 | ipc_callid_t callid; |
468 | size_t len; |
470 | size_t size; |
- | 471 | wchar_t ch; |
|
469 | size_t i; |
472 | size_t off; |
470 | 473 | ||
471 | if (!ipc_data_write_receive(&callid, &len)) { |
474 | if (!ipc_data_write_receive(&callid, &size)) { |
472 | ipc_answer_0(callid, EINVAL); |
475 | ipc_answer_0(callid, EINVAL); |
473 | ipc_answer_0(rid, EINVAL); |
476 | ipc_answer_0(rid, EINVAL); |
474 | } |
477 | } |
475 | 478 | ||
476 | if (len > CWRITE_BUF_SIZE) |
479 | if (size > CWRITE_BUF_SIZE) |
477 | len = CWRITE_BUF_SIZE; |
480 | size = CWRITE_BUF_SIZE; |
478 | 481 | ||
479 | (void) ipc_data_write_finalize(callid, cwrite_buf, len); |
482 | (void) ipc_data_write_finalize(callid, cwrite_buf, size); |
480 | 483 | ||
- | 484 | off = 0; |
|
481 | for (i = 0; i < len; i++) { |
485 | while (off < size) { |
- | 486 | ch = str_decode(cwrite_buf, &off, size); |
|
482 | write_char(consnum, cwrite_buf[i]); |
487 | write_char(consnum, ch); |
483 | } |
488 | } |
484 | 489 | ||
485 | gcons_notify_char(consnum); |
490 | gcons_notify_char(consnum); |
486 | ipc_answer_1(rid, EOK, len); |
491 | ipc_answer_1(rid, EOK, size); |
487 | } |
492 | } |
488 | 493 | ||
489 | /** Default thread for new connections */ |
494 | /** Default thread for new connections */ |
490 | static void client_connection(ipc_callid_t iid, ipc_call_t *icall) |
495 | static void client_connection(ipc_callid_t iid, ipc_call_t *icall) |
491 | { |
496 | { |