Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4153 → Rev 4154

/trunk/uspace/app/init/init.c
44,6 → 44,7
#include <task.h>
#include <malloc.h>
#include <macros.h>
#include <console.h>
#include "init.h"
#include "version.h"
 
/trunk/uspace/app/tetris/input.c
58,6 → 58,7
 
#include <async.h>
#include <ipc/console.h>
#include <console.h>
#include <kbd/kbd.h>
 
/* return true iff the given timeval is positive */
114,7 → 115,7
if (!lastchar) {
again:
if (!getchar_inprog) {
cons_phone = get_console_phone();
cons_phone = console_phone_get();
getchar_inprog = async_send_2(cons_phone,
CONSOLE_GETKEY, 0, 0, &charcall);
}
/trunk/uspace/app/klog/klog.c
41,6 → 41,7
#include <as.h>
#include <sysinfo.h>
#include <io/stream.h>
#include <console.h>
#include <errno.h>
 
#define NAME "klog"
/trunk/uspace/lib/libc/include/console.h
38,9 → 38,17
#include <console/style.h>
#include <console/color.h>
 
extern void console_open(void);
extern void console_close(void);
 
extern int console_phone_get(void);
extern void console_wait(void);
 
extern void console_clear(void);
extern void console_goto(int, int);
extern void console_putchar(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);
/trunk/uspace/lib/libc/include/io/stream.h
39,8 → 39,6
 
#define EMFILE -17
 
extern void open_console(void);
extern void close_console(void);
extern void klog_update(void);
 
extern ssize_t read_stdin(void *, size_t);
47,9 → 45,6
extern ssize_t write_stdout(const void *, size_t);
extern ssize_t write_stderr(const void *, size_t);
 
extern int get_console_phone(void);
extern void console_wait(void);
 
#endif
 
/** @}
/trunk/uspace/lib/libc/generic/kbd.c
37,15 → 37,19
#include <kbd/kbd.h>
#include <ipc/ipc.h>
#include <ipc/console.h>
#include <console.h>
#include <async.h>
 
int kbd_get_event(kbd_event_t *ev)
{
int console_phone = get_console_phone();
int cons_phone = console_phone_get();
ipcarg_t r0, r1, r2, r3;
int rc;
 
rc = async_req_0_4(console_phone, CONSOLE_GETKEY, &r0, &r1, &r2, &r3);
if (cons_phone < 0)
return -1;
 
rc = async_req_0_4(cons_phone, CONSOLE_GETKEY, &r0, &r1, &r2, &r3);
if (rc < 0)
return -1;
 
/trunk/uspace/lib/libc/generic/console.c
1,4 → 1,6
/*
* Copyright (c) 2006 Josef Cejka
* Copyright (c) 2006 Jakub Vana
* Copyright (c) 2008 Jiri Svoboda
* All rights reserved.
*
35,29 → 37,70
#include <async.h>
#include <io/stream.h>
#include <ipc/console.h>
#include <ipc/services.h>
#include <console.h>
 
static int console_phone = -1;
 
void console_open(void)
{
if (console_phone < 0) {
int phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, 0);
if (phone >= 0)
console_phone = phone;
}
}
 
void console_close(void)
{
if (console_phone >= 0) {
if (ipc_hangup(console_phone) == 0) {
console_phone = -1;
}
}
}
 
int console_phone_get(void)
{
if (console_phone < 0)
console_open();
return console_phone;
}
 
void console_wait(void)
{
while (console_phone < 0)
console_open();
}
 
void console_clear(void)
{
int cons_phone = get_console_phone();
int cons_phone = console_phone_get();
async_msg_0(cons_phone, CONSOLE_CLEAR);
}
 
void console_goto(int row, int col)
{
int cons_phone = get_console_phone();
int cons_phone = console_phone_get();
async_msg_2(cons_phone, CONSOLE_GOTO, row, col);
}
 
void console_putchar(int c)
{
int cons_phone = console_phone_get();
async_msg_1(cons_phone, CONSOLE_PUTCHAR, c);
}
 
void console_flush(void)
{
int cons_phone = get_console_phone();
int cons_phone = console_phone_get();
async_msg_0(cons_phone, CONSOLE_FLUSH);
}
 
int console_get_size(int *rows, int *cols)
{
int cons_phone = get_console_phone();
int cons_phone = console_phone_get();
ipcarg_t r, c;
int rc;
 
71,25 → 114,25
 
void console_set_style(int style)
{
int cons_phone = get_console_phone();
int cons_phone = console_phone_get();
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_console_phone();
int cons_phone = console_phone_get();
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_console_phone();
int cons_phone = console_phone_get();
async_msg_2(cons_phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color);
}
 
void console_cursor_visibility(int show)
{
int cons_phone = get_console_phone();
int cons_phone = console_phone_get();
async_msg_1(cons_phone, CONSOLE_CURSOR_VISIBILITY, show != 0);
}
 
/trunk/uspace/lib/libc/generic/io/stream.c
43,13 → 43,12
#include <ipc/fb.h>
#include <ipc/services.h>
#include <ipc/console.h>
#include <console.h>
#include <kbd/kbd.h>
#include <unistd.h>
#include <async.h>
#include <sys/types.h>
 
static int console_phone = -1;
 
ssize_t write_stderr(const void *buf, size_t count)
{
return count;
57,8 → 56,9
 
ssize_t read_stdin(void *buf, size_t count)
{
open_console();
if (console_phone >= 0) {
int cons_phone = console_phone_get();
 
if (cons_phone >= 0) {
kbd_event_t ev;
int rc;
size_t i = 0;
79,55 → 79,23
 
ssize_t write_stdout(const void *buf, size_t count)
{
open_console();
if (console_phone >= 0) {
int cons_phone = console_phone_get();
 
if (cons_phone >= 0) {
int i;
 
for (i = 0; i < count; i++)
async_msg_1(console_phone, CONSOLE_PUTCHAR,
((const char *) buf)[i]);
console_putchar(((const char *) buf)[i]);
 
return count;
} else
return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, count);
}
 
void open_console(void)
{
if (console_phone < 0) {
int phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, 0);
if (phone >= 0)
console_phone = phone;
}
}
 
void close_console(void)
{
if (console_phone >= 0) {
if (ipc_hangup(console_phone) == 0) {
console_phone = -1;
}
}
}
 
void klog_update(void)
{
(void) __SYSCALL3(SYS_KLOG, 1, NULL, 0);
}
 
int get_console_phone(void)
{
if (console_phone < 0)
console_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_CONSOLE, 0, 0);
return console_phone;
}
 
void console_wait(void)
{
while (console_phone < 0)
get_console_phone();
}
 
/** @}
*/
/trunk/uspace/srv/loader/main.c
53,6 → 53,7
#include <ipc/services.h>
#include <ipc/loader.h>
#include <loader/pcb.h>
#include <console.h>
#include <errno.h>
#include <async.h>
#include <as.h>
282,13 → 283,13
/* Dynamically linked program */
DPRINTF("Run ELF interpreter.\n");
DPRINTF("Entry point: 0x%lx\n", interp_info.entry);
close_console();
console_close();
ipc_answer_0(rid, EOK);
elf_run(&interp_info, &pcb);
} else {
/* Statically linked program */
close_console();
console_close();
ipc_answer_0(rid, EOK);
elf_run(&prog_info, &pcb);
}