Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 965 → Rev 966

/uspace/trunk/libipc/include/ipc.h
35,9 → 35,24
typedef sysarg_t ipc_data_t[IPC_CALL_LEN];
typedef sysarg_t ipc_callid_t;
 
typedef void (* ipc_async_callback_t)(ipc_data_t *data);
 
extern int ipc_call_sync(int phoneid, int arg1, int arg2, ipc_data_t *resdata);
#define ipc_call_sync_2(phoneid, method, arg1, arg2, res1, res2) ipc_call_sync_3((phoneid), (method), (arg1), (arg2), 0, (res1), (res2), 0)
extern int ipc_call_sync_3(int phoneid, sysarg_t method, sysarg_t arg1,
sysarg_t arg2, sysarg_t arg3,
sysarg_t *result1, sysarg_t *result2,
sysarg_t *result3);
 
 
extern int ipc_call_sync(int phoneid, sysarg_t method, sysarg_t arg1,
sysarg_t *result);
extern int ipc_wait_for_call(ipc_data_t *data, int flags);
extern void ipc_answer(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
sysarg_t arg2);
 
#define ipc_call_async(phoneid,method,arg1,callback) (ipc_call_async_2(phoneid, method, arg1, 0, callback))
void ipc_call_async_2(int phoneid, sysarg_t method, sysarg_t arg1,
sysarg_t arg2,
ipc_async_callback_t callback);
 
#endif
/uspace/trunk/libipc/include/ns.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 __LIBIPC__NS_H__
#define __LIBIPC__NS_H__
 
#include <kernel/ipc/ns.h>
 
#endif
/uspace/trunk/libipc/generic/ipc.c
29,23 → 29,86
#include <ipc.h>
#include <libc.h>
 
int ipc_call_sync(int phoneid, int arg1, int arg2, ipc_data_t *resdata)
int ipc_call_sync(int phoneid, sysarg_t method, sysarg_t arg1,
sysarg_t *result)
{
return __SYSCALL4(SYS_IPC_CALL_SYNC, phoneid, arg1, arg2,
(sysarg_t)resdata);
ipc_data_t resdata;
int callres;
callres = __SYSCALL4(SYS_IPC_CALL_SYNC, phoneid, method, arg1,
(sysarg_t)&resdata);
if (callres)
return callres;
if (result)
*result = IPC_GET_ARG1(resdata);
return IPC_GET_RETVAL(resdata);
}
 
/*
int ipc_call_async()
int ipc_call_sync_3(int phoneid, sysarg_t method, sysarg_t arg1,
sysarg_t arg2, sysarg_t arg3,
sysarg_t *result1, sysarg_t *result2, sysarg_t *result3)
{
ipc_data_t data;
int callres;
 
IPC_SET_METHOD(data, method);
IPC_SET_ARG1(data, arg1);
IPC_SET_ARG2(data, arg2);
IPC_SET_ARG3(data, arg3);
 
callres = __SYSCALL2(SYS_IPC_CALL_SYNC_MEDIUM, phoneid, (sysarg_t)&data);
if (callres)
return callres;
 
if (result1)
*result1 = IPC_GET_ARG1(data);
if (result2)
*result2 = IPC_GET_ARG2(data);
if (result3)
*result3 = IPC_GET_ARG3(data);
return IPC_GET_RETVAL(data);
}
 
/** Send asynchronous message
*
* - if fatal error, call callback handler with proper error code
* - if message cannot be temporarily sent, add to queue
*/
void ipc_call_async_2(int phoneid, sysarg_t method, sysarg_t arg1,
sysarg_t arg2,
ipc_async_callback_t callback)
{
ipc_callid_t callid;
ipc_data_t data; /* Data storage for saving calls */
 
callid = __SYSCALL4(SYS_IPC_CALL_ASYNC, phoneid, method, arg1, arg2);
if (callid == IPC_CALLRET_FATAL) {
/* Call asynchronous handler with error code */
IPC_SET_RETVAL(data, IPC_CALLRET_FATAL);
callback(&data);
return;
}
if (callid == IPC_CALLRET_TEMPORARY) {
/* Add asynchronous call to queue of non-dispatched async calls */
IPC_SET_METHOD(data, method);
IPC_SET_ARG1(data, arg1);
IPC_SET_ARG2(data, arg2);
return;
}
/* Add callid to list of dispatched calls */
}
 
int ipc_answer()
 
/** Send answer to a received call */
void ipc_answer(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1,
sysarg_t arg2)
{
__SYSCALL4(SYS_IPC_ANSWER, callid, retval, arg1, arg2);
}
*/
 
 
/** Call syscall function sys_ipc_wait_for_call */
static inline ipc_callid_t _ipc_wait_for_call(ipc_data_t *data, int flags)
{
60,7 → 123,12
{
ipc_callid_t callid;
 
callid = _ipc_wait_for_call(data, flags);
/* TODO: Handle async replies etc.. */
do {
/* Try to dispatch non-dispatched async calls */
callid = _ipc_wait_for_call(data, flags);
if (callid & IPC_CALLID_ANSWERED) {
/* TODO: Call async answer handler */
}
} while (callid & IPC_CALLID_ANSWERED);
return callid;
}
/uspace/trunk/libipc/Makefile
54,7 → 54,7
-include Makefile.depend
 
clean:
-rm -f libipcc.a Makefile.depend
-rm -f libipc.a Makefile.depend
find generic/ -name '*.o' -follow -exec rm \{\} \;
 
depend:
/uspace/trunk/init/init.c
28,14 → 28,13
 
#include "version.h"
#include <ipc.h>
#include <ns.h>
 
int main(int argc, char *argv[])
{
ipc_data_t ipcdata;
 
version_print();
 
ipc_call_sync(0, 1, 2, &ipcdata);
ipc_call_sync_2(PHONE_NS, NS_PING, 2, 0, 0, 0);
return 0;
}