1/** 2 * \file 3 * \brief init user-space domain special structures. 4 */ 5 6/* 7 * Copyright (c) 2007, 2008, 2009, 2010, 2012, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#ifndef BARRELFISH_KPI_INIT_H 16#define BARRELFISH_KPI_INIT_H 17 18#include <stdbool.h> 19 20/** 21 * Size of bootinfo mapping. 22 */ 23#define BOOTINFO_SIZEBITS (BASE_PAGE_BITS + 2) 24#define BOOTINFO_SIZE (1UL << BOOTINFO_SIZEBITS) 25 26/** 27 * Address (in spawned domain) of page with command-line arguments and environment 28 */ 29#define ARGS_FRAME_BITS 17 // 128 kB 30#define ARGS_SIZE ((genpaddr_t)1 << ARGS_FRAME_BITS) 31#define MAX_CMDLINE_ARGS 128 32#define MAX_ENVIRON_VARS 128 33 34/** 35 * Size of page with inherited file descriptors 36 */ 37#define FDS_SIZE (32 * 1024) // estimate worst case here. 38 39 40/** 41 * \brief Amount of space required for the dispatcher frame. 42 * 43 * This needs to be big enough to fit the struct dispatcher_<arch>, and should 44 * also provide extra room for LMP channel receive buffers. 45 * 46 * \bug Make this arch specific 47 * 48 * Moved from include/barrelfish_kpi/dispatcher_shared.h -SG,2018-12-19. 49 */ 50#define DISPATCHER_FRAME_SIZE ((genpaddr_t)1 << 19) 51 52/** 53 * Size of initial page to carry out monitor URPC 54 */ 55// Supports at least #MON_URPC_CHANNEL_LEN 56// Change #MON_URPC_CHANNEL_LEN if changing this 57#define MON_URPC_SIZE (2 * BASE_PAGE_SIZE) 58 59/** 60 61 * Maximum possible number of entries in the memory regions array. This is 62 * limited by the page size minus the size of the initial part of the bootinfo 63 * structure. 64 */ 65#define MAX_MEM_REGIONS ((BOOTINFO_SIZE - sizeof(struct bootinfo)) / \ 66 sizeof(struct mem_region)) 67 68/* Root CNode */ 69#define ROOTCN_SLOT_TASKCN 0 ///< Taskcn slot in root cnode 70#define ROOTCN_SLOT_PAGECN 1 ///< Pagecn slot in root cnode 71#define ROOTCN_SLOT_BASE_PAGE_CN 2 ///< Slot for a cnode of BASE_PAGE_SIZE frames 72#define ROOTCN_SLOT_SUPERCN 3 ///< Slot for a cnode of SUPER frames 73#define ROOTCN_SLOT_SEGCN 4 ///< SegCN slot in root cnode 74#define ROOTCN_SLOT_PACN 5 ///< PhysAddr cnode slot in root cnode 75#define ROOTCN_SLOT_MODULECN 6 ///< Multiboot modules cnode slot in root cnode 76#define ROOTCN_SLOT_SLOT_ALLOC0 7 ///< Used for base cn slot allocator in early code 77#define ROOTCN_SLOT_SLOT_ALLOC1 8 ///< Root of slot alloc1 78#define ROOTCN_SLOT_SLOT_ALLOC2 9 ///< Root of slot alloc2 79#define ROOTCN_SLOT_ROOT_MAPPING 10 ///< Slot for a cnode for the root vnode mappings 80#define ROOTCN_SLOT_ARGCN 11 ///< Argcn slot in root cnode 81#define ROOTCN_SLOT_BSPKCB 12 ///< BSP KCB cap to fix reverse lookup issues 82#define ROOTCN_SLOT_EARLY_CN_CN 13 ///< Slot for a cnode of L2_CNODE_SIZE frames 83#define ROOTCN_SLOTS_USER 14 ///< First free slot in root cnode for user 84 85/* Size of CNodes in Root CNode if not the default size */ 86#define SLOT_ALLOC_CNODE_BITS L2_CNODE_BITS 87#define SLOT_ALLOC_CNODE_SLOTS L2_CNODE_SLOTS 88/* Only allocate 32 chunks for early cnode allocator */ 89#define EARLY_CNODE_ALLOCATED_BITS (L2_CNODE_BITS - 2) 90#define EARLY_CNODE_ALLOCATED_SLOTS (1ULL << EARLY_CNODE_ALLOCATED_BITS) 91 92/* Task CNode */ 93#define TASKCN_SLOT_TASKCN 0 ///< Task CNode in itself (XXX) 94#define TASKCN_SLOT_DISPATCHER 1 ///< Dispatcher cap in task cnode 95#define TASKCN_SLOT_ROOTCN 2 ///< RootCN slot in task cnode 96#define TASKCN_SLOT_DISPFRAME 4 ///< Dispatcher frame cap in task cnode 97#define TASKCN_SLOT_IRQ 5 ///< IRQ cap in task cnode 98#define TASKCN_SLOT_IO 6 ///< IO cap in task cnode 99#define TASKCN_SLOT_BOOTINFO 7 ///< Bootinfo frame slot in task cnode 100#define TASKCN_SLOT_KERNELCAP 8 ///< Kernel cap in task cnode 101#define TASKCN_SLOT_TRACEBUF 9 ///< Trace buffer cap in task cnode 102#define TASKCN_SLOT_ARGSPAGE 10 ///< ? 103#define TASKCN_SLOT_MON_URPC 11 ///< Frame cap for urpc comm. 104#define TASKCN_SLOT_SESSIONID 12 ///< Session ID domain belongs to 105#define TASKCN_SLOT_FDSPAGE 13 ///< cap for inherited file descriptors 106#define TASKCN_SLOT_PERF_MON 14 ///< cap for performance monitoring 107#define TASKCN_SLOT_SYSMEM 15 ///< ??? 108#define TASKCN_SLOT_COREBOOT 16 ///< Copy of realmode section used to bootstrap a core 109#define TASKCN_SLOT_IPI 17 ///< Copy of IPI cap 110#define TASKCN_SLOT_PROC_MNG 18 ///< Cap for the process manager 111#define TASKCN_SLOT_DOMAINID 19 ///< Domain ID cap 112#define TASKCN_SLOT_DEVMAN 20 ///< DeviceID manager capability 113#define TASKCN_SLOTS_USER 21 ///< First free slot in taskcn for user 114 115/* Page CNode */ 116#define PAGECN_SLOT_VROOT 0 ///< First slot of page cnode is root page table 117 118#define ROOTCN_SLOT_LEVEL CSPACE_LEVEL_L1 119#define ROOTCN_SLOT_ADDR(slot) ((slot) << L2_CNODE_BITS) 120 121// Cspace addresses for well-defined L2 CNodes 122#define CPTR_TASKCN_BASE ROOTCN_SLOT_ADDR(ROOTCN_SLOT_TASKCN) 123#define CPTR_BASE_PAGE_CN_BASE ROOTCN_SLOT_ADDR(ROOTCN_SLOT_BASE_PAGE_CN) 124#define CPTR_SUPERCN_BASE ROOTCN_SLOT_ADDR(ROOTCN_SLOT_SUPERCN) 125#define CPTR_PHYADDRCN_BASE ROOTCN_SLOT_ADDR(ROOTCN_SLOT_PACN) 126#define CPTR_MODULECN_BASE ROOTCN_SLOT_ADDR(ROOTCN_SLOT_MODULECN) 127#define CPTR_PAGECN_BASE ROOTCN_SLOT_ADDR(ROOTCN_SLOT_PAGECN) 128 129/** 130 * Memory region types. 131 */ 132enum region_type { 133 /// Empty memory: describes a RAM cap in supercn 134 RegionType_Empty, 135 /// Code/Data of init itself: describes a Frame cap in segcn 136 RegionType_RootTask, 137 /// Physical address range (not RAM): describes a PhysAddr cap in physaddrcn 138 RegionType_PhyAddr, 139 /// BIOS tables and platform-specific data: describes a PhysAddr cap in physaddrcn 140 RegionType_PlatformData, 141 /// Multiboot module: describes multiple Frame caps in modulecn 142 RegionType_Module, 143 ///< describes memory region that is an ACPI table 144 RegionType_ACPI_TABLE, 145 RegionType_Max ///< Must be last 146}; 147 148/** 149 * A memory region. 150 */ 151struct mem_region { 152 genpaddr_t mr_base;///< Address of the start of the region 153 enum region_type mr_type;///< Type of region 154 gensize_t mr_bytes;///< Size in bytes 155 bool mr_consumed;///< Flag for user code to mark region consumed 156 size_t mrmod_size;///< Size in bytes (module type only) 157 ptrdiff_t mrmod_data;///< Offset of module string (module type only) 158 int mrmod_slot;///< First slot containing caps (module only) 159}; 160 161/** 162 * This structure holds essential information for the init process to 163 * allocate and manage its address space. 164 */ 165struct bootinfo { 166 /// For __k1om__ 167 uint64_t host_msg; 168 uint8_t host_msg_bits; 169 170 /// Number of entries in regions array 171 size_t regions_length; 172 /// Amount of memory required to spawn another core 173 size_t mem_spawn_core; 174 /// Memory regions array 175 struct mem_region regions[]; 176}; 177 178#endif 179