1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12 13#pragma once 14 15#include <allocman/allocman.h> 16#include <allocman/cspace/cspace.h> 17#include <vka/capops.h> 18 19/* Helper routines for treating cspaces in a high level way. Giving you seL4 like operations 20 * at the cspace level instead of the cap/slot level */ 21 22static inline int cspace_move_alloc(allocman_t *alloc, cspacepath_t src, cspacepath_t *result) { 23 int error; 24 error = allocman_cspace_alloc(alloc, result); 25 if (error) { 26 return error; 27 } 28 return vka_cnode_move(result, &src) != seL4_NoError; 29} 30 31static inline int cspace_move_alloc_cptr(allocman_t *alloc, cspace_interface_t source_cspace, seL4_CPtr slot, cspacepath_t *result) { 32 return cspace_move_alloc(alloc, source_cspace.make_path(source_cspace.cspace, slot), result); 33} 34 35