1 /**
2  * \file
3  * Namespace functions, C interface
4  */
5 /*
6  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7  *               Alexander Warg <warg@os.inf.tu-dresden.de>
8  *     economic rights: Technische Universität Dresden (Germany)
9  *
10  * This file is part of TUD:OS and distributed under the terms of the
11  * GNU General Public License 2.
12  * Please see the COPYING-GPL-2 file for details.
13  *
14  * As a special exception, you may use this file as part of a free software
15  * library without restriction.  Specifically, if other files instantiate
16  * templates or use macros or inline functions from this file, or you compile
17  * this file and link it with other files to produce an executable, this
18  * file does not by itself cause the resulting executable to be covered by
19  * the GNU General Public License.  This exception does not however
20  * invalidate any other reasons why the executable file might be covered by
21  * the GNU General Public License.
22  */
23 #pragma once
24 
25 /**
26  * \defgroup api_l4re_c_ns Namespace interface
27  * \ingroup api_l4re_c
28  * Namespace C interface.
29  */
30 
31 #include <l4/re/env.h>
32 
33 /**
34  * Namespace register flags.
35  * \ingroup api_l4re_c_ns
36  *
37  * \see L4Re::Namespace::Register_flags
38  */
39 enum l4re_ns_register_flags {
40   L4RE_NS_REGISTER_RO  = L4_FPAGE_RO,
41   L4RE_NS_REGISTER_DIR = 0x10,
42   L4RE_NS_REGISTER_RW  = L4_FPAGE_RX,
43   L4RE_NS_REGISTER_RWS = L4_FPAGE_RWX,
44   L4RE_NS_REGISTER_S   = L4_FPAGE_W,
45 };
46 
47 EXTERN_C_BEGIN
48 
49 /**
50  * Namespace type
51  * \ingroup api_l4re_c_ds
52  */
53 typedef l4_cap_idx_t l4re_namespace_t;
54 
55 
56 
57 /**
58  * \ingroup api_l4re_c_ns
59  * \copybrief l4re_ns_query_srv()
60  * \param timeout  Timeout of query in milliseconds. The client will only wait
61  *                 if a name already has been registered with the server but no
62  *                 object has been attached yet.
63  * \copydetails l4re_ns_query_srv()
64  */
65 L4_CV long
66 l4re_ns_query_to_srv(l4re_namespace_t srv, char const *name,
67                      l4_cap_idx_t const cap, int timeout) L4_NOTHROW;
68 
69 /**
70  * \ingroup api_l4re_c_ns
71  * Query the name space for the object named by `name`.
72  *
73  * \param srv   Name space server to use for the query.
74  * \param name  String to query.
75  * \param cap   Capability slot where the received capability will be stored.
76  *
77  * \retval 0           Name could be fully resolved.
78  * \retval >0          Name could only be partly resolved. The number of
79  *                     remaining characters is returned.
80  * \retval -L4_ENOENT  Entry could not be found.
81  * \retval -L4_EAGAIN  Entry exists but no object is yet attached.
82  *                     Try again later.
83  * \retval <0          IPC errors, see #l4_error_code_t.
84  */
85 L4_CV L4_INLINE long
86 l4re_ns_query_srv(l4re_namespace_t srv, char const *name,
87                   l4_cap_idx_t const cap) L4_NOTHROW;
88 
89 /**
90  *
91  * \ingroup api_l4re_c_ns
92  * \copybrief L4Re::Namespace::register_obj
93  * \param srv  Name space server to use for the query.
94  * \copydetails L4Re::Namespace::register_obj
95  */
96 L4_CV long
97 l4re_ns_register_obj_srv(l4re_namespace_t srv, char const *name,
98                          l4_cap_idx_t const obj, unsigned flags) L4_NOTHROW;
99 
100 
101 
102 /****** Implementation ***********/
103 
104 L4_CV L4_INLINE long
l4re_ns_query_srv(l4re_namespace_t srv,char const * name,l4_cap_idx_t const cap)105 l4re_ns_query_srv(l4re_namespace_t srv, char const *name,
106                   l4_cap_idx_t const cap) L4_NOTHROW
107 {
108   return l4re_ns_query_to_srv(srv, name, cap, 40000);
109 }
110 
111 
112 EXTERN_C_END
113