Skip to content

Commit

Permalink
simple: Define SIMPLE_SKIPPED_INIT_CAPS better
Browse files Browse the repository at this point in the history
Make sure this macro is defined based on all possible configurations.
Also update simple_default_nth_cap() to skip based on all features
correctly.

Signed-off-by: Robbie VanVossen <[email protected]>
  • Loading branch information
Furao authored and kent-mcleod committed Aug 12, 2023
1 parent 310eace commit 3be9f94
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
13 changes: 13 additions & 0 deletions libsel4simple-default/src/libsel4simple-default.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ seL4_CPtr simple_default_nth_cap(void *data, int n)
if (true_return >= seL4_CapIOSpace) {
true_return++;
}
#endif
#ifndef CONFIG_ARM_SMMU
/* skip seL4_CapSMMUSIDControl and seL4_CapSMMUCBControl if
* SMMU is not supported on this platform */
if (true_return >= seL4_CapSMMUSIDControl) {
true_return += 2;
}
#endif
#ifndef CONFIG_KERNEL_MCS
/* skip seL4_CapInitThreadSC if MCS is not enabled */
if (true_return >= seL4_CapInitThreadSC) {
true_return++;
}
#endif
} else if (n < shared_frame_range) {
return bi->sharedFrames.start + (n - SIMPLE_NUM_INIT_CAPS);
Expand Down
14 changes: 13 additions & 1 deletion libsel4simple/arch_include/arm/simple/arch/simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@

/* Simple does not address initial null caps, including seL4_CapNull.
* seL4_CapIOSpace, seL4_CapIOPortControl are null on architectures other than x86 */
#define SIMPLE_SKIPPED_INIT_CAPS 3
#ifdef CONFIG_KERNEL_MCS
#define SIMPLE_SKIP_THREADSC 0
#else
#define SIMPLE_SKIP_THREADSC 1
#endif

#ifdef CONFIG_ARM_SMMU
#define SIMPLE_SKIP_SMMU_CAPS 0
#else
#define SIMPLE_SKIP_SMMU_CAPS 2
#endif

#define SIMPLE_SKIPPED_INIT_CAPS (3 + SIMPLE_SKIP_THREADSC + SIMPLE_SKIP_SMMU_CAPS)

/* Request a cap to a specific IRQ number on the system
*
Expand Down
15 changes: 12 additions & 3 deletions libsel4simple/arch_include/x86/simple/arch/simple.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@
#include <utils/util.h>
#include <vka/cspacepath_t.h>

/* Simple does not address initial null caps, including seL4_CapNull */
/* Simple does not address initial null caps, including seL4_CapNull
* seL4_CapSMMUSIDControl, seL4_CapSMMUCBControl are null on x86 */
#ifdef CONFIG_IOMMU
#define SIMPLE_SKIPPED_INIT_CAPS 1
#define SIMPLE_SKIP_IOSPACE 0
#else
/* seL4_CapIOSpace is null if IOMMU isn't supported */
#define SIMPLE_SKIPPED_INIT_CAPS 2
#define SIMPLE_SKIP_IOSPACE 1
#endif

#ifdef CONFIG_KERNEL_MCS
#define SIMPLE_SKIP_THREADSC 0
#else
#define SIMPLE_SKIP_THREADSC 1
#endif

#define SIMPLE_SKIPPED_INIT_CAPS (3 + SIMPLE_SKIP_IOSPACE + SIMPLE_SKIP_THREADSC)

/**
* Request a cap to the IOPorts
*
Expand Down

0 comments on commit 3be9f94

Please sign in to comment.