1/* 2 * Copyright (c) 2012, ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#include "caplock.h" 11#include <barrelfish/waitset.h> 12#include <barrelfish/event_queue.h> 13#include <barrelfish/debug.h> 14#include <monitor_invocations.h> 15#include "capqueue.h" 16#include "monitor_debug.h" 17 18static struct capqueue_queue global_queue; 19 20void 21caplock_wait(struct domcapref cap, 22 struct event_queue_node *qn, struct event_closure cont) 23{ 24 DEBUG_CAPOPS("caplock_wait\n"); 25 capqueue_wait(&global_queue, qn, cont); 26} 27 28void 29caplock_unlock(struct domcapref cap) 30{ 31 errval_t err = monitor_unlock_cap(cap.croot, cap.cptr, cap.level); 32 if (err_no(err) == SYS_ERR_CAP_NOT_FOUND || 33 err == err_push(SYS_ERR_CAP_NOT_FOUND, SYS_ERR_IDENTIFY_LOOKUP)) 34 { 35 DEBUG_ERR(err, "unlocking cap"); 36 } 37 else if (err_is_fail(err)) { 38 USER_PANIC_ERR(err, "unlocking cap"); 39 } 40 capqueue_notify(&global_queue); 41} 42 43void 44caplock_init(struct waitset *ws) 45{ 46 capqueue_init(&global_queue, ws); 47} 48