Subversion Repositories HelenOS

Compare Revisions

Regard whitespace Rev 4438 → Rev 4439

/branches/dd/uspace/srv/console/console.c
55,9 → 55,12
#include "console.h"
#include "gcons.h"
 
#define NAME "console"
 
#define MAX_KEYREQUESTS_BUFFERED 32
 
#define NAME "console"
/** Size of cwrite_buf. */
#define CWRITE_BUF_SIZE 256
 
/** Index of currently used virtual console.
*/
76,40 → 79,36
 
typedef struct {
keybuffer_t keybuffer; /**< Buffer for incoming keys. */
/** Buffer for unsatisfied request for keys. */
FIFO_CREATE_STATIC(keyrequests, ipc_callid_t,
MAX_KEYREQUESTS_BUFFERED);
int keyrequest_counter; /**< Number of requests in buffer. */
int client_phone; /**< Phone to connected client. */
int used; /**< 1 if this virtual console is
* connected to some client.*/
connected to some client. */
screenbuffer_t screenbuffer; /**< Screenbuffer for saving screen
* contents and related settings. */
contents and related settings. */
} connection_t;
 
static connection_t connections[CONSOLE_COUNT]; /**< Array of data for virtual
* consoles */
static keyfield_t *interbuffer = NULL; /**< Pointer to memory shared
* with framebufer used for
* faster virtual console
* switching */
/** Array of data for virtual consoles */
static connection_t connections[CONSOLE_COUNT];
 
/** Pointer to memory shared with framebufer used for
faster virtual console switching */
static keyfield_t *interbuffer = NULL;
 
/** Information on row-span yet unsent to FB driver. */
struct {
int row; /**< Row where the span lies. */
int col; /**< Leftmost column of the span. */
int n; /**< Width of the span. */
int cnt; /**< Width of the span. */
} fb_pending;
 
/** Size of cwrite_buf. */
#define CWRITE_BUF_SIZE 256
 
/** Buffer for receiving data via the CONSOLE_WRITE call from the client. */
static char cwrite_buf[CWRITE_BUF_SIZE];
 
static void fb_putchar(wchar_t c, int row, int col);
 
 
/** Find unused virtual console.
*
*/
121,6 → 120,7
if (!connections[i].used)
return i;
}
return -1;
}
 
185,12 → 185,10
case at_style:
set_style(attrs->a.s.style);
break;
 
case at_idx:
set_color(attrs->a.i.fg_color, attrs->a.i.bg_color,
attrs->a.i.flags);
break;
 
case at_rgb:
set_rgb_color(attrs->a.r.fg_color, attrs->a.r.bg_color);
break;
200,8 → 198,8
/** Send an area of screenbuffer to the FB driver. */
static void fb_update_area(connection_t *conn, int x, int y, int w, int h)
{
int i, j;
int rc;
int i;
int j;
attrs_t *attrs;
keyfield_t *field;
 
209,46 → 207,25
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
interbuffer[i + j * w] =
*get_field_at(&conn->screenbuffer,
x + i, y + j);
*get_field_at(&conn->screenbuffer, x + i, y + j);
}
}
 
rc = async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
x, y, w, h);
} else {
rc = ENOTSUP;
}
 
if (rc != 0) {
/*
attrs = &conn->screenbuffer.attrs;
 
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
field = get_field_at(&conn->screenbuffer,
x + i, y + j);
if (!attrs_same(*attrs, field->attrs))
set_attrs(&field->attrs);
attrs = &field->attrs;
 
fb_putchar(field->character, y + j, x + i);
}
}*/
}
}
 
/** Flush pending cells to FB. */
static void fb_pending_flush(void)
{
screenbuffer_t *scr;
screenbuffer_t *scr
= &(connections[active_console].screenbuffer);
 
scr = &(connections[active_console].screenbuffer);
 
if (fb_pending.n > 0) {
if (fb_pending.cnt > 0) {
fb_update_area(&connections[active_console], fb_pending.col,
fb_pending.row, fb_pending.n, 1);
fb_pending.n = 0;
fb_pending.row, fb_pending.cnt, 1);
fb_pending.cnt = 0;
}
}
 
256,25 → 233,25
*
* This adds the cell to the pending rowspan if possible. Otherwise
* the old span is flushed first.
*
*/
static void cell_mark_changed(int row, int col)
{
if (fb_pending.n != 0) {
if (row != fb_pending.row ||
col != fb_pending.col + fb_pending.n) {
if (fb_pending.cnt != 0) {
if ((row != fb_pending.row)
|| (col != fb_pending.col + fb_pending.cnt)) {
fb_pending_flush();
}
}
 
if (fb_pending.n == 0) {
if (fb_pending.cnt == 0) {
fb_pending.row = row;
fb_pending.col = col;
}
 
++fb_pending.n;
fb_pending.cnt++;
}
 
 
/** Print a character to the active VC with buffering. */
static void fb_putchar(wchar_t c, int row, int col)
{
340,7 → 317,9
static void change_console(int newcons)
{
connection_t *conn;
int i, j, rc;
int i;
int j;
int rc;
keyfield_t *field;
attrs_t *attrs;
408,8 → 387,7
set_attrs(&field->attrs);
attrs = &field->attrs;
if ((field->character == ' ') &&
(attrs_same(field->attrs,
conn->screenbuffer.attrs)))
(attrs_same(field->attrs, conn->screenbuffer.attrs)))
continue;
 
fb_putchar(field->character, j, i);
435,7 → 413,7
int newcon;
/* Ignore parameters, the connection is alread opened */
while (1) {
while (true) {
callid = async_get_call(&call);
switch (IPC_GET_METHOD(call)) {
case IPC_M_PHONE_HUNGUP:
460,8 → 438,7
ev.mods = IPC_GET_ARG3(call);
ev.c = IPC_GET_ARG4(call);
/* switch to another virtual console */
/* Switch to another virtual console */
conn = &connections[active_console];
 
if ((ev.key >= KC_F1) && (ev.key < KC_F1 +
473,7 → 450,7
break;
}
/* if client is awaiting key, send it */
/* If client is awaiting key, send it */
if (conn->keyrequest_counter > 0) {
conn->keyrequest_counter--;
ipc_answer_4(fifo_pop(conn->keyrequests), EOK,
552,7 → 529,7
/* Accept the connection */
ipc_answer_0(iid, EOK);
while (1) {
while (true) {
async_serialize_end();
callid = async_get_call(&call);
async_serialize_start();
748,7 → 725,7
ib_size = sizeof(keyfield_t) * fb_info.cols * fb_info.rows;
interbuffer = as_get_mappable_page(ib_size);
 
fb_pending.n = 0;
fb_pending.cnt = 0;
 
if (as_area_create(interbuffer, ib_size, AS_AREA_READ |
AS_AREA_WRITE | AS_AREA_CACHEABLE) != interbuffer) {