48,6 → 48,7 |
#include <screenbuffer.h> |
#include <sys/mman.h> |
#include <stdio.h> |
#include <string.h> |
#include <sysinfo.h> |
#include <event.h> |
|
63,6 → 64,9 |
int active_console = 0; |
int prev_console = 0; |
|
/** Phone to the keyboard driver. */ |
static int kbd_phone; |
|
/** Information about framebuffer */ |
struct { |
int phone; /**< Framebuffer phone */ |
103,7 → 107,7 |
/** Buffer for receiving data via the CONSOLE_WRITE call from the client. */ |
static char cwrite_buf[CWRITE_BUF_SIZE]; |
|
static void fb_putchar(char c, int row, int col); |
static void fb_putchar(wchar_t c, int row, int col); |
|
|
/** Find unused virtual console. |
140,6 → 144,26 |
async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col); |
} |
|
static void screen_yield(void) |
{ |
ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_YIELD); |
} |
|
static void screen_reclaim(void) |
{ |
ipc_call_sync_0_0(fb_info.phone, FB_SCREEN_RECLAIM); |
} |
|
static void kbd_yield(void) |
{ |
ipc_call_sync_0_0(kbd_phone, KBD_YIELD); |
} |
|
static void kbd_reclaim(void) |
{ |
ipc_call_sync_0_0(kbd_phone, KBD_RECLAIM); |
} |
|
static void set_style(int style) |
{ |
async_msg_1(fb_info.phone, FB_SET_STYLE, style); |
197,6 → 221,7 |
} |
|
if (rc != 0) { |
/* |
attrs = &conn->screenbuffer.attrs; |
|
for (j = 0; j < h; j++) { |
209,9 → 234,9 |
|
fb_putchar(field->character, y + j, x + i); |
} |
}*/ |
} |
} |
} |
|
/** Flush pending cells to FB. */ |
static void fb_pending_flush(void) |
251,18 → 276,18 |
|
|
/** Print a character to the active VC with buffering. */ |
static void fb_putchar(char c, int row, int col) |
static void fb_putchar(wchar_t c, int row, int col) |
{ |
async_msg_3(fb_info.phone, FB_PUTCHAR, c, row, col); |
} |
|
/** Process a character from the client (TTY emulation). */ |
static void write_char(int console, char key) |
static void write_char(int console, wchar_t ch) |
{ |
bool flush_cursor = false; |
screenbuffer_t *scr = &(connections[console].screenbuffer); |
|
switch (key) { |
switch (ch) { |
case '\n': |
fb_pending_flush(); |
flush_cursor = true; |
287,7 → 312,7 |
if (console == active_console) |
cell_mark_changed(scr->position_y, scr->position_x); |
|
screenbuffer_putchar(scr, key); |
screenbuffer_putchar(scr, ch); |
scr->position_x++; |
} |
|
328,8 → 353,11 |
async_serialize_start(); |
curs_hide_sync(); |
gcons_in_kernel(); |
screen_yield(); |
kbd_yield(); |
async_serialize_end(); |
|
|
if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) { |
prev_console = active_console; |
active_console = KERNEL_CONSOLE; |
340,8 → 368,11 |
if (newcons != KERNEL_CONSOLE) { |
async_serialize_start(); |
|
if (active_console == KERNEL_CONSOLE) |
if (active_console == KERNEL_CONSOLE) { |
screen_reclaim(); |
kbd_reclaim(); |
gcons_redraw_console(); |
} |
|
active_console = newcons; |
gcons_change_console(newcons); |
434,7 → 465,7 |
conn = &connections[active_console]; |
|
if ((ev.key >= KC_F1) && (ev.key < KC_F1 + |
CONSOLE_COUNT)) { |
CONSOLE_COUNT) && ((ev.mods & KM_CTRL) == 0)) { |
if (ev.key == KC_F12) |
change_console(KERNEL_CONSOLE); |
else |
465,25 → 496,28 |
static void cons_write(int consnum, ipc_callid_t rid, ipc_call_t *request) |
{ |
ipc_callid_t callid; |
size_t len; |
size_t i; |
size_t size; |
wchar_t ch; |
size_t off; |
|
if (!ipc_data_write_receive(&callid, &len)) { |
if (!ipc_data_write_receive(&callid, &size)) { |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(rid, EINVAL); |
} |
|
if (len > CWRITE_BUF_SIZE) |
len = CWRITE_BUF_SIZE; |
if (size > CWRITE_BUF_SIZE) |
size = CWRITE_BUF_SIZE; |
|
(void) ipc_data_write_finalize(callid, cwrite_buf, len); |
(void) ipc_data_write_finalize(callid, cwrite_buf, size); |
|
for (i = 0; i < len; i++) { |
write_char(consnum, cwrite_buf[i]); |
off = 0; |
while (off < size) { |
ch = str_decode(cwrite_buf, &off, size); |
write_char(consnum, ch); |
} |
|
gcons_notify_char(consnum); |
ipc_answer_1(rid, EOK, len); |
ipc_answer_1(rid, EOK, size); |
} |
|
/** Default thread for new connections */ |
507,6 → 541,8 |
gcons_notify_connect(consnum); |
conn->client_phone = IPC_GET_ARG5(*icall); |
screenbuffer_clear(&conn->screenbuffer); |
if (consnum == active_console) |
clrscr(); |
|
/* Accept the connection */ |
ipc_answer_0(iid, EOK); |
644,7 → 680,6 |
printf(NAME ": HelenOS Console service\n"); |
|
ipcarg_t phonehash; |
int kbd_phone; |
size_t ib_size; |
int i; |
|