summaryrefslogtreecommitdiff
path: root/include/sbi/sbi_platform.h
diff options
context:
space:
mode:
authorDamien Le Moal <[email protected]>2018-12-21 09:13:37 +0900
committerDamien Le Moal <[email protected]>2018-12-21 15:09:13 +0900
commitaa68f0252f2a0749dee35bda309c397f79ae26a0 (patch)
tree1edc7262e0c70f0a391abbc4c009e42f8a303aad /include/sbi/sbi_platform.h
parentf003787455709a1a6c69c1b6ab6a02d4d767c325 (diff)
Refine platform features control
Allow a platform to report its supported features in more details. The new features defined are: * SBI_PLATFORM_HAS_PMP * SBI_PLATFORM_HAS_SCOUNTEREN * SBI_PLATFORM_HAS_MCOUNTEREN In addition, define the macro SBI_PLATFORM_DEFAULT_FEATURES as the set of features that are generally expected to be supported by a Linux capable platform. Operations touching the features controlled with these falgs are not executed if the platform does not set the corresponding feature flags. Signed-off-by: Damien Le Moal <[email protected]>
Diffstat (limited to 'include/sbi/sbi_platform.h')
-rw-r--r--include/sbi/sbi_platform.h34
1 files changed, 23 insertions, 11 deletions
diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index 57b8e6be..39dfb499 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -13,10 +13,19 @@
#include <sbi/sbi_scratch.h>
enum sbi_platform_features {
- SBI_PLATFORM_HAS_MMIO_TIMER_VALUE = (1 << 0),
- SBI_PLATFORM_HAS_HART_HOTPLUG = (1 << 1),
+ SBI_PLATFORM_HAS_MMIO_TIMER_VALUE = (1 << 0),
+ SBI_PLATFORM_HAS_HART_HOTPLUG = (1 << 1),
+ SBI_PLATFORM_HAS_PMP = (1 << 2),
+ SBI_PLATFORM_HAS_SCOUNTEREN = (1 << 3),
+ SBI_PLATFORM_HAS_MCOUNTEREN = (1 << 4),
};
+#define SBI_PLATFORM_DEFAULT_FEATURES \
+ (SBI_PLATFORM_HAS_MMIO_TIMER_VALUE | \
+ SBI_PLATFORM_HAS_PMP | \
+ SBI_PLATFORM_HAS_SCOUNTEREN | \
+ SBI_PLATFORM_HAS_MCOUNTEREN)
+
struct sbi_platform {
char name[64];
u64 features;
@@ -48,17 +57,20 @@ struct sbi_platform {
int (*system_shutdown)(u32 type);
} __attribute__((packed));
-#define sbi_platform_ptr(__s) \
-((struct sbi_platform *)((__s)->platform_addr))
-
-#define sbi_platform_thishart_ptr() \
-((struct sbi_platform *)(sbi_scratch_thishart_ptr()->platform_addr))
-
+#define sbi_platform_ptr(__s) \
+ ((struct sbi_platform *)((__s)->platform_addr))
+#define sbi_platform_thishart_ptr() \
+ ((struct sbi_platform *)(sbi_scratch_thishart_ptr()->platform_addr))
#define sbi_platform_has_mmio_timer_value(__p) \
-((__p)->features & SBI_PLATFORM_HAS_MMIO_TIMER_VALUE)
-
+ ((__p)->features & SBI_PLATFORM_HAS_MMIO_TIMER_VALUE)
#define sbi_platform_has_hart_hotplug(__p) \
-((__p)->features & SBI_PLATFORM_HAS_HART_HOTPLUG)
+ ((__p)->features & SBI_PLATFORM_HAS_HART_HOTPLUG)
+#define sbi_platform_has_pmp(__p) \
+ ((__p)->features & SBI_PLATFORM_HAS_PMP)
+#define sbi_platform_has_scounteren(__p) \
+ ((__p)->features & SBI_PLATFORM_HAS_SCOUNTEREN)
+#define sbi_platform_has_mcounteren(__p) \
+ ((__p)->features & SBI_PLATFORM_HAS_MCOUNTEREN)
static inline const char *sbi_platform_name(struct sbi_platform *plat)
{