3 * \brief Essential capability definitions.
7 * Copyright (c) 2007-2012, ETH Zurich.
8 * Copyright (c) 2015, Hewlett Packard Enterprise Development LP.
11 * This file is distributed under the terms in the attached LICENSE file.
12 * If you do not find this file, copies can be found by writing to:
13 * ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
16 #ifndef BARRELFISH_CAPABILITIES_H
17 #define BARRELFISH_CAPABILITIES_H
19 /* FIXME: OBJBITS defines must match sizes in Hamlet's capabilities/caps.hl */
21 // Size of CNode entry
25 #define OBJBITS_DISPATCHER 10
27 // Size of kernel control block
28 #define OBJBITS_KCB 16
34 #include <barrelfish_kpi/types.h>
36 #define CAPRIGHTS_READ (1 << 0)
37 #define CAPRIGHTS_WRITE (1 << 1)
38 #define CAPRIGHTS_EXECUTE (1 << 2)
39 #define CAPRIGHTS_GRANT (1 << 3)
40 #define CAPRIGHTS_IDENTIFY (1 << 4)
41 #define CAPRIGHTS_NUM 5
43 #define CAPRIGHTS_ALLRIGHTS ((1 << CAPRIGHTS_NUM) - 1)
44 #define CAPRIGHTS_READ_WRITE (CAPRIGHTS_READ | CAPRIGHTS_WRITE)
45 #define CAPRIGHTS_NORIGHTS 0
47 typedef uint8_t CapRights;
48 #define PRIuCAPRIGHTS PRIu8
49 #define PRIxCAPRIGHTS PRIx8
53 // capbits needs CapRights and dcb;
54 #include <barrelfish_kpi/capbits.h>
56 static inline bool type_is_vnode(enum objtype type)
58 STATIC_ASSERT(46 == ObjType_Num, "Check VNode definitions");
60 return (type == ObjType_VNode_x86_64_pml4 ||
61 type == ObjType_VNode_x86_64_pdpt ||
62 type == ObjType_VNode_x86_64_pdir ||
63 type == ObjType_VNode_x86_64_ptable ||
64 type == ObjType_VNode_x86_32_pdpt ||
65 type == ObjType_VNode_x86_32_pdir ||
66 type == ObjType_VNode_x86_32_ptable ||
67 type == ObjType_VNode_AARCH64_l3 ||
68 type == ObjType_VNode_AARCH64_l2 ||
69 type == ObjType_VNode_AARCH64_l1 ||
70 type == ObjType_VNode_ARM_l2 ||
71 type == ObjType_VNode_ARM_l1
76 * Return size of vnode in bits. This is the size of a page table page.
78 * @param type Object type.
80 * @return Number of bits represented by a VNode.
82 static inline size_t vnode_objbits(enum objtype type)
84 // This function should be emitted by hamlet or somesuch.
85 STATIC_ASSERT(46 == ObjType_Num, "Check VNode definitions");
87 if (type == ObjType_VNode_x86_64_pml4 ||
88 type == ObjType_VNode_x86_64_pdpt ||
89 type == ObjType_VNode_x86_64_pdir ||
90 type == ObjType_VNode_x86_64_ptable ||
91 type == ObjType_VNode_x86_32_pdpt ||
92 type == ObjType_VNode_x86_32_pdir ||
93 type == ObjType_VNode_x86_32_ptable)
95 return 12; // BASE_PAGE_BITS
97 else if (type == ObjType_VNode_AARCH64_l1 ||
98 type == ObjType_VNode_AARCH64_l2 ||
99 type == ObjType_VNode_AARCH64_l3)
103 else if (type == ObjType_VNode_ARM_l1)
107 else if (type == ObjType_VNode_ARM_l2)
112 assert(0 && !"Page table size unknown.");
117 * Return number of page table entries for vnode in bits.
118 * @param type Object type.
119 * @return Number of page table entries in bits
121 static inline size_t vnode_entry_bits(enum objtype type) {
122 // This function should be emitted by hamlet or somesuch.
123 STATIC_ASSERT(46 == ObjType_Num, "Check VNode definitions");
125 if (type == ObjType_VNode_x86_64_pml4 ||
126 type == ObjType_VNode_x86_64_pdpt ||
127 type == ObjType_VNode_x86_64_pdir ||
128 type == ObjType_VNode_x86_64_ptable)
130 return 9; // log2(X86_64_PTABLE_SIZE)
133 if (type == ObjType_VNode_x86_32_pdpt)
135 return 2; // log2(X86_32_PDPTE_SIZE)
137 else if (type == ObjType_VNode_x86_32_pdir ||
138 type == ObjType_VNode_x86_32_ptable)
140 return 9; // log2(X86_32_PTABLE_SIZE) == log2(X86_32_PDIR_SIZE)
143 if (type == ObjType_VNode_x86_32_pdir ||
144 type == ObjType_VNode_x86_32_ptable)
146 return 10; // log2(X86_32_PTABLE_SIZE) == log2(X86_32_PDIR_SIZE)
150 if (type == ObjType_VNode_AARCH64_l1)
155 if (type == ObjType_VNode_AARCH64_l2 ||
156 type == ObjType_VNode_AARCH64_l3)
158 return 9; // log2(ARM_MAX_ENTRIES)
161 if (type == ObjType_VNode_ARM_l2)
163 return 9; // log2(ARM_L2_MAX_ENTRIES)
165 else if (type == ObjType_VNode_ARM_l1)
167 return 12; // log2(ARM_L1_MAX_ENTRIES)
170 assert(!"unknown page table type");
174 static inline enum objtype get_mapping_type(enum objtype captype)
176 STATIC_ASSERT(46 == ObjType_Num, "Knowledge of all mapping types");
180 return ObjType_Frame_Mapping;
181 case ObjType_DevFrame:
182 return ObjType_DevFrame_Mapping;
183 case ObjType_VNode_x86_64_pml4:
184 return ObjType_VNode_x86_64_pml4_Mapping;
185 case ObjType_VNode_x86_64_pdpt:
186 return ObjType_VNode_x86_64_pdpt_Mapping;
187 case ObjType_VNode_x86_64_pdir:
188 return ObjType_VNode_x86_64_pdir_Mapping;
189 case ObjType_VNode_x86_64_ptable:
190 return ObjType_VNode_x86_64_ptable_Mapping;
191 case ObjType_VNode_x86_32_pdpt:
192 return ObjType_VNode_x86_32_pdpt_Mapping;
193 case ObjType_VNode_x86_32_pdir:
194 return ObjType_VNode_x86_32_pdir_Mapping;
195 case ObjType_VNode_x86_32_ptable:
196 return ObjType_VNode_x86_32_ptable_Mapping;
197 case ObjType_VNode_ARM_l1:
198 return ObjType_VNode_ARM_l1_Mapping;
199 case ObjType_VNode_ARM_l2:
200 return ObjType_VNode_ARM_l2_Mapping;
201 case ObjType_VNode_AARCH64_l1:
202 return ObjType_VNode_AARCH64_l1_Mapping;
203 case ObjType_VNode_AARCH64_l2:
204 return ObjType_VNode_AARCH64_l2_Mapping;
205 case ObjType_VNode_AARCH64_l3:
206 return ObjType_VNode_AARCH64_l3_Mapping;
207 /* all other types are not mappable */
213 static inline bool type_is_mapping(enum objtype type)
215 STATIC_ASSERT(46 == ObjType_Num, "Knowledge of all mapping types");
218 case ObjType_Frame_Mapping:
219 case ObjType_DevFrame_Mapping:
220 case ObjType_VNode_x86_64_pml4_Mapping:
221 case ObjType_VNode_x86_64_pdpt_Mapping:
222 case ObjType_VNode_x86_64_pdir_Mapping:
223 case ObjType_VNode_x86_64_ptable_Mapping:
224 case ObjType_VNode_x86_32_pdpt_Mapping:
225 case ObjType_VNode_x86_32_pdir_Mapping:
226 case ObjType_VNode_x86_32_ptable_Mapping:
227 case ObjType_VNode_ARM_l1_Mapping:
228 case ObjType_VNode_ARM_l2_Mapping:
229 case ObjType_VNode_AARCH64_l1_Mapping:
230 case ObjType_VNode_AARCH64_l2_Mapping:
231 case ObjType_VNode_AARCH64_l3_Mapping:
234 /* all other types are not mapping types */
241 * CNode capability commands.
244 CNodeCmd_Copy, ///< Copy capability
245 CNodeCmd_Mint, ///< Mint capability
246 CNodeCmd_Retype, ///< Retype capability
247 CNodeCmd_Delete, ///< Delete capability
248 CNodeCmd_Revoke, ///< Revoke capability
249 CNodeCmd_Create, ///< Create capability
250 CNodeCmd_GetState, ///< Get distcap state for capability
256 VNodeCmd_Identify, ///< Return the physical address of the VNode
268 * Kernel capabilities commands.
269 * Monitor's invocations of capability operations
270 * which the kernel will not subject to cross core checks
273 KernelCmd_Spawn_core, ///< Spawn a new kernel
274 KernelCmd_Identify_cap, ///< Return the meta data of a capability
275 KernelCmd_Identify_domains_cap, ///< Return the meta data of another domain's capability
276 KernelCmd_Remote_relations, ///< Set capability as being remote
277 KernelCmd_Cap_has_relations, ///< Return presence of local relations
278 KernelCmd_Create_cap, ///< Create a new capability
279 KernelCmd_Copy_existing,
280 KernelCmd_Get_core_id, ///< Returns the id of the core the domain is on
281 KernelCmd_Get_arch_id, ///< Returns arch id of caller's core
282 KernelCmd_Nullify_cap, ///< Set the capability to NULL allowed it to be reused
283 KernelCmd_Setup_trace, ///< Set up trace buffer
284 KernelCmd_Register, ///< Register monitor notify endpoint
285 KernelCmd_Domain_Id, ///< Set domain ID of dispatcher
286 KernelCmd_Get_cap_owner,
287 KernelCmd_Set_cap_owner,
289 KernelCmd_Unlock_cap,
290 KernelCmd_Delete_last,
291 KernelCmd_Delete_foreigns,
292 KernelCmd_Revoke_mark_target,
293 KernelCmd_Revoke_mark_relations,
294 KernelCmd_Delete_step,
295 KernelCmd_Clear_step,
297 KernelCmd_Has_descendants,
298 KernelCmd_Sync_timer,
299 KernelCmd_IPI_Register,
300 KernelCmd_IPI_Delete,
301 KernelCmd_GetGlobalPhys,
302 KernelCmd_Add_kcb, ///< add extra kcb to be scheduled
303 KernelCmd_Remove_kcb, ///< remove kcb from scheduling ring
304 KernelCmd_Suspend_kcb_sched, ///< suspend/resume kcb scheduler
309 * Specific commands for dispatcher capabilities.
311 enum dispatcher_cmd {
312 DispatcherCmd_Setup, ///< Set dispatcher parameters
313 DispatcherCmd_Properties, ///< Set dispatcher properties
314 DispatcherCmd_PerfMon, ///< Performance monitoring
315 DispatcherCmd_SetupGuest, ///< Set up the DCB of a guest domain
316 DispatcherCmd_DumpPTables, ///< Dump hw page tables of dispatcher
317 DispatcherCmd_DumpCapabilities, ///< Dump capabilities of dispatcher
318 DispatcherCmd_Vmread, ///< Execute vmread on the current and active VMCS
319 DispatcherCmd_Vmwrite, ///< Execute vmwrite on the current and active VMCS
320 DispatcherCmd_Vmptrld, ///< Make VMCS clear and inactive
321 DispatcherCmd_Vmclear, ///< Make VMCS current and active
325 * Frame capability commands.
328 FrameCmd_Identify, ///< Return physical address of frame
332 * IRQ Table capability commands.
335 IRQTableCmd_Alloc, ///< Allocate new vector (XXX: HACK: this is x86 specific)
336 IRQTableCmd_AllocDestCap, ///< Allocate new dest capability (XXX: HACK: this is x86 specific)
337 IRQTableCmd_Set, ///< Set endpoint for IRQ# notifications
338 IRQTableCmd_Delete ///< Remove notification endpoint for IRQ#
342 * IRQ Vector commands.
346 IRQVectorCmd_Connect, ///< Connect this capability to a messaging channel
347 IRQVectorCmd_GetVector ///< Return the local interrupt vector
351 * IRQ Vector commands.
355 IRQCmd_GetVector ///< Return vector and controller saved in this cap.
360 * IO capability commands.
363 IOCmd_Outb, ///< Output byte to port
364 IOCmd_Outw, ///< Output word to port
365 IOCmd_Outd, ///< Output double word to port
366 IOCmd_Inb, ///< Input byte from port
367 IOCmd_Inw, ///< Input word from port
368 IOCmd_Ind ///< Input double word from port
372 * Notify capability commands.
380 * Performance monitoring commands.
381 * Seems to be already included in the Dispatcher capability.
384 PerfmonCmd_Activate, ///< Activate performance counters
385 PerfmonCmd_Deactivate, ///< Deactivate performance counters
386 PerfmonCmd_Write ///< Read current performance counter values
391 * ID capability commands.
394 IDCmd_Identify ///< Return system-wide unique ID
398 * IPI capability commands
402 IPICmd_Send_Start, ///< Send Startup IPI to a destination core
403 IPICmd_Send_Init, ///< Send Init IPI to a destination core
406 * Maximum command ordinal.
408 #define CAP_MAX_CMD KernelCmd_Count
411 * \brief Values returned from frame identify invocation
413 struct frame_identity {
414 genpaddr_t base; ///< Physical base address of frame
415 uint8_t bits; ///< Size of frame, in bits
419 * \brief Values returned from the VNode identify invocation
421 struct vnode_identity {
422 genpaddr_t base; ///< Physical base address of the VNode
423 uint8_t type; ///< Type of VNode
426 #endif // __ASSEMBLER__
428 #endif // BARRELFISH_CAPABILITIES_H