3 * \brief init user-space domain special structures.
7 * Copyright (c) 2007, 2008, 2009, 2010, 2012, ETH Zurich.
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, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
15 #ifndef BARRELFISH_KPI_INIT_H
16 #define BARRELFISH_KPI_INIT_H
21 * Size of bootinfo mapping.
23 #define BOOTINFO_SIZEBITS (BASE_PAGE_BITS + 2)
24 #define BOOTINFO_SIZE (1UL << BOOTINFO_SIZEBITS)
27 * Address (in spawned domain) of page with command-line arguments and environment
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
35 * Size of page with inherited file descriptors
37 #define FDS_SIZE (32 * 1024) // estimate worst case here.
41 * Size of dispatcher frame
43 #define DISPATCHER_SIZE ((genpaddr_t)1 << DISPATCHER_FRAME_BITS)
46 * Size of initial page to carry out monitor URPC
48 // Supports at least #MON_URPC_CHANNEL_LEN
49 // Change #MON_URPC_CHANNEL_LEN if changing this
50 #define MON_URPC_SIZE (2 * BASE_PAGE_SIZE)
54 * Maximum possible number of entries in the memory regions array. This is
55 * limited by the page size minus the size of the initial part of the bootinfo
58 #define MAX_MEM_REGIONS ((BOOTINFO_SIZE - sizeof(struct bootinfo)) / \
59 sizeof(struct mem_region))
61 /// Default number of entries in a cnode (in bits)
62 #define DEFAULT_CNODE_BITS (BASE_PAGE_BITS - OBJBITS_CTE)
64 /// Default number of entries in a cnode
65 #define DEFAULT_CNODE_SLOTS (1UL << DEFAULT_CNODE_BITS)
67 /// Number of entries in page cnode (in bits)
68 #define PAGE_CNODE_BITS (DEFAULT_CNODE_BITS + 2)
70 /// Number of entries in page cnode
71 #define PAGE_CNODE_SLOTS (1UL << PAGE_CNODE_BITS)
73 /// Remainder of guard size when subtracting bits from capaddr_t bitsize
74 #define GUARD_REMAINDER(bits) (CPTR_BITS - (bits))
77 #define ROOTCN_SLOT_TASKCN 0 ///< Taskcn slot in root cnode
78 #define ROOTCN_SLOT_PAGECN 1 ///< Pagecn slot in root cnode
79 #define ROOTCN_SLOT_BASE_PAGE_CN 2 ///< Slot for a cnode of BASE_PAGE_SIZE frames
80 #define ROOTCN_SLOT_SUPERCN 3 ///< Slot for a cnode of SUPER frames
81 #define ROOTCN_SLOT_SEGCN 4 ///< SegCN slot in root cnode
82 #define ROOTCN_SLOT_PACN 5 ///< PhysAddr cnode slot in root cnode
83 #define ROOTCN_SLOT_MODULECN 6 ///< Multiboot modules cnode slot in root cnode
84 #define ROOTCN_SLOT_SLOT_ALLOC0 7 ///< Root of slot alloc0
85 #define ROOTCN_SLOT_SLOT_ALLOC1 8 ///< Root of slot alloc1
86 #define ROOTCN_SLOT_SLOT_ALLOC2 9 ///< Root of slot alloc2
87 #define ROOTCN_SLOT_ARGCN 10 ///< Argcn slot in root cnode
88 #define ROOTCN_SLOTS_USER 11 ///< First free slot in root cnode for user
90 /* Size of CNodes in Root CNode if not the default size */
91 #define SLOT_ALLOC_CNODE_BITS (DEFAULT_CNODE_BITS * 2)
92 #define SLOT_ALLOC_CNODE_SLOTS (1UL << SLOT_ALLOC_CNODE_BITS)
95 #define TASKCN_SLOT_DISPATCHER 1 ///< Dispatcher cap in task cnode
96 #define TASKCN_SLOT_ROOTCN 2 ///< RootCN slot in task cnode
97 #define TASKCN_SLOT_DISPFRAME 4 ///< Dispatcher frame cap in task cnode
98 #define TASKCN_SLOT_IRQ 5 ///< IRQ cap in task cnode
99 #define TASKCN_SLOT_IO 6 ///< IO cap in task cnode
100 #define TASKCN_SLOT_BOOTINFO 7 ///< Bootinfo frame slot in task cnode
101 #define TASKCN_SLOT_KERNELCAP 8 ///< Kernel cap in task cnode
102 #define TASKCN_SLOT_TRACEBUF 9 ///< Trace buffer cap in task cnode
103 #define TASKCN_SLOT_ARGSPAGE 10 ///< ?
104 #define TASKCN_SLOT_MON_URPC 11 ///< Frame cap for urpc comm.
105 #define TASKCN_SLOT_SESSIONID 12 ///< Session ID domain belongs to
106 #define TASKCN_SLOT_FDSPAGE 13 ///< cap for inherited file descriptors
107 #define TASKCN_SLOT_PERF_MON 14 ///< cap for performance monitoring
108 #define TASKCN_SLOT_DISPFRAME2 15 ///< Copy of dispatcher frame cap (mapped into spawn vspace)
109 #define TASKCN_SLOT_ARGSPAGE2 16 ///< Copy of environment cap (mapped into spawn vspace)
110 #define TASKCN_SLOTS_USER 17 ///< First free slot in taskcn for user
112 /// Address bits resolved for the standard CNodes (taskcn, supercn, base_page_cn)
113 #define DEFAULT_CN_ADDR_BITS (CPTR_BITS - DEFAULT_CNODE_BITS)
115 #define CPTR_BASE_PAGE_CN_BASE (ROOTCN_SLOT_BASE_PAGE_CN << DEFAULT_CN_ADDR_BITS)
116 #define CPTR_SUPERCN_BASE (ROOTCN_SLOT_SUPERCN << DEFAULT_CN_ADDR_BITS)
117 #define CPTR_PHYADDRCN_BASE (ROOTCN_SLOT_PACN << DEFAULT_CN_ADDR_BITS)
118 #define CPTR_MODULECN_BASE (ROOTCN_SLOT_MODULECN << DEFAULT_CN_ADDR_BITS)
119 #define CPTR_PML4_BASE (ROOTCN_SLOT_PAGECN << (CPTR_BITS - PAGE_CNODE_BITS))
120 #define MODULECN_SIZE_BITS 14 ///< Size of module cnode (in bits)
123 * Memory region types.
126 /// Empty memory: describes a RAM cap in supercn
128 /// Code/Data of init itself: describes a Frame cap in segcn
130 /// Physical address range (not RAM): describes a PhysAddr cap in physaddrcn
132 /// BIOS tables and platform-specific data: describes a PhysAddr cap in physaddrcn
133 RegionType_PlatformData,
134 /// Multiboot module: describes multiple Frame caps in modulecn
136 RegionType_Max ///< Must be last
143 genpaddr_t mr_base;///< Address of the start of the region
144 enum region_type mr_type;///< Type of region
145 uint8_t mr_bits;///< Size as a power of two shift (not module type)
146 bool mr_consumed;///< Flag for user code to mark region consumed
147 size_t mrmod_size;///< Size in bytes (module type only)
148 ptrdiff_t mrmod_data;///< Offset of module string (module type only)
149 int mrmod_slot;///< First slot containing caps (module only)
153 * This structure holds essential information for the init process to
154 * allocate and manage its address space.
157 /// Number of entries in regions array
158 size_t regions_length;
159 /// Amount of memory required to spawn another core
160 size_t mem_spawn_core;
161 /// Memory regions array
162 struct mem_region regions[];