summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnup Patel <apatel@ventanamicro.com>2022-12-29 05:56:15 +0300
committerAnup Patel <anup@brainfault.org>2023-01-07 13:28:49 +0300
commitf14595a7cfc8de16a06335c6ecdf9ae23a0adf53 (patch)
tree85c79c44afff34a609e56ac0ffc336aa044e5b0c
parent65638f8d6b1f438ae442bad7a4f77b188d3d3689 (diff)
downloadopensbi-f14595a7cfc8de16a06335c6ecdf9ae23a0adf53.tar.xz
lib: sbi: Allow platform to influence cold boot HART selection
We add an optional cold_boot_allowed() platform callback which allows platform support to decide which HARTs can do cold boot initialization. If this platform callback is not available then any HART can do cold boot initialization. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
-rw-r--r--include/sbi/sbi_platform.h20
-rw-r--r--lib/sbi/sbi_init.c7
2 files changed, 25 insertions, 2 deletions
diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h
index 010e9ce..43d1c03 100644
--- a/include/sbi/sbi_platform.h
+++ b/include/sbi/sbi_platform.h
@@ -65,6 +65,9 @@ enum sbi_platform_features {
/** Platform functions */
struct sbi_platform_operations {
+ /* Check if specified HART is allowed to do cold boot */
+ bool (*cold_boot_allowed)(u32 hartid);
+
/* Platform nascent initialization */
int (*nascent_init)(void);
@@ -357,6 +360,23 @@ static inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat,
}
/**
+ * Check whether given HART is allowed to do cold boot
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param hartid HART ID
+ *
+ * @return true if HART is allowed to do cold boot and false otherwise
+ */
+static inline bool sbi_platform_cold_boot_allowed(
+ const struct sbi_platform *plat,
+ u32 hartid)
+{
+ if (plat && sbi_platform_ops(plat)->cold_boot_allowed)
+ return sbi_platform_ops(plat)->cold_boot_allowed(hartid);
+ return true;
+}
+
+/**
* Nascent (very early) initialization for current HART
*
* NOTE: This function can be used to do very early initialization of
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c
index ded3da0..259a191 100644
--- a/lib/sbi/sbi_init.c
+++ b/lib/sbi/sbi_init.c
@@ -498,8 +498,11 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
* HARTs which satisfy above condition.
*/
- if (next_mode_supported && atomic_xchg(&coldboot_lottery, 1) == 0)
- coldboot = true;
+ if (sbi_platform_cold_boot_allowed(plat, hartid)) {
+ if (next_mode_supported &&
+ atomic_xchg(&coldboot_lottery, 1) == 0)
+ coldboot = true;
+ }
/*
* Do platform specific nascent (very early) initialization so