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 <vka/vka.h> 16#include <vka/kobject_t.h> 17#include <utils/util.h> 18 19static inline int vka_alloc_pml4(vka_t *vka, vka_object_t *result) 20{ 21 return vka_alloc_object(vka, kobject_get_type(KOBJECT_PML4, 0), seL4_PML4Bits, result); 22} 23 24static inline int vka_alloc_pdpt(vka_t *vka, vka_object_t *result) 25{ 26 return vka_alloc_object(vka, kobject_get_type(KOBJECT_PDPT, 0), seL4_PDPTBits, result); 27} 28 29LEAKY(pml4) 30LEAKY(pdpt) 31 32static inline int vka_alloc_vspace_root(vka_t *vka, vka_object_t *result) 33{ 34 return vka_alloc_pml4(vka, result); 35} 36 37static inline unsigned long 38vka_x86_mode_get_object_size(seL4_Word objectType) 39{ 40 switch (objectType) { 41 case seL4_X64_HugePageObject: 42 return seL4_HugePageBits; 43 case seL4_X86_PDPTObject: 44 return seL4_PDPTBits; 45 case seL4_X64_PML4Object: 46 return seL4_PML4Bits; 47 default: 48 /* Unknown object type. */ 49 ZF_LOGE("Unknown object type %ld", (long)objectType); 50 return -1; 51 } 52} 53 54