Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1489 → Rev 1490

/uspace/trunk/console/console.c
115,10 → 115,11
/* 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 >= '1') && (c < '1' + CONSOLE_COUNT)) {
/*FIXME: draw another console content from buffer */
 
active_console = c - KBD_KEY_F1;
active_console = c - '1';
conn = &connections[active_console];
 
ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL);
231,6 → 232,8
int kbd_phone, fb_phone;
ipcarg_t retval, arg1 = 0xdead, arg2 = 0xbeef;
int i;
 
async_set_client_connection(client_connection);
/* Connect to keyboard driver */
 
/uspace/trunk/fb/main.c
0,0 → 1,55
/*
* Copyright (C) 2006 Ondrej Palkovsky
* 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 <ipc/ipc.h>
#include <ipc/services.h>
#include <sysinfo.h>
#include <async.h>
 
#include "fb.h"
#include "sysio.h"
 
int main(int argc, char *argv[])
{
ipcarg_t phonead;
int initialized = 0;
 
if (sysinfo_value("fb.kind") == 1) {
if (fb_init() == 0)
initialized = 1;
}
if (!initialized)
sysio_init();
 
if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead) != 0)
return -1;
async_manager();
/* Never reached */
return 0;
}
/uspace/trunk/fb/sysio.c
0,0 → 1,83
/*
* Copyright (C) 2006 Ondrej Palkovsky
* 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 <async.h>
#include <ipc/fb.h>
#include <ipc/ipc.h>
#include <libc.h>
#include <errno.h>
 
#include "sysio.h"
 
/* Allow only 1 connection */
static int client_connected = 0;
 
static void sysput(char c)
{
__SYSCALL3(SYS_IO, 1, (sysarg_t)&c, (sysarg_t) 1);
}
 
static void sysio_client_connection(ipc_callid_t iid, ipc_call_t *icall)
{
int retval;
ipc_callid_t callid;
ipc_call_t call;
char c;
 
if (client_connected) {
ipc_answer_fast(iid, ELIMIT, 0,0);
return;
}
client_connected = 1;
ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
while (1) {
callid = async_get_call(&call);
switch (IPC_GET_METHOD(call)) {
case IPC_M_PHONE_HUNGUP:
client_connected = 0;
ipc_answer_fast(callid,0,0,0);
return; /* Exit thread */
case FB_PUTCHAR:
c = IPC_GET_ARG1(call);
sysput(c);
retval = 0;
break;
case FB_GET_CSIZE:
ipc_answer_fast(callid, 0, 25, 80);
continue;
default:
retval = ENOENT;
}
ipc_answer_fast(callid,retval,0,0);
}
}
 
void sysio_init(void)
{
async_set_client_connection(sysio_client_connection);
}
/uspace/trunk/fb/fb.c
27,12 → 27,10
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ddi.h>
#include <task.h>
#include <sysinfo.h>
#include <align.h>
#include <as.h>
389,36 → 387,6
clear_port(0);
}
 
static int init_fb(void)
{
__address fb_ph_addr;
unsigned int fb_width;
unsigned int fb_height;
unsigned int fb_bpp;
unsigned int fb_scanline;
__address fb_addr;
int a=0;
int i,j,k;
int w;
char text[]="HelenOS Framebuffer driver\non Virtual Framebuffer\nVFB ";
 
fb_ph_addr=sysinfo_value("fb.address.physical");
fb_width=sysinfo_value("fb.width");
fb_height=sysinfo_value("fb.height");
fb_bpp=sysinfo_value("fb.bpp");
fb_scanline=sysinfo_value("fb.scanline");
 
fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE);
map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr,
(fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH,
AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline);
 
return 0;
}
 
static void draw_char(int vp, char c, unsigned int row, unsigned int col)
{
viewport_t *vport = &viewports[vp];
442,7 → 410,7
invert_char(vp, vport->cur_row, vport->cur_col);
}
 
void client_connection(ipc_callid_t iid, ipc_call_t *icall)
static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall)
{
ipc_callid_t callid;
ipc_call_t call;
577,22 → 545,31
}
}
 
int main(int argc, char *argv[])
int fb_init(void)
{
char connected = 0;
int res;
ipcarg_t phonead;
__address fb_ph_addr;
unsigned int fb_width;
unsigned int fb_height;
unsigned int fb_bpp;
unsigned int fb_scanline;
__address fb_addr;
 
if(!sysinfo_value("fb"))
return -1;
async_set_client_connection(fb_client_connection);
 
if ((res = ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, &phonead)) != 0)
return -1;
fb_ph_addr=sysinfo_value("fb.address.physical");
fb_width=sysinfo_value("fb.width");
fb_height=sysinfo_value("fb.height");
fb_bpp=sysinfo_value("fb.bpp");
fb_scanline=sysinfo_value("fb.scanline");
 
fb_addr=ALIGN_UP(((__address)set_maxheapsize(USER_ADDRESS_SPACE_SIZE_ARCH>>1)),PAGE_SIZE);
if (init_fb() != 0)
return -1;
map_physmem(task_get_id(),(void *)((__address)fb_ph_addr),(void *)fb_addr,
(fb_scanline*fb_height+PAGE_SIZE-1)>>PAGE_WIDTH,
AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline);
 
async_manager();
/* Never reached */
return 0;
}
 
/uspace/trunk/fb/sysio.h
0,0 → 1,34
/*
* Copyright (C) 2006 Ondrej Palkovsky
* 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.
*/
 
#ifndef _SYSIO_H_
#define _SYSIO_H_
 
void sysio_init(void);
 
#endif
/uspace/trunk/fb/Makefile
46,7 → 46,9
OUTPUT = fb
SOURCES = \
fb.c \
font-8x16.c
font-8x16.c \
main.c \
sysio.c
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
 
/uspace/trunk/fb/fb.h
29,7 → 29,6
#ifndef _FB_H_
#define _FB_H_
 
#include <types.h>
#include <arch/types.h>
int fb_init(void);
 
#endif
/uspace/trunk/libc/include/async.h
35,6 → 35,7
#include <atomic.h>
 
typedef ipc_callid_t aid_t;
typedef void (*async_client_conn_t)(ipc_callid_t callid, ipc_call_t *call);
 
int async_manager(void);
ipc_callid_t async_get_call(ipc_call_t *data);
72,10 → 73,10
void async_usleep(suseconds_t timeout);
void async_create_manager(void);
void async_destroy_manager(void);
void async_set_client_connection(async_client_conn_t conn);
int _async_init(void);
 
/* Should be defined by application */
void client_connection(ipc_callid_t callid, ipc_call_t *call) __attribute__((weak));
void interrupt_received(ipc_call_t *call) __attribute__((weak));
 
 
/uspace/trunk/libc/generic/async.c
128,8 → 128,12
void (*cthread)(ipc_callid_t,ipc_call_t *);
} connection_t;
 
 
__thread connection_t *PS_connection;
 
static void default_client_connection(ipc_callid_t callid, ipc_call_t *call);
static async_client_conn_t client_connection = default_client_connection;
 
/** Add microseconds to give timeval */
static void tv_add(struct timeval *tv, suseconds_t usecs)
{
272,7 → 276,7
* This function is defined as a weak symbol - to be redefined in
* user code.
*/
void client_connection(ipc_callid_t callid, ipc_call_t *call)
static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
{
ipc_answer_fast(callid, ENOENT, 0, 0);
}
670,3 → 674,12
/* futex is up automatically after psthread_schedule_next...*/
free(msg);
}
 
/** Set function that is called, IPC_M_CONNECT_ME_TO is received
*
* @param conn Function that will form new psthread.
*/
void async_set_client_connection(async_client_conn_t conn)
{
client_connection = conn;
}
/uspace/trunk/libc/generic/io/stream.c
52,17 → 52,9
 
stream_t streams[FDS] = {{0, 0, 0}};
 
/*
ssize_t write_stdout(void *param, const void * buf, size_t count);
ssize_t write_stdout(void *param, const void * buf, size_t count)
{
return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count);
}*/
 
static ssize_t write_stderr(void *param, const void *buf, size_t count)
{
return count;
//return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count);
}
 
static ssize_t read_stdin(void *param, void *buf, size_t count)
77,7 → 69,6
((char *)buf)[i++] = r0;
}
return i;
//return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count);
}
 
static ssize_t write_stdout(void *param, const void *buf, size_t count)
89,7 → 80,6
ipc_call_sync_2(console_phone, CONSOLE_PUTCHAR, 0, ((const char *)buf)[i], &r0, &r1);
return count;
//return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count);
}