1/** 2 * \file 3 * \brief Management of inter-monitor bindings 4 */ 5 6/* 7 * Copyright (c) 2007, 2008, 2010, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#include <monitor.h> 16 17// Array of monitor bindings indexed by core ID 18static struct intermon_state *bindings[MAX_COREID + 1]; 19 20// This is called when a new binding comes up 21errval_t intermon_binding_set(struct intermon_state *st) 22{ 23 assert(st != NULL); 24 if (st->core_id > MAX_COREID) { 25 return MON_ERR_INVALID_CORE_ID; 26 } 27 if (bindings[st->core_id] != NULL) { 28 //printf("%s:%s:%d: overwrite binding (core_id=%"PRIuCOREID"), scary.\n", 29 // __FILE__, __FUNCTION__, __LINE__, st->core_id); 30 } 31 bindings[st->core_id] = st; 32 33 return SYS_ERR_OK; 34} 35 36errval_t intermon_binding_get(coreid_t coreid, struct intermon_binding **ret) 37{ 38 assert(ret != NULL); 39 //printf("%s:%s:%d: coreid=%"PRIuCOREID"\n", __FILE__, __FUNCTION__, __LINE__, coreid); 40 41 if (coreid > MAX_COREID) { 42 *ret = NULL; 43 return MON_ERR_INVALID_CORE_ID; 44 } 45 46 if (bindings[coreid] == NULL) { 47 *ret = NULL; 48 return MON_ERR_NO_MONITOR_FOR_CORE; 49 } 50 51 *ret = bindings[coreid]->binding; 52 return SYS_ERR_OK; 53} 54