//uspace/trunk/ns/ns.c |
---|
31,6 → 31,7 |
{ |
ipc_call_t call; |
ipc_callid_t callid; |
char *as; |
ipcarg_t retval, arg1, arg2; |
41,6 → 42,17 |
callid = ipc_wait_for_call(&call, 0); |
printf("NS:Call phone=%lX..", call.phoneid); |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_AS_SEND: |
as = (char *)IPC_GET_ARG2(call); |
printf("Received as: %P, size:%d\n", as, IPC_GET_ARG3(call)); |
retval = ipc_answer(callid, 0,(sysarg_t)(1024*1024), 0); |
if (!retval) { |
printf("Reading shared memory..."); |
printf("Text: %s", as); |
} else |
printf("Failed answer: %d\n", retval); |
continue; |
break; |
case IPC_M_INTERRUPT: |
printf("GOT INTERRUPT: %c\n", IPC_GET_ARG2(call)); |
break; |
//uspace/trunk/libipc/include/ipc.h |
---|
54,7 → 54,7 |
extern int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1, |
ipcarg_t *result); |
extern ipc_callid_t ipc_wait_for_call(ipc_call_t *data, int flags); |
extern void ipc_answer(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1, |
extern ipcarg_t ipc_answer(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1, |
ipcarg_t arg2); |
#define ipc_call_async(phoneid,method,arg1,private, callback) (ipc_call_async_2(phoneid, method, arg1, 0, private, callback)) |
//uspace/trunk/libipc/generic/ipc.c |
---|
148,10 → 148,10 |
/** Send answer to a received call */ |
void ipc_answer(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1, |
ipcarg_t ipc_answer(ipc_callid_t callid, ipcarg_t retval, ipcarg_t arg1, |
ipcarg_t arg2) |
{ |
__SYSCALL4(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2); |
return __SYSCALL4(SYS_IPC_ANSWER_FAST, callid, retval, arg1, arg2); |
} |
/** Try to dispatch queed calls from async queue */ |
271,3 → 271,12 |
{ |
return __SYSCALL1(SYS_IPC_UNREGISTER_IRQ, irq); |
} |
/* |
int ipc_open_dgrconn(int pohoneid, size_t max_dgram) |
{ |
} |
*/ |
//uspace/trunk/init/init.c |
---|
38,6 → 38,7 |
#include <futex.h> |
#include <as.h> |
#include <ddi.h> |
#include <string.h> |
int a; |
atomic_t ftx; |
291,6 → 292,29 |
return 0; |
} |
static int test_as_send() |
{ |
char *as; |
int retval; |
ipcarg_t result; |
as = as_area_create((void *)(1024*1024), 16384, AS_AREA_READ | AS_AREA_WRITE); |
if (!as) { |
printf("Error creating as.\n"); |
return 0; |
} |
memcpy(as, "Hello world.\n", 14); |
retval = ipc_call_sync_2(PHONE_NS, IPC_M_AS_SEND, 0, (sysarg_t) as, |
NULL, NULL); |
if (retval) { |
printf("AS_SEND failed.\n"); |
return 0; |
} |
printf("Done\n"); |
} |
int main(int argc, char *argv[]) |
{ |
pstid_t ptid; |
306,7 → 330,8 |
// test_connection_ipc(); |
// test_hangup(); |
// test_slam(); |
test_as_send(); |
/* |
printf("Userspace task, taskid=%llX\n", task_get_id()); |
futex_initialize(&ftx, 1); |
349,5 → 374,6 |
psthread_join(ptid); |
printf("Main thread exiting.\n"); |
*/ |
return 0; |
} |
//uspace/trunk/libc/include/as.h |
---|
26,16 → 26,15 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef __AS_H__ |
#define __AS_H__ |
#ifndef __libc_AS_H__ |
#define __libc_AS_H__ |
#include <types.h> |
#include <task.h> |
#include <kernel/mm/as.h> |
extern void *as_area_create(void *address, size_t size, int flags); |
extern int as_area_resize(void *address, size_t size, int flags); |
extern int as_area_destroy(void *address); |
extern int as_area_accept(task_id_t id, void *base, size_t size, int flags); |
extern int as_area_send(task_id_t id, void *base); |
#endif |
//uspace/trunk/libc/generic/as.c |
---|
69,46 → 69,6 |
return __SYSCALL1(SYS_AS_AREA_DESTROY, (sysarg_t ) address); |
} |
/** Prepare to accept address space area. |
* |
* @param id Task ID of the donor task. |
* @param base Destination address for the new address space area. |
* @param size Size of the new address space area. |
* @param flags Flags of the area TASK is willing to accept. |
* |
* @return 0 on success or a code from errno.h. |
*/ |
int as_area_accept(task_id_t id, void *base, size_t size, int flags) |
{ |
as_area_acptsnd_arg_t arg; |
arg.task_id = id; |
arg.base = base; |
arg.size = size; |
arg.flags = flags; |
return __SYSCALL1(SYS_AS_AREA_ACCEPT, (sysarg_t) &arg); |
} |
/** Send address space area to another task. |
* |
* @param id Task ID of the acceptor task. |
* @param base Source address of the existing address space area. |
* |
* @return 0 on success or a code from errno.h. |
*/ |
int as_area_send(task_id_t id, void *base) |
{ |
as_area_acptsnd_arg_t arg; |
arg.task_id = id; |
arg.base = base; |
arg.size = 0; |
arg.flags = 0; |
return __SYSCALL1(SYS_AS_AREA_SEND, (sysarg_t) &arg); |
} |
static size_t heapsize = 0; |
/* Start of heap linker symbol */ |
extern char _heap; |