Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4347 → Rev 4348

/branches/dynload/uspace/srv/console/console.c
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,7 → 234,7
 
fb_putchar(field->character, y + j, x + i);
}
}
}*/
}
}
 
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,7 → 353,10
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;
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;
/branches/dynload/uspace/srv/console/screenbuffer.c
43,13 → 43,13
* @param scr screenbuffer
* @param c stored character
*/
void screenbuffer_putchar(screenbuffer_t *scr, char c)
void screenbuffer_putchar(screenbuffer_t *scr, wchar_t ch)
{
keyfield_t *field;
 
field = get_field_at(scr, scr->position_x, scr->position_y);
 
field->character = c;
field->character = ch;
field->attrs = scr->attrs;
}
 
/branches/dynload/uspace/srv/console/screenbuffer.h
36,6 → 36,7
#define __SCREENBUFFER_H__
 
#include <stdint.h>
#include <sys/types.h>
 
#define DEFAULT_FOREGROUND 0x0 /**< default console foreground color */
#define DEFAULT_BACKGROUND 0xf0f0f0 /**< default console background color */
70,7 → 71,7
 
/** One field on screen. It contain one character and its attributes. */
typedef struct {
char character; /**< Character itself */
wchar_t character; /**< Character itself */
attrs_t attrs; /**< Character`s attributes */
} keyfield_t;
 
91,7 → 92,7
* @param y position on screen
* @return keyfield structure with character and its attributes on x,y
*/
static inline keyfield_t *get_field_at(screenbuffer_t *scr, unsigned int x, unsigned int y)
static inline keyfield_t *get_field_at(screenbuffer_t *scr, unsigned int x, unsigned int y)
{
return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x;
}
116,7 → 117,7
}
 
 
void screenbuffer_putchar(screenbuffer_t *scr, char c);
void screenbuffer_putchar(screenbuffer_t *scr, wchar_t c);
screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y);
 
void screenbuffer_clear(screenbuffer_t *scr);