2 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3 * Alexander Warg <warg@os.inf.tu-dresden.de>
4 * economic rights: Technische Universität Dresden (Germany)
6 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
10 #include <l4/sys/err.h>
11 #include <l4/sys/types.h>
13 #include <l4/re/util/cap_alloc>
14 #include <l4/cxx/ipc_stream>
21 func_neg_call(L4::Cap<void> const &server, l4_uint32_t *result,
24 L4::Ipc_iostream s(l4_utcb());
25 s << l4_umword_t(Opcode::func_neg) << val;
26 l4_msgtag_t res = s.call(server.cap());
27 if (l4_ipc_error(res, l4_utcb()))
34 func_sub_call(L4::Cap<void> const &server, l4_uint32_t *result,
35 l4_uint32_t val1, l4_uint32_t val2)
37 L4::Ipc_iostream s(l4_utcb());
38 s << l4_umword_t(Opcode::func_sub) << val1 << val2;
39 l4_msgtag_t res = s.call(server.cap(), Protocol::Calc);
40 if (l4_ipc_error(res, l4_utcb()))
50 L4::Cap<void> server = L4Re::Env::env()->get_cap<void>("calc_server");
51 if (!server.is_valid())
53 printf("Could not get server capability!\n");
60 printf("Asking for %d - %d\n", val1, val2);
62 if (func_sub_call(server, &val1, val1, val2))
64 printf("Error talking to server\n");
67 printf("Result of substract call: %d\n", val1);
68 printf("Asking for -%d\n", val1);
69 if (func_neg_call(server, &val1, val1))
71 printf("Error talking to server\n");
74 printf("Result of negate call: %d\n", val1);