diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-03-02 14:20:01 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-03-11 13:00:00 +0300 |
commit | 71d2b837c46e7528ab03bd6489fec86100681f22 (patch) | |
tree | 570c2000c3340cd3a35a66f3560bf06d7c8a4817 /lib/sbi/sbi_hart.c | |
parent | d96316481dbc9a52e7e97c4cef70957507c2845f (diff) | |
download | opensbi-71d2b837c46e7528ab03bd6489fec86100681f22.tar.xz |
lib: Move all coldboot wait APIs to sbi_init.c
The coldboot wait APIs are only used by sbi_init.c so no point in
having coldboot related code in sbi_hart.c.
As per-above rationale, we move all coldboot wait related APIs to
sbi_init.c as static/local functions.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'lib/sbi/sbi_hart.c')
-rw-r--r-- | lib/sbi/sbi_hart.c | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index c00e16a..9017db1 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -377,73 +377,3 @@ struct sbi_scratch *sbi_hart_id_to_scratch(struct sbi_scratch *scratch, { return ((h2s)scratch->hartid_to_scratch)(hartid); } - -#define COLDBOOT_WAIT_BITMAP_SIZE __riscv_xlen -static spinlock_t coldboot_lock = SPIN_LOCK_INITIALIZER; -static unsigned long coldboot_done = 0; -static unsigned long coldboot_wait_bitmap = 0; - -void sbi_hart_wait_for_coldboot(struct sbi_scratch *scratch, u32 hartid) -{ - unsigned long saved_mie, cmip; - const struct sbi_platform *plat = sbi_platform_ptr(scratch); - - if ((sbi_platform_hart_count(plat) <= hartid) || - (COLDBOOT_WAIT_BITMAP_SIZE <= hartid)) - sbi_hart_hang(); - - /* Save MIE CSR */ - saved_mie = csr_read(CSR_MIE); - - /* Set MSIE bit to receive IPI */ - csr_set(CSR_MIE, MIP_MSIP); - - /* Acquire coldboot lock */ - spin_lock(&coldboot_lock); - - /* Mark current HART as waiting */ - coldboot_wait_bitmap |= (1UL << hartid); - - /* Wait for coldboot to finish using WFI */ - while (!coldboot_done) { - spin_unlock(&coldboot_lock); - do { - wfi(); - cmip = csr_read(CSR_MIP); - } while (!(cmip & MIP_MSIP)); - spin_lock(&coldboot_lock); - }; - - /* Unmark current HART as waiting */ - coldboot_wait_bitmap &= ~(1UL << hartid); - - /* Release coldboot lock */ - spin_unlock(&coldboot_lock); - - /* Restore MIE CSR */ - csr_write(CSR_MIE, saved_mie); - - /* Clear current HART IPI */ - sbi_platform_ipi_clear(plat, hartid); -} - -void sbi_hart_wake_coldboot_harts(struct sbi_scratch *scratch, u32 hartid) -{ - const struct sbi_platform *plat = sbi_platform_ptr(scratch); - int max_hart = sbi_platform_hart_count(plat); - - /* Acquire coldboot lock */ - spin_lock(&coldboot_lock); - - /* Mark coldboot done */ - coldboot_done = 1; - - /* Send an IPI to all HARTs waiting for coldboot */ - for (int i = 0; i < max_hart; i++) { - if ((i != hartid) && (coldboot_wait_bitmap & (1UL << i))) - sbi_platform_ipi_send(plat, i); - } - - /* Release coldboot lock */ - spin_unlock(&coldboot_lock); -} |