aos/include/mm/mm.h
Daniel Schwyn 6d444bf552 Main handout
Signed-off-by: Daniel Schwyn <daniel.schwyn@inf.ethz.ch>
2022-03-03 14:57:51 +01:00

59 lines
1.8 KiB
C

/**
* \file
* \brief Memory manager header
*/
/*
* Copyright (c) 2008, 2011, ETH Zurich.
* Copyright (c), 2022, The University of British Columbia
* All rights reserved.
*
* This file is distributed under the terms in the attached LICENSE file.
* If you do not find this file, copies can be found by writing to:
* ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
*/
#ifndef AOS_MM_H
#define AOS_MM_H
#include <sys/cdefs.h>
#include <errors/errno.h>
#include <aos/types.h>
#include <aos/capabilities.h>
#include <aos/slab.h>
#include "slot_alloc.h"
__BEGIN_DECLS
/**
* \brief Memory manager instance data
*
* This should be opaque from the perspective of the client, but to allow
* them to allocate its memory, we declare it in the public header.
*/
struct mm {
struct slab_allocator slabs; ///< Slab allocator used for allocating nodes
slot_alloc_t slot_alloc; ///< Slot allocator for allocating cspace
slot_refill_t slot_refill; ///< Slot allocator refill function
void *slot_alloc_inst; ///< Opaque instance pointer for slot allocator
enum objtype objtype; ///< Type of capabilities stored
// TODO: add your meta data tracking here...
};
errval_t mm_init(struct mm *mm, enum objtype objtype,
slab_refill_func_t slab_refill_func,
slot_alloc_t slot_alloc_func,
slot_refill_t slot_refill_func,
void *slot_alloc_inst);
errval_t mm_add(struct mm *mm, struct capref cap);
errval_t mm_alloc_aligned(struct mm *mm, size_t size, size_t alignment,
struct capref *retcap);
errval_t mm_alloc(struct mm *mm, size_t size, struct capref *retcap);
errval_t mm_free(struct mm *mm, struct capref cap);
void mm_destroy(struct mm *mm);
__END_DECLS
#endif /* AOS_MM_H */