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 <autoconf.h> 16#include <sel4/types.h> 17#include <allocman/utspace/utspace.h> 18#include <vka/cspacepath_t.h> 19#include <assert.h> 20 21/* This is an untyped manager that is vaguely related to the twinkle allocator. 22 This means it does a simple progressive allocation of untypeds and doesn't 23 support free. */ 24 25struct utspace_twinkle_ut { 26 cspacepath_t path; 27 size_t offset; 28 size_t size_bits; 29}; 30 31typedef struct utspace_twinkle { 32 size_t num_uts; 33 struct utspace_twinkle_ut *uts; 34} utspace_twinkle_t; 35 36void utspace_twinkle_create(utspace_twinkle_t *twinkle); 37int _utspace_twinkle_add_uts(struct allocman *alloc, void *_twinkle, size_t num, const cspacepath_t *uts, size_t *size_bits, uintptr_t *paddr, int utType); 38 39seL4_Word _utspace_twinkle_alloc(struct allocman *alloc, void *_twinkle, size_t size_bits, seL4_Word type, const cspacepath_t *slot, uintptr_t paddr, bool canBeDev, int *error); 40void _utspace_twinkle_free(struct allocman *alloc, void *_twinkle, seL4_Word cookie, size_t size_bits); 41 42static inline uintptr_t _utspace_twinkle_paddr(void *_twinkle, seL4_Word cookie, size_t size_bits) { 43 assert(!"not implemented"); 44 return ALLOCMAN_NO_PADDR; 45} 46 47static inline struct utspace_interface utspace_twinkle_make_interface(utspace_twinkle_t *twinkle) { 48 return (struct utspace_interface) { 49 .alloc = _utspace_twinkle_alloc, 50 .free = _utspace_twinkle_free, 51 .add_uts = _utspace_twinkle_add_uts, 52 .paddr = _utspace_twinkle_paddr, 53 .properties = ALLOCMAN_DEFAULT_PROPERTIES, 54 .utspace = twinkle 55 }; 56} 57 58