1/*
2 * Copyright 2014, General Dynamics C4 Systems
3 *
4 * This software may be distributed and modified according to the terms of
5 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
6 * See "LICENSE_GPLv2.txt" for details.
7 *
8 * @TAG(GD_GPL)
9 */
10
11#ifndef __OBJECT_UNTYPED_H
12#define __OBJECT_UNTYPED_H
13
14#include <config.h>
15#include <types.h>
16#include <api/failures.h>
17#include <api/types.h>
18#include <object/structures.h>
19#include <object/cnode.h>
20
21/* It is assumed that every untyped is within seL4_MinUntypedBits and seL4_MaxUntypedBits
22 * (inclusive). This means that every untyped stored as seL4_MinUntypedBits
23 * subtracted from its size before it is stored in capBlockSize, and
24 * capFreeIndex counts in chunks of size 2^seL4_MinUntypedBits. The seL4_MaxUntypedBits
25 * is the minimal untyped that can be stored when considering both how
26 * many bits of capBlockSize there are, and the largest offset that can
27 * be stored in capFreeIndex */
28#define MAX_FREE_INDEX(sizeBits) (BIT((sizeBits) - seL4_MinUntypedBits))
29#define FREE_INDEX_TO_OFFSET(freeIndex) ((freeIndex)<<seL4_MinUntypedBits)
30#define GET_FREE_REF(base,freeIndex) ((word_t)(((word_t)(base)) + FREE_INDEX_TO_OFFSET(freeIndex)))
31#define GET_FREE_INDEX(base,free) (((word_t)(free) - (word_t)(base))>>seL4_MinUntypedBits)
32#define GET_OFFSET_FREE_PTR(base, offset) ((void *)(((word_t)(base)) + (offset)))
33#define OFFSET_TO_FREE_INDEX(offset) ((offset)>>seL4_MinUntypedBits)
34
35exception_t decodeUntypedInvocation(word_t invLabel, word_t length,
36                                    cte_t *slot, cap_t cap,
37                                    extra_caps_t excaps, bool_t call,
38                                    word_t *buffer);
39exception_t invokeUntyped_Retype(cte_t *srcSlot, bool_t reset,
40                                 void* retypeBase, object_t newType,
41                                 word_t userSize, slot_range_t destSlots,
42                                 bool_t deviceMemory);
43#endif
44