Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1027 → Rev 1028

/uspace/trunk/ns/Makefile
0,0 → 1,74
#
# Copyright (C) 2005 Martin Decky
# 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.
#
 
## Setup toolchain
#
 
LIBC_PREFIX = ../libc
LIBIPC_PREFIX = ../libipc
include $(LIBC_PREFIX)/Makefile.toolchain
 
CFLAGS += -I../libipc/include
 
LIBS = $(LIBIPC_PREFIX)/libipc.a $(LIBC_PREFIX)/libc.a
 
## Sources
#
 
OUTPUT = ns
SOURCES = \
ns.c
 
OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
 
.PHONY: all clean depend disasm
 
all: $(OUTPUT) disasm
 
-include Makefile.depend
 
clean:
-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend
 
depend:
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend
 
$(OUTPUT): $(OBJECTS) $(LIBS)
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
 
disasm:
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm
 
%.o: %.S
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
 
%.o: %.s
$(AS) $(AFLAGS) $< -o $@
 
%.o: %.c
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
/uspace/trunk/libipc/include/ipc.h
52,9 → 52,9
ipcarg_t *result3);
 
 
extern int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1,
extern int ipc_call_sync(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t *result);
extern int ipc_wait_for_call(ipc_call_t *data, int flags);
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,
ipcarg_t arg2);
 
62,5 → 62,7
void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1,
ipcarg_t arg2, void *private,
ipc_async_callback_t callback);
int ipc_connect_to_me(int phoneid, int arg1, int arg2,
unsigned long long *taskid);
 
#endif
/uspace/trunk/libipc/include/ns.h
29,6 → 29,7
#ifndef __LIBIPC__NS_H__
#define __LIBIPC__NS_H__
 
#include <kernel/ipc/ns.h>
#define NS_PING 1024
#define NS_PING_SVC 1025
 
#endif
/uspace/trunk/libipc/generic/ipc.c
117,6 → 117,7
call = malloc(sizeof(*call));
if (!call) {
callback(private, ENOMEM, NULL);
return;
}
callid = __SYSCALL4(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1, arg2);
221,7 → 222,7
* @return Callid or 0 if nothing available and started with
* IPC_WAIT_NONBLOCKING
*/
int ipc_wait_for_call(ipc_call_t *call, int flags)
ipc_callid_t ipc_wait_for_call(ipc_call_t *call, int flags)
{
ipc_callid_t callid;
 
236,3 → 237,11
 
return callid;
}
 
/** Ask destination to do a callback connection */
int ipc_connect_to_me(int phoneid, int arg1, int arg2,
unsigned long long *taskid)
{
return __SYSCALL4(SYS_IPC_CONNECT_TO_ME, phoneid, arg1, arg2,
(sysarg_t) taskid);
}
/uspace/trunk/init/init.c
28,10 → 28,10
 
#include "version.h"
#include <ipc.h>
#include <ns.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <ns.h>
 
/*
static void test_printf(void)
46,7 → 46,7
}
*/
 
/*
extern char _heap;
static void test_mremap(void)
{
printf("Writing to good memory\n");
61,7 → 61,6
 
printf("memory done\n");
}
*/
/*
static void test_sbrk(void)
{
91,7 → 90,16
}
*/
 
/*
 
static void test_ping(void)
{
ipcarg_t result;
int retval;
 
retval = ipc_call_sync(PHONE_NS, NS_PING, 0xbeef,&result);
printf("Retval: %d - received: %P\n", retval, result);
}
 
static void got_answer(void *private, int retval, ipc_data_t *data)
{
printf("Retval: %d...%s...%X, %X\n", retval, private,
99,7 → 107,7
}
static void test_async_ipc(void)
{
ipc_data_t data;
ipc_call_t data;
int i;
 
printf("Sending ping\n");
122,16 → 130,39
ipc_wait_for_call(&data, NULL);
printf("Received call???\n");
}
*/
 
 
static void got_answer_2(void *private, int retval, ipc_data_t *data)
{
printf("Pong\n");
}
static void test_advanced_ipc(void)
{
int res;
unsigned long long taskid;
ipc_callid_t callid;
ipc_call_t data;
 
printf("Asking 0 to connect to me...\n");
res = ipc_connect_to_me(0, 1, 2, &taskid);
printf("Result: %d - taskid: %Q\n", res, taskid);
// while (1) {
printf("----------------\n");
ipc_call_async(PHONE_NS, NS_PING_SVC, 0, "prov",
got_answer_2);
callid = ipc_wait_for_call(&data, NULL);
printf("Received ping\n");
ipc_answer(callid, 0, 0, 0);
// }
callid = ipc_wait_for_call(&data, NULL);
}
 
int main(int argc, char *argv[])
{
ipcarg_t arg1, arg2;
 
version_print();
 
ipc_call_sync_2(PHONE_NS, NS_PING, 0xaaaa, 0xbbbb, &arg1, &arg2);
printf("Pong: %P %P\n", arg1, arg2);
// test_ping();
// test_async_ipc();
test_advanced_ipc();
return 0;
}
/uspace/trunk/Makefile
37,7 → 37,8
libc \
libipc \
libadt \
init
init \
ns
 
BUILDS := $(addsuffix .build,$(DIRS))
CLEANS := $(addsuffix .clean,$(DIRS))