Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4346 → Rev 4347

/branches/dynload/uspace/srv/kbd/port/gxemul.c
39,6 → 39,7
#include <sysinfo.h>
#include <kbd_port.h>
#include <kbd.h>
#include <ddi.h>
 
static irq_cmd_t gxemul_cmds[] = {
{
63,7 → 64,7
{
async_set_interrupt_received(gxemul_irq_handler);
gxemul_cmds[0].addr = (void *) sysinfo_value("kbd.address.virtual");
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(),
0, &gxemul_kbd);
return 0;
}
/branches/dynload/uspace/srv/kbd/port/ns16550.c
99,7 → 99,7
ns16550_kernel = sysinfo_value("kbd.address.kernel");
ns16550_kbd.cmds[0].addr = (void *) (ns16550_kernel + LSR_REG);
ns16550_kbd.cmds[3].addr = (void *) (ns16550_kernel + RBR_REG);
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(),
0, &ns16550_kbd);
return pio_enable((void *) ns16550_physical, 8, &vaddr);
}
/branches/dynload/uspace/srv/kbd/port/msim.c
39,6 → 39,7
#include <sysinfo.h>
#include <kbd_port.h>
#include <kbd.h>
#include <ddi.h>
 
irq_cmd_t msim_cmds[] = {
{
63,7 → 64,7
{
async_set_interrupt_received(msim_irq_handler);
msim_cmds[0].addr = sysinfo_value("kbd.address.virtual");
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(),
0, &msim_kbd);
return 0;
}
/branches/dynload/uspace/srv/kbd/port/i8042.c
43,6 → 43,7
#include <sysinfo.h>
#include <kbd_port.h>
#include <kbd.h>
#include <ddi.h>
#include "i8042.h"
 
/* Interesting bits for status register */
136,7 → 137,7
/* Enable kbd */
i8042_kbd.cmds[0].addr = &((i8042_t *) i8042_kernel)->status;
i8042_kbd.cmds[3].addr = &((i8042_t *) i8042_kernel)->data;
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &i8042_kbd);
ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(), 0, &i8042_kbd);
 
int newcontrol = i8042_KBD_IE | i8042_KBD_TRANSLATE;
if (mouseenabled)
/branches/dynload/uspace/srv/kbd/port/z8530.c
89,7 → 89,7
CHAN_A_STATUS;
z8530_cmds[3].addr = (void *) sysinfo_value("kbd.address.kernel") +
CHAN_A_DATA;
ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
ipc_register_irq(sysinfo_value("kbd.inr"), device_assign_devno(),
sysinfo_value("kbd.inr"), &z8530_kbd);
return 0;
}
/branches/dynload/uspace/srv/console/console.c
49,6 → 49,7
#include <sys/mman.h>
#include <stdio.h>
#include <sysinfo.h>
#include <event.h>
 
#include "console.h"
#include "gcons.h"
62,8 → 63,7
int active_console = 0;
int prev_console = 0;
 
/** Information about framebuffer
*/
/** Information about framebuffer */
struct {
int phone; /**< Framebuffer phone */
ipcarg_t rows; /**< Framebuffer rows */
90,7 → 90,22
* faster virtual console
* switching */
 
/** 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. */
} 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(char c, int row, int col);
 
 
/** Find unused virtual console.
*
*/
158,21 → 173,99
}
}
 
static void prtchr(char c, int row, int col)
/** 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)
{
async_msg_3(fb_info.phone, FB_PUTCHAR, c, row, col);
int i, j;
int rc;
attrs_t *attrs;
keyfield_t *field;
 
if (interbuffer) {
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);
}
}
 
rc = 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);
}
}
}
}
 
/** Check key and process special keys.
/** Flush pending cells to FB. */
static void fb_pending_flush(void)
{
screenbuffer_t *scr;
 
scr = &(connections[active_console].screenbuffer);
 
if (fb_pending.n > 0) {
fb_update_area(&connections[active_console], fb_pending.col,
fb_pending.row, fb_pending.n, 1);
fb_pending.n = 0;
}
}
 
/** Mark a character cell as changed.
*
*
* 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) {
fb_pending_flush();
}
}
 
if (fb_pending.n == 0) {
fb_pending.row = row;
fb_pending.col = col;
}
 
++fb_pending.n;
}
 
 
/** Print a character to the active VC with buffering. */
static void fb_putchar(char 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)
{
bool flush_cursor = false;
screenbuffer_t *scr = &(connections[console].screenbuffer);
 
switch (key) {
case '\n':
fb_pending_flush();
flush_cursor = true;
scr->position_y++;
scr->position_x = 0;
break;
187,20 → 280,24
break;
scr->position_x--;
if (console == active_console)
prtchr(' ', scr->position_y, scr->position_x);
cell_mark_changed(scr->position_y, scr->position_x);
screenbuffer_putchar(scr, ' ');
break;
default:
if (console == active_console)
prtchr(key, scr->position_y, scr->position_x);
cell_mark_changed(scr->position_y, scr->position_x);
 
screenbuffer_putchar(scr, key);
scr->position_x++;
}
 
if (scr->position_x >= scr->size_x) {
flush_cursor = true;
scr->position_y++;
}
scr->position_y += (scr->position_x >= scr->size_x);
if (scr->position_y >= scr->size_y) {
fb_pending_flush();
scr->position_y = scr->size_y - 1;
screenbuffer_clear_line(scr, scr->top_line);
scr->top_line = (scr->top_line + 1) % scr->size_y;
207,12 → 304,11
if (console == active_console)
async_msg_1(fb_info.phone, FB_SCROLL, 1);
}
 
scr->position_x = scr->position_x % scr->size_x;
if (console == active_console)
 
if (console == active_console && flush_cursor)
curs_goto(scr->position_y, scr->position_x);
}
 
/** Switch to new console */
225,7 → 321,9
if (newcons == active_console)
return;
 
fb_pending_flush();
 
if (newcons == KERNEL_CONSOLE) {
async_serialize_start();
curs_hide_sync();
252,16 → 350,19
set_attrs(&conn->screenbuffer.attrs);
curs_visibility(false);
if (interbuffer) {
for (i = 0; i < conn->screenbuffer.size_x; i++)
for (j = 0; j < conn->screenbuffer.size_y; j++) {
for (j = 0; j < conn->screenbuffer.size_y; j++) {
for (i = 0; i < conn->screenbuffer.size_x; i++) {
unsigned int size_x;
size_x = conn->screenbuffer.size_x;
interbuffer[i + j * size_x] =
interbuffer[j * size_x + i] =
*get_field_at(&conn->screenbuffer, i, j);
}
}
/* This call can preempt, but we are already at the end */
rc = async_req_0_0(fb_info.phone, FB_DRAW_TEXT_DATA);
rc = async_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,
0, 0, conn->screenbuffer.size_x,
conn->screenbuffer.size_y);
}
if ((!interbuffer) || (rc != 0)) {
280,7 → 381,7
conn->screenbuffer.attrs)))
continue;
 
prtchr(field->character, j, i);
fb_putchar(field->character, j, i);
}
}
360,6 → 461,31
}
}
 
/** Handle CONSOLE_WRITE call. */
static void cons_write(int consnum, ipc_callid_t rid, ipc_call_t *request)
{
ipc_callid_t callid;
size_t len;
size_t i;
 
if (!ipc_data_write_receive(&callid, &len)) {
ipc_answer_0(callid, EINVAL);
ipc_answer_0(rid, EINVAL);
}
 
if (len > CWRITE_BUF_SIZE)
len = CWRITE_BUF_SIZE;
 
(void) ipc_data_write_finalize(callid, cwrite_buf, len);
 
for (i = 0; i < len; i++) {
write_char(consnum, cwrite_buf[i]);
}
 
gcons_notify_char(consnum);
ipc_answer_1(rid, EOK, len);
}
 
/** Default thread for new connections */
static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
{
368,6 → 494,7
int consnum;
ipcarg_t arg1, arg2, arg3, arg4;
connection_t *conn;
screenbuffer_t *scr;
if ((consnum = find_free_connection()) == -1) {
ipc_answer_0(iid, ELIMIT);
411,6 → 538,9
write_char(consnum, IPC_GET_ARG1(call));
gcons_notify_char(consnum);
break;
case CONSOLE_WRITE:
cons_write(consnum, callid, &call);
continue;
case CONSOLE_CLEAR:
/* Send message to fb */
if (consnum == active_console) {
432,10 → 562,16
arg2 = fb_info.cols;
break;
case CONSOLE_FLUSH:
if (consnum == active_console)
fb_pending_flush();
if (consnum == active_console) {
async_req_0_0(fb_info.phone, FB_FLUSH);
 
scr = &(connections[consnum].screenbuffer);
curs_goto(scr->position_y, scr->position_x);
}
break;
case CONSOLE_SET_STYLE:
fb_pending_flush();
arg1 = IPC_GET_ARG1(call);
screenbuffer_set_style(&conn->screenbuffer, arg1);
if (consnum == active_console)
442,6 → 578,7
set_style(arg1);
break;
case CONSOLE_SET_COLOR:
fb_pending_flush();
arg1 = IPC_GET_ARG1(call);
arg2 = IPC_GET_ARG2(call);
arg3 = IPC_GET_ARG3(call);
451,6 → 588,7
set_color(arg1, arg2, arg3);
break;
case CONSOLE_SET_RGB_COLOR:
fb_pending_flush();
arg1 = IPC_GET_ARG1(call);
arg2 = IPC_GET_ARG2(call);
screenbuffer_set_rgb_color(&conn->screenbuffer, arg1,
459,6 → 597,7
set_rgb_color(arg1, arg2);
break;
case CONSOLE_CURSOR_VISIBILITY:
fb_pending_flush();
arg1 = IPC_GET_ARG1(call);
conn->screenbuffer.is_cursor_visible = arg1;
if (consnum == active_console)
487,6 → 626,9
arg3 = ev.mods;
arg4 = ev.c;
break;
case CONSOLE_KCON_ENABLE:
change_console(KERNEL_CONSOLE);
break;
}
ipc_answer_4(callid, EOK, arg1, arg2, arg3, arg4);
}
564,6 → 706,8
ib_size = sizeof(keyfield_t) * fb_info.cols * fb_info.rows;
interbuffer = as_get_mappable_page(ib_size);
 
fb_pending.n = 0;
 
if (as_area_create(interbuffer, ib_size, AS_AREA_READ |
AS_AREA_WRITE | AS_AREA_CACHEABLE) != interbuffer) {
interbuffer = NULL;
586,14 → 730,10
return -1;
/* Receive kernel notifications */
if (sysinfo_value("kconsole.present")) {
int devno = sysinfo_value("kconsole.devno");
int inr = sysinfo_value("kconsole.inr");
if (ipc_register_irq(inr, devno, 0, NULL) != EOK)
printf(NAME ": Error registering kconsole notifications\n");
if (event_subscribe(EVENT_KCONSOLE, 0) != EOK)
printf(NAME ": Error registering kconsole notifications\n");
async_set_interrupt_received(interrupt_received);
}
async_set_interrupt_received(interrupt_received);
// FIXME: avoid connectiong to itself, keep using klog
// printf(NAME ": Accepting connections\n");
/branches/dynload/uspace/srv/loader/main.c
53,6 → 53,7
#include <ipc/services.h>
#include <ipc/loader.h>
#include <loader/pcb.h>
#include <console.h>
#include <errno.h>
#include <async.h>
#include <as.h>
290,13 → 291,13
/* Dynamically linked program */
DPRINTF("Run ELF interpreter.\n");
DPRINTF("Entry point: 0x%lx\n", interp_info.entry);
close_console();
console_close();
ipc_answer_0(rid, EOK);
program_run(interp_info.entry, &pcb);
} else {
/* Statically linked program */
close_console();
console_close();
ipc_answer_0(rid, EOK);
program_run(prog_info.entry, &pcb);
}
/branches/dynload/uspace/srv/fb/serial_console.c
223,26 → 223,48
}
}
 
static void draw_text_data(keyfield_t *data)
/** Draw text data to viewport.
*
* @param vport Viewport id
* @param data Text data.
* @param x Leftmost column of the area.
* @param y Topmost row of the area.
* @param w Number of rows.
* @param h Number of columns.
*/
static void draw_text_data(keyfield_t *data, unsigned int x,
unsigned int y, unsigned int w, unsigned int h)
{
int i, j;
unsigned int i, j;
keyfield_t *field;
attrs_t *a0, *a1;
 
serial_goto(0, 0);
serial_goto(y, x);
a0 = &data[0].attrs;
serial_set_attrs(a0);
 
for (i = 0; i < scr_height; i++) {
for (j = 0; j < scr_width; j++) {
a1 = &data[i * scr_width + j].attrs;
for (j = 0; j < h; j++) {
if (j > 0 && w != scr_width)
serial_goto(y, x);
 
for (i = 0; i < w; i++) {
unsigned int col = x + i;
unsigned int row = y + j;
 
field = &data[j * w + i];
 
a1 = &field->attrs;
if (!attrs_same(*a0, *a1))
serial_set_attrs(a1);
(*putc_function)(data[i * scr_width + j].character);
(*putc_function)(field->character);
a0 = a1;
}
}
}
 
int lastcol = 0;
int lastrow = 0;
 
/**
* Main function of the thread serving client connections.
*/
255,10 → 277,7
size_t intersize = 0;
 
char c;
int lastcol = 0;
int lastrow = 0;
int newcol;
int newrow;
int col, row, w, h;
int fgcolor;
int bgcolor;
int flags;
299,30 → 318,40
retval = EINVAL;
break;
case FB_DRAW_TEXT_DATA:
col = IPC_GET_ARG1(call);
row = IPC_GET_ARG2(call);
w = IPC_GET_ARG3(call);
h = IPC_GET_ARG4(call);
if (!interbuf) {
retval = EINVAL;
break;
}
draw_text_data(interbuf);
if (col + w > scr_width || row + h > scr_height) {
retval = EINVAL;
break;
}
draw_text_data(interbuf, col, row, w, h);
lastrow = row + h - 1;
lastcol = col + w;
retval = 0;
break;
case FB_PUTCHAR:
c = IPC_GET_ARG1(call);
newrow = IPC_GET_ARG2(call);
newcol = IPC_GET_ARG3(call);
if ((lastcol != newcol) || (lastrow != newrow))
serial_goto(newrow, newcol);
lastcol = newcol + 1;
lastrow = newrow;
row = IPC_GET_ARG2(call);
col = IPC_GET_ARG3(call);
if ((lastcol != col) || (lastrow != row))
serial_goto(row, col);
lastcol = col + 1;
lastrow = row;
(*putc_function)(c);
retval = 0;
break;
case FB_CURSOR_GOTO:
newrow = IPC_GET_ARG1(call);
newcol = IPC_GET_ARG2(call);
serial_goto(newrow, newcol);
lastrow = newrow;
lastcol = newcol;
row = IPC_GET_ARG1(call);
col = IPC_GET_ARG2(call);
serial_goto(row, col);
lastrow = row;
lastcol = col;
retval = 0;
break;
case FB_GET_CSIZE:
/branches/dynload/uspace/srv/fb/msim.c
45,7 → 45,7
#include "msim.h"
 
#define WIDTH 80
#define HEIGHT 25
#define HEIGHT 24
 
static char *virt_addr;
 
/branches/dynload/uspace/srv/fb/ski.c
47,7 → 47,7
#define SKI_PUTCHAR 31
 
#define WIDTH 80
#define HEIGHT 25
#define HEIGHT 24
 
/** Display character on ski debug console
*
/branches/dynload/uspace/srv/fb/fb.c
866,35 → 866,40
cursor_show(vport);
}
 
 
/** Draw text data to viewport
/** Draw text data to viewport.
*
* @param vport Viewport id
* @param data Text data fitting exactly into viewport
*
* @param data Text data.
* @param x Leftmost column of the area.
* @param y Topmost row of the area.
* @param w Number of rows.
* @param h Number of columns.
*/
static void draw_text_data(viewport_t *vport, keyfield_t *data)
static void draw_text_data(viewport_t *vport, keyfield_t *data, unsigned int x,
unsigned int y, unsigned int w, unsigned int h)
{
unsigned int i;
unsigned int i, j;
bb_cell_t *bbp;
attrs_t *a;
attr_rgb_t rgb;
for (i = 0; i < vport->cols * vport->rows; i++) {
unsigned int col = i % vport->cols;
unsigned int row = i / vport->cols;
bbp = &vport->backbuf[BB_POS(vport, col, row)];
uint8_t glyph = bbp->glyph;
 
a = &data[i].attrs;
rgb_from_attr(&rgb, a);
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
unsigned int col = x + i;
unsigned int row = y + j;
 
bbp->glyph = data[i].character;
bbp->fg_color = rgb.fg_color;
bbp->bg_color = rgb.bg_color;
bbp = &vport->backbuf[BB_POS(vport, col, row)];
uint8_t glyph = bbp->glyph;
 
draw_vp_glyph(vport, false, col, row);
a = &data[j * w + i].attrs;
rgb_from_attr(&rgb, a);
 
bbp->glyph = data[j * w + i].character;
bbp->fg_color = rgb.fg_color;
bbp->bg_color = rgb.bg_color;
 
draw_vp_glyph(vport, false, col, row);
}
}
cursor_show(vport);
}
998,6 → 1003,8
viewport_t *vport = &viewports[vp];
unsigned int x;
unsigned int y;
unsigned int w;
unsigned int h;
switch (IPC_GET_METHOD(*call)) {
case IPC_M_SHARE_OUT:
1058,15 → 1065,23
IPC_GET_ARG2(*call), vport->width - x, vport->height - y, putpixel, (void *) vport);
break;
case FB_DRAW_TEXT_DATA:
x = IPC_GET_ARG1(*call);
y = IPC_GET_ARG2(*call);
w = IPC_GET_ARG3(*call);
h = IPC_GET_ARG4(*call);
if (!interbuffer) {
retval = EINVAL;
break;
}
if (intersize < vport->cols * vport->rows * sizeof(*interbuffer)) {
if (x + w > vport->cols || y + h > vport->rows) {
retval = EINVAL;
break;
}
draw_text_data(vport, interbuffer);
if (intersize < w * h * sizeof(*interbuffer)) {
retval = EINVAL;
break;
}
draw_text_data(vport, interbuffer, x, y, w, h);
break;
default:
handled = false;
/branches/dynload/uspace/srv/fb/ega.c
78,7 → 78,7
 
static unsigned int scr_width;
static unsigned int scr_height;
static char *scr_addr;
static uint8_t *scr_addr;
 
static unsigned int style;
 
151,13 → 151,30
cursor_goto(row, col + 1);
}
 
static void draw_text_data(keyfield_t *data)
/** Draw text data to viewport.
*
* @param vport Viewport id
* @param data Text data.
* @param x Leftmost column of the area.
* @param y Topmost row of the area.
* @param w Number of rows.
* @param h Number of columns.
*/
static void draw_text_data(keyfield_t *data, unsigned int x,
unsigned int y, unsigned int w, unsigned int h)
{
int i;
unsigned int i, j;
keyfield_t *field;
uint8_t *dp;
 
for (i = 0; i < scr_width * scr_height; i++) {
scr_addr[i * 2] = data[i].character;
scr_addr[i * 2 + 1] = attr_to_ega_style(&data[i].attrs);
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
field = &data[j * w + i];
dp = &scr_addr[2 * ((y + j) * scr_width + (x + i))];
 
dp[0] = field->character;
dp[1] = attr_to_ega_style(&field->attrs);
}
}
}
 
237,7 → 254,7
ipc_callid_t callid;
ipc_call_t call;
char c;
unsigned int row, col;
unsigned int row, col, w, h;
int bg_color, fg_color, attr;
uint32_t bg_rgb, fg_rgb;
keyfield_t *interbuf = NULL;
270,11 → 287,19
retval = EINVAL;
break;
case FB_DRAW_TEXT_DATA:
col = IPC_GET_ARG1(call);
row = IPC_GET_ARG2(call);
w = IPC_GET_ARG3(call);
h = IPC_GET_ARG4(call);
if (!interbuf) {
retval = EINVAL;
break;
}
draw_text_data(interbuf);
if (col + w > scr_width || row + h > scr_height) {
retval = EINVAL;
break;
}
draw_text_data(interbuf, col, row, w, h);
retval = 0;
break;
case FB_GET_CSIZE:
359,7 → 384,7
break;
 
default:
retval = ENOENT;
retval = EINVAL;
}
ipc_answer_0(callid, retval);
}
/branches/dynload/uspace/srv/vfs/vfs_ops.c
343,6 → 343,7
pr->callid = callid;
pr->rid = rid;
pr->dev_handle = dev_handle;
link_initialize(&pr->link);
list_append(&pr->link, &pending_req);
return;
}