1/*
2 * Copyright 2018, 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#pragma once
13
14#include <vka/vka.h>
15#include <vka/kobject_t.h>
16#include <utils/util.h>
17
18static inline int vka_alloc_vspace_root(vka_t *vka, vka_object_t *result)
19{
20    return vka_alloc_object(vka, kobject_get_type(KOBJECT_PAGE_TABLE, 0), seL4_PageTableBits, result);
21}
22
23
24static inline unsigned long
25vka_arch_get_object_size(seL4_Word objectType)
26{
27    switch (objectType) {
28    case seL4_RISCV_4K_Page:
29        return seL4_PageBits;
30    case seL4_RISCV_Mega_Page:
31        return seL4_LargePageBits;
32#if CONFIG_PT_LEVELS > 2
33    case seL4_RISCV_Giga_Page:
34        return seL4_HugePageBits;
35#endif
36#if CONFIG_PT_LEVELS > 3
37    case seL4_RISCV_Tera_Page:
38        return seL4_TeraPageBits;
39#endif
40    case seL4_RISCV_PageTableObject:
41        return seL4_PageTableBits;
42
43    default:
44         ZF_LOGE("Unknown object type %ld", (long)objectType);
45         return -1;
46    }
47}
48
49