]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libsigma0/lib/src/client.c
72e64cb3c43556e3f83aba8dc6fee5e4c33e21e3
[l4.git] / l4 / pkg / libsigma0 / lib / src / client.c
1 /*
2  * (c) 2008-2009 Technische Universität Dresden
3  * This file is part of TUD:OS and distributed under the terms of the
4  * GNU Lesser General Public License 2.1.
5  * Please see the COPYING-LGPL-2.1 file for details.
6  */
7 #include <l4/sys/ipc.h>
8 #include <l4/sigma0/sigma0.h>
9
10 /**
11  * New client.
12  *
13  * \param pager  pager implementing Sigma0 protocol
14  * \param gate   slot to attach to
15  * \return           #0                 on success
16  *                  -#L4SIGMA0_IPCERROR IPC error
17  *                  -#L4SIGMA0_NOFPAGE  no fpage received
18  */
19 int l4sigma0_new_client(l4_cap_idx_t pager, l4_cap_idx_t gate)
20 {
21   l4_msgtag_t tag = l4_msgtag(L4_PROTO_SIGMA0, 1, 0, 0);
22   l4_utcb_t *utcb = l4_utcb();
23   l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
24   l4_buf_regs_t *b = l4_utcb_br_u(utcb);
25
26   m->mr[0] = SIGMA0_REQ_NEW_CLIENT;
27   b->bdr = 0;
28   b->br[0] = L4_ITEM_MAP;
29   b->br[1] = l4_obj_fpage(gate, 0, 0).raw;
30
31   tag = l4_ipc_call(pager, utcb, tag, L4_IPC_NEVER);
32   if (l4_msgtag_has_error(tag))
33     return -L4SIGMA0_IPCERROR;
34
35   if (l4_msgtag_items(tag) != 1)
36     return -L4SIGMA0_NOFPAGE;
37
38   return 0;
39 }