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 <sel4/types.h> 16#include <assert.h> 17#include <autoconf.h> 18#include <sel4vka/gen_config.h> 19#include <utils/util.h> 20#include <vka/sel4_arch/kobject_t.h> 21 22enum _arm_kobject_type { 23 KOBJECT_PAGE_DIRECTORY = KOBJECT_MODE_NUM_TYPES, 24 KOBJECT_PAGE_TABLE, 25 KOBJECT_ARCH_NUM_TYPES, 26}; 27 28/* 29 * Get the size (in bits) of the untyped memory required to 30 * create an object of the given size 31 */ 32static inline seL4_Word arch_kobject_get_size(kobject_t type, seL4_Word objectSize) 33{ 34 switch (type) { 35 /* ARM-specific frames. */ 36 case KOBJECT_FRAME: 37 switch (objectSize) { 38 case seL4_PageBits: 39 case seL4_LargePageBits: 40 return objectSize; 41 } 42 /* If frame size was unknown fall through to default case as it 43 * might be a mode specific frame size */ 44 default: 45 return arm_mode_kobject_get_size(type, objectSize); 46 } 47} 48 49static inline seL4_Word arch_kobject_get_type(kobject_t type, seL4_Word objectSize) 50{ 51 switch (type) { 52 case KOBJECT_PAGE_DIRECTORY: 53 return seL4_ARM_PageDirectoryObject; 54 case KOBJECT_PAGE_TABLE: 55 return seL4_ARM_PageTableObject; 56 /* ARM-specific frames. */ 57 case KOBJECT_FRAME: 58 switch (objectSize) { 59 case seL4_PageBits: 60 return seL4_ARM_SmallPageObject; 61 case seL4_LargePageBits: 62 return seL4_ARM_LargePageObject; 63 default: 64 return arm_mode_kobject_get_type(type, objectSize); 65 } 66 default: 67 return arm_mode_kobject_get_type(type, objectSize); 68 } 69} 70 71