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 <damien.lemoal@wdc.com>
This commit is contained in:
Damien Le Moal
2018-12-21 09:13:37 +09:00
parent f003787455
commit aa68f0252f
7 changed files with 45 additions and 26 deletions

View File

@@ -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)
{