1 /*
2  * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
3  *
4  * SPDX-License-Identifier: BSD-2-Clause
5  */
6 
7 #pragma once
8 
9 #include <autoconf.h>
10 
11 /* caps with fixed slot positions in the root CNode */
12 enum {
13     seL4_CapNull                =  0, /* null cap */
14     seL4_CapInitThreadTCB       =  1, /* initial thread's TCB cap */
15     seL4_CapInitThreadCNode     =  2, /* initial thread's root CNode cap */
16     seL4_CapInitThreadVSpace    =  3, /* initial thread's VSpace cap */
17     seL4_CapIRQControl          =  4, /* global IRQ controller cap */
18     seL4_CapASIDControl         =  5, /* global ASID controller cap */
19     seL4_CapInitThreadASIDPool  =  6, /* initial thread's ASID pool cap */
20     seL4_CapIOPortControl       =  7, /* global IO port control cap (null cap if not supported) */
21     seL4_CapIOSpace             =  8, /* global IO space cap (null cap if no IOMMU support) */
22     seL4_CapBootInfoFrame       =  9, /* bootinfo frame cap */
23     seL4_CapInitThreadIPCBuffer = 10, /* initial thread's IPC buffer frame cap */
24     seL4_CapDomain              = 11, /* global domain controller cap */
25     seL4_CapSMMUSIDControl      = 12,  /*global SMMU SID controller cap, null cap if not supported*/
26     seL4_CapSMMUCBControl       = 13,  /*global SMMU CB controller cap, null cap if not supported*/
27 #ifdef CONFIG_KERNEL_MCS
28     seL4_CapInitThreadSC        = 14, /* initial thread's scheduling context cap */
29     seL4_NumInitialCaps         = 15
30 #else
31     seL4_NumInitialCaps         = 14
32 #endif /* !CONFIG_KERNEL_MCS */
33 };
34 
35 /* Legacy code will have assumptions on the vspace root being a Page Directory
36  * type, so for now we define one to the other */
37 #define seL4_CapInitThreadPD seL4_CapInitThreadVSpace
38 
39 /* types */
40 typedef seL4_Word seL4_SlotPos;
41 
42 typedef struct seL4_SlotRegion {
43     seL4_SlotPos start; /* first CNode slot position OF region */
44     seL4_SlotPos end;   /* first CNode slot position AFTER region */
45 } seL4_SlotRegion;
46 
47 typedef struct seL4_UntypedDesc {
48     seL4_Word  paddr;   /* physical address of untyped cap  */
49     seL4_Uint8 sizeBits;/* size (2^n) bytes of each untyped */
50     seL4_Uint8 isDevice;/* whether the untyped is a device  */
51     seL4_Uint8 padding[sizeof(seL4_Word) - 2 * sizeof(seL4_Uint8)];
52 } seL4_UntypedDesc;
53 
54 typedef struct seL4_BootInfo {
55     seL4_Word         extraLen;        /* length of any additional bootinfo information */
56     seL4_NodeId       nodeID;          /* ID [0..numNodes-1] of the seL4 node (0 if uniprocessor) */
57     seL4_Word         numNodes;        /* number of seL4 nodes (1 if uniprocessor) */
58     seL4_Word         numIOPTLevels;   /* number of IOMMU PT levels (0 if no IOMMU support) */
59     seL4_IPCBuffer   *ipcBuffer;       /* pointer to initial thread's IPC buffer */
60     seL4_SlotRegion   empty;           /* empty slots (null caps) */
61     seL4_SlotRegion   sharedFrames;    /* shared-frame caps (shared between seL4 nodes) */
62     seL4_SlotRegion   userImageFrames; /* userland-image frame caps */
63     seL4_SlotRegion   userImagePaging; /* userland-image paging structure caps */
64     seL4_SlotRegion   ioSpaceCaps;     /* IOSpace caps for ARM SMMU */
65     seL4_SlotRegion   extraBIPages;    /* caps for any pages used to back the additional bootinfo information */
66     seL4_Word         initThreadCNodeSizeBits; /* initial thread's root CNode size (2^n slots) */
67     seL4_Domain       initThreadDomain; /* Initial thread's domain ID */
68 #ifdef CONFIG_KERNEL_MCS
69     seL4_SlotRegion   schedcontrol; /* Caps to sched_control for each node */
70 #endif
71     seL4_SlotRegion   untyped;         /* untyped-object caps (untyped caps) */
72     seL4_UntypedDesc  untypedList[CONFIG_MAX_NUM_BOOTINFO_UNTYPED_CAPS]; /* information about each untyped */
73     /* the untypedList should be the last entry in this struct, in order
74      * to make this struct easier to represent in other languages */
75 } seL4_BootInfo;
76 
77 /* If extraLen > 0 then 4K after the start of bootinfo is a region of extraLen additional
78  * bootinfo structures. Bootinfo structures are arch/platform specific and may or may not
79  * exist in any given execution. */
80 typedef struct seL4_BootInfoHeader {
81     /* identifier of the following chunk. IDs are arch/platform specific */
82     seL4_Word id;
83     /* length of the chunk, including this header */
84     seL4_Word len;
85 } seL4_BootInfoHeader;
86 
87 /* Bootinfo identifiers share a global namespace, even if they are arch or platform specific
88  * and are enumerated here */
89 #define SEL4_BOOTINFO_HEADER_PADDING 0
90 #define SEL4_BOOTINFO_HEADER_X86_VBE 1
91 #define SEL4_BOOTINFO_HEADER_X86_MBMMAP 2
92 #define SEL4_BOOTINFO_HEADER_X86_ACPI_RSDP 3
93 #define SEL4_BOOTINFO_HEADER_X86_FRAMEBUFFER 4
94 #define SEL4_BOOTINFO_HEADER_X86_TSC_FREQ 5 // frequency is in mhz
95 #define SEL4_BOOTINFO_HEADER_FDT 6
96 #define SEL4_BOOTINFO_HEADER_NUM SEL4_BOOTINFO_HEADER_FDT + 1
97