2 * \brief Nameservice Implementation
4 * NS Implementation using THC. Currently not included in libbarrelfish
5 * due to limitations in memory allocation: THC allocates a large stack
6 * and during NS initialization only allocation of one page is allowed.
10 * Copyright (c) 2010, 2011, ETH Zurich.
11 * All rights reserved.
13 * This file is distributed under the terms in the attached LICENSE file.
14 * If you do not find this file, copies can be found by writing to:
15 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
18 #include <barrelfish/barrelfish.h>
19 #include <barrelfish/threads.h>
20 #include <barrelfish/nameservice_client.h>
22 #include <octopus/init.h>
23 #include <octopus/trigger.h>
24 #include <octopus/getset.h>
26 errval_t nameservice_lookup(const char *iface, iref_t *retiref)
31 err = oct_get(&record, iface);
32 if (err_no(err) == OCT_ERR_NO_RECORD) {
33 return err_push(err, LIB_ERR_NAMESERVICE_UNKNOWN_NAME);
36 // XXX: numbers from records are 64bit, irefs are 32
37 uint64_t iref_number = 0;
38 err = oct_read(record, "_ { iref: %d }", &iref_number);
39 *retiref = iref_number;
41 if (err_is_fail(err)) {
42 err = err_push(err, LIB_ERR_NAMESERVICE_INVALID_NAME);
49 errval_t nameservice_blocking_lookup(const char *iface, iref_t *retiref)
57 uint64_t iref_number = 0;
59 struct octopus_thc_client_binding_t *cl = oct_get_thc_client();
61 return LIB_ERR_NAMESERVICE_NOT_BOUND;
64 octopus_trigger_t t = oct_mktrigger(OCT_ERR_NO_RECORD, OCT_ON_SET, 0, 0);
65 err = cl->call_seq.get(cl, iface, &record, t, &error_code);
70 if (err_no(err) == OCT_ERR_NO_RECORD) {
71 assert(record == NULL);
72 cl->recv.trigger(cl, &mode, &fn, &state, &record);
77 assert(record != NULL);
78 // XXX: numbers from records are 64bit, irefs are 32
79 if (retiref != NULL) {
80 err = oct_read(record, "_ { iref: %d }", &iref_number);
81 *retiref = (iref_t) iref_number;
89 errval_t nameservice_register(const char *iface, iref_t iref)
91 return oct_set("%s { iref: %d }", iface, iref);