1/** 2 * \brief Nameservice Implementation 3 * 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. 7 */ 8 9/* 10 * Copyright (c) 2010, 2011, ETH Zurich. 11 * All rights reserved. 12 * 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, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group. 16 */ 17#if 0 18#include <barrelfish/barrelfish.h> 19#include <barrelfish/threads.h> 20#include <barrelfish/nameservice_client.h> 21 22#include <octopus/init.h> 23#include <octopus/trigger.h> 24#include <octopus/getset.h> 25 26errval_t nameservice_lookup(const char *iface, iref_t *retiref) 27{ 28 errval_t err; 29 30 char* record = NULL; 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); 34 } 35 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; 40 41 if (err_is_fail(err)) { 42 err = err_push(err, LIB_ERR_NAMESERVICE_INVALID_NAME); 43 } 44 45 free(record); 46 return SYS_ERR_OK; 47} 48 49errval_t nameservice_blocking_lookup(const char *iface, iref_t *retiref) 50{ 51 errval_t err; 52 errval_t error_code; 53 char* record = NULL; 54 octopus_mode_t mode; 55 uint64_t state; 56 uint64_t fn; 57 uint64_t iref_number = 0; 58 59 struct octopus_thc_client_binding_t *cl = oct_get_thc_client(); 60 if (cl == NULL) { 61 return LIB_ERR_NAMESERVICE_NOT_BOUND; 62 } 63 64 octopus_trigger_t t = oct_mktrigger(OCT_ERR_NO_RECORD, octopus_BINDING_RPC, 65 OCT_ON_SET, 0, 0); 66 err = cl->call_seq.get(cl, iface, &record, t, &error_code); 67 if (err_is_ok(err)) { 68 err = error_code; 69 } 70 71 if (err_no(err) == OCT_ERR_NO_RECORD) { 72 assert(record == NULL); 73 cl->recv.trigger(cl, &mode, &fn, &state, &record); 74 err = SYS_ERR_OK; 75 } 76 77 if (err_is_ok(err)) { 78 assert(record != NULL); 79 // XXX: numbers from records are 64bit, irefs are 32 80 if (retiref != NULL) { 81 err = oct_read(record, "_ { iref: %d }", &iref_number); 82 *retiref = (iref_t) iref_number; 83 } 84 free(record); 85 } 86 87 return err; 88} 89 90errval_t nameservice_register(const char *iface, iref_t iref) 91{ 92 return oct_set("%s { iref: %d }", iface, iref); 93} 94#endif 95