1// -*- Mode: C++ -*-
2// vim:ft=cpp
3/**
4 * \file
5 * \brief  Kumem allocator helper
6 */
7/*
8 * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
9 *          Alexander Warg <warg@os.inf.tu-dresden.de>
10 *     economic rights: Technische Universität Dresden (Germany)
11 *
12 * This file is part of TUD:OS and distributed under the terms of the
13 * GNU General Public License 2.
14 * Please see the COPYING-GPL-2 file for details.
15 *
16 * As a special exception, you may use this file as part of a free software
17 * library without restriction.  Specifically, if other files instantiate
18 * templates or use macros or inline functions from this file, or you compile
19 * this file and link it with other files to produce an executable, this
20 * file does not by itself cause the resulting executable to be covered by
21 * the GNU General Public License.  This exception does not however
22 * invalidate any other reasons why the executable file might be covered by
23 * the GNU General Public License.
24 */
25
26#pragma once
27
28#include <l4/re/env>
29
30namespace L4Re { namespace Util {
31
32/**
33 * \defgroup l4re_util_kumem Kumem utiltities
34 * \ingroup api_l4re_util
35 */
36/*@{*/
37
38/**
39 * Allocate state area.
40 *
41 * \param[out] mem          Pointer to memory that has been allocated.
42 * \param      pages_order  Size to allocate, in log2 pages.
43 * \param      task         Task to use for allocation.
44 * \param      rm           Region manager to use for allocation.
45 *
46 * \retval 0   for success
47 * \retval <0  error code on failure
48 *
49 * \note
50 * The amount of kernel-user memory that can be allocated at once is limited by
51 * the used kernel implementation. The minimum allocatable amount is one page.
52 * A portable implementation should not depend on allocations greater than
53 * 16KiB to succeed.
54 */
55int
56kumem_alloc(l4_addr_t *mem, unsigned pages_order,
57            L4::Cap<L4::Task> task = L4Re::Env::env()->task(),
58            L4::Cap<L4Re::Rm> rm = L4Re::Env::env()->rm()) noexcept;
59
60/*@}*/
61}}
62