Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1517 → Rev 1518

/uspace/trunk/kbd/generic/kbd.c
100,7 → 100,7
if (!keybuffer_pop(&keybuffer, (char *)&arg1)) {
break;
}
ipc_call_async(phoneid, KBD_PUSHCHAR, arg1, NULL, NULL);
send_call(phoneid, KBD_PUSHCHAR, arg1);
}
 
}
/uspace/trunk/console/console.c
41,7 → 41,6
#include <screenbuffer.h>
#include <sys/mman.h>
 
#define CONSOLE_COUNT 12
#define MAX_KEYREQUESTS_BUFFERED 32
 
#define NAME "CONSOLE"
118,7 → 117,7
scr->position_x--;
 
if (console == active_console) {
ipc_call_async_3(fb_info.phone, FB_PUTCHAR, ' ', scr->position_y, scr->position_x, NULL, NULL);
nsend_call_3(fb_info.phone, FB_PUTCHAR, ' ', scr->position_y, scr->position_x);
}
screenbuffer_putchar(scr, ' ');
126,7 → 125,7
break;
default:
if (console == active_console) {
ipc_call_async_3(fb_info.phone, FB_PUTCHAR, key, scr->position_y, scr->position_x, NULL, NULL);
nsend_call_3(fb_info.phone, FB_PUTCHAR, key, scr->position_y, scr->position_x);
}
screenbuffer_putchar(scr, key);
138,13 → 137,14
if (scr->position_y >= scr->size_y) {
scr->position_y = scr->size_y - 1;
screenbuffer_clear_line(scr, scr->top_line++);
ipc_call_async(fb_info.phone, FB_SCROLL, 1, NULL, NULL);
if (console == active_console)
nsend_call(fb_info.phone, FB_SCROLL, 1);
}
scr->position_x = scr->position_x % scr->size_x;
if (console == active_console)
ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, scr->position_y, scr->position_x, NULL, NULL);
send_call_2(fb_info.phone, FB_CURSOR_GOTO, scr->position_y, scr->position_x);
}
 
192,7 → 192,7
conn = &connections[active_console];
 
ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 0, NULL, NULL);
nsend_call(fb_info.phone, FB_CURSOR_VISIBILITY, 0);
if (interbuffer) {
for (i = 0; i < conn->screenbuffer.size_x; i++)
201,8 → 201,7
sync_send_2(fb_info.phone, FB_DRAW_TEXT_DATA, 0, 0, NULL, NULL);
} else {
 
ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
nsend_call(fb_info.phone, FB_CLEAR, 0);
for (i = 0; i < conn->screenbuffer.size_x; i++)
209,14 → 208,14
for (j = 0; j < conn->screenbuffer.size_y; j++) {
d = get_field_at(&(conn->screenbuffer),i, j)->character;
if (d && d != ' ')
ipc_call_async_3(fb_info.phone, FB_PUTCHAR, d, j, i, NULL, NULL);
nsend_call_3(fb_info.phone, FB_PUTCHAR, d, j, i);
}
 
}
ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x, NULL, NULL);
ipc_call_async_2(fb_info.phone, FB_SET_STYLE, conn->screenbuffer.style.fg_color, \
conn->screenbuffer.style.bg_color, NULL, NULL);
ipc_call_async(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL, NULL);
nsend_call_2(fb_info.phone, FB_CURSOR_GOTO, conn->screenbuffer.position_y, conn->screenbuffer.position_x);
nsend_call_2(fb_info.phone, FB_SET_STYLE, conn->screenbuffer.style.fg_color, \
conn->screenbuffer.style.bg_color);
send_call(fb_info.phone, FB_CURSOR_VISIBILITY, 1);
 
break;
}
240,7 → 239,7
}
 
/** Default thread for new connections */
void client_connection(ipc_callid_t iid, ipc_call_t *icall)
static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
{
ipc_callid_t callid;
ipc_call_t call;
272,7 → 271,7
case CONSOLE_CLEAR:
/* Send message to fb */
if (consnum == active_console) {
ipc_call_async_2(fb_info.phone, FB_CLEAR, 0, 0, NULL, NULL);
send_call(fb_info.phone, FB_CLEAR, 0);
}
screenbuffer_clear(&(connections[consnum].screenbuffer));
330,8 → 329,8
}
ipc_call_sync_2(fb_info.phone, FB_GET_CSIZE, 0, 0, &(fb_info.rows), &(fb_info.cols));
ipc_call_async_2(fb_info.phone, FB_SET_STYLE, DEFAULT_FOREGROUND_COLOR, DEFAULT_BACKGROUND_COLOR, NULL, NULL);
ipc_call_sync(fb_info.phone, FB_CURSOR_VISIBILITY, 1, NULL);
nsend_call_2(fb_info.phone, FB_SET_STYLE, DEFAULT_FOREGROUND_COLOR, DEFAULT_BACKGROUND_COLOR);
nsend_call(fb_info.phone, FB_CURSOR_VISIBILITY, 1);
/* Init virtual consoles */
for (i = 0; i < CONSOLE_COUNT; i++) {
361,8 → 360,9
async_new_connection(phonehash, 0, NULL, keyboard_events);
ipc_call_async_2(fb_info.phone, FB_CURSOR_GOTO, 0, 0, NULL, NULL);
nsend_call_2(fb_info.phone, FB_CURSOR_GOTO, 0, 0);
 
/* Register at NS */
if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, &phonehash) != 0) {
return -1;
};
/uspace/trunk/console/console.h
29,6 → 29,8
#ifndef __CONSOLE_H__
#define __CONSOLE_H__
 
#define CONSOLE_COUNT 12
 
#define CONSOLE_GETCHAR 1026
#define CONSOLE_PUTCHAR 1027
#define CONSOLE_CLEAR 1028
/uspace/trunk/console/gcons.c
0,0 → 1,131
/*
* 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/fb.h>
#include <ipc/ipc.h>
 
#include "console.h"
 
#define CONSOLE_TOP 50
#define CONSOLE_MARGIN 10
 
#define STATUS_SPACE 20
#define STATUS_WIDTH 40
#define STATUS_HEIGHT 30
 
static int use_gcons = 0;
static ipcarg_t xres,yres;
 
static int console_vp;
static int cstatus_vp[CONSOLE_COUNT];
 
static int fbphone;
 
static void vp_switch(int vp)
{
ipc_call_sync_2(fbphone,FB_VIEWPORT_SWITCH, vp, 0, NULL, NULL);
}
 
static int vp_create(unsigned int x, unsigned int y,
unsigned int width, unsgined int height)
{
return ipc_call_sync_2(fbphone, (x << 16) | y, (width << 16) | height,
NULL, NULL);
}
 
static void fb_clear(void)
{
ipc_call_sync_2(fbphone, FB_CLEAR, 0, 0, NULL, NULL);
}
 
static void fb_set_style(int fgcolor, int bgcolor)
{
ipc_call_sync_2(fbphone, );
}
 
void gcons_change_console(int consnum)
{
if (!use_gcons)
return;
 
vp_switch(console_vp);
}
 
void gcons_notify_char(int consnum)
{
if (!use_gcons)
return;
 
vp_switch(console_vp);
}
 
void gcons_redraw_console(int phone)
{
if (!use_gcons)
return;
vp_switch(0);
/* Set style...*/
fb_clear();
vp_switch(console_vp);
}
 
/** Initialize nice graphical console environment */
void gcons_init(int phone)
{
int rc;
int i;
 
fbphone = phone;
 
rc = ipc_call_sync_2(phone, FB_GET_RESOLUTION, 0, 0, &xres, &yres);
if (rc)
return;
if (xres < 800 || yres < 600)
return;
 
/* create console viewport */
console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, xres-2*CONSOLE_MARGIN,
yres-(CONSOLE_TOP+CONSOLE_MARGIN));
if (console_vp < 0)
return;
/* Create status buttons */
for (i=0; i < CONSOLE_COUNT; i++) {
cstatus_vp[i] = vp_create(phone, CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE),
CONSOLE_MARGIN, STATUS_WIDTH, STATUS_HEIGHT);
if (cstatus_vp[i] < 0)
return;
}
use_gcons = 1;
gcons_draw_console();
}
/uspace/trunk/init/init.c
159,59 → 159,13
printf("Retval: %d...%s...%zX, %zX\n", retval, private,
IPC_GET_ARG1(*data), IPC_GET_ARG2(*data));
}
static void test_async_ipc(void)
{
ipc_call_t data;
int i;
 
printf("Sending ping\n");
ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
"Pong1", got_answer);
ipc_call_async_2(PHONE_NS, NS_PING, 2, 0xbeefbee4,
"Pong2", got_answer);
ipc_call_async_2(PHONE_NS, NS_PING, 3, 0xbeefbee4,
"Pong3", got_answer);
ipc_call_async_2(PHONE_NS, NS_PING, 4, 0xbeefbee4,
"Pong4", got_answer);
ipc_call_async_2(PHONE_NS, NS_PING, 5, 0xbeefbee4,
"Pong5", got_answer);
ipc_call_async_2(PHONE_NS, NS_PING, 6, 0xbeefbee4,
"Pong6", got_answer);
printf("Waiting forever...\n");
for (i=0; i<100;i++)
printf(".");
printf("\n");
ipc_wait_for_call(&data);
printf("Received call???\n");
}
 
 
static void got_answer_2(void *private, int retval, ipc_call_t *data)
{
printf("Pong\n");
}
static void test_advanced_ipc(void)
{
int res;
ipcarg_t phonead;
ipc_callid_t callid;
ipc_call_t data;
int i;
 
printf("Asking 0 to connect to me...\n");
res = ipc_connect_to_me(0, 1, 2, &phonead);
printf("Result: %d - phonead: %llu\n", res, phonead);
for (i=0; i < 100; i++) {
printf("----------------\n");
ipc_call_async(PHONE_NS, NS_PING_SVC, 0, "prov",
got_answer_2);
callid = ipc_wait_for_call(&data);
printf("Received ping\n");
ipc_answer_fast(callid, 0, 0, 0);
}
// callid = ipc_wait_for_call(&data, NULL);
}
 
static void test_connection_ipc(void)
{
int res;
227,59 → 181,6
}
 
static void test_hangup(void)
{
int phoneid;
ipc_call_t data;
ipc_callid_t callid;
int i;
 
printf("Starting connect...\n");
phoneid = ipc_connect_me_to(PHONE_NS, 10, 20);
printf("Phoneid: %d, pinging\n", phoneid);
ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
"Pong1", got_answer);
printf("Hangin up\n");
ipc_hangup(phoneid);
printf("Connecting\n");
phoneid = ipc_connect_me_to(PHONE_NS, 10, 20);
printf("Newphid: %d\n", phoneid);
for (i=0; i < 1000; i++) {
if ((callid=ipc_trywait_for_call(&data)))
printf("callid: %d\n");
}
printf("New new phoneid: %d\n", ipc_connect_me_to(PHONE_NS, 10, 20));
}
 
static void test_slam(void)
{
int i;
ipc_call_t data;
ipc_callid_t callid;
 
printf("ping");
ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
"Pong1", got_answer);
printf("slam");
ipc_call_async_2(PHONE_NS, NS_HANGUP, 1, 0xbeefbee2,
"Hang", got_answer);
printf("ping2\n");
ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
"Ping2", got_answer);
for (i=0; i < 1000; i++) {
if ((callid=ipc_trywait_for_call(&data)))
printf("callid: %d\n");
}
ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
"Pong1", got_answer);
printf("Closing file\n");
ipc_hangup(PHONE_NS);
ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2,
"Pong1", got_answer);
ipc_wait_for_call(&data);
}
 
static int ptest(void *arg)
{
stage = 1;
/uspace/trunk/libc/include/ipc/ipc.h
66,13 → 66,14
ipcarg_t arg2);
extern ipcarg_t ipc_answer(ipc_callid_t callid, ipc_call_t *call);
 
#define ipc_call_async(phoneid,method,arg1,private, callback) (ipc_call_async_2(phoneid, method, arg1, 0, private, callback))
#define ipc_call_async(phoneid,method,arg1,private, callback,can_preempt) (ipc_call_async_2(phoneid, method, arg1, 0, private, callback, can_preempt))
extern void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, void *private,
ipc_async_callback_t callback);
ipc_async_callback_t callback, int can_preempt);
extern void ipc_call_async_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, ipcarg_t arg3, void *private,
ipc_async_callback_t callback);
ipc_async_callback_t callback, int can_preempt);
 
extern int ipc_connect_to_me(int phoneid, int arg1, int arg2, ipcarg_t *phone);
extern int ipc_connect_me_to(int phoneid, int arg1, int arg2);
extern int ipc_hangup(int phoneid);
80,4 → 81,16
extern int ipc_unregister_irq(int irq);
extern int ipc_forward_fast(ipc_callid_t callid, int phoneid, int method, ipcarg_t arg1);
 
 
/* Primitve functions for IPC communication */
void send_call_3(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2,
ipcarg_t arg3);
void send_call_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2);
#define send_call(ph,m,a1) send_call_2(ph,m,a1,0)
/* These functions never preempt */
void nsend_call_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, ipcarg_t arg3);
void nsend_call_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2);
#define nsend_call(ph,m,a1) nsend_call_2(ph,m,a1,0)
 
#endif
/uspace/trunk/libc/generic/ipc.c
133,7 → 133,8
}
 
/** Epilogue of ipc_async_send functions */
static inline void ipc_finish_async(ipc_callid_t callid, int phoneid, async_call_t *call)
static inline void ipc_finish_async(ipc_callid_t callid, int phoneid,
async_call_t *call, int can_preempt)
{
if (callid == IPC_CALLRET_FATAL) {
futex_up(&ipc_futex);
148,13 → 149,18
futex_up(&ipc_futex);
 
call->u.msg.phoneid = phoneid;
 
call->ptid = psthread_get_id();
futex_down(&async_futex);
list_append(&call->list, &queued_calls);
 
psthread_schedule_next_adv(PS_TO_MANAGER);
/* Async futex unlocked by previous call */
if (can_preempt) {
call->ptid = psthread_get_id();
psthread_schedule_next_adv(PS_TO_MANAGER);
/* Async futex unlocked by previous call */
} else {
call->ptid = 0;
futex_up(&async_futex);
}
return;
}
call->u.callid = callid;
171,7 → 177,7
*/
void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, void *private,
ipc_async_callback_t callback)
ipc_async_callback_t callback, int can_preempt)
{
async_call_t *call;
ipc_callid_t callid;
190,7 → 196,7
IPC_SET_ARG1(call->u.msg.data, arg1);
IPC_SET_ARG2(call->u.msg.data, arg2);
}
ipc_finish_async(callid, phoneid, call);
ipc_finish_async(callid, phoneid, call, can_preempt);
}
 
/** Send asynchronous message
200,7 → 206,7
*/
void ipc_call_async_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, ipcarg_t arg3, void *private,
ipc_async_callback_t callback)
ipc_async_callback_t callback, int can_preempt)
{
async_call_t *call;
ipc_callid_t callid;
218,7 → 224,7
futex_down(&ipc_futex);
callid = _ipc_call_async(phoneid, &call->u.msg.data);
 
ipc_finish_async(callid, phoneid, call);
ipc_finish_async(callid, phoneid, call, can_preempt);
}
 
 
276,7 → 282,8
list_remove(&call->list);
 
futex_up(&async_futex);
psthread_add_ready(call->ptid);
if (call->ptid)
psthread_add_ready(call->ptid);
if (callid == IPC_CALLRET_FATAL) {
if (call->callback)
430,43 → 437,26
return __SYSCALL4(SYS_IPC_FORWARD_FAST, callid, phoneid, method, arg1);
}
 
 
/** Open shared memory connection over specified phoneid
*
*
* Allocate as_area, notify the other side about our intention
* to open the connection
*
* @return Connection id identifying this connection
*/
//int ipc_dgr_open(int pohoneid, size_t bufsize)
//{
/* Find new file descriptor in local descriptor table */
/* Create AS_area, initialize structures */
/* Send AS to other side, handle error states */
 
//}
/*
void ipc_dgr_close(int cid)
/* Primitive functions for simple communication */
void send_call_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, ipcarg_t arg3)
{
ipc_call_async_3(phoneid, method, arg1, arg2, arg3, NULL, NULL, 1);
}
 
void * ipc_dgr_alloc(int cid, size_t size)
void send_call_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2)
{
ipc_call_async_2(phoneid, method, arg1, arg2, NULL, NULL, 1);
}
 
void ipc_dgr_free(int cid, void *area)
void nsend_call_3(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, ipcarg_t arg3)
{
 
ipc_call_async_3(phoneid, method, arg1, arg2, arg3, NULL, NULL, 0);
}
 
int ipc_dgr_send(int cid, void *area)
void nsend_call_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2)
{
ipc_call_async_2(phoneid, method, arg1, arg2, NULL, NULL, 0);
}
 
 
int ipc_dgr_send_data(int cid, void *data, size_t size)
{
}
 
*/
/uspace/trunk/libc/generic/async.c
606,7 → 606,7
 
msg->wdata.active = 1; /* We may sleep in next method, but it
* will use it's own mechanism */
ipc_call_async_2(phoneid,method,arg1,arg2,msg,reply_received);
ipc_call_async_2(phoneid,method,arg1,arg2,msg,reply_received,1);
 
return (aid_t) msg;
}
/uspace/trunk/libc/generic/io/stream.c
77,7 → 77,7
ipcarg_t r0,r1;
 
for (i = 0; i < count; i++)
ipc_call_async_2(console_phone, CONSOLE_PUTCHAR, ((const char *)buf)[i], 0, NULL, NULL);
send_call(console_phone, CONSOLE_PUTCHAR, ((const char *)buf)[i]);
return count;
}
/uspace/trunk/libc/generic/mmap.c
40,8 → 40,8
// if (! ((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
// return NULL;
// if (! (flags & MAP_ANONYMOUS))
// return NULL;
if (! (flags & MAP_ANONYMOUS))
return NULL;
 
return as_area_create(start, length, prot);
}