Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 4337 → Rev 4338

/branches/dynload/uspace/app/bdsh/input.c
33,6 → 33,7
#include <stdlib.h>
#include <string.h>
#include <io/stream.h>
#include <console.h>
 
#include "config.h"
#include "util.h"
164,7 → 165,10
char line[INPUT_MAX];
size_t len = 0;
 
console_set_style(STYLE_EMPHASIS);
printf("%s", usr->prompt);
console_set_style(STYLE_NORMAL);
 
read_line(line, INPUT_MAX);
len = strlen(line);
/* Make sure we don't have rubbish or a C/R happy user */
/branches/dynload/uspace/app/tester/console/console1.c
0,0 → 1,109
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <io/stream.h>
#include <async.h>
#include "../tester.h"
 
#include <console.h>
 
const char *color_name[] = {
[COLOR_BLACK] = "black",
[COLOR_BLUE] = "blue",
[COLOR_GREEN] = "green",
[COLOR_CYAN] = "cyan",
[COLOR_RED] = "red",
[COLOR_MAGENTA] = "magenta",
[COLOR_YELLOW] = "yellow",
[COLOR_WHITE] = "white"
};
 
char * test_console1(bool quiet)
{
int i, j;
 
printf("Style test: ");
console_set_style(STYLE_NORMAL);
printf("normal ");
console_set_style(STYLE_EMPHASIS);
printf("emphasized");
console_set_style(STYLE_NORMAL);
printf(".\n");
 
printf("Foreground color test:\n");
for (j = 0; j < 2; j++) {
for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) {
console_set_color(i, COLOR_WHITE,
j ? CATTR_BRIGHT : 0);
printf(" %s ", color_name[i]);
}
console_set_color(COLOR_BLACK, COLOR_WHITE, 0);
putchar('\n');
}
 
printf("Background color test:\n");
for (j = 0; j < 2; j++) {
for (i = COLOR_BLACK; i <= COLOR_WHITE; i++) {
console_set_color(COLOR_WHITE, i,
j ? CATTR_BRIGHT : 0);
printf(" %s ", color_name[i]);
}
console_set_color(COLOR_BLACK, COLOR_WHITE, 0);
putchar('\n');
}
 
printf("Now let's test RGB colors:\n");
 
for (i = 0; i < 255; i += 16) {
console_set_rgb_color(0xffffff, i << 16);
putchar('X');
}
console_set_color(COLOR_BLACK, COLOR_WHITE, 0);
putchar('\n');
 
for (i = 0; i < 255; i += 16) {
console_set_rgb_color(0xffffff, i << 8);
putchar('X');
}
console_set_color(COLOR_BLACK, COLOR_WHITE, 0);
putchar('\n');
 
for (i = 0; i < 255; i += 16) {
console_set_rgb_color(0xffffff, i);
putchar('X');
}
console_set_color(COLOR_BLACK, COLOR_WHITE, 0);
putchar('\n');
 
printf("[press a key]\n");
getchar();
 
return NULL;
}
/branches/dynload/uspace/app/tester/console/console1.def
0,0 → 1,6
{
"console1",
"Console color test",
&test_console1,
true
},
/branches/dynload/uspace/app/tester/stdio/stdio1.def
0,0 → 1,6
{
"stdio1",
"ANSI C streams reading test",
&test_stdio1,
true
},
/branches/dynload/uspace/app/tester/stdio/stdio2.def
0,0 → 1,6
{
"stdio2",
"ANSI C streams writing test",
&test_stdio2,
true
},
/branches/dynload/uspace/app/tester/stdio/stdio2.c
0,0 → 1,69
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "../tester.h"
 
char * test_stdio2(bool quiet)
{
FILE *f;
char *file_name = "/test";
size_t n;
int c;
 
printf("Open file '%s' for writing\n", file_name);
errno = 0;
f = fopen(file_name, "wt");
 
if (f == NULL)
return "Failed opening file.";
 
fprintf(f, "Integer: %d, string: '%s'\n", 42, "Hello!");
if (fclose(f) != 0)
return "Failed closing file.";
 
printf("Open file '%s' for reading\n", file_name);
 
f = fopen(file_name, "rt");
if (f == NULL)
return "Failed opening file.";
 
printf("File contains:\n");
while (true) {
c = fgetc(f);
if (c == EOF) break;
putchar(c);
}
 
if (fclose(f) != 0)
return "Failed closing file.";
 
return NULL;
}
/branches/dynload/uspace/app/tester/stdio/stdio1.c
0,0 → 1,85
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "../tester.h"
 
#define BUF_SIZE 32
static char buf[BUF_SIZE + 1];
 
char * test_stdio1(bool quiet)
{
FILE *f;
char *file_name = "/readme";
size_t n;
int c;
 
printf("Open file '%s'\n", file_name);
errno = 0;
f = fopen(file_name, "rt");
 
if (f == NULL) printf("errno = %d\n", errno);
 
if (f == NULL)
return "Failed opening file.";
 
n = fread(buf, 1, BUF_SIZE, f);
if (ferror(f)) {
fclose(f);
return "Failed reading file.";
}
 
printf("Read %d bytes.\n", n);
 
buf[n] = '\0';
printf("Read string '%s'.\n", buf);
 
printf("Seek to beginning.\n");
if (fseek(f, 0, SEEK_SET) != 0) {
fclose(f);
return "Failed seeking.";
}
 
printf("Read using fgetc().\n");
while (true) {
c = fgetc(f);
if (c == EOF) break;
 
printf("'%c'", c);
}
 
printf("[EOF]\n");
printf("Closing.\n");
 
if (fclose(f) != 0)
return "Failed closing.";
 
return NULL;
}
/branches/dynload/uspace/app/tester/tester.c
58,6 → 58,9
#include "devmap/devmap1.def"
#include "loop/loop1.def"
#include "vfs/vfs1.def"
#include "console/console1.def"
#include "stdio/stdio1.def"
#include "stdio/stdio2.def"
{NULL, NULL, NULL}
};
 
/branches/dynload/uspace/app/tester/tester.h
71,6 → 71,9
extern char * test_devmap1(bool quiet);
extern char * test_loop1(bool quiet);
extern char * test_vfs1(bool quiet);
extern char * test_console1(bool quiet);
extern char * test_stdio1(bool quiet);
extern char * test_stdio2(bool quiet);
 
extern test_t tests[];
 
/branches/dynload/uspace/app/tester/Makefile
56,6 → 56,9
ipc/hangup.c \
loop/loop1.c \
devmap/devmap1.c \
console/console1.c \
stdio/stdio1.c \
stdio/stdio2.c \
vfs/vfs1.c
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
/branches/dynload/uspace/app/tetris/input.c
57,7 → 57,7
#include "tetris.h"
 
#include <async.h>
#include "../../srv/console/console.h"
#include <ipc/console.h>
 
/* return true iff the given timeval is positive */
#define TV_POS(tv) \
/branches/dynload/uspace/app/tetris/screen.c
50,13 → 50,12
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <io/stream.h>
#include <console.h>
 
 
#include <async.h>
#include "screen.h"
#include "tetris.h"
#include "../../srv/console/console.h"
#include <ipc/console.h>
 
static cell curscreen[B_SIZE]; /* 1 => standout (or otherwise marked) */
static int curscore;
73,29 → 72,19
putchar(*(s++));
}
 
static int con_phone;
 
 
 
static void set_style(int fgcolor, int bgcolor)
{
async_msg_2(con_phone, CONSOLE_SET_STYLE, fgcolor, bgcolor);
}
 
static void start_standout(void)
{
set_style(0xf0f0f0, 0);
console_set_rgb_color(0xf0f0f0, 0);
}
 
static void resume_normal(void)
{
set_style(0, 0xf0f0f0);
console_set_rgb_color(0, 0xf0f0f0);
}
 
 
void clear_screen(void)
{
async_msg_0(con_phone, CONSOLE_CLEAR);
console_clear();
moveto(0, 0);
}
 
107,7 → 96,7
{
 
resume_normal();
async_msg_0(con_phone, CONSOLE_CLEAR);
console_clear();
curscore = -1;
memset((char *)curscreen, 0, sizeof(curscreen));
}
118,8 → 107,7
void
scr_init(void)
{
con_phone = get_cons_phone();
async_msg_1(con_phone, CONSOLE_CURSOR_VISIBILITY, 0);
console_cursor_visibility(0);
resume_normal();
scr_clear();
}
126,12 → 114,12
 
void moveto(int r, int c)
{
async_msg_2(con_phone, CONSOLE_GOTO, r, c);
console_goto(r, c);
}
 
static void fflush(void)
{
async_msg_0(con_phone, CONSOLE_FLUSH);
console_flush();
}
 
winsize_t winsize;
138,8 → 126,7
 
static int get_display_size(winsize_t *ws)
{
return async_req_0_2(con_phone, CONSOLE_GETSIZE, &ws->ws_row,
&ws->ws_col);
return console_get_size(&ws->ws_row, &ws->ws_col);
}
 
/*
/branches/dynload/uspace/app/tetris/screen.h
49,8 → 49,8
#include <async.h>
 
typedef struct {
ipcarg_t ws_row;
ipcarg_t ws_col;
int ws_row;
int ws_col;
} winsize_t;
 
extern winsize_t winsize;
/branches/dynload/uspace/app/klog/klog.c
88,9 → 88,9
printf(NAME ": Error initializing memory area\n");
return -1;
}
 
int devno = sysinfo_value("klog.devno");
int inr = sysinfo_value("klog.inr");
int devno = sysinfo_value("klog.devno");
if (ipc_register_irq(inr, devno, 0, NULL) != EOK) {
printf(NAME ": Error registering klog notifications\n");
return -1;
/branches/dynload/uspace/app/trace/trace.c
49,7 → 49,7
#include "proto.h"
#include <ipc/services.h>
#include "../../srv/vfs/vfs.h"
#include "../../srv/console/console.h"
#include <ipc/console.h>
 
#include "syscalls.h"
#include "ipcp.h"
666,9 → 666,15
o = oper_new("flush", 0, arg_def, V_VOID, 0, resp_def);
proto_add_oper(p, CONSOLE_FLUSH, o);
 
arg_def[0] = V_INTEGER;
o = oper_new("set_style", 1, arg_def, V_INTEGER, 0, resp_def);
proto_add_oper(p, CONSOLE_SET_STYLE, o);
arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER; arg_def[2] = V_INTEGER;
o = oper_new("set_color", 3, arg_def, V_INTEGER, 0, resp_def);
proto_add_oper(p, CONSOLE_SET_COLOR, o);
arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER;
o = oper_new("set_style", 2, arg_def, V_INTEGER, 0, resp_def);
proto_add_oper(p, CONSOLE_SET_STYLE, o);
o = oper_new("set_rgb_color", 2, arg_def, V_INTEGER, 0, resp_def);
proto_add_oper(p, CONSOLE_SET_RGB_COLOR, o);
o = oper_new("cursor_visibility", 1, arg_def, V_VOID, 0, resp_def);
proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o);
 
/branches/dynload/uspace/lib/libc/include/console.h
0,0 → 1,53
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libc
* @{
*/
/** @file
*/
 
#ifndef LIBC_CONSOLE_H_
#define LIBC_CONSOLE_H_
 
#include <console/style.h>
#include <console/color.h>
 
extern void console_clear(void);
extern void console_goto(int, int);
extern void console_flush(void);
extern int console_get_size(int *, int *);
extern void console_set_style(int);
extern void console_set_color(int, int, int);
extern void console_set_rgb_color(int, int);
extern void console_cursor_visibility(int);
 
#endif
/** @}
*/
/branches/dynload/uspace/lib/libc/include/async.h
118,7 → 118,7
/*
* User-friendly wrappers for async_req_fast() and async_req_slow(). The macros
* are in the form async_req_m_n(), where m is the number of payload arguments
* and n is the number of return arguments. The macros decidce between the fast
* and n is the number of return arguments. The macros decide between the fast
* and slow verion based on m.
*/
#define async_req_0_0(phoneid, method) \
/branches/dynload/uspace/lib/libc/include/stdio.h
52,6 → 52,19
(void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, strlen(buf)); \
}
 
typedef struct {
/** Underlying file descriptor. */
int fd;
 
/** Error indicator. */
int error;
 
/** End-of-file indicator. */
int eof;
} FILE;
 
extern FILE *stdin, *stdout, *stderr;
 
extern int getchar(void);
 
extern int puts(const char *);
59,7 → 72,7
 
extern int printf(const char *, ...);
extern int asprintf(char **, const char *, ...);
extern int sprintf(char *, const char *fmt, ...);
extern int sprintf(char *, const char *, ...);
extern int snprintf(char *, size_t , const char *, ...);
 
extern int vprintf(const char *, va_list);
66,11 → 79,35
extern int vsprintf(char *, const char *, va_list);
extern int vsnprintf(char *, size_t, const char *, va_list);
 
#define fprintf(f, fmt, ...) printf(fmt, ##__VA_ARGS__)
 
extern int rename(const char *, const char *);
 
extern FILE *fopen(const char *, const char *);
extern int fclose(FILE *);
extern size_t fread(void *, size_t, size_t, FILE *);
extern size_t fwrite(const void *, size_t, size_t, FILE *);
extern int feof(FILE *);
extern int ferror(FILE *);
extern void clearerr(FILE *);
 
extern int fgetc(FILE *);
extern int fputc(int, FILE *);
extern int fputs(const char *, FILE *);
 
extern int fprintf(FILE *, const char *, ...);
extern int vfprintf(FILE *, const char *, va_list);
 
#define getc fgetc
#define putc fputc
 
extern int fseek(FILE *, long, int);
 
#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif
 
#endif
 
/** @}
*/
/branches/dynload/uspace/lib/libc/include/unistd.h
44,9 → 44,11
 
#define getpagesize() (PAGE_SIZE)
 
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif
 
extern ssize_t write(int, const void *, size_t);
extern ssize_t read(int, void *, size_t);
/branches/dynload/uspace/lib/libc/include/console/color.h
0,0 → 1,55
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libc
* @{
*/
/** @file
*/
 
#ifndef LIBC_CONSOLE_COLOR_H_
#define LIBC_CONSOLE_COLOR_H_
 
enum console_color {
COLOR_BLACK = 0,
COLOR_BLUE = 1,
COLOR_GREEN = 2,
COLOR_CYAN = 3,
COLOR_RED = 4,
COLOR_MAGENTA = 5,
COLOR_YELLOW = 6,
COLOR_WHITE = 7,
 
CATTR_BRIGHT = 8,
CATTR_BLINK = 8
};
 
#endif
/** @}
*/
/branches/dynload/uspace/lib/libc/include/console/style.h
0,0 → 1,46
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libc
* @{
*/
/** @file
*/
 
#ifndef LIBC_CONSOLE_STYLE_H_
#define LIBC_CONSOLE_STYLE_H_
 
enum console_style {
STYLE_NORMAL = 0,
STYLE_EMPHASIS = 1
};
 
#endif
/** @}
*/
/branches/dynload/uspace/lib/libc/include/ipc/console.h
0,0 → 1,56
/*
* Copyright (c) 2006 Josef Cejka
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libcipc
* @{
*/
/** @file
*/
 
#ifndef LIBC_IPC_CONSOLE_H_
#define LIBC_IPC_CONSOLE_H_
 
#include <ipc/ipc.h>
 
typedef enum {
CONSOLE_GETCHAR = IPC_FIRST_USER_METHOD,
CONSOLE_PUTCHAR,
CONSOLE_CLEAR,
CONSOLE_GOTO,
CONSOLE_GETSIZE,
CONSOLE_FLUSH,
CONSOLE_SET_STYLE,
CONSOLE_SET_COLOR,
CONSOLE_SET_RGB_COLOR,
CONSOLE_CURSOR_VISIBILITY
} console_request_t;
 
#endif
/** @}
*/
Property changes:
Added: svn:mergeinfo
/branches/dynload/uspace/lib/libc/include/ipc/fb.h
48,6 → 48,8
FB_VIEWPORT_CREATE,
FB_VIEWPORT_DELETE,
FB_SET_STYLE,
FB_SET_COLOR,
FB_SET_RGB_COLOR,
FB_GET_RESOLUTION,
FB_DRAW_TEXT_DATA,
FB_FLUSH,
67,7 → 69,6
FB_POINTER_MOVE
} fb_request_t;
 
 
#endif
 
/** @}
/branches/dynload/uspace/lib/libc/include/errno.h
35,6 → 35,10
#ifndef LIBC_ERRNO_H_
#define LIBC_ERRNO_H_
 
/* TODO: support threads/fibrils */
extern int _errno;
#define errno _errno
 
#include <kernel/errno.h>
 
#define ENAMETOOLONG (-256)
/branches/dynload/uspace/lib/libc/generic/console.c
0,0 → 1,97
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libc
* @{
*/
/** @file
*/
 
#include <async.h>
#include <io/stream.h>
#include <ipc/console.h>
#include <console.h>
 
void console_clear(void)
{
int cons_phone = get_cons_phone();
async_msg_0(cons_phone, CONSOLE_CLEAR);
}
 
void console_goto(int row, int col)
{
int cons_phone = get_cons_phone();
async_msg_2(cons_phone, CONSOLE_GOTO, row, col);
}
 
void console_flush(void)
{
int cons_phone = get_cons_phone();
async_msg_0(cons_phone, CONSOLE_FLUSH);
}
 
int console_get_size(int *rows, int *cols)
{
int cons_phone = get_cons_phone();
ipcarg_t r, c;
int rc;
 
rc = async_req_0_2(cons_phone, CONSOLE_GETSIZE, &r, &c);
 
*rows = (int) r;
*cols = (int) c;
 
return rc;
}
 
void console_set_style(int style)
{
int cons_phone = get_cons_phone();
async_msg_1(cons_phone, CONSOLE_SET_STYLE, style);
}
 
void console_set_color(int fg_color, int bg_color, int flags)
{
int cons_phone = get_cons_phone();
async_msg_3(cons_phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags);
}
 
void console_set_rgb_color(int fg_color, int bg_color)
{
int cons_phone = get_cons_phone();
async_msg_2(cons_phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color);
}
 
void console_cursor_visibility(int show)
{
int cons_phone = get_cons_phone();
async_msg_1(cons_phone, CONSOLE_CURSOR_VISIBILITY, show != 0);
}
 
/** @}
*/
/branches/dynload/uspace/lib/libc/generic/libc.c
57,6 → 57,8
extern char _heap;
extern int main(int argc, char *argv[]);
 
int _errno;
 
void _exit(int status)
{
thread_exit(status);
/branches/dynload/uspace/lib/libc/generic/async.c
483,7 → 483,7
{
connection_t *conn;
unsigned long key;
 
conn = malloc(sizeof(*conn));
if (!conn) {
if (callid)
498,7 → 498,7
conn->call = *call;
conn->wdata.active = 1; /* We will activate the fibril ASAP */
conn->cfibril = cfibril;
 
conn->wdata.fid = fibril_create(connection_fibril, conn);
if (!conn->wdata.fid) {
free(conn);
506,14 → 506,15
ipc_answer_0(callid, ENOMEM);
return NULL;
}
/* Add connection to the connection hash table */
key = conn->in_phone_hash;
futex_down(&async_futex);
hash_table_insert(&conn_hash_table, &key, &conn->link);
futex_up(&async_futex);
 
fibril_add_ready(conn->wdata.fid);
 
return conn->wdata.fid;
}
 
524,6 → 525,7
*
* @param callid Hash of the incoming call.
* @param call Data of the incoming call.
*
*/
static void handle_call(ipc_callid_t callid, ipc_call_t *call)
{
533,8 → 535,8
(*interrupt_received)(callid, call);
_in_interrupt_handler = 0;
return;
}
 
}
switch (IPC_GET_METHOD(*call)) {
case IPC_M_CONNECT_ME_TO:
/* Open new connection with fibril etc. */
542,11 → 544,11
client_connection);
return;
}
 
/* Try to route the call through the connection hash table */
if (route_call(callid, call))
return;
 
/* Unknown call from unknown phone - hang it up */
ipc_answer_0(callid, EHANGUP);
}
739,23 → 741,17
ipcarg_t arg2, ipcarg_t arg3, ipcarg_t arg4, ipc_call_t *dataptr)
{
amsg_t *msg;
 
if (_in_interrupt_handler) {
printf("Cannot send asynchronous request in interrupt "
"handler.\n");
_exit(1);
}
 
msg = malloc(sizeof(*msg));
msg->done = 0;
msg->dataptr = dataptr;
 
/* We may sleep in the next method, but it will use its own mechanism */
msg->wdata.active = 1;
ipc_call_async_4(phoneid, method, arg1, arg2, arg3, arg4, msg,
reply_received, 1);
 
reply_received, !_in_interrupt_handler);
return (aid_t) msg;
}
 
781,23 → 777,17
ipc_call_t *dataptr)
{
amsg_t *msg;
 
if (_in_interrupt_handler) {
printf("Cannot send asynchronous request in interrupt "
"handler.\n");
_exit(1);
}
 
msg = malloc(sizeof(*msg));
msg->done = 0;
msg->dataptr = dataptr;
 
/* We may sleep in next method, but it will use its own mechanism */
msg->wdata.active = 1;
 
ipc_call_async_5(phoneid, method, arg1, arg2, arg3, arg4, arg5, msg,
reply_received, 1);
 
reply_received, !_in_interrupt_handler);
return (aid_t) msg;
}
 
884,21 → 874,16
{
amsg_t *msg;
if (_in_interrupt_handler) {
printf("Cannot call async_usleep in interrupt handler.\n");
_exit(1);
}
 
msg = malloc(sizeof(*msg));
if (!msg)
return;
 
msg->wdata.fid = fibril_get_id();
msg->wdata.active = 0;
 
gettimeofday(&msg->wdata.expires, NULL);
tv_add(&msg->wdata.expires, timeout);
 
futex_down(&async_futex);
insert_timeout(&msg->wdata);
/* Leave the async_futex locked when entering this function */
/branches/dynload/uspace/lib/libc/generic/vfs/vfs.c
49,7 → 49,7
#include <errno.h>
#include <string.h>
#include <ipc/devmap.h>
#include "../../srv/vfs/vfs.h"
#include "../../../srv/vfs/vfs.h"
 
int vfs_phone = -1;
futex_t vfs_phone_futex = FUTEX_INITIALIZER;
/branches/dynload/uspace/lib/libc/generic/io/stdio.c
0,0 → 1,278
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libc
* @{
*/
/**
* @file
* @brief ANSI C Stream I/O.
*/
 
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <bool.h>
#include <stdio.h>
 
FILE *stdin, *stdout, *stderr;
 
/**
* Open a stream.
*
* @param file_name Name of the file to open.
* @param mode Mode string, (r|w|a)[b|t][+].
*/
FILE *fopen(const char *file_name, const char *mode)
{
FILE *f;
int flags;
bool plus;
const char *mp;
 
/* Parse mode except first character. */
 
mp = mode;
if (*mp++ == '\0') {
errno = EINVAL;
return NULL;
}
 
if (*mp == 'b' || *mp == 't') ++mp;
 
if (*mp == '+') {
++mp;
plus = true;
} else {
plus = false;
}
 
if (*mp != '\0') {
errno = EINVAL;
return NULL;
}
 
/* Parse first character of mode and determine flags for open(). */
 
switch (mode[0]) {
case 'r':
flags = plus ? O_RDWR : O_RDONLY;
break;
case 'w':
flags = (O_TRUNC | O_CREAT) | (plus ? O_RDWR : O_WRONLY);
break;
case 'a':
/* TODO: a+ must read from beginning, append to the end. */
if (plus) {
errno = ENOTSUP;
return NULL;
}
flags = (O_APPEND | O_CREAT) | (plus ? O_RDWR : O_WRONLY);
default:
errno = EINVAL;
return NULL;
}
 
/* Open file. */
f = malloc(sizeof(FILE));
if (f == NULL) {
errno = ENOMEM;
return NULL;
}
 
f->fd = open(file_name, flags, 0666);
if (f->fd < 0) {
free(f);
return NULL; /* errno was set by open() */
}
 
f->error = 0;
f->eof = 0;
 
return f;
}
 
/** Close a stream.
*
* @param f Pointer to stream.
* @return 0 on success, EOF on error.
*/
int fclose(FILE *f)
{
int rc;
 
rc = close(f->fd);
free(f);
 
if (rc != 0)
return EOF; /* errno was set by close() */
 
return 0;
}
 
/** Read from a stream.
*
* @param buf Destination buffer.
* @param size Size of each record.
* @param nmemb Number of records to read.
* @param f Pointer to the stream.
*/
size_t fread(void *buf, size_t size, size_t nmemb, FILE *f)
{
size_t left, done, n;
 
left = size * nmemb;
done = 0;
 
while (left > 0 && !f->error && !f->eof) {
n = read(f->fd, buf + done, left);
 
if (n < 0) {
f->error = 1;
} else if (n == 0) {
f->eof = 1;
} else {
left -= n;
done += n;
}
}
 
return done / size;
}
 
 
/** Write to a stream.
*
* @param buf Source buffer.
* @param size Size of each record.
* @param nmemb Number of records to write.
* @param f Pointer to the stream.
*/
size_t fwrite(const void *buf, size_t size, size_t nmemb, FILE *f)
{
size_t left, done, n;
 
left = size * nmemb;
done = 0;
 
while (left > 0 && !f->error) {
n = write(f->fd, buf + done, left);
 
if (n <= 0) {
f->error = 1;
} else {
left -= n;
done += n;
}
}
 
return done / size;
}
 
/** Return the end-of-file indicator of a stream. */
int feof(FILE *f)
{
return f->eof;
}
 
/** Return the error indicator of a stream. */
int ferror(FILE *f)
{
return f->error;
}
 
/** Clear the error and end-of-file indicators of a stream. */
void clearerr(FILE *f)
{
f->eof = 0;
f->error = 0;
}
 
/** Read character from a stream. */
int fgetc(FILE *f)
{
unsigned char c;
size_t n;
 
n = fread(&c, sizeof(c), 1, f);
if (n < 1) return EOF;
 
return (int) c;
}
 
/** Write character to a stream. */
int fputc(int c, FILE *f)
{
unsigned char cc;
size_t n;
 
cc = (unsigned char) c;
n = fwrite(&cc, sizeof(cc), 1, f);
if (n < 1) return EOF;
 
return (int) cc;
}
 
/** Write string to a stream. */
int fputs(const char *s, FILE *f)
{
int rc;
 
rc = 0;
 
while (*s && rc >= 0) {
rc = fputc(*s++, f);
}
 
if (rc < 0) return EOF;
 
return 0;
}
 
/** Seek to position in stream. */
int fseek(FILE *f, long offset, int origin)
{
off_t rc;
 
rc = lseek(f->fd, offset, origin);
if (rc == (off_t) (-1)) {
/* errno has been set by lseek. */
return -1;
}
 
f->eof = 0;
 
return 0;
}
 
/** @}
*/
/branches/dynload/uspace/lib/libc/generic/io/fprintf.c
0,0 → 1,69
/*
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup libc
* @{
*/
/**
* @file
* @brief fprintf, vfprintf
*/
 
#include <stdio.h>
#include <sys/types.h>
#include <io/printf_core.h>
 
static int vfprintf_write(const char *s, size_t count, void *f)
{
return fwrite(s, 1, count, (FILE *) f);
}
 
int vfprintf(FILE *f, const char *fmt, va_list ap)
{
struct printf_spec ps = {
(int (*)(void *, size_t, void *)) vfprintf_write,
(void *) f
};
 
return printf_core(fmt, &ps, ap);
}
 
int fprintf(FILE *f, const char *fmt, ...)
{
int rv;
va_list args;
 
va_start(args, fmt);
rv = vfprintf(f, fmt, args);
va_end(args);
 
return rv;
}
 
/** @}
*/
/branches/dynload/uspace/lib/libc/generic/io/stream.c
42,7 → 42,7
#include <ipc/ns.h>
#include <ipc/fb.h>
#include <ipc/services.h>
#include <console.h>
#include <ipc/console.h>
#include <unistd.h>
#include <async.h>
#include <sys/types.h>
/branches/dynload/uspace/lib/libc/Makefile
34,7 → 34,6
 
LIBC_PREFIX = $(shell pwd)
SOFTINT_PREFIX = ../softint
CONSOLE_PREFIX = ../../srv/console
RTLD_PREFIX = ../../lib/rtld
 
## Setup toolchain
42,7 → 41,7
 
include $(LIBC_PREFIX)/Makefile.toolchain
 
CFLAGS += -I$(CONSOLE_PREFIX) -I$(RTLD_PREFIX)/include -I../../srv/loader/include -D__32_BITS__
CFLAGS += -I$(RTLD_PREFIX)/include -I../../srv/loader/include -D__32_BITS__
PIC_CFLAGS := $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
 
## Sources
54,6 → 53,7
generic/ddi.c \
generic/as.c \
generic/cap.c \
generic/console.c \
generic/mem.c \
generic/string.c \
generic/fibril.c \
66,6 → 66,8
generic/io/asprintf.c \
generic/io/io.c \
generic/io/printf.c \
generic/io/fprintf.c \
generic/io/stdio.c \
generic/io/stream.c \
generic/io/sprintf.c \
generic/io/snprintf.c \
/branches/dynload/uspace/lib/libc/arch/ia64/src/entry.s
38,7 → 38,7
#
__entry:
alloc loc0 = ar.pfs, 0, 1, 2, 0
mov r1 = _gp
movl r1 = _gp
 
# Pass PCB pointer as the first argument to __main
mov out0 = r2
/branches/dynload/uspace/lib/libc/arch/ia64/src/thread_entry.s
36,7 → 36,7
__thread_entry:
alloc loc0 = ar.pfs, 0, 1, 1, 0
 
mov r1 = _gp
movl r1 = _gp
#
# r8 contains address of uarg structure.
/branches/dynload/uspace/srv/kbd/genarch/src/nofb.c
59,8 → 59,11
{
static unsigned long buf = 0;
static int count = 0;
if(scan_code == 0x7e) {
 
if (scan_code == '\r')
scan_code = '\n';
 
if (scan_code == 0x7e) {
switch (buf) {
case KEY_F5:
keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
/branches/dynload/uspace/srv/kbd/Makefile
92,6 → 92,10
GENARCH_SOURCES += \
genarch/src/nofb.c
endif
ifeq ($(ARCH), mips32eb)
GENARCH_SOURCES += \
genarch/src/nofb.c
endif
 
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES)))
/branches/dynload/uspace/srv/console/console.c
40,7 → 40,7
#include <ipc/services.h>
#include <errno.h>
#include <key_buffer.h>
#include <console.h>
#include <ipc/console.h>
#include <unistd.h>
#include <async.h>
#include <libadt/fifo.h>
47,7 → 47,9
#include <screenbuffer.h>
#include <sys/mman.h>
#include <stdio.h>
#include <sysinfo.h>
 
#include "console.h"
#include "gcons.h"
 
#define MAX_KEYREQUESTS_BUFFERED 32
57,6 → 59,7
/** Index of currently used virtual console.
*/
int active_console = 0;
int prev_console = 0;
 
/** Information about framebuffer
*/
121,17 → 124,39
async_msg_2(fb_info.phone, FB_CURSOR_GOTO, row, col);
}
 
static void set_style(style_t *style)
static void set_style(int style)
{
async_msg_2(fb_info.phone, FB_SET_STYLE, style->fg_color,
style->bg_color);
async_msg_1(fb_info.phone, FB_SET_STYLE, style);
}
 
static void set_style_col(int fgcolor, int bgcolor)
static void set_color(int fgcolor, int bgcolor, int flags)
{
async_msg_2(fb_info.phone, FB_SET_STYLE, fgcolor, bgcolor);
async_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags);
}
 
static void set_rgb_color(int fgcolor, int bgcolor)
{
async_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
}
 
static void set_attrs(attrs_t *attrs)
{
switch (attrs->t) {
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;
}
}
 
static void prtchr(char c, int row, int col)
{
async_msg_3(fb_info.phone, FB_PUTCHAR, c, row, col);
195,7 → 220,7
connection_t *conn;
int i, j, rc;
keyfield_t *field;
style_t *style;
attrs_t *attrs;
if (newcons == active_console)
return;
206,9 → 231,10
gcons_in_kernel();
async_serialize_end();
if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE))
if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {
prev_console = active_console;
active_console = KERNEL_CONSOLE;
else
} else
newcons = active_console;
}
222,7 → 248,7
gcons_change_console(newcons);
conn = &connections[active_console];
set_style(&conn->screenbuffer.style);
set_attrs(&conn->screenbuffer.attrs);
curs_visibility(false);
if (interbuffer) {
for (i = 0; i < conn->screenbuffer.size_x; i++)
234,25 → 260,25
*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_0_0(fb_info.phone, FB_DRAW_TEXT_DATA);
}
if ((!interbuffer) || (rc != 0)) {
set_style(&conn->screenbuffer.style);
set_attrs(&conn->screenbuffer.attrs);
clrscr();
style = &conn->screenbuffer.style;
attrs = &conn->screenbuffer.attrs;
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++) {
field = get_field_at(&conn->screenbuffer, i, j);
if (!style_same(*style, field->style))
set_style(&field->style);
style = &field->style;
if (!attrs_same(*attrs, field->attrs))
set_attrs(&field->attrs);
attrs = &field->attrs;
if ((field->character == ' ') &&
(style_same(field->style,
conn->screenbuffer.style)))
(attrs_same(field->attrs,
conn->screenbuffer.attrs)))
continue;
 
prtchr(field->character, j, i);
}
}
337,9 → 363,9
ipc_callid_t callid;
ipc_call_t call;
int consnum;
ipcarg_t arg1, arg2;
ipcarg_t arg1, arg2, arg3;
connection_t *conn;
 
if ((consnum = find_free_connection()) == -1) {
ipc_answer_0(iid, ELIMIT);
return;
354,12 → 380,12
/* Accept the connection */
ipc_answer_0(iid, EOK);
 
while (1) {
async_serialize_end();
callid = async_get_call(&call);
async_serialize_start();
 
arg1 = 0;
arg2 = 0;
switch (IPC_GET_METHOD(call)) {
367,7 → 393,7
gcons_notify_disconnect(consnum);
/* Answer all pending requests */
while (conn->keyrequest_counter > 0) {
while (conn->keyrequest_counter > 0) {
conn->keyrequest_counter--;
ipc_answer_0(fifo_pop(conn->keyrequests),
ENOENT);
405,11 → 431,26
break;
case CONSOLE_SET_STYLE:
arg1 = IPC_GET_ARG1(call);
screenbuffer_set_style(&conn->screenbuffer, arg1);
if (consnum == active_console)
set_style(arg1);
break;
case CONSOLE_SET_COLOR:
arg1 = IPC_GET_ARG1(call);
arg2 = IPC_GET_ARG2(call);
screenbuffer_set_style(&conn->screenbuffer, arg1,
arg3 = IPC_GET_ARG3(call);
screenbuffer_set_color(&conn->screenbuffer, arg1,
arg2, arg3);
if (consnum == active_console)
set_color(arg1, arg2, arg3);
break;
case CONSOLE_SET_RGB_COLOR:
arg1 = IPC_GET_ARG1(call);
arg2 = IPC_GET_ARG2(call);
screenbuffer_set_rgb_color(&conn->screenbuffer, arg1,
arg2);
if (consnum == active_console)
set_style_col(arg1, arg2);
set_rgb_color(arg1, arg2);
break;
case CONSOLE_CURSOR_VISIBILITY:
arg1 = IPC_GET_ARG1(call);
442,6 → 483,11
}
}
 
static void interrupt_received(ipc_callid_t callid, ipc_call_t *call)
{
change_console(prev_console);
}
 
int main(int argc, char *argv[])
{
printf(NAME ": HelenOS Console service\n");
449,11 → 495,11
ipcarg_t phonehash;
int kbd_phone;
int i;
 
async_set_client_connection(client_connection);
/* Connect to keyboard driver */
 
kbd_phone = ipc_connect_me_to(PHONE_NS, SERVICE_KEYBOARD, 0, 0);
while (kbd_phone < 0) {
usleep(10000);
478,7 → 524,7
async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.rows,
&fb_info.cols);
set_style_col(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
set_rgb_color(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
clrscr();
/* Init virtual consoles */
510,20 → 556,30
interbuffer = NULL;
}
}
 
curs_goto(0, 0);
curs_visibility(
connections[active_console].screenbuffer.is_cursor_visible);
 
/* Register at NS */
if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, 0, &phonehash) != 0)
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");
async_set_interrupt_received(interrupt_received);
}
// FIXME: avoid connectiong to itself, keep using klog
// printf(NAME ": Accepting connections\n");
async_manager();
 
return 0;
return 0;
}
/** @}
/branches/dynload/uspace/srv/console/console.h
39,15 → 39,6
 
#define CONSOLE_COUNT 12
 
#define CONSOLE_GETCHAR 1026
#define CONSOLE_PUTCHAR 1027
#define CONSOLE_CLEAR 1028
#define CONSOLE_GOTO 1029
#define CONSOLE_GETSIZE 1030
#define CONSOLE_FLUSH 1031
#define CONSOLE_SET_STYLE 1032
#define CONSOLE_CURSOR_VISIBILITY 1033
 
#endif
/** @}
/branches/dynload/uspace/srv/console/gcons.c
97,9 → 97,9
async_msg_0(fbphone, FB_CLEAR);
}
 
static void set_style(int fgcolor, int bgcolor)
static void set_rgb_color(int fgcolor, int bgcolor)
{
async_msg_2(fbphone, FB_SET_STYLE, fgcolor, bgcolor);
async_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
}
 
/** Transparent putchar */
346,7 → 346,7
return;
vp_switch(0);
set_style(MAIN_COLOR, MAIN_COLOR);
set_rgb_color(MAIN_COLOR, MAIN_COLOR);
clear();
draw_pixmap(_binary_helenos_ppm_start,
(size_t) &_binary_helenos_ppm_size, xres - 66, 2);
481,7 → 481,7
if (cstatus_vp[i] < 0)
return;
vp_switch(cstatus_vp[i]);
set_style(0x202020, 0xffffff);
set_rgb_color(0x202020, 0xffffff);
}
/* Initialize icons */
/branches/dynload/uspace/srv/console/screenbuffer.c
33,6 → 33,7
*/
 
#include <screenbuffer.h>
#include <console/style.h>
#include <malloc.h>
#include <unistd.h>
 
49,7 → 50,7
field = get_field_at(scr, scr->position_x, scr->position_y);
 
field->character = c;
field->style = scr->style;
field->attrs = scr->attrs;
}
 
/** Initilize screenbuffer. Allocate space for screen content in accordance to given size.
67,8 → 68,8
scr->size_x = size_x;
scr->size_y = size_y;
scr->style.fg_color = DEFAULT_FOREGROUND;
scr->style.bg_color = DEFAULT_BACKGROUND;
scr->attrs.t = at_style;
scr->attrs.a.s.style = STYLE_NORMAL;
scr->is_cursor_visible = 1;
screenbuffer_clear(scr);
85,7 → 86,7
for (i = 0; i < (scr->size_x * scr->size_y); i++) {
scr->buffer[i].character = ' ';
scr->buffer[i].style = scr->style;
scr->buffer[i].attrs = scr->attrs;
}
 
scr->top_line = 0;
103,7 → 104,7
for (i = 0; i < scr->size_x; i++) {
scr->buffer[i + line * scr->size_x].character = ' ';
scr->buffer[i + line * scr->size_x].style = scr->style;
scr->buffer[i + line * scr->size_x].attrs = scr->attrs;
}
}
 
136,12 → 137,37
* @param fg_color
* @param bg_color
*/
void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color)
void screenbuffer_set_style(screenbuffer_t *scr, int style)
{
scr->style.fg_color = fg_color;
scr->style.bg_color = bg_color;
scr->attrs.t = at_style;
scr->attrs.a.s.style = style;
}
 
/** Set new color.
* @param scr
* @param fg_color
* @param bg_color
*/
void screenbuffer_set_color(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color, unsigned int flags)
{
scr->attrs.t = at_idx;
scr->attrs.a.i.fg_color = fg_color;
scr->attrs.a.i.bg_color = bg_color;
scr->attrs.a.i.flags = flags;
}
 
/** Set new RGB color.
* @param scr
* @param fg_color
* @param bg_color
*/
void screenbuffer_set_rgb_color(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color)
{
scr->attrs.t = at_rgb;
scr->attrs.a.r.fg_color = fg_color;
scr->attrs.a.r.bg_color = bg_color;
}
 
/** @}
*/
/branches/dynload/uspace/srv/console/screenbuffer.h
41,23 → 41,46
#define DEFAULT_BACKGROUND 0xf0f0f0 /**< default console background color */
 
typedef struct {
uint8_t style;
} attr_style_t;
 
typedef struct {
uint8_t fg_color;
uint8_t bg_color;
uint8_t flags;
} attr_idx_t;
 
typedef struct {
uint32_t bg_color; /**< background color */
uint32_t fg_color; /**< foreground color */
} style_t;
} attr_rgb_t;
 
typedef struct {
enum {
at_style,
at_idx,
at_rgb
} t;
union {
attr_style_t s;
attr_idx_t i;
attr_rgb_t r;
} a;
} attrs_t;
 
/** One field on screen. It contain one character and its attributes. */
typedef struct {
char character; /**< Character itself */
style_t style; /**< Character`s attributes */
attrs_t attrs; /**< Character`s attributes */
} keyfield_t;
 
/** Structure for buffering state of one virtual console.
*/
typedef struct {
keyfield_t *buffer; /**< Screen content - characters and its style. Used as cyclyc buffer. */
keyfield_t *buffer; /**< Screen content - characters and their attributes. Used as a circular buffer. */
unsigned int size_x, size_y; /**< Number of columns and rows */
unsigned int position_x, position_y; /**< Coordinates of last printed character for determining cursor position */
style_t style; /**< Current style */
attrs_t attrs; /**< Current attributes. */
unsigned int top_line; /**< Points to buffer[][] line that will be printed at screen as the first line */
unsigned char is_cursor_visible; /**< Cursor state - default is visible */
} screenbuffer_t;
73,14 → 96,23
return scr->buffer + x + ((y + scr->top_line) % scr->size_y) * scr->size_x;
}
 
/** Compares two styles.
/** Compares two sets of attributes.
* @param s1 first style
* @param s2 second style
* @return nonzero on equality
*/
static inline int style_same(style_t s1, style_t s2)
static inline int attrs_same(attrs_t a1, attrs_t a2)
{
return s1.fg_color == s2.fg_color && s1.bg_color == s2.bg_color;
if (a1.t != a2.t) return 0;
 
switch (a1.t) {
case at_style: return a1.a.s.style == a2.a.s.style;
case at_idx: return a1.a.i.fg_color == a2.a.i.fg_color &&
a1.a.i.bg_color == a2.a.i.bg_color &&
a1.a.i.flags == a2.a.i.flags;
case at_rgb: return a1.a.r.fg_color == a2.a.r.fg_color &&
a1.a.r.bg_color == a2.a.r.bg_color;
}
}
 
 
91,7 → 123,11
void screenbuffer_clear_line(screenbuffer_t *scr, unsigned int line);
void screenbuffer_copy_buffer(screenbuffer_t *scr, keyfield_t *dest);
void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y);
void screenbuffer_set_style(screenbuffer_t *scr, unsigned int fg_color, unsigned int bg_color);
void screenbuffer_set_style(screenbuffer_t *scr, int style);
void screenbuffer_set_color(screenbuffer_t *scr, unsigned int fg_color,
unsigned int bg_color, unsigned int attr);
void screenbuffer_set_rgb_color(screenbuffer_t *scr, unsigned int fg_color,
unsigned int bg_color);
 
#endif
 
/branches/dynload/uspace/srv/loader/main.c
59,6 → 59,8
#include <elf.h>
#include <elf_load.h>
 
#define DPRINTF(...)
 
void program_run(void *entry, pcb_t *pcb);
 
/** Pathname of the file that will be loaded */
227,7 → 229,7
 
rc = elf_load_file(pathname, 0, 0, &prog_info);
if (rc < 0) {
printf("Failed to load executable '%s'.\n", pathname);
DPRINTF("Failed to load executable '%s'.\n", pathname);
ipc_answer_0(rid, EINVAL);
return 1;
}
247,7 → 249,8
printf("Load ELF interpreter '%s'\n", prog_info.interp);
rc = elf_load_file(prog_info.interp, 0, 0, &interp_info);
if (rc < 0) {
printf("Failed to load interpreter '%s.'\n", prog_info.interp);
DPRINTF("Failed to load interpreter '%s.'\n",
prog_info.interp);
ipc_answer_0(rid, EINVAL);
return 1;
}
274,8 → 277,8
{
if (is_dyn_linked == true) {
/* Dynamically linked program */
printf("run dynamic linker\n");
printf("entry point: 0x%lx\n", interp_info.entry);
DPRINTF("Run ELF interpreter.\n");
DPRINTF("Entry point: 0x%lx\n", interp_info.entry);
close_console();
 
ipc_answer_0(rid, EOK);
332,7 → 335,7
}
if ((callid & IPC_CALLID_NOTIFICATION) == 0 &&
IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP) {
printf("responding EINVAL to method %d\n",
DPRINTF("Responding EINVAL to method %d.\n",
IPC_GET_METHOD(call));
ipc_answer_0(callid, EINVAL);
}
/branches/dynload/uspace/srv/loader/elf_load.c
57,6 → 57,8
#include "elf_load.h"
#include "arch.h"
 
#define DPRINTF(...)
 
static char *error_codes[] = {
"no error",
"invalid image",
107,11 → 109,9
int fd;
int rc;
 
// printf("open and read '%s'...\n", file_name);
 
fd = open(file_name, O_RDONLY);
if (fd < 0) {
printf("failed opening file (error %d)\n", fd);
DPRINTF("failed opening file\n");
return -1;
}
 
160,19 → 160,18
 
rc = my_read(elf->fd, header, sizeof(elf_header_t));
if (rc < 0) {
printf("read error\n");
DPRINTF("Read error.\n");
return EE_INVALID;
}
 
elf->header = header;
 
// printf("ELF-load:");
/* Identify ELF */
if (header->e_ident[EI_MAG0] != ELFMAG0 ||
header->e_ident[EI_MAG1] != ELFMAG1 ||
header->e_ident[EI_MAG2] != ELFMAG2 ||
header->e_ident[EI_MAG3] != ELFMAG3) {
printf("invalid header\n");
DPRINTF("Invalid header.\n");
return EE_INVALID;
}
182,18 → 181,18
header->e_ident[EI_VERSION] != EV_CURRENT ||
header->e_version != EV_CURRENT ||
header->e_ident[EI_CLASS] != ELF_CLASS) {
printf("incompatible data/version/class\n");
DPRINTF("Incompatible data/version/class.\n");
return EE_INCOMPATIBLE;
}
 
if (header->e_phentsize != sizeof(elf_segment_header_t)) {
printf("e_phentsize:%d != %d\n", header->e_phentsize,
DPRINTF("e_phentsize:%d != %d\n", header->e_phentsize,
sizeof(elf_segment_header_t));
return EE_INCOMPATIBLE;
}
 
if (header->e_shentsize != sizeof(elf_section_header_t)) {
printf("e_shentsize:%d != %d\n", header->e_shentsize,
DPRINTF("e_shentsize:%d != %d\n", header->e_shentsize,
sizeof(elf_section_header_t));
return EE_INCOMPATIBLE;
}
200,23 → 199,19
 
/* Check if the object type is supported. */
if (header->e_type != ET_EXEC && header->e_type != ET_DYN) {
printf("Object type %d is not supported\n", header->e_type);
DPRINTF("Object type %d is not supported\n", header->e_type);
return EE_UNSUPPORTED;
}
 
/* Shared objects can be loaded with a bias */
// printf("Object type: %d\n", header->e_type);
if (header->e_type == ET_DYN)
elf->bias = so_bias;
else
elf->bias = 0;
 
// printf("Bias set to 0x%x\n", elf->bias);
elf->info->interp = NULL;
elf->info->dynamic = NULL;
 
// printf("parse segments\n");
 
/* Walk through all segment headers and process them. */
for (i = 0; i < header->e_phnum; i++) {
elf_segment_header_t segment_hdr;
228,7 → 223,7
rc = my_read(elf->fd, &segment_hdr,
sizeof(elf_segment_header_t));
if (rc < 0) {
printf("read error\n");
DPRINTF("Read error.\n");
return EE_INVALID;
}
 
237,7 → 232,7
return rc;
}
 
// printf("parse sections\n");
DPRINTF("Parse sections.\n");
 
/* Inspect all section headers and proccess them. */
for (i = 0; i < header->e_shnum; i++) {
250,7 → 245,7
rc = my_read(elf->fd, &section_hdr,
sizeof(elf_section_header_t));
if (rc < 0) {
printf("read error\n");
DPRINTF("Read error.\n");
return EE_INVALID;
}
 
262,7 → 257,7
elf->info->entry =
(entry_point_t)((uint8_t *)header->e_entry + elf->bias);
 
// printf("done\n");
DPRINTF("Done.\n");
 
return EE_OK;
}
303,7 → 298,7
/* Record pointer to dynamic section into info structure */
elf->info->dynamic =
(void *)((uint8_t *)entry->p_vaddr + elf->bias);
printf("dynamic section found at 0x%x\n",
DPRINTF("dynamic section found at 0x%x\n",
(uintptr_t)elf->info->dynamic);
break;
case 0x70000000:
314,7 → 309,7
// case PT_LOPROC:
// case PT_HIPROC:
default:
printf("segment p_type %d unknown\n", entry->p_type);
DPRINTF("Segment p_type %d unknown.\n", entry->p_type);
return EE_UNSUPPORTED;
break;
}
337,8 → 332,8
size_t mem_sz;
int rc;
 
// printf("load segment at addr 0x%x, size 0x%x\n", entry->p_vaddr,
// entry->p_memsz);
DPRINTF("Load segment at addr 0x%x, size 0x%x\n", entry->p_vaddr,
entry->p_memsz);
bias = elf->bias;
 
345,7 → 340,7
if (entry->p_align > 1) {
if ((entry->p_offset % entry->p_align) !=
(entry->p_vaddr % entry->p_align)) {
printf("align check 1 failed offset%%align=%d, "
DPRINTF("Align check 1 failed offset%%align=%d, "
"vaddr%%align=%d\n",
entry->p_offset % entry->p_align,
entry->p_vaddr % entry->p_align
367,8 → 362,8
base = ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE);
mem_sz = entry->p_memsz + (entry->p_vaddr - base);
 
// printf("map to p_vaddr=0x%x-0x%x...\n", entry->p_vaddr + bias,
// entry->p_vaddr + bias + ALIGN_UP(entry->p_memsz, PAGE_SIZE));
DPRINTF("Map to p_vaddr=0x%x-0x%x.\n", entry->p_vaddr + bias,
entry->p_vaddr + bias + ALIGN_UP(entry->p_memsz, PAGE_SIZE));
 
/*
* For the course of loading, the area needs to be readable
377,18 → 372,17
a = as_area_create((uint8_t *)base + bias, mem_sz,
AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
if (a == (void *)(-1)) {
printf("memory mapping failed (0x%x, %d)\n",
DPRINTF("memory mapping failed (0x%x, %d)\n",
base+bias, mem_sz);
return EE_MEMORY;
}
 
// printf("as_area_create(0x%lx, 0x%x, %d) -> 0x%lx\n",
// entry->p_vaddr+bias, entry->p_memsz, flags, (uintptr_t)a);
DPRINTF("as_area_create(0x%lx, 0x%x, %d) -> 0x%lx\n",
entry->p_vaddr+bias, entry->p_memsz, flags, (uintptr_t)a);
 
/*
* Load segment data
*/
// printf("seek to %d\n", entry->p_offset);
rc = lseek(elf->fd, entry->p_offset, SEEK_SET);
if (rc < 0) {
printf("seek error\n");
395,11 → 389,10
return EE_INVALID;
}
 
// printf("read 0x%x bytes to address 0x%x\n", entry->p_filesz, entry->p_vaddr+bias);
/* rc = read(fd, (void *)(entry->p_vaddr + bias), entry->p_filesz);
if (rc < 0) { printf("read error\n"); return EE_INVALID; }*/
 
/* Long reads are not possible yet. Load segment picewise */
/* Long reads are not possible yet. Load segment piecewise. */
 
unsigned left, now;
uint8_t *dp;
411,12 → 404,10
now = 16384;
if (now > left) now = left;
 
// printf("read %d...", now);
rc = my_read(elf->fd, dp, now);
// printf("->%d\n", rc);
 
if (rc < 0) {
printf("read error\n");
DPRINTF("Read error.\n");
return EE_INVALID;
}
 
433,7 → 424,7
// printf("set area flags to %d\n", flags);
rc = as_area_change_flags((uint8_t *)entry->p_vaddr + bias, flags);
if (rc != 0) {
printf("failed to set memory area flags\n");
DPRINTF("Failed to set memory area flags.\n");
return EE_MEMORY;
}
 
/branches/dynload/uspace/srv/loader/arch/ia64/_link.ld.in
12,15 → 12,10
*(.interp);
} :interp
 
. = 0x00084000 + SIZEOF_HEADERS;
/* On Itanium code sections must be aligned to 16 bytes. */
. = ALIGN(0x800000000 + SIZEOF_HEADERS, 16);
 
.init : {
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
LONG(0);
*(.init);
} : text
.text : {
/branches/dynload/uspace/srv/loader/arch/mips32eb
0,0 → 1,0
link mips32
Property changes:
Added: svn:special
+*
\ No newline at end of property
/branches/dynload/uspace/srv/fb/serial_console.c
43,18 → 43,57
#include <ipc/fb.h>
#include <bool.h>
#include <errno.h>
#include <console/color.h>
#include <console/style.h>
 
#include "serial_console.h"
 
#define MAX_CONTROL 20
 
static void serial_sgr(const unsigned int mode);
 
static int width;
static int height;
static bool color = true; /** True if producing color output. */
static putc_function_t putc_function;
 
/* Allow only 1 connection */
static int client_connected = 0;
 
enum sgr_color_index {
CI_BLACK = 0,
CI_RED = 1,
CI_GREEN = 2,
CI_BROWN = 3,
CI_BLUE = 4,
CI_MAGENTA = 5,
CI_CYAN = 6,
CI_WHITE = 7,
};
 
enum sgr_command {
SGR_RESET = 0,
SGR_BOLD = 1,
SGR_BLINK = 5,
SGR_REVERSE = 7,
SGR_NORMAL_INT = 22,
SGR_BLINK_OFF = 25,
SGR_REVERSE_OFF = 27,
SGR_FGCOLOR = 30,
SGR_BGCOLOR = 40
};
 
static int color_map[] = {
[COLOR_BLACK] = CI_BLACK,
[COLOR_BLUE] = CI_RED,
[COLOR_GREEN] = CI_GREEN,
[COLOR_CYAN] = CI_CYAN,
[COLOR_RED] = CI_RED,
[COLOR_MAGENTA] = CI_MAGENTA,
[COLOR_YELLOW] = CI_BROWN,
[COLOR_WHITE] = CI_WHITE
};
 
void serial_puts(char *str)
{
while (*str)
66,13 → 105,20
if ((row > height) || (col > width))
return;
char control[20];
snprintf(control, 20, "\033[%u;%uf", row + 1, col + 1);
char control[MAX_CONTROL];
snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1);
serial_puts(control);
}
 
void serial_clrscr(void)
{
/* Initialize graphic rendition attributes. */
serial_sgr(SGR_RESET);
if (color) {
serial_sgr(SGR_FGCOLOR + CI_BLACK);
serial_sgr(SGR_BGCOLOR + CI_WHITE);
}
 
serial_puts("\033[2J");
}
 
89,7 → 135,8
}
}
 
void serial_set_style(const unsigned int mode)
/** ECMA-48 Set Graphics Rendition. */
static void serial_sgr(const unsigned int mode)
{
char control[MAX_CONTROL];
snprintf(control, MAX_CONTROL, "\033[%um", mode);
136,6 → 183,7
int newrow;
int fgcolor;
int bgcolor;
int style;
int i;
if (client_connected) {
186,12 → 234,47
retval = 0;
break;
case FB_SET_STYLE:
style = IPC_GET_ARG1(call);
if (style == STYLE_EMPHASIS) {
if (color) {
serial_sgr(SGR_RESET);
serial_sgr(SGR_FGCOLOR + CI_RED);
serial_sgr(SGR_BGCOLOR + CI_WHITE);
}
serial_sgr(SGR_BOLD);
} else {
if (color) {
serial_sgr(SGR_RESET);
serial_sgr(SGR_FGCOLOR + CI_BLACK);
serial_sgr(SGR_BGCOLOR + CI_WHITE);
}
serial_sgr(SGR_NORMAL_INT);
}
retval = 0;
break;
case FB_SET_COLOR:
fgcolor = IPC_GET_ARG1(call);
bgcolor = IPC_GET_ARG2(call);
 
if (color) {
serial_sgr(SGR_RESET);
serial_sgr(SGR_FGCOLOR + color_map[fgcolor]);
serial_sgr(SGR_BGCOLOR + color_map[bgcolor]);
} else {
if (fgcolor < bgcolor)
serial_sgr(SGR_RESET);
else
serial_sgr(SGR_REVERSE);
}
retval = 0;
break;
case FB_SET_RGB_COLOR:
fgcolor = IPC_GET_ARG1(call);
bgcolor = IPC_GET_ARG2(call);
if (fgcolor < bgcolor)
serial_set_style(0);
serial_sgr(SGR_REVERSE_OFF);
else
serial_set_style(7);
serial_sgr(SGR_REVERSE);
retval = 0;
break;
case FB_SCROLL:
/branches/dynload/uspace/srv/fb/fb.c
51,6 → 51,8
#include <ipc/services.h>
#include <kernel/errno.h>
#include <kernel/genarch/fb/visuals.h>
#include <console/color.h>
#include <console/style.h>
#include <async.h>
#include <bool.h>
 
71,8 → 73,13
#define MAX_PIXMAPS 256 /**< Maximum number of saved pixmaps */
#define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */
 
/** Function to render a pixel from a RGB value. */
typedef void (*rgb_conv_t)(void *, uint32_t);
 
/** Function to draw a glyph. */
typedef void (*dg_t)(unsigned int x, unsigned int y, bool cursor,
uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color);
 
struct {
uint8_t *fb_addr;
88,7 → 95,14
rgb_conv_t rgb_conv;
} screen;
 
/** Backbuffer character cell. */
typedef struct {
uint8_t glyph;
uint32_t fg_color;
uint32_t bg_color;
} bb_cell_t;
 
typedef struct {
bool initialized;
unsigned int x;
unsigned int y;
99,10 → 113,22
unsigned int cols;
unsigned int rows;
/* Style and glyphs for text printing */
style_t style;
/*
* Style and glyphs for text printing
*/
 
/** Current attributes. */
attr_rgb_t attr;
 
/** Pre-rendered mask for rendering glyphs. Different viewports
* might use different drawing functions depending on whether their
* scanlines are aligned on a word boundary.*/
uint8_t *glyphs;
 
uint8_t *bgpixel;
 
/** Glyph drawing function for this viewport. */
dg_t dglyph;
/* Auto-cursor position */
bool cursor_active;
111,8 → 137,8
bool cursor_shown;
/* Back buffer */
bb_cell_t *backbuf;
unsigned int bbsize;
uint8_t *backbuf;
} viewport_t;
 
typedef struct {
139,8 → 165,38
 
static bool client_connected = false; /**< Allow only 1 connection */
 
static void draw_glyph(unsigned int x, unsigned int y, bool cursor,
uint8_t *glyphs, uint8_t glyph);
static uint32_t color_table[16] = {
[COLOR_BLACK] = 0x000000,
[COLOR_BLUE] = 0x0000f0,
[COLOR_GREEN] = 0x00f000,
[COLOR_CYAN] = 0x00f0f0,
[COLOR_RED] = 0xf00000,
[COLOR_MAGENTA] = 0xf000f0,
[COLOR_YELLOW] = 0xf0f000,
[COLOR_WHITE] = 0xf0f0f0,
 
[8 + COLOR_BLACK] = 0x000000,
[8 + COLOR_BLUE] = 0x0000ff,
[8 + COLOR_GREEN] = 0x00ff00,
[8 + COLOR_CYAN] = 0x00ffff,
[8 + COLOR_RED] = 0xff0000,
[8 + COLOR_MAGENTA] = 0xff00ff,
[8 + COLOR_YELLOW] = 0xffff00,
[8 + COLOR_WHITE] = 0xffffff,
};
 
static int rgb_from_style(attr_rgb_t *rgb, int style);
static int rgb_from_idx(attr_rgb_t *rgb, ipcarg_t fg_color,
ipcarg_t bg_color, ipcarg_t flags);
 
static int fb_set_color(viewport_t *vport, ipcarg_t fg_color,
ipcarg_t bg_color, ipcarg_t attr);
 
static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor,
uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color);
static void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor,
uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color);
 
static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col,
unsigned int row);
 
279,7 → 335,7
draw_filled_rect(
vport->x + COL2X(vport->cols), vport->y,
vport->x + vport->width, vport->y + vport->height,
vport->style.bg_color);
vport->attr.bg_color);
}
 
if (ROW2Y(vport->rows) < vport->height) {
286,11 → 342,22
draw_filled_rect(
vport->x, vport->y + ROW2Y(vport->rows),
vport->x + vport->width, vport->y + vport->height,
vport->style.bg_color);
vport->attr.bg_color);
}
}
 
static void backbuf_clear(bb_cell_t *backbuf, size_t len, uint32_t fg_color,
uint32_t bg_color)
{
unsigned i;
 
for (i = 0; i < len; i++) {
backbuf[i].glyph = 0;
backbuf[i].fg_color = fg_color;
backbuf[i].bg_color = bg_color;
}
}
 
/** Clear viewport.
*
* @param vport Viewport to clear
298,7 → 365,8
*/
static void vport_clear(viewport_t *vport)
{
memset(vport->backbuf, 0, vport->bbsize);
backbuf_clear(vport->backbuf, vport->cols * vport->rows,
vport->attr.fg_color, vport->attr.bg_color);
vport_redraw(vport);
}
 
313,6 → 381,9
unsigned int row, col;
unsigned int x, y;
uint8_t glyph;
uint32_t fg_color;
uint32_t bg_color;
bb_cell_t *bbp, *xbp;
 
/*
* Redraw.
323,17 → 394,27
x = vport->x;
for (col = 0; col < vport->cols; col++) {
if ((row + lines >= 0) && (row + lines < vport->rows)) {
glyph = vport->backbuf[BB_POS(vport, col, row + lines)];
xbp = &vport->backbuf[BB_POS(vport, col, row + lines)];
bbp = &vport->backbuf[BB_POS(vport, col, row)];
 
if (vport->backbuf[BB_POS(vport, col, row)] == glyph) {
glyph = xbp->glyph;
fg_color = xbp->fg_color;
bg_color = xbp->bg_color;
 
if (bbp->glyph == glyph &&
bbp->fg_color == xbp->fg_color &&
bbp->bg_color == xbp->bg_color) {
x += FONT_WIDTH;
continue;
}
} else {
glyph = 0;
fg_color = vport->attr.fg_color;
bg_color = vport->attr.bg_color;
}
 
draw_glyph(x, y, false, vport->glyphs, glyph);
(*vport->dglyph)(x, y, false, vport->glyphs, glyph,
fg_color, bg_color);
x += FONT_WIDTH;
}
y += FONT_SCANLINES;
345,13 → 426,14
 
if (lines > 0) {
memmove(vport->backbuf, vport->backbuf + vport->cols * lines,
vport->cols * (vport->rows - lines));
memset(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)],
0, vport->cols * lines);
vport->cols * (vport->rows - lines) * sizeof(bb_cell_t));
backbuf_clear(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)],
vport->cols * lines, vport->attr.fg_color, vport->attr.bg_color);
} else {
memmove(vport->backbuf - vport->cols * lines, vport->backbuf,
vport->cols * (vport->rows + lines));
memset(vport->backbuf, 0, - vport->cols * lines);
vport->cols * (vport->rows + lines) * sizeof(bb_cell_t));
backbuf_clear(vport->backbuf, - vport->cols * lines,
vport->attr.fg_color, vport->attr.bg_color);
}
}
 
376,23 → 458,16
for (x = 0; x < FONT_WIDTH; x++) {
screen.rgb_conv(&vport->glyphs[GLYPH_POS(glyph, y, false) + x * screen.pixelbytes],
(fb_font[glyph * FONT_SCANLINES + y] & (1 << (7 - x)))
? vport->style.fg_color : vport->style.bg_color);
? 0xffffff : 0x000000);
uint32_t curcolor;
if (y < FONT_SCANLINES - 2)
curcolor =
(fb_font[glyph * FONT_SCANLINES + y] & (1 << (7 - x)))
? vport->style.fg_color : vport->style.bg_color;
else
curcolor = vport->style.fg_color;
screen.rgb_conv(&vport->glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes], curcolor);
screen.rgb_conv(&vport->glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes],
(fb_font[glyph * FONT_SCANLINES + y] & (1 << (7 - x)))
? 0x000000 : 0xffffff);
}
}
}
screen.rgb_conv(vport->bgpixel, vport->style.bg_color);
screen.rgb_conv(vport->bgpixel, vport->attr.bg_color);
}
 
 
420,10 → 495,11
unsigned int cols = width / FONT_WIDTH;
unsigned int rows = height / FONT_SCANLINES;
unsigned int bbsize = cols * rows;
unsigned int bbsize = cols * rows * sizeof(bb_cell_t);
unsigned int glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes;
unsigned int word_size = sizeof(unsigned long);
uint8_t *backbuf = (uint8_t *) malloc(bbsize);
bb_cell_t *backbuf = (bb_cell_t *) malloc(bbsize);
if (!backbuf)
return ENOMEM;
439,8 → 515,8
free(backbuf);
return ENOMEM;
}
memset(backbuf, 0, bbsize);
 
backbuf_clear(backbuf, cols * rows, DEFAULT_FGCOLOR, DEFAULT_BGCOLOR);
memset(glyphs, 0, glyphsize);
memset(bgpixel, 0, screen.pixelbytes);
452,12 → 528,29
viewports[i].cols = cols;
viewports[i].rows = rows;
viewports[i].style.bg_color = DEFAULT_BGCOLOR;
viewports[i].style.fg_color = DEFAULT_FGCOLOR;
viewports[i].attr.bg_color = DEFAULT_BGCOLOR;
viewports[i].attr.fg_color = DEFAULT_FGCOLOR;
viewports[i].glyphs = glyphs;
viewports[i].bgpixel = bgpixel;
 
/*
* Conditions necessary to select aligned version:
*
* - word size is divisible by pixelbytes
* - cell scanline size is divisible by word size
* - cell scanlines are word-aligned
*/
if ((word_size % screen.pixelbytes) == 0 &&
(FONT_WIDTH * screen.pixelbytes) % word_size == 0 &&
(x * screen.pixelbytes) % word_size == 0 &&
screen.scanline % word_size == 0) {
 
viewports[i].dglyph = draw_glyph_aligned;
} else {
viewports[i].dglyph = draw_glyph_fallback;
}
 
viewports[i].cur_col = 0;
viewports[i].cur_row = 0;
viewports[i].cursor_active = false;
534,25 → 627,134
}
 
 
/** Draw a glyph.
/** Draw a glyph, takes advantage of alignment.
*
* @param x x coordinate of top-left corner on screen.
* @param y y coordinate of top-left corner on screen.
* @param cursor Draw glyph with cursor
* @param glyphs Pointer to font bitmap.
* @param glyph Code of the glyph to draw.
* This version can only be used if the following conditions are met:
*
* - word size is divisible by pixelbytes
* - cell scanline size is divisible by word size
* - cell scanlines are word-aligned
*
* It makes use of the pre-rendered mask to process (possibly) several
* pixels at once (word size / pixelbytes pixels at a time are processed)
* making it very fast. Most notably this version is not applicable at 24 bits
* per pixel.
*
* @param x x coordinate of top-left corner on screen.
* @param y y coordinate of top-left corner on screen.
* @param cursor Draw glyph with cursor
* @param glyphs Pointer to font bitmap.
* @param glyph Code of the glyph to draw.
* @param fg_color Foreground color.
* @param bg_color Backgroudn color.
*/
static void draw_glyph(unsigned int x, unsigned int y, bool cursor,
uint8_t *glyphs, uint8_t glyph)
static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor,
uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color)
{
unsigned int yd;
for (yd = 0; yd < FONT_SCANLINES; yd++)
memcpy(&screen.fb_addr[FB_POS(x, y + yd)],
&glyphs[GLYPH_POS(glyph, yd, cursor)], screen.glyphscanline);
unsigned int i, yd;
unsigned long fg_buf, bg_buf;
unsigned long *maskp, *dp;
unsigned long mask;
unsigned int ww, d_add;
 
/*
* Prepare a pair of words, one filled with foreground-color
* pattern and the other filled with background-color pattern.
*/
for (i = 0; i < sizeof(unsigned long) / screen.pixelbytes; i++) {
screen.rgb_conv(&((uint8_t *)&fg_buf)[i * screen.pixelbytes],
fg_color);
screen.rgb_conv(&((uint8_t *)&bg_buf)[i * screen.pixelbytes],
bg_color);
}
 
 
/* Pointer to the current position in the mask. */
maskp = (unsigned long *) &glyphs[GLYPH_POS(glyph, 0, cursor)];
 
/* Pointer to the current position on the screen. */
dp = (unsigned long *) &screen.fb_addr[FB_POS(x, y)];
 
/* Width of the character cell in words. */
ww = FONT_WIDTH * screen.pixelbytes / sizeof(unsigned long);
 
/* Offset to add when moving to another screen scanline. */
d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes;
 
for (yd = 0; yd < FONT_SCANLINES; yd++) {
/*
* Now process the cell scanline, combining foreground
* and background color patters using the pre-rendered mask.
*/
for (i = 0; i < ww; i++) {
mask = *maskp++;
*dp++ = (fg_buf & mask) | (bg_buf & ~mask);
}
 
/* Move to the beginning of the next scanline of the cell. */
dp = (unsigned long *) ((uint8_t *) dp + d_add);
}
}
 
/** Draw a glyph, fallback version.
*
* This version does not make use of the pre-rendered mask, it uses
* the font bitmap directly. It works always, but it is slower.
*
* @param x x coordinate of top-left corner on screen.
* @param y y coordinate of top-left corner on screen.
* @param cursor Draw glyph with cursor
* @param glyphs Pointer to font bitmap.
* @param glyph Code of the glyph to draw.
* @param fg_color Foreground color.
* @param bg_color Backgroudn color.
*/
void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor,
uint8_t *glyphs, uint8_t glyph, uint32_t fg_color, uint32_t bg_color)
{
unsigned int i, j, yd;
uint8_t fg_buf[4], bg_buf[4];
uint8_t *dp, *sp;
unsigned int d_add;
uint8_t b;
 
/* Pre-render 1x the foreground and background color pixels. */
if (cursor) {
screen.rgb_conv(fg_buf, bg_color);
screen.rgb_conv(bg_buf, fg_color);
} else {
screen.rgb_conv(fg_buf, fg_color);
screen.rgb_conv(bg_buf, bg_color);
}
 
/* Pointer to the current position on the screen. */
dp = (uint8_t *) &screen.fb_addr[FB_POS(x, y)];
 
/* Offset to add when moving to another screen scanline. */
d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes;
 
for (yd = 0; yd < FONT_SCANLINES; yd++) {
/* Byte containing bits of the glyph scanline. */
b = fb_font[glyph * FONT_SCANLINES + yd];
 
for (i = 0; i < FONT_WIDTH; i++) {
/* Choose color based on the current bit. */
sp = (b & 0x80) ? fg_buf : bg_buf;
 
/* Copy the pixel. */
for (j = 0; j < screen.pixelbytes; j++) {
*dp++ = *sp++;
}
 
/* Move to the next bit. */
b = b << 1;
}
/* Move to the beginning of the next scanline of the cell. */
dp += d_add;
}
}
 
/** Draw glyph at specified position in viewport.
*
* @param vport Viewport identification
566,13 → 768,19
{
unsigned int x = vport->x + COL2X(col);
unsigned int y = vport->y + ROW2Y(row);
 
uint8_t glyph;
uint32_t fg_color;
uint32_t bg_color;
glyph = vport->backbuf[BB_POS(vport, col, row)];
draw_glyph(x, y, cursor, vport->glyphs, glyph);
glyph = vport->backbuf[BB_POS(vport, col, row)].glyph;
fg_color = vport->backbuf[BB_POS(vport, col, row)].fg_color;
bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color;
 
(*vport->dglyph)(x, y, cursor, vport->glyphs, glyph,
fg_color, bg_color);
}
 
 
/** Hide cursor if it is shown
*
*/
620,12 → 828,18
*/
static void draw_char(viewport_t *vport, uint8_t c, unsigned int col, unsigned int row)
{
bb_cell_t *bbp;
 
/* Do not hide cursor if we are going to overwrite it */
if ((vport->cursor_active) && (vport->cursor_shown) &&
((vport->cur_col != col) || (vport->cur_row != row)))
cursor_hide(vport);
vport->backbuf[BB_POS(vport, col, row)] = c;
 
bbp = &vport->backbuf[BB_POS(vport, col, row)];
bbp->glyph = c;
bbp->fg_color = vport->attr.fg_color;
bbp->bg_color = vport->attr.bg_color;
 
draw_vp_glyph(vport, false, col, row);
vport->cur_col = col;
652,17 → 866,37
static void draw_text_data(viewport_t *vport, keyfield_t *data)
{
unsigned int i;
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;
uint8_t glyph = vport->backbuf[BB_POS(vport, col, row)];
// TODO: use data[i].style
bbp = &vport->backbuf[BB_POS(vport, col, row)];
uint8_t glyph = bbp->glyph;
 
if (glyph != data[i].character) {
vport->backbuf[BB_POS(vport, col, row)] = data[i].character;
bbp->glyph = data[i].character;
a = &data[i].attrs;
 
switch (a->t) {
case at_style:
rgb_from_style(&rgb, a->a.s.style);
break;
case at_idx:
rgb_from_idx(&rgb, a->a.i.fg_color,
a->a.i.bg_color, a->a.i.flags);
break;
case at_rgb:
rgb = a->a.r;
break;
}
 
bbp->fg_color = rgb.fg_color;
bbp->bg_color = rgb.bg_color;
 
draw_vp_glyph(vport, false, col, row);
}
}
1180,6 → 1414,47
}
 
static int rgb_from_style(attr_rgb_t *rgb, int style)
{
switch (style) {
case STYLE_NORMAL:
rgb->fg_color = color_table[COLOR_BLACK];
rgb->bg_color = color_table[COLOR_WHITE];
break;
case STYLE_EMPHASIS:
rgb->fg_color = color_table[COLOR_RED];
rgb->bg_color = color_table[COLOR_WHITE];
break;
default:
return EINVAL;
}
 
return EOK;
}
 
static int rgb_from_idx(attr_rgb_t *rgb, ipcarg_t fg_color,
ipcarg_t bg_color, ipcarg_t flags)
{
fg_color = (fg_color & 7) | ((flags & CATTR_BRIGHT) ? 8 : 0);
bg_color = (bg_color & 7) | ((flags & CATTR_BRIGHT) ? 8 : 0);
 
rgb->fg_color = color_table[fg_color];
rgb->bg_color = color_table[bg_color];
 
return EOK;
}
 
static int fb_set_style(viewport_t *vport, ipcarg_t style)
{
return rgb_from_style(&vport->attr, (int) style);
}
 
static int fb_set_color(viewport_t *vport, ipcarg_t fg_color,
ipcarg_t bg_color, ipcarg_t flags)
{
return rgb_from_idx(&vport->attr, fg_color, bg_color, flags);
}
 
/** Function for handling connections to FB
*
*/
1336,9 → 1611,15
retval = EOK;
break;
case FB_SET_STYLE:
vport->style.fg_color = IPC_GET_ARG1(call);
vport->style.bg_color = IPC_GET_ARG2(call);
render_glyphs(vport);
retval = fb_set_style(vport, IPC_GET_ARG1(call));
break;
case FB_SET_COLOR:
retval = fb_set_color(vport, IPC_GET_ARG1(call),
IPC_GET_ARG2(call), IPC_GET_ARG3(call));
break;
case FB_SET_RGB_COLOR:
vport->attr.fg_color = IPC_GET_ARG1(call);
vport->attr.bg_color = IPC_GET_ARG2(call);
retval = EOK;
break;
case FB_GET_RESOLUTION:
/branches/dynload/uspace/srv/fb/ega.c
49,6 → 49,8
#include <ipc/ns.h>
#include <ipc/services.h>
#include <libarch/ddi.h>
#include <console/style.h>
#include <console/color.h>
 
#include "ega.h"
#include "../console/screenbuffer.h"
64,8 → 66,8
#define EGA_IO_ADDRESS 0x3d4
#define EGA_IO_SIZE 2
 
int ega_normal_color=0x0f;
int ega_inverted_color=0xf0;
int ega_normal_color = 0x0f;
int ega_inverted_color = 0xf0;
 
#define NORMAL_COLOR ega_normal_color
#define INVERTED_COLOR ega_inverted_color
127,13 → 129,13
{
int i;
if (rows > 0) {
memcpy(scr_addr, ((char *) scr_addr) + rows * scr_width * 2,
memmove(scr_addr, ((char *) scr_addr) + rows * scr_width * 2,
scr_width * scr_height * 2 - rows * scr_width * 2);
for (i = 0; i < rows * scr_width; i++)
(((short *) scr_addr) + scr_width * scr_height - rows *
scr_width)[i] = ((style << 8) + ' ');
} else if (rows < 0) {
memcpy(((char *)scr_addr) - rows * scr_width * 2, scr_addr,
memmove(((char *)scr_addr) - rows * scr_width * 2, scr_addr,
scr_width * scr_height * 2 + rows * scr_width * 2);
for (i = 0; i < -rows * scr_width; i++)
((short *)scr_addr)[i] = ((style << 8 ) + ' ');
154,8 → 156,10
 
for (i = 0; i < scr_width * scr_height; i++) {
scr_addr[i * 2] = data[i].character;
/* FIXME
scr_addr[i * 2 + 1] = EGA_STYLE(data[i].style.fg_color,
data[i].style.bg_color);
*/
}
}
 
275,8 → 279,24
retval = 0;
break;
case FB_SET_STYLE:
retval = 0;
switch (IPC_GET_ARG1(call)) {
case STYLE_NORMAL: style = INVERTED_COLOR; break;
case STYLE_EMPHASIS: style = INVERTED_COLOR | 4; break;
default: retval = EINVAL;
}
break;
case FB_SET_COLOR:
fgcolor = IPC_GET_ARG1(call);
bgcolor = IPC_GET_ARG2(call);
style = (fgcolor & 7) | ((bgcolor & 7) << 4);
if (IPC_GET_ARG3(call) & CATTR_BRIGHT)
style = style | 0x08;
retval = 0;
break;
case FB_SET_RGB_COLOR:
fgcolor = IPC_GET_ARG1(call);
bgcolor = IPC_GET_ARG2(call);
style = EGA_STYLE(fgcolor, bgcolor);
retval = 0;
break;
317,8 → 337,8
scr_height = sysinfo_value("fb.height");
if(sysinfo_value("fb.blinking"))
{
ega_normal_color&=0x77;
ega_inverted_color&=0x77;
ega_normal_color &= 0x77;
ega_inverted_color &= 0x77;
}
style = NORMAL_COLOR;
 
/branches/dynload/uspace/srv/fb/Makefile
67,6 → 67,9
SOURCES += ega.c
CFLAGS += -DEGA_ENABLED
endif
ifeq ($(ARCH), arm32)
CFLAGS += -DFB_INVERT_ENDIAN
endif
ifeq ($(ARCH), mips32)
SOURCES += msim.c \
serial_console.c