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 21enum _arm_mode_kobject_type { 22 KOBJECT_FRAME = 0, 23 KOBJECT_MODE_NUM_TYPES, 24}; 25 26typedef int kobject_t; 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 arm_mode_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_SectionBits: 39 case seL4_SuperSectionBits: 40 return objectSize; 41 default: 42 return 0; 43 } 44 default: 45 /* Unknown object type. */ 46 ZF_LOGE("Unknown object type"); 47 return 0; 48 } 49} 50 51static inline seL4_Word arm_mode_kobject_get_type(kobject_t type, seL4_Word objectSize) 52{ 53 switch (type) { 54 case KOBJECT_FRAME: 55 switch (objectSize) { 56 case seL4_SectionBits: 57 return seL4_ARM_SectionObject; 58 case seL4_SuperSectionBits: 59 return seL4_ARM_SuperSectionObject; 60 default: 61 return -1; 62 } 63 default: 64 /* Unknown object type. */ 65 ZF_LOGE("Unknown object type"); 66 return -1; 67 } 68} 69 70