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 #include <sel4/macros.h>
11 
12 #ifndef __ASSEMBLER__
13 
14 #ifdef CONFIG_HARDWARE_DEBUG_API
15 /* API arg values for breakpoint API, "type" arguments. */
16 typedef enum {
17     seL4_DataBreakpoint = 0,
18     seL4_InstructionBreakpoint,
19     seL4_SingleStep,
20     seL4_SoftwareBreakRequest,
21     SEL4_FORCE_LONG_ENUM(seL4_BreakpointType)
22 } seL4_BreakpointType;
23 
24 /* API arg values for breakpoint API, "access" arguments. */
25 typedef enum {
26     seL4_BreakOnRead = 0,
27     seL4_BreakOnWrite,
28     seL4_BreakOnReadWrite,
29     seL4_MaxBreakpointAccess,
30     SEL4_FORCE_LONG_ENUM(seL4_BreakpointAccess)
31 } seL4_BreakpointAccess;
32 
33 /* Format of a debug-exception message. */
34 typedef enum {
35     seL4_DebugException_FaultIP,
36     seL4_DebugException_ExceptionReason,
37     seL4_DebugException_TriggerAddress,
38     seL4_DebugException_BreakpointNumber,
39     seL4_DebugException_Length,
40     SEL4_FORCE_LONG_ENUM(seL4_DebugException_Msg)
41 } seL4_DebugException_Msg;
42 #endif
43 
44 enum priorityConstants {
45     seL4_InvalidPrio = -1,
46     seL4_MinPrio = 0,
47     seL4_MaxPrio = CONFIG_NUM_PRIORITIES - 1
48 };
49 
50 /* seL4_MessageInfo_t defined in api/shared_types.bf */
51 
52 enum seL4_MsgLimits {
53     seL4_MsgLengthBits = 7,
54     seL4_MsgExtraCapBits = 2
55 };
56 
57 enum {
58     seL4_MsgMaxLength = 120,
59 };
60 #define seL4_MsgMaxExtraCaps (LIBSEL4_BIT(seL4_MsgExtraCapBits)-1)
61 
62 /* seL4_CapRights_t defined in shared_types_*.bf */
63 #define seL4_CapRightsBits 4
64 
65 typedef enum {
66     seL4_NoFailure = 0,
67     seL4_InvalidRoot,
68     seL4_MissingCapability,
69     seL4_DepthMismatch,
70     seL4_GuardMismatch,
71     SEL4_FORCE_LONG_ENUM(seL4_LookupFailureType),
72 } seL4_LookupFailureType;
73 #endif /* !__ASSEMBLER__ */
74 
75 #ifdef CONFIG_KERNEL_MCS
76 /* Minimum size of a scheduling context (2^{n} bytes) */
77 #define seL4_MinSchedContextBits 8
78 #ifndef __ASSEMBLER__
79 /* the size of a scheduling context, excluding extra refills */
80 #define seL4_CoreSchedContextBytes (10 * sizeof(seL4_Word) + (6 * 8))
81 /* the size of a single extra refill */
82 #define seL4_RefillSizeBytes (2 * 8)
83 
84 /*
85  * @brief Calculate the max extra refills a scheduling context can contain for a specific size.
86  *
87  * @param  size of the schedulding context. Must be >= seL4_MinSchedContextBits
88  * @return the max number of extra refills that can be passed to seL4_SchedControl_Configure for
89  *         this scheduling context
90  */
seL4_MaxExtraRefills(seL4_Word size)91 static inline seL4_Word seL4_MaxExtraRefills(seL4_Word size)
92 {
93     return (LIBSEL4_BIT(size) -  seL4_CoreSchedContextBytes) / seL4_RefillSizeBytes;
94 }
95 
96 /* Flags to be used with seL4_SchedControl_ConfigureFlags */
97 typedef enum {
98     seL4_SchedContext_NoFlag = 0x0,
99     seL4_SchedContext_Sporadic = 0x1,
100     SEL4_FORCE_LONG_ENUM(seL4_SchedContextFlag),
101 } seL4_SchedContextFlag;
102 
103 #endif /* !__ASSEMBLER__ */
104 #endif /* CONFIG_KERNEL_MCS */
105 
106 #ifdef CONFIG_KERNEL_INVOCATION_REPORT_ERROR_IPC
107 #define DEBUG_MESSAGE_START 6
108 #define DEBUG_MESSAGE_MAXLEN 50
109 #endif
110