Subversion Repositories HelenOS

Compare Revisions

Regard whitespace Rev 2015 → Rev 2025

/trunk/uspace/fb/fb.c
161,13 → 161,15
 
static void bgr_byte0888(void *dst, int rgb)
{
*((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | RED(rgb, 8);
*((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 |
RED(rgb, 8);
}
 
static int byte0888_bgr(void *src)
{
int color = *(uint32_t *)(src);
return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color >> 16) & 0xff);
return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color
>> 16) & 0xff);
}
 
static void rgb_byte888(void *dst, int rgb)
198,7 → 200,8
static void rgb_byte555(void *dst, int rgb)
{
/* 5-bit, 5-bits, 5-bits */
*((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, 5);
*((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 |
BLUE(rgb, 5);
}
 
/** 16-bit depth (5:5:5) */
205,7 → 208,8
static int byte555_rgb(void *src)
{
int color = *(uint16_t *)(src);
return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3);
return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) <<
(8 + 3)) | ((color & 0x1f) << 3);
}
 
/** 16-bit depth (5:6:5) */
212,7 → 216,8
static void rgb_byte565(void *dst, int rgb)
{
/* 5-bit, 6-bits, 5-bits */
*((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5);
*((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 |
BLUE(rgb, 5);
}
 
/** 16-bit depth (5:6:5) */
219,7 → 224,8
static int byte565_rgb(void *src)
{
int color = *(uint16_t *)(src);
return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) <<
(8 + 2)) | ((color & 0x1f) << 3);
}
 
/** Put pixel - 8-bit depth (3:2:3) */
232,7 → 238,8
static int byte8_rgb(void *src)
{
int color = *(uint8_t *)src;
return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) <<
(8 + 6)) | ((color & 0x7) << 5);
}
 
/** Put pixel into viewport
242,7 → 249,8
* @param y Y coord relative to viewport
* @param color RGB color
*/
static void putpixel(viewport_t *vport, unsigned int x, unsigned int y, int color)
static void putpixel(viewport_t *vport, unsigned int x, unsigned int y, int
color)
{
int dx = vport->x + x;
int dy = vport->y + y;
266,15 → 274,14
return COLOR((*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]));
}
 
static inline void putpixel_mem(char *mem, unsigned int x, unsigned int y,
int color)
static inline void putpixel_mem(char *mem, unsigned int x, unsigned int y, int
color)
{
(*screen.rgb2scr)(&mem[POINTPOS(x,y)], COLOR(color));
}
 
static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
unsigned int width, unsigned int height,
int color)
unsigned int width, unsigned int height, int color)
{
unsigned int x, y;
static void *tmpline;
298,8 → 305,10
if (vport->dbdata) {
for (y=sy;y < sy+height; y++) {
int rline = (y + vport->dboffset) % vport->height;
int rpos = (rline * vport->width + sx) * screen.pixelbytes;
memcpy(&vport->dbdata[rpos], tmpline, screen.pixelbytes * width);
int rpos = (rline * vport->width + sx) *
screen.pixelbytes;
memcpy(&vport->dbdata[rpos], tmpline,
screen.pixelbytes * width);
}
}
 
308,7 → 317,8
/** Fill viewport with background color */
static void clear_port(viewport_t *vport)
{
draw_rectangle(vport, 0, 0, vport->width, vport->height, vport->style.bg_color);
draw_rectangle(vport, 0, 0, vport->width, vport->height,
vport->style.bg_color);
}
 
/** Scroll unbuffered viewport up/down
325,15 → 335,17
memcpy(&screen.fbaddress[POINTPOS(vport->x,y)],
&screen.fbaddress[POINTPOS(vport->x,y + lines)],
screen.pixelbytes * vport->width);
draw_rectangle(vport, 0, vport->height - lines,
vport->width, lines, vport->style.bg_color);
draw_rectangle(vport, 0, vport->height - lines, vport->width,
lines, vport->style.bg_color);
} else if (lines < 0) {
lines = -lines;
for (y=vport->y + vport->height-1; y >= vport->y + lines; y--)
for (y = vport->y + vport->height-1; y >= vport->y + lines;
y--)
memcpy(&screen.fbaddress[POINTPOS(vport->x,y)],
&screen.fbaddress[POINTPOS(vport->x,y - lines)],
screen.pixelbytes * vport->width);
draw_rectangle(vport, 0, 0, vport->width, lines, vport->style.bg_color);
draw_rectangle(vport, 0, 0, vport->width, lines,
vport->style.bg_color);
}
}
 
407,8 → 419,8
* @param style Color of the character
* @param transparent If false, print background color
*/
static void draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx, unsigned int sy,
style_t style, int transparent)
static void draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx,
unsigned int sy, style_t style, int transparent)
{
int i;
unsigned int y;
418,9 → 430,11
glline = fb_font[glyph * FONT_SCANLINES + y];
for (i = 0; i < 8; i++) {
if (glline & (1 << (7 - i)))
putpixel(vport, sx + i, sy + y, style.fg_color);
putpixel(vport, sx + i, sy + y,
style.fg_color);
else if (!transparent)
putpixel(vport, sx + i, sy + y, style.bg_color);
putpixel(vport, sx + i, sy + y,
style.bg_color);
}
}
}
433,7 → 447,8
 
for (x = 0; x < COL_WIDTH; x++)
for (y = 0; y < FONT_SCANLINES; y++)
invert_pixel(vport, col * COL_WIDTH + x, row * FONT_SCANLINES + y);
invert_pixel(vport, col * COL_WIDTH + x, row *
FONT_SCANLINES + y);
}
 
/***************************************************************/
487,7 → 502,8
* @param invert_colors Inverted colors.
*
*/
static bool screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int scan, unsigned int visual, bool invert_colors)
static bool screen_init(void *addr, unsigned int xres, unsigned int yres,
unsigned int scan, unsigned int visual, bool invert_colors)
{
switch (visual) {
case VISUAL_INDIRECT_8:
577,8 → 593,8
* @param col Screen position relative to viewport
* @param transparent If false, print background color with character
*/
static void draw_char(viewport_t *vport, char c, unsigned int row, unsigned int col,
style_t style, int transparent)
static void draw_char(viewport_t *vport, char c, unsigned int row, unsigned int
col, style_t style, int transparent)
{
/* Optimize - do not hide cursor if we are going to overwrite it */
if (vport->cursor_active && vport->cursor_shown &&
585,7 → 601,8
(vport->cur_col != col || vport->cur_row != row))
invert_char(vport, vport->cur_row, vport->cur_col);
draw_glyph(vport, c, col * COL_WIDTH, row * FONT_SCANLINES, style, transparent);
draw_glyph(vport, c, col * COL_WIDTH, row * FONT_SCANLINES, style,
transparent);
 
vport->cur_col = col;
vport->cur_row = row;
612,12 → 629,14
 
clear_port(vport);
for (i=0; i < vport->cols * vport->rows; i++) {
if (data[i].character == ' ' && style_same(data[i].style,vport->style))
if (data[i].character == ' ' && style_same(data[i].style,
vport->style))
continue;
col = i % vport->cols;
row = i / vport->cols;
draw_glyph(vport, data[i].character, col * COL_WIDTH, row * FONT_SCANLINES,
data[i].style, style_same(data[i].style,vport->style));
draw_glyph(vport, data[i].character, col * COL_WIDTH, row *
FONT_SCANLINES, data[i].style,
style_same(data[i].style,vport->style));
}
cursor_print(vport);
}
670,12 → 689,12
*
* Protocol for drawing pixmaps:
* - FB_PREPARE_SHM(client shm identification)
* - IPC_M_SEND_AS_AREA
* - IPC_M_AS_AREA_SEND
* - FB_DRAW_PPM(startx,starty)
* - FB_DROP_SHM
*
* Protocol for text drawing
* - IPC_M_SEND_AS_AREA
* - IPC_M_AS_AREA_SEND
* - FB_DRAW_TEXT_DATA
*
* @param callid Callid of the current call
754,8 → 773,9
break;
}
ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call),
vport->width - x, vport->height - y, (putpixel_cb_t)putpixel, vport);
ppm_draw(shm, shm_size, IPC_GET_ARG1(*call),
IPC_GET_ARG2(*call), vport->width - x, vport->height -
y, (putpixel_cb_t)putpixel, vport);
break;
case FB_DRAW_TEXT_DATA:
if (!interbuffer) {
762,7 → 782,8
retval = EINVAL;
break;
}
if (intersize < vport->cols*vport->rows*sizeof(*interbuffer)) {
if (intersize < vport->cols * vport->rows *
sizeof(*interbuffer)) {
retval = EINVAL;
break;
}
793,8 → 814,10
rowsize = width * screen.pixelbytes;
 
for (y=0;y < height; y++) {
tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;
memcpy(pmap->data + rowsize*y, screen.fbaddress + tmp, rowsize);
tmp = (vport->y + y) * screen.scanline + vport->x *
screen.pixelbytes;
memcpy(pmap->data + rowsize * y, screen.fbaddress + tmp,
rowsize);
}
}
 
851,8 → 874,10
realrowsize = realwidth * screen.pixelbytes;
 
for (y=0; y < realheight; y++) {
tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;
memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize, realrowsize);
tmp = (vport->y + y) * screen.scanline + vport->x *
screen.pixelbytes;
memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize,
realrowsize);
}
return 0;
}
869,10 → 894,13
return;
 
for (i=0; i < MAX_ANIMATIONS; i++) {
if (!animations[i].animlen || !animations[i].initialized || !animations[i].enabled)
if (!animations[i].animlen || !animations[i].initialized ||
!animations[i].enabled)
continue;
draw_pixmap(animations[i].vp, animations[i].pixmaps[animations[i].pos]);
animations[i].pos = (animations[i].pos+1) % animations[i].animlen;
draw_pixmap(animations[i].vp,
animations[i].pixmaps[animations[i].pos]);
animations[i].pos = (animations[i].pos + 1) %
animations[i].animlen;
}
}
 
894,7 → 922,8
 
/* Save image under the cursor */
if (pointer_vport == -1) {
pointer_vport = viewport_create(pointer_x, pointer_y, pointer_width, pointer_height);
pointer_vport = viewport_create(pointer_x, pointer_y,
pointer_width, pointer_height);
if (pointer_vport < 0)
return;
} else {
905,17 → 934,22
if (pointer_pixmap == -1)
pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]);
else
copy_vp_to_pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]);
copy_vp_to_pixmap(&viewports[pointer_vport],
&pixmaps[pointer_pixmap]);
 
/* Draw cursor */
for (i=0; i < pointer_height; i++)
for (j=0;j < pointer_width; j++) {
bytepos = i*((pointer_width-1)/8+1) + j/8;
visibility = pointer_mask_bits[bytepos] & (1 << (j % 8));
visibility = pointer_mask_bits[bytepos] & (1 << (j %
8));
if (visibility) {
color = pointer_bits[bytepos] & (1 << (j % 8)) ? 0 : 0xffffff;
if (pointer_x+j < screen.xres && pointer_y+i < screen.yres)
putpixel(&viewports[0], pointer_x+j, pointer_y+i, color);
color = pointer_bits[bytepos] & (1 << (j % 8))
? 0 : 0xffffff;
if (pointer_x + j < screen.xres && pointer_y +
i < screen.yres)
putpixel(&viewports[0], pointer_x + j,
pointer_y+i, color);
}
}
pointer_shown = 1;
950,7 → 984,8
nvp = IPC_GET_ARG1(*call);
if (nvp == -1)
nvp = vp;
if (nvp >= MAX_VIEWPORTS || nvp < 0 || !viewports[nvp].initialized) {
if (nvp >= MAX_VIEWPORTS || nvp < 0 ||
!viewports[nvp].initialized) {
retval = EINVAL;
break;
}
979,7 → 1014,8
break;
case FB_ANIM_ADDPIXMAP:
i = IPC_GET_ARG1(*call);
if (i >= MAX_ANIMATIONS || i < 0 || !animations[i].initialized) {
if (i >= MAX_ANIMATIONS || i < 0 ||
!animations[i].initialized) {
retval = EINVAL;
break;
}
988,7 → 1024,8
break;
}
newval = IPC_GET_ARG2(*call);
if (newval < 0 || newval > MAX_PIXMAPS || !pixmaps[newval].data) {
if (newval < 0 || newval > MAX_PIXMAPS ||
!pixmaps[newval].data) {
retval = EINVAL;
break;
}
1003,7 → 1040,8
nvp = IPC_GET_ARG2(*call);
if (nvp == -1)
nvp = vp;
if (nvp >= MAX_VIEWPORTS || nvp < 0 || !viewports[nvp].initialized) {
if (nvp >= MAX_VIEWPORTS || nvp < 0 ||
!viewports[nvp].initialized) {
retval = EINVAL;
break;
}
1042,7 → 1080,8
nvp = IPC_GET_ARG1(*call);
if (nvp == -1)
nvp = vp;
if (nvp < 0 || nvp >= MAX_VIEWPORTS || !viewports[nvp].initialized) {
if (nvp < 0 || nvp >= MAX_VIEWPORTS ||
!viewports[nvp].initialized) {
retval = EINVAL;
break;
}
1053,7 → 1092,8
nvp = IPC_GET_ARG1(*call);
if (nvp == -1)
nvp = vp;
if (nvp < 0 || nvp >= MAX_VIEWPORTS || !viewports[nvp].initialized)
if (nvp < 0 || nvp >= MAX_VIEWPORTS ||
!viewports[nvp].initialized)
retval = EINVAL;
else
retval = save_vp_to_pixmap(&viewports[nvp]);
1140,7 → 1180,8
}
ipc_answer_fast(callid,0,0,0);
 
draw_char(vport, c, row, col, vport->style, IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR);
draw_char(vport, c, row, col, vport->style,
IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR);
continue; /* msg already answered */
case FB_CLEAR:
clear_port(vport);
1195,8 → 1236,11
}
viewports[i].dboffset = 0;
if (IPC_GET_ARG2(call) == 1 && !viewports[i].dbdata)
viewports[i].dbdata = malloc(screen.pixelbytes*viewports[i].width * viewports[i].height);
else if (IPC_GET_ARG2(call) == 0 && viewports[i].dbdata) {
viewports[i].dbdata = malloc(screen.pixelbytes
* viewports[i].width *
viewports[i].height);
else if (IPC_GET_ARG2(call) == 0 &&
viewports[i].dbdata) {
free(viewports[i].dbdata);
viewports[i].dbdata = NULL;
}
1220,9 → 1264,8
break;
case FB_VIEWPORT_CREATE:
retval = viewport_create(IPC_GET_ARG1(call) >> 16,
IPC_GET_ARG1(call) & 0xffff,
IPC_GET_ARG2(call) >> 16,
IPC_GET_ARG2(call) & 0xffff);
IPC_GET_ARG1(call) & 0xffff, IPC_GET_ARG2(call)
>> 16, IPC_GET_ARG2(call) & 0xffff);
break;
case FB_VIEWPORT_DELETE:
i = IPC_GET_ARG1(call);
1283,10 → 1326,11
fb_invert_colors = sysinfo_value("fb.invert-colors");
 
asz = fb_scanline * fb_height;
fb_addr = as_get_mappable_page(asz, (int) sysinfo_value("fb.address.color"));
fb_addr = as_get_mappable_page(asz, (int)
sysinfo_value("fb.address.color"));
physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >> PAGE_WIDTH,
AS_AREA_READ | AS_AREA_WRITE);
physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >>
PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
 
if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual,
fb_invert_colors))
/trunk/uspace/fb/ega.c
151,7 → 151,8
 
for (i=0; i < scr_width*scr_height; i++) {
scr_addr[i*2] = data[i].character;
scr_addr[i*2+1] = EGA_STYLE(data[i].style.fg_color, data[i].style.bg_color);
scr_addr[i * 2 + 1] = EGA_STYLE(data[i].style.fg_color,
data[i].style.bg_color);
}
}
 
173,8 → 174,10
static int print_screen(int i)
{
if (saved_screens[i].data)
memcpy(scr_addr, saved_screens[i].data, 2 * scr_width * scr_height);
else return EINVAL;
memcpy(scr_addr, saved_screens[i].data, 2 * scr_width *
scr_height);
else
return EINVAL;
return i;
}
 
208,8 → 211,10
case IPC_M_AS_AREA_SEND:
/* We accept one area for data interchange */
intersize = IPC_GET_ARG2(call);
if (intersize >= scr_width*scr_height*sizeof(*interbuf)) {
receive_comm_area(callid,&call,(void *)&interbuf);
if (intersize >= scr_width * scr_height *
sizeof(*interbuf)) {
receive_comm_area(callid, &call, (void *)
&interbuf);
continue;
}
retval = EINVAL;
252,7 → 257,7
break;
case FB_SCROLL:
i = IPC_GET_ARG1(call);
if (i > scr_height || i < (- (int)scr_height)) {
if (i > scr_height || i < -((int) scr_height)) {
retval = EINVAL;
break;
}
304,7 → 309,6
void *ega_ph_addr;
size_t sz;
 
 
ega_ph_addr=(void *)sysinfo_value("fb.address.physical");
scr_width=sysinfo_value("fb.width");
scr_height=sysinfo_value("fb.height");
/trunk/uspace/console/console.c
70,17 → 70,26
 
typedef struct {
keybuffer_t keybuffer; /**< Buffer for incoming keys. */
FIFO_CREATE_STATIC(keyrequests, ipc_callid_t , MAX_KEYREQUESTS_BUFFERED); /**< Buffer for unsatisfied request for 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.*/
screenbuffer_t screenbuffer; /**< Screenbuffer for saving screen contents and related settings. */
int used; /**< 1 if this virtual console is
* connected to some client.*/
screenbuffer_t screenbuffer; /**< Screenbuffer for saving screen
* 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 virt. console switching */
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 */
 
static int kernel_pixmap = -1; /**< Number of fb pixmap, where kernel console is stored */
static int kernel_pixmap = -1; /**< Number of fb pixmap, where kernel
* console is stored */
 
 
/** Find unused virtual console.
115,7 → 124,8
 
static void set_style(style_t *style)
{
async_msg_2(fb_info.phone, FB_SET_STYLE, style->fg_color, style->bg_color);
async_msg_2(fb_info.phone, FB_SET_STYLE, style->fg_color,
style->bg_color);
}
 
static void set_style_col(int fgcolor, int bgcolor)
150,14 → 160,10
case '\b':
if (scr->position_x == 0)
break;
 
scr->position_x--;
 
if (console == active_console)
prtchr(' ', scr->position_y, scr->position_x);
screenbuffer_putchar(scr, ' ');
break;
default:
if (console == active_console)
257,9 → 263,12
if (interbuffer) {
for (i = 0; i < conn->screenbuffer.size_x; i++)
for (j = 0; j < conn->screenbuffer.size_y; j++)
interbuffer[i + j*conn->screenbuffer.size_x] = *get_field_at(&(conn->screenbuffer),i, j);
interbuffer[i + j * conn->screenbuffer.size_x]
= *get_field_at(&(conn->screenbuffer),
i, j);
/* This call can preempt, but we are already at the end */
rc = async_req_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, NULL);
rc = async_req_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL,
NULL);
};
if ((!interbuffer) || (rc != 0)) {
269,11 → 278,14
 
for (j = 0; j < conn->screenbuffer.size_y; j++)
for (i = 0; i < conn->screenbuffer.size_x; i++) {
field = get_field_at(&(conn->screenbuffer),i, j);
field = get_field_at(&(conn->screenbuffer), i,
j);
if (!style_same(*style, field->style))
set_style(&field->style);
style = &field->style;
if ((field->character == ' ') && (style_same(field->style, conn->screenbuffer.style)))
if ((field->character == ' ') &&
(style_same(field->style,
conn->screenbuffer.style)))
continue;
 
prtchr(field->character, j, i);
280,7 → 292,8
}
}
curs_goto(conn->screenbuffer.position_y, conn->screenbuffer.position_x);
curs_goto(conn->screenbuffer.position_y,
conn->screenbuffer.position_x);
curs_visibility(conn->screenbuffer.is_cursor_visible);
 
async_serialize_end();
310,7 → 323,8
retval = 0;
break;
case KBD_MS_MOVE:
gcons_mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call));
gcons_mouse_move(IPC_GET_ARG1(call),
IPC_GET_ARG2(call));
retval = 0;
break;
case KBD_PUSHCHAR:
321,7 → 335,10
/* switch to another virtual console */
conn = &connections[active_console];
// if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) {
/*
* if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 +
* CONSOLE_COUNT)) {
*/
if ((c >= 0x101) && (c < 0x101 + CONSOLE_COUNT)) {
if (c == 0x112)
change_console(KERNEL_CONSOLE);
333,7 → 350,8
/* if client is awaiting key, send it */
if (conn->keyrequest_counter > 0) {
conn->keyrequest_counter--;
ipc_answer_fast(fifo_pop(conn->keyrequests), 0, c, 0);
ipc_answer_fast(fifo_pop(conn->keyrequests), 0,
c, 0);
break;
}
385,7 → 403,8
/* Answer all pending requests */
while (conn->keyrequest_counter > 0) {
conn->keyrequest_counter--;
ipc_answer_fast(fifo_pop(conn->keyrequests), ENOENT, 0, 0);
ipc_answer_fast(fifo_pop(conn->keyrequests),
ENOENT, 0, 0);
break;
}
conn->used = 0;
404,13 → 423,12
break;
case CONSOLE_GOTO:
screenbuffer_goto(&conn->screenbuffer, IPC_GET_ARG2(call), IPC_GET_ARG1(call));
screenbuffer_goto(&conn->screenbuffer,
IPC_GET_ARG2(call), IPC_GET_ARG1(call));
if (consnum == active_console)
curs_goto(IPC_GET_ARG1(call),IPC_GET_ARG2(call));
curs_goto(IPC_GET_ARG1(call),
IPC_GET_ARG2(call));
break;
 
case CONSOLE_GETSIZE:
arg1 = fb_info.rows;
arg2 = fb_info.cols;
417,16 → 435,15
break;
case CONSOLE_FLUSH:
if (consnum == active_console)
async_req_2(fb_info.phone, FB_FLUSH, 0, 0, NULL, NULL);
async_req_2(fb_info.phone, FB_FLUSH, 0, 0,
NULL, NULL);
break;
case CONSOLE_SET_STYLE:
arg1 = IPC_GET_ARG1(call);
arg2 = IPC_GET_ARG2(call);
screenbuffer_set_style(&conn->screenbuffer,arg1, arg2);
if (consnum == active_console)
set_style_col(arg1, arg2);
break;
case CONSOLE_CURSOR_VISIBILITY:
arg1 = IPC_GET_ARG1(call);
437,17 → 454,20
case CONSOLE_GETCHAR:
if (keybuffer_empty(&conn->keybuffer)) {
/* buffer is empty -> store request */
if (conn->keyrequest_counter < MAX_KEYREQUESTS_BUFFERED) {
if (conn->keyrequest_counter <
MAX_KEYREQUESTS_BUFFERED) {
fifo_push(conn->keyrequests, callid);
conn->keyrequest_counter++;
} else {
/* no key available and too many requests => fail */
/*
* No key available and too many
* requests => fail.
*/
ipc_answer_fast(callid, ELIMIT, 0, 0);
}
continue;
};
}
keybuffer_pop(&conn->keybuffer, (int *)&arg1);
break;
}
ipc_answer_fast(callid, 0, arg1, arg2);
464,18 → 484,21
/* Connect to keyboard driver */
 
while ((kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0)) < 0) {
while ((kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0))
< 0) {
usleep(10000);
};
}
if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phonehash) != 0) {
if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, &phonehash) != 0)
{
return -1;
};
}
async_new_connection(phonehash, 0, NULL, keyboard_events);
/* Connect to framebuffer driver */
while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) {
while ((fb_info.phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0))
< 0) {
usleep(10000);
}
489,7 → 512,8
/* Enable double buffering */
async_msg_2(fb_info.phone, FB_VIEWPORT_DB, (sysarg_t)-1, 1);
async_req_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols));
async_req_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows),
&(fb_info.cols));
set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
clrscr();
498,11 → 522,13
connections[i].used = 0;
keybuffer_init(&(connections[i].keybuffer));
connections[i].keyrequests.head = connections[i].keyrequests.tail = 0;
connections[i].keyrequests.head =
connections[i].keyrequests.tail = 0;
connections[i].keyrequests.items = MAX_KEYREQUESTS_BUFFERED;
connections[i].keyrequest_counter = 0;
if (screenbuffer_init(&(connections[i].screenbuffer), fb_info.cols, fb_info.rows ) == NULL) {
if (screenbuffer_init(&(connections[i].screenbuffer),
fb_info.cols, fb_info.rows) == NULL) {
/*FIXME: handle error */
return -1;
}
509,9 → 535,13
}
connections[KERNEL_CONSOLE].used = 1;
if ((interbuffer = mmap(NULL, sizeof(keyfield_t) * fb_info.cols * fb_info.rows , PROTO_READ|PROTO_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 0 ,0 )) != NULL) {
if (async_req_3(fb_info.phone, IPC_M_AS_AREA_SEND, (ipcarg_t)interbuffer, 0, AS_AREA_READ, NULL, NULL, NULL) != 0) {
munmap(interbuffer, sizeof(keyfield_t) * fb_info.cols * fb_info.rows);
if ((interbuffer = mmap(NULL, sizeof(keyfield_t) * fb_info.cols *
fb_info.rows, PROTO_READ | PROTO_WRITE, MAP_ANONYMOUS |
MAP_PRIVATE, 0, 0)) != NULL) {
if (async_req_3(fb_info.phone, IPC_M_AS_AREA_SEND, (ipcarg_t)
interbuffer, 0, AS_AREA_READ, NULL, NULL, NULL) != 0) {
munmap(interbuffer, sizeof(keyfield_t) * fb_info.cols
* fb_info.rows);
interbuffer = NULL;
}
}
522,7 → 552,7
/* Register at NS */
if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) {
return -1;
};
}
async_manager();
 
/trunk/uspace/console/gcons.c
119,9 → 119,11
 
vp_switch(cstatus_vp[consnum]);
if (ic_pixmaps[state] != -1)
async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]);
async_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum],
ic_pixmaps[state]);
 
if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) {
if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state !=
CONS_DISCONNECTED_SEL) {
snprintf(data, 5, "%d", consnum+1);
for (i=0;data[i];i++)
tran_putch(data[i], 1, 2+i);
166,7 → 168,8
if (!use_gcons)
return;
 
if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA)
if (consnum == active_console || console_state[consnum] ==
CONS_HAS_DATA)
return;
 
console_state[consnum] = CONS_HAS_DATA;
314,16 → 317,19
int rc;
 
/* Create area */
shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
MAP_ANONYMOUS, 0, 0);
if (shm == MAP_FAILED)
return;
 
memcpy(shm, logo, size);
/* Send area */
rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm, 0, NULL,
NULL);
if (rc)
goto exit;
rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t) shm, 0,
PROTO_READ, NULL, NULL, NULL);
if (rc)
goto drop;
/* Draw logo */
351,8 → 357,10
vp_switch(0);
set_style(MAIN_COLOR, MAIN_COLOR);
clear();
draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2);
draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17);
draw_pixmap(_binary_helenos_ppm_start, (size_t)
&_binary_helenos_ppm_size, xres - 66, 2);
draw_pixmap(_binary_nameic_ppm_start, (size_t)
&_binary_nameic_ppm_size, 5, 17);
 
for (i=0;i < CONSOLE_COUNT; i++)
redraw_state(i);
372,16 → 380,19
int pxid = -1;
 
/* Create area */
shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
MAP_ANONYMOUS, 0, 0);
if (shm == MAP_FAILED)
return -1;
 
memcpy(shm, data, size);
/* Send area */
rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL);
rc = async_req_2(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm, 0, NULL,
NULL);
if (rc)
goto exit;
rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL);
rc = async_req_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t) shm, 0,
PROTO_READ, NULL, NULL, NULL);
if (rc)
goto drop;
 
408,25 → 419,31
extern int _binary_anim_3_ppm_size;
extern char _binary_anim_4_ppm_start[0];
extern int _binary_anim_4_ppm_size;
 
static void make_anim(void)
{
int an;
int pm;
 
an = async_req(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE], NULL);
an = async_req(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE],
NULL);
if (an < 0)
return;
 
pm = make_pixmap(_binary_anim_1_ppm_start, (int)&_binary_anim_1_ppm_size);
pm = make_pixmap(_binary_anim_1_ppm_start, (int)
&_binary_anim_1_ppm_size);
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
 
pm = make_pixmap(_binary_anim_2_ppm_start, (int)&_binary_anim_2_ppm_size);
pm = make_pixmap(_binary_anim_2_ppm_start, (int)
&_binary_anim_2_ppm_size);
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
 
pm = make_pixmap(_binary_anim_3_ppm_start, (int)&_binary_anim_3_ppm_size);
pm = make_pixmap(_binary_anim_3_ppm_start, (int)
&_binary_anim_3_ppm_size);
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
 
pm = make_pixmap(_binary_anim_4_ppm_start, (int)&_binary_anim_4_ppm_size);
pm = make_pixmap(_binary_anim_4_ppm_start, (int)
&_binary_anim_4_ppm_size);
async_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
 
async_msg(fbphone, FB_ANIM_START, an);
442,6 → 459,7
extern int _binary_cons_has_data_ppm_size;
extern char _binary_cons_kernel_ppm_start[0];
extern int _binary_cons_kernel_ppm_size;
 
/** Initialize nice graphical console environment */
void gcons_init(int phone)
{
460,9 → 478,9
 
/* create console viewport */
/* Align width & height to character size */
console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP,
ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8),
ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16));
console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, ALIGN_DOWN(xres -
2 * CONSOLE_MARGIN, 8), ALIGN_DOWN(yres - (CONSOLE_TOP +
CONSOLE_MARGIN), 16));
if (console_vp < 0)
return;
469,8 → 487,9
/* Create status buttons */
status_start += (xres-800) / 2;
for (i=0; i < CONSOLE_COUNT; i++) {
cstatus_vp[i] = vp_create(status_start+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT);
cstatus_vp[i] = vp_create(status_start + CONSOLE_MARGIN + i *
(STATUS_WIDTH + STATUS_SPACE), STATUS_TOP,
STATUS_WIDTH, STATUS_HEIGHT);
if (cstatus_vp[i] < 0)
return;
vp_switch(cstatus_vp[i]);
478,14 → 497,17
}
/* Initialize icons */
ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start,
(int)&_binary_cons_selected_ppm_size);
ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start,
(int)&_binary_cons_idle_ppm_size);
ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start,
(int)&_binary_cons_has_data_ppm_size);
ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start,
(int)&_binary_cons_idle_ppm_size);
ic_pixmaps[CONS_SELECTED] =
make_pixmap(_binary_cons_selected_ppm_start, (int)
&_binary_cons_selected_ppm_size);
ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, (int)
&_binary_cons_idle_ppm_size);
ic_pixmaps[CONS_HAS_DATA] =
make_pixmap(_binary_cons_has_data_ppm_start, (int)
&_binary_cons_has_data_ppm_size);
ic_pixmaps[CONS_DISCONNECTED] =
make_pixmap(_binary_cons_idle_ppm_start, (int)
&_binary_cons_idle_ppm_size);
ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start,
(int)&_binary_cons_kernel_ppm_size);
ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
/trunk/uspace/libc/arch/sparc64/include/psthread.h
47,12 → 47,13
 
#define context_set(c, _pc, stack, size, ptls) \
(c)->pc = ((uintptr_t) _pc) - 8; \
(c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \
(c)->sp = ((uintptr_t) stack) + ALIGN_UP((size), \
STACK_ALIGNMENT) - (STACK_BIAS + SP_DELTA); \
(c)->fp = -STACK_BIAS; \
(c)->tp = ptls
/*
* Only save registers that must be preserved across
* Save only registers that must be preserved across
* function calls.
*/
typedef struct {