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